Extension:Add Article/Category to Category/fr

From MediaWiki.org
Jump to: navigation, search
Langue : English  • Français
MediaWiki Extension
Crystal Clear action run.png
Add Article/Category to Category

Statut: stable

Implémentation Page action
Description Ajoute la possibilité d'ajouter une inputbox(pour créer un article ou une catégorie au choix) dans une page de catégorie. La nouvelle page contiendra directement "[[category:]]".
Auteur(s) Pingou (Inspired by Liang Chen The BiGreat)
Version 0.2 (2009-12-20)
MediaWiki 1.8 +
Licence GPL
Télécharger http://winux.pingou.biz/index.php/Add_Article/Category_to_Category
Exemple http://winux.pingou.biz/index.php/Cat%C3%A9gorie:Winux

Contents

[edit] Installation

  1. Créer un fichier ArtCatToCategory.php dans le répertoire extensions de mediawiki et collez-y le source à l'intérieur.
  2. Ajouter la ligne require_once("$IP/extensions/ArtCatToCategory.php"); à la fin du fichier LocalSettings.php présent à la racine de votre installation mediawiki
  3. C'est terminé !!!

[edit] Source

<?php
/*--------------------------------------------
A Pingou's Extension for MediaWiki
Add Article/Category to Category
Inspired by Liang Chen The BiGreat
Add Article to category
Release Date: 2009/12/20
Contact: pingou@pingou.biz
Demo: winux.pingou.biz
Download: http://winux.pingou.biz/index.php/Add_Article/Category_to_Category
--------------------------------------------*/
 
 
if( !defined( 'MEDIAWIKI' ) )
die();
 
$wgExtensionCredits['other'][] = array(
    'name' => 'Add Article/Category to Category',
    'description' => 'Your MediaWiki will get an inputbox on each Category page, and you can create a new article or category directly to that category',
    'author' => 'Pingou (Inspired by Liang Chen The BiGreat)',
     'url' => 'http://winux.pingou.biz/index.php/Add_Article/Category_to_Category'
);
$wgHooks['EditFormPreloadText'][] = 'addcategory';
$wgHooks['CategoryPageView'][] = 'categorychange';
 
 
 
function addcategory(&$text)
{
        $cname = $_GET['category'];
        $wnew = $_GET['new'];
 
        if ($wnew==1)
        {
        $temp1 ="[[Catégorie:".$cname."]]";
        $text=$temp1;
        }
        return true;
}
 
 
 
function categorychange($catpage)
{
        $boxtext  = "Tapez le nom de la page ou de la catégorie...";
        $btext = "Créer";
        global $wgOut;
        global $wgScript;
        $Action = htmlspecialchars( $wgScript );
 
 
 
//$wgOut->addWikiText( "Test");
$temp2=<<<ENDFORM
<!-- Add Article Extension Start - by Pingou -->
<script type="text/javascript">
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}
function addText(thefield){
        if (thefield.value=="")
        thefield.value = thefield.defaultValue
}
 
function create_page_or_category()
{
        if (document.forms['createbox'].cat_or_page.value=='page')
        {
                document.forms['createbox'].submit();
        }
      else
        {
                document.forms['createbox'].title.value = "Catégorie:" + document.forms['createbox'].title.value ;
                document.forms['createbox'].submit();
        }
}
</script>
 
<!--<table border="0" align="right" width="823" cellspacing="0" cellpadding="0">-->
<table border="0" align="right" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="right" bgcolor="">
<form name="createbox" action="{$Action}" method="get" class="createbox">
        <input type='hidden' name="action" value="edit">
        <input type='hidden' name="new" value="1">
        <input type='hidden' name="category" value="{$catpage->mTitle->getText()}">
 
Créer une
<select name="cat_or_page" id="cat_or_page">
           <option value="page">page</option>
           <option value="categorie">catégorie</option>
       </select>
dans cette catégorie. Son nom :
 
 
        <input class="createboxInput" name="title" type="text" value="{$boxtext}" size="42" style="color:#666;" onfocus="clearText(this);" onblur="addText(this);"/>
        <input type='button' name="create" class="createboxButton" value="{$btext}" onClick="create_page_or_category()"/>
 
</form>
</td>
</tr>
</table>
 
<!-- Add Article Extension End - by Pingou -->
ENDFORM;
$wgOut->addHTML($temp2);
        return true;
}

[edit] Demo

[edit] Liens connexes

Inspirée par : Extension:Add_Article_to_Category

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox