Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
92
core/controller/frontcontroller.php
Normal file
92
core/controller/frontcontroller.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/controller/controller.php';
|
||||
require_once 'core/controller/installer.php';
|
||||
|
||||
/**
|
||||
* Ïåðâè÷íûé êîíòðîëëåð êîíòðîëëåð ñòðàíèö
|
||||
* @package core
|
||||
*/
|
||||
class Controller_Front extends Controller
|
||||
{
|
||||
|
||||
protected $shortcut; // ßðëûê ê ìîäóëþ
|
||||
protected $_param; // Ïàðàìåòð ïî êîòîðîìó âûáèðàåòñÿ ìîäóëü
|
||||
protected $default; // Çíà÷åíèå ïàðàìåòðà ïî óìîë÷àíèþ
|
||||
protected $installer;
|
||||
|
||||
public function __construct(Settings $_registry, $_shortcut)
|
||||
{
|
||||
require_once 'creole/Creole.php';
|
||||
parent::__construct();
|
||||
$registry = $_registry;
|
||||
$this->_registry = $_registry;
|
||||
$this->_shortcut = $_shortcut;
|
||||
|
||||
$this->db = Creole::getConnection($registry->readKey(array('system', 'dsn')));
|
||||
$this->installer = new Installer($_registry);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ñîçäàåò ýêçåìïëÿð ìîäóëÿ è âûïîëíÿåò äåéñòâèÿ äëÿ íåãî
|
||||
* @param string $name Èìÿ ìîäóëÿ
|
||||
* @param request $request Èìÿ ìîäóëÿ
|
||||
* @return string
|
||||
*/
|
||||
public function loadModule($name, Collection $request)
|
||||
{
|
||||
$this->installer->setUp($this->db, array($this, 'installPath'));
|
||||
$this->installer->doUpdates($name); // ModuleLoader (1)
|
||||
|
||||
$moduleFile = Shortcut::getUrl($this->shortcut, $name); // ModuleLoader (2)
|
||||
$module = $this->loadClass($moduleFile);
|
||||
|
||||
if ($module) {
|
||||
// Èíèöèàëèçàöèÿ ìîäóëÿ
|
||||
// $module->viewPath = dirname($moduleFile);
|
||||
$module->viewPath = Shortcut::getUrl('modulepath', $name);
|
||||
$module->name = $name;
|
||||
|
||||
$module->param = $this->param;
|
||||
//
|
||||
$module->_registry = $this->_registry;
|
||||
$module->_shortcut = $this->_shortcut;
|
||||
|
||||
$module->iconPath = $this->iconPath; // -> Registry
|
||||
$module->themePath = $this->themePath; // -> Registry
|
||||
$module->jsPath = $this->jsPath; // -> Registry
|
||||
$module->db = $this->db;
|
||||
// Íå äëÿ âñåõ ïðèëîæåíèé íóæíî âåñòè ëîã äåéñòâèé
|
||||
// Âåäåíèå ëîãà
|
||||
$logger = $this->loadClass(FRAMEWORK_PATH . '/core/filter/actionlogger.php', $module);
|
||||
$logger->before = $this->loadSettings(Shortcut::getUrl('logger', $name));
|
||||
// Óïðàâëåíèå äîñòóïîì
|
||||
$module->access = $this->loadClass(FRAMEWORK_PATH . '/core/filter/actionaccess.php', $logger);
|
||||
$module->access->access = $this->loadSettings(Shortcut::getUrl('access', $name));
|
||||
|
||||
$module->setUp();
|
||||
|
||||
return $module->access->execute($request);
|
||||
}
|
||||
return null; // throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
public function setParameter($shortcut, $param, $name)
|
||||
{
|
||||
$this->shortcut = $shortcut;
|
||||
// Ïàðàìåòð
|
||||
$this->_param = $param;
|
||||
$this->default = $name;
|
||||
}
|
||||
|
||||
private function getParameter(Collection $list)
|
||||
{
|
||||
return ($list->get($this->_param)) ? $list->get($this->_param): $this->default;
|
||||
}
|
||||
|
||||
public function execute(HTTPRequest $request)
|
||||
{
|
||||
return $this->loadModule($this->getParameter($request), $request);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue