Index: trunk/extensions/Lingo/Lingo.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
| 5 | + * Provides hover-over tool tips on articles from words defined on the Terminology page. |
5 | 6 | * For more info see http://mediawiki.org/wiki/Extension:Lingo |
6 | 7 | * |
7 | 8 | * @defgroup Lingo |
— | — | @@ -15,8 +16,6 @@ |
16 | 17 | |
17 | 18 | define( 'LINGO_VERSION', '0.1' ); |
18 | 19 | |
19 | | - |
20 | | - |
21 | 20 | $wgExtensionCredits[ 'parserhook' ][ ] = array( |
22 | 21 | 'path' => __FILE__, |
23 | 22 | 'name' => 'Lingo', |
— | — | @@ -75,9 +74,10 @@ |
76 | 75 | $min = min( array_map( 'strlen', array_keys( $terms ) ) ); |
77 | 76 | |
78 | 77 | //Parse HTML from page |
79 | | - $doc = new DOMDocument(); |
80 | | - $text = '<html><meta http-equiv="content-type" content="charset=utf-8"/>' . $text . "</html>"; |
81 | | - @$doc -> loadHTML( $text ); |
| 78 | +// $doc = new DOMDocument(); |
| 79 | +// $doc -> loadHTML( $text ); |
| 80 | + $doc = @DOMDocument::loadHTML( $text ); |
| 81 | + |
82 | 82 | //Find all text in HTML. |
83 | 83 | $xpath = new DOMXpath( $doc ); |
84 | 84 | $elements = $xpath -> query( "//*[text()!=' ']/text()" ); |
— | — | @@ -126,7 +126,14 @@ |
127 | 127 | } |
128 | 128 | |
129 | 129 | if ( $changed ) { |
130 | | - $text = $doc -> saveHTML(); |
| 130 | + |
| 131 | + $body = $xpath -> query( '/html/body' ); |
| 132 | + |
| 133 | + $text = ''; |
| 134 | + foreach ( $body -> item( 0 ) -> childNodes as $child ) { |
| 135 | + $text .= $doc -> saveXML( $child ); |
| 136 | + } |
| 137 | + |
131 | 138 | } |
132 | 139 | |
133 | 140 | return true; |