コード例 #1
0
ファイル: news.php プロジェクト: biggtfish/magixcms
 /**
  * @access private
  * Insert une image dans les news
  * @param string $nimage
  * @param void $confimg
  * @param bool $update
  * @return string
  * @throws Exception
  */
 private function insert_image_news($nimage, $confimg, $update = false)
 {
     if (isset($nimage)) {
         try {
             $makeFiles = new magixcjquery_files_makefiles();
             $initImg = new backend_model_image();
             if ($update == true) {
                 $vimage = parent::s_n_image_news($this->edit);
                 if (file_exists(self::dir_img_news() . $vimage['n_image'])) {
                     $makeFiles->removeFile(self::dir_img_news(), $vimage['n_image']);
                     $makeFiles->removeFile(self::dir_img_news(), 's_' . $vimage['n_image']);
                 } else {
                     throw new Exception('file: ' . $vimage['n_image'] . ' is not found');
                 }
             }
             /**
              * Envoi une image dans le dossier "racine" catalogimg
              */
             $initImg->upload_img($confimg, 'upload' . DIRECTORY_SEPARATOR . 'news' . DIRECTORY_SEPARATOR, false);
             /**
              * Analyze l'extension du fichier en traitement
              * @var $fileextends
              */
             $fileextends = $initImg->image_analyze(self::dir_img_news() . $nimage);
             /**
              * 
              * Enter description here ...
              * @var unknown_type
              */
             $rimage = magixglobal_model_cryptrsa::uniq_id();
             /**
              * Initialisation de la classe phpthumb 
              * @var void
              */
             $thumb = PhpThumbFactory::create(self::dir_img_news() . $nimage);
             $imageuri = $rimage . $fileextends;
             $imgsetting = new backend_model_setting();
             $imgsizesmall = $initImg->dataImgSize('news', 'news', 'small');
             $imgsizemed = $initImg->dataImgSize('news', 'news', 'medium');
             //Redimensionnement et changement de nom suivant la catégorie
             switch ($imgsizemed['img_resizing']) {
                 case 'basic':
                     $thumb->resize($imgsizemed['width'], $imgsizemed['height'])->save(self::dir_img_news() . $imageuri);
                     break;
                 case 'adaptive':
                     $thumb->adaptiveResize($imgsizemed['width'], $imgsizemed['height'])->save(self::dir_img_news() . $imageuri);
                     break;
             }
             switch ($imgsizesmall['img_resizing']) {
                 case 'basic':
                     $thumb->resize($imgsizesmall['width'], $imgsizesmall['height'])->save(self::dir_img_news() . 's_' . $imageuri);
                     break;
                 case 'adaptive':
                     $thumb->adaptiveResize($imgsizesmall['width'], $imgsizesmall['height'])->save(self::dir_img_news() . 's_' . $imageuri);
                     break;
             }
             //Supprime le fichier original pour gagner en espace
             if (file_exists(self::dir_img_news() . $nimage)) {
                 $makeFiles->removeFile(self::dir_img_news(), $nimage);
             }
             /*else{
             			throw new Exception('file: '.$nimage.' is not found');
             		}*/
             return $imageuri;
         } catch (Exception $e) {
             magixglobal_model_system::magixlog('An error has occured :', $e);
         }
     }
 }
