Files
aowow/endpoints/reputation/reputation.php
Sarjuuk 81d9248541 Template/Update (Part 3)
* convert amalgamation more.php into separate endpoints
 * fix url of help articles
2025-09-25 15:55:31 +02:00

59 lines
1.8 KiB
PHP

<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class ReputationBaseResponse extends TemplateResponse
{
protected bool $requiresLogin = true;
protected string $template = 'list-page-generic';
protected string $pageName = 'reputation';
protected ?int $activeTab = parent::TAB_COMMUNITY;
protected array $breadcrumb = [3, 10];
public function __construct(string $pageParam)
{
parent::__construct($pageParam);
if ($pageParam)
$this->generateError();
}
protected function generate() : void
{
$this->h1 = Lang::main('moreTitles', $this->pageName);
array_unshift($this->title, $this->h1);
if ($repData = DB::Aowow()->select('SELECT `action`, `amount`, `date` AS "when", IF(`action` IN (?a), `sourceA`, 0) AS "param" FROM ?_account_reputation WHERE `userId` = ?d',
[SITEREP_ACTION_COMMENT, SITEREP_ACTION_UPVOTED, SITEREP_ACTION_DOWNVOTED], User::$id))
{
array_walk($repData, fn(&$x) => $x['when'] = date(Util::$dateFormatInternal, $x['when']));
$this->tabsTitle = Lang::main('yourRepHistory');
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], __forceTabs: true);
$this->lvTabs->addListviewTab(new Listview(array(
'id' => 'reputation-history',
'name' => '$LANG.reputationhistory',
'data' => $repData
), 'reputationhistory'));
}
parent::generate();
$this->result->registerDisplayHook('article', [self::class, 'articleHook']);
}
public static function articleHook(Template\PageTemplate &$pt, Markup &$article) : void
{
$article->apply(Cfg::applyToString(...));
}
}
?>