Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[com_finder] maps view: Indexed content counting and other improvements #10257

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 33 additions & 8 deletions administrator/components/com_finder/models/maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,39 @@ protected function getListQuery()

// Select all fields from the table.
$query->select('a.*')
->select('s.count_published')
->select('s.count_unpublished')
->from($db->quoteName('#__finder_taxonomy', 'a'))
->where($db->quoteName('a.parent_id') . ' <> 0');

// Self-join to get children.
$query->select('COUNT(b.id) AS num_children')
->join('LEFT', $db->quoteName('#__finder_taxonomy', 'b') . ' ON ' . $db->quoteName('b.parent_id') . ' = ' . $db->quoteName('a.id'));

// Join to get the map links
$query->select('COUNT(c.node_id) AS num_nodes')
->join('LEFT', $db->quoteName('#__finder_taxonomy_map', 'c') . ' ON ' . $db->quoteName('c.node_id') . ' = ' . $db->quoteName('a.id'))
->group('a.id, a.parent_id, a.title, a.state, a.access, a.ordering');
->join('LEFT', $db->quoteName('#__finder_taxonomy', 'b') . ' ON ' . $db->qn('b.parent_id') . ' = ' . $db->qn('a.id'));

// Join to get the map links.
$stateSubQuery1 = $db->getQuery(true);
$stateSubQuery1->select($db->quoteName('mp.node_id'))
->select('COUNT(mp.node_id) AS count_published')
->from($db->quoteName('#__finder_links', 'lp'))
->join('LEFT', $db->quoteName('#__finder_taxonomy_map', 'mp') . ' ON ' . $db->qn('lp.link_id') . ' = ' . $db->qn('mp.link_id'))
->where($db->quoteName('lp.published') . ' = 1')
->group($db->quoteName('mp.node_id'));

$stateSubQuery2 = $db->getQuery(true);
$stateSubQuery2->select($db->quoteName('mu.node_id'))
->select('COUNT(mu.node_id) AS count_unpublished')
->from($db->quoteName('#__finder_links', 'lu'))
->join('LEFT', $db->quoteName('#__finder_taxonomy_map', 'mu') . ' ON ' . $db->qn('lu.link_id') . ' = ' . $db->qn('mu.link_id'))
->where($db->quoteName('lu.published') . ' = 0')
->group($db->quoteName('mu.node_id'));

$stateQuery = $db->getQuery(true);
$stateQuery->select('s1.*')
->select('s2.count_unpublished')
->from('(' . $stateSubQuery1 . ') AS s1')
->join('LEFT', '(' . $stateSubQuery2 . ') AS s2 ON ' . $db->qn('s1.node_id') . ' = ' . $db->qn('s2.node_id'));

$query->join('LEFT', '(' . $stateQuery . ') AS s ON ' . $db->qn('s.node_id') . ' = ' . $db->qn('a.id'));

// Calculate levels.
$levelQuery = $db->getQuery(true);
Expand All @@ -186,13 +208,16 @@ protected function getListQuery()
$levelQuery2->select('b.title AS branch_title, 2 as level')
->select($db->quoteName('a.id'))
->from($db->quoteName('#__finder_taxonomy', 'a'))
->join('LEFT', $db->quoteName('#__finder_taxonomy', 'b') . ' ON ' . $db->quoteName('a.parent_id') . ' = ' . $db->quoteName('b.id'))
->join('LEFT', $db->quoteName('#__finder_taxonomy', 'b') . ' ON ' . $db->qn('a.parent_id') . ' = ' . $db->qn('b.id'))
->where($db->quoteName('a.parent_id') . ' NOT IN (0, 1)');

$levelQuery->union($levelQuery2);

// Join to get the levels.
$query->join('LEFT', '(' . $levelQuery . ') AS d ON ' . $db->quoteName('d.id') . ' = ' . $db->quoteName('a.id'));
$query->join('LEFT', '(' . $levelQuery . ') AS d ON ' . $db->qn('d.id') . ' = ' . $db->qn('a.id'));

// Group
$query->group('a.id, a.parent_id, a.title, a.state, a.access, a.ordering');

// Self-join to get the parent title.
$query->select('e.title AS parent_title')
Expand Down
50 changes: 36 additions & 14 deletions administrator/components/com_finder/views/maps/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('bootstrap.tooltip');

$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$lang = JFactory::getLanguage();

$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$lang = JFactory::getLanguage();
$branchFilter = $this->escape($this->state->get('filter.branch'));
$colSpan = $branchFilter ? 5 : 6;
JText::script('COM_FINDER_MAPS_CONFIRM_DELETE_PROMPT');

