Skip to content

Commit 682923c

Browse files
Phil E. TaylorQuy
andauthored
[4] Smart Search: Content Maps Empty State (#33491)
Co-authored-by: Quy <[email protected]>
1 parent 2865c95 commit 682923c

File tree

4 files changed

+77
-18
lines changed

4 files changed

+77
-18
lines changed

administrator/components/com_finder/src/Model/MapsModel.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
1818
use Joomla\CMS\MVC\Model\ListModel;
1919
use Joomla\CMS\Plugin\PluginHelper;
20+
use Joomla\Database\DatabaseQuery;
2021

2122
/**
2223
* Maps model for the Finder package.
@@ -392,4 +393,23 @@ public function purge()
392393

393394
return true;
394395
}
396+
397+
/**
398+
* Manipulate the query to be used to evaluate if this is an Empty State to provide specific conditions for this extension.
399+
*
400+
* @return DatabaseQuery
401+
*
402+
* @since __DEPLOY_VERSION__
403+
*/
404+
protected function getEmptyStateQuery()
405+
{
406+
$query = parent::getEmptyStateQuery();
407+
408+
$title = 'ROOT';
409+
410+
$query->where($this->_db->quoteName('title') . ' <> :title')
411+
->bind(':title', $title);
412+
413+
return $query;
414+
}
395415
}

administrator/components/com_finder/src/View/Maps/HtmlView.php

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class HtmlView extends BaseHtmlView
7878
*/
7979
public $activeFilters;
8080

81+
/**
82+
* @var boolean
83+
*
84+
* @since __DEPLOY_VERSION__
85+
*/
86+
private $isEmptyState = false;
87+
8188
/**
8289
* Method to display the view.
8390
*
@@ -100,6 +107,11 @@ public function display($tpl = null)
100107
$this->filterForm = $this->get('FilterForm');
101108
$this->activeFilters = $this->get('ActiveFilters');
102109

110+
if ($this->total === 0 && $this->isEmptyState = $this->get('isEmptyState'))
111+
{
112+
$this->setLayout('emptystate');
113+
}
114+
103115
// Check for errors.
104116
if (count($errors = $this->get('Errors')))
105117
{
@@ -128,29 +140,32 @@ protected function addToolbar()
128140
// Get the toolbar object instance
129141
$toolbar = Toolbar::getInstance('toolbar');
130142

131-
if ($canDo->get('core.edit.state'))
143+
if (!$this->isEmptyState)
132144
{
133-
$dropdown = $toolbar->dropdownButton('status-group')
134-
->text('JTOOLBAR_CHANGE_STATUS')
135-
->toggleSplit(false)
136-
->icon('icon-ellipsis-h')
137-
->buttonClass('btn btn-action')
138-
->listCheck(true);
139-
140-
$childBar = $dropdown->getChildToolbar();
145+
if ($canDo->get('core.edit.state'))
146+
{
147+
$dropdown = $toolbar->dropdownButton('status-group')
148+
->text('JTOOLBAR_CHANGE_STATUS')
149+
->toggleSplit(false)
150+
->icon('icon-ellipsis-h')
151+
->buttonClass('btn btn-action')
152+
->listCheck(true);
141153

142-
$childBar->publish('maps.publish')->listCheck(true);
143-
$childBar->unpublish('maps.unpublish')->listCheck(true);
144-
}
154+
$childBar = $dropdown->getChildToolbar();
145155

146-
ToolbarHelper::divider();
147-
$toolbar->appendButton('Popup', 'bars', 'COM_FINDER_STATISTICS', 'index.php?option=com_finder&view=statistics&tmpl=component', 550, 350, '', '', '', Text::_('COM_FINDER_STATISTICS_TITLE'));
148-
ToolbarHelper::divider();
156+
$childBar->publish('maps.publish')->listCheck(true);
157+
$childBar->unpublish('maps.unpublish')->listCheck(true);
158+
}
149159

150-
if ($canDo->get('core.delete'))
151-
{
152-
ToolbarHelper::deleteList('', 'maps.delete');
153160
ToolbarHelper::divider();
161+
$toolbar->appendButton('Popup', 'bars', 'COM_FINDER_STATISTICS', 'index.php?option=com_finder&view=statistics&tmpl=component', 550, 350, '', '', '', Text::_('COM_FINDER_STATISTICS_TITLE'));
162+
ToolbarHelper::divider();
163+
164+
if ($canDo->get('core.delete'))
165+
{
166+
ToolbarHelper::deleteList('', 'maps.delete');
167+
ToolbarHelper::divider();
168+
}
154169
}
155170

156171
if ($canDo->get('core.admin') || $canDo->get('core.options'))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* @package Joomla.Administrator
4+
* @subpackage com_finder
5+
*
6+
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
7+
* @license GNU General Public License version 2 or later; see LICENSE.txt
8+
*/
9+
10+
defined('_JEXEC') or die;
11+
12+
use Joomla\CMS\Language\Text;
13+
use Joomla\CMS\Layout\LayoutHelper;
14+
15+
$displayData = [
16+
'textPrefix' => 'COM_FINDER',
17+
'formURL' => 'index.php?option=com_finder&view=maps',
18+
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help4.x:Smart_Search:_Content_Maps',
19+
'icon' => 'icon-search-plus finder',
20+
'title' => Text::_('COM_FINDER_MAPS_TOOLBAR_TITLE')
21+
];
22+
23+
echo LayoutHelper::render('joomla.content.emptystate', $displayData);

administrator/language/en-GB/com_finder.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ COM_FINDER_CONFIGURATION="Smart Search: Options"
5656
COM_FINDER_CREATE_FILTER="Create a filter."
5757
COM_FINDER_EDIT_FILTER="Edit Filter"
5858
COM_FINDER_EMPTYSTATE_BUTTON_ADD="Start the indexer"
59+
COM_FINDER_EMPTYSTATE_CONTENT="No content has been indexed or you have deleted all your maps. Please visit the Smart Search Index page to reindex your content."
5960
COM_FINDER_EMPTYSTATE_SEARCHES_CONTENT="There are no phrases used for site searching to view yet."
6061
COM_FINDER_FIELD_CREATED_BY_ALIAS_LABEL="Alias"
6162
COM_FINDER_FIELD_CREATED_BY_LABEL="Created By"

0 commit comments

Comments
 (0)