FANDOM


<?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: code@chen.technology Demo: kaoshi.wobuxihuan.org


*/

if( !defined( 'MEDIAWIKI' ) ) {

   die();

}

$wgExtensionCredits['other'][] = array(

   'name' => 'Add Article to Category',
   'description' => 'Proviedes an inputbox on each category page that allows to create a new page that is directly put into that category',
   'author' => 'Liang Chen',
    'url' => 'https://www.mediawiki.org/wiki/Extension:Add_Article_to_Category'

);

$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 );           
      

$temp2=<<<ENDFORM <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>

<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>

ENDFORM;

   $wgOut->addHTML($temp2);
       return true;

}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.