r93422 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93421‎ | r93422 | r93423 >
Date:19:54, 28 July 2011
Author:emufarmers
Status:deferred (Comments)
Tags:
Comment:
Revert r90286 for FCKeditor. I'm not sure why this broke the extension, but it did.
Modified paths:
  • /trunk/extensions/FCKeditor/FCKeditor.body.php (modified) (history)
  • /trunk/extensions/FCKeditor/FCKeditorParser.body.php (modified) (history)
  • /trunk/extensions/FCKeditor/FCKeditorSajax.body.php (modified) (history)
  • /trunk/extensions/FCKeditor/FCKeditorSkin.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FCKeditor/FCKeditorSkin.body.php
@@ -68,18 +68,18 @@
6969 if( $thumb ) {
7070 $ret .= "_fck_mw_type=\"thumb"."\" ";
7171 $class .= "fck_mw_frame";
72 - } elseif( $framed ) {
 72+ } else if( $framed ) {
7373 $ret .= "_fck_mw_type=\"frame"."\" ";
7474 $class .= "fck_mw_frame";
7575 }
7676
7777 if( $align == 'right' ) {
7878 $class .= ( $class ? ' ' : '' ) . 'fck_mw_right';
79 - } elseif( $align == 'center' ) {
 79+ } else if( $align == 'center' ) {
8080 $class .= ( $class ? ' ' : '' ) . 'fck_mw_center';
81 - } elseif( $align == 'left' ) {
 81+ } else if( $align == 'left' ) {
8282 $class .= ( $class ? ' ' : '' ) . 'fck_mw_left';
83 - } elseif( $framed || $thumb ) {
 83+ } else if( $framed || $thumb ) {
8484 $class .= ( $class ? ' ' : '' ) . 'fck_mw_right';
8585 }
8686
Index: trunk/extensions/FCKeditor/FCKeditorSajax.body.php
@@ -109,19 +109,19 @@
110110 $ns = NS_CATEGORY;
111111 $term = substr( $term, 9 );
112112 $prefix = 'Category:';
113 - } elseif( strpos( strtolower( $term ), ':category:' ) === 0 ) {
 113+ } else if( strpos( strtolower( $term ), ':category:' ) === 0 ) {
114114 $ns = NS_CATEGORY;
115115 $term = substr( $term, 10 );
116116 $prefix = ':Category:';
117 - } elseif( strpos( strtolower( $term ), 'media:' ) === 0 ) {
 117+ } else if( strpos( strtolower( $term ), 'media:' ) === 0 ) {
118118 $ns = NS_IMAGE;
119119 $term = substr( $term, 6 );
120120 $prefix = 'Media:';
121 - } elseif( strpos( strtolower( $term ), ':image:' ) === 0 ) {
 121+ } else if( strpos( strtolower( $term ), ':image:' ) === 0 ) {
122122 $ns = NS_IMAGE;
123123 $term = substr( strtolower( $term ), 7 );
124124 $prefix = ':Image:';
125 - } elseif( strpos( $term, ':' ) && is_array( $wgExtraNamespaces ) ) {
 125+ } else if( strpos( $term, ':' ) && is_array( $wgExtraNamespaces ) ) {
126126 $pos = strpos( $term, ':' );
127127 $find_ns = array_search( substr( $term, 0, $pos ), $wgExtraNamespaces );
128128 if( $find_ns ) {
@@ -201,7 +201,7 @@
202202 /// @todo FIXME: should use Database class
203203 $sql = "SELECT tmpSelectCatPage.page_title AS title FROM ".$dbr->tableName('categorylinks')." AS tmpSelectCat ".
204204 "LEFT JOIN ".$dbr->tableName('page')." AS tmpSelectCatPage ON tmpSelectCat.cl_from = tmpSelectCatPage.page_id ".
205 - "WHERE tmpSelectCat.cl_to LIKE ".$dbr->addQuotes($m_root)." AND tmpSelectCatPage.page_namespace = $ns";
 205+ "WHERE tmpSelectCat.cl_to LIKE ".$dbr->addQuotes($m_root)." AND tmpSelectCatPage.page_namespace = $ns";
206206
207207 $res = $dbr->query( $sql, __METHOD__ );
208208 $ret = '';
Index: trunk/extensions/FCKeditor/FCKeditorParser.body.php
@@ -389,7 +389,7 @@
390390 if( $sum == 1 && $lastSum == 0 ) {
391391 $stringToParse .= strtr( substr( $text, $startingPos, $pos - $startingPos ), $strtr );
392392 $startingPos = $pos;
393 - } elseif( $sum == 0 ) {
 393+ } else if( $sum == 0 ) {
394394 $stringToParse .= 'Fckmw' . $this->fck_mw_strtr_span_counter . 'fckmw';
395395 $inner = htmlspecialchars( strtr( substr( $text, $startingPos, $pos - $startingPos + 19 ), $strtr ) );
396396 $this->fck_mw_strtr_span['href="Fckmw' . $this->fck_mw_strtr_span_counter . 'fckmw"'] = 'href="' . $inner . '"';
@@ -627,7 +627,7 @@
628628 } else {
629629 $inBlockElem = true;
630630 }
631 - } elseif ( !$inBlockElem && !$this->mInPre ) {
 631+ } else if ( !$inBlockElem && !$this->mInPre ) {
632632 if ( ' ' == $t{0} and ( $this->mLastSection == 'pre' or trim( $t ) != '' ) ) {
633633 // pre
634634 if( $this->mLastSection != 'pre' ) {
@@ -657,7 +657,7 @@
658658 $output .= $paragraphStack;
659659 $paragraphStack = false;
660660 $this->mLastSection = 'p';
661 - } elseif ($this->mLastSection != 'p') {
 661+ } else if ($this->mLastSection != 'p') {
662662 $output .= $this->closeParagraph().'<p>';
663663 $this->mLastSection = 'p';
664664 }
Index: trunk/extensions/FCKeditor/FCKeditor.body.php
@@ -465,7 +465,7 @@
466466
467467 if ( !( typeof(oDoc.FCK) == "undefined" ) && !( typeof(oDoc.FCK.EditingArea) == "undefined" ) ){
468468 txtarea = oDoc.FCK.EditingArea.Textarea;
469 - } elseif( oDoc.editform ){
 469+ } else if( oDoc.editform ){
470470 // if we have FCK enabled, behave differently...
471471 if ( showFCKEditor & RTE_VISIBLE ){
472472 SRCiframe = oDoc.getElementById( 'wpTextbox1___Frame' );
@@ -501,7 +501,7 @@
502502 // save window scroll position
503503 if ( oDoc.documentElement && oDoc.documentElement.scrollTop )
504504 var winScroll = oDoc.documentElement.scrollTop;
505 - elseif ( oDoc.body )
 505+ else if ( oDoc.body )
506506 var winScroll = oDoc.body.scrollTop;
507507
508508 // get current selection
@@ -522,10 +522,10 @@
523523 // restore window scroll position
524524 if ( oDoc.documentElement && oDoc.documentElement.scrollTop )
525525 oDoc.documentElement.scrollTop = winScroll;
526 - elseif ( oDoc.body )
 526+ else if ( oDoc.body )
527527 oDoc.body.scrollTop = winScroll;
528528
529 - } elseif ( txtarea.selectionStart || txtarea.selectionStart == '0' ){ // Mozilla
 529+ } else if ( txtarea.selectionStart || txtarea.selectionStart == '0' ){ // Mozilla
530530
531531 // save textarea scroll position
532532 var textScroll = txtarea.scrollTop;
@@ -539,7 +539,7 @@
540540 if( !selText ){
541541 selText = sampleText;
542542 isSample = true;
543 - } elseif( selText.charAt(selText.length - 1) == ' ' ){ //exclude ending space char
 543+ } else if( selText.charAt(selText.length - 1) == ' ' ){ //exclude ending space char
544544 selText = selText.substring(0, selText.length - 1);
545545 tagClose += ' ';
546546 }
@@ -563,7 +563,7 @@
564564 if( !selText ) {
565565 selText = sampleText;
566566 isSample = true;
567 - } elseif( selText.charAt(selText.length - 1) == ' ' ) { //exclude ending space char
 567+ } else if( selText.charAt(selText.length - 1) == ' ' ) { //exclude ending space char
568568 selText = selText.substring(0, selText.length - 1);
569569 tagClose += ' '
570570 }
@@ -594,7 +594,7 @@
595595 // Remove the mwSetupToolbar onload hook to avoid a JavaScript error with FF.
596596 if ( window.removeEventListener )
597597 window.removeEventListener( 'load', mwSetupToolbar, false );
598 - elseif ( window.detachEvent )
 598+ else if ( window.detachEvent )
599599 window.detachEvent( 'onload', mwSetupToolbar );
600600 mwSetupToolbar = function(){ return false ; };
601601

Follow-up revisions

RevisionCommit summaryAuthorDate
r108796MFT r93422: Un-break FCKEditorraymond08:55, 13 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90286Swap else if for elseif...reedy16:26, 17 June 2011

Comments

#Comment by Nikerabbit (talk | contribs)   05:38, 29 July 2011

Because javascript doesn't have elseif statements? But impossible to tell from just "broken".

#Comment by Dantman (talk | contribs)   05:59, 29 July 2011

Sounds precisely about right. JavaScript works like all other C-style languages and uses `} else if {`... Which I guess originated with the if implicitly applying to the else as if `if ( ... ) { ... } else if ( ... ) { ... }` was interpreted like `if ( ... ) { ... } else { if ( ... ) { ... } }` same functional purpose, same if/else parsing, no special elseif handling... I could be wrong of course that's just a guess. PHP however is the ugly duck. Technically `} else if {` is supposed to work, likely due to what I just mentioned of how elseif functions the same as if you put an if inside the else. However supposedly php does this inefficiently (it could be a myth, but php has never really done things sanely) and the elseif construct is faster than else if and is preferred to use. I suppose elseif also plays an important role in php's alternative conditional syntax `if ( ... ): endif;` since you can't have `else if:` only `elseif:` works.

This code can actually be un-reverted if you make sure to keep the `elseif` -> `else if` change inside trunk/extensions/FCKeditor/FCKeditor.body.php which appears to be the only JS in this diff.

#Comment by Krinkle (talk | contribs)   03:17, 17 September 2011

Status & tagging log