r107290 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107289‎ | r107290 | r107291 >
Date:20:33, 25 December 2011
Author:jarry1250
Status:ok
Tags:
Comment:
Followup r107242, 107233: rework to reduce indentation in various places; improve message line per Nikerabbit.
Modified paths:
  • /trunk/extensions/TranslateSvg/SpecialTranslateSvg.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TranslateSvg/SpecialTranslateSvg.php
@@ -56,7 +56,7 @@
5757 $this->printTranslations( $file->getName() );
5858 }
5959 } else {
60 - $this->getOutput()->addHTML( Html::element( 'p', null, wfMessage( 'translatesvg-unsuccessful' )->parse() ) );
 60+ $this->getOutput()->addWikiMsg( 'translatesvg-unsuccessful' );
6161 }
6262 } else {
6363 $this->getOutput()->setStatusCode( 404 );
@@ -99,53 +99,51 @@
100100 $switch = $this->svg->createElement( 'switch' );
101101 $text->parentNode->insertBefore( $switch, $text );
102102 $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
107105 }
108106 if( $text->childNodes->length > 1 ){
109107 return false; //Complex use of <tspan>s not yet supported.
110108 }
111109 if( $text->childNodes->length === 1 && $text->childNodes->item( 0 )->nodeType !== 3 ){
112110 $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 )
117115 {
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;
143143 }
144144 }
145 - $text->appendChild( $child->childNodes->item( 0 ) );
146 - $text->removeChild( $child );
147 - } else {
148 - return false;
149145 }
 146+ $text->appendChild( $child->childNodes->item( 0 ) );
 147+ $text->removeChild( $child );
150148 }
151149 }
152150 return true;
@@ -212,8 +210,8 @@
213211 $html .= Html::openElement( 'fieldset', array( 'id' => "mw-translatesvg-fieldset-$language" ) ) .
214212 Html::element( 'legend', null, $languages[$language] ) .
215213 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' ) ) );
218216 $groups = array();
219217 for( $i = 0; $i < $this->number; $i++ ){
220218 $fallback = $this->getFallback( $i );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107242Sort languages before displaying; make languages collapsible; if nothing to t...jarry125023:30, 24 December 2011

Status & tagging log