X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2FOutputPage.php;h=5dd58a629df90e26d868995fb49eca62bd9f5926;hb=feb1eab8444bf79a6f162156d2614cb0009bbfa2;hp=7f1948affd2944ed477181a585f7c06e040c32cd;hpb=c6879704abf865e25554e9bd92b185f96097985d;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 7f1948affd..5dd58a629d 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1,118 +1,7 @@
# See design.doc
-function linkToMathImage ( $tex, $outputhash )
-{
- global $wgMathPath;
- return "";
-}
-
-function renderMath( $tex )
-{
- global $wgUser, $wgMathDirectory, $wgTmpDirectory, $wgInputEncoding;
- $mf = wfMsg( "math_failure" );
- $munk = wfMsg( "math_unknown_error" );
-
- $fname = "renderMath";
-
- $math = $wgUser->getOption("math");
- if ($math == 3)
- return ('$ '.wfEscapeHTML($tex).' $');
-
- $md5 = md5($tex);
- $md5_sql = mysql_escape_string(pack("H32", $md5));
- if ($math == 0)
- $sql = "SELECT math_outputhash FROM math WHERE math_inputhash = '".$md5_sql."'";
- else
- $sql = "SELECT math_outputhash,math_html_conservativeness,math_html FROM math WHERE math_inputhash = '".$md5_sql."'";
-
- $res = wfQuery( $sql, $fname );
- if ( wfNumRows( $res ) == 0 )
- {
- $cmd = "./math/texvc ".escapeshellarg($wgTmpDirectory)." ".
- escapeshellarg($wgMathDirectory)." ".escapeshellarg($tex)." ".escapeshellarg($wgInputEncoding);
- $contents = `$cmd`;
-
- if (strlen($contents) == 0)
- return "".$mf." (".$munk."): ".wfEscapeHTML($tex)."";
- $retval = substr ($contents, 0, 1);
- if (($retval == "C") || ($retval == "M") || ($retval == "L")) {
- if ($retval == "C")
- $conservativeness = 2;
- else if ($retval == "M")
- $conservativeness = 1;
- else
- $conservativeness = 0;
- $outdata = substr ($contents, 33);
-
- $i = strpos($outdata, "\000");
-
- $outhtml = substr($outdata, 0, $i);
- $mathml = substr($outdata, $i+1);
-
- $sql_html = "'".mysql_escape_string($outhtml)."'";
- $sql_mathml = "'".mysql_escape_string($mathml)."'";
- } else if (($retval == "c") || ($retval == "m") || ($retval == "l")) {
- $outhtml = substr ($contents, 33);
- if ($retval == "c")
- $conservativeness = 2;
- else if ($retval == "m")
- $conservativeness = 1;
- else
- $conservativeness = 0;
- $sql_html = "'".mysql_escape_string($outhtml)."'";
- $mathml = '';
- $sql_mathml = 'NULL';
- } else if ($retval == "X") {
- $outhtml = '';
- $mathml = substr ($contents, 33);
- $sql_html = 'NULL';
- $sql_mathml = "'".mysql_escape_string($mathml)."'";
- $conservativeness = 0;
- } else if ($retval == "+") {
- $outhtml = '';
- $mathml = '';
- $sql_html = 'NULL';
- $sql_mathml = 'NULL';
- $conservativeness = 0;
- } else {
- if ($retval == "E")
- $errmsg = wfMsg( "math_lexing_error" );
- else if ($retval == "S")
- $errmsg = wfMsg( "math_syntax_error" );
- else if ($retval == "F")
- $errmsg = wfMsg( "math_unknown_function" );
- else
- $errmsg = $munk;
- return "
". wfEscapeHTMLTagsOnly($q[0]). ""; - $stripped3 .= $unique3; + $stripped3 .= $unique3 . $presecs . "s"; $stripped2 = $q[1]; } } @@ -302,34 +188,38 @@ class OutputPage { $specialChars = array("\\", "$"); $escapedChars = array("\\\\", "\\$"); for ( $i = 1; $i <= $presecs; ++$i ) { - $text = preg_replace( "/{$unique3}/", str_replace( $specialChars, - $escapedChars, $prelist[$i] ), $text, 1 ); + $text = preg_replace( "/{$unique3}{$i}s/", str_replace( $specialChars, + $escapedChars, $prelist[$i] ), $text ); } for ( $i = 1; $i <= $mathsecs; ++$i ) { - $text = preg_replace( "/{$unique2}/", str_replace( $specialChars, - $escapedChars, $mathlist[$i] ), $text, 1 ); + $text = preg_replace( "/{$unique2}{$i}s/", str_replace( $specialChars, + $escapedChars, $mathlist[$i] ), $text ); } for ( $i = 1; $i <= $nwsecs; ++$i ) { - $text = preg_replace( "/{$unique}/", str_replace( $specialChars, - $escapedChars, $nwlist[$i] ), $text, 1 ); + $text = preg_replace( "/{$unique}{$i}s/", str_replace( $specialChars, + $escapedChars, $nwlist[$i] ), $text ); } $this->addHTML( $text ); - wfProfileOut(); + wfProfileOut( $fname ); } function sendCacheControl() { + global $wgUseGzip; if( $this->mLastModified != "" ) { wfDebug( "** private caching; {$this->mLastModified} **\n", false ); header( "Cache-Control: private, must-revalidate, max-age=0" ); - header( "Vary: Accept-Encoding" ); header( "Last-modified: {$this->mLastModified}" ); + if( $wgUseGzip ) { + # We should put in Accept-Encoding, but IE chokes on anything but + # User-Agent in a Vary: header (at least through 6.0) + header( "Vary: User-Agent" ); + } } else { wfDebug( "** no caching **\n", false ); header( "Cache-Control: no-cache" ); # Experimental - see below header( "Pragma: no-cache" ); - header( "Vary: Accept-Encoding" ); header( "Last-modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" ); } header( "Expires: Mon, 15 Jan 2001 00:00:00 GMT" ); # Cachers always validate the page! @@ -342,18 +232,26 @@ class OutputPage { { global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration; global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode; - wfProfileIn( "OutputPage::output" ); + if( $this->mDoNothing ){ + return; + } + $fname = "OutputPage::output"; + wfProfileIn( $fname ); + $sk = $wgUser->getSkin(); - wfProfileIn( "OutputPage::output-headers" ); $this->sendCacheControl(); header( "Content-type: text/html; charset={$wgOutputEncoding}" ); header( "Content-language: {$wgLanguageCode}" ); if ( "" != $this->mRedirect ) { + if( substr( $this->mRedirect, 0, 4 ) != "http" ) { + # Standards require redirect URLs to be absolute + global $wgServer; + $this->mRedirect = $wgServer . $this->mRedirect; + } header( "Location: {$this->mRedirect}" ); - wfProfileOut(); return; } @@ -361,36 +259,8 @@ class OutputPage { foreach( $this->mCookies as $name => $val ) { setcookie( $name, $val, $exp, "/" ); } - wfProfileOut(); - - wfProfileIn( "OutputPage::output-middle" ); - $sk->initPage(); - $this->out( $this->headElement() ); - $this->out( "\ngetBodyOptions(); - foreach ( $ops as $name => $val ) { - $this->out( " $name='$val'" ); - } - $this->out( ">\n" ); - if ( $wgDebugComments ) { - $this->out( "\n" ); - } - $this->out( $sk->beforeContent() ); - wfProfileOut(); - - wfProfileIn( "OutputPage::output-bodytext" ); - $this->out( $this->mBodytext ); - wfProfileOut(); - wfProfileIn( "OutputPage::output-after" ); - $this->out( $sk->afterContent() ); - wfProfileOut(); - - wfProfileOut(); # A hack - we can't report after here - $this->out( $this->reportTime() ); - - $this->out( "\n