<?php
/**
* @version $Id: pagebreak.php 10576 2008-07-21 12:50:09Z ircmaxell $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent( 'onPrepareContent', 'plgContentPagebreak' );
/**
* 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>
*
*/
function plgContentPagebreak( &$row, &$params, $page=0 )
{
// expression to search for
$regex = '#<hr([^>]*?)class=(\"|\')system-pagebreak(\"|\')([^>]*?)\/*>#iU';
// Get Plugin info
$plugin =& JPluginHelper::getPlugin('content', 'pagebreak');
$pluginParams = new JParameter( $plugin->params );
$print = JRequest::getBool('print');
$showall = JRequest::getBool('showall');
if (!$pluginParams->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 ( strpos( $row->text, 'class="system-pagebreak' ) === false && strpos( $row->text, 'class=\'system-pagebreak' ) === false ) {
return true;
}
$db =& JFactory::getDBO();
$full = JRequest::getBool('fullview');
if(!$page) {
$page = 0;
}
// check whether plugin has been unpublished
if (!JPluginHelper::isEnabled('content', 'pagebreak') || $params->get( 'intro_only' )|| $params->get( 'popup' ) || $full) {
$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 && $pluginParams->get('showall', 1) ))
{
$hasToc = $pluginParams->get( 'multipage_toc', 1 );
if ( $hasToc ) {
// display TOC
$page = 1;
plgContentCreateTOC( $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)
{
// Get pl
Time to create page: 0.067 seconds