Skip to content

Commit

Permalink
[3] Pagebreak navigation cosmetic. Icons, aria-label, title, tooltips…
Browse files Browse the repository at this point in the history
… and things (#27398)

* Pagebreak navigation cosmetic. Add $this->list

* Pagebreak navigation. Icons,title,aria-label,other

* Fix Notice: Undefined variable: list, line 287

* Fix: No aria-hidden for button texts
  • Loading branch information
ReLater authored and rdeutz committed Jan 4, 2020
1 parent 8e991cf commit 3e7298c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 28 deletions.
44 changes: 26 additions & 18 deletions plugins/content/pagebreak/pagebreak.php
Expand Up @@ -32,6 +32,14 @@
*/
class PlgContentPagebreak extends JPlugin
{
/**
* The navigation list with all page objects if parameter 'multipage_toc' is active.
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $list = array();

/**
* Plugin that adds a pagebreak into the text and truncates text at that point
*
Expand Down Expand Up @@ -262,7 +270,6 @@ protected function _createToc(&$row, &$matches, &$page)
$limitstart = $input->getUInt('limitstart', 0);
$showall = $input->getInt('showall', 0);
$headingtext = '';
$list = array();

if ($this->params->get('article_index', 1) == 1)
{
Expand All @@ -275,11 +282,11 @@ protected function _createToc(&$row, &$matches, &$page)
}

// TOC first Page link.
$list[1] = new stdClass;
$list[1]->liClass = ($limitstart === 0 && $showall === 0) ? 'toclink active' : 'toclink';
$list[1]->class = $list[1]->liClass;
$list[1]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language));
$list[1]->title = $heading;
$this->list[1] = new stdClass;
$this->list[1]->liClass = ($limitstart === 0 && $showall === 0) ? 'toclink active' : 'toclink';
$this->list[1]->class = $this->list[1]->liClass;
$this->list[1]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language));
$this->list[1]->title = $heading;

$i = 2;

Expand Down Expand Up @@ -307,24 +314,25 @@ protected function _createToc(&$row, &$matches, &$page)
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}

$list[$i] = new stdClass;
$list[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&limitstart=' . ($i - 1));
$list[$i]->title = $title;
$list[$i]->liClass = ($limitstart === $i - 1) ? 'active' : '';
$list[$i]->class = ($limitstart === $i - 1) ? 'toclink active' : 'toclink';
$this->list[$i] = new stdClass;
$this->list[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&limitstart=' . ($i - 1));
$this->list[$i]->title = $title;
$this->list[$i]->liClass = ($limitstart === $i - 1) ? 'active' : '';
$this->list[$i]->class = ($limitstart === $i - 1) ? 'toclink active' : 'toclink';

$i++;
}

if ($this->params->get('showall'))
{
$list[$i] = new stdClass;
$list[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=1');
$list[$i]->liClass = ($showall === 1) ? 'active' : '';
$list[$i]->class = ($showall === 1) ? 'toclink active' : 'toclink';
$list[$i]->title = JText::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES');
$this->list[$i] = new stdClass;
$this->list[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=1');
$this->list[$i]->liClass = ($showall === 1) ? 'active' : '';
$this->list[$i]->class = ($showall === 1) ? 'toclink active' : 'toclink';
$this->list[$i]->title = JText::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES');
}

$list = $this->list;
$path = JPluginHelper::getLayoutPath('content', 'pagebreak', 'toc');
ob_start();
include $path;
Expand All @@ -335,8 +343,8 @@ protected function _createToc(&$row, &$matches, &$page)
* Creates the navigation for the item
*
* @param object &$row The article object. Note $article->text is also available
* @param int $page The total number of pages
* @param int $n The page number
* @param int $page The page number
* @param int $n The total number of pages
*
* @return void
*
Expand Down
27 changes: 17 additions & 10 deletions plugins/content/pagebreak/tmpl/navigation.php
Expand Up @@ -8,24 +8,31 @@
*/

defined('_JEXEC') or die;

JHtml::_('bootstrap.tooltip');
$lang = JFactory::getLanguage();
?>
<ul>
<li>
<?php if ($links['previous']) : ?>
<a href="<?php echo $links['previous']; ?>">
<?php echo trim(str_repeat(JText::_('JGLOBAL_LT'), 2) . ' ' . JText::_('JPREV')); ?>
<?php if ($links['previous']) :
$direction = $lang->isRtl() ? 'right' : 'left';
$title = htmlspecialchars($this->list[$page]->title, ENT_QUOTES, 'UTF-8');
$ariaLabel = JText::_('JPREVIOUS') . ': ' . $title . ' (' . JText::sprintf('JLIB_HTML_PAGE_CURRENT_OF_TOTAL', $page, $n) . ')';
?>
<a class="hasTooltip" href="<?php echo $links['previous']; ?>" title="<?php echo $title; ?>" aria-label="<?php echo $ariaLabel; ?>" rel="prev">
<?php echo '<span class="icon-chevron-' . $direction . '" aria-hidden="true"></span> ' . JText::_('JPREV'); ?>
</a>
<?php else: ?>
<?php echo JText::_('JPREV'); ?>
<?php endif; ?>
</li>
<li>
<?php if ($links['next']) : ?>
<a href="<?php echo $links['next']; ?>">
<?php echo trim(JText::_('JNEXT') . ' ' . str_repeat(JText::_('JGLOBAL_GT'), 2)); ?>
<?php if ($links['next']) :
$direction = $lang->isRtl() ? 'left' : 'right';
$title = htmlspecialchars($this->list[$page + 2]->title, ENT_QUOTES, 'UTF-8');
$ariaLabel = JText::_('JNEXT') . ': ' . $title . ' (' . JText::sprintf('JLIB_HTML_PAGE_CURRENT_OF_TOTAL', ($page + 2), $n) . ')';
?>
<a class="hasTooltip" href="<?php echo $links['next']; ?>" title="<?php echo $title; ?>" aria-label="<?php echo $ariaLabel; ?>" rel="next">
<?php echo JText::_('JNEXT') . ' <span class="icon-chevron-' . $direction . '" aria-hidden="true"></span>'; ?>
</a>
<?php else: ?>
<?php echo JText::_('JNEXT'); ?>
<?php endif; ?>
</li>
</ul>

0 comments on commit 3e7298c

Please sign in to comment.