From f2ff39359214400f3b5f7914803ef70f0ad3f832 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 1 Jul 2021 14:58:33 +0900 Subject: [PATCH] Support PNG and SVG icon sets for point level icons #1739 --- .../point_level_icon/point_level_icon.lib.php | 3 ++- modules/point/lang/en.php | 2 ++ modules/point/lang/ko.php | 3 ++- modules/point/point.admin.controller.php | 21 +++++++++++++++++++ modules/point/tpl/config.html | 4 ++-- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/addons/point_level_icon/point_level_icon.lib.php b/addons/point_level_icon/point_level_icon.lib.php index f93bf198d..96457dacc 100644 --- a/addons/point_level_icon/point_level_icon.lib.php +++ b/addons/point_level_icon/point_level_icon.lib.php @@ -54,7 +54,8 @@ function pointLevelIconTrans($matches, $addon_info) $text = $matches[5]; // Get a path where level icon is - $level_icon = sprintf('%smodules/point/icons/%s/%d.gif', Context::getRequestUri(), $config->level_icon, $level); + $level_icon_type = $config->level_icon_type ?? 'gif'; + $level_icon = sprintf('%smodules/point/icons/%s/%d.%s', Context::getRequestUri(), $config->level_icon, $level, $level_icon_type); // Get per to go to the next level if not a top level $per = NULL; diff --git a/modules/point/lang/en.php b/modules/point/lang/en.php index 2320c4980..76ecef5cf 100644 --- a/modules/point/lang/en.php +++ b/modules/point/lang/en.php @@ -8,6 +8,8 @@ $lang->about_point_io = 'Point module can be on or off. If you OFF this module, $lang->max_level = 'Max Level'; $lang->about_max_level = 'You may set the max level. Level icons should be considered, and it is strongly recommended that you keep this value below 1000.'; $lang->level_icon = 'Level Icon'; +$lang->about_level_icon = 'Level icons are stored in the ./modules/point/icons/NAME/ folder, and support gif, png and svg extensions.
Please be aware that different icon sets may support different ranges of high levels.'; +$lang->msg_level_icon_not_found = 'Cannot find the selected level icon set.
Level icons must be stored in the ./modules/point/icons/NAME/ folder, and must contain at least one of the following files: 1.gif, 1.png, 1.svg'; $lang->about_level_icon = 'Path of level icon is "./module/point/icons/[level].gif" and max level could be different with icon set. So please be careful'; $lang->point_name = 'Point Name'; $lang->about_point_name = 'You may give a name or unit to a point'; diff --git a/modules/point/lang/ko.php b/modules/point/lang/ko.php index 43d24ece4..c6cda75f7 100644 --- a/modules/point/lang/ko.php +++ b/modules/point/lang/ko.php @@ -8,7 +8,8 @@ $lang->about_point_io = '체크 하면 포인트 모듈 기능을 켤 수 있습 $lang->max_level = '최고 레벨'; $lang->about_max_level = '최고레벨을 지정할 수 있습니다. 레벨 아이콘을 염두에 두어야 하고, 1000레벨 이상은 권장하지 않습니다.'; $lang->level_icon = '레벨 아이콘'; -$lang->about_level_icon = '레벨 아이콘은 ./modules/point/icons/레벨.gif 로 지정되며 최고레벨과 아이콘셋이 다를 수 있으니 주의해주세요!'; +$lang->about_level_icon = '레벨 아이콘은 ./modules/point/icons/아이콘명/ 폴더에 저장되어 있으며, 확장자는 gif, png, svg를 지원합니다.
아이콘셋에 따라 지원하는 최고 레벨이 다를 수 있으니 주의하시기 바랍니다.'; +$lang->msg_level_icon_not_found = '선택한 레벨 아이콘을 찾을 수 없습니다.
레벨 아이콘은 ./modules/point/icons/아이콘명/ 폴더에 저장되어 있어야 하며, 최소 1레벨에 해당하는 gif, png 또는 svg 파일이 존재해야 합니다.'; $lang->point_name = '포인트 이름'; $lang->about_point_name = '포인트 이름이나 단위를 정할 수 있습니다.'; $lang->level_point = '레벨 포인트'; diff --git a/modules/point/point.admin.controller.php b/modules/point/point.admin.controller.php index 235bda723..032cb02c0 100644 --- a/modules/point/point.admin.controller.php +++ b/modules/point/point.admin.controller.php @@ -102,6 +102,27 @@ class pointAdminController extends point // Set the level icon $config->level_icon = $args->level_icon; + $config->level_icon_type = 'gif'; + $level_icon_dir = $this->module_path . '/icons/' . $config->level_icon; + if (!file_exists($level_icon_dir)) + { + return new BaseObject(-1, 'msg_level_icon_not_found'); + } + if (!file_exists($level_icon_dir . '/1.gif')) + { + if (file_exists($level_icon_dir . '/1.png')) + { + $config->level_icon_type = 'png'; + } + elseif (file_exists($level_icon_dir . '/1.svg')) + { + $config->level_icon_type = 'svg'; + } + else + { + return new BaseObject(-1, 'msg_level_icon_not_found'); + } + } // Check if downloads are not allowed $config->disable_download = ($args->disable_download === 'Y') ? 'Y' : 'N'; diff --git a/modules/point/tpl/config.html b/modules/point/tpl/config.html index 428901a9d..1f97edde7 100644 --- a/modules/point/tpl/config.html +++ b/modules/point/tpl/config.html @@ -195,7 +195,7 @@ 1 - 1 + 1 {@$point_group_item = $point_group[1]} {@$title=array()} @@ -219,7 +219,7 @@ {$i} - {$i} + {$i} {implode(', ', $title)}