Source for file controler.php
Documentation is available at controler.php
* Fichier de la classe Controler
* LODEL - Logiciel d'Edition ELectronique.
* Copyright (c) 2001-2002, Ghislain Picard, Marin Dacos
* Copyright (c) 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
* Copyright (c) 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
* Copyright (c) 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* Copyright (c) 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* Copyright (c) 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* Home page: http://www.lodel.org
* E-Mail: lodel@lodel.org
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* @author Ghislain Picard
* @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* @licence http://www.gnu.org/copyleft/gpl.html
* @since Fichier ajouté depuis la version 0.8
* @version CVS:$Id: controler.php 4266 2008-04-17 12:06:36Z cenou $
* Classe gérant la partie contrôleur du modèle MVC utilisé par Lodel 0.8
* @author Ghislain Picard
* @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* @licence http://www.gnu.org/copyleft/gpl.html
* @since Fichier ajouté depuis la version 0.8
* Constructeur de la classe Controler.
* Ce constructeur se charge du nettoyage des variables $_POST, $_GET dans un premier temps. Puis
* suivant la logique appelée et l'action demandée il se charge d'appeler la bonne logique métier.
* Enfin, suivant le résultat de cet appel il appelle vue correspondante.
* Controler::controler(array("entities","entities_advanced","entities_edition",
* "entities_import", "entities_index", "filebrowser", "tasks","xml"),$lo);
* @param array $logics Les logiques métiers acceptées par le point d'entrée
* @param string $lo La logique métier appelée. Par défaut cette valeur est vide
* @param array $request La requête à traiter, si elle n'est passée ni en GET ni en POST (dans un script par ex.) : utilisé pour l'import massif de XML
function Controler($logics, $lo = '', $request = array())
// si la requete provient d'un script qui appelle le controleur
View::back(2); //revient 2 rang en arrière dans l'historique.
extract_post($therequest); // nettoyage des valeurs issues de formulaire
if ($lo != 'texts' && !in_array($lo, $logics)) {
// get the various common parameters
require_once 'validfunc.php';
foreach (array('class', 'classtype', 'type', 'textgroups') as $var) {
die("ERROR: a valid $var name is required");
$context[$var] = $therequest[$var];
// ids. Warning: don't remove this, the security in the following rely on these ids are real int.
foreach (array('id', 'idgroup', 'idclass', 'idparent') as $var) {
$context[$var] = intval($therequest[$var]);
if ($therequest['dir'] && ($therequest['dir'] == 'up' ||
$therequest['dir'] == 'down' ||
$context['dir'] = $therequest['dir'];
die("ERROR: invalid action");
require_once 'logic.php';
// que fait-on suivant l'action demandée
// create the logic for the table
if ($do == 'listAction') {
die('ERROR: invalid action');
$ret = $logic->$do($context, $error);
die('ERROR: invalid return from the logic.');
//Appel de la vue nécessaire
case '_next' : // si le controleur est appelé par un script
// hum... needs to remove the slashes... don't really like that, because some value may still
// come from database or lodel. Doing this way is not a security issue but may forbide
// user to use \' in there text
#require_once 'func.php';
$logic->viewAction($context, $error); // in case anything is needed to be put in the context
$context['error'] = $error;
if ($do == 'listAction') {
$view->renderCached($context, $lo);
$view->render($context, "edit_$lo");
if (strpos($ret, '_location:') === 0) {
$view->render($context, $ret);
$view->renderCached($context, 'index');
|