public function editpostAction() { if ($datas = $this->getRequest()->getPost()) { try { $application = $this->getApplication(); // Test s'il y a un value_id if (empty($datas['value_id'])) { throw new Exception($this->_('An error occurred while saving')); } if (empty($datas['title'])) { throw new Exception($this->_('Folder title is required')); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); $folder = new Folder_Model_Folder(); $category = new Folder_Model_Category(); if (!empty($datas['category_id'])) { $category->find($datas['category_id'], 'category_id'); } if ($datas['parent_id'] == 'null') { unset($datas['parent_id']); //Assigne le nom de catégorie root à la feature $option_value->setTabbarName($datas['title'])->save(); } else { $datas['pos'] = $category->getNextCategoryPosition($datas['parent_id']); } if (!empty($datas['file'])) { $relative_path = '/folder/'; $path = Application_Model_Application::getBaseImagePath() . $relative_path; $file = Core_Model_Directory::getTmpDirectory(true) . '/' . $datas['file']; if (!is_dir($path)) { mkdir($path, 0777, true); } if (!copy($file, $path . $datas['file'])) { throw new exception($this->_('An error occurred while saving. Please try again later.')); } else { $datas['picture'] = $relative_path . $datas['file']; } } else { if (!empty($datas['remove_picture'])) { $datas['picture'] = null; } } $category->addData($datas)->save(); //Change root category if (!isset($datas['parent_id'])) { $folder->find($option_value->getId(), 'value_id'); $folder->setValueId($datas['value_id'])->setRootCategoryId($category->getId())->save(); $parent_id = 'null'; } else { $parent_id = $datas['parent_id']; } $html = array('success' => '1', 'success_message' => $this->_('Infos successfully saved'), 'category_id' => $category->getId(), 'parent_id' => $parent_id, 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function editpostAction() { if ($datas = $this->getRequest()->getPost()) { try { $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); $datas = $datas['menus']; foreach ($datas as $product_id => $data) { $product = new Catalog_Model_Product(); if ($id = $this->getRequest()->getParam('id')) { $product->find($id); if ($product->getValueId() != $option_value->getId()) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } } if (!$product->getId()) { $product->setValueId($option_value->getId()); } $pos_datas = array(); if (!empty($data['pos'])) { foreach ($data['pos'] as $key => $pos_data) { $pos_datas[$key] = $pos_data; } } if (!empty($data['picture'])) { if (substr($data['picture'], 0, 1) == '/') { unset($data['picture']); } else { $illus_relative_path = '/feature/' . $option_value->getValueId() . '/'; $folder = Application_Model_Application::getBaseImagePath() . $illus_relative_path; $file = Core_Model_Directory::getTmpDirectory(true) . '/' . $data['picture']; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!copy($file, $folder . $data['picture'])) { throw new exception($this->_('An error occurred while saving your picture. Please try againg later.')); } else { $data['picture'] = $illus_relative_path . $data['picture']; } } } $product->addData($data)->setType('menu'); $product->setPosDatas($pos_datas); $product->save(); } $html = array(); if (!$product->getData('is_deleted')) { $html['menu_id'] = $product->getId(); } $html['success'] = 1; $html['success_message'] = $this->_('Set meal successfully saved.'); $html['message_timeout'] = 2; $html['message_button'] = 0; $html['message_loader'] = 0; } catch (Exception $e) { $html = array('message' => $this->_('An error occurred while saving the set meal. Please try again later.')); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function getPictoUrl() { $picto_path = Application_Model_Application::getImagePath() . $this->getPicto(); $picto_base_path = Application_Model_Application::getBaseImagePath() . $this->getPicto(); if ($this->getPicto() and file_exists($picto_base_path)) { return $picto_path; } return null; }
public function getPictureUrl() { $path_picture = Application_Model_Application::getImagePath() . $this->getPicture(); $base_path_picture = Application_Model_Application::getBaseImagePath() . $this->getPicture(); if ($this->getPicture() and file_exists($base_path_picture)) { return $path_picture; } return ''; }
public function getCoverUrl() { $cover_path = Application_Model_Application::getImagePath() . $this->getCover(); $cover_base_path = Application_Model_Application::getBaseImagePath() . $this->getCover(); if ($this->getCover() and file_exists($cover_base_path)) { return $cover_path; } return null; }
public function getImageUrl() { $image_path = Application_Model_Application::getImagePath() . $this->getData('image'); $base_image_path = Application_Model_Application::getBaseImagePath() . $this->getData('image'); if ($this->getData('image') and file_exists($base_image_path)) { return $image_path; } return null; }
public function getPictureUrl() { if ($this->getData('picture')) { $path_picture = Application_Model_Application::getImagePath() . $this->getData('picture'); $base_path_picture = Application_Model_Application::getBaseImagePath() . $this->getData('picture'); if (file_exists($base_path_picture)) { return $path_picture; } } return null; }
public function editpostAction() { if ($data = $this->getRequest()->getPost()) { try { $application = $this->getApplication(); // Test s'il y a un value_id if (empty($data['value_id'])) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($data['value_id']); $html = ''; $contact = new Contact_Model_Contact(); $contact->find($option_value->getId(), 'value_id'); if (!empty($data['file'])) { $file = pathinfo($data['file']); $filename = $file['basename']; $relative_path = $option_value->getImagePathTo(); $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $img_dst = $folder . '/' . $filename; $img_src = Core_Model_Directory::getTmpDirectory(true) . '/' . $filename; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!@copy($img_src, $img_dst)) { throw new exception($this->_('An error occurred while saving your picture. Please try again later.')); } else { $data['cover'] = $relative_path . '/' . $filename; } } else { if (!empty($data['remove_cover'])) { $data['cover'] = null; } } $contact->setData($data); if ($contact->getStreet() and $contact->getPostcode() and $contact->getCity()) { $latlon = Siberian_Google_Geocoding::getLatLng(array("street" => $contact->getStreet(), "postcode" => $contact->getPostcode(), "city" => $contact->getCity())); if (!empty($latlon[0]) && !empty($latlon[1])) { $contact->setLatitude($latlon[0])->setLongitude($latlon[1]); } } else { $contact->setLatitude(null)->setLongitude(null); } $contact->save(); $html = array('success' => '1', 'success_message' => $this->_('Info successfully saved'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function editAction() { if ($datas = $this->getRequest()->getPost()) { try { $application = $this->getApplication(); // Test s'il y a un value_id if (empty($datas['agenda_id'])) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } $event = new Event_Model_Event_Custom(); $option_value = $this->getCurrentOptionValue(); $data = array(); if (!empty($datas['id'])) { $event->find($datas['id']); if ($event->getAgendaId() != $datas['agenda_id']) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } } if (!empty($datas['picture'])) { if (substr($datas['picture'], 0, 1) == '/') { unset($datas['picture']); } else { $application = $this->getApplication(); $illus_relative_path = '/feature/' . $option_value->getId() . '/'; $folder = Application_Model_Application::getBaseImagePath() . $illus_relative_path; $file = Core_Model_Directory::getTmpDirectory(true) . '/' . $datas['picture']; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!copy($file, $folder . $datas['picture'])) { throw new exception($this->_("An error occurred while saving your picture. Please try againg later.")); } else { $datas['picture'] = $illus_relative_path . $datas['picture']; } } } else { $datas['picture'] = null; } if (!empty($datas['rsvp']) and stripos($datas['rsvp'], 'http') === false) { $datas['rsvp'] = 'http://' . $datas['rsvp']; } $event->addData($datas)->save(); $cache = Zend_Registry::get('cache'); $cache->remove($option_value->getObject()->getCacheId()); $html = array('success' => '1', 'success_message' => $this->_("Event successfully saved"), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function editpostcategoryAction() { if ($data = $this->getRequest()->getPost()) { try { $isNew = false; if (!$data["category_id"]) { $isNew = true; $topic = new Topic_Model_Topic(); $topic->find(array("value_id" => $this->getCurrentOptionValue()->getValueId())); if (!$topic->getId()) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } $category = new Topic_Model_Category(); $position = $category->getMaxPosition($topic->getId()); $data["position"] = $position ? $position + 1 : 1; $data["topic_id"] = $topic->getId(); } else { $category = new Topic_Model_Category($data["category_id"]); } if (!empty($data["file"])) { $picture = $data["file"]; $relative_path = '/features/topic/'; $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $path = Application_Model_Application::getBaseImagePath() . $relative_path; $file = Core_Model_Directory::getTmpDirectory(true) . '/' . $picture; if (file_exists($file)) { if (!is_dir($path)) { mkdir($path, 0777, true); } if (!copy($file, $folder . $picture)) { throw new exception($this->_('An error occurred while saving. Please try again later.')); } else { $data['picture'] = $relative_path . $picture; } } } if ($data["remove_picture"]) { $data['picture'] = null; } $category->addData($data)->save(); $html = array('is_new' => (int) $isNew, 'category_id' => $category->getId(), 'category_label' => $category->getName(), 'success' => '1', 'success_message' => $this->_('Category successfully saved.'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); if ($isNew) { $html['row_html'] = $this->getLayout()->addPartial('child_' . $category->getId(), 'admin_view_default', 'topic/application/edit/list.phtml')->setCategory($category)->toHtml(); } } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->_sendHtml($html); } }
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 editpostAction() { $html = ''; if ($datas = $this->getRequest()->getPost()) { try { if (!empty($datas['text'])) { $comment = new Comment_Model_Comment(); $img_src = Core_Model_Directory::getTmpDirectory(true) . '/'; $image = ''; if (empty($datas['image'])) { $datas['image'] = null; } else { if (file_exists($img_src . $datas['image'])) { $img_src = $img_src . $datas['image']; $relativePath = '/feature/' . $this->getCurrentOptionValue()->getId(); $img_dst = Application_Model_Application::getBaseImagePath() . $relativePath; if (!is_dir($img_dst)) { mkdir($img_dst, 0777, true); } $img_dst .= '/' . $datas['image']; @rename($img_src, $img_dst); if (!file_exists($img_dst)) { throw new Exception($this->_('An error occurred while saving your picture. Please try againg later.')); } $datas['image'] = $relativePath . '/' . $datas['image']; $image = Application_Model_Application::getImagePath() . '/'; $image .= $datas['image']; } } $comment->setData($datas)->save(); $url = array('comment/admin/edit'); if ($pos_id) { $url[] = 'pos_id/' . $pos_id; } $html = array('success' => '1', 'success_message' => $this->_('Information successfully saved'), 'image' => $image, 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function editpostAction() { if ($datas = $this->getRequest()->getPost()) { try { $application = $this->getApplication(); // Test s'il y a un value_id if (empty($datas['value_id'])) { throw new Exception($this->_('An error occurred while saving your contact informations.')); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); $html = ''; $contact = new Contact_Model_Contact(); $contact->find($option_value->getId(), 'value_id'); if (!empty($datas['file'])) { $relative_path = '/contact/cover/'; $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $file = Core_Model_Directory::getTmpDirectory(true) . '/' . $datas['file']; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!copy($file, $folder . $datas['file'])) { throw new exception($this->_('An error occurred while saving your picture. Please try againg later.')); } else { $datas['cover'] = $relative_path . $datas['file']; } } else { if (!empty($datas['remove_cover'])) { $datas['cover'] = null; } } $contact->setData($datas)->save(); $html = array('success' => '1', 'success_message' => $this->_('Informations successfully saved'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function colorize($tile_path, $option, $color = null, $flat = true) { if (!is_file($tile_path)) { return ''; } // Créé les chemins $application = $this->getApplication(); $dst = '/' . $this->getCode() . '/' . $option->getCode() . '_' . uniqid() . '.png'; $base_dst = Application_Model_Application::getBaseImagePath() . '/' . $dst; if (!is_dir(dirname($base_dst))) { mkdir(dirname($base_dst), 0777, true); } if (!$color) { $color = $this->getImageColor(); } $color = str_replace('#', '', $color); $rgb = $this->toRgb($color); list($width, $height) = getimagesize($tile_path); $tile = imagecreatefromstring(file_get_contents($tile_path)); if ($tile) { for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { $colors = imagecolorat($tile, $x, $y); $current_rgb = imagecolorsforindex($tile, $colors); if ($flat) { $color = imagecolorallocatealpha($tile, $rgb['red'], $rgb['green'], $rgb['blue'], $current_rgb['alpha']); } else { $color = imagecolorallocatealpha($tile, $current_rgb['red'] * $rgb['red'] / 255, $current_rgb['green'] * $rgb['green'] / 255, $current_rgb['blue'] * $rgb['blue'] / 255, $current_rgb['alpha']); } imagesetpixel($tile, $x, $y, $color); } } $filename = basename($tile_path); imagesavealpha($tile, true); if (!@imagepng($tile, $base_dst)) { $dst = ''; } } return $dst; }
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 editpostAction() { if ($datas = $this->getRequest()->getPost()) { $html = ''; try { // Test s'il y a un value_id if (empty($datas['value_id'])) { throw new Exception($this->_('An error occurred while saving your page.')); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); if (!$option_value->getId()) { throw new Exception($this->_('An error occurred while saving your page.')); } $page = new Cms_Model_Application_Page(); if (!empty($datas["page_id"])) { if ($datas["page_id"] == "new") { unset($datas["page_id"]); } $page->find($datas["page_id"]); if ($page->getId() and $page->getValueId() != $option_value->getId()) { throw new Exception($this->_('An error occurred while saving your page.')); } } if (empty($datas["picture"])) { $datas["picture"] = null; } else { if (file_exists(Core_Model_Directory::getTmpDirectory(true) . "/" . $datas["picture"])) { $application = $this->getApplication(); $relative_path = $option_value->getImagePathTo(); $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $path = Application_Model_Application::getBaseImagePath() . $relative_path; $file = Core_Model_Directory::getTmpDirectory(true) . '/' . $datas['picture']; if (!is_dir($path)) { mkdir($path, 0777, true); } if (!copy($file, $folder . $datas['picture'])) { throw new exception($this->_('An error occurred while saving. Please try again later.')); } else { $datas['picture'] = $relative_path . $datas['picture']; } } } // Traitement des images des blocks $blocks = !empty($datas['block']) && is_array($datas['block']) ? $datas['block'] : array(); $image_path = $option_value->getImagePathTo() . '/'; $base_image_path = $this->getApplication()->getBaseImagePath() . $image_path; if (!is_dir($base_image_path)) { mkdir($base_image_path, 0777, true); } foreach ($blocks as $k => $block) { if ($block["type"] == "image" && !empty($block['image_url'])) { foreach ($block['image_url'] as $index => $image_url) { //déjà enregistrée if (substr($image_url, 0, 1) != '/') { if (!empty($image_url) and file_exists(Core_Model_Directory::getTmpDirectory(true) . '/' . $image_url)) { rename(Core_Model_Directory::getTmpDirectory(true) . '/' . $image_url, $base_image_path . $image_url); $blocks[$k]['image_url'][$index] = $image_path . $image_url; } } else { // $img = explode('/', $image_url); // $img = $img[count($img) - 1]; // $blocks[$k]['image_url'][$index] = $image_path . $img; $blocks[$k]['image_url'][$index] = $image_url; } } foreach ($block['image_fullsize_url'] as $index => $image_url) { //déjà enregistrée if (substr($image_url, 0, 1) != '/') { if (!empty($image_url) and file_exists(Core_Model_Directory::getTmpDirectory(true) . '/' . $image_url)) { rename(Core_Model_Directory::getTmpDirectory(true) . '/' . $image_url, $base_image_path . $image_url); $blocks[$k]['image_fullsize_url'][$index] = $image_path . $image_url; } } else { // $img = explode('/', $image_url); // $img = $img[count($img) - 1]; // $blocks[$k]['image_fullsize_url'][$index] = $image_path . $img; $blocks[$k]['image_fullsize_url'][$index] = $image_url; } } } if (($block["type"] == "text" || $block["type"] == "video") && !empty($block['image'])) { //déjà enregistrée if (substr($block['image'], 0, 1) != '/') { if (!empty($block['image']) and file_exists(Core_Model_Directory::getTmpDirectory(true) . '/' . $block['image'])) { rename(Core_Model_Directory::getTmpDirectory(true) . '/' . $block['image'], $base_image_path . $block['image']); $blocks[$k]['image'] = $image_path . $block['image']; } } else { // $img = explode('/', $block['image']); // $img = $img[count($img) - 1]; // $blocks[$k]['image'] = $image_path . $img; $blocks[$k]['image'] = $block['image']; } } if ($block["type"] == "text") { $blocks[$k]["content"] = stripslashes($block["content"]); } if ($block["type"] == "address" and (empty($block["latitude"]) or empty($block["longitude"]))) { $latlon = Siberian_Google_Geocoding::getLatLng(array("address" => $block["address"])); if (!empty($latlon[0]) and !empty($latlon[1])) { $blocks[$k]["latitude"] = $latlon[0]; $blocks[$k]["longitude"] = $latlon[1]; } } } $datas['block'] = $blocks; // Sauvegarde $page->setData($datas)->save(); $html = array('success' => 1, 'success_message' => $this->_('Page successfully saved'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function editpostAction() { if ($data = $this->getRequest()->getPost()) { $html = ''; try { // Test s'il y a un value_id if (empty($data['value_id'])) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($data['value_id']); // Instancie une nouvelle promotion $promotion = new Promotion_Model_Promotion(); // Test si l'option des réductions spéciales est activée et payée if ($id = $this->getRequest()->getParam('id')) { $promotion->find($id); if ($promotion->getValueId() and $promotion->getValueId() != $option_value->getId()) { throw new Exception('An error occurred while saving. Please try again later.'); } } //Vérifs champs if (empty($data['title']) || empty($data['description']) || empty($data['title'])) { throw new Exception($this->_('An error occurred while saving your discount. Please fill in all fields')); } if (!isset($data['is_illimited']) && empty($data['end_at'])) { throw new Exception($this->_('An error occurred while saving your discount. Please fill in all fields')); } if (!empty($data['end_at'])) { $date_actuelle = new Zend_Date(); $date_modif = new Zend_Date($data['end_at'], 'y-MM-dd'); if ($date_modif < $date_actuelle) { throw new Exception($this->_('Please select an end date greater than the current date.')); die; } } if (!empty($data['is_illimited'])) { $data['end_at'] = null; } $data['force_validation'] = !empty($data['force_validation']); $data['is_unique'] = !empty($data['is_unique']); $data['owner'] = 1; if (isset($data['available_for']) and $data['available_for'] == 'all') { $promotion->resetConditions(); } if (!empty($data['picture'])) { $filename = pathinfo($data['picture'], PATHINFO_BASENAME); $relative_path = $option_value->getImagePathTo(); $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $img_dst = $folder . '/' . $filename; $img_src = Core_Model_Directory::getTmpDirectory(true) . '/' . $filename; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!@copy($img_src, $img_dst)) { throw new exception($this->_('An error occurred while saving your picture. Please try again later.')); } else { $data['picture'] = $relative_path . '/' . $filename; } } else { if (!empty($data['remove_cover'])) { $data['picture'] = null; } } $promotion->setData($data); $promotion->save(); if (!empty($data['unlock_code'])) { $dir_image = Core_Model_Directory::getBasePathTo("/images/application/" . $this->getApplication()->getId()); if (!is_dir($dir_image)) { mkdir($dir_image, 0775, true); } if (!is_dir($dir_image . "/application")) { mkdir($dir_image . "/application", 0775, true); } if (!is_dir($dir_image . "/application/qrpromotion")) { mkdir($dir_image . "/application/qrpromotion", 0775, true); } $dir_image .= "/application/qrpromotion/"; $image_name = $promotion->getId() . "-qrpromotion_qrcode.png"; copy('http://api.qrserver.com/v1/create-qr-code/?color=000000&bgcolor=FFFFFF&data=sendback%3A' . $data["unlock_code"] . '&qzone=1&margin=0&size=200x200&ecc=L', $dir_image . $image_name); } $html = array('promotion_id' => $promotion->getId(), 'success_message' => $this->_('Discount successfully saved'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'url' => '/promotion/admin/list'); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function preDispatch() { parent::preDispatch(); $this->_upload_path = Application_Model_Application::getBaseImagePath(); }
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 editpostAction() { if ($datas = $this->getRequest()->getPost()) { $html = ''; try { // Test s'il y a un value_id if (empty($datas['value_id'])) { throw new Exception($this->_("An error occurred while saving your images gallery. Please try again later.")); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); $isNew = true; $save = true; $image = new Media_Model_Gallery_Image(); if (!empty($datas['id'])) { $image->find($datas['id']); $isNew = false; $id = $datas['id']; } else { $id = 'new'; $datas['value_id'] = $option_value->getId(); } if ($image->getId() and $image->getValueId() != $option_value->getId()) { throw new Exception("An error occurred while saving your images gallery. Please try again later."); } if (!empty($datas['param_instagram'])) { $instagram = new Media_Model_Gallery_Image_Instagram(); $userId = $instagram->getUserId($datas['param_instagram']); if (!$userId) { throw new Exception($this->_("The entered name is not a valid Instagram user.")); } $datas['type_id'] = 'instagram'; } elseif (!empty($datas['param'])) { $datas['type_id'] = 'picasa'; } else { $datas['type_id'] = 'custom'; } $html = array('success' => 1, 'is_new' => (int) $isNew); if (empty($datas['type_id']) or $datas['type_id'] == 'picasa') { $image->setTypeId('picasa'); $image->getTypeInstance()->setParam($datas['param']); if (empty($datas['album_id'])) { $albums = $image->getTypeInstance()->findAlbums(); } if (!empty($albums)) { $html['albums'] = $albums; $save = false; } $datas['type'] = !empty($datas['album_id']) || !empty($albums) ? 'album' : 'search'; } if ($save) { $image->setData($datas)->save(); $html['id'] = (int) $image->getId(); $html['is_new'] = (int) $isNew; $html['success_message'] = $this->_("Images gallery has been saved successfully"); $html['message_timeout'] = 2; $html['message_button'] = 0; $html['message_loader'] = 0; if (isset($datas['images']['list_' . $id])) { foreach ($datas['images']['list_' . $id] as $key => $info) { $gallery = new Media_Model_Gallery_Image_Custom(); if (!empty($info['image_id'])) { $gallery->find($info['image_id']); } if (!empty($info['delete'])) { $gallery->delete(); continue; } if (!$gallery->getId()) { $gallery->setGalleryId($image->getId()); } if (!empty($info['path'])) { $filename = $info['path']; $img_src = Core_Model_Directory::getTmpDirectory(true) . '/' . $filename; if (file_exists($img_src)) { $relative_path = $option_value->getImagePathTo(); $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $img_dst = $folder . '/' . $filename; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!@rename($img_src, $img_dst)) { throw new Exception("An error occurred while saving your images gallery. Please try again later."); } $gallery->setUrl($relative_path . '/' . $filename); } } $gallery->setTitle(!empty($info['title']) ? $info['title'] : null)->setDescription(!empty($info['description']) ? $info['description'] : null)->save(); } } } } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
/** * Sauvegarde */ public function postAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { $data = $data["form"]; $data_image = array(); $errors = ''; // Recherche des sections $section = new Form_Model_Section(); $sections = $section->findByValueId($this->getCurrentOptionValue()->getId()); $field = new Form_Model_Field(); // Date Validator // $validator = new Zend_Validate_Date(array('format' => 'yyyy-mm-ddTHH:mm')); $dataChanged = array(); foreach ($sections as $k => $section) { // Load the fields $section->findFields($section->getId()); // Browse the fields foreach ($section->getFields() as $field) { // If the field has options if ($field->hasOptions()) { // If the data is not empty if (isset($data[$field->getId()])) { // if all checkbox = false $empty_checkbox = false; if (is_array($data[$field->getId()])) { if (count($data[$field->getId()]) <= count(array_keys($data[$field->getId()], false))) { $empty_checkbox = true; } } if (!$empty_checkbox) { // Browse the field's options foreach ($field->getOptions() as $option) { // If it's a multiselect option and there's at least one selected option, store its value if (is_array($data[$field->getId()])) { // If the key exists, if (array_key_exists($option["id"], $data[$field->getId()])) { // $data[$field->getId()][$option["id"]] = $option["name"]; if ($data[$field->getId()][$option["id"]]) { $dataChanged[$field->getName()][$option["id"]] = $option["name"]; } } // If the current option has been posted, store its value } else { if ($option["id"] == $data[$field->getId()]) { // $data[$field->getId()] = $option["name"]; $dataChanged[$field->getName()] = $option["name"]; } } } } else { if ($field->isRequired()) { $errors .= $this->_('<strong>%s</strong> must be filled<br />', $field->getName()); } } // If the field is empty and required, add an error } else { if ($field->isRequired()) { $errors .= $this->_('<strong>%s</strong> must be filled<br />', $field->getName()); } } } else { // If the field is required if ($field->isRequired()) { // Add an error based on its type (and if it's empty) switch ($field->getType()) { case "email": if (empty($data[$field->getId()]) or !Zend_Validate::is($data[$field->getId()], 'EmailAddress')) { $errors .= $this->_('<strong>%s</strong> must be a valid email address<br />', $field->getName()); } break; case "nombre": if (!isset($data[$field->getId()]) or !Zend_Validate::is($data[$field->getId()], 'Digits')) { $errors .= $this->_('<strong>%s</strong> must be a numerical value<br />', $field->getName()); } break; case "date": if (!isset($data[$field->getId()])) { $errors .= $this->_('<strong>%s</strong> must be a valid date (e.g. dd/mm/yyyy)<br />', $field->getName()); } break; default: if (empty($data[$field->getId()])) { $errors .= $this->_('<strong>%s</strong> must be filled<br />', $field->getName()); } break; } } // If not empty, store its value if (!empty($data[$field->getId()])) { // If the field is an image if ($field->getType() == "image") { $image = $data[$field->getId()]; if (!preg_match("@^data:image/([^;]+);@", $image, $matches)) { throw new Exception($this->_("Unrecognized image format")); } $extension = $matches[1]; $fileName = uniqid() . '.' . $extension; $relativePath = $this->getCurrentOptionValue()->getImagePathTo(); $fullPath = Application_Model_Application::getBaseImagePath() . $relativePath; if (!is_dir($fullPath)) { mkdir($fullPath, 0777, true); } $filePath = $fullPath . '/' . $fileName; $contents = file_get_contents($image); if ($contents === FALSE) { throw new Exception($this->_("No uploaded image")); } $res = @file_put_contents($filePath, $contents); if ($res === FALSE) { throw new Exception('Unable to save image'); } list($width, $height) = getimagesize($fullPath . DS . $fileName); $max_height = $max_width = 600; $image_name = uniqid($max_height); if ($height > $width) { $image_width = $max_height * $width / $height; $image_height = $max_height; } else { $image_width = $max_width; $image_height = $max_width * $height / $width; } $newIcon = new Core_Model_Lib_Image(); $newIcon->setId($image_name)->setPath($fullPath . DS . $fileName)->setWidth($image_width)->setHeight($image_height)->crop(); $image_url = $this->getRequest()->getBaseUrl() . $newIcon->getUrl(); $dataChanged[$field->getName()] = '<br/><img width="' . $image_width . '" height="' . $image_height . '" src="' . $image_url . '" alt="' . $field->getName() . '" />'; } else { $dataChanged[$field->getName()] = $data[$field->getId()]; } } } } } if (empty($errors)) { $form = $this->getCurrentOptionValue()->getObject(); $layout = $this->getLayout()->loadEmail('form', 'send_email'); $layout->getPartial('content_email')->setFields($dataChanged); $content = $layout->render(); $mail = new Zend_Mail('UTF-8'); $mail->setBodyHtml($content); $mail->setFrom($form->getEmail(), $this->getApplication()->getName()); $mail->addTo($form->getEmail(), $this->_('Your app\'s form')); $mail->setSubject($this->_('Your app\'s form')); $mail->send(); $html = array("success" => 1, "message" => $this->_("The form has been sent successfully")); } else { $html = array('error' => 1, 'message' => $errors); } } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }
public function editpostAction() { if ($data = $this->getRequest()->getPost()) { try { if (empty($data['value_id'])) { throw new Exception($this->_('An error occurred while saving the product. Please try again later.')); } $option_value = new Application_Model_Option_Value(); $option_value->find($data['value_id']); $html = array(); $product = new Catalog_Model_Product(); if (!empty($data['product_id'])) { $product->find($data['product_id']); } $isNew = (bool) (!$product->getId()); $isDeleted = !empty($data['is_deleted']); if ($product->getId() and $product->getValueId() != $option_value->getId()) { throw new Exception($this->_('An error occurred while saving the product. Please try again later.')); } if (!$isDeleted) { if (!isset($data['is_active'])) { $data['is_active'] = 1; } $data['value_id'] = $option_value->getValueId(); $parent_id = $data['category_id']; if (!empty($data['subcategory_id'])) { $data['category_id'] = $data['subcategory_id']; } if (!empty($data['picture'])) { if (!file_exists(Core_Model_Directory::getTmpDirectory(true) . "/" . $data['picture'])) { unset($data['picture']); } else { $illus_relative_path = $option_value->getImagePathTo(); $folder = Application_Model_Application::getBaseImagePath() . $illus_relative_path; $file = pathinfo(Core_Model_Directory::getBasePathTo($data['picture'])); $filename = $file['basename']; $img_src = Core_Model_Directory::getTmpDirectory(true) . "/" . $data['picture']; $img_dst = $folder . '/' . $filename; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!@copy($img_src, $img_dst)) { throw new exception($this->_('An error occurred while saving your picture. Please try againg later.')); } else { $data['picture'] = $illus_relative_path . '/' . $filename; } } } } if (!$product->getId() and empty($data['is_multiple']) or $product->getId() and $product->getData('type') != 'format' and isset($data['option'])) { unset($data['option']); } $product->addData($data); $product->save(); $html = array('success' => 1); if (!$isDeleted) { $product_id = $product->getId(); $product = new Catalog_Model_Product(); $product->find($product_id); $html = array('success' => 1, 'product_id' => $product->getId(), 'parent_id' => $parent_id, 'category_id' => $data['category_id']); $html['product_html'] = $this->getLayout()->addPartial('row', 'admin_view_default', 'catalog/application/edit/category/product.phtml')->setProduct($product)->setOptionValue($option_value)->toHtml(); } } catch (Exception $e) { $html['message'] = $e->getMessage(); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
protected function _createIcon($datas) { // Créé l'icône $image = imagecreatetruecolor(256, 256); // Rempli la couleur de fond $rgb = $this->_hex2RGB(00); $background_color = imagecolorallocate($image, $rgb['red'], $rgb['green'], $rgb['blue']); imagefill($image, 0, 0, $background_color); $targ_w = $targ_h = 256; if (!empty($datas['icon']['file'])) { //Applique l'image $logo_relative_path = '/logo/'; $folder = Application_Model_Application::getBaseImagePath() . $logo_relative_path; if (!is_dir($folder)) { mkdir($folder, 0777, true); } $src = Core_Model_Directory::getTmpDirectory(true) . '/' . $datas['icon']['file']; $source = imagecreatefromstring(file_get_contents($src)); } $dest = ImageCreateTrueColor($targ_w, $targ_h); imagecopyresampled($dest, $image, 0, 0, 0, 0, $targ_w, $targ_h, $targ_w, $targ_h); if ($datas['icon']['file'] != '') { imagecopyresampled($dest, $source, 0, 0, $datas['icon']['x1'], $datas['icon']['y1'], $targ_w, $targ_h, $datas['icon']['w'], $datas['icon']['h']); } return $dest; }
public function deletePictures() { if ($picture_list = $this->getRemovePicture()) { foreach ($picture_list as $picture) { if ($picture != "") { $image = new Media_Model_Library_Image(); $image->find($picture); if ($image->getId()) { unlink(Application_Model_Application::getBaseImagePath() . $image->getLink()); $image->delete(); } } } } }
public function editpostAction() { if ($datas = $this->getRequest()->getPost()) { $html = ''; try { $message = new Push_Model_Message(); $message->setMessageTypeByOptionValue($this->getCurrentOptionValue()->getOptionId()); $sendNow = false; $inputs = array('send_at', 'send_until'); foreach ($inputs as $input) { if (empty($datas[$input . '_a_specific_datetime'])) { $datas[$input] = null; } else { if (empty($datas[$input])) { throw new Exception($this->_('Please, enter a valid date')); } else { $date = new Zend_Date($datas[$input]); $datas[$input] = $date->toString('y-MM-dd HH:mm:ss'); } } } if (empty($datas['send_at'])) { $sendNow = true; $datas['send_at'] = Zend_Date::now()->toString('y-MM-dd HH:mm:ss'); } if (!empty($datas['send_until']) and $datas['send_at'] > $datas['send_until']) { throw new Exception($this->_("The duration limit must be higher than the sent date")); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); if (!empty($datas['file'])) { $file = pathinfo($datas['file']); $filename = $file['basename']; $relative_path = $option_value->getImagePathTo(); $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $img_dst = $folder . $filename; $img_src = Core_Model_Directory::getTmpDirectory(true) . '/' . $filename; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!@copy($img_src, $img_dst)) { throw new exception($this->_('An error occurred while saving your picture. Please try again later.')); } else { $datas['cover'] = $relative_path . $filename; } } else { if (!empty($data['remove_cover'])) { $data['cover'] = null; } } if (empty($datas['action_value'])) { $datas['action_value'] = null; } else { if (!preg_match('/^[0-9]*$/', $datas['action_value'])) { $url = "http://" . $datas['action_value']; if (stripos($datas['action_value'], "http://") !== false || stripos($datas['action_value'], "https://") !== false) { $url = $datas['action_value']; } $datas['action_value'] = file_get_contents("http://tinyurl.com/api-create.php?url=" . urlencode($url)); } } $datas['type_id'] = $message->getMessageType(); $datas['app_id'] = $this->getApplication()->getId(); $datas["send_to_all"] = $datas["topic_receiver"] ? 0 : 1; $message->setData($datas)->save(); //PnTopics if ($datas["topic_receiver"]) { $topic_data = explode(";", $datas["topic_receiver"]); foreach ($topic_data as $id_topic) { if ($id_topic != "") { $category_message = new Topic_Model_Category_Message(); $category_message_data = array("category_id" => $id_topic, "message_id" => $message->getId()); $category_message->setData($category_message_data); $category_message->save(); } } } if ($message->getMessageType() == 1) { if ($sendNow) { $c = curl_init(); curl_setopt($c, CURLOPT_URL, $this->getUrl('push/message/send', array('message_id' => $message->getId()))); curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); // Follow the redirects (needed for mod_rewrite) curl_setopt($c, CURLOPT_HEADER, false); // Don't retrieve headers curl_setopt($c, CURLOPT_NOBODY, true); // Don't retrieve the body curl_setopt($c, CURLOPT_RETURNTRANSFER, true); // Return from curl_exec rather than echoing curl_setopt($c, CURLOPT_FRESH_CONNECT, true); // Always ensure the connection is fresh // Timeout super fast once connected, so it goes into async. curl_setopt($c, CURLOPT_TIMEOUT, 10); curl_exec($c); curl_close($c); } } else { $message->updateStatus('delivered'); } $html = array('success' => 1, 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); if ($sendNow) { $html['success_message'] = $this->_('Your message has been saved successfully and will be sent in a few minutes'); } else { $html['success_message'] = $this->_('Your message has been saved successfully and will be sent at the entered date'); } } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function editpostAction() { if ($datas = $this->getRequest()->getPost()) { try { $isNew = false; $application = $this->getApplication(); // Test s'il y a un value_id if (empty($datas['value_id'])) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); $html = array('success' => '1', 'success_message' => $this->_('Link has been successfully saved'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); // Prépare la weblink $weblink = $option_value->getObject(); if (!$weblink->getId()) { $weblink->setValueId($datas['value_id']); } // S'il y a une cover image if (!empty($datas['file'])) { if (!empty($datas['file'])) { $relative_path = '/weblink/cover/'; $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $path = Application_Model_Application::getBaseImagePath() . $relative_path; $file = Core_Model_Directory::getTmpDirectory(true) . '/' . $datas['file']; if (!is_dir($path)) { mkdir($path, 0777, true); } if (!copy($file, $folder . $datas['file'])) { throw new exception($this->_('An error occurred while saving your picture. Please try againg later.')); } else { $weblink->setCover($relative_path . $datas['file']); } if (empty($datas['link'])) { $html['success_message'] = $this->_("The image has been successfully saved"); } } } else { if (!empty($datas['remove_cover'])) { $weblink->setCover(null); if (empty($datas['link'])) { $html['success_message'] = $this->_("The image has been successfully deleted"); } } } // Sauvegarde le weblink $weblink->save(); if (!empty($datas['link'])) { $link_datas = $datas['link']; if (empty($link_datas['url']) or !Zend_Uri::check($link_datas['url'])) { throw new Exception($this->_('Please enter a valid url')); } // Prépare le link $link = new Weblink_Model_Weblink_Link(); if (!empty($link_datas['link_id'])) { $link->find($link_datas['link_id']); } $isNew = !$link->getId(); $link_datas['weblink_id'] = $weblink->getId(); // Test s'il y a un picto if (!empty($link_datas['picto']) and file_exists(Core_Model_Directory::getTmpDirectory(true) . '/' . $link_datas['picto'])) { $relative_path = '/pictos/'; $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $path = Application_Model_Application::getBaseImagePath() . $relative_path; $file = Core_Model_Directory::getTmpDirectory(true) . '/' . $link_datas['picto']; if (!is_dir($path)) { mkdir($path, 0777, true); } if (!copy($file, $folder . $link_datas['picto'])) { throw new exception($this->_("An error occurred while saving your picto. Please try againg later.")); } else { $link_datas['picto'] = $relative_path . $link_datas['picto']; } } // Sauvegarde le link $link->addData($link_datas)->save(); if ($link->getIsDeleted()) { $html['success_message'] = $this->_('Link has been successfully deleted'); $html['is_deleted'] = 1; } } if ($isNew) { $html['row_html'] = $this->getLayout()->addPartial('row_', 'admin_view_default', 'weblink/application/multi/edit/row.phtml')->setCurrentLink($link)->setCurrentOptionValue($option_value)->toHtml(); } } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function editAction() { if ($datas = $this->getRequest()->getPost()) { try { $application = $this->getApplication(); // Test s'il y a un value_id if (empty($datas['agenda_id'])) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } $event = new Event_Model_Event_Custom(); $option_value = $this->getCurrentOptionValue(); $data = array(); if (!empty($datas['id'])) { $event->find($datas['id']); if ($event->getAgendaId() != $datas['agenda_id']) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } } if (!empty($datas['picture'])) { $filename = $datas['picture']; $img_src = Core_Model_Directory::getTmpDirectory(true) . '/' . $filename; if (file_exists($img_src)) { $relative_path = $option_value->getImagePathTo(); $folder = Application_Model_Application::getBaseImagePath() . $relative_path; $img_dst = $folder . '/' . $filename; if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (!@copy($img_src, $img_dst)) { throw new exception($this->_("An error occurred while saving your picture. Please try againg later.")); } else { $datas['picture'] = $relative_path . '/' . $filename; } } else { unset($data['picture']); } } else { $datas['picture'] = null; } foreach (array("rsvp", "ticket_shop_url", "location_url") as $url_type) { if (!empty($datas[$url_type]) and stripos($datas[$url_type], 'http') === false) { $datas[$url_type] = 'http://' . $datas[$url_type]; } } if (!empty($datas["websites"]) and is_array($datas["websites"])) { $websites = array(); $cpt = 0; foreach ($datas["websites"] as $website) { if (empty($website["label"]) or empty($website["url"])) { continue; } if (stripos($website["url"], 'http') === false) { $website["url"] = 'http://' . $website["url"]; } $websites[++$cpt] = $website; } $datas["websites"] = Zend_Json::encode($websites); } else { $datas["websites"] = null; } $event->addData($datas)->save(); $cache = Zend_Registry::get('cache'); $cache->remove($option_value->getObject()->getCacheId()); $html = array('success' => '1', 'success_message' => $this->_("Event successfully saved"), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function getPictureUrl() { $path = Application_Model_Application::getImagePath() . $this->getPicture(); $base_path = Application_Model_Application::getBaseImagePath() . $this->getPicture(); return is_file($base_path) ? $path : null; }
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)); } }