diff options
| -rw-r--r-- | FisheyeGallery.php | 74 | ||||
| -rw-r--r-- | FisheyeImage.php | 29 | ||||
| -rw-r--r-- | admin/admin_fisheye_inc.php | 4 | ||||
| -rw-r--r-- | admin/schema_inc.php | 3 | ||||
| -rw-r--r-- | browse.php | 6 | ||||
| -rw-r--r-- | edit.php | 7 | ||||
| -rw-r--r-- | edit_image.php | 6 | ||||
| -rw-r--r-- | image/generating_thumbnails.png | bin | 4410 -> 0 bytes | |||
| -rw-r--r-- | image_order.php | 6 | ||||
| -rw-r--r-- | list_galleries.php | 23 | ||||
| -rw-r--r-- | modules/mod_navigation.tpl | 26 | ||||
| -rw-r--r-- | templates/center_list_galleries.php | 2 | ||||
| -rw-r--r-- | templates/edit_image.tpl | 2 | ||||
| -rw-r--r-- | templates/gallery_nav.tpl | 8 | ||||
| -rw-r--r-- | templates/image_order.tpl | 44 | ||||
| -rw-r--r-- | templates/list_galleries.tpl | 3 | ||||
| -rw-r--r-- | templates/upload_fisheye.tpl | 28 | ||||
| -rw-r--r-- | templates/view_image.tpl | 15 | ||||
| -rw-r--r-- | upload.php | 199 | ||||
| -rw-r--r-- | upload_inc.php | 126 |
20 files changed, 324 insertions, 287 deletions
diff --git a/FisheyeGallery.php b/FisheyeGallery.php index 3957230..37e7c12 100644 --- a/FisheyeGallery.php +++ b/FisheyeGallery.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_fisheye/FisheyeGallery.php,v 1.9 2005/10/12 15:13:49 spiderr Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/FisheyeGallery.php,v 1.10 2005/11/22 07:25:47 squareing Exp $ * @package fisheye */ @@ -103,9 +103,10 @@ class FisheyeGallery extends FisheyeBase { } if( !empty( $pCurrentImageId ) ) { // this code sucks but works - XOXO spiderr - $query = "SELECT tfgim.*,tfi.`image_id` + $query = "SELECT tfgim.*, tfi.`image_id`, tf.`storage_path` FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim INNER JOIN `".BIT_DB_PREFIX."tiki_fisheye_image` tfi ON ( tfi.`content_id`=tfgim.`item_content_id` ) + INNER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON ( tf.`file_id`=tfi.`image_id` ) WHERE tfgim.`gallery_content_id` = ? ORDER BY tfgim.`position`, tfi.`content_id` "; if( $rs = $this->mDb->query($query, array( $this->mContentId ) ) ) { @@ -114,9 +115,25 @@ class FisheyeGallery extends FisheyeBase { if( $rows[$i]['image_id'] == $pCurrentImageId ) { if( $i > 0 ) { $this->mInfo['previous_image_id'] = $rows[$i-1]['image_id']; + + $trailingName = dirname( $rows[$i-1]['storage_path'] )."/avatar.jpg"; + if( file_exists( BIT_ROOT_PATH.$trailingName ) ) { + $this->mInfo['previous_image_avatar'] = BIT_ROOT_URL.$trailingName; + } else { + $mime_type = BitSystem::lookupMimeType( preg_match( "/\..*?$/", $rows[$i-1]['storage_path'] ) ); + $this->mInfo['previous_image_avatar'] = LibertySystem::getMimeThumbnailURL( $mime_type ); + } } if( $i + 1 < count( $rows ) ) { $this->mInfo['next_image_id'] = $rows[$i+1]['image_id']; + + $trailingName = dirname( $rows[$i+1]['storage_path'] )."/avatar.jpg"; + if( file_exists( BIT_ROOT_PATH.$trailingName ) ) { + $this->mInfo['next_image_avatar'] = BIT_ROOT_URL.$trailingName; + } else { + $mime_type = BitSystem::lookupMimeType( preg_match( "/\..*?$/", $rows[$i+1]['storage_path'] ) ); + $this->mInfo['next_image_avatar'] = LibertySystem::getMimeThumbnailURL( $mime_type ); + } } } } @@ -157,7 +174,7 @@ class FisheyeGallery extends FisheyeBase { foreach ($rows as $row) { $pass = TRUE; if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) { - $pass = empty( $row['security_id'] ) || ( $row['user_id'] == $gBitUser->mUserId ) || !empty( $_SESSION['gatekeeper_security'][$row['security_id']] ); + $pass = $gBitUser->hasPermission( 'bit_p_admin_fisheye' ) || empty( $row['security_id'] ) || ( $row['user_id'] == $gBitUser->mUserId ) || !empty( $_SESSION['gatekeeper_security'][$row['security_id']] ); } if( $pass && $item = $gLibertySystem->getLibertyObject( $row['item_content_id'], $row['content_type_guid'] ) ) { $item->loadThumbnail( $this->mInfo['thumbnail_size'] ); @@ -460,16 +477,15 @@ vd( $this->mErrors ); function getList( &$pListHash ) { -// function getList($pUserId = NULL, $pFindString = NULL, $pSortMode = NULL, $pMaxRows = NULL) { global $gBitUser,$gBitSystem, $commentsLib; $this->prepGetList( $pListHash ); $bindVars = array(); $select = ''; $mid = ''; + $sort = ''; $join = ''; - $mapJoin = empty( $pListHash['show_empty'] ) ? ' INNER JOIN ' : ' LEFT OUTER JOIN '; // this *has* to go first because of bindVars order if( empty( $pListHash['show_empty'] ) ) { // This will nicely pull out the unused rows, but it is dog slow @@ -490,9 +506,9 @@ vd( $this->mErrors ); $mid .= " AND tc.`user_id` = ? "; $bindVars[] = $pListHash['user_id']; } - if( !empty( $pListHash['search'] ) ) { - $mid .= " AND UPPER(tc.`title`) LIKE ? "; - $bindVars[] = '%'.strtoupper( $pListHash['search'] ).'%'; + if( !empty( $pListHash['find'] ) ) { + $mid .= " AND UPPER( tc.`title` ) LIKE ? "; + $bindVars[] = '%'.strtoupper( $pListHash['find'] ).'%'; } if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) { $select .= ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` '; @@ -503,31 +519,51 @@ vd( $this->mErrors ); } } + // weed out empty galleries if we don't need them + if( empty( $pListHash['show_empty'] ) ) { + $mapJoin = "INNER JOIN `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim ON (tfgim.`gallery_content_id`=tc.`content_id`)"; + } else { + $mapJoin = ""; + } + + if ( !empty( $pListHash['sort_mode'] ) ) { //converted in prepGetList() - $mid .= " ORDER BY ".$this->mDb->convert_sortmode( $pListHash['sort_mode'] )." "; + $sort .= " ORDER BY tc.".$this->mDb->convert_sortmode( $pListHash['sort_mode'] )." "; } $query = "SELECT DISTINCT( tfg.`gallery_id` ) AS `hash_key`, tfg.*, tc.*, uu.`login`, uu.`real_name`, ptc.`content_type_guid` AS `preview_content_type_guid` $select - FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery` tfg LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content` ptc ON( tfg.`preview_content_id`=ptc.`content_id` ), `".BIT_DB_PREFIX."users_users` uu, `".BIT_DB_PREFIX."tiki_content` tc $join - WHERE tfg.`content_id` = tc.`content_id` AND uu.`user_id` = tc.`user_id` $mid"; - if( $rs = $this->mDb->query( $query, $bindVars, $pListHash['max_records'],$pListHash['offset'] ) ) { - $ret = $rs->GetAssoc(); + FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery` tfg + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content` ptc ON( tfg.`preview_content_id`=ptc.`content_id` ), `".BIT_DB_PREFIX."users_users` uu, `".BIT_DB_PREFIX."tiki_content` tc + $mapJoin $join + WHERE tfg.`content_id` = tc.`content_id` AND uu.`user_id` = tc.`user_id` $mid $sort"; + if( $rs = $this->mDb->query( $query, $bindVars, $pListHash['max_records'], $pListHash['offset'] ) ) { + $data = $rs->GetAssoc(); if( empty( $pListHash['no_thumbnails'] ) ) { $thumbsize = !empty( $pListHash['thumbnail_size'] ) ? $pListHash['thumbnail_size'] : 'small'; - foreach( array_keys( $ret ) as $galleryId ) { - $ret[$galleryId]['display_url'] = $this->getDisplayUrl( $galleryId ); - if( $thumbImage = $this->getThumbnailImage( $ret[$galleryId]['content_id'], $ret[$galleryId]['preview_content_id'], $ret[$galleryId]['preview_content_type_guid'] ) ) { - $ret[$galleryId]['thumbnail_url'] = $thumbImage->getThumbnailUrl( $thumbsize ); + foreach( array_keys( $data ) as $galleryId ) { + $data[$galleryId]['display_url'] = $this->getDisplayUrl( $galleryId ); + if( $thumbImage = $this->getThumbnailImage( $data[$galleryId]['content_id'], $data[$galleryId]['preview_content_id'], $data[$galleryId]['preview_content_type_guid'] ) ) { + $data[$galleryId]['thumbnail_url'] = $thumbImage->getThumbnailUrl( $thumbsize ); } elseif( !empty( $pListHash['show_empty'] ) ) { - $ret[$galleryId]['thumbnail_url'] = FISHEYE_PKG_URL.'image/no_image.png'; + $data[$galleryId]['thumbnail_url'] = FISHEYE_PKG_URL.'image/no_image.png'; } else { - unset( $ret[$galleryId] ); + unset( $data[$galleryId] ); } } } } + // count galleries + $query_c = "SELECT COUNT( DISTINCT( tfg.`gallery_id` ) ) + FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery` tfg + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content` ptc ON( tfg.`preview_content_id`=ptc.`content_id` ), `".BIT_DB_PREFIX."users_users` uu, `".BIT_DB_PREFIX."tiki_content` tc + $mapJoin $join + WHERE tfg.`content_id` = tc.`content_id` AND uu.`user_id` = tc.`user_id` $mid"; + $cant = $this->mDb->getOne( $query_c, $bindVars ); + + $ret['cant'] = $cant; + $ret['data'] = $data; return $ret; } } diff --git a/FisheyeImage.php b/FisheyeImage.php index 0311862..72c8021 100644 --- a/FisheyeImage.php +++ b/FisheyeImage.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_fisheye/FisheyeImage.php,v 1.10 2005/10/12 15:13:49 spiderr Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/FisheyeImage.php,v 1.11 2005/11/22 07:25:47 squareing Exp $ * @package fisheye */ @@ -220,7 +220,7 @@ class FisheyeImage extends FisheyeBase { $fileHash['dest_path'] = dirname( $this->mInfo['image_file']['storage_path'] ).'/'; $fileHash['name'] = $this->mInfo['image_file']['filename']; $fileHash['degrees'] = $pDegrees; - $rotateFunc = ($gBitSystem->getPreference( 'image_processor' ) == 'imagick' ) ? 'liberty_imagick_rotate_image' : 'liberty_gd_rotate_image'; + $rotateFunc = liberty_get_function( 'rotate' ); if( $rotateFunc( $fileHash ) ) { liberty_clear_thumbnails( $fileHash ); $this->mDb->query( "UPDATE `".BIT_DB_PREFIX."tiki_fisheye_image` SET `width`=`height`, `height`=`width` WHERE `content_id`=?", array( $this->mContentId ) ); @@ -296,11 +296,15 @@ class FisheyeImage extends FisheyeBase { $info = NULL; $pFilePath = ($pFilePath ? $pFilePath : (empty($this->mInfo['image_file']['storage_path']) ? NULL : BIT_ROOT_PATH.$this->mInfo['image_file']['storage_path'])); - if ($pFilePath && file_exists($pFilePath) && filesize( $pFilePath ) ) { - if( $info = getimagesize(rtrim($pFilePath)) ) { - $info['width'] = $info[0]; - $info['height'] = $info[1]; - $info['size'] = filesize($pFilePath); + $checkFiles = array( $pFilePath, dirname( $pFilePath ).'/original.jpg' ); + + foreach( $checkFiles as $cf ) { + if ($cf && file_exists( $cf ) && filesize( $cf ) ) { + if( $info = getimagesize( rtrim( $cf ) ) ) { + $info['width'] = $info[0]; + $info['height'] = $info[1]; + $info['size'] = filesize( $cf ); + } } } @@ -382,16 +386,7 @@ class FisheyeImage extends FisheyeBase { if( empty( $this->mInfo['image_file']['gallery_thumbnail_url'] ) ) { $this->loadThumbnail( $pSize ); } - // this is not the cleanest file_exists check, but has to be this way since $this->mInfo['image_file']* - // have BIT_ROOT_URL in them, and you will end up with dual prefixes if you do somethingn like - // file_exists( BIT_ROOT_PATH.$this->mInfo['image_file']['gallery_thumbnail_url'] ) - if( !empty( $this->mInfo['image_file']['storage_path'] ) && file_exists( BIT_ROOT_PATH.dirname( $this->mInfo['image_file']['storage_path'] )."/$pSize.jpg" ) ) { - $ret = $this->mInfo['image_file']['gallery_thumbnail_url']; - } else { - $ret = FISHEYE_PKG_URL.'image/generating_thumbnails.png'; - } - - return $ret; + return $this->mInfo['image_file']['gallery_thumbnail_url']; } function expunge() { diff --git a/admin/admin_fisheye_inc.php b/admin/admin_fisheye_inc.php index 6776759..9fb8844 100644 --- a/admin/admin_fisheye_inc.php +++ b/admin/admin_fisheye_inc.php @@ -101,6 +101,10 @@ $formImageLists = array( 'label' => 'Use icons in the gallery bar', 'note' => 'When viewing an image, show <strong>previous</strong> and <strong>next</strong> links as images instead of words', ), + "gallery_bar_use_thumbnails" => array( + 'label' => 'Use Thumbnails in gallery bar', + 'note' => 'When viewing an image, show previous and next <strong>thumbnails</strong> with the appropriate links.', + ), ); $gBitSmarty->assign( 'formImageLists', $formImageLists); diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 5dc5317..a649975 100644 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -95,7 +95,8 @@ $gBitInstaller->registerUserPermissions( FISHEYE_PKG_NAME, array( array('bit_p_create_fisheye', 'Can create an image gallery', 'registered', FISHEYE_PKG_NAME), array('bit_p_edit_fisheye', 'Can edit image gallery', 'registered', FISHEYE_PKG_NAME), array('bit_p_upload_fisheye', 'Can upload images to gallery', 'registered', FISHEYE_PKG_NAME), - array('bit_p_admin_fisheye', 'Can admin image galleries', 'editors', FISHEYE_PKG_NAME) + array('bit_p_admin_fisheye', 'Can admin image galleries', 'editors', FISHEYE_PKG_NAME), + array('bit_p_fisheye_upload_nonimages', 'Can upload non_image files', 'editors', FISHEYE_PKG_NAME) ) ); ?> @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_fisheye/browse.php,v 1.3 2005/08/01 18:40:07 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/browse.php,v 1.4 2005/11/22 07:25:47 squareing Exp $ * @package fisheye * @subpackage functions */ @@ -16,8 +16,8 @@ global $gBitSystem, $gBitSmarty; $gFisheyeGallery = new FisheyeGallery(); $galleryList = $gFisheyeGallery->getList( $_REQUEST ); -$gBitSmarty->assign_by_ref('galleryList', $galleryList); +$gBitSmarty->assign_by_ref( 'galleryList', $galleryList['data'] ); -$gBitSystem->display("bitpackage:fisheye/browse_galleries.tpl"); +$gBitSystem->display( "bitpackage:fisheye/browse_galleries.tpl" ); ?> @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_fisheye/edit.php,v 1.7 2005/10/23 14:39:44 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/edit.php,v 1.8 2005/11/22 07:25:47 squareing Exp $ * @package fisheye * @subpackage functions */ @@ -81,10 +81,11 @@ if( !empty($_REQUEST['savegallery']) ) { $errors = (!empty($gContent->mErrors) ? $gContent->mErrors : array()); $gBitSmarty->assign_by_ref('errors', $errors); -$gBitSmarty->assign_by_ref( 'parentGalleries', $gContent->getParentGalleries() ); +$gallery = $gContent->getParentGalleries(); +$gBitSmarty->assign_by_ref( 'parentGalleries', $gallery ); $getHash = array( 'user_id' => $gBitUser->mUserId, 'contain_item' => $gContent->mContentId, 'max_records' => -1, 'no_thumbnails' => TRUE, 'sort_mode'=>'title_asc' ); $galleryList = $gContent->getList( $getHash ); -$gBitSmarty->assign_by_ref('galleryList', $galleryList); +$gBitSmarty->assign_by_ref( 'galleryList', $galleryList['data'] ); $gContent->invokeServices( 'content_edit_function' ); diff --git a/edit_image.php b/edit_image.php index dbe2323..64d7283 100644 --- a/edit_image.php +++ b/edit_image.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_fisheye/edit_image.php,v 1.7 2005/09/03 10:19:11 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/edit_image.php,v 1.8 2005/11/22 07:25:47 squareing Exp $ * @package fisheye * @subpackage functions */ @@ -83,9 +83,9 @@ $gContent->loadParentGalleries(); // Get a list of all existing galleries $gFisheyeGallery = new FisheyeGallery(); -$listHash = array( 'user_id'=>$gContent->mInfo['user_id'], 'max_records' => -1, 'no_thumbnails' => TRUE, 'sort_mode'=>'title_asc' ); +$listHash = array( 'user_id' => $gContent->mInfo['user_id'], 'max_records' => -1, 'no_thumbnails' => TRUE, 'sort_mode' => 'title_asc', 'show_empty' => TRUE ); $galleryList = $gFisheyeGallery->getList( $listHash ); -$gBitSmarty->assign_by_ref('galleryList', $galleryList); +$gBitSmarty->assign_by_ref( 'galleryList', $galleryList['data'] ); $gBitSmarty->assign('requested_gallery', !empty($_REQUEST['gallery_id']) ? $_REQUEST['gallery_id'] : NULL); diff --git a/image/generating_thumbnails.png b/image/generating_thumbnails.png Binary files differdeleted file mode 100644 index 7fbb59d..0000000 --- a/image/generating_thumbnails.png +++ /dev/null diff --git a/image_order.php b/image_order.php index f23ceeb..3911d43 100644 --- a/image_order.php +++ b/image_order.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_fisheye/image_order.php,v 1.7 2005/10/12 15:13:49 spiderr Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/image_order.php,v 1.8 2005/11/22 07:25:47 squareing Exp $ * @package fisheye * @subpackage functions */ @@ -148,9 +148,9 @@ if (!empty($_REQUEST['cancel'])) { } // Get a list of all existing galleries -$listHash = array( 'user_id'=>$gBitUser->mUserId, 'max_records'=>-1, 'no_thumbnails' => TRUE, 'sort_mode'=>'title_asc' ); +$listHash = array( 'user_id' => $gBitUser->mUserId, 'max_records' => -1, 'no_thumbnails' => TRUE, 'sort_mode' => 'title_asc', 'show_empty' => TRUE ); $galleryList = $gContent->getList( $listHash ); -$gBitSmarty->assign_by_ref('galleryList', $galleryList); +$gBitSmarty->assign_by_ref( 'galleryList', $galleryList['data'] ); $gContent->loadImages(); $gBitSmarty->assign_by_ref('galleryImages', $gContent->mItems); diff --git a/list_galleries.php b/list_galleries.php index 033b872..684ff93 100644 --- a/list_galleries.php +++ b/list_galleries.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_fisheye/list_galleries.php,v 1.3 2005/08/01 18:40:07 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/list_galleries.php,v 1.4 2005/11/22 07:25:47 squareing Exp $ * @package fisheye * @subpackage functions */ @@ -31,18 +31,17 @@ if (!empty($_REQUEST['user_id']) && is_numeric($_REQUEST['user_id'])) { $_REQUEST['thumbnail_size'] = $gBitSystem->getPreference( 'fisheye_list_thumbnail_size', 'small' ); $galleryList = $gFisheyeGallery->getList( $_REQUEST ); -$gBitSmarty->assign_by_ref('galleryList', $galleryList); -if (!empty($_REQUEST['offset']) && is_numeric($_REQUEST['offset'])) { - $gBitSmarty->assign_by_ref('iMaxRows', $iMaxRows); -} -if (!empty($_REQUEST['sort_mode'])) { - $gBitSmarty->assign_by_ref('iSortMode', $_REQUEST['sort_mode']); -} -if (!empty($_REQUEST['search'])) { - $gBitSmarty->assign_by_ref('iSearchString', $iSearchtring); -} +// pagination +$offset = !empty( $_REQUEST['offset'] ) ? $_REQUEST['offset'] : 0; +$gBitSmarty->assign( 'curPage', $page = !empty( $_REQUEST['page'] ) ? $_REQUEST['page'] : 1 ); +$offset = ( $page - 1 ) * $gBitSystem->mPrefs['maxRecords']; + +// calculate page number +$numPages = ceil( $galleryList['cant'] / $gBitSystem->mPrefs['maxRecords'] ); +$gBitSmarty->assign( 'numPages', $numPages ); -$gBitSystem->display("bitpackage:fisheye/$template", "List Galleries" ); +$gBitSmarty->assign( 'galleryList', $galleryList['data'] ); +$gBitSystem->display( "bitpackage:fisheye/$template", "List Galleries" ); ?> diff --git a/modules/mod_navigation.tpl b/modules/mod_navigation.tpl new file mode 100644 index 0000000..1c2caff --- /dev/null +++ b/modules/mod_navigation.tpl @@ -0,0 +1,26 @@ +{strip} +{if $gGallery} + {bitmodule title="$moduleTitle" name="fisheye_navigation"} + <div class="left"> + {if $gGallery->mInfo.previous_image_id} + <a href="{$gContent->getDisplayUrl($gGallery->mInfo.previous_image_id)|escape}"> + <img src="{$gGallery->mInfo.previous_image_avatar}" /> + <br /> + « {tr}previous{/tr} + </a> + {else} {/if} + </div> + + <div class="right"> + {if $gGallery->mInfo.next_image_id} + <a href="{$gContent->getDisplayUrl($gGallery->mInfo.next_image_id)|escape}"> + <img src="{$gGallery->mInfo.next_image_avatar}" /> + <br /> + {tr}next{/tr} » + </a> + {else} {/if} + </div> + {/bitmodule} +{/if} +{/strip} + diff --git a/templates/center_list_galleries.php b/templates/center_list_galleries.php index d5c3975..cc3641e 100644 --- a/templates/center_list_galleries.php +++ b/templates/center_list_galleries.php @@ -6,7 +6,7 @@ $_REQUEST['root_only'] = TRUE; $_REQUEST['get_thumbnails'] = TRUE; $galleryList = $gFisheyeGallery->getList( $_REQUEST ); - $gBitSmarty->assign_by_ref('galleryList', $galleryList); + $gBitSmarty->assign_by_ref( 'galleryList', $galleryList['data'] ); /* Process the input parameters this page accepts */ if (!empty($gQueryUser) && $gQueryUser->isRegistered()) { diff --git a/templates/edit_image.tpl b/templates/edit_image.tpl index 04f4a70..d5d3ec4 100644 --- a/templates/edit_image.tpl +++ b/templates/edit_image.tpl @@ -1,7 +1,5 @@ {strip} -{include file="bitpackage:fisheye/crop_image_js.tpl"} - <div class="floaticon"> <a href="{$smarty.const.FISHEYE_PKG_URL}edit_image.php">{biticon ipackage="liberty" iname="upload" iexplain="upload new image"}</a> </div> diff --git a/templates/gallery_nav.tpl b/templates/gallery_nav.tpl index 1328950..e6c3cd5 100644 --- a/templates/gallery_nav.tpl +++ b/templates/gallery_nav.tpl @@ -17,6 +17,10 @@ {else} « {tr}previous{/tr} {/if} + {if $gBitSystem->isFeatureActive( 'gallery_bar_use_thumbnails' )} + <br /> + <img src="{$gGallery->mInfo.previous_image_avatar}" /> + {/if} </a> {else} {/if} </span> @@ -29,6 +33,10 @@ {else} {tr}next{/tr} » {/if} + {if $gBitSystem->isFeatureActive( 'gallery_bar_use_thumbnails' )} + <br /> + <img src="{$gGallery->mInfo.next_image_avatar}" /> + {/if} </a> {else} {/if} </span> diff --git a/templates/image_order.tpl b/templates/image_order.tpl index 0a33c30..ad57cc5 100644 --- a/templates/image_order.tpl +++ b/templates/image_order.tpl @@ -13,7 +13,7 @@ <table class="data"> <caption>{tr}Image Order{/tr}</caption> <tr> - <td style="width:1px;"></td> + <th style="width:1px;"></th> <th scope="col" style="width:1px;">{tr}Thumbnail{/tr}</th> <th scope="col">{tr}Title and Position{/tr}</th> <th scope="col">{tr}Miscellaneous{/tr}</th> @@ -54,7 +54,7 @@ <div class="row"> {formlabel label="Position" for="imagePosition-`$galleryImages[ix]->mContentId`"} {forminput} - <input type="text" size="3" maxlength="3" name="imagePosition[{$galleryImages[ix]->mContentId}]" id="imagePosition-{$galleryImages[ix]->mContentId}" value="{$galleryImages[ix]->mInfo.position}"/> + <input type="text" size="8" maxlength="15" name="imagePosition[{$galleryImages[ix]->mContentId}]" id="imagePosition-{$galleryImages[ix]->mContentId}" value="{$galleryImages[ix]->mInfo.position}"/> {/forminput} </div> @@ -106,24 +106,32 @@ <option value="delete">{tr}Delete{/tr}</option> <option value="remove">{tr}Remove{/tr} ({tr}Don't delete if in other galleries{/tr})</option> <option value="thumbnail">{tr}Regenerate Thumbnails{/tr}</option> - <option value="rotate:-90"><< {tr}Rotate Counter Clockwise{/tr}</option> - <option value="rotate:90">>> {tr}Rotate Clockwise{/tr}</option> + <optgroup label="{tr}Rotate{/tr}"> + <option value="rotate:90">>> {tr}Rotate Clockwise{/tr}</option> + <option value="rotate:-90"><< {tr}Rotate Counter Clockwise{/tr}</option> + </optgroup> {if $gBitSystem->isPackageActive( 'gatekeeper' ) } - <option value="security:">{tr}Set Security to{/tr} ~~ {tr}Publically Visible{/tr} ~~</option> - {foreach from=$securities key=secId item=sec} - <option value="security:{$secId}">{tr}Set Security to{/tr} "{$sec.security_description}"</option> - {/foreach} + <optgroup label="{tr}Set Security to{/tr}"> + <option value="security:">~~ {tr}Publically Visible{/tr} ~~</option> + {foreach from=$securities key=secId item=sec} + <option value="security:{$secId}">{tr}Set Security to{/tr} "{$sec.security_description}"</option> + {/foreach} + </optgroup> {/if} - {foreach from=$galleryList item=gal key=galleryId} - {if $gContent->mInfo.content_id ne $gal.content_id} - <option value="gallerycopy:{$gal.content_id}">{tr}Copy to gallery{/tr} "{$gal.title|truncate:30}"</option> - {/if} - {/foreach} - {foreach from=$galleryList item=gal key=galleryId} - {if $gContent->mInfo.content_id ne $gal.content_id} - <option value="gallerymove:{$gal.content_id}">{tr}Move to gallery{/tr} "{$gal.title|truncate:30}"</option> - {/if} - {/foreach} + <optgroup label="{tr}Copy to Gallery{/tr}"> + {foreach from=$galleryList item=gal key=galleryId} + {if $gContent->mInfo.content_id ne $gal.content_id} + <option value="gallerycopy:{$gal.content_id}">{$gal.title|truncate:50}</option> + {/if} + {/foreach} + </optgroup> + <optgroup label="{tr}Move to Gallery{/tr}"> + {foreach from=$galleryList item=gal key=galleryId} + {if $gContent->mInfo.content_id ne $gal.content_id} + <option value="gallerymove:{$gal.content_id}">{$gal.title|truncate:50}</option> + {/if} + {/foreach} + </optgroup> </select> {formhelp note=""} {/forminput} diff --git a/templates/list_galleries.tpl b/templates/list_galleries.tpl index bf4350f..56e173d 100644 --- a/templates/list_galleries.tpl +++ b/templates/list_galleries.tpl @@ -26,6 +26,8 @@ </ul> </div> + {minifind} + <ul class="clear data"> {foreach from=$galleryList key=galleryId item=gal} <li class="item {cycle values='odd,even'} {$gal.content_type_guid}"> @@ -97,6 +99,7 @@ </ul> <div class="clear"></div> + {libertypagination page=$curPage numPages=$numPages find=$find} </div> <!-- end .body --> </div> <!-- end .fisheye --> {/strip} diff --git a/templates/upload_fisheye.tpl b/templates/upload_fisheye.tpl index 1976136..85bbc9f 100644 --- a/templates/upload_fisheye.tpl +++ b/templates/upload_fisheye.tpl @@ -1,15 +1,15 @@ <div class="admin fisheye"> <div class="header"> - <h1>{tr}Upload Images{/tr}</h1> + <h1>{tr}Upload Files{/tr}</h1> </div> <div class="body"> - {form enctype="multipart/form-data" legend="Upload Images"} + {form enctype="multipart/form-data" legend="Upload Files"} {formfeedback note=$quotaMessage} {formfeedback warning="The maximum file size you can upload is `$uploadMax` Megabytes"} {formfeedback error=$errors} - {formhelp note="Here you can upload images. You can upload single image files, or you can upload archived files (.zip's, .sit's, .tar's, etc.) Archvied uploads will automatically be decompressed, and a gallery will created for every gallery in it. If you have nested folders, the hierarchy will be maintained for you with nested galleries." force=true} + {formhelp note="Here you can upload files. You can upload single files, or you can upload archived files (.zip's, .sit's, .tar's, etc.) Archvied uploads will automatically be decompressed, and a gallery will created for every gallery in it. If you have nested folders, the hierarchy will be maintained for you with nested galleries." force=true} {if $browserInfo.platform=='mac'} {formhelp note="Mac Users: The newer .sitx format is not supported currently because the makers of the StuffIt application have not released new versions of their software for servers. Please use DropZip or similar for best results." force=true} {/if} @@ -21,8 +21,8 @@ <div class="row"> {formlabel label="Select File(s)"} {forminput} - <input type="file" name="file0" id="imageupload" /> - {formhelp note=""} + <input type="file" name="file0" id="fileupload" /> + {formhelp note="To upload more than one file, please click on choose repeatedly<br />(javascript has to be enabled for this to work)."} {/forminput} </div> @@ -35,13 +35,25 @@ <script type="text/javascript">//<![CDATA[ // Multi file upload var multi_selector = new MultiSelector( document.getElementById( 'fileslist' ), 10 ); - multi_selector.addElement( document.getElementById( 'imageupload' ) ); + multi_selector.addElement( document.getElementById( 'fileupload' ) ); //]]></script> {/forminput} </div> + {if $gBitUser->hasPermission( 'bit_p_fisheye_upload_nonimages' )} + <div class="row"> + {formlabel label="Process Archive(s)" for="process_archive"} + {forminput} + <input type="checkbox" id="process_archive" name="process_archive" value="true" checked="checked" /> + {formhelp note="If you don't want to have archived files processed and extracted, please uncheck the above box."} + {/forminput} + </div> + {else} + <input type="hidden" id="process_archive" value="true" /> + {/if} + <div class="row"> - {formlabel label="Add Image(s) to these Galleries"} + {formlabel label="Add File(s) to these Galleries"} {forminput} {foreach from=$galleryList key=galId item=gal} <input type="checkbox" name="galleryAdditions[]" value="{$galId}" @@ -58,7 +70,7 @@ <a href="{$smarty.const.FISHEYE_PKG_URL}view.php?gallery_id={$gal.gallery_id}">{$gal.title}</a> <br /> {foreachelse} - <div>{tr}No Galleries Found{/tr}. {tr}A gallery named <strong>{displayname hash=$gBitUser->mInfo nolink=1}'s Gallery</strong> will be created for you and images will be added to it.{/tr}</div> + <div>{tr}No Galleries Found{/tr}. {tr}A gallery named <strong>{displayname hash=$gBitUser->mInfo nolink=1}'s Gallery</strong> will be created for you and files will be added to it.{/tr}</div> {/foreach} {/forminput} </div> diff --git a/templates/view_image.tpl b/templates/view_image.tpl index c70a351..8699bdd 100644 --- a/templates/view_image.tpl +++ b/templates/view_image.tpl @@ -11,8 +11,8 @@ {/if} {/if} {if $gContent->hasUserPermission('bit_p_admin')} - <a title="{tr}Edit{/tr}" href="{$smarty.const.FISHEYE_PKG_URL}edit_image.php?image_id={$gContent->mImageId}">{biticon ipackage=liberty iname="edit" iexplain="Edit Image"}</a> - <a title="{tr}Delete{/tr}" href="{$smarty.const.FISHEYE_PKG_URL}edit_image.php?image_id={$gContent->mImageId}&delete=1">{biticon ipackage=liberty iname="delete" iexplain="Delete Image"}</a> + <a title="{tr}Edit{/tr}" href="{$smarty.const.FISHEYE_PKG_URL}edit_image.php?image_id={$gContent->mImageId}">{biticon ipackage=liberty iname="edit" iexplain="Edit Image"}</a> + <a title="{tr}Delete{/tr}" href="{$smarty.const.FISHEYE_PKG_URL}edit_image.php?image_id={$gContent->mImageId}&delete=1">{biticon ipackage=liberty iname="delete" iexplain="Delete Image"}</a> {/if} </div> @@ -36,12 +36,13 @@ {/box} <div class="pagination"> - {if $gContent->mInfo.width && $gContent->mInfo.height} - {tr}View other sizes{/tr}<br /> - {foreach key=size from=$gContent->mInfo.image_file.thumbnail_url item=url} + {tr}View other sizes{/tr}<br /> + {foreach key=size from=$gContent->mInfo.image_file.thumbnail_url item=url} {if $url != $gContent->mInfo.display_url}<a href="{$gContent->getDisplayUrl(0,$size)|escape}">{/if}{$size}{if $url != $gContent->mInfo.display_url}</a>{/if} • - {/foreach} - <a href="{$gContent->mInfo.image_file.source_url}">Original</a> {$gContent->mInfo.width}x{$gContent->mInfo.height} + {/foreach} + <a href="{$gContent->mInfo.image_file.source_url}">Original</a> + {if $gContent->mInfo.width && $gContent->mInfo.height} + {$gContent->mInfo.width}x{$gContent->mInfo.height} {/if} </div> </div> <!-- end .body --> @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_fisheye/upload.php,v 1.7 2005/10/29 17:52:39 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/upload.php,v 1.8 2005/11/22 07:25:47 squareing Exp $ * @package fisheye * @subpackage functions */ @@ -17,16 +17,17 @@ global $gBitSystem; global $fisheyeErrors, $fisheyeWarnings, $fisheyeSuccess; include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' ); +require_once( FISHEYE_PKG_PATH.'upload_inc.php'); -if (!empty($_REQUEST['save_image'])) { +if( !empty( $_REQUEST['save_image'] ) ) { // first of all set the execution time for this process to unlimited - set_time_limit(0); + set_time_limit(0); $upImages = array(); $upArchives = array(); $upErrors = array(); foreach( array_keys( $_FILES ) as $key ) { - if( preg_match( '/^image/', $_FILES[$key]['type'] ) ) { + if( preg_match( '/(^image|pdf)/i', $_FILES[$key]['type'] ) ) { $upImages[$key] = $_FILES[$key]; } elseif( !empty( $_FILES[$key]['size'] ) ) { $upArchives[$key] = $_FILES[$key]; @@ -47,23 +48,8 @@ if (!empty($_REQUEST['save_image'])) { $order = 100; foreach( array_keys( $upImages ) as $key ) { - if( ($upImages[$key]['size'] > 0) && is_uploaded_file( $upImages[$key]['tmp_name'] ) ) { - // make a copy for each image we need to store - $storeHash = $_REQUEST; - $image = new FisheyeImage(); - // Store/Update the image - if (isset($_FILES[$key])) { - $storeHash['upload'] = &$_FILES[$key]; - $storeHash['upload']['process_storage'] = STORAGE_IMAGE; - } - $storeHash['purge_from_galleries'] = TRUE; - if( !$image->store( $storeHash ) ) { - array_merge( $upErrors, array_values( $image->mErrors ) ); - } - - $image->addToGalleries( $_REQUEST['galleryAdditions'], $order ); - $order += 10; - } + fisheye_store_upload( $upImages[$key], $order ); + $order += 10; } if( !is_object( $gContent ) || !$gContent->isValid() ) { @@ -109,178 +95,11 @@ if( $gBitSystem->isPackageActive( 'quota' ) ) { // Get a list of all existing galleries $gFisheyeGallery = new FisheyeGallery(); -$listHash = array( 'user_id' => $gBitUser->mUserId, 'show_empty' => true, 'max_records'=>-1, 'no_thumbnails'=>TRUE, 'sort_mode'=>'title_asc' ); +$listHash = array( 'user_id' => $gBitUser->mUserId, 'show_empty' => true, 'max_records'=>-1, 'no_thumbnails'=>TRUE, 'sort_mode'=>'title_asc', 'show_empty' => TRUE ); $galleryList = $gFisheyeGallery->getList( $listHash ); -$gBitSmarty->assign_by_ref('galleryList', $galleryList); +$gBitSmarty->assign_by_ref( 'galleryList', $galleryList['data'] ); $gBitSmarty->assign( 'uploadMax', $uploadMax ); $gBitSystem->display( 'bitpackage:fisheye/upload_fisheye.tpl', 'Upload Images' ); - -function fisheye_get_default_gallery_id( $pUserId, $pNewName ) { - $gal = new FisheyeGallery(); - $getHash = array( 'user_id' => $pUserId, 'max_records' => 1, 'sort_mode' => 'created_desc' ); - if( $upList = $gal->getList( $getHash ) ) { - $ret = key( $upList ); - } else { - $galleryHash = array( 'title' => $pNewName ); - if( $gal->store( $galleryHash ) ) { - $ret = $gal->mGalleryId; - } - } - - global $gContent; - if( !is_object( $gContent ) || !$gContent->isValid() ) { - $gContent = new FisheyeGallery( $ret ); - $gContent->load(); - } - return $ret; -} - -function liberty_process_archive( &$pFileHash ) { - $cwd = getcwd(); - $dir = dirname( $pFileHash['tmp_name'] ); - $upExt = strtolower( substr( $pFileHash['name'], (strrpos( $pFileHash['name'], '.' ) + 1) ) ); - $baseDir = $dir.'/'; - if( is_uploaded_file( $pFileHash['tmp_name'] ) ) { - global $gBitUser; - $baseDir .= $gBitUser->mUserId; - } - $destDir = $baseDir.'/'.basename( $pFileHash['tmp_name'] ); - if( (is_dir( $baseDir ) || mkdir( $baseDir )) && @mkdir( $destDir ) ) { - // Some commands don't nicely support extracting to other directories - chdir( $destDir ); - list( $mimeType, $mimeExt ) = split( '/', $pFileHash['type'] ); - switch( $mimeExt ) { - case 'x-rar-compressed': - case 'x-rar': - $shellResult = shell_exec( "rar x -w\"$destDir\" $pFileHash[tmp_name] " ); - break; - case 'x-bzip2': - case 'bzip2': - case 'x-gzip': - case 'gzip': - case 'x-tgz': - case 'x-tar': - case 'tar': - switch( $upExt ) { - case 'gz': - case 'tgz': $compressFlag = '-z'; break; - case 'bz2': $compressFlag = '-j'; break; - default: $compressFlag = ''; break; - } - $shellResult = shell_exec( "tar -x $compressFlag -f $pFileHash[tmp_name] -C \"$destDir\"" ); - break; - case 'x-zip-compressed': - case 'x-zip': - case 'zip': - $shellResult = shell_exec( "unzip $pFileHash[tmp_name] -d \"$destDir\"" ); - break; - case 'x-stuffit': - case 'stuffit': - $shellResult = shell_exec( "unstuff -d=\"$destDir\" $pFileHash[tmp_name] " ); - break; - default: - if( $upExt == 'zip' ) { - $shellResult = shell_exec( "unzip $pFileHash[tmp_name] -d \"$destDir\"" ); - } elseif( $upExt == 'rar' ) { - $shellResult = shell_exec( "rar x -w\"$destDir\" $pFileHash[tmp_name] " ); - } elseif( $upExt == 'sit' || $upExt == 'sitx' ) { - print( "unstuff -d=\"$destDir\" $pFileHash[tmp_name] " ); - $shellResult = shell_exec( "unstuff -d=\"$destDir\" $pFileHash[tmp_name] " ); - vd( $shellResult ); - } - break; - } - } - chdir( $cwd ); - return $destDir; -} - - -// Recursively builds a tree where each directory represents a gallery, and files are assumed to be images. -function fisheye_process_archive( &$pFileHash, &$pParentGallery, $pRoot=FALSE ) { - $errors = NULL; - $destDir = liberty_process_archive( $pFileHash ); - - if( empty( $pParentGallery ) && !is_uploaded_file( $pFileHash['tmp_name'] ) ) { - $pParentGallery = new FisheyeGallery(); - $galleryHash = array( 'title' => basename( $destDir ) ); - if( !$pParentGallery->store( $galleryHash ) ) { - $errors = array_merge( $errors, array_values( $pParentGallery->mErrors ) ); - } - global $gContent; - $gContent = &$pParentGallery; - } - - if( $archiveDir = opendir( $destDir ) ) { - $order = 100; - while( $fileName = readdir($archiveDir) ) { - $sortedNames[] = $fileName; - } - sort( $sortedNames ); - foreach( $sortedNames as $fileName ) { - if( !preg_match( '/^\./', $fileName ) ) { - $scanFile = array( - 'name' => $fileName, - 'size' => filesize( "$destDir/$fileName" ), - 'tmp_name' => "$destDir/$fileName", - ); - - if( !empty( $_REQUEST['resize'] ) && is_numeric( $_REQUEST['resize'] ) ) { - $scanFile['max_height'] = $scanFile['max_width'] = $_REQUEST['resize']; - } - - if( is_dir( $destDir.'/'.$fileName ) ) { - // We found a new Gallery! - $newGallery = new FisheyeGallery(); - $galleryHash = array( 'title' => str_replace( '_', ' ', $fileName ) ); - if( $newGallery->store( $galleryHash ) ) { - if( $pRoot ) { - $newGallery->addToGalleries( $_REQUEST['galleryAdditions'] ); - } - if( is_object( $pParentGallery ) ) { - $pParentGallery->addItem( $newGallery->mContentId, $order ); - } - //recurse down in! - $errors = array_merge( $errors, fisheye_process_archive( $scanFile, $newGallery ) ); - } else { - $errors = array_merge( $errors, array_values( $newGallery->mErrors ) ); - } - } else { - // support for the fileinfo pecl package: http://pecl.php.net/package/fileinfo - if( function_exists( 'finfo_open' ) ) { - $res = finfo_open(FILEINFO_MIME); - $scanFile['type'] = finfo_file($res, $scanFile['tmp_name']); - finfo_close($res); - } - if( empty( $scanFile['type'] ) ) { - $scanFile['type'] = ( "image/unknown" ); - } - $newImage = new FisheyeImage(); - $imageHash = array( 'upload' => $scanFile ); - if( $newImage->store( $imageHash ) ) { - if( $pRoot ) { - $newImage->addToGalleries( $_REQUEST['galleryAdditions'] ); - } - if( !is_object( $pParentGallery ) ) { - global $gBitUser; - $pParentGallery = new FisheyeGallery( fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) ); - $pParentGallery->load(); - } - $pParentGallery->addItem( $newImage->mContentId ); - } else { - $errors = array_merge( $errors, array_values( $newImage->mErrors ) ); - } - } - $order += 10; - } - } - } - return $errors; -} - - - - ?> diff --git a/upload_inc.php b/upload_inc.php new file mode 100644 index 0000000..e92b362 --- /dev/null +++ b/upload_inc.php @@ -0,0 +1,126 @@ +<?php +function fisheye_get_default_gallery_id( $pUserId, $pNewName ) { + $gal = new FisheyeGallery(); + $getHash = array( 'user_id' => $pUserId, 'max_records' => 1, 'sort_mode' => 'created_desc' ); + $upList = $gal->getList( $getHash ); + if( !empty( $upList['data'] ) ) { + $ret = key( $upList['data'] ); + } else { + $galleryHash = array( 'title' => $pNewName ); + if( $gal->store( $galleryHash ) ) { + $ret = $gal->mGalleryId; + } + } + + global $gContent; + if( !is_object( $gContent ) || !$gContent->isValid() ) { + $gContent = new FisheyeGallery( $ret ); + $gContent->load(); + } + return $ret; +} + +function fisheye_store_upload( &$pFileHash, $pOrder = 10 ) { + if( !empty( $pFileHash ) && ($pFileHash['size'] > 0) && is_uploaded_file( $pFileHash['tmp_name'] ) ) { + // make a copy for each image we need to store + $storeHash = $_REQUEST; + $image = new FisheyeImage(); + // Store/Update the image + $storeHash['upload'] = &$pFileHash; + $storeHash['upload']['process_storage'] = STORAGE_IMAGE; + $storeHash['purge_from_galleries'] = TRUE; + if( !$image->store( $storeHash ) ) { + array_merge( $upErrors, array_values( $image->mErrors ) ); + } + + $image->addToGalleries( $_REQUEST['galleryAdditions'], $pOrder ); + } +} + +// Recursively builds a tree where each directory represents a gallery, and files are assumed to be images. +function fisheye_process_archive( &$pFileHash, &$pParentGallery, $pRoot=FALSE ) { + global $gBitSystem, $gBitUser; + $errors = array(); + if( ($destDir = liberty_process_archive( $pFileHash )) && (!empty( $_REQUEST['process_archive'] ) || !$gBitUser->hasPermission( 'bit_p_fisheye_upload_nonimages' )) ) { + if( empty( $pParentGallery ) && !is_uploaded_file( $pFileHash['tmp_name'] ) ) { + $pParentGallery = new FisheyeGallery(); + $galleryHash = array( 'title' => basename( $destDir ) ); + if( !$pParentGallery->store( $galleryHash ) ) { + $errors = array_merge( $errors, array_values( $pParentGallery->mErrors ) ); + } + global $gContent; + $gContent = &$pParentGallery; + } + + fisheye_process_directory( $destDir, $pParentGallery, $pRoot ); + } else { + global $gBitUser; + if( $gBitUser->hasPermission( 'bit_p_fisheye_upload_nonimages' ) ) { + fisheye_store_upload( $pFileHash ); + } else { + $errors['upload'] = tra( 'Your upload could not be processed because it was determined to be a non-image and you only have permission to upload images.' ); + } + } + return $errors; +} + +// Recursively builds a tree where each directory represents a gallery, and files are assumed to be images. +function fisheye_process_directory( $pDestinationDir, &$pParentGallery, $pRoot=FALSE ) { + $errors = array(); + if( $archiveDir = opendir( $pDestinationDir ) ) { + $order = 100; + while( $fileName = readdir($archiveDir) ) { + $sortedNames[] = $fileName; + } + sort( $sortedNames ); + foreach( $sortedNames as $fileName ) { + if( !preg_match( '/^\./', $fileName ) ) { + $scanFile = array( + 'name' => $fileName, + 'size' => filesize( "$pDestinationDir/$fileName" ), + 'tmp_name' => "$pDestinationDir/$fileName", + ); + + if( !empty( $_REQUEST['resize'] ) && is_numeric( $_REQUEST['resize'] ) ) { + $scanFile['max_height'] = $scanFile['max_width'] = $_REQUEST['resize']; + } + + if( is_dir( $pDestinationDir.'/'.$fileName ) ) { + // We found a new Gallery! + $newGallery = new FisheyeGallery(); + $galleryHash = array( 'title' => str_replace( '_', ' ', $fileName ) ); + if( $newGallery->store( $galleryHash ) ) { + if( $pRoot ) { + $newGallery->addToGalleries( $_REQUEST['galleryAdditions'] ); + } + if( is_object( $pParentGallery ) ) { + $pParentGallery->addItem( $newGallery->mContentId, $order ); + } + //recurse down in! + $errors = array_merge( $errors, fisheye_process_archive( $scanFile, $newGallery ) ); + } else { + $errors = array_merge( $errors, array_values( $newGallery->mErrors ) ); + } + } else { + $newImage = new FisheyeImage(); + $imageHash = array( 'upload' => $scanFile ); + if( $newImage->store( $imageHash ) ) { + if( $pRoot ) { + $newImage->addToGalleries( $_REQUEST['galleryAdditions'] ); + } + if( !is_object( $pParentGallery ) ) { + global $gBitUser; + $pParentGallery = new FisheyeGallery( fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) ); + $pParentGallery->load(); + } + $pParentGallery->addItem( $newImage->mContentId ); + } else { + $errors = array_merge( $errors, array_values( $newImage->mErrors ) ); + } + } + $order += 10; + } + } + } +} +?> |
