예제 #1
0
 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);
 }
예제 #2
0
 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;
 }
예제 #3
0
 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 '';
 }
예제 #4
0
 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;
 }
예제 #5
0
 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;
 }
예제 #6
0
 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;
 }
예제 #7
0
 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;
 }
예제 #8
0
 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;
 }
예제 #9
0
 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));
     }
 }
예제 #10
0
 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));
     }
 }
예제 #11
0
 public function getImages($offset)
 {
     if (!$this->_images) {
         $this->_images = array();
         try {
             $image = new Media_Model_Gallery_Image_Custom();
             $params = array('limit' => self::DISPLAYED_PER_PAGE);
             if (!empty($offset)) {
                 $params['offset'] = $offset;
             }
             $images = $image->findAll(array('gallery_id' => $this->getImageId()), 'image_id DESC', $params);
         } catch (Exception $e) {
             $images = array();
         }
         foreach ($images as $key => $image) {
             $this->_images[] = new Core_Model_Default(array('offset' => $offset++, 'title' => $image->getTitle(), 'description' => $image->getDescription(), 'author' => null, 'image' => Application_Model_Application::getImagePath() . $image->getData('url')));
         }
     }
     return $this->_images;
 }
예제 #12
0
 public function findallAction()
 {
     $data = array("collection" => array());
     $option = $this->getCurrentOptionValue();
     $color = $this->getApplication()->getBlock('background')->getColor();
     $offset = $this->getRequest()->getParam('offset', 0);
     if ($device_uid = $this->getRequest()->getParam('device_uid')) {
         $message = new Push_Model_Message();
         $message->setMessageTypeByOptionValue($this->getCurrentOptionValue()->getOptionId());
         $messages = $message->findByDeviceId($device_uid, $offset);
         $icon_new = $option->getImage()->getCanBeColorized() ? $this->_getColorizedImage($option->getIconId(), $color) : $option->getIconUrl();
         $icon_pencil = $this->_getColorizedImage($this->_getImage("pictos/pencil.png"), $color);
         foreach ($messages as $message) {
             $meta = array("area1" => array("picto" => $icon_pencil, "text" => $message->getFormattedCreatedAt(Zend_Date::DATETIME_MEDIUM)));
             if (!$message->getIsRead()) {
                 $meta["area3"] = array("picto" => $icon_new, "text" => $this->_("New"));
             }
             $picture = $message->getCover() ? Application_Model_Application::getImagePath() . $message->getCover() : null;
             $action_value = null;
             if ($message->getActionValue()) {
                 if (is_numeric($message->getActionValue())) {
                     $option_value = new Application_Model_Option_Value();
                     $option_value->find($message->getActionValue());
                     $action_value = $option_value->getPath(null, array('value_id' => $option_value->getId()), false);
                 } else {
                     $action_value = $message->getActionValue();
                 }
             }
             if ($this->getApplication()->getIcon(74)) {
                 $icon = $this->getApplication()->getIcon(74);
             } else {
                 $icon = null;
             }
             $data["collection"][] = array("id" => $message->getId(), "author" => $message->getTitle(), "message" => $message->getText(), "topic" => $message->getLabel(), "meta" => $meta, "picture" => $picture, "icon" => $icon, "action_value" => $action_value);
         }
         $message->markAsRead($device_uid);
     }
     $data["page_title"] = $this->getCurrentOptionValue()->getTabbarName();
     $data["displayed_per_page"] = Push_Model_Message::DISPLAYED_PER_PAGE;
     $this->_sendHtml($data);
 }
예제 #13
0
 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));
     }
 }
예제 #14
0
 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));
     }
 }
예제 #15
0
 protected function _getNoImage()
 {
     return Application_Model_Application::getImagePath() . '/placeholder/no-image-event.png';
 }
예제 #16
0
 public function getImageFullSize()
 {
     return $this->getImageFullsizeUrl() ? Application_Model_Application::getImagePath() . $this->getImageFullsizeUrl() : '';
 }
예제 #17
0
 public function getLibraryPictures($all = true)
 {
     if ($this->getLibraryId()) {
         $library_image = new Media_Model_Library_Image();
         $images = $library_image->findAll(array("library_id" => $this->getLibraryId()));
         $image_list = array();
         foreach ($images as $image) {
             $image_path = Application_Model_Application::getImagePath() . $image->getLink();
             $image_list[] = array("id" => $image->getId(), "url" => $image_path);
         }
         if (count($image_list) > 0 and !$all) {
             $image_list = $image_list[0];
         }
         return $image_list;
     }
     return null;
 }
예제 #18
0
 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;
 }
예제 #19
0
 public function getImageUrl()
 {
     return $this->getImage() ? Application_Model_Application::getImagePath() . $this->getImage() : null;
 }