forward404(); $this->redirect("sfSWFUpload/fileSizeMultiUpload"); } public function executeExample() { $this->forward404(); } public function executeShowUploads() { $this->setLayout(false); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); $this->getPhotoUploads(); } public function executeSimpleMultiUpload() { $this->forward404(); $this->getPhotoUploads(); } public function executeFileSizeMultiUpload() { $this->forward404(); $this->getPhotoUploads(); } public function executeUpload() { $upload_name = "Filedata"; $temp_file = sfRequestCompat10::getFilePath($this->getRequest(), $upload_name); $path_info = pathinfo($_FILES[$upload_name]['name']); $ext = ".".$path_info["extension"]; $fileName = md5($temp_file.time()); $this->fileUpload($fileName, $temp_file, $ext); return $this->renderText('NAHRÁNO'); } protected function getPhotoUploads() { $type = $this->getRequestParameter('category'); $id = $this->getRequestParameter('id'); $target_div = $this->getRequest()->hasParameter('target')?$this->getRequestParameter('target'):'admin-preview'; $foto_gallery_dir = sfConfig::get("app_swfupload_gallery_folder")."/"; $small_gallery_dir = "/".$foto_gallery_dir.$type."/".$id."/".sfConfig::get("app_swfupload_thumbs_folder"); $big_gallery_dir = "/".$foto_gallery_dir.$type."/".$id."/".sfConfig::get("app_swfupload_images_folder"); $this->photos = array(); if (is_dir(sfConfig::get('sf_web_dir').$small_gallery_dir)) { if ($gd = opendir(sfConfig::get('sf_web_dir').$small_gallery_dir)) { while (($file = readdir($gd)) !== false) { if ( (filetype(sfConfig::get('sf_web_dir').$small_gallery_dir ."/". $file) != "dir") && ($file != ".") && ($file != "..") && ($file != "Thumbs.db") ) { $this->photos[] = $file; } } } } else { $this->photos[] = null; } $this->big_gallery_dir = $big_gallery_dir; $this->small_gallery_dir = $small_gallery_dir; $this->category = $type; $this->id = $id; $this->target = $target_div; /* $c = new Criteria(); if($type === "project") $c->add(PhotoPeer::PROJECT_ID,$id); if($type === "property") $c->add(PhotoPeer::PROPERTY_ID,$id); $result = PhotoPeer::doSelect($c); $this->captions = array(); foreach ($result as $item) { $this->captions[$item->getPath()] = $item->getDescriptionI18nCs(); } */ //include_once(sfConfig::get('sf_symfony_lib_dir').'/helper/JavascriptHelper.php'); } protected function fileUpload($fileName, $temp_file, $ext) { $type = $this->getRequestParameter('category'); $id = $this->getRequestParameter('id'); // Save Thumb and foto in directory // CREATE THE DIRECTORIES IF DOESNT EXIST $foto_gallery_root_dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.sfConfig::get("app_swfupload_gallery_folder").DIRECTORY_SEPARATOR; $foto_gallery_type = $foto_gallery_root_dir.$type.DIRECTORY_SEPARATOR; $foto_gallery_id = $foto_gallery_root_dir.$type.DIRECTORY_SEPARATOR.$id.DIRECTORY_SEPARATOR; $foto_gallery_dir = $foto_gallery_root_dir.$type.DIRECTORY_SEPARATOR.$id.DIRECTORY_SEPARATOR; if ( !is_dir($foto_gallery_root_dir)) { mkdir($foto_gallery_root_dir); } if ( !is_dir($foto_gallery_type)) { mkdir($foto_gallery_type); } if ( !is_dir($foto_gallery_id)) { mkdir($foto_gallery_id); } if ( !is_dir($foto_gallery_dir)) { mkdir($foto_gallery_dir); } if (sfConfig::get("app_swfupload_create_thumb") == "true") { $small_gallery_dir = $foto_gallery_dir.DIRECTORY_SEPARATOR.sfConfig::get("app_swfupload_thumbs_folder"); if ( !is_dir($small_gallery_dir)) { mkdir($small_gallery_dir); } // Create the thumbnail $thumbnail = new sfThumbnail(sfConfig::get("app_swfupload_thumb_width"), sfConfig::get("app_swfupload_thumb_height"),true,true,sfConfig::get("app_swfupload_thumb_quality")); $thumbnail->loadFile($temp_file); $thumbnail->save($small_gallery_dir.DIRECTORY_SEPARATOR.$fileName.$ext, sfConfig::get("app_swfupload_image_mime")); } if (sfConfig::get("app_swfupload_create_middle") == "true") { $middle_gallery_dir = $foto_gallery_dir.DIRECTORY_SEPARATOR.sfConfig::get("app_swfupload_middle_folder"); if ( !is_dir($middle_gallery_dir)) { mkdir($middle_gallery_dir); } // Create the thumbnail $thumbnail = new sfThumbnail(sfConfig::get("app_swfupload_middle_width"), sfConfig::get("app_swfupload_middle_height"),true,true,sfConfig::get("app_swfupload_middle_quality")); $thumbnail->loadFile($temp_file); $thumbnail->save($middle_gallery_dir.DIRECTORY_SEPARATOR.$fileName.$ext, sfConfig::get("app_swfupload_image_mime")); } $big_gallery_dir = $foto_gallery_dir.DIRECTORY_SEPARATOR.sfConfig::get("app_swfupload_images_folder"); if ( !is_dir($big_gallery_dir)) { mkdir($big_gallery_dir); } $foto = new sfThumbnail(sfConfig::get("app_swfupload_image_width"), sfConfig::get("app_swfupload_image_height"),true,false,sfConfig::get("app_swfupload_image_quality")); $foto->loadFile($temp_file); $foto->save($big_gallery_dir.DIRECTORY_SEPARATOR.$fileName.$ext, sfConfig::get("app_swfupload_image_mime")); unlink($temp_file); } }