From: Tim Starling Date: Sat, 28 Feb 2004 05:55:13 +0000 (+0000) Subject: Comments and code formatting X-Git-Tag: 1.3.0beta1~924 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=f798585de73e0c1024d0fd9b25220cd1bf8cd286;p=lhc%2Fweb%2Fwiklou.git Comments and code formatting --- diff --git a/includes/Parser.php b/includes/Parser.php index 2e6845da56..3b883c082d 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1,8 +1,12 @@ getOption( "stubthreshold" )) == 0 && - is_object($article) && $article->getID() > 0; - - if( $use_parser_cache ){ - if( $this->fillFromParserCache() ){ - wfProfileOut( $fname ); - return; - } - } - */ - + while ( "" != $text ) { $p = preg_split( "/<\\s*nowiki\\s*>/i", $text, 2 ); $stripped .= $p[0]; @@ -132,12 +121,6 @@ class Parser $escapedChars, $nwlist[$i] ), $text ); } - /* - if($use_parser_cache ){ - $this->saveParserCache( $text ); - } - */ - $this->mOutput->setText( $text ); wfProfileOut( $fname ); return $this->mOutput; @@ -255,102 +238,102 @@ function fixTagAttributes ( $t ) function doTableStuff ( $t ) { - $t = explode ( "\n" , $t ) ; - $td = array () ; # Is currently a td tag open? - $ltd = array () ; # Was it TD or TH? - $tr = array () ; # Is currently a tr tag open? - $ltr = array () ; # tr attributes - foreach ( $t AS $k => $x ) - { - $x = rtrim ( $x ) ; - $fc = substr ( $x , 0 , 1 ) ; - if ( "{|" == substr ( $x , 0 , 2 ) ) - { - $t[$k] = "fixTagAttributes ( substr ( $x , 3 ) ) . ">" ; - array_push ( $td , false ) ; - array_push ( $ltd , "" ) ; - array_push ( $tr , false ) ; - array_push ( $ltr , "" ) ; - } - else if ( count ( $td ) == 0 ) { } # Don't do any of the following - else if ( "|}" == substr ( $x , 0 , 2 ) ) - { - $z = "
\n" ; - $l = array_pop ( $ltd ) ; - if ( array_pop ( $tr ) ) $z = "" . $z ; - if ( array_pop ( $td ) ) $z = "" . $z ; - array_pop ( $ltr ) ; - $t[$k] = $z ; - } -/* else if ( "|_" == substr ( $x , 0 , 2 ) ) # Caption - { - $z = trim ( substr ( $x , 2 ) ) ; - $t[$k] = "{$z}\n" ; - }*/ - else if ( "|-" == substr ( $x , 0 , 2 ) ) # Allows for |--------------- - { - $x = substr ( $x , 1 ) ; - while ( $x != "" && substr ( $x , 0 , 1 ) == '-' ) $x = substr ( $x , 1 ) ; - $z = "" ; - $l = array_pop ( $ltd ) ; - if ( array_pop ( $tr ) ) $z = "" . $z ; - if ( array_pop ( $td ) ) $z = "" . $z ; - array_pop ( $ltr ) ; - $t[$k] = $z ; - array_push ( $tr , false ) ; - array_push ( $td , false ) ; - array_push ( $ltd , "" ) ; - array_push ( $ltr , $this->fixTagAttributes ( $x ) ) ; - } - else if ( "|" == $fc || "!" == $fc || "|+" == substr ( $x , 0 , 2 ) ) # Caption + $t = explode ( "\n" , $t ) ; + $td = array () ; # Is currently a td tag open? + $ltd = array () ; # Was it TD or TH? + $tr = array () ; # Is currently a tr tag open? + $ltr = array () ; # tr attributes + foreach ( $t AS $k => $x ) + { + $x = rtrim ( $x ) ; + $fc = substr ( $x , 0 , 1 ) ; + if ( "{|" == substr ( $x , 0 , 2 ) ) + { + $t[$k] = "fixTagAttributes ( substr ( $x , 3 ) ) . ">" ; + array_push ( $td , false ) ; + array_push ( $ltd , "" ) ; + array_push ( $tr , false ) ; + array_push ( $ltr , "" ) ; + } + else if ( count ( $td ) == 0 ) { } # Don't do any of the following + else if ( "|}" == substr ( $x , 0 , 2 ) ) + { + $z = "
\n" ; + $l = array_pop ( $ltd ) ; + if ( array_pop ( $tr ) ) $z = "" . $z ; + if ( array_pop ( $td ) ) $z = "" . $z ; + array_pop ( $ltr ) ; + $t[$k] = $z ; + } + /* else if ( "|_" == substr ( $x , 0 , 2 ) ) # Caption + { + $z = trim ( substr ( $x , 2 ) ) ; + $t[$k] = "{$z}\n" ; + }*/ + else if ( "|-" == substr ( $x , 0 , 2 ) ) # Allows for |--------------- + { + $x = substr ( $x , 1 ) ; + while ( $x != "" && substr ( $x , 0 , 1 ) == '-' ) $x = substr ( $x , 1 ) ; + $z = "" ; + $l = array_pop ( $ltd ) ; + if ( array_pop ( $tr ) ) $z = "" . $z ; + if ( array_pop ( $td ) ) $z = "" . $z ; + array_pop ( $ltr ) ; + $t[$k] = $z ; + array_push ( $tr , false ) ; + array_push ( $td , false ) ; + array_push ( $ltd , "" ) ; + array_push ( $ltr , $this->fixTagAttributes ( $x ) ) ; + } + else if ( "|" == $fc || "!" == $fc || "|+" == substr ( $x , 0 , 2 ) ) # Caption + { + if ( "|+" == substr ( $x , 0 , 2 ) ) + { + $fc = "+" ; + $x = substr ( $x , 1 ) ; + } + $after = substr ( $x , 1 ) ; + if ( $fc == "!" ) $after = str_replace ( "!!" , "||" , $after ) ; + $after = explode ( "||" , $after ) ; + $t[$k] = "" ; + foreach ( $after AS $theline ) + { + $z = "" ; + if ( $fc != "+" ) + { + $tra = array_pop ( $ltr ) ; + if ( !array_pop ( $tr ) ) $z = "\n" ; + array_push ( $tr , true ) ; + array_push ( $ltr , "" ) ; + } + + $l = array_pop ( $ltd ) ; + if ( array_pop ( $td ) ) $z = "" . $z ; + if ( $fc == "|" ) $l = "TD" ; + else if ( $fc == "!" ) $l = "TH" ; + else if ( $fc == "+" ) $l = "CAPTION" ; + else $l = "" ; + array_push ( $ltd , $l ) ; + $y = explode ( "|" , $theline , 2 ) ; + if ( count ( $y ) == 1 ) $y = "{$z}<{$l}>{$y[0]}" ; + else $y = $y = "{$z}<{$l} ".$this->fixTagAttributes($y[0]).">{$y[1]}" ; + $t[$k] .= $y ; + array_push ( $td , true ) ; + } + } + } + + # Closing open td, tr && table + while ( count ( $td ) > 0 ) { - if ( "|+" == substr ( $x , 0 , 2 ) ) - { - $fc = "+" ; - $x = substr ( $x , 1 ) ; - } - $after = substr ( $x , 1 ) ; - if ( $fc == "!" ) $after = str_replace ( "!!" , "||" , $after ) ; - $after = explode ( "||" , $after ) ; - $t[$k] = "" ; - foreach ( $after AS $theline ) - { - $z = "" ; - if ( $fc != "+" ) - { - $tra = array_pop ( $ltr ) ; - if ( !array_pop ( $tr ) ) $z = "\n" ; - array_push ( $tr , true ) ; - array_push ( $ltr , "" ) ; - } - - $l = array_pop ( $ltd ) ; - if ( array_pop ( $td ) ) $z = "" . $z ; - if ( $fc == "|" ) $l = "TD" ; - else if ( $fc == "!" ) $l = "TH" ; - else if ( $fc == "+" ) $l = "CAPTION" ; - else $l = "" ; - array_push ( $ltd , $l ) ; - $y = explode ( "|" , $theline , 2 ) ; - if ( count ( $y ) == 1 ) $y = "{$z}<{$l}>{$y[0]}" ; - else $y = $y = "{$z}<{$l} ".$this->fixTagAttributes($y[0]).">{$y[1]}" ; - $t[$k] .= $y ; - array_push ( $td , true ) ; - } + if ( array_pop ( $td ) ) $t[] = "" ; + if ( array_pop ( $tr ) ) $t[] = "" ; + $t[] = "" ; } - } - -# Closing open td, tr && table -while ( count ( $td ) > 0 ) -{ -if ( array_pop ( $td ) ) $t[] = "" ; -if ( array_pop ( $tr ) ) $t[] = "" ; -$t[] = "" ; -} - $t = implode ( "\n" , $t ) ; -# $t = $this->removeHTMLtags( $t ); - return $t ; + $t = implode ( "\n" , $t ) ; + # $t = $this->removeHTMLtags( $t ); + return $t ; } # Well, OK, it's actually about 14 passes. But since all the