public function validateAction() { if ($datas = $this->getRequest()->getPost()) { try { $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); $datas = array('success' => 1, 'file' => $file, 'message_success' => $this->_('Info successfully saved'), 'message_button' => 0, 'message_timeout' => 2); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($datas); } }
public function validatecropAction() { if ($datas = $this->getRequest()->getPost()) { try { $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); $datas = array('success' => 1, 'file' => $file, 'message_success' => 'Enregistrement réussi', 'message_button' => 0, 'message_timeout' => 2); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
public function saveAction() { if ($datas = $this->getRequest()->getPost()) { try { $logo_relative_path = '/logo/'; $folder = Application_Model_Application::getBaseImagePath() . $logo_relative_path; $datas['dest_folder'] = $folder; $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); $this->_application->setLogo($logo_relative_path . $file); $this->_application->save(); $datas = array('success' => 1, 'file' => Application_Model_Application::getImagePath() . $logo_relative_path . $file); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
public function savestartupAction() { if ($datas = $this->getRequest()->getPost()) { try { $application = $this->getApplication(); $relative_path = '/' . $application->getId() . '/startup_image/'; $filetype = $this->getRequest()->getParam('filetype'); $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $datas['dest_folder'] = $folder; $datas['new_name'] = $datas['file']; $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); $url = ""; $format = pathinfo($file, PATHINFO_EXTENSION); //Startup images must be forced to png if ($format != "png") { switch ($format) { case 'jpg': case 'jpeg': $image = imagecreatefromjpeg($folder . $file); break; case 'gif': $image = imagecreatefromgif($folder . $file); break; } $new_name = uniqid() . ".png"; imagepng($image, $folder . $new_name); $file = $new_name; } if ($filetype == "standard") { $application->setData("startup_image", $relative_path . $file); } else { $application->setData("startup_image_" . $filetype, $relative_path . $file); } $application->save(); $datas = array('success' => 1, 'file' => $application->getStartupImageUrl($filetype)); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
public function savehomepageAction() { if ($datas = $this->getRequest()->getPost()) { try { $filetype = $this->getRequest()->getParam('filetype'); $folder = Application_Model_Application::getBaseImagePath() . $this->_homepage_relative_path . $filetype . '/'; $datas['dest_folder'] = $folder; $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); if ($filetype == 'bg') { $this->getApplication()->setHomepageBackgroundImageRetinaLink($this->_homepage_relative_path . 'bg' . '/' . $file); } else { $this->getApplication()->setHomepageBackgroundImageLink($this->_homepage_relative_path . 'bg_lowres' . '/' . $file); } $this->getApplication()->save(); $datas = array('success' => 1, 'file' => $file); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
public function savestartupAction() { if ($datas = $this->getRequest()->getPost()) { try { $relative_path = '/startup_image/'; $filetype = $this->getRequest()->getParam('filetype'); $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $datas['dest_folder'] = $folder; $datas['new_name'] = $datas['file']; $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); if ($filetype == 'retina') { $this->getApplication()->setStartupImageRetina($relative_path . '/' . $file); } else { $this->getApplication()->setStartupImage($relative_path . '/' . $file); } $this->getApplication()->save(); $datas = array('success' => 1, 'file' => $file); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
public function setbackgroundimageAction() { if ($datas = $this->getRequest()->getPost()) { try { $option_value = new Application_Model_Option_Value(); $option_value->find($datas['option_id']); if (!$option_value->getId()) { throw new Exception($this->_("An error occurred while saving your picture. Please try againg later.")); } // Récupère l'option $option = new Application_Model_Option(); $option->find($option_value->getOptionId()); $save_path = '/feature/' . $option->getId() . '/background/'; $relative_path = Application_Model_Application::getImagePath() . $save_path; $folder = Application_Model_Application::getBaseImagePath() . $save_path; $datas['dest_folder'] = $folder; $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); $option_value->setBackgroundImage($save_path . $file)->save(); $datas = array('success' => 1, 'file' => $relative_path . $file); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
public function cropAction() { if ($datas = $this->getRequest()->getPost()) { try { $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); $datas = array('success' => 1, 'file' => $file); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
public function savesliderimagesAction() { if ($datas = $this->getRequest()->getPost()) { try { $url = ""; $image_id = null; $application = $this->getApplication(); $relative_path = '/' . $application->getId() . '/slider_images/'; $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $datas['dest_folder'] = $folder; $uploader = new Core_Model_Lib_Uploader(); if ($file = $uploader->savecrop($datas)) { $url = Application_Model_Application::getImagePath() . $relative_path . $file; $library = new Media_Model_Library(); $library->find($application->getHomepageSliderLibraryId()); if (!$library->getId()) { $library->setName('homepage_slider_' . $application->getId())->save(); $application->setHomepageSliderLibraryId($library->getId())->save(); } $image = new Media_Model_Library_Image(); $image->setLibraryId($library->getId())->setLink($url)->setAppId($application->getId())->save(); $image_id = $image->getId(); } $datas = array('success' => 1, 'file' => array("id" => $image_id, "url" => $url)); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }