Exemple #1
0
 public function render($tpl = null)
 {
     //authenticate the current user to make sure they are an admin
     UsersHelper::authenticateAdmin();
     //document
     $document = JFactory::getDocument();
     $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js');
     $document->addScript(JURI::base() . 'src/Cobalt/media/js/custom_manager.js');
     /** Menu Links **/
     $menu = MenuHelper::getMenuModules();
     $this->menu = $menu;
     //model
     $model = new DealCustomModel();
     //gather information for view
     $layout = $this->getLayout();
     $model->set("_layout", $layout);
     $this->pagination = $model->getPagination();
     if ($layout && $layout == 'edit') {
         //toolbar
         ToolbarHelper::cancel('cancel');
         ToolbarHelper::save('save');
         //assign view info
         $this->custom_types = DropdownHelper::getCustomTypes('deal');
         $this->custom = $model->getItem();
         if ($this->custom['type'] != null) {
             $document->addScriptDeclaration('var type = "' . $this->custom['type'] . '";');
         }
     } else {
         //buttons
         ToolbarHelper::addNew('edit');
         ToolbarHelper::editList('edit');
         ToolbarHelper::deleteList(TextHelper::_('COBALT_CONFIRMATION'), 'delete');
         //assign view info
         $custom = $model->getCustom();
         $this->custom_fields = $custom;
         // Initialise state variables.
         $state = $model->getState();
         $this->state = $state;
         $this->listOrder = $this->state->get('Dealcustom.filter_order');
         $this->listDirn = $this->state->get('Dealcustom.filter_order_Dir');
         $this->saveOrder = $this->listOrder == 'c.ordering';
     }
     //display
     return parent::render();
 }