Пример #1
0
/**
* Page break mambot
*
* <b>Usage:</b>
* <code>{mospagebreak}</code>
* <code>{mospagebreak title="The page title"}</code>
* <code>{mospagebreak title="The page title" toc="1"}</code>
*
* Note that the following syntax is deprecated
* <code>{mospagebreak title=The page title&toc=1}</code>
*
* If <i>title</i> is specified, then a page sub-title is included
*
* If <i>toc</i> is specified, then a table of contents is included
*/
function botMosPaging($published, &$row, &$params, $page = 0)
{
    global $mosConfig_live_site;
    global $mainframe, $Itemid;
    if (!$published || $params->get('intro_only') || $params->get('popup')) {
        $row->text = preg_replace('/{mospagebreak\\s*.*?}/i', '', $row->text);
        return;
    }
    // $bots holds all the mospagebreak mambots
    preg_match_all('/{(mospagebreak)\\s*(.*?)}/i', $row->text, $bots, PREG_SET_ORDER);
    // split the text around the mambot
    $text = preg_split('/{(mospagebreak)\\s*(.*?)}/i', $row->text);
    // count the number of pages
    $n = count($text);
    if ($n > 1) {
        // we have found at least one mambot, therefore at least 2 pages
        // reset the text, we already hold it in the $text array
        $row->text = "";
        $hasToc = false;
        $hasTitle = false;
        $args = array();
        if (@$bots[$page - 1]) {
            // we have a mambot for this page
            if (@$bots[$page - 1][2]) {
                // the mambot has arguments
                parse_str(str_replace('&amp;', '&', $bots[$page - 1][2]), $args);
                if (@$args['toc'] == '1' || @$args['toc'] == 'yes') {
                    $hasToc = true;
                }
                if (@$args['title']) {
                    $hasTitle = true;
                }
            }
        }
        $hasToc = $mainframe->getCfg('multipage_toc');
        if ($hasToc) {
            $link = 'index.php?option=com_content&amp;task=view&amp;id=' . $row->id . '&amp;Itemid=' . $Itemid;
            $row->toc = '<table cellpadding="0" cellspacing="0" class="contenttoc" align="right">';
            $row->toc .= '<tr>';
            $row->toc .= '<th>' . _TOC_JUMPTO . '</th>';
            $row->toc .= '</tr>';
            $row->toc .= '<tr>';
            $row->toc .= '<td><a href="' . sefRelToAbs($link) . '" class="toclink">' . $row->title . '</a></td>';
            $row->toc .= '</tr>';
            $i = 2;
            $nextTitle = _PN_PAGE . ' ' . ($page + 2);
            foreach ($bots as $bot) {
                $link2 = $link . '&amp;limit=1&amp;limitstart=' . ($i - 1);
                if (@$bot[2]) {
                    parse_str(str_replace('&amp;', '&', $bot[2]), $args2);
                    if (@$args2['title']) {
                        $row->toc .= '<tr><td><a href="' . sefRelToAbs($link2) . '" class="toclink">' . $args2['title'] . '</a></td></tr>';
                        if ($page == $i - 2) {
                            $nextTitle = $args2['title'];
                        }
                    } else {
                        $row->toc .= '<tr><td><a href="' . sefRelToAbs($link2) . '" class="toclink">' . _PN_PAGE . ' ' . $i . '</a></td></tr>';
                    }
                } else {
                    $row->toc .= '<tr><td><a href="' . sefRelToAbs($link2) . '" class="toclink">' . _PN_PAGE . ' ' . $i . '</a></td></tr>';
                }
                $i++;
            }
            $row->toc .= '</table>';
        } else {
            $row->toc = '';
        }
        // traditional mos page navigation
        require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php';
        $pageNav = new mosPageNav($n, $page, 1);
        // page counter
        $row->text .= '<div class="pagenavcounter">';
        $row->text .= $pageNav->writeLeafsCounter();
        $row->text .= '</div>';
        // the page text
        $row->text .= $text[$page];
        $row->text .= '<br />';
        $row->text .= '<div class="pagenavbar">';
        if ($hasToc) {
            $link = 'index.php?option=com_content&amp;task=view&amp;id=' . $row->id . '&amp;Itemid=' . $Itemid;
            if ($page < $n - 1) {
                $link_next = $link . '&amp;limit=1&amp;limitstart=' . ($page + 1);
                //$nextTitle  = mosGetParam( $_REQUEST, 'nextTitle ', 0 ); // hack to hide undefined var when error reporting on max
                //$name = isset($args2['title']) ? $nextTitle : "";
                $next = "<a href=\"" . sefRelToAbs($link_next) . "\">" . _CMN_NEXT . _CMN_NEXT_ARROW . "</a>";
            } else {
                $next = _CMN_NEXT;
            }
            if ($page > 0) {
                $link_prev = $link . '&amp;limit=1&amp;limitstart=' . ($page - 1);
                $prev = "<a href=\"" . sefRelToAbs($link_prev) . "\">" . _CMN_PREV_ARROW . _CMN_PREV . "</a>";
            } else {
                $prev = _CMN_PREV;
            }
            $row->text .= '<div>' . $prev . " - " . $next . '</div>';
        }
        // the page links
        if (!$hasToc) {
            $row->text .= $pageNav->writePagesLinks('index.php?option=com_content&amp;task=view&amp;id=' . $row->id . '&amp;Itemid=' . $Itemid);
        }
        $row->text .= '</div><br />';
    }
    return true;
}
Пример #2
0
/**
* Page break mambot
*
* <b>Usage:</b>
* <code>{mospagebreak}</code>
* <code>{mospagebreak title=The page title}</code>
* or
* <code>{mospagebreak heading=The first page}</code>
* or
* <code>{mospagebreak title=The page title&heading=The first page}</code>
* or
* <code>{mospagebreak heading=The first page&title=The page title}</code>
*
*/
function botMosPaging($published, &$row, &$params, $page = 0)
{
    global $mainframe, $Itemid, $database, $_MAMBOTS;
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, 'mospagebreak') === false) {
        return true;
    }
    // expression to search for
    $regex = '/{(mospagebreak)\\s*(.*?)}/i';
    // check whether mambot has been unpublished
    if (!$published || $params->get('intro_only') || $params->get('popup')) {
        $row->text = preg_replace($regex, '', $row->text);
        return;
    }
    // find all instances of mambot and put in $matches
    $matches = array();
    preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
    // split the text around the mambot
    $text = preg_split($regex, $row->text);
    // count the number of pages
    $n = count($text);
    // we have found at least one mambot, therefore at least 2 pages
    if ($n > 1) {
        // check if param query has previously been processed
        if (!isset($_MAMBOTS->_content_mambot_params['mospaging'])) {
            // load mambot params info
            $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mospaging'" . "\n AND folder = 'content'";
            $database->setQuery($query);
            $database->loadObject($mambot);
            // save query to class variable
            $_MAMBOTS->_content_mambot_params['mospaging'] = $mambot;
        }
        // pull query data from class variable
        $mambot = $_MAMBOTS->_content_mambot_params['mospaging'];
        $botParams = new mosParameters($mambot->params);
        $title = $botParams->def('title', 1);
        // adds heading or title to <site> Title
        if ($title) {
            $page_text = $page + 1;
            $row->page_title = _PN_PAGE . ' ' . $page_text;
            if (!$page) {
                // processing for first page
                parse_str(html_entity_decode($matches[0][2]), $args);
                if (@$args['heading']) {
                    //$row->page_title = $args['heading'];
                    $row->page_title = '';
                } else {
                    $row->page_title = '';
                }
            } else {
                if ($matches[$page - 1][2]) {
                    parse_str(html_entity_decode($matches[$page - 1][2]), $args);
                    if (@$args['title']) {
                        $row->page_title = ': ' . stripslashes($args['title']);
                    }
                }
            }
        }
        // reset the text, we already hold it in the $text array
        $row->text = '';
        $hasToc = $mainframe->getCfg('multipage_toc');
        if ($hasToc) {
            // display TOC
            createTOC($row, $matches, $page);
        } else {
            $row->toc = '';
        }
        // traditional mos page navigation
        require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php';
        $pageNav = new mosPageNav($n, $page, 1);
        // page counter
        $row->text .= '<div class="pagenavcounter">';
        $row->text .= $pageNav->writeLeafsCounter();
        $row->text .= '</div>';
        // page text
        $row->text .= $text[$page];
        $row->text .= '<br />';
        $row->text .= '<div class="pagenavbar">';
        // adds navigation between pages to bottom of text
        if ($hasToc) {
            createNavigation($row, $page, $n);
        }
        // page links shown at bottom of page if TOC disabled
        if (!$hasToc) {
            $row->text .= $pageNav->writePagesLinks('index.php?option=com_content&amp;task=view&amp;id=' . $row->id . '&amp;Itemid=' . $Itemid);
        }
        $row->text .= '</div><br />';
    }
    return true;
}
Пример #3
0
/**
* Page break mambot
*
* <strong>Usage:</strong>
* <code>{mospagebreak}</code>
* <code>{mospagebreak title=The page title}</code>
* or
* <code>{mospagebreak heading=The first page}</code>
* or
* <code>{mospagebreak title=The page title&heading=The first page}</code>
* or
* <code>{mospagebreak heading=The first page&title=The page title}</code>
*
*/
function botMosPaging($published, &$row, &$cparams, $page = 0, $params)
{
    global $mainframe, $Itemid, $database, $configuration;
    if (strtolower(get_class($row)) != 'mosextendedcontent') {
        return;
    }
    // expression to search for
    $regex = '/{(mospagebreak)\\s*(.*?)}/i';
    if (!$published || $cparams->get('intro_only') || $cparams->get('popup')) {
        $row->text = preg_replace($regex, '', $row->text);
        return;
    }
    // find all instances of mambot and put in $matches
    $matches = array();
    preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
    // split the text around the mambot
    $text = preg_split($regex, $row->text);
    $matches[0][2] = @html_entity_decode($matches[0][2], ENT_QUOTES, strtoupper($configuration->current_language->charset));
    // count the number of pages
    $n = count($text);
    // we have found at least one mambot, therefore at least 2 pages
    if ($n > 1) {
        // load mambot params info
        $title = $params->def('title', 1);
        // adds heading or title to <site> Title
        if ($title) {
            $page_text = $page + 1;
            $row->page_title = T_('Page') . ' ' . $page_text;
            if (!$page) {
                // processing for first page
                parse_str($matches[0][2], $args);
                if (@$args['heading']) {
                    $row->page_title = $args['heading'];
                } else {
                    $row->page_title = '';
                }
            } else {
                if ($matches[$page - 1][2]) {
                    parse_str($matches[$page - 1][2], $args);
                    if (@$args['title']) {
                        $row->page_title = $args['title'];
                    }
                }
            }
        }
        // reset the text, we already hold it in the $text array
        $row->text = '';
        $hasToc = $mainframe->getCfg('multipage_toc');
        if ($hasToc) {
            // display TOC
            createTOC($row, $matches, $page);
        } else {
            $row->toc = '';
        }
        // traditional mos page navigation
        require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php';
        $pageNav = new mosPageNav($n, $page, 1);
        // page counter
        $row->text .= '<div class="pagenavcounter">';
        $row->text .= $pageNav->writeLeafsCounter();
        $row->text .= '</div>';
        // page text
        $row->text .= $text[$page];
        $row->text .= '<br />';
        $row->text .= '<div class="pagenavbar">';
        // adds navigation between pages to bottom of text
        if ($hasToc) {
            createNavigation($row, $page, $n);
        }
        // page links shown at bottom of page if TOC disabled
        if (!$hasToc) {
            $row->text .= $pageNav->writePagesLinks('index.php?option=com_content&amp;task=view&amp;id=' . $row->id . '&amp;Itemid=' . $Itemid);
        }
        $row->text .= '</div><br />';
    }
    return true;
}