Extension:Add Article to Category
From MediaWiki.org
| Language: | English • français • 中文 |
|---|
| This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net. |
|
Add Article to Category Release status: stable |
|||
|---|---|---|---|
| Implementation | Page action | ||
| Description | Adds an inputbox (for create new article) to each category page. The content of new page will contain "[[category:]]" automatically. | ||
| Author(s) | Liang Chen The BiGreat (BiGreattalk) | ||
| Last version | 0.1.9 (2007-01-19) | ||
| MediaWiki | 1.8 + | ||
| License | No license specified | ||
| Download | below and on liang-chen.com | ||
| Example | kaoshi.wobuxihuan.org (demo)or Hindupedia | ||
|
|||
| Check usage and version matrix | |||
Add the ability to add an inputbox (for create new article) to each category page. The content of new page will contain "[[category:]]" automatically.
Contents |
Install [edit]
- Download the extension here or in the section below.
- Upload the articletocategory.php to your extensions/ directory.
- Add
require_once("$IP/extensions/articletocategory.php");to your LocalSettings.php file (near the end). - Done
Screenshots [edit]
Update [edit]
- 03/09 -- Fix a bug in the zip file, please download again.
Code [edit]
-
<?php -
/*-------------------------------------------- -
A Liang Chen's Extension for MediaWiki -
Add Article to Category -
Release Date: 2007/01/19 -
Update Date: 2007/03/09 to 0.1.9, fix a bug in zip file which may cause problem in style. -
Contact: anything@liang-chen.com -
Demo: kaoshi.wobuxihuan.org -
Download: http://www.liang-chen.com/myworld/content/view/36/70/ -
--------------------------------------------*/ -
-
-
if( !defined( 'MEDIAWIKI' ) )
-
die();
-
-
$wgExtensionCredits['other'][] = array(
-
'name' => 'Add Article to Category', -
'description' => 'Your MediaWiki will get an inputbox on each Category page, and you can create a new article directly to that category', -
'author' => 'Liang Chen The BiGreat', -
'url' => 'http://www.liang-chen.com/myworld/content/view/36/70/' -
);
-
$wgHooks['EditFormPreloadText'][] = 'addcategory';
-
$wgHooks['CategoryPageView'][] = 'categorychange';
-
function addcategory(&$text)
-
{ -
$cname = $_GET['category']; -
$wnew = $_GET['new']; -
global $wgContLang; -
-
if ($wnew==1) -
{ -
$ns = $wgContLang->getFormattedNsText(NS_CATEGORY); -
$text ="Add Your Content Here\r\n\r\n[[$ns:".$cname."]]"; -
} -
return true; -
} -
-
-
-
function categorychange($catpage)
-
{ -
-
$boxtext = "Create an Article in this category"; -
$btext = "Submit"; -
global $wgOut; -
global $wgScript; -
$Action = htmlspecialchars( $wgScript ); -
-
-
-
//$wgOut->addWikiText( "Test"); -
$temp2=<<<ENDFORM
-
<!-- Add Article Extension Start - P by BiGreat--> -
<script type="text/javascript"> -
function clearText(thefield){ -
if (thefield.defaultValue==thefield.value) -
thefield.value = "" -
} -
function addText(thefield){ -
if (thefield.value=="") -
thefield.value = thefield.defaultValue -
} -
</script> -
<table border="0" align="right" width="423" 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()}"> -
-
<input class="createboxInput" name="title" type="text" value="{$boxtext}" size="30" style="color:#666;" onfocus="clearText(this);" onblur="addText(this);"/> -
<input type='submit' name="create" class="createboxButton" value="{$btext}"/> -
</form> -
</td> -
</tr> -
</table> -
<!-- Add Article Extension End - P by BiGreat--> -
ENDFORM;
-
$wgOut->addHTML($temp2);
-
return true; -
}
DEMO [edit]
Tweaks [edit]
If you want the option to not have the box on some pages, see Extension talk:Add Article to Category #Added functionality to exclude some categories
See also [edit]
- SimpleForms categorisation example - uses SimpleForms extension to categorise article directly without editing
- CreateArticle

