Files
aowow/includes/class.title.php
Sarjuuk 732226b44a BaseType:
- dropped property "names" and changed getField to return localized Fields if specified. Dropped stupid getNameFieldName() in the process as it was now obsolete.
 - made property "matches" private. Access through getMatches() that will execute the query _only_ when needed (which is basically always anyway (so much for optimization))

SpellList: parsing
 - ""fixed"" behavior of the amount-switch $l when used on russian text. It has 3 options instead of 2, no idea what the last one is for though
 - fixed extra leading whitespace occuring when parsing formulas

Lang:
 - removed offset from getMagicShools(), apparently it is unneeded :o

Util:
 - changed the output of formatTime() in the long version to be more correct in layout
 - initialized values in parseTime() to prevent empty strings returned by formatTime()
 - added asBin() and asHex() - helper to improve display of bitmasks (Spells are coming!)
 - update Spell-Effects/Auras and added misc strings to display different MiscValue-content

Filter:
 - removed escapes from $_POST-handler. If the input is erronous it should be corrected/ignored/noted by the $_GET-handler

Smarty:
 - added optinal parameter to saveCache(), loadCache() to better handle filter variables

Search:
 - changed $maxResults to 10 for OpenSearches in an effort to lower execution time and appied limits to all queries
 - changed result calculation for OpenSearch. It should now stick to it's limit of 10 results for the list
 - simplified WorldEvent search

global.js:
 - backported function to parse title-tag of dfn-elements into mouseover-tooltips
 - shortened document.getElementByTagName(x) calls to gE(document, x)
2013-04-26 17:02:35 +02:00

137 lines
4.2 KiB
PHP

<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
class TitleList extends BaseType
{
use listviewHelper;
public $sources = [];
protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_titles WHERE [cond] ORDER BY Id ASC';
protected $matchQuery = 'SELECT COUNT(1) FROM ?_titles WHERE [cond]';
public function __construct($data)
{
parent::__construct($data);
// post processing
while ($this->iterate())
{
// preparse sources
if (!empty($this->curTpl['source']))
{
$sources = explode(' ', $this->curTpl['source']);
foreach ($sources as $src)
{
$src = explode(':', $src);
$this->sources[$this->id][$src[0]][] = $src[1];
}
}
}
$this->reset(); // push first element back for instant use
}
public function getListviewData()
{
$data = [];
$this->createSource();
while ($this->iterate())
{
$data[$this->id] = array(
'id' => $this->id,
'name' => $this->getField('male', 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'];
}
if ($_ = $this->getField('female', true))
$data['namefemale'] = $_;
return $data;
}
public function addGlobalsToJscript(&$refs)
{
if (!isset($refs['gTitles']))
$refs['gTitles'] = [];
while ($this->iterate())
{
$refs['gTitles'][$this->id]['name'] = Util::jsEscape($this->getField('male', true));
if ($_ = $this->getField('female', true))
$refs['gTitles'][$this->id]['namefemale'] = $_;
}
}
private function createSource()
{
$sources = array(
4 => [], // Quest
12 => [], // Achievements
13 => [] // simple text
);
while ($this->iterate())
{
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[4]))
$sources[4] = (new QuestList(array(['id', $sources[4]])))->getSourceData();
if (!empty($sources[12]))
$sources[12] = (new AchievementList(array(['id', $sources[12]])))->getSourceData();
if (!empty($sources[13]))
$sources[13] = DB::Aowow()->SELECT('SELECT *, Id AS ARRAY_KEY FROM ?_sourceStrings WHERE Id IN (?a)', $sources[13]);
foreach ($this->sources as $Id => $src)
{
$tmp = [];
// Quest-source
if (isset($src[4]))
foreach ($src[4] as $s)
$tmp[4][] = $sources[4][$s];
// Achievement-source
if (isset($src[12]))
foreach ($src[12] as $s)
$tmp[12][] = $sources[12][$s];
// other source (only one item possible, so no iteration needed)
if (isset($src[13]))
$tmp[13] = [Util::localizedString($sources[13][$this->sources[$Id][13][0]], 'source')];
$this->templates[$Id]['source'] = json_encode($tmp);
}
}
public function getHtmlizedName($gender = GENDER_MALE)
{
$field = $gender == GENDER_FEMALE ? 'female' : 'male';
return str_replace('%s', '<span class="q0">&lt;'.Lang::$main['name'].'&gt;</span>', $this->getField($field, true));
}
public function addRewardsToJScript(&$ref) { }
public function renderTooltip() { }
}
?>