/** * Executes ResizeImage action * * This action can be used into an ajax action to resize an image. This function requires * some parameters: * image : The name of the image to resize * imagePath : The full image path * imageWidth : The new image width * imageHeight : The new image height * imageType : The new image type. This parameter must be 1-GIF 2-JPG 3-PNG. Other * formats will be ignored * imageQuality : The new value for the image quality. Applies only to JPG images * * return A JSon header. */ public function executeResizeImage() { // Resizes the image $imagePath = w3sCommonFunctions::checkLastDirSeparator(sfConfig::get('app_images_path')); $imageEditor = new ImageEditor($this->getRequestParameter('image'), $imagePath); echo $this->getRequestParameter('imageWidth') . ' - ' . $this->getRequestParameter('imageHeight'); $imageEditor->resize($this->getRequestParameter('imageWidth'), $this->getRequestParameter('imageHeight')); // Retrieve the image type and verifies if the new image will be of the same type $imageAttributes = getimagesize($imagePath . $this->getRequestParameter('image')); $newType = $this->getRequestParameter('imageType') != $imageAttributes[2] ? $this->getRequestParameter('imageType') : 0; // Writes the new image and returns its name $newFileName = $imageEditor->outputFile($this->getRequestParameter('image'), $imagePath, $newType, $this->getRequestParameter('imageQuality')); // Produces the output header for ajax calling. $canvasImage = w3sClassImageManager::getImageAttributes($newFileName, $this->getRequestParameter('previewWidth'), $this->getRequestParameter('previewHeight'), $this->getRequestParameter('setCanvas')); //$output = '[["w3s_image_size", "' . $imageAttributes["size"] . '"],["w3s_image_preview", "' . $imageAttributes["htmlImage"] . '"], ["w3s_image_canvas", "' . $imageAttributes["canvasValue"] . '"],["w3s_start_width", "' . $imageAttributes["width"] . '"],["w3s_start_height", "' . $imageAttributes["height"] . '"]]'; $jsonImage = '[["w3s_image_preview", "' . $canvasImage["htmlImage"] . '"],'; $jsonImage .= '["w3s_editor_image_size", "' . $canvasImage["size"] . '"],'; $jsonImage .= '["w3s_editor_width", "' . $canvasImage["width"] . '"],'; $jsonImage .= '["w3s_editor_height", "' . $canvasImage["height"] . '"],'; $jsonImage .= '["w3s_editor_type_select", "' . $canvasImage["imageType"] . '"],'; $jsonImage .= '["w3s_editor_canvas", "' . $canvasImage["canvasValue"] . '"],'; $jsonImage .= '["w3s_editor_start_width", "' . $canvasImage["width"] . '"],'; $jsonImage .= '["w3s_editor_start_height", "' . $canvasImage["height"] . '"],'; $jsonImage .= '["w3s_ppt_htmlImage", "' . $canvasImage["htmlImage"] . '"],'; $jsonImage .= '["w3s_ppt_imageType", "' . $canvasImage["imageType"] . '"],'; $jsonImage .= '["w3s_ppt_size", "' . $canvasImage["size"] . '"],'; $jsonImage .= '["w3s_ppt_width", "' . $canvasImage["width"] . '"],'; $jsonImage .= '["w3s_ppt_height", "' . $canvasImage["height"] . '"]]'; $this->imagesList = w3sCommonFunctions::buildFilesList($imagePath, $newFileName, array('gif', 'jpg', 'jpeg', 'png')); /* if ($newFileName != $this->getRequestParameter('image')){ }*/ $this->getResponse()->setHttpHeader("X-JSON", '(' . $jsonImage . ')'); return sfView::HEADER_ONLY; }
/** * Show the images for the menu builder editor */ public function executeShowImages() { try { $imagesList = w3sCommonFunctions::buildFilesList(sfConfig::get('app_images_path'), '', array('gif', 'jpg', 'jpeg', 'png')); $imageList = new w3sImageListMenuBuilder($imagesList, $this->getRequestParameter('property')); return $this->renderText($imageList->renderImageList(), $this->getRequestParameter('property')); } catch (Exception $e) { return $this->renderText('Something was wrong while refreshing images lists.'); } }
public function executeDisplayImageDir() { $this->imagesList = w3sCommonFunctions::buildFilesList(sfConfig::get('app_images_path'), '', array('gif', 'jpg', 'jpeg', 'png')); }
/** * Executes delete image action. */ public function executeRefreshImages() { try { $imageList = new w3sImageListVertical(w3sCommonFunctions::buildFilesList(sfConfig::get('app_images_path'), '', array('gif', 'jpg', 'jpeg', 'png')), ''); return $this->renderText($imageList->renderImageList()); } catch (Exception $e) { return $this->renderText('Something was wrong while refreshing images lists.'); } }
/** * Draws a list of images * * @return string * */ protected function drawImagesList() { $imageList = new w3sImageListVertical(w3sCommonFunctions::buildFilesList(sfConfig::get('app_images_path'), '', array('gif', 'jpg', 'jpeg', 'png')), basename($this->attributes["fullImagePath"])); return $imageList->renderImageList(); }