Index: trunk/extensions/TranslateSvg/SpecialTranslateSvg.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | $this->printTranslations( $file->getName() ); |
58 | 58 | } |
59 | 59 | } else { |
60 | | - $this->getOutput()->addHTML( Html::element( 'p', null, wfMessage( 'translatesvg-unsuccessful' )->parse() ) ); |
| 60 | + $this->getOutput()->addWikiMsg( 'translatesvg-unsuccessful' ); |
61 | 61 | } |
62 | 62 | } else { |
63 | 63 | $this->getOutput()->setStatusCode( 404 ); |
— | — | @@ -99,53 +99,51 @@ |
100 | 100 | $switch = $this->svg->createElement( 'switch' ); |
101 | 101 | $text->parentNode->insertBefore( $switch, $text ); |
102 | 102 | $switch->appendChild( $text ); //Move node into sibling <switch> element |
103 | | - } else { |
104 | | - if( $text->parentNode->nodeName !== "switch" ){ |
105 | | - return false; //Deep heirarchies cause us problems later |
106 | | - } |
| 103 | + } else if( $text->parentNode->nodeName !== "switch" ){ |
| 104 | + return false; //Deep heirarchies cause us problems later |
107 | 105 | } |
108 | 106 | if( $text->childNodes->length > 1 ){ |
109 | 107 | return false; //Complex use of <tspan>s not yet supported. |
110 | 108 | } |
111 | 109 | if( $text->childNodes->length === 1 && $text->childNodes->item( 0 )->nodeType !== 3 ){ |
112 | 110 | $child = $text->childNodes->item( 0 ); |
113 | | - if( $child->nodeName === 'tspan' |
114 | | - && $child->childNodes->length === 1 |
115 | | - && $child->childNodes->item( 0 )->nodeType === 3 |
116 | | - && $this->svg->getElementsByTagName( 'style' )->length === 0 ) |
| 111 | + if( !$child->nodeName === 'tspan' |
| 112 | + || !$child->childNodes->length === 1 |
| 113 | + || !$child->childNodes->item( 0 )->nodeType === 3 |
| 114 | + || !$this->svg->getElementsByTagName( 'style' )->length === 0 ) |
117 | 115 | { |
118 | | - //Repair by trimming excess <tspan>s |
119 | | - $attrs = ( $child->hasAttributes() ) ? $child->attributes : array(); |
120 | | - foreach ($attrs as $num => $attr){ |
121 | | - $parentattr = trim( $text->getAttribute( $attr->name ) ); |
122 | | - if( trim( $parentattr ) === '' ){ |
123 | | - $text->setAttribute( $attr->name, $attr->value ); //Simple upmerge |
124 | | - } else { |
125 | | - //Resolve conflict. the aim is to preserve the visuals. |
126 | | - switch( $attr->name ){ |
127 | | - case 'x': |
128 | | - case 'y': |
129 | | - $text->setAttribute( $attr->name, $attr->value ); //Overwrite |
130 | | - break; |
131 | | - case 'style': |
132 | | - $merged = $parentattr; |
133 | | - if( substr( $merged, -1 ) !== ';' ){ |
134 | | - $merged .= ';'; |
135 | | - } |
136 | | - $merged .= $attr->value; |
137 | | - break; |
138 | | - case 'id': |
139 | | - break; //Ignore |
140 | | - default: |
141 | | - return false; |
142 | | - } |
| 116 | + return false; |
| 117 | + } |
| 118 | + //Repair by trimming excess <tspan>s |
| 119 | + $attrs = ( $child->hasAttributes() ) ? $child->attributes : array(); |
| 120 | + foreach ($attrs as $attr){ |
| 121 | + $parentattr = trim( $text->getAttribute( $attr->name ) ); |
| 122 | + if( trim( $parentattr ) === '' ){ |
| 123 | + $text->setAttribute( $attr->name, $attr->value ); //Simple upmerge |
| 124 | + } else { |
| 125 | + //Resolve conflict. the aim is to preserve the visuals. |
| 126 | + switch( $attr->name ){ |
| 127 | + case 'x': |
| 128 | + case 'y': |
| 129 | + $text->setAttribute( $attr->name, $attr->value ); //Overwrite |
| 130 | + break; |
| 131 | + case 'style': |
| 132 | + $merged = $parentattr; |
| 133 | + if( substr( $merged, -1 ) !== ';' ){ |
| 134 | + $merged .= ';'; |
| 135 | + } |
| 136 | + $merged .= $attr->value; |
| 137 | + $text->setAttribute( $attr->name, $merged ); |
| 138 | + break; |
| 139 | + case 'id': |
| 140 | + break; //Ignore |
| 141 | + default: |
| 142 | + return false; |
143 | 143 | } |
144 | 144 | } |
145 | | - $text->appendChild( $child->childNodes->item( 0 ) ); |
146 | | - $text->removeChild( $child ); |
147 | | - } else { |
148 | | - return false; |
149 | 145 | } |
| 146 | + $text->appendChild( $child->childNodes->item( 0 ) ); |
| 147 | + $text->removeChild( $child ); |
150 | 148 | } |
151 | 149 | } |
152 | 150 | return true; |
— | — | @@ -212,8 +210,8 @@ |
213 | 211 | $html .= Html::openElement( 'fieldset', array( 'id' => "mw-translatesvg-fieldset-$language" ) ) . |
214 | 212 | Html::element( 'legend', null, $languages[$language] ) . |
215 | 213 | Html::openElement( 'div', array( 'class' => 'mw-collapsible mw-collapsed', |
216 | | - 'data-collapsetext' => wfMsg( 'translatesvg-toggle-hide' ), |
217 | | - 'data-expandtext' => wfMsg( 'translatesvg-toggle-view' ) ) ); |
| 214 | + 'data-collapsetext' => wfMsg( 'translatesvg-toggle-hide' ), |
| 215 | + 'data-expandtext' => wfMsg( 'translatesvg-toggle-view' ) ) ); |
218 | 216 | $groups = array(); |
219 | 217 | for( $i = 0; $i < $this->number; $i++ ){ |
220 | 218 | $fallback = $this->getFallback( $i ); |