Skip to content

Commit 0a40ab5

Browse files
committed
Kategorien können nun eine Beschreibung haben
1 parent b54220a commit 0a40ab5

File tree

5 files changed

+49
-24
lines changed

5 files changed

+49
-24
lines changed

files/lib/data/faq/category/FaqCategory.class.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use wcf\system\request\LinkHandler;
1414
use wcf\system\style\FontAwesomeIcon;
1515
use wcf\system\WCF;
16+
use wcf\util\StringUtil;
1617

1718
/**
1819
* @method FaqCategory[] getChildCategories()
@@ -86,7 +87,17 @@ public function getLink(): string
8687
]);
8788
}
8889

89-
public function getIcon(int $size = 24): string
90+
public function getDescription(): string
91+
{
92+
return WCF::getLanguage()->get($this->description);
93+
}
94+
95+
public function getDescriptionHtml(): string
96+
{
97+
return $this->descriptionUseHtml ? $this->getDescription() : StringUtil::encodeHTML($this->getDescription());
98+
}
99+
100+
public function getIcon(int $size = 24, bool $defaultIcon = false): string
90101
{
91102
if (
92103
isset($this->additionalData['faqIcon'])
@@ -95,6 +106,10 @@ public function getIcon(int $size = 24): string
95106
return FontAwesomeIcon::fromString($this->additionalData['faqIcon'])->toHtml($size);
96107
}
97108

109+
if ($defaultIcon) {
110+
return FontAwesomeIcon::fromString('circle-question;false')->toHtml($size);
111+
}
112+
98113
return '';
99114
}
100115
}

files/lib/page/FaqQuestionListPage.class.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,8 @@ public function readData()
7474
}
7575

7676
$faq = [
77-
'id' => $category->categoryID,
78-
'title' => WCF::getLanguage()->get($category->title),
77+
'category' => $category,
7978
'attachments' => $attachmentList,
80-
'icon24' => $category->getIcon(24),
81-
'icon64' => $category->getIcon(64),
8279
'questions' => [],
8380
];
8481

files/lib/system/category/FaqCategoryType.class.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class FaqCategoryType extends AbstractCategoryType
1414
/**
1515
* @inheritDoc
1616
*/
17-
protected $hasDescription = false;
17+
protected $hasDescription = true;
1818

1919
/**
2020
* @inheritDoc
@@ -42,7 +42,14 @@ final class FaqCategoryType extends AbstractCategoryType
4242
protected function init()
4343
{
4444
$this->maximumNestingLevel = SIMPLE_FAQ_VIEW === 'gallery' ? 0 : 1;
45+
$this->hasDescription = SIMPLE_FAQ_VIEW === 'gallery' ? false : true;
4546

4647
parent::init();
4748
}
49+
50+
#[Override]
51+
public function supportsHtmlDescription()
52+
{
53+
return SIMPLE_FAQ_VIEW === 'gallery' ? false : true;
54+
}
4855
}

files/style/faq.scss

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,22 @@
4343
}
4444

4545
.faq {
46-
> h2 {
47-
font-size: 1.5rem;
48-
border-bottom: 1px solid currentColor;
49-
padding-bottom: 10px
46+
> .sectionHeader {
47+
h2 {
48+
font-size: 1.5rem !important;
49+
}
50+
border-bottom: 1px solid currentColor !important;
51+
padding-bottom: 10px;
5052
}
5153
> .sub {
5254
margin-top: 16px;
5355
margin-bottom: 8px;
5456
margin-left: 16px;
55-
> h2 {
56-
font-size: 1.3rem;
57-
border-bottom: 1px solid currentColor;
57+
.sectionHeader {
58+
h2 {
59+
font-size: 1.3rem !important;
60+
}
61+
border-bottom: 1px solid currentColor !important;
5862
padding-bottom: 10px;
5963
}
6064
}

templates/faqQuestionList.tpl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,9 @@
2323
<div class="faqGallery">
2424
{foreach from=$faqs item=faq}
2525
{if ($faq['questions']|isset && $faq['questions']|count)}
26-
<button type="button" class="button galleryButton" data-id="{$faq['id']}">
27-
{if $faq['icon64'] === ''}
28-
{icon name='circle-question' size=64}
29-
{else}
30-
{unsafe:$faq['icon64']}
31-
{/if}
32-
{$faq['title']}
26+
<button type="button" class="button galleryButton" data-id="{$faq['category']->categoryID}">
27+
{unsafe:$faq['category']->getIcon(64, true)}
28+
{$faq['category']->getTitle()}
3329
</button>
3430
{/if}
3531
{/foreach}
@@ -46,8 +42,8 @@
4642
{if ($faq['questions']|isset && $faq['questions']|count)}
4743
{assign var='attachmentList' value=$faq['attachments']}
4844

49-
<div id="faqSection{$faq['id']}" class="section faqGallerySection jsObjectActionContainer faq" data-object-action-class-name="wcf\data\faq\QuestionAction" style="display: none;">
50-
<h2>{unsafe:$faq['icon24']} {$faq['title']}</h2>
45+
<div id="faqSection{$faq['category']->categoryID}" class="section faqGallerySection jsObjectActionContainer faq" data-object-action-class-name="wcf\data\faq\QuestionAction" style="display: none;">
46+
<h2>{unsafe:$faq['category']->getIcon(24)} {$faq['category']->getTitle()}</h2>
5147

5248
{if $faq['questions']|isset}
5349
{foreach from=$faq['questions'] item=question}
@@ -64,7 +60,10 @@
6460
{assign var='attachmentList' value=$faq['attachments']}
6561

6662
<div class="section faq{if SIMPLE_FAQ_VIEW === 'cleave'} cleaveCategory{/if}">
67-
<h2>{unsafe:$faq['icon24']} {$faq['title']}</h2>
63+
<header class="sectionHeader">
64+
<h2 class="sectionTitle">{unsafe:$faq['category']->getIcon(24)} {$faq['category']->getTitle()}</h2>
65+
<p class="sectionDescription">{unsafe:$faq['category']->getDescriptionHtml()}</p>
66+
</header>
6867

6968
{if $faq['questions']|isset}
7069
{foreach from=$faq['questions'] item=question}
@@ -78,7 +77,10 @@
7877
{assign var='attachmentList' value=$sub['attachments']}
7978

8079
<div class="sub">
81-
<h2>{$sub['title']}</h2>
80+
<header class="sectionHeader">
81+
<h2 class="sectionTitle">{unsafe:$sub['category']->getIcon(24)} {$sub['category']->getTitle()}</h2>
82+
<p class="sectionDescription">{unsafe:$sub['category']->getDescriptionHtml()}</p>
83+
</header>
8284

8385
{foreach from=$sub['questions'] item=question}
8486
{include file='__faqQuestionListEntry'}

0 commit comments

Comments
 (0)