Wikini

HandlerBackLinks

PagePrincipale :: DerniersChangements :: DerniersCommentaires :: ParametresUtilisateur :: Vous êtes ec2-54-235-6-60.compute-1.amazonaws.com
Pour faire ce handler, j'ai repris le code de l'action backlinks, et je me suis inspiré du handler refferers, dont la philosophie est à peu pres la même...

Dans un fichier backlinks.php (dans le repertoire wikini/handlers/page/), écrire :
<?php
/*
backlinks.php
Copyright 2002  Patrick PAUL
Copyright 2003  David DELON
Copyright 2003  Eric FELDSTEIN
Copyright 2003  Jean-Pascal MILCENT
Copyright 2003  Charles NEPOTE
Copyright 2004  Emmanuel Coirier
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.
*/

echo '<div class="page">';

if (
$global $_REQUEST['global'])
{
    
$title 'Pages faisant r&eacute;f&eacute;rence &agrave; '.$this->getPageTag().' :';
}
else
{
    
$title 'Pages internes faisant r&eacute;f&eacute;rence &agrave; '.$this->ComposeLinkToPage($this->GetPageTag()).' :';
    
//$referrers = $this->LoadReferrers($this->GetPageTag());
}

echo 
"<b>$title</b><br /><br />\n";
if (
$pages $this->LoadPagesLinkingTo($this->getPageTag()))
{
    foreach (
$pages as $page)
    {
        echo 
$this->ComposeLinkToPage($page['tag']),"<br />\n";
    }
}
else
{
    echo 
'<i>Aucune page n'a de lien vers ',$this->ComposeLinkToPage($this->getPageTag()),'.</i>';
}

echo '
</div>';
?>


On peut également modifier le fichire footer.php (wikini/actions/) en rajoutant l'élement suivant :
<a href="<?php echo $this->href('backlinks'?>" title="Cliquez pour voir les pages internes faisant référence à cette page.">Rétro-liens</a>


Pour faire appel directement à cette fonction, il suffit de faire suivre l'url de /backlinks (comme cela se fait pour edit, par exemple).

Ces modifications s'adressent à la version stable. Pour la version CVS, il faut rajouter les entêtes/pieds de page ainsi que la vérification de la sécurité.

Il serait peut-être bien de préciser pour ceux qui souhaite intégrer cette contrib :

Voici donc le code complet :

<?php
/*
backlinks.php
Copyright 2002  Patrick PAUL
Copyright 2003  David DELON
Copyright 2003  Eric FELDSTEIN
Copyright 2003  Jean-Pascal MILCENT
Copyright 2003  Charles NEPOTE
Copyright 2004  Emmanuel Coirier
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.
*/
if (!defined('WIKINI_VERSION')) {
    die (
'acc&egrave;s direct interdit');
}

echo 
$this->Header();
echo 
'<div class="page">';

if (
$global $_REQUEST['global'])
{
    
$title 'Pages faisant r&eacute;f&eacute;rence &agrave; '.$this->getPageTag().' :';
}
else
{
    
$title 'Pages internes faisant r&eacute;f&eacute;rence &agrave; '.$this->ComposeLinkToPage($this->GetPageTag()).' :';
    
//$referrers = $this->LoadReferrers($this->GetPageTag());
}

echo 
"<b>$title</b><br /><br />\n";
if (
$pages $this->LoadPagesLinkingTo($this->getPageTag()))
{
    foreach (
$pages as $page)
    {
        echo 
$this->ComposeLinkToPage($page['tag']),"<br />\n";
    }
}
else
{
    echo 
'<i>Aucune page n'a de lien vers ',$this->ComposeLinkToPage($this->getPageTag()),'.</i>';
}
echo '
</div>';
echo $this->Footer();
?>


A part ca, cette contrib fonctionne très très bien ;-)
-- ThierryBazzanella

Je propose le code suivant, beaucoup plus simple...:
<?php

/*
backlinks.php : handler permettant d'obtenir tous les retro-liens d'un page de WikiNi

Copyright 2004  Didier Loiseau
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
if(!defined('WIKINI_VERSION')){
    die (
'acc&egrave;s direct interdit');
}

echo 
$this->Header();
echo 
"<div class=\"page\" style="padding1em">\n";
echo 
$this->Action('backlinks page="' $this->GetPageTag() . '"');
echo 
"\n</div>\n";
echo 
$this->Footer();

?>

NB.:
demo: http://www.notredomaine.org/LordFarquaad/backlinks
telechargement: http://contributions-wikini.notredomaine.org/HandlerBacklinks-v.0.1.0-20041219.zip

Je vois au moins deux applications importantes au HandlerBacklinks:
Je pense qu'il serait bon de l'intégrer dans la prochaine version de WikiNi, et de modificer le message d'erreur lors d'une tentative de suppression de page non-orpheline ainsi que l'ActionWantedPages.
-- LordFarquaad

Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]