fix some spacing
[lhc/web/wiklou.git] / includes / OutputPage.php
index 968acf6..62219e2 100644 (file)
@@ -248,6 +248,11 @@ class OutputPage extends ContextSource {
         */
        private $mRedirectedFrom = null;
 
+       /**
+        * Additional key => value data
+        */
+       private $mProperties = array();
+
        /**
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
@@ -516,9 +521,11 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add only CSS of one or more modules recognized by the resource loader. Module
-        * styles added through this function will be loaded by the resource loader when
-        * the page loads.
+        * Add only CSS of one or more modules recognized by the resource loader.
+        *
+        * Module styles added through this function will be added using standard link CSS
+        * tags, rather than as a combined Javascript and CSS package. Thus, they will
+        * load when JavaScript is disabled (unless CSS also happens to be disabled).
         *
         * @param $modules Mixed: module name (string) or array of module names
         */
@@ -620,6 +627,32 @@ class OutputPage extends ContextSource {
                return $this->mArticleBodyOnly;
        }
 
+       /**
+        * Set an additional output property
+        * @since 1.21
+        *
+        * @param string $name
+        * @param mixed $value
+        */
+       public function setProperty( $name, $value ) {
+               $this->mProperties[$name] = $value;
+       }
+
+       /**
+        * Get an additional output property
+        * @since 1.21
+        *
+        * @param $name
+        * @return mixed: Property value or null if not found
+        */
+       public function getProperty( $name ) {
+               if ( isset( $this->mProperties[$name] ) ) {
+                       return $this->mProperties[$name];
+               } else {
+                       return null;
+               }
+       }
+
        /**
         * checkLastModified tells the client to use the client-cached page if
         * possible. If successful, the OutputPage is disabled so that
@@ -1275,7 +1308,7 @@ class OutputPage extends ContextSource {
         * @param  $level Int ResourceLoaderModule class constant
         */
        public function reduceAllowedModules( $type, $level ) {
-               $this->mAllowedModules[$type] = min( $this->getAllowedModules($type), $level );
+               $this->mAllowedModules[$type] = min( $this->getAllowedModules( $type ), $level );
        }
 
        /**
@@ -1564,7 +1597,6 @@ class OutputPage extends ContextSource {
                $this->addHTML( $text );
        }
 
-
        /**
         * Add the output of a QuickTemplate to the output buffer
         *
@@ -1873,7 +1905,7 @@ class OutputPage extends ContextSource {
                                        wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **\n", false );
                                        # start with a shorter timeout for initial testing
                                        # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
-                                       $response->header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage.', content="ESI/1.0"');
+                                       $response->header( 'Surrogate-Control: max-age=' . $wgSquidMaxage . '+' . $this->mSquidMaxage . ', content="ESI/1.0"' );
                                        $response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
                                } else {
                                        # We'll purge the proxy cache for anons explicitly, but require end user agents
@@ -1883,7 +1915,7 @@ class OutputPage extends ContextSource {
                                        wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **\n", false );
                                        # start with a shorter timeout for initial testing
                                        # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
-                                       $response->header( 'Cache-Control: s-maxage='.$this->mSquidMaxage.', must-revalidate, max-age=0' );
+                                       $response->header( 'Cache-Control: s-maxage=' . $this->mSquidMaxage . ', must-revalidate, max-age=0' );
                                }
                        } else {
                                # We do want clients to cache if they can, but they *must* check for updates
@@ -1892,7 +1924,7 @@ class OutputPage extends ContextSource {
                                $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
                                $response->header( "Cache-Control: private, must-revalidate, max-age=0" );
                        }
-                       if($this->mLastModified) {
+                       if( $this->mLastModified ) {
                                $response->header( "Last-Modified: {$this->mLastModified}" );
                        }
                } else {
@@ -2272,7 +2304,7 @@ class OutputPage extends ContextSource {
 
                        $pageLang = $this->getTitle()->getPageLanguage();
                        $params = array(
-                               'id'   => 'wpTextbox1',
+                               'id' => 'wpTextbox1',
                                'name' => 'wpTextbox1',
                                'cols' => $this->getUser()->getOption( 'cols' ),
                                'rows' => $this->getUser()->getOption( 'rows' ),
@@ -2919,14 +2951,13 @@ $templates
                $this->mJsConfigVars[$keys] = $value;
        }
 
-
        /**
         * Get an array containing the variables to be set in mw.config in JavaScript.
         *
         * DO NOT CALL THIS FROM OUTSIDE OF THIS CLASS OR Skin::makeGlobalVariablesScript().
         * This is only public until that function is removed. You have been warned.
         *
-        * Do not add things here which can be evaluated in ResourceLoaderStartupScript
+        * Do not add things here which can be evaluated in ResourceLoaderStartUpModule
         * - in other words, page-independent/site-wide variables (without state).
         * You will only be adding bloat to the html page and causing page caches to
         * have to be purged on configuration changes.
@@ -2971,6 +3002,8 @@ $templates
                        implode( "\t", $digitTransTable ),
                );
 
+               $user = $this->getUser();
+
                $vars = array(
                        'wgCanonicalNamespace' => $nsname,
                        'wgCanonicalSpecialPageName' => $canonicalName,
@@ -2981,8 +3014,8 @@ $templates
                        'wgArticleId' => $pageID,
                        'wgIsArticle' => $this->isArticle(),
                        'wgAction' => Action::getActionName( $this->getContext() ),
-                       'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(),
-                       'wgUserGroups' => $this->getUser()->getEffectiveGroups(),
+                       'wgUserName' => $user->isAnon() ? null : $user->getName(),
+                       'wgUserGroups' => $user->getEffectiveGroups(),
                        'wgCategories' => $this->getCategories(),
                        'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
                        'wgPageContentLanguage' => $lang->getCode(),
@@ -2993,6 +3026,12 @@ $templates
                        'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
                        'wgRelevantPageName' => $relevantTitle->getPrefixedDBKey(),
                );
+               if ( $user->isLoggedIn() ) {
+                       $vars['wgUserId'] = $user->getId();
+                       $vars['wgUserEditCount'] = $user->getEditCount();
+                       $userReg = wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
+                       $vars['wgUserRegistration'] = $userReg !== null ? ( $userReg * 1000 ) : null;
+               }
                if ( $wgContLang->hasVariants() ) {
                        $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
                }
@@ -3066,7 +3105,7 @@ $templates
                                        'http-equiv' => 'Content-Type',
                                        'content' => "$wgMimeType; charset=UTF-8"
                                ) );
-                               $tags['meta-content-style-type'] = Html::element( 'meta', array(  // bug 15835
+                               $tags['meta-content-style-type'] = Html::element( 'meta', array( // bug 15835
                                        'http-equiv' => 'Content-Style-Type',
                                        'content' => 'text/css'
                                ) );
@@ -3095,7 +3134,7 @@ $templates
                        );
                        $tags['meta-keywords'] = Html::element( 'meta', array(
                                'name' => 'keywords',
-                               'content' =>  preg_replace(
+                               'content' => preg_replace(
                                        array_keys( $strip ),
                                        array_values( $strip ),
                                        implode( ',', $this->mKeywords )
@@ -3182,7 +3221,6 @@ $templates
                        ) );
                }
 
-
                # Language variants
                if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks ) {
                        $lang = $this->getTitle()->getPageLanguage();
@@ -3629,7 +3667,7 @@ $templates
                                                '1.20'
                                        );
                                }
-                       }  else {
+                       } else {
                                $args = array();
                                $name = $spec;
                        }