Skip to content

Commit

Permalink
Rename SImage to StkImage
Browse files Browse the repository at this point in the history
  • Loading branch information
vampy committed Oct 30, 2017
1 parent 420055a commit 4d8d123
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion include/Addon.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
22 changes: 11 additions & 11 deletions include/AddonViewer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions include/Cache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
}
}
4 changes: 2 additions & 2 deletions include/File.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions include/SImage.class.php → include/StkImage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Class to hold all image-manipulation operations
*/
class SImage
class StkImage
{
/**
* Small image type
Expand Down Expand Up @@ -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
*/
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion manage-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
if (!$image->isApproved())
{
$unapproved[] =
'<img src="' . ROOT_LOCATION . 'image.php?size=' . SImage::SIZE_MEDIUM . '&pic=' . $image->getPath() . '" />';
'<img src="' . ROOT_LOCATION . 'image.php?size=' . StkImage::SIZE_MEDIUM . '&pic=' . $image->getPath() . '" />';
}
}
// add to view
Expand Down
6 changes: 3 additions & 3 deletions tests/include/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
];
}

Expand Down
24 changes: 12 additions & 12 deletions tests/include/SImageTest.php → tests/include/StkImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
* along with stk-addons. If not, see <http://www.gnu.org/licenses/>.
*/

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)],

];
}
Expand All @@ -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)]
];
}

Expand Down

0 comments on commit 4d8d123

Please sign in to comment.