From f53b42c8cc49860cc871fc0cc6190d8bd6928dad Mon Sep 17 00:00:00 2001 From: chmst Date: Fri, 24 Sep 2021 07:49:35 +0200 Subject: [PATCH] Replace pr #460, add empty state --- .../src/View/Weblinks/HtmlView.php | 15 +++++++++- .../com_weblinks/tmpl/weblinks/emptystate.php | 29 +++++++++++++++++++ .../language/en-GB/com_weblinks.ini | 3 ++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/administrator/components/com_weblinks/tmpl/weblinks/emptystate.php diff --git a/src/administrator/components/com_weblinks/src/View/Weblinks/HtmlView.php b/src/administrator/components/com_weblinks/src/View/Weblinks/HtmlView.php index 110370f..220514d 100644 --- a/src/administrator/components/com_weblinks/src/View/Weblinks/HtmlView.php +++ b/src/administrator/components/com_weblinks/src/View/Weblinks/HtmlView.php @@ -61,6 +61,14 @@ class HtmlView extends BaseHtmlView */ public $activeFilters; + /** + * Is this view an Empty State + * + * @var boolean + * @since 4.0.0 + */ + private $isEmptyState = false; + /** * Display the view. * @@ -82,6 +90,11 @@ class HtmlView extends BaseHtmlView throw new GenericDataException(implode("\n", $errors), 500); } + if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // We don't need toolbar in the modal layout. if ($this->getLayout() !== 'modal') { @@ -130,7 +143,7 @@ class HtmlView extends BaseHtmlView ToolbarHelper::addNew('weblink.add'); } - if ($canDo->get('core.edit.state')) + if (!$this->isEmptyState && $canDo->get('core.edit.state')) { $dropdown = $toolbar->dropdownButton('status-group') ->text('JTOOLBAR_CHANGE_STATUS') diff --git a/src/administrator/components/com_weblinks/tmpl/weblinks/emptystate.php b/src/administrator/components/com_weblinks/tmpl/weblinks/emptystate.php new file mode 100644 index 0000000..8091dd2 --- /dev/null +++ b/src/administrator/components/com_weblinks/tmpl/weblinks/emptystate.php @@ -0,0 +1,29 @@ + 'COM_WEBLINKS', + 'formURL' => 'index.php?option=com_weblinks', + 'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help4.x:Weblinks', + 'icon' => 'icon-globe weblink', +]; + +$user = Factory::getApplication()->getIdentity(); + +if ($user->authorise('core.create', 'com_weblinks') || count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) +{ + $displayData['createURL'] = 'index.php?option=com_weblinks&task=weblink.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); \ No newline at end of file diff --git a/src/administrator/language/en-GB/com_weblinks.ini b/src/administrator/language/en-GB/com_weblinks.ini index 0898fda..afb6503 100644 --- a/src/administrator/language/en-GB/com_weblinks.ini +++ b/src/administrator/language/en-GB/com_weblinks.ini @@ -14,6 +14,9 @@ COM_WEBLINKS_COMPONENT_LABEL="Web Link" COM_WEBLINKS_CONFIGURATION="Web Links Manager Options" COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC="These settings determine how the Web Links Component will integrate with other extensions." COM_WEBLINKS_EDIT_WEBLINK="Edit Web Link" +COM_WEBLINKS_EMPTYSTATE_BUTTON_ADD="Add your first Web Link" +COM_WEBLINKS_EMPTYSTATE_CONTENT="Add, edit and remove links to other web sites on your Joomla! web site, and organize them into categories. You can then display these links on your site, and optionally let visitors add new links." +COM_WEBLINKS_EMPTYSTATE_TITLE="No Web Links have been created yet." COM_WEBLINKS_ERROR_UNIQUE_ALIAS="Another Web Link from this category has the same alias (remember it may be a trashed item)." COM_WEBLINKS_ERR_TABLES_NAME="There is already a Web Link with that name in this category. Please try again." COM_WEBLINKS_ERR_TABLES_PROVIDE_URL="Please provide a valid URL"