Title.
if ($title && $page && isset($matches[$page - 1][0]))
{
$attrs = Utility::parseAttributes($matches[$page - 1][0]);
if (isset($attrs['title']))
{
$row->page_title = $attrs['title'];
}
}
// Reset the text, we already hold it in the $text array.
$row->text = '';
if ($style === 'pages')
{
// Display TOC.
if ($hasToc)
{
$this->_createToc($row, $matches, $page);
}
else
{
$row->toc = '';
}
// Traditional mos page navigation
$pageNav = new Pagination($n, $page, 1);
// Flag indicates to not add limitstart=0 to URL
$pageNav->hideEmptyLimitstart = true;
// Page counter.
$row->text .= '';
$row->text .= $pageNav->getPagesCounter();
$row->text .= '
';
// Page text.
$text[$page] = str_replace('
', '', $text[$page]);
$row->text .= $text[$page];
// $row->text .= '
';
$row->text .= '';
}
else
{
$t[] = $text[0];
if ($style === 'tabs')
{
$t[] = (string) HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'article' . $row->id . '-' . $style . '0', 'view' => 'tabs']);
}
else
{
$t[] = (string) HTMLHelper::_('bootstrap.startAccordion', 'myAccordion', array('active' => 'article' . $row->id . '-' . $style . '0'));
}
foreach ($text as $key => $subtext)
{
$index = 'article' . $row->id . '-' . $style . $key;
if ($key >= 1)
{
$match = $matches[$key - 1];
$match = (array) Utility::parseAttributes($match[0]);
if (isset($match['alt']))
{
$title = stripslashes($match['alt']);
}
elseif (isset($match['title']))
{
$title = stripslashes($match['title']);
}
else
{
$title = Text::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $key + 1);
}
if ($style === 'tabs')
{
$t[] = (string) HTMLHelper::_('uitab.addTab', 'myTab', $index, $title);
}
else
{
$t[] = (string) HTMLHelper::_('bootstrap.addSlide', 'myAccordion', $title, $index);
}
$t[] = (string) $subtext;
if ($style === 'tabs')
{
$t[] = (string) HTMLHelper::_('uitab.endTab');
}
else
{
$t[] = (string) HTMLHelper::_('bootstrap.endSlide');
}
}
}
if ($style === 'tabs')
{
$t[] = (string) HTMLHelper::_('uitab.endTabSet');
}
else
{
$t[] = (string) HTMLHelper::_('bootstrap.endAccordion');
}
$row->text = implode(' ', $t);
}
}
}
/**
* Creates a Table of Contents for the pagebreak
*
* @param object &$row The article object. Note $article->text is also available
* @param array &$matches Array of matches of a regex in onContentPrepare
* @param integer &$page The 'page' number
*
* @return void
*
* @since 1.6
*/
protected function _createToc(&$row, &$matches, &$page)
{
$heading = $row->title ?? Text::_('PLG_CONTENT_PAGEBREAK_NO_TITLE');
$input = Factory::getApplication()->input;
$limitstart = $input->getUint('limitstart', 0);
$showall = $input->getInt('showall', 0);
$headingtext = '';
if ($this->params->get('article_index', 1) == 1)
{
$headingtext = Text::_('PLG_CONTENT_PAGEBREAK_ARTICLE_INDEX');
if ($this->params->get('article_index_text'))
{
$headingtext = htmlspecialchars($this->params->get('article_index_text'), ENT_QUOTES, 'UTF-8');
}
}
// TOC first Page link.
$this->list[1] = new stdClass;
$this->list[1]->link = RouteHelper::getArticleRoute($row->slug, $row->catid, $row->language);
$this->list[1]->title = $heading;
$this->list[1]->active = ($limitstart === 0 && $showall === 0);
$i = 2;
foreach ($matches as $bot)
{
if (@$bot[0])
{
$attrs2 = Utility::parseAttributes($bot[0]);
if (@$attrs2['alt'])
{
$title = stripslashes($attrs2['alt']);
}
elseif (@$attrs2['title'])
{
$title = stripslashes($attrs2['title']);
}
else
{
$title = Text::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}
}
else
{
$title = Text::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}
$this->list[$i] = new stdClass;
$this->list[$i]->link = RouteHelper::getArticleRoute($row->slug, $row->catid, $row->language) . '&limitstart=' . ($i - 1);
$this->list[$i]->title = $title;
$this->list[$i]->active = ($limitstart === $i - 1);
$i++;
}
if ($this->params->get('showall'))
{
$this->list[$i] = new stdClass;
$this->list[$i]->link = RouteHelper::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=1';
$this->list[$i]->title = Text::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES');
$this->list[$i]->active = ($limitstart === $i - 1);
}
$list = $this->list;
$path = PluginHelper::getLayoutPath('content', 'pagebreak', 'toc');
ob_start();
include $path;
$row->toc = ob_get_clean();
}
/**
* Creates the navigation for the item
*
* @param object &$row The article object. Note $article->text is also available
* @param int $page The page number
* @param int $n The total number of pages
*
* @return void
*
* @since 1.6
*/
protected function _createNavigation(&$row, $page, $n)
{
$links = array(
'next' => '',
'previous' => '',
);
if ($page < $n - 1)
{
$links['next'] = RouteHelper::getArticleRoute($row->slug, $row->catid, $row->language) . '&limitstart=' . ($page + 1);
}
if ($page > 0)
{
$links['previous'] = RouteHelper::getArticleRoute($row->slug, $row->catid, $row->language);
if ($page > 1)
{
$links['previous'] .= '&limitstart=' . ($page - 1);
}
}
$path = PluginHelper::getLayoutPath('content', 'pagebreak', 'navigation');
ob_start();
include $path;
$row->text .= ob_get_clean();
}
}