Exemple #1
0
 public function render($tpl = null)
 {
     //authenticate the current user to make sure they are an admin
     UsersHelper::authenticateAdmin();
     // Create toolbar
     $this->toolbar = new Toolbar();
     //javascripts
     $document = JFactory::getDocument();
     $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js');
     /** Menu Links **/
     $menu = MenuHelper::getMenuModules();
     $this->menu = $menu;
     //gather information for view
     $model = new TemplatesModel();
     //get layout
     $layout = $this->getLayout();
     $model->set("_layout", $layout);
     //filter for layout type
     if ($layout == "edit") {
         //toolbar buttons
         $this->toolbar->cancel();
         $this->toolbar->save();
         //javascripts
         $document->addScript(JURI::base() . 'src/Cobalt/media/js/template_manager.js');
         //assign view data
         $this->template_types = DropdownHelper::getTemplateTypes();
         $this->template = $model->getTemplate();
     } else {
         //buttons
         $this->toolbar->addNew();
         ToolbarHelper::editList('edit');
         $this->toolbar->addDeleteRow();
         $templates = $model->getTemplates();
         $this->templates = $templates;
         // Initialise state variables.
         $state = $model->getState();
         $this->state = $state;
         $this->listOrder = $this->state->get('Templates.filter_order');
         $this->listDirn = $this->state->get('Templates.filter_order_Dir');
     }
     //display
     return parent::render();
 }