remove unused message
[lhc/web/wiklou.git] / includes / ImageFunctions.php
index c031d7e..a66b4d7 100644 (file)
@@ -2,7 +2,6 @@
 \r
 /**\r
  * Returns the image directory of an image\r
- * If the directory does not exist, it is created.\r
  * The result is an absolute path.\r
  *\r
  * This function is called from thumb.php before Setup.php is included\r
@@ -16,19 +15,13 @@ function wfImageDir( $fname ) {
        if (!$wgHashedUploadDirectory) { return $wgUploadDirectory; }\r
 \r
        $hash = md5( $fname );\r
-       $oldumask = umask(0);\r
-       $dest = $wgUploadDirectory . '/' . $hash{0};\r
-       if ( ! is_dir( $dest ) ) { mkdir( $dest, 0777 ); }\r
-       $dest .= '/' . substr( $hash, 0, 2 );\r
-       if ( ! is_dir( $dest ) ) { mkdir( $dest, 0777 ); }\r
+       $dest = $wgUploadDirectory . '/' . $hash{0} . '/' . substr( $hash, 0, 2 );\r
 \r
-       umask( $oldumask );\r
        return $dest;\r
 }\r
 \r
 /**\r
  * Returns the image directory of an image's thubnail\r
- * If the directory does not exist, it is created.\r
  * The result is an absolute path.\r
  *\r
  * This function is called from thumb.php before Setup.php is included\r
@@ -41,22 +34,6 @@ function wfImageThumbDir( $fname, $shared = false ) {
        $base = wfImageArchiveDir( $fname, 'thumb', $shared );\r
        if ( Image::isHashed( $shared ) ) {\r
                $dir =  "$base/$fname";\r
-\r
-               if ( !is_dir( $base ) ) {\r
-                       $oldumask = umask(0);\r
-                       @mkdir( $base, 0777 );\r
-                       umask( $oldumask );\r
-               }\r
-\r
-               if ( ! is_dir( $dir ) ) {\r
-                       if ( is_file( $dir ) ) {\r
-                               // Old thumbnail in the way of directory creation, kill it\r
-                               unlink( $dir );\r
-                       }\r
-                       $oldumask = umask(0);\r
-                       @mkdir( $dir, 0777 );\r
-                       umask( $oldumask );\r
-               }\r
        } else {\r
                $dir = $base;\r
        }\r
@@ -73,7 +50,6 @@ function wfDeprecatedThumbDir( $thumbName , $subdir='thumb', $shared=false) {
 \r
 /**\r
  * Returns the image directory of an image's old version\r
- * If the directory does not exist, it is created.\r
  * The result is an absolute path.\r
  *\r
  * This function is called from thumb.php before Setup.php is included\r
@@ -90,22 +66,8 @@ function wfImageArchiveDir( $fname , $subdir='archive', $shared=false ) {
        $hashdir = $shared ? $wgHashedSharedUploadDirectory : $wgHashedUploadDirectory;\r
        if (!$hashdir) { return $dir.'/'.$subdir; }\r
        $hash = md5( $fname );\r
-       $oldumask = umask(0);\r
-\r
-       # Suppress warning messages here; if the file itself can't\r
-       # be written we'll worry about it then.\r
-       wfSuppressWarnings();\r
-\r
-       $archive = $dir.'/'.$subdir;\r
-       if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }\r
-       $archive .= '/' . $hash{0};\r
-       if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }\r
-       $archive .= '/' . substr( $hash, 0, 2 );\r
-       if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }\r
-\r
-       wfRestoreWarnings();\r
-       umask( $oldumask );\r
-       return $archive;\r
+\r
+       return $dir.'/'.$subdir.'/'.$hash[0].'/'.substr( $hash, 0, 2 );\r
 }\r
 \r
 \r
@@ -217,20 +179,27 @@ function wfGetSVGsize( $filename ) {
  */\r
 function wfIsBadImage( $name ) {\r
        static $titleList = false;\r
-       \r
-       if( !$titleList ) {\r
-               # Build the list now\r
-               $titleList = array();\r
-               $lines = explode( "\n", wfMsgForContent( 'bad_image_list' ) );\r
-               foreach( $lines as $line ) {\r
-                       if( preg_match( '/^\*\s*\[\[:?(.*?)\]\]/i', $line, $matches ) ) {\r
-                               $title = Title::newFromText( $matches[1] );\r
-                               if( is_object( $title ) && $title->getNamespace() == NS_IMAGE )\r
-                                       $titleList[ $title->getDBkey() ] = true;\r
+       wfProfileIn( __METHOD__ );\r
+       $bad = false;\r
+       if( wfRunHooks( 'BadImage', array( $name, &$bad ) ) ) {\r
+               if( !$titleList ) {\r
+                       # Build the list now\r
+                       $titleList = array();\r
+                       $lines = explode( "\n", wfMsgForContent( 'bad_image_list' ) );\r
+                       foreach( $lines as $line ) {\r
+                               if( preg_match( '/^\*\s*\[\[:?(.*?)\]\]/i', $line, $matches ) ) {\r
+                                       $title = Title::newFromText( $matches[1] );\r
+                                       if( is_object( $title ) && $title->getNamespace() == NS_IMAGE )\r
+                                               $titleList[ $title->getDBkey() ] = true;\r
+                               }\r
                        }\r
                }\r
+               wfProfileOut( __METHOD__ );\r
+               return array_key_exists( $name, $titleList );\r
+       } else {\r
+               wfProfileOut( __METHOD__ );\r
+               return $bad;\r
        }\r
-       return array_key_exists( $name, $titleList );\r
 }\r
 \r
 /**\r