Fixed some doxygen warnings
[lhc/web/wiklou.git] / includes / OutputPage.php
index 9722be8..343a352 100644 (file)
@@ -9,7 +9,15 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class OutputPage {
        var $mMetatags = array(), $mKeywords = array(), $mLinktags = array();
        var $mExtStyles = array();
-       var $mPagetitle = '', $mBodytext = '', $mDebugtext = '';
+       var $mPagetitle = '', $mBodytext = '';
+
+       /**
+        * Holds the debug lines that will be outputted as comments in page source if
+        * $wgDebugComments is enabled. See also $wgShowDebug.
+        * TODO: make a getter method for this
+        */
+       public $mDebugtext = '';
+
        var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false;
        var $mSubtitle = '', $mRedirect = '', $mStatusCode;
        var $mLastModified = '', $mETag = false;
@@ -187,6 +195,7 @@ class OutputPage {
         */
        public function addScriptFile( $file, $version = null ) {
                global $wgStylePath, $wgStyleVersion;
+               // See if $file parameter is an absolute URL or begins with a slash
                if( substr( $file, 0, 1 ) == '/' || preg_match( '#^[a-z]*://#i', $file ) ) {
                        $path = $file;
                } else {
@@ -509,7 +518,7 @@ class OutputPage {
                if ( $this->mTitle instanceof Title ) {
                        return $this->mTitle;
                } else {
-                       wfDebug( __METHOD__ . ' called and $mTitle is null. Return $wgTitle for sanity' );
+                       wfDebug( __METHOD__ . " called and \$mTitle is null. Return \$wgTitle for sanity\n" );
                        global $wgTitle;
                        return $wgTitle;
                }
@@ -768,7 +777,7 @@ class OutputPage {
                $pageTable = $dbr->tableName( 'page' );
                $where = $lb->constructSet( 'page', $dbr );
                $propsTable = $dbr->tableName( 'page_props' );
-               $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, pp_value
+               $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, page_latest, pp_value
                        FROM $pageTable LEFT JOIN $propsTable ON pp_propname='hiddencat' AND pp_page=page_id WHERE $where";
                $res = $dbr->query( $sql, __METHOD__ );
 
@@ -1053,7 +1062,7 @@ class OutputPage {
                        $popts, true, true, $this->mRevisionId
                );
                $popts->setTidy( false );
-               if ( $cache && $article && !$parserOutput->isCacheable() ) {
+               if ( $cache && $article && $parserOutput->isCacheable() ) {
                        $parserCache = ParserCache::singleton();
                        $parserCache->save( $parserOutput, $article, $popts );
                }
@@ -1267,7 +1276,7 @@ class OutputPage {
                $cvCookies = $this->getCacheVaryCookies();
                foreach ( $cvCookies as $cookieName ) {
                        # Check for a simple string match, like the way squid does it
-                       if ( strpos( $cookieHeader, $cookieName ) ) {
+                       if ( strpos( $cookieHeader, $cookieName ) !== false ) {
                                wfDebug( __METHOD__ . ": found $cookieName\n" );
                                return true;
                        }
@@ -1792,20 +1801,6 @@ class OutputPage {
                $this->returnToMain();
        }
 
-       /**
-        * @deprecated use permissionRequired()
-        */
-       public function sysopRequired() {
-               throw new MWException( "Call to deprecated OutputPage::sysopRequired() method\n" );
-       }
-
-       /**
-        * @deprecated use permissionRequired()
-        */
-       public function developerRequired() {
-               throw new MWException( "Call to deprecated OutputPage::developerRequired() method\n" );
-       }
-
        /**
         * Produce the stock "please login to use the wiki" page
         */
@@ -1854,7 +1849,6 @@ class OutputPage {
                if ( $action == null ) {
                        $text = wfMsgNoTrans( 'permissionserrorstext', count( $errors ) ) . "\n\n";
                } else {
-                       global $wgLang;
                        $action_desc = wfMsgNoTrans( "action-$action" );
                        $text = wfMsgNoTrans(
                                'permissionserrorstext-withaction',
@@ -1919,16 +1913,7 @@ class OutputPage {
                        if( $source ) {
                                $this->setPageTitle( wfMsg( 'viewsource' ) );
                                $this->setSubtitle(
-                                       wfMsg(
-                                               'viewsourcefor',
-                                               $skin->link(
-                                                       $this->getTitle(),
-                                                       null,
-                                                       array(),
-                                                       array(),
-                                                       array( 'known', 'noclasses' )
-                                               )
-                                       )
+                                       wfMsg( 'viewsourcefor', $skin->linkKnown( $this->getTitle() ) )
                                );
                        } else {
                                $this->setPageTitle( wfMsg( 'badaccess' ) );
@@ -1971,6 +1956,29 @@ class OutputPage {
                }
        }
 
+       /**
+        * Adds JS-based password security checker
+        * @param $passwordId String ID of input box containing password
+        * @param $retypeId String ID of input box containing retyped password
+        * @return none
+        */
+       public function addPasswordSecurity( $passwordId, $retypeId ) {
+               $this->includeJQuery();
+               $data = array(
+                       'password' => '#' . $passwordId,
+                       'retype' => '#' . $retypeId,
+                       'messages' => array(),
+               );
+               foreach ( array( 'password-strength', 'password-strength-bad', 'password-strength-mediocre',
+                               'password-strength-acceptable', 'password-strength-good', 'password-retype', 'password-retype-mismatch'
+                       ) as $message ) {
+                       $data['messages'][$message] = wfMsg( $message );
+               }
+               $this->addScript( Html::inlineScript( 'var passwordSecurity=' . FormatJson::encode( $data ) ) );
+               $this->addScriptFile( 'password.js' );
+               $this->addStyle( 'common/password.css' );
+       }
+
        /** @deprecated */
        public function errorpage( $title, $msg ) {
                wfDeprecated( __METHOD__ );
@@ -2105,8 +2113,8 @@ class OutputPage {
         * @return String: The doctype, opening <html>, and head element.
         */
        public function headElement( Skin $sk, $includeStyle = true ) {
-               global $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
-               global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5;
+               global $wgOutputEncoding, $wgMimeType;
+               global $wgUseTrackbacks, $wgHtml5;
                global $wgUser, $wgRequest, $wgLang;
 
                if ( $sk->commonPrintStylesheet() ) {
@@ -2114,9 +2122,7 @@ class OutputPage {
                }
                $sk->setupUserCss( $this );
 
-               $dir = $wgContLang->getDir();
-               $htmlAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $dir );
-               $ret = Html::htmlHeader( $htmlAttribs );
+               $ret = Html::htmlHeader( array( 'lang' => wfUILang()->getCode() ) );
 
                if ( $this->getHTMLTitle() == '' ) {
                        $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) );
@@ -2171,6 +2177,7 @@ class OutputPage {
                }
 
                # Class bloat
+               $dir = wfUILang()->getDir();
                $bodyAttrs['class'] = "mediawiki $dir";
 
                if ( $wgLang->capitalizeAllNouns() ) {
@@ -2233,9 +2240,9 @@ class OutputPage {
                                                NS_USER,
                                                $userpage->getDBkey() . '/' . $name . '.js'
                                        );
-                                       if ( $scriptpage && $scriptpage->exists() ) {
+                                       if ( $scriptpage && $scriptpage->exists() && ( $scriptpage->getLength() > 0 ) ) {
                                                $userjs = $scriptpage->getLocalURL( 'action=raw&ctype=' . $wgJsMimeType );
-                                               $this->addScriptFile( $userjs );
+                                               $this->addScriptFile( $userjs, $scriptpage->getLatestRevID() );
                                        }
                                }
                        }
@@ -2442,8 +2449,7 @@ class OutputPage {
         */
        protected function styleLink( $style, $options ) {
                if( isset( $options['dir'] ) ) {
-                       global $wgContLang;
-                       $siteDir = $wgContLang->getDir();
+                       $siteDir = wfUILang()->getDir();
                        if( $siteDir != $options['dir'] ) {
                                return '';
                        }