Beispiel #1
0
 protected function saveSettings()
 {
     if (version_compare(JVERSION, '2.5.0', 'ge')) {
         $this->checkPermissions();
         JRequest::checkToken() or jexit('Invalid Token');
         $data = JRequest::getVar('jform', array(), 'post', 'array');
         $id = JRequest::getInt('id');
         $option = JRequest::getCmd('component');
         // Joomla! 3.2 compatibility
         if (version_compare(JVERSION, '3.2', 'ge')) {
             require_once JPATH_SITE . '/components/com_config/model/cms.php';
             require_once JPATH_SITE . '/components/com_config/model/form.php';
         }
         // Validate the form
         JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/' . $option);
         $form = JForm::getInstance('com_sigpro.settings', 'config', array('control' => 'jform', 'load_data' => $loadData), false, '/config');
         JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_config/models');
         $model = JModelLegacy::getInstance('Component', 'ConfigModel');
         $params = $model->validate($form, $data);
         if ($params === false) {
             $errors = $model->getErrors();
             $response = new stdClass();
             $response->message = $errors[0] instanceof Exception ? $errors[0]->getMessage() : $errors[0];
             $response->type = 'warning';
             return $response;
         }
         $data = array('params' => $params, 'id' => $id, 'option' => $option);
     } else {
         JRequest::checkToken() or jexit('Invalid Token');
         $data = JRequest::get('post');
     }
     $model = SigProModel::getInstance('Settings', 'SigProModel');
     $model->setState('option', 'com_sigpro');
     $model->setState('data', $data);
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $options = array('defaultgroup' => '_system', 'cachebase' => JPATH_ADMINISTRATOR . '/cache');
         $cache = JCache::getInstance('callback', $options);
         $cache->clean();
     }
     $response = new stdClass();
     if ($model->save()) {
         $response->message = JText::_('COM_SIGPRO_SETTINGS_SAVED');
         $response->type = 'message';
     } else {
         $response->message = $model->getError();
         $response->type = 'error';
     }
     return $response;
 }
Beispiel #2
0
 public function display($tpl = null)
 {
     $model = SigProModel::getInstance('Galleries', 'SigProModel');
     $model->setState('limit', $this->limit);
     $model->setState('limitstart', $this->limitstart);
     $model->setState('sorting', $this->sorting);
     $model->setState('type', $this->type);
     $galleries = $model->getData();
     $this->assignRef('rows', $galleries);
     jimport('joomla.html.pagination');
     $total = $model->getState('total');
     $this->assignRef('total', $total);
     $pagination = new JPagination($total, $this->limitstart, $this->limit);
     $this->assignRef('pagination', $pagination);
     if ($this->type == 'k2') {
         $frameSrc = 'index.php?option=com_k2&view=items&task=element&tmpl=component&limit=10';
         $frameHeight = 450;
         $frameClass = 'sigProModalK2ItemsFrame';
     } else {
         $frameSrc = 'index.php?option=com_sigpro&view=galleries&task=add&tmpl=component&editorName=' . $this->editorName . '&type=' . $this->type . '&parentTmpl=' . $this->tmpl;
         $frameHeight = 50;
         $frameClass = 'sigProModalAddGalleryFrame';
     }
     if ($this->template) {
         $frameSrc .= '&template=' . $this->template;
     }
     $frameSrc = JRoute::_($frameSrc);
     $this->assignRef('frameSrc', $frameSrc);
     $this->assignRef('frameHeight', $frameHeight);
     $this->assignRef('frameClass', $frameClass);
     $options = array();
     $options[] = JHTML::_('select.option', 'folder ASC', JText::_('COM_SIGPRO_FOLDER_NAME_ASC'));
     $options[] = JHTML::_('select.option', 'folder DESC', JText::_('COM_SIGPRO_FOLDER_NAME_DESC'));
     $options[] = JHTML::_('select.option', 'modified ASC', JText::_('COM_SIGPRO_MODIFIED_DATE_ASC'));
     $options[] = JHTML::_('select.option', 'modified DESC', JText::_('COM_SIGPRO_MODIFIED_DATE_DESC'));
     $lists = array();
     $lists['sorting'] = JHTML::_('select.genericlist', $options, 'sorting', 'onchange="this.form.submit();"', 'value', 'text', $this->sorting);
     $this->assignRef('lists', $lists);
     parent::display($tpl);
 }