fix some spacing
[lhc/web/wiklou.git] / includes / OutputPage.php
index 577d610..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
@@ -1564,7 +1597,6 @@ class OutputPage extends ContextSource {
                $this->addHTML( $text );
        }
 
-
        /**
         * Add the output of a QuickTemplate to the output buffer
         *
@@ -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();
                }
@@ -3182,7 +3221,6 @@ $templates
                        ) );
                }
 
-
                # Language variants
                if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks ) {
                        $lang = $this->getTitle()->getPageLanguage();