コード例 #1
0
ファイル: edit.php プロジェクト: nickmancol/forkcms-rhcloud
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // load record
     $this->loadData();
     // add js
     $this->header->addJS('jstree/jquery.tree.js', null, false);
     $this->header->addJS('jstree/lib/jquery.cookie.js', null, false);
     $this->header->addJS('jstree/plugins/jquery.tree.cookie.js', null, false);
     // add css
     $this->header->addCSS('/backend/modules/pages/js/jstree/themes/fork/style.css', null, true);
     // get the templates
     $this->templates = BackendExtensionsModel::getTemplates();
     // set the default template as checked
     $this->templates[$this->record['template_id']]['checked'] = true;
     // homepage?
     if ($this->id == 1) {
         // loop and set disabled state
         foreach ($this->templates as &$row) {
             $row['disabled'] = $row['has_block'];
         }
     }
     // get the extras
     $this->extras = BackendExtensionsModel::getExtras();
     $this->loadForm();
     $this->loadDrafts();
     $this->loadRevisions();
     $this->validateForm();
     $this->parse();
     $this->display();
 }
コード例 #2
0
ファイル: add.php プロジェクト: naujasdizainas/forkcms
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // add js
     $this->header->addJS('jstree/jquery.tree.js');
     $this->header->addJS('jstree/lib/jquery.cookie.js');
     $this->header->addJS('jstree/plugins/jquery.tree.cookie.js');
     // add css
     $this->header->addCSS('/backend/modules/pages/js/jstree/themes/fork/style.css', null, true);
     // get the templates
     $this->templates = BackendExtensionsModel::getTemplates();
     $this->isGod = BackendAuthentication::getUser()->isGod();
     // init var
     $defaultTemplateId = BackendModel::getModuleSetting($this->getModule(), 'default_template', false);
     // fallback
     if ($defaultTemplateId === false) {
         // get first key
         $keys = array_keys($this->templates);
         // set the first items as default if no template was set as default.
         $defaultTemplateId = $this->templates[$keys[0]]['id'];
     }
     // set the default template as checked
     $this->templates[$defaultTemplateId]['checked'] = true;
     // get the extras
     $this->extras = BackendExtensionsModel::getExtras();
     $this->loadForm();
     $this->validateForm();
     $this->parse();
     $this->display();
 }
コード例 #3
0
 /**
  * Load the record
  */
 private function loadData()
 {
     // get record
     $this->id = $this->getParameter('id', 'int');
     // validate id
     if ($this->id === null || !BackendExtensionsModel::existsTemplate($this->id)) {
         $this->redirect(BackendModel::createURLForAction('theme_templates') . '&error=non-existing');
     }
     // get the record
     $this->record = BackendExtensionsModel::getTemplate($this->id);
     // unserialize
     $this->record['data'] = unserialize($this->record['data']);
     $this->names = $this->record['data']['names'];
     if (isset($this->record['data']['default_extras_' . BL::getWorkingLanguage()])) {
         $this->extras = $this->record['data']['default_extras_' . BL::getWorkingLanguage()];
     } elseif (isset($this->record['data']['default_extras'])) {
         $this->extras = $this->record['data']['default_extras'];
     }
     // assign
     $this->tpl->assign('template', $this->record);
     // is the template being used
     $inUse = BackendExtensionsModel::isTemplateInUse($this->id);
     // determine if deleting is allowed
     $deleteAllowed = true;
     if ($this->record['id'] == BackendModel::getModuleSetting('pages', 'default_template')) {
         $deleteAllowed = false;
     } elseif (count(BackendExtensionsModel::getTemplates()) == 1) {
         $deleteAllowed = false;
     } elseif ($inUse) {
         $deleteAllowed = false;
     } elseif (!BackendAuthentication::isAllowedAction('delete_theme_template')) {
         $deleteAllowed = false;
     }
     // assign
     $this->tpl->assign('inUse', $inUse);
     $this->tpl->assign('showExtensionsDeleteThemeTemplate', $deleteAllowed);
 }