From: Joshua Rüsweg Date: Wed, 19 Jul 2017 20:34:53 +0000 (+0200) Subject: Add trophy list page X-Git-Tag: 3.1.0_Alpha_1~238 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a20cde88b79fc8afb33c8a8a627b113acd1b693e;p=GitHub%2FWoltLab%2FWCF.git Add trophy list page See #2315 --- diff --git a/com.woltlab.wcf/page.xml b/com.woltlab.wcf/page.xml index a9c03d5d63..53629e03e2 100644 --- a/com.woltlab.wcf/page.xml +++ b/com.woltlab.wcf/page.xml @@ -549,6 +549,16 @@ Kontakt + + system + wcf\page\TrophyListPage + Trophäen + Trophies + com.woltlab.wcf.MembersList + user.profile.trophy.canSeeTrophies + module_trophy + 1 + diff --git a/com.woltlab.wcf/templates/trophyList.tpl b/com.woltlab.wcf/templates/trophyList.tpl new file mode 100644 index 0000000000..7b50e06445 --- /dev/null +++ b/com.woltlab.wcf/templates/trophyList.tpl @@ -0,0 +1,80 @@ +{capture assign='pageTitle'}{$category->getTitle()}{if $pageNo > 1} - {lang}wcf.page.pageNo{/lang}{/if}{/capture} + +{capture assign='contentHeader'} +
+
+

{$category->getTitle()}

+ +
+
+{/capture} + +{capture assign='headContent'} + {if $pageNo < $pages} + + {/if} + {if $pageNo > 1} + + {/if} +{/capture} + +{include file='header'} + +{hascontent} +
+ {content} + {pages print=true assign='pagesLinks' controller='TrophyList' object=$category link="pageNo=%d"} + {/content} +
+{/hascontent} + +
+ + +
+ {if $objects|count} +
    + {foreach from=$objects item=trophy} +
  1. +
    {@$trophy->renderTrophy(64)}
    + +
    +

    {@$trophy->getTitle()}

    + {@$trophy->getDescription()} +
    +
  2. + {/foreach} +
+ {else} +

{lang}wcf.global.noItems{/lang}

+ {/if} +
+
+ +
+ {hascontent} +
+ {content}{@$pagesLinks}{/content} +
+ {/hascontent} + + {hascontent} + + {/hascontent} +
+ +{include file='footer'} \ No newline at end of file diff --git a/wcfsetup/install/files/lib/page/TrophyListPage.class.php b/wcfsetup/install/files/lib/page/TrophyListPage.class.php new file mode 100644 index 0000000000..a60d379de1 --- /dev/null +++ b/wcfsetup/install/files/lib/page/TrophyListPage.class.php @@ -0,0 +1,125 @@ + + * @package WoltLabSuite\Core\Page + * + * @property TrophyList $objectList + */ +class TrophyListPage extends MultipleLinkPage { + /** + * @inheritDoc + */ + public $neededModules = ['MODULE_TROPHY']; + + /** + * @inheritDoc + */ + public $neededPermissions = ['user.profile.trophy.canSeeTrophies']; + + /** + * @inheritDoc + */ + public $itemsPerPage = 30; + + /** + * @inheritDoc + */ + public $objectListClassName = TrophyList::class; + + /** + * selected sort field + * @var string + */ + public $sortField = 'trophyID'; + + /** + * selected sort order + * @var string + */ + public $sortOrder = 'ASC'; + + /** + * the category id filter + * @var int + */ + public $categoryID = 0; + + /** + * The category object filter + * @var TrophyCategory + */ + public $category; + + /** + * @inheritDoc + */ + public function readParameters() { + parent::readParameters(); + + if (isset($_REQUEST['id'])) $this->categoryID = intval($_REQUEST['id']); + + // read category id, if no categoryID is selected + if ($this->categoryID == 0) { + $categories = TrophyCategoryCache::getInstance()->getEnabledCategories(); + + if (count($categories)) { + $category = reset($categories); + $this->categoryID = $category->getObjectID(); + } + else { + throw new IllegalLinkException(); + } + } + + $this->category = TrophyCategoryCache::getInstance()->getCategoryByID($this->categoryID); + + if ($this->category === null) { + throw new IllegalLinkException(); + } + + if (!$this->category->isAccessible()) { + throw new PermissionDeniedException(); + } + } + + /** + * @inheritDoc + */ + protected function initObjectList() { + parent::initObjectList(); + + $this->objectList->getConditionBuilder()->add('isDisabled = ?', [0]); + $this->objectList->getConditionBuilder()->add('categoryID = ?', [$this->categoryID]); + } + + /** + * @inheritDoc + */ + public function assignVariables() { + parent::assignVariables(); + + if (!isset($_REQUEST['id'])) { + WCF::getTPL()->assign([ + 'canonicalURL' => $this->category->getLink() + ]); + } + + WCF::getTPL()->assign([ + 'category' => $this->category, + 'categoryID' => $this->categoryID, + 'categories' => TrophyCategoryCache::getInstance()->getEnabledCategories() + ]); + } +}