[['a', 'c', 'ar'], 'g' => 'g.`id`'], 'a' => ['j' => ['?_account a ON a.`id` = g.`userId`', true], 's' => ', IFNULL(a.`username`, "") AS "author"'], 'c' => ['j' => ['?_comments c ON c.`type` = '.Type::GUIDE.' AND c.`typeId` = g.`id` AND (c.`flags` & '.CC_FLAG_DELETED.') = 0', true], 's' => ', COUNT(c.`id`) AS "comments"'], 'ar' => ['j' => ['?_articles ar ON ar.`type` = 300 AND ar.`typeId` = g.`id`'], 's' => ', MAX(ar.`rev`) AS "latest"'] ); public function __construct(array $conditions = [], array $miscData = []) { parent::__construct($conditions, $miscData); if ($this->error) return; $ratings = GuideMgr::getRatings($this->getFoundIDs()); // post processing foreach ($this->iterate() as $id => &$_curTpl) $_curTpl = array_merge($_curTpl, $ratings[$id]); } public static function getName(int $id) : ?LocString { if ($n = DB::Aowow()->SelectRow('SELECT `title` AS "name_loc0" FROM ?# WHERE `id` = ?d', self::$dataTable, $id)) return new LocString($n); return null; } public function getArticle(int $rev = -1) : string { if ($rev < -1) $rev = -1; if (empty($this->article[$rev])) { $a = DB::Aowow()->selectRow('SELECT `article`, `rev` FROM ?_articles WHERE ((`type` = ?d AND `typeId` = ?d){ OR `url` = ?}){ AND `rev`= ?d} ORDER BY `rev` DESC LIMIT 1', Type::GUIDE, $this->id, $this->getField('url') ?: DBSIMPLE_SKIP, $rev < 0 ? DBSIMPLE_SKIP : $rev); $this->article[$a['rev']] = $a['article']; if ($this->article[$a['rev']]) { Markup::parseTags($this->article[$a['rev']], $this->jsGlobals); return $this->article[$a['rev']]; } else trigger_error('GuideList::getArticle - linked article is missing'); } return $this->article[$rev] ?? ''; } public function getListviewData(bool $addDescription = false) : array { $data = []; foreach ($this->iterate() as $__) { $data[$this->id] = array( 'id' => $this->id, 'category' => $this->getField('category'), 'title' => $this->getField('title'), 'description' => $this->getField('description'), 'sticky' => !!($this->getField('cuFlags') & CC_FLAG_STICKY), 'nvotes' => $this->getField('nvotes'), 'url' => '?guide=' . ($this->getField('url') ?: $this->id), 'status' => $this->getField('status'), 'author' => $this->getField('author'), 'authorroles' => $this->getField('roles'), 'rating' => $this->getField('rating'), 'views' => $this->getField('views'), 'comments' => $this->getField('comments'), // 'patch' => $this->getField(''), // 30305 - patch is pointless, use date instead 'date' => $this->getField('date'), // ok 'when' => date(Util::$dateFormatInternal, $this->getField('date')) ); if ($this->getField('category') == 1) { $data[$this->id]['classs'] = $this->getField('classId'); $data[$this->id]['spec'] = $this->getField('specId'); } } return $data; } public function userCanView() : bool { // is owner || is staff return $this->getField('userId') == User::$id || User::isInGroup(U_GROUP_STAFF); } public function canBeViewed() : bool { // currently approved || has prev. approved version return $this->getField('status') == GuideMgr::STATUS_APPROVED || $this->getField('rev') > 0; } public function canBeReported() : bool { // not own guide && is not archived return $this->getField('userId') != User::$id && $this->getField('status') != GuideMgr::STATUS_ARCHIVED; } public function getJSGlobals(int $addMask = GLOBALINFO_ANY) : array { return $this->jsGlobals; } public function renderTooltip() : ?string { $specStr = ''; if ($this->getField('classId') && $this->getField('category') == 1) { if ($c = $this->getField('classId')) { $n = Lang::game('cl', $c); $specStr .= ' – %s'; if (($s = $this->getField('specId')) > -1) { $i = Game::$specIconStrings[$c][$s]; $n = ''; $specStr .= ''.Lang::game('classSpecs', $c, $s).''; } $specStr = sprintf($specStr, $n); } } $tt = '
'.$this->getField('title').' '; $tt .= '
'.$this->getField('description').' ';
$tt .= ' |