2007-07-31 10:21:34 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2007-11-16 20:13:25 +00:00
|
|
|
* Special:Gadgets, provides a preview of MediaWiki:Gadgets.
|
2008-02-04 08:08:43 +00:00
|
|
|
*
|
2007-07-31 10:21:34 +00:00
|
|
|
* @addtogroup SpecialPage
|
|
|
|
* @author Daniel Kinzler, brightbyte.de
|
|
|
|
* @copyright © 2007 Daniel Kinzler
|
2007-11-16 20:13:25 +00:00
|
|
|
* @license GNU General Public License 2.0 or later
|
2007-07-31 10:21:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if( !defined( 'MEDIAWIKI' ) ) {
|
|
|
|
echo( "not a valid entry point.\n" );
|
|
|
|
die( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class SpecialGadgets extends SpecialPage {
|
2008-02-04 08:08:43 +00:00
|
|
|
|
2007-07-31 10:21:34 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
function __construct() {
|
|
|
|
SpecialPage::SpecialPage( 'Gadgets', '', true );
|
|
|
|
}
|
2008-02-04 08:08:43 +00:00
|
|
|
|
2007-07-31 10:21:34 +00:00
|
|
|
/**
|
|
|
|
* Main execution function
|
|
|
|
* @param $par Parameters passed to the page
|
|
|
|
*/
|
|
|
|
function execute( $par ) {
|
|
|
|
global $wgOut, $wgUser;
|
2008-02-04 08:40:17 +00:00
|
|
|
|
|
|
|
wfLoadExtensionMessages( 'Gadgets' );
|
2007-11-16 20:13:25 +00:00
|
|
|
$skin = $wgUser->getSkin();
|
2007-07-31 10:21:34 +00:00
|
|
|
|
2008-01-14 22:46:14 +00:00
|
|
|
$this->setHeaders();
|
2007-07-31 10:21:34 +00:00
|
|
|
$wgOut->setPagetitle( wfMsg( "gadgets-title" ) );
|
|
|
|
$wgOut->addWikiText( wfMsg( "gadgets-pagetext" ) );
|
|
|
|
|
|
|
|
$gadgets = wfLoadGadgetsStructured();
|
|
|
|
if ( !$gadgets ) return;
|
|
|
|
|
2007-11-16 20:13:25 +00:00
|
|
|
$listOpen = false;
|
2007-07-31 10:21:34 +00:00
|
|
|
|
|
|
|
$msgOpt = array( 'parseinline', 'parsemag' );
|
|
|
|
|
|
|
|
foreach ( $gadgets as $section => $entries ) {
|
|
|
|
if ( $section !== false && $section !== '' ) {
|
2007-11-16 20:13:25 +00:00
|
|
|
$t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-section-$section" );
|
2007-07-31 10:21:34 +00:00
|
|
|
$lnk = $t ? $skin->makeLinkObj( $t, wfMsgHTML("edit") ) : htmlspecialchars($section);
|
2007-11-16 20:13:25 +00:00
|
|
|
$ttext = wfMsgExt( "gadget-section-$section", $msgOpt );
|
2007-07-31 10:21:34 +00:00
|
|
|
|
2007-11-16 20:13:25 +00:00
|
|
|
if( $listOpen ) {
|
|
|
|
$wgOut->addHTML( '</ul>' );
|
|
|
|
$listOpen = false;
|
|
|
|
}
|
2007-07-31 10:21:34 +00:00
|
|
|
$wgOut->addHTML( "\n<h2>$ttext [$lnk]</h2>\n" );
|
|
|
|
}
|
2008-02-04 08:08:43 +00:00
|
|
|
|
2007-07-31 10:21:34 +00:00
|
|
|
foreach ( $entries as $gname => $code ) {
|
2007-11-16 20:13:25 +00:00
|
|
|
$t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-$gname" );
|
2007-07-31 10:21:34 +00:00
|
|
|
if ( !$t ) continue;
|
|
|
|
|
|
|
|
$lnk = $skin->makeLinkObj( $t, wfMsgHTML("edit") );
|
2007-11-16 20:13:25 +00:00
|
|
|
$ttext = wfMsgExt( "gadget-$gname", $msgOpt );
|
2008-02-04 08:08:43 +00:00
|
|
|
|
2007-11-16 20:13:25 +00:00
|
|
|
if( !$listOpen ) {
|
|
|
|
$listOpen = true;
|
2008-02-04 08:08:43 +00:00
|
|
|
$wgOut->addHTML( '<ul>' );
|
2007-11-16 20:13:25 +00:00
|
|
|
}
|
2007-07-31 10:21:34 +00:00
|
|
|
$wgOut->addHTML( "<li>" );
|
2008-03-01 14:29:01 +00:00
|
|
|
$wgOut->addHTML( "$ttext [$lnk]<br />" );
|
2007-07-31 10:21:34 +00:00
|
|
|
|
|
|
|
$wgOut->addHTML( wfMsgHTML("gadgets-uses") . ": " );
|
|
|
|
|
|
|
|
$first = true;
|
|
|
|
foreach ( $code as $codePage ) {
|
2007-11-16 20:13:25 +00:00
|
|
|
$t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-$codePage" );
|
2007-07-31 10:21:34 +00:00
|
|
|
if ( !$t ) continue;
|
|
|
|
|
|
|
|
if ( $first ) $first = false;
|
|
|
|
else $wgOut->addHTML(", ");
|
|
|
|
|
|
|
|
$lnk = $skin->makeLinkObj( $t, htmlspecialchars( $t->getText() ) );
|
|
|
|
$wgOut->addHTML($lnk);
|
|
|
|
}
|
|
|
|
|
|
|
|
$wgOut->addHtml( "</li>" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-16 20:13:25 +00:00
|
|
|
if( $listOpen ) {
|
|
|
|
$wgOut->addHTML( '</ul>' );
|
|
|
|
}
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
|
|
|
}
|