* (bug 27585) add pagecount to list=filearchive
[lhc/web/wiklou.git] / includes / Title.php
index f289bd4..a48cbae 100644 (file)
@@ -990,8 +990,9 @@ class Title {
         * @return String the URL
         */
        public function getInternalURL( $query = '', $variant = false ) {
-               global $wgInternalServer;
-               $url = $wgInternalServer . $this->getLocalURL( $query, $variant );
+               global $wgInternalServer, $wgServer;
+               $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer;
+               $url = $server . $this->getLocalURL( $query, $variant );
                wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) );
                return $url;
        }
@@ -1954,7 +1955,7 @@ class Title {
         * Is this a *valid* .css or .js subpage of a user page?
         *
         * @return Bool
-        * @deprecated @since 1.17
+        * @deprecated since 1.17
         */
        public function isValidCssJsSubpage() {
                return $this->isCssJsSubpage();
@@ -2987,24 +2988,9 @@ class Title {
 
                // Image-specific checks
                if ( $this->getNamespace() == NS_FILE ) {
-                       if ( $nt->getNamespace() != NS_FILE ) {
-                               $errors[] = array( 'imagenocrossnamespace' );
-                       }
-                       $file = wfLocalFile( $this );
-                       if ( $file->exists() ) {
-                               if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) {
-                                       $errors[] = array( 'imageinvalidfilename' );
-                               }
-                               if ( !File::checkExtensionCompatibility( $file, $nt->getDBkey() ) ) {
-                                       $errors[] = array( 'imagetypemismatch' );
-                               }
-                       }
-                       $destfile = wfLocalFile( $nt );
-                       if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destfile->exists() && wfFindFile( $nt ) ) {
-                               $errors[] = array( 'file-exists-sharedrepo' );
-                       }
+                       $errors = array_merge( $errors, $this->validateFileMoveOperation( $nt ) );
                }
-
+               
                if ( $nt->getNamespace() == NS_FILE && $this->getNamespace() != NS_FILE ) {
                        $errors[] = array( 'nonfile-cannot-move-to-file' );
                }
@@ -3048,6 +3034,38 @@ class Title {
                }
                return $errors;
        }
+       
+       /**
+        * Check if the requested move target is a valid file move target
+        * @param Title $nt Target title
+        * @return array List of errors
+        */
+       protected function validateFileMoveOperation( $nt ) {
+               global $wgUser;
+               
+               $errors = array();
+               
+               if ( $nt->getNamespace() != NS_FILE ) {
+                       $errors[] = array( 'imagenocrossnamespace' );
+               }
+               
+               $file = wfLocalFile( $this );
+               if ( $file->exists() ) {
+                       if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) {
+                               $errors[] = array( 'imageinvalidfilename' );
+                       }
+                       if ( !File::checkExtensionCompatibility( $file, $nt->getDBkey() ) ) {
+                               $errors[] = array( 'imagetypemismatch' );
+                       }
+               }
+               
+               $destFile = wfLocalFile( $nt );
+               if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destfile->exists() && wfFindFile( $nt ) ) {
+                       $errors[] = array( 'file-exists-sharedrepo' );
+               }
+               
+               return $errors;
+       }
 
        /**
         * Move a title to a new location
@@ -4119,6 +4137,10 @@ class Title {
         * @return array applicable restriction types
         */
        public function getRestrictionTypes() {
+               if ( $this->getNamespace() == NS_SPECIAL ) {
+                       return array();
+               }
+
                $types = self::getFilteredRestrictionTypes( $this->exists() );
 
                if ( $this->getNamespace() != NS_FILE ) {
@@ -4145,7 +4167,7 @@ class Title {
                $types = $wgRestrictionTypes;
                if ( $exists ) {
                        # Remove the create restriction for existing titles
-                       $types = array_diff( $types, array( 'create' ) );                       
+                       $types = array_diff( $types, array( 'create' ) );
                } else {
                        # Only the create and upload restrictions apply to non-existing titles
                        $types = array_intersect( $types, array( 'create', 'upload' ) );