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
|
|
|
*
|
2010-06-06 15:12:22 +00:00
|
|
|
* @file
|
|
|
|
* @ingroup SpecialPage
|
2007-07-31 10:21:34 +00:00
|
|
|
* @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() {
|
2010-07-26 13:30:31 +00:00
|
|
|
parent::SpecialPage( 'Gadgets', '', true );
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
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 ) {
|
2008-08-17 15:42:26 +00:00
|
|
|
global $wgOut, $wgUser, $wgLang, $wgContLang;
|
2008-02-04 08:40:17 +00:00
|
|
|
|
2010-05-27 15:56:53 +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" ) );
|
2010-07-08 08:13:03 +00:00
|
|
|
$wgOut->addWikiMsg( 'gadgets-pagetext' );
|
2007-07-31 10:21:34 +00:00
|
|
|
|
|
|
|
$gadgets = wfLoadGadgetsStructured();
|
|
|
|
if ( !$gadgets ) return;
|
|
|
|
|
2008-08-17 15:42:26 +00:00
|
|
|
$lang = "";
|
|
|
|
if ( $wgLang->getCode() != $wgContLang->getCode() ) {
|
|
|
|
$lang = "/" . $wgLang->getCode();
|
|
|
|
}
|
|
|
|
|
2007-11-16 20:13:25 +00:00
|
|
|
$listOpen = false;
|
2007-07-31 10:21:34 +00:00
|
|
|
|
|
|
|
$msgOpt = array( 'parseinline', 'parsemag' );
|
2010-01-12 19:45:49 +00:00
|
|
|
$editInterfaceAllowed = $wgUser->isAllowed( 'editinterface' ) ? true : false ;
|
|
|
|
|
2007-07-31 10:21:34 +00:00
|
|
|
foreach ( $gadgets as $section => $entries ) {
|
|
|
|
if ( $section !== false && $section !== '' ) {
|
2008-08-17 15:42:26 +00:00
|
|
|
$t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-section-$section$lang" );
|
2010-01-12 19:45:49 +00:00
|
|
|
if ( $editInterfaceAllowed ) {
|
|
|
|
$lnkTarget = $t
|
|
|
|
? $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) )
|
|
|
|
: htmlspecialchars( $section );
|
2010-05-30 17:33:59 +00:00
|
|
|
$lnk = "    [$lnkTarget]";
|
2010-01-12 19:45:49 +00:00
|
|
|
} else {
|
|
|
|
$lnk = '';
|
|
|
|
}
|
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 ) {
|
2010-01-12 19:45:49 +00:00
|
|
|
$wgOut->addHTML( Xml::closeElement( 'ul' ) . "\n" );
|
2007-11-16 20:13:25 +00:00
|
|
|
$listOpen = false;
|
|
|
|
}
|
2010-01-12 19:45:49 +00:00
|
|
|
$wgOut->addHTML( Html::rawElement( 'h2', array(), $ttext . $lnk ) . "\n" );
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
2008-02-04 08:08:43 +00:00
|
|
|
|
2008-07-07 18:50:47 +00:00
|
|
|
foreach ( $entries as $gname => $code ) {
|
2008-08-17 15:42:26 +00:00
|
|
|
$t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-$gname$lang" );
|
2007-07-31 10:21:34 +00:00
|
|
|
if ( !$t ) continue;
|
|
|
|
|
2010-01-12 19:45:49 +00:00
|
|
|
if ( $editInterfaceAllowed ) {
|
|
|
|
$lnkTarget = $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) );
|
2010-05-30 17:33:59 +00:00
|
|
|
$lnk = "    [$lnkTarget]";
|
2010-01-12 19:45:49 +00:00
|
|
|
} else {
|
|
|
|
$lnk = '';
|
|
|
|
}
|
2007-11-16 20:13:25 +00:00
|
|
|
$ttext = wfMsgExt( "gadget-$gname", $msgOpt );
|
2008-07-07 18:50:47 +00:00
|
|
|
|
2007-11-16 20:13:25 +00:00
|
|
|
if( !$listOpen ) {
|
|
|
|
$listOpen = true;
|
2010-01-12 19:45:49 +00:00
|
|
|
$wgOut->addHTML( Xml::openElement( 'ul' ) );
|
2007-11-16 20:13:25 +00:00
|
|
|
}
|
2010-01-12 19:45:49 +00:00
|
|
|
$wgOut->addHTML( Xml::openElement( 'li' ) .
|
|
|
|
$ttext . $lnk . "<br />" .
|
|
|
|
wfMsgHTML( 'gadgets-uses' ) . wfMsg( 'colon-separator' )
|
|
|
|
);
|
2007-07-31 10:21:34 +00:00
|
|
|
|
2010-01-12 19:45:49 +00:00
|
|
|
$lnk = array();
|
2008-07-07 18:50:47 +00:00
|
|
|
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;
|
|
|
|
|
2010-01-12 19:45:49 +00:00
|
|
|
$lnk[] = $skin->link( $t, htmlspecialchars( $t->getText() ) );
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
2010-01-12 19:45:49 +00:00
|
|
|
$wgOut->addHTML( $wgLang->commaList( $lnk ) );
|
|
|
|
$wgOut->addHTML( Xml::closeElement( 'li' ) . "\n" );
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-16 20:13:25 +00:00
|
|
|
if( $listOpen ) {
|
2010-01-12 19:45:49 +00:00
|
|
|
$wgOut->addHTML( Xml::closeElement( 'ul' ) . "\n" );
|
2007-11-16 20:13:25 +00:00
|
|
|
}
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
|
|
|
}
|