Skip to content

Commit

Permalink
Merge pull request #24 from babsgosgens/babs
Browse files Browse the repository at this point in the history
[imp] Moved markup to layout
  • Loading branch information
phproberto committed May 31, 2014
2 parents 86ffbec + d0900a1 commit 3f91d4a
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 125 deletions.
51 changes: 51 additions & 0 deletions layouts/plugins/content/pagebreak/navigation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('JPATH_BASE') or die;

$row = &$displayData[0];
$page = $displayData[1];
$n = $displayData[2];

$pnSpace = '';

if (JText::_('JGLOBAL_LT') || JText::_('JGLOBAL_LT'))
{
$pnSpace = ' ';
}

if ($page < $n - 1)
{
$page_next = $page + 1;

$link_next = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($page_next));

// Next >>
$next = '<a href="' . $link_next . '">' . JText::_('JNEXT') . $pnSpace . JText::_('JGLOBAL_GT') . JText::_('JGLOBAL_GT') . '</a>';
}
else
{
$next = JText::_('JNEXT');
}

if ($page > 0)
{
$page_prev = $page - 1 == 0 ? '' : $page - 1;

$link_prev = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($page_prev));

// << Prev
$prev = '<a href="' . $link_prev . '">' . JText::_('JGLOBAL_LT') . JText::_('JGLOBAL_LT') . $pnSpace . JText::_('JPREV') . '</a>';
}
else
{
$prev = JText::_('JPREV');
}

$row->text .= '<ul><li>' . $prev . ' </li><li>' . $next . '</li></ul>';
105 changes: 105 additions & 0 deletions layouts/plugins/content/pagebreak/toc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('JPATH_BASE') or die;

$row = &$displayData[0];
$matches = &$displayData[1];
$page = &$displayData[2];
$params = &$displayData[3];

$heading = isset($row->title) ? $row->title : JText::_('PLG_CONTENT_PAGEBREAK_NO_TITLE');
$input = JFactory::getApplication()->input;
$limitstart = $input->getUInt('limitstart', 0);
$showall = $input->getInt('showall', 0);

// TOC header.
$row->toc = '<div class="pull-right article-index">';

if ($params->get('article_index') == 1)
{
$headingtext = JText::_('PLG_CONTENT_PAGEBREAK_ARTICLE_INDEX');

if ($params->get('article_index_text'))
{
htmlspecialchars($headingtext = $params->get('article_index_text'));
}

$row->toc .= '<h3>' . $headingtext . '</h3>';
}

// TOC first Page link.
$class = ($limitstart === 0 && $showall === 0) ? 'toclink active' : 'toclink';
$row->toc .= '<ul class="nav nav-tabs nav-stacked">
<li class="' . $class . '">
<a href="' . JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=') . '" class="' . $class . '">'
. $heading .
'</a>
</li>
';

$i = 2;

foreach ($matches as $bot)
{
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($i - 1));

if (@$bot[0])
{
$attrs2 = JUtility::parseAttributes($bot[0]);

if (@$attrs2['alt'])
{
$title = stripslashes($attrs2['alt']);
}
elseif (@$attrs2['title'])
{
$title = stripslashes($attrs2['title']);
}
else
{
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}
}
else
{
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}

$class = ($limitstart == $i - 1) ? 'toclink active' : 'toclink';
$row->toc .= '
<li>
<a href="' . $link . '" class="' . $class . '">'
. $title .
'</a>
</li>
';
$i++;
}

if ($params->get('showall'))
{
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=1&limitstart=');
$class = ($showall == 1) ? 'toclink active' : 'toclink';
$row->toc .= '
<li>
<a href="' . $link . '" class="' . $class . '">'
. JText::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES') .
'</a>
</li>
';
}

$row->toc .= '</ul></div>';
129 changes: 4 additions & 125 deletions plugins/content/pagebreak/pagebreak.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,95 +253,8 @@ public function onContentPrepare($context, &$row, &$params, $page = 0)
*/
protected function _createTOC(&$row, &$matches, &$page)
{
$heading = isset($row->title) ? $row->title : JText::_('PLG_CONTENT_PAGEBREAK_NO_TITLE');
$input = JFactory::getApplication()->input;
$limitstart = $input->getUInt('limitstart', 0);
$showall = $input->getInt('showall', 0);

// TOC header.
$row->toc = '<div class="pull-right article-index">';

if ($this->params->get('article_index') == 1)
{
$headingtext = JText::_('PLG_CONTENT_PAGEBREAK_ARTICLE_INDEX');

if ($this->params->get('article_index_text'))
{
htmlspecialchars($headingtext = $this->params->get('article_index_text'));
}

$row->toc .= '<h3>' . $headingtext . '</h3>';
}

// TOC first Page link.
$class = ($limitstart === 0 && $showall === 0) ? 'toclink active' : 'toclink';
$row->toc .= '<ul class="nav nav-tabs nav-stacked">
<li class="' . $class . '">
<a href="' . JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=') . '" class="' . $class . '">'
. $heading .
'</a>
</li>
';

$i = 2;

foreach ($matches as $bot)
{
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($i - 1));

if (@$bot[0])
{
$attrs2 = JUtility::parseAttributes($bot[0]);

if (@$attrs2['alt'])
{
$title = stripslashes($attrs2['alt']);
}
elseif (@$attrs2['title'])
{
$title = stripslashes($attrs2['title']);
}
else
{
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}
}
else
{
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}

$class = ($limitstart == $i - 1) ? 'toclink active' : 'toclink';
$row->toc .= '
<li>
<a href="' . $link . '" class="' . $class . '">'
. $title .
'</a>
</li>
';
$i++;
}

if ($this->params->get('showall'))
{
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=1&limitstart=');
$class = ($showall == 1) ? 'toclink active' : 'toclink';
$row->toc .= '
<li>
<a href="' . $link . '" class="' . $class . '">'
. JText::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES') .
'</a>
</li>
';
}

$row->toc .= '</ul></div>';
$displayData = array($row,$matches,$page,$this->params);
echo JLayoutHelper::render('plugins.content.pagebreak.toc', $displayData);
}

/**
Expand All @@ -357,41 +270,7 @@ protected function _createTOC(&$row, &$matches, &$page)
*/
protected function _createNavigation(&$row, $page, $n)
{
$pnSpace = '';

if (JText::_('JGLOBAL_LT') || JText::_('JGLOBAL_LT'))
{
$pnSpace = ' ';
}

if ($page < $n - 1)
{
$page_next = $page + 1;

$link_next = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($page_next));

// Next >>
$next = '<a href="' . $link_next . '">' . JText::_('JNEXT') . $pnSpace . JText::_('JGLOBAL_GT') . JText::_('JGLOBAL_GT') . '</a>';
}
else
{
$next = JText::_('JNEXT');
}

if ($page > 0)
{
$page_prev = $page - 1 == 0 ? '' : $page - 1;

$link_prev = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($page_prev));

// << Prev
$prev = '<a href="' . $link_prev . '">' . JText::_('JGLOBAL_LT') . JText::_('JGLOBAL_LT') . $pnSpace . JText::_('JPREV') . '</a>';
}
else
{
$prev = JText::_('JPREV');
}

$row->text .= '<ul><li>' . $prev . ' </li><li>' . $next . '</li></ul>';
$displayData = array($row,$page,$n);
echo JLayoutHelper::render('plugins.content.pagebreak.navigation', $displayData);
}
}

0 comments on commit 3f91d4a

Please sign in to comment.