/** * init globals */ public static function initGlobals($pluginFolder) { UniteProviderFunctionsUG::initGlobalsBase($pluginFolder); self::$is_admin == false; //this var set from admin object self::$pathSettings = self::$pathPlugin . "settings/"; self::$pathGalleries = self::$pathPlugin . "galleries/"; self::$path_elfinder = self::$pathPlugin . "libraries/elfinder/"; self::$pathTemplates = self::$pathPlugin . "views/templates/"; self::$pathViews = self::$pathPlugin . "views/"; self::$pathHelpersViews = self::$pathPlugin . "helpers/views/"; self::$pathHelpersTemplates = self::$pathPlugin . "helpers/templates/"; self::$pathHelpersClasses = self::$pathPlugin . "helpers/classes/"; self::$pathHelpersSettings = self::$pathPlugin . "helpers/settings/"; UniteFunctionsUG::validateDir(self::$pathGalleries); self::$filepathItemSettings = self::$pathSettings . "item_settings.php"; self::$urlGalleries = self::$urlPlugin . "galleries/"; self::$url_elfinder = self::$urlPlugin . "libraries/elfinder/"; self::$url_provider = self::$urlPlugin . "inc_php/framework/provider/"; self::initClientSideText(); }
/** * make thumbnail from the image, and save to some path * return new path */ public function makeThumb($filepathImage, $pathThumbs, $maxWidth = -1, $maxHeight = -1, $type = "") { //validate input UniteFunctionsUG::validateFilepath($filepathImage, "image not found"); UniteFunctionsUG::validateDir($pathThumbs, "Thumbs folder don't exists."); if ($type == self::TYPE_EXACT || $type == self::TYPE_EXACT_TOP) { if ($maxHeight == -1) { $this->throwError("image with exact type must have height!"); } if ($maxWidth == -1) { $this->throwError("image with exact type must have width!"); } } //get filename $info = UniteFunctionsUG::getPathInfo($filepathImage); $filename = UniteFunctionsUG::getVal($info, "basename"); UniteFunctionsUG::validateNotEmpty($filename, "image filename not given"); //if gd library doesn't exists - output normal image without resizing. if (function_exists("gd_info") == false) { $this->throwError("php must support GD Library"); } if ($maxWidth == -1 && $maxHeight == -1) { $this->throwError("Wrong thumb size"); } if ($maxWidth == -1) { $maxWidth = 1000000; } if ($maxHeight == -1) { $maxHeight = 100000; } $this->filename = $filename; $this->maxWidth = $maxWidth; $this->maxHeight = $maxHeight; $this->type = $type; $this->pathCache = $pathThumbs; $filenameThumb = $this->getThumbFilename(); $filepathNew = $this->pathCache . $filenameThumb; if (file_exists($filepathNew)) { return $filenameThumb; } if ($type == self::TYPE_EXACT || $type == self::TYPE_EXACT_TOP) { $isSaved = $this->cropImageSaveNew($filepathImage, $filepathNew); } else { $isSaved = $this->resizeImageSaveNew($filepathImage, $filepathNew); } if ($isSaved) { return $filenameThumb; } else { return ""; } }