summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Fowler <spider@viovio.com>2011-06-26 17:59:08 -0400
committerChristian Fowler <spider@viovio.com>2011-06-26 17:59:08 -0400
commitd921a364f7eba7df08dc54042ee5adc2f957abb0 (patch)
treee16f5d9c2a3b55c64417c148483c1d8400444ec6
parent0fb1681f889704b283d518eca5af2e8ee9063af3 (diff)
downloadfisheye-d921a364f7eba7df08dc54042ee5adc2f957abb0.tar.gz
fisheye-d921a364f7eba7df08dc54042ee5adc2f957abb0.tar.bz2
fisheye-d921a364f7eba7df08dc54042ee5adc2f957abb0.zip
convert liberty_files.storage_path to liberty_files.file_name to remove all hardcoded pathing information. legacy path is supported via basename
-rw-r--r--FisheyeGallery.php9
-rw-r--r--FisheyeImage.php63
-rw-r--r--fisheye_rss.php2
-rw-r--r--templates/center_list_galleries.tpl2
4 files changed, 35 insertions, 41 deletions
diff --git a/FisheyeGallery.php b/FisheyeGallery.php
index 1b3158d..75334b9 100644
--- a/FisheyeGallery.php
+++ b/FisheyeGallery.php
@@ -148,7 +148,7 @@ class FisheyeGallery extends FisheyeBase {
}
if( @$this->verifyId( $pCurrentImageId ) && @$this->verifyId($this->mContentId)) {
// this code sucks but works - XOXO spiderr
- $query = "SELECT fgim.*, fi.`image_id`, lf.`storage_path`
+ $query = "SELECT fgim.*, fi.`image_id`, lf.`file_name`, lf.`user_id`, la.`attachment_id`
FROM `".BIT_DB_PREFIX."fisheye_gallery_image_map` fgim
INNER JOIN `".BIT_DB_PREFIX."fisheye_image` fi ON ( fi.`content_id`=fgim.`item_content_id` )
INNER JOIN `".BIT_DB_PREFIX."liberty_attachments` la ON ( fi.`content_id`=la.`content_id` )
@@ -156,13 +156,15 @@ class FisheyeGallery extends FisheyeBase {
WHERE fgim.`gallery_content_id` = ?
ORDER BY fgim.`item_position`, fi.`content_id` ";
if( $rs = $this->mDb->query($query, array( $this->mContentId ) ) ) {
+ $tempImage = new FisheyeImage();
$rows = $rs->getRows();
for( $i = 0; $i < count( $rows ); $i++ ) {
if( $rows[$i]['image_id'] == $pCurrentImageId ) {
if( $i > 0 ) {
$this->mInfo['previous_image_id'] = $rows[$i-1]['image_id'];
$this->mInfo['previous_image_avatar'] = liberty_fetch_thumbnail_url( array(
- 'storage_path' => $rows[$i-1]['storage_path'],
+ 'file_name' => $rows[$i-1]['file_name'],
+ 'source_file' => $tempImage->getSourceFile( $rows[$i-1] ),
'mime_image' => TRUE,
'size' => 'avatar',
));
@@ -170,7 +172,8 @@ class FisheyeGallery extends FisheyeBase {
if( $i + 1 < count( $rows ) ) {
$this->mInfo['next_image_id'] = $rows[$i+1]['image_id'];
$this->mInfo['next_image_avatar'] = liberty_fetch_thumbnail_url( array(
- 'storage_path' => $rows[$i+1]['storage_path'],
+ 'file_name' => $rows[$i+1]['file_name'],
+ 'source_file' => $tempImage->getSourceFile( $rows[$i+1] ),
'mime_image' => TRUE,
'size' => 'avatar',
));
diff --git a/FisheyeImage.php b/FisheyeImage.php
index 4287c61..aed2e60 100644
--- a/FisheyeImage.php
+++ b/FisheyeImage.php
@@ -351,13 +351,13 @@ class FisheyeImage extends FisheyeBase {
function rotateImage( $pDegrees, $pImmediateRender = FALSE ) {
global $gBitSystem;
- if( !empty( $this->mInfo['storage_path'] ) || $this->load() ) {
+ if( $this->getField( 'file_name' ) || $this->load() ) {
$fileHash['source_file'] = $this->getSourceFile();
$fileHash['dest_base_name'] = preg_replace('/(.+)\..*$/', '$1', basename( $fileHash['source_file'] ) );
$fileHash['type'] = 'image/'.strtolower( substr( $fileHash['source_file'], (strrpos( $fileHash['source_file'], '.' )+1) ) );
$fileHash['size'] = filesize( $fileHash['source_file'] );
$fileHash['dest_path'] = dirname( $this->getSourceFile() ).'/';
- $fileHash['name'] = $this->mInfo['filename'];
+ $fileHash['name'] = $this->getField( 'file_name' );
if( $pDegrees == 'auto' ) {
if( $exifOrientation = $this->getExifField( 'orientation' ) ) {
switch( $exifOrientation ) {
@@ -417,13 +417,13 @@ class FisheyeImage extends FisheyeBase {
*/
function convertColorspace( $pColorSpace ) {
$ret = FALSE;
- if( !empty( $this->mInfo['storage_path'] ) || $this->load() ) {
+ if( $this->getField( 'file_name' ) || $this->load() ) {
$fileHash['source_file'] = $this->getSourceFile();
$fileHash['dest_base_name'] = preg_replace('/(.+)\..*$/', '$1', basename( $fileHash['source_file'] ) );
$fileHash['type'] = 'image/'.strtolower( substr( $fileHash['source_file'], (strrpos( $fileHash['source_file'], '.' )+1) ) );
$fileHash['size'] = filesize( $fileHash['source_file'] );
$fileHash['dest_path'] = dirname( $this->getSourceFile() ).'/';
- $fileHash['name'] = $this->mInfo['filename'];
+ $fileHash['name'] = $this->getField( 'file_name' );
if( $convertFunc = liberty_get_function( 'convert_colorspace' ) ) {
if( $ret = $convertFunc( $fileHash, $pColorSpace ) ) {
liberty_clear_thumbnails( $fileHash );
@@ -439,13 +439,13 @@ class FisheyeImage extends FisheyeBase {
function resizeOriginal( $pResizeOriginal ) {
global $gBitSystem;
- if( !empty( $this->mInfo['storage_path'] ) || $this->load() ) {
+ if( $this->getField( 'file_name' ) || $this->load() ) {
$fileHash['source_file'] = $this->getSourceFile();
$fileHash['dest_base_name'] = preg_replace('/(.+)\..*$/', '$1', basename( $fileHash['source_file'] ) );
$fileHash['type'] = 'image/'.strtolower( substr( $fileHash['source_file'], (strrpos( $fileHash['source_file'], '.' )+1) ) );
$fileHash['size'] = filesize( $fileHash['source_file'] );
$fileHash['dest_path'] = dirname( $this->getSourceFile() ).'/';
- $fileHash['name'] = $this->mInfo['filename'];
+ $fileHash['name'] = $this->getField( 'file_name' );
$fileHash['max_height'] = $fileHash['max_width'] = $pResizeOriginal;
// make a copy of the fileHash that we can compare output after processing
$preResize = $fileHash;
@@ -468,9 +468,8 @@ class FisheyeImage extends FisheyeBase {
$details = $this->getImageDetails( $fileHash['source_file'] );
// store all the values that might have changed due to the resize
$storeHash = array(
- 'file_size' => $details['size'],
- 'mime_type' => $details['mime'],
- 'storage_path' => $this->getSourceFile(),
+ 'file_size' => $details['size'],
+ 'mime_type' => $details['mime'],
);
$this->mDb->associateUpdate( BIT_DB_PREFIX."liberty_files", $storeHash, array( 'file_id' => $this->mInfo['file_id'] ) );
//$query = "UPDATE `".BIT_DB_PREFIX."liberty_files` SET `file_size`=? WHERE `file_id`=?";
@@ -507,12 +506,12 @@ class FisheyeImage extends FisheyeBase {
function renderThumbnails( $pThumbSizes=NULL ) {
- if( !empty( $this->mInfo['storage_path'] ) || $this->load() ) {
+ if( $this->getField( 'file_name' ) || $this->load() ) {
$fileHash['source_file'] = $this->getSourceFile();
$fileHash['type'] = 'image/'.strtolower( substr( $fileHash['source_file'], (strrpos( $fileHash['source_file'], '.' )+1) ) );
$fileHash['size'] = filesize( $fileHash['source_file'] );
$fileHash['dest_path'] = $this->getStorageBranch();
- $fileHash['name'] = $this->mInfo['filename'];
+ $fileHash['name'] = $this->getField( 'file_name' );
$fileHash['thumbnail_sizes'] = $pThumbSizes;
// just generate thumbnails
liberty_generate_thumbnails( $fileHash );
@@ -523,32 +522,22 @@ class FisheyeImage extends FisheyeBase {
return( count($this->mErrors) == 0 );
}
- function getSourceUrl() {
- $ret = NULL;
- if( !empty( $this->mInfo['storage_path'] ) ) {
- $ret = $this->getStorageUrl().rawurlencode( basename( $this->mInfo['storage_path'] ) );
- }
- return $ret;
- }
-
- function getSourceFile() {
- $ret = NULL;
- if( !empty( $this->mInfo['storage_path'] ) ) {
- $ret = $this->getStoragePath().basename( $this->mInfo['storage_path'] );
- }
- return $ret;
- }
-
- function getStorageUrl( $pSubDir = NULL, $pUserId = NULL, $pPackage = FISHEYE_PKG_NAME, $pPermissions = 0755 ) {
- return parent::getStorageUrl( 'images', $this->getField('user_id'), NULL ).$this->getField('attachment_id').'/';
+ function getStorageUrl( $pParamHash = array() ) {
+ $pParamHash['sub_dir'] = 'images';
+ $pParamHash['user_id'] = $this->getParameter( $pParamHash, 'user_id', $this->getField('user_id') );
+ return parent::getStorageUrl( $pParamHash ).$this->getParameter( $pParamHash, 'attachment_id', $this->getField('attachment_id') ).'/';
}
- function getStorageBranch( $pSubDir = NULL, $pUserId = NULL, $pPackage = FISHEYE_PKG_NAME, $pPermissions = 0755, $pRootDir = NULL ) {
- return parent::getStorageBranch( 'images', $this->getField('user_id'), NULL ).$this->getField('attachment_id').'/';
+ function getStorageBranch( $pParamHash = array() ) {
+ $pParamHash['sub_dir'] = 'images';
+ $pParamHash['user_id'] = $this->getParameter( $pParamHash, 'user_id', $this->getField('user_id') );
+ return parent::getStorageBranch( $pParamHash ).$this->getParameter( $pParamHash, 'attachment_id', $this->getField('attachment_id') ).'/';
}
- function getStoragePath( $pSubDir = NULL, $pUserId = NULL, $pPackage = FISHEYE_PKG_NAME, $pPermissions = 0755, $pRootDir = NULL ) {
- return parent::getStoragePath( 'images', $this->getField('user_id'), NULL ).$this->getField('attachment_id').'/';
+ function getStoragePath( $pParamHash = array() ) {
+ $pParamHash['sub_dir'] = 'images';
+ $pParamHash['user_id'] = $this->getParameter( $pParamHash, 'user_id', $this->getField('user_id') );
+ return parent::getStoragePath( $pParamHash ).$this->getParameter( $pParamHash, 'attachment_id', $this->getField('attachment_id') ).'/';
}
function getPreviewHash() {
@@ -692,8 +681,8 @@ class FisheyeImage extends FisheyeBase {
$ret = trim( parent::getTitle( $pHash, $pDefault ) );
if( empty( $ret ) && $pDefault ) {
$storage = (!empty( $this->mStorage ) ? current( $this->mStorage ) : NULL);
- if( !empty( $storage['filename'] ) ) {
- $ret = $storage['filename'];
+ if( !empty( $storage['file_name'] ) ) {
+ $ret = $storage['file_name'];
} else {
global $gLibertySystem;
$ret = $gLibertySystem->getContentTypeName( $pHash['content_type_guid'] );
@@ -839,13 +828,15 @@ class FisheyeImage extends FisheyeBase {
$whereSql $orderby";
if( $rs = $this->mDb->query( $query, $bindVars, $pListHash['max_records'], $pListHash['offset'], $pListHash['query_cache_time'] ) ) {
while( $row = $rs->fetchRow() ) {
+ // legacy table data was named storage_path and included a partial path. strip out any path just in case
+ $row['file_name'] = basename( $row['file_name'] );
$ret[$row['hash_key']] = $row;
$imageId = $row['image_id'];
if( empty( $pListHash['no_thumbnails'] ) ) {
$ret[$imageId]['display_url'] = $this->getDisplayUrl( $imageId );
$ret[$imageId]['has_machine_name'] = $this->isMachineName( $ret[$imageId]['title'] );
$ret[$imageId]['thumbnail_url'] = liberty_fetch_thumbnail_url( array(
- 'storage_path' => $row['storage_path'],
+ 'source_file' => $this->getSourceFile( $row ),
'default_image' => FISHEYE_PKG_URL.'image/generating_thumbnails.png',
'size' => $thumbSize,
));
diff --git a/fisheye_rss.php b/fisheye_rss.php
index 7fd1980..68dbb8d 100644
--- a/fisheye_rss.php
+++ b/fisheye_rss.php
@@ -54,7 +54,7 @@ if( !$gBitUser->hasPermission( 'p_fisheye_view' ) ) {
$item = new FeedItem();
$item->title = $feed['title'];
$item->link = $feed['display_url'];
- $item->description = '<a href="'.$feed['display_url'].'"><img src="'.liberty_fetch_thumbnail_url( array( 'storage_path' => $feed['storage_path'], 'size' => 'medium' )).'" /></a>';
+ $item->description = '<a href="'.$feed['display_url'].'"><img src="'.$feed['thumbnail_url'].'" /></a>';
$item->description .= '<p>'.$feed['data'].'</p>';
$item->date = ( int )$feed['last_modified'];
diff --git a/templates/center_list_galleries.tpl b/templates/center_list_galleries.tpl
index 8b2aed4..c679805 100644
--- a/templates/center_list_galleries.tpl
+++ b/templates/center_list_galleries.tpl
@@ -1 +1 @@
-{include file="bitpackage:fisheye/user_galleries.tpl"} \ No newline at end of file
+{include file="bitpackage:fisheye/user_galleries.tpl"}