<page identifier="com.woltlab.wcf.TrophyList">
<pageType>system</pageType>
<controller>wcf\page\TrophyListPage</controller>
+ <handler>wcf\system\page\handler\TrophyListPageHandler</handler>
<name language="de">Trophäen</name>
<name language="en">Trophies</name>
<parent>com.woltlab.wcf.MembersList</parent>
+ <requireObjectID>1</requireObjectID>
+ <permissions>user.profile.trophy.canSeeTrophies</permissions>
+ <options>module_trophy</options>
+ <allowSpidersToIndex>1</allowSpidersToIndex>
+ </page>
+ <page identifier="com.woltlab.wcf.Trophy">
+ <pageType>system</pageType>
+ <controller>wcf\page\TrophyPage</controller>
+ <handler>wcf\system\page\handler\TrophyPageHandler</handler>
+ <name language="de">Trophäe</name>
+ <name language="en">Trophy</name>
+ <parent>com.woltlab.wcf.TrophyList</parent>
+ <hasFixedParent>1</hasFixedParent>
+ <requireObjectID>1</requireObjectID>
<permissions>user.profile.trophy.canSeeTrophies</permissions>
<options>module_trophy</options>
<allowSpidersToIndex>1</allowSpidersToIndex>
--- /dev/null
+{capture assign='pageTitle'}{$trophy->getTitle()}{if $pageNo > 1} - {lang}wcf.page.pageNo{/lang}{/if}{/capture}
+
+{capture assign='headContent'}
+ {if $pageNo < $pages}
+ <link rel="next" href="{link controller='Trophy' object=$trophy}pageNo={@$pageNo+1}{/link}">
+ {/if}
+ {if $pageNo > 1}
+ <link rel="prev" href="{link controller='Trophy' object=$trophy}{if $pageNo > 2}pageNo={@$pageNo-1}{/if}{/link}">
+ {/if}
+{/capture}
+
+{capture assign='contentHeader'}
+ <header class="contentHeader messageGroupContentHeader">
+ <div class="contentHeaderIcon">
+ {@$trophy->renderTrophy(64)}
+ </div>
+
+ <div class="contentHeaderTitle">
+ <h1 class="contentTitle">{$trophy->getTitle()}</h1>
+ <ul class="inlineList contentHeaderMetaData">
+ <li>{@$trophy->getDescription()}</li>
+ <li><span class="icon icon16 fa-users"></span> {@$items}</li>
+ </ul>
+ </div>
+ </header>
+{/capture}
+
+{include file='header'}
+
+{hascontent}
+ <div class="paginationTop">
+ {content}
+ {pages print=true assign='pagesLinks' controller='Trophy' object=$trophy link="pageNo=%d"}
+ {/content}
+ </div>
+{/hascontent}
+
+{if $objects|count}
+ <ol class="section containerBoxList trophyCategoryList tripleColumned">
+ {foreach from=$objects item=userTrophy}
+ <li class="box64">
+ <div>{@$userTrophy->getUserProfile()->getAvatar()->getImageTag(64)}</div>
+
+ <div class="sidebarItemTitle">
+ <h3>{@$userTrophy->getUserProfile()->getAnchorTag()}</h3>
+ <small>{@$userTrophy->getDescription()} - {@$userTrophy->time|time}</small>
+ </div>
+ </li>
+ {/foreach}
+ </ol>
+{else}
+ <p class="info">{lang}wcf.global.noItems{/lang}</p>
+{/if}
+
+<footer class="contentFooter">
+ {hascontent}
+ <div class="paginationBottom">
+ {content}{@$pagesLinks}{/content}
+ </div>
+ {/hascontent}
+
+ {hascontent}
+ <nav class="contentFooterNavigation">
+ <ul>
+ {content}{event name='contentFooterNavigation'}{/content}
+ </ul>
+ </nav>
+ {/hascontent}
+</footer>
+
+{include file='footer'}
\ No newline at end of file
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) {
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()
]);
+
+ if (count($this->objectList) === 0) {
+ @header('HTTP/1.0 404 Not Found');
+ }
}
}
--- /dev/null
+<?php
+namespace wcf\page;
+use wcf\data\trophy\Trophy;
+use wcf\data\trophy\TrophyCache;
+use wcf\data\user\trophy\UserTrophy;
+use wcf\data\user\trophy\UserTrophyList;
+use wcf\system\cache\builder\UserOptionCacheBuilder;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\PermissionDeniedException;
+use wcf\system\page\PageLocationManager;
+use wcf\system\WCF;
+
+/**
+ * Represents a trophy page.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Page
+ * @since 3.1
+ *
+ * @property UserTrophyList $objectList
+ */
+class TrophyPage extends MultipleLinkPage {
+ /**
+ * @inheritDoc
+ */
+ public $neededModules = ['MODULE_TROPHY'];
+
+ /**
+ * @inheritDoc
+ */
+ public $neededPermissions = ['user.profile.trophy.canSeeTrophies'];
+
+ /**
+ * @inheritDoc
+ */
+ public $itemsPerPage = 30;
+
+ /**
+ * @inheritDoc
+ */
+ public $objectListClassName = UserTrophyList::class;
+
+ /**
+ * @inheritDoc
+ */
+ public $sortField = 'time';
+
+ /**
+ * @inheritDoc
+ */
+ public $sortOrder = 'DESC';
+
+ /**
+ * the trophy id
+ * @var int
+ */
+ public $trophyID = 0;
+
+ /**
+ * The trophy instance
+ * @var Trophy
+ */
+ public $trophy;
+
+ public function readData() {
+ parent::readData();
+
+ PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.TrophyList', $this->trophy->getCategory()->getObjectID(), $this->trophy->getCategory());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function readParameters() {
+ parent::readParameters();
+
+ if (isset($_REQUEST['id'])) $this->trophyID = intval($_REQUEST['id']);
+
+ $this->trophy = TrophyCache::getInstance()->getTrophyByID($this->trophyID);
+ if ($this->trophy === null) {
+ throw new IllegalLinkException();
+ }
+
+ if ($this->trophy->isDisabled()) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function readObjects() {
+ parent::readObjects();
+
+ $userIDs = [];
+ /** @var UserTrophy $trophy */
+ foreach ($this->objectList->getObjects() as $trophy) {
+ $userIDs[] = $trophy->userID;
+ }
+
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs));
+ }
+
+ /**
+ * @inheritDoc
+ */
+ protected function initObjectList() {
+ parent::initObjectList();
+
+ $this->objectList->getConditionBuilder()->add('user_trophy.trophyID = ?', [$this->trophy->getObjectID()]);
+
+ if (!WCF::getUser()->userID) {
+ $this->objectList->getConditionBuilder()->add('user_trophy.userID IN (SELECT userID FROM wcf'. WCF_N .'_user_option_value WHERE userOption'. UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID .' = 0)');
+ }
+ else if (!WCF::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) {
+ $conditionBuilder = new PreparedStatementConditionBuilder(false, 'OR');
+ $conditionBuilder->add('user_trophy.userID IN (SELECT userID FROM wcf'. WCF_N .'_user_option_value WHERE (userOption'. UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID .' = 0 OR userOption'. UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID .' = 1))');
+
+ $friendshipConditionBuilder = new PreparedStatementConditionBuilder(false);
+ $friendshipConditionBuilder->add('user_trophy.userID IN (SELECT userID FROM wcf'. WCF_N .'_user_option_value WHERE userOption'. UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID .' = 2)');
+ $friendshipConditionBuilder->add('user_trophy.userID IN (SELECT userID FROM wcf'. WCF_N .'_user_follow WHERE followUserID = ?)', [WCF::getUser()->userID]);
+ $conditionBuilder->add('(' . $friendshipConditionBuilder . ')', $friendshipConditionBuilder->getParameters());
+ $conditionBuilder->add('user_trophy.userID = ?', [WCF::getUser()->userID]);
+
+ $this->objectList->getConditionBuilder()->add('('. $conditionBuilder .')', $conditionBuilder->getParameters());
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function assignVariables() {
+ parent::assignVariables();
+
+ WCF::getTPL()->assign([
+ 'trophy' => $this->trophy,
+ 'trophyID' => $this->trophyID
+ ]);
+
+ if (count($this->objectList) === 0) {
+ @header('HTTP/1.0 404 Not Found');
+ }
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\page\handler;
+use wcf\data\trophy\category\TrophyCategory;
+
+/**
+ * Menu page handler for the trophy list page.
+ *
+ * @author Joshua Rüsweg
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Page\Handler
+ * @since 3.1
+ */
+class TrophyListPageHandler extends AbstractLookupPageHandler {
+ use TDecoratedCategoryOnlineLocationLookupPageHandler;
+
+ /**
+ * @inheritDoc
+ */
+ protected function getDecoratedCategoryClass() {
+ return TrophyCategory::class;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\page\handler;
+use wcf\data\trophy\TrophyCache;
+use wcf\data\trophy\TrophyList;
+use wcf\system\WCF;
+
+/**
+ * Menu page handler for the trophy page.
+ *
+ * @author Joshua Rüsweg
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Page\Handler
+ * @since 3.1
+ */
+class TrophyPageHandler extends AbstractLookupPageHandler {
+ /**
+ * @inheritDoc
+ */
+ public function getLink($objectID) {
+ return TrophyCache::getInstance()->getTrophyByID($objectID)->getLink();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function isValid($objectID) {
+ return TrophyCache::getInstance()->getTrophyByID($objectID) !== null;
+ }
+
+ /** @noinspection PhpMissingParentCallCommonInspection */
+ /**
+ * @inheritDoc
+ */
+ public function isVisible($objectID = null) {
+ return WCF::getSession()->getPermission('user.profile.trophy.canSeeTrophies');
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function lookup($searchString) {
+ $trophyList = new TrophyList();
+ if (!empty($trophyList->sqlJoins)) $trophyList->sqlJoins .= ', ';
+ $trophyList->sqlJoins = "LEFT JOIN wcf".WCF_N."_language_item language_item ON (language_item.languageItem = trophy.title)";
+ $trophyList->getConditionBuilder()->add('(trophy.title LIKE ? OR language_item.languageItemValue LIKE ?)', ['%' . $searchString . '%', '%' . $searchString . '%']);
+ $trophyList->sqlLimit = 10;
+ $trophyList->sqlOrderBy = 'title';
+ $trophyList->readObjects();
+
+ $results = [];
+ foreach ($trophyList->getObjects() as $trophy) {
+ $results[] = [
+ 'description' => $trophy->getDescription(),
+ 'image' => $trophy->renderTrophy(48),
+ 'link' => $trophy->getLink(),
+ 'objectID' => $trophy->trophyID,
+ 'title' => $trophy->getTitle()
+ ];
+ }
+
+ return $results;
+ }
+}
font-size: 18px;
}
+ &.icon48 {
+ font-size: 27px;
+ }
+
&.icon64 {
font-size: 36px;
}