Ejemplo n.º 1
0
 public static function realImgSrc($imgSrc, $type = "main", $size = "normal", $title = '')
 {
     if ($imgSrc) {
         $path = "/uploads/images_thumbs/" . UploadedFile::fileNameToPath($imgSrc);
     } else {
         $imgSrc = "DefaultMainPhoto.jpg";
         $path = "/templates/arfooo/images/";
     }
     switch ($size) {
         case "small":
             $imgSrc = "s" . $imgSrc;
             break;
         case "medium":
             $imgSrc = "m" . $imgSrc;
             break;
         case "nano":
             $imgSrc = "n" . $imgSrc;
             break;
     }
     if ($title) {
         $path .= NameTool::strToAscii($title) . '-';
     }
     $imgSrc = $path . $imgSrc;
     return AppRouter::getResourceUrl($imgSrc);
 }
Ejemplo n.º 2
0
 function deleteSitePhotoFiles($src)
 {
     if (empty($src)) {
         return;
     }
     $dirPath = Config::get("SITES_THUMBS_PATH") . UploadedFile::fileNameToPath($src);
     $this->deleteFileIfExists($dirPath . "s" . $src);
     $this->deleteFileIfExists($dirPath . "m" . $src);
     $this->deleteFileIfExists($dirPath . "n" . $src);
     $this->deleteFileIfExists($dirPath . $src);
 }
Ejemplo n.º 3
0
 public static function createDirsToFile($path, $fileName)
 {
     $currentPath = $path;
     $dirs = array_slice(explode("/", UploadedFile::fileNameToPath($fileName)), 0, -1);
     foreach ($dirs as $dir) {
         $currentPath .= $dir . "/";
         if (!is_dir($currentPath)) {
             $oldMask = umask(0);
             mkdir($currentPath, 0777);
             umask($oldMask);
         }
     }
     return $currentPath;
 }
Ejemplo n.º 4
0
 function getThumbnailSrc($canBeOverwrittenByGalleryImage = true)
 {
     if ($canBeOverwrittenByGalleryImage && (empty($this->url) || Config::get("firstGalleryImageForThumbEnabled") && $this->firstGalleryImageSrc)) {
         if ($this->firstGalleryImageSrc) {
             return AppRouter::getResourceUrl("/uploads/images_thumbs/" . UploadedFile::fileNameToPath($this->firstGalleryImageSrc) . 's' . $this->firstGalleryImageSrc);
         } else {
             return $this->getDefaultImageSrc();
         }
     }
     $siteId = $this->siteId;
     if ($this->imageSrc) {
         return AppRouter::getResourceUrl("/uploads/images_thumbs/" . $this->imageSrc);
     } else {
         if (empty($this->url)) {
             return $this->getDefaultImageSrc();
         } else {
             if (Config::get('cacheSiteImagesEnabled') == 1) {
                 $fileName = $siteId . '.jpg';
                 $filePath = Config::get("SITES_THUMBS_PATH") . $fileName;
                 if (file_exists($filePath)) {
                     return AppRouter::getResourceUrl("/uploads/images_thumbs/" . $fileName);
                 } else {
                     return AppRouter::getRewrittedUrl("/site/getThumb/" . $siteId);
                 }
             } else {
                 if (Config::get("thumbsGeneratorUrl")) {
                     return $this->getThumbGeneratorSiteUrl();
                 } else {
                     return $this->getDefaultImageSrc();
                 }
             }
         }
     }
 }