Index: trunk/extensions/CategoryOnUpload/CategoryOnUpload.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * CategoryOnUpload Extension |
6 | 5 | * |
— | — | @@ -8,7 +7,7 @@ |
9 | 8 | * Warning: Should not be enabled on wikis with lots of categories. |
10 | 9 | * |
11 | 10 | * @ingroup Extensions |
12 | | - * |
| 11 | + * |
13 | 12 | * @link http://www.mediawiki.org/wiki/Extension:CategoryOnUpload |
14 | 13 | * |
15 | 14 | * @author Robert Leverington <robert@rhl.me.uk> |
— | — | @@ -17,7 +16,7 @@ |
18 | 17 | */ |
19 | 18 | |
20 | 19 | // Ensure accessed via a valid entry point. |
21 | | -if( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' ); |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' ); |
22 | 21 | |
23 | 22 | // Register extension credits. |
24 | 23 | $wgExtensionCredits[ 'other' ][] = array( |
— | — | @@ -45,7 +44,6 @@ |
46 | 45 | * Adds a category selection box to the end of the default UploadForm table. |
47 | 46 | */ |
48 | 47 | function efCategoryOnUploadForm( $uploadFormObj ) { |
49 | | - |
50 | 48 | /* Get the database prefix, needed for 1.12 to do custom query. When 1.13 |
51 | 49 | * is released it can be removed and the category table used instead. |
52 | 50 | */ |
— | — | @@ -73,11 +71,8 @@ |
74 | 72 | |
75 | 73 | /* If permitted output the "none" option. |
76 | 74 | */ |
77 | | - if( $wgCategoryOnUploadAllowNone ) { |
78 | | - |
79 | | - $cat .= |
80 | | - Xml::option( wfMsg( 'categoryonupload-none' ), '#' ); |
81 | | - |
| 75 | + if ( $wgCategoryOnUploadAllowNone ) { |
| 76 | + $cat .= Xml::option( wfMsg( 'categoryonupload-none' ), '#' ); |
82 | 77 | } |
83 | 78 | |
84 | 79 | /* Get deault category, to compare with category option being output, so the |
— | — | @@ -85,8 +80,7 @@ |
86 | 81 | */ |
87 | 82 | global $wgCategoryOnUploadDefault, $wgCategoryOnUploadList; |
88 | 83 | |
89 | | - if( !is_array( $wgCategoryOnUploadList ) ) { |
90 | | - |
| 84 | + if ( !is_array( $wgCategoryOnUploadList ) ) { |
91 | 85 | /* Get a database read object. |
92 | 86 | */ |
93 | 87 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -98,7 +92,7 @@ |
99 | 93 | * interface could be created; but when it was developed only a few needed |
100 | 94 | * to be displayed so this was not an issue. Fallback to the select box is |
101 | 95 | * essential no matter what improvements are made. |
102 | | - * |
| 96 | + * |
103 | 97 | * It would be nice to use the category table to avoid having to do a |
104 | 98 | * manual query and perhaps improve performance, but it appears to not |
105 | 99 | * descriminate between existing and non-existing categories, this would be |
— | — | @@ -114,23 +108,21 @@ |
115 | 109 | * of resources. If this becomes an issue simply remove the # comments and |
116 | 110 | * comment out the first line. |
117 | 111 | */ |
118 | | - while( $row = $dbr->fetchObject( $res ) ) { |
119 | | - |
| 112 | + while ( $row = $dbr->fetchObject( $res ) ) { |
120 | 113 | $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(); |
123 | 116 | |
124 | 117 | /* Add option to output, if it is the default then make it selected too. |
125 | 118 | */ |
126 | 119 | $cat .= Xml::option( $text, $row->cl_to, ( $text == $wgCategoryOnUploadDefault ) ); |
127 | 120 | |
128 | 121 | } |
129 | | - |
130 | 122 | } else { |
131 | | - foreach( $wgCategoryOnUploadList as $category ) { |
| 123 | + foreach ( $wgCategoryOnUploadList as $category ) { |
132 | 124 | $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(); |
135 | 127 | |
136 | 128 | /* Add option to output, if it is the default then make it selected too. |
137 | 129 | */ |
— | — | @@ -140,9 +132,8 @@ |
141 | 133 | |
142 | 134 | /* Close all the open elements, finished generation. |
143 | 135 | */ |
144 | | - $cat .= |
145 | | - Xml::closeElement( 'select' ) . |
146 | | - Xml::closeElement( 'td' ) . |
| 136 | + $cat .= Xml::closeElement( 'select' ) . |
| 137 | + Xml::closeElement( 'td' ) . |
147 | 138 | Xml::closeElement( 'tr' ); |
148 | 139 | |
149 | 140 | /* Add the category selector to the start of the form so that other |
— | — | @@ -156,14 +147,12 @@ |
157 | 148 | * generated. |
158 | 149 | */ |
159 | 150 | return true; |
160 | | - |
161 | 151 | } |
162 | 152 | |
163 | 153 | /** |
164 | 154 | * Append the category statement to the end of the upload summary. |
165 | 155 | */ |
166 | 156 | function efCategoryOnUploadProcess( $uploadFormObj ) { |
167 | | - |
168 | 157 | /* Get the request object. |
169 | 158 | */ |
170 | 159 | global $wgRequest; |
— | — | @@ -175,7 +164,7 @@ |
176 | 165 | /* Append the category statement to the end of the upload summary if the |
177 | 166 | * cateogry is not '#' (indicating no category to be added). |
178 | 167 | */ |
179 | | - if( $cat != '#' ) { |
| 168 | + if ( $cat != '#' ) { |
180 | 169 | $uploadFormObj->mComment .= "\n" . '[[Category:' . $wgRequest->getText( 'wpUploadCategory' ) . ']]'; |
181 | 170 | } |
182 | 171 | |
— | — | @@ -183,5 +172,4 @@ |
184 | 173 | * generated. |
185 | 174 | */ |
186 | 175 | return true; |
187 | | - |
188 | 176 | } |