Table of Contents
The Naos Framework is mainly driven by a set of major concepts. These are described in the following sections and chapters. The following diagram show the associations between the major basic concepts of Naos Framework.
A module contains a set of controllers, a web directory, a set of Smarty output plugins and a set of templates which are managed on controller level.
In general a module is described by its directory structure, which is defined as follows.
+-<application>/ or naos.framework.v5/ | +-module/ | +-<module>/ | +-controllers/ | | | +-<Controller> | +-views/ | | | +-plugin/ | | | | | +-<Plugin> | | | +-template/ | | | +-<controller>/ | | | +-<Template> | +-web/
Furthermore a module has to be activated by the configuration of the application, which is in general done by defining its context. The context describes if the modules is part of the Naos Framework or if it is part of your application.
Example 2.1. Two activated modules
[module] ; activated modules modules = myinfo,naos-error ; comma separated list of module identifiers module.myinfo.context = application ; context is either "naos" or "application" module.naos-error.context = naos
A controller contains a set of actions and templates. In general a controller should describe a small self-contained part of the applications business logic or workflow.
A controller is defined by a class derived from Naos_Controller_Action and placed in the controllers directory (see Module). The naming of the controller class has to follow the scheme Module_<Module>_<Controller>, whereas <Module> and <Controller> have to be the camelized version of their names. The PHP file has to be named <Controller>Controller.php.
Example 2.2. A controller named view within the module naos-page
class Module_NaosPage_ViewController extends Naos_Controller_Action
{
// ...
}
Templates which belong to the controller have to be placed in the directory views/template/<controller>/ whereas <controller> is the non-camelized version of the name of the controller.
An action is the smallest part describing the applications business logic. Often an action depends on the execution of a previous action and describes one step of a workflow. In general an action performs a data processing part followed by a redirection to another action or the triggering of the output rendering. The code of an action is always executed in the context of a view and data node (which is mostly defined by a menu item, but this might deviate during the execution of the workflow).
An action is defined by a member function of the according controller class. The naming convention is as follows: public function <action>Action(), whereas <action> is the camelized version of the actions name starting with an lower case character.
Example 2.3. An action named process-login-form
class Module_Example_TestController extends Naos_Controller_Action
{
public function processLoginFormAction()
{
// ...
}
}
A layout describes the appearance of your application in the web browser. Besides the layout template and the definition of the output views, which get modified during the execution of the application by the action workflow, a layout usually comprises images and CSS files (which are located in the web directory of the layout).
The layout definition has to follow the following directory scheme.
+-<application>/ or naos.framework.v5/ | +-layout/ | +-<layout>/ | +-layout.conf | +-layout.tpl | +-web/
The layout.conf describes the identification scheme of the views in the layout.tpl.
Example 2.4. A layout with 3 views named topbar, main and bottombar.
Example of a template.tpl:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <compiler-flags autotranslate="true"/> <head> <title>Naos Framework v5</title> <link rel="stylesheet" type="text/css" href="res:/layout/naos/style.css"/> </head> <body> <!-- view: topbar --> <div id="view_topbar"></div> <div style="text-align: center;"><img src="res:/layout/naos/logo-small.png" alt="Logo"/></div> <!-- view: main --> <div id="view_main"></div> <div style="text-align: center; margin-top: 10px;">powered by Zend Framework and Smarty.</div> <!-- view: bottombar --> <div id="view_bottombar"></div> </body> </html>
Example of a template.conf:
[layout] ; Attention: exported to JavaScript (JSON) title = tr: NAOS Layout views = main,topbar,bottombar ; comma separated list view.main.match = id:view_main ; define identification of html tag, which we want to use as view output view.main.replace = inner ; modes are "inner" and "outer" view.topbar.match = id:view_topbar ; define identification of html tag, which we want to use as view output view.topbar.replace = inner ; modes are "inner" and "outer" view.bottombar.match = id:view_bottombar ; define identification of html tag, which we want to use as view output view.bottombar.replace = inner ; modes are "inner" and "outer"
The data node concept is one of the highly abstract but very clever concepts of the Naos Framework. A data node is nothing else than a unique identifier, which can be used as reference for context dependend data. Which data node is provided during the execution of an action can be defined in several places, e.g. in the menu item definition (see Section 2.1.5, “Menus and Menu Items”) or in an URL (see Section 2.2, “Application URLs”).
Data nodes can be either defined by the configuration of the application (application.conf) or by database entries. Database entries are going to be managable by a web interface with the release of naos.framework.v6.
Example 2.5. Example of the usage of a data node.
Four data nodes defined by the configuration file application.conf:
[datanode] ; predefined nodes nodes = default,page1,page2,page3 ; comma separated list ; define "default" node node.default.id = default ; identifier (everything except numbers) node.default.title = tr: Default Node ; node title node.default.description = tr: Default Node ; node title ; define "page1" node node.page1.id = welcome ; identifier (everything except numbers) node.page1.title = tr: Startseite ; node title node.page1.description = tr: Startseite ; node title ; define "page2" node node.page2.id = agb ; identifier (everything except numbers) node.page2.title = tr: AGB ; node title node.page2.description = tr: AGB ; node title ; define "page3" node node.page3.id = imprint ; identifier (everything except numbers) node.page3.title = tr: Impressum ; node title node.page3.description = tr: Impressum ; node title
A menu item using referencing two data nodes:
menu.default.item.welcome.id = A menu.default.item.welcome.title = tr: Startseite menu.default.item.welcome.position = 1 ; menu position menu.default.item.welcome.locales = * ; comma separated list of locale codes or all = * menu.default.item.welcome.layout = timetool ; layout identifier menu.default.item.welcome.view.register.node = default menu.default.item.welcome.view.register.module = main menu.default.item.welcome.view.register.controller = view menu.default.item.welcome.view.register.action = register-form menu.default.item.welcome.view.register.parameter = menu.default.item.welcome.view.main.node = welcome menu.default.item.welcome.view.main.module = naos-page menu.default.item.welcome.view.main.controller = view menu.default.item.welcome.view.main.action = page menu.default.item.welcome.view.main.parameter =
A URL referencing a data node:
vapp:/timetool/installation/step1@mainview:default
There are two major reasons for the introduction of the Menu and Menu Item concept. The first reason is that a menu item serves as a application entry point, meaning it describes an initial or subsequent state with a certain state of integrity. The second reasons is that the standardized interface will be supported by the management web interface of naos.framework.v6.
A menu is defined by an identifier and a set of menu items. A menu item is defined by a set of configuration parameter for every view of the addressed layout and a set of sub menu items. Sub menu items can be defined in the database only, whereas all other configuration parameter can be applied in the application.conf as well as in the database.
Example 2.6. Example of a menu definition in the file application.conf.
[menu] ; menus and predefined menu items menus = default ; comma separated list menu_defaults = default ; comma separated list menu.default.title = tr: Naos Standard Menu menu.default.items = welcome,imprint ; comma separated list menu.default.item_defaults = welcome ; comma separated list ; define "welcome" menu item menu.default.item.welcome.id = A ; identifier (everything except numbers) menu.default.item.welcome.title = tr: Welcome menu.default.item.welcome.position = 1 ; menu item position menu.default.item.welcome.locales = * ; comma separated list of locale codes or all = * menu.default.item.welcome.layout = naos ; layout identifier menu.default.item.welcome.view.main.node = A ; node identifier menu.default.item.welcome.view.main.module = naos-example ; view "main": module we want to call menu.default.item.welcome.view.main.controller = view ; view "main": controller we want to call menu.default.item.welcome.view.main.action = welcome ; view "main": action we want to call menu.default.item.welcome.view.main.parameter = ; view "main": the parameter menu.default.item.welcome.view.topbar.node = A ; node identifier menu.default.item.welcome.view.topbar.module = naos-example ; view "main": module we want to call menu.default.item.welcome.view.topbar.controller = view ; view "main": controller we want to call menu.default.item.welcome.view.topbar.action = menu-top ; view "main": action we want to call menu.default.item.welcome.view.topbar.parameter = ; view "main": the parameter ; define "imprint" menu item menu.default.item.imprint.id = B ; identifier (everything except numbers) menu.default.item.imprint.title = tr: Imprint menu.default.item.imprint.position = 2 ; menu item position menu.default.item.imprint.locales = * ; comma separated list of locale codes or all = * menu.default.item.imprint.layout = naos ; layout identifier menu.default.item.imprint.view.main.node = A ; view "main": node identifier [optional] menu.default.item.imprint.view.main.module = naos-example ; view "main": module we want to call [optional] menu.default.item.imprint.view.main.controller = view ; view "main": controller we want to call [optional] menu.default.item.imprint.view.main.action = imprint ; view "main": action we want to call [optional] menu.default.item.imprint.view.main.parameter = ; view "main": the parameter
The following HTTP scheme URLs address the imprint menu item:
http://www.yourdomain.com/your.application/en/imprint http://www.yourdomain.com/your.application/en/B
The following VMENU scheme URLs address the imprint menu item:
vmenu:/default/imprint vmenu:/default/B