JFactory::getDocument()->addScriptDeclaration('
Expand Down Expand Up @@ -64,17 +65,24 @@
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'd.branch_title', $listDirn, $listOrder); ?>
</th>
<?php if (!$branchFilter) : ?>
<th width="1%" class="nowrap center">
<?php echo JText::_('COM_FINDER_HEADING_CHILDREN'); ?>
</th>
<?php endif; ?>
<th width="1%" class="nowrap center">
<i class="icon-publish"></i>
<span class="hidden-phone"><?php echo JText::_('COM_FINDER_MAPS_COUNT_PUBLISHED_ITEMS'); ?></span>
</th>
<th width="1%" class="nowrap center">
<?php echo JText::_('COM_FINDER_HEADING_NODES'); ?>
<i class="icon-unpublish"></i>
<span class="hidden-phone"><?php echo JText::_('COM_FINDER_MAPS_COUNT_UNPUBLISHED_ITEMS'); ?></span>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<td colspan="<?php echo $colSpan; ?>">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
Expand All @@ -90,9 +98,6 @@
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'maps.', $canChange, 'cb'); ?>
</td>
<td>
<?php if ((int) $item->num_children === 0) : ?>
<span class="gi">&mdash;</span>
<?php endif; ?>
<?php
if (trim($item->parent_title, '**') == 'Language')
{
Expand All @@ -103,24 +108,41 @@
$key = FinderHelperLanguage::branchSingular($item->title);
$title = $lang->hasKey($key) ? JText::_($key) : $item->title;
}
echo $title;
?>
<?php if ((int) $item->num_children === 0) : ?>
<span class="gi">&mdash;</span>
<?php endif; ?>
<label for="cb<?php echo $i; ?>" style="display:inline-block;">
<?php echo $this->escape($title); ?>
</label>
<?php if ($this->escape(trim($title, '**')) == 'Language' && JLanguageMultilang::isEnabled()) : ?>
<strong><?php echo JText::_('COM_FINDER_MAPS_MULTILANG'); ?></strong>
<?php endif; ?>
</td>
<?php if (!$branchFilter) : ?>
<td class="center btns">
<?php if ((int) $item->num_children !== 0) : ?>
<span class="badge <?php if ($item->num_children > 0) echo "badge-info"; ?>"><?php echo $item->num_children; ?></span>
<a href="<?php echo JRoute::_('index.php?option=com_finder&view=maps&filter[branch]=' . $item->id); ?>">
<span class="badge <?php if ($item->num_children > 0) echo "badge-info"; ?>"><?php echo $item->num_children; ?></span></a>
<?php else : ?>
-
<?php endif; ?>
</td>
<?php endif; ?>
<td class="center btns">
<?php if ((int) $item->num_children === 0) : ?>
<a class="badge <?php if ((int) $item->count_published > 0) echo "badge-success"; ?>" title="<?php echo JText::_('COM_FINDER_MAPS_COUNT_PUBLISHED_ITEMS'); ?>" href="<?php echo JRoute::_('index.php?option=com_finder&view=index&filter[state]=1&filter[content_map]=' . $item->id); ?>">
<?php echo (int) $item->count_published; ?></a>
<?php else : ?>
&nbsp;
-
<?php endif; ?>
</td>
<td class="center btns">
<?php if ((int) $item->num_children === 0) : ?>
<span class="badge <?php if ($item->num_nodes > 0) echo "badge-info"; ?>"><?php echo $item->num_nodes; ?></span>
<a class="badge <?php if ((int) $item->count_unpublished > 0) echo "badge-important"; ?>" title="<?php echo JText::_('COM_FINDER_MAPS_COUNT_UNPUBLISHED_ITEMS'); ?>" href="<?php echo JRoute::_('index.php?option=com_finder&view=index&filter[state]=0&filter[content_map]=' . $item->id); ?>">
<?php echo (int) $item->count_unpublished; ?></a>
<?php else : ?>
&nbsp;
-
<?php endif; ?>
</td>
</tr>
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.com_finder.ini
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ COM_FINDER_MAPS="Maps"
COM_FINDER_MAPS_BRANCH_LINK="Select to show the children in this branch."
COM_FINDER_MAPS_BRANCHES="Branches Only"
COM_FINDER_MAPS_CONFIRM_DELETE_PROMPT="Are you sure you want to delete the selected maps(s)?"
COM_FINDER_MAPS_COUNT_PUBLISHED_ITEMS="Published Indexed Content"
COM_FINDER_MAPS_COUNT_UNPUBLISHED_ITEMS="Unpublished Indexed Content"
COM_FINDER_MAPS_MULTILANG="Note: Language filter system plugin has been enabled, so this branch will not be used."
COM_FINDER_MAPS_NO_CONTENT="No results to display. Either no content has been indexed or no content meets your filter criteria."
COM_FINDER_MAPS_RETURN_TO_BRANCHES="Return to Map Groups"
Expand Down