[Mediawiki-api] Creating an Extension for my thesaurus

Kathleen Borja jane88borj at yahoo.com
Mon Jul 27 03:17:07 UTC 2009


Roan Kattouw <roan.kattouw <at> gmail.com> writes:

> > On the /extensions directory, the "SpecialThesaurus.php" includes this code:
> The code you're quoting uses pretty old conventions, and I'm not sure
> it'll still work correctly. What you wanna do is the following:
> 
> In extensions/Thesaurus/SpecialThesaurus.php:
> 
> class SpecialThesaurus extends SpecialPage
> {
>         function __construct() {
>                 parent::__construct( 'Thesaurus' );
>         }
> 
>         function execute( $par ) {
>                 global $wgOut;
>                 $this->setHeaders();
>                 $this->setTitle( 'Some title' );
>                 $wgOut->addHTML( "Example HTML" );
>                 // $par is the subpage parameter, i.e. for
> Special:Thesaurus/Foo $par == 'Foo'
>                 // To get the URL to this special page, use
> $this->getTitle()->getFullURL()
>         }
> }
> 
> In extensions/Thesaurus/Thesaurus.php:
> 
> $wgSpecialPages['Thesaurus'] = 'SpecialThesaurus';
> $wgAutoloadClasses['SpecialThesaurus'] = dirname(__FILE__) .
> '/SpecialThesaurus.php';
> 
> Note that the special page itself should also be in
> extensions/Thesaurus/ , not in includes/ .
> 
> Roan Kattouw (Catrope)
> 


Thank you for the quick response. I'm sorry to reply you back late. I'm in
school right now. That's why I was able to have Internet connection. Anyway, I
copied and pasted the codes you suggested. I put the first one in
extensions/Thesaurus/SpecialThesaurus.php wherein the class SpecialThesaurus
is placed. So, the code looks like this:
<?php
	class SpecialThesaurus extends SpecialPage
{
        function __construct() {
                parent::__construct( 'Thesaurus' );
        }

        function execute( $par ) {
                global $wgOut;
                $this->setHeaders();
                $this->setTitle( 'Some title' );
                $wgOut->addHTML( "Example HTML" );
                // $par is the subpage parameter, i.e. for
Special:Thesaurus/Foo $par == 'Foo'
                // To get the URL to this special page, use
$this->getTitle()->getFullURL()
        }
}
?>

Then, I put the following lines in extensions/Thesaurus/Thesaurus.php:
<?php
$wgSpecialPages['Thesaurus'] = 'SpecialThesaurus';
$wgAutoloadClasses['SpecialThesaurus'] = dirname(__FILE__) .
'/SpecialThesaurus.php';
?>


Problems:
	-Is there something that I am lacking? Why is it that there's no output when I
type in the URL? My URL looks was :
http://localhost/wikibits/index.php/SpecialThesaurus.php. I am running the
script on a localhost server. Is there something wrong with the URL? I can
hardly view the special page...
	
	-If I'll be adding some form elements, where shall I put them?on the
SpecialThesaurus.php or Thesaurus.php?
	
	-So, for now, I have 2 files in the extensions/Thesaurus directory. Is it right?
	
Again, thanks a lot. (^_^)
	
	




More information about the Mediawiki-api mailing list