diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-11-08 17:07:31 +0100 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-11-08 17:07:31 +0100 |
commit | 05b42c3327a14351692330bdc299dd011cd03dc4 (patch) | |
tree | 5698448603b3eabc475fd91dd531e34aa5d6af8e | |
parent | 2f2fa9f27db1dc630180babf7efa206157f37003 (diff) | |
download | ratatoeskr-cms-05b42c3327a14351692330bdc299dd011cd03dc4.tar.gz ratatoeskr-cms-05b42c3327a14351692330bdc299dd011cd03dc4.tar.bz2 ratatoeskr-cms-05b42c3327a14351692330bdc299dd011cd03dc4.zip |
Make imagetype file extension array a const of Image
Yet another pointless global var gone :)
-rw-r--r-- | ratatoeskr/sys/models.php | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php index 01ffeb3..74d4419 100644 --- a/ratatoeskr/sys/models.php +++ b/ratatoeskr/sys/models.php @@ -21,19 +21,6 @@ require_once(dirname(__FILE__) . "/textprocessors.php"); require_once(dirname(__FILE__) . "/pluginpackage.php"); /* - * Array: $imagetype_file_extensions - * Array of default file extensions for most IMAGETYPE_* constants - */ -$imagetype_file_extensions = [ - IMAGETYPE_GIF => "gif", - IMAGETYPE_JPEG => "jpg", - IMAGETYPE_PNG => "png", - IMAGETYPE_BMP => "bmp", - IMAGETYPE_TIFF_II => "tif", - IMAGETYPE_TIFF_MM => "tif", -]; - -/* * Variable: $ratatoeskr_settings * The global <Settings> object. Can be accessed like an array. * Has these fields: @@ -2157,6 +2144,18 @@ class Image extends BySQLRowEnabled private const PRE_MAXW = 150; private const PRE_MAXH = 100; + /** + * Array of default file extensions for most IMAGETYPE_* constants + */ + private const IMAGETYPE_FILE_EXTENSIONS = [ + IMAGETYPE_GIF => "gif", + IMAGETYPE_JPEG => "jpg", + IMAGETYPE_PNG => "png", + IMAGETYPE_BMP => "bmp", + IMAGETYPE_TIFF_II => "tif", + IMAGETYPE_TIFF_MM => "tif", + ]; + /** @var int */ private $id; @@ -2267,8 +2266,6 @@ class Image extends BySQLRowEnabled */ public function exchange_image($file, ?Database $db = null): void { - global $imagetype_file_extensions; - $file = (string)$file; if (!is_file($file)) { @@ -2278,13 +2275,13 @@ class Image extends BySQLRowEnabled if ($imageinfo === false) { throw new UnknownFileFormat(); } - if (!isset($imagetype_file_extensions[$imageinfo[2]])) { + if (!isset(self::IMAGETYPE_FILE_EXTENSIONS[$imageinfo[2]])) { throw new UnknownFileFormat(); } if (is_file(SITE_BASE_PATH . "/images/" . $this->filename)) { unlink(SITE_BASE_PATH . "/images/" . $this->filename); } - $new_fn = $this->id . "." . $imagetype_file_extensions[$imageinfo[2]]; + $new_fn = $this->id . "." . self::IMAGETYPE_FILE_EXTENSIONS[$imageinfo[2]]; if (!move_uploaded_file($file, SITE_BASE_PATH . "/images/" . $new_fn)) { throw new IOError("Can not move file."); } |