Index: trunk/extensions/PatchOutputMobile/PatchOutputMobile.i18n.php |
— | — | @@ -0,0 +1,8 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$messages = array(); |
| 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', |
| 9 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/PatchOutputMobile/PatchOutputMobile.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 10 | + native |
Index: trunk/extensions/PatchOutputMobile/PatchOutputMobile.php |
— | — | @@ -18,15 +18,20 @@ |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:PatchOutputMobile', |
20 | 20 | ); |
21 | 21 | |
| 22 | +$dir = dirname(__FILE__) . '/'; |
| 23 | +$wgExtensionMessagesFiles['PatchOutputMobile'] = $dir . 'PatchOutputMobile.i18n.php'; |
| 24 | + |
22 | 25 | $wgExtPatchOutputMobile = new ExtPatchOutputMobile(); |
23 | 26 | |
24 | 27 | $wgHooks['OutputPageBeforeHTML'][] = array( &$wgExtPatchOutputMobile, |
25 | 28 | 'onOutputPageBeforeHTML' ); |
26 | 29 | |
27 | 30 | class ExtPatchOutputMobile { |
28 | | - const VERSION = '0.2.3'; |
| 31 | + const VERSION = '0.2.4'; |
29 | 32 | |
30 | 33 | private $doc; |
| 34 | + |
| 35 | + public static $messages = array(); |
31 | 36 | |
32 | 37 | public $items_to_remove = array( |
33 | 38 | '#contentSub', # redirection notice |
— | — | @@ -61,15 +66,21 @@ |
62 | 67 | ); |
63 | 68 | |
64 | 69 | public function onOutputPageBeforeHTML( &$out, &$text ) { |
| 70 | + // Need to stash the results of the "wfMsg" call before the Output Buffering handler |
| 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'); |
| 75 | + |
65 | 76 | ob_start( array( $this, 'parse' ) ); |
66 | 77 | return true; |
67 | 78 | } |
68 | 79 | |
69 | 80 | private function showHideCallback( $matches ) { |
70 | 81 | static $headings = 0; |
71 | | - $show = 'Show'; |
72 | | - $hide = 'Hide'; |
73 | | - $back_to_top = 'Jump Back A Section'; |
| 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']; |
74 | 85 | ++$headings; |
75 | 86 | // Back to top link |
76 | 87 | $base = "<div class='section_anchors' id='anchor_" . intval( $headings - 1 ) . |
— | — | @@ -137,6 +148,12 @@ |
138 | 149 | |
139 | 150 | $item_to_remove_records = $this->parseItemsToRemove(); |
140 | 151 | |
| 152 | + $title_node = $this->doc->getElementsByTagName( 'title' ); |
| 153 | + |
| 154 | + if ( $title_node->length > 0 ) { |
| 155 | + $title = $title_node->item( 0 )->nodeValue; |
| 156 | + } |
| 157 | + |
141 | 158 | // Tags |
142 | 159 | |
143 | 160 | // You can't remove DOMNodes from a DOMNodeList as you're iterating |
— | — | @@ -144,12 +161,7 @@ |
145 | 162 | // iterator on the foreach out of wack and results will be quite |
146 | 163 | // strange. Though, making a queue of items to remove seems to work. |
147 | 164 | // For example: |
148 | | - $title_node = $this->doc->getElementsByTagName( 'title' ); |
149 | 165 | |
150 | | - if ( $title_node->length > 0 ) { |
151 | | - $title = $title_node->item( 0 )->nodeValue; |
152 | | - } |
153 | | - |
154 | 166 | $domElemsToRemove = array(); |
155 | 167 | foreach ( $item_to_remove_records['TAG'] as $tag_to_remove ) { |
156 | 168 | $tag_to_remove_nodes = $this->doc->getElementsByTagName( $tag_to_remove ); |