Source for file editorFrame.php
Documentation is available at editorFrame.php
* The frame that contains the image to be edited.
* @author $Author: Wei Zhuo $
* @author $Author: Paul Moers <mail@saulmade.nl> $ - watermarking and replace code + several small enhancements <http://fckplugins.saulmade.nl>
* @version $Id: editorFrame.php 26 2004-03-31 02:35:21Z Wei Zhuo $
require_once('config.inc.php');
require_once('Classes/ImageManager.php');
require_once('Classes/ImageEditor.php');
// process any uploaded files
$imageRelative = $manager->processUploads();
// get image info and process any action
$imageInfo = $editor->processImage($imageRelative);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<link href="assets/editorFrame.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="assets/wz_jsgraphics.js"></script>
<script type="text/javascript" src="assets/wz_dragdrop.js"></script>
<script type="text/javascript" src="assets/EditorContent.js"></script>
<script type="text/javascript" src="assets/editorFrame.js"></script>
/* for centering the image vertically in IE */
<script type="text/javascript">
var processedAction = " <?php echo $_GET['action']; ?>";
if (processedAction == 'replace' && parent.old)
// reallow the user to close the editor window now uploading is done
parent.onbeforeunload = function () {parent.old();};
// set function for the wz_dragdrop script to use when dragging
// keep the watermark within the background
orig = dd.elements.background,
floater = dd.elements.floater,
else if (floater.x + floater.w > orig.x + orig.w)
newX = orig.x + (orig.w - floater.w);
else if (floater.y + floater.h > orig.y + orig.h)
newY = orig.y + (orig.h - floater.h);
if (newX != floater.x || newY != floater.y)
floater.moveTo(newX, newY);
<script type="text/javascript">
var mode = " <?php echo $editor->getAction(); ?>" //crop, scale, measure
var currentImageFile = " <?php if(count($imageInfo)> 0) echo rawurlencode($imageInfo['file']); ?>";
return (I18N[str] || str);
<script type="text/javascript">
if ($editor->isFileSaved() == 1)
// Reload the images in the imageframe of the Manager :
// Is there a "imgManager" frame.
if ((popupWindow = parent.opener.parent) && (imgManager = parent.opener.parent.document.getElementById("imgManager")))
// refresh it - so it shows the edited image.
imgManager.src = imgManager.src;
// Reload the images in the editor :
// base system is the FCKeditor?
if (popupWindow.opener.FCK)
editorFrame = popupWindow.opener.parent.document.getElementById(popupWindow.opener.FCK.Name + '___Frame');
if (editorDocument = popupWindow.opener.FCK.EditorDocument.body)
editorImages = editorDocument.getElementsByTagName("img");
for (i = 0; i < editorImages.length; i++)
// reapply images their src to reload'm
editorImages[i].src = editorImages[i].src;
alert(i18n("Error: Couldn't update editor window.\nAny image that was edited and saved will still be visible as the old version!\nPlease save and reload the editor content."));
var message = i18n('File saved.');
if ($editor->forcedNewName != false)
message += '\n' + i18n('File name was changed into ') + ' <?php echo $editor->forcedNewName; ?>';
else if ($editor->isFileSaved() == - 1)
alert(i18n('File was not saved.'));
// show action buttons and current action's controls - were hidden during processing
if (processedAction != '')
var tools = parent.document.getElementById('tools_' + processedAction);
tools.style.display = 'block';
var buttons = parent.document.getElementById('buttons');
buttons.style.display = 'block';
// populating watermarks select box (excluding watermarks that are to big or became to big for the editted image)
watermarkBox = parent.document.getElementById("watermark_file");
imagesArray = new Array();
// first clear all its options
watermarkBox.options.length = 0;
foreach($IMConfig['watermarks'] as $watermark)
$watermarkInfo = @getImageSize($IMConfig['base_dir'] . $watermark);
if ($watermarkInfo[0] < $imageInfo[width] && $watermarkInfo[1] < $imageInfo[height])
echo "watermarkBox.options[watermarkBox.options.length] = new Option('" . basename($watermark) . "', '$filename');";
echo "watermarkBox.options[watermarkBox.options.length - 1].setAttribute('fullPath', '" . $IMConfig['base_dir'] . $watermark . "');";
echo "watermarkBox.options[watermarkBox.options.length - 1].setAttribute('x', $watermarkInfo[0]);";
echo "watermarkBox.options[watermarkBox.options.length - 1].setAttribute('y', $watermarkInfo[1]);";
echo $filename . "Preload = new Image(10, 10);";
echo $filename . "Preload.src = '" . $IMConfig['base_url'] . $watermark . "';";
// first item unavailable?
else if ($watermark == $IMConfig['watermarks'][0])
echo "var firstWatermarkItemUnavailable = true;";
// no watermarks found? Show message instead of watermarking controls.
if (!watermarkBox.options[0])
parent.document.getElementById("watermarkControls").style.display = "none";
parent.document.getElementById("watermarkMessage").style.display = "block";
var watermarkingEnabled = false;
// else just show the controls
parent.document.getElementById("watermarkControls").style.display = "block";
parent.document.getElementById("watermarkMessage").style.display = "none";
var watermarkingEnabled = true;
<div id="ant" class="selection" style="visibility:hidden"><img src="img/spacer.gif" width="0" height="0" border="0" alt="" id="cropContent"></div>
<?php if ($editor->isGDEditable() == - 1) { ?>
<div style="text-align:center; padding:10px;"><span class="error">GIF format is not supported, image editing not supported.</span></div>
<table height="100%" width="100%">
<?php if(count($imageInfo) > 0 && is_file($imageInfo['fullpath'])) { ?>
<div id="background" name="background" style="margin: auto; width: <?php echo $imageInfo['width']; ?>px; height: <?php echo $imageInfo['height']; ?>px; background-image: url( <?php echo $imageInfo['src']; ?>);">
<img name="floater" id="floater" style="width: 150px; height: 150px; behavior: url('assets/pngbehavior.htc'); position: absolute" src=" <?php echo $IMConfig['base_url'] . $IMConfig['watermarks'][0]; ?>" />
<span id="imgCanvas" name="imgCanvas" class="crop" style="display: none;"><img src=" <?php echo $imageInfo['src']; ?>" <?php echo $imageInfo['dimensions']; ?> alt="" id="theImage" name="theImage" /></span>
<span class="error">No Image Available</span>
<script type="text/javascript">
if (watermarkingEnabled == true)
SET_DHTML("background"+NO_DRAG, "floater"+CURSOR_MOVE);
if (window.firstWatermarkItemUnavailable == true)
dd.elements.floater.swapImage(eval("window." + watermarkBox.options[0].value + "Preload.src"));
dd.elements.floater.resizeTo(watermarkBox.options[0].getAttribute("x"), watermarkBox.options[0].getAttribute("y"));
dd.elements.floater.hide();
dd.elements.floater.nimg.style.behavior = "url('assets/pngbehavior.htc')";
if (isset ($_GET['action']))
if ($_GET['action'] == "watermark")
dd.elements.floater.show();
if (document.getElementById("floater"))
document.getElementById("floater").style.display = "none";
// hiding parent processing message
parent.window.hideMessage();
// make sure the slider of the watermark's opacity if at max
parent.window.updateSlider(100, 'watermark');
|