Source for file edit_image.php
Documentation is available at edit_image.php
require_once( '../kernel/setup_inc.php' );
require_once( FISHEYE_PKG_PATH. 'FisheyeGallery.php');
require_once( FISHEYE_PKG_PATH. 'FisheyeImage.php');
include_once( FISHEYE_PKG_PATH. 'image_lookup_inc.php' );
if( $gContent->isValid() ) {
$gContent->verifyUpdatePermission();
bit_redirect( FISHEYE_PKG_URL. '?user_id='. $gBitUser->mUserId );
//Utility function, maybe should be moved for use elsewhere. Seems like it has a multitude of possible hook points
$search = array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6");
$replace= array("'", "'", '"', '"', '-', '--', '...');
$replace= array("'", "'", '"', '"', '-', '--', '...');
if( !empty($_REQUEST['edit'])){
if( !empty($_REQUEST['saveImage']) || !empty($_REQUEST['regenerateThumbnails'] ) ) {
if (empty($_REQUEST['gallery_id']) && empty($_REQUEST['image_id'])) {
// We have no way to know what gallery to add an image to or what image to edit!
$gBitSmarty->assign( 'msg', tra( "No gallery or image was specified" ) );
$gBitSystem->display( "error.tpl" , NULL, array( 'display_mode' => 'edit' ));
// Store/Update the image
if (isset ($_FILES['imageFile']) && is_uploaded_file($_FILES['imageFile']['tmp_name'])) {
$_REQUEST['_files_override'] = array( $_FILES['imageFile'] );
$_REQUEST['purge_from_galleries'] = TRUE;
if( $gContent->store($_REQUEST) ) {
// if user uploaded a file with a different name, delete the previous original file
// maybe we need to resize the original and generate thumbnails
if( !empty( $_REQUEST['resize'] ) ) {
$gContent->resizeOriginal( $_REQUEST['resize'] );
// This needs to happen after the store, else the image width/hieght are screwed for people using the background thumbnailer
if( !empty( $_REQUEST['rotate_image'] ) ) {
$gContent->rotateImage( $_REQUEST['rotate_image'] );
if( !empty( $_REQUEST['ajax'] ) ) {
// we need to refresh the images in the page after saving - not working yet - xing
header( 'Location: '. FISHEYE_PKG_URL. "image_order.php?refresh=1&gallery_id=". $_REQUEST['gallery_id'] );
$gContent->addToGalleries( $_REQUEST['gallery_additions'] );
if( !empty( $_REQUEST['generate_thumbnails'] ) ) {
$gContent->generateThumbnails();
if( empty( $gContent->mErrors ) ) {
// add a refresh parameter to the URL so the thumbnails will properly refresh first go reload
} elseif( !empty($_REQUEST['ajax_edit']) ) {
if( !empty( $_REQUEST['rotate_image'] ) ) {
$gContent->rotateImage( $_REQUEST['rotate_image'], TRUE );
} elseif( !empty($_REQUEST['delete']) ) {
$gContent->verifyUserPermission( tra( "You do not have permission to delete this image." ) );
if( !empty( $_REQUEST['cancel'] ) ) {
// user cancelled - just continue on, doing nothing
} elseif( empty( $_REQUEST['confirm'] ) ) {
$formHash['delete'] = TRUE;
$formHash['image_id'] = $gContent->mImageId;
$gBitSystem->confirmDialog( $formHash,
'warning' => tra('Are you sure you want to delete this image?') . ' (' . $gContent->getTitle() . ') ' . tra('It will be removed from all galleries to which it belongs.'),
'error' => tra('This cannot be undone!'),
$errors = $gContent->mErrors;
$gBitSmarty->assign_by_ref('errors', $errors);
$gContent->loadParentGalleries();
// Get a list of all existing galleries
'user_id' => $gBitUser->mUserId,
if( $gContent->mContentId ) {
$getHash['contain_item'] = $gContent->mContentId;
// modify listHash according to global preferences
unset ( $getHash['user_id'] );
} elseif( $gBitSystem->isFeatureActive( 'fisheye_show_public_on_upload' ) ) {
// $getHash['show_public'] = TRUE;
$galleryTree = $gFisheyeGallery->generateList( $getHash, array( 'name' => "gallery_id", 'id' => "gallerylist", 'item_attributes' => array( 'class'=> 'listingtitle'), 'radio_checkbox' => TRUE, ), true );
$gBitSmarty->assign_by_ref( 'galleryTree', $galleryTree );
$gBitSmarty->assign('requested_gallery', !empty($_REQUEST['gallery_id']) ? $_REQUEST['gallery_id'] : NULL);
$gContent->invokeServices( 'content_edit_function' );
if( !empty( $_REQUEST['ajax'] ) ) {
echo $gBitSmarty->fetch( 'bitpackage:fisheye/edit_image_inc.tpl', tra('Edit Image: '). $gContent->getTitle() );
$gBitSystem->display( 'bitpackage:fisheye/edit_image.tpl', tra('Edit Image: '). $gContent->getTitle() , array( 'display_mode' => 'edit' ));
|