(bug 7098) Add an option to disable/enable sending of HTTP ETag headers,
[lhc/web/wiklou.git] / includes / Title.php
index 535b076..6f740dc 100644 (file)
@@ -108,7 +108,7 @@ class Title {
         * @static
         * @access public
         */
-       function newFromText( $text, $defaultNamespace = NS_MAIN ) {
+       public static function newFromText( $text, $defaultNamespace = NS_MAIN ) {
                $fname = 'Title::newFromText';
 
                if( is_object( $text ) ) {
@@ -132,7 +132,7 @@ class Title {
                 */
                $filteredText = Sanitizer::decodeCharReferences( $text );
 
-               $t =& new Title();
+               $t = new Title();
                $t->mDbkeyform = str_replace( ' ', '_', $filteredText );
                $t->mDefaultNamespace = $defaultNamespace;
 
@@ -233,8 +233,8 @@ class Title {
         * @static
         * @access public
         */
-       function &makeTitle( $ns, $title ) {
-               $t =& new Title();
+       public static function &makeTitle( $ns, $title ) {
+               $t = new Title();
                $t->mInterwiki = '';
                $t->mFragment = '';
                $t->mNamespace = intval( $ns );
@@ -246,7 +246,7 @@ class Title {
        }
 
        /**
-        * Create a new Title frrom a namespace index and a DB key.
+        * Create a new Title from a namespace index and a DB key.
         * The parameters will be checked for validity, which is a bit slower
         * than makeTitle() but safer for user-provided data.
         *
@@ -256,7 +256,7 @@ class Title {
         * @static
         * @access public
         */
-       function makeTitleSafe( $ns, $title ) {
+       public static function makeTitleSafe( $ns, $title ) {
                $t = new Title();
                $t->mDbkeyform = Title::makeName( $ns, $title );
                if( $t->secureAndSplit() ) {
@@ -273,7 +273,7 @@ class Title {
         * @return Title the new object
         * @access public
         */
-       function newMainPage() {
+       public static function newMainPage() {
                return Title::newFromText( wfMsgForContent( 'mainpage' ) );
        }
 
@@ -285,10 +285,10 @@ class Title {
         * @static
         * @access public
         */
-       function newFromRedirect( $text ) {
-               global $wgMwRedir;
+       public static function newFromRedirect( $text ) {
+               $mwRedir = MagicWord::get( 'redirect' );
                $rt = NULL;
-               if ( $wgMwRedir->matchStart( $text ) ) {
+               if ( $mwRedir->matchStart( $text ) ) {
                        if ( preg_match( '/\[{2}(.*?)(?:\||\]{2})/', $text, $m ) ) {
                                # categories are escaped using : for example one can enter:
                                # #REDIRECT [[:Category:Music]]. Need to remove it.
@@ -336,7 +336,7 @@ class Title {
         * @static
         * @access public
         */
-       function legalChars() {
+       public static function legalChars() {
                global $wgLegalTitleChars;
                return $wgLegalTitleChars;
        }
@@ -376,7 +376,7 @@ class Title {
         * @param string $title the DB key form the title
         * @return string the prefixed form of the title
         */
-       /* static */ function makeName( $ns, $title ) {
+       public static function makeName( $ns, $title ) {
                global $wgContLang;
 
                $n = $wgContLang->getNsText( $ns );
@@ -1075,6 +1075,7 @@ class Title {
                if( $action == 'create' ) {
                        if( (  $this->isTalkPage() && !$wgUser->isAllowed( 'createtalk' ) ) ||
                                ( !$this->isTalkPage() && !$wgUser->isAllowed( 'createpage' ) ) ) {
+                               wfProfileOut( $fname );
                                return false;
                        }
                }
@@ -1187,8 +1188,12 @@ class Title {
         * Check that the corresponding skin exists
         */
        function isValidCssJsSubpage() {
-               global $wgValidSkinNames;
-               return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), $wgValidSkinNames ) );
+               if ( $this->isCssJsSubpage() ) {
+                       $skinNames = Skin::getSkinNames();
+                       return array_key_exists( $this->getSkinFromCssJsSubpage(), $skinNames );
+               } else {
+                       return false;
+               }
        }
        /**
         * Trim down a .css or .js subpage title to get the corresponding skin name
@@ -1854,7 +1859,7 @@ class Title {
         * @private
         */
        function moveOverExistingRedirect( &$nt, $reason = '' ) {
-               global $wgUseSquid, $wgMwRedir;
+               global $wgUseSquid;
                $fname = 'Title::moveOverExistingRedirect';
                $comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
 
@@ -1893,7 +1898,8 @@ class Title {
                $linkCache->clearLink( $nt->getPrefixedDBkey() );
 
                # Recreate the redirect, this time in the other direction.
-               $redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
+               $mwRedir = MagicWord::get( 'redirect' );
+               $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
                $redirectArticle = new Article( $this );
                $newid = $redirectArticle->insertOn( $dbw );
                $redirectRevision = new Revision( array(
@@ -1933,7 +1939,6 @@ class Title {
         */
        function moveToNewTitle( &$nt, $reason = '' ) {
                global $wgUseSquid;
-               global $wgMwRedir;
                $fname = 'MovePageForm::moveToNewTitle';
                $comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
                if ( $reason ) {
@@ -1966,7 +1971,8 @@ class Title {
                $linkCache->clearLink( $nt->getPrefixedDBkey() );
 
                # Insert redirect
-               $redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
+               $mwRedir = MagicWord::get( 'redirect' );
+               $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
                $redirectArticle = new Article( $this );
                $newid = $redirectArticle->insertOn( $dbw );
                $redirectRevision = new Revision( array(