コード例 #1
0
ファイル: ModulesController.php プロジェクト: krvd/cms-Inji
 public function delModelAction($module, $modelName)
 {
     unlink(App::$primary->path . '/modules/' . $module . '/models/' . $modelName . '.php');
     $config = Config::custom(App::$primary->path . '/modules/' . $module . '/generatorHash.php');
     if (isset($config['models/' . $modelName . '.php'])) {
         unset($config['models/' . $modelName . '.php']);
         Config::save(App::$primary->path . '/modules/' . $module . '/generatorHash.php', $config);
     }
     Tools::redirect('/admin/modules/editor/' . $module, 'Модель ' . $modelName . ' была удалена');
 }
コード例 #2
0
ファイル: Router.php プロジェクト: krvd/cms-Inji
 /**
  * Include class by name
  * 
  * @param string $className
  * @return boolean
  */
 public static function loadClass($className)
 {
     $folders = [];
     if (strpos($className, '\\')) {
         $classPath = explode('\\', $className);
         $moduleName = $classPath[0];
         if (Module::installed($moduleName, App::$cur)) {
             $classPath = implode('/', array_slice($classPath, 1));
             if (App::$cur) {
                 if (App::$cur !== App::$primary) {
                     $folders['appModule'] = ['folder' => App::$primary->path . '/modules/' . $moduleName, 'classPath' => $classPath];
                 }
                 $folders['primaryAppModule'] = ['folder' => App::$cur->path . '/modules/' . $moduleName, 'classPath' => $classPath];
             }
             $folders['systemModule'] = ['folder' => INJI_SYSTEM_DIR . '/modules/' . $moduleName, 'classPath' => $classPath];
         }
     }
     $classPath = str_replace('\\', '/', $className);
     if (App::$cur) {
         if (App::$cur !== App::$primary) {
             $folders['primaryApp'] = ['folder' => App::$primary->path, 'classPath' => $classPath];
         }
         $folders['app'] = ['folder' => App::$cur->path, 'classPath' => $classPath];
     }
     $folders['system'] = ['folder' => INJI_SYSTEM_DIR, 'classPath' => $classPath];
     $paths = [];
     foreach ($folders as $code => $folderParams) {
         $paths = $paths + static::genFolderPaths($code, $folderParams['folder'], $folderParams['classPath']);
     }
     foreach ($paths as $path) {
         if (file_exists($path)) {
             include_once $path;
             if (in_array('Model', class_parents($className, false)) && \App::$primary) {
                 $filename = Cache::getDir('system') . '/classData.php';
                 $classData = Config::custom($filename);
                 if (empty($classData['Model'][$className]['tableCreated'])) {
                     $classData['Model'][$className]['tableCreated'] = $className::createTable();
                     Config::save($filename, $classData);
                 }
             }
             return true;
         }
     }
     return FALSE;
 }
コード例 #3
0
ファイル: ViewController.php プロジェクト: krvd/cms-Inji
 public function editTemplateAction($templateName)
 {
     $this->view->setTitle('Редактирование шаблона');
     App::$cur->view->customAsset('css', '/static/moduleAsset/View/css/blockDrop.css');
     App::$cur->view->customAsset('js', '/static/moduleAsset/View/js/blockDrop.js');
     $template = Config::custom(App::$primary->path . '/templates/' . $templateName . '/config.php');
     $pathMap = App::$primary->path . '/templates/' . $templateName . '/map.html';
     if (!empty($_POST)) {
         $templates = App::$primary->view->config;
         $templates['app']['installed'][$templateName] = $_POST['name'];
         Config::save('module', $templates, 'View', App::$primary);
         file_put_contents($pathMap, trim($_POST['map']));
         $template['template_name'] = $templateName;
         $template['name'] = $templateName;
         Config::save(App::$primary->path . '/templates/' . $_POST['name'] . '/config.php', $template);
         Tools::redirect('/admin/View');
     }
     $template['map'] = file_get_contents($pathMap);
     $this->view->page(['data' => compact('template')]);
 }
