/** * Constructor * */ function __construct($application, $options) { $this->_application = $application; $this->_options = $options; $this->_subPath = $this->_application->get_id(); $this->_root = $this->_options['root'] . "/" . $this->_subPath; $this->_tmpPath = $this->_options['tmpFolder'] . "/" . $this->_subPath; $this->_webRoot = $this->_options['webRoot'] . "/" . $this->_subPath; $this->_forceRoot = $this->_options['forceRoot']; }
public function editAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $formTab = $this->getRequest()->getUserParam('tab', "Ga"); $id = $this->_applicationId; //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } $application = new Application_Model_Application(); if (!Application_Model_ApplicationMapper::getInstance()->find($id, $application)) { throw new Exception("Configuration not found"); } $this->view->data = $application->toArray(); $bootstrap = $this->getInvokeArg('bootstrap'); $config = $bootstrap->getOptions(); $this->view->clientId = isset($config['googleapi']['analitycs']['clientId']) && $config['googleapi']['analitycs']['clientId'] != '' ? $config['googleapi']['analitycs']['clientId'] : ''; $formClassName = "Admin_Form_Config" . $formTab; if (!class_exists($formClassName)) { $this->_formHelper->returnError("ne postoji"); // Mare Srbine } //create form object $form = new $formClassName($data); $errors = array(); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values['settings'] = $application->get_settings(); $formValues = $form->getValues(); switch ($formTab) { case "Ga": $values['settings']['tags']['ga']['tracking_id'] = $formValues['tracking_id']; $values['settings']['tags']['ga']['active'] = $formValues['ga_active'] == "true" ? true : false; break; case "GaView": $values['settings']['tags']['ga']['view_id'] = $formValues['view_id']; break; } //create entity object from submitted values, and save $application = new Application_Model_Application($values); $application->set_id($this->_applicationId); //new entity Application_Model_ApplicationMapper::getInstance()->save($application); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Configuration saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } }
/** * Get facebook resources // js, html * * @param Application_Model_Application $app * @param array $config => connect, resize, https, resizeScript */ public function facebookRes($app, $config = array()) { $connect = isset($config['connect']) ? $config['connect'] : true; $resize = isset($config['resize']) ? $config['resize'] : true; $https = isset($config['https']) ? $config['https'] : true; if (!isset($app) || !$connect && !$resize) { return false; } $fbLocale = 'en_US'; $signedRequest = $app->get_signed_request(); if (isset($signedRequest['user']['locale'])) { $fbLocale = $signedRequest['user']['locale']; } $fbConnectFile = 'http'; if ($https) { $fbConnectFile .= 's'; } $fbConnectFile .= '://connect.facebook.net/' . $fbLocale . '/all.js'; $resizeScript = ''; if ($resize) { if (isset($config['resizeScript'])) { $resizeScript = $config['resizeScript']; } else { $resizeScript .= 'FB.Canvas.setAutoGrow();'; } } $html = ' <div id="fb-root"></div> <script type="text/javascript"> window.fbAsyncInit = function() { FB.init({ appId : \'' . $app->get_fb_settings('api_id') . '\', //status : true, // check login status //cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); ' . $resizeScript . ' }; (function(d){ var js, id = \'facebook-jssdk\'; if (d.getElementById(id)) { return; // already loaded, no need to load again } js = d.createElement(\'script\'); js.id = id; js.async = true; js.src = "' . $fbConnectFile . '"; d.getElementsByTagName(\'head\')[0].appendChild(js); }(document)); </script> '; return $html; }
/** * Get Google Search code * * @param Application_Model_Application $app */ public function GoogleSearchCode($app, $ReturnCss = true) { $gsSettings = $app->get_settings('gsc'); $html = ''; if (!isset($gsSettings) || $gsSettings['cx'] == '' || !isset($gsSettings['active']) || $gsSettings['active'] == false) { return ''; } if ($ReturnCss) { echo $this->prepareCss($gsSettings); } $html = "\n <div id='search'>\n <script>\n (function() {\n var cx = '" . $gsSettings['cx'] . "';\n var gcse = document.createElement('script');\n gcse.type = 'text/javascript';\n gcse.async = true;\n gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +\n '//www.google.com/cse/cse.js?cx=' + cx;\n var s = document.getElementsByTagName('script')[0];\n s.parentNode.insertBefore(gcse, s);\n })();\n </script>\n \n "; $html .= "<gcse:searchbox-only " . "resultsUrl='" . $this->view->serverUrl() . "/" . $this->view->currLang . "/search' " . "lr='lang_" . $this->view->currLang . "' enableAutoComplete='true'>" . "</gcse:searchbox-only>\n</div>"; $html .= "<span id='searchToggle' class='fa fa-search'></span>"; echo $html; }
public function setPathInfo($pathInfo = null) { parent::setPathInfo($pathInfo); $path = $this->_pathInfo; $paths = explode('/', trim($path, '/')); $language = !empty($paths[0]) ? $paths[0] : ''; if (in_array($language, Core_Model_Language::getLanguageCodes())) { $this->_language_code = $language; unset($paths[array_search($language, $paths)]); $paths = array_values($paths); } if (!$this->isInstalling()) { if (!empty($paths[0]) and $paths[0] == Application_Model_Application::OVERVIEW_PATH) { $this->_is_application = true; $this->_use_application_key = true; unset($paths[0]); } if (Application_Model_Application::getInstance()->getDomain() == $this->getHttpHost()) { $this->_is_application = true; $this->_use_application_key = false; } } $paths = array_diff($paths, Core_Model_Language::getLanguageCodes()); $paths = array_values($paths); $this->_pathInfo = '/' . implode('/', $paths); return $this; }
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 init() { parent::init(); $this->getResponse()->setHeader('Content-Type', 'application/xml; charset="UTF-8"'); if (preg_match('/(uploadimage)/', $this->getRequest()->getActionName())) { return $this; } $this->_current_device_id = $this->getRequest()->getParam('device_id'); $this->_current_app = Application_Model_Application::getInstance(); if ($customer_id = $this->getRequest()->getParam('customer_id')) { $customer->find($customer_id); if (!$customer->getId()) { $error = true; } else { $this->_current_customer = $customer; } } else { $this->_current_customer = $customer; } if (!$customer->getId()) { $error = true; } if ($error) { $this->_sendError(); } }
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 getApplications() { if (!$this->_applications) { $this->_applications = array(Application_Model_Application::getInstance()); } return $this->_applications; }
public function findallAction() { $html = array("collection" => array()); try { if ($data = $this->getRequest()->getParams()) { // if($device_uid = $this->getRequest()->getParam('device_uid')) { $device_uid = $this->getRequest()->getParam('device_uid'); $topic = new Topic_Model_Topic(); $topic->find(array("value_id" => $data["value_id"])); $subscription = new Topic_Model_Subscription(); $html = array(); if ($topic->getId()) { $html["description"] = $topic->getDescription(); $parent_categories = $topic->getCategories(); foreach ($parent_categories as $category) { $picture = $category->getPicture() ? Application_Model_Application::getImagePath() . $category->getPicture() : ""; $data_category = array("id" => $category->getId(), "name" => $category->getName(), "description" => $category->getDescription(), "picture" => $picture, "is_subscribed" => $device_uid ? $subscription->isSubscribed($category->getId(), $device_uid) : null); $children = $category->getChildren(); $data_children = array(); foreach ($children as $child) { $picture = $child->getPicture() ? Application_Model_Application::getImagePath() . $child->getPicture() : ""; $data_children[] = array("id" => $child->getId(), "name" => $child->getName(), "description" => $child->getDescription(), "picture" => $picture, "is_subscribed" => $device_uid ? $subscription->isSubscribed($child->getId(), $device_uid) : null); } $data_category["children"] = $data_children; $html["collection"][] = $data_category; } } // } } } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $html["page_title"] = $this->getCurrentOptionValue()->getTabbarName(); $this->_sendHtml($html); }
public static function getInstance() { if (!self::$_instance) { self::$_instance = new self(); self::$_instance->find(1); } return self::$_instance; }
public function deleteAction() { if ($app_id = $this->getRequest()->getParam('app_id')) { try { $application = new Application_Model_Application(); $application->find($app_id); if (!$application->getId()) { throw new Exception($this->_("This application does not exist")); } $application->delete(); $html = array('success' => 1, 'app_id' => $app_id); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }
public function findbyadminAction() { $data = array("app_ids" => array(), "is_allowed_to_add_pages" => array()); $application = new Application_Model_Application(); if (!Siberian_Version::is("sae")) { $applications = $application->findAllByAdmin($this->getRequest()->getParam("admin_id")); } else { $applications = array(Application_Model_Application::getInstance()); } foreach ($applications as $application) { $data["app_ids"][] = $application->getId(); if ($application->getIsAllowedToAddPages()) { $data["is_allowed_to_add_pages"][] = $application->getId(); } } $this->_sendHtml($data); }
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 getBackgroundImageUrl() { if (!$this->_background_image_url) { if ($this->getBackgroundImage() and $this->getBackgroundImage() != "no-image") { $this->_background_image_url = Application_Model_Application::getImagePath() . $this->getBackgroundImage(); } } return $this->_background_image_url; }
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 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 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() { $url = null; if ($this->getPicture()) { if (file_exists(Core_Model_Directory::getBasePathTo(Application_Model_Application::getImagePath() . $this->getPicture()))) { $url = Application_Model_Application::getImagePath() . $this->getPicture(); } } return $url; }
public function createAction() { if ($datas = $this->getRequest()->getPost()) { $application = new Application_Model_Application(); try { if (empty($datas['name'])) { throw new Exception($this->_('Please, enter a name')); } $application->setName($datas['name'])->save(); // rename(APPLICATION_PATH.'/Bootstrap.php', APPLICATION_PATH.'/Bootstrap.old.php'); // rename(APPLICATION_PATH.'/Bootstrap.new.php', APPLICATION_PATH.'/Bootstrap.php'); $html = array('success' => 1); } catch (Exception $e) { $html = array('message' => $e->getMessage()); $this->getResponse()->setHttpResponseCode(400); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
/** * Hosting quota in bytes * * @return int */ public function getQuota() { //get hosting quota $quota = (int) $this->_application->get_settings('hosting_quota'); if (!isset($quota) || $quota <= 0) { //10MB gratis $quota = 10 * 1024 * 1024; } return $quota; }
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 setaddpageAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (empty($data["admin_id"]) or empty($data["app_id"])) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $admin = new Admin_Model_Admin(); $admin->find($data["admin_id"]); $application = new Application_Model_Application(); $application->find($data["app_id"]); if (!$admin->getId() or !$application->getId()) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $admin->setIsAllowedToAddPages(!empty($data["can_add_page"]))->save(); $data = array("success" => 1, "message" => $this->_("Data saved successfully.")); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
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 downloadappAction() { if ($app_id = $this->getRequest()->getParam('app_id')) { $mobile = new Mobile_Detect(); $application = new Application_Model_Application(); $application->find($app_id); $redirect_to = $application->getUrl(); if ($mobile->isAndroiddevice()) { $store_url = $application->getDevice(2)->getStoreUrl(); if ($store_url) { $redirect_to = preg_match('/details/', $store_url) ? preg_replace('/(.*\\/)((details).*)/', 'market://$2', $store_url) : $store_url; } } else { if ($mobile->isIosdevice()) { $store_url = $application->getDevice(1)->getStoreUrl(); if ($store_url) { $redirect_to = str_replace(array('http:', 'https:'), 'itms-apps:', $store_url); } } } $this->getResponse()->setRedirect($redirect_to)->sendResponse(); die; } }
protected function _initMenus() { $bootstrap = $this->getInvokeArg('bootstrap'); $config = $bootstrap->getOptions(); $menus = array('main', 'footer'); if (isset($config['menuSettings']['menus']) && count($config['menuSettings']['menus'])) { $menus = $config['menuSettings']['menus']; } $menuItemMapper = Cms_Model_MenuItemMapper::getInstance(); $this->view->menuItems = array(); foreach ($menus as $currMenu) { $this->view->menuItems[$currMenu] = new Zend_Navigation($menuItemMapper->fetchZendNavigationArray(array('application_id' => $this->_application->get_id(), 'menu' => $currMenu, 'lang' => CURR_LANG, 'visible_only' => true), array(), false)); } //set meta from menu if ($this->_isMetaFromActiveMenu) { $this->_populateMetaFromActiveMenu(); } }
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)); } }