diff --git a/administrator/components/com_installer/src/Controller/UpdateController.php b/administrator/components/com_installer/src/Controller/UpdateController.php index 23a9586b929af..a8e9d4d98803d 100644 --- a/administrator/components/com_installer/src/Controller/UpdateController.php +++ b/administrator/components/com_installer/src/Controller/UpdateController.php @@ -19,6 +19,7 @@ use Joomla\CMS\Session\Session; use Joomla\CMS\Updater\Updater; use Joomla\CMS\Uri\Uri; +use Joomla\Component\Installer\Administrator\Model\UpdateModel; use Joomla\Utilities\ArrayHelper; /** @@ -40,7 +41,7 @@ public function update() // Check for request forgeries. $this->checkToken(); - /** @var \Joomla\Component\Installer\Administrator\Model\UpdateModel $model */ + /** @var UpdateModel $model */ $model = $this->getModel('update'); $uid = $this->input->get('cid', array(), 'array'); @@ -96,9 +97,12 @@ public function find() $minimum_stability = (int) $params->get('minimum_stability', Updater::STABILITY_STABLE); // Find updates. - /** @var \Joomla\Component\Installer\Administrator\Model\UpdateModel $model */ + /** @var UpdateModel $model */ $model = $this->getModel('update'); + // Purge the table before checking again + $model->purge(); + $disabledUpdateSites = $model->getDisabledUpdateSites(); if ($disabledUpdateSites) @@ -108,26 +112,13 @@ public function find() } $model->findUpdates(0, $cache_timeout, $minimum_stability); - $this->setRedirect(Route::_('index.php?option=com_installer&view=update', false)); - } - /** - * Purges updates. - * - * @return void - * - * @since 1.6 - */ - public function purge() - { - // Check for request forgeries. - $this->checkToken(); - - /** @var \Joomla\Component\Installer\Administrator\Model\UpdateModel $model */ - $model = $this->getModel('update'); - $model->purge(); + if (0 === $model->getTotal()) + { + $this->setMessage(Text::_('COM_INSTALLER_MSG_UPDATE_NOUPDATES'), 'info'); + } - $this->setRedirect(Route::_('index.php?option=com_installer&view=update', false), $model->_message); + $this->setRedirect(Route::_('index.php?option=com_installer&view=update', false)); } /** @@ -170,7 +161,7 @@ public function ajax() $minimum_stability = (int) $params->get('minimum_stability', Updater::STABILITY_STABLE); } - /** @var \Joomla\Component\Installer\Administrator\Model\UpdateModel $model */ + /** @var UpdateModel $model */ $model = $this->getModel('update'); $model->findUpdates($eid, $cache_timeout, $minimum_stability); diff --git a/administrator/components/com_installer/src/Model/UpdateModel.php b/administrator/components/com_installer/src/Model/UpdateModel.php index 1b55b89637aa3..f04698b968b37 100644 --- a/administrator/components/com_installer/src/Model/UpdateModel.php +++ b/administrator/components/com_installer/src/Model/UpdateModel.php @@ -22,6 +22,7 @@ use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Updater\Update; use Joomla\CMS\Updater\Updater; +use Joomla\Database\DatabaseQuery; use Joomla\Database\Exception\ExecutionFailureException; use Joomla\Database\ParameterType; use Joomla\Utilities\ArrayHelper; @@ -630,4 +631,20 @@ protected function preparePreUpdate($update, $table) break; } } + + /** + * Manipulate the query to be used to evaluate if this is an Empty State to provide specific conditions for this extension. + * + * @return DatabaseQuery + * + * @since __DEPLOY_VERSION__ + */ + protected function getEmptyStateQuery(): DatabaseQuery + { + $query = parent::getEmptyStateQuery(); + + $query->where($this->_db->quoteName('extension_id') . ' != 0'); + + return $query; + } } diff --git a/administrator/components/com_installer/src/View/Update/HtmlView.php b/administrator/components/com_installer/src/View/Update/HtmlView.php index 9d207f8daf40e..f0132f7a476e6 100644 --- a/administrator/components/com_installer/src/View/Update/HtmlView.php +++ b/administrator/components/com_installer/src/View/Update/HtmlView.php @@ -48,6 +48,12 @@ class HtmlView extends InstallerViewDefault */ protected $missingDownloadKeys = 0; + /** + * @var boolean + * @since __DEPLOY_VERSION__ + */ + private $isEmptyState = false; + /** * Display the view. * @@ -70,7 +76,11 @@ public function display($tpl = null) $this->paths = &$paths; - if (count($this->items) > 0) + if (count($this->items) === 0 && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + else { Factory::getApplication()->enqueueMessage(Text::_('COM_INSTALLER_MSG_WARNINGS_UPDATE_NOTICE'), 'warning'); } @@ -113,9 +123,12 @@ public function display($tpl = null) */ protected function addToolbar() { - ToolbarHelper::custom('update.update', 'upload', '', 'COM_INSTALLER_TOOLBAR_UPDATE', true); + if (false === $this->isEmptyState) + { + ToolbarHelper::custom('update.update', 'upload', '', 'COM_INSTALLER_TOOLBAR_UPDATE', true); + } + ToolbarHelper::custom('update.find', 'refresh', '', 'COM_INSTALLER_TOOLBAR_FIND_UPDATES', false); - ToolbarHelper::custom('update.purge', 'purge', '', 'COM_INSTALLER_TOOLBAR_PURGE', false); ToolbarHelper::divider(); parent::addToolbar(); diff --git a/administrator/components/com_installer/tmpl/update/emptystate.php b/administrator/components/com_installer/tmpl/update/emptystate.php new file mode 100644 index 0000000000000..18c71b26a9715 --- /dev/null +++ b/administrator/components/com_installer/tmpl/update/emptystate.php @@ -0,0 +1,30 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Session\Session; + +$displayData = [ + 'textPrefix' => 'COM_INSTALLER', + 'formURL' => 'index.php?option=com_installer&view=update', + 'helpURL' => 'https://docs.joomla.org/Help4.x:Extensions:_Update', + 'icon' => 'icon-puzzle-piece install', +]; + +$user = Factory::getApplication()->getIdentity(); + +if ($user->authorise('core.create', 'com_content') || count($user->getAuthorisedCategories('com_content', 'core.create')) > 0) +{ + $displayData['createURL'] = 'index.php?option=com_installer&task=update.find&' . Session::getFormToken() . '=1'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/administrator/language/en-GB/com_installer.ini b/administrator/language/en-GB/com_installer.ini index fa0a4ae990a8e..a902194ff533d 100644 --- a/administrator/language/en-GB/com_installer.ini +++ b/administrator/language/en-GB/com_installer.ini @@ -25,6 +25,9 @@ COM_INSTALLER_DISCOVER_TABLE_CAPTION="Table of Discovered Extensions" COM_INSTALLER_DOWNLOADKEY_EXTRA_QUERY_LABEL="Download Key" COM_INSTALLER_DOWNLOADKEY_MISSING_LABEL="The Download Key is missing" COM_INSTALLER_DOWNLOADKEY_MISSING_TIP="Updates for this extension will not work until you enter its Download Key. Click on the Update Site's title to enter the Download Key." +COM_INSTALLER_EMPTYSTATE_TITLE="Check For Updates" +COM_INSTALLER_EMPTYSTATE_BUTTON_ADD="Check For Updates" +COM_INSTALLER_EMPTYSTATE_CONTENT="You currently have no pending updates to apply. Check regularly for new updates to keep your site up to date and secure." 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." @@ -225,7 +228,7 @@ COM_INSTALLER_TITLE_UPDATESITES="Extensions: Update Sites" COM_INSTALLER_TOOLBAR_DATABASE_FIX="Update Structure" COM_INSTALLER_TOOLBAR_DISCOVER="Discover" COM_INSTALLER_TOOLBAR_FIND_LANGUAGES="Find languages" -COM_INSTALLER_TOOLBAR_FIND_UPDATES="Find Updates" +COM_INSTALLER_TOOLBAR_FIND_UPDATES="Check For Updates" COM_INSTALLER_TOOLBAR_INSTALL="Install" COM_INSTALLER_TOOLBAR_PURGE="Clear Cache" COM_INSTALLER_TOOLBAR_UPDATE="Update"