I finally got some piece of code working and as I said, I'll show you. There is a lot of code.. (well... more PhpDoc Comments than code bu anyway.. you'll have to scroll.) By the way, if somes knows Mojavi, you'll see this code looks like it. I've been greatly inspired by mojavi when I was building this "Framework". Good work Mojavi Team, I don't understand everything yet, but you've build something great.
Here goes the code, I just pasted what's needed to explain my though (look at preview posts) (I'll explain after and I hope you don't dislike french comments)
Controller.php :
PHP Code:
<?php
// +---------------------------------------------------------------------------+
// | Ce fichier fait parti du package Conceptromec |
// | Copyright (c) Conceptromec |
// | |
// | Pour plus d'informations, veuillez contacter Conceptromec |
// +---------------------------------------------------------------------------+
/**
* Objet Controller. Cet objet va analyser la requête courrante, exécuter l'action
* et va exécuter la bonne vue.
*
* @author Jean-Philippe Déry <jeanphilippe_dery@hotmail.com>
* @package Conceptromec
* @version 1.0
*/
class Controller
{
/**
* Objet Request.
*
* @var object
* @access private
* @since 1.0
*/
var $request = null;
/**
* Tableau contenant les informations du controlleur.
*
* @var array
* @access private
* @since 1.0
*/
var $infos = array
(
'current_module' => '',
'current_action' => '',
'request_module' => '',
'request_action' => ''
);
/**
* Objet User.
*
* @var object
* @access private
* @since 1.0
*/
var $user = null;
/**
* Objet requestChain.
*
* @var object
* @access private
* @since 1.0
*/
var $requestChain = null;
/**
* Constructeur. Créé une instance de tous les objets nécessaires.
*
* @access public
* @since 1.0
*/
function Controller()
{
$this->request =& new Request();
$this->user =& new User();
$this->requestChain =& new RequestChain($this);
}
/**
* Détermine si une action existe.
*
* @param string $modName Le nom du module.
* @param string $actName Le nom de l'action.
*
* @return bool True if the module exists otherwise false.
*
* @access public
* @since 1.0
*/
function actionExists($modName, $actName)
{
$file = BASE_DIR . "modules/$modName/actions/{$actName}Action.php";
if (is_readable($file))
{
return true;
}
return false;
}
/**
* Return an instance of a given action.
*
* @param string $modName Le nom du module.
* @param string $actName Le nom de l'action.
*
* @return object The action's instance.
*
* @access public
* @since 1.0
*/
function & getAction($modName, $actName)
{
$file = BASE_DIR . $file = BASE_DIR . "modules/$modName/actions/{$actName}Action.php";
require_once $file;
$action = "{$actName}Action";
$action =& new $action($this, $modName, $actName);
return $action;
}
/**
* Détermine if a view exists.
*
* @param string $modName Le nom du module.
* @param string $actName Le nom de l'action.
* @param string $actVlue View's type.
*
* @return bool True the view exists otherwise false.
*
* @access public
* @since 1.0
*/
function viewExists($modName, $actName, $actView)
{
$file = BASE_DIR . "modules/$modName/views/{$actName}View_{$actView}.php";
if (is_readable($file))
{
return true;
}
return false;
}
/**
* Return an instance of a given view.
*
* @param string $modName Le nom du module.
* @param string $actName Le nom de l'action.
* @param string $actView View's type.
*
* @return object Objet View.
*
* @access public
* @since 1.0
*/
function & getView($modName, $actName, $actView)
{
$file = BASE_DIR . "modules/$modName/views/{$actName}View_{$actView}.php";
require_once $file;
$view = "{$actName}View";
$view =& new $view($this);
return $view;
}
/**
* Retourne l'objet User.
*
* @return object Objet User.
*
* @access public
* @since 1.0
*/
function & getUser()
{
return $this->user;
}
/**
* Retoune l'objet Request.
*
* @return object L'objet Request
*
* @access public
* @since 1.0
*/
function & getRequest()
{
return $this->request;
}
/**
* Retourne les informations du controlleur.
*
* @return array Les informations du controlleur.
*
* @access public
* @since 1.0
*/
function & getInfos()
{
return $this->infos;
}
/**
* Effectue l'action courrante.
*
* @access public
* @since 1.0
*/
function dispatch()
{
$modName =& $this->request->getParameter('module');
$actName =& $this->request->getParameter('action');
if ($modName == null && $actName == null)
{
$modName = DEFAULT_MODULE;
$actName = DEFAULT_ACTION;
}
$this->infos['requestModule'] = $modName;
$this->infos['requestAction'] = $actName;
$this->handle($modName, $actName);
}
/**
* Exécute une action donnée.
*
* @param string $modName Le nom du module.
* @param string $actName Le nom de l'action.
*
* @access public
* @since 1.0
*/
function handle($modName, $actName)
{
$request =& $this->request;
$user =& $this->user;
$infos =& $this->infos;
$requestChain =& $this->requestChain;
$modName = preg_replace('/[^a-z0-9_]/i', '', trim($modName));
$actName = preg_replace('/[^a-z0-9_]/i', '', trim($actName));
if ($this->actionExists($modName, $actName))
{
$action =& $this->getAction($modName, $actName);
if ($action->isSecure())
{
if (!$user->isAuthenticated())
{
if ($this->actionExists(AUTH_MODULE, AUTH_ACTION))
{
$this->handle(AUTH_MODULE, AUTH_ACTION);
exit;
}
trigger_error('Cannot find required module : ' . AUTH_MODULE . ':' . AUTH_ACTION, E_USER_ERROR);
}
if (!$user->hasPrivileges($action->getPrivileges()))
{
if ($this->actionExists(ERROR_NO_PRIV_MODULE, ERROR_NO_PRIV_ACTION))
{
$this->handle(ERROR_NO_PRIV_MODULE, ERROR_NO_PRIV_ACTION);
exit;
}
trigger_error('Cannot find required module : ' . ERROR_NO_PRIV_MODULE . ':' . ERROR_NO_PRIV_ACTION, E_USER_ERROR);
}
}
$action->setPreFilters($requestChain);
$action->setPostFilters($requestChain);
$requestChain->addRequest($modName, $actName, $action, REQCHAIN_POS_MIDDLE);
$requestChain->execute();
}
else
{
if ($this->actionExists(ERROR_404_MODULE, ERROR_404_ACTION))
{
$this->handle(ERROR_404_MODULE, ERROR_404_ACTION);
exit;
}
trigger_error('Cannot find required module : ' . ERROR_404_MODULE . ':' . ERROR_404_ACTION, E_USER_ERROR);
}
}
/**
* Gère les erreures.
*
* @param int $flag Le type d'erreur générée.
* @param string $message Le message de l'erreur.
* @param string $file Le fichier où s'est produit l'erreur.
* @param int $line La ligne où s'est produit l'erreur.
*
* @access public
* @since 1.0
*/
function throwError($flag, $message, $file, $line)
{
switch ($flag)
{
case E_USER_ERROR :
echo '<b>ERROR</b> [' . $file . ' : ' . $line . '] ' . $message . '<br/>';
break;
case E_USER_WARNING :
echo '<b>WARNING</b> [' . $file . ' : ' . $line . '] ' . $message . '<br/>';
break;
case E_USER_NOTICE :
echo '<b>NOTICE</b> [' . $file . ' : ' . $line . '] ' . $message . '<br/>';
break;
case E_ERROR :
echo '<b>ERROR</b> [' . $file . ' : ' . $line . '] ' . $message . '<br/>';
break;
case E_WARNING :
echo '<b>WARNING</b> [' . $file . ' : ' . $line . '] ' . $message . '<br/>';
break;
case E_NOTICE :
echo '<b>NOTICE</b> [' . $file . ' : ' . $line . '] ' . $message . '<br/>';
break;
default :
echo '<b>UNKNOWN</b> [' . $file . ' : ' . $line . '] ' . $message . '<br/>';
break;
}
}
}
?>
Action.php :
PHP Code:
<?php
// +---------------------------------------------------------------------------+
// | Ce fichier fait parti du package Conceptromec |
// | Copyright (c) Conceptromec |
// | |
// | Pour plus d'informations, veuillez contacter Conceptromec |
// +---------------------------------------------------------------------------+
/**
* Objet Action. Interface de toutes les actions.
*
* @author Jean-Philippe Déry <jeanphilippe_dery@hotmail.com>
* @package Conceptromec
* @version 1.0
*/
class Action
{
/**
* Objet Controller.
*
* @var object
* @access private
* @since 1.0
*/
var $controller = null;
/**
* Objet Request.
*
* @var object
* @access private
* @since 1.0
*/
var $request = null;
/**
* Tableau contenant les informations du controlleur.
*
* @var array
* @access private
* @since 1.0
*/
var $infos = array();
/**
* Objet User.
*
* @var object
* @access private
* @since 1.0
*/
var $user = null;
/**
* Objet MySqlDb.
*
* @var object
* @access private
* @since 1.0
*/
var $db = null;
/**
* Nom du module.
*
* @var string
* @access private
* @since 1.0
*/
var $modName = '';
/**
* Nom de l'action.
*
* @var string
* @access private
* @since 1.0
*/
var $actName = '';
/**
* Stack de données pour la vue.
*
* @var array
* @access private
* @since 1.0
*/
var $data = array();
/**
* Constructeur. Instancie les objets nécessaires.
*
* @param object $controller Objet Controlleur.
* @param string $modName Le nom du module.
* @param string $actName Le nom de l'action.
*
* @access public
* @since 1.0
*/
function Action (&$controller, $modName, $actName)
{
$this->controller =& $controller;
$this->request =& $controller->getRequest();
$this->user =& $controller->getUser();
$this->infos =& $controller->getInfos();
$this->db =& MysqlDb::getInstance();
$this->modName = $modName;
$this->actName = $actName;
$this->getLang();
}
/**
* Charge tous les mots pour l'action courrante dans l'attribut
* $this->data['lang'].
*
* @access private
* @since 1.0
*/
function getLang()
{
$user =& $this->user;
$data =& $this->data;
$language = $user->getAttribute('language');
$file = BASE_DIR . "modules/$this->modName/" .
"langs/{$this->actName}_{$language}.php";
if (is_readable($file))
{
require_once($file);
if (isset($lang))
{
$data['lang'] =& $lang;
}
}
}
/**
* Enregistre une action qui doit être exécutée avant l'action
* principale.
*
* @param object $requestList Objet RequestList.
*
* @access public
* @since 1.0
*/
function setPreFilters(&$requestList)
{
return;
}
/**
* Enregistre une action qui doit être exécutée après l'action
* principale.
*
* @param object $requestList Objet RequestList.
*
* @access public
* @since 1.0
*/
function setPostFilters(&$requestList)
{
return;
}
/**
* Exécute l'action et retourne le type de vue.
*
* @return string La constante de la vue.
*
* @access public
* @since 1.0
*/
function execute()
{
return VIEW_NONE;
}
/**
* Retourne les données pour la vue.
*
* @return array The $data array.
*
* @access public
* @since 1.0
*/
function & getData()
{
return $this->data;
}
/**
* Démterine si l'action est sécure.
*
* @return bool True si l'action est sécure sinon false.
*
* @access public
* @since 1.0
*/
function isSecure()
{
return false;
}
/**
* Retourne les privilèges de l'action.
*
* @return mixed Les privilèges sinon null.
*
* @access public
* @since 1.0
*/
function getPrivileges()
{
return null;
}
}
?>
Request Chain (Actually an action Chain) :
PHP Code:
<?php
// +---------------------------------------------------------------------------+
// | Ce fichier fait parti du package Conceptromec |
// | Copyright (c) Conceptromec |
// | |
// | Pour plus d'informations, veuillez contacter Conceptromec |
// +---------------------------------------------------------------------------+
/**
* Place l'action donnée dans les premières à être exécutés.
*
* @since 1.0
*/
define('REQCHAIN_POS_BEGIN', 0);
/**
* Place l'action dans la liste du milieu.
*
* @since 1.0
*/
define('REQCHAIN_POS_MIDDLE', 1);
/**
* Place l'action dans la liste de fin.
*
* @since 1.0
*/
define('REQCHAIN_POS_END', 2);
/**
* RequestChain Object. Create a list containing actions to execute.
*
* @author Jean-Philippe Déry <jeanphilippe_dery@hotmail.com>
* @package Conceptromec
* @version 1.0
*/
class RequestChain
{
/**
* Controller Instance.
*
* @var object
* @access private
* @since 1.0
*/
var $controller = null;
/**
* Request Object.
*
* @var object
* @access private
* @since 1.0
*/
var $request = null;
/**
* Array which contains information about action executions.
*
* @var array
* @access private
* @since 1.0
*/
var $infos = array();
/**
* User Instance.
*
* @var object
* @access private
* @since 1.0
*/
var $user = null;
/**
* Actions list.
*
* @var array
* @access private
* @since 1.0
*/
var $chain = array
(
REQCHAIN_POS_BEGIN => array(),
REQCHAIN_POS_MIDDLE => array(),
REQCHAIN_POS_END => array(),
);
/**
* Constructeur.
*
* @param object $controller Controller Instance.
*
* @access public
* @since 1.0
*/
function RequestChain($controller)
{
$this->controller =& $controller;
$this->request =& $controller->getRequest();
$this->infos =& $controller->getInfos();
}
/**
* Add an action to the list.
*
* @param string $modName The module's name.
* @param string $actName The action's name.
* @param object $action The action's instance.
* @param int $pos The action's position within the list.
*
* @access public
* @since 1.0
*/
function addRequest($modName, $actName, &$action, $pos = REQCHAIN_POS_MIDDLE)
{
$this->chain[$pos][] = array
(
'modName' => $modName,
'actName' => $actName,
'action' => $action,
);
}
/**
* Execute the request chain.
*
* @access public
* @since 1.0
*/
function execute()
{
$controller =& $this->controller;
$request =& $this->request;
$user =& $this->user;
$infos =& $this->infos;
$viewChain =& new ViewChain();
for ($j = 0; $j < 2; $j++)
{
$chain =& $this->chain[$j];
$size = sizeof($chain);
for ($i = 0; $i < $size; $i++)
{
$modName =& $chain[$i]['modName'];
$actName =& $chain[$i]['actName'];
$action =& $chain[$i]['action'];
// Update module infos
$infos['currentModule'] = $modName;
$infos['currentAction'] = $actName;
// Execute the given action
$actView =& $action->execute();
if ($actView != VIEW_NONE || $actView != null)
{
if ($controller->viewExists($modName, $actName, $actView))
{
$view =& $controller->getView($modName, $actName, $actView);
$view->setData($action->getData());
$view->setPreFilters($viewChain);
$view->setPostFilters($viewChain);
$viewChain->addView($view, VIEWCHAIN_POS_MIDDLE);
$viewChain->execute();
}
}
}
}
}
}
?>
View.php :
PHP Code:
<?php
// +---------------------------------------------------------------------------+
// | Ce fichier fait parti du package Conceptromec |
// | Copyright (c) Conceptromec |
// | |
// | Pour plus d'informations, veuillez contacter Conceptromec |
// +---------------------------------------------------------------------------+
/**
* Error View.
*
* @since 1.0
*/
define('VIEW_ERROR', 'error');
/**
* Common View.
*
* @since 1.0
*/
define('VIEW_INDEX', 'index');
/**
* Form View.
*
* @since 1.0
*/
define('VIEW_INPUT', 'input');
/**
* No View.
*
* @since 1.0
*/
define('VIEW_NONE', '');
/**
* Success View.
*
* @since 1.0
*/
define('VIEW_SUCCESS', 'success');
/**
* View Object. Interface of every actions.
*
* @author Jean-Philippe Déry <jeanphilippe_dery@hotmail.com>
* @package Conceptromec
* @version 1.0
*/
class View
{
/**
* Controller Instance.
*
* @var object
* @access private
* @since 1.0
*/
var $controller = null;
/**
* Request Object.
*
* @var object
* @access private
* @since 1.0
*/
var $request = null;
/**
* Array which contains information about action executions.
*
* @var array
* @access private
* @since 1.0
*/
var $infos = array();
/**
* User Instance.
*
* @var object
* @access private
* @since 1.0
*/
var $user = null;
/**
* Objet template utilisé pour charger les fichiers templates
*
* @var object
* @access protected
* @since 1.0
*/
var $template = null;
/**
* Données provenant du model.
*
* @var array
* @access protected
* @since 1.0
*/
var $data = array();
/**
* Créé une nouvelle instance d'une vue.
*
* @param object $controller L'objet Controller.
*
* @access public
* @since 1.0
*/
function View (&$controller)
{
$this->controller =& $controller;
$this->request =& $controller->getRequest();
$this->user =& $controller->getUser();
$this->infos =& $controller->getInfos();
$this->template =& new Template();
}
/**
* Assigne le fichier template à utiliser.
*
* @param string $file Le fichier template a charger
*
* @access public
* @since 1.0
*/
function setTemplate($file)
{
$template =& $this->template;
$infos =& $this->infos;
$path = BASE_DIR . "modules/{$infos['currentModule']}/templates/$file";
if (is_readable($path))
{
$template->load($path);
}
}
/**
* Assigne les données de la vue.
*
* @param array $data Les données du model.
*
* @access public
* @since 1.0.
*/
function setData(&$data)
{
$this->data = $data;
}
/**
* Enregistre une action qui doit être exécutée avant l'action
* principale.
*
* @param object $viewList Objet RequestList.
*
* @access public
* @since 1.0
*/
function setPreFilters(&$viewList)
{
return;
}
/**
* Enregistre une action qui doit être exécutée après l'action
* principale.
*
* @param object $viewList Objet RequestList.
*
* @access public
* @since 1.0
*/
function setPostFilters(&$viewList)
{
return;
}
/**
* Exécute la vue et l'affiche a l'écran.
*
* @param object $action L'objet action.
*
* @access public
* @since 1.0
*/
function execute()
{
}
}
?>
ViewChain :
PHP Code:
<?php
// +---------------------------------------------------------------------------+
// | Ce fichier fait parti du package Conceptromec |
// | Copyright (c) Conceptromec |
// | |
// | Pour plus d'informations, veuillez contacter Conceptromec |
// +---------------------------------------------------------------------------+
/**
* Place l'action donnée dans les premières à être exécutés.
*
* @since 1.0
*/
define('VIEWCHAIN_POS_BEGIN', 0);
/**
* Place l'action dans la liste du milieu.
*
* @since 1.0
*/
define('VIEWCHAIN_POS_MIDDLE', 1);
/**
* Place l'action dans la liste de fin.
*
* @since 1.0
*/
define('VIEWCHAIN_POS_END', 2);
/**
* Objet ViewChain. Cet objet permet d'exécuter plusieurs vue qui sont stoqués
* dans une file.
*
* @author Jean-Philippe Déry <jeanphilippe_dery@hotmail.com>
* @package Conceptromec
* @version 1.0
*/
class ViewChain
{
/**
* Liste des vues a exécuter
*
* @var array
* @access private
* @since 1.0
*/
var $chain = array
(
VIEWCHAIN_POS_BEGIN => array(),
VIEWCHAIN_POS_MIDDLE => array(),
VIEWCHAIN_POS_END => array(),
);
/**
* Ajoute une vue à la chaine d'exécution.
*
* @param ojbect $view Un objet View.
*
* @access public
* @since 1.0
*/
function addView(&$view, $pos = VIEWCHAIN_POS_MIDDLE)
{
$this->chain[$pos][] = $view;
}
/**
* Exécute la liste des vues.
*
* @access public
* @since 1.0
*/
function execute()
{
for ($j = 0; $j < 2; $j++)
{
$chain =& $this->chain[$j];
$size = sizeof($chain);
for ($i = 0; $i < $size; $i++)
{
$chain[$i]->execute();
}
}
}
}
?>
Ok this is the base class, now for the classes that make a "blank" page. (Page with navigation, header, footer but nothing in the middle.. yet)
IndexAction.php
PHP Code:
<?php
// +---------------------------------------------------------------------------+
// | Ce fichier fait parti du package Conceptromec |
// | Copyright (c) Conceptromec |
// | |
// | Pour plus d'informations, veuillez contacter Conceptromec |
// +---------------------------------------------------------------------------+
/**
* Objet IndexAction. Buisness Logic de la page d'index.
*
* @author Jean-Philippe Déry <jeanphilippe_dery@hotmail.com>
* @package Conceptromec
* @version 1.0
*/
class IndexAction extends Action
{
/**
* Constructeur. Instancie les objets nécessaires.
*
* @param object $controller Objet Controlleur.
* @param string $modName Le nom du module.
* @param string $actName Le nom de l'action.
*
* @access public
* @since 1.0
*/
function IndexAction (&$controller, $modName, $actName)
{
parent::Action($controller, $modName, $actName);
}
/**
* Exécute l'action.
*
* @return string La constante de la vue à utiliser.
*
* @access public
* @since 1.0
*/
function execute()
{
return VIEW_INDEX;
}
/**
* Cette action ne nécessite pas de sécurité.
*
* @return bool False car l'action ne nécessite pas de sécurité.
*
* @access public
* @since 1.0
*/
function isSecure()
{
return false;
}
/**
* Cette page ne nécessite aucun privilèges spéciaux.
*
* @return null Null car aucuns privilèges n'est requis.
*
* @access public
* @since 1.0
*/
function getPrivileges()
{
return null;
}
}
?>
IndexView_index.php
PHP Code:
<?php
// +---------------------------------------------------------------------------+
// | Ce fichier fait parti du package Conceptromec |
// | Copyright (c) Conceptromec |
// | |
// | Pour plus d'informations, veuillez contacter Conceptromec |
// +---------------------------------------------------------------------------+
require_once BASE_DIR . 'modules/Default/views/Default.php';
/**
* Objet View. Objet de base pour toutes vues.
*
* @author Jean-Philippe Déry <jeanphilippe_dery@hotmail.com>
* @package Conceptromec
* @version 1.0
*/
class IndexView extends View
{
/**
* Créé une nouvelle instance d'une vue.
*
* @param object $controller L'objet Controller.
*
* @access public
* @since 1.0
*/
function IndexView (&$controller)
{
parent::View($controller);
}
/**
* Enregistre une action qui doit être exécutée avant l'action
* principale.
*
* @param object $viewList Objet RequestList.
*
* @access public
* @since 1.0
*/
function setPreFilters(&$viewList)
{
require_once BASE_DIR . 'modules/Default/viewFilter/HeaderViewFilter.php';
$headerView =& new HeaderViewFilter($this->controller);
$headerView->setData($this->data);
$viewList->addView($headerView);
}
/**
* Enregistre une action qui doit être exécutée après l'action
* principale.
*
* @param object $viewList Objet RequestList.
*
* @access public
* @since 1.0
*/
function setPostFilters(&$viewList)
{
return;
}
/**
* Exécute la vue et l'affiche a l'écran.
*
* @access public
* @since 1.0
*/
function execute()
{
$controller =& $this->controller;
$request =& $this->request;
$user =& $this->user;
$infos =& $this->infos;
$template =& $this->template;
$lang =& $this->data['lang'];
$data =& $this->data;
$this->setTemplate('Index_index.tpl');
$template->pparse();
}
}
?>
HeaderViewFilter.php :
PHP Code:
<?php
// +---------------------------------------------------------------------------+
// | Ce fichier fait parti du package Conceptromec |
// | Copyright (c) Conceptromec |
// | |
// | Pour plus d'informations, veuillez contacter Conceptromec |
// +---------------------------------------------------------------------------+
require_once BASE_DIR . 'modules/Default/views/Default.php';
/**
* Objet HeaderViewFilter
*
* @author Jean-Philippe Déry <jeanphilippe_dery@hotmail.com>
* @package Conceptromec
* @version 1.0
*/
class HeaderViewFilter extends View
{
/**
* Créé une nouvelle instance d'une vue.
*
* @param object $controller L'objet Controller.
*
* @access public
* @since 1.0
*/
function HeaderViewFilter (&$controller)
{
parent::View($controller);
}
/**
* Enregistre une action qui doit être exécutée avant l'action
* principale.
*
* @param object $requestList Objet RequestList.
*
* @access public
* @since 1.0
*/
function setPreFilters(&$requestList)
{
return;
}
/**
* Enregistre une action qui doit être exécutée après l'action
* principale.
*
* @param object $requestList Objet RequestList.
*
* @access public
* @since 1.0
*/
function setPostFilters(&$requestList)
{
return;
}
/**
* Exécute la vue et l'affiche a l'écran.
*
* @param object $action L'objet action.
*
* @access public
* @since 1.0
*/
function execute()
{
$this->setTemplate('Header.tpl');
// Raccourcis
$controller =& $this->controller;
$request =& $this->request;
$user =& $this->user;
$infos =& $this->infos;
$template =& $this->template;
$data =& $this->data;
$lang =& $this->data['lang'];
// Ajoute les valeurs dans le template
$template->assignVars(array
(
'L_CONCEPTROMEC' => $lang['Conceptromec'],
'L_HOME' => $lang['Home'],
'L_PRODUCTS' => $lang['Products'],
'L_NEWS' => $lang['News'],
'L_CAREERS' => $lang['Careers'],
'L_CONTACT_US' => $lang['Contact_Us'],
'L_GENERAL' => $lang['General'],
'L_SALES' => $lang['Sales'],
'L_INGENEERING' => $lang['Ingeneering'],
'L_SUPPORT' => $lang['Support'],
'L_ABOUT_US' => $lang['About_Us'],
'L_HISTORY' => $lang['History'],
'L_MISSION' => $lang['Mission'],
'L_CLIENT' => $lang['Client'],
'L_LOST_PASSWORD' => $lang['Lost_Password'],
'L_PROJECTS' => $lang['Projects'],
'HEADER_DESCRIPTION' => HEADER_DESCRIPTION,
'HEADER_KEYWORDS' => HEADER_KEYWORDS,
'HEADER_CONTENT_TYPE' => HEADER_CONTENT_TYPE,
'HEADER_CHARSET' => HEADER_CHARSET,
'BASE_DIR' => BASE_DIR,
));
// Menus Login/Logout
if ($user->isAuthenticated())
{
$template->assignVars(array
(
'L_SIGN_OUT' => $lang['Sign_Out'],
'L_PROFILE' => $lang['Profile'],
));
}
else
{
$template->assignVars(array
(
'L_SIGN_IN' => $lang['Sign_In'],
'L_REGISTER' => $lang['Register'],
));
}
$template->pparse();
}
}
?>
Ok this is done now. I'll explain.
The Controller handle the request, since the IndexAction occurs when there is no request given, let's assume no request has been given.
into : Controller::handle(), The action (model) is instanciated and both methods setPreFilter() and setPostFilters are called. These method will be overriden within other classes to provide other possibles action to be executed before and after the main action.
When the main action (model) is executed, it returns a view name. From this view, the controller select the View class to execute (well just like Mojavi). Then the view is instanciated and both methods setPreFilters() and setPostFilters() which will be overriden on the classes. In the example, the method setPreFilters() from IndexAction Class will add the class HeaderViewFilter which generate a html header.
So, before generating the main page view, the header will be printed out.
I hope this is helping you to understand, I'll understand if you don't read everything because, indeed, there is a LOT of stuff here and you need a lot of time and interests to go trough
.
Thanks for reading and now, if you can, tell me this thing fit into MVC pattern.
Thanks.
P.S. Just some note. About the word "Filter", when I studied Mojavi, the filter thing was not absolutly clear to me. I figured it was juste some piece of execution to be run before an action (model). I may be wrong. Oh, yhea, something else. in the words setPreFilters and setPostFilters, the words "post" has nothing to do with $_POST or "method="post" values. they means before, after... Just in case (I'm not kicking *** when writing in english. Hope you can understand)
Bookmarks