r81248 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81247‎ | r81248 | r81249 >
Date:13:17, 31 January 2011
Author:reedy
Status:deferred (Comments)
Tags:
Comment:
bug 27041, SpecialPage:addPage is deprecated...
Modified paths:
  • /trunk/extensions/Aggregator/Aggregator.php (modified) (history)
  • /trunk/extensions/ArticleComments/ArticleComments.php (modified) (history)
  • /trunk/extensions/Rdf/Rdf.php (modified) (history)
  • /trunk/extensions/SpecialFileList/SpecialFilelist.php (modified) (history)
  • /trunk/extensions/Wikidata/SpecialLanguages.php (modified) (history)
  • /trunk/extensions/uniwiki/CustomToolbar/CustomToolbar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleComments/ArticleComments.php
@@ -116,13 +116,8 @@
117117 $wgArticleCommentsNSDisplayList = array();
118118
119119 # Sets up special page to handle comment submission
120 -$wgExtensionFunctions[] = 'setupSpecialProcessComment';
 120+$wgSpecialPages[] = array( 'ProcessComment', '', true, 'specialProcessComment', false );
121121
122 -// FIXME: Use of SpecialPage::addPage is deprecated.
123 -function setupSpecialProcessComment() {
124 - SpecialPage::addPage( new SpecialPage( 'ProcessComment', '', true, 'specialProcessComment', false ) );
125 -}
126 -
127122 # Sets up the ArticleComments Parser hook for <comments />
128123 function wfArticleCommentsParserSetup( &$parser ) {
129124 $parser->setHook( 'comments', 'wfArticleCommentsParserHook' );
Index: trunk/extensions/Rdf/Rdf.php
@@ -99,12 +99,11 @@
100100 $wgHooks['TitleMoveComplete'][] = 'MwRdfOnTitleMoveComplete';
101101 $wgHooks['ArticleDeleteComplete'][] = 'MwRdfOnArticleDeleteComplete';
102102
 103+$wgSpecialPages[] = array( 'Rdf', '', true, 'wfSpecialRdf', 'extensions/MwRdf.php' );
 104+
103105 function setupMwRdf() {
104106 global $wgRequest, $wgOut;
105107
106 - SpecialPage::AddPage(new SpecialPage('Rdf', '', true, 'wfSpecialRdf',
107 - 'extensions/MwRdf.php'));
108 -
109108 # Add an RDF metadata link if requested
110109
111110 $action = $wgRequest->getText('action', 'view');
Index: trunk/extensions/SpecialFileList/SpecialFilelist.php
@@ -23,432 +23,425 @@
2424 $dir = dirname(__FILE__) . '/';
2525 $wgExtensionMessagesFiles['Filelist'] = $dir . 'SpecialFilelist.i18n.php';
2626
27 -require_once( 'ImageGallery.php' );
 27+$wgSpecialPages[] = 'SpecialFilelist';
2828
29 -function wfSpecialFilelist () {
30 - wfLoadExtensionMessages( 'Filelist' );
31 - global $IP;
32 - require_once "$IP/includes/SpecialPage.php";
33 - class SpecialFilelist extends SpecialPage {
 29+class SpecialFilelist extends SpecialPage {
3430
35 - var $dbr , $sk ;
 31+ var $dbr , $sk ;
3632
37 - /**
38 - * Constructor
39 - */
40 - function SpecialFilelist() {
41 - parent::__construct( 'Filelist' );
42 - $this->includable( false );
 33+ /**
 34+ * Constructor
 35+ */
 36+ function __construct() {
 37+ parent::__construct( 'Filelist' );
 38+ $this->includable( false );
 39+ }
 40+
 41+ /**
 42+ * Get the SQL to hide bot-users
 43+ @param hide Hide the bots? (boolean)
 44+ */
 45+ function getHideBotSQL ( $hide ) {
 46+ if ( !$hide ) {
 47+ # Don't hide bots
 48+ return "" ;
4349 }
4450
45 - /**
46 - * Get the SQL to hide bot-users
47 - @param hide Hide the bots? (boolean)
48 - */
49 - function getHideBotSQL ( $hide ) {
50 - if ( !$hide ) {
51 - # Don't hide bots
52 - return "" ;
 51+ global $wgGroupPermissions ;
 52+ $botconds=array();
 53+ foreach ($wgGroupPermissions as $groupname=>$perms) {
 54+ if(array_key_exists('bot',$perms) && $perms['bot']) {
 55+ $botconds[]="ug_group='$groupname'";
5356 }
54 -
55 - global $wgGroupPermissions ;
56 - $botconds=array();
57 - foreach ($wgGroupPermissions as $groupname=>$perms) {
58 - if(array_key_exists('bot',$perms) && $perms['bot']) {
59 - $botconds[]="ug_group='$groupname'";
60 - }
61 - }
62 - $isbotmember=$this->dbr->makeList($botconds, LIST_OR);
63 -
64 - /** This join, in conjunction with WHERE ug_group
65 - IS NULL, returns only those rows from IMAGE
66 - where the uploading user is not a member of
67 - a group which has the 'bot' permission set.
68 - */
69 - $ug = $this->dbr->tableName('user_groups');
70 - $joinsql=" LEFT OUTER JOIN $ug ON img_user=ug_user AND ("
71 - . $isbotmember.')';
72 - return $joinsql ;
7357 }
 58+ $isbotmember=$this->dbr->makeList($botconds, LIST_OR);
7459
75 - /**
76 - * Returns the latest timestamp for an image in the image table
77 - @param params Parameters, not changed by this function (passed as refrence for speedup)
 60+ /** This join, in conjunction with WHERE ug_group
 61+ IS NULL, returns only those rows from IMAGE
 62+ where the uploading user is not a member of
 63+ a group which has the 'bot' permission set.
7864 */
79 - function getTimeStamp ( &$params ) {
80 - $sql="SELECT img_timestamp from " . $params['imagetable'];
81 - if($params['hidebots']) {
82 - $sql .= $params['botsql'].' WHERE ug_group IS NULL';
83 - }
84 - if ( isset ( $params['user'] ) ) {
85 - $sql .= " AND img_user='" . $params['user']->getID() . "'" ;
86 - }
87 - $sql .= ' ORDER BY img_timestamp' ;
88 - $sql .= ' DESC' ;
89 - $sql .= ' LIMIT 1';
90 - $res = $this->dbr->query($sql, 'SpecialFilelist::getTimeStamp');
91 - $row = $this->dbr->fetchRow($res);
92 - if($row!==false) {
93 - $ts=$row[0];
94 - } else {
95 - $ts=false;
96 - }
97 - $this->dbr->freeResult($res);
 65+ $ug = $this->dbr->tableName('user_groups');
 66+ $joinsql=" LEFT OUTER JOIN $ug ON img_user=ug_user AND ("
 67+ . $isbotmember.')';
 68+ return $joinsql ;
 69+ }
9870
99 - /** If we were clever, we'd use this to cache. */
100 - $latestTimestamp = wfTimestamp( TS_MW, $ts);
101 - return $latestTimestamp ;
 71+ /**
 72+ * Returns the latest timestamp for an image in the image table
 73+ @param params Parameters, not changed by this function (passed as refrence for speedup)
 74+ */
 75+ function getTimeStamp ( &$params ) {
 76+ $sql="SELECT img_timestamp from " . $params['imagetable'];
 77+ if($params['hidebots']) {
 78+ $sql .= $params['botsql'].' WHERE ug_group IS NULL';
10279 }
 80+ if ( isset ( $params['user'] ) ) {
 81+ $sql .= " AND img_user='" . $params['user']->getID() . "'" ;
 82+ }
 83+ $sql .= ' ORDER BY img_timestamp' ;
 84+ $sql .= ' DESC' ;
 85+ $sql .= ' LIMIT 1';
 86+ $res = $this->dbr->query($sql, 'SpecialFilelist::getTimeStamp');
 87+ $row = $this->dbr->fetchRow($res);
 88+ if($row!==false) {
 89+ $ts=$row[0];
 90+ } else {
 91+ $ts=false;
 92+ }
 93+ $this->dbr->freeResult($res);
10394
104 - /**
105 - * Returns an array of images from the database
106 - @param params Parameters, not changed by this function (passed as refrence for speedup)
107 - */
108 - function getImages ( &$params ) {
109 - $where = array();
110 - $searchpar = '';
111 - if ( $params['match'] != '' ) {
112 - $nt = Title::newFromURL( $params['match'] );
113 - if($nt ) {
114 - $m = $this->dbr->strencode( strtolower( $nt->getDBkey() ) );
115 - $m = str_replace( '%', "\\%", $m );
116 - $m = str_replace( '_', "\\_", $m );
117 - $where[] = "LCASE(img_name) LIKE '%{$m}%'";
118 - $searchpar = '&wpIlMatch=' . ( $params['match'] );
119 - }
120 - }
 95+ /** If we were clever, we'd use this to cache. */
 96+ $latestTimestamp = wfTimestamp( TS_MW, $ts);
 97+ return $latestTimestamp ;
 98+ }
12199
122 - if( $params['until'] != "" ) {
123 - $where[] = 'img_timestamp >= ' . $this->dbr->timestamp( $params['until'] );
124 - } else if ( $params['date'] != "" ) {
125 - $where[] = 'img_timestamp < ' . $this->dbr->timestamp( $params['date'] );
 100+ /**
 101+ * Returns an array of images from the database
 102+ @param params Parameters, not changed by this function (passed as refrence for speedup)
 103+ */
 104+ function getImages ( &$params ) {
 105+ $where = array();
 106+ $searchpar = '';
 107+ if ( $params['match'] != '' ) {
 108+ $nt = Title::newFromURL( $params['match'] );
 109+ if($nt ) {
 110+ $m = $this->dbr->strencode( strtolower( $nt->getDBkey() ) );
 111+ $m = str_replace( '%', "\\%", $m );
 112+ $m = str_replace( '_', "\\_", $m );
 113+ $where[] = "LCASE(img_name) LIKE '%{$m}%'";
 114+ $searchpar = '&wpIlMatch=' . ( $params['match'] );
126115 }
 116+ }
127117
128 - $sql = 'SELECT img_size, img_name, img_user, img_user_text,'.
129 - 'img_description,img_timestamp FROM ' . $params['imagetable'] ;
 118+ if( $params['until'] != "" ) {
 119+ $where[] = 'img_timestamp >= ' . $this->dbr->timestamp( $params['until'] );
 120+ } else if ( $params['date'] != "" ) {
 121+ $where[] = 'img_timestamp < ' . $this->dbr->timestamp( $params['date'] );
 122+ }
130123
131 - # Hide the bots?
132 - if($params['hidebots']) {
133 - $sql .= $params['botsql'] ;
134 - $where[] = 'ug_group IS NULL' ;
135 - }
 124+ $sql = 'SELECT img_size, img_name, img_user, img_user_text,'.
 125+ 'img_description,img_timestamp FROM ' . $params['imagetable'] ;
136126
137 - # Single user?
138 - if ( isset ( $params['user'] ) ) {
139 - $where[] = "img_user='" . $params['user']->getID() . "'" ;
140 - }
 127+ # Hide the bots?
 128+ if($params['hidebots']) {
 129+ $sql .= $params['botsql'] ;
 130+ $where[] = 'ug_group IS NULL' ;
 131+ }
141132
142 - if(count($where)) {
143 - $sql.=' WHERE '.$this->dbr->makeList($where, LIST_AND);
144 - }
145 - $sql.=' ORDER BY img_timestamp '. ( $params['latestfirst'] ? '' : ' DESC' );
146 - $sql.=' LIMIT '.($params['limit']+1);
147 - $res = $this->dbr->query($sql, 'SpecialFilelist::getImages');
 133+ # Single user?
 134+ if ( isset ( $params['user'] ) ) {
 135+ $where[] = "img_user='" . $params['user']->getID() . "'" ;
 136+ }
148137
149 - /**
150 - * We have to flip things around to get the last N after a certain date
151 - */
152 - $images = array();
153 - while ( $s = $this->dbr->fetchObject( $res ) ) {
154 - if( $params['latestfirst'] ) {
155 - array_unshift( $images, $s );
156 - } else {
157 - array_push( $images, $s );
158 - }
159 - }
160 - $this->dbr->freeResult( $res );
161 - return $images ;
 138+ if(count($where)) {
 139+ $sql.=' WHERE '.$this->dbr->makeList($where, LIST_AND);
162140 }
 141+ $sql.=' ORDER BY img_timestamp '. ( $params['latestfirst'] ? '' : ' DESC' );
 142+ $sql.=' LIMIT '.($params['limit']+1);
 143+ $res = $this->dbr->query($sql, 'SpecialFilelist::getImages');
163144
164145 /**
165 - * Returns HTML for a gallery
166 - */
167 - function makeGallery ( &$images , &$params ) {
168 - global $wgLang ;
169 - $gallery = new ImageGallery();
170 - $firstTimestamp = null;
171 - $lastTimestamp = null;
172 - $shownImages = 0;
173 - $params['therearemore'] = false ;
174 - foreach( $images as $s ) {
175 - if( ++$shownImages > $params['limit'] ) {
176 - # One extra just to test for whether to show a page link;
177 - # don't actually show it, but remember there are more.
178 - $params['therearemore'] = true ;
179 - break;
180 - }
 146+ * We have to flip things around to get the last N after a certain date
 147+ */
 148+ $images = array();
 149+ while ( $s = $this->dbr->fetchObject( $res ) ) {
 150+ if( $params['latestfirst'] ) {
 151+ array_unshift( $images, $s );
 152+ } else {
 153+ array_push( $images, $s );
 154+ }
 155+ }
 156+ $this->dbr->freeResult( $res );
 157+ return $images ;
 158+ }
181159
182 - $name = $s->img_name;
183 - $ut = $s->img_user_text;
 160+ /**
 161+ * Returns HTML for a gallery
 162+ */
 163+ function makeGallery ( &$images , &$params ) {
 164+ global $wgLang ;
 165+ $gallery = new ImageGallery();
 166+ $firstTimestamp = null;
 167+ $lastTimestamp = null;
 168+ $shownImages = 0;
 169+ $params['therearemore'] = false ;
 170+ foreach( $images as $s ) {
 171+ if( ++$shownImages > $params['limit'] ) {
 172+ # One extra just to test for whether to show a page link;
 173+ # don't actually show it, but remember there are more.
 174+ $params['therearemore'] = true ;
 175+ break;
 176+ }
184177
185 - $nt = Title::newFromText( $name, NS_IMAGE );
186 - $ul = $this->sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
 178+ $name = $s->img_name;
 179+ $ut = $s->img_user_text;
187180
188 - $gallery->add( $nt, "$ul<br />\n<i>".$wgLang->timeanddate( $s->img_timestamp, true )."</i><br />\n" );
 181+ $nt = Title::newFromText( $name, NS_IMAGE );
 182+ $ul = $this->sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
189183
190 - $timestamp = wfTimestamp( TS_MW, $s->img_timestamp );
191 - if( empty( $firstTimestamp ) ) {
192 - $firstTimestamp = $timestamp;
193 - }
194 - $lastTimestamp = $timestamp;
 184+ $gallery->add( $nt, "$ul<br />\n<i>".$wgLang->timeanddate( $s->img_timestamp, true )."</i><br />\n" );
 185+
 186+ $timestamp = wfTimestamp( TS_MW, $s->img_timestamp );
 187+ if( empty( $firstTimestamp ) ) {
 188+ $firstTimestamp = $timestamp;
195189 }
196 - $params['lasttimestamp'] = $lastTimestamp ;
197 - $params['firsttimestamp'] = $firstTimestamp ;
198 - return $gallery->toHTML() ;
 190+ $lastTimestamp = $timestamp;
199191 }
 192+ $params['lasttimestamp'] = $lastTimestamp ;
 193+ $params['firsttimestamp'] = $firstTimestamp ;
 194+ return $gallery->toHTML() ;
 195+ }
200196
201 - /**
202 - * Returns a list of files
203 - */
204 - function makeList ( &$images , &$params ) {
205 - global $wgLang ;
206 - $firstTimestamp = null;
207 - $lastTimestamp = null;
208 - $shownImages = 0;
209 - $params['therearemore'] = false ;
210 - $out = "" ;
211 - foreach( $images as $s ) {
212 - if( ++$shownImages > $params['limit'] ) {
213 - # One extra just to test for whether to show a page link;
214 - # don't actually show it, but remember there are more.
215 - $params['therearemore'] = true ;
216 - break;
217 - }
 197+ /**
 198+ * Returns a list of files
 199+ */
 200+ function makeList ( &$images , &$params ) {
 201+ global $wgLang ;
 202+ $firstTimestamp = null;
 203+ $lastTimestamp = null;
 204+ $shownImages = 0;
 205+ $params['therearemore'] = false ;
 206+ $out = "" ;
 207+ foreach( $images as $s ) {
 208+ if( ++$shownImages > $params['limit'] ) {
 209+ # One extra just to test for whether to show a page link;
 210+ # don't actually show it, but remember there are more.
 211+ $params['therearemore'] = true ;
 212+ break;
 213+ }
218214
219 - $name = $s->img_name;
220 - $ut = $s->img_user_text;
221 - if ( 0 == $s->img_user ) {
222 - $ul = $ut;
223 - } else {
224 - $ul = $this->sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
225 - }
 215+ $name = $s->img_name;
 216+ $ut = $s->img_user_text;
 217+ if ( 0 == $s->img_user ) {
 218+ $ul = $ut;
 219+ } else {
 220+ $ul = $this->sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
 221+ }
226222
227 - $ilink = "<a href=\"" . htmlspecialchars( wfLocalFile( $name )->getUrl() ) .
228 - "\">" . strtr(htmlspecialchars( $name ), '_', ' ') . "</a>";
 223+ $ilink = "<a href=\"" . htmlspecialchars( wfLocalFile( $name )->getUrl() ) .
 224+ "\">" . strtr(htmlspecialchars( $name ), '_', ' ') . "</a>";
229225
230 - $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) );
231 - $l = "(" .
232 - $this->sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ),
233 - wfMsg( 'filelist-image-desc' ) ) .
234 - ") {$ilink} . . {$nb} . . {$ul} . . " .
235 - $wgLang->timeanddate( $s->img_timestamp, true );
 226+ $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) );
 227+ $l = "(" .
 228+ $this->sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ),
 229+ wfMsg( 'filelist-image-desc' ) ) .
 230+ ") {$ilink} . . {$nb} . . {$ul} . . " .
 231+ $wgLang->timeanddate( $s->img_timestamp, true );
236232
237 - $l .= $this->sk->commentBlock( $s->img_description );
238 - $out .= $l . "<br />\n" ;
 233+ $l .= $this->sk->commentBlock( $s->img_description );
 234+ $out .= $l . "<br />\n" ;
239235
240 - $timestamp = wfTimestamp( TS_MW, $s->img_timestamp );
241 - if( empty( $firstTimestamp ) ) {
242 - $firstTimestamp = $timestamp;
243 - }
244 - $lastTimestamp = $timestamp;
 236+ $timestamp = wfTimestamp( TS_MW, $s->img_timestamp );
 237+ if( empty( $firstTimestamp ) ) {
 238+ $firstTimestamp = $timestamp;
245239 }
246 - $params['lasttimestamp'] = $lastTimestamp ;
247 - $params['firsttimestamp'] = $firstTimestamp ;
248 - return $out ;
 240+ $lastTimestamp = $timestamp;
249241 }
 242+ $params['lasttimestamp'] = $lastTimestamp ;
 243+ $params['firsttimestamp'] = $firstTimestamp ;
 244+ return $out ;
 245+ }
250246
251 - /**
252 - * Preparing parameter for URL
253 - */
254 - function convertURLparams ( &$params ) {
255 - $p2 = array() ;
256 - if ( isset ( $p2['user'] ) ) {
257 - $p2['user'] = urlencode ( $p2['user']->getName() ) ;
258 - }
 247+ /**
 248+ * Preparing parameter for URL
 249+ */
 250+ function convertURLparams ( &$params ) {
 251+ $p2 = array() ;
 252+ if ( isset ( $p2['user'] ) ) {
 253+ $p2['user'] = urlencode ( $p2['user']->getName() ) ;
 254+ }
259255
260 - if ( $params['gallery'] != true ) $p2['gallery'] = $params['gallery'] ? "1" : "0" ;
261 - if ( $params['hidebots'] != true ) $p2['hidebots'] = $params['hidebots'] ? "1" : "0" ;
262 - if ( $params['date'] != "" ) $p2['date'] = $params['date'] ;
263 - if ( $params['until'] != "" ) $p2['until'] = $params['until'] ;
264 - if ( $params['match'] != "" ) $p2['match'] = $params['match'] ;
265 - $p2['limit'] = $params['limit'] ;
 256+ if ( $params['gallery'] != true ) $p2['gallery'] = $params['gallery'] ? "1" : "0" ;
 257+ if ( $params['hidebots'] != true ) $p2['hidebots'] = $params['hidebots'] ? "1" : "0" ;
 258+ if ( $params['date'] != "" ) $p2['date'] = $params['date'] ;
 259+ if ( $params['until'] != "" ) $p2['until'] = $params['until'] ;
 260+ if ( $params['match'] != "" ) $p2['match'] = $params['match'] ;
 261+ $p2['limit'] = $params['limit'] ;
266262
267 - return $p2 ;
268 - }
 263+ return $p2 ;
 264+ }
269265
270 - /**
271 - * Return URL parameters
272 - */
273 - function getURLparams ( &$params ) {
274 - $ret = "" ;
275 - foreach ( $params AS $k => $v ) {
276 - if ( $v == "" ) continue ;
277 - if ( $ret != "" ) {
278 - $ret .= "&" ;
279 - }
280 - $ret .= $k . "=" . urlencode ( $v ) ;
 266+ /**
 267+ * Return URL parameters
 268+ */
 269+ function getURLparams ( &$params ) {
 270+ $ret = "" ;
 271+ foreach ( $params AS $k => $v ) {
 272+ if ( $v == "" ) continue ;
 273+ if ( $ret != "" ) {
 274+ $ret .= "&" ;
281275 }
282 - return $ret ;
 276+ $ret .= $k . "=" . urlencode ( $v ) ;
283277 }
 278+ return $ret ;
 279+ }
284280
285 - /**
286 - * Returns the form for keyword matching
287 - */
288 - function matchform ( &$params ) {
289 - $titleObj = SpecialPage::getTitleFor( 'Filelist' );
290 - $action = $titleObj->escapeLocalURL();
291 - $sub = wfMsg( 'ilsubmit' );
292 - $p2 = $this->convertURLparams ( $params ) ;
293 - unset ( $p2['match'] ) ;
294 - $action .= "?" . $this->getURLparams ( $p2 ) ;
295 - $ret = "<form id=\"matchform\" method=\"post\" action=\"" .
296 - "{$action}\">" .
297 - "<input type='text' size='20' name=\"match\" value=\"" .
298 - htmlspecialchars( $params['match'] ) . "\" /> " .
299 - "<input type='submit' name=\"domatch\" value=\"{$sub}\" /></form>" ;
300 - return "<p>" . $ret . "</p>" ;
 281+ /**
 282+ * Returns the form for keyword matching
 283+ */
 284+ function matchform ( &$params ) {
 285+ $titleObj = SpecialPage::getTitleFor( 'Filelist' );
 286+ $action = $titleObj->escapeLocalURL();
 287+ $sub = wfMsg( 'ilsubmit' );
 288+ $p2 = $this->convertURLparams ( $params ) ;
 289+ unset ( $p2['match'] ) ;
 290+ $action .= "?" . $this->getURLparams ( $p2 ) ;
 291+ $ret = "<form id=\"matchform\" method=\"post\" action=\"" .
 292+ "{$action}\">" .
 293+ "<input type='text' size='20' name=\"match\" value=\"" .
 294+ htmlspecialchars( $params['match'] ) . "\" /> " .
 295+ "<input type='submit' name=\"domatch\" value=\"{$sub}\" /></form>" ;
 296+ return "<p>" . $ret . "</p>" ;
 297+ }
 298+
 299+ /**
 300+ * Returns the limits links
 301+ */
 302+ function limits ( &$params ) {
 303+ global $wgLang ;
 304+ $titleObj = SpecialPage::getTitleFor( 'Filelist' );
 305+ $ret = array () ;
 306+
 307+ if ( $params['gallery'] ) {
 308+ $al = array ( 12 , 36 , 48 , 60 ) ;
 309+ } else {
 310+ $al = array ( 10 , 25 , 50 , 100 ) ;
301311 }
302312
303 - /**
304 - * Returns the limits links
305 - */
306 - function limits ( &$params ) {
307 - global $wgLang ;
308 - $titleObj = SpecialPage::getTitleFor( 'Filelist' );
309 - $ret = array () ;
 313+ $p2 = $this->convertURLparams ( $params ) ;
310314
311 - if ( $params['gallery'] ) {
312 - $al = array ( 12 , 36 , 48 , 60 ) ;
313 - } else {
314 - $al = array ( 10 , 25 , 50 , 100 ) ;
315 - }
 315+ foreach ( $al AS $l ) {
 316+ $p2['limit'] = $l ;
 317+ $p = $this->getURLparams ( $p2 ) ;
316318
317 - $p2 = $this->convertURLparams ( $params ) ;
 319+ $ret[] = $this->sk->makeKnownLinkObj( $titleObj, $wgLang->formatNum( $l ), $p ) ;
 320+ }
318321
319 - foreach ( $al AS $l ) {
320 - $p2['limit'] = $l ;
321 - $p = $this->getURLparams ( $p2 ) ;
 322+ $text = wfMsg( "showlast", $wgLang->pipeList( $ret ), wfMsg('bydate') );
 323+ return $text ;
 324+ }
322325
323 - $ret[] = $this->sk->makeKnownLinkObj( $titleObj, $wgLang->formatNum( $l ), $p ) ;
324 - }
 326+ /**
 327+ * Returns the option links
 328+ */
 329+ function options ( &$params ) {
 330+ global $wgLang;
325331
326 - $text = wfMsg( "showlast", $wgLang->pipeList( $ret ), wfMsg('bydate') );
327 - return $text ;
328 - }
 332+ $titleObj = SpecialPage::getTitleFor( 'Filelist' );
 333+ $ret = array () ;
329334
330 - /**
331 - * Returns the option links
332 - */
333 - function options ( &$params ) {
334 - global $wgLang;
 335+ $p2 = $this->convertURLparams ( $params ) ;
 336+ $p2['hidebots'] = $params['hidebots'] ? "0" : "1" ;
 337+ $bots = wfMsg( 'showhidebots', ($params['hidebots'] ? wfMsg('show') : wfMsg('hide'))) ;
 338+ $ret[] = $this->sk->makeKnownLinkObj( $titleObj, $bots, $this->getURLparams ( $p2 ) );
335339
336 - $titleObj = SpecialPage::getTitleFor( 'Filelist' );
337 - $ret = array () ;
 340+ $p2 = $this->convertURLparams ( $params ) ;
 341+ $p2['gallery'] = $params['gallery'] ? "0" : "1" ;
 342+ $bots = $params['gallery'] ? wfMsg('filelist-show-list') : wfMsg('filelist-show-gallery') ;
 343+ $ret[] = $this->sk->makeKnownLinkObj( $titleObj, $bots, $this->getURLparams ( $p2 ) );
338344
339 - $p2 = $this->convertURLparams ( $params ) ;
340 - $p2['hidebots'] = $params['hidebots'] ? "0" : "1" ;
341 - $bots = wfMsg( 'showhidebots', ($params['hidebots'] ? wfMsg('show') : wfMsg('hide'))) ;
342 - $ret[] = $this->sk->makeKnownLinkObj( $titleObj, $bots, $this->getURLparams ( $p2 ) );
 345+ return "<p>" . $wgLang->pipeList( $ret ) . "</p>" ;
 346+ }
343347
 348+ /**
 349+ * Returns the previous/next links
 350+ */
 351+ function prevnext ( &$params ) {
 352+ global $wgLang ;
 353+ $out = "" ;
 354+ $titleObj = SpecialPage::getTitleFor( 'Filelist' );
 355+
 356+ $prevLink = wfMsg( 'prevn', $wgLang->formatNum( $params['limit'] ) );
 357+ if( $params['therearebefore'] ) {
344358 $p2 = $this->convertURLparams ( $params ) ;
345 - $p2['gallery'] = $params['gallery'] ? "0" : "1" ;
346 - $bots = $params['gallery'] ? wfMsg('filelist-show-list') : wfMsg('filelist-show-gallery') ;
347 - $ret[] = $this->sk->makeKnownLinkObj( $titleObj, $bots, $this->getURLparams ( $p2 ) );
 359+ $p2['until'] = $params['firsttimestamp'] ;
 360+ unset ( $p2['date'] ) ;
 361+ $prevLink = $this->sk->makeKnownLinkObj( $titleObj, $prevLink, $this->getURLparams ( $p2 ) );
 362+ }
348363
349 - return "<p>" . $wgLang->pipeList( $ret ) . "</p>" ;
 364+ $nextLink = wfMsg( 'nextn', $wgLang->formatNum( $params['limit'] ) );
 365+ if( $params['therearemore'] ) {
 366+ $p2 = $this->convertURLparams ( $params ) ;
 367+ $p2['date'] = $params['lasttimestamp'] ;
 368+ unset ( $p2['until'] ) ;
 369+ $nextLink = $this->sk->makeKnownLinkObj( $titleObj, $nextLink, $this->getURLparams ( $p2 ) );
350370 }
351371
352 - /**
353 - * Returns the previous/next links
354 - */
355 - function prevnext ( &$params ) {
356 - global $wgLang ;
357 - $out = "" ;
358 - $titleObj = SpecialPage::getTitleFor( 'Filelist' );
 372+ $out .= $wgLang->pipeList( array( $prevLink, $nextLink ) );
359373
360 - $prevLink = wfMsg( 'prevn', $wgLang->formatNum( $params['limit'] ) );
361 - if( $params['therearebefore'] ) {
362 - $p2 = $this->convertURLparams ( $params ) ;
363 - $p2['until'] = $params['firsttimestamp'] ;
364 - unset ( $p2['date'] ) ;
365 - $prevLink = $this->sk->makeKnownLinkObj( $titleObj, $prevLink, $this->getURLparams ( $p2 ) );
366 - }
 374+ return "<p>" . $out . "</p>" ;
 375+ }
367376
368 - $nextLink = wfMsg( 'nextn', $wgLang->formatNum( $params['limit'] ) );
369 - if( $params['therearemore'] ) {
370 - $p2 = $this->convertURLparams ( $params ) ;
371 - $p2['date'] = $params['lasttimestamp'] ;
372 - unset ( $p2['until'] ) ;
373 - $nextLink = $this->sk->makeKnownLinkObj( $titleObj, $nextLink, $this->getURLparams ( $p2 ) );
374 - }
 377+ /**
 378+ * main()
 379+ */
 380+ function execute( $par = null ) {
 381+ global $wgOut, $wgRequest, $wgUser;
 382+ $this->dbr = wfGetDB( DB_SLAVE );
 383+ $this->sk = $wgUser->getSkin();
375384
376 - $out .= $wgLang->pipeList( array( $prevLink, $nextLink ) );
 385+ # Setting a bunch of parameters to passed or default values; also some variables which makes them easier to pass to functions
 386+ $params['gallery'] = $wgRequest->getBool ( 'gallery' , true ) ;
 387+ $params['hidebots'] = $wgRequest->getBool ( 'hidebots' , true ) ;
 388+ $params['date'] = $wgRequest->getVal ( 'date' , "" ) ;
 389+ $params['until'] = $wgRequest->getVal ( 'until' , "" ) ;
 390+ $params['match'] = $wgRequest->getVal ( 'match' , "" ) ;
 391+ $params['limit'] = $wgRequest->getInt ( 'limit' , ($params['gallery']?48:50) ) ;
 392+ $params['user'] = urldecode ( $wgRequest->getVal ( 'user' , ($par==null?"":$par) ) ) ;
 393+ $params['botsql'] = $this->getHideBotSQL ( $params['hidebots'] ) ;
 394+ $params['imagetable'] = $this->dbr->tableName('image');
377395
378 - return "<p>" . $out . "</p>" ;
 396+ # If "until" is set, "date" should be invalid; also, "latestfirst" should be true to force inverted
 397+ if ( $params['until'] != "" ) {
 398+ $params['date'] = "" ;
 399+ $params['latestfirst'] = true ;
 400+ } else {
 401+ $params['latestfirst'] = false ;
379402 }
380403
381 - /**
382 - * main()
383 - */
384 - function execute( $par = null ) {
385 - global $wgOut, $wgRequest, $wgUser;
386 - $this->dbr = wfGetDB( DB_SLAVE );
387 - $this->sk = $wgUser->getSkin();
 404+ # Preventing full DB scan for single user; remove this and the following line once the user field has an index
 405+ $params['user'] = "" ;
388406
389 - # Setting a bunch of parameters to passed or default values; also some variables which makes them easier to pass to functions
390 - $params['gallery'] = $wgRequest->getBool ( 'gallery' , true ) ;
391 - $params['hidebots'] = $wgRequest->getBool ( 'hidebots' , true ) ;
392 - $params['date'] = $wgRequest->getVal ( 'date' , "" ) ;
393 - $params['until'] = $wgRequest->getVal ( 'until' , "" ) ;
394 - $params['match'] = $wgRequest->getVal ( 'match' , "" ) ;
395 - $params['limit'] = $wgRequest->getInt ( 'limit' , ($params['gallery']?48:50) ) ;
396 - $params['user'] = urldecode ( $wgRequest->getVal ( 'user' , ($par==null?"":$par) ) ) ;
397 - $params['botsql'] = $this->getHideBotSQL ( $params['hidebots'] ) ;
398 - $params['imagetable'] = $this->dbr->tableName('image');
399 -
400 - # If "until" is set, "date" should be invalid; also, "latestfirst" should be true to force inverted
401 - if ( $params['until'] != "" ) {
402 - $params['date'] = "" ;
403 - $params['latestfirst'] = true ;
 407+ # Set $user variable if there is a valid user requested
 408+ if ( $params['user'] != "" ) {
 409+ $user = User::newFromName ( $params['user'] ) ;
 410+ if ( 0 != $user->getID() ) {
 411+ $params['user'] = $user ;
404412 } else {
405 - $params['latestfirst'] = false ;
406 - }
407 -
408 - # Preventing full DB scan for single user; remove this and the following line once the user field has an index
409 - $params['user'] = "" ;
410 -
411 - # Set $user variable if there is a valid user requested
412 - if ( $params['user'] != "" ) {
413 - $user = User::newFromName ( $params['user'] ) ;
414 - if ( 0 != $user->getID() ) {
415 - $params['user'] = $user ;
416 - } else {
417 - unset ( $params['user'] ) ;
418 - }
419 - unset ( $user ) ;
420 - } else {
421413 unset ( $params['user'] ) ;
422414 }
 415+ unset ( $user ) ;
 416+ } else {
 417+ unset ( $params['user'] ) ;
 418+ }
423419
424 - # Ths following depends on the user above, so don't move it upwards!
425 - $params['timestamp'] = $this->getTimeStamp ( $params ) ;
 420+ # Ths following depends on the user above, so don't move it upwards!
 421+ $params['timestamp'] = $this->getTimeStamp ( $params ) ;
426422
427 - $images = $this->getImages ( $params ) ;
 423+ $images = $this->getImages ( $params ) ;
428424
429 - if ( $params['gallery'] ) {
430 - $between = $this->makeGallery ( $images , $params ) ;
431 - } else {
432 - $between = $this->makeList ( $images , $params ) ;
433 - }
 425+ if ( $params['gallery'] ) {
 426+ $between = $this->makeGallery ( $images , $params ) ;
 427+ } else {
 428+ $between = $this->makeList ( $images , $params ) ;
 429+ }
434430
435 - # This is strange
436 - $params['therearebefore'] = ( $params['firsttimestamp'] != $params['timestamp'] ) ;
 431+ # This is strange
 432+ $params['therearebefore'] = ( $params['firsttimestamp'] != $params['timestamp'] ) ;
437433
438 - $noi = count ( $images ) > $params['limit'] ? $params['limit'] : count ( $images ) ;
 434+ $noi = count ( $images ) > $params['limit'] ? $params['limit'] : count ( $images ) ;
439435
440 - $out = '<p>' . wfMsgForContent ( 'imagelisttext' , $noi , wfMsg('bydate') ) . '</p>' ;
441 - $out .= $this->matchform ( $params ) ;
442 - $out .= $this->options ( $params ) ;
443 - $out .= $this->limits ( $params ) ;
444 - $out .= $this->prevnext ( $params ) ;
445 - $out .= $between ;
446 - $out .= $this->prevnext ( $params ) ;
 436+ $out = '<p>' . wfMsgForContent ( 'imagelisttext' , $noi , wfMsg('bydate') ) . '</p>' ;
 437+ $out .= $this->matchform ( $params ) ;
 438+ $out .= $this->options ( $params ) ;
 439+ $out .= $this->limits ( $params ) ;
 440+ $out .= $this->prevnext ( $params ) ;
 441+ $out .= $between ;
 442+ $out .= $this->prevnext ( $params ) ;
447443
448444
449 - $this->setHeaders();
450 - $wgOut->addHTML( $out );
451 - }
 445+ $this->setHeaders();
 446+ $wgOut->addHTML( $out );
452447 }
453 -
454 - SpecialPage::addPage( new SpecialFilelist );
455448 }
Index: trunk/extensions/uniwiki/CustomToolbar/CustomToolbar.php
@@ -81,7 +81,7 @@
8282 $wgExtensionFunctions[] = 'wfCustomToolbarUploadForm';
8383 function wfCustomToolbarUploadForm() {
8484 $file = "extensions/uniwiki/CustomToolbar/CustomToolbar.php";
85 - SpecialPage::AddPage(
 85+ SpecialPage::addPage(
8686 new UnlistedSpecialPage('CustomToolbarUpload', '', false, $file)
8787 );
8888 }
Index: trunk/extensions/Aggregator/Aggregator.php
@@ -31,13 +31,10 @@
3232 define( 'MAGPIE_OUTPUT_ENCODING', 'UTF-8' );
3333 }
3434 require_once 'rss_fetch.inc';
35 -
36 - // Wiki pieces
37 - require_once 'SpecialPage.php';
38 - require_once 'Feed.php';
39 - SpecialPage::addPage( new SpecialPage( 'Aggregator', /*perm*/false, /*listed*/ true, /*function*/ false, /*file*/ false ) );
4035 }
4136
 37+$wgSpecialPages[] = array( 'Aggregator', /*perm*/false, /*listed*/ true, /*function*/ false, /*file*/ false );
 38+
4239 /**
4340 * Parser extension hook
4441 */
Index: trunk/extensions/Wikidata/SpecialLanguages.php
@@ -20,56 +20,53 @@
2121 'descmsg' => 'langman-desc',
2222 );
2323
24 -function wfSpecialManageLanguages() {
25 - global $IP;
26 -
27 - require_once "$IP/includes/SpecialPage.php";
 24+$wgSpecialPages[] = 'SpecialLanguages';
2825
29 - class SpecialLanguages extends SpecialPage {
30 - function SpecialLanguages() {
31 - parent::__construct( 'Languages' );
32 - }
 26+class SpecialLanguages extends SpecialPage {
 27+ function SpecialLanguages() {
 28+ parent::__construct( 'Languages' );
 29+ }
3330
34 - function execute( $par ) {
35 - global $wgOut, $wgRequest, $wgUser;
36 - $wgOut->setPageTitle( wfMsg( 'langman_title' ) );
37 - if ( !$wgUser->isAllowed( 'addlanguage' ) ) {
38 - $wgOut->addHTML( wfMsg( 'langman_not_allowed' ) );
39 - return false;
40 - }
41 - $action = $wgRequest->getText( 'action' );
42 - if ( !$action ) {
43 - $wgOut->addWikiText( wfMsg( 'langman_header' ) );
 31+ function execute( $par ) {
 32+ global $wgOut, $wgRequest, $wgUser;
 33+ $wgOut->setPageTitle( wfMsg( 'langman_title' ) );
 34+ if ( !$wgUser->isAllowed( 'addlanguage' ) ) {
 35+ $wgOut->addHTML( wfMsg( 'langman_not_allowed' ) );
 36+ return false;
 37+ }
 38+ $action = $wgRequest->getText( 'action' );
 39+ if ( !$action ) {
 40+ $wgOut->addWikiText( wfMsg( 'langman_header' ) );
 41+ } else {
 42+ $dbr = wfGetDB( DB_MASTER );
 43+ $langname = $wgRequest->getText( 'langname' );
 44+ $langiso6393 = $wgRequest->getText( 'langiso6393' );
 45+ $langiso6392 = $wgRequest->getText( 'langiso6392' );
 46+ $langwmf = $wgRequest->getText( 'langwmf' );
 47+ if ( !$langname || !$langiso6393 ) {
 48+ $wgOut->addHTML( "<strong>" . wfMsg( 'langman_req_fields' ) . "</strong>" );
4449 } else {
45 - $dbr = wfGetDB( DB_MASTER );
46 - $langname = $wgRequest->getText( 'langname' );
47 - $langiso6393 = $wgRequest->getText( 'langiso6393' );
48 - $langiso6392 = $wgRequest->getText( 'langiso6392' );
49 - $langwmf = $wgRequest->getText( 'langwmf' );
50 - if ( !$langname || !$langiso6393 ) {
51 - $wgOut->addHTML( "<strong>" . wfMsg( 'langman_req_fields' ) . "</strong>" );
52 - } else {
53 - $wgOut->addHTML( "<strong>" . wfMsg( 'langman_adding', $langname, $langiso6393 ) . "</strong>" );
54 - $sql = 'INSERT INTO language(iso639_2,iso639_3,wikimedia_key) values(' . $dbr->addQuotes( $langiso6392 ) . ',' . $dbr->addQuotes( $langiso6393 ) . ',' . $dbr->addQuotes( $langwmf ) . ')';
 50+ $wgOut->addHTML( "<strong>" . wfMsg( 'langman_adding', $langname, $langiso6393 ) . "</strong>" );
 51+ $sql = 'INSERT INTO language(iso639_2,iso639_3,wikimedia_key) values(' . $dbr->addQuotes( $langiso6392 ) . ',' . $dbr->addQuotes( $langiso6393 ) . ',' . $dbr->addQuotes( $langwmf ) . ')';
5552
56 - $dbr->query( $sql );
57 - $id = $dbr->insertId();
58 - $sql = 'INSERT INTO language_names(language_id,name_language_id,language_name) values (' . $id . ',85,' . $dbr->addQuotes( $langname ) . ')';
59 - $dbr->query( $sql );
 53+ $dbr->query( $sql );
 54+ $id = $dbr->insertId();
 55+ $sql = 'INSERT INTO language_names(language_id,name_language_id,language_name) values (' . $id . ',85,' . $dbr->addQuotes( $langname ) . ')';
 56+ $dbr->query( $sql );
6057
61 - }
62 -
6358 }
6459
65 - $this->showForm();
 60+ }
6661
 62+ $this->showForm();
6763
68 - # $wgRequest->getText( 'page' );
69 - }
70 - function showForm() {
71 - global $wgOut;
72 - $action = $this->getTitle()->escapeLocalURL( 'action=submit' );
73 - $wgOut->addHTML(
 64+
 65+ # $wgRequest->getText( 'page' );
 66+ }
 67+ function showForm() {
 68+ global $wgOut;
 69+ $action = $this->getTitle()->escapeLocalURL( 'action=submit' );
 70+ $wgOut->addHTML(
7471 <<<END
7572 <form name="addlanguage" method="post" action="$action">
7673 <table border="0">
@@ -130,10 +127,7 @@
131128 </form>
132129 END
133130 );
134 - return true;
 131+ return true;
135132
136 - }
137133 }
138 -
139 - SpecialPage::addPage( new SpecialLanguages );
140134 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81220Part of bug 27041, removing all calls to escapeLike in extensionsreedy22:34, 30 January 2011
r81241bug 27041, fixup usages of userMailer()reedy12:21, 31 January 2011
r81242Per bug 27041, remove calls to $dbr->immediateBegin();...reedy12:24, 31 January 2011
r81243bug 27041, replace call to SiteStats::admins() to SiteStats::numberingroup( '...reedy12:26, 31 January 2011
r81244bug 27041, swap Database::newFromParams to DatabaseBase::newFromType()reedy12:34, 31 January 2011
r81245bug 27041, kill Image::__constructreedy12:45, 31 January 2011

Comments

#Comment by Catrope (talk | contribs)   14:59, 2 February 2011

Untag 1.17. If this just changed a few addPage() calls to $wgSpecialPages, fine, but it also refactors a number of special pages to be in classes. Making a few obscure extensions stop using deprecated but working code in 1.17 rather than 1.18 is not worth my review time.

Status & tagging log