2013-07-21 09:47:49 +00:00
|
|
|
<?php
|
|
|
|
// SeedDMS. Document Management System
|
|
|
|
// Copyright (C) 2013 Uwe Steinmann
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
require_once('inc.ClassControllerCommon.php');
|
|
|
|
|
|
|
|
class Controller {
|
|
|
|
/**
|
|
|
|
* Create a controller from a class
|
|
|
|
*
|
|
|
|
* This method will check for a class file in the controller directory
|
|
|
|
* and returns an instance of it.
|
|
|
|
*
|
|
|
|
* @param string $class name of controller class
|
|
|
|
* @param array $params parameter passed to constructor of controller class
|
|
|
|
* @return object an object of a class implementing the view
|
|
|
|
*/
|
|
|
|
static function factory($class, $params=array()) { /* {{{ */
|
2024-04-19 15:18:06 +00:00
|
|
|
global $settings, $session, $extMgr, $request, $logger;
|
2013-07-21 09:47:49 +00:00
|
|
|
if(!$class) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$classname = "SeedDMS_Controller_".$class;
|
2014-12-08 13:35:51 +00:00
|
|
|
$filename = '';
|
2020-01-03 09:21:58 +00:00
|
|
|
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
2016-12-29 16:36:27 +00:00
|
|
|
$filename = $settings->_rootDir.'ext/'.$extname.'/controllers/class.'.$class.".php";
|
2014-12-08 13:35:51 +00:00
|
|
|
if(file_exists($filename)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$filename = '';
|
|
|
|
}
|
|
|
|
if(!$filename)
|
|
|
|
$filename = $settings->_rootDir."controllers/class.".$class.".php";
|
|
|
|
if(!file_exists($filename))
|
|
|
|
$filename = '';
|
|
|
|
if($filename) {
|
2018-11-23 20:38:23 +00:00
|
|
|
require_once($filename);
|
2013-07-21 09:47:49 +00:00
|
|
|
$controller = new $classname($params);
|
|
|
|
/* Set some configuration parameters */
|
|
|
|
$controller->setParam('postVars', $_POST);
|
|
|
|
$controller->setParam('getVars', $_GET);
|
|
|
|
$controller->setParam('requestVars', $_REQUEST);
|
|
|
|
$controller->setParam('session', $session);
|
2022-07-29 19:36:40 +00:00
|
|
|
$controller->setParam('request', $request);
|
2013-07-21 09:47:49 +00:00
|
|
|
$controller->setParam('settings', $settings);
|
2024-04-19 15:18:06 +00:00
|
|
|
$controller->setParam('logger', $logger);
|
2013-07-21 09:47:49 +00:00
|
|
|
return $controller;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
}
|