X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=blobdiff_plain;f=includes%2FRawPage.php;h=b1e2539a261d200ad60984270785561129bdd30c;hb=087a9f70c5c152b72dc6c539cf64e334a0f2d029;hp=defd74f287af450768347530e830e7e165321b86;hpb=393ce6d8df159c6a4c2364ee8d11f8b368b41dff;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/RawPage.php b/includes/RawPage.php index defd74f287..b1e2539a26 100644 --- a/includes/RawPage.php +++ b/includes/RawPage.php @@ -7,6 +7,7 @@ * License: GPL (http://www.gnu.org/copyleft/gpl.html) * * @author Gabriel Wicke + * @file */ /** @@ -20,7 +21,7 @@ class RawPage { var $mContentType, $mExpandTemplates; function __construct( &$article, $request = false ) { - global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType; + global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgForcedRawSMaxage, $wgGroupPermissions; $allowedCTypes = array('text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit'); $this->mArticle =& $article; @@ -35,6 +36,7 @@ class RawPage { $ctype = $this->mRequest->getVal( 'ctype' ); $smaxage = $this->mRequest->getIntOrNull( 'smaxage', $wgSquidMaxage ); $maxage = $this->mRequest->getInt( 'maxage', $wgSquidMaxage ); + $this->mExpandTemplates = $this->mRequest->getVal( 'templates' ) === 'expand'; $this->mUseMessageCache = $this->mRequest->getBool( 'usemsgcache' ); @@ -65,7 +67,7 @@ class RawPage { break; } $this->mOldId = $oldid; - + # special case for 'generated' raw things: user css/js $gen = $this->mRequest->getVal( 'gen' ); @@ -81,13 +83,24 @@ class RawPage { $this->mGen = false; } $this->mCharset = $wgInputEncoding; - $this->mSmaxage = intval( $smaxage ); + + # Force caching for CSS and JS raw content, default: 5 minutes + if (is_null($smaxage) and ($ctype=='text/css' or $ctype==$wgJsMimeType)) { + $this->mSmaxage = intval($wgForcedRawSMaxage); + } else { + $this->mSmaxage = intval( $smaxage ); + } $this->mMaxage = $maxage; - - // Output may contain user-specific data; vary for open sessions - $this->mPrivateCache = ( $this->mSmaxage == 0 ) || - ( session_id() != '' ); - + + # Output may contain user-specific data; + # vary generated content for open sessions and private wikis + if ($this->mGen or !$wgGroupPermissions['*']['read']) { + $this->mPrivateCache = ( $this->mSmaxage == 0 ) || + ( session_id() != '' ); + } else { + $this->mPrivateCache = false; + } + if ( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) { $this->mContentType = 'text/x-wiki'; } else { @@ -113,9 +126,8 @@ class RawPage { } else { $url = $_SERVER['PHP_SELF']; } - - $ua = @$_SERVER['HTTP_USER_AGENT']; - if( strcmp( $wgScript, $url ) && strpos( $ua, 'MSIE' ) !== false ) { + + if( strcmp( $wgScript, $url ) ) { # Internet Explorer will ignore the Content-Type header if it # thinks it sees a file extension it recognizes. Make sure that # all raw requests are done through the script node, which will @@ -181,9 +193,9 @@ class RawPage { $lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() ); header( "Last-modified: $lastmod" ); - if ( !is_null($this->mSection) && $this->mSection != '' ) { + if ( !is_null($this->mSection ) ) { global $wgParser; - return $wgParser->getSection ( $rev->getText(), $this->mSection ); + $text = $wgParser->getSection ( $rev->getText(), $this->mSection ); } else $text = $rev->getText(); $found = true; @@ -199,7 +211,7 @@ class RawPage { # have the pages. header( "HTTP/1.0 404 Not Found" ); } - + // Special-case for empty CSS/JS // // Internet Explorer for Mac handles empty files badly; @@ -213,7 +225,7 @@ class RawPage { $this->mContentType == 'text/javascript' ) ) { return "/* Empty */"; } - + return $this->parseArticleText( $text ); } @@ -228,4 +240,3 @@ class RawPage { return $text; } } -