[Mediawiki-api] Creating an Extension for my thesaurus

Kathleen Borja jane88borj at yahoo.com
Sat Jul 25 09:21:03 UTC 2009


I'm making my mediawiki-driven senior project for this semester. It is about
creating a thesaurus for bikol languages. I started editing pages and also
importing pages manually. So far, all the changes work. Now, I'm making the core
function of my project-thesaurus. I implemented a string search algorithm in a
php file(but not yet on the special file), which I will be using in the search
function on the SpecailThesaurus.php file. I'm making a special page on the
/includes directory and also on the /extensions directory named
"SpecialThesaurus.php". 

Problems:
-How can I set the action attribute in "form" so that it displays all the output
on the page $SERVER['PHP_SELF'];

-How can I enable this script "SpecialThesaurus.php" so that it shows after a
user adds/edit a page? 

Thanks. (^_^)

On the /extensions directory, the "SpecialThesaurus.php" includes this code:
---------------
<?php
$wgExtensionFunctions[] = "wfExtensionSpecialThesaurus";

function wfExtensionSpecialThesaurus()
{
    global $wgMessageCache;
    $wgMessageCache->addMessages(array('thesaurus' => 'WikiBiTs Thesaurus page'));

    require_once('includes/SpecialPage.php');
    SpecialPage::addPage(new SpecialPage('Thesaurus'));
}
?>
---------------


On the /includes directory, the "SpecialThesaurus.php" includes this code:
---------------
<?php
if( !defined( 'MEDIAWIKI' ) )
die();
$wgExtensionCredits['validextensionclass'][] = array(
       'name' => 'Thesaurus for Biko languages',
       'author' =>'Kathleen Jane P. Borja', 
       'url' => 'http://www.mediawiki.org/wiki/User:Kathjane', 
       'description' => 'This Extension searches for bikol word for a given
literary input (poems, short stories, etc.), tags the searched word with bikol
synonym according to origin (Bikol-Naga, Bikol-Masbate, etc.) and user type
(Student, College Graduate, or Professional). '
       );

function wfSpecialThesaurus()
{
$searchboxtext = "Search for Bikol words";
$tagboxtext = "Tag with Bikol Synonym";
global $wgOut;

$result=<<<ENDFORM


<!-- Thesaurus Extension by Borja, Kathleen -->
<table border="0" align="left" width="650" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="left" bgcolor="">
<form name="searchbox" action="" method="get" class="searchbox">
Search : <input class="searchboxinput" name="searchkword" type="text"
value="{$searchboxtext}" size="50" />
         <input type="submit" name="submitsearch" value="Go" />
 <input type="reset" name="cancelsearch" value="Cancel"/><br><br>
Results:<br>
<textarea name="resultarea" cols="60" rows="10"></textarea><br><br>
Tag with: <input type="text" name="tagbox" value={$tagboxtext}" size="50" />
Origin: <select>
<option name="default" />Bicol-Naga
<option name="bicolmasbate" />Bicol-Masbate
<option name="bicolragay" />Bicol-Ragay
<option name="bicollegazpi" />Bicol-Legazpi
<option name="others" />Others
</select>
User Category:
<select>
<option name="student" />Student
<option name="collegegraduate" />College Graduate
<option name="professional" />Professional
<option name="others" />Others
</select><br><br>
<input type="submit" name="saveall" value="Save" />
<input type="reset" name="cancelall" value="Cancel" />
</form>
</td>
</tr>
</table>
<!-- Thesaurus Extension End - -->
ENDFORM;
$wgOut->addHTML($result);
return true;
}
?>
---------------





More information about the Mediawiki-api mailing list