r96850 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96849‎ | r96850 | r96851 >
Date:15:10, 12 September 2011
Author:reedy
Status:ok
Tags:
Comment:
REL1_18: MFT r96006, 96627
Modified paths:
  • /branches/REL1_18/extensions/EmailCapture/EmailCapture.i18n.php (modified) (history)
  • /branches/REL1_18/extensions/EmailCapture/SpecialEmailCapture.php (modified) (history)
  • /branches/REL1_18/extensions/Gadgets/ApiQueryGadgetCategories.php (modified) (history)
  • /branches/REL1_18/extensions/Gadgets/ApiQueryGadgets.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/extensions/Gadgets/ApiQueryGadgets.php
@@ -74,40 +74,13 @@
7575 if ( isset( $this->props['name'] ) ) {
7676 $row['name'] = $g->getName();
7777 }
 78+ if ( isset( $this->props['metadata'] ) ) {
 79+ $row['metadata'] = $this->fakeMetadata( $g );
 80+ $this->setIndexedTagNameForMetadata( $row['metadata'] );
 81+ }
7882 if ( isset( $this->props['desc'] ) ) {
7983 $row['desc'] = $g->getDescription();
8084 }
81 - if ( isset( $this->props['desc-raw'] ) ) {
82 - $row['desc-raw'] = $g->getRawDescription();
83 - }
84 - if ( isset( $this->props['category'] ) ) {
85 - $row['category'] = $g->getCategory();
86 - }
87 - if ( isset( $this->props['resourceloader'] ) && $g->supportsResourceLoader() ) {
88 - $row['resourceloader'] = '';
89 - }
90 - if ( isset( $this->props['scripts'] ) ) {
91 - $row['scripts'] = $g->getScripts();
92 - $result->setIndexedTagName( $row['scripts'], 'script' );
93 - }
94 - if ( isset( $this->props['styles'] ) ) {
95 - $row['styles'] = $g->getStyles();
96 - $result->setIndexedTagName( $row['styles'], 'style' );
97 - }
98 - if ( isset( $this->props['dependencies'] ) ) {
99 - $row['dependencies'] = $g->getDependencies();
100 - $result->setIndexedTagName( $row['dependencies'], 'module' );
101 - }
102 - if ( isset( $this->props['rights'] ) ) {
103 - $row['rights'] = $g->getRequiredRights();
104 - $result->setIndexedTagName( $row['rights'], 'right' );
105 - }
106 - if ( isset( $this->props['default'] ) && $g->isOnByDefault() ) {
107 - $row['default'] = '';
108 - }
109 - if ( isset( $this->props['definition'] ) ) {
110 - $row['definition'] = $g->getDefinition();
111 - }
11285 $data[] = $row;
11386 }
11487 $result->setIndexedTagName( $data, 'gadget' );
@@ -124,26 +97,57 @@
12598 && ( !$this->listAllowed || $gadget->isAllowed( $wgUser ) )
12699 && ( !$this->listEnabled || $gadget->isEnabled( $wgUser ) );
127100 }
 101+
 102+ private function fakeMetadata( Gadget $g ) {
 103+ return array(
 104+ 'settings' => array(
 105+ 'rights' => $g->getRequiredRights(),
 106+ 'default' => $g->isOnByDefault(),
 107+ 'hidden' => false, // Only exists in RL2 branch
 108+ 'shared' => false, // Only exists in RL2 branch
 109+ 'category' => $g->getCategory(),
 110+ ),
 111+ 'module' => array(
 112+ 'scripts' => $g->getScripts(),
 113+ 'styles' => $g->getStyles(),
 114+ 'dependencies' => $g->getDependencies(),
 115+ 'messages' => array(), // Only exists in RL2 branch
 116+ )
 117+ );
 118+ }
128119
 120+ private function setIndexedTagNameForMetadata( &$metadata ) {
 121+ static $tagNames = array(
 122+ 'rights' => 'right',
 123+ 'scripts' => 'script',
 124+ 'styles' => 'style',
 125+ 'dependencies' => 'dependency',
 126+ 'messages' => 'message',
 127+ );
 128+
 129+ $result = $this->getResult();
 130+ foreach ( $metadata as $type => &$data ) {
 131+ foreach ( $data as $key => &$value ) {
 132+ if ( is_array( $value ) ) {
 133+ $tag = isset( $tagNames[$key] ) ? $tagNames[$key] : $key;
 134+ $result->setIndexedTagName( $value, $tag );
 135+ }
 136+ }
 137+ }
 138+ }
 139+
