This commit is contained in:
Anatoly 2018-01-15 16:22:12 +03:00
commit f33afc2861
18 changed files with 240 additions and 48 deletions

View file

@ -62,6 +62,7 @@ class Controller_Action
public function loadConfig($name) {
$filename = Shortcut::getUrl('config', $name);
$settings = [];
if (file_exists($filename)) {
include($filename);
} else {
@ -210,7 +211,8 @@ class Controller_Action
public function nUrl($name, array $param = array())
{
/*.Filter_ActionAccess.*/$access = $this->access;
if ($access != null || $access->checkAction($name)) {
if ($access == null || $access->checkAction($name)) {
return lcurry(array($this, 'postUrl'), $name, $param);
}
return null;
@ -372,4 +374,9 @@ class Controller_Action
{
$this->_getActionPath()->getPath($this, ($action) ? $action : $request->getAction());
}
function redirect($action) {
header('location: ' . $this->fUrl($action));
exit();
}
}

View file

@ -66,7 +66,13 @@ class Controller_Component
function execute(HttpRequest $request, $has_id = true) {
$crequest = new ComponentRequest($this->component_id, $request);
$action = 'action' . ucfirst($request->get('action', 'index'));
$_action = $request->get('action', 'index');
if (is_array($_action)) {
$action = 'action' . ucfirst(Arr::get($_action, $this->component_id, 'index'));
} else {
$action = 'action' . ucfirst($_action);
}
$this->before();
if (method_exists($this, $action)) {
@ -106,7 +112,9 @@ class Controller_Component
$tpl->set('common', Path::join(WWW_PATH, '../', 'common'));
$tpl->set('script', Path::join(WWW_PATH, 'js'));
$tpl->set('media', Path::join(TEMPLATE_WEB, $template));
$tpl->set('site_template', SITE_WWW_PATH . '/templates' . $registry->readKey(array('system', 'template')));
if ($registry) {
$tpl->set('site_template', SITE_WWW_PATH . '/templates' . $registry->readKey(array('system', 'template')));
}
$tpl->set('base', SITE_WWW_PATH);
$tpl->set('component_base', $this->webPath[$selected]);
@ -125,14 +133,6 @@ class Controller_Component
return Path::join($this->webPath[0], 'templates', 'modern');
}
/**
* @param $name Имя модели
*/
private function getModelPath($name)
{
return Path::join (CMS_PATH, "model", $name . ".php");
}
/**
* Создает модель
* @param string $name
@ -140,9 +140,8 @@ class Controller_Component
*/
public function getModel($name)
{
require_once ($this->getModelPath ($name));
$modelName = $name . "Mapper";
$model = new $modelName ();
$modelName = "Mapper_" . $name;
$model = new $modelName();
$model->db = $this->db;
return $model;
}
@ -188,7 +187,7 @@ class Controller_Component
$view->component_title = $settings['title'];
}
static function loadComponent($expression, Database $db, Settings $registry)
static function loadComponent($expression, Database $db, /*.Settings.*/ $registry)
{
$expression = htmlspecialchars_decode($expression);
@ -322,11 +321,7 @@ class Controller_Component
*/
function addRequireJsPath($name, $path, $shim = null) {
global $requireJsConfig;
$requireJsConfig['paths'][$name] = $path;
if ($shim) {
$requireJsConfig['shim'][$name] = $shim;
}
Controller_Site::addRequireJsPath($name, $path, $shim);
}
function actionIndex(/*.ComponentRequest.*/ $request) {

View file

@ -48,7 +48,7 @@ class Controller_Installer
foreach ($sql as $version => $install) {
if (version_compare($version, $version_new, "<=") && version_compare($version, $version_old, ">")) {
$file = Path::join(call_user_func($this->installPath, $name), "sql", $install);
$json_installer->install($file,null);
$json_installer->install($file, null);
$result[] = $version;
}
}
@ -64,11 +64,13 @@ class Controller_Installer
$this->_registry->removeKey($name);
$this->_registry->write();
}
// Устанавливает обновления если есть
function doUpdates($name, $force = false) // Установка модуля
{
$result = array();
$setup = $this->getSetupFile($name);
if (file_exists($setup) && ($this->isChanged($name) || $force)) {
$registry = $this->_registry;
$settings = new Settings($setup);
@ -91,21 +93,22 @@ class Controller_Installer
$result[]=$res;
}
}
}
// Обновление версии меню
$registry->removeKey($name);
$registry->writeKey(array($name), $settings->get('settings'));
$registry->writeKey(array($name),
// Обновление версии меню
$registry->removeKey($name);
$registry->writeKey(array($name), $settings->get('settings'));
$registry->writeKey(array($name),
array('version' => $version_new,
'time' => filemtime($setup)));
}
$registry->write();
}
return $result;
}
function install($dbinit_path,$dbfill_path=null){
function install($dbinit_path, $dbfill_path = null) {
$json_installer = new Database_JsonInstall($this->db_manager);
$json_installer->install($dbinit_path,$dbfill_path);
$json_installer->install($dbinit_path, $dbfill_path);
}
}