From b60c3eb2c0d6bc3b37a4317691ebddc6af5fadb2 Mon Sep 17 00:00:00 2001 From: Rylea Stark Date: Mon, 30 Nov 2020 03:24:20 -0700 Subject: [PATCH] v2.0.0a1 Check for limits as defined in permissions when displaying badges related to #16 Adds 2x,3x,4x image values to badges and categories #21 Replaced template matching with regular expression to improve tag selection. --- Admin/Controller/Badge.php | 6 ++-- Admin/Controller/BadgeCategory.php | 3 ++ Entity/Badge.php | 27 +++++++++++++-- Entity/BadgeCategory.php | 27 +++++++++++++-- Repository/UserBadge.php | 8 +++-- _data/phrases.xml | 4 +++ _data/template_modifications.xml | 15 +++------ _data/templates.xml | 33 +++++++++++++++++-- _output/phrases/CMTV_Badges_image_url_1x.txt | 1 + _output/phrases/CMTV_Badges_image_url_2x.txt | 1 + _output/phrases/CMTV_Badges_image_url_3x.txt | 1 + _output/phrases/CMTV_Badges_image_url_4x.txt | 1 + _output/phrases/_metadata.json | 24 ++++++++++++++ _output/template_modifications/_metadata.json | 4 +-- .../public/CMTV_Badges_member_tooltip.json | 4 +-- .../public/CMTV_Badges_message_macros.json | 4 +-- _output/templates/_metadata.json | 6 ++-- .../admin/CMTV_Badges_badge_edit.html | 31 ++++++++++++++++- addon.json | 4 +-- 19 files changed, 169 insertions(+), 35 deletions(-) create mode 100644 _output/phrases/CMTV_Badges_image_url_1x.txt create mode 100644 _output/phrases/CMTV_Badges_image_url_2x.txt create mode 100644 _output/phrases/CMTV_Badges_image_url_3x.txt create mode 100644 _output/phrases/CMTV_Badges_image_url_4x.txt diff --git a/Admin/Controller/Badge.php b/Admin/Controller/Badge.php index 21d17fc..c1dbd44 100644 --- a/Admin/Controller/Badge.php +++ b/Admin/Controller/Badge.php @@ -1,7 +1,6 @@ 'str', 'fa_icon' => 'str', 'image_url' => 'str', + 'image_url_2x' => 'str', + 'image_url_3x' => 'str', + 'image_url_4x' => 'str', 'class' => 'str', 'badge_category_id' => 'uint', 'display_order' => 'uint' diff --git a/Admin/Controller/BadgeCategory.php b/Admin/Controller/BadgeCategory.php index 83cc74c..a6014f5 100644 --- a/Admin/Controller/BadgeCategory.php +++ b/Admin/Controller/BadgeCategory.php @@ -126,6 +126,9 @@ protected function badgeCategorySaveProcess(\CMTV\Badges\Entity\BadgeCategory $b 'icon_type' => 'str', 'fa_icon' => 'str', 'image_url' => 'str', + 'image_url_2x' => 'str', + 'image_url_3x' => 'str', + 'image_url_4x' => 'str', 'class' => 'str', 'display_order' => 'uint' ]); diff --git a/Entity/Badge.php b/Entity/Badge.php index 4501bef..dc1227c 100644 --- a/Entity/Badge.php +++ b/Entity/Badge.php @@ -17,6 +17,9 @@ * @property string icon_type * @property string fa_icon * @property string image_url + * @property string image_url_2x + * @property string image_url_3x + * @property string image_url_4x * @property string class * @property int display_order * @@ -57,19 +60,37 @@ public static function getStructure(Structure $structure) 'fa_icon' => [ 'type' => self::STR, - 'maxLength' => 50, + 'maxLength' => 256, 'default' => '' ], 'image_url' => [ 'type' => self::STR, 'default' => '', - 'maxLength' => 200 + 'maxLength' => 512 + ], + + 'image_url_2x' => [ + 'type' => self::STR, + 'default' => '', + 'maxLength' => 512 + ], + + 'image_url_3x' => [ + 'type' => self::STR, + 'default' => '', + 'maxLength' => 512 + ], + + 'image_url_4x' => [ + 'type' => self::STR, + 'default' => '', + 'maxLength' => 512 ], 'class' => [ 'type' => self::STR, - 'maxLength' => 50, + 'maxLength' => 256, 'default' => '' ], diff --git a/Entity/BadgeCategory.php b/Entity/BadgeCategory.php index a5582cd..af7c67f 100644 --- a/Entity/BadgeCategory.php +++ b/Entity/BadgeCategory.php @@ -16,6 +16,9 @@ * @property string icon_type * @property string fa_icon * @property string image_url + * @property string image_url_2x + * @property string image_url_3x + * @property string image_url_4x * @property string class * @property int display_order * @@ -49,19 +52,37 @@ public static function getStructure(Structure $structure) 'fa_icon' => [ 'type' => self::STR, - 'maxLength' => 50, + 'maxLength' => 256, 'default' => '' ], 'image_url' => [ 'type' => self::STR, 'default' => '', - 'maxLength' => 200 + 'maxLength' => 512 + ], + + 'image_url_2x' => [ + 'type' => self::STR, + 'default' => '', + 'maxLength' => 512 + ], + + 'image_url_3x' => [ + 'type' => self::STR, + 'default' => '', + 'maxLength' => 512 + ], + + 'image_url_4x' => [ + 'type' => self::STR, + 'default' => '', + 'maxLength' => 512 ], 'class' => [ 'type' => self::STR, - 'maxLength' => 50, + 'maxLength' => 256, 'default' => '' ], diff --git a/Repository/UserBadge.php b/Repository/UserBadge.php index 19b5342..d7f5632 100644 --- a/Repository/UserBadge.php +++ b/Repository/UserBadge.php @@ -77,14 +77,18 @@ public function takeAwayBadge(User $user, int $badgeId) public function getRecentUserBadges(User $user) { + $allowedFeatured = $this->getAllowedFeaturedBadges($user); $sortSetting = XF::options()->CMTV_Badges_Featured_Badges_Sort; if($sortSetting == 'asc' || $sortSetting == 'desc') { $finder = $this->finder(C::__('UserBadge')) ->where('user_id', $user->user_id) ->order('award_date', $sortSetting) - ->with('Badge') - ->limit(5); + ->with('Badge'); + + if ($allowedFeatured !== -1) { + $finder->limit($allowedFeatured); + } $recentBadges = $finder->fetch(); } diff --git a/_data/phrases.xml b/_data/phrases.xml index c43c8e6..0abdff6 100644 --- a/_data/phrases.xml +++ b/_data/phrases.xml @@ -36,6 +36,10 @@ fa-comments or fas fa-adjust. List of icon codes.]]> + + + + diff --git a/_data/template_modifications.xml b/_data/template_modifications.xml index c2da9e0..a66dd0a 100644 --- a/_data/template_modifications.xml +++ b/_data/template_modifications.xml @@ -18,14 +18,8 @@ $0]]> $0]]> - - -
- - - -
- ]]>
+ + *\s*
*\s**\s**\s*<\/xf:contentcheck>*\s*<\/div>*\s*<\/xf:if>)]]> @@ -60,9 +54,8 @@ $0]]> arg-location="member_view" arg-user="{$user}" /> ]]> - - -
]]> + + *\s*
)]]> diff --git a/_data/templates.xml b/_data/templates.xml index b980095..a1a89ed 100644 --- a/_data/templates.xml +++ b/_data/templates.xml @@ -102,7 +102,7 @@
]]> -