Support PNG and SVG icon sets for point level icons #1739

This commit is contained in:
Kijin Sung 2021-07-01 14:58:33 +09:00
parent f1c839042c
commit f2ff393592
5 changed files with 29 additions and 4 deletions

View file

@ -54,7 +54,8 @@ function pointLevelIconTrans($matches, $addon_info)
$text = $matches[5]; $text = $matches[5];
// Get a path where level icon is // 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 // Get per to go to the next level if not a top level
$per = NULL; $per = NULL;

View file

@ -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->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->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->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.<br />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.<br />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->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->point_name = 'Point Name';
$lang->about_point_name = 'You may give a name or unit to a point'; $lang->about_point_name = 'You may give a name or unit to a point';

View file

@ -8,7 +8,8 @@ $lang->about_point_io = '체크 하면 포인트 모듈 기능을 켤 수 있습
$lang->max_level = '최고 레벨'; $lang->max_level = '최고 레벨';
$lang->about_max_level = '최고레벨을 지정할 수 있습니다. 레벨 아이콘을 염두에 두어야 하고, 1000레벨 이상은 권장하지 않습니다.'; $lang->about_max_level = '최고레벨을 지정할 수 있습니다. 레벨 아이콘을 염두에 두어야 하고, 1000레벨 이상은 권장하지 않습니다.';
$lang->level_icon = '레벨 아이콘'; $lang->level_icon = '레벨 아이콘';
$lang->about_level_icon = '레벨 아이콘은 ./modules/point/icons/레벨.gif 로 지정되며 최고레벨과 아이콘셋이 다를 수 있으니 주의해주세요!'; $lang->about_level_icon = '레벨 아이콘은 ./modules/point/icons/아이콘명/ 폴더에 저장되어 있으며, 확장자는 gif, png, svg를 지원합니다.<br />아이콘셋에 따라 지원하는 최고 레벨이 다를 수 있으니 주의하시기 바랍니다.';
$lang->msg_level_icon_not_found = '선택한 레벨 아이콘을 찾을 수 없습니다.<br />레벨 아이콘은 ./modules/point/icons/아이콘명/ 폴더에 저장되어 있어야 하며, 최소 1레벨에 해당하는 gif, png 또는 svg 파일이 존재해야 합니다.';
$lang->point_name = '포인트 이름'; $lang->point_name = '포인트 이름';
$lang->about_point_name = '포인트 이름이나 단위를 정할 수 있습니다.'; $lang->about_point_name = '포인트 이름이나 단위를 정할 수 있습니다.';
$lang->level_point = '레벨 포인트'; $lang->level_point = '레벨 포인트';

View file

@ -102,6 +102,27 @@ class pointAdminController extends point
// Set the level icon // Set the level icon
$config->level_icon = $args->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 // Check if downloads are not allowed
$config->disable_download = ($args->disable_download === 'Y') ? 'Y' : 'N'; $config->disable_download = ($args->disable_download === 'Y') ? 'Y' : 'N';

View file

@ -195,7 +195,7 @@
</tr> </tr>
<tr> <tr>
<td>1</td> <td>1</td>
<td><img src="{getUrl()}modules/point/icons/{$config->level_icon}/1.gif" alt="1" /></td> <td><img src="{getUrl()}modules/point/icons/{$config->level_icon}/1.{$config->level_icon_type ?? 'gif'}" alt="1" /></td>
<td><label for="level_step_1" style="margin:0"><input type="number" id="level_step_1" class="level_step" value="{$config->level_step[1]}" style="width:120px;text-align:right" /> {$config->point_name}</label></td> <td><label for="level_step_1" style="margin:0"><input type="number" id="level_step_1" class="level_step" value="{$config->level_step[1]}" style="width:120px;text-align:right" /> {$config->point_name}</label></td>
{@$point_group_item = $point_group[1]} {@$point_group_item = $point_group[1]}
{@$title=array()} {@$title=array()}
@ -219,7 +219,7 @@
<!--@end--> <!--@end-->
<tr class="row{(($i-1)%2+1)}"> <tr class="row{(($i-1)%2+1)}">
<td>{$i}</td> <td>{$i}</td>
<td><img src="{getUrl()}modules/point/icons/{$config->level_icon}/{$i}.gif" alt="{$i}" /></td> <td><img src="{getUrl()}modules/point/icons/{$config->level_icon}/{$i}.{$config->level_icon_type ?? 'gif'}" alt="{$i}" /></td>
<td><label for="level_step_{$i}" style="margin:0"><input type="number" id="level_step_{$i}" class="level_step" value="{$config->level_step[$i]}" style="width:120px;text-align:right" /> {$config->point_name}</label></td> <td><label for="level_step_{$i}" style="margin:0"><input type="number" id="level_step_{$i}" class="level_step" value="{$config->level_step[$i]}" style="width:120px;text-align:right" /> {$config->point_name}</label></td>
<td>{implode(', ', $title)}</td> <td>{implode(', ', $title)}</td>
</tr> </tr>