コード例 #4
0
ファイル: Modules.php プロジェクト: krvd/cms-Inji
 public function addActionToController($module, $type, $controller, $url)
 {
     $modulePath = Module::getModulePath($module);
     $path = Modules::getModulePath($module) . '/' . $type . '/' . $controller . '.php';
     $class = CodeGenerator::parseClass($path);
     $class->addMethod($url . 'Action');
     $controllerCode = "<?php\n\n" . $class->generate();
     Tools::createDir(pathinfo($path, PATHINFO_DIRNAME));
     file_put_contents($path, $controllerCode);
     $config = Config::custom($modulePath . '/generatorHash.php');
     $config[$type . '/' . $module . 'Controller.php'] = md5($controllerCode);
     Config::save($modulePath . '/generatorHash.php', $config);
 }
コード例 #5
0
ファイル: Inji.php プロジェクト: krvd/cms-Inji
 /**
  * Unlisten event
  * 
  * @param string $eventName
  * @param string $listenCode
  * @param boolean $save
  */
 public function unlisten($eventName, $listenCode, $save = false)
 {
     if ($save) {
         $config = Config::custom(App::$primary->path . '/config/events.php');
         if (!empty($config[$eventName][$listenCode])) {
             unset($config[$eventName][$listenCode]);
             Config::save(App::$primary->path . '/config/events.php', $config);
         }
     }
     if (!empty($this->_listeners[$eventName][$listenCode])) {
         unset($this->_listeners[$eventName][$listenCode]);
     }
 }
コード例 #6
0
ファイル: Template.php プロジェクト: krvd/cms-Inji
 /**
  * Load template config
  * 
  * @param string $configPath
  */
 public function loadConfig($configPath = '')
 {
     if (!$configPath) {
         $configPath = $this->path . '/config.php';
     }
     $this->configPath = $configPath;
     $this->config = \Config::custom($this->configPath);
 }
コード例 #7
0
ファイル: editor.php プロジェクト: krvd/cms-Inji
<?php

$table = new Ui\Table();
$table->name = 'Модели';
$table->addButton(['href' => "/admin/modules/createModel/{$module}", 'text' => 'Создать']);
$table->setCols(['Модель', 'Внешние изменения', 'Операции']);
$modulePath = Module::getModulePath($module);
$path = $modulePath . '/models';
$config = Config::custom(App::$primary->path . '/modules/' . $module . '/generatorHash.php');
if (file_exists($path)) {
    $files = array_slice(scandir($path), 2);
    foreach ($files as $file) {
        if (is_dir($path . '/' . $file)) {
            continue;
        }
        $modelName = pathinfo($file, PATHINFO_FILENAME);
        $table->addRow([$modelName, !empty($config['models/' . $file]) && $config['models/' . $file] == md5(file_get_contents($path . '/' . $file)) ? '<b class="text-success">Нету</b>' : '<b class="text-danger">Есть</b>', ['class' => 'actionTd', 'html' => '<a class="btn btn-xs btn-success" href="/admin/modules/editModel/' . $module . '/' . $modelName . '"><i class="glyphicon glyphicon-edit"></i></a>' . ' <a class="btn btn-xs btn-danger" href="/admin/modules/delModel/' . $module . '/' . $modelName . '"><i class="glyphicon glyphicon-remove"></i></a>']]);
    }
}
$table->draw();
$table = new Ui\Table();
$table->name = 'Контроллеры';
$table->addButton(['href' => "/admin/modules/createController/{$module}", 'text' => 'Создать']);
$table->setCols(['Контроллер', 'Тип', 'Операции']);
$types = ['appControllers', 'appAdminControllers', 'Controllers'];
foreach ($types as $type) {
    if (file_exists($modulePath . '/' . $type)) {
        $files = array_slice(scandir($modulePath . '/' . $type), 2);
        foreach ($files as $file) {
            $table->addRow([pathinfo($file, PATHINFO_FILENAME), $type, ['class' => 'actionTd', 'html' => '<a class="btn btn-xs btn-success" href="/admin/modules/controllerEditor/' . $module . '/' . $type . '/' . pathinfo($file, PATHINFO_FILENAME) . '"><i class="glyphicon glyphicon-edit"></i></a>' . ' <a class="btn btn-xs btn-danger" href="/admin/modules/delController/' . $module . '/' . $type . '/' . pathinfo($file, PATHINFO_FILENAME) . '"><i class="glyphicon glyphicon-remove"></i></a>']]);
        }