diff options
| author | lsces <lester@lsces.co.uk> | 2025-08-28 16:21:17 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2025-08-28 16:21:17 +0100 |
| commit | bb1d0a4f7da3f9438f3b906c560d19867a3e4e5d (patch) | |
| tree | a49f5f6906a2cb1e27a4d303721e60931bfd3eb4 | |
| parent | 7a981e40e60ac07b2e57932d6434dfb7ee7b5fb4 (diff) | |
| download | fisheye-bb1d0a4f7da3f9438f3b906c560d19867a3e4e5d.tar.gz fisheye-bb1d0a4f7da3f9438f3b906c560d19867a3e4e5d.tar.bz2 fisheye-bb1d0a4f7da3f9438f3b906c560d19867a3e4e5d.zip | |
Extra code updated to PHP8.4 and namespace ... work in progress on updating some third party code
| -rwxr-xr-x[-rw-r--r--] | includes/bit_setup_inc.php | 32 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/display_fisheye_gallery_inc.php | 56 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/display_fisheye_image_inc.php | 9 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/gallery_lookup_inc.php | 11 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/image_lookup_inc.php | 20 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/upload_inc.php | 129 |
6 files changed, 122 insertions, 135 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index c61aa3e..f048d3c 100644..100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -1,25 +1,34 @@ <?php +use \Bitweaver\Fisheye\FisheyeGallery; global $gBitSystem, $gBitUser, $gBitSmarty, $gBitThemes; -$registerHash = array( +$pRegisterHash = [ 'package_name' => 'fisheye', 'package_path' => dirname( dirname( __FILE__ ) ).'/', - 'homeable' => TRUE, -); -$gBitSystem->registerPackage( $registerHash ); + 'homeable' => true, +]; +// fix to quieten down VS Code which can't see the dynamic creation of these ... +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_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/'); +define( 'FISHEYE_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); -if( $gBitSystem->isPackageActive( 'fisheye' ) ) { +$gBitSystem->registerPackage( $pRegisterHash ); + +if( $gBitSystem->isPackageActive( 'fisheye' ) ) { // && $gBitUser->hasPermission( 'p_fisheye_view' )) { // Default Preferences Defines define ( 'FISHEYE_DEFAULT_ROWS_PER_PAGE', 5 ); define ( 'FISHEYE_DEFAULT_COLS_PER_PAGE', 2 ); define ( 'FISHEYE_DEFAULT_THUMBNAIL_SIZE', 'large' ); - $menuHash = array( + $menuHash = [ 'package_name' => FISHEYE_PKG_NAME, 'index_url' => FISHEYE_PKG_URL.'index.php', 'menu_template' => 'bitpackage:fisheye/menu_fisheye.tpl', - ); + ]; $gBitSystem->registerAppMenu( $menuHash ); define( 'LIBERTY_SERVICE_PHOTOSHARING', 'photosharing'); @@ -34,15 +43,12 @@ if( $gBitSystem->isPackageActive( 'fisheye' ) ) { $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 ) ) ) { foreach( $galleries as $contentId ) { - $delGallery = new FisheyeGallery( NULL, $contentId ); + $delGallery = new FisheyeGallery( null, $contentId ); if( $delGallery->load() ) { - $delGallery->expunge( TRUE ); + $delGallery->expunge(); } } } } } - - include_once( FISHEYE_PKG_CLASS_PATH.'FisheyeGallery.php' ); -} -?> +}
\ No newline at end of file diff --git a/includes/display_fisheye_gallery_inc.php b/includes/display_fisheye_gallery_inc.php index f83d6e1..24bfe28 100644..100755 --- a/includes/display_fisheye_gallery_inc.php +++ b/includes/display_fisheye_gallery_inc.php @@ -4,56 +4,38 @@ * @subpackage functions */ -$displayHash = array( 'perm_name' => 'p_fisheye_view' ); -$gContent->invokeServices( 'content_display_function', $displayHash ); - -if (!empty($_REQUEST['page']) && is_numeric($_REQUEST['page'])) { - $page = $_REQUEST['page']; -} else { - $page = 0; -} +use Bitweaver\KernelTools; -if( $page > $gContent->getField( 'num_pages' ) ) { - $page = $gContent->getField( 'num_pages' ); -} elseif ($page < 1) { - $page = 1; -} +$displayHash = [ 'perm_name' => 'p_fisheye_view' ]; +$gContent->invokeServices( 'content_display_function', $displayHash ); -$imagesPerPage = $gContent->getField( 'rows_per_page' ) * $gContent->getField( 'cols_per_page', 10 ); +$listHash = $_REQUEST; +$listHash['max_records'] = 12; switch( $gContent->getLayout() ) { case 'auto_flow': - $gBitThemes->loadCss( FISHEYE_PKG_PATH."css/div_layout.css", TRUE ); + $gBitThemes->loadCss( FISHEYE_PKG_PATH."css/div_layout.css", true ); break; case 'matteo': - $gBitThemes->loadCss( FISHEYE_PKG_PATH."gallery_view/matteo/mb_layout.css", TRUE ); + $gBitThemes->loadCss( FISHEYE_PKG_PATH."gallery_view/matteo/mb_layout.css", true ); $gBitThemes->loadAjax( 'jquery' ); - $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/matteo/mbGallery.js', FALSE, 500, FALSE ); - $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/matteo/mbGalleryBox.js', FALSE, 501, FALSE ); + $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/matteo/mbGallery.js', false, 500, false ); + $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/matteo/mbGalleryBox.js', false, 501, false ); break; case 'galleriffic': - $imagesPerPage = -1; + $listHash['max_records'] = -1; // Need to add options for different styles of layout - $gBitThemes->loadCss( FISHEYE_PKG_PATH."/gallery_views/galleriffic/css/galleriffic_style_1.css", TRUE ); - $gBitThemes->loadAjax( 'jquery' ); - $gBitThemes->loadJavascript( UTIL_PKG_PATH.'javascript/jquery/plugins/migrate/jquery.migrate.js', FALSE, 500, FALSE ); - $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/galleriffic/js/jquery.galleriffic.js', FALSE, 500, FALSE ); - $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/galleriffic/js/jquery.history.js', FALSE, 501, FALSE ); - $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/galleriffic/js/jquery.opacityrollover.js', FALSE, 502, FALSE ); - $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/galleriffic/gftop.js', FALSE, 503, FALSE ); + $gBitThemes->loadCss( FISHEYE_PKG_PATH."/gallery_views/galleriffic/css/galleriffic_style_1.css", true ); + $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/galleriffic/js/jquery.galleriffic.js', false, 500, false ); + $gBitThemes->loadJavascript( FISHEYE_PKG_PATH.'/gallery_views/galleriffic/js/jquery.opacityrollover.js', false, 502, false ); break; } -$imageOffset = $imagesPerPage * ($page-1); - -$gBitSmarty->assignByRef('pageCount', $page); -$gBitSmarty->assignByRef('imagesPerPage', $imagesPerPage); -$gBitSmarty->assignByRef('imageOffset', $imageOffset); -$gBitSmarty->assignByRef('rows_per_page', $gContent->mInfo['rows_per_page']); -$gBitSmarty->assign('cols_per_page', $gContent->getField( 'cols_per_page', 10 ) ); - -$gContent->loadImages( $page, $imagesPerPage ); +$gContent->loadImages( $listHash ); +$gContent->loadParentGalleries(); $gContent->addHit(); -$gBitSystem->setBrowserTitle( $gContent->getTitle().' '.tra('Gallery') ); -$gBitSystem->display( $gContent->getRenderTemplate() , NULL, array( 'display_mode' => 'display' )); +$gBitSmarty->assign( 'listInfo', $listHash['listInfo'] ); + +$gBitSystem->setBrowserTitle( $gContent->getTitle().' '.KernelTools::tra('Gallery') ); +$gBitSystem->display( $gContent->getRenderTemplate() , null, [ 'display_mode' => 'display' ] ); diff --git a/includes/display_fisheye_image_inc.php b/includes/display_fisheye_image_inc.php index ae341e1..2dfd93f 100644..100755 --- a/includes/display_fisheye_image_inc.php +++ b/includes/display_fisheye_image_inc.php @@ -4,11 +4,14 @@ * @subpackage functions */ +use \Bitweaver\HttpStatusCodes; +use Bitweaver\KernelTools; + if( !$gContent->isValid() ) { - $gBitSystem->fatalError( tra( "No image exists with the given ID" ) ,'error.tpl', '', HttpStatusCodes::HTTP_GONE ); + $gBitSystem->fatalError( KernelTools::tra( "No image exists with the given ID" ) ,'error.tpl', '', HttpStatusCodes::HTTP_GONE ); } -$displayHash = array( 'perm_name' => 'p_fisheye_view' ); +$displayHash = [ 'perm_name' => 'p_fisheye_view' ]; $gContent->invokeServices( 'content_display_function', $displayHash ); // Get the proper thumbnail size to display on this page @@ -20,6 +23,6 @@ $gBitSystem->setBrowserTitle( $gContent->getTitle() ); if( $gBitThemes->isAjaxRequest() ) { $gBitSmarty->display( $gContent->getRenderTemplate() ); } else { - $gBitSystem->display( $gContent->getRenderTemplate() , NULL, array( 'display_mode' => 'display' )); + $gBitSystem->display( $gContent->getRenderTemplate() , null, [ 'display_mode' => 'display' ] ); } diff --git a/includes/gallery_lookup_inc.php b/includes/gallery_lookup_inc.php index b504585..eca8188 100644..100755 --- a/includes/gallery_lookup_inc.php +++ b/includes/gallery_lookup_inc.php @@ -5,13 +5,14 @@ */ global $gContent; +use \Bitweaver\Fisheye\FisheyeGallery; -$lookup = array(); +$lookup = []; if( !$gContent = FisheyeGallery::lookup( $_REQUEST ) ) { $gContent = new FisheyeGallery(); - $galleryId = NULL; -} + $galleryId = null; +} if( !empty( $_REQUEST['gallery_path'] ) ) { $gContent->setGalleryPath( $_REQUEST['gallery_path'] ); @@ -20,6 +21,6 @@ if( !empty( $_REQUEST['gallery_path'] ) ) { $gContent->setGalleryPath( '/'.$gal['gallery_id'] ); } -$gBitSmarty->assignByRef('gContent', $gContent); -$gBitSmarty->assignByRef('galleryId', $gContent->mGalleryId); +$gBitSmarty->assign('gContent', $gContent); +$gBitSmarty->assign('galleryId', $gContent->mGalleryId); diff --git a/includes/image_lookup_inc.php b/includes/image_lookup_inc.php index 8de4b0e..61e0bab 100644..100755 --- a/includes/image_lookup_inc.php +++ b/includes/image_lookup_inc.php @@ -6,19 +6,20 @@ */ global $gContent, $gGallery; - - +use \Bitweaver\Fisheye\FisheyeImage; +use \Bitweaver\Fisheye\FisheyeGallery; +; if( $gContent = FisheyeImage::lookup( $_REQUEST ) ) { // nothing to do. ::lookup will do a full load } else { $gContent = new FisheyeImage(); - $imageId = NULL; + $imageId = null; } if( !empty( $_REQUEST['gallery_path'] ) ) { $_REQUEST['gallery_path'] = rtrim( $_REQUEST['gallery_path'], '/' ); $gContent->setGalleryPath( $_REQUEST['gallery_path'] ); - $matches = array(); + $matches = []; $tail = strrpos( $_REQUEST['gallery_path'], '/' ); $_REQUEST['gallery_id'] = substr( $_REQUEST['gallery_path'], $tail + 1 ); } @@ -32,15 +33,12 @@ if( empty( $_REQUEST['gallery_id'] ) ) { // the image is considered the primary content, however the gallery is useful if( !empty($_REQUEST['gallery_id']) && is_numeric($_REQUEST['gallery_id']) ) { $gGallery = FisheyeGallery::lookup( $_REQUEST ); - $gBitSmarty->assignByRef('gGallery', $gGallery); - $gBitSmarty->assignByRef('galleryId', $_REQUEST['gallery_id']); + $gBitSmarty->assign('gGallery', $gGallery); + $gBitSmarty->assign('galleryId', $_REQUEST['gallery_id']); } // This user does not own this gallery and they have not been granted the permission to edit this gallery $gContent->verifyViewPermission(); -$gBitSmarty->assignByRef('gContent', $gContent); -$gBitSmarty->assignByRef('imageId', $gContent->mImageId ); - - -?> +$gBitSmarty->assign('gContent', $gContent); +$gBitSmarty->assign('imageId', $gContent->mImageId ); diff --git a/includes/upload_inc.php b/includes/upload_inc.php index 778b321..dbc47f3 100644..100755 --- a/includes/upload_inc.php +++ b/includes/upload_inc.php @@ -4,21 +4,24 @@ * @subpackage functions */ - +use Bitweaver\Fisheye\FisheyeImage; +use Bitweaver\Fisheye\FisheyeGallery; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; /** * fisheye_handle_upload */ -function fisheye_handle_upload( &$pFiles, &$pRequest ) { +function fisheye_handle_upload( &$pFiles ) { global $gBitUser, $gContent, $gBitSystem, $fisheyeErrors, $fisheyeWarnings, $fisheyeSuccess, $gFisheyeUploads; // first of all set the execution time for this process to unlimited set_time_limit(0); - $upImages = array(); - $upArchives = array(); - $upErrors = array(); - $upData = array(); + $upImages = []; + $upArchives = []; + $upErrors = []; + $upData = []; $i = 0; usort( $pFiles, 'fisheye_sort_uploads' ); @@ -26,40 +29,32 @@ function fisheye_handle_upload( &$pFiles, &$pRequest ) { // No gallery was specified, let's try to find one or create one. if( empty( $_REQUEST['gallery_additions'] ) ) { if( $gBitUser->hasPermission( 'p_fisheye_create' )) { - $_REQUEST['gallery_additions'] = array( fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) ); + $_REQUEST['gallery_additions'] = [ fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) ]; } else { - $gBitSystem->fatalError( tra( "You don't have permissions to create a new gallery. Please select an existing one to insert your images to." )); - } - } - - if( !is_object( $gContent ) || !$gContent->isValid() ) { - $gContent = new FisheyeGallery( $_REQUEST['gallery_additions'][0] ); - if( !$gContent->load() ) { - unset( $gContent ); - $_REQUEST['gallery_additions'] = array( fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) ); + $gBitSystem->fatalError( KernelTools::tra( "You don't have permissions to create a new gallery. Please select an existing one to insert your images to." )); } } - foreach( array_keys( $pFiles ) as $key ) { - $pFiles[$key]['type'] = $gBitSystem->verifyMimeType( $pFiles[$key]['tmp_name'] ); - if( preg_match( '/(^image|pdf|vnd)/i', $pFiles[$key]['type'] ) ) { - $upImages[$key] = $pFiles[$key]; - // clone the request data so edit service values are passed into store process - $upData[$key] = $_REQUEST; - // add the form data for each upload - if( !empty( $_REQUEST['imagedata'][$i] ) ) { - array_merge( $upData[$key], $_REQUEST['imagedata'][$i] ); + if ( !empty($pFiles[$key]['name']) ) { + $pFiles[$key]['type'] = $gBitSystem->verifyMimeType( $pFiles[$key]['tmp_name'] ); + if( preg_match( '/(^image|pdf|vnd)/i', $pFiles[$key]['type'] ?? '' ) ) { + $upImages[$key] = $pFiles[$key]; + // clone the request data so edit service values are passed into store process + $upData[$key] = $_REQUEST; + // add the form data for each upload + if( !empty( $_REQUEST['imagedata'][$i] ) ) { + array_merge( $upData[$key], $_REQUEST['imagedata'][$i] ); + } + } elseif( !empty( $pFiles[$key]['tmp_name'] ) && !empty( $pFiles[$key]['name'] ) ) { + $upArchives[$key] = $pFiles[$key]; } - } elseif( !empty( $pFiles[$key]['tmp_name'] ) && !empty( $pFiles[$key]['name'] ) ) { - $upArchives[$key] = $pFiles[$key]; + $i++; } - - $i++; } foreach( array_keys( $upArchives ) as $key ) { - $upErrors = fisheye_process_archive( $upArchives[$key], $gContent, TRUE ); + $upErrors = fisheye_process_archive( $upArchives[$key], $gContent, true ); } foreach( array_keys( $upImages ) as $key ) { @@ -70,11 +65,14 @@ function fisheye_handle_upload( &$pFiles, &$pRequest ) { $upErrors = array_merge( $upErrors, fisheye_store_upload( $upImages[$key], $upData[$key], !empty( $_REQUEST['rotate_image'] ))); } + if( !is_object( $gContent ) || !$gContent->isValid() ) { + $gContent = new FisheyeGallery( $_REQUEST['gallery_additions'][0] ); + $gContent->load(); + } + if( !empty( $gFisheyeUploads ) ){ $_REQUEST['uploaded_objects'] = &$gFisheyeUploads; - if( is_a( $gContent, 'LibertyContent' ) ) { - $gContent->invokeServices( "content_post_upload_function", $_REQUEST ); - } + $gContent->invokeServices( "content_post_upload_function", $_REQUEST ); } return $upErrors; @@ -94,12 +92,12 @@ function fisheye_sort_uploads( $a, $b ) { function fisheye_get_default_gallery_id( $pUserId, $pNewName ) { global $gBitUser; $gal = new FisheyeGallery(); - $getHash = array( 'user_id' => $pUserId, 'max_records' => 1, 'sort_mode' => 'created_desc', 'show_empty' => TRUE ); + $getHash = [ 'user_id' => $pUserId, 'max_records' => 1, 'sort_mode' => 'created_desc', 'show_empty' => true ]; $upList = $gal->getList( $getHash ); if( !empty( $upList ) ) { $ret = key( $upList ); } else { - $galleryHash = array( 'title' => $pNewName ); + $galleryHash = [ 'title' => $pNewName ]; if( $gal->store( $galleryHash ) ) { $ret = $gal->mGalleryId; } @@ -116,9 +114,9 @@ function fisheye_get_default_gallery_id( $pUserId, $pNewName ) { /** * fisheye_store_upload */ -function fisheye_store_upload( &$pFileHash, $pImageData = array(), $pAutoRotate=TRUE ) { +function fisheye_store_upload( &$pFileHash, $pImageData = [], $pAutoRotate=true ) { global $gBitSystem, $gFisheyeUploads; - $ret = array(); + $ret = []; // verifyMimeType to make sure we are working with the proper file type assumptions $pFileHash['type'] = $gBitSystem->verifyMimeType($pFileHash['tmp_name']); @@ -126,9 +124,9 @@ function fisheye_store_upload( &$pFileHash, $pImageData = array(), $pAutoRotate= // make a copy for each image we need to store $image = new FisheyeImage(); // Store/Update the image - $pImageData['_files_override'] = array( $pFileHash ); + $pImageData['_files_override'] = [ $pFileHash ]; $pImageData['process_storage'] = STORAGE_IMAGE; - $pImageData['purge_from_galleries'] = TRUE; + $pImageData['purge_from_galleries'] = true; // store the image if( !$image->store( $pImageData ) ) { $ret = $image->mErrors; @@ -142,14 +140,14 @@ function fisheye_store_upload( &$pFileHash, $pImageData = array(), $pAutoRotate= } if( !($galleryAdditions = BitBase::getParameter( $pImageData, 'gallery_additions' )) ) { global $gBitUser; - $galleryAdditions = array( fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) ); + $galleryAdditions = [ fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) ]; } $image->addToGalleries( $galleryAdditions ); $gFisheyeUploads[] = $image; } // when we're using xupload, we need to remove temp files manually - @unlink( $pFileHash['tmp_name'] ); + if ( is_readable( $pFileHash['tmp_name'] ) ) @unlink( $pFileHash['tmp_name'] ); } return $ret; } @@ -157,14 +155,14 @@ function fisheye_store_upload( &$pFileHash, $pImageData = array(), $pAutoRotate= /** * 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 ) { +function fisheye_process_archive( &$pFileHash, &$pParentGallery, $pRoot=false ) { global $gBitSystem, $gBitUser; - $errors = array(); + $errors = []; - if( ( $destDir = liberty_process_archive( $pFileHash ) ) && ( !empty( $_REQUEST['process_archive'] ) || !$gBitUser->hasPermission( 'p_fisheye_upload_nonimages' ) ) ) { + if( ( $destDir = \Bitweaver\Liberty\liberty_process_archive( $pFileHash ) ) && ( !empty( $_REQUEST['process_archive'] ) || !$gBitUser->hasPermission( 'p_fisheye_upload_nonimages' ) ) ) { if( empty( $pParentGallery ) && !is_file( $pFileHash['tmp_name'] ) ) { $pParentGallery = new FisheyeGallery(); - $galleryHash = array( 'title' => basename( $destDir ) ); + $galleryHash = [ 'title' => basename( $destDir ) ]; if( !$pParentGallery->store( $galleryHash ) ) { $errors = array_merge( $errors, array_values( $pParentGallery->mErrors ) ); } @@ -181,7 +179,7 @@ function fisheye_process_archive( &$pFileHash, &$pParentGallery, $pRoot=FALSE ) if( $gBitUser->hasPermission( 'p_fisheye_upload_nonimages' ) ) { $errors = array_merge( $errors, 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.' ); + $errors['upload'] = KernelTools::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; @@ -198,9 +196,9 @@ function fisheye_verify_upload_item( $pScanFile ) { /** * 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 ) { +function fisheye_process_directory( $pDestinationDir, &$pParentGallery, $pRoot=false ) { global $gBitSystem, $gBitUser; - $errors = array(); + $errors = []; if( $archiveDir = opendir( $pDestinationDir ) ) { $order = 100; while( $fileName = readdir($archiveDir) ) { @@ -213,12 +211,12 @@ function fisheye_process_directory( $pDestinationDir, &$pParentGallery, $pRoot=F } if( !preg_match( '/^\./', $fileName ) && ( $fileName != 'Thumbs.db' ) ) { $mimeResults = $gBitSystem->verifyFileExtension( $pDestinationDir.'/'.$fileName ); - $scanFile = array( + $scanFile = [ 'type' => $mimeResults[1], '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']; @@ -227,11 +225,11 @@ function fisheye_process_directory( $pDestinationDir, &$pParentGallery, $pRoot=F if( is_dir( $pDestinationDir.'/'.$fileName ) ) { if( $fileName == '__MACOSX' ) { // Mac OS resources file - unlink_r( $pDestinationDir.'/'.$fileName ); + KernelTools::unlink_r( $pDestinationDir.'/'.$fileName ); } else { // We found a new Gallery! $newGallery = new FisheyeGallery(); - $galleryHash = array( 'title' => str_replace( '_', ' ', $fileName ) ); + $galleryHash = [ 'title' => str_replace( '_', ' ', $fileName ) ]; if( $newGallery->store( $galleryHash ) ) { if( $pRoot ) { $newGallery->addToGalleries( $_REQUEST['gallery_additions'] ); @@ -250,7 +248,7 @@ function fisheye_process_directory( $pDestinationDir, &$pParentGallery, $pRoot=F $errors = array_merge( $errors, fisheye_process_archive( $scanFile, $pParentGallery ) ); } elseif( fisheye_verify_upload_item( $scanFile ) ) { $newImage = new FisheyeImage(); - $imageHash = array( '_files_override' => array( $scanFile ) ); + $imageHash = [ '_files_override' => [ $scanFile ] ]; if( $newImage->store( $imageHash ) ) { if( $pRoot ) { $newImage->addToGalleries( $_REQUEST['gallery_additions'] ); @@ -271,8 +269,8 @@ function fisheye_process_directory( $pDestinationDir, &$pParentGallery, $pRoot=F $order += 10; } } - if ( !is_windows() ) { - unlink_r( $pDestinationDir ); + if ( !KernelTools::is_windows() ) { + KernelTools::unlink_r( $pDestinationDir ); } } return $errors; @@ -285,10 +283,10 @@ function fisheye_process_directory( $pDestinationDir, &$pParentGallery, $pRoot=F function fisheye_process_ftp_directory( $pProcessDir ) { global $gBitSystem, $gBitUser; if( empty( $_REQUEST['gallery_additions'] ) ) { - $_REQUEST['gallery_additions'] = array(); + $_REQUEST['gallery_additions'] = []; } - $errors = array(); + $errors = []; if( $archiveDir = opendir( $pProcessDir ) ) { $order = 100; while( $fileName = readdir($archiveDir) ) { @@ -300,17 +298,17 @@ function fisheye_process_ftp_directory( $pProcessDir ) { foreach( $sortedNames as $fileName ) { if( !preg_match( '/^\./', $fileName ) && ( $fileName != 'Thumbs.db' ) ) { - $scanFile = array( - 'type' => $gBitSystem->lookupMimeType( substr( $fileName, ( strrpos( $fileName, '.' ) + 1 ) ) ), + $scanFile = [ + 'type' => $gBitSystem->lookupMimeType( substr( $fileName, strrpos( $fileName, '.' ) + 1 ) ), 'name' => $fileName, 'size' => filesize( "$pProcessDir/$fileName" ), 'tmp_name' => "$pProcessDir/$fileName", - ); + ]; if( is_dir( $pProcessDir.'/'.$fileName ) ) { // create a new gallery from directory $dirGallery = new FisheyeGallery(); - $galleryHash = array( 'title' => str_replace( '_', ' ', $fileName ) ); + $galleryHash = [ 'title' => str_replace( '_', ' ', $fileName ) ]; if( $dirGallery->store( $galleryHash ) ) { $dirGallery->addToGalleries( $_REQUEST['gallery_additions'] ); $errors = array_merge( $errors, fisheye_process_directory( $pProcessDir.'/'.$fileName, $dirGallery ) ); @@ -322,7 +320,7 @@ function fisheye_process_ftp_directory( $pProcessDir ) { if( preg_match( '/(^image|pdf)/i', $scanFile['type'] ) ) { // process image $newImage = new FisheyeImage(); - $imageHash = array( 'upload' => $scanFile ); + $imageHash = [ 'upload' => $scanFile ]; if( $newImage->store( $imageHash ) ) { $newImage->addToGalleries( $_REQUEST['gallery_additions'] ); @@ -335,7 +333,7 @@ function fisheye_process_ftp_directory( $pProcessDir ) { if( @!is_object( $imageGallery ) ) { global $gBitUser; - $galleryHash = array( 'title' => $gBitUser->getDisplayName()."'s Gallery" ); + $galleryHash = [ 'title' => $gBitUser->getDisplayName()."'s Gallery" ]; $imageGallery = new FisheyeGallery(); if( $imageGallery->store( $galleryHash ) ) { $imageGallery->load(); @@ -351,12 +349,12 @@ function fisheye_process_ftp_directory( $pProcessDir ) { } else { // create a new gallery from archive $archiveGallery = new FisheyeGallery(); - $galleryHash = array( 'title' => substr( $fileName, 0, ( str_replace( '_', ' ', strrpos( $fileName, '.' ) ) ) ) ); + $galleryHash = [ 'title' => substr( $fileName, 0, str_replace( '_', ' ', strrpos( $fileName, '.' ) ) ) ]; if( !$archiveGallery->store( $galleryHash ) ) { $errors = array_merge( $errors, array_values( $archiveGallery->mErrors ) ); } - $errors = fisheye_process_archive( $scanFile, $archiveGallery, TRUE ); + $errors = fisheye_process_archive( $scanFile, $archiveGallery, true ); unset( $archiveGallery ); } } @@ -366,4 +364,3 @@ function fisheye_process_ftp_directory( $pProcessDir ) { } return $errors; } -?> |
