You've already forked joomla_test
first commit
This commit is contained in:
1
plugins/content/pagebreak/index.html
Normal file
1
plugins/content/pagebreak/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
397
plugins/content/pagebreak/pagebreak.php
Normal file
397
plugins/content/pagebreak/pagebreak.php
Normal file
@ -0,0 +1,397 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Content.pagebreak
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
jimport('joomla.utilities.utility');
|
||||
|
||||
/**
|
||||
* Page break plugin
|
||||
*
|
||||
* <b>Usage:</b>
|
||||
* <code><hr class="system-pagebreak" /></code>
|
||||
* <code><hr class="system-pagebreak" title="The page title" /></code>
|
||||
* or
|
||||
* <code><hr class="system-pagebreak" alt="The first page" /></code>
|
||||
* or
|
||||
* <code><hr class="system-pagebreak" title="The page title" alt="The first page" /></code>
|
||||
* or
|
||||
* <code><hr class="system-pagebreak" alt="The first page" title="The page title" /></code>
|
||||
*
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Content.pagebreak
|
||||
* @since 1.6
|
||||
*/
|
||||
class PlgContentPagebreak extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.1
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Plugin that adds a pagebreak into the text and truncates text at that point
|
||||
*
|
||||
* @param string $context The context of the content being passed to the plugin.
|
||||
* @param object &$row The article object. Note $article->text is also available
|
||||
* @param mixed &$params The article params
|
||||
* @param integer $page The 'page' number
|
||||
*
|
||||
* @return mixed Always returns void or true
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function onContentPrepare($context, &$row, &$params, $page = 0)
|
||||
{
|
||||
$canProceed = $context == 'com_content.article';
|
||||
|
||||
if (!$canProceed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$style = $this->params->get('style', 'pages');
|
||||
|
||||
// Expression to search for.
|
||||
$regex = '#<hr(.*)class="system-pagebreak"(.*)\/>#iU';
|
||||
|
||||
$input = JFactory::getApplication()->input;
|
||||
|
||||
$print = $input->getBool('print');
|
||||
$showall = $input->getBool('showall');
|
||||
|
||||
if (!$this->params->get('enabled', 1))
|
||||
{
|
||||
$print = true;
|
||||
}
|
||||
|
||||
if ($print)
|
||||
{
|
||||
$row->text = preg_replace($regex, '<br />', $row->text);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Simple performance check to determine whether bot should process further.
|
||||
if (JString::strpos($row->text, 'class="system-pagebreak') === false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$view = $input->getString('view');
|
||||
$full = $input->getBool('fullview');
|
||||
|
||||
if (!$page)
|
||||
{
|
||||
$page = 0;
|
||||
}
|
||||
|
||||
if ($params->get('intro_only') || $params->get('popup') || $full || $view != 'article')
|
||||
{
|
||||
$row->text = preg_replace($regex, '', $row->text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Find all instances of plugin and put in $matches.
|
||||
$matches = array();
|
||||
preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
|
||||
|
||||
if (($showall && $this->params->get('showall', 1)))
|
||||
{
|
||||
$hasToc = $this->params->get('multipage_toc', 1);
|
||||
|
||||
if ($hasToc)
|
||||
{
|
||||
// Display TOC.
|
||||
$page = 1;
|
||||
$this->_createToc($row, $matches, $page);
|
||||
}
|
||||
else
|
||||
{
|
||||
$row->toc = '';
|
||||
}
|
||||
|
||||
$row->text = preg_replace($regex, '<br />', $row->text);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Split the text around the plugin.
|
||||
$text = preg_split($regex, $row->text);
|
||||
|
||||
// Count the number of pages.
|
||||
$n = count($text);
|
||||
|
||||
// We have found at least one plugin, therefore at least 2 pages.
|
||||
if ($n > 1)
|
||||
{
|
||||
$title = $this->params->get('title', 1);
|
||||
$hasToc = $this->params->get('multipage_toc', 1);
|
||||
|
||||
// Adds heading or title to <site> Title.
|
||||
if ($title)
|
||||
{
|
||||
if ($page)
|
||||
{
|
||||
if ($page && @$matches[$page - 1][2])
|
||||
{
|
||||
$attrs = JUtility::parseAttributes($matches[$page - 1][1]);
|
||||
|
||||
if (@$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 JPagination($n, $page, 1);
|
||||
|
||||
// Page counter.
|
||||
$row->text .= '<div class="pagenavcounter">';
|
||||
$row->text .= $pageNav->getPagesCounter();
|
||||
$row->text .= '</div>';
|
||||
|
||||
// Page text.
|
||||
$text[$page] = str_replace('<hr id="system-readmore" />', '', $text[$page]);
|
||||
$row->text .= $text[$page];
|
||||
|
||||
// $row->text .= '<br />';
|
||||
$row->text .= '<div class="pager">';
|
||||
|
||||
// Adds navigation between pages to bottom of text.
|
||||
if ($hasToc)
|
||||
{
|
||||
$this->_createNavigation($row, $page, $n);
|
||||
}
|
||||
|
||||
// Page links shown at bottom of page if TOC disabled.
|
||||
if (!$hasToc)
|
||||
{
|
||||
$row->text .= $pageNav->getPagesLinks();
|
||||
}
|
||||
|
||||
$row->text .= '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$t[] = $text[0];
|
||||
|
||||
$t[] = (string) JHtml::_($style . '.start', 'article' . $row->id . '-' . $style);
|
||||
|
||||
foreach ($text as $key => $subtext)
|
||||
{
|
||||
if ($key >= 1)
|
||||
{
|
||||
$match = $matches[$key - 1];
|
||||
$match = (array) JUtility::parseAttributes($match[0]);
|
||||
|
||||
if (isset($match['alt']))
|
||||
{
|
||||
$title = stripslashes($match['alt']);
|
||||
}
|
||||
elseif (isset($match['title']))
|
||||
{
|
||||
$title = stripslashes($match['title']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $key + 1);
|
||||
}
|
||||
|
||||
$t[] = (string) JHtml::_($style . '.panel', $title, 'article' . $row->id . '-' . $style . $key);
|
||||
}
|
||||
|
||||
$t[] = (string) $subtext;
|
||||
}
|
||||
|
||||
$t[] = (string) JHtml::_($style . '.end');
|
||||
|
||||
$row->text = implode(' ', $t);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = 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>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
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>';
|
||||
}
|
||||
}
|
78
plugins/content/pagebreak/pagebreak.xml
Normal file
78
plugins/content/pagebreak/pagebreak.xml
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.1" type="plugin" group="content">
|
||||
<name>plg_content_pagebreak</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>November 2005</creationDate>
|
||||
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>PLG_CONTENT_PAGEBREAK_XML_DESCRIPTION</description>
|
||||
<files>
|
||||
<filename plugin="pagebreak">pagebreak.php</filename>
|
||||
<filename>index.html</filename>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">en-GB.plg_content_pagebreak.ini</language>
|
||||
<language tag="en-GB">en-GB.plg_content_pagebreak.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
|
||||
<fieldset name="basic">
|
||||
<field name="title" type="radio"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
description="PLG_CONTENT_PAGEBREAK_SITE_TITLE_DESC"
|
||||
label="PLG_CONTENT_PAGEBREAK_SITE_TITLE_LABEL"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
<field name="article_index" type="radio"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
description="PLG_CONTENT_PAGEBREAK_SITE_ARTICLEINDEX_DESC"
|
||||
label="PLG_CONTENT_PAGEBREAK_SITE_ARTICLEINDEX_LABEL"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
<field name="article_index_text" type="text" default=""
|
||||
label="PLG_CONTENT_PAGEBREAK_SITE_ARTICLEINDEXTEXT"
|
||||
description="PLG_CONTENT_PAGEBREAK_SITE_ARTICLEINDEXTEXT_DESC" />
|
||||
|
||||
<field name="multipage_toc" type="radio"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
description="PLG_CONTENT_PAGEBREAK_TOC_DESC"
|
||||
label="PLG_CONTENT_PAGEBREAK_TOC_LABEL"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="showall" type="radio"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
description="PLG_CONTENT_PAGEBREAK_SHOW_ALL_DESC"
|
||||
label="PLG_CONTENT_PAGEBREAK_SHOW_ALL_LABEL"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
<field name="style" type="list"
|
||||
default="pages"
|
||||
description="PLG_CONTENT_PAGEBREAK_STYLE_DESC"
|
||||
label="PLG_CONTENT_PAGEBREAK_STYLE_LABEL"
|
||||
>
|
||||
<option value="pages">PLG_CONTENT_PAGEBREAK_PAGES</option>
|
||||
<option value="sliders">PLG_CONTENT_PAGEBREAK_SLIDERS</option>
|
||||
<option value="tabs">PLG_CONTENT_PAGEBREAK_TABS</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
Reference in New Issue
Block a user