$FILTER_PREACTION
$FILTER_PREACTION :
Main controller.
It manages all requests and responses. Example to use it:
define('SMARTY_DIR', '../Smarty/libs/');
require_once(SMARTY_DIR.'Smarty.class.php');
require_once('mymvc/myMVC.php');
require_once('../etc/etc.php'); // YOUR define file
$controller = new myMVC_Controller(); $controller->setRenderEngine(new myMVC_SmartyEngine($_SERVER['DOCUMENT_ROOT'].'/../pages/templates',
$_SERVER['DOCUMENT_ROOT'].'/../pages/templates_c'));
$controller->setActions(array('MainAction', 'TestAction', 'Test1Action', 'NoRightsAction', 'LoginAction', 'myMVC_BaseLogoutAction'),
'MainAction', 'NoRightsAction');
$controller->setViews(array('MainView', 'TestView', 'Test1View', 'NoRightsView', 'LoginView')); $controller->setLanguageInformation(array('de_DE' => 'Deutsch', 'en_US' => 'English', 'it_IT' => 'Italiano'),
'de_DE', $_SERVER['DOCUMENT_ROOT'].'/../locale', 'testmvc');
$controller->setFilter(myMVC_Controller::$FILTER_PREACTION, 'myMVC_LoginFilter', array(), array('loginAction' => 'LoginAction')); $controller->process();
setActions(array $actions, string $defaultAction, string $noRightAction = NULL)
Set the available actions list.
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
|
On problems
setFilter(integer $type, string $class, array $exceptions = array(), array $params = array())
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!!
integer | $type | Filter type
|
string | $class | The class of the filter (derived from myMVC_BaseFilter) |
array | $exceptions | Optional list of classes (Action or View, depending on filter type,
|
array | $params | Optional parameters for the filter |
On problems
setLanguageInformation(array $availableLanguages, string $defaultLanguage, string $getTextLocaleDir, $getTextLocaleDomain, string $languageParameter = 'lang')
Set the language information (GetText)
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 |
$getTextLocaleDomain | ||
string | $languageParameter | Name of the parameter with the new language (default: lang) |
On problems
setCurrentLanguage()
Get the wanted language (from browser or from parameter) and load the language definition (for GetText)
Note: this function is PUBLIC, so that you can call it from CLI, too. To do that, use following code example:
$mainDir = dirname($_SERVER['SCRIPT_FILENAME']);
if(substr($mainDir, 0, 1) != '/')
$etcDir = $_SERVER['PWD'].'/'.$mainDir;
else
$etcDir = $mainDir;
require_once('myMVC.php');
$controller = new myMVC_Controller(); $controller->setLanguageInformation(array('de_DE' => 'Deutsch', 'en_US' => 'English'),
'de_DE', $etcDir.'/../locale', 'myApplication');
$controller->setCurrentLanguage();