r19032 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19031‎ | r19032 | r19033 >
Date:20:25, 9 January 2007
Author:hashar
Status:old
Tags:
Comment:
whitespaces killing
Modified paths:
  • /trunk/phase3/includes/AjaxDispatcher.php (modified) (history)
  • /trunk/phase3/includes/AjaxFunctions.php (modified) (history)
  • /trunk/phase3/includes/AjaxResponse.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/AjaxDispatcher.php
@@ -47,7 +47,7 @@
4848
4949 function performAction() {
5050 global $wgAjaxExportList, $wgOut;
51 -
 51+
5252 if ( empty( $this->mode ) ) {
5353 return;
5454 }
@@ -59,7 +59,7 @@
6060 } else {
6161 try {
6262 $result = call_user_func_array($this->func_name, $this->args);
63 -
 63+
6464 if ( $result === false || $result === NULL ) {
6565 header( 'Status: 500 Internal Error', true, 500 );
6666 echo "{$this->func_name} returned no data";
@@ -68,7 +68,7 @@
6969 if ( is_string( $result ) ) {
7070 $result= new AjaxResponse( $result );
7171 }
72 -
 72+
7373 $result->sendHeaders();
7474 $result->printText();
7575 }
@@ -82,7 +82,7 @@
8383 }
8484 }
8585 }
86 -
 86+
8787 wfProfileOut( __METHOD__ );
8888 $wgOut = null;
8989 }
Index: trunk/phase3/includes/AjaxFunctions.php
@@ -45,7 +45,7 @@
4646 if ($iconv_to != "UTF-8") {
4747 $decodedStr = iconv("UTF-8", $iconv_to, $decodedStr);
4848 }
49 -
 49+
