/** * Get favicon image path * * @return string */ public function getFavicon() { $imgName = Fox::getPreference('web/head/favicon_image'); if ($imgName && file_exists(Fox::getUploadDirectoryPath() . DIRECTORY_SEPARATOR . Fox_Core_Model_Preference::CORE_UPLOAD_FOLDER . DIRECTORY_SEPARATOR . $imgName)) { return Fox::getUploadDirectoryUrl() . '/' . Fox_Core_Model_Preference::CORE_UPLOAD_FOLDER . '/' . $imgName; } else { return $this->themeUrl('images/default_favicon.ico'); } }
/** * Resize member image * * @param string|NULL $img Image name * @param int $width Target width * @param int $height Target height * @return string Returns the url of the resized image * @throws Exception if member upload directory not found */ public function getResizedMemberImage($img = NULL, $width = 100, $height = 100) { $image = ''; $resizePath = $width . 'x' . $height; if ($img != NULL) { $image = $img; } else { if ($this->getMemberImage()) { $image = $this->getMemberImage(); } } $destinationPath = self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $resizePath; $destinationImagePath = $destinationPath . DIRECTORY_SEPARATOR . $image; $destinationBasePath = Fox::getUploadDirectoryPath() . DIRECTORY_SEPARATOR; if (!$image || !file_exists($destinationBasePath . $destinationImagePath)) { if (!file_exists($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $resizePath)) { if (!@mkdir($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $resizePath, 0777, TRUE)) { throw new Exception('"' . $destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $resizePath . '" path was not found.'); } @chmod($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $resizePath, 0777); } if ($image && file_exists($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $image)) { $thumb = new Uni_Util_ImageEditor(); $thumb->resize($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $image, $width, $height, $image, $destinationBasePath . $destinationPath . DIRECTORY_SEPARATOR, false); @chmod($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $resizePath, 0777); } else { $image = 'no-image.png'; $destinationImagePath = $destinationPath . DIRECTORY_SEPARATOR . $image; if (file_exists($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $image)) { $thumb = new Uni_Util_ImageEditor(); $thumb->resize($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $image, $width, $height, $image, $destinationBasePath . $destinationPath . DIRECTORY_SEPARATOR, false); @chmod($destinationBasePath . self::ENTITY_TYPE_MEMBER . DIRECTORY_SEPARATOR . $resizePath, 0777); } } } $destinationImagePath = str_replace(DIRECTORY_SEPARATOR, "/", $destinationImagePath); return Fox::getUploadDirectoryUrl() . '/' . $destinationImagePath; }