WikiXtof

Action Recent Blog Pages

Accueil :: SuperMenu :: Contact :: Connexion :: Vous êtes 216.73.217.24

Action WiKiNi visant à créer une page type Blog


J'ai d'abord chercher à faire un Blog dans WiKiNi (WebLogEtWikini) avec le CalendrierChristianGoubier (excellente soit dit en passant, cf. CalendrierEtWiki). Mais cette action contraint le nom des pages en JourJJMMAAAA. Or moi je veux que mes pages de wiki en MotWiki deviennent des articles de Blog datés.

Il me faut finalement juste l'équivalent de DerniersChangements avec les 10-20 premières lignes du contenu des 10-20 dernières pages modifiées.

Quelques idées pour cibler un peu plus le contenu "typé Blog" dans ce capharnaum de wiki (puisque c'est bien ça le wiki, un capharnaum) :

Je suis en passe d'avoir tout (cf les OK dans la liste) avec le code suivant :

<?php

/*
recentpages.php
Copyright 2007 Christophe NETILLARD
based on recentchanges.php from
Copyright (c) 2002, Hendrik Mans <hendrik@mans.de>
Copyright 2002, 2003 David DELON
Copyright 2002, 2003 Charles NEPOTE
Copyright 2002 Patrick PAUL
Copyright  2003  Eric DELORD
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Contrôle pour être sûr que l'action est bien appelée par WikiNi
if (!defined("WIKINI_VERSION"))
{
  die (
"accès direct interdit");
}
// Which is the max number of pages to be shown ?
if ($max = $this->GetParameter("max"))
{
    if (
$max=="last") $max=10; else $last = (int) $max;
}
else
{
    
$max = 10;
}

// Which Owner is the Blog publisher ? if none, any page can be quoted
$BlogOwner = $this->GetParameter("owner");

// How many lines needed for the summary of each article ? Default = 10
if ($SumLines = $this->GetParameter("lines")) {} else $SumLines = 10;

// Cut a string at a max number of lines
function substrlines ($string = "", $max_lines = 1) {
    
// pour verif du nb de ligne
    // echo substr_count($string, "\n");
    // S'il y a moins de lignes au total qu'on en demande, on ne cherche pas !
    
if ((substr_count($string, "\n") + 1) > $max_lines)
    {
        
$pos = 0;
        
// décalage d'un curseur $pos de ligne en ligne
        
for ($line = 1 ; $line <= $max_lines ; $line++)
        {
            
$pos = strpos($string, "\n", $pos) + 1;
        }
        
$string = substr($string, 0, $pos);
    }
    return 
$string;
}

// Show recently changed pages
if ($pages = $this->LoadRecentlyChanged($max))
{
        foreach (
$pages as $i => $page)
        {
            
// day time
            
list($day, $time) = explode(" ", $page["time"]);
            
// Affichage de la page si pas auto inclue et acces OK
            
if (!eregi("^".$page["tag"]."$",$this->GetPageTag()) && $this->HasAccess("read",$page["tag"]))
            {
                
// Check if publishing of only one owner
                
if ($BlogOwner == "" || $BlogOwner == $page["owner"])
                {
                    
// echo entry
                    
echo "<b>$day&nbsp;</b>(",$time,") ",$this->ComposeLinkToPage($page["tag"], "", $this->SplitWikiWord($page["tag"]), 0)," . . . . Contribution de ",$this->Format($page["user"]),"<br /><br />\n" ;
                    
$NomPageCitee = $page["tag"];
                    
$PageCitee = $this->LoadPage($NomPageCitee,"",0);
                    
$Extrait = substrlines($PageCitee["body"], $SumLines);
                    
//echo $Extrait;
                    
$Citation = $this->Format($Extrait."\n[[".$page["tag"]." [Lire la suite] ]]\n----\n");
                    echo 
"<div class=\"\">\n", $Citation,"</div>\n";
                }
            }
        }
}
?>



Discussion


il me semble qu'avec la ligne suivante les valeurs du paramètre max sont correctes :
// Show recently changed pages
if ($pages = $this->LoadRecentlyChanged(($max+1)))
--Xf75013?
...
Commentaires [Cacher commentaires/formulaire]

Notice: Undefined index: menu_page in /var/www/vhosts/xtof.ouvaton.org/httpdocs/actions/footer.php on line 103