diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:54:15 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:54:15 +0100 |
| commit | 4f72c4761359485da48b19eb8d9cf525797e7df8 (patch) | |
| tree | fe82ef7aa5142b6aca98dbfa49445df3897e1f56 /includes | |
| parent | 7c55576c11eaa4586f93461cbd70c54b74b38c36 (diff) | |
| download | fisheye-4f72c4761359485da48b19eb8d9cf525797e7df8.tar.gz fisheye-4f72c4761359485da48b19eb8d9cf525797e7df8.tar.bz2 fisheye-4f72c4761359485da48b19eb8d9cf525797e7df8.zip | |
php-cs-fixer tidies to php8.5 standards
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rwxr-xr-x | includes/bit_setup_inc.php | 10 | ||||
| -rwxr-xr-x | includes/classes/FisheyeBase.php | 8 | ||||
| -rwxr-xr-x | includes/classes/FisheyeGallery.php | 86 | ||||
| -rwxr-xr-x | includes/classes/FisheyeImage.php | 65 | ||||
| -rwxr-xr-x | includes/classes/FisheyeRemote.php | 87 | ||||
| -rwxr-xr-x | includes/gallery_lookup_inc.php | 2 | ||||
| -rwxr-xr-x | includes/upload_inc.php | 6 |
7 files changed, 121 insertions, 143 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index f048d3c..4e9d190 100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -11,9 +11,9 @@ $pRegisterHash = [ define( 'FISHEYE_PKG_NAME', $pRegisterHash['package_name'] ); define( 'FISHEYE_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' ); define( 'FISHEYE_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' ); -define( 'FISHEYE_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); +define( 'FISHEYE_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); define( 'FISHEYE_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/'); -define( 'FISHEYE_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); +define( 'FISHEYE_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); $gBitSystem->registerPackage( $pRegisterHash ); @@ -33,15 +33,15 @@ if( $gBitSystem->isPackageActive( 'fisheye' ) ) { // && $gBitUser->hasPermission define( 'LIBERTY_SERVICE_PHOTOSHARING', 'photosharing'); - $gLibertySystem->registerService( LIBERTY_SERVICE_PHOTOSHARING, FISHEYE_PKG_NAME, array( + $gLibertySystem->registerService( LIBERTY_SERVICE_PHOTOSHARING, FISHEYE_PKG_NAME, [ 'users_expunge_function' => 'fisheye_expunge_user', - ) ); + ] ); function fisheye_expunge_user( $pObject ) { global $gBitDb; if( !empty( $pObject->mUserId ) ) { $query = "SELECT fg.`content_id` FROM `".BIT_DB_PREFIX."fisheye_gallery` fg INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON(fg.`content_id`=lc.`content_id`) WHERE lc.`user_id`=?"; - if( $galleries = $gBitDb->getCol( $query, array( $pObject->mUserId ) ) ) { + if( $galleries = $gBitDb->getCol( $query, [ $pObject->mUserId ] ) ) { foreach( $galleries as $contentId ) { $delGallery = new FisheyeGallery( null, $contentId ); if( $delGallery->load() ) { diff --git a/includes/classes/FisheyeBase.php b/includes/classes/FisheyeBase.php index 3cca1bd..f4b267c 100755 --- a/includes/classes/FisheyeBase.php +++ b/includes/classes/FisheyeBase.php @@ -7,6 +7,7 @@ * required setup */ namespace Bitweaver\Fisheye; + use Bitweaver\Liberty\LibertyMime; // FisheyeGallery base class use Bitweaver\Liberty\LibertyContent; @@ -37,9 +38,9 @@ abstract class FisheyeBase extends LibertyMime public function isMachineName( $pString ) { if ( !empty($pString) ) { return preg_match( '/(^[0-9][-0-9 ]*$)|(^[-0-9 ]*(img|dsc|dscn|pict|htg|dscf|p)[-0-9 ][-0-9 ]*.*$)/i', trim( $pString ) ); - } else { - return ''; } + return ''; + } // Gets a list of galleries which this item is attached to @@ -205,7 +206,6 @@ not ready for primetime return $ret; } - public function addToGalleries( $pGalleryArray ) { global $gBitSystem; if( $this->isValid() ) { @@ -219,7 +219,7 @@ not ready for primetime case 'newest': $galleryId = $this->mDb->getAssoc( "SELECT `gallery_id` FROM `".BIT_DB_PREFIX."fisheye_gallery` fg INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (fg.`content_id`=lg.`content_id`) WHERE `user_id` = ? ORDER BY gallery_id DESC", [ $this->getField( 'user_id' ) ] ); break; - + } } if( empty( $inGalleries[$galleryId] ) ) { diff --git a/includes/classes/FisheyeGallery.php b/includes/classes/FisheyeGallery.php index 19a23fd..16d5b88 100755 --- a/includes/classes/FisheyeGallery.php +++ b/includes/classes/FisheyeGallery.php @@ -7,8 +7,8 @@ * required setup */ namespace Bitweaver\Fisheye; + use Bitweaver\BitBase; -use Bitweaver\KernelTools; use Bitweaver\Liberty\LibertyContent; define( 'FISHEYE_PAGINATION_FIXED_GRID', 'fixed_grid' ); @@ -52,8 +52,8 @@ class FisheyeGallery extends FisheyeBase { 'handler_class' => 'FisheyeGallery', 'handler_package' => 'fisheye', 'handler_file' => 'FisheyeGallery.php', - 'maintainer_url' => 'https://www.bitweaver.org' - ] ); + 'maintainer_url' => 'https://www.bitweaver.org', + ], ); // Permission setup $this->mViewContentPerm = 'p_fisheye_view'; @@ -81,7 +81,7 @@ class FisheyeGallery extends FisheyeBase { $lookupContentId = null; if (!empty($pLookupHash['gallery_id']) && is_numeric($pLookupHash['gallery_id'])) { if( $lookup = $gBitDb->getRow( "SELECT lc.`content_id`, lc.`content_type_guid` FROM `".BIT_DB_PREFIX."fisheye_gallery` fg INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON(lc.`content_id`=fg.`content_id`) WHERE `gallery_id`=?", [ $pLookupHash['gallery_id'] ] ) ) { - $lookupContentId = $lookup['content_id']; + $lookupContentId = $lookup['content_id']; $lookupContentGuid = $lookup['content_type_guid']; } } elseif (!empty($pLookupHash['content_id']) && is_numeric($pLookupHash['content_id'])) { @@ -100,7 +100,7 @@ class FisheyeGallery extends FisheyeBase { global $gBitSystem; $bindVars = []; $selectSql = $joinSql = $whereSql = ''; - + if( $this->verifyId( $this->mGalleryId ) ) { $whereSql = " WHERE fg.`gallery_id` = ?"; $bindVars = [ $this->mGalleryId ]; @@ -124,16 +124,16 @@ class FisheyeGallery extends FisheyeBase { $whereSql"; $rs = $this->mDb->getRow($query, $bindVars); if( !empty($rs) ) { - $this->mInfo = $rs; - $this->mContentId = $rs['content_id']; + $this->mInfo = $rs; + $this->mContentId = $rs['content_id']; LibertyContent::load(); if( @$this->verifyId($this->mInfo['gallery_id'] ) ) { $this->mGalleryId = $this->mInfo['gallery_id']; $this->mContentId = $this->mInfo['content_id']; - $this->mInfo['creator'] = isset( $rs['creator_real_name'] ) ? $rs['creator_real_name'] : $rs['creator_user']; - $this->mInfo['editor'] = isset( $rs['modifier_real_name'] ) ? $rs['modifier_real_name'] : $rs['modifier_user']; + $this->mInfo['creator'] = $rs['creator_real_name'] ?? $rs['creator_user']; + $this->mInfo['editor'] = $rs['modifier_real_name'] ?? $rs['modifier_user']; // Set some basic defaults for how to display a gallery if they're not already set if (empty($this->mInfo['thumbnail_size'])) { @@ -227,7 +227,7 @@ class FisheyeGallery extends FisheyeBase { $orderSql = $gBitSystem->isFeatureActive( 'fisheye_gallery_default_sort_mode' ) ? ", ".$this->mDb->convertSortmode( $gBitSystem->getConfig( 'fisheye_gallery_default_sort_mode' ) ) : ", fgim.`item_content_id`"; - + // load for just a single page if( $pListHash['page'] != -1 ) { if( $this->getLayout() == FISHEYE_PAGINATION_POSITION_NUMBER ) { @@ -236,7 +236,7 @@ class FisheyeGallery extends FisheyeBase { WHERE gallery_content_id=? ORDER BY floor(item_position)"; $mantissa = $this->mDb->getOne( $query, [ $this->mContentId ], 1, $pListHash['page'] - 1 ); - // gallery image order with no positions set will have null mantissa, and all images will be shown + // gallery image order with no positions set will have null mantissa, and all images will be shown if( !is_null( $mantissa ) ) { $whereSql .= " AND floor(item_position)=? "; array_push( $bindVars, $mantissa ); @@ -261,7 +261,7 @@ class FisheyeGallery extends FisheyeBase { WHERE fgim.`gallery_content_id` = ? $whereSql ORDER BY fgim.`item_position` $orderSql"; $rows = $this->mDb->query($query, $bindVars, $rowCount, $offset); - foreach ($rows as $row) { + foreach ($rows as $row) { $pass = true; if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) { $pass = $gBitUser->hasPermission( 'p_fisheye_admin' ) || !@$this->verifyId( $row['security_id'] ) || ( $row['user_id'] == $gBitUser->mUserId ) || @$this->verifyId( $_SESSION['gatekeeper_security'][$row['security_id']] ); @@ -279,7 +279,7 @@ class FisheyeGallery extends FisheyeBase { LibertyContent::postGetList( $pListHash ); - return \count ( $this->mItems ) > 0; + return \count ( $this->mItems ) > 0; } public function getImageList() { @@ -393,7 +393,6 @@ class FisheyeGallery extends FisheyeBase { return count($this->mErrors) == 0; } - public function generateGalleryThumbnails(): void { if( $this->isValid() ) { if( $this->loadImages() ) { @@ -404,7 +403,6 @@ class FisheyeGallery extends FisheyeBase { } } - public function getThumbnailContentId() { if( !$this->getField( 'thumbnail_content_id' ) ) { $this->getThumbnailImage(); @@ -422,7 +420,6 @@ class FisheyeGallery extends FisheyeBase { } } - public function getThumbnailUrl( string $pSize = 'small', ?array $pInfoHash = null, ?int $pSecondaryId = null, ?int $pDefault = null ): string|null { if( empty( $this->mInfo['preview_content'] ) ) { $this->loadThumbnail(); @@ -434,7 +431,6 @@ class FisheyeGallery extends FisheyeBase { return ''; } - public function getThumbnailImage( $pContentId=null, $pThumbnailContentId=null, $pThumbnailContentType=null ) { global $gLibertySystem, $gBitUser; $ret = null; @@ -491,7 +487,6 @@ class FisheyeGallery extends FisheyeBase { return $ret; } - public function loadThumbnail( $pSize='small', $pContentId=null ) { if( $this->mPreviewImage = $this->getThumbnailImage( $pContentId ) ) { $this->mInfo['preview_content'] = &$this->mPreviewImage; @@ -499,7 +494,6 @@ class FisheyeGallery extends FisheyeBase { } } - public function storeGalleryThumbnail($pContentId = null) { $ret = false; if ($pContentId && !$this->isInGallery( $this->mContentId, $pContentId ) ) { @@ -557,11 +551,11 @@ class FisheyeGallery extends FisheyeBase { return $ret; } - /** - * Adds a new item (image or gallery) to this gallery. We check to make sure we are not a member + /** + * Adds a new item (image or gallery) to this gallery. We check to make sure we are not a member * of this gallery and this gallery is not a member of the new item to avoid infinite recursion scenarios - * @return bool wheter or not the item was added - */ + * @return bool wheter or not the item was added + */ public function addItem( $pContentId, $pPosition=null ) { global $gBitSystem; $ret = false; @@ -615,7 +609,6 @@ class FisheyeGallery extends FisheyeBase { return true; } - public function galleryExistsInDatabase() { $ret = false; @@ -631,10 +624,10 @@ class FisheyeGallery extends FisheyeBase { return $ret; } - /** - * Returns the layout of the gallery accounting for various defaults - * @return string the layout string preference - */ + /** + * Returns the layout of the gallery accounting for various defaults + * @return string the layout string preference + */ public function getLayout() { global $gBitSystem; return $this->getPreference( 'gallery_pagination', $gBitSystem->getConfig( 'default_gallery_pagination', FISHEYE_PAGINATION_GALLERIFFIC ) ); @@ -651,30 +644,30 @@ class FisheyeGallery extends FisheyeBase { ]; } - /** - * Returns include file that will setup the object for rendering - * @return string the fully specified path to file to be included - */ + /** + * Returns include file that will setup the object for rendering + * @return string the fully specified path to file to be included + */ public function getRenderFile() { return FISHEYE_PKG_INCLUDE_PATH.'display_fisheye_gallery_inc.php'; } - /** - * Returns template file used for display - * @return string the fully specified path to file to be included - */ + /** + * Returns template file used for display + * @return string the fully specified path to file to be included + */ public function getRenderTemplate() { return 'bitpackage:fisheye/view_gallery.tpl'; } - /** - * Function that returns link to display a piece of content - * @param array pGalleryId id of gallery to link - * @return string the url to display the gallery. - */ + /** + * Function that returns link to display a piece of content + * @param array pGalleryId id of gallery to link + * @return string the url to display the gallery. + */ public static function getDisplayUrlFromHash( &$pParamHash ) { $path = null; - $ret = ''; + $ret = ''; if( BitBase::verifyIdParameter( $pParamHash, 'gallery_id' ) ) { $ret = FISHEYE_PKG_URL; global $gBitSystem; @@ -790,8 +783,6 @@ class FisheyeGallery extends FisheyeBase { WHERE lc.`content_type_guid` = 'fisheyegallery' $whereSql ORDER BY T.BRANCH, fgimo.`item_position`"; - - if( !empty( $bindVars ) ) { FisheyeGallery::splitConnectByTree( $ret, $gBitDb->GetAssoc( $query, $bindVars ) ); } else { @@ -911,7 +902,6 @@ class FisheyeGallery extends FisheyeBase { return $ret; } - // Generate a select drop menu of listed galleries public function generateMenu( $pListHash, $pOptions, $pLocate=null ) { $ret = "<select class='form-control' "; @@ -1036,7 +1026,7 @@ class FisheyeGallery extends FisheyeBase { if( empty( $pListHash['no_thumbnails'] ) ) { $thumbsize = !empty( $pListHash['thumbnail_size'] ) ? $pListHash['thumbnail_size'] : 'small'; foreach( array_keys( $data ) as $galleryId ) { - $data[$galleryId]['display_url'] = static::getDisplayUrlFromHash( $data[$galleryId] ); + $data[$galleryId]['display_url'] = static::getDisplayUrlFromHash( $data[$galleryId] ); $data[$galleryId]['display_uri'] = static::getDisplayUriFromHash( $data[$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 ); @@ -1077,7 +1067,7 @@ class FisheyeGallery extends FisheyeBase { if( $zip->open ($filename, \ZIPARCHIVE::OVERWRITE) !== true ){ $this->mErrors['download'] = "Unable to create zip file"; }else{ - addGalleryRecursive( $this->mGalleryId, $zip, $path); + addGalleryRecursive( $this->mGalleryId, $zip, $path); } $zip->close(); @@ -1122,7 +1112,7 @@ function addGalleryRecursive( $pGalleryId, &$pZip, $pPath = '/' ){ $title = $item->getTitle(); $pZip->addFile($sourcePath, $pPath.$title.substr($sourcePath,strrpos($sourcePath,'.')) ); } elseif ( is_a( $item , '\Bitweaver\Fisheye\FisheyeGallery' ) ) { - addGalleryRecursive( $item->mGalleryId, $pZip ,$pPath ); + addGalleryRecursive( $item->mGalleryId, $pZip ,$pPath ); } } } diff --git a/includes/classes/FisheyeImage.php b/includes/classes/FisheyeImage.php index d367d15..c2a1a25 100755 --- a/includes/classes/FisheyeImage.php +++ b/includes/classes/FisheyeImage.php @@ -7,6 +7,7 @@ * required setup */ namespace Bitweaver\Fisheye; + use Bitweaver\Liberty\LibertyContent; use Bitweaver\Liberty\LibertyMime; use Bitweaver\BitBase; @@ -35,8 +36,8 @@ class FisheyeImage extends FisheyeBase { 'handler_class' => 'FisheyeImage', 'handler_package' => 'fisheye', 'handler_file' => 'FisheyeImage.php', - 'maintainer_url' => 'https://www.bitweaver.org' - ] ); + 'maintainer_url' => 'https://www.bitweaver.org', + ], ); // Permission setup $this->mViewContentPerm = 'p_fisheye_view'; @@ -103,8 +104,8 @@ class FisheyeImage extends FisheyeBase { $this->mImageId = $this->mInfo['image_id']; $this->mContentId = $this->mInfo['content_id']; - $this->mInfo['creator'] = isset( $this->mInfo['creator_real_name'] ) ? $this->mInfo['creator_real_name'] : $this->mInfo['creator_user']; - $this->mInfo['editor'] = isset( $this->mInfo['modifier_real_name'] ) ? $this->mInfo['modifier_real_name'] : $this->mInfo['modifier_user']; + $this->mInfo['creator'] = $this->mInfo['creator_real_name'] ?? $this->mInfo['creator_user']; + $this->mInfo['editor'] = $this->mInfo['modifier_real_name'] ?? $this->mInfo['modifier_user']; if( $gBitSystem->isPackageActive( 'gatekeeper' ) && !@$this->verifyId( $this->mInfo['security_id'] ) ) { // check to see if this image is in a protected gallery @@ -363,7 +364,7 @@ class FisheyeImage extends FisheyeBase { $fileHash['size'] = filesize( $fileHash['source_file'] ); $fileHash['dest_branch'] = dirname( $this->getSourceFile() ).'/'; $fileHash['name'] = $this->getField( 'file_name' ); - if( $pDegrees == 'auto' ) { + if( $pDegrees == 'auto' ) { if( $exifOrientation = $this->getExifField( 'orientation' ) ) { switch( $exifOrientation ) { case 1: //) transform="";; @@ -397,7 +398,7 @@ class FisheyeImage extends FisheyeBase { } if( is_numeric( $pDegrees ) ) { $fileHash['degrees'] = $pDegrees; - + if( ($rotateFunc = \Bitweaver\Liberty\liberty_get_function( 'rotate' )) && $rotateFunc( $fileHash ) ) { \Bitweaver\Liberty\liberty_clear_thumbnails( $fileHash ); $this->mDb->getOne( "UPDATE `".BIT_DB_PREFIX."fisheye_image` SET `width`=`height`, `height`=`width` WHERE `content_id`=?", [ $this->mContentId ] ); @@ -413,7 +414,6 @@ class FisheyeImage extends FisheyeBase { return count($this->mErrors) == 0; } - /** * convertColorspace * @@ -443,7 +443,6 @@ class FisheyeImage extends FisheyeBase { return $ret; } - public function resizeOriginal( $pResizeOriginal ) { global $gBitSystem; if( $this->getField( 'file_name' ) || $this->load() ) { @@ -492,7 +491,6 @@ class FisheyeImage extends FisheyeBase { return count($this->mErrors) == 0; } - public function generateThumbnails( $pResizeOriginal=null, $pImmediateRender=false ) { global $gBitSystem; $ret = false; @@ -510,7 +508,6 @@ class FisheyeImage extends FisheyeBase { return $ret; } - public function renderThumbnails( $pThumbSizes=null ) { global $gBitSystem; if( $this->getField( 'file_name' ) || $this->load() ) { @@ -594,27 +591,27 @@ class FisheyeImage extends FisheyeBase { return $this->getField('height'); } - /** - * Returns include file that will setup vars for display - * @return string the fully specified path to file to be included - */ + /** + * Returns include file that will setup vars for display + * @return string the fully specified path to file to be included + */ public function getRenderFile() { return FISHEYE_PKG_INCLUDE_PATH.'display_fisheye_image_inc.php'; } - /** - * Returns template file used for display - * @return string the fully specified path to file to be included - */ + /** + * Returns template file used for display + * @return string the fully specified path to file to be included + */ public function getRenderTemplate() { return 'bitpackage:fisheye/view_image.tpl'; } - /** - * Function that returns link to display a piece of content - * @param array pParamHash if a string, it is assumed to be the size, if an array, it is assumed to be a mInfo hash - * @return string the url to display the gallery. - */ + /** + * Function that returns link to display a piece of content + * @param array pParamHash if a string, it is assumed to be the size, if an array, it is assumed to be a mInfo hash + * @return string the url to display the gallery. + */ public static function getDisplayUrlFromHash( &$pParamHash ) { $ret = ''; $size = (!empty( $pParamHash['size'] ) && is_string( $pParamHash['size'] ) && isset( $pParamHash['thumbnail_url'][$pParamHash['size']] ) ) ? $pParamHash['size'] : null ; @@ -644,10 +641,10 @@ class FisheyeImage extends FisheyeBase { return $ret; } - /** - * Function that returns link to display an image - * @return string the url to display the gallery. - */ + /** + * Function that returns link to display an image + * @return string the url to display the gallery. + */ public function getDisplayUrl() { $info = &$this->mInfo; $info['image_id'] = $this->mImageId; @@ -655,12 +652,12 @@ class FisheyeImage extends FisheyeBase { return FisheyeImage::getDisplayUrlFromHash( $info ); } - /** - * Function that returns link to display an image - * Used to display thumbnails for navigation bar - * @param integer pImageId id of image to link - * @return string the url to display the image. - */ + /** + * Function that returns link to display an image + * Used to display thumbnails for navigation bar + * @param integer pImageId id of image to link + * @return string the url to display the image. + */ public function getImageUrl( $pImageId ) { $info = [ 'image_id' => $pImageId ]; return FisheyeImage::getDisplayUrlFromHash( $info ); @@ -718,7 +715,6 @@ class FisheyeImage extends FisheyeBase { return $ret; } - public function getThumbnailContentId() { return $this->mContentId; } @@ -800,7 +796,6 @@ class FisheyeImage extends FisheyeBase { return $ret; } - public function getList( &$pListHash ) { global $gBitUser,$gBitSystem; diff --git a/includes/classes/FisheyeRemote.php b/includes/classes/FisheyeRemote.php index d4da14e..9eee150 100755 --- a/includes/classes/FisheyeRemote.php +++ b/includes/classes/FisheyeRemote.php @@ -24,6 +24,7 @@ * required setup */ namespace Bitweaver\Fisheye; + use Bitweaver\KernelTools; define( 'FEG2REMOTE_SUCCESS', 0 ); @@ -63,10 +64,9 @@ class FisheyeRemote { return '2.14'; } - // separate out pPostData and pParamhash data since some plugins can populate _POST['g2_form'] and _GET['g2_form'] differently. // weird but true. ubermind is an example - public function processRequest( $pGetData, $pPostData ) { + public function processRequest( $pGetData, $pPostData ) { $pData = array_merge($pGetData, $pPostData); //Some programs (galleryexport) pass both post and get...and the cmd can be in either get or post if(!empty($pData)){ @@ -127,17 +127,16 @@ class FisheyeRemote { if( !empty( $response ) ) { print $this->sendResponse( $response ); } - } - + } - public function cmdNoOp( $pParamHash ) { + public function cmdNoOp( $pParamHash ) { global $gBitUser; - + $response = $this->createResponse( FEG2REMOTE_SUCCESS, 'No-op successful' ); return $response; - } + } - public function cmdLogin( $pParamHash ) { + public function cmdLogin( $pParamHash ) { global $gBitUser, $gBitSystem; $url = $gBitUser->login( $pParamHash['uname'], $pParamHash['password'] ); $response = $gBitUser->isRegistered() @@ -151,13 +150,13 @@ class FisheyeRemote { : $this->createResponse( FEG2REMOTE_PASSWORD_WRONG, 'Invalid username or password' ); return $response; - } + } // Recursively traverses a multi-dimensional array of galleries public function traverseGalleries( &$pGalHash, &$pResponse ) { global $gBitUser; - // Albums don't like being 0 indexed + // Albums don't like being 0 indexed $this->mSubGalIdx = 0; // the lightroom client is dumb, and can only handle one 0 level parent @@ -171,20 +170,20 @@ class FisheyeRemote { $pResponse['album.perms.del_alb.' . $this->mSubGalIdx] = 'false'; $pResponse['album.perms.create_sub.' . $this->mSubGalIdx] = 'true'; } - + return $this->traverseSubGalleries( $pGalHash, $pResponse, 1 ); } - /** - * Function that returns link to display a piece of content - * @param $pGalHash branch of gallery information from FisheyeGallery::getTree - * @param $pResponse aggregate string containing response array - * @param $pParentRandom depth of pGalHash - this is used to non-definitively uniquify album.parent and album.name entries - * @return string the url to display the gallery. - */ + /** + * Function that returns link to display a piece of content + * @param $pGalHash branch of gallery information from FisheyeGallery::getTree + * @param $pResponse aggregate string containing response array + * @param $pParentRandom depth of pGalHash - this is used to non-definitively uniquify album.parent and album.name entries + * @return string the url to display the gallery. + */ public function traverseSubGalleries( &$pGalHash, &$pResponse, $pParentRandom ) { global $gBitUser; - foreach( $pGalHash as $key=>$gallery) { + foreach( $pGalHash as $key=>$gallery) { $this->mSubGalIdx++; // Any number greater than 2 digits crashes iPhoto2Gallery @@ -199,8 +198,8 @@ class FisheyeRemote { // append pParentRandom to make .name probably unique since Fisheye can handle one gallery linked to multiple parents $pResponse['album.name.' . $this->mSubGalIdx] = $gallery['content']['content_id'].$randomizer; $pResponse['album.title.' . $this->mSubGalIdx] = $this->cleanResponseValue( $gallery['content']['title'] ); - - if( !empty( $gallery['content']['data'] ) ) { + + if( !empty( $gallery['content']['data'] ) ) { $pResponse['album.summary.' . $this->mSubGalIdx] = $gallery['content']['data']; $pResponse['album.info.extrafields.' . $this->mSubGalIdx] = "Summary"; } @@ -209,16 +208,16 @@ class FisheyeRemote { $pResponse['album.perms.write.' . $this->mSubGalIdx] = 'true'; $pResponse['album.perms.del_alb.' . $this->mSubGalIdx] = 'true'; $pResponse['album.perms.create_sub.' . $this->mSubGalIdx] = 'true'; - - if( !empty( $gallery['children'] ) ) { + + if( !empty( $gallery['children'] ) ) { $this->traverseSubGalleries($gallery['children'],$pResponse, $randomizer ); } } $ret = $this->mSubGalIdx; return $ret; - } + } - public function cmdFetchAlbums( $pParamHash ) { + public function cmdFetchAlbums( $pParamHash ) { require_once FISHEYE_PKG_CLASS_PATH.'FisheyeGallery.php'; global $gBitUser; if( $gBitUser->isRegistered() ) { @@ -238,10 +237,9 @@ class FisheyeRemote { $response = $this->createResponse( FEG2REMOTE_PASSWORD_WRONG, 'Application not logged in' ); } return $response; - } - + } - public function cmdAddItem( $pParamHash ) { + public function cmdAddItem( $pParamHash ) { $response = []; $uploadFile = !empty( $_FILES['g2_userfile'] ) ? $_FILES['g2_userfile'] : null; @@ -255,22 +253,22 @@ class FisheyeRemote { $storeHash['summary'] = !empty( $pParamHash['extrafield.Summary'] ) ? $pParamHash['extrafield.Summary'] : null; $storeHash['edit'] = !empty( $pParamHash['extrafield.Description'] ) ? $pParamHash['extrafield.Description'] : null; - require_once FISHEYE_PKG_INCLUDE_PATH.'upload_inc.php'; - + require_once FISHEYE_PKG_INCLUDE_PATH.'upload_inc.php'; + $parentGallery = new FisheyeGallery(); if( $parentGallery = $parentGallery->lookup([ 'content_id' => $pParamHash['set_albumName'] ] ) ) { $parentGallery->load(); $storeHash['gallery_additions'] = [ $parentGallery->mGalleryId ]; } $response = $errors = fisheye_store_upload( $uploadFile , $storeHash ) - ? $response = $this->createResponse( FEG2REMOTE_UPLOAD_PHOTO_FAIL, 'Export Failed' ) + ? $response = $this->createResponse( FEG2REMOTE_UPLOAD_PHOTO_FAIL, 'Export Failed' ) : $this->createResponse( FEG2REMOTE_SUCCESS, 'Image added', [ 'item_name'=>$uploadFile['name'] ] ); } - + return $response; - } + } - public function cmdNewAlbum( $pParamHash ) { + public function cmdNewAlbum( $pParamHash ) { global $gBitUser; $response = []; @@ -280,7 +278,7 @@ class FisheyeRemote { $storeHash['title'] = !empty($pParamHash['newAlbumTitle']) ? $pParamHash['newAlbumTitle'] : ''; $storeHash['edit'] = !empty($pParamHash['newAlbumDesc']) ? $pParamHash['newAlbumDesc'] : ''; - $gallery = new FisheyeGallery(); + $gallery = new FisheyeGallery(); $gallery->store( $storeHash ); if($pParamHash['set_albumName']){ @@ -294,9 +292,9 @@ class FisheyeRemote { $response = $this->createResponse( FEG2REMOTE_SUCCESS, 'Gallery created', [ 'album_name' => $storeHash['title'] ] ); return $response; - } + } - public function sendResponse( $pResponse ) { + public function sendResponse( $pResponse ) { global $gBitUser; print "#__GR2PROTO__\n"; //error_log( "#__GR2PROTO__".' : '.$gBitUser->mUserId ); @@ -308,13 +306,12 @@ class FisheyeRemote { print "auth_token=".$gBitUser->mTicket; //error_log( "auth_token=".$gBitUser->mTicket ); //error_log( "#__end__" ); - } + } - public function createResponse( $pStatus, $pStatusText, $pExtra = null ) { $ret = []; - - // Each response must contain at least the keys: status and status_text. + + // Each response must contain at least the keys: status and status_text. $ret['status'] = $this->cleanResponseValue( $pStatus ); // translate the text response for i18n $ret['status_text'] = $this->cleanResponseValue( KernelTools::tra( $pStatusText ) ); @@ -328,22 +325,20 @@ class FisheyeRemote { } /** - * This will clean up the response value to make sure it is in an acceptable format for the remote client. + * This will clean up the response value to make sure it is in an acceptable format for the remote client. * Gallery apparently is very particular about the manner in which this data is cleaned up, and must be done * in this specific order. */ - public function cleanResponseValue( $pValue ) { + public function cleanResponseValue( $pValue ) { $pValue = str_replace('\\', '\\\\', $pValue); $pValue = str_replace("\r\n", '\n', $pValue); $pValue = str_replace([ "\r", "\n", "\t" ], [ '\n', '\n', '\t' ], $pValue); $pValue = str_replace([ '#', '!', '=' ], [ '\\#', '\\!', '\\=' ], $pValue); return $pValue; - } - + } public function cleanResponseKey( $pKey ) { return str_replace([ '#', '!', '=', ':' ], [ '\\#', '\\!', '\\=', '\\:' ], $pKey); } - } diff --git a/includes/gallery_lookup_inc.php b/includes/gallery_lookup_inc.php index eca8188..28d652a 100755 --- a/includes/gallery_lookup_inc.php +++ b/includes/gallery_lookup_inc.php @@ -12,7 +12,7 @@ $lookup = []; if( !$gContent = FisheyeGallery::lookup( $_REQUEST ) ) { $gContent = new FisheyeGallery(); $galleryId = null; -} +} if( !empty( $_REQUEST['gallery_path'] ) ) { $gContent->setGalleryPath( $_REQUEST['gallery_path'] ); diff --git a/includes/upload_inc.php b/includes/upload_inc.php index dbc47f3..cab8b30 100755 --- a/includes/upload_inc.php +++ b/includes/upload_inc.php @@ -78,7 +78,6 @@ function fisheye_handle_upload( &$pFiles ) { return $upErrors; } - /** * fisheye_sort_upload */ @@ -96,7 +95,7 @@ function fisheye_get_default_gallery_id( $pUserId, $pNewName ) { $upList = $gal->getList( $getHash ); if( !empty( $upList ) ) { $ret = key( $upList ); - } else { + } else { $galleryHash = [ 'title' => $pNewName ]; if( $gal->store( $galleryHash ) ) { $ret = $gal->mGalleryId; @@ -119,7 +118,7 @@ function fisheye_store_upload( &$pFileHash, $pImageData = [], $pAutoRotate=true $ret = []; // verifyMimeType to make sure we are working with the proper file type assumptions - $pFileHash['type'] = $gBitSystem->verifyMimeType($pFileHash['tmp_name']); + $pFileHash['type'] = $gBitSystem->verifyMimeType($pFileHash['tmp_name']); if( !empty( $pFileHash ) && ( $pFileHash['size'] > 0 ) && is_file( $pFileHash['tmp_name'] ) && fisheye_verify_upload_item( $pFileHash ) ) { // make a copy for each image we need to store $image = new FisheyeImage(); @@ -276,7 +275,6 @@ function fisheye_process_directory( $pDestinationDir, &$pParentGallery, $pRoot=f return $errors; } - // this function will process a directory and all it's sub directories without // making any assumptions. hierarchy of sub directories is maintained and // archives can be processed or simply added to the galleries. |
