r65343 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65342‎ | r65343 | r65344 >
Date:21:24, 20 April 2010
Author:siebrand
Status:deferred
Tags:
Comment:
stylize.php, indentation updated
Modified paths:
  • /trunk/extensions/CategoryOnUpload/CategoryOnUpload.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryOnUpload/CategoryOnUpload.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /**
54 * CategoryOnUpload Extension
65 *
@@ -8,7 +7,7 @@
98 * Warning: Should not be enabled on wikis with lots of categories.
109 *
1110 * @ingroup Extensions
12 - *
 11+ *
1312 * @link http://www.mediawiki.org/wiki/Extension:CategoryOnUpload
1413 *
1514 * @author Robert Leverington <robert@rhl.me.uk>
@@ -17,7 +16,7 @@
1817 */
1918
2019 // Ensure accessed via a valid entry point.
21 -if( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' );
 20+if ( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' );
2221
2322 // Register extension credits.
2423 $wgExtensionCredits[ 'other' ][] = array(
@@ -45,7 +44,6 @@
4645 * Adds a category selection box to the end of the default UploadForm table.
4746 */
4847 function efCategoryOnUploadForm( $uploadFormObj ) {
49 -
5048 /* Get the database prefix, needed for 1.12 to do custom query. When 1.13
5149 * is released it can be removed and the category table used instead.
5250 */
@@ -73,11 +71,8 @@
7472
7573 /* If permitted output the "none" option.
7674 */
77 - if( $wgCategoryOnUploadAllowNone ) {
78 -
79 - $cat .=
80 - Xml::option( wfMsg( 'categoryonupload-none' ), '#' );
81 -
 75+ if ( $wgCategoryOnUploadAllowNone ) {
 76+ $cat .= Xml::option( wfMsg( 'categoryonupload-none' ), '#' );
8277 }
8378
8479 /* Get deault category, to compare with category option being output, so the
@@ -85,8 +80,7 @@
8681 */
8782 global $wgCategoryOnUploadDefault, $wgCategoryOnUploadList;
8883
89 - if( !is_array( $wgCategoryOnUploadList ) ) {
90 -
 84+ if ( !is_array( $wgCategoryOnUploadList ) ) {
9185 /* Get a database read object.
9286 */
9387 $dbr = wfGetDB( DB_SLAVE );
@@ -98,7 +92,7 @@
9993 * interface could be created; but when it was developed only a few needed
10094 * to be displayed so this was not an issue. Fallback to the select box is
10195 * essential no matter what improvements are made.
102 - *
 96+ *
10397 * It would be nice to use the category table to avoid having to do a
10498 * manual query and perhaps improve performance, but it appears to not
10599 * descriminate between existing and non-existing categories, this would be
@@ -114,23 +108,21 @@
115109 * of resources. If this becomes an issue simply remove the # comments and
116110 * comment out the first line.
117111 */
118 - while( $row = $dbr->fetchObject( $res ) ) {
119 -
 112+ while ( $row = $dbr->fetchObject( $res ) ) {
120113 $text = str_replace( '_', ' ', $row->cl_to );
121 - #$title = Title::newFromText( $row->cl_to, NS_CATEGORY );
122 - #$text = $title->getText();
 114+ # $title = Title::newFromText( $row->cl_to, NS_CATEGORY );
 115+ # $text = $title->getText();
123116
124117 /* Add option to output, if it is the default then make it selected too.
125118 */
126119 $cat .= Xml::option( $text, $row->cl_to, ( $text == $wgCategoryOnUploadDefault ) );
127120
128121 }
129 -
130122 } else {
131 - foreach( $wgCategoryOnUploadList as $category ) {
 123+ foreach ( $wgCategoryOnUploadList as $category ) {
132124 $text = str_replace( '_', ' ', $category );
133 - #$title = Title::newFromText( $row->cl_to, NS_CATEGORY );
134 - #$text = $title->getText();
 125+ # $title = Title::newFromText( $row->cl_to, NS_CATEGORY );
 126+ # $text = $title->getText();
135127
136128 /* Add option to output, if it is the default then make it selected too.
137129 */
@@ -140,9 +132,8 @@
141133
142134 /* Close all the open elements, finished generation.
143135 */
144 - $cat .=
145 - Xml::closeElement( 'select' ) .
146 - Xml::closeElement( 'td' ) .
 136+ $cat .= Xml::closeElement( 'select' ) .
 137+ Xml::closeElement( 'td' ) .
147138 Xml::closeElement( 'tr' );
148139
149140 /* Add the category selector to the start of the form so that other
@@ -156,14 +147,12 @@
157148 * generated.
158149 */
159150 return true;
160 -
161151 }
162152
163153 /**
164154 * Append the category statement to the end of the upload summary.
165155 */
166156 function efCategoryOnUploadProcess( $uploadFormObj ) {
167 -
168157 /* Get the request object.
169158 */
170159 global $wgRequest;
@@ -175,7 +164,7 @@
176165 /* Append the category statement to the end of the upload summary if the
177166 * cateogry is not '#' (indicating no category to be added).
178167 */
179 - if( $cat != '#' ) {
 168+ if ( $cat != '#' ) {
180169 $uploadFormObj->mComment .= "\n" . '[[Category:' . $wgRequest->getText( 'wpUploadCategory' ) . ']]';
181170 }
182171
@@ -183,5 +172,4 @@
184173 * generated.
185174 */
186175 return true;
187 -
188176 }

Status & tagging log