/** * Overwrites default behavior. No call to phpThumb needed for original photo. * Just move it to the imgdir. * * @param unknown_type $oldOriginalPath * @return unknown */ function createPhoto($oldOriginalPath, $moveOriginal = true) { //create directory if (!PhotoQHelper::createDir($this->_yearMonthDirPath)) { return new PhotoQErrorMessage(sprintf(_c('Error when creating directory: %s| dirname', 'PhotoQ'), $this->_yearMonthDirPath)); } //move the image file if (!file_exists($this->_path)) { if ($moveOriginal) { if (!PhotoQHelper::moveFile($oldOriginalPath, $this->_path)) { return new PhotoQErrorMessage(sprintf(_c('Unable to move %s, posting aborted.| imgname', 'PhotoQ'), $this->_imgName)); } } else { //we don't move we only copy if (!copy($oldOriginalPath, $this->_path)) { return new PhotoQErrorMessage(sprintf(_c('Unable to copy %s, posting aborted.| imgname', 'PhotoQ'), $this->_imgName)); } } } else { return new PhotoQErrorMessage(sprintf(_c('Image %s already exists, posting aborted.| imgname', 'PhotoQ'), $this->_imgName)); } return new PhotoQStatusMessage(__('Original photo moved successfully')); }
/** * Handles uploading of a new watermark image. * */ function uploadWatermark() { //watermark images can have different suffixes, but we only want one watermark file at a time. //instead of finding them all we just delete and recreate the directory. $wmDir = $this->_oc->getImgDir() . 'photoQWatermark/'; PhotoQHelper::recursiveRemoveDir($wmDir); PhotoQHelper::createDir($wmDir); //put uploaded file into watermark directory if (!($file = $this->_handleUpload($wmDir))) { //$this->_errStack->push(PHOTOQ_FILE_UPLOAD_FAILED,'error', array('errMsg' => $file['error'])); delete_option('wimpq_watermark'); } else { $pathParts = PhotoQHelper::pathInfo($file); $newPath = preg_replace("#" . $pathParts['filename'] . "#", 'watermark', $file); PhotoQHelper::moveFile($file, $newPath); if (get_option('wimpq_watermark')) { update_option('wimpq_watermark', $newPath); } else { add_option('wimpq_watermark', $newPath); } //this is now done via batch processing //$this->rebuildPublished($this->_oc->getImageSizeNamesWithWatermark(), false, false, false); $this->_errStack->push(PHOTOQ_INFO_MSG, 'info', array(), __('New Watermark successfully uploaded. Updating image sizes including watermark...')); } }
function addImageSize($name) { $imageSizes =& $this->_options['imageSizes']; if ($name != 'original' && !array_key_exists($name, $imageSizes->getValue())) { //add corresponding directory to imgdir if (PhotoQHelper::createDir($this->getImgDir() . $name)) { //add to database $imageSizes->addChild(new ImageSizeOption($name)); $this->_store(); } else { return new PhotoQErrorMessage(sprintf(__("Could not create image size. The required directory in %s could not be created. Please check your settings and/or PHP Safe Mode.", 'PhotoQ'), $this->getImgDir() . $name)); } } else { return new PhotoQErrorMessage(__("Name already taken, please choose another name.", 'PhotoQ')); } return new PhotoQStatusMessage(__("New image size successfully created.", 'PhotoQ')); }