diff --git a/administrator/components/com_installer/models/forms/filter_update.xml b/administrator/components/com_installer/models/forms/filter_update.xml index 667c6a5e00fda..e319957e48c90 100644 --- a/administrator/components/com_installer/models/forms/filter_update.xml +++ b/administrator/components/com_installer/models/forms/filter_update.xml @@ -1,46 +1,64 @@
-
+
- - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/administrator/components/com_installer/models/update.php b/administrator/components/com_installer/models/update.php index f80fd575f238e..1df7f560869f9 100644 --- a/administrator/components/com_installer/models/update.php +++ b/administrator/components/com_installer/models/update.php @@ -11,6 +11,8 @@ jimport('joomla.updater.update'); +use Joomla\Utilities\ArrayHelper; + /** * Installer Update Model * @@ -31,13 +33,11 @@ public function __construct($config = array()) if (empty($config['filter_fields'])) { $config['filter_fields'] = array( - 'name', - 'client_id', - 'type', - 'folder', - 'extension_id', - 'update_id', - 'update_site_id', + 'name', 'u.name', + 'client_id', 'u.client_id', 'client_translated', + 'type', 'u.type', 'type_translated', + 'folder', 'u.folder', 'folder_translated', + 'extension_id', 'u.extension_id', ); } @@ -56,28 +56,23 @@ public function __construct($config = array()) * * @since 1.6 */ - protected function populateState($ordering = null, $direction = null) + protected function populateState($ordering = 'u.name', $direction = 'asc') { - $app = JFactory::getApplication(); - $value = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); - $this->setState('filter.search', $value); - - $clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', ''); - $this->setState('filter.client_id', $clientId); + $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string')); + $this->setState('filter.client_id', $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', null, 'int')); + $this->setState('filter.type', $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string')); + $this->setState('filter.folder', $this->getUserStateFromRequest($this->context . '.filter.folder', 'filter_folder', '', 'string')); - $categoryId = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', ''); - $this->setState('filter.type', $categoryId); - - $group = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group', ''); - $this->setState('filter.group', $group); + // Extension id is a special filter case to check updates for extension id, also could use filter[search]=eid:XX + $this->setState('filter.extension_id', $this->getUserStateFromRequest($this->context . '.filter.extension_id', 'filter_extension_id', null, 'int')); + $app = JFactory::getApplication(); $this->setState('message', $app->getUserState('com_installer.message')); $this->setState('extension_message', $app->getUserState('com_installer.extension_message')); $app->setUserState('com_installer.message', ''); $app->setUserState('com_installer.extension_message', ''); - $this->setState('list.ordering', 'name'); - parent::populateState('name', 'asc'); + parent::populateState($ordering, $direction); } /** @@ -90,58 +85,140 @@ protected function populateState($ordering = null, $direction = null) protected function getListQuery() { $db = $this->getDbo(); - $query = $db->getQuery(true); - $type = $this->getState('filter.type'); - $client = $this->getState('filter.client_id'); - $group = $this->getState('filter.group'); // Grab updates ignoring new installs $query = $db->getQuery(true) ->select('u.*') - ->select('e.manifest_cache') + ->select($db->quoteName('e.manifest_cache')) ->from($db->quoteName('#__updates', 'u')) ->join('LEFT', $db->quoteName('#__extensions', 'e') . ' ON ' . $db->quoteName('e.extension_id') . ' = ' . $db->quoteName('u.extension_id')) - ->where($db->quoteName('u.extension_id') . ' != 0') - ->order($db->quoteName('u.' . $this->getState('list.ordering')) . ' ' . $this->getState('list.direction')); + ->where($db->quoteName('u.extension_id') . ' != ' . $db->quote(0)); + + // Process select filters. + $clientId = $this->getState('filter.client_id'); + $type = $this->getState('filter.type'); + $folder = $this->getState('filter.folder'); + $extensionId = $this->getState('filter.extension_id'); if ($type) { - $query->where('u.type = ' . $db->quote($type)); + $query->where($db->quoteName('u.type') . ' = ' . $db->quote($type)); } - if ($client != '') + if ($clientId != '') { - $query->where('u.client_id = ' . intval($client)); + $query->where($db->quoteName('u.client_id') . ' = ' . (int) $clientId); } - if ($group != '' && in_array($type, array('plugin', 'library', ''))) + if ($folder != '' && in_array($type, array('plugin', 'library', ''))) { - $query->where('u.folder = ' . $db->quote($group == '*' ? '' : $group)); + $query->where($db->quoteName('u.folder') . ' = ' . $db->quote($folder == '*' ? '' : $folder)); } - // Filter by extension_id - if ($eid = $this->getState('filter.extension_id')) + if ($extensionId) { - $query->where($db->quoteName('u.extension_id') . ' = ' . $db->quote((int) $eid)); - } - else - { - $query->where($db->quoteName('u.extension_id') . ' != ' . $db->quote(0)) - ->where($db->quoteName('u.extension_id') . ' != ' . $db->quote(700)); + $query->where($db->quoteName('u.extension_id') . ' = ' . $db->quote((int) $extensionId)); } - // Filter by search + // Process search filter. $search = $this->getState('filter.search'); if (!empty($search)) { - $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%')); - $query->where('u.name LIKE ' . $search); + if (stripos($search, 'eid:') !== false) + { + $query->where($db->quoteName('u.extension_id') . ' = ' . (int) substr($search, 4)); + } + else + { + if (stripos($search, 'uid:') !== false) + { + $query->where($db->quoteName('u.update_site_id') . ' = ' . (int) substr($search, 4)); + } + elseif (stripos($search, 'id:') !== false) + { + $query->where($db->quoteName('u.update_id') . ' = ' . (int) substr($search, 3)); + } + else + { + $query->where($db->quoteName('u.name') . ' LIKE ' . $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true)) . '%')); + } + $query->where($db->quoteName('u.extension_id') . ' != ' . $db->quote(700)); + } } return $query; } + /** + * Translate a list of objects + * + * @param array &$items The array of objects + * + * @return array The array of translated objects + * + * @since __DEPLOY_VERSION__ + */ + protected function translate(&$items) + { + foreach ($items as &$item) + { + $item->client_translated = $item->client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE'); + $manifest = json_decode($item->manifest_cache); + $item->current_version = isset($manifest->version) ? $manifest->version : JText::_('JLIB_UNKNOWN'); + $item->type_translated = JText::_('COM_INSTALLER_TYPE_' . strtoupper($item->type)); + $item->folder_translated = $item->folder ? $item->folder : JText::_('COM_INSTALLER_TYPE_NONAPPLICABLE'); + $item->install_type = $item->extension_id ? JText::_('COM_INSTALLER_MSG_UPDATE_UPDATE') : JText::_('COM_INSTALLER_NEW_INSTALL'); + } + + return $items; + } + + /** + * Returns an object list + * + * @param string $query The query + * @param int $limitstart Offset + * @param int $limit The number of records + * + * @return array + * + * @since __DEPLOY_VERSION__ + */ + 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; + } + } + /** * Get the count of disabled update sites * @@ -154,9 +231,9 @@ public function getDisabledUpdateSites() $db = $this->getDbo(); $query = $db->getQuery(true) - ->select('count(*)') - ->from('#__update_sites') - ->where('enabled = 0'); + ->select('COUNT(*)') + ->from($db->quoteName('#__update_sites')) + ->where($db->quoteName('enabled') . ' = 0'); $db->setQuery($query); @@ -179,8 +256,7 @@ public function findUpdates($eid = 0, $cache_timeout = 0, $minimum_stability = J // Purge the updates list $this->purge(); - $updater = JUpdater::getInstance(); - $updater->findUpdates($eid, $cache_timeout, $minimum_stability); + JUpdater::getInstance()->findUpdates($eid, $cache_timeout, $minimum_stability); return true; } @@ -229,9 +305,9 @@ public function enableSites() { $db = $this->getDbo(); $query = $db->getQuery(true) - ->update('#__update_sites') - ->set('enabled = 1') - ->where('enabled = 0'); + ->update($db->quoteName('#__update_sites')) + ->set($db->quoteName('enabled') . ' = 1') + ->where($db->quoteName('enabled') . ' = 0'); $db->setQuery($query); if (!$db->execute()) @@ -420,7 +496,7 @@ public function getForm($data = array(), $loadData = true) protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState($this->context . '.data', array()); + $data = JFactory::getApplication()->getUserState($this->context, array()); return $data; } diff --git a/administrator/components/com_installer/views/update/tmpl/default.php b/administrator/components/com_installer/views/update/tmpl/default.php index 9ea5fb3b890d4..31fbdd6763a69 100644 --- a/administrator/components/com_installer/views/update/tmpl/default.php +++ b/administrator/components/com_installer/views/update/tmpl/default.php @@ -17,121 +17,121 @@ $listDirn = $this->escape($this->state->get('list.direction')); ?>
-
-
- sidebar; ?> -
-
- - showMessage) : ?> - loadTemplate('message'); ?> - + + sidebar)) : ?> +
+ sidebar; ?> +
+
+ +
+ + showMessage) : ?> + loadTemplate('message'); ?> + - ftp) : ?> - loadTemplate('ftp'); ?> - - $this)); ?> + ftp) : ?> + loadTemplate('ftp'); ?> + - - items)) : ?> - - - - - - - - - - - - - - - - - - - - - items as $i => $item) : ?> - client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE'); - $manifest = json_decode($item->manifest_cache); - $current_version = isset($manifest->version) ? $manifest->version : JText::_('JLIB_UNKNOWN'); - ?> - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- pagination->getListFooter(); ?> -
- update_id); ?> - - - - extension_id ? JText::_('COM_INSTALLER_MSG_UPDATE_UPDATE') : JText::_('COM_INSTALLER_NEW_INSTALL') ?> - - type) ?> - - - - version; ?> - - folder != '' ? $item->folder : JText::_('COM_INSTALLER_TYPE_NONAPPLICABLE'); ?> - - - detailsurl ?> - infourl)) : ?> -
- - escape($item->infourl); ?> - - -
- + $this)); ?> +
+ items)) : ?>
- ×
- - + + + + + + + + + + + + + + + + + + + + + + items as $i => $item) : ?> + client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE'); + $manifest = json_decode($item->manifest_cache); + $current_version = isset($manifest->version) ? $manifest->version : JText::_('JLIB_UNKNOWN'); + ?> + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ pagination->getListFooter(); ?> +
+ update_id); ?> + + + + client_translated; ?> + + type_translated; ?> + + current_version; ?> + + version; ?> + + folder_translated; ?> + + install_type; ?> + + + detailsurl; ?> + infourl)) : ?> +
+ escape($item->infourl); ?> + +
+
+ - -
diff --git a/administrator/components/com_installer/views/update/view.html.php b/administrator/components/com_installer/views/update/view.html.php index 11e363b74508e..325e3a5a91b8a 100644 --- a/administrator/components/com_installer/views/update/view.html.php +++ b/administrator/components/com_installer/views/update/view.html.php @@ -50,13 +50,11 @@ class InstallerViewUpdate extends InstallerViewDefault */ public function display($tpl = null) { - $app = JFactory::getApplication(); - // Get data from the model. - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->filterForm = $this->get('FilterForm'); + $this->state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); $paths = new stdClass; @@ -66,7 +64,7 @@ public function display($tpl = null) if (count($this->items) > 0) { - $app->enqueueMessage(JText::_('COM_INSTALLER_MSG_WARNINGS_UPDATE_NOTICE'), 'notice'); + JFactory::getApplication()->enqueueMessage(JText::_('COM_INSTALLER_MSG_WARNINGS_UPDATE_NOTICE'), 'notice'); } parent::display($tpl); diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index 3aaa71a514ea5..3412f9c027f70 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -38,11 +38,19 @@ COM_INSTALLER_HEADING_CLIENT="Client" COM_INSTALLER_HEADING_DETAILS_URL="Details URL" COM_INSTALLER_HEADING_DETAILSURL="URL Details" COM_INSTALLER_HEADING_FOLDER="Folder" +COM_INSTALLER_HEADING_FOLDER_ASC="Folder ascending" +COM_INSTALLER_HEADING_FOLDER_DESC="Folder descending" COM_INSTALLER_HEADING_ID="ID" COM_INSTALLER_HEADING_INSTALLTYPE="Install Type" COM_INSTALLER_HEADING_LOCATION="Location" +COM_INSTALLER_HEADING_LOCATION_ASC="Location ascending" +COM_INSTALLER_HEADING_LOCATION_DESC="Location descending" COM_INSTALLER_HEADING_NAME="Name" +COM_INSTALLER_HEADING_NAME_ASC="Name ascending" +COM_INSTALLER_HEADING_NAME_DESC="Name descending" COM_INSTALLER_HEADING_TYPE="Type" +COM_INSTALLER_HEADING_TYPE_ASC="Type ascending" +COM_INSTALLER_HEADING_TYPE_DESC="Type descending" COM_INSTALLER_HEADING_UPDATESITE_NAME="Update Site" COM_INSTALLER_HEADING_UPDATESITEID="ID" COM_INSTALLER_INSTALL_BUTTON="Install"