Index: trunk/extensions/GlobalUsage/GlobalUsageQuery.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * A helper class to query the globalimagelinks table |
5 | | - * |
| 5 | + * |
6 | 6 | */ |
7 | 7 | class GlobalUsageQuery { |
8 | 8 | private $limit = 50; |
— | — | @@ -27,7 +27,6 @@ |
28 | 28 | $this->target = Title::makeTitleSafe( NS_FILE, $target ); |
29 | 29 | } |
30 | 30 | $this->offset = array(); |
31 | | - |
32 | 31 | } |
33 | 32 | |
34 | 33 | /** |
— | — | @@ -37,11 +36,13 @@ |
38 | 37 | * @param $reversed bool True if this is the upper offset |
39 | 38 | */ |
40 | 39 | public function setOffset( $offset, $reversed = null ) { |
41 | | - if ( !is_null( $reversed ) ) |
| 40 | + if ( !is_null( $reversed ) ) { |
42 | 41 | $this->reversed = $reversed; |
43 | | - |
44 | | - if ( !is_array( $offset ) ) |
| 42 | + } |
| 43 | + |
| 44 | + if ( !is_array( $offset ) ) { |
45 | 45 | $offset = explode( '|', $offset ); |
| 46 | + } |
46 | 47 | |
47 | 48 | if ( count( $offset ) == 3 ) { |
48 | 49 | $this->offset = $offset; |
— | — | @@ -50,6 +51,7 @@ |
51 | 52 | return false; |
52 | 53 | } |
53 | 54 | } |
| 55 | + |
54 | 56 | /** |
55 | 57 | * Return the offset set by the user |
56 | 58 | * |
— | — | @@ -58,19 +60,21 @@ |
59 | 61 | public function getOffsetString() { |
60 | 62 | return implode( '|', $this->offset ); |
61 | 63 | } |
| 64 | + |
62 | 65 | /** |
63 | 66 | * Is the result reversed |
64 | | - * |
| 67 | + * |
65 | 68 | * @return bool |
66 | 69 | */ |
67 | 70 | public function isReversed() { |
68 | 71 | return $this->reversed; |
69 | 72 | } |
| 73 | + |
70 | 74 | /** |
71 | 75 | * Returns the string used for continuation |
72 | | - * |
| 76 | + * |
73 | 77 | * @return string |
74 | | - * |
| 78 | + * |
75 | 79 | */ |
76 | 80 | public function getContinueString() { |
77 | 81 | if ( $this->hasMore() ) |
— | — | @@ -101,14 +105,13 @@ |
102 | 106 | $this->filterLocal = $value; |
103 | 107 | } |
104 | 108 | |
105 | | - |
106 | 109 | /** |
107 | 110 | * Executes the query |
108 | 111 | */ |
109 | 112 | public function execute() { |
110 | 113 | /* Construct the SQL query */ |
111 | 114 | $tables = array( 'globalimagelinks' ); |
112 | | - |
| 115 | + |
113 | 116 | // Add target image(s) |
114 | 117 | if ( is_array( $this->target ) ) { |
115 | 118 | $namespace = NS_FILE; |
— | — | @@ -122,21 +125,21 @@ |
123 | 126 | case NS_CATEGORY: |
124 | 127 | $tables[] = 'categorylinks'; |
125 | 128 | $tables[] = 'page'; |
126 | | - $where = array( |
| 129 | + $where = array( |
127 | 130 | 'cl_to' => $this->target->getDbKey(), |
128 | | - 'cl_from = page_id', |
129 | | - 'page_namespace = ' . NS_FILE, |
| 131 | + 'cl_from = page_id', |
| 132 | + 'page_namespace = ' . NS_FILE, |
130 | 133 | 'gil_to = page_title', |
131 | 134 | ); |
132 | 135 | break; |
133 | 136 | default: |
134 | 137 | return array(); |
135 | 138 | } |
136 | | - |
137 | | - |
138 | | - if ( $this->filterLocal ) |
| 139 | + |
| 140 | + if ( $this->filterLocal ) { |
139 | 141 | // Don't show local file usage |
140 | 142 | $where[] = 'gil_wiki != ' . $this->db->addQuotes( wfWikiId() ); |
| 143 | + } |
141 | 144 | |
142 | 145 | // Set the continuation condition |
143 | 146 | $order = 'ASC'; |
— | — | @@ -144,7 +147,7 @@ |
145 | 148 | $qTo = $this->db->addQuotes( $this->offset[0] ); |
146 | 149 | $qWiki = $this->db->addQuotes( $this->offset[1] ); |
147 | 150 | $qPage = intval( $this->offset[2] ); |
148 | | - |
| 151 | + |
149 | 152 | // Check which limit we got in order to determine which way to traverse rows |
150 | 153 | if ( $this->reversed ) { |
151 | 154 | // Reversed traversal; do not include offset row |
— | — | @@ -157,7 +160,7 @@ |
158 | 161 | $op2 = '>='; |
159 | 162 | $order = 'ASC'; |
160 | 163 | } |
161 | | - |
| 164 | + |
162 | 165 | $where[] = "(gil_to $op1 $qTo) OR " . |
163 | 166 | "(gil_to = $qTo AND gil_wiki $op1 $qWiki) OR " . |
164 | 167 | "(gil_to = $qTo AND gil_wiki = $qWiki AND gil_page $op2 $qPage)"; |
— | — | @@ -186,11 +189,13 @@ |
187 | 190 | // Always return the result in the same order; regardless whether reversed was specified |
188 | 191 | // reversed is really only used to determine from which direction the offset is |
189 | 192 | $rows = array(); |
190 | | - foreach ( $res as $row ) |
| 193 | + foreach ( $res as $row ) { |
191 | 194 | $rows[] = $row; |
192 | | - if ( $this->reversed ) |
| 195 | + } |
| 196 | + if ( $this->reversed ) { |
193 | 197 | $rows = array_reverse( $rows ); |
194 | | - |
| 198 | + } |
| 199 | + |
195 | 200 | // Build the result array |
196 | 201 | $count = 0; |
197 | 202 | $this->hasMore = false; |
— | — | @@ -204,10 +209,12 @@ |
205 | 210 | break; |
206 | 211 | } |
207 | 212 | |
208 | | - if ( !isset( $this->result[$row->gil_to] ) ) |
| 213 | + if ( !isset( $this->result[$row->gil_to] ) ) { |
209 | 214 | $this->result[$row->gil_to] = array(); |
210 | | - if ( !isset( $this->result[$row->gil_to][$row->gil_wiki] ) ) |
| 215 | + } |
| 216 | + if ( !isset( $this->result[$row->gil_to][$row->gil_wiki] ) ) { |
211 | 217 | $this->result[$row->gil_to][$row->gil_wiki] = array(); |
| 218 | + } |
212 | 219 | |
213 | 220 | $this->result[$row->gil_to][$row->gil_wiki][] = array( |
214 | 221 | 'image' => $row->gil_to, |
— | — | @@ -219,26 +226,28 @@ |
220 | 227 | ); |
221 | 228 | } |
222 | 229 | } |
| 230 | + |
223 | 231 | /** |
224 | 232 | * Returns the result set. The result is a 4 dimensional array |
225 | 233 | * (file, wiki, page), whose items are arrays with keys: |
226 | | - * - image: File name |
| 234 | + * - image: File name |
227 | 235 | * - id: Page id |
228 | 236 | * - namespace: Page namespace text |
229 | 237 | * - title: Unprefixed page title |
230 | 238 | * - wiki: Wiki id |
231 | | - * |
| 239 | + * |
232 | 240 | * @return array Result set |
233 | 241 | */ |
234 | 242 | public function getResult() { |
235 | 243 | return $this->result; |
236 | 244 | } |
| 245 | + |
237 | 246 | /** |
238 | 247 | * Returns a 3 dimensional array with the result of the first file. Useful |
239 | 248 | * if only one image was queried. |
240 | | - * |
| 249 | + * |
241 | 250 | * For further information see documentation of getResult() |
242 | | - * |
| 251 | + * |
243 | 252 | * @return array Result set |
244 | 253 | */ |
245 | 254 | public function getSingleImageResult() { |
— | — | @@ -259,7 +268,7 @@ |
260 | 269 | |
261 | 270 | /** |
262 | 271 | * Returns the result length |
263 | | - * |
| 272 | + * |
264 | 273 | * @return int |
265 | 274 | */ |
266 | 275 | public function count() { |
Index: trunk/extensions/GlobalUsage/ApiQueryGlobalUsage.php |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | if ( isset( $prop['namespace'] ) ) { |
72 | 72 | $result['ns'] = $item['namespace_id']; |
73 | 73 | } |
74 | | - |
| 74 | + |
75 | 75 | $fit = $apiResult->addValue( array( |
76 | 76 | 'query', 'pages', $pageId, 'globalusage' |
77 | 77 | ), null, $result ); |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | ); |
128 | 128 | } |
129 | 129 | |
130 | | - public function getParamDescription () { |
| 130 | + public function getParamDescription() { |
131 | 131 | return array( |
132 | 132 | 'prop' => array( |
133 | 133 | 'What properties to return', |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | public function getDescription() { |
145 | 145 | return 'Returns global image usage for a certain image'; |
146 | 146 | } |
147 | | - |
| 147 | + |
148 | 148 | public function getPossibleErrors() { |
149 | 149 | return array_merge( parent::getPossibleErrors(), array( |
150 | 150 | array ( 'code' => 'badcontinue', 'info' => 'Invalid continue parameter' ), |
Index: trunk/extensions/GlobalUsage/GlobalUsage.php |
— | — | @@ -33,7 +33,6 @@ |
34 | 34 | exit( 1 ); |
35 | 35 | } |
36 | 36 | |
37 | | - |
38 | 37 | $dir = dirname( __FILE__ ) . '/'; |
39 | 38 | |
40 | 39 | $wgExtensionCredits['specialpage'][] = array( |
Index: trunk/extensions/GlobalUsage/SpecialGlobalUsage.php |
— | — | @@ -24,8 +24,7 @@ |
25 | 25 | |
26 | 26 | $this->showForm(); |
27 | 27 | |
28 | | - if ( is_null( $this->target ) ) |
29 | | - { |
| 28 | + if ( is_null( $this->target ) ) { |
30 | 29 | $wgOut->setPageTitle( wfMsg( 'globalusage' ) ); |
31 | 30 | return; |
32 | 31 | } |
— | — | @@ -34,7 +33,7 @@ |
35 | 34 | |
36 | 35 | $this->showResult(); |
37 | 36 | } |
38 | | - |
| 37 | + |
39 | 38 | /** |
40 | 39 | * Shows the search form |
41 | 40 | */ |
— | — | @@ -58,12 +57,9 @@ |
59 | 58 | // Filter local checkbox |
60 | 59 | . "\n\t<p>" . Xml::checkLabel( wfMsg( 'globalusage-filterlocal' ), |
61 | 60 | 'filterlocal', 'mw-filterlocal', $this->filterLocal ) . '</p>'; |
62 | | - |
| 61 | + |
63 | 62 | if ( !is_null( $this->target ) && wfFindFile( $this->target ) ) { |
64 | 63 | // Show the image if it exists |
65 | | - global $wgUser; |
66 | | - $skin = $wgUser->getSkin(); |
67 | | - |
68 | 64 | $html .= Linker::makeThumbLinkObj( $this->target, |
69 | 65 | wfFindFile( $this->target ), |
70 | 66 | /* $label */ $this->target->getPrefixedText(), |
— | — | @@ -71,7 +67,7 @@ |
72 | 68 | /* $handlerParams */ array(), /* $framed */ false, |
73 | 69 | /* $manualThumb */ false ); |
74 | 70 | } |
75 | | - |
| 71 | + |
76 | 72 | // Wrap the entire form in a nice fieldset |
77 | 73 | $html .= Xml::fieldSet( wfMsg( 'globalusage-text' ), $formContent ) . "\n</form>"; |
78 | 74 | |
— | — | @@ -87,10 +83,11 @@ |
88 | 84 | $query = new GlobalUsageQuery( $this->target ); |
89 | 85 | |
90 | 86 | // Extract params from $wgRequest |
91 | | - if ( $wgRequest->getText( 'from' ) ) |
| 87 | + if ( $wgRequest->getText( 'from' ) ) { |
92 | 88 | $query->setOffset( $wgRequest->getText( 'from' ) ); |
93 | | - elseif ( $wgRequest->getText( 'to' ) ) |
| 89 | + } elseif ( $wgRequest->getText( 'to' ) ) { |
94 | 90 | $query->setOffset( $wgRequest->getText( 'to' ), true ); |
| 91 | + } |
95 | 92 | $query->setLimit( $wgRequest->getInt( 'limit', 50 ) ); |
96 | 93 | $query->filterLocal( $this->filterLocal ); |
97 | 94 | |
— | — | @@ -119,8 +116,9 @@ |
120 | 117 | 'globalusage-on-wiki', 'parseinline', |
121 | 118 | $targetName, WikiMap::getWikiName( $wiki ) ) |
122 | 119 | . "</h2><ul>\n" ); |
123 | | - foreach ( $result as $item ) |
| 120 | + foreach ( $result as $item ) { |
124 | 121 | $wgOut->addHtml( "\t<li>" . self::formatItem( $item ) . "</li>\n" ); |
| 122 | + } |
125 | 123 | $wgOut->addHtml( "</ul>\n" ); |
126 | 124 | } |
127 | 125 | $wgOut->addHtml( '</div>' ); |
— | — | @@ -128,14 +126,16 @@ |
129 | 127 | // Bottom navbar |
130 | 128 | $wgOut->addHtml( $navbar ); |
131 | 129 | } |
| 130 | + |
132 | 131 | /** |
133 | 132 | * Helper to format a specific item |
134 | 133 | */ |
135 | 134 | public static function formatItem( $item ) { |
136 | | - if ( !$item['namespace'] ) |
| 135 | + if ( !$item['namespace'] ) { |
137 | 136 | $page = $item['title']; |
138 | | - else |
| 137 | + } else { |
139 | 138 | $page = "{$item['namespace']}:{$item['title']}"; |
| 139 | + } |
140 | 140 | |
141 | 141 | $link = WikiMap::makeForeignLink( $item['wiki'], $page, |
142 | 142 | str_replace( '_', ' ', $page ) ); |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Helper function to create the navbar, stolen from wfViewPrevNext |
149 | | - * |
| 149 | + * |
150 | 150 | * @param $query GlobalUsageQuery An executed GlobalUsageQuery object |
151 | 151 | * @return string Navbar HTML |
152 | 152 | */ |
— | — | @@ -157,7 +157,7 @@ |
158 | 158 | $target = $this->target->getText(); |
159 | 159 | $limit = $query->getLimit(); |
160 | 160 | $fmtLimit = $wgLang->formatNum( $limit ); |
161 | | - |
| 161 | + |
162 | 162 | # Find out which strings are for the prev and which for the next links |
163 | 163 | $offset = $query->getOffsetString(); |
164 | 164 | $continue = $query->getContinueString(); |
— | — | @@ -205,7 +205,7 @@ |
206 | 206 | $numLinks = array(); |
207 | 207 | foreach ( array( 20, 50, 100, 250, 500 ) as $num ) { |
208 | 208 | $fmtLimit = $wgLang->formatNum( $num ); |
209 | | - |
| 209 | + |
210 | 210 | $q = array( 'offset' => $offset, 'limit' => $num, 'target' => $target ); |
211 | 211 | if ( $this->filterLocal ) |
212 | 212 | $q['filterlocal'] = '1'; |
Index: trunk/extensions/GlobalUsage/GlobalUsageHooks.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | |
45 | 45 | return true; |
46 | 46 | } |
| 47 | + |
47 | 48 | /** |
48 | 49 | * Hook to TitleMoveComplete |
49 | 50 | * Sets the page title in usage table to the new name. |
— | — | @@ -52,6 +53,7 @@ |
53 | 54 | $gu->moveTo( $pageid, $nt ); |
54 | 55 | return true; |
55 | 56 | } |
| 57 | + |
56 | 58 | /** |
57 | 59 | * Hook to ArticleDeleteComplete |
58 | 60 | * Deletes entries from usage table. |
— | — | @@ -62,6 +64,7 @@ |
63 | 65 | |
64 | 66 | return true; |
65 | 67 | } |
| 68 | + |
66 | 69 | /** |
67 | 70 | * Hook to FileDeleteComplete |
68 | 71 | * Copies the local link table to the global. |
— | — | @@ -83,6 +86,7 @@ |
84 | 87 | $gu->deleteLinksToFile( $title ); |
85 | 88 | return true; |
86 | 89 | } |
| 90 | + |
87 | 91 | /** |
88 | 92 | * Hook to UploadComplete |
89 | 93 | * Deletes the file from the global link table. |
— | — | @@ -95,6 +99,8 @@ |
96 | 100 | |
97 | 101 | /** |
98 | 102 | * Initializes a GlobalUsage object for the current wiki. |
| 103 | + * |
| 104 | + * @return GlobalUsage |
99 | 105 | */ |
100 | 106 | private static function getGlobalUsage() { |
101 | 107 | global $wgGlobalUsageDatabase; |
— | — | @@ -117,6 +123,8 @@ |
118 | 124 | |
119 | 125 | /** |
120 | 126 | * Hook to apply schema changes |
| 127 | + * |
| 128 | + * @param $updater DatabaseUpdater |
121 | 129 | */ |
122 | 130 | public static function onLoadExtensionSchemaUpdates( $updater = null ) { |
123 | 131 | $dir = dirname( __FILE__ ); |
Index: trunk/extensions/CodeReview/backend/CodeRevision.php |
— | — | @@ -770,8 +770,11 @@ |
771 | 771 | 'cc_repo_id' => $this->repoId, |
772 | 772 | 'cc_rev_id' => $this->id ); |
773 | 773 | |
774 | | - if( $attached ) { $conditions['cc_patch_line!'] = null; } |
775 | | - else { $conditions['cc_patch_line'] = null; } |
| 774 | + if( $attached ) { |
| 775 | + $conditions['cc_patch_line!'] = null; |
| 776 | + } else { |
| 777 | + $conditions['cc_patch_line'] = null; |
| 778 | + } |
776 | 779 | |
777 | 780 | $dbr = wfGetDB( DB_SLAVE ); |
778 | 781 | $result = $dbr->select( 'code_comment', |