fix some spacing
[lhc/web/wiklou.git] / includes / filerepo / FileRepo.php
index 4cc4fde..03d6ea9 100644 (file)
@@ -120,7 +120,7 @@ class FileRepo {
                $this->isPrivate = !empty( $info['isPrivate'] );
                // Give defaults for the basic zones...
                $this->zones = isset( $info['zones'] ) ? $info['zones'] : array();
-               foreach ( array( 'public', 'thumb', 'temp', 'deleted' ) as $zone ) {
+               foreach ( array( 'public', 'thumb', 'transcoded', 'temp', 'deleted' ) as $zone ) {
                        if ( !isset( $this->zones[$zone]['container'] ) ) {
                                $this->zones[$zone]['container'] = "{$this->name}-{$zone}";
                        }
@@ -204,7 +204,7 @@ class FileRepo {
         * @return String or false
         */
        public function getZoneUrl( $zone, $ext = null ) {
-               if ( in_array( $zone, array( 'public', 'temp', 'thumb' ) ) ) { // standard public zones
+               if ( in_array( $zone, array( 'public', 'temp', 'thumb', 'transcoded' ) ) ) { // standard public zones
                        if ( $ext !== null && isset( $this->zones[$zone]['urlsByExt'][$ext] ) ) {
                                return $this->zones[$zone]['urlsByExt'][$ext]; // custom URL for extension/zone
                        } elseif ( isset( $this->zones[$zone]['url'] ) ) {
@@ -220,6 +220,8 @@ class FileRepo {
                                return false; // no public URL
                        case 'thumb':
                                return $this->thumbUrl;
+                       case 'transcoded':
+                               return "{$this->url}/transcoded";
                        default:
                                return false;
                }
@@ -240,7 +242,7 @@ class FileRepo {
         */
        public function getZoneHandlerUrl( $zone ) {
                if ( isset( $this->zones[$zone]['handlerUrl'] )
-                       && in_array( $zone, array( 'public', 'temp', 'thumb' ) ) )
+                       && in_array( $zone, array( 'public', 'temp', 'thumb', 'transcoded' ) ) )
                {
                        return $this->zones[$zone]['handlerUrl'];
                }
@@ -488,6 +490,18 @@ class FileRepo {
                return $result;
        }
 
+       /**
+        * Return an array of files where the name starts with $prefix.
+        *
+        * STUB
+        * @param string $prefix The prefix to search for
+        * @param int $limit The maximum amount of files to return
+        * @return array
+        */
+       public function findFilesByPrefix( $prefix, $limit ) {
+               return array();
+       }
+
        /**
         * Get the public root URL of the repository
         *
@@ -761,7 +775,7 @@ class FileRepo {
                                throw new MWException( 'Validation error in $dstRel' );
                        }
                        $dstPath = "$root/$dstRel";
-                       $dstDir  = dirname( $dstPath );
+                       $dstDir = dirname( $dstPath );
                        // Create destination directories for this triplet
                        if ( !$this->initDirectory( $dstDir )->isOK() ) {
                                return $this->newFatal( 'directorycreateerror', $dstDir );
@@ -951,11 +965,11 @@ class FileRepo {
        public function storeTemp( $originalName, $srcPath ) {
                $this->assertWritableRepo(); // fail out if read-only
 
-               $date       = gmdate( "YmdHis" );
-               $hashPath   = $this->getHashPath( $originalName );
-               $dstRel     = "{$hashPath}{$date}!{$originalName}";
-               $dstUrlRel  = $hashPath . $date . '!' . rawurlencode( $originalName );
-               $virtualUrl = $this->getVirtualUrl( 'temp' )  . '/' . $dstUrlRel;
+               $date = gmdate( "YmdHis" );
+               $hashPath = $this->getHashPath( $originalName );
+               $dstRel = "{$hashPath}{$date}!{$originalName}";
+               $dstUrlRel = $hashPath . $date . '!' . rawurlencode( $originalName );
+               $virtualUrl = $this->getVirtualUrl( 'temp' ) . '/' . $dstUrlRel;
 
                $result = $this->quickImport( $srcPath, $virtualUrl );
                $result->value = $virtualUrl;
@@ -1105,7 +1119,7 @@ class FileRepo {
                        if ( !$this->initDirectory( $dstDir )->isOK() ) {
                                return $this->newFatal( 'directorycreateerror', $dstDir );
                        }
-                       if ( !$this->initDirectory($archiveDir )->isOK() ) {
+                       if ( !$this->initDirectory( $archiveDir )->isOK() ) {
                                return $this->newFatal( 'directorycreateerror', $archiveDir );
                        }
 
@@ -1608,7 +1622,7 @@ class FileRepo {
         */
        public function nameForThumb( $name ) {
                if ( strlen( $name ) > $this->abbrvThreshold ) {
-                       $ext  = FileBackend::extensionFromPath( $name );
+                       $ext = FileBackend::extensionFromPath( $name );
                        $name = ( $ext == '' ) ? 'thumbnail' : "thumbnail.$ext";
                }
                return $name;
@@ -1670,10 +1684,17 @@ class FileRepo {
                                        'directory' => ( $this->zones['thumb']['directory'] == '' )
                                                ? 'temp'
                                                : $this->zones['thumb']['directory'] . '/temp'
+                               ),
+                               'transcoded'  => array(
+                                       'container' => $this->zones['transcoded']['container'],
+                                       'directory' => ( $this->zones['transcoded']['directory'] == '' )
+                                               ? 'temp'
+                                               : $this->zones['transcoded']['directory'] . '/temp'
                                )
                        ),
                        'url'        => $this->getZoneUrl( 'temp' ),
                        'thumbUrl'   => $this->getZoneUrl( 'thumb' ) . '/temp',
+                       'transcodedUrl'   => $this->getZoneUrl( 'transcoded' ) . '/temp',
                        'hashLevels' => $this->hashLevels // performance
                ) );
        }