5050 return $decodedStr;
5151 }
5252
@@ -71,7 +71,7 @@
7272 function wfSajaxSearch( $term ) {
7373 global $wgContLang, $wgOut;
7474 $limit = 16;
75 -
 75+
7676 $l = new Linker;
7777
7878 $term = str_replace( ' ', '_', $wgContLang->ucfirst(
@@ -109,7 +109,7 @@
110110 $subtitle = $wgOut->parse( wfMsg( $subtitlemsg, wfEscapeWikiText($term) ) ); #FIXME: parser is missing mTitle !
111111
112112 $term = htmlspecialchars( $term );
113 - $html = '<div style="float:right; border:solid 1px black;background:gainsboro;padding:2px;"><a onclick="Searching_Hide_Results();">'
 113+ $html = '<div style="float:right; border:solid 1px black;background:gainsboro;padding:2px;"><a onclick="Searching_Hide_Results();">'
114114 . wfMsg( 'hideresults' ) . '</a></div>'
115115 . '<h1 class="firstHeading">'.wfMsg('search')
116116 . '</h1><div id="contentSub">'. $subtitle . '</div><ul><li>'
@@ -121,11 +121,11 @@
122122 "search=$term&go=Go" )
123123 . "</li></ul><h2>" . wfMsg( 'articletitles', $term ) . "</h2>"
124124 . '<ul>' .$r .'</ul>'.$more;
125 -
 125+
126126 $response = new AjaxResponse( $html );
127 -
 127+
128128 $response->setCacheDuration( 30*60 );
129 -
 129+
130130 return $response;
131131 }
132132
Index: trunk/phase3/includes/AjaxResponse.php
@@ -6,7 +6,7 @@
77 class AjaxResponse {
88 var $mCacheDuration;
99 var $mVary;
10 -
 10+
1111 var $mDisabled;
1212 var $mText;
1313 var $mResponseCode;
@@ -16,13 +16,13 @@
1717 function AjaxResponse( $text = NULL ) {
1818 $this->mCacheDuration = NULL;
1919 $this->mVary = NULL;
20 -
 20+
2121 $this->mDisabled = false;
2222 $this->mText = '';
2323 $this->mResponseCode = '200 OK';
2424 $this->mLastModified = false;
2525 $this->mContentType= 'text/html; charset=utf-8';
26 -
 26+
2727 if ( $text ) {
2828 $this->addText( $text );
2929 }
@@ -39,15 +39,15 @@
4040 function setResponseCode( $code ) {
4141 $this->mResponseCode = $code;
4242 }
43 -
 43+
4444 function setContentType( $type ) {
4545 $this->mContentType = $type;
4646 }
47 -
 47+
4848 function disable() {
4949 $this->mDisabled = true;
5050 }
51 -
 51+
5252 function addText( $text ) {
5353 if ( ! $this->mDisabled && $text ) {
5454 $this->mText .= $text;
@@ -59,62 +59,62 @@
6060 print $this->mText;
6161 }
6262 }
63 -
 63+
6464 function sendHeaders() {
6565 global $wgUseSquid, $wgUseESI;
66 -
 66+
6767 if ( $this->mResponseCode ) {
6868 $n = preg_replace( '/^ *(\d+)/', '\1', $this->mResponseCode );
6969 header( "Status: " . $this->mResponseCode, true, (int)$n );
7070 }
71 -
 71+
7272 header ("Content-Type: " . $this->mContentType );
73 -
 73+
7474 if ( $this->mLastModified ) {
7575 header ("Last-Modified: " . $this->mLastModified );
7676 }
7777 else {
7878 header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
7979 }
80 -
 80+
8181 if ( $this->mCacheDuration ) {
82 -
 82+
8383 # If squid caches are configured, tell them to cache the response,
8484 # and tell the client to always check with the squid. Otherwise,
8585 # tell the client to use a cached copy, without a way to purge it.
86 -
 86+
8787 if( $wgUseSquid ) {
88 -
 88+
8989 # Expect explicite purge of the proxy cache, but require end user agents
9090 # to revalidate against the proxy on each visit.
9191 # Surrogate-Control controls our Squid, Cache-Control downstream caches
92 -
 92+
9393 if ( $wgUseESI ) {
9494 header( 'Surrogate-Control: max-age='.$this->mCacheDuration.', content="ESI/1.0"');
9595 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
9696 } else {
9797 header( 'Cache-Control: s-maxage='.$this->mCacheDuration.', must-revalidate, max-age=0' );
9898 }
99 -
 99+
100100 } else {
101 -
 101+
102102 # Let the client do the caching. Cache is not purged.
103103 header ("Expires: " . gmdate( "D, d M Y H:i:s", time() + $this->mCacheDuration ) . " GMT");
104104 header ("Cache-Control: s-max-age={$this->mCacheDuration},public,max-age={$this->mCacheDuration}");
105105 }
106 -
 106+
107107 } else {
108108 # always expired, always modified
109109 header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
110110 header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
111111 header ("Pragma: no-cache"); // HTTP/1.0
112112 }
113 -
 113+
114114 if ( $this->mVary ) {
115115 header ( "Vary: " . $this->mVary );
116116 }
117117 }
118 -
 118+
119119 /**
120120 * checkLastModified tells the client to use the client-cached response if
121121 * possible. If sucessful, the AjaxResponse is disabled so that
@@ -154,9 +154,9 @@
155155 $this->setResponseCode( "304 Not Modified" );
156156 $this->disable();
157157 $this->mLastModified = $lastmod;
158 -
 158+
159159 wfDebug( "$fname: CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
160 -
 160+
161161 return true;
162162 } else {
163163 wfDebug( "$fname: READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
@@ -167,11 +167,11 @@
168168 $this->mLastModified = $lastmod;
169169 }
170170 }
171 -
 171+
172172 function loadFromMemcached( $mckey, $touched ) {
173173 global $wgMemc;
174174 if ( !$touched ) return false;
175 -
 175+
176176 $mcvalue = $wgMemc->get( $mckey );
177177 if ( $mcvalue ) {
178178 # Check to see if the value has been invalidated
@@ -183,20 +183,20 @@
184184 wfDebug( "$mckey has expired\n" );
185185 }
186186 }
187 -
 187+
188188 return false;
189189 }
190 -
 190+
191191 function storeInMemcached( $mckey, $expiry = 86400 ) {
192192 global $wgMemc;
193 -
194 - $wgMemc->set( $mckey,
 193+
 194+ $wgMemc->set( $mckey,
195195 array(
196196 'timestamp' => wfTimestampNow(),
197197 'value' => $this->mText
198198 ), $expiry
199199 );
200 -
 200+
201201 return true;
202202 }
203203 }