Class myMVC_Controller

Description

Main controller.

It manages all requests and responses. Example to use it:

  1.  define('SMARTY_DIR',                '../Smarty/libs/');
  2.  require_once(SMARTY_DIR.'Smarty.class.php');
  3.  require_once('mymvc/myMVC.php');
  4.  require_once('../etc/etc.php')// <b>YOUR</b> define file
  5.  
  6.  $controller new myMVC_Controller();
  7.  $controller->setRenderEngine(new myMVC_SmartyEngine($_SERVER['DOCUMENT_ROOT'].'/../pages/templates',
  8.                                                      $_SERVER['DOCUMENT_ROOT'].'/../pages/templates_c'));
  9.  $controller->setActions(array('MainAction''TestAction''Test1Action''NoRightsAction''LoginAction''myMVC_BaseLogoutAction'),
  10.                          'MainAction''NoRightsAction');
  11.  $controller->setViews(array('MainView''TestView''Test1View''NoRightsView''LoginView'));
  12.  $controller->setLanguageInformation(array('de_DE' => 'Deutsch''en_US' => 'English''it_IT' => 'Italiano'),
  13.                                      'de_DE'$_SERVER['DOCUMENT_ROOT'].'/../locale''testmvc');
  14.  $controller->setFilter(myMVC_Controller::$FILTER_PREACTION'myMVC_LoginFilter'array()array('loginAction' => 'LoginAction'));
  15.  $controller->process();

Located in /myMVC/Controller.php (line 46)


	
			
Variable Summary
 static mixed $FILTER_PREACTION
 static mixed $FILTER_PREVIEW
Method Summary
 static void clearActionList ()
 static array getActionsList ()
 static array getAvailableLanguages ()
 static string getCurrentAction ()
 static string getCurrentLanguage ()
 static string getDefaultAction ()
 static array getMenuActions ()
 static boolean hasUserRightForAction (string $action)
 myMVC_Controller __construct ()
 void process ()
 void setActions (array $actions, string $defaultAction, [string $noRightAction = NULL])
 void setFilter (int $type, string $class, [array $exceptions = array()], [array $params = array()])
 void setLanguageInformation (array $availableLanguages, string $defaultLanguage, string $getTextLocaleDir,  $getTextLocaleDomain, [string $languageParameter = 'lang'])
 void setRenderEngine (class $class)
 void setViews (array $views)
Variables
static mixed $FILTER_PREACTION = 'preaction' (line 61)
  • access: public
static mixed $FILTER_PREVIEW = 'preview' (line 62)
  • access: public
Methods
static clearActionList (line 126)

Deletes the currently saved action list.

It must be called after a successful login!

  • access: public
void clearActionList ()
static getActionsList (line 111)

Returns a list of possible actions

  • return: The list of the possible actions, or NULL if no action is registerd
  • access: public
array getActionsList ()
static getAvailableLanguages (line 508)

Returns all available languages in the program

  • return: Associative array of languages (code => description, eg. 'de_DE' => 'Deutsch')
  • access: public
array getAvailableLanguages ()
static getCurrentAction (line 155)

Returns the current called action.

  • return: The class name of the current action or NULL if no action was called
  • access: public
string getCurrentAction ()
static getCurrentLanguage (line 524)

Returns the current used language

  • return: The current language (eg: de_DE or en_US)
  • access: public
string getCurrentLanguage ()
static getDefaultAction (line 138)

Returns the current defined default action.

  • return: The class name of the default action or NULL if no default action was defined
  • access: public
string getDefaultAction ()
static getMenuActions (line 169)

Returns the list of all actions, that should appear in the menu.

  • return: The list of all menu action. It can be empty
  • access: public
array getMenuActions ()
static hasUserRightForAction (line 184)

Returns whether the user has rights for the given action.

  • return: true if the user has rights to call the action, false otherwise
  • access: public
boolean hasUserRightForAction (string $action)
  • string $action: The class name of the requested action
Constructor __construct (line 68)

Constructor.

Initializes all engines (Request, Session, Template engine, and so on)

  • access: public
myMVC_Controller __construct ()
process (line 583)

Process the request.

Action or View will be evaluated.

  • throws: myMVC_MVCException On problems
  • access: public
void process ()
setActions (line 202)

Set the available actions list.

  • throws: myMVC_MVCException On problems
  • access: public
void setActions (array $actions, string $defaultAction, [string $noRightAction = NULL])
  • array $actions: Array of Action Class names (derived from myMVC_BaseAction)
  • string $defaultAction: Name of the default Action (called if no Action was given)
  • string $noRightAction: Name of the Action to be called if the current users does not have the rights for the called Action. If it is NULL, and the user doesn't have the rights, an Exception will be generated
setFilter (line 364)

Sets the filter for the controller.

A filter can be called before an action or a view IMPORTANT: just a filter per type can be defined!!

  • throws: myMVC_MVCException On problems
  • access: public
void setFilter (int $type, string $class, [array $exceptions = array()], [array $params = array()])
  • int $type: Filter type (myMVC_Controller::$FILTER_PREACTION or myMVC_Controller::$FILTER_PREVIEW)
  • string $class: The class of the filter (derived from myMVC_BaseFilter)
  • array $exceptions: Optional list of classes (Action or View, depending on filter type, which has to be excluded from filter [aka: the controller will call this class, and not the filter])
  • array $params: Optional parameters for the filter
setLanguageInformation (line 441)

Set the language information (GetText)

  • throws: myMVC_MVCException On problems
  • access: public
void setLanguageInformation (array $availableLanguages, string $defaultLanguage, string $getTextLocaleDir,  $getTextLocaleDomain, [string $languageParameter = 'lang'])
  • array $availableLanguages: Associative array of languages (code => description, eg. 'de_DE' => 'Deutsch')
  • string $defaultLanguage: Default language. It MUST be one in the array $availableLanguages
  • string $getTextLocaleDir: GetText Domain
  • string $languageParameter: Name of the parameter with the new language (default: lang)
  • $getTextLocaleDomain
setRenderEngine (line 95)

Set the render engine zu use for template.

Currently just myMVC_SmartyEngine is implemented.

  • access: public
void setRenderEngine (class $class)
  • class $class: The render engine. It must be a subclass of myMVC_BaseEngine
setViews (line 304)

Set the available views list.

  • throws: myMVC_MVCException On problems
  • access: public
void setViews (array $views)
  • array $views: Array of View Class names (derived from myMVC_BaseView)

Documentation generated on Sat, 20 Oct 2012 08:28:28 +0200 by phpDocumentor 1.4.4