コード例 #2
0
ファイル: catalog.php プロジェクト: biggtfish/magixcms
 /**
  * Insertion d'une image dans la galerie spécifique à un produit
  * @param $img
  * @param $imgcatalog
  * @param bool $debug
  * @return string
  * @throws Exception
  */
 private function insert_image_galery($img, $imgcatalog, $debug = false)
 {
     if (isset($this->{$img})) {
         try {
             //Supprime le fichier original pour gagner en espace
             $makeFiles = new magixcjquery_files_makefiles();
             // Charge la classe de traitement des images
             $initImg = new backend_model_image();
             /**
              * Envoi une image dans le dossier "racine" catalogimg
              */
             $initImg->upload_img('imgcatalog', 'upload' . DIRECTORY_SEPARATOR . 'catalogimg' . DIRECTORY_SEPARATOR . 'galery' . DIRECTORY_SEPARATOR, $debug);
             /**
              * Analyze l'extension du fichier en traitement
              * @var $fileextends
              */
             $fileextends = $initImg->image_analyze(self::dirImgProductGalery() . $this->{$img});
             if ($initImg->imgSizeMin(self::dirImgProductGalery() . $this->{$img}, 25, 25)) {
                 // Charge la classe pour renommer le fichier
                 $makeFiles = new magixcjquery_files_makefiles();
                 /*
                  * Renomme le fichier
                  */
                 $makeFiles->renameFiles(self::dirImgProductGalery(), self::dirImgProductGalery() . $this->{$img}, self::dirImgProductGalery() . $imgcatalog . $fileextends);
                 /**
                  * Initialisation de la classe phpthumb
                  * @var void
                  */
                 $thumb = PhpThumbFactory::create(self::dirImgProductGalery() . $imgcatalog . $fileextends);
                 //Charge la taille des images des galeries du catalogue
                 $firebug = new magixcjquery_debug_magixfire();
                 /**
                  * Création des images et miniatures utile.
                  * 2 tailles !!!
                  */
                 $imgsizelarge = $initImg->dataImgSize('catalog', 'galery', 'large');
                 $imgsizesmall = $initImg->dataImgSize('catalog', 'galery', 'small');
                 if ($debug) {
                     $firebug->magixFireGroup('Setting image');
                 }
                 switch ($imgsizelarge['img_resizing']) {
                     case 'basic':
                         if ($debug) {
                             $firebug->magixFireGroup($imgsizelarge['config_size_attr'] . ' => ' . $imgsizelarge['type']);
                             $firebug->magixFireLog($imgsizelarge['img_resizing'], 'Type');
                             $firebug->magixFireLog($imgsizelarge['width'], 'Width');
                             $firebug->magixFireLog($imgsizelarge['height'], 'Height');
                             $firebug->magixFireGroupEnd();
                         }
                         $thumb->resize($imgsizelarge['width'], $imgsizelarge['height'])->save(self::dirImgProductGalery() . 'maxi' . DIRECTORY_SEPARATOR . $imgcatalog . $fileextends);
                         break;
                     case 'adaptive':
                         if ($debug) {
                             $firebug->magixFireGroup($imgsizelarge['config_size_attr'] . ' => ' . $imgsizelarge['type']);
                             $firebug->magixFireLog($imgsizelarge['img_resizing'], 'Type');
                             $firebug->magixFireLog($imgsizelarge['width'], 'Width');
                             $firebug->magixFireLog($imgsizelarge['height'], 'Height');
                             $firebug->magixFireGroupEnd();
                         }
                         $thumb->adaptiveResize($imgsizelarge['width'], $imgsizelarge['height'])->save(self::dirImgProductGalery() . 'maxi' . DIRECTORY_SEPARATOR . $imgcatalog . $fileextends);
                         break;
                 }
                 switch ($imgsizesmall['img_resizing']) {
                     case 'basic':
                         if ($debug) {
                             $firebug->magixFireGroup($imgsizesmall['config_size_attr'] . ' => ' . $imgsizesmall['type']);
                             $firebug->magixFireLog($imgsizesmall['img_resizing'], 'Type');
                             $firebug->magixFireLog($imgsizesmall['width'], 'Width');
                             $firebug->magixFireLog($imgsizesmall['height'], 'Height');
                             $firebug->magixFireGroupEnd();
                         }
                         $thumb->resize($imgsizesmall['width'], $imgsizesmall['height'])->save(self::dirImgProductGalery() . 'mini' . DIRECTORY_SEPARATOR . $imgcatalog . $fileextends);
                         break;
                     case 'adaptive':
                         if ($debug) {
                             $firebug->magixFireGroup($imgsizesmall['config_size_attr'] . ' => ' . $imgsizesmall['type']);
                             $firebug->magixFireLog($imgsizesmall['img_resizing'], 'Type');
                             $firebug->magixFireLog($imgsizesmall['width'], 'Width');
                             $firebug->magixFireLog($imgsizesmall['height'], 'Height');
                             $firebug->magixFireGroupEnd();
                         }
                         $thumb->adaptiveResize($imgsizesmall['width'], $imgsizesmall['height'])->save(self::dirImgProductGalery() . 'mini' . DIRECTORY_SEPARATOR . $imgcatalog . $fileextends);
                         break;
                 }
                 if ($debug) {
                     $firebug->magixFireGroupEnd();
                 }
                 if (file_exists(self::dirImgProductGalery() . $imgcatalog . $fileextends)) {
                     $makeFiles->removeFile(self::dirImgProductGalery(), $imgcatalog . $fileextends);
                 }
                 return $imgcatalog . $fileextends;
             } else {
                 if (file_exists(self::dirImgProductGalery() . $this->{$img})) {
                     $makeFiles->removeFile(self::dirImgProductGalery(), $this->{$img});
                 } else {
                     throw new Exception('file: ' . $this->{$img} . ' is not found');
                 }
             }
         } catch (Exception $e) {
             magixglobal_model_system::magixlog('An error has occured :', $e);
         }
     }
 }