129140 public function getAllowedParams() {
130141 return array(
131142 'prop' => array(
132 - ApiBase::PARAM_DFLT => 'name',
 143+ ApiBase::PARAM_DFLT => 'name|metadata',
133144 ApiBase::PARAM_ISMULTI => true,
134145 ApiBase::PARAM_TYPE => array(
135146 'name',
 147+ 'metadata',
136148 'desc',
137 - 'desc-raw',
138 - 'category',
139 - 'resourceloader',
140 - 'scripts',
141 - 'styles',
142 - 'dependencies',
143 - 'rights',
144 - 'default',
145 - 'definition',
146149 ),
147150 ),
 151+ 'language' => null,
148152 'categories' => array(
149153 ApiBase::PARAM_ISMULTI => true,
150154 ApiBase::PARAM_TYPE => 'string',
@@ -162,20 +166,13 @@
163167 }
164168
165169 public function getParamDescription() {
 170+ $p = $this->getModulePrefix();
166171 return array(
167172 'prop' => array(
168173 'What gadget information to get:',
169174 ' name - Internal gadget name',
 175+ ' metadata - The gadget metadata',
170176 ' desc - Gadget description transformed into HTML (can be slow, use only if really needed)',
171 - ' desc-raw - Gadget description in raw wikitext',
172 - ' category - Internal name of a category gadget belongs to (empty if top-level gadget)',
173 - ' resourceloader - Whether gadget supports ResourceLoader',
174 - " scripts - List of gadget's scripts",
175 - " styles - List of gadget's styles",
176 - ' dependencies - List of ResourceLoader modules gadget depends on',
177 - ' rights - List of rights required to use gadget, if any',
178 - ' default - Whether gadget is enabled by default',
179 - ' definition - Line from MediaWiki:Gadgets-definition used to define the gadget',
180177 ),
181178 'categories' => 'Gadgets from what categories to retrieve',
182179 'names' => 'Name(s) of gadgets to retrieve',
@@ -195,7 +192,7 @@
196193 'Get a list of gadgets belonging to caregory "foo":',
197194 ' api.php?action=query&list=gadgets&gacategories=foo',
198195 'Get information about gadgets named "foo" and "bar":',
199 - ' api.php?action=query&list=gadgets&ganames=foo|bar&gaprop=name|desc|category',
 196+ ' api.php?action=query&list=gadgets&ganames=foo|bar&gaprop=name|desc|metadata',
200197 'Get a list of gadgets enabled by current user:',
201198 ' api.php?action=query&list=gadgets&gaenabled',
202199 );
Index: branches/REL1_18/extensions/Gadgets/ApiQueryGadgetCategories.php
@@ -51,12 +51,9 @@
5252 $row['name'] = $category;
5353 }
5454 if ( $category !== "" ) {
55 - if ( isset( $this->props['desc'] ) ) {
 55+ if ( isset( $this->props['title'] ) ) {
5656 $row['desc'] = wfMessage( "gadget-section-$category" )->parse();
5757 }
58 - if ( isset( $this->props['desc-raw'] ) ) {
59 - $row['desc-raw'] = wfMessage( "gadget-section-$category" )->plain();
60 - }
6158 }
6259 if ( isset( $this->props['members'] ) ) {
6360 $row['members'] = count( $list );
@@ -75,8 +72,7 @@
7673 ApiBase::PARAM_ISMULTI => true,
7774 ApiBase::PARAM_TYPE => array(
7875 'name',
79 - 'desc',
80 - 'desc-raw',
 76+ 'title',
8177 'members',
8278 ),
8379 ),
@@ -96,8 +92,7 @@
9793 'prop' => array(
9894 'What gadget category information to get:',
9995 ' name - Internal category name',
100 - ' desc - Category description transformed into HTML (can be slow, use only if really needed)',
101 - ' desc-raw - Category description in raw wikitext',
 96+ ' title - Category title',
10297 ' members - Number of gadgets in category',
10398 ),
10499 'names' => 'Name(s) of gadgets to retrieve',
Index: branches/REL1_18/extensions/EmailCapture/EmailCapture.i18n.php
@@ -15,6 +15,8 @@
1616 'emailcapture' => 'E-mail verification',
1717 'emailcapture-desc' => 'Capture e-mail addresses, and allow users to verify them through e-mail',
1818 'emailcapture-failure' => "Your e-mail was '''not''' verified.",
 19+ 'emailcapture-invalid-code' => 'Invalid confirmation code.',
 20+ 'emailcapture-already-confirmed' => 'Your e-mail address has already been confirmed.',
1921 'emailcapture-response-subject' => '{{SITENAME}} e-mail address verification',
2022 'emailcapture-response-body' => 'Hello!
2123
Index: branches/REL1_18/extensions/EmailCapture/SpecialEmailCapture.php
@@ -14,16 +14,28 @@
1515 $code = $wgRequest->getVal( 'verify' );
1616 if ( $code !== null ) {
1717 $dbw = wfGetDB( DB_MASTER );
18 - $dbw->update(
 18+ $row = $dbw->selectRow(
1919 'email_capture',
20 - array( 'ec_verified' => 1 ),
 20+ array( 'ec_verified' ),
2121 array( 'ec_code' => $code ),
2222 __METHOD__
2323 );
24 - if ( $dbw->affectedRows() ) {
25 - $wgOut->addWikiMsg( 'emailcapture-success' );
 24+ if ( $row && !$row->ec_verified ) {
 25+ $dbw->update(
 26+ 'email_capture',
 27+ array( 'ec_verified' => 1 ),
 28+ array( 'ec_code' => $code ),
 29+ __METHOD__
 30+ );
 31+ if ( $dbw->affectedRows() ) {
 32+ $wgOut->addWikiMsg( 'emailcapture-success' );
 33+ } else {
 34+ $wgOut->addWikiMsg( 'emailcapture-failure' );
 35+ }
 36+ } else if ( $row && $row->ec_verified ) {
 37+ $wgOut->addWikiMsg( 'emailcapture-already-confirmed' );
2638 } else {
27 - $wgOut->addWikiMsg( 'emailcapture-failure' );
 39+ $wgOut->addWikiMsg( 'emailcapture-invalid-code' );
2840 }
2941 } else {
3042 // Show simple form for submitting verification code

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96006Gadgets: To prevent back compat hacks in 1.19, change the Gadgets API to be c...catrope16:08, 1 September 2011
r96627* (bug 30823) Clarify error messages on Special:EmailCapture...brion22:47, 8 September 2011

Status & tagging log