Skip to content

Commit

Permalink
Kategorien können nun eine Beschreibung haben
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanashi committed Nov 2, 2024
1 parent b54220a commit 0a40ab5
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 24 deletions.
17 changes: 16 additions & 1 deletion files/lib/data/faq/category/FaqCategory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use wcf\system\request\LinkHandler;
use wcf\system\style\FontAwesomeIcon;
use wcf\system\WCF;
use wcf\util\StringUtil;

/**
* @method FaqCategory[] getChildCategories()
Expand Down Expand Up @@ -86,7 +87,17 @@ public function getLink(): string
]);
}

public function getIcon(int $size = 24): string
public function getDescription(): string
{
return WCF::getLanguage()->get($this->description);
}

public function getDescriptionHtml(): string
{
return $this->descriptionUseHtml ? $this->getDescription() : StringUtil::encodeHTML($this->getDescription());
}

public function getIcon(int $size = 24, bool $defaultIcon = false): string
{
if (
isset($this->additionalData['faqIcon'])
Expand All @@ -95,6 +106,10 @@ public function getIcon(int $size = 24): string
return FontAwesomeIcon::fromString($this->additionalData['faqIcon'])->toHtml($size);
}

if ($defaultIcon) {
return FontAwesomeIcon::fromString('circle-question;false')->toHtml($size);
}

return '';
}
}
5 changes: 1 addition & 4 deletions files/lib/page/FaqQuestionListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ public function readData()
}

$faq = [
'id' => $category->categoryID,
'title' => WCF::getLanguage()->get($category->title),
'category' => $category,
'attachments' => $attachmentList,
'icon24' => $category->getIcon(24),
'icon64' => $category->getIcon(64),
'questions' => [],
];

Expand Down
9 changes: 8 additions & 1 deletion files/lib/system/category/FaqCategoryType.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class FaqCategoryType extends AbstractCategoryType
/**
* @inheritDoc
*/
protected $hasDescription = false;
protected $hasDescription = true;

/**
* @inheritDoc
Expand Down Expand Up @@ -42,7 +42,14 @@ final class FaqCategoryType extends AbstractCategoryType
protected function init()
{
$this->maximumNestingLevel = SIMPLE_FAQ_VIEW === 'gallery' ? 0 : 1;
$this->hasDescription = SIMPLE_FAQ_VIEW === 'gallery' ? false : true;

parent::init();
}

#[Override]
public function supportsHtmlDescription()
{
return SIMPLE_FAQ_VIEW === 'gallery' ? false : true;
}
}
18 changes: 11 additions & 7 deletions files/style/faq.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,22 @@
}

.faq {
> h2 {
font-size: 1.5rem;
border-bottom: 1px solid currentColor;
padding-bottom: 10px
> .sectionHeader {
h2 {
font-size: 1.5rem !important;
}
border-bottom: 1px solid currentColor !important;
padding-bottom: 10px;
}
> .sub {
margin-top: 16px;
margin-bottom: 8px;
margin-left: 16px;
> h2 {
font-size: 1.3rem;
border-bottom: 1px solid currentColor;
.sectionHeader {
h2 {
font-size: 1.3rem !important;
}
border-bottom: 1px solid currentColor !important;
padding-bottom: 10px;
}
}
Expand Down
24 changes: 13 additions & 11 deletions templates/faqQuestionList.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@
<div class="faqGallery">
{foreach from=$faqs item=faq}
{if ($faq['questions']|isset && $faq['questions']|count)}
<button type="button" class="button galleryButton" data-id="{$faq['id']}">
{if $faq['icon64'] === ''}
{icon name='circle-question' size=64}
{else}
{unsafe:$faq['icon64']}
{/if}
{$faq['title']}
<button type="button" class="button galleryButton" data-id="{$faq['category']->categoryID}">
{unsafe:$faq['category']->getIcon(64, true)}
{$faq['category']->getTitle()}
</button>
{/if}
{/foreach}
Expand All @@ -46,8 +42,8 @@
{if ($faq['questions']|isset && $faq['questions']|count)}
{assign var='attachmentList' value=$faq['attachments']}

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

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

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

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

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

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

0 comments on commit 0a40ab5

Please sign in to comment.