Committing Evan's patches (with some modifications), reintroducing class=internal...
[lhc/web/wiklou.git] / includes / Title.php
index db4e112..7396b6b 100644 (file)
@@ -15,7 +15,6 @@ class Title {
                $this->mNamespace = 0;
                $this->mRestrictionsLoaded = false;
                $this->mRestrictions = array();
-               $this->mPrefixedText = false;
        }
 
        # Static factory methods
@@ -28,7 +27,6 @@ class Title {
                        return $t;
                else
                        return NULL;
-               return $t;
        }
 
        function newFromText( $text )
@@ -58,7 +56,7 @@ class Title {
 
        function newFromURL( $url )
        {
-               global $wgLang, $wgServer, $HTTP_SERVER_VARS;
+               global $wgLang, $wgServer;
                
                $t = new Title();
                $s = urldecode( $url ); # This is technically wrong, as anything
@@ -68,7 +66,10 @@ class Title {
                
                # For links that came from outside, check for alternate/legacy
                # character encoding.
-               if( strncmp($wgServer, $HTTP_SERVER_VARS["HTTP_REFERER"], strlen( $wgServer ) ) )
+               wfDebug( "Refer: {$_SERVER['HTTP_REFERER']}\n" );
+               wfDebug( "Servr: $wgServer\n" );
+               if( empty( $_SERVER["HTTP_REFERER"] ) ||
+                       strncmp($wgServer, $_SERVER["HTTP_REFERER"], strlen( $wgServer ) ) )
                        $s = $wgLang->checkTitleEncoding( $s );
                
                $t->mDbkeyform = str_replace( " ", "_", $s );
@@ -189,7 +190,8 @@ class Title {
 
        function getPrefixedText()
        {
-               if ( $this->mPrefixedText === false ) {
+          # TEST THIS @@@
+               if ( empty( $this->mPrefixedText ) ) {
                        $s = $this->prefix( $this->mTextform );
                        $s = str_replace( "_", " ", $s );
                        $this->mPrefixedText = $s;
@@ -244,7 +246,7 @@ class Title {
        {
                return wfEscapeHTML( $this->getPrefixedText() );
        }
-
+       
        function isExternal() { return ( "" != $this->mInterwiki ); }
 
        function isProtected()
@@ -337,6 +339,14 @@ class Title {
                $this->mRestrictionsLoaded = false;
                $this->mRestrictions = array();
        }
+       
+       function invalidateCache() {
+               $now = wfTimestampNow();
+               $ns = $this->getNamespace();
+               $ti = wfStrencode( $this->getDBkey() );
+               $sql = "UPDATE cur SET cur_touched='$now' WHERE cur_namespace=$ns AND cur_title='$ti'";
+               return wfQuery( $sql, "Title::invalidateCache" );
+       }
 
        /* private */ function prefix( $name )
        {
@@ -399,7 +409,7 @@ class Title {
                if ( ":" == $t{0} ) {
                        $r = substr( $t, 1 );
                } else {
-                       if ( preg_match( "/^((?:i|x|[a-z]{2,3})(?:-[a-z0-9]+)?|[A-Za-z0-9_\\x80-\\xff]+):(.*)$/", $t, $m ) ) {
+                       if ( preg_match( "/^((?:i|x|[a-z]{2,3})(?:-[a-z0-9]+)?|[A-Za-z0-9_\\x80-\\xff]+):_*(.*)$/", $t, $m ) ) {
                                #$p = strtolower( $m[1] );
                                $p = $m[1];
                                if ( $ns = $wgLang->getNsIndex( strtolower( $p ) )) {
@@ -443,5 +453,13 @@ class Title {
                wfProfileOut( $fname );
                return true;
        }
+       
+       function getTalkPage() {
+               return Title::makeTitle( Namespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
+       }
+       
+       function getSubjectPage() {
+               return Title::makeTitle( Namespace::getSubject( $this->getNamespace() ), $this->getDBkey() );
+       }
 }
 ?>