[['src']], // 11: Type::TITLE 'src' => ['j' => ['?_source src ON `type` = 11 AND `typeId` = t.`id`', true], 's' => ', `src13`, `moreType`, `moreTypeId`'] ); public function __construct(array $conditions = [], array $miscData = []) { parent::__construct($conditions, $miscData); // post processing foreach ($this->iterate() as &$_curTpl) { // preparse sources - notice: under this system titles can't have more than one source (or two for achivements), which is enough for standard TC cases but may break custom cases if ($_curTpl['moreType'] == Type::ACHIEVEMENT) $this->sources[$this->id][SRC_ACHIEVEMENT][] = $_curTpl['moreTypeId']; else if ($_curTpl['moreType'] == Type::QUEST) $this->sources[$this->id][SRC_QUEST][] = $_curTpl['moreTypeId']; else if ($_curTpl['src13']) $this->sources[$this->id][SRC_CUSTOM_STRING][] = $_curTpl['src13']; // titles display up to two achievements at once if ($_curTpl['src12Ext']) $this->sources[$this->id][SRC_ACHIEVEMENT][] = $_curTpl['src12Ext']; unset($_curTpl['src12Ext']); unset($_curTpl['moreType']); unset($_curTpl['moreTypeId']); unset($_curTpl['src3']); // shorthand for more generic access; required by CommunityContent to determine subject foreach (Locale::cases() as $loc) if ($loc->validate()) $_curTpl['name'] = new LocString($_curTpl, 'male', fn($x) => trim(str_replace('%s', '', $x))); // $_curTpl['name_loc'.$loc->value] = trim(str_replace('%s', '', $_curTpl['male_loc'.$loc->value])); } } public static function getName(int $id) : ?LocString { if ($n = DB::Aowow()->SelectRow('SELECT `male_loc0`, `male_loc2`, `male_loc3`, `male_loc4`, `male_loc6`, `male_loc8` FROM ?# WHERE `id` = ?d', self::$dataTable, $id)) return new LocString($n, 'male', fn($x) => trim(str_replace('%s', '', $x))); return null; } public function getListviewData() : array { $data = []; $this->createSource(); foreach ($this->iterate() as $__) { $data[$this->id] = array( 'id' => $this->id, 'name' => $this->getField('male', true), 'namefemale' => $this->getField('female', true), 'side' => $this->curTpl['side'], 'gender' => $this->curTpl['gender'], 'expansion' => $this->curTpl['expansion'], 'category' => $this->curTpl['category'] ); if (!empty($this->curTpl['source'])) $data[$this->id]['source'] = $this->curTpl['source']; } return $data; } public function getJSGlobals(int $addMask = 0) : array { $data = []; foreach ($this->iterate() as $__) { $data[Type::TITLE][$this->id]['name'] = $this->getField('male', true); if ($_ = $this->getField('female', true)) $data[Type::TITLE][$this->id]['namefemale'] = $_; } return $data; } private function createSource() : void { $sources = array( SRC_QUEST => [], SRC_ACHIEVEMENT => [], SRC_CUSTOM_STRING => [] ); foreach ($this->iterate() as $__) { if (empty($this->sources[$this->id])) continue; foreach (array_keys($sources) as $srcKey) if (isset($this->sources[$this->id][$srcKey])) $sources[$srcKey] = array_merge($sources[$srcKey], $this->sources[$this->id][$srcKey]); } // fill in the details if (!empty($sources[SRC_QUEST])) $sources[SRC_QUEST] = (new QuestList(array(['id', $sources[SRC_QUEST]])))->getSourceData(); if (!empty($sources[SRC_ACHIEVEMENT])) $sources[SRC_ACHIEVEMENT] = (new AchievementList(array(['id', $sources[SRC_ACHIEVEMENT]])))->getSourceData(); foreach ($this->sources as $Id => $src) { $tmp = []; // Quest-source if (isset($src[SRC_QUEST])) { foreach ($src[SRC_QUEST] as $s) { if (isset($sources[SRC_QUEST][$s]['s'])) $this->faction2Side($sources[SRC_QUEST][$s]['s']); $tmp[SRC_QUEST][] = $sources[SRC_QUEST][$s]; } } // Achievement-source if (isset($src[SRC_ACHIEVEMENT])) { foreach ($src[SRC_ACHIEVEMENT] as $s) { if (isset($sources[SRC_ACHIEVEMENT][$s]['s'])) $this->faction2Side($sources[SRC_ACHIEVEMENT][$s]['s']); $tmp[SRC_ACHIEVEMENT][] = $sources[SRC_ACHIEVEMENT][$s]; } } // other source (only one item possible, so no iteration needed) if (isset($src[SRC_CUSTOM_STRING])) $tmp[SRC_CUSTOM_STRING] = [Lang::game('pvpSources', $Id)]; $this->templates[$Id]['source'] = $tmp; } } public function getHtmlizedName(int $gender = GENDER_MALE) : string { $field = $gender == GENDER_FEMALE ? 'female' : 'male'; return str_replace('%s', '<'.Util::ucFirst(Lang::main('name')).'>', $this->getField($field, true)); } public function renderTooltip() : ?string { return null; } private function faction2Side(int &$faction) : void // thats weird.. and hopefully unique to titles { if ($faction == 2) // Horde $faction = 0; else if ($faction != 1) // Alliance $faction = -1; // Both } } ?>