/**
* Class for copying. Save all generated image metadata upon resizing an image and saving the resized image as a copy
*
* @author Phil Powell
* @version 1.0.0
* @packageIMAGE
*/
class ImageCopyMetadataActionPerformer extends DBActionPerformer {
/*----------------------------------------------------------------------------------------------------------------------------------------------------------
This class will save all generated image metadata upon resizing an image and saving the resized image as a copy.
Since an image copy is created you will have to create brand new metadata associated with this new image.
------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/**
* Constructor
*
* @access public
*/
function ImageCopyMetadataActionPerformer() { // CONSTRUCTOR
parent::DBActionPerformer(); // "super()"
}
/**
* Because this is a localized instance of $actionPerformer the value of $actionPerformer->fileName will be null because
* this instance has not (yet) set a value to $actionPerformer->fileName. To ensure that the property has the correct value
* for the save() method you will have to manually set it from here with the newly-set value of $_POST['image_name']
* which in turn has been set in order for the $_POST to globalize with the correct values for db action to be accurate
*
* @access public
*/
function save() { // VOID METHOD
global $section, $action, ${$section . 'LocationPath'}, $phpVersionInt, $dbHandlerArray, $redirectArray;
$locationPath = ($_POST['album']) ? "${$section . 'LocationPath'}/" . $_POST['album'] : ${$section . 'LocationPath'};
$_POST['image_name'] =& $_POST['image_copy_name']; // YOU HAVE TO OVERRIDE image_name WITH image_copy_name
if ((int)$phpVersionInt > 412) global $_POST;
// NEW 2/1/2005: DO NOT ALLOW 'resize' TO GO TO 'update' SINCE YOU HAVE DONE 'save' - CHANGE $dbHandlerArray, $redirectArray AND GLOBALIZE
$dbHandlerArray[$section][$action] = ''; // WILL NOT BE GOING TO DO A DB ACTION FROM ANY NON-DB ACTION INCLUDING resize()
$redirectArray[$section]['resize'] = 'edit'; // IF ACTION IS 'resize' THEN GO TO EDIT VIEW INSTEAD OF RETURNING TO RESIZING VIEW
$redirectArray[$section]['save'] = ''; // TEMPORARY CHANGE TO PREVENT save() FROM REDIRECTING ITSELF
global $dbHandlerArray, $redirectArray; // GLOBALIZE CHANGES TO $dbHandlerArray, $redirectArray (WILL RESET UPON CLIENT REDIRECTION)
/*------------------------------------------------------------------------------------------------------------------------------------------------------------
New 8/12/2004: To make the code smaller and more elegant, write onto the inherited $fileName property the value of
$_POST['image_name'], then use this parent class (DBActionPerformer) method save() to save it instead of this instance's save()
-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
$this->fileName = $_POST['image_name']; // NEW 2/1/2005: NO NEED TO USE setFileName() METHOD YOU HAVE SET $this->fileName HERE
$this->save(); // INHERITED save() METHOD WITH ITS OWN REDIRECTION CHANGED BY THIS CLASS METHOD
}
}
At the close of the save() method, the values of $redirectArray and $dbHandlerArray literally revert back to their default values every time, in spite of having to have globalized their values.
I don't understand what's going on, can someone else explain this to me?
Thanx
Phil