dropped single-item classes for all types, because it doesn't make much difference to use a list with a single item instead, especially if it's preselected. Additionally it is now easier to chain certain queries together and execute them all at once. additionally, additionally certain data can now be cahced and shared between types of the same .. type, that were previously in different instances alltogether.

And you may now specify a limit to sql-queries (while setting up a typeList), it will default to the config-limit if no value is given.
This commit is contained in:
Sarjuuk
2013-03-05 20:31:38 +01:00
parent 8a9d984eda
commit 9019c3b811
21 changed files with 1614 additions and 1429 deletions

View File

@@ -3,51 +3,133 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class Achievement extends BaseType
class AchievementList extends BaseType
{
public $criteria = [];
public $tooltip = '';
public $tooltip = [];
protected $setupQuery = "SELECT * FROM ?_achievement WHERE `Id` = ?";
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_achievement WHERE [filter] [cond] GROUP BY Id ORDER BY `orderInGroup` ASC';
protected $matchQuery = 'SELECT COUNT(1) FROM ?_achievement WHERE [filter] [cond]';
public function __construct($data)
public function __construct($conditions)
{
parent::__construct($data);
parent::__construct($conditions);
// post processing
if (!$this->template['iconString'])
$this->template['iconString'] = 'INV_Misc_QuestionMark';
while ($this->iterate())
{
if (!$this->curTpl['iconString'])
$this->templates[$this->Id]['iconString'] = 'INV_Misc_QuestionMark';
//"rewards":[[11,137],[3,138]] [type, typeId]
if (!empty($this->curTpl['rewardIds']))
{
$rewards = [];
$rewIds = explode(" ", $this->curTpl['rewardIds']);
foreach ($rewIds as $rewId)
$rewards[] = ($rewId > 0 ? [TYPE_ITEM => $rewId] : ($rewId < 0 ? [TYPE_TITLE => -$rewId] : NULL));
$this->templates[$this->Id]['rewards'] = $rewards;
}
}
$this->reset(); // restore 'iterator'
}
public function addRewardsToJScript(&$refs)
{
// collect Ids to execute in single query
$lookup = [];
while ($this->iterate())
{
$rewards = explode(" ", $this->curTpl['rewardIds']);
foreach ($rewards as $reward)
{
if ($reward > 0)
$lookup['item'][] = $reward;
else if ($reward < 0)
$lookup['title'][] = -$reward;
}
}
if (isset($lookup['item']))
(new ItemList(array(['i.entry', array_unique($lookup['item'])])))->addGlobalsToJscript($refs);
if (isset($lookup['title']))
(new TitleList(array(['Id', array_unique($lookup['title'])])))->addGlobalsToJscript($refs);
}
public function addGlobalsToJscript(&$refs)
{
if (!isset($refs['gAchievements']))
$refs['gAchievements'] = [];
while ($this->iterate())
{
$refs['gAchievements'][$this->Id] = array(
'icon' => $this->curTpl['iconString'],
'name' => Util::localizedString($this->curTpl, 'name')
);
}
}
public function getListviewData()
{
return array(
'id' => $this->Id,
'name' => Util::localizedString($this->template, 'name'),
'description' => Util::localizedString($this->template, 'description'),
'points' => $this->template['points'],
'faction' => $this->template['faction'] + 1,
'category' => $this->template['category'],
'parentCat' => $this->template['parentCat'],
'rewards' => empty($this->template['rewards']) ? NULL : $this->template['rewards'],
'reward' => empty($this->template['reward_loc'.User::$localeId]) ? NULL : Util::localizedString($this->template, 'reward'),
);
$data = [];
while ($this->iterate())
{
$data[$this->Id] = array(
'id' => $this->Id,
'name' => Util::localizedString($this->curTpl, 'name'),
'description' => Util::localizedString($this->curTpl, 'description'),
'points' => $this->curTpl['points'],
'faction' => $this->curTpl['faction'] + 1,
'category' => $this->curTpl['category'],
'parentCat' => $this->curTpl['parentCat'],
);
if (!empty($this->curTpl['rewards']))
{
$rewards = [];
foreach ($this->curTpl['rewards'] as $pair)
$rewards[] = '['.key($pair).','.current($pair).']';
$data[$this->Id]['rewards'] = '['.implode(',', $rewards).']';
}
else if (!empty ($this->curTpl['reward']))
$data[$this->Id]['reward'] = Util::localizedString($this->curTpl, 'reward');
}
return $data;
}
// hmm, really needed? .. probably .. needs rename? .. also probably
public function getDetailedData()
{
return array(
'id' => $this->Id,
'name' => Util::localizedString($this->template, 'name'),
'description' => Util::localizedString($this->template, 'description'),
'points' => $this->template['points'],
'iconname' => $this->template['iconString'],
'count' => $this->template['reqCriteriaCount'],
'reward' => empty($this->template['reward_loc'.User::$localeId]) ? NULL : Util::localizedString($this->template, 'reward'),
);
$data = [];
while ($this->iterate())
{
$data[$this->Id] = array(
'id' => $this->Id,
'name' => Util::localizedString($this->curTpl, 'name'),
'description' => Util::localizedString($this->curTpl, 'description'),
'points' => $this->curTpl['points'],
'iconname' => $this->curTpl['iconString'],
'count' => $this->curTpl['reqCriteriaCount'],
'reward' => empty($this->curTpl['reward_loc'.User::$localeId]) ? NULL : Util::localizedString($this->curTpl, 'reward')
);
}
return $data;
}
// only for current template
public function getCriteria($idx = -1)
{
if (empty($this->criteria))
@@ -57,63 +139,29 @@ class Achievement extends BaseType
return [];
if (is_array($result[0]))
$this->criteria = $result;
$this->criteria[$this->Id] = $result;
else
$this->criteria[] = $result;
$this->criteria[$this->Id][] = $result;
}
if ($idx < 0)
return $this->criteria;
return $this->criteria[$this->Id];
else
return $this->criteria[$idx];
return $this->criteria[$this->Id][$idx];
}
public function addGlobalsToJScript(&$gAchievements)
public function renderTooltip()
{
$gAchievements[$this->Id] = array(
'icon' => $this->template['iconString'],
'name' => Util::localizedString($this->template, 'name'),
);
}
public function addRewardsToJscript(&$gItems, &$gTitles)
{
$rewards = explode(" ", $this->template['rewardIds']);
$lookup = [];
foreach ($rewards as $reward)
{
if ($reward > 0)
$lookup['item'][] = $reward;
else if ($reward < 0)
$lookup['title'][] = -$reward;
}
if (isset($lookup['item']))
{
$rewItems = new ItemList(array(['i.entry', $lookup['item']]));
$rewItems->addGlobalsToJScript($gItems);
}
if (isset($lookup['title']))
{
$rewTitles = new TitleList(array(['Id', $lookup['title']]));
$rewTitles->addGlobalsToJScript($gTitles);
}
}
public function createTooltip()
{
if (!empty($this->tooltip))
return $this->tooltip;
if (!empty($this->tooltip[$this->Id]))
return $this->tooltip[$this->Id];
$criteria = $this->getCriteria();
$tmp = [];
$tmp = [];
$rows = [];
$i = 0;
$i = 0;
foreach ($criteria as $_row)
{
if($i++ % 2)
if ($i++ % 2)
$tmp[] = $_row;
else
$rows[] = $_row;
@@ -121,9 +169,9 @@ class Achievement extends BaseType
if ($tmp)
$rows = array_merge($rows, $tmp);
$description = Util::localizedString($this->template, 'description');
$name = Util::localizedString($this->template, 'name');
$criteria = '';
$description = Util::localizedString($this->curTpl, 'description');
$name = Util::localizedString($this->curTpl, 'name');
$criteria = '';
$i = 0;
foreach ($rows as $crt)
@@ -148,7 +196,7 @@ class Achievement extends BaseType
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
if (!$crtName)
$crtName = Item::getName($crt['value1']);
$crtName = Util::getItemName($crt['value1']);
break;
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
if (!$crtName)
@@ -184,88 +232,29 @@ class Achievement extends BaseType
$x .= '</td></tr></table>';
// Completed
$this->tooltip = $x;
$this->tooltip[$this->Id] = $x;
return $this->tooltip;
return $this->tooltip[$this->Id];
}
public function getSourceData()
{
return array(
"n" => Util::localizedString($this->template, 'name'),
"s" => $this->template['faction'],
"t" => TYPE_ACHIEVEMENT,
"ti" => $this->Id
);
}
}
$data = [];
class AchievementList extends BaseTypeList
{
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_achievement WHERE [filter] [cond] GROUP BY Id ORDER BY `orderInGroup` ASC';
public function __construct($conditions)
{
// may be called without filtering
if (class_exists('AchievementFilter'))
while ($this->iterate())
{
$this->filter = new AchievementFilter();
if (($fiData = $this->filter->init()) === false)
return;
$data[$this->Id] = array(
"n" => Util::localizedString($this->curTpl, 'name'),
"s" => $this->curTpl['faction'],
"t" => TYPE_ACHIEVEMENT,
"ti" => $this->Id
);
}
parent::__construct($conditions);
// post processing
foreach ($this->container as $k => $acv)
{
//"rewards":[[11,137],[3,138]] [what, entry] 3:item; 11:title, 6:spell(unused)
if (!empty($acv->template['rewardIds']))
{
$rewards = [];
$rewIds = explode(" ", $acv->template['rewardIds']);
foreach ($rewIds as $rewId)
$rewards[] = ($rewId > 0 ? "[3,".$rewId."]" : ($rewId < 0 ? "[11,".-$rewId."]" : NULL));
$this->container[$k]->template['rewards'] = "[".implode(",",$rewards)."]";
}
}
return $data;
}
public function addRewardsToJScript(&$gItems, &$gTitles)
{
// collect Ids to execute in single query
$lookup = [];
foreach ($this->container as $id => $data)
{
$rewards = explode(" ", $data->template['rewardIds']);
foreach ($rewards as $reward)
{
if ($reward > 0)
$lookup['item'][] = $reward;
else if ($reward < 0)
$lookup['title'][] = -$reward;
}
}
if (isset($lookup['item']))
{
$rewItems = new ItemList(array(['i.entry', array_unique($lookup['item'])]));
$rewItems->addGlobalsToJScript($gItems);
}
if (isset($lookup['title']))
{
$rewTitles = new TitleList(array(['Id', array_unique($lookup['title'])]));
$rewTitles->addGlobalsToJScript($gTitles);
}
}
// run once
// run once .. should this even be here..?
public function setupAchievements()
{
set_time_limit(120);
@@ -309,21 +298,21 @@ class AchievementList extends BaseTypeList
world.achievement_dbc"
);
foreach ($this->container as $acv)
while ($this->iterate())
{
// set iconString
$icon = DB::Aowow()->SelectCell('SELECT iconname FROM ?_spellicons WHERE id = ?d', $acv->template['iconId']);
$icon = DB::Aowow()->SelectCell('SELECT iconname FROM ?_spellicons WHERE id = ?d', $this->curTpl['iconId']);
// set parentCat
$parentCat = DB::Aowow()->SelectCell('SELECT parentCategory FROM ?_achievementcategory WHERE Id = ?d', $acv->template['category']);
$parentCat = DB::Aowow()->SelectCell('SELECT parentCategory FROM ?_achievementcategory WHERE Id = ?d', $this->curTpl['category']);
// series parent(16) << child(16)
$series = $acv->template['parent'] << 16;
$series = $this->curTpl['parent'] << 16;
$series |= DB::Aowow()->SelectCell('SELECT Id FROM ?_achievement WHERE parent = ?d', $acv->Id);
// set rewards
$rewardIds = [];
if ($rStr = $acv->template['reward_loc0'])
if ($rStr = $this->curTpl['reward_loc0'])
{
// i can haz title?
@@ -384,4 +373,5 @@ class AchievementList extends BaseTypeList
}
}
}
?>
?>

File diff suppressed because it is too large Load Diff

View File

@@ -3,29 +3,42 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class Quest extends BaseType
class QuestList extends BaseType
{
public $cat1 = 0;
public $cat2 = 0;
protected $setupQuery = 'SELECT * FROM quest_template a LEFT JOIN locales_quest b ON a.Id = b.entry WHERE a.Id = ?';
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM quest_template a LEFT JOIN locales_quest b ON a.Id = b.entry WHERE [filter] [cond] ORDER BY Id ASC';
protected $matchQuery = 'SELECT COUNT(1) FROM quest_template a LEFT JOIN locales_quest b ON a.Id = b.entry WHERE [filter] [cond]';
public function __construct($data)
// parent::__construct does the job
public function iterate($qty = 1)
{
parent::__construct($data);
$r = parent::iterate($qty);
// post process
$this->cat1 = $this->template['ZoneOrSort']; // should probably be in a method...
foreach (Util::$questClasses as $k => $arr)
if (!$this->Id)
{
if (in_array($this->cat1, $arr))
$this->cat1 = 0;
$this->cat2 = 0;
}
else
{
$this->cat1 = $this->curTpl['ZoneOrSort']; // should probably be in a method...
foreach (Util::$questClasses as $k => $arr)
{
$this->cat2 = $k;
break;
if (in_array($this->cat1, $arr))
{
$this->cat2 = $k;
break;
}
}
}
return $r;
}
// static use START
public static function getName($id)
{
$n = DB::Aowow()->SelectRow('
@@ -54,160 +67,114 @@ class Quest extends BaseType
else
return 0;
}
// static use END
public function getSourceData()
{
return array(
"n" => Util::localizedString($this->template, 'Title'),
"t" => TYPE_QUEST,
"ti" => $this->Id,
"c" => $this->cat1,
"c2" => $this->cat2
);
}
$data = [];
public function getListviewData()
{
$data = array(
'category' => $this->cat1,
'category2' => $this->cat2,
'id' => $this->Id,
'level' => $this->template['Level'],
'reqlevel' => $this->template['MinLevel'],
'name' => Util::localizedString($this->template, 'Title'),
'side' => Util::sideByRaceMask($this->template['RequiredRaces'])
);
$rewards = [];
for ($i = 1; $i < 5; $i++)
if ($this->template['RewardItemId'.$i])
$rewards[] = [$this->template['RewardItemId'.$i], $this->template['RewardItemCount'.$i]];
$choices = [];
for ($i = 1; $i < 7; $i++)
if ($this->template['RewardChoiceItemId'.$i])
$choices[] = [$this->template['RewardChoiceItemId'.$i], $this->template['RewardChoiceItemCount'.$i]];
if (!empty($rewards))
$data['itemrewards'] = $rewards;
if (!empty($choices))
$data['itemchoices'] = $choices;
if ($this->template['RewardTitleId'])
$data['titlereward'] = $this->template['RewardTitleId'];
// todo reprewards .. accesses QuestFactionReward.dbc
while ($this->iterate())
{
$data[$this->Id] = array(
"n" => Util::localizedString($this->curTpl, 'Title'),
"t" => TYPE_QUEST,
"ti" => $this->Id,
"c" => $this->cat1,
"c2" => $this->cat2
);
}
return $data;
}
public function addRewardsToJscript(&$gItems, &$gSpells, &$gTitles)
public function getListviewData()
{
// items
$items = [];
for ($i = 1; $i < 5; $i++)
if ($this->template['RewardItemId'.$i])
$items[] = $this->template['RewardItemId'.$i];
$data = [];
for ($i = 1; $i < 7; $i++)
if ($this->template['RewardChoiceItemId'.$i])
$items[] = $this->template['RewardChoiceItemId'.$i];
if (!empty($items))
while ($this->iterate())
{
$items = new ItemList(array(['entry', $items]));
$items->addSelfToJScipt($gItems);
$set = array(
'category' => $this->cat1,
'category2' => $this->cat2,
'id' => $this->Id,
'level' => $this->curTpl['Level'],
'reqlevel' => $this->curTpl['MinLevel'],
'name' => Util::localizedString($this->curTpl, 'Title'),
'side' => Util::sideByRaceMask($this->curTpl['RequiredRaces'])
);
$rewards = [];
for ($i = 1; $i < 5; $i++)
if ($this->curTpl['RewardItemId'.$i])
$rewards[] = [$this->curTpl['RewardItemId'.$i], $this->curTpl['RewardItemCount'.$i]];
$choices = [];
for ($i = 1; $i < 7; $i++)
if ($this->curTpl['RewardChoiceItemId'.$i])
$choices[] = [$this->curTpl['RewardChoiceItemId'.$i], $this->curTpl['RewardChoiceItemCount'.$i]];
if ($rewards)
$set['itemrewards'] = $rewards;
if ($choices)
$set['itemchoices'] = $choices;
if ($this->curTpl['RewardTitleId'])
$set['titlereward'] = $this->curTpl['RewardTitleId'];
// todo reprewards .. accesses QuestFactionReward.dbc
}
// spells
$spells = [];
if ($this->template['RewardSpell'])
$spells[] = $this->template['RewardSpell'];
if ($this->template['RewardSpellCast'])
$spells[] = $this->template['RewardSpellCast'];
if (!empty($spells))
{
$spells = new SpellList(array(['id', $spells]));
$spells->addSelfToJScipt($gSpells);
}
// titles
if ($tId = $this->template['RewardTitleId'])
{
$title = new Title($tId);
$title->addGlobalsToJScript($gTitles);
}
}
}
class QuestList extends BaseTypeList
{
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM quest_template a LEFT JOIN locales_quest b ON a.Id = b.entry WHERE [filter] [cond] ORDER BY Id ASC';
public function __construct($conditions)
{
// may be called without filtering
if (class_exists('QuestFilter'))
{
$this->filter = new QuestFilter();
if (($fiData = $this->filter->init()) === false)
return;
}
parent::__construct($conditions);
return $data;
}
public function addRewardsToJscript(&$gItems, &$gSpells, &$gTitles)
public function addRewardsToJscript(&$refs)
{
$items = [];
$spells = [];
$titles = [];
foreach ($this->container as $quest)
while ($this->iterate())
{
// items
for ($i = 1; $i < 5; $i++)
if ($quest->template['RewardItemId'.$i])
$items[] = $quest->template['RewardItemId'.$i];
if ($this->curTpl['RewardItemId'.$i] > 0)
$items[] = $this->curTpl['RewardItemId'.$i];
for ($i = 1; $i < 7; $i++)
if ($quest->template['RewardChoiceItemId'.$i])
$items[] = $quest->template['RewardChoiceItemId'.$i];
if ($this->curTpl['RewardChoiceItemId'.$i] > 0)
$items[] = $this->curTpl['RewardChoiceItemId'.$i];
// spells
if ($quest->template['RewardSpell'])
$spells[] = $quest->template['RewardSpell'];
if ($this->curTpl['RewardSpell'] > 0)
$spells[] = $this->curTpl['RewardSpell'];
if ($quest->template['RewardSpellCast'])
$spells[] = $quest->template['RewardSpellCast'];
if ($this->curTpl['RewardSpellCast'] > 0)
$spells[] = $this->curTpl['RewardSpellCast'];
// titles
if ($quest->template['RewardTitleId'])
$titles[] = $quest->template['RewardTitleId'];
if ($this->curTpl['RewardTitleId'] > 0)
$titles[] = $this->curTpl['RewardTitleId'];
}
if (!empty($items))
{
$items = new ItemList(array(['i.entry', $items]));
$items->addGlobalsToJScript($gItems);
}
if ($items)
(new ItemList(array(['i.entry', $items])))->addGlobalsToJscript($refs);
if (!empty($spells))
{
$spells = new SpellList(array(['id', $spells]));
$spells->addGlobalsToJScript($gSpells);
}
if ($spells)
(new SpellList(array(['Id', $spells])))->addGlobalsToJscript($refs);
if (!empty($titles))
{
$titles = new TitleList(array(['id', $titles]));
$titles->addGlobalsToJScript($gTitles);
}
if ($titles)
(new TitleList(array(['Id', $titles])))->addGlobalsToJscript($refs);
}
public function renderTooltip()
{
// todo
}
public function addGlobalsToJScript(&$refs)
{
// todo
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,45 +3,57 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class Title extends BaseType
class TitleList extends BaseType
{
public $name = [];
public $source = [];
private $sources = [];
protected $setupQuery = "SELECT * FROM ?_titles WHERE `Id` = ?";
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
$this->name[GENDER_MALE] = Util::localizedString($this->template, 'male');
if ($this->template['female_loc0'] || $this->template['female_loc'.User::$localeId])
$this->name[GENDER_FEMALE] = Util::localizedString($this->template, 'female');
// preparse sources
if (!empty($this->template['source']))
while ($this->iterate())
{
$sources = explode(' ', $this->template['source']);
foreach ($sources as $src)
// overwrite names with gender-speciffics
$this->names[$this->Id][GENDER_MALE] = Util::localizedString($this->curTpl, 'male');
if ($this->curTpl['female_loc0'] || $this->curTpl['female_loc'.User::$localeId])
$this->names[$this->Id][GENDER_FEMALE] = Util::localizedString($this->curTpl, 'female');
// preparse sources
if (!empty($this->curTpl['source']))
{
$src = explode(':', $src);
$this->source[$src[0]][] = $src[1];
$sources = explode(' ', $this->curTpl['source']);
foreach ($sources as $src)
{
$src = explode(':', $src);
$this->sources[$this->Id][$src[0]][] = $src[1];
}
}
}
}
public function getListviewData()
{
$data = array(
'id' => $this->Id,
'name' => $this->name[GENDER_MALE],
'side' => $this->template['side'],
'gender' => $this->template['gender'],
'expansion' => $this->template['expansion'],
'category' => $this->template['category'],
'source' => $this->source
);
$data = [];
$this->createSource();
while ($this->iterate())
{
$data[$this->Id] = array(
'Id' => $this->Id,
'name' => $this->names[$this->Id][GENDER_MALE],
'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 (isset($this->name[GENDER_FEMALE]))
$data['namefemale'] = $this->name[GENDER_FEMALE];
@@ -49,27 +61,77 @@ class Title extends BaseType
return $data;
}
public function addGlobalsToJScript(&$gTitles)
public function addGlobalsToJscript(&$refs)
{
$gTitles[$this->Id] = ['name' => Util::jsEscape($this->name[GENDER_MALE])];
if (!isset($refs['gTitles']))
$refs['gTitles'] = [];
if (isset($this->name[GENDER_FEMALE]))
$gTitles[$this->Id]['namefemale'] = Util::jsEscape($this->name[GENDER_FEMALE]);
while ($this->iterate())
{
$refs['gTitles'][$this->Id]['name'] = Util::jsEscape($this->names[$this->Id][GENDER_MALE]);
return true;
if (isset($this->names[$this->Id][GENDER_FEMALE]))
$refs['gTitles'][$this->Id]['namefemale'] = Util::jsEscape($this->names[$this->Id][GENDER_FEMALE]);
}
}
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)
{
return str_replace('%s', '<span class="q0">&lt;Name&gt;</span>', $this->name[$gender]);
return str_replace('%s', '<span class="q0">&lt;'.Lang::$main['name'].'&gt;</span>', $this->name[$gender]);
}
}
class TitleList extends BaseTypeList
{
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_titles WHERE [cond] ORDER BY Id ASC';
public function addRewardsToJScript(&$ref) { }
public function renderTooltip() { }
}
?>

View File

@@ -3,7 +3,7 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class WorldEvent
class WorldEvent extends BaseType
{
public static function getName($id)

View File

@@ -19,7 +19,7 @@ define('TYPE_FACTION', 8);
define('TYPE_PET', 9);
define('TYPE_ACHIEVEMENT', 10);
define('TYPE_TITLE', 11);
define('TYPE_EVENT', 12);
define('TYPE_WORLDEVENT', 12);
define('TYPE_CLASS', 13);
define('TYPE_RACE', 14);
define('TYPE_SKILL', 15);
@@ -33,8 +33,8 @@ define('CACHETYPE_SEARCH', 3);
define('SEARCH_TYPE_REGULAR', 0x10000000);
define('SEARCH_TYPE_OPEN', 0x20000000);
define('SEARCH_TYPE_JSON', 0x40000000);
define('SEARCH_MASK_OPEN', 0x03FFFFFF);
define('SEARCH_MASK_ALL', 0x03FFFFFF);
define('SEARCH_MASK_OPEN', 0x017F807F); // open search
define('SEARCH_MASK_ALL', 0x07FFFFFF); // normal search
// Databases
define('DB_AOWOW', 0);
@@ -94,6 +94,12 @@ define('LOCALE_DE', 3);
define('LOCALE_ES', 6);
define('LOCALE_RU', 8);
// Additional info in item-listviews
define('ITEMINFO_JSON', 0x1);
define('ITEMINFO_SUBITEMS', 0x2);
define('ITEMINFO_VENDOR', 0x4);
define('ITEMINFO_LOOT', 0x8);
/*
* Game
*/
@@ -185,6 +191,7 @@ define('SPELL_SCHOOL_NATURE', 3);
define('SPELL_SCHOOL_FROST', 4);
define('SPELL_SCHOOL_SHADOW', 5);
define('SPELL_SCHOOL_ARCANE', 6);
define('SPELL_ALL_SCHOOLS', 0x7F);
// CharacterSlot
define('SLOT_HEAD', 0);

View File

@@ -20,7 +20,7 @@ require 'includes/class.database.php';
// autoload any List-Classes
spl_autoload_register(function ($class) {
if (!strpos($class, 'Mysql') && !strpos($class, 'Filter'))
if (strpos($class, 'List'))
require 'includes/class.'.strtr($class, ['List' => '']).'.php';
});
@@ -93,7 +93,7 @@ class Smarty_AoWoW extends Smarty
if (!$cache)
return false;
$cache = explode("\n", $cache, 2);
$cache = explode("\n", $cache);
@list($time, $rev) = explode(' ', $cache[0]);
$expireTime = $time + $this->config['page']['cacheTimer'];

View File

@@ -3,48 +3,19 @@
if (!defined('AOWOW_REVISION'))
die('invalid access');
class BaseType
abstract class BaseType
{
public $template = null;
public $Id = 0;
protected $setupQuery = '';
public function __construct($data)
{
if (!$this->setupQuery)
return false;
if (is_array($data))
$this->template = $data;
else
$this->template = DB::Aowow()->SelectRow($this->setupQuery, intVal($data));
if (empty($this->template))
{
$this->template = null;
return false;
}
$this->Id = isset($this->template['Id']) ? (int)$this->template['Id'] : (int)$this->template['entry'];
}
// should return data required to display a listview of any kind
public function getListviewData() { }
// should return data to extend global js variables for a certain type (e.g. g_items)
public function addGlobalsToJScript(&$ref) { }
// should return data to extend global js variables for the rewards provided by this type (e.g. g_titles)
public function addRewardsToJscript(&$ref1, &$ref2 = null, &$ref3 = null) { }
}
class BaseTypeList
{
public $container = [];
public $filter = null;
public $names = [];
public $Id = 0;
public $matches = 0; // total matches unaffected by sqlLimit in config
public $error = true;
protected $templates = [];
protected $curTpl = []; // lets iterate!
protected $filter = null;
protected $setupQuery = '';
protected $matchQuery = '';
/*
* condition as array [field, value, operator]
@@ -56,19 +27,34 @@ class BaseTypeList
* ! - negated default value (NOT LIKE; <>; NOT IN)
* condition as str
* defines linking (AND || OR)
* condition as int
* defines LIMIT
*
* example:
* array(['id', 45], ['name', 'test', '!'], 'OR')
* array(['id', 45], ['name', 'test', '!'], 'OR', 5)
* results in
* WHERE id = 45 OR name NOT LIKE %test%;
* WHERE id = 45 OR name NOT LIKE %test% LIMIT 5;
*/
public function __construct($conditions)
public function __construct($conditions = [])
{
if (!$this->setupQuery)
return false;
global $AoWoWconf; // yes i hate myself..
$sql = [];
$linking = ' AND ';
$sql = [];
$linking = ' AND ';
$limit = ' LIMIT '.$AoWoWconf['sqlLimit'];
$className = strtr(get_class($this), ['List' => '']);
if (!$this->setupQuery || !$this->matchQuery)
return;
// may be called without filtering
if (class_exists($className.'Filter'))
{
$fiName = $className.'Filter';
$this->filter = new $fiName();
if ($this->filter->init() === false)
return;
}
foreach ($conditions as $c)
{
@@ -90,6 +76,9 @@ class BaseTypeList
else
continue;
if (isset($c[2]) && $c[2] != '!')
$op = $c[2];
if (is_array($c[1]))
{
$op = (isset($c[2]) && $c[2] == '!') ? 'NOT IN' : 'IN';
@@ -109,52 +98,84 @@ class BaseTypeList
else
continue;
if (isset($c[2]) && $c[2] != '!')
$op = $c[2];
$sql[] = $field.' '.$op.' '.$val;
}
else if (is_string($c))
$linking = $c == 'OR' ? ' OR ' : ' AND ';
else
$linking = $c == 'AND' ? ' AND ' : ' OR ';
else if (is_int($c))
$limit = $c > 0 ? ' LIMIT '.$c : '';
continue; // ignore other possibilities
}
// todo: add strings propperly without them being escaped by simpleDB..?
$this->setupQuery = str_replace('[filter]', $this->filter && $this->filter->buildFilterQuery() ? $this->filter->query.' AND ' : NULL, $this->setupQuery);
$this->setupQuery = str_replace('[cond]', empty($sql) ? '1' : '('.implode($linking, $sql).')', $this->setupQuery);
$this->setupQuery = str_replace('[filter]', $this->filter && $this->filter->buildFilterQuery() ? $this->filter->query.' AND ' : NULL, $this->setupQuery);
$this->setupQuery = str_replace('[cond]', empty($sql) ? '1' : '('.implode($linking, $sql).')', $this->setupQuery);
$this->setupQuery .= $limit;
$rows = DB::Aowow()->Select($this->setupQuery);
$className = str_replace('List', '', get_class($this));
$this->matchQuery = str_replace('[filter]', $this->filter && $this->filter->buildFilterQuery() ? $this->filter->query.' AND ' : NULL, $this->matchQuery);
$this->matchQuery = str_replace('[cond]', empty($sql) ? '1' : '('.implode($linking, $sql).')', $this->matchQuery);
foreach ($rows as $k => $row)
$this->container[$k] = new $className($row); // free dirty mindfuck galore here...
$rows = DB::Aowow()->Select($this->setupQuery);
if (!$rows)
return;
$this->matches = DB::Aowow()->SelectCell($this->matchQuery);
foreach ($rows as $k => $tpl)
{
$this->names[$k] = Util::localizedString($tpl, Util::getNameFieldName($tpl));
$this->templates[$k] = $tpl;
}
$this->reset();
$this->error = false;
}
public function getListviewData()
public function iterate($qty = 1)
{
$data = [];
// no extra queries required, just call recursively
foreach ($this->container as $type)
$data[] = $type->getListviewData();
if (!$this->curTpl) // exceeded end of line .. array .. in last iteration
reset($this->templates);
return $data;
$this->curTpl = current($this->templates);
$field = $this->curTpl ? Util::getIdFieldName($this->curTpl) : null;
$this->Id = $this->curTpl ? $this->curTpl[$field] : 0;
while ($qty--)
next($this->templates);
return $this->Id;
}
public function addGlobalsToJScript(&$ref)
public function reset()
{
// no extra queries required, just call recursively
foreach ($this->container as $type)
$type->addGlobalsToJScript($ref);
$this->curTpl = reset($this->templates);
$this->Id = $this->curTpl[Util::getIdFieldName($this->curTpl)];
}
public function addRewardsToJScript(&$ref1, &$ref2 = null, &$ref3 = null)
// read-access to templates
public function getField($field)
{
// no extra queries required, just call recursively
foreach ($this->container as $type)
$type->addRewardsToJScript($ref1, $ref2, $ref3);
if (!$this->curTpl || !isset($this->curTpl[$field]))
return null;
return $this->curTpl[$field];
}
// should return data required to display a listview of any kind
// this is a rudimentary example, that will not suffice for most Types
abstract public function getListviewData();
// should return data to extend global js variables for a certain type (e.g. g_items)
abstract public function addGlobalsToJScript(&$ref);
// should return data to extend global js variables for the rewards provided by this type (e.g. g_titles)
// rewards will not always be required and only by Achievement and Quest .. but yeah.. maybe it should be merged with addGlobalsToJScript
abstract public function addRewardsToJScript(&$ref);
// NPC, GO, Item, Quest, Spell, Achievement, Profile would require this
abstract public function renderTooltip();
}
class Lang
@@ -234,7 +255,7 @@ class Lang
public static function getMagicSchools($schoolMask)
{
$schoolMask &= 0x7F; // clamp to available schools..
$schoolMask &= SPELL_ALL_SCHOOLS; // clamp to available schools..
$tmp = [];
$i = 1;
@@ -335,7 +356,7 @@ class Util
'enus', null, 'frfr', 'dede', null, null, 'eses', null, 'ruru'
);
private static $typeStrings = array( // zero-indexed
public static $typeStrings = array( // zero-indexed
null, 'npc', 'object', 'item', 'itemset', 'quest', 'spell', 'zone', 'faction',
'pet', 'achievement', 'title', 'event', 'class', 'race', 'skill', null, 'currency'
);
@@ -1055,10 +1076,10 @@ class Util
return strtr(trim($string), array(
'\\' => '\\\\',
"'" => "\\'",
'"' => '\\"',
// '"' => '\\"',
"\r" => '\\r',
"\n" => '\\n',
'</' => '<\/',
// '</' => '<\/',
));
}
@@ -1070,7 +1091,7 @@ class Util
if (!empty($data[$field.'_loc'.User::$localeId]))
return $data[$field.'_loc'.User::$localeId];
// locale not enUS; aowow-type localization available
// locale not enUS; aowow-type localization available; add brackets
else if (User::$localeId != LOCALE_EN && isset($data[$field.'_loc0']) && !empty($data[$field.'_loc0']))
return '['.$data[$field.'_loc0'].']';
@@ -1124,7 +1145,7 @@ class Util
return sprintf(Lang::$item['ratingString'], '<!--rtg%'.$type.'-->' . $result, '<!--lvl-->' . $level);
}
public static function powerUseLocale($domain)
public static function powerUseLocale($domain = 'www')
{
foreach (Util::$localeStrings as $k => $v)
{
@@ -1138,7 +1159,6 @@ class Util
if ($domain == 'www')
{
/* todo: dont .. should use locale given by inclusion of aowowPower .. should be fixed in aowowPower.js */
User::useLocale(LOCALE_EN);
Lang::load(User::$localeString);
}
@@ -1172,8 +1192,9 @@ class Util
break;
case 3:
case 7:
$spl = new Spell($enchant['object'.$h]);
$spl = new SpellList(array(['Id', (int)$enchant['object'.$h]]));
$gain = $spl->getStatGain();
foreach ($gain as $k => $v) // array_merge screws up somehow...
@$jsonStats[$k] += $v;
break;
@@ -1219,6 +1240,35 @@ class Util
return $return;
}
// BaseType::_construct craaap!
// todo: unify names
public static function getNameFieldName($tpl)
{
if (isset($tpl['name']) || isset($tpl['name_loc0']))
return 'name';
else if (isset($tpl['title']) || isset($tpl['title_loc0']))
return 'title';
else if (isset($tpl['male']) || isset($tpl['male_loc']))
return 'male';
else
return null;
}
// BaseType::iterate craaaaaaaaap!!!
// todo: unify indizes
public static function getIdFieldName($tpl)
{
if (isset($tpl['entry']))
return 'entry';
else if (isset($tpl['Id']))
return 'Id';
else if (isset($tpl['ID']))
return 'ID';
else
return null;
}
}
?>

View File

@@ -96,12 +96,12 @@ if ($_type & 0x18) { // 3 | 4
$iList = new ItemList($conditions);
$items = [];
foreach ($iList->container as $id => $item)
while ($iList->iterate())
{
$item->getJsonStats($pieceAssoc);
$iList->extendJsonStats($pieceAssoc);
$stats = [];
foreach ($item->json as $k => $v)
foreach ($iList->json[$iList->Id] as $k => $v)
{
if (!$v && $k != 'classs' && $k != 'subclass')
continue;
@@ -109,10 +109,10 @@ if ($_type & 0x18) { // 3 | 4
$stats[] = is_numeric($v) || $v[0] == "{" ? '"'.$k.'":'.$v.'' : '"'.$k.'":"'.$v.'"';
}
foreach ($item->itemMods as $k => $v)
foreach ($iList->itemMods[$iList->Id] as $k => $v)
$stats[] = '"'.Util::$itemMods[$k].'":'.$v.'';
$items[$id] = "\t{".implode(',', $stats)."}";
$items[$iList->Id] = "\t{".implode(',', $stats)."}";
}
echo implode(",\n", $items)."\n],[\n";

View File

@@ -1,21 +1,21 @@
<?php
/*
enum(array( // AcctError
'ACCT_USERNAME_LENGTH' => 'activate_usernamelength',
'ACCT_PASSWORD_LENGTH' => 'activate_passwordlength',
'ACCT_USERNAME_SYMBOLS' => 'activate_invalidusername',
'ACCT_PASSWORD_SYMBOLS' => 'activate_invalidpassword',
'ACCT_EMAIL_SYMBOLS' => 'signup_emailinvalid',
'ACCT_USERNAME_LENGTH' => 'activate_usernamelength',
'ACCT_PASSWORD_LENGTH' => 'activate_passwordlength',
'ACCT_USERNAME_SYMBOLS' => 'activate_invalidusername',
'ACCT_PASSWORD_SYMBOLS' => 'activate_invalidpassword',
'ACCT_EMAIL_SYMBOLS' => 'signup_emailinvalid',
'ACCT_PASSWORDS_NOT_EQUAL' => 'signup_passwordsnotequal',
'ACCT_USERNAME_EXISTS' => 'activate_usernameinuse',
'ACCT_NO_SUCH_ACCT' => 'signin_un_or_pass_fail',
'ACCT_PASSWORDS_NOT_EQUAL' => 'signup_passwordsnotequal',
'ACCT_USERNAME_EXISTS' => 'activate_usernameinuse',
'ACCT_NO_SUCH_ACCT' => 'signin_un_or_pass_fail',
'ACCT_IP_LOCKED' => 'signin_ip_locked',
'ACCT_SIGNUP_BLOCKED' => 'signup_blocked',
'ACCT_SIGNIN_BLOCKED' => 'signin_blocked',
'ACCT_SIGNUP_BLOCKED' => 'signup_blocked',
'ACCT_SIGNIN_BLOCKED' => 'signin_blocked',
'ACCT_INTERNAL_ERROR' => 'internal_error',
'ACCT_INTERNAL_ERROR' => 'internal_error',
));
enum(array( // UserPropsLimits
@@ -97,7 +97,8 @@ function signin()
function signup()
{
/* $username = Get(GET_STRING, 'username', 'POST');
/*
$username = Get(GET_STRING, 'username', 'POST');
$password = Get(GET_STRING, 'password', 'POST');
$pwd2 = Get(GET_STRING, 'password2', 'POST');
$email = Get(GET_STRING, 'email', 'POST');

View File

@@ -4,10 +4,10 @@ if (!defined('AOWOW_REVISION'))
die('invalid access');
$pageData = array(
'summary' => '[]',
'items' => []
'items' => null,
'summary' => '[]'
);
$compareString = '';
$compareString = '';
// prefer $_GET over $_COOKIE
if (!empty($_GET['compare']))
@@ -48,22 +48,23 @@ if ($compareString)
$pageData['summary'] = "[".implode(',', $outSet)."]";
$iList = new ItemList(array(['i.entry', $items]));
foreach ($iList->container as $item)
while ($iList->iterate())
{
$item->getJsonStats();
$iList->extendJsonStats();
$stats = [];
foreach ($item->json as $k => $v)
foreach ($iList->json[$iList->Id] as $k => $v)
$stats[] = is_numeric($v) || $v[0] == "{" ? '"'.$k.'":'.$v.'' : '"'.$k.'":"'.$v.'"';
foreach ($item->itemMods as $k => $v)
foreach ($iList->itemMods[$iList->Id] as $k => $v)
if ($v)
$stats[] = '"'.Util::$itemMods[$k].'":'.$v;
$pageData['items'][] = [
$item->Id,
Util::jsEscape(Util::localizedString($item->template, 'name')),
$item->template['Quality'],
$item->template['icon'],
$iList->Id,
Util::jsEscape($iList->names[$iList->Id]),
$iList->getField('Quality'),
$iList->getField('icon'),
"{".implode(",", $stats)."}"
];
}

View File

@@ -11,20 +11,18 @@ if (!defined('AOWOW_REVISION'))
// require 'includes/class.community.php'; // wo dont need those .. yet
$id = intVal($pageParam);
$item = new Item($id);
$item = new ItemList(array(['i.entry', $id]));
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_ITEM, $id, -1, User::$localeId]);
if (isset($_GET['xml']))
{
// output item info as xml
// why should i implement this..?
}
else if (isset($_GET['power']))
die('unsupported, as i do not see the point');
if (isset($_GET['power']))
{
header('Content-type: application/x-javascript; charsetUTF-8');
Util::powerUseLocale($_GET['domain']);
Util::powerUseLocale(@$_GET['domain']);
$enh = [];
$itemString = $id;
@@ -50,21 +48,20 @@ else if (isset($_GET['power']))
$itemString .= 's';
}
// : are not accepted in filenames
$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_ITEM, str_replace(':', ',', $itemString), -1, User::$localeId]);
// output json for tooltips
if (!$smarty->loadCache($cacheKeyTooltip, $x))
{
if (!$item->template)
if ($item->error)
die('$WowheadPower.registerItem(\''.$itemString.'\', '.User::$localeId.', {})');
$item->createTooltip($enh);
$item->renderTooltip($enh);
$x .= '$WowheadPower.registerItem(\''.$itemString.'\', '.User::$localeId.", {\n";
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($item->name)."',\n";
$x .= "\tquality: ".$item->template['Quality'].",\n";
$x .= "\ticon: '".Util::jsEscape($item->template['icon'])."',\n";
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($item->tooltip)."'\n";
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($item->names[$item->Id])."',\n";
$x .= "\tquality: ".$item->getField('Quality').",\n";
$x .= "\ticon: '".Util::jsEscape($item->getField('icon'))."',\n";
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($item->tooltip[$item->Id])."'\n";
$x .= "});";
$smarty->saveCache($cacheKeyTooltip, $x);

View File

@@ -8,33 +8,33 @@ if (!defined('AOWOW_REVISION'))
// require 'includes/allquests.php';
// require 'includes/class.community.php'; // not needed .. yet
$id = intVal($pageParam);
$spell = new Spell($id);
$Id = intVal($pageParam);
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_SPELL, $id, -1, User::$localeId]);
$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_SPELL, $id, -1, User::$localeId]);
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_SPELL, $Id, -1, User::$localeId]);
$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_SPELL, $Id, -1, User::$localeId]);
if (isset($_GET['power']))
{
header('Content-type: application/x-javascript; charsetUTF-8');
Util::powerUseLocale($_GET['domain']);
Util::powerUseLocale(@$_GET['domain']);
if (!$smarty->loadCache($cacheKeyTooltip, $x))
{
$spell = new Spell($id);
if (!$spell->template)
die('$WowheadPower.registerSpell(\''.$id.'\', '.User::$localeId.', {})');
$spell = new SpellList(array(['Id', $Id]));
$x = '$WowheadPower.registerSpell('.$id.', '.User::$localeId.",{\n";
if ($n = Util::localizedString($spell->template, 'spellname'))
if ($spell->error)
die('$WowheadPower.registerSpell('.$Id.', '.User::$localeId.', {});');
$x = '$WowheadPower.registerSpell('.$Id.', '.User::$localeId.", {\n";
if ($n = $spell->names[$Id])
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($n)."',\n";
if ($i = $spell->template['iconString'])
if ($i = $spell->getField('iconString'))
$x .= "\ticon: '".Util::jsEscape($i)."',\n";
if ($spell->getTooltip())
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($spell->tooltip)."'";
if ($spell->getBuff())
$x .= ",\n\tbuff_".User::$localeString.": '".Util::jsEscape($spell->buff)."'\n";
if ($t = $spell->renderTooltip($Id))
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($t)."'";
if ($b = $spell->renderBuff($Id))
$x .= ",\n\tbuff_".User::$localeString.": '".Util::jsEscape($b)."'\n";
$x .= '});';
$smarty->saveCache($cacheKeyTooltip, $x);
@@ -42,16 +42,14 @@ if (isset($_GET['power']))
die($x);
}
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{
$spell = new SpellList(array(['Id', $Id]));
// v there be dragons v
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{
unset($spell);
// Spelldata
if ($spellObj = new Spell($id))
if ($spellObj = new SpellList(array(['Id', $Id])))
{
$row = $spellObj->template; // equivalent to 5 layers of panzertape
@@ -142,7 +140,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
$spell['stances'] = Lang::getStances($row['stanceMask']);
// Btt - Buff TollTip
if ($buff = $spellObj->getBuff())
if ($buff = $spellObj->renderBuff())
$spell['btt'] = $buff;
// Iterate through all effects:
@@ -566,7 +564,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
FROM ?_spellicons s, ?_achievementcriteria c, ?_achievement a
LEFT JOIN (?_zones z) ON a.map != -1 AND a.map = z.mapID
WHERE
a.iconId = s.id
a.icon = s.id
AND a.id = c.refAchievement
AND c.type IN (?a)
AND c.value1 = ?d

View File

@@ -12,43 +12,54 @@ $cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_TITLE, $Id, -1, User::$locale
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{
$title = new Title($Id);
if ($title->template)
$title = new TitleList(array(['Id', $Id]));
if ($title->error)
{
$title->addGlobalsToJScript($pageData['gTitles']);
$smarty->updatePageVars(array(
'subject' => ucfirst(Lang::$game['title']),
'id' => $Id,
'notFound' => sprintf(Lang::$main['pageNotFound'], Lang::$game['title']),
));
$smarty->assign('lang', Lang::$main);
$smarty->display('404.tpl');
exit();
}
else
{
$title->addGlobalsToJscript($pageData);
$infobox = [];
$colon = User::$localeId == LOCALE_FR ? ' : ' : ': '; // Je suis un prick! <_<
if ($title->template['side'] == 1)
if ($title->getField('side') == 1)
$infobox[] = Lang::$main['side'].$colon.'[span class=alliance-icon]'.Lang::$game['alliance'].'[/span]';
else if ($title->template['side'] == 2)
else if ($title->getField('side') == 2)
$infobox[] = Lang::$main['side'].$colon.'[span class=horde-icon]'.Lang::$game['horde'].'[/span]';
else
$infobox[] = Lang::$main['side'].$colon.Lang::$main['both'];
if ($title->template['gender'])
$infobox[] = Lang::$main['gender'].$colon.'[span class='.($title->template['gender'] == 2 ? 'female' : 'male').'-icon]'.Lang::$main['sex'][$title->template['gender']].'[/span]';
if ($g = $title->getField('gender'))
$infobox[] = Lang::$main['gender'].$colon.'[span class='.($g == 2 ? 'female' : 'male').'-icon]'.Lang::$main['sex'][$g].'[/span]';
if ($title->template['eventId'])
$infobox[] = Lang::$game['eventShort'].$colon.'[url=?event='.$title->template['eventId'].']'.WorldEvent::getName($title->template['eventId']).'[/url]';
if ($e = $title->getField('eventId'))
$infobox[] = Lang::$game['eventShort'].$colon.'[url=?event='.$e.']'.WorldEvent::getName($e).'[/url]';
$pageData = array(
'page' => array(
'name' => $title->getHtmlizedName(),
'id' => $title->Id,
'expansion' => Util::$expansionString[$title->template['expansion']]
'id' => $Id,
'expansion' => Util::$expansionString[$title->getField('expansion')]
),
'infobox' => '[li][ul]'.implode('[/ul][ul]', $infobox).'[/ul][/li]',
);
foreach ($title->source as $type => $entries)
foreach ($title->sources[$Id] as $type => $entries)
{
// todo: hidden-/visibleCols by actual use
switch ($type)
{
case 4:
$quests = new QuestList(array(['id', $entries]));
$quests->addRewardsToJscript($pageData['gItems'], $pageData['gSpells'], $pageData['gTitles']);
$quests = new QuestList(array(['Id', $entries]));
$quests->addRewardsToJscript($pageData);
$pageData['page']['questReward'] = $quests->getListviewData();
$pageData['page']['questParams'] = array(
@@ -59,9 +70,9 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
);
break;
case 12:
$acvs = new AchievementList(array(['id', $entries]));
$acvs->addGlobalsToJScript($pageData['gAchievements']);
$acvs->addRewardsToJscript($pageData['gItems'], $pageData['gTitles']);
$acvs = new AchievementList(array(['Id', $entries]));
$acvs->addGlobalsToJscript($pageData);
$acvs->addRewardsToJscript($pageData);
$pageData['page']['acvReward'] = $acvs->getListviewData();
$pageData['page']['acvParams'] = array(
@@ -76,30 +87,21 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
}
}
$pageData['title'] = ucFirst(trim(str_replace('%s', '', str_replace(',', '', $title->name[0]))));
$pageData['path'] = '[0, 10, '.$title->getField('category').']';
$smarty->saveCache($cacheKeyPage, $pageData);
}
else
{
$smarty->updatePageVars(array(
'subject' => ucfirst(Lang::$game['title']),
'id' => $Id,
'notFound' => sprintf(Lang::$main['pageNotFound'], Lang::$game['title']),
));
$smarty->assign('lang', Lang::$main);
$smarty->display('404.tpl');
exit();
}
}
$smarty->updatePageVars(array(
'title' => $pageData['title']." - ".ucfirst(Lang::$game['title']),
'path' => "[0, 10, ".$title->template['category']."]",
'path' => $pageData['path'],
'tab' => 0, // for g_initHeader($tab)
'type' => TYPE_TITLE, // 11:Titles
'typeId' => $Id
));
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "title" OR page = "*")');
foreach ($announcements as $k => $v)

View File

@@ -19,65 +19,14 @@ if (!$smarty->loadCache($cacheKey, $pageData))
$titles = new TitleList(isset($cat) ? array(['category', (int)$cat]) : []);
$listview = $titles->getListviewData();
$sources = array(
4 => [], // Quest
12 => [], // Achievement
13 => [] // DB-Text
$pageData = array(
'page' => $listview,
'params' => array(
'parent' => false,
'tabs' => false
)
);
// parse sources
foreach ($listview as $lvTitle)
{
if(!isset($lvTitle['source']))
continue;
foreach (array_keys($sources) as $srcKey)
if (isset($lvTitle['source'][$srcKey]))
$sources[$srcKey] = array_merge($sources[$srcKey], $lvTitle['source'][$srcKey]);
}
// replace with suitable objects
if (!empty($sources[4]))
$sources[4] = new QuestList(array(['Id', $sources[4]]));
if (!empty($sources[12]))
$sources[12] = new AchievementList(array(['Id', $sources[12]]));
if (!empty($sources[13]))
$sources[13] = DB::Aowow()->SELECT('SELECT *, Id AS ARRAY_KEY FROM ?_sourceStrings WHERE Id IN (?a)', $sources[13]);
foreach ($listview as $k => $lvTitle)
{
if(!isset($lvTitle['source']))
continue;
// Quest-source
if (isset($lvTitle['source'][4]))
{
$ids = $lvTitle['source'][4];
$listview[$k]['source'][4] = [];
foreach ($ids as $id)
$listview[$k]['source'][4][] = $sources[4]->container[$id]->getSourceData();
}
// Achievement-source
if (isset($lvTitle['source'][12]))
{
$ids = $lvTitle['source'][12];
$listview[$k]['source'][12] = [];
foreach ($ids as $id)
$listview[$k]['source'][12][] = $sources[12]->container[$id]->getSourceData();
}
// other source (only one item possible, so no iteration needed)
if (isset($lvTitle['source'][13]))
$listview[$k]['source'][13] = [$sources[13][$lvTitle['source'][13][0]]];
$listview[$k]['source'] = json_encode($listview[$k]['source']);
}
$pageData['page'] = $listview;
$smarty->saveCache($cacheKey, $pageData);
}

View File

@@ -55,7 +55,7 @@ if (!defined('AOWOW_REVISION'))
// from g_item_slots: 13:"One-Hand", 26:"Ranged", 17:"Two-Hand",
$slotPointer = [13, 17, 26, 26, 13, 17, 17, 13, 17, null, 17, null, null, 13, null, 13, null, null, null, null, 17];
$locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU];
$enchantSpells = new SpellList([['effect1Id', '=', '53'], ['name_loc0', 'NOT LIKE', 'QA%']]); // enchantItemPermanent && !qualityAssurance
$enchantSpells = new SpellList([['effect1Id', 53], ['name_loc0', 'QA%', '!']]); // enchantItemPermanent && !qualityAssurance
$castItems = [];
$jsonEnchants = [];
@@ -72,29 +72,29 @@ if (!defined('AOWOW_REVISION'))
$enchantsOut = [];
foreach ($enchantSpells->spellList as $spl)
while ($enchantSpells->iterate())
{
$enchant = DB::Aowow()->SelectRow('SELECT * FROM ?_itemEnchantment WHERE Id = ?d', $spl->template['effect1MiscValue']);
$enchant = DB::Aowow()->SelectRow('SELECT * FROM ?_itemEnchantment WHERE Id = ?d', $enchantSpells->getField('effect1MiscValue'));
if (!$enchant) // 'shouldn't' happen
continue;
// slots have to be recalculated
$slot = 0;
if ($spl->template['equippedItemClass'] == 4) // armor
if ($enchantSpells->getField('equippedItemClass') == 4) // armor
{
if ($invType = $spl->template['equippedItemInventoryTypeMask'])
$slot = $spl->template['equippedItemInventoryTypeMask'] >> 1;
if ($invType = $enchantSpells->getField('equippedItemInventoryTypeMask'))
$slot = $enchantSpells->getField('equippedItemInventoryTypeMask') >> 1;
else /* if (equippedItemSubClassMask == 64) */ // shields have it their own way <_<
$slot = (1 << (14 - 1));
}
else if ($spl->template['equippedItemClass'] == 2) // weapon
else if ($enchantSpells->getField('equippedItemClass') == 2) // weapon
{
foreach ($slotPointer as $i => $sp)
{
if (!$sp)
continue;
if ((1 << $i) & $spl->template['equippedItemSubClassMask'])
if ((1 << $i) & $enchantSpells->getField('equippedItemSubClassMask'))
{
if ($sp == 13) // also mainHand & offHand *siiigh*
$slot |= ((1 << (21 - 1)) | (1 << (22 - 1)));
@@ -112,7 +112,7 @@ if (!defined('AOWOW_REVISION'))
$ench = array(
'name' => [], // set by skill or item
'quality' => -1, // modified if item
'icon' => strToLower($spl->template['iconString']), // item over spell
'icon' => strToLower($enchantSpells->getField('iconString')), // item over spell
'source' => [], // <0: item; >0:spell
'skill' => -1, // modified if skill
'slots' => [], // determied per spell but set per item
@@ -132,37 +132,38 @@ if (!defined('AOWOW_REVISION'))
$ench['jsonequip']['reqlevel'] = $enchant['requiredLevel'];
// check if the spell has an entry in skill_line_ability -> Source:Profession
if ($skill = DB::Aowow()->SelectCell('SELECT skillId FROM ?_skill_line_ability WHERE spellId = ?d', $spl->Id))
if ($skill = DB::Aowow()->SelectCell('SELECT skillId FROM ?_skill_line_ability WHERE spellId = ?d', $enchantSpells->Id))
{
$ench['name'][] = Util::jsEscape(Util::localizedString($spl->template, 'name'));
$ench['source'][] = $spl->Id;
$ench['name'][] = Util::jsEscape($enchantSpells->names[$enchantSpells->Id]));
$ench['source'][] = $enchantSpells->Id;
$ench['skill'] = $skill;
$ench['slots'][] = $slot;
}
// check if this item can be cast via item -> Source:Item
if (!isset($castItems[$spl->Id]))
$castItems[$spl->Id] = new ItemList([['spellid_1', '=', $spl->Id], ['name', 'NOT LIKE', 'Scroll of Enchant%']]); // do not reuse enchantment scrolls
if (!isset($castItems[$enchantSpells->Id]))
$castItems[$enchantSpells->Id] = new ItemList([['spellid_1', $enchantSpells->Id], ['name', 'Scroll of Enchant%', '!']]); // do not reuse enchantment scrolls
foreach ($castItems[$spl->Id]->container as $item)
$cI &= $castItems[$enchantSpells->Id]; // this construct is a bit .. unwieldy
while ($cI->iterate())
{
$ench['name'][] = Util::jsEscape(Util::localizedString($item->template, 'name'));
$ench['source'][] = -$item->Id;
$ench['icon'] = strTolower($item->template['icon']);
$ench['name'][] = Util::jsEscape($cI->names[$cI->Id]);
$ench['source'][] = -$cI->Id;
$ench['icon'] = strTolower($cI->getField('icon'));
$ench['slots'][] = $slot;
if ($item->template['Quality'] > $ench['quality'])
$ench['quality'] = $item->template['Quality'];
if ($cI->getField('Quality') > $ench['quality'])
$ench['quality'] = $cI->getField('Quality');
if ($item->template['AllowableClass'] > 0)
if ($cI->getField('AllowableClass') > 0)
{
$ench['classes'] = $item->template['AllowableClass'];
$ench['jsonequip']['classes'] = $item->template['AllowableClass'];
$ench['classes'] = $cI->getField('AllowableClass');
$ench['jsonequip']['classes'] = $cI->getField('AllowableClass');
}
if (!isset($ench['jsonequip']['reqlevel']))
if ($item->template['RequiredLevel'] > 0)
$ench['jsonequip']['reqlevel'] = $item->template['RequiredLevel'];
if ($cI->getField('RequiredLevel') > 0)
$ench['jsonequip']['reqlevel'] = $cI->getField('RequiredLevel');
}
// enchant spell not in use

View File

@@ -127,6 +127,13 @@ if (!defined('AOWOW_REVISION'))
echo "script set up in ".Util::execTime()."<br>\n";
$glyphSpells = [];
foreach ($glyphList as $pop)
if ($pop['glyphEffect'])
$glyphSpells[] = $pop['glyphEffect'];
$glyphSpells = new SpellList(array(['Id', $glyphSpells]));
foreach ($locales as $lId)
{
User::useLocale($lId);
@@ -138,16 +145,17 @@ if (!defined('AOWOW_REVISION'))
if (!$pop['glyphEffect'])
continue;
$spl = new Spell($pop['glyphEffect']);
while ($glyphSpells->Id != $pop['glyphEffect'])
$glyphSpells->iterate();
if ($spl->template['effect1Id'] != 6 && $spl->template['effect2Id'] != 6 && $spl->template['effect3Id'] != 6)
if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6)
continue;
if ($pop['itemId'] == 42958) // Crippling Poison has no skillLine.. oO => hardcode
{
$glyphsOut[$pop['itemId']] = array(
'name' => Util::jsEscape(Util::localizedString($pop, 'name')),
'description' => Util::jsEscape($spl->parseText()),
'description' => Util::jsEscape($glyphSpells->parseText()),
'icon' => 'ability_poisonsting',
'type' => 0,
'classs' => $pop['classs'],
@@ -158,7 +166,7 @@ if (!defined('AOWOW_REVISION'))
continue;
}
$description = $spl->parseText();
$description = $glyphSpells->parseText();
$spellFamily = $class2Family[$pop['classs']];
$classId = $pop['classs'] - 1;
$skill = 0;
@@ -181,11 +189,11 @@ if (!defined('AOWOW_REVISION'))
while (empty($icons) && $i < 3)
{
$i++;
$m1 = $spl->template['effect1SpellClassMask'.$l[$i]];
$m2 = $spl->template['effect2SpellClassMask'.$l[$i]];
$m3 = $spl->template['effect3SpellClassMask'.$l[$i]];
$m1 = $glyphSpells->getField('effect1SpellClassMask'.$l[$i]);
$m2 = $glyphSpells->getField('effect2SpellClassMask'.$l[$i]);
$m3 = $glyphSpells->getField('effect3SpellClassMask'.$l[$i]);
if ($spl->template['effect'.$i.'Id'] != 6 || (!$m1 && !$m2 && !$m3))
if ($glyphSpells->getField('effect'.$i.'Id') != 6 || (!$m1 && !$m2 && !$m3))
continue;
$where = "SpellFamilyId = ?d AND ((SpellFamilyFlags3 & 0xFFFFFFFF) & ?d OR (SpellFamilyFlags2 & 0xFFFFFFFF) & ?d OR (SpellFamilyFlags1 & 0xFFFFFFFF) & ?d)";

View File

@@ -113,7 +113,7 @@ if (!defined('AOWOW_REVISION'))
// costy and locale-independant -> cache
if (!isset($jsonBonus[$set['spell'.$i]]))
{
$bSpell = new Spell($set['spell'.$i]);
$bSpell = new SpellList(array(['Id', $set['spell'.$i]]));
$jsonBonus[$set['spell'.$i]] = $bSpell->getStatGain();
}

View File

@@ -114,12 +114,12 @@ if (!defined('AOWOW_REVISION'))
for ($k = 0; $k <= ($m - 1); $k++)
{
$tSpell = new Spell($talents[$j]['rank'.($k + 1)]);
$tSpell = new SpellList(array(['Id', $talents[$j]['rank'.($k + 1)]]));
$d[] = $tSpell->parseText();
$s[] = $talents[$j]['rank'.($k + 1)];
if ($talents[$j]['isSpell'])
$t[] = $tSpell->getTalentHead();
$t[] = $tSpell->getTalentHeadForCurrent();
}
if ($talents[$j]['dependsOn'])

View File

@@ -14,7 +14,7 @@
<div id="lv-titles" class="listview"></div>
<script type="text/javascript">
{include file='bricks/title_table.tpl' data=$data.page params=null}
{include file='bricks/title_table.tpl' data=$data.page params=$data.params}
</script>
<div class="clear"></div>