diff options
| author | spiderr <spider@viovio.com> | 2012-07-19 14:43:41 -0400 |
|---|---|---|
| committer | spiderr <spider@viovio.com> | 2012-07-19 14:43:41 -0400 |
| commit | 3f3a8974b942fb68c7941e5c5f8db70231977906 (patch) | |
| tree | c280a3a2cb963b4a1c8658d16c19430362e5d055 /plugins | |
| parent | 4b8f9526bf923f7f14af14873ec06279b741908c (diff) | |
| download | liberty-3f3a8974b942fb68c7941e5c5f8db70231977906.tar.gz liberty-3f3a8974b942fb68c7941e5c5f8db70231977906.tar.bz2 liberty-3f3a8974b942fb68c7941e5c5f8db70231977906.zip | |
rework upload files to have an option to save as original.ext, file_name is still recorded in the database properly. rework PDF thumbnailing.
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/mime.default.php | 19 | ||||
| -rw-r--r-- | plugins/processor.magickwand.php | 18 | ||||
| -rw-r--r-- | plugins/storage.bitfile.php | 2 |
3 files changed, 12 insertions, 27 deletions
diff --git a/plugins/mime.default.php b/plugins/mime.default.php index dc75cf7..1fc09f2 100644 --- a/plugins/mime.default.php +++ b/plugins/mime.default.php @@ -145,7 +145,7 @@ if( !function_exists( 'mime_default_update' )) { if( !empty( $pStoreRow['dest_branch'] ) && !empty( $pStoreRow['file_name'] ) ) { // First we remove the old file $path = STORAGE_PKG_PATH.$pStoreRow['dest_branch']; - $file = $path.$pStoreRow['file_name']; + $file = $path.liberty_mime_get_default_file_name( $pStoreRow['file_name'], $pStoreRow['mime_type'] ); if(( $nuke = LibertyMime::validateStoragePath( $path )) && is_dir( $nuke )) { if( !empty( $pStoreRow['unlink_dir'] )) { @unlink_r( $path ); @@ -251,8 +251,13 @@ if( !function_exists( 'mime_default_load' )) { $storageName = basename( $row['file_name'] ); // compatibility with _FILES hash $row['name'] = $storageName; - $row['type'] = $row['mime_type']; - $storageBranch = liberty_mime_get_storage_branch( array( 'sub_dir' => $row['attachment_id'], 'user_id' =>$row['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name( $row ) ) ).$storageName; + $defaultFileName = liberty_mime_get_default_file_name( $row['file_name'], $row['mime_type'] ); + $storageBranchPath = liberty_mime_get_storage_branch( array( 'sub_dir' => $row['attachment_id'], 'user_id' =>$row['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name( $row ) ) ); + $storageBranch = $storageBranchPath.$defaultFileName; + if( !file_exists( STORAGE_PKG_PATH.$storageBranch ) ) { + $storageBranch = liberty_mime_get_storage_branch( array( 'sub_dir' => $row['attachment_id'], 'user_id' =>$row['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name( $row ) ) ).$storageName; + } + // this will fetch the correct thumbnails $thumbHash['source_file'] = STORAGE_PKG_PATH.$storageBranch; $row['source_file'] = STORAGE_PKG_PATH.$storageBranch; @@ -281,14 +286,11 @@ if( !function_exists( 'mime_default_load' )) { // make sure to check for these when you use them. frequently the original might not be available // e.g.: video files are large and the original might be deleted after conversion if( is_file( STORAGE_PKG_PATH.$storageBranch )) { + $ret['mime_type'] = $row['mime_type']; $ret['source_file'] = STORAGE_PKG_PATH.$storageBranch; $ret['source_url'] = STORAGE_PKG_URL.$storageBranch; $ret['last_modified'] = filemtime( $ret['source_file'] ); - if( $gBitSystem->isFeatureActive( "pretty_urls" ) || $gBitSystem->isFeatureActive( "pretty_urls_extended" )) { - $ret['download_url'] = LIBERTY_PKG_URL."download/file/".$row['attachment_id']; - } else { - $ret['download_url'] = LIBERTY_PKG_URL."download_file.php?attachment_id=".$row['attachment_id']; - } + $ret['download_url'] = LibertyMime::getAttachmentDownloadUrl( $row['attachment_id'] ); } // add a description of how to insert this file into a wiki page @@ -323,7 +325,6 @@ if( !function_exists( 'mime_default_download' )) { $dl = new HTTP_Download(); $dl->setLastModified( $pFileHash['last_modified'] ); $dl->setFile( $pFileHash['source_file'] ); - //$dl->setContentDisposition( HTTP_DOWNLOAD_INLINE, $pFileHash['file_name'] ); $dl->setContentDisposition( HTTP_DOWNLOAD_ATTACHMENT, $pFileHash['file_name'] ); $dl->setContentType( $pFileHash['mime_type'] ); $res = $dl->send(); diff --git a/plugins/processor.magickwand.php b/plugins/processor.magickwand.php index 4c06fe9..8b8cac0 100644 --- a/plugins/processor.magickwand.php +++ b/plugins/processor.magickwand.php @@ -22,20 +22,8 @@ function liberty_magickwand_resize_image( &$pFileHash ) { $magickWand = NewMagickWand(); $pFileHash['error'] = NULL; $ret = NULL; - $isPdf = preg_match( '/pdf/i', $pFileHash['type'] ); + if( !empty( $pFileHash['source_file'] ) && is_file( $pFileHash['source_file'] ) && filesize( $pFileHash['source_file'] ) ) { - // This has to come BEFORE the MagickReadImage - if( $isPdf ) { - // has a customer pdf rasterization function been defined? - if( function_exists( 'liberty_rasterize_pdf' ) && $rasteredFile = liberty_rasterize_pdf( $pFileHash['source_file'] ) ) { - $pFileHash['source_file'] = $rasteredFile; - $isPdf = FALSE; - } else { - MagickSetImageUnits( $magickWand, MW_PixelsPerInchResolution ); - $rez = empty( $pFileHash['max_width'] ) || $pFileHash['max_width'] == MAX_THUMBNAIL_DIMENSION ? 250 : 72; - MagickSetResolution( $magickWand, 300, 300 ); - } - } if( $error = liberty_magickwand_check_error( MagickReadImage( $magickWand, $pFileHash['source_file'] ), $magickWand ) ) { // $pFileHash['error'] = $error; $destFile = liberty_process_generic( $pFileHash, FALSE ); @@ -48,10 +36,6 @@ function liberty_magickwand_resize_image( &$pFileHash ) { MagickSetImageColorspace( $magickWand, MW_RGBColorspace ); $pFileHash['colorspace_conversion'] = TRUE; } - if( $isPdf ) { - MagickResetIterator( $magickWand ); - MagickNextImage( $magickWand ); - } MagickSetImageCompressionQuality( $magickWand, $gBitSystem->getConfig( 'liberty_thumbnail_quality', 85 )); $iwidth = round( MagickGetImageWidth( $magickWand ) ); $iheight = round( MagickGetImageHeight( $magickWand ) ); diff --git a/plugins/storage.bitfile.php b/plugins/storage.bitfile.php index cee4ab8..06899a9 100644 --- a/plugins/storage.bitfile.php +++ b/plugins/storage.bitfile.php @@ -90,7 +90,7 @@ function bit_files_load( $pRow ) { // this fuction broken, will fix soon - spiderr // I think its fixed now - no promises though! - drewslater global $gBitSystem, $gLibertySystem; - $ret = NULL; + $ret = array(); if( !empty( $pRow['foreign_id'] ) && is_numeric( $pRow['foreign_id'] )) { $query = " SELECT * |
