示例#1
0
 /**
  * Build an SQL query to load the list data.
  *
  * @return	JDatabaseQuery
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select($this->getState('list.select', 'a.id, a.title, a.note, a.position, a.module, a.language,' . 'a.checked_out, a.checked_out_time, a.published+2*(e.enabled-1) as published, a.access, a.ordering, a.publish_up, a.publish_down'));
     $query->from($db->quoteName('#__modules') . ' AS a');
     // Join over the language
     $query->select('l.title AS language_title');
     $query->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
     // Join over the users for the checked out user.
     $query->select('uc.name AS editor');
     $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
     // Join over the asset groups.
     $query->select('ag.title AS access_level');
     $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
     // Join over the module menus
     $query->select('MIN(mm.menuid) AS pages');
     $query->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = a.id');
     // Join over the extensions
     $query->select('e.name AS name');
     $query->join('LEFT', '#__extensions AS e ON e.element = a.module');
     $query->group('a.id, a.title, a.note, a.position, a.module, a.language,a.checked_out,' . 'a.checked_out_time, a.published, a.access, a.ordering,l.title, uc.name, ag.title, e.name,' . 'l.lang_code, uc.id, ag.id, mm.moduleid, e.element, a.publish_up, a.publish_down,e.enabled');
     // Filter by access level.
     if ($access = $this->getState('filter.access')) {
         $query->where('a.access = ' . (int) $access);
     }
     // Filter by client.
     $clientId = $this->getState('filter.client_id');
     if (is_numeric($clientId)) {
         $query->where('a.client_id = ' . (int) $clientId . ' AND e.client_id =' . (int) $clientId);
     }
     // Filter by template
     $template = $this->getState('filter.template');
     if ($template) {
         $listPosition = ModulesHelper::getPositionsByTemplate();
         if (!empty($listPosition)) {
             $query->where('a.position in (' . $listPosition . ')');
         }
     }
     // Filter by published state
     $state = $this->getState('filter.state');
     if (is_numeric($state)) {
         $query->where('a.published = ' . (int) $state);
     } elseif ($state === '') {
         $query->where('(a.published IN (0, 1))');
     }
     // Filter by position
     $position = $this->getState('filter.position');
     if ($position && $position != 'none') {
         $query->where('a.position = ' . $db->Quote($position));
     } elseif ($position == 'none') {
         $query->where('a.position = ' . $db->Quote(''));
     }
     // Filter by module
     $module = $this->getState('filter.module');
     if ($module) {
         $query->where('a.module = ' . $db->Quote($module));
     }
     // Filter by search in title
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('a.id = ' . (int) substr($search, 3));
         } else {
             $search = $db->Quote('%' . $db->escape($search, true) . '%');
             $query->where('(' . 'a.title LIKE ' . $search . ' OR a.note LIKE ' . $search . ')');
         }
     }
     // Filter on the language.
     if ($language = $this->getState('filter.language')) {
         $query->where('a.language = ' . $db->quote($language));
     }
     //echo nl2br(str_replace('#__','jos_',$query));
     return $query;
 }
示例#2
0
 /**
  * Get list of module position.
  *
  * @param   integer  $clientId  Client ID.
  *
  * @return  array
  */
 static function getPositions($clientId)
 {
     jimport('joomla.filesystem.folder');
     try {
         $app = JFactory::getApplication('administrator');
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('DISTINCT(position)');
         $query->from('#__modules');
         $query->where($db->quoteName('client_id') . ' = ' . (int) $clientId);
         $template = $app->getUserState('com_modules.modules.filter.template', null);
         if ($template) {
             $listPosition = ModulesHelper::getPositionsByTemplate();
             if (!empty($listPosition)) {
                 $query->where('position in (' . $listPosition . ')');
             }
         }
         $query->order('position');
         $db->setQuery($query);
         $positions = $db->loadColumn();
         $positions = is_array($positions) ? $positions : array();
     } catch (Exception $e) {
         throw $e;
     }
     // Build the list
     $options = array();
     foreach ($positions as $position) {
         if (!$position) {
             $options[] = JHtml::_('select.option', 'none', ':: ' . JText::_('JNONE') . ' ::');
         } else {
             $options[] = JHtml::_('select.option', $position, $position);
         }
     }
     return $options;
 }