From 2c4cf44b247ef0e5bbde078271fd4af0e60e4a9c Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Fri, 13 Jun 2014 20:29:02 +0300 Subject: [PATCH 01/12] Adding update site management to com_installer --- .../com_installer/controllers/updatesites.php | 84 ++++++++ .../com_installer/helpers/installer.php | 5 + .../com_installer/models/updatesites.php | 186 ++++++++++++++++++ .../views/updatesites/index.html | 1 + .../views/updatesites/tmpl/default.php | 129 ++++++++++++ .../views/updatesites/tmpl/index.html | 1 + .../views/updatesites/view.html.php | 118 +++++++++++ .../language/en-GB/en-GB.com_installer.ini | 8 + administrator/language/en-GB/en-GB.ini | 1 + language/en-GB/en-GB.lib_joomla.ini | 1 + libraries/joomla/table/updatesite.php | 80 ++++++++ 11 files changed, 614 insertions(+) create mode 100644 administrator/components/com_installer/controllers/updatesites.php create mode 100644 administrator/components/com_installer/models/updatesites.php create mode 100644 administrator/components/com_installer/views/updatesites/index.html create mode 100644 administrator/components/com_installer/views/updatesites/tmpl/default.php create mode 100644 administrator/components/com_installer/views/updatesites/tmpl/index.html create mode 100644 administrator/components/com_installer/views/updatesites/view.html.php create mode 100644 libraries/joomla/table/updatesite.php diff --git a/administrator/components/com_installer/controllers/updatesites.php b/administrator/components/com_installer/controllers/updatesites.php new file mode 100644 index 0000000000000..e4b5f52b9f5c9 --- /dev/null +++ b/administrator/components/com_installer/controllers/updatesites.php @@ -0,0 +1,84 @@ +registerTask('unpublish', 'publish'); + $this->registerTask('publish', 'publish'); + } + + /** + * Enable/Disable an extension (if supported). + * + * @return void + * + * @since 3.4 + */ + public function publish() + { + // Check for request forgeries. + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + $ids = $this->input->get('cid', array(), 'array'); + $values = array('publish' => 1, 'unpublish' => 0); + $task = $this->getTask(); + $value = JArrayHelper::getValue($values, $task, 0, 'int'); + + if (empty($ids)) + { + JError::raiseWarning(500, JText::_('COM_INSTALLER_ERROR_NO_UPDATESITES_SELECTED')); + } + else + { + // Get the model. + $model = $this->getModel('Updatesites'); + + // Change the state of the records. + if (!$model->publish($ids, $value)) + { + JError::raiseWarning(500, implode('
', $model->getErrors())); + } + else + { + if ($value == 1) + { + $ntext = 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED'; + } + elseif ($value == 0) + { + $ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED'; + } + $this->setMessage(JText::plural($ntext, count($ids))); + } + } + + $this->setRedirect(JRoute::_('index.php?option=com_installer&view=updatesites', false)); + } +} diff --git a/administrator/components/com_installer/helpers/installer.php b/administrator/components/com_installer/helpers/installer.php index 2a30c544f05b4..fa1dffaf5a5fc 100644 --- a/administrator/components/com_installer/helpers/installer.php +++ b/administrator/components/com_installer/helpers/installer.php @@ -62,6 +62,11 @@ public static function addSubmenu($vName = 'install') 'index.php?option=com_installer&view=languages', $vName == 'languages' ); + JHtmlSidebar::addEntry( + JText::_('COM_INSTALLER_SUBMENU_UPDATESITES'), + 'index.php?option=com_installer&view=updatesites', + $vName == 'updatesites' + ); } /** diff --git a/administrator/components/com_installer/models/updatesites.php b/administrator/components/com_installer/models/updatesites.php new file mode 100644 index 0000000000000..082a2b2334297 --- /dev/null +++ b/administrator/components/com_installer/models/updatesites.php @@ -0,0 +1,186 @@ +getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', ''); + $this->setState('filter.client_id', $clientId); + + $status = $this->getUserStateFromRequest($this->context . '.filter.enabled', 'filter_enabled', ''); + $this->setState('filter.enabled', $status); + + $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); + + parent::populateState('name', 'asc'); + } + + /** + * Enable/Disable an extension. + * + * @param array &$eid Extension ids to un/publish + * @param int $value Publish value + * + * @return boolean True on success + * + * @since 3.4 + */ + public function publish(&$eid = array(), $value = 1) + { + $user = JFactory::getUser(); + + if ($user->authorise('core.edit.state', 'com_installer')) + { + $result = true; + + /* + * Ensure eid is an array of extension ids + */ + if (!is_array($eid)) + { + $eid = array($eid); + } + + // Get a table object for the extension type + $table = JTable::getInstance('Updatesite'); + + // Enable the update site in the table and store it in the database + foreach ($eid as $i => $id) + { + $table->load($id); + $table->enabled = $value; + if (!$table->store()) + { + $this->setError($table->getError()); + $result = false; + } + } + } + else + { + $result = false; + JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); + } + return $result; + } + + /** + * Method to get the database query + * + * @return JDatabaseQuery The database query + * + * @since 3.4 + */ + protected function getListQuery() + { + $enabled = $this->getState('filter.enabled'); + $type = $this->getState('filter.type'); + $client = $this->getState('filter.client_id'); + $group = $this->getState('filter.group'); + + $query = JFactory::getDbo()->getQuery(true) + ->select(array( + 's.*', + 'e.extension_id', + 'e.name as extension_name', + 'e.type', + 'e.element', + 'e.folder', + 'e.client_id', + 'e.state', + 'e.manifest_cache', + )) + ->from('#__update_sites AS s') + ->innerJoin('#__update_sites_extensions AS se on(se.update_site_id = s.update_site_id)') + ->innerJoin('#__extensions AS e ON(e.extension_id = se.extension_id)') + ->where('state=0'); + + if ($enabled != '') + { + $query->where('enabled=' . (int) $enabled); + } + + if ($type) + { + $query->where('type=' . $this->_db->quote($type)); + } + + if ($client != '') + { + $query->where('client_id=' . (int) $client); + } + + if ($group != '' && in_array($type, array('plugin', 'library', ''))) + { + $query->where('folder=' . $this->_db->quote($group == '*' ? '' : $group)); + } + + // Filter by search in id + $search = $this->getState('filter.search'); + + if (!empty($search) && stripos($search, 'id:') === 0) + { + $query->where('update_site_id = ' . (int) substr($search, 3)); + } + + return $query; + } +} diff --git a/administrator/components/com_installer/views/updatesites/index.html b/administrator/components/com_installer/views/updatesites/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/administrator/components/com_installer/views/updatesites/index.html @@ -0,0 +1 @@ + diff --git a/administrator/components/com_installer/views/updatesites/tmpl/default.php b/administrator/components/com_installer/views/updatesites/tmpl/default.php new file mode 100644 index 0000000000000..dd9e44d1b6cbe --- /dev/null +++ b/administrator/components/com_installer/views/updatesites/tmpl/default.php @@ -0,0 +1,129 @@ +escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); +?> +
+
+ sidebar)) : ?> +
+ sidebar; ?> +
+
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+ +
+ + +
+
+
+ + items)) : ?> + + + + + + + + + + + + + + + + + + + + items as $i => $item) : ?> + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ pagination->getListFooter(); ?> +
+ update_site_id); ?> + + name; ?> + + + extension_name; ?> + + + client; ?> + + element) : ?> + X + + enabled, $i, 'updatesites.'); ?> + + + type); ?> + + folder != '' ? $item->folder : JText::_('COM_INSTALLER_TYPE_NONAPPLICABLE'); ?> + + update_site_id ?> +
+ + + + + + + + +
+ +
diff --git a/administrator/components/com_installer/views/updatesites/tmpl/index.html b/administrator/components/com_installer/views/updatesites/tmpl/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/administrator/components/com_installer/views/updatesites/tmpl/index.html @@ -0,0 +1 @@ + diff --git a/administrator/components/com_installer/views/updatesites/view.html.php b/administrator/components/com_installer/views/updatesites/view.html.php new file mode 100644 index 0000000000000..e10c23ed697af --- /dev/null +++ b/administrator/components/com_installer/views/updatesites/view.html.php @@ -0,0 +1,118 @@ +state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + JError::raiseError(500, implode("\n", $errors)); + return false; + } + + // Check if there are no matching items + if (!count($this->items)) + { + JFactory::getApplication()->enqueueMessage( + JText::_('COM_INSTALLER_MSG_MANAGE_NOUPDATESITE'), + 'warning' + ); + } + + // Include the component HTML helpers. + JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); + + // Display the view + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * + * @since 3.4 + */ + protected function addToolbar() + { + $canDo = JHelperContent::getActions('com_installer'); + + if ($canDo->get('core.edit.state')) + { + JToolbarHelper::publish('updatesites.publish', 'JTOOLBAR_ENABLE', true); + JToolbarHelper::unpublish('updatesites.unpublish', 'JTOOLBAR_DISABLE', true); + JToolbarHelper::divider(); + } + + JToolbarHelper::help('JHELP_EXTENSIONS_EXTENSION_MANAGER_UPDATESITES'); + + JHtmlSidebar::setAction('index.php?option=com_installer&view=updatesites'); + + JHtmlSidebar::addFilter( + JText::_('COM_INSTALLER_VALUE_CLIENT_SELECT'), + 'filter_client_id', + JHtml::_('select.options', array('0' => 'JSITE', '1' => 'JADMINISTRATOR'), 'value', 'text', $this->state->get('filter.client_id'), true) + ); + + JHtmlSidebar::addFilter( + JText::_('COM_INSTALLER_VALUE_STATE_SELECT'), + 'filter_status', + JHtml::_('select.options', array('0' => 'JUNPUBLISHED', '1' => 'JPUBLISHED'), 'value', 'text', $this->state->get('filter.enabled'), true) + ); + + JHtmlSidebar::addFilter( + JText::_('COM_INSTALLER_VALUE_TYPE_SELECT'), + 'filter_type', + JHtml::_('select.options', InstallerHelper::getExtensionTypes(), 'value', 'text', $this->state->get('filter.type'), true) + ); + + JHtmlSidebar::addFilter( + JText::_('COM_INSTALLER_VALUE_FOLDER_SELECT'), + 'filter_group', + JHtml::_('select.options', array_merge(InstallerHelper::getExtensionGroupes(), array('*' => JText::_('COM_INSTALLER_VALUE_FOLDER_NONAPPLICABLE'))), 'value', 'text', $this->state->get('filter.group'), true) + ); + + parent::addToolbar(); + } +} diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index eb91a6518b4fc..0597ea9d3fd06 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -13,6 +13,7 @@ COM_INSTALLER_ENABLED_UPDATES_MORE=", %s disabled sites were enabled" COM_INSTALLER_ERROR_DISABLE_DEFAULT_TEMPLATE_NOT_PERMITTED="Disable default template is not permitted" COM_INSTALLER_ERROR_METHOD="Method Not Implemented" COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED="No extensions selected" +COM_INSTALLER_ERROR_NO_UPDATESITES_SELECTED="No update sites selected" COM_INSTALLER_EXTENSION_DISABLE="Disable extension" COM_INSTALLER_EXTENSION_DISABLED="Disabled extension" COM_INSTALLER_EXTENSION_ENABLE="Enable extension" @@ -30,6 +31,7 @@ COM_INSTALLER_HEADER_INSTALL="Extension Manager: Install" COM_INSTALLER_HEADER_LANGUAGES="Install Accredited Language Translations" COM_INSTALLER_HEADER_MANAGE="Extension Manager: Manage" COM_INSTALLER_HEADER_UPDATE="Extension Manager: Update" +COM_INSTALLER_HEADER_UPDATESITES="Extension Manager: Update Sites" COM_INSTALLER_HEADER_WARNINGS="Extension Manager: Warnings" COM_INSTALLER_HEADING_CLIENT="Client" COM_INSTALLER_HEADING_DETAILS_URL="Details URL" @@ -40,6 +42,8 @@ COM_INSTALLER_HEADING_INSTALLTYPE="Install Type" COM_INSTALLER_HEADING_LOCATION="Location" COM_INSTALLER_HEADING_NAME="Name" COM_INSTALLER_HEADING_TYPE="Type" +COM_INSTALLER_HEADING_UPDATESITE_NAME="Update Site" +COM_INSTALLER_HEADING_UPDATESITEID="Update Site ID" COM_INSTALLER_INSTALL_BUTTON="Install" COM_INSTALLER_INSTALL_DIRECTORY="Install Directory" COM_INSTALLER_INSTALL_ERROR="Error installing %s" @@ -98,6 +102,7 @@ COM_INSTALLER_MSG_LANGUAGES_CANT_FIND_REMOTE_PACKAGE="The installer can't get th COM_INSTALLER_MSG_LANGUAGES_NOLANGUAGES="There are no available languages to install at the moment. Please click on the "Find languages" button to check for updates on the Joomla Languages server. You will need an internet connection for this to work." COM_INSTALLER_MSG_LANGUAGES_TRY_LATER="Try again later or contact the language team coordinator" COM_INSTALLER_MSG_MANAGE_NOEXTENSION="There are no extensions installed matching your query" +COM_INSTALLER_MSG_MANAGE_NOUPDATESITE="There are no update sites matching your query" COM_INSTALLER_MSG_N_DATABASE_ERROR_PANEL="%d Database Problems Found" COM_INSTALLER_MSG_N_DATABASE_ERROR_PANEL_1="1 Database Problem Found" COM_INSTALLER_MSG_UPDATE_ERROR="Error updating %s." @@ -134,6 +139,8 @@ COM_INSTALLER_N_EXTENSIONS_PUBLISHED="%d extensions successfully enabled." COM_INSTALLER_N_EXTENSIONS_PUBLISHED_1="%d extension successfully enabled." COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED="%d extensions successfully disabled." COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED_1="%d extension successfully disabled." +COM_INSTALLER_N_UPDATESITES_PUBLISHED="%d update sites successfully enabled." +COM_INSTALLER_N_UPDATESITES_PUBLISHED_1="%d update site successfully enabled." COM_INSTALLER_NEW_INSTALL="New install" COM_INSTALLER_NO_INSTALL_TYPE_FOUND="No Install Type Found" COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED="Package download failed: %s" @@ -152,6 +159,7 @@ COM_INSTALLER_SUBMENU_INSTALL="Install" COM_INSTALLER_SUBMENU_LANGUAGES="Install languages" COM_INSTALLER_SUBMENU_MANAGE="Manage" COM_INSTALLER_SUBMENU_UPDATE="Update" +COM_INSTALLER_SUBMENU_UPDATESITES="Update Sites" COM_INSTALLER_SUBMENU_WARNINGS="Warnings" COM_INSTALLER_TITLE_DATABASE="Extension manager - Database" COM_INSTALLER_TITLE_DISCOVER="Extension manager - Discover" diff --git a/administrator/language/en-GB/en-GB.ini b/administrator/language/en-GB/en-GB.ini index 70c05b89607ff..abcca73e2ce79 100644 --- a/administrator/language/en-GB/en-GB.ini +++ b/administrator/language/en-GB/en-GB.ini @@ -648,6 +648,7 @@ JHELP_EXTENSIONS_EXTENSION_MANAGER_INSTALL="Extensions_Extension_Manager_Install JHELP_EXTENSIONS_EXTENSION_MANAGER_LANGUAGES="Extensions_Extension_Manager_languages" JHELP_EXTENSIONS_EXTENSION_MANAGER_MANAGE="Extensions_Extension_Manager_Manage" JHELP_EXTENSIONS_EXTENSION_MANAGER_UPDATE="Extensions_Extension_Manager_Update" +JHELP_EXTENSIONS_EXTENSION_MANAGER_UPDATESITES="Extensions_Extension_Manager_Updatesites" JHELP_EXTENSIONS_EXTENSION_MANAGER_WARNINGS="Extensions_Extension_Manager_Warnings" JHELP_EXTENSIONS_LANGUAGE_MANAGER_CONTENT="Extensions_Language_Manager_Content" JHELP_EXTENSIONS_LANGUAGE_MANAGER_EDIT="Extensions_Language_Manager_Edit" diff --git a/language/en-GB/en-GB.lib_joomla.ini b/language/en-GB/en-GB.lib_joomla.ini index 4dc5ba098f523..7e606bacbcc70 100644 --- a/language/en-GB/en-GB.lib_joomla.ini +++ b/language/en-GB/en-GB.lib_joomla.ini @@ -190,6 +190,7 @@ JLIB_DATABASE_ERROR_MOVE_FAILED="%s: :move failed - %s" JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_CATEGORY="Category must have a title" JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_EXTENSION="Extension must have a title" JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_MODULE="Module must have a title" +JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_UPDATESITE="Update site must have a title" JLIB_DATABASE_ERROR_NEGATIVE_NOT_PERMITTED="%s cannot be negative" JLIB_DATABASE_ERROR_NO_ROWS_SELECTED="No rows selected." JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND="Table %s not supported. File not found." diff --git a/libraries/joomla/table/updatesite.php b/libraries/joomla/table/updatesite.php new file mode 100644 index 0000000000000..a75fa0371ee91 --- /dev/null +++ b/libraries/joomla/table/updatesite.php @@ -0,0 +1,80 @@ +name) == '' || trim($this->location) == '') + { + $this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_EXTENSION')); + + return false; + } + return true; + } + + /** + * Method to create and execute a SELECT WHERE query. + * + * @param array $options Array of options + * + * @return string Results of query + * + * @since 3.4 + */ + public function find($options = array()) + { + $where = array(); + + foreach ($options as $col => $val) + { + $where[] = $col . ' = ' . $this->_db->quote($val); + } + + $query = $this->_db->getQuery(true) + ->select($this->_db->quoteName($this->_tbl_key)) + ->from($this->_db->quoteName($this->_tbl)) + ->where(implode(' AND ', $where)); + $this->_db->setQuery($query); + + return $this->_db->loadResult(); + } +} From f89a9ae99a52b7fb3465dba71714fef06ff3eb66 Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Fri, 13 Jun 2014 20:38:36 +0300 Subject: [PATCH 02/12] Reinstating the Purge button in the update view because you REALLY need it and that's the only place you'll be looking for it! --- .../components/com_installer/views/update/view.html.php | 1 + administrator/language/en-GB/en-GB.com_installer.ini | 1 + 2 files changed, 2 insertions(+) diff --git a/administrator/components/com_installer/views/update/view.html.php b/administrator/components/com_installer/views/update/view.html.php index 120618af6a1e6..8ff79988e6dbd 100644 --- a/administrator/components/com_installer/views/update/view.html.php +++ b/administrator/components/com_installer/views/update/view.html.php @@ -80,6 +80,7 @@ protected function addToolbar() { JToolbarHelper::custom('update.update', 'upload', 'upload', 'COM_INSTALLER_TOOLBAR_UPDATE', true, false); JToolbarHelper::custom('update.find', 'refresh', 'refresh', 'COM_INSTALLER_TOOLBAR_FIND_UPDATES', false, false); + JToolbarHelper::custom('update.purge', 'purge', 'purge', 'COM_INSTALLER_TOOLBAR_PURGE', false, false); JToolbarHelper::divider(); JToolbarHelper::help('JHELP_EXTENSIONS_EXTENSION_MANAGER_UPDATE'); diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index 0597ea9d3fd06..5c2703f5b702b 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -173,6 +173,7 @@ COM_INSTALLER_TOOLBAR_DISCOVER="Discover" COM_INSTALLER_TOOLBAR_FIND_LANGUAGES="Find languages" COM_INSTALLER_TOOLBAR_FIND_UPDATES="Find Updates" COM_INSTALLER_TOOLBAR_INSTALL="Install" +COM_INSTALLER_TOOLBAR_PURGE="Purge" COM_INSTALLER_TOOLBAR_UPDATE="Update" COM_INSTALLER_TYPE_CLIENT="Location" COM_INSTALLER_TYPE_COMPONENT="Component" From 312bbe9fe4288b2e4179e5d4d16c1326fe5243c5 Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Sat, 14 Jun 2014 09:26:18 +0300 Subject: [PATCH 03/12] Do not enable update sites when purging the updates --- .../components/com_installer/controllers/update.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_installer/controllers/update.php b/administrator/components/com_installer/controllers/update.php index 37b2aaae7d3e4..94cdef43e966f 100644 --- a/administrator/components/com_installer/controllers/update.php +++ b/administrator/components/com_installer/controllers/update.php @@ -94,7 +94,11 @@ public function purge() JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $model = $this->getModel('update'); $model->purge(); - $model->enableSites(); + + // We no longer need to enable update sites in Joomla! 3.4 as we now allow the users to manage update sites + // themselves. + // $model->enableSites(); + $this->setRedirect(JRoute::_('index.php?option=com_installer&view=update', false), $model->_message); } From d4f585ea2fe79a46ec383f27b3abb93fbf6777fe Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Sat, 14 Jun 2014 12:32:24 +0300 Subject: [PATCH 04/12] Missing language string --- administrator/language/en-GB/en-GB.com_installer.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index 5c2703f5b702b..9420c9e66d9b4 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -167,6 +167,7 @@ COM_INSTALLER_TITLE_INSTALL="Extension manager - Install" COM_INSTALLER_TITLE_LANGUAGES="Extension manager - Install Languages" COM_INSTALLER_TITLE_MANAGE="Extension manager - Manage" COM_INSTALLER_TITLE_UPDATE="Extension manager - Update" +COM_INSTALLER_TITLE_UPDATESITES="Extension manager - Update Sites" COM_INSTALLER_TITLE_WARNINGS="Extension manager - Warnings" COM_INSTALLER_TOOLBAR_DATABASE_FIX="Fix" COM_INSTALLER_TOOLBAR_DISCOVER="Discover" From 62125487b38f1bd21990c0415fa3464c5e85cd6a Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Sat, 14 Jun 2014 12:35:07 +0300 Subject: [PATCH 05/12] Fixing name columns --- .../components/com_installer/models/updatesites.php | 3 ++- .../com_installer/views/updatesites/tmpl/default.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/administrator/components/com_installer/models/updatesites.php b/administrator/components/com_installer/models/updatesites.php index 082a2b2334297..566df612f1dd1 100644 --- a/administrator/components/com_installer/models/updatesites.php +++ b/administrator/components/com_installer/models/updatesites.php @@ -139,6 +139,7 @@ protected function getListQuery() $query = JFactory::getDbo()->getQuery(true) ->select(array( 's.*', + 's.name as update_site_name', 'e.extension_id', 'e.name as extension_name', 'e.type', @@ -160,7 +161,7 @@ protected function getListQuery() if ($type) { - $query->where('type=' . $this->_db->quote($type)); + $query->where('e.type=' . $this->_db->quote($type)); } if ($client != '') diff --git a/administrator/components/com_installer/views/updatesites/tmpl/default.php b/administrator/components/com_installer/views/updatesites/tmpl/default.php index dd9e44d1b6cbe..d92219c9576f1 100644 --- a/administrator/components/com_installer/views/updatesites/tmpl/default.php +++ b/administrator/components/com_installer/views/updatesites/tmpl/default.php @@ -50,7 +50,7 @@ - + @@ -86,11 +86,11 @@ update_site_id); ?> - name; ?> + update_site_name; ?> - - extension_name; ?> + + name; ?> From 66fe43457ce590d2cd68939deaaaf5f39eb5cda2 Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Sat, 14 Jun 2014 12:44:29 +0300 Subject: [PATCH 06/12] Fixing filters in Update Sites view --- .../com_installer/models/extension.php | 2 +- .../com_installer/models/updatesites.php | 77 ++++++++++++++++--- .../views/updatesites/tmpl/default.php | 6 +- .../views/updatesites/view.html.php | 4 +- 4 files changed, 74 insertions(+), 15 deletions(-) diff --git a/administrator/components/com_installer/models/extension.php b/administrator/components/com_installer/models/extension.php index ce653cb270f32..a731540c95e1e 100644 --- a/administrator/components/com_installer/models/extension.php +++ b/administrator/components/com_installer/models/extension.php @@ -103,7 +103,7 @@ protected function _getList($query, $limitstart = 0, $limit = 0) * * @return array The array of translated objects */ - private function translate(&$items) + protected function translate(&$items) { $lang = JFactory::getLanguage(); foreach ($items as &$item) diff --git a/administrator/components/com_installer/models/updatesites.php b/administrator/components/com_installer/models/updatesites.php index 566df612f1dd1..8be5fe45ce6a3 100644 --- a/administrator/components/com_installer/models/updatesites.php +++ b/administrator/components/com_installer/models/updatesites.php @@ -32,7 +32,11 @@ public function __construct($config = array()) { if (empty($config['filter_fields'])) { - $config['filter_fields'] = array('name', 'client_id', 'enabled', 'type', 'folder', 'extension_id',); + $config['filter_fields'] = array( + 'update_site_name', 'extension_name', 'client_id', + 'status', 'extension_type', 'folder', 'update_site_id', + 'enabled' + ); } parent::__construct($config); @@ -64,8 +68,8 @@ protected function populateState($ordering = null, $direction = null) $status = $this->getUserStateFromRequest($this->context . '.filter.enabled', 'filter_enabled', ''); $this->setState('filter.enabled', $status); - $categoryId = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', ''); - $this->setState('filter.type', $categoryId); + $categoryId = $this->getUserStateFromRequest($this->context . '.filter.extension_type', 'filter_extension_type', ''); + $this->setState('filter.extension_type', $categoryId); $group = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group', ''); $this->setState('filter.group', $group); @@ -132,7 +136,7 @@ public function publish(&$eid = array(), $value = 1) protected function getListQuery() { $enabled = $this->getState('filter.enabled'); - $type = $this->getState('filter.type'); + $extension_type = $this->getState('filter.extension_type'); $client = $this->getState('filter.client_id'); $group = $this->getState('filter.group'); @@ -142,7 +146,7 @@ protected function getListQuery() 's.name as update_site_name', 'e.extension_id', 'e.name as extension_name', - 'e.type', + 'e.type as extension_type', 'e.element', 'e.folder', 'e.client_id', @@ -159,9 +163,9 @@ protected function getListQuery() $query->where('enabled=' . (int) $enabled); } - if ($type) + if ($extension_type) { - $query->where('e.type=' . $this->_db->quote($type)); + $query->where('e.type=' . $this->_db->quote($extension_type)); } if ($client != '') @@ -169,7 +173,7 @@ protected function getListQuery() $query->where('client_id=' . (int) $client); } - if ($group != '' && in_array($type, array('plugin', 'library', ''))) + if ($group != '' && in_array($extension_type, array('plugin', 'library', ''))) { $query->where('folder=' . $this->_db->quote($group == '*' ? '' : $group)); } @@ -179,9 +183,64 @@ protected function getListQuery() if (!empty($search) && stripos($search, 'id:') === 0) { - $query->where('update_site_id = ' . (int) substr($search, 3)); + $query->where('s.update_site_id = ' . (int) substr($search, 3)); } return $query; } + + /** + * 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 = $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(); + $this->translate($result); + if (!empty($search)) + { + foreach ($result as $i => $item) + { + if (!preg_match("/$search/i", $item->name)) + { + if (!preg_match("/$search/i", $item->update_site_name)) + { + unset($result[$i]); + } + } + } + } + JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == '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); + } + else + { + $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction')); + $result = parent::_getList($query, $limitstart, $limit); + $this->translate($result); + return $result; + } + } } diff --git a/administrator/components/com_installer/views/updatesites/tmpl/default.php b/administrator/components/com_installer/views/updatesites/tmpl/default.php index d92219c9576f1..66b5b2eb3089c 100644 --- a/administrator/components/com_installer/views/updatesites/tmpl/default.php +++ b/administrator/components/com_installer/views/updatesites/tmpl/default.php @@ -59,10 +59,10 @@ - + - + @@ -104,7 +104,7 @@ - type); ?> + extension_type); ?> folder != '' ? $item->folder : JText::_('COM_INSTALLER_TYPE_NONAPPLICABLE'); ?> diff --git a/administrator/components/com_installer/views/updatesites/view.html.php b/administrator/components/com_installer/views/updatesites/view.html.php index e10c23ed697af..68923ae879212 100644 --- a/administrator/components/com_installer/views/updatesites/view.html.php +++ b/administrator/components/com_installer/views/updatesites/view.html.php @@ -103,8 +103,8 @@ protected function addToolbar() JHtmlSidebar::addFilter( JText::_('COM_INSTALLER_VALUE_TYPE_SELECT'), - 'filter_type', - JHtml::_('select.options', InstallerHelper::getExtensionTypes(), 'value', 'text', $this->state->get('filter.type'), true) + 'filter_extension_type', + JHtml::_('select.options', InstallerHelper::getExtensionTypes(), 'value', 'text', $this->state->get('filter.extension_type'), true) ); JHtmlSidebar::addFilter( From 61bbbf04b0f44278b4c8ff3cfa073e7bb9918a1b Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Sat, 14 Jun 2014 13:19:58 +0300 Subject: [PATCH 07/12] Translation of the extension name in update sites view --- .../com_installer/models/updatesites.php | 61 +++++++++++-------- .../views/updatesites/tmpl/default.php | 6 +- .../views/updatesites/view.html.php | 4 +- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/administrator/components/com_installer/models/updatesites.php b/administrator/components/com_installer/models/updatesites.php index 8be5fe45ce6a3..d647f2fb257e0 100644 --- a/administrator/components/com_installer/models/updatesites.php +++ b/administrator/components/com_installer/models/updatesites.php @@ -23,7 +23,7 @@ class InstallerModelUpdatesites extends InstallerModel /** * Constructor. * - * @param array $config An optional associative array of configuration settings. + * @param array $config An optional associative array of configuration settings. * * @see JController * @since 3.4 @@ -33,8 +33,8 @@ public function __construct($config = array()) if (empty($config['filter_fields'])) { $config['filter_fields'] = array( - 'update_site_name', 'extension_name', 'client_id', - 'status', 'extension_type', 'folder', 'update_site_id', + 'update_site_name', 'name', 'client_id', + 'status', 'type', 'folder', 'update_site_id', 'enabled' ); } @@ -47,8 +47,8 @@ public function __construct($config = array()) * * Note. Calling getState in this method will result in recursion. * - * @param string $ordering An optional ordering field. - * @param string $direction An optional direction (asc|desc). + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). * * @return void * @@ -68,8 +68,8 @@ protected function populateState($ordering = null, $direction = null) $status = $this->getUserStateFromRequest($this->context . '.filter.enabled', 'filter_enabled', ''); $this->setState('filter.enabled', $status); - $categoryId = $this->getUserStateFromRequest($this->context . '.filter.extension_type', 'filter_extension_type', ''); - $this->setState('filter.extension_type', $categoryId); + $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); @@ -80,8 +80,8 @@ protected function populateState($ordering = null, $direction = null) /** * Enable/Disable an extension. * - * @param array &$eid Extension ids to un/publish - * @param int $value Publish value + * @param array &$eid Extension ids to un/publish + * @param int $value Publish value * * @return boolean True on success * @@ -123,6 +123,7 @@ public function publish(&$eid = array(), $value = 1) $result = false; JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } + return $result; } @@ -136,17 +137,20 @@ public function publish(&$eid = array(), $value = 1) protected function getListQuery() { $enabled = $this->getState('filter.enabled'); - $extension_type = $this->getState('filter.extension_type'); + $type = $this->getState('filter.type'); $client = $this->getState('filter.client_id'); $group = $this->getState('filter.group'); $query = JFactory::getDbo()->getQuery(true) ->select(array( - 's.*', + 's.update_site_id', 's.name as update_site_name', + 's.type as update_site_type', + 's.location', + 's.enabled', 'e.extension_id', - 'e.name as extension_name', - 'e.type as extension_type', + 'e.name', + 'e.type', 'e.element', 'e.folder', 'e.client_id', @@ -160,20 +164,20 @@ protected function getListQuery() if ($enabled != '') { - $query->where('enabled=' . (int) $enabled); + $query->where('enabled=' . (int)$enabled); } - if ($extension_type) + if ($type) { - $query->where('e.type=' . $this->_db->quote($extension_type)); + $query->where('e.type=' . $this->_db->quote($type)); } if ($client != '') { - $query->where('client_id=' . (int) $client); + $query->where('client_id=' . (int)$client); } - if ($group != '' && in_array($extension_type, array('plugin', 'library', ''))) + if ($group != '' && in_array($type, array('plugin', 'library', ''))) { $query->where('folder=' . $this->_db->quote($group == '*' ? '' : $group)); } @@ -183,7 +187,7 @@ protected function getListQuery() if (!empty($search) && stripos($search, 'id:') === 0) { - $query->where('s.update_site_id = ' . (int) substr($search, 3)); + $query->where('s.update_site_id = ' . (int)substr($search, 3)); } return $query; @@ -192,26 +196,27 @@ protected function getListQuery() /** * Returns an object list * - * @param string $query The query - * @param int $limitstart Offset - * @param int $limit The number of records + * @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 = $this->getState('list.ordering'); - $search = $this->getState('filter.search'); + $ordering = $this->getState('list.ordering'); + $search = $this->getState('filter.search'); // Replace slashes so preg_match will work - $search = str_replace('/', ' ', $search); - $db = $this->getDbo(); + $search = str_replace('/', ' ', $search); + $db = $this->getDbo(); if ($ordering == 'name' || (!empty($search) && stripos($search, 'id:') !== 0)) { $db->setQuery($query); $result = $db->loadObjectList(); $this->translate($result); + if (!empty($search)) { foreach ($result as $i => $item) @@ -225,14 +230,17 @@ protected function _getList($query, $limitstart = 0, $limit = 0) } } } + JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == '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); } else @@ -240,6 +248,7 @@ protected function _getList($query, $limitstart = 0, $limit = 0) $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction')); $result = parent::_getList($query, $limitstart, $limit); $this->translate($result); + return $result; } } diff --git a/administrator/components/com_installer/views/updatesites/tmpl/default.php b/administrator/components/com_installer/views/updatesites/tmpl/default.php index 66b5b2eb3089c..f15d33f81dff1 100644 --- a/administrator/components/com_installer/views/updatesites/tmpl/default.php +++ b/administrator/components/com_installer/views/updatesites/tmpl/default.php @@ -53,7 +53,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -104,7 +104,7 @@ - extension_type); ?> + type); ?> folder != '' ? $item->folder : JText::_('COM_INSTALLER_TYPE_NONAPPLICABLE'); ?> diff --git a/administrator/components/com_installer/views/updatesites/view.html.php b/administrator/components/com_installer/views/updatesites/view.html.php index 68923ae879212..e10c23ed697af 100644 --- a/administrator/components/com_installer/views/updatesites/view.html.php +++ b/administrator/components/com_installer/views/updatesites/view.html.php @@ -103,8 +103,8 @@ protected function addToolbar() JHtmlSidebar::addFilter( JText::_('COM_INSTALLER_VALUE_TYPE_SELECT'), - 'filter_extension_type', - JHtml::_('select.options', InstallerHelper::getExtensionTypes(), 'value', 'text', $this->state->get('filter.extension_type'), true) + 'filter_type', + JHtml::_('select.options', InstallerHelper::getExtensionTypes(), 'value', 'text', $this->state->get('filter.type'), true) ); JHtmlSidebar::addFilter( From 721a458d545637153a1ad05cbf338aa792733882 Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Sat, 14 Jun 2014 13:21:03 +0300 Subject: [PATCH 08/12] Moving status column next to checkboxes in update sites view --- .../views/updatesites/tmpl/default.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/administrator/components/com_installer/views/updatesites/tmpl/default.php b/administrator/components/com_installer/views/updatesites/tmpl/default.php index f15d33f81dff1..220fcd274277e 100644 --- a/administrator/components/com_installer/views/updatesites/tmpl/default.php +++ b/administrator/components/com_installer/views/updatesites/tmpl/default.php @@ -49,6 +49,9 @@ + + + @@ -58,9 +61,6 @@ - - - @@ -85,6 +85,13 @@ update_site_id); ?> + + element) : ?> + X + + enabled, $i, 'updatesites.'); ?> + + update_site_name; ?> @@ -96,13 +103,6 @@ client; ?> - - element) : ?> - X - - enabled, $i, 'updatesites.'); ?> - - type); ?> From 8ae969b4cb4e7dbf4f0803b25759842d3b71bf78 Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Sat, 14 Jun 2014 23:24:56 +0300 Subject: [PATCH 09/12] Object calisthenics and using exceptions instead of JError --- .../com_installer/controllers/updatesites.php | 35 +++++---- .../com_installer/models/updatesites.php | 76 +++++++++---------- .../views/updatesites/view.html.php | 7 +- 3 files changed, 56 insertions(+), 62 deletions(-) diff --git a/administrator/components/com_installer/controllers/updatesites.php b/administrator/components/com_installer/controllers/updatesites.php index e4b5f52b9f5c9..b0a1275a884a5 100644 --- a/administrator/components/com_installer/controllers/updatesites.php +++ b/administrator/components/com_installer/controllers/updatesites.php @@ -40,6 +40,8 @@ public function __construct($config = array()) * @return void * * @since 3.4 + * + * @throws Exception on error */ public function publish() { @@ -53,30 +55,27 @@ public function publish() if (empty($ids)) { - JError::raiseWarning(500, JText::_('COM_INSTALLER_ERROR_NO_UPDATESITES_SELECTED')); + throw new Exception(JText::_('COM_INSTALLER_ERROR_NO_UPDATESITES_SELECTED'), 500); + } + + // Get the model. + $model = $this->getModel('Updatesites'); + + // Change the state of the records. + if (!$model->publish($ids, $value)) + { + throw new Exception(implode('
', $model->getErrors()), 500); } else { - // Get the model. - $model = $this->getModel('Updatesites'); + $ntext = 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED'; - // Change the state of the records. - if (!$model->publish($ids, $value)) - { - JError::raiseWarning(500, implode('
', $model->getErrors())); - } - else + if ($value == 0) { - if ($value == 1) - { - $ntext = 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED'; - } - elseif ($value == 0) - { - $ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED'; - } - $this->setMessage(JText::plural($ntext, count($ids))); + $ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED'; } + + $this->setMessage(JText::plural($ntext, count($ids))); } $this->setRedirect(JRoute::_('index.php?option=com_installer&view=updatesites', false)); diff --git a/administrator/components/com_installer/models/updatesites.php b/administrator/components/com_installer/models/updatesites.php index d647f2fb257e0..c573973bbbf49 100644 --- a/administrator/components/com_installer/models/updatesites.php +++ b/administrator/components/com_installer/models/updatesites.php @@ -56,8 +56,6 @@ public function __construct($config = array()) */ protected function populateState($ordering = null, $direction = null) { - $app = JFactory::getApplication(); - // Load the filter state. $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); @@ -86,43 +84,43 @@ protected function populateState($ordering = null, $direction = null) * @return boolean True on success * * @since 3.4 + * + * @throws Exception on ACL error */ public function publish(&$eid = array(), $value = 1) { $user = JFactory::getUser(); - if ($user->authorise('core.edit.state', 'com_installer')) + if (!$user->authorise('core.edit.state', 'com_installer')) { - $result = true; + throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 403); + } - /* - * Ensure eid is an array of extension ids - */ - if (!is_array($eid)) - { - $eid = array($eid); - } + $result = true; - // Get a table object for the extension type - $table = JTable::getInstance('Updatesite'); + /* + * Ensure eid is an array of extension ids + */ + if (!is_array($eid)) + { + $eid = array($eid); + } + + // Get a table object for the extension type + $table = JTable::getInstance('Updatesite'); + + // Enable the update site in the table and store it in the database + foreach ($eid as $i => $id) + { + $table->load($id); + $table->enabled = $value; - // Enable the update site in the table and store it in the database - foreach ($eid as $i => $id) + if (!$table->store()) { - $table->load($id); - $table->enabled = $value; - if (!$table->store()) - { - $this->setError($table->getError()); - $result = false; - } + $this->setError($table->getError()); + $result = false; } } - else - { - $result = false; - JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); - } return $result; } @@ -164,7 +162,7 @@ protected function getListQuery() if ($enabled != '') { - $query->where('enabled=' . (int)$enabled); + $query->where('s.enabled=' . (int)$enabled); } if ($type) @@ -217,21 +215,19 @@ protected function _getList($query, $limitstart = 0, $limit = 0) $result = $db->loadObjectList(); $this->translate($result); - if (!empty($search)) + if (!empty($search) && (stripos($search, 'id:') !== 0)) { foreach ($result as $i => $item) { - if (!preg_match("/$search/i", $item->name)) + if (!preg_match("/$search/i", $item->name) && !preg_match("/$search/i", $item->update_site_name)) { - if (!preg_match("/$search/i", $item->update_site_name)) - { - unset($result[$i]); - } + unset($result[$i]); } } } JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, true); + $total = count($result); $this->cache[$this->getStoreId('getTotal')] = $total; @@ -243,13 +239,11 @@ protected function _getList($query, $limitstart = 0, $limit = 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; - } + $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction')); + $result = parent::_getList($query, $limitstart, $limit); + $this->translate($result); + + return $result; } } diff --git a/administrator/components/com_installer/views/updatesites/view.html.php b/administrator/components/com_installer/views/updatesites/view.html.php index e10c23ed697af..213cae1e27cee 100644 --- a/administrator/components/com_installer/views/updatesites/view.html.php +++ b/administrator/components/com_installer/views/updatesites/view.html.php @@ -36,6 +36,8 @@ class InstallerViewUpdatesites extends InstallerViewDefault * @return mixed|void * * @since 3.4 + * + * @throws Exception on errors */ public function display($tpl = null) { @@ -47,8 +49,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - JError::raiseError(500, implode("\n", $errors)); - return false; + throw new Exception(implode("\n", $errors), 500); } // Check if there are no matching items @@ -97,7 +98,7 @@ protected function addToolbar() JHtmlSidebar::addFilter( JText::_('COM_INSTALLER_VALUE_STATE_SELECT'), - 'filter_status', + 'filter_enabled', JHtml::_('select.options', array('0' => 'JUNPUBLISHED', '1' => 'JPUBLISHED'), 'value', 'text', $this->state->get('filter.enabled'), true) ); From 3a9c317bc49fa80b9f40d224fa977b5baccfb7dc Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Mon, 16 Jun 2014 12:41:02 +0300 Subject: [PATCH 10/12] Code quality improvements, thanks to @Bakual and @beat --- .../com_installer/controllers/updatesites.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/administrator/components/com_installer/controllers/updatesites.php b/administrator/components/com_installer/controllers/updatesites.php index b0a1275a884a5..ab9fce36cb232 100644 --- a/administrator/components/com_installer/controllers/updatesites.php +++ b/administrator/components/com_installer/controllers/updatesites.php @@ -66,17 +66,10 @@ public function publish() { throw new Exception(implode('
', $model->getErrors()), 500); } - else - { - $ntext = 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED'; - if ($value == 0) - { - $ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED'; - } + $ntext = ($value == 0) ? 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED' : 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED'; - $this->setMessage(JText::plural($ntext, count($ids))); - } + $this->setMessage(JText::plural($ntext, count($ids))); $this->setRedirect(JRoute::_('index.php?option=com_installer&view=updatesites', false)); } From 93ca605d35eb29360a041c7c90e465b7e2f81a07 Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Mon, 16 Jun 2014 12:45:45 +0300 Subject: [PATCH 11/12] Removing duplicate strings, thanks to @infograf768 --- administrator/components/com_installer/models/update.php | 4 ++-- administrator/language/en-GB/en-GB.com_installer.ini | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_installer/models/update.php b/administrator/components/com_installer/models/update.php index 17b7790f8345e..2f0e5df60fe45 100644 --- a/administrator/components/com_installer/models/update.php +++ b/administrator/components/com_installer/models/update.php @@ -177,12 +177,12 @@ public function purge() ->set($db->quoteName('last_check_timestamp') . ' = ' . $db->quote(0)); $db->setQuery($query); $db->execute(); - $this->_message = JText::_('COM_INSTALLER_PURGED_UPDATES'); + $this->_message = JText::_('JLIB_INSTALLER_PURGED_UPDATES'); return true; } else { - $this->_message = JText::_('COM_INSTALLER_FAILED_TO_PURGE_UPDATES'); + $this->_message = JText::_('JLIB_INSTALLER_FAILED_TO_PURGE_UPDATES'); return false; } } diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index 9420c9e66d9b4..6eda7ecf49d6b 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -23,7 +23,6 @@ COM_INSTALLER_EXTENSION_PROTECTED="Protected extension" COM_INSTALLER_EXTENSION_PUBLISHED="Extension successfully enabled." COM_INSTALLER_EXTENSION_UNPUBLISHED="Extension successfully disabled." COM_INSTALLER_FAILED_TO_ENABLE_UPDATES=", failed to enable updates" -COM_INSTALLER_FAILED_TO_PURGE_UPDATES="Failed to purge updates" COM_INSTALLER_FILTER_LABEL="Search by extension name" COM_INSTALLER_HEADER_DATABASE="Extension Manager: Check Database" COM_INSTALLER_HEADER_DISCOVER="Extension Manager: Discover" @@ -147,7 +146,6 @@ COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED="Package download failed: %s" COM_INSTALLER_PACKAGE_FILE="Package File" COM_INSTALLER_PREFERENCES_DESCRIPTION="Fine-tune how extensions installation and updates work" COM_INSTALLER_PREFERENCES_LABEL="Preferences" -COM_INSTALLER_PURGED_UPDATES="Purged updates" COM_INSTALLER_SHOW_JED_INFORMATION_DESC="Show or hide the information at the top of the installer page about the Joomla! Extensions Directory." COM_INSTALLER_SHOW_JED_INFORMATION_HIDE_MESSAGE="Hide message" COM_INSTALLER_SHOW_JED_INFORMATION_LABEL="Joomla! Extensions Directory" From 3fc449cda9937f88a876576d087ce0261edeadba Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Wed, 18 Jun 2014 23:06:09 +0300 Subject: [PATCH 12/12] Removing unnecessary method from libraries/joomla/table/updatesite.php --- libraries/joomla/table/updatesite.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/libraries/joomla/table/updatesite.php b/libraries/joomla/table/updatesite.php index a75fa0371ee91..f09f7b604bce5 100644 --- a/libraries/joomla/table/updatesite.php +++ b/libraries/joomla/table/updatesite.php @@ -50,31 +50,4 @@ public function check() } return true; } - - /** - * Method to create and execute a SELECT WHERE query. - * - * @param array $options Array of options - * - * @return string Results of query - * - * @since 3.4 - */ - public function find($options = array()) - { - $where = array(); - - foreach ($options as $col => $val) - { - $where[] = $col . ' = ' . $this->_db->quote($val); - } - - $query = $this->_db->getQuery(true) - ->select($this->_db->quoteName($this->_tbl_key)) - ->from($this->_db->quoteName($this->_tbl)) - ->where(implode(' AND ', $where)); - $this->_db->setQuery($query); - - return $this->_db->loadResult(); - } }