Пример #1
0
 public function getImage($name, $base = false)
 {
     if (file_exists(Core_Model_Directory::getDesignPath(true) . '/images/' . $name)) {
         return Core_Model_Directory::getDesignPath($base) . '/images/' . $name;
     } else {
         if (file_exists(Media_Model_Library_Image::getBaseImagePathTo($name))) {
             return $base ? Media_Model_Library_Image::getBaseImagePathTo($name) : Media_Model_Library_Image::getImagePathTo($name);
         }
     }
     return "";
 }
Пример #2
0
 public function getIconUrl($base = false)
 {
     if (empty($this->_icon_url) and $this->getIconId()) {
         if ($this->getIcon() and !$base) {
             $this->_icon_url = Media_Model_Library_Image::getImagePathTo($this->getIcon(), $this->getAppId());
         } else {
             $icon = new Media_Model_Library_Image();
             $icon->find($this->getIconId());
             $this->_icon_url = $icon->getUrl();
         }
     }
     return $this->_icon_url;
 }
Пример #3
0
 public function getImage($name, $base = false)
 {
     if (file_exists($this->getBaseImagePath() . "/" . $name)) {
         $path = $base ? $this->getBaseImagePath() : $this->getImagePath();
         return $path . "/" . $name;
     } else {
         if (file_exists(Media_Model_Library_Image::getBaseImagePathTo($name))) {
             return $base ? Media_Model_Library_Image::getBaseImagePathTo($name) : Media_Model_Library_Image::getImagePathTo($name);
         }
     }
     return "";
 }
Пример #4
0
 public function uploadiconAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             $uploader = new Core_Model_Lib_Uploader();
             $file = $uploader->savecrop($datas);
             if (!empty($file)) {
                 $option_value = new Application_Model_Option_Value();
                 $option_value->find($datas['option_id']);
                 $lib = new Media_Model_Library();
                 $lib->find($option_value->getLibraryId());
                 $library_name = $lib->getName();
                 $formated_library_name = Core_Model_Lib_String::format($library_name, true);
                 $base_lib_path = Media_Model_Library_Image::getBaseImagePathTo($formated_library_name);
                 $files = Core_Model_Directory::getTmpDirectory(true) . '/' . $file;
                 $CanBeColorized = $datas['is_colorized'] == 'true' ? 1 : 0;
                 if (!is_dir($base_lib_path)) {
                     mkdir($base_lib_path, 0777, true);
                 }
                 if (!copy($files, $base_lib_path . '/' . $file)) {
                     throw new exception($this->_('An error occurred while saving your picture. Please try againg later.'));
                 } else {
                     $icon_lib = new Media_Model_Library_Image();
                     $icon_lib->setLibraryId($option_value->getLibraryId())->setLink('/' . $formated_library_name . '/' . $file)->setOptionId($option_value->getOptionId())->setAdminId($this->getSession()->getAdmin()->getId())->setCanBeColorized($CanBeColorized)->setPosition(0)->save();
                     $option_value->setIcon('/' . $formated_library_name . '/' . $file)->setIconId($icon_lib->getImageId())->save();
                     $icon_saved = $this->setIcon($icon_lib->getImageId(), $datas['option_id']);
                     // Charge l'option_value
                     $option_value = new Application_Model_Option_Value();
                     $option_value->find($datas['option_id']);
                     $icon_color = $this->getApplication()->getDesignBlock('tabbar')->getImageColor();
                     $html = array('success' => 1, 'file' => '/' . $formated_library_name . '/' . $file, 'icon_id' => $icon_lib->getImageId(), 'colorizable' => $CanBeColorized, 'icon_url' => Media_Model_Library_Image::getImagePathTo($formated_library_name . '/' . $file), 'colored_icon_url' => $this->getUrl('template/block/colorize', array('id' => $option_value->getIconId(), 'color' => str_replace('#', '', $icon_color))), 'colored_header_icon_url' => $icon_saved['colored_header_icon_url'], 'message' => '', 'message_button' => 1, 'message_loader' => 1);
                 }
             }
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }