From 4d8d1234f812e2d9cf380bfb8b2449ff3979f49d Mon Sep 17 00:00:00 2001 From: Daniel Butum Date: Mon, 30 Oct 2017 17:41:18 +0200 Subject: [PATCH] Rename SImage to StkImage --- image.php | 2 +- include/Addon.class.php | 2 +- include/AddonViewer.class.php | 22 ++++++++--------- include/Cache.class.php | 4 ++-- include/File.class.php | 4 ++-- .../{SImage.class.php => StkImage.class.php} | 6 ++--- manage-panel.php | 2 +- tests/include/CacheTest.php | 6 ++--- .../{SImageTest.php => StkImageTest.php} | 24 +++++++++---------- 9 files changed, 36 insertions(+), 36 deletions(-) rename include/{SImage.class.php => StkImage.class.php} (99%) rename tests/include/{SImageTest.php => StkImageTest.php} (66%) diff --git a/image.php b/image.php index b4c70a55..95d30b62 100644 --- a/image.php +++ b/image.php @@ -21,4 +21,4 @@ $size = empty($_GET['size']) ? null : $_GET['size']; $file = empty($_GET['pic']) ? null : $_GET['pic']; -SImage::resizeImage($file, (int)$size); +StkImage::resizeImage($file, (int)$size); diff --git a/include/Addon.class.php b/include/Addon.class.php index 4ee990dd..8046db25 100644 --- a/include/Addon.class.php +++ b/include/Addon.class.php @@ -1560,7 +1560,7 @@ public static function filterMenuTemplate($addons, $current_id = null) $icon_id = $addon->getIcon(); if ($icon_id !== Addon::NO_IMAGE) { - $im = Cache::getImage($icon_id, SImage::SIZE_SMALL); + $im = Cache::getImage($icon_id, StkImage::SIZE_SMALL); if ($im['exists'] && $im['is_approved']) { $icon = $im['url']; diff --git a/include/AddonViewer.class.php b/include/AddonViewer.class.php index 53226ddc..48b1b2c4 100755 --- a/include/AddonViewer.class.php +++ b/include/AddonViewer.class.php @@ -137,7 +137,7 @@ public function fillTemplate($template) } // Get image url - $image = Cache::getImage($this->addon->getImage(), SImage::SIZE_LARGE); + $image = Cache::getImage($this->addon->getImage(), StkImage::SIZE_LARGE); if ($this->addon->getImage() !== Addon::NO_IMAGE && $image['exists'] == true && $image['is_approved'] == true) { $tpl['image_url'] = $image['url']; @@ -222,7 +222,7 @@ public function fillTemplate($template) continue; } - $image_cache = Cache::getImage($image->getId(), SImage::SIZE_MEDIUM); + $image_cache = Cache::getImage($image->getId(), StkImage::SIZE_MEDIUM); $image_tpl = [ "has_icon" => false, "has_image" => false, @@ -275,20 +275,20 @@ public function fillTemplate($template) { $config = [ "status" => [ - "alpha_img" => SImage::getImageLabel(_h('Alpha')), - "beta_img" => SImage::getImageLabel(_h('Beta')), - "rc_img" => SImage::getImageLabel(_h('Release-Candidate')), - "latest_img" => SImage::getImageLabel(_h('Latest')), - "invalid_img" => SImage::getImageLabel(_h('Invalid Textures')) + "alpha_img" => StkImage::getImageLabel(_h('Alpha')), + "beta_img" => StkImage::getImageLabel(_h('Beta')), + "rc_img" => StkImage::getImageLabel(_h('Release-Candidate')), + "latest_img" => StkImage::getImageLabel(_h('Latest')), + "invalid_img" => StkImage::getImageLabel(_h('Invalid Textures')) ] ]; if ($this->user_has_permission) { - $config["status"]["approve_img"] = SImage::getImageLabel(_h('Approved')); - $config["status"]["invisible_img"] = SImage::getImageLabel(_h('Invisible')); - $config["status"]["dfsg_img"] = SImage::getImageLabel(_h('DFSG Compliant')); - $config["status"]["featured_img"] = SImage::getImageLabel(_h('Featured')); + $config["status"]["approve_img"] = StkImage::getImageLabel(_h('Approved')); + $config["status"]["invisible_img"] = StkImage::getImageLabel(_h('Invisible')); + $config["status"]["dfsg_img"] = StkImage::getImageLabel(_h('DFSG Compliant')); + $config["status"]["featured_img"] = StkImage::getImageLabel(_h('Featured')); } $tpl['config'] = $config; diff --git a/include/Cache.class.php b/include/Cache.class.php index 5fc28dfc..9ca81121 100644 --- a/include/Cache.class.php +++ b/include/Cache.class.php @@ -226,7 +226,7 @@ public static function fileExists($filename) * Get image properties for a cacheable image * * @param int $id the id of the file - * @param int $size image size, see SImage::SIZE_* + * @param int $size image size, see StkImage::SIZE_* * * @return array * @throws CacheException @@ -278,6 +278,6 @@ public static function getImage($id, $size = null) */ public static function getCachePrefix($size) { - return sprintf("%d--", SImage::sizeToInt($size)); + return sprintf("%d--", StkImage::sizeToInt($size)); } } diff --git a/include/File.class.php b/include/File.class.php index 6a4d1e52..cf0aad64 100644 --- a/include/File.class.php +++ b/include/File.class.php @@ -555,7 +555,7 @@ public static function createImage($file_name, $addon_id) // Image is too large. Scale it. try { - $image = new SImage($image_path); + $image = new StkImage($image_path); $image->scale($image_max_dimension, $image_max_dimension); $image->save($image_path); } @@ -587,7 +587,7 @@ public static function createImage($file_name, $addon_id) */ public static function createImageFromQuadsXML($quad_file, $addon_id) { - $image_path = SImage::createImageFromQuadsXML($quad_file, $addon_id); + $image_path = StkImage::createImageFromQuadsXML($quad_file, $addon_id); // Add image record to add-on static::createImage($image_path, $addon_id); diff --git a/include/SImage.class.php b/include/StkImage.class.php similarity index 99% rename from include/SImage.class.php rename to include/StkImage.class.php index 342dc58e..a0ad4679 100644 --- a/include/SImage.class.php +++ b/include/StkImage.class.php @@ -21,7 +21,7 @@ /** * Class to hold all image-manipulation operations */ -class SImage +class StkImage { /** * Small image type @@ -273,7 +273,7 @@ public function scale($max_x, $max_y, $min_x = 1, $min_y = 1) * Resize an image, and send the new resized image to the user with http headers * * @param string $file_path - * @param int $size_type the image size type, see SImage::SIZE_ + * @param int $size_type the image size type, see StkImage::SIZE_ * * @return null */ @@ -288,7 +288,7 @@ public static function resizeImage($file_path, $size_type = null) return; } - $size = SImage::sizeToInt($size_type); + $size = StkImage::sizeToInt($size_type); $cache_name = Cache::getCachePrefix($size_type) . basename($file_path); $local_path = UP_PATH . $file_path; // all images should be in our upload directory diff --git a/manage-panel.php b/manage-panel.php index e9662320..6029b083 100644 --- a/manage-panel.php +++ b/manage-panel.php @@ -75,7 +75,7 @@ if (!$image->isApproved()) { $unapproved[] = - ''; + ''; } } // add to view diff --git a/tests/include/CacheTest.php b/tests/include/CacheTest.php index 85d1d069..3fefc8e3 100644 --- a/tests/include/CacheTest.php +++ b/tests/include/CacheTest.php @@ -24,9 +24,9 @@ public function providerTestGetCachePrefix() return [ ['100--', Cache::getCachePrefix(999)], ['100--', Cache::getCachePrefix(-999)], - ['300--', Cache::getCachePrefix(SImage::SIZE_LARGE)], - ['75--', Cache::getCachePrefix(SImage::SIZE_MEDIUM)], - ['25--', Cache::getCachePrefix(SImage::SIZE_SMALL)] + ['300--', Cache::getCachePrefix(StkImage::SIZE_LARGE)], + ['75--', Cache::getCachePrefix(StkImage::SIZE_MEDIUM)], + ['25--', Cache::getCachePrefix(StkImage::SIZE_SMALL)] ]; } diff --git a/tests/include/SImageTest.php b/tests/include/StkImageTest.php similarity index 66% rename from tests/include/SImageTest.php rename to tests/include/StkImageTest.php index 405b26a9..5e073ef1 100644 --- a/tests/include/SImageTest.php +++ b/tests/include/StkImageTest.php @@ -17,17 +17,17 @@ * along with stk-addons. If not, see . */ -class SImageTest extends PHPUnit_Framework_TestCase +class StkImageTest extends PHPUnit_Framework_TestCase { public function providerTestSizeToInt() { return [ - [100, SImage::sizeToInt(SImage::SIZE_DEFAULT)], - [100, SImage::sizeToInt('9999')], - [100, SImage::sizeToInt(514949489)], - [25, SImage::sizeToInt(SImage::SIZE_SMALL)], - [75, SImage::sizeToInt(SImage::SIZE_MEDIUM)], - [300, SImage::sizeToInt(SImage::SIZE_LARGE)], + [100, StkImage::sizeToInt(StkImage::SIZE_DEFAULT)], + [100, StkImage::sizeToInt('9999')], + [100, StkImage::sizeToInt(514949489)], + [25, StkImage::sizeToInt(StkImage::SIZE_SMALL)], + [75, StkImage::sizeToInt(StkImage::SIZE_MEDIUM)], + [300, StkImage::sizeToInt(StkImage::SIZE_LARGE)], ]; } @@ -46,11 +46,11 @@ public function testSizeToInt($expected, $actual) public function providerTestIntToSize() { return [ - [SImage::SIZE_DEFAULT, SImage::intToSize('999999')], - [SImage::SIZE_DEFAULT, SImage::intToSize(5454488)], - [SImage::SIZE_SMALL, SImage::intToSize(25)], - [SImage::SIZE_MEDIUM, SImage::intToSize(75)], - [SImage::SIZE_LARGE, SImage::intToSize(300)] + [StkImage::SIZE_DEFAULT, StkImage::intToSize('999999')], + [StkImage::SIZE_DEFAULT, StkImage::intToSize(5454488)], + [StkImage::SIZE_SMALL, StkImage::intToSize(25)], + [StkImage::SIZE_MEDIUM, StkImage::intToSize(75)], + [StkImage::SIZE_LARGE, StkImage::intToSize(300)] ]; }