diff --git a/administrator/components/com_cache/src/View/Cache/HtmlView.php b/administrator/components/com_cache/src/View/Cache/HtmlView.php index c130da66a9cc2..65f01a0b6aecf 100644 --- a/administrator/components/com_cache/src/View/Cache/HtmlView.php +++ b/administrator/components/com_cache/src/View/Cache/HtmlView.php @@ -101,11 +101,16 @@ public function display($tpl = null): void $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (count($errors = $this->get('Errors'))) + if (\count($errors = $this->get('Errors'))) { throw new GenericDataException(implode("\n", $errors), 500); } + if (!\count($this->data)) + { + $this->setLayout('emptystate'); + } + $this->addToolbar(); parent::display($tpl); @@ -125,10 +130,13 @@ protected function addToolbar(): void // Get the toolbar object instance $toolbar = Toolbar::getInstance('toolbar'); - ToolbarHelper::custom('delete', 'delete', '', 'JTOOLBAR_DELETE', true); - ToolbarHelper::custom('deleteAll', 'remove', '', 'JTOOLBAR_DELETE_ALL', false); - $toolbar->appendButton('Confirm', 'COM_CACHE_RESOURCE_INTENSIVE_WARNING', 'delete', 'COM_CACHE_PURGE_EXPIRED', 'purge', false); - ToolbarHelper::divider(); + if (\count($this->data)) + { + ToolbarHelper::custom('delete', 'delete', '', 'JTOOLBAR_DELETE', true); + ToolbarHelper::custom('deleteAll', 'remove', '', 'JTOOLBAR_DELETE_ALL', false); + $toolbar->appendButton('Confirm', 'COM_CACHE_RESOURCE_INTENSIVE_WARNING', 'delete', 'COM_CACHE_PURGE_EXPIRED', 'purge', false); + ToolbarHelper::divider(); + } if (Factory::getUser()->authorise('core.admin', 'com_cache')) { diff --git a/administrator/components/com_cache/tmpl/cache/emptystate.php b/administrator/components/com_cache/tmpl/cache/emptystate.php new file mode 100644 index 0000000000000..421414bab0dd9 --- /dev/null +++ b/administrator/components/com_cache/tmpl/cache/emptystate.php @@ -0,0 +1,20 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die; + +use Joomla\CMS\Layout\LayoutHelper; + +$displayData = [ + 'textPrefix' => 'COM_CACHE', + 'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Cache', + 'icon' => 'icon-bolt clear', +]; + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/administrator/language/en-GB/com_cache.ini b/administrator/language/en-GB/com_cache.ini index 7b476769d913a..a45c9203ab4ee 100644 --- a/administrator/language/en-GB/com_cache.ini +++ b/administrator/language/en-GB/com_cache.ini @@ -6,6 +6,8 @@ COM_CACHE="Cache" COM_CACHE_CLEAR_CACHE="Maintenance: Clear Cache" COM_CACHE_CONFIGURATION="Cache: Options" +COM_CACHE_EMPTYSTATE_CONTENT="If you enable caching in Joomla Global Configuration, then any cached items will be displayed here." +COM_CACHE_EMPTYSTATE_TITLE="You have no cached content." COM_CACHE_ERROR_CACHE_CONNECTION_FAILED="Could not connect to the cache store to fetch the cache data." COM_CACHE_ERROR_CACHE_DRIVER_UNSUPPORTED="Could not read the cache data, the configured cache handler is not supported by this environment." COM_CACHE_EXPIRED_ITEMS_DELETE_ERROR="Error clearing cache group(s): %s."