r99229 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99228‎ | r99229 | r99230 >
Date:18:42, 7 October 2011
Author:sean_colombo
Status:deferred
Tags:
Comment:
Followup to r98191. Added alias file, changed to be a special page, and fixed parsing of an i18n msg.
Modified paths:
  • /trunk/extensions/ApiExplorer/ApiExplorer.alias.php (added) (history)
  • /trunk/extensions/ApiExplorer/SpecialApiExplorer.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ApiExplorer/SpecialApiExplorer.php
@@ -14,7 +14,7 @@
1515
1616 if ( !defined( 'MEDIAWIKI' ) ) die();
1717
18 -$wgExtensionFunctions[] = 'wfSpecialApiExplorer';
 18+$wgSpecialPages[ "ApiExplorer" ] = "SpecialApiExplorer";
1919 $wgExtensionCredits['specialpage'][] = array(
2020 'path' => __FILE__,
2121 'name' => 'API Explorer',
@@ -25,84 +25,80 @@
2626
2727 $dir = dirname( __FILE__ ) . '/';
2828 $wgExtensionMessagesFiles['ApiExplorer'] = $dir . 'ApiExplorer.i18n.php';
29 -// @todo FIXME: Special pages need an aliases file for i18n of special page names.
 29+$wgExtensionAliasesFiles['ApiExplorer'] = $dir . 'ApiExplorer.alias.php';
3030
31 -// @todo FIXME: Should be in a class and be added from $wgSpecialPages.
32 -function wfSpecialApiExplorer () {
33 - global $IP;
34 - require_once "$IP/includes/SpecialPage.php";
35 - class SpecialApiExplorer extends SpecialPage {
36 - /**
37 - * Constructor
38 - */
39 - function SpecialApiExplorer() {
40 - SpecialPage::SpecialPage( 'ApiExplorer' );
41 - $this->includable( false );
42 - }
 31+/**
 32+ * @ingroup SpecialPage
 33+ */
 34+class SpecialApiExplorer extends SpecialPage {
 35+ /**
 36+ * Constructor
 37+ */
 38+ public function __construct() {
 39+ SpecialPage::SpecialPage( 'ApiExplorer' );
 40+ $this->includable( false );
 41+ }
4342
44 - /**
45 - * Main function of the special page. Basically serves as a wrapper which loads
46 - * the main functionality (which is in Javascript).
47 - *
48 - * @param $par - parameters for SpecialPage. Ignored.
49 - */
50 - function execute( $par = null ) {
51 - global $wgOut, $wgExtensionsPath, $wgCityId, $wgStyleVersion;
52 - wfProfileIn( __METHOD__ );
 43+ /**
 44+ * Main function of the special page. Basically serves as a wrapper which loads
 45+ * the main functionality (which is in Javascript).
 46+ *
 47+ * @param $par - parameters for SpecialPage. Ignored.
 48+ */
 49+ public function execute( $par = null ) {
 50+ global $wgOut, $wgExtensionsPath, $wgCityId, $wgStyleVersion;
 51+ wfProfileIn( __METHOD__ );
5352
54 - // TODO: Make this work for ResourceLoader (Wikia isn't using RL yet at the time of this writing).
55 - // Wikia has the cachebuster in the wgExtensionPath (we rewrite that in varnish because many proxies won't cache things that have "?" in the URL), but other MediaWikis need the style-version in the querystring.
56 - $cbSuffix = ( isset( $wgCityId ) ? "?{$wgStyleVersion}" : "" );
57 - $wgOut->addScript( "<script type=\"text/javascript\" src=\"{$wgExtensionsPath}/wikia/JavascriptAPI/Mediawiki.js{$cbSuffix}\"></script>" );
58 - $wgOut->addScript( "<script type=\"text/javascript\" src=\"{$wgExtensionsPath}/ApiExplorer/apiExplorer.js{$cbSuffix}\"></script>" );
59 - $wgOut->addScript( "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$wgExtensionsPath}/ApiExplorer/apiExplorer.css{$cbSuffix}\" />" );
 53+ // TODO: Make this work for ResourceLoader (Wikia isn't using RL yet at the time of this writing).
 54+ // Wikia has the cachebuster in the wgExtensionPath (we rewrite that in varnish because many proxies won't cache things that have "?" in the URL), but other MediaWikis need the style-version in the querystring.
 55+ $cbSuffix = ( isset( $wgCityId ) ? "?{$wgStyleVersion}" : "" );
 56+ $wgOut->addScript( "<script type=\"text/javascript\" src=\"{$wgExtensionsPath}/wikia/JavascriptAPI/Mediawiki.js{$cbSuffix}\"></script>" );
 57+ $wgOut->addScript( "<script type=\"text/javascript\" src=\"{$wgExtensionsPath}/ApiExplorer/apiExplorer.js{$cbSuffix}\"></script>" );
 58+ $wgOut->addScript( "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$wgExtensionsPath}/ApiExplorer/apiExplorer.css{$cbSuffix}\" />" );
6059
61 - ob_start();
62 - $buttonHeight = 15;
63 - $collapseSrc = "$wgExtensionsPath/ApiExplorer/collapse.png$cbSuffix";
64 - $expandSrc = "$wgExtensionsPath/ApiExplorer/collapse.png$cbSuffix";
65 - ?><style>
66 - .collapsible h2 span, .collapsible h3 span{
67 - width:<?= $buttonHeight ?>px;
68 - height:1em;
69 - float:right;
70 - display:inline-block;
 60+ ob_start();
 61+ $buttonHeight = 15;
 62+ $collapseSrc = "$wgExtensionsPath/ApiExplorer/collapse.png$cbSuffix";
 63+ $expandSrc = "$wgExtensionsPath/ApiExplorer/collapse.png$cbSuffix";
 64+ ?><style>
 65+ .collapsible h2 span, .collapsible h3 span{
 66+ width:<?= $buttonHeight ?>px;
 67+ height:1em;
 68+ float:right;
 69+ display:inline-block;
7170
72 - background-repeat:no-repeat;
73 - background-position:right center;
74 - background-image: url(<?= "$wgExtensionsPath/ApiExplorer/collapse.png$cbSuffix"; ?>);
75 - }
76 - .collapsed h2 span, .collapsed h3 span{
77 - background-image: url(<?= "$wgExtensionsPath/ApiExplorer/expand.png$cbSuffix"; ?>);
78 - }
79 - </style>
80 - <div id='apEx_intro'>
81 - <?= wfMsg('apiexplorer-intro') ?>
82 - </div>
83 - <div id='apEx_loading'><?= wfMsg('apiexplorer-loading') ?></div>
84 - <div id='apEx'>
85 - <?php
86 - $params = array( "modules", "querymodules", "formatmodules" );
87 - foreach ( $params as $param ) {
88 - ?><div class='<?= $param ?> collapsible collapsed paramName' data-param-name='<?= $param ?>'>
89 - <h2 class='name'><span class='toggleIcon'></span></h2>
90 - <div class='paramContent'>
91 - <div class='description'></div>
92 - <dl>
93 - <!-- Filled by a call to the API -->
94 - </dl>
95 - </div>
96 - </div><?php
97 - } ?>
98 - </div>
99 - <?php
100 - $outHtml = ob_get_clean();
 71+ background-repeat:no-repeat;
 72+ background-position:right center;
 73+ background-image: url(<?= "$wgExtensionsPath/ApiExplorer/collapse.png$cbSuffix"; ?>);
 74+ }
 75+ .collapsed h2 span, .collapsed h3 span{
 76+ background-image: url(<?= "$wgExtensionsPath/ApiExplorer/expand.png$cbSuffix"; ?>);
 77+ }
 78+ </style>
 79+ <div id='apEx_intro'>
 80+ <?= wfMsgExt('apiexplorer-intro', array('parse', 'content') ) ?>
 81+ </div>
 82+ <div id='apEx_loading'><?= wfMsg('apiexplorer-loading') ?></div>
 83+ <div id='apEx'>
 84+ <?php
 85+ $params = array( "modules", "querymodules", "formatmodules" );
 86+ foreach ( $params as $param ) {
 87+ ?><div class='<?= $param ?> collapsible collapsed paramName' data-param-name='<?= $param ?>'>
 88+ <h2 class='name'><span class='toggleIcon'></span></h2>
 89+ <div class='paramContent'>
 90+ <div class='description'></div>
 91+ <dl>
 92+ <!-- Filled by a call to the API -->
 93+ </dl>
 94+ </div>
 95+ </div><?php
 96+ } ?>
 97+ </div>
 98+ <?php
 99+ $outHtml = ob_get_clean();
101100
102 - $this->setHeaders();
103 - $wgOut->addHTML( $outHtml );
104 - wfProfileOut( __METHOD__ );
105 - } // end execute()
106 - }
107 -
108 - SpecialPage::addPage( new SpecialApiExplorer );
109 -} // end wfSpecialApiExplorer()
 101+ $this->setHeaders();
 102+ $wgOut->addHTML( $outHtml );
 103+ wfProfileOut( __METHOD__ );
 104+ } // end execute()
 105+} // end class SpecialApiExplorer
Index: trunk/extensions/ApiExplorer/ApiExplorer.alias.php
@@ -0,0 +1,22 @@
 2+<?php
 3+/**
 4+ * Aliases for Special:404
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+$specialPageAliases = array();
 11+
 12+/** English (English) */
 13+$specialPageAliases['en'] = array(
 14+ 'ApiExplorer' => array( 'ApiExplorer' ),
 15+);
 16+
 17+
 18+
 19+
 20+/**
 21+ * For backwards compatibility with MediaWiki 1.15 and earlier.
 22+ */
 23+$aliases =& $specialPageAliases;
Property changes on: trunk/extensions/ApiExplorer/ApiExplorer.alias.php
___________________________________________________________________
Added: svn:eol-style
124 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r99344r99229: Fix c&p errorraymond10:51, 9 October 2011
r99345r99229: Register alias file for translatewiki.netraymond10:52, 9 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98191Adding ApiExplorer extension which uses the API to dynamically generate API d...sean_colombo22:50, 26 September 2011

Status & tagging log