Exemple #1
0
 /**
  * @param	int $clientId	The client id
  * @param	string $state 	The state of the template
  */
 public static function templates($clientId = 0, $state = '')
 {
     $templates = AdvancedModulesHelper::getTemplates($clientId, $state);
     foreach ($templates as $template) {
         $options[] = JHtml::_('select.option', $template->element, $template->name);
     }
     return $options;
 }
Exemple #2
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/modules.php';
     // Load the submenu.
     AdvancedModulesHelper::addSubmenu(JRequest::getCmd('view', 'modules'));
     $view = JRequest::getCmd('view', 'modules');
     $layout = JRequest::getCmd('layout', 'default');
     $id = JRequest::getInt('id');
     // Check for edit form.
     if ($view == 'module' && $layout == 'edit' && !$this->checkEditId('com_advancedmodules.edit.module', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(JRoute::_('index.php?option=com_advancedmodules&view=modules', false));
         return false;
     }
     parent::display();
 }
Exemple #3
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = AdvancedModulesHelper::getActions();
     JToolBarHelper::title(JText::_('AMM_ADVANCED_MODULES_MANAGER'), 'module.png');
     if ($canDo->get('core.create')) {
         //JToolBarHelper::addNew('module.add');
         $bar = JToolBar::getInstance('toolbar');
         $bar->appendButton('Popup', 'new', 'JTOOLBAR_NEW', 'index.php?option=com_advancedmodules&view=select&tmpl=component', 850, 400);
     }
     if ($canDo->get('core.edit')) {
         JToolBarHelper::editList('module.edit');
     }
     if ($canDo->get('core.create')) {
         JToolBarHelper::custom('modules.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::publish('modules.publish', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::unpublish('modules.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolBarHelper::divider();
         if (version_compare(JVERSION, '1.7.0', 'l')) {
             JToolBarHelper::custom('modules.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true);
         } else {
             JToolBarHelper::checkin('modules.checkin');
         }
     }
     if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'modules.delete', 'JTOOLBAR_EMPTY_TRASH');
         JToolBarHelper::divider();
     } else {
         if ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('modules.trash');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_advancedmodules');
         JToolBarHelper::divider();
     }
     JToolBarHelper::help('JHELP_EXTENSIONS_MODULE_MANAGER');
 }
Exemple #4
0
 /**
  * Method to get an array of data items.
  *
  * @return	mixed	An array of data items on success, false on failure.
  * @since	1.6
  */
 public function getItems()
 {
     if (!isset($this->items)) {
         $lang = JFactory::getLanguage();
         $search = $this->getState('filter.search');
         $state = $this->getState('filter.state');
         $clientId = $this->getState('filter.client_id');
         $filter_template = $this->getState('filter.template');
         $type = $this->getState('filter.type');
         $ordering = $this->getState('list.ordering');
         $direction = $this->getState('list.direction');
         $limitstart = $this->getState('list.start');
         $limit = $this->getState('list.limit');
         $client = JApplicationHelper::getClientInfo($clientId);
         if ($type != 'template') {
             // Get the database object and a new query object.
             $query = $this->_db->getQuery(true);
             $query->select('DISTINCT(position) as value');
             $query->from('#__modules');
             $query->where('`client_id` = ' . (int) $clientId);
             if ($search) {
                 $query->where('position LIKE ' . $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'));
             }
             $this->_db->setQuery($query);
             $positions = $this->_db->loadObjectList('value');
             // Check for a database error.
             if ($error = $this->_db->getErrorMsg()) {
                 $this->setError($error);
                 return false;
             }
             foreach ($positions as $value => $position) {
                 $positions[$value] = array();
             }
         } else {
             $positions = array();
         }
         // Load the positions from the installed templates.
         foreach (AdvancedModulesHelper::getTemplates($clientId) as $template) {
             $path = JPath::clean($client->path . '/templates/' . $template->element . '/templateDetails.xml');
             if (file_exists($path)) {
                 $xml = simplexml_load_file($path);
                 if (isset($xml->positions[0])) {
                     $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, $lang->getDefault(), false, false);
                     foreach ($xml->positions[0] as $position) {
                         $value = (string) $position['value'];
                         $label = (string) $position;
                         if (!$value) {
                             $value = $label;
                             $label = preg_replace('/[^a-zA-Z0-9_\\-]/', '_', 'TPL_' . $template->element . '_POSITION_' . $value);
                             $altlabel = preg_replace('/[^a-zA-Z0-9_\\-]/', '_', 'COM_MODULES_POSITION_' . $value);
                             if (!$lang->hasKey($label) && $lang->hasKey($altlabel)) {
                                 $label = $altlabel;
                             }
                         }
                         if ($type == 'user' || $state != '' && $state != $template->enabled) {
                             unset($positions[$value]);
                         } elseif (preg_match(chr(1) . $search . chr(1) . 'i', $value) && ($filter_template == '' || $filter_template == $template->element)) {
                             if (!isset($positions[$value])) {
                                 $positions[$value] = array();
                             }
                             $positions[$value][$template->name] = $label;
                         }
                     }
                 }
             }
         }
         $this->total = count($positions);
         if ($limitstart >= $this->total) {
             $limitstart = $limitstart < $limit ? 0 : $limitstart - $limit;
             $this->setState('list.start', $limitstart);
         }
         if ($ordering == 'value') {
             if ($direction == 'asc') {
                 ksort($positions);
             } else {
                 krsort($positions);
             }
         } else {
             if ($direction == 'asc') {
                 asort($positions);
             } else {
                 arsort($positions);
             }
         }
         $this->items = array_slice($positions, $limitstart, $limit ? $limit : null);
     }
     return $this->items;
 }
Exemple #5
0
				<option value=""><?php 
echo JText::_('COM_MODULES_OPTION_SELECT_POSITION');
?>
</option>
				<?php 
echo JHtml::_('select.options', AdvancedModulesHelper::getPositions($this->state->get('filter.client_id')), 'value', 'text', $this->state->get('filter.position'));
?>
			</select>

            <select name="filter_module" class="inputbox" onchange="this.form.submit()">
				<option value=""><?php 
echo JText::_('COM_MODULES_OPTION_SELECT_MODULE');
?>
</option>
				<?php 
echo JHtml::_('select.options', AdvancedModulesHelper::getModules($this->state->get('filter.client_id')), 'value', 'text', $this->state->get('filter.module'));
?>
			</select>



			<select name="filter_access" class="inputbox" onchange="this.form.submit()">
				<option value=""><?php 
echo JText::_('JOPTION_SELECT_ACCESS');
?>
</option>
				<?php 
echo JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'));
?>
			</select>
Exemple #6
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
     $canDo = AdvancedModulesHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
     $item = $this->get('Item');
     JToolBarHelper::title(JText::sprintf('AMM_MODULE_EDIT', JText::_($this->item->module)), 'module.png');
     // If not checked out, can save the item.
     if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
         JToolBarHelper::apply('module.apply');
         JToolBarHelper::save('module.save');
     }
     if (!$checkedOut && $canDo->get('core.create')) {
         if (version_compare(JVERSION, '1.7.0', 'l')) {
             JToolBarHelper::custom('module.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
         } else {
             JToolBarHelper::save2new('module.save2new');
         }
     }
     // If an existing item, can save to a copy.
     if (!$isNew && $canDo->get('core.create')) {
         if (version_compare(JVERSION, '1.7.0', 'l')) {
             JToolBarHelper::custom('module.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
         } else {
             JToolBarHelper::save2copy('module.save2copy');
         }
     }
     if (empty($this->item->id)) {
         JToolBarHelper::cancel('module.cancel');
     } else {
         JToolBarHelper::cancel('module.cancel', 'JTOOLBAR_CLOSE');
     }
     if ($canDo->get('core.admin')) {
         require_once JPATH_PLUGINS . DS . 'system' . DS . 'nonumberelements' . DS . 'helpers' . DS . 'parameters.php';
         $parameters =& NNParameters::getParameters();
         $config = JComponentHelper::getParams('com_advancedmodules');
         $config = $parameters->getParams($config->toObject(), JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advancedmodules' . DS . 'config.xml');
         if ($config->show_config_in_item) {
             JToolBarHelper::divider();
             JToolBarHelper::preferences('com_advancedmodules');
         }
     }
     // Get the help information for the menu item.
     $lang = JFactory::getLanguage();
     $help = $this->get('Help');
     if ($lang->hasKey($help->url)) {
         $debug = $lang->setDebug(false);
         $url = JText::_($help->url);
         $lang->setDebug($debug);
     } else {
         $url = null;
     }
     JToolBarHelper::divider();
     JToolBarHelper::help($help->key, false, $url);
 }