SPIP. Разбить статью на несколько страниц

Очень часто на медийных сайтах, в первую очередь на сайтах газет и других печатных изданий большая статья автоматически разбивается на несколько страниц.

Пример можно посмотреть по ссылке:
http://www.nytimes.com/2011/12/25/business/bourbons-all-american-roar.html?ref=global-home

Что бы такой функционал добавить на SPIP сайт необходимо создать новый фильтр. Информацию о нем подсказал Gilles Vincent, за что ему отдельное спасибо.

Исходный код фильтра

/*
*   +----------------------------------+
*    Nom du Filtre : decouper_en_page                                              
*   +----------------------------------+
*    Date : Vendredi 6 juin 2003
 *    Auteur :  "gpl"  : gpl@macplus.org  
*              Aurelien PIERARD : aurelien.pierard@sig.premier-ministre.gouv.fr
 *   +-------------------------------------+
*    Fonctions de ce filtre :
*        Il sert a presenter un article sur plusieurs pages  
*   +-------------------------------------+
*  
* Pour toute suggestion, remarque, proposition d'ajout
 * reportez-vous au forum de l'article :
* http://www.uzine.net/spip_contrib/article.php3?id_article=62
*/


function decouper_en_page($text,$id_article) {
        $nextart = $_GET['artsuite'];
       
       if (empty($nextart)) $nextart = 0;
   
       // page split (separator : "-----")        
       $page = split('-----', $text);
        // Total pages number
       $num_pages = count($page);

       // If only one page, or at the result of a seach, return everything.
       if ($num_pages == 1 || !empty($var_recherche) || $nextart < 0 || $nextart > $num_pages) {
            // Add anchors to <h3>
           $text = preg_replace("|\{\{\{(.*)\}\}\}|U","<a id=\"sommaire_#NB_TITRE_DE_MON_ARTICLE#\"></a>$0", $text);
           $array = explode("#NB_TITRE_DE_MON_ARTICLE#" , $text);
            $res =count($array);
           $i =1;
           $text=$array[0];
           while($i<$res){
               $text=$text.$i.$array[$i];
               $i++;
           }
           return $text;
        }

       $p_prec = $nextart - 1;
       $p_suiv = $nextart + 1;
       $uri_art = generer_url_entite($id_article, "article");
       $uri_art .= strpos($uri_art, '?') ? '&' : '?';

       // Add anchors to <h3>
       $page[$nextart] = preg_replace("|\{\{\{(.*)\}\}\}|U","<a id=\"sommaire_#NB_TITRE_DE_MON_ARTICLE#\"></a>$0", $page[$nextart]);
        $array = explode("#NB_TITRE_DE_MON_ARTICLE#" , $page[$nextart]);
       $res =count($array);
       $i =1;
       $page[$nextart]=$array[0];
       while($i<$res){
           $page[$nextart]=$page[$nextart].$i.$array[$i];
            $i++;
       }
       // Pagination
       switch (TRUE) {
           case ($nextart == 0):
               $previous = "";
               $next = "<a href='" . $uri_art . "artsuite=" . $p_suiv . "'>&gt;&gt;</a>";
                break;
           case ($nextart == ($num_pages-1)):
               $previous = "<a href='" . $uri_art . "artsuite=" . $p_prec . "'>&lt;&lt;</a>";
                $next = "";
               break;
           default:
               $previous = "<a href='" . $uri_art . "artsuite=" . $p_prec . "'>&lt;&lt;</a>";
                $next = "<a href='" . $uri_art . "artsuite=" . $p_suiv . "'>&gt;&gt;</a>";
               break;
       }
   
       for ($i = 0; $i < $num_pages; $i++) {
            $j = $i;
           if ($i == $nextart) {
               $actual .= " <strong>" . ++$j . "</strong> ";
           }
           else {
               $actual .= " <a href='" . $uri_art . "artsuite=$i'>" . ++$j . "</a> ";
            }
       }

       // Here, you can customize
       $result .= $page[$nextart];
       $result .= "<div class='pagination' style='text-align:center'>pages : $previous $actual $next</div>";
        return $result;
}
// FIN du Filtre decouper_en_page
наверх