Extension:Add Article/Category to Category
From MediaWiki.org
| Language: | English • français |
|---|
|
Add Article/Category to Category Release status: stable |
|
|---|---|
| Implementation | Page action |
| Description | Adds an inputbox (for create new article or category) to each category page. The content of new page will contain "[[category:]]" automatically. |
| Author(s) | Pingou (Inspired by Liang Chen The BiGreat) |
| Last version | 0.2 (2009-12-20) |
| MediaWiki | 1.8 + |
| License | GPL |
| Download | http://winux.pingou.biz/index.php/Add_Article/Category_to_Category |
| Example | http://winux.pingou.biz/index.php/Cat%C3%A9gorie:Winux |
| Check usage and version matrix | |
Contents |
Installation [edit]
- Create file ArtCatToCategory.php in extensions directory and paste source behind.
- Add
require_once("$IP/extensions/ArtCatToCategory.php");to your LocalSettings.php file (near the end). - Done
Source [edit]
<?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 = "Tape the article or category's name..."; $btext = "Create"; global $wgOut; global $wgScript; $Action = htmlspecialchars( $wgScript ); $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 = "Category:" + 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()}"> Create a(n) <select name="cat_or_page" id="cat_or_page"> <option value="page">article</option> <option value="categorie">category</option> </select> in this category. Name: : <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; }
Demo [edit]
See also [edit]
Inspired by : Extension:Add_Article_to_Category