Index: trunk/extensions/PatchOutputMobile/PatchOutputMobile.i18n.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | $messages = array(); |
5 | 5 | $messages['en'] = array( |
6 | | - 'patch_output_mobile_show' => 'show', |
7 | | - 'patch_output_mobile_hide' => 'hide', |
8 | | - 'patch_output_mobile_back_to_top' => 'Jump Back A Section', |
| 6 | + 'patch-output-mobile-show' => 'show', |
| 7 | + 'patch-output-mobile-hide' => 'hide', |
| 8 | + 'patch-output-mobile-back-to-top' => 'Jump Back A Section', |
9 | 9 | ); |
\ No newline at end of file |
Index: trunk/extensions/PatchOutputMobile/views/notices/_donate.html.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -$donate_html = <<<EOT |
| 4 | +$donateHtml = <<<EOT |
5 | 5 | <div class='mwm-message mwm-notice'> |
6 | 6 | Text WIKI to <a href="sms:25383">25383</a> to donate $10. |
7 | 7 | <br /> |
Index: trunk/extensions/PatchOutputMobile/views/layout/_search_webkit.html.php |
— | — | @@ -1,26 +1,7 @@ |
2 | 2 | <?php |
3 | | -/* |
4 | | -$search_webkit_html = <<<EOD |
5 | | -<div id='header'> |
6 | | - <div id='searchbox'> |
7 | | - <img alt='W logo' id='logo' src='http://en.m.wikipedia.org/images/w.gif' /> |
8 | | - <form action='/wiki' class='search_bar' method='get'> |
9 | | - <input id='searchField' name='search' size='27' type='search' value='' /> |
10 | | - <div id='clearButton'></div> |
11 | | - <button id='goButton' type='submit'></button> |
12 | | - </form> |
13 | | - </div> |
14 | | - <div class='nav' id='nav'> |
15 | | - <form method="get" action="/"><button type="submit" id="homeButton">Home</button></form> |
16 | | - <form method="get" action="/wiki/::Random"><button type="submit" id="randomButton">Random</button></form> |
17 | | - </div> |
18 | | -</div> |
19 | | -EOD; |
20 | | -*/ |
| 3 | +$searchField = (!empty($_GET['search'])) ? $_GET['search'] : ''; |
21 | 4 | |
22 | | -$search_field = (!empty($_GET['search'])) ? $_GET['search'] : ''; |
23 | | - |
24 | | -$search_webkit_html = <<<EOD |
| 5 | +$searchWebkitHtml = <<<EOD |
25 | 6 | <div id='header'> |
26 | 7 | <div id='searchbox'> |
27 | 8 | <img alt='W logo' id='logo' src='http://en.m.wikipedia.org/images/w.gif' /> |
— | — | @@ -28,7 +9,7 @@ |
29 | 10 | <input type="hidden" value="Special:Search" name="title" /> |
30 | 11 | <input type="hidden" value="Search" name="fulltext" /> |
31 | 12 | <input type="hidden" value="0" name="redirs" /> |
32 | | - <input id='searchField' name='search' size='27' type='search' value='{$search_field}' /> |
| 13 | + <input id='searchField' name='search' size='27' type='search' value='{$searchField}' /> |
33 | 14 | <div id='clearButton'></div> |
34 | 15 | <button id='goButton' type='submit'></button> |
35 | 16 | </form> |
Index: trunk/extensions/PatchOutputMobile/views/layout/_footmenu_default.html.php |
— | — | @@ -1,12 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -$footer_html = <<<EOD |
| 4 | +$footerHtml = <<<EOD |
5 | 5 | <div id='footer'> |
6 | 6 | <div class='nav' id='footmenu'> |
7 | 7 | <div class='mwm-notice'> |
8 | 8 | <a href="http://en.wikipedia.org/w/mobileRedirect.php?to=">View this page on regular Wikipedia</a> |
9 | 9 | <div id="perm"> |
10 | | - <a href="https://www.mediawiki.org/disable/???">Permanently disable mobile site</a> |
| 10 | + <a href="https://www.mediawiki.org/disable/?">Permanently disable mobile site</a> |
11 | 11 | </div> |
12 | 12 | </div> |
13 | 13 | </div> |
Index: trunk/extensions/PatchOutputMobile/views/layout/application.html.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -$application_html = <<<EOT |
| 3 | +$applicationHtml = <<<EOT |
4 | 4 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
5 | 5 | <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'> |
6 | 6 | <head> |
— | — | @@ -22,12 +22,12 @@ |
23 | 23 | <script type="text/javascript" language="javascript" SRC="http://en.m.wikipedia.org/javascripts/application.js"></script> |
24 | 24 | </head> |
25 | 25 | <body> |
26 | | - {$search_webkit_html} |
| 26 | + {$searchWebkitHtml} |
27 | 27 | <div class='show' id='content_wrapper'> |
28 | | - {$donate_html} |
29 | | - {$content_html} |
| 28 | + {$donateHtml} |
| 29 | + {$contentHtml} |
30 | 30 | </div> |
31 | | - {$footer_html} |
| 31 | + {$footerHtml} |
32 | 32 | </body> |
33 | 33 | </html> |
34 | 34 | EOT; |
Index: trunk/extensions/PatchOutputMobile/PatchOutputMobile.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:PatchOutputMobile', |
20 | 20 | ); |
21 | 21 | |
22 | | -$dir = dirname(__FILE__) . '/'; |
| 22 | +$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR; |
23 | 23 | $wgExtensionMessagesFiles['PatchOutputMobile'] = $dir . 'PatchOutputMobile.i18n.php'; |
24 | 24 | |
25 | 25 | $wgExtPatchOutputMobile = new ExtPatchOutputMobile(); |
— | — | @@ -27,28 +27,28 @@ |
28 | 28 | 'onOutputPageBeforeHTML' ); |
29 | 29 | |
30 | 30 | class ExtPatchOutputMobile { |
31 | | - const VERSION = '0.2.4'; |
| 31 | + const VERSION = '0.2.6'; |
32 | 32 | |
33 | 33 | private $doc; |
34 | 34 | |
35 | 35 | public static $messages = array(); |
36 | 36 | |
37 | | - public $items_to_remove = array( |
38 | | - '#contentSub', # redirection notice |
39 | | - 'div.messagebox', # cleanup data |
40 | | - '#siteNotice', # site notice |
41 | | - '#siteSub', # "From Wikipedia..." |
42 | | - '#jump-to-nav', # jump-to-nav |
43 | | - 'div.editsection', # edit blocks |
44 | | - 'div.infobox', # Infoboxes in the article |
45 | | - 'table.toc', # table of contents |
46 | | - '#catlinks', # category links |
47 | | - 'div.stub', # stub warnings |
48 | | - 'table.metadata', # ugly metadata |
| 37 | + public $itemsToRemove = array( |
| 38 | + '#contentSub', # redirection notice |
| 39 | + 'div.messagebox', # cleanup data |
| 40 | + '#siteNotice', # site notice |
| 41 | + '#siteSub', # "From Wikipedia..." |
| 42 | + '#jump-to-nav', # jump-to-nav |
| 43 | + 'div.editsection', # edit blocks |
| 44 | + 'div.infobox', # Infoboxes in the article |
| 45 | + 'table.toc', # table of contents |
| 46 | + '#catlinks', # category links |
| 47 | + 'div.stub', # stub warnings |
| 48 | + 'table.metadata', # ugly metadata |
49 | 49 | 'form', |
50 | 50 | 'div.sister-project', |
51 | 51 | 'script', |
52 | | - 'div.magnify', # stupid magnify thing |
| 52 | + 'div.magnify', # stupid magnify thing |
53 | 53 | '.editsection', |
54 | 54 | 'span.t', |
55 | 55 | 'sup[style*="help"]', |
— | — | @@ -68,9 +68,9 @@ |
69 | 69 | public function onOutputPageBeforeHTML( &$out, &$text ) { |
70 | 70 | // Need to stash the results of the "wfMsg" call before the Output Buffering handler |
71 | 71 | // because at this point the database connection is shut down, etc. |
72 | | - ExtPatchOutputMobile::$messages['patch_output_mobile_show'] = wfMsg('patch_output_mobile_show'); |
73 | | - ExtPatchOutputMobile::$messages['patch_output_mobile_hide'] = wfMsg('patch_output_mobile_hide'); |
74 | | - ExtPatchOutputMobile::$messages['patch_output_mobile_back_to_top'] = wfMsg('patch_output_mobile_back_to_top'); |
| 72 | + ExtPatchOutputMobile::$messages['patch-output-mobile-show'] = wfMsg( 'patch-output-mobile-show' ); |
| 73 | + ExtPatchOutputMobile::$messages['patch-output-mobile-hide'] = wfMsg( 'patch-output-mobile-hide' ); |
| 74 | + ExtPatchOutputMobile::$messages['patch-output-mobile-back-to-top'] = wfMsg( 'patch-output-mobile-back-to-top' ); |
75 | 75 | |
76 | 76 | ob_start( array( $this, 'parse' ) ); |
77 | 77 | return true; |
— | — | @@ -78,14 +78,14 @@ |
79 | 79 | |
80 | 80 | private function showHideCallback( $matches ) { |
81 | 81 | static $headings = 0; |
82 | | - $show = ExtPatchOutputMobile::$messages['patch_output_mobile_show']; |
83 | | - $hide = ExtPatchOutputMobile::$messages['patch_output_mobile_hide']; |
84 | | - $back_to_top = ExtPatchOutputMobile::$messages['patch_output_mobile_back_to_top']; |
| 82 | + $show = ExtPatchOutputMobile::$messages['patch-output-mobile-show']; |
| 83 | + $hide = ExtPatchOutputMobile::$messages['patch-output-mobile-hide']; |
| 84 | + $backToTop = ExtPatchOutputMobile::$messages['patch-output-mobile-back-to-top']; |
85 | 85 | ++$headings; |
86 | 86 | // Back to top link |
87 | 87 | $base = "<div class='section_anchors' id='anchor_" . intval( $headings - 1 ) . |
88 | 88 | "'><a href='#section_" . intval( $headings - 1 ) . |
89 | | - "' class='back_to_top'>↑ {$back_to_top}</a></div>"; |
| 89 | + "' class='back_to_top'>↑ {$backToTop}</a></div>"; |
90 | 90 | // generate the HTML we are going to inject |
91 | 91 | $buttons = "<button class='section_heading show' section_id='{$headings}'>{$show}</button><button class='section_heading hide' section_id='{$headings}'>{$hide}</button>"; |
92 | 92 | $base .= "<h2 class='section_heading' id='section_{$headings}'{$matches[1]}{$buttons} <span>{$matches[2]}</span></h2><div class='content_block' id='content_{$headings}'>"; |
— | — | @@ -127,16 +127,16 @@ |
128 | 128 | } |
129 | 129 | |
130 | 130 | private function parseItemsToRemove() { |
131 | | - $item_to_remove_records = array(); |
| 131 | + $itemToRemoveRecords = array(); |
132 | 132 | |
133 | | - foreach ( $this->items_to_remove as $item_to_remove ) { |
| 133 | + foreach ( $this->itemsToRemove as $itemToRemove ) { |
134 | 134 | $type = ''; |
135 | | - $raw_name = ''; |
136 | | - CssDetection::detectIdCssOrTag( $item_to_remove, $type, $raw_name ); |
137 | | - $item_to_remove_records[$type][] = $raw_name; |
| 135 | + $rawName = ''; |
| 136 | + CssDetection::detectIdCssOrTag( $itemToRemove, $type, $rawName ); |
| 137 | + $itemToRemoveRecords[$type][] = $rawName; |
138 | 138 | } |
139 | 139 | |
140 | | - return $item_to_remove_records; |
| 140 | + return $itemToRemoveRecords; |
141 | 141 | } |
142 | 142 | |
143 | 143 | public function DOMParse( $html ) { |
— | — | @@ -146,12 +146,12 @@ |
147 | 147 | $this->doc->preserveWhiteSpace = false; |
148 | 148 | $this->doc->strictErrorChecking = false; |
149 | 149 | |
150 | | - $item_to_remove_records = $this->parseItemsToRemove(); |
| 150 | + $itemToRemoveRecords = $this->parseItemsToRemove(); |
151 | 151 | |
152 | | - $title_node = $this->doc->getElementsByTagName( 'title' ); |
| 152 | + $titleNode = $this->doc->getElementsByTagName( 'title' ); |
153 | 153 | |
154 | | - if ( $title_node->length > 0 ) { |
155 | | - $title = $title_node->item( 0 )->nodeValue; |
| 154 | + if ( $titleNode->length > 0 ) { |
| 155 | + $title = $titleNode->item( 0 )->nodeValue; |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Tags |
— | — | @@ -163,12 +163,12 @@ |
164 | 164 | // For example: |
165 | 165 | |
166 | 166 | $domElemsToRemove = array(); |
167 | | - foreach ( $item_to_remove_records['TAG'] as $tag_to_remove ) { |
168 | | - $tag_to_remove_nodes = $this->doc->getElementsByTagName( $tag_to_remove ); |
| 167 | + foreach ( $itemToRemoveRecords['TAG'] as $tagToRemove ) { |
| 168 | + $tagToRemoveNodes = $this->doc->getElementsByTagName( $tagToRemove ); |
169 | 169 | |
170 | | - foreach( $tag_to_remove_nodes as $tag_to_remove_node ) { |
171 | | - if ( $tag_to_remove_node ) { |
172 | | - $domElemsToRemove[] = $tag_to_remove_node; |
| 170 | + foreach( $tagToRemoveNodes as $tagToRemoveNode ) { |
| 171 | + if ( $tagToRemoveNode ) { |
| 172 | + $domElemsToRemove[] = $tagToRemoveNode; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
— | — | @@ -178,55 +178,55 @@ |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Elements with named IDs |
182 | | - foreach ( $item_to_remove_records['ID'] as $item_to_remove ) { |
183 | | - $item_to_remove_node = $this->doc->getElementById( $item_to_remove ); |
184 | | - if ( $item_to_remove_node ) { |
185 | | - $removed_item_to_remove = $item_to_remove_node->parentNode->removeChild( $item_to_remove_node ); |
| 182 | + foreach ( $itemToRemoveRecords['ID'] as $itemToRemove ) { |
| 183 | + $itemToRemoveNode = $this->doc->getElementById( $itemToRemove ); |
| 184 | + if ( $itemToRemoveNode ) { |
| 185 | + $removedItemToRemove = $itemToRemoveNode->parentNode->removeChild( $itemToRemoveNode ); |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | 189 | // CSS Classes |
190 | 190 | $xpath = new DOMXpath( $this->doc ); |
191 | | - foreach ( $item_to_remove_records['CLASS'] as $class_to_remove ) { |
192 | | - $elements = $xpath->query( '//*[@class="' . $class_to_remove . '"]' ); |
| 191 | + foreach ( $itemToRemoveRecords['CLASS'] as $classToRemove ) { |
| 192 | + $elements = $xpath->query( '//*[@class="' . $classToRemove . '"]' ); |
193 | 193 | |
194 | 194 | foreach( $elements as $element ) { |
195 | | - $removed_element = $element->parentNode->removeChild( $element ); |
| 195 | + $removedElement = $element->parentNode->removeChild( $element ); |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Tags with CSS Classes |
200 | | - foreach ( $item_to_remove_records['TAG_CLASS'] as $class_to_remove ) { |
201 | | - $parts = explode( '.', $class_to_remove ); |
| 200 | + foreach ( $itemToRemoveRecords['TAG_CLASS'] as $classToRemove ) { |
| 201 | + $parts = explode( '.', $classToRemove ); |
202 | 202 | |
203 | 203 | $elements = $xpath->query( |
204 | 204 | '//' . $parts[0] . '[@class="' . $parts[1] . '"]' |
205 | 205 | ); |
206 | 206 | |
207 | 207 | foreach( $elements as $element ) { |
208 | | - $removed_element = $element->parentNode->removeChild( $element ); |
| 208 | + $removedElement = $element->parentNode->removeChild( $element ); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | 212 | // Handle red links with action equal to edit |
213 | | - $redlinks = $xpath->query( '//a[@class="new"]' ); |
214 | | - foreach( $redlinks as $redlink ) { |
| 213 | + $redLinks = $xpath->query( '//a[@class="new"]' ); |
| 214 | + foreach( $redLinks as $redLink ) { |
215 | 215 | //PHP Bug #36795 — Inappropriate "unterminated entity reference" |
216 | | - $spannode = $this->doc->createElement( "span", str_replace( "&", "&", $redlink->nodeValue ) ); |
| 216 | + $spanNode = $this->doc->createElement( "span", str_replace( "&", "&", $redLink->nodeValue ) ); |
217 | 217 | |
218 | | - if ( $redlink->hasAttributes() ) { |
219 | | - $attributes = $redlink->attributes; |
| 218 | + if ( $redLink->hasAttributes() ) { |
| 219 | + $attributes = $redLink->attributes; |
220 | 220 | foreach ( $attributes as $i => $attribute ) { |
221 | | - $spannode->setAttribute( $attribute->name, $attribute->value ); |
| 221 | + $spanNode->setAttribute( $attribute->name, $attribute->value ); |
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | | - $redlink->parentNode->replaceChild( $spannode, $redlink ); |
| 225 | + $redLink->parentNode->replaceChild( $spanNode, $redLink ); |
226 | 226 | } |
227 | 227 | |
228 | 228 | $content = $this->doc->getElementById( 'content' ); |
229 | 229 | |
230 | | - $content_html = $this->doc->saveXML( $content, LIBXML_NOEMPTYTAG ); |
| 230 | + $contentHtml = $this->doc->saveXML( $content, LIBXML_NOEMPTYTAG ); |
231 | 231 | |
232 | 232 | if ( empty( $title ) ) { |
233 | 233 | $title = 'Wikipedia'; |
— | — | @@ -237,32 +237,32 @@ |
238 | 238 | require( 'views/layout/_footmenu_default.html.php' ); |
239 | 239 | require( 'views/layout/application.html.php' ); |
240 | 240 | |
241 | | - return ( strlen( $content_html ) > 4000 ) ? $this->javascriptize( $application_html ) : $application_html; //$content_html; |
| 241 | + return ( strlen( $contentHtml ) > 4000 ) ? $this->javascriptize( $applicationHtml ) : $applicationHtml; |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | 245 | class CssDetection { |
246 | 246 | |
247 | | - public static function detectIdCssOrTag( $snippet, &$type, &$raw_name ) { |
| 247 | + public static function detectIdCssOrTag( $snippet, &$type, &$rawName ) { |
248 | 248 | $output = ''; |
249 | 249 | |
250 | 250 | if ( strpos( $snippet, '.' ) === 0 ) { |
251 | 251 | $output = 'Class found: '; |
252 | 252 | $type = 'CLASS'; |
253 | | - $raw_name = substr( $snippet, 1 ); |
| 253 | + $rawName = substr( $snippet, 1 ); |
254 | 254 | } |
255 | 255 | |
256 | 256 | if ( strpos( $snippet, '#' ) === 0 ) { |
257 | 257 | $output = 'ID found: '; |
258 | 258 | $type = 'ID'; |
259 | | - $raw_name = substr( $snippet, 1 ); |
| 259 | + $rawName = substr( $snippet, 1 ); |
260 | 260 | } |
261 | 261 | |
262 | 262 | if ( strpos( $snippet, '.' ) !== 0 && |
263 | 263 | strpos( $snippet, '.' ) !== false ) { |
264 | 264 | $output = 'Tag with Class found: '; |
265 | 265 | $type = 'TAG_CLASS'; |
266 | | - $raw_name = $snippet; |
| 266 | + $rawName = $snippet; |
267 | 267 | } |
268 | 268 | |
269 | 269 | if ( strpos( $snippet, '.' ) === false && |
— | — | @@ -271,13 +271,13 @@ |
272 | 272 | strpos( $snippet, ']' ) === false ) { |
273 | 273 | $output = 'Tag found: '; |
274 | 274 | $type = 'TAG'; |
275 | | - $raw_name = $snippet; |
| 275 | + $rawName = $snippet; |
276 | 276 | } |
277 | 277 | |
278 | 278 | if ( empty( $output ) ) { |
279 | 279 | $output = 'Unknown HTML snippet found: '; |
280 | 280 | $type = 'UNKNOWN'; |
281 | | - $raw_name = $snippet; |
| 281 | + $rawName = $snippet; |
282 | 282 | } |
283 | 283 | |
284 | 284 | return $output; |