Exemple #1
0
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $ordering = $this->getState('list.ordering', 'ordering');
     if (in_array($ordering, array('pages', 'name'))) {
         $this->_db->setQuery($query);
         $result = $this->_db->loadObjectList();
         $this->translate($result);
         $lang = JFactory::getLanguage();
         JArrayHelper::sortObjects($result, $ordering, $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     } else {
         if ($ordering == 'ordering') {
             $query->order('position ASC');
         }
         $query->order($this->_db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
         if ($ordering == 'position') {
             $query->order('ordering ASC');
         }
         $result = parent::_getList($query, $limitstart, $limit);
         $this->translate($result);
         return $result;
     }
 }
 /**
  * Returns an object list
  *
  * @param	string The query
  * @param	int Offset
  * @param	int The number of records
  * @return	array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $ordering = $this->getState('list.ordering');
     $search = $this->getState('filter.search');
     // Replace slashes so preg_match will work
     $search = str_replace('/', ' ', $search);
     $db = $this->getDbo();
     if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) {
         $db->setQuery($query);
         $result = $db->loadObjectList();
         $lang = JFactory::getLanguage();
         $this->translate($result);
         if (!empty($search)) {
             foreach ($result as $i => $item) {
                 if (!preg_match("/{$search}/i", $item->name)) {
                     unset($result[$i]);
                 }
             }
         }
         JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     } else {
         $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
         $result = parent::_getList($query, $limitstart, $limit);
         $this->translate($result);
         return $result;
     }
 }
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $items = parent::_getList($query, $limitstart, $limit);
     if ($items === null) {
         return $items;
     }
     $tmp = array();
     foreach ($items as $item) {
         $table = JTable::getInstance('GCalendar', 'GCalendarTable');
         $table->load($item->id);
         $tmp[] = $table;
     }
     return $tmp;
 }
 /**
  * Returns an object list
  *
  * @param   string  $query       The query
  * @param   int     $limitstart  Offset
  * @param   int     $limit       The number of records
  *
  * @return  array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $listOrder = $this->getState('list.ordering', 'name');
     $listDirn = $this->getState('list.direction', 'asc');
     // Replace slashes so preg_match will work
     $search = $this->getState('filter.search');
     $search = str_replace('/', ' ', $search);
     $db = $this->getDbo();
     // Process ordering and pagination.
     if (in_array($listOrder, array('name', 'client_translated', 'type_translated', 'folder_translated')) || !empty($search) && stripos($search, 'id:') !== 0) {
         $db->setQuery($query);
         $result = $db->loadObjectList();
         $this->translate($result);
         // Search in the name.
         if (!empty($search)) {
             $escapedSearchString = $this->refineSearchStringToRegex($search, '/');
             foreach ($result as $i => $item) {
                 if (!preg_match("/{$escapedSearchString}/i", $item->name)) {
                     unset($result[$i]);
                 }
             }
         }
         // Sort array object by selected ordering and selected direction. Sort is case insensative and using locale sorting.
         $result = ArrayHelper::sortObjects($result, $listOrder, strtolower($listDirn) == 'desc' ? -1 : 1, false, true);
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     }
     $query->order($db->quoteName($listOrder) . ' ' . $db->escape($listDirn));
     $result = parent::_getList($query, $limitstart, $limit);
     $this->translate($result);
     return $result;
 }
Exemple #5
0
 /**
  * Returns an object list
  *
  * @param   string The query
  * @param   int    Offset
  * @param   int    The number of records
  * @return  array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $search = $this->getState('filter.search');
     $ordering = $this->getState('list.ordering', 'ordering');
     if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) {
         $this->_db->setQuery($query);
         $result = $this->_db->loadObjectList();
         $this->translate($result);
         if (!empty($search)) {
             foreach ($result as $i => $item) {
                 if (!preg_match("/{$search}/i", $item->name)) {
                     unset($result[$i]);
                 }
             }
         }
         $direction = $this->getState('list.direction') == 'desc' ? -1 : 1;
         JArrayHelper::sortObjects($result, $ordering, $direction, true, true);
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     } else {
         if ($ordering == 'ordering') {
             $query->order('a.folder ASC');
             $ordering = 'a.ordering';
         }
         $query->order($this->_db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
         if ($ordering == 'folder') {
             $query->order('a.ordering ASC');
         }
         $result = parent::_getList($query, $limitstart, $limit);
         $this->translate($result);
         return $result;
     }
 }
Exemple #6
0
 /**
  * Returns an object list
  *
  * @param   string $query      The query
  * @param   int    $limitstart Offset
  * @param   int    $limit      The number of records
  *
  * @return  array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $ordering = strtolower($this->getState('list.ordering', 'ordering'));
     $orderDirn = strtoupper($this->getState('list.direction', 'ASC'));
     if (in_array($ordering, array('pages', 'name'))) {
         $this->_db->setQuery($query);
         $result = $this->_db->loadObjectList();
         $this->translate($result);
         JArrayHelper::sortObjects($result, $ordering, $orderDirn == 'DESC' ? -1 : 1, true, true);
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     }
     if ($ordering != 'color') {
         if ($ordering == 'ordering') {
             $query->order('a.position ASC');
             $ordering = 'a.ordering';
         }
         if ($ordering == 'language_title') {
             $ordering = 'l.title';
         }
         $query->order($this->_db->quoteName($ordering) . ' ' . $orderDirn);
         if ($ordering == 'position') {
             $query->order('a.ordering ASC');
         }
         $result = parent::_getList($query, $limitstart, $limit);
         $this->translate($result);
         return $result;
     }
     $this->_db->setQuery($query);
     $result = $this->_db->loadObjectList();
     $this->translate($result);
     $newresult = array();
     foreach ($result as $i => $row) {
         $params = json_decode($row->advancedparams);
         if (is_null($params)) {
             $params = new stdClass();
         }
         $color = isset($params->color) ? str_replace('#', '', $params->color) : 'none';
         $color = empty($color) ? 'none' : $color;
         $newresult['_' . $color . '_' . ($i + 1) / 10000] = $row;
     }
     if ($orderDirn == 'DESC') {
         krsort($newresult);
     } else {
         ksort($newresult);
     }
     $newresult = array_values($newresult);
     $total = count($newresult);
     $this->cache[$this->getStoreId('getTotal')] = $total;
     if ($total < $limitstart) {
         $limitstart = 0;
         $this->setState('list.start', 0);
     }
     return array_slice($newresult, $limitstart, $limit ? $limit : null);
 }
 /**
  * Returns an object list
  *
  * @param   string  $query       The query
  * @param   int     $limitstart  Offset
  * @param   int     $limit       The number of records
  *
  * @return  array
  *
  * @since   3.5
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $db = $this->getDbo();
     $listOrder = $this->getState('list.ordering', 'u.name');
     $listDirn = $this->getState('list.direction', 'asc');
     // Process ordering.
     if (in_array($listOrder, array('client_translated', 'folder_translated', 'type_translated'))) {
         $db->setQuery($query);
         $result = $db->loadObjectList();
         $this->translate($result);
         $result = ArrayHelper::sortObjects($result, $listOrder, strtolower($listDirn) === 'desc' ? -1 : 1, true, true);
         $total = count($result);
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     } else {
         $query->order($db->quoteName($listOrder) . ' ' . $db->escape($listDirn));
         $result = parent::_getList($query, $limitstart, $limit);
         $this->translate($result);
         return $result;
     }
 }
Exemple #8
0
 /**
  * Returns an object list
  *
  * @param   string  $query       The query
  * @param   int     $limitstart  Offset
  * @param   int     $limit       The number of records
  *
  * @return  array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $listOrder = $this->getState('list.ordering', 'a.position');
     $listDirn = $this->getState('list.direction', 'asc');
     // If ordering by fields that need translate we need to sort the array of objects after translating them.
     if (in_array($listOrder, array('pages', 'name'))) {
         // Fetch the results.
         $this->_db->setQuery($query);
         $result = $this->_db->loadObjectList();
         // Translate the results.
         $this->translate($result);
         // Sort the array of translated objects.
         $result = ArrayHelper::sortObjects($result, $listOrder, strtolower($listDirn) == 'desc' ? -1 : 1, true, true);
         // Process pagination.
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     }
     // If ordering by fields that doesn't need translate just order the query.
     if ($listOrder === 'a.ordering') {
         $query->order($this->_db->quoteName('a.position') . ' ASC')->order($this->_db->quoteName($listOrder) . ' ' . $this->_db->escape($listDirn));
     } elseif ($listOrder === 'a.position') {
         $query->order($this->_db->quoteName($listOrder) . ' ' . $this->_db->escape($listDirn))->order($this->_db->quoteName('a.ordering') . ' ASC');
     } else {
         $query->order($this->_db->quoteName($listOrder) . ' ' . $this->_db->escape($listDirn));
     }
     // Process pagination.
     $result = parent::_getList($query, $limitstart, $limit);
     // Translate the results.
     $this->translate($result);
     return $result;
 }
Exemple #9
0
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $result = parent::_getList($query, $limitstart, $limit);
     $odd = 1;
     foreach ($result as $k => $row) {
         $result[$k]->odd = $odd;
         $odd = 1 - $odd;
     }
     return $result;
 }
Exemple #10
0
 /**
  * Returns an object list
  *
  * @param   JDatabaseQuery $query      The query
  * @param   int            $limitstart Offset
  * @param   int            $limit      The number of records
  *
  * @return  array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $search = $this->getState('filter.name') ? $this->getState('filter.name') : $this->getState('filter.search');
     $ordering = $this->getState('list.ordering', 'ordering');
     if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) {
         $this->_db->setQuery($query);
         $result = $this->_db->loadObjectList();
         $this->translate($result);
         if (!empty($search)) {
             foreach ($result as $i => $item) {
                 if (!preg_match("/{$search}/i", $item->name)) {
                     unset($result[$i]);
                 }
             }
         }
         $lang = JFactory::getLanguage();
         $direction = $this->getState('list.direction') == 'desc' ? -1 : 1;
         JArrayHelper::sortObjects($result, $ordering, $direction, true, $lang->getLocale());
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     } else {
         // Add the list ordering clause.
         $direction = strtoupper($this->state->get('list.direction'));
         switch ($this->state->get('list.ordering')) {
             case 'ordering':
                 $query->order('a.ordering ' . $direction);
                 break;
             case 'enabled':
                 $query->order('a.enabled ' . $direction);
                 break;
             case 'element':
                 $query->order('a.element ' . $direction);
                 break;
             case 'access':
                 $query->order('a.access ' . $direction);
                 break;
             default:
                 $query->order('a.extension_id ' . $direction);
         }
         $result = parent::_getList($query, $limitstart, $limit);
         $this->translate($result);
         return $result;
     }
 }
Exemple #11
0
 /**
  * Returns an object list
  *
  * @param   string  $query       The query
  * @param   int     $limitstart  Offset
  * @param   int     $limit       The number of records
  *
  * @return  array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $listOrder = $this->getState('list.ordering', 'name');
     $listDirn = $this->getState('list.direction', 'asc');
     // Replace slashes so preg_match will work
     $search = $this->getState('filter.search');
     $search = str_replace('/', ' ', $search);
     $db = $this->getDbo();
     // Define which fields have to be processed in a custom way because of translation.
     $customOrderFields = array('name', 'client_translated', 'type_translated', 'folder_translated');
     // Process searching, ordering and pagination for fields that need to be translated.
     if (in_array($listOrder, $customOrderFields) || !empty($search) && stripos($search, 'id:') !== 0) {
         // Get results from database and translate them.
         $db->setQuery($query);
         $result = $db->loadObjectList();
         $this->translate($result);
         // Process searching.
         if (!empty($search) && stripos($search, 'id:') !== 0) {
             $escapedSearchString = $this->refineSearchStringToRegex($search, '/');
             // By default search only the extension name field.
             $searchFields = array('name');
             // If in update sites view search also in the update site name field.
             if ($this instanceof InstallerModelUpdatesites) {
                 $searchFields[] = 'update_site_name';
             }
             foreach ($result as $i => $item) {
                 // Check if search string exists in any of the fields to be searched.
                 $found = 0;
                 foreach ($searchFields as $key => $field) {
                     if (!$found && preg_match('/' . $escapedSearchString . '/i', $item->{$field})) {
                         $found = 1;
                     }
                 }
                 // If search string was not found in any of the fields searched remove it from results array.
                 if (!$found) {
                     unset($result[$i]);
                 }
             }
         }
         // Process ordering.
         // Sort array object by selected ordering and selected direction. Sort is case insensative and using locale sorting.
         $result = ArrayHelper::sortObjects($result, $listOrder, strtolower($listDirn) == 'desc' ? -1 : 1, false, true);
         // Process pagination.
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     }
     // Process searching, ordering and pagination for regular database fields.
     $query->order($db->quoteName($listOrder) . ' ' . $db->escape($listDirn));
     $result = parent::_getList($query, $limitstart, $limit);
     $this->translate($result);
     return $result;
 }
Exemple #12
0
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $result = parent::_getList($query, $limitstart, $limit);
     if (is_array($result)) {
         foreach ($result as $field) {
             $field->fieldparams = new Registry($field->fieldparams);
             $field->params = new Registry($field->params);
         }
     }
     return $result;
 }
Exemple #13
0
 function _getList($query, $limitstart = 0, $limit = 0)
 {
     return parent::_getList($query, $limitstart, 10);
     // Just to set the limit for the dashboard.
 }
Exemple #14
0
 /**
  * Returns an object list
  *
  * @param	string The query
  * @param	int Offset
  * @param	int The number of records
  * @return	array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $ordering = $this->getState('list.ordering', 'ordering');
     if (in_array($ordering, array('pages', 'name'))) {
         $this->_db->setQuery($query);
         $result = $this->_db->loadObjectList();
         $this->translate($result);
         $lang = JFactory::getLanguage();
         JArrayHelper::sortObjects($result, $ordering, $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     } else {
         if ($ordering == 'color') {
             $this->_db->setQuery($query);
             $result = $this->_db->loadObjectList();
             $this->translate($result);
             $newresult = array();
             foreach ($result as $i => $row) {
                 $registry = new JRegistry();
                 $registry->loadString($row->advancedparams);
                 $params = $registry->toObject();
                 $color = isset($params->color) ? strtolower($params->color) : '';
                 $newresult[$color . '_' . ($i + 1) / 10000] = $row;
             }
             if ($this->getState('list.direction') == 'desc') {
                 krsort($newresult);
             } else {
                 ksort($newresult);
             }
             $total = count($newresult);
             $this->cache[$this->getStoreId('getTotal')] = $total;
             if ($total < $limitstart) {
                 $limitstart = 0;
                 $this->setState('list.start', 0);
             }
             return array_slice($newresult, $limitstart, $limit ? $limit : null);
         } else {
             if ($ordering == 'ordering') {
                 $query->order('a.position ASC');
                 $ordering = 'a.ordering';
             }
             if ($ordering == 'language_title') {
                 $ordering = 'l.title';
             }
             $query->order($this->_db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
             if ($ordering == 'position') {
                 $query->order('a.ordering ASC');
             }
             $result = parent::_getList($query, $limitstart, $limit);
             $this->translate($result);
             return $result;
         }
     }
 }