removing smarty - part VI

- rewrote currencies, achievements, events, factions
- GenericPage:
   * moved more checks from Util
   * structured and commented GenericPage to be easier to comprehend
   * added GenericPage::postCache() to modify cached data before display (e.g. update time for events)
- fixed:
   * parsing events from markdown (e.g. articles)
   * huge padding of minibox headings (css)
   * Loot passing jsGlobals to template
   * ItemList::getExtendedCost passing jsGlobals to template
   * categories for factions
   * conflicting GenericPage::$subject when displaying 'notFound'
   * load of typos
This commit is contained in:
Sarjuuk
2014-06-21 18:39:54 +02:00
parent 9c7c2e29b5
commit caa7a7e39f
33 changed files with 1969 additions and 1856 deletions

View File

@@ -16,6 +16,10 @@ trait DetailPage
// mode, type, typeId, localeId, category, filter // mode, type, typeId, localeId, category, filter
$key = [$this->mode, $this->type, $this->typeId, User::$localeId, '-1', '-1']; $key = [$this->mode, $this->type, $this->typeId, User::$localeId, '-1', '-1'];
// check for $this->enhancedTT from Item and apply
// foreach ($extra as $x)
// $key[] = (string)$x;
return implode('_', $key); return implode('_', $key);
} }
} }
@@ -65,10 +69,6 @@ class GenericPage
private $gUser = []; private $gUser = [];
private $community = ['co' => [], 'sc' => [], 'vi' => []]; private $community = ['co' => [], 'sc' => [], 'vi' => []];
protected function generatePath() {}
protected function generateTitle() {}
protected function generateContent() {}
public function __construct() public function __construct()
{ {
// restricted access // restricted access
@@ -87,118 +87,22 @@ class GenericPage
$this->mode = CACHETYPE_XML; $this->mode = CACHETYPE_XML;
else else
{ {
if (!$this->isValidPage() || !$this->tpl)
$this->error();
$this->gUser = User::getUserGlobals(); $this->gUser = User::getUserGlobals();
$this->gLocale = array( $this->gLocale = array(
'id' => User::$localeId, 'id' => User::$localeId,
'name' => User::$localeString 'name' => User::$localeString
); );
if (!$this->isValidPage() || !$this->tpl)
$this->error();
} }
} }
private function prepareContent() /**********/
{ /* Checks */
if (!$this->loadCache()) /**********/
{
// run generators
$this->addArticle();
$this->generatePath(); private function isSaneInclude($path, $file) // "template_exists"
$this->generateTitle();
$this->generateContent();
$this->applyGlobals();
$this->saveCache();
}
if (!empty($this->hasComContent))
$this->community = CommunityContent::getAll($this->type, $this->typeId);
$this->mysql = DB::Aowow()->getStatistics();
}
public function display($override = '')
{
if ($override)
{
$this->addAnnouncements();
include('template/pages/'.$override.'.tpl.php');
die();
}
else if ($this->mode == CACHETYPE_TOOLTIP)
{
if (!$this->loadCache($tt))
{
$tt = $this->generateTooltip();
$this->saveCache($tt);
}
header('Content-type: application/x-javascript; charsetUTF-8');
die($tt);
}
else if ($this->mode == CACHETYPE_XML)
{
if (!$this->loadCache($xml))
{
$xml = $this->generateXML();
$this->saveCache($xml);
}
header('Content-type: text/xml; charsetUTF-8');
die($xml);
}
else
{
$this->prepareContent();
if (!$this->isSaneInclude('template/pages/', $this->tpl))
die(User::isInGroup(U_GROUP_STAFF) ? 'Error: nonexistant template requested: template/pages/'.$this->tpl.'.tpl.php' : null);
$this->addAnnouncements();
include('template/pages/'.$this->tpl.'.tpl.php');
die();
}
}
public function gBrick($file, array $localVars = [])
{
foreach ($localVars as $n => $v)
$$n = $v;
if (!$this->isSaneInclude('template/globals/', $file))
echo !User::isInGroup(U_GROUP_STAFF) ? "\n\nError: nonexistant template requested: template/globals/".$file.".tpl.php\n\n" : null;
else
include('template/globals/'.$file.'.tpl.php');
}
public function brick($file, array $localVars = [])
{
foreach ($localVars as $n => $v)
$$n = $v;
if (!$this->isSaneInclude('template/bricks/', $file))
echo User::isInGroup(U_GROUP_STAFF) ? "\n\nError: nonexistant template requested: template/bricks/".$file.".tpl.php\n\n" : null;
else
include('template/bricks/'.$file.'.tpl.php');
}
public function lvBrick($file, array $localVars = [])
{
foreach ($localVars as $n => $v)
$$n = $v;
if (!$this->isSaneInclude('template/listviews/', $file))
echo User::isInGroup(U_GROUP_STAFF) ? "\n\nError: nonexistant template requested: template/listviews/".$file.".tpl.php\n\n" : null;
else
include('template/listviews/'.$file.'.tpl.php');
}
private function isSaneInclude($path, $file)
{ {
if (preg_match('/[^\w\-]/i', $file)) if (preg_match('/[^\w\-]/i', $file))
return false; return false;
@@ -209,17 +113,17 @@ class GenericPage
return true; return true;
} }
private function isValidPage() private function isValidPage() // has a valid combination of categories
{ {
if ($this->category === null || empty($this->validCats)) if (!isset($this->category) || empty($this->validCats))
return true; return true;
switch (count($this->category)) switch (count($this->category))
{ {
case 0: // no params works always case 0: // no params works always
return true; return true;
case 1: // null is avalid || value in a 1-dim-array || key in a n-dim-array case 1: // null is valid || value in a 1-dim-array || key for a n-dim-array
return $this->category[0] === null || in_array($this->category[0], $this->validCats) || (isset($this->validCats[$this->category[0]]) && is_array($this->validCats[$this->category[0]])); return $this->category[0] === null || in_array($this->category[0], $this->validCats) || !empty($this->validCats[$this->category[0]]);
case 2: // first param has to be a key. otherwise invalid case 2: // first param has to be a key. otherwise invalid
if (!isset($this->validCats[$this->category[0]])) if (!isset($this->validCats[$this->category[0]]))
return false; return false;
@@ -236,6 +140,40 @@ class GenericPage
return false; return false;
} }
/****************/
/* Prepare Page */
/****************/
private function prepareContent() // get from cache ?: run generators
{
if (!$this->loadCache())
{
$this->addArticle();
$this->generatePath();
$this->generateTitle();
$this->generateContent();
$this->applyGlobals();
$this->saveCache();
}
$this->gPageInfo = array( // varies slightly for special pages like maps, user-dashboard or profiler
'type' => $this->type,
'typeId' => $this->typeId,
'name' => $this->name
);
if (method_exists($this, 'postCache')) // e.g. update dates for events and such
$this->postCache();
if (!empty($this->hasComContent)) // get comments, screenshots, videos
$this->community = CommunityContent::getAll($this->type, $this->typeId);
$this->mysql = DB::Aowow()->getStatistics();
}
public function addJS($name, $unshift = false) public function addJS($name, $unshift = false)
{ {
if (is_array($name)) if (is_array($name))
@@ -268,7 +206,7 @@ class GenericPage
} }
} }
private function addArticle() // fetch article & static infobox private function addArticle() // get article & static infobox (run before processing jsGlobals)
{ {
if (empty($this->type) && !isset($this->typeId)) if (empty($this->type) && !isset($this->typeId))
return; return;
@@ -284,7 +222,7 @@ class GenericPage
{ {
foreach ($article as $text) foreach ($article as $text)
{ {
if (preg_match_all('/\[(npc|object|item|itemset|quest|spell|zone|faction|pet|achievement|title|holiday|class|race|skill|currency)=(\d+)[^\]]*\]/i', $text, $matches, PREG_SET_ORDER)) if (preg_match_all('/\[(npc|object|item|itemset|quest|spell|zone|faction|pet|achievement|title|event|class|race|skill|currency)=(\d+)[^\]]*\]/i', $text, $matches, PREG_SET_ORDER))
{ {
foreach ($matches as $match) foreach ($matches as $match)
{ {
@@ -318,7 +256,7 @@ class GenericPage
} }
} }
private function addAnnouncements() private function addAnnouncements() // get announcements and notes for user
{ {
// display occured notices // display occured notices
if ($_ = Util::getNotes(false)) if ($_ = Util::getNotes(false))
@@ -354,7 +292,153 @@ class GenericPage
} }
} }
public function extendGlobalIds($type, $data) protected function getCategoryFromUrl($str)
{
$arr = explode('.', $str);
$params = [];
foreach ($arr as $v)
if (is_numeric($v))
$params[] = (int)$v;
$this->category = $params;
}
/*******************/
/* Special Display */
/*******************/
public function notFound($typeStr) // unknown ID
{
if ($this->mode == CACHETYPE_TOOLTIP)
{
header('Content-type: application/x-javascript; charset=utf-8');
echo $this->generateTooltip(true);
}
else if ($this->mode == CACHETYPE_XML)
{
header('Content-type: text/xml; charset=utf-8');
echo $this->generateXML(true);
}
else
{
$this->typeStr = $typeStr;
$this->mysql = DB::Aowow()->getStatistics();
$this->display('text-page-generic');
}
exit();
}
public function error() // unknown page
{
$this->type = -99; // get error-article
$this->typeId = 0;
$this->title[] = Lang::$main['errPageTitle'];
$this->name = Lang::$main['errPageTitle'];
$this->addArticle();
$this->mysql = DB::Aowow()->getStatistics();
$this->display('text-page-generic');
exit();
}
public function maintenance() // display brb gnomes
{
$this->display('maintenance');
exit();
}
/*******************/
/* General Display */
/*******************/
public function display($override = '') // load given template string or GenericPage::$tpl
{
if ($override)
{
$this->addAnnouncements();
include('template/pages/'.$override.'.tpl.php');
die();
}
else if ($this->mode == CACHETYPE_TOOLTIP)
{
if (!$this->loadCache($tt))
{
$tt = $this->generateTooltip();
$this->saveCache($tt);
}
header('Content-type: application/x-javascript; charset=utf-8');
die($tt);
}
else if ($this->mode == CACHETYPE_XML)
{
if (!$this->loadCache($xml))
{
$xml = $this->generateXML();
$this->saveCache($xml);
}
header('Content-type: text/xml; charset=utf-8');
die($xml);
}
else
{
$this->prepareContent();
if (!$this->isSaneInclude('template/pages/', $this->tpl))
die(User::isInGroup(U_GROUP_STAFF) ? 'Error: nonexistant template requested: template/pages/'.$this->tpl.'.tpl.php' : null);
$this->addAnnouncements();
include('template/pages/'.$this->tpl.'.tpl.php');
die();
}
}
public function gBrick($file, array $localVars = []) // load jsGlobal
{
foreach ($localVars as $n => $v)
$$n = $v;
if (!$this->isSaneInclude('template/globals/', $file))
echo !User::isInGroup(U_GROUP_STAFF) ? "\n\nError: nonexistant template requested: template/globals/".$file.".tpl.php\n\n" : null;
else
include('template/globals/'.$file.'.tpl.php');
}
public function brick($file, array $localVars = []) // load brick
{
foreach ($localVars as $n => $v)
$$n = $v;
if (!$this->isSaneInclude('template/bricks/', $file))
echo User::isInGroup(U_GROUP_STAFF) ? "\n\nError: nonexistant template requested: template/bricks/".$file.".tpl.php\n\n" : null;
else
include('template/bricks/'.$file.'.tpl.php');
}
public function lvBrick($file, array $localVars = []) // load listview
{
foreach ($localVars as $n => $v)
$$n = $v;
if (!$this->isSaneInclude('template/listviews/', $file))
echo User::isInGroup(U_GROUP_STAFF) ? "\n\nError: nonexistant template requested: template/listviews/".$file.".tpl.php\n\n" : null;
else
include('template/listviews/'.$file.'.tpl.php');
}
/**********************/
/* Prepare js-Globals */
/**********************/
public function extendGlobalIds($type, $data) // add typeIds <int|array[int]> that should be displayed as jsGlobal on the page
{ {
if (!$type || !$data) if (!$type || !$data)
return false; return false;
@@ -371,7 +455,7 @@ class GenericPage
$this->jsgBuffer[$type][] = (int)$data; $this->jsgBuffer[$type][] = (int)$data;
} }
public function extendGlobalData($data, $extra = null) public function extendGlobalData($data, $extra = null) // add jsGlobals or typeIds (can be mixed in one array: TYPE => [mixeddata]) to display on the page
{ {
foreach ($data as $type => $globals) foreach ($data as $type => $globals)
{ {
@@ -396,7 +480,7 @@ class GenericPage
$this->jsGlobals[$type][2] = $extra; $this->jsGlobals[$type][2] = $extra;
} }
private function initJSGlobal($type) private function initJSGlobal($type) // init store for type
{ {
$jsg = &$this->jsGlobals; // shortcut $jsg = &$this->jsGlobals; // shortcut
@@ -415,7 +499,7 @@ class GenericPage
case TYPE_PET: $jsg[TYPE_PET] = ['pet', [], []]; break; case TYPE_PET: $jsg[TYPE_PET] = ['pet', [], []]; break;
case TYPE_ACHIEVEMENT: $jsg[TYPE_ACHIEVEMENT] = ['achievement', [], []]; break; case TYPE_ACHIEVEMENT: $jsg[TYPE_ACHIEVEMENT] = ['achievement', [], []]; break;
case TYPE_TITLE: $jsg[TYPE_TITLE] = ['title', [], []]; break; case TYPE_TITLE: $jsg[TYPE_TITLE] = ['title', [], []]; break;
case TYPE_WORLDEVENT: $jsg[TYPE_WORLDEVENT] = ['holiday', [], []]; break; case TYPE_WORLDEVENT: $jsg[TYPE_WORLDEVENT] = ['event', [], []]; break;
case TYPE_CLASS: $jsg[TYPE_CLASS] = ['class', [], []]; break; case TYPE_CLASS: $jsg[TYPE_CLASS] = ['class', [], []]; break;
case TYPE_RACE: $jsg[TYPE_RACE] = ['race', [], []]; break; case TYPE_RACE: $jsg[TYPE_RACE] = ['race', [], []]; break;
case TYPE_SKILL: $jsg[TYPE_SKILL] = ['skill', [], []]; break; case TYPE_SKILL: $jsg[TYPE_SKILL] = ['skill', [], []]; break;
@@ -423,7 +507,7 @@ class GenericPage
} }
} }
private function applyGlobals() private function applyGlobals() // lookup jsGlobals from collected typeIds
{ {
foreach ($this->jsgBuffer as $type => $ids) foreach ($this->jsgBuffer as $type => $ids)
{ {
@@ -435,7 +519,25 @@ class GenericPage
continue; continue;
$this->initJSGlobal($type); $this->initJSGlobal($type);
$cnd = array(['id', array_unique($ids, SORT_NUMERIC)], CFG_SQL_LIMIT_NONE);
// todo (med): properly distinguish holidayId and eventId
$cnd = [CFG_SQL_LIMIT_NONE];
if ($type == TYPE_WORLDEVENT)
{
$hIds = array_filter($ids, function($v) { return $v > 0; });
$eIds = array_filter($ids, function($v) { return $v < 0; });
if ($hIds)
$cnd[] = ['holidayId', array_unique($hIds, SORT_NUMERIC)];
if ($eIds)
$cnd[] = ['id', array_unique($eIds, SORT_NUMERIC)];
if ($eIds && $hIds)
$cnd[] = 'OR';
}
else
$cnd [] = ['id', array_unique($ids, SORT_NUMERIC)];
switch ($type) switch ($type)
{ {
@@ -461,46 +563,11 @@ class GenericPage
} }
} }
public function notFound($subject) /*********/
{ /* Cache */
if ($this->mode == CACHETYPE_TOOLTIP) /*********/
echo $this->generateTooltip(true);
else if ($this->mode == CACHETYPE_XML)
echo $this->generateXML(true);
else
{
$this->subject = $subject;
$this->mysql = DB::Aowow()->getStatistics();
$this->display('text-page-generic'); public function saveCache($saveString = null) // visible properties or given strings are cached
}
exit();
}
public function error()
{
$this->type = -99; // get error-article
$this->typeId = 0;
$this->title[] = Lang::$main['errPageTitle'];
$this->name = Lang::$main['errPageTitle'];
$this->addArticle();
$this->mysql = DB::Aowow()->getStatistics();
$this->display('text-page-generic');
exit();
}
public function maintenance()
{
$this->display('maintenance');
exit();
}
// creates the cache file
public function saveCache($saveString = null)
{ {
if ($this->mode == CACHETYPE_NONE) if ($this->mode == CACHETYPE_NONE)
return false; return false;
@@ -521,7 +588,7 @@ class GenericPage
if ((new ReflectionProperty($this, $key))->getModifiers() & 0x1300) if ((new ReflectionProperty($this, $key))->getModifiers() & 0x1300)
$cache[$key] = $val; $cache[$key] = $val;
} }
catch (ReflectionException $e) { } // shut up! catch (ReflectionException $e) { } // shut up!
} }
$data .= serialize($cache); $data .= serialize($cache);
@@ -532,8 +599,7 @@ class GenericPage
file_put_contents($file, $data); file_put_contents($file, $data);
} }
// loads and evaluates the cache file public function loadCache(&$saveString = null)
public function loadCache(&$saveVar = null)
{ {
if ($this->mode == CACHETYPE_NONE) if ($this->mode == CACHETYPE_NONE)
return false; return false;
@@ -565,7 +631,7 @@ class GenericPage
} }
else if ($type == '1') else if ($type == '1')
{ {
$saveVar = $cache[1]; $saveString = $cache[1];
return true; return true;
} }

View File

@@ -65,7 +65,14 @@ class Loot
return json_encode($stack, JSON_NUMERIC_CHECK); return json_encode($stack, JSON_NUMERIC_CHECK);
} }
private static function getByItemIdRecursive($tableName, $lootId, &$handledRefs, $groupId = 0, $baseChance = 1.0) private static function storeJSGlobals($data)
{
foreach ($data as $type => $jsData)
foreach ($jsData as $k => $v)
self::$jsGlobals[$type][$k] = $v;
}
private static function getByContainerRecursive($tableName, $lootId, &$handledRefs, $groupId = 0, $baseChance = 1.0)
{ {
$loot = []; $loot = [];
$rawItems = []; $rawItems = [];
@@ -118,7 +125,7 @@ class Loot
// bandaid.. remove when propperly handling lootmodes // bandaid.. remove when propperly handling lootmodes
if (!in_array($entry['mincountOrRef'], $handledRefs)) if (!in_array($entry['mincountOrRef'], $handledRefs))
{ // todo (high): find out, why i used this in the first place. (don't do drugs, kids) { // todo (high): find out, why i used this in the first place. (don't do drugs, kids)
list($data, $raw) = self::getByItemIdRecursive(LOOT_REFERENCE, $entry['mincountOrRef'], $handledRefs, /*$entry['groupid'],*/ 0, abs($entry['ChanceOrQuestChance'] / 100)); list($data, $raw) = self::getByContainerRecursive(LOOT_REFERENCE, $entry['mincountOrRef'], $handledRefs, /*$entry['groupid'],*/ 0, abs($entry['ChanceOrQuestChance'] / 100));
$handledRefs[] = $entry['mincountOrRef']; $handledRefs[] = $entry['mincountOrRef'];
@@ -157,7 +164,7 @@ class Loot
} }
else // shouldn't have happened else // shouldn't have happened
{ {
self::addNote(U_GROUP_EMPLOYEE, 'Loot::getByItemIdRecursive: unhandled case in calculating chance for item '.$entry['item'].'!'); self::addNote(U_GROUP_EMPLOYEE, 'Loot::getByContainerRecursive: unhandled case in calculating chance for item '.$entry['item'].'!');
continue; continue;
} }
@@ -171,7 +178,7 @@ class Loot
$sum = 0; $sum = 0;
else if ($sum > 100) else if ($sum > 100)
{ {
self::addNote(U_GROUP_EMPLOYEE, 'Loot::getByItemIdRecursive: entry '.$lootId.' / group '.$k.' has a total chance of '.number_format($sum, 2).'%. Some items cannot drop!'); self::addNote(U_GROUP_EMPLOYEE, 'Loot::getByContainerRecursive: entry '.$lootId.' / group '.$k.' has a total chance of '.number_format($sum, 2).'%. Some items cannot drop!');
$sum = 100; $sum = 100;
} }
@@ -202,7 +209,7 @@ class Loot
modes:{"mode":1,"1":{"count":4408,"outof":16013},"4":{"count":4408,"outof":22531}} modes:{"mode":1,"1":{"count":4408,"outof":16013},"4":{"count":4408,"outof":22531}}
*/ */
$handledRefs = []; $handledRefs = [];
$struct = self::getByItemIdRecursive($table, $entry, $handledRefs); $struct = self::getByContainerRecursive($table, $entry, $handledRefs);
if (!$struct) if (!$struct)
return false; return false;
@@ -496,7 +503,7 @@ class Loot
$srcObj = new QuestList($conditions); $srcObj = new QuestList($conditions);
if (!$srcObj->error) if (!$srcObj->error)
{ {
$srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS); self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS));
$srcData = $srcObj->getListviewData(); $srcData = $srcObj->getListviewData();
foreach ($srcObj->iterate() as $_) foreach ($srcObj->iterate() as $_)
@@ -517,7 +524,7 @@ class Loot
$srcObj = new SpellList($conditions); $srcObj = new SpellList($conditions);
if (!$srcObj->error) if (!$srcObj->error)
{ {
$srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED); self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$srcData = $srcObj->getListviewData(); $srcData = $srcObj->getListviewData();
if (!empty($result)) if (!empty($result))
@@ -544,8 +551,8 @@ class Loot
$srcObj = new $oName(array([$field, $ids])); $srcObj = new $oName(array([$field, $ids]));
if (!$srcObj->error) if (!$srcObj->error)
{ {
$srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED);
$srcData = $srcObj->getListviewData(); $srcData = $srcObj->getListviewData();
self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
foreach ($srcObj->iterate() as $curTpl) foreach ($srcObj->iterate() as $curTpl)
{ {

View File

@@ -44,6 +44,8 @@ class AchievementList extends BaseType
$_curTpl['rewards'][TYPE_TITLE][] = -$rewId; $_curTpl['rewards'][TYPE_TITLE][] = -$rewId;
} }
} }
$_curTpl['iconString'] = $_curTpl['iconString'] ?: 'trade_engineering';
} }
} }

View File

@@ -9,10 +9,10 @@ class FactionList extends BaseType
public static $type = TYPE_FACTION; public static $type = TYPE_FACTION;
public static $brickFile = 'faction'; public static $brickFile = 'faction';
protected $queryBase = 'SELECT f.*, f.parentFactionId AS cat2, f.id AS ARRAY_KEY FROM ?_factions f'; protected $queryBase = 'SELECT f.*, f.parentFactionId AS cat, f.id AS ARRAY_KEY FROM ?_factions f';
protected $queryOpts = array( protected $queryOpts = array(
'f' => [['f2']], 'f' => [['f2']],
'f2' => ['j' => ['?_factions f2 ON f.parentFactionId = f2.id', true], 's' => ', IFNULL(f2.parentFactionId, 0) AS cat'], 'f2' => ['j' => ['?_factions f2 ON f.parentFactionId = f2.id', true], 's' => ', IFNULL(f2.parentFactionId, 0) AS cat2'],
'ft' => ['j' => '?_factiontemplate ft ON ft.factionId = f.id'] 'ft' => ['j' => '?_factiontemplate ft ON ft.factionId = f.id']
); );

View File

@@ -107,13 +107,13 @@ class ItemList extends BaseType
if ($_ = @$costs['reqArenaPoints']) if ($_ = @$costs['reqArenaPoints'])
{ {
$data[-103] = $_; $data[-103] = $_;
$this->jsGlobals[TYPE_CURRENCY][103] = [103]; $this->jsGlobals[TYPE_CURRENCY][103] = 103;
} }
if ($_ = @$costs['reqHonorPoints']) if ($_ = @$costs['reqHonorPoints'])
{ {
$data[-104] = $_; $data[-104] = $_;
$this->jsGlobals[TYPE_CURRENCY][104] = [104]; $this->jsGlobals[TYPE_CURRENCY][104] = 104;
} }
for ($i = 1; $i < 6; $i++) for ($i = 1; $i < 6; $i++)
@@ -135,7 +135,9 @@ class ItemList extends BaseType
if ($cItems) if ($cItems)
{ {
$moneyItems = new CurrencyList(array(['itemId', $cItems])); $moneyItems = new CurrencyList(array(['itemId', $cItems]));
$this->jsGlobals = $moneyItems->getJSGlobals(); foreach ($moneyItems->getJSGlobals() as $type => $jsData)
foreach ($jsData as $k => $v)
$this->jsGlobals[$type][$k] = $v;
foreach ($itemz as $id => $vendors) foreach ($itemz as $id => $vendors)
{ {
@@ -158,7 +160,7 @@ class ItemList extends BaseType
} }
if (!$found) if (!$found)
$this->jsGlobals[TYPE_ITEM][$k] = [$k]; $this->jsGlobals[TYPE_ITEM][$k] = $k;
} }
} }
$vendors[$l] = $costs; $vendors[$l] = $costs;
@@ -289,7 +291,7 @@ class ItemList extends BaseType
if ($e = $cost['event']) if ($e = $cost['event'])
{ {
$this->jsGlobals[TYPE_WORLDEVENT][$e] = [$e]; $this->jsGlobals[TYPE_WORLDEVENT][$e] = $e;
$data[$this->id]['condition'] = array( $data[$this->id]['condition'] = array(
'type' => TYPE_WORLDEVENT, 'type' => TYPE_WORLDEVENT,
'typeId' => -$e, 'typeId' => -$e,
@@ -366,7 +368,7 @@ class ItemList extends BaseType
public function getJSGlobals($addMask = GLOBALINFO_SELF, &$extra = []) public function getJSGlobals($addMask = GLOBALINFO_SELF, &$extra = [])
{ {
$data = $this->jsGlobals; $data = $addMask & GLOBALINFO_RELATED ? $this->jsGlobals : [];
foreach ($this->iterate() as $id => $__) foreach ($this->iterate() as $id => $__)
{ {

View File

@@ -696,7 +696,7 @@ class Util
public static $tcEncoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789'; public static $tcEncoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789';
public static $wowheadLink = ''; public static $wowheadLink = '';
private static $notes = []; private static $notes = [];
// creates an announcement; use if minor issues arise // creates an announcement; use if minor issues arise
public static function addNote($uGroupMask, $str) public static function addNote($uGroupMask, $str)
@@ -895,7 +895,7 @@ class Util
// pageText for Books (Item or GO) and questText // pageText for Books (Item or GO) and questText
public static function parseHtmlText($text) public static function parseHtmlText($text)
{ {
if (stristr($text, '<HTML>')) // text is basicly a html-document with weird linebreak-syntax if (stristr($text, '<HTML>')) // text is basically a html-document with weird linebreak-syntax
{ {
$pairs = array( $pairs = array(
'<HTML>' => '', '<HTML>' => '',
@@ -915,9 +915,9 @@ class Util
'/\|T([\w]+\\\)*([^\.]+)\.blp:\d+\|t/ui', // images (force size to tiny) |T<fullPath>:<size>|t '/\|T([\w]+\\\)*([^\.]+)\.blp:\d+\|t/ui', // images (force size to tiny) |T<fullPath>:<size>|t
'/\|c(\w{6})\w{2}([^\|]+)\|r/ui', // color |c<RRGGBBAA><text>|r '/\|c(\w{6})\w{2}([^\|]+)\|r/ui', // color |c<RRGGBBAA><text>|r
'/\$g\s*([^:;]+)\s*:\s*([^:;]+)\s*(:?[^:;]*);/ui',// directed gender-reference $g:<male>:<female>:<refVariable> '/\$g\s*([^:;]+)\s*:\s*([^:;]+)\s*(:?[^:;]*);/ui',// directed gender-reference $g:<male>:<female>:<refVariable>
'/\$t([^;]+);/ui', // nonesense, that the client apparently ignores '/\$t([^;]+);/ui', // nonsense, that the client apparently ignores
'/\|\d\-?\d?\((\$\w)\)/ui', // and another modifier for something russian |3-6($r) '/\|\d\-?\d?\((\$\w)\)/ui', // and another modifier for something russian |3-6($r)
'/<([^\"=\/>]+\s[^\"=\/>]+)>/ui' // emotes (workaround: at least one whitespace and never " oder = between brackets) '/<([^\"=\/>]+\s[^\"=\/>]+)>/ui' // emotes (workaround: at least one whitespace and never " or = between brackets)
); );
$to = array( $to = array(
@@ -1031,18 +1031,6 @@ class Util
return ''; return '';
} }
public static function extractURLParams($str)
{
$arr = explode('.', $str);
$params = [];
foreach ($arr as $v)
if (is_numeric($v))
$params[] = (int)$v;
return $params;
}
// for item and spells // for item and spells
public static function setRatingLevel($level, $type, $val) public static function setRatingLevel($level, $type, $val)
{ {

View File

@@ -19,406 +19,394 @@ if (!defined('AOWOW_REVISION'))
* } * }
*/ */
require 'includes/community.class.php'; // menuId 9: Achievement g_initPath()
// tabId 0: Database g_initHeader()
$_id = intVal($pageParam); class AchievementPage extends GenericPage
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_ACHIEVEMENT, $_id, -1, User::$localeId]);
$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_ACHIEVEMENT, $_id, -1, User::$localeId]);
// AowowPower-request
if (isset($_GET['power']))
{ {
header('Content-type: application/x-javascript; charsetUTF-8'); use DetailPage;
Util::powerUseLocale(@$_GET['domain']); protected $type = TYPE_ACHIEVEMENT;
protected $typeId = 0;
protected $tpl = 'achievement';
protected $path = [0, 9];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
if (!$smarty->loadCache($cacheKeyTooltip, $x)) public function __construct($__, $id)
{ {
$acv = new AchievementList(array(['id', $_id])); parent::__construct();
if ($acv->error)
die('$WowheadPower.registerAchievement(\''.$_id.'\', '.User::$localeId.', {})');
$x = '$WowheadPower.registerAchievement('.$_id.', '.User::$localeId.",{\n"; // temp locale
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($acv->getField('name', true))."',\n"; if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain']))
$x .= "\ticon: '".urlencode($acv->getField('iconString'))."',\n"; Util::powerUseLocale($_GET['domain']);
$x .= "\ttooltip_".User::$localeString.": '".$acv->renderTooltip()."'\n";
$x .= "});";
$smarty->saveCache($cacheKeyTooltip, $x); $this->typeId = intVal($id);
}
die($x);
}
// regular page $this->subject = new AchievementList(array(['id', $this->typeId]));
if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($this->subject->error)
{ $this->notFound(Lang::$game['achievement']);
$acv = new AchievementList(array(['id', $_id]));
if ($acv->error)
$smarty->notFound(Lang::$game['achievement'], $_id);
// create page title and path $this->extendGlobalData($this->subject->getJSGlobals(GLOBALINFO_REWARDS));
$curCat = $acv->getField('category');
$path = [];
do
{
array_unshift($path, $curCat);
$curCat = DB::Aowow()->SelectCell('SELECT parentCategory FROM ?_achievementcategory WHERE id = ?d', $curCat);
}
while ($curCat > 0);
array_unshift($path, 0, 9); $this->name = $this->subject->getField('name', true);
$acv->addGlobalsToJScript(GLOBALINFO_REWARDS);
/***********/
/* Infobox */
/***********/
$infobox = [];
// points
if ($_ = $acv->getField('points'))
$infobox[] = Lang::$achievement['points'].Lang::$colon.'[achievementpoints='.$_.']';
// location
// todo (low)
// faction
switch ($acv->getField('faction'))
{
case 1:
$infobox[] = Lang::$main['side'].Lang::$colon.'[span class=icon-alliance]'.Lang::$game['si'][SIDE_ALLIANCE].'[/span]';
break;
case 2:
$infobox[] = Lang::$main['side'].Lang::$colon.'[span class=icon-horde]'.Lang::$game['si'][SIDE_HORDE].'[/span]';
break;
default: // case 3
$infobox[] = Lang::$main['side'].Lang::$colon.Lang::$game['si'][SIDE_BOTH];
} }
// todo (low): crosslink with charactersDB to check if realmFirsts are still available protected function generatePath()
$infobox = array_merge($infobox, Lang::getInfoBoxForFlags($acv->getField('cuFlags')));
/**********/
/* Series */
/**********/
$series = [];
if ($c = $acv->getField('chainId'))
{ {
$chainAcv = new AchievementList(array(['chainId', $c])); // create page title and path
$curCat = $this->subject->getField('category');
foreach ($chainAcv->iterate() as $aId => $__) do
{ {
$pos = $chainAcv->getField('chainPos'); array_unshift($this->path, $curCat);
if (!isset($series[$pos])) $curCat = DB::Aowow()->SelectCell('SELECT parentCategory FROM ?_achievementcategory WHERE id = ?d', $curCat);
$series[$pos] = [];
$series[$pos][] = array(
'side' => $chainAcv->getField('faction'),
'typeStr' => Util::$typeStrings[TYPE_ACHIEVEMENT],
'typeId' => $aId,
'name' => $chainAcv->getField('name', true)
);
} }
while ($curCat > 0);
array_unshift($this->path, 0, 9);
$this->path[] = $this->subject->getField('typeCat');
} }
/****************/ protected function generateTitle()
/* Main Content */
/****************/
// menuId 9: Achievement g_initPath()
// tabId 0: Database g_initHeader()
$pageData = array(
'page' => array(
'title' => $acv->getField('name', true).' - '.Util::ucfirst(Lang::$game['achievement']),
'path' => json_encode($path, JSON_NUMERIC_CHECK),
'tab' => 0,
'type' => TYPE_ACHIEVEMENT,
'typeId' => $_id,
'headIcons' => $acv->getField('iconString'),
'infobox' => $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null,
'series' => $series ? [[$series, null]] : null,
'redButtons' => array(
BUTTON_LINKS => ['color' => 'ffffff00', 'linkId' => Util::$typeStrings[TYPE_ACHIEVEMENT].':'.$_id.':&quot;..UnitGUID(&quot;player&quot;)..&quot;:0:0:0:0:0:0:0:0'],
BUTTON_WOWHEAD => true
),
'name' => $acv->getField('name', true),
'description' => $acv->getField('description', true),
'count' => $acv->getField('reqCriteriaCount'),
'reward' => $acv->getField('reward', true),
'nCriteria' => count($acv->getCriteria()),
'titleReward' => [],
'itemReward' => [],
'criteria' => [],
'icons' => []
),
'relTabs' => []
);
// create rewards
if ($foo = $acv->getField('rewards')[TYPE_ITEM])
{ {
$bar = new ItemList(array(['i.id', $foo])); array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['achievement']));
foreach ($bar->iterate() as $id => $__) }
protected function generateContent()
{
/***********/
/* Infobox */
/***********/
$infobox = [];
// points
if ($_ = $this->subject->getField('points'))
$infobox[] = Lang::$achievement['points'].Lang::$main['colon'].'[achievementpoints='.$_.']';
// location
// todo (low)
// faction
switch ($this->subject->getField('faction'))
{ {
$pageData['page']['itemReward'][] = array( case 1:
'name' => $bar->getField('name', true), $infobox[] = Lang::$main['side'].Lang::$main['colon'].'[span class=icon-alliance]'.Lang::$game['si'][SIDE_ALLIANCE].'[/span]';
'quality' => $bar->getField('quality'), break;
'typeStr' => Util::$typeStrings[TYPE_ITEM], case 2:
'id' => $id, $infobox[] = Lang::$main['side'].Lang::$main['colon'].'[span class=icon-horde]'.Lang::$game['si'][SIDE_HORDE].'[/span]';
'globalStr' => 'g_items' break;
); default: // case 3
$infobox[] = Lang::$main['side'].Lang::$main['colon'].Lang::$game['si'][SIDE_BOTH];
} }
}
if ($foo = $acv->getField('rewards')[TYPE_TITLE]) // todo (low): crosslink with charactersDB to check if realmFirsts are still available
{
$bar = new TitleList(array(['id', $foo]));
foreach ($bar->iterate() as $__)
$pageData['page']['titleReward'][] = sprintf(Lang::$achievement['titleReward'], $bar->id, trim(str_replace('%s', '', $bar->getField('male', true))));
}
/**************/ $infobox = array_merge($infobox, Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')));
/* Extra Tabs */
/**************/
// tab: see also /**********/
$conditions = array( /* Series */
['name_loc'.User::$localeId, $acv->getField('name', true)], /**********/
['id', $_id, '!']
);
$saList = new AchievementList($conditions);
$pageData['relTabs'][] = array(
'file' => 'achievement',
'data' => $saList->getListviewData(),
'params' => array(
'id' => 'see-also',
'name' => '$LANG.tab_seealso',
'visibleCols' => "$['category']",
'tabs' => '$tabsRelated'
)
);
$saList->addGlobalsToJscript(); $series = [];
// tab: criteria of if ($c = $this->subject->getField('chainId'))
$refs = DB::Aowow()->SelectCol('SELECT refAchievementId FROM ?_achievementcriteria WHERE Type = ?d AND value1 = ?d', {
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, $chainAcv = new AchievementList(array(['chainId', $c]));
$_id
); foreach ($chainAcv->iterate() as $aId => $__)
if (!empty($refs)) {
{ $pos = $chainAcv->getField('chainPos');
$coList = new AchievementList(array(['id', $refs])); if (!isset($series[$pos]))
$pageData['relTabs'][] = array( $series[$pos] = [];
$series[$pos][] = array(
'side' => $chainAcv->getField('faction'),
'typeStr' => Util::$typeStrings[TYPE_ACHIEVEMENT],
'typeId' => $aId,
'name' => $chainAcv->getField('name', true)
);
}
}
/****************/
/* Main Content */
/****************/
$this->headIcons = [$this->subject->getField('iconString')];
$this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null;
$this->series = $series ? [[$series, null]] : null;
$this->description = $this->subject->getField('description', true);
$this->redButtons = array(
BUTTON_LINKS => ['color' => 'ffffff00', 'linkId' => Util::$typeStrings[TYPE_ACHIEVEMENT].':'.$this->typeId.':&quot;..UnitGUID(&quot;player&quot;)..&quot;:0:0:0:0:0:0:0:0'],
BUTTON_WOWHEAD => !($this->subject->getField('cuFlags') & CUSTOM_SERVERSIDE)
);
$this->criteria = array(
'reqQty' => $this->subject->getField('reqCriteriaCount'),
'icons' => [],
'data' => []
);
// create rewards
if ($foo = $this->subject->getField('rewards')[TYPE_ITEM])
{
$bar = new ItemList(array(['i.id', $foo]));
foreach ($bar->iterate() as $id => $__)
{
$this->rewards['item'][] = array(
'name' => $bar->getField('name', true),
'quality' => $bar->getField('quality'),
'typeStr' => Util::$typeStrings[TYPE_ITEM],
'id' => $id,
'globalStr' => 'g_items'
);
}
}
if ($foo = $this->subject->getField('rewards')[TYPE_TITLE])
{
$bar = new TitleList(array(['id', $foo]));
foreach ($bar->iterate() as $__)
$this->rewards['title'][] = sprintf(Lang::$achievement['titleReward'], $bar->id, trim(str_replace('%s', '', $bar->getField('male', true))));
}
$this->rewards['text'] = $this->subject->getField('reward', true);
/**************/
/* Extra Tabs */
/**************/
// tab: see also
$conditions = array(
['name_loc'.User::$localeId, $this->subject->getField('name', true)],
['id', $this->typeId, '!']
);
$saList = new AchievementList($conditions);
$this->lvData[] = array(
'file' => 'achievement', 'file' => 'achievement',
'data' => $coList->getListviewData(), 'data' => $saList->getListviewData(),
'params' => array( 'params' => array(
'id' => 'criteria-of', 'id' => 'see-also',
'name' => '$LANG.tab_criteriaof', 'name' => '$LANG.tab_seealso',
'visibleCols' => "$['category']", 'visibleCols' => "$['category']",
'tabs' => '$tabsRelated' 'tabs' => '$tabsRelated'
) )
); );
$this->extendGlobalData($saList->getJSGlobals());
$coList->addGlobalsToJscript(); // tab: criteria of
} $refs = DB::Aowow()->SelectCol('SELECT refAchievementId FROM ?_achievementcriteria WHERE Type = ?d AND value1 = ?d',
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT,
/*****************/ $this->typeId
/* Criteria List */
/*****************/
$iconId = 1;
$rightCol = [];
foreach ($acv->getCriteria() as $i => $crt)
{
// hide hidden criteria for regular users (really do..?)
// if (($crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_HIDDEN) && User::$perms > 0)
// continue;
// alternative display option
$displayMoney = $crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER;
$crtName = Util::localizedString($crt, 'name');
$tmp = array(
'id' => $crt['id'],
'name' => $crtName,
'type' => $crt['type'],
); );
if (!empty($refs))
$obj = (int)$crt['value1'];
$qty = (int)$crt['value2'];
switch ($crt['type'])
{ {
// link to npc $coList = new AchievementList(array(['id', $refs]));
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE: $this->lvData[] = array(
case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE: 'file' => 'achievement',
$tmp['link'] = array( 'data' => $coList->getListviewData(),
'href' => '?npc='.$obj, 'params' => array(
'text' => $crtName, 'id' => 'criteria-of',
); 'name' => '$LANG.tab_criteriaof',
$tmp['extra_text'] = Lang::$achievement['slain']; 'visibleCols' => "$['category']",
break; 'tabs' => '$tabsRelated'
// link to area (by map) )
case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG: );
case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA: $this->extendGlobalData($coList->getJSGlobals());
case ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA: }
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND:
case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP: /*****************/
if ($zoneId = DB::Aowow()->selectCell('SELECT id FROM ?_zones WHERE mapId = ? LIMIT 1', $obj)) /* Criteria List */
/*****************/
$iconId = 1;
$rightCol = [];
foreach ($this->subject->getCriteria() as $i => $crt)
{
// hide hidden criteria for regular users (really do..?)
// if (($crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_HIDDEN) && User::$perms > 0)
// continue;
// alternative display option
$displayMoney = $crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER;
$crtName = Util::localizedString($crt, 'name');
$tmp = array(
'id' => $crt['id'],
'name' => $crtName,
'type' => $crt['type'],
);
$obj = (int)$crt['value1'];
$qty = (int)$crt['value2'];
switch ($crt['type'])
{
// link to npc
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE:
$tmp['link'] = array( $tmp['link'] = array(
'href' => '?zone='.$zoneId, 'href' => '?npc='.$obj,
'text' => $crtName, 'text' => $crtName,
); );
else $tmp['extraText'] = Lang::$achievement['slain'];
$tmp['extra_text'] = $crtName; break;
break; // link to area (by map)
// link to area case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE: case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA:
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA: case ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA:
$tmp['link'] = array( case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND:
'href' => '?zone='.$obj, case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP:
'text' => $crtName, if ($zoneId = DB::Aowow()->selectCell('SELECT id FROM ?_zones WHERE mapId = ? LIMIT 1', $obj))
); $tmp['link'] = array(
break; 'href' => '?zone='.$zoneId,
// link to skills 'text' => $crtName,
case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL: );
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL: else
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS: $tmp['extraText'] = $crtName;
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE: break;
$tmp['link'] = array( // link to area
'href' => '?skill='.$obj, case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE:
'text' => $crtName, case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA:
); $tmp['link'] = array(
break; 'href' => '?zone='.$obj,
// link to class 'text' => $crtName,
case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS: );
$tmp['link'] = array( break;
'href' => '?class='.$obj, // link to skills
'text' => $crtName, case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL:
); case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL:
break; case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
// link to race case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE: $tmp['link'] = array(
$tmp['link'] = array( 'href' => '?skill='.$obj,
'href' => '?race='.$obj, 'text' => $crtName,
'text' => $crtName, );
); break;
break; // link to class
// link to title - todo (low): crosslink case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE: $tmp['link'] = array(
$tmp['extra_text'] = Util::ucFirst(Lang::$game['title']).Lang::$colon.$crtName; 'href' => '?class='.$obj,
break; 'text' => $crtName,
// link to achivement (/w icon) );
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT: break;
$tmp['link'] = array( // link to race
'href' => '?achievement='.$obj, case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
'text' => $crtName, $tmp['link'] = array(
); 'href' => '?race='.$obj,
$tmp['icon'] = $iconId; 'text' => $crtName,
$pageData['page']['icons'][] = array( );
'itr' => $iconId++, break;
'type' => 'g_achievements', // link to title - todo (low): crosslink
'id' => $obj, case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE:
); $tmp['extraText'] = Util::ucFirst(Lang::$game['title']).Lang::$main['colon'].$crtName;
$smarty->extendGlobalIds(TYPE_ACHIEVEMENT, $obj); break;
break; // link to achivement (/w icon)
// link to quest case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT:
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST: $tmp['link'] = array(
// $crtName = ; 'href' => '?achievement='.$obj,
$tmp['link'] = array( 'text' => $crtName,
'href' => '?quest='.$obj, );
'text' => $crtName ? $crtName : QuestList::getName($obj), $tmp['icon'] = $iconId;
); $this->criteria['icons'][] = array(
break; 'itr' => $iconId++,
// link to spell (/w icon) 'type' => 'g_achievements',
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET: 'id' => $obj,
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2: );
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL: $this->extendGlobalIds(TYPE_ACHIEVEMENT, $obj);
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL: break;
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2: // link to quest
$text = $crtName ? $crtName : SpellList::getName($obj); case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
$tmp['link'] = array( // $crtName = ;
'href' => '?spell='.$obj, $tmp['link'] = array(
'text' => $text 'href' => '?quest='.$obj,
); 'text' => $crtName ?: QuestList::getName($obj),
$smarty->extendGlobalIds(TYPE_SPELL, $obj); );
$tmp['icon'] = $iconId; break;
$pageData['page']['icons'][] = array( // link to spell (/w icon)
'itr' => $iconId++, case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
'type' => 'g_spells', case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
'id' => $obj, case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
); case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
break; case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
// link to item (/w icon) $tmp['link'] = array(
case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM: 'href' => '?spell='.$obj,
case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM: 'text' => ($crtName ?: SpellList::getName($obj))
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM: );
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM: $this->extendGlobalIds(TYPE_SPELL, $obj);
$crtItm = new ItemList(array(['i.id', $obj])); $tmp['icon'] = $iconId;
$text = $crtName ? $crtName : $crtItm->getField('name', true); $this->criteria['icons'][] = array(
$tmp['link'] = array( 'itr' => $iconId++,
'href' => '?item='.$obj, 'type' => 'g_spells',
'text' => $text, 'id' => $obj,
'quality' => $crtItm->getField('quality'), );
'count' => $qty, break;
); // link to item (/w icon)
$crtItm->addGlobalsToJscript(); case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
$tmp['icon'] = $iconId; case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
$pageData['page']['icons'][] = array( case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
'itr' => $iconId++, case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
'type' => 'g_items', $crtItm = new ItemList(array(['i.id', $obj]));
'id' => $obj, $tmp['link'] = array(
'count' => $qty, 'href' => '?item='.$obj,
); 'text' => ($crtName ?: $crtItm->getField('name', true)),
break; 'quality' => $crtItm->getField('quality'),
// link to faction (/w target reputation) 'count' => $qty,
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION: );
$tmp['link'] = array( $this->extendGlobalData($crtItm->getJSGlobals());
'href' => '?faction='.$obj, $tmp['icon'] = $iconId;
'text' => $crtName ? $crtName : FactionList::getName($obj), $this->criteria['icons'][] = array(
); 'itr' => $iconId++,
$tmp['extra_text'] = ' ('.Lang::getReputationLevelForPoints($qty).')'; 'type' => 'g_items',
break; 'id' => $obj,
// link to GObject 'count' => $qty,
case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT: );
case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT: break;
$tmp['link'] = array( // link to faction (/w target reputation)
'href' => '?object='.$obj, case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
'text' => $crtName, $tmp['link'] = array(
); 'href' => '?faction='.$obj,
break; 'text' => $crtName ?: FactionList::getName($obj),
default: );
$tmp['standard'] = true; $tmp['extraText'] = ' ('.Lang::getReputationLevelForPoints($qty).')';
// Add a gold coin icon break;
$tmp['extra_text'] = $displayMoney ? Util::formatMoney($qty) : $crtName; // link to GObject
break; case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT:
case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT:
$tmp['link'] = array(
'href' => '?object='.$obj,
'text' => $crtName,
);
break;
default:
// Add a gold coin icon if required
$tmp['extraText'] = $displayMoney ? Util::formatMoney($qty) : $crtName;
break;
}
// If the right column
if ($i % 2)
$this->criteria['data'][] = $tmp;
else
$rightCol[] = $tmp;
} }
// If the right column
if ($i % 2) // If you found the second column - merge data from it to the end of the main body
$pageData['page']['criteria'][] = $tmp; if ($rightCol)
else $this->criteria['data'] = array_merge($this->criteria['data'], $rightCol);
$rightCol[] = $tmp;
} }
// If you found the second column - merge data from it to the end of the main body protected function generateTooltip($asError = false)
if ($rightCol) {
$pageData['page']['criteria'] = array_merge($pageData['page']['criteria'], $rightCol); if ($asError)
die('$WowheadPower.registerAchievement('.$this->typeId.', '.User::$localeId.', {});');
$smarty->saveCache($cacheKeyPage, $pageData); $x = '$WowheadPower.registerAchievement('.$this->typeId.', '.User::$localeId.",{\n";
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($this->subject->getField('name', true))."',\n";
$x .= "\ticon: '".urlencode($this->subject->getField('iconString'))."',\n";
$x .= "\ttooltip_".User::$localeString.": '".$this->subject->renderTooltip()."'\n";
$x .= "});";
return $x;
}
} }
$smarty->updatePageVars($pageData['page']);
$smarty->assign('community', CommunityContent::getAll(TYPE_ACHIEVEMENT, $_id)); // comments, screenshots, videos
$smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$achievement, ['colon' => Lang::$colon]));
$smarty->assign('lvData', $pageData['relTabs']);
// load the page
$smarty->display('achievement.tpl');
?> ?>

View File

@@ -4,135 +4,143 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); die('illegal access');
$cats = Util::extractURLParams($pageParam); // menuId 9: Object g_initPath()
$path = [0, 9]; // tabId 0: Database g_initHeader()
$title = []; class AchievementsPage extends GenericPage
$filter = [];
$filterHash = !empty($_GET['filter']) ? '#'.sha1(serialize($_GET['filter'])) : null;
$cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_ACHIEVEMENT, -1, implode('.', $cats).$filterHash, User::$localeId]);
$validCats = array(
92 => true,
96 => [14861, 14862, 14863],
97 => [14777, 14778, 14779, 14780],
95 => [165, 14801, 14802, 14803, 14804, 14881, 14901, 15003],
168 => [14808, 14805, 14806, 14921, 14922, 14923, 14961, 14962, 15001, 15002, 15041, 15042],
169 => [170, 171, 172],
201 => [14864, 14865, 14866],
155 => [160, 187, 159, 163, 161, 162, 158, 14981, 156, 14941],
81 => true,
1 => array (
130 => [140, 145, 147, 191],
141 => true,
128 => [135, 136, 137],
122 => [123, 124, 125, 126, 127],
133 => true,
14807 => [14821, 14822, 14823, 14963, 15021, 15062],
132 => [178, 173],
134 => true,
131 => true,
21 => [152, 153, 154]
)
);
if (!Util::isValidPage($validCats, $cats))
$smarty->error();
if (!$smarty->loadCache($cacheKey, $pageData, $filter))
{ {
$acvFilter = new AchievementListFilter(); use ListPage;
// include child categories if current category is empty protected $type = TYPE_ACHIEVEMENT;
$condition = !empty($cats) ? [['category', (int)end($cats)]] : []; protected $tpl = 'achievements';
protected $path = [0, 9];
$fiCnd = $acvFilter->getConditions(); protected $tabId = 0;
if ($fiCnd) protected $mode = CACHETYPE_PAGE;
$condition[] = $fiCnd; protected $js = ['filters.js'];
protected $validCats = array(
$acvList = new AchievementList($condition); 92 => true,
if (!$acvList->getMatches()) 96 => [14861, 14862, 14863],
{ 97 => [14777, 14778, 14779, 14780],
$curCats = $catList = [!empty($cats) ? (int)end($cats) : 0]; 95 => [165, 14801, 14802, 14803, 14804, 14881, 14901, 15003],
while ($curCats) 168 => [14808, 14805, 14806, 14921, 14922, 14923, 14961, 14962, 15001, 15002, 15041, 15042],
{ 169 => [170, 171, 172],
$curCats = DB::Aowow()->SelectCol('SELECT Id FROM ?_achievementCategory WHERE parentCategory IN (?a)', $curCats); 201 => [14864, 14865, 14866],
$catList = array_merge($catList, $curCats); 155 => [160, 187, 159, 163, 161, 162, 158, 14981, 156, 14941],
} 81 => true,
$condition = []; 1 => array (
if ($fiCnd) 130 => [140, 145, 147, 191],
$condition[] = $fiCnd; 141 => true,
if ($catList) 128 => [135, 136, 137],
$condition[] = ['category', $catList]; 122 => [123, 124, 125, 126, 127],
133 => true,
$acvList = new AchievementList($condition); 14807 => [14821, 14822, 14823, 14963, 15021, 15062],
} 132 => [178, 173],
134 => true,
// recreate form selection 131 => true,
$filter = array_merge($acvFilter->getForm('form'), $filter); 21 => [152, 153, 154]
$filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$filter['fi'] = $acvFilter->getForm();
// create page title and path
if ($cats)
{
$catrows = DB::Aowow()->Select('SELECT * FROM ?_achievementcategory WHERE id IN (?a)', $cats);
foreach ($catrows as $cat)
{
$path[] = $cat['id'];
$title[] = Util::localizedString($cat, 'name');
}
array_unshift($title, Util::ucFirst(Lang::$game['achievements']));
}
// page content
// menuId 9: Achievement g_initPath()
// tabId 0: Database g_initHeader()
$pageData = array(
'page' => array(
'title' => implode(" - ", $title),
'path' => json_encode($path, JSON_NUMERIC_CHECK),
'tab' => 0,
'subCat' => $pageParam ? '='.$pageParam : '',
'reqJS' => [STATIC_URL.'/js/filters.js']
),
'lv' => array(
'data' => $acvList->getListviewData(),
'params' => []
) )
); );
// fill g_items, g_titles, g_achievements public function __construct($pageCall, $pageParam)
$acvList->addGlobalsToJscript();
// if we are have different cats display field
if ($acvList->hasDiffFields(['category']))
$pageData['lv']['params']['visibleCols'] = "$['category']";
if (!empty($filter['fi']['extraCols']))
$pageData['lv']['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
// create note if search limit was exceeded
if ($acvList->getMatches() > CFG_SQL_LIMIT_DEFAULT)
{ {
$pageData['lv']['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), CFG_SQL_LIMIT_DEFAULT); $this->getCategoryFromUrl($pageParam);
$pageData['lv']['params']['_truncated'] = 1;
parent::__construct();
$this->name = Util::ucFirst(Lang::$game['achievements']);
$this->subCat = $pageParam ? '='.$pageParam : '';
} }
if ($acvFilter->error) protected function generateContent()
$pageData['lv']['params']['_errors'] = '$1'; {
$conditions = [];
$smarty->saveCache($cacheKey, $pageData, $filter); // include child categories if current category is empty
if ($this->category)
$conditions[] = ['category', (int)end($this->category)];
$acvFilter = new AchievementListFilter();
// recreate form selection
$this->filter = $acvFilter->getForm('form');
$this->filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : null;
$this->filter['fi'] = $acvFilter->getForm();
if ($fiCnd = $acvFilter->getConditions())
$conditions[] = $fiCnd;
$acvList = new AchievementList($conditions);
if (!$acvList->getMatches())
{
$curCats = $catList = [!empty($this->category) ? (int)end($this->category) : 0];
while ($curCats)
{
$curCats = DB::Aowow()->SelectCol('SELECT Id FROM ?_achievementCategory WHERE parentCategory IN (?a)', $curCats);
$catList = array_merge($catList, $curCats);
}
$conditions = [];
if ($fiCnd)
$conditions[] = $fiCnd;
if ($catList)
$conditions[] = ['category', $catList];
$acvList = new AchievementList($conditions);
}
$params = $data = [];
if (!$acvList->error)
{
$data = $acvList->getListviewData();
// fill g_items, g_titles, g_achievements
$this->extendGlobalData($acvList->getJSGlobals());
// if we are have different cats display field
if ($acvList->hasDiffFields(['category']))
$params['visibleCols'] = "$['category']";
if (!empty($this->filter['fi']['extraCols']))
$params['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
// create note if search limit was exceeded
if ($acvList->getMatches() > CFG_SQL_LIMIT_DEFAULT)
{
$params['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), CFG_SQL_LIMIT_DEFAULT);
$params['_truncated'] = 1;
}
if ($acvFilter->error)
$params['_errors'] = '$1';
}
$this->lvData = array(
'file' => 'achievement',
'data' => $data,
'params' => $params
);
// sort for dropdown-menus in filter
asort(Lang::$game['si']);
}
protected function generateTitle()
{
array_unshift($this->title, Util::ucFirst(Lang::$game['achievements']));
if ($this->category)
{
$catrow = DB::Aowow()->SelectRow('SELECT * FROM ?_achievementcategory WHERE id = ?d', end($this->category));
array_unshift($this->title, Util::localizedString($catrow, 'name'));
}
}
protected function generatePath()
{
if ($this->category)
{
$catrows = DB::Aowow()->SelectCol('SELECT id FROM ?_achievementcategory WHERE id IN (?a)', $this->category);
foreach ($catrows as $cat)
$this->path[] = $cat;
}
}
} }
// sort for dropdown-menus
asort(Lang::$game['si']);
$smarty->updatePageVars($pageData['page']);
$smarty->assign('filter', $filter);
$smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$achievement, ['colon' => Lang::$colon]));
$smarty->assign('lvData', $pageData['lv']);
// load the page
$smarty->display('achievements.tpl');
?> ?>

View File

@@ -28,12 +28,7 @@ class ClassPage extends GenericPage
if ($this->subject->error) if ($this->subject->error)
$this->notFound(Lang::$game['class']); $this->notFound(Lang::$game['class']);
$this->name = $this->subject->getField('name', true); $this->name = $this->subject->getField('name', true);
$this->gPageInfo = array(
'type' => $this->type,
'typeId' => $this->typeId,
'name' => $this->name
);
} }
protected function generatePath() protected function generatePath()

View File

@@ -4,52 +4,54 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); die('illegal access');
$cat = Util::extractURLParams($pageParam); // menuId 15: Currency g_initPath()
$path = [0, 15]; // tabId 0: Database g_initHeader()
$validCats = [1, 2, 3, 22]; class CurrenciesPage extends GenericPage
$title = [Util::ucFirst(Lang::$game['currencies'])];
$cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_CURRENCY, -1, $cat ? $cat[0] : -1, User::$localeId]);
if (!Util::isValidPage($validCats, $cat))
$smarty->error();
if ($cat)
{ {
$path[] = $cat[0]; // should be only one parameter anyway use ListPage;
array_unshift($title, Lang::$currency['cat'][$cat[0]]);
protected $type = TYPE_CURRENCY;
protected $tpl = 'list-page-generic';
protected $path = [0, 15];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
protected $validCats = [1, 2, 3, 22];
public function __construct($pageCall, $pageParam)
{
$this->getCategoryFromUrl($pageParam);
parent::__construct();
$this->name = Util::ucFirst(Lang::$game['currencies']);
}
protected function generateContent()
{
$conditions = [];
if ($this->category)
$conditions[] = ['category', (int)$this->category[0]];
$money = new CurrencyList($conditions);
$this->lvData[] = array(
'file' => 'currency',
'data' => $money->getListviewData(),
'params' => []
);
}
protected function generateTitle()
{
array_unshift($this->title, $this->name);
if ($this->category)
array_unshift($this->title, Lang::$currency['cat'][$this->category[0]]);
}
protected function generatePath()
{
if ($this->category)
$this->path[] = $this->category[0];
}
} }
if (!$smarty->loadCache($cacheKey, $pageData))
{
$money = new CurrencyList($cat ? array(['category', (int)$cat[0]]) : []);
$money->addGlobalsToJscript();
// menuId 15: Currency g_initPath()
// tabId 0: Database g_initHeader()
$pageData = array(
'page' => array(
'tab' => 0,
'title' => implode(" - ", $title),
'path' => json_encode($path, JSON_NUMERIC_CHECK)
),
'lv' => array(
array(
'file' => 'currency',
'data' => $money->getListviewData(),
'params' => []
)
)
);
$smarty->saveCache($cacheKey, $pageData);
}
$smarty->updatePageVars($pageData['page']);
$smarty->assign('lang', Lang::$main);
$smarty->assign('lvData', $pageData['lv']);
// load the page
$smarty->display('list-page-generic.tpl');
?> ?>

View File

@@ -4,235 +4,243 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); die('illegal access');
require 'includes/community.class.php'; // menuId 15: Currency g_initPath()
// tabId 0: Database g_initHeader()
$_id = intVal($pageParam); class CurrencyPage extends GenericPage
$_path = [0, 15];
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_CURRENCY, $_id, -1, User::$localeId]);
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{ {
$currency = new CurrencyList(array(['id', $_id])); use DetailPage;
if ($currency->error)
$smarty->notFound(Lang::$game['skill'], $_id);
$_cat = $currency->getField('category'); protected $type = TYPE_CURRENCY;
$_itemId = $currency->getField('itemId'); protected $typeId = 0;
$_isSpecial = $_id == 103 || $_id == 104; // honor && arena points are not handled as items protected $tpl = 'detail-page-generic';
$_path[] = $_cat; protected $path = [0, 15];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
/***********/ public function __construct($__, $id)
/* Infobox */
/**********/
$infobox = '';
if ($_id == 103) // Arena Points
$infobox = '[ul][li]'.Lang::$currency['cap'].Lang::$colon.'10\'000[/li][/ul]';
else if ($_id == 104) // Honor
$infobox = '[ul][li]'.Lang::$currency['cap'].Lang::$colon.'75\'000[/li][/ul]';
/****************/
/* Main Content */
/****************/
// menuId 14: Skill g_initPath()
// tabId 0: Database g_initHeader()
$pageData = array(
'page' => array(
'title' => $currency->getField('name', true)." - ".Util::ucfirst(Lang::$game['skill']),
'path' => json_encode($_path, JSON_NUMERIC_CHECK),
'tab' => 0,
'type' => TYPE_CURRENCY,
'typeId' => $_id,
'infobox' => $infobox,
'name' => $currency->getField('name', true),
'headIcons' => $_id == 104 ? ['inv_bannerpvp_02', 'inv_bannerpvp_01'] : [$currency->getField('iconString')],
'redButtons' => array(
BUTTON_WOWHEAD => true,
BUTTON_LINKS => true
)
),
'relTabs' => []
);
/**************/
/* Extra Tabs */
/**************/
if (!$_isSpecial)
{ {
// tabs: this currency is contained in.. parent::__construct();
$lootTabs = Util::getLootSource($_itemId);
foreach ($lootTabs as $tab)
{
$pageData['relTabs'][] = array(
'file' => $tab[0],
'data' => $tab[1],
'params' => [
'tabs' => '$tabsRelated',
'name' => $tab[2],
'id' => $tab[3],
'extraCols' => $tab[4] ? '$['.implode(', ', array_unique($tab[4])).']' : null,
'hiddenCols' => $tab[5] ? '$['.implode(', ', array_unique($tab[5])).']' : null,
'visibleCols' => $tab[6] ? '$'. json_encode( array_unique($tab[6])) : null
]
);
}
// tab: sold by $this->typeId = intVal($id);
$itemObj = new ItemList(array(['id', $_itemId]));
if ($vendors = @$itemObj->getExtendedCost()[$_itemId]) $this->subject = new CurrencyList(array(['id', $this->typeId]));
if ($this->subject->error)
$this->notFound(Lang::$game['currency']);
$this->name = $this->subject->getField('name', true);
}
protected function generatePath()
{
$this->path[] = $this->subject->getField('typeCat');
}
protected function generateTitle()
{
array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['gameObject']));
}
protected function generateContent()
{
$_itemId = $this->subject->getField('itemId');
$_isSpecial = $this->typeId == 103 || $this->typeId == 104; // honor && arena points are not handled as items
/***********/
/* Infobox */
/**********/
$infobox = '';
if ($this->typeId == 103) // Arena Points
$infobox = '[ul][li]'.Lang::$currency['cap'].Lang::$main['colon'].'10\'000[/li][/ul]';
else if ($this->typeId == 104) // Honor
$infobox = '[ul][li]'.Lang::$currency['cap'].Lang::$main['colon'].'75\'000[/li][/ul]';
/****************/
/* Main Content */
/****************/
$this->infobox = $infobox;
$this->name = $this->subject->getField('name', true);
$this->headIcons = $this->typeId == 104 ? ['inv_bannerpvp_02', 'inv_bannerpvp_01'] : [$this->subject->getField('iconString')];
$this->redButtons = array(
BUTTON_WOWHEAD => true,
BUTTON_LINKS => true
);
/**************/
/* Extra Tabs */
/**************/
if (!$_isSpecial)
{ {
$soldBy = new CreatureList(array(['id', array_keys($vendors)])); include 'includes/loot.class.php';
if (!$soldBy->error)
// tabs: this currency is contained in..
$lootTabs = Loot::getByItem($_itemId);
$this->extendGlobalData(Loot::$jsGlobals);
foreach ($lootTabs as $tab)
{ {
$soldBy->addGlobalsToJScript(GLOBALINFO_SELF); $this->lvData[] = array(
$sbData = $soldBy->getListviewData(); 'file' => $tab[0],
'data' => $tab[1],
'params' => [
'tabs' => '$tabsRelated',
'name' => $tab[2],
'id' => $tab[3],
'extraCols' => $tab[4] ? '$['.implode(', ', array_unique($tab[4])).']' : null,
'hiddenCols' => $tab[5] ? '$['.implode(', ', array_unique($tab[5])).']' : null,
'visibleCols' => $tab[6] ? '$'. json_encode( array_unique($tab[6])) : null
]
);
}
$extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost']; // tab: sold by
$itemObj = new ItemList(array(['id', $_itemId]));
if ($vendors = @$itemObj->getExtendedCost()[$_itemId])
{
$this->extendGlobalData($itemObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$holidays = []; $soldBy = new CreatureList(array(['id', array_keys($vendors)]));
foreach ($sbData as $k => &$row) if (!$soldBy->error)
{ {
$currency = []; $sbData = $soldBy->getListviewData();
$tokens = []; $extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost'];
foreach ($vendors[$k] as $id => $qty) $holidays = [];
foreach ($sbData as $k => &$row)
{ {
if (is_string($id)) $this->subject = [];
continue; $tokens = [];
foreach ($vendors[$k] as $id => $qty)
{
if (is_string($id))
continue;
if ($id > 0) if ($id > 0)
$tokens[] = [$id, $qty]; $tokens[] = [$id, $qty];
else if ($id < 0) else if ($id < 0)
$currency[] = [-$id, $qty]; $this->subject[] = [-$id, $qty];
} }
if ($_ = $vendors[$k]['event']) if ($_ = $vendors[$k]['event'])
{ {
if (count($extraCols) == 3) // not already pushed if (count($extraCols) == 3) // not already pushed
$extraCols[] = 'Listview.extraCols.condition'; $extraCols[] = 'Listview.extraCols.condition';
$holidays[$_] = 0; // applied as back ref. $holidays[$_] = 0; // applied as back ref.
$row['condition'][] = array( $row['condition'][] = array(
'type' => TYPE_WORLDEVENT, 'type' => TYPE_WORLDEVENT,
'typeId' => &$holidays[$_], 'typeId' => &$holidays[$_],
'status' => 1 'status' => 1
);
}
$row['stock'] = $vendors[$k]['stock'];
$row['stack'] = $itemObj->getField('buyCount');
$row['cost'] = array(
$itemObj->getField('buyPrice'),
$this->subject ? $this->subject : null,
$tokens ? $tokens : null
); );
} }
$row['stock'] = $vendors[$k]['stock']; if ($holidays)
$row['stack'] = $itemObj->getField('buyCount'); {
$row['cost'] = array( $hObj = new WorldEventList(array(['id', array_keys($holidays)]));
$itemObj->getField('buyPrice'), $this->extendGlobalData($hObj->getJSGlobals());
$currency ? $currency : null, foreach ($hObj->iterate() as $id => $tpl)
$tokens ? $tokens : null {
if ($_ = $tpl['holidayId'])
$holidays[$tpl['eventBak']] = $_;
else
$holidays[-$id] = $id;
}
}
$this->lvData[] = array(
'file' => 'creature',
'data' => $sbData,
'params' => [
'tabs' => '$tabsRelated',
'name' => '$LANG.tab_soldby',
'id' => 'sold-by-npc',
'extraCols' => '$['.implode(', ', $extraCols).']',
'hiddenCols' => "$['level', 'type']"
]
); );
} }
}
}
if ($holidays) // tab: created by (spell) [for items its handled in Util::getLootSource()]
{ if ($this->typeId == 104)
$hObj = new WorldEventList(array(['id', array_keys($holidays)])); {
$hObj->addGlobalsToJscript(); $createdBy = new SpellList(array(['effect1Id', 45], ['effect2Id', 45], ['effect3Id', 45], 'OR'));
foreach ($hObj->iterate() as $id => $tpl) if (!$createdBy->error)
{ {
if ($_ = $tpl['holidayId']) $this->extendGlobalData($createdBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$holidays[$tpl['eventBak']] = $_;
else
$holidays[-$id] = $id;
}
}
$pageData['relTabs'][] = array( if ($createdBy->hasSetFields(['reagent1']))
'file' => 'creature', $visCols = ['reagents'];
'data' => $sbData,
$this->lvData[] = array(
'file' => 'spell',
'data' => $createdBy->getListviewData(),
'params' => [ 'params' => [
'tabs' => '$tabsRelated', 'tabs' => '$tabsRelated',
'name' => '$LANG.tab_soldby', 'name' => '$LANG.tab_createdby',
'id' => 'sold-by-npc', 'id' => 'created-by',
'extraCols' => '$['.implode(', ', $extraCols).']', 'visibleCols' => isset($visCols) ? '$'.json_encode($visCols) : null
'hiddenCols' => "$['level', 'type']"
] ]
); );
} }
} }
}
// tab: created by (spell) [for items its handled in Util::getLootSource()] // tab: currency for
if ($_id == 104) if ($this->typeId == 103)
{
$createdBy = new SpellList(array(['effect1Id', 45], ['effect2Id', 45], ['effect3Id', 45], 'OR'));
if (!$createdBy->error)
{ {
if ($createdBy->hasSetFields(['reagent1'])) $n = '?items&filter=cr=145;crs=1;crv=0';
$visCols = ['reagents']; $w = 'iec.reqArenaPoints > 0';
}
else if ($this->typeId == 104)
{
$n = '?items&filter=cr=144;crs=1;crv=0';
$w = 'iec.reqHonorPoints > 0';
}
else
{
$n = in_array($this->typeId, [42, 61, 81, 241, 121, 122, 123, 125, 126, 161, 201, 101, 102, 221, 301, 341]) ? '?items&filter=cr=158;crs='.$_itemId.';crv=0' : null;
$w = 'iec.reqItemId1 = '.$_itemId.' OR iec.reqItemId2 = '.$_itemId.' OR iec.reqItemId3 = '.$_itemId.' OR iec.reqItemId4 = '.$_itemId.' OR iec.reqItemId5 = '.$_itemId;
}
$pageData['relTabs'][] = array( $boughtBy = DB::Aowow()->selectCol('
'file' => 'spell', SELECT item FROM npc_vendor nv JOIN ?_itemExtendedCost iec ON iec.id = nv.extendedCost WHERE '.$w.'
'data' => $createdBy->getListviewData(), UNION
'params' => [ SELECT item FROM game_event_npc_vendor genv JOIN ?_itemExtendedCost iec ON iec.id = genv.extendedCost WHERE '.$w
'tabs' => '$tabsRelated', );
'name' => '$LANG.tab_createdby', if ($boughtBy)
'id' => 'created-by', {
'visibleCols' => isset($visCols) ? '$'.json_encode($visCols) : null $boughtBy = new ItemList(array(['id', $boughtBy]));
] if (!$boughtBy->error)
); {
$this->lvData[] = array(
'file' => 'item',
'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, [TYPE_CURRENCY => $this->typeId]),
'params' => [
'tabs' => '$tabsRelated',
'name' => '$LANG.tab_currencyfor',
'id' => 'currency-for',
'extraCols' => "$[Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack'), Listview.extraCols.cost]",
'note' => $n ? '$$WH.sprintf(LANG.lvnote_filterresults, \''.$n.'\')' : null
]
);
$this->extendGlobalData($boughtBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
}
} }
} }
// tab: currency for
if ($_id == 103)
{
$n = '?items&filter=cr=145;crs=1;crv=0';
$w = 'iec.reqArenaPoints > 0';
}
else if ($_id == 104)
{
$n = '?items&filter=cr=144;crs=1;crv=0';
$w = 'iec.reqHonorPoints > 0';
}
else
{
$n = in_array($_id, [42, 61, 81, 241, 121, 122, 123, 125, 126, 161, 201, 101, 102, 221, 301, 341]) ? '?items&filter=cr=158;crs='.$_itemId.';crv=0' : null;
$w = 'iec.reqItemId1 = '.$_itemId.' OR iec.reqItemId2 = '.$_itemId.' OR iec.reqItemId3 = '.$_itemId.' OR iec.reqItemId4 = '.$_itemId.' OR iec.reqItemId5 = '.$_itemId;
}
$boughtBy = DB::Aowow()->selectCol('
SELECT item FROM npc_vendor nv JOIN ?_itemExtendedCost iec ON iec.id = nv.extendedCost WHERE '.$w.'
UNION
SELECT item FROM game_event_npc_vendor genv JOIN ?_itemExtendedCost iec ON iec.id = genv.extendedCost WHERE '.$w
);
if ($boughtBy)
{
$boughtBy = new ItemList(array(['id', $boughtBy]));
if (!$boughtBy->error)
{
$boughtBy->addGlobalsToJscript();
$pageData['relTabs'][] = array(
'file' => 'item',
'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, [TYPE_CURRENCY => $_id]),
'params' => [
'tabs' => '$tabsRelated',
'name' => '$LANG.tab_currencyfor',
'id' => 'currency-for',
'extraCols' => "$[Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack'), Listview.extraCols.cost]",
'note' => $n ? '$$WH.sprintf(LANG.lvnote_filterresults, \''.$n.'\')' : null
]
);
}
}
$smarty->saveCache($cacheKeyPage, $pageData);
} }
$smarty->updatePageVars($pageData['page']);
$smarty->assign('community', CommunityContent::getAll(TYPE_CURRENCY, $_id)); // comments, screenshots, videos
$smarty->assign('lang', array_merge(Lang::$main));
$smarty->assign('lvData', $pageData['relTabs']);
// load the page
$smarty->display('detail-page-generic.tpl');
?> ?>

View File

@@ -4,316 +4,332 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); die('illegal access');
require 'includes/community.class.php'; // menuId 11: Object g_initPath()
// tabId 0: Database g_initHeader()
$_id = intVal($pageParam); class EventPage extends GenericPage
$_path = [0, 11];
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_WORLDEVENT, $_id, -1, User::$localeId]);
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{ {
$conditions = []; use DetailPage;
if ($_id < 0)
$conditions[] = ['id', -$_id];
else
$conditions[] = ['holidayId', $_id];
$event = new WorldEventList($conditions); protected $type = TYPE_WORLDEVENT;
if ($event->error) protected $typeId = 0;
$smarty->notFound(Lang::$game['event'], $_id); protected $tpl = 'detail-page-generic';
protected $path = [0, 11];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
$_hId = $event->getField('holidayId'); private $hId = 0;
$_eId = $event->getField('eventBak'); private $eId = 0;
// redirect if associated with a holiday public function __construct($__, $id)
if ($_hId && $_id != $_hId)
header('Location: '.HOST_URL.'?event='.$_hId);
$hasFilter = in_array($_hId, [372, 283, 285, 353, 420, 400, 284, 201, 374, 409, 141, 324, 321, 424, 335, 327, 341, 181, 404, 398, 301]);
if ($_hId)
{ {
switch ($event->getField('scheduleType')) parent::__construct();
$this->typeId = intVal($id);
$conditions = $this->typeId < 0 ? [['id', -$this->typeId]] : [['holidayId', $this->typeId]];
$this->subject = new WorldEventList($conditions);
if ($this->subject->error)
$this->notFound(Lang::$game['event']);
$this->hId = $this->subject->getField('holidayId');
$this->eId = $this->subject->getField('eventBak');
// redirect if associated with a holiday
if ($this->hId && $this->typeId != $this->hId)
header('Location: '.HOST_URL.'?event='.$this->hId);
$this->name = $this->subject->getField('name', true);
}
protected function generatePath()
{
switch ($this->subject->getField('scheduleType'))
{ {
case -1: $_path[] = 1; break; case '': $this->path[] = 0; break;
case -1: $this->path[] = 1; break;
case 0: case 0:
case 1: $_path[] = 2; break; case 1: $this->path[] = 2; break;
case 2: $_path[] = 3; break; case 2: $this->path[] = 3; break;
} }
} }
else
$_path[] = 0;
/***********/ protected function generateTitle()
/* Infobox */
/***********/
$infobox = [];
// boss
if ($_ = $event->getField('bossCreature'))
{ {
Util::$pageTemplate->extendGlobalIds(TYPE_NPC, $_); array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['event']));
$infobox[] = Lang::$npc['rank'][3].Lang::$colon.'[npc='.$_.']';
} }
// finalized after the cache is handled protected function generateContent()
/****************/
/* Main Content */
/****************/
// menuId 11: Event g_initPath()
// tabId 0: Database g_initHeader()
$pageData = array(
'dates' => array(
'firstDate' => $event->getField('startTime'),
'lastDate' => $event->getField('endTime'),
'length' => $event->getField('length'),
'rec' => $event->getField('occurence')
),
'page' => array(
'title' => $event->getField('name', true).' - '.Util::ucFirst(Lang::$game['event']),
'name' => $event->getField('name', true),
'path' => json_encode($_path, JSON_NUMERIC_CHECK),
'tab' => 0,
'type' => TYPE_WORLDEVENT,
'typeId' => $_id,
'infobox' => $infobox,
'headIcons' => [$event->getField('iconString')],
'redButtons' => array(
BUTTON_WOWHEAD => $_id > 0,
BUTTON_LINKS => true
)
),
'relTabs' => []
);
/**************/
/* Extra Tabs */
/**************/
// tab: npcs
if ($npcIds = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, IF(ec.eventEntry > 0, 1, 0) AS added FROM creature c, game_event_creature ec WHERE ec.guid = c.guid AND ABS(ec.eventEntry) = ?d', $_eId))
{ {
$creatures = new CreatureList(array(['id', array_keys($npcIds)])); /***********/
if (!$creatures->error) /* Infobox */
/***********/
$this->infobox = [];
// boss
if ($_ = $this->subject->getField('bossCreature'))
{ {
$data = $creatures->getListviewData(); $this->extendGlobalIds(TYPE_NPC, $_);
$this->infobox[] = Lang::$npc['rank'][3].Lang::$main['colon'].'[npc='.$_.']';
foreach ($data as &$d)
$d['method'] = $npcIds[$d['id']];
$pageData['relTabs'][] = array(
'file' => CreatureList::$brickFile,
'data' => $data,
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?npcs&filter=cr=38;crs='.$_hId.';crv=0') : null
)
);
} }
}
// tab: objects /****************/
if ($objectIds = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, IF(eg.eventEntry > 0, 1, 0) AS added FROM gameobject g, game_event_gameobject eg WHERE eg.guid = g.guid AND ABS(eg.eventEntry) = ?d', $_eId)) /* Main Content */
{ /****************/
$objects = new GameObjectList(array(['id', array_keys($objectIds)]));
if (!$objects->error)
{
$data = $objects->getListviewData();
foreach ($data as &$d)
$d['method'] = $objectIds[$d['id']];
$pageData['relTabs'][] = array( $this->headIcons = [$this->subject->getField('iconString')];
'file' => GameObjectList::$brickFile, $this->redButtons = array(
'data' => $data, BUTTON_WOWHEAD => $this->typeId > 0,
'params' => array( BUTTON_LINKS => true
'tabs' => '$tabsRelated', );
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?objects&filter=cr=16;crs='.$_hId.';crv=0') : null $this->dates = array(
) 'firstDate' => $this->subject->getField('startTime'),
); 'lastDate' => $this->subject->getField('endTime'),
} 'length' => $this->subject->getField('length'),
} 'rec' => $this->subject->getField('occurence')
// tab: achievements
if ($_ = $event->getField('achievementCatOrId'))
{
$condition = $_ > 0 ? [['category', $_]] : [['id', -$_]];
$acvs = new AchievementList($condition);
if (!$acvs->error)
{
$acvs->addGlobalsToJScript(GLOBALINFO_SELF | GLOBALINFO_RELATED);
$pageData['relTabs'][] = array(
'file' => AchievementList::$brickFile,
'data' => $acvs->getListviewData(),
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?achievements&filter=cr=11;crs='.$_hId.';crv=0') : null,
'visibleCols' => "$['category']"
)
);
}
}
$itemCnd = [];
if ($_hId)
{
$itemCnd = array(
'OR',
['holidayId', $_hId], // direct requirement on item
); );
// tab: quests (by table, go & creature) /**************/
$quests = new QuestList(array(['holidayId', $_hId])); /* Extra Tabs */
if (!$quests->error) /**************/
$hasFilter = in_array($this->hId, [372, 283, 285, 353, 420, 400, 284, 201, 374, 409, 141, 324, 321, 424, 335, 327, 341, 181, 404, 398, 301]);
// tab: npcs
if ($npcIds = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, IF(ec.eventEntry > 0, 1, 0) AS added FROM creature c, game_event_creature ec WHERE ec.guid = c.guid AND ABS(ec.eventEntry) = ?d', $this->eId))
{ {
$quests->addGlobalsToJScript(GLOBALINFO_SELF | GLOBALINFO_REWARDS); $creatures = new CreatureList(array(['id', array_keys($npcIds)]));
if (!$creatures->error)
$pageData['relTabs'][] = array(
'file' => QuestList::$brickFile,
'data' => $quests->getListviewData(),
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?quests&filter=cr=33;crs='.$_hId.';crv=0') : null
)
);
$questItems = [];
foreach (array_column($quests->rewards, TYPE_ITEM) as $arr)
$questItems = array_merge($questItems, $arr);
foreach (array_column($quests->requires, TYPE_ITEM) as $arr)
$questItems = array_merge($questItems, $arr);
if ($questItems)
$itemCnd[] = ['id', $questItems];
}
}
// items from creature
if ($npcIds && !$creatures->error)
{
// vendor
$cIds = $creatures->getFoundIDs();
if ($sells = DB::Aowow()->selectCol('SELECT item FROM npc_vendor nv WHERE entry IN (?a) UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id IN (?a)', $cIds, $cIds))
$itemCnd[] = ['id', $sells];
}
// tab: items
// not checking for loot ... cant distinguish between eventLoot and fillerCrapLoot
if ($itemCnd)
{
$eventItems = new ItemList($itemCnd);
if (!$eventItems->error)
{
$eventItems->addGlobalsToJScript(GLOBALINFO_SELF);
$pageData['relTabs'][] = array(
'file' => ItemList::$brickFile,
'data' => $eventItems->getListviewData(),
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?items&filter=cr=160;crs='.$_hId.';crv=0') : null
)
);
}
}
// tab: see also (event conditions)
if ($rel = DB::Aowow()->selectCol('SELECT IF(eventEntry = prerequisite_event, NULL, IF(eventEntry = ?d, -prerequisite_event, eventEntry)) FROM game_event_prerequisite WHERE prerequisite_event = ?d OR eventEntry = ?d', $_eId, $_eId, $_eId))
{
$list = [];
array_walk($rel, function(&$v, $k) use (&$list) {
if ($v > 0)
$list[] = $v;
else if ($v === null)
Util::$pageTemplate->internalNotice(U_GROUP_EMPLOYEE, 'game_event_prerequisite: this event has itself as prerequisite');
});
if ($list)
{
$relEvents = new WorldEventList(array(['id', $list]));
$relEvents->addGlobalsToJscript();
$relData = $relEvents->getListviewData(true);
foreach ($relEvents->iterate() as $id => $__)
{ {
$relData[$id]['condition'] = array( $data = $creatures->getListviewData();
'type' => TYPE_WORLDEVENT, foreach ($data as &$d)
'typeId' => -$_eId, $d['method'] = $npcIds[$d['id']];
'status' => 2
$this->lvData[] = array(
'file' => CreatureList::$brickFile,
'data' => $data,
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?npcs&filter=cr=38;crs='.$this->hId.';crv=0') : null
)
); );
} }
}
$event->addGlobalsToJscript(); // tab: objects
foreach ($rel as $r) if ($objectIds = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, IF(eg.eventEntry > 0, 1, 0) AS added FROM gameobject g, game_event_gameobject eg WHERE eg.guid = g.guid AND ABS(eg.eventEntry) = ?d', $this->eId))
{
$objects = new GameObjectList(array(['id', array_keys($objectIds)]));
if (!$objects->error)
{ {
if ($r >= 0) $data = $objects->getListviewData();
continue; foreach ($data as &$d)
$d['method'] = $objectIds[$d['id']];
Util::$pageTemplate->extendGlobalIds(TYPE_WORLDEVENT, -$r); $this->lvData[] = array(
'file' => GameObjectList::$brickFile,
'data' => $data,
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?objects&filter=cr=16;crs='.$this->hId.';crv=0') : null
)
);
}
}
$d = $event->getListviewData(true); // tab: achievements
$d[-$_eId]['condition'][] = array( if ($_ = $this->subject->getField('achievementCatOrId'))
'type' => TYPE_WORLDEVENT, {
'typeId' => $r, $condition = $_ > 0 ? [['category', $_]] : [['id', -$_]];
'status' => 2 $acvs = new AchievementList($condition);
if (!$acvs->error)
{
$this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$this->lvData[] = array(
'file' => AchievementList::$brickFile,
'data' => $acvs->getListviewData(),
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?achievements&filter=cr=11;crs='.$this->hId.';crv=0') : null,
'visibleCols' => "$['category']"
)
);
}
}
$itemCnd = [];
if ($this->hId)
{
$itemCnd = array(
'OR',
['holidayId', $this->hId], // direct requirement on item
);
// tab: quests (by table, go & creature)
$quests = new QuestList(array(['holidayId', $this->hId]));
if (!$quests->error)
{
$this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS));
$this->lvData[] = array(
'file' => QuestList::$brickFile,
'data' => $quests->getListviewData(),
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?quests&filter=cr=33;crs='.$this->hId.';crv=0') : null
)
); );
$relData= array_merge($relData, $d); $questItems = [];
} foreach (array_column($quests->rewards, TYPE_ITEM) as $arr)
$questItems = array_merge($questItems, $arr);
$pageData['relTabs'][] = array( foreach (array_column($quests->requires, TYPE_ITEM) as $arr)
'file' => WorldEventList::$brickFile, $questItems = array_merge($questItems, $arr);
'data' => $relData,
'params' => array( if ($questItems)
'id' => 'see-also', $itemCnd[] = ['id', $questItems];
'name' => '$LANG.tab_seealso', }
'tabs' => '$tabsRelated', }
'hiddenCols' => "$['date']",
'extraCols' => '$[Listview.extraCols.condition]' // items from creature
) if ($npcIds && !$creatures->error)
); {
// vendor
$cIds = $creatures->getFoundIDs();
if ($sells = DB::Aowow()->selectCol('SELECT item FROM npc_vendor nv WHERE entry IN (?a) UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id IN (?a)', $cIds, $cIds))
$itemCnd[] = ['id', $sells];
}
// tab: items
// not checking for loot ... cant distinguish between eventLoot and fillerCrapLoot
if ($itemCnd)
{
$eventItems = new ItemList($itemCnd);
if (!$eventItems->error)
{
$this->extendGlobalData($eventItems->getJSGlobals(GLOBALINFO_SELF));
$this->lvData[] = array(
'file' => ItemList::$brickFile,
'data' => $eventItems->getListviewData(),
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?items&filter=cr=160;crs='.$this->hId.';crv=0') : null
)
);
}
}
// tab: see also (event conditions)
if ($rel = DB::Aowow()->selectCol('SELECT IF(eventEntry = prerequisite_event, NULL, IF(eventEntry = ?d, -prerequisite_event, eventEntry)) FROM game_event_prerequisite WHERE prerequisite_event = ?d OR eventEntry = ?d', $this->eId, $this->eId, $this->eId))
{
$list = [];
array_walk($rel, function($v, $k) use (&$list) {
if ($v > 0)
$list[] = $v;
else if ($v === null)
Util::addNote(U_GROUP_EMPLOYEE, 'game_event_prerequisite: this event has itself as prerequisite');
});
if ($list)
{
$relEvents = new WorldEventList(array(['id', $list]));
$this->extendGlobalData($relEvents->getJSGlobals());
$relData = $relEvents->getListviewData();
foreach ($relEvents->iterate() as $id => $__)
{
$relData[$id]['condition'][] = array(
'type' => TYPE_WORLDEVENT,
'typeId' => -$this->eId,
'status' => 2
);
}
$this->extendGlobalData($this->subject->getJSGlobals());
foreach ($rel as $r)
{
if ($r >= 0)
continue;
$this->extendGlobalIds(TYPE_WORLDEVENT, -$r);
$d = $this->subject->getListviewData();
$d[-$this->eId]['condition'][] = array(
'type' => TYPE_WORLDEVENT,
'typeId' => $r,
'status' => 2
);
$relData = array_merge($relData, $d);
}
$this->lvData[] = array(
'file' => WorldEventList::$brickFile,
'data' => $relData,
'params' => array(
'id' => 'see-also',
'name' => '$LANG.tab_seealso',
'tabs' => '$tabsRelated',
'hiddenCols' => "$['date']",
'extraCols' => '$[Listview.extraCols.condition]'
)
);
}
} }
} }
protected function postCache()
{
/********************/
/* finalize infobox */
/********************/
$smarty->saveCache($cacheKeyPage, $pageData); // update dates to now()
$updated = WorldEventList::updateDates($this->dates);
// start
if ($updated['start'])
array_push($this->infobox, Lang::$event['start'].Lang::$main['colon'].date(Lang::$main['dateFmtLong'], $updated['start']));
// end
if ($updated['end'])
array_push($this->infobox, Lang::$event['end'].Lang::$main['colon'].date(Lang::$main['dateFmtLong'], $updated['end']));
// occurence
if ($updated['rec'] > 0)
array_push($this->infobox, Lang::$event['interval'].Lang::$main['colon'].Util::formatTime($updated['rec'] * 1000));
// in progress
if ($updated['start'] < time() && $updated['end'] > time())
array_push($this->infobox, '[span class=q2]'.Lang::$event['inProgress'].'[/span]');
$this->infobox = '[ul][li]'.implode('[/li][li]', $this->infobox).'[/li][/ul]';
/***************************/
/* finalize related events */
/***************************/
foreach($this->lvData as &$view)
{
if ($view['file'] != WorldEventList::$brickFile)
continue;
foreach ($view['data'] as &$data)
{
$updated = WorldEventList::updateDates($data['_date']);
unset($data['_date']);
$data['startDate'] = $updated['start'] ? date(Util::$dateFormatInternal, $updated['start']) : false;
$data['endDate'] = $updated['end'] ? date(Util::$dateFormatInternal, $updated['end']) : false;
$data['rec'] = $updated['rec'];
}
}
}
} }
/***********/
/* Infobox */
/***********/
$updated = WorldEventList::updateDates($pageData['dates']);
// start
if ($updated['end'])
array_push($pageData['page']['infobox'], Lang::$event['start'].Lang::$colon.date(Lang::$dateFmtLong, $updated['start']));
// end
if ($updated['end'])
array_push($pageData['page']['infobox'], Lang::$event['end'].Lang::$colon.date(Lang::$dateFmtLong, $updated['end']));
// occurence
if ($updated['rec'] > 0)
array_push($pageData['page']['infobox'], Lang::$event['interval'].Lang::$colon.Util::formatTime($updated['rec'] * 1000));
// in progress
if ($updated['start'] < time() && $updated['end'] > time())
array_push($pageData['page']['infobox'], '[span class=q2]'.Lang::$event['inProgress'].'[/span]');
$pageData['page']['infobox'] = '[ul][li]'.implode('[/li][li]', $pageData['page']['infobox']).'[/li][/ul]';
$smarty->updatePageVars($pageData['page']);
$smarty->assign('community', CommunityContent::getAll(TYPE_WORLDEVENT, $_id)); // comments, screenshots, videos
$smarty->assign('lang', array_merge(Lang::$main));
$smarty->assign('lvData', $pageData['relTabs']);
// load the page
$smarty->display('detail-page-generic.tpl');
?> ?>

View File

@@ -4,97 +4,103 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); die('illegal access');
$cat = Util::extractURLParams($pageParam); // menuId 11: Event g_initPath()
$condition = []; // tabId 0: Database g_initHeader()
$path = [0, 11]; class EventsPage extends GenericPage
$validCats = [0, 1, 2, 3];
$title = [Lang::$game['events']];
$cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_WORLDEVENT, -1, $cat ? $cat[0] : -1, User::$localeId]);
if (!Util::isValidPage($validCats, $cat))
$smarty->error();
if (!$smarty->loadCache($cacheKey, $pageData))
{ {
if ($cat) use ListPage;
protected $type = TYPE_WORLDEVENT;
protected $tpl = 'list-page-generic';
protected $path = [0, 11];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
protected $validCats = [0, 1, 2, 3];
public function __construct($pageCall, $pageParam)
{ {
$path[] = $cat[0]; $this->getCategoryFromUrl($pageParam);;
array_unshift($title, Lang::$event['category'][$cat[0]]);
switch ($cat[0]) parent::__construct();
{
case 0: $condition[] = ['e.holidayId', 0]; break; $this->name = Util::ucFirst(Lang::$game['events']);
case 1: $condition[] = ['h.scheduleType', -1]; break;
case 2: $condition[] = ['h.scheduleType', [0, 1]]; break;
case 3: $condition[] = ['h.scheduleType', 2]; break;
}
} }
$events = new WorldEventList($condition); protected function generateContent()
$events->addGlobalsToJScript();
$deps = [];
foreach ($events->iterate() as $__)
if ($d = $events->getField('requires'))
$deps[$events->id] = $d;
// menuId 11: Event g_initPath()
// tabId 0: Database g_initHeader()
$pageData = array(
'page' => array(
'tab' => 0,
'title' => implode(" - ", $title),
'path' => json_encode($path, JSON_NUMERIC_CHECK)
),
'lv' => [],
'deps' => $deps
);
$pageData['lv'][] = array(
'file' => 'event',
'data' => $events->getListviewData(),
'params' => ['tabs' => '$myTabs']
);
$pageData['lv'][] = array(
'file' => 'calendar',
'data' => array_filter($events->getListviewData(), function($x) {return $x['id'] > 0;}),
'params' => array(
'tabs' => '$myTabs',
'hideCount' => 1
)
);
$smarty->saveCache($cacheKey, $pageData);
}
// recalculate dates with now(); can't be cached, obviously
foreach ($pageData['lv'] as &$views)
{
foreach ($views['data'] as &$data)
{ {
// is a followUp-event $condition = [];
if (!empty($pageData['deps'][$data['id']]))
if ($this->category)
{ {
$data['startDate'] = $data['endDate'] = false; switch ($this->category[0])
unset($data['_date']); {
continue; case 0: $condition[] = ['e.holidayId', 0]; break;
case 1: $condition[] = ['h.scheduleType', -1]; break;
case 2: $condition[] = ['h.scheduleType', [0, 1]]; break;
case 3: $condition[] = ['h.scheduleType', 2]; break;
}
} }
$updated = WorldEventList::updateDates($data['_date']); $events = new WorldEventList($condition);
unset($data['_date']); $this->extendGlobalData($events->getJSGlobals());
$data['startDate'] = $updated['start'] ? date(Util::$dateFormatInternal, $updated['start']) : false;
$data['endDate'] = $updated['end'] ? date(Util::$dateFormatInternal, $updated['end']) : false; $this->deps = [];
$data['rec'] = $updated['rec']; foreach ($events->iterate() as $__)
if ($d = $events->getField('requires'))
$this->deps[$events->id] = $d;
$this->lvData[] = array(
'file' => 'event',
'data' => $events->getListviewData(),
'params' => ['tabs' => '$myTabs']
);
$this->lvData[] = array(
'file' => 'calendar',
'data' => array_filter($events->getListviewData(), function($x) {return $x['id'] > 0;}),
'params' => array(
'tabs' => '$myTabs',
'hideCount' => 1
)
);
}
protected function generateTitle()
{
array_unshift($this->title, $this->name);
if ($this->category)
array_unshift($this->title, Lang::$event['category'][$this->category[0]]);
}
protected function generatePath()
{
if ($this->category)
$this->path[] = $this->category[0];
}
protected function postCache()
{
// recalculate dates with now()
foreach ($this->lvData as &$views)
{
foreach ($views['data'] as &$data)
{
// is a followUp-event
if (!empty($this->deps[$data['id']]))
{
$data['startDate'] = $data['endDate'] = false;
unset($data['_date']);
continue;
}
$updated = WorldEventList::updateDates($data['_date']);
unset($data['_date']);
$data['startDate'] = $updated['start'] ? date(Util::$dateFormatInternal, $updated['start']) : false;
$data['endDate'] = $updated['end'] ? date(Util::$dateFormatInternal, $updated['end']) : false;
$data['rec'] = $updated['rec'];
}
}
} }
} }
$smarty->updatePageVars($pageData['page']);
$smarty->assign('lang', Lang::$main);
$smarty->assign('lvData', $pageData['lv']);
// load the page
$smarty->display('list-page-generic.tpl');
?> ?>

View File

@@ -4,305 +4,300 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); die('illegal access');
require 'includes/community.class.php'; // menuId 7: Faction g_initPath()
// tabId 0: Database g_initHeader()
$_id = intVal($pageParam); class FactionPage extends GenericPage
$_path = [0, 7];
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_FACTION, $_id, -1, User::$localeId]);
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{ {
$faction = new FactionList(array(['id', $_id])); use DetailPage;
if ($faction->error)
$smarty->notFound(Lang::$game['faction'], $_id);
if ($foo = $faction->getField('cat')) protected $type = TYPE_FACTION;
protected $typeId = 0;
protected $tpl = 'detail-page-generic';
protected $path = [0, 7];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
public function __construct($__, $id)
{ {
if ($bar = $faction->getField('cat2')) parent::__construct();
$_path[] = $bar;
$_path[] = $foo; $this->typeId = intVal($id);
$this->subject = new FactionList(array(['id', $this->typeId]));
if ($this->subject->error)
$smarty->notFound(Lang::$game['faction']);
$this->name = $this->subject->getField('name', true);
} }
protected function generatePath()
/***********/
/* Infobox */
/***********/
$infobox = [];
// Quartermaster if any
if ($ids = $faction->getField('qmNpcIds'))
{ {
Util::$pageTemplate->extendGlobalIds(TYPE_NPC, $ids); if ($foo = $this->subject->getField('cat'))
$qmStr = Lang::$faction['quartermaster'].Lang::$colon;
if (count($ids) == 1)
$qmStr .= '[npc='.$ids[0].']';
else if (count($ids) > 1)
{ {
$qmStr .= '[ul]'; if ($bar = $this->subject->getField('cat2'))
foreach ($ids as $id) $this->path[] = $bar;
$qmStr .= '[li][npc='.$id.'][/li]';
$qmStr .= '[/ul]'; $this->path[] = $foo;
} }
$infobox[] = $qmStr;
} }
// side if any protected function generateTitle()
if ($_ = $faction->getField('side'))
$infobox[] = Lang::$main['side'].Lang::$colon.'[span class=icon-'.($_ == 1 ? 'alliance' : 'horde').']'.Lang::$game['si'][$_].'[/span]';
/****************/
/* Main Content */
/****************/
// menuId 7: Faction g_initPath()
// tabId 0: Database g_initHeader()
$pageData = array(
'page' => array(
'title' => $faction->getField('name', true)." - ".Util::ucfirst(Lang::$game['faction']),
'path' => json_encode($_path, JSON_NUMERIC_CHECK),
'tab' => 0,
'type' => TYPE_FACTION,
'typeId' => $_id,
'extraText' => '',
'infobox' => $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null,
'redButtons' => array(
BUTTON_WOWHEAD => true,
BUTTON_LINKS => true
),
'name' => $faction->getField('name', true)
),
'relTabs' => []
);
// Spillover Effects
/* todo (low): also check on reputation_spillover_template (but its data is identical to calculation below
$rst = DB::Aowow()->selectRow('SELECT
CONCAT_WS(" ", faction1, faction2, faction3, faction4) AS faction,
CONCAT_WS(" ", rate_1, rate_2, rate_3, rate_4) AS rate,
CONCAT_WS(" ", rank_1, rank_2, rank_3, rank_4) AS rank
FROM reputation_spillover_template WHERE faction = ?d', $_id);
*/
$conditions = array(
['id', $_id, '!'], // not self
['reputationIndex', -1, '!'] // only gainable
);
if ($p = $faction->getField('parentFactionId')) // linked via parent
$conditions[] = ['OR', ['id', $p], ['parentFactionId', $p]];
else
$conditions[] = ['parentFactionId', $_id]; // self as parent
$spillover = new FactionList($conditions);
$spillover->addGlobalsToJscript();
$buff = [];
foreach ($spillover->iterate() as $spillId => $__)
if ($val = ($spillover->getField('spilloverRateIn') * $faction->getField('spilloverRateOut') * 100))
$buff[] = '[tr][td][faction='.$spillId.'][/td][td][span class=q'.($val > 0 ? '2]+' : '10]').$val.'%[/span][/td][td]'.Lang::$game['rep'][$spillover->getField('spilloverMaxRank')].'[/td][/tr]';
if ($buff)
$pageData['page']['extraText'] .= '[h3 class=clear]'.Lang::$faction['spillover'].'[/h3][div margin=15px]'.Lang::$faction['spilloverDesc'].'[/div][table class=grid width=400px][tr][td width=150px][b]'.Util::ucFirst(Lang::$game['faction']).'[/b][/td][td width=100px][b]'.Lang::$spell['_value'].'[/b][/td][td width=150px][b]'.Lang::$faction['maxStanding'].'[/b][/td][/tr]'.implode('', $buff).'[/table]';
// reward rates
if ($rates = DB::Aowow()->selectRow('SELECT * FROM reputation_reward_rate WHERE faction = ?d', $_id))
{ {
$buff = ''; array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['faction']));
foreach ($rates as $k => $v) }
{
if ($v == 1)
continue;
switch ($k) protected function generateContent()
{
/***********/
/* Infobox */
/***********/
$infobox = [];
// Quartermaster if any
if ($ids = $this->subject->getField('qmNpcIds'))
{
$this->extendGlobalIds(TYPE_NPC, $ids);
$qmStr = Lang::$faction['quartermaster'].Lang::$main['colon'];
if (count($ids) == 1)
$qmStr .= '[npc='.$ids[0].']';
else if (count($ids) > 1)
{ {
case 'quest_rate': $buff .= '[tr][td]'.Lang::$game['quests'].Lang::$colon.'[/td]'; break; $qmStr .= '[ul]';
case 'quest_daily_rate': $buff .= '[tr][td]'.Lang::$game['quests'].' ('.Lang::$quest['daily'].')'.Lang::$colon.'[/td]'; break; foreach ($ids as $id)
case 'quest_weekly_rate': $buff .= '[tr][td]'.Lang::$game['quests'].' ('.Lang::$quest['weekly'].')'.Lang::$colon.'[/td]'; break; $qmStr .= '[li][npc='.$id.'][/li]';
case 'quest_monthly_rate': $buff .= '[tr][td]'.Lang::$game['quests'].' ('.Lang::$quest['monthly'].')'.Lang::$colon.'[/td]'; break;
case 'creature_rate': $buff .= '[tr][td]'.Lang::$game['npcs'].Lang::$colon.'[/td]'; break; $qmStr .= '[/ul]';
case 'spell_rate': $buff .= '[tr][td]'.Lang::$game['spells'].Lang::$colon.'[/td]'; break;
} }
$buff .= '[td width=30px align=right]x'.number_format($v, 1).'[/td][/tr]'; $infobox[] = $qmStr;
} }
// side if any
if ($_ = $this->subject->getField('side'))
$infobox[] = Lang::$main['side'].Lang::$main['colon'].'[span class=icon-'.($_ == 1 ? 'alliance' : 'horde').']'.Lang::$game['si'][$_].'[/span]';
/****************/
/* Main Content */
/****************/
$this->extraText = '';
$this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null;
$this->redButtons = array(
BUTTON_WOWHEAD => true,
BUTTON_LINKS => true
);
// Spillover Effects
/* todo (low): also check on reputation_spillover_template (but its data is identical to calculation below
$rst = DB::Aowow()->selectRow('SELECT
CONCAT_WS(" ", faction1, faction2, faction3, faction4) AS faction,
CONCAT_WS(" ", rate_1, rate_2, rate_3, rate_4) AS rate,
CONCAT_WS(" ", rank_1, rank_2, rank_3, rank_4) AS rank
FROM reputation_spillover_template WHERE faction = ?d', $this->typeId);
*/
$conditions = array(
['id', $this->typeId, '!'], // not self
['reputationIndex', -1, '!'] // only gainable
);
if ($p = $this->subject->getField('parentFactionId')) // linked via parent
$conditions[] = ['OR', ['id', $p], ['parentFactionId', $p]];
else
$conditions[] = ['parentFactionId', $this->typeId]; // self as parent
$spillover = new FactionList($conditions);
$this->extendGlobalData($spillover->getJSGlobals());
$buff = '';
foreach ($spillover->iterate() as $spillId => $__)
if ($val = ($spillover->getField('spilloverRateIn') * $this->subject->getField('spilloverRateOut') * 100))
$buff .= '[tr][td][faction='.$spillId.'][/td][td][span class=q'.($val > 0 ? '2]+' : '10]').$val.'%[/span][/td][td]'.Lang::$game['rep'][$spillover->getField('spilloverMaxRank')].'[/td][/tr]';
if ($buff) if ($buff)
$pageData['page']['extraText'] = '[h3 class=clear][Custom Reward Rate][/h3][table]'.$buff.'[/table]'; $this->extraText .= '[h3 class=clear]'.Lang::$faction['spillover'].'[/h3][div margin=15px]'.Lang::$faction['spilloverDesc'].'[/div][table class=grid width=400px][tr][td width=150px][b]'.Util::ucFirst(Lang::$game['faction']).'[/b][/td][td width=100px][b]'.Lang::$spell['_value'].'[/b][/td][td width=150px][b]'.Lang::$faction['maxStanding'].'[/b][/td][/tr]'.$buff.'[/table]';
}
/**************/
/* Extra Tabs */
/**************/
// tab: items // reward rates
$items = new ItemList(array(['requiredFaction', $_id])); if ($rates = DB::Aowow()->selectRow('SELECT * FROM reputation_reward_rate WHERE faction = ?d', $this->typeId))
if (!$items->error)
{
$items->addGlobalsToJScript(GLOBALINFO_SELF);
$tab = array(
'file' => 'item',
'data' => $items->getListviewData(),
'showRep' => true,
'params' => array(
'tabs' => '$tabsRelated',
'extraCols' => '$_',
'sort' => "$['standing', 'name']"
)
);
if ($items->getMatches() > CFG_SQL_LIMIT_DEFAULT)
$tab['params']['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=17;crs='.$_id.';crv=0');
$pageData['relTabs'][] = $tab;
}
// tab: creatures with onKill reputation
if ($faction->getField('reputationIndex') != -1) // only if you can actually gain reputation by kills
{
$cIds = DB::Aowow()->selectCol('SELECT DISTINCT cor.creature_id FROM creature_onkill_reputation cor, ?_factions f WHERE
(cor.RewOnKillRepValue1 > 0 AND (cor.RewOnKillRepFaction1 = ?d OR (cor.RewOnKillRepFaction1 = f.id AND f.parentFactionId = ?d AND cor.IsTeamAward1 <> 0))) OR
(cor.RewOnKillRepValue2 > 0 AND (cor.RewOnKillRepFaction2 = ?d OR (cor.RewOnKillRepFaction2 = f.id AND f.parentFactionId = ?d AND cor.IsTeamAward2 <> 0)))',
$_id, $faction->getField('parentFactionId'),
$_id, $faction->getField('parentFactionId')
);
if ($cIds)
{ {
$killCreatures = new CreatureList(array(['id', $cIds])); $buff = '';
if (!$killCreatures->error) foreach ($rates as $k => $v)
{ {
$killCreatures->addGlobalsToJscript(); if ($v == 1)
continue;
switch ($k)
{
case 'quest_rate': $buff .= '[tr][td]'.Lang::$game['quests'].Lang::$main['colon'].'[/td]'; break;
case 'quest_daily_rate': $buff .= '[tr][td]'.Lang::$game['quests'].' ('.Lang::$quest['daily'].')'.Lang::$main['colon'].'[/td]'; break;
case 'quest_weekly_rate': $buff .= '[tr][td]'.Lang::$game['quests'].' ('.Lang::$quest['weekly'].')'.Lang::$main['colon'].'[/td]'; break;
case 'quest_monthly_rate': $buff .= '[tr][td]'.Lang::$game['quests'].' ('.Lang::$quest['monthly'].')'.Lang::$main['colon'].'[/td]'; break;
case 'creature_rate': $buff .= '[tr][td]'.Lang::$game['npcs'].Lang::$main['colon'].'[/td]'; break;
case 'spell_rate': $buff .= '[tr][td]'.Lang::$game['spells'].Lang::$main['colon'].'[/td]'; break;
}
$buff .= '[td width=30px align=right]x'.number_format($v, 1).'[/td][/tr]';
}
if ($buff)
$this->extraText .= '[h3 class=clear][Custom Reward Rate][/h3][table]'.$buff.'[/table]';
}
/**************/
/* Extra Tabs */
/**************/
// tab: items
$items = new ItemList(array(['requiredFaction', $this->typeId]));
if (!$items->error)
{
$this->extendGlobalData($items->getJSGlobals(GLOBALINFO_SELF));
$tab = array(
'file' => 'item',
'data' => $items->getListviewData(),
'showRep' => true,
'params' => array(
'tabs' => '$tabsRelated',
'extraCols' => '$_',
'sort' => "$['standing', 'name']"
)
);
if ($items->getMatches() > CFG_SQL_LIMIT_DEFAULT)
$tab['params']['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=17;crs='.$this->typeId.';crv=0');
$this->lvData[] = $tab;
}
// tab: creatures with onKill reputation
if ($this->subject->getField('reputationIndex') != -1) // only if you can actually gain reputation by kills
{
$cIds = DB::Aowow()->selectCol('SELECT DISTINCT cor.creature_id FROM creature_onkill_reputation cor, ?_factions f WHERE
(cor.RewOnKillRepValue1 > 0 AND (cor.RewOnKillRepFaction1 = ?d OR (cor.RewOnKillRepFaction1 = f.id AND f.parentFactionId = ?d AND cor.IsTeamAward1 <> 0))) OR
(cor.RewOnKillRepValue2 > 0 AND (cor.RewOnKillRepFaction2 = ?d OR (cor.RewOnKillRepFaction2 = f.id AND f.parentFactionId = ?d AND cor.IsTeamAward2 <> 0)))',
$this->typeId, $this->subject->getField('parentFactionId'),
$this->typeId, $this->subject->getField('parentFactionId')
);
if ($cIds)
{
$killCreatures = new CreatureList(array(['id', $cIds]));
if (!$killCreatures->error)
{
$tab = array(
'file' => 'creature',
'data' => $killCreatures->getListviewData(),
'showRep' => true,
'params' => array(
'tabs' => '$tabsRelated',
)
);
if ($killCreatures->getMatches() > CFG_SQL_LIMIT_DEFAULT)
$tab['params']['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=42;crs='.$this->typeId.';crv=0');
$this->lvData[] = $tab;
}
}
}
// tab: members
if ($_ = $this->subject->getField('templateIds'))
{
$members = new CreatureList(array(['faction', $_]));
if (!$members->error)
{
$tab = array( $tab = array(
'file' => 'creature', 'file' => 'creature',
'data' => $killCreatures->getListviewData(), 'data' => $members->getListviewData(),
'showRep' => true, 'showRep' => true,
'params' => array(
'id' => 'member',
'name' => '$LANG.tab_members',
'tabs' => '$tabsRelated'
)
);
if ($members->getMatches() > CFG_SQL_LIMIT_DEFAULT)
$tab['params']['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=3;crs='.$this->typeId.';crv=0');
$this->lvData[] = $tab;
}
}
// tab: objects
if ($_ = $this->subject->getField('templateIds'))
{
$objects = new GameObjectList(array(['faction', $_]));
if (!$objects->error)
{
$this->lvData[] = array(
'file' => 'object',
'data' => $objects->getListviewData(),
'params' => array( 'params' => array(
'tabs' => '$tabsRelated', 'tabs' => '$tabsRelated',
) )
); );
if ($killCreatures->getMatches() > CFG_SQL_LIMIT_DEFAULT)
$tab['params']['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=42;crs='.$_id.';crv=0');
$pageData['relTabs'][] = $tab;
} }
} }
}
// tab: members // tab: quests
if ($_ = $faction->getField('templateIds')) $conditions = array(
{ ['AND', ['rewardFactionId1', $this->typeId], ['rewardFactionValue1', 0, '>']],
$members = new CreatureList(array(['faction', $_])); ['AND', ['rewardFactionId2', $this->typeId], ['rewardFactionValue2', 0, '>']],
if (!$members->error) ['AND', ['rewardFactionId3', $this->typeId], ['rewardFactionValue3', 0, '>']],
['AND', ['rewardFactionId4', $this->typeId], ['rewardFactionValue4', 0, '>']],
['AND', ['rewardFactionId5', $this->typeId], ['rewardFactionValue5', 0, '>']],
'OR'
);
$quests = new QuestList($conditions);
if (!$quests->error)
{ {
$members->addGlobalsToJscript(); $this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_ANY));
$tab = array( $tab = array(
'file' => 'creature', 'file' => 'quest',
'data' => $members->getListviewData(), 'data' => $quests->getListviewData($this->typeId),
'showRep' => true, 'showRep' => true,
'params' => array(
'id' => 'member',
'name' => '$LANG.tab_members',
'tabs' => '$tabsRelated'
)
);
if ($members->getMatches() > CFG_SQL_LIMIT_DEFAULT)
$tab['params']['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=3;crs='.$_id.';crv=0');
$pageData['relTabs'][] = $tab;
}
}
// tab: objects
if ($_ = $faction->getField('templateIds'))
{
$objects = new GameObjectList(array(['faction', $_]));
if (!$objects->error)
{
$pageData['relTabs'][] = array(
'file' => 'object',
'data' => $objects->getListviewData(),
'params' => array( 'params' => array(
'tabs' => '$tabsRelated', 'tabs' => '$tabsRelated',
'extraCols' => '$_'
)
);
if ($quests->getMatches() > CFG_SQL_LIMIT_DEFAULT)
$tab['params']['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=1;crs='.$this->typeId.';crv=0');
$this->lvData[] = $tab;
}
// tab: achievements
$conditions = array(
['ac.type', ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION],
['ac.value1', $this->typeId]
);
$acvs = new AchievementList($conditions);
if (!$acvs->error)
{
$this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_ANY));
$this->lvData[] = array(
'file' => 'achievement',
'data' => $acvs->getListviewData(),
'params' => array(
'id' => 'criteria-of',
'name' => '$LANG.tab_criteriaof',
'tabs' => '$tabsRelated',
'visibleCols' => "$['category']"
) )
); );
} }
} }
// tab: quests
$conditions = array(
['AND', ['rewardFactionId1', $_id], ['rewardFactionValue1', 0, '>']],
['AND', ['rewardFactionId2', $_id], ['rewardFactionValue2', 0, '>']],
['AND', ['rewardFactionId3', $_id], ['rewardFactionValue3', 0, '>']],
['AND', ['rewardFactionId4', $_id], ['rewardFactionValue4', 0, '>']],
['AND', ['rewardFactionId5', $_id], ['rewardFactionValue5', 0, '>']],
'OR'
);
$quests = new QuestList($conditions);
if (!$quests->error)
{
$quests->addGlobalsToJScript(GLOBALINFO_ANY);
$tab = array(
'file' => 'quest',
'data' => $quests->getListviewData($_id),
'showRep' => true,
'params' => array(
'tabs' => '$tabsRelated',
'extraCols' => '$_'
)
);
if ($quests->getMatches() > CFG_SQL_LIMIT_DEFAULT)
$tab['params']['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=1;crs='.$_id.';crv=0');
$pageData['relTabs'][] = $tab;
}
// tab: achievements
$conditions = array(
['ac.type', ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION],
['ac.value1', $_id]
);
$acvs = new AchievementList($conditions);
if (!$acvs->error)
{
$acvs->addGlobalsToJScript(GLOBALINFO_ANY);
$pageData['relTabs'][] = array(
'file' => 'achievement',
'data' => $acvs->getListviewData(),
'params' => array(
'id' => 'criteria-of',
'name' => '$LANG.tab_criteriaof',
'tabs' => '$tabsRelated',
'visibleCols' => "$['category']"
)
);
}
$smarty->saveCache($cacheKeyPage, $pageData);
} }
$smarty->updatePageVars($pageData['page']);
$smarty->assign('community', CommunityContent::getAll(TYPE_FACTION, $_id)); // comments, screenshots, videos
$smarty->assign('lang', array_merge(Lang::$main, [Lang::$colon]));
$smarty->assign('lvData', $pageData['relTabs']);
// load the page
$smarty->display('detail-page-generic.tpl');
?> ?>

View File

@@ -4,78 +4,88 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); die('illegal access');
$cats = Util::extractURLParams($pageParam); // menuId 7: Faction g_initPath()
$path = [0, 7]; // tabId 0: Database g_initHeader()
$title = [Util::ucFirst(Lang::$game['factions'])]; class FactionsPage extends GenericPage
$cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_FACTION, -1, implode('.', $cats), User::$localeId]);
$validCats = array(
1118 => [469, 891, 67, 892, 169],
980 => [936],
1097 => [1037, 1052, 1117],
0 => true
);
if (!Util::isValidPage($validCats, $cats))
$smarty->error();
if (!$smarty->loadCache($cacheKey, $pageData))
{ {
$conditions = []; use ListPage;
if (!User::isInGroup(U_GROUP_STAFF)) // unlisted factions protected $type = TYPE_FACTION;
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; protected $tpl = 'list-page-generic';
protected $path = [0, 7];
if (isset($cats[0]) && empty($cats[1])) protected $tabId = 0;
{ protected $mode = CACHETYPE_PAGE;
if (!$cats[0]) protected $validCats = array(
$conditions[] = ['parentFactionId', [1118, 980, 1097, 469, 891, 67, 892, 169, 1037, 1052, 1117, 936], '!']; 1118 => [469, 891, 67, 892, 169],
else 980 => [936],
{ 1097 => [1037, 1052, 1117],
$subs = DB::Aowow()->selectCol('SELECT id FROM ?_factions WHERE parentFactionId = ?d', $cats[0]); 0 => true
$conditions[] = ['OR', ['parentFactionId', $subs], ['id', $subs]];
}
$path[] = $cats[0];
$t = Lang::$faction['cat'][$cats[0]];
array_unshift($title, is_array($t) ? $t[0] : $t);
}
else if (!empty($cats[1]))
{
$conditions[] = ['parentFactionId', $cats[1]];
$path[] = $cats[0];
$path[] = $cats[1];
array_unshift($title, Lang::$faction['cat'][$cats[0]][$cats[1]]);
}
$factions = new FactionList($conditions);
// menuId 7: Faction g_initPath()
// tabId 0: Database g_initHeader()
$pageData = array(
'page' => array(
'title' => implode(' - ', $title),
'path' => json_encode($path, JSON_NUMERIC_CHECK),
'tab' => 0
),
'lv' => array(
array(
'file' => 'faction',
'data' => $factions->getListviewData(),
'params' => []
)
)
); );
$smarty->saveCache($cacheKey, $pageData); public function __construct($pageCall, $pageParam)
{
$this->getCategoryFromUrl($pageParam);;
parent::__construct();
$this->name = Util::ucFirst(Lang::$game['factions']);
}
protected function generateContent()
{
$conditions = [];
if (!User::isInGroup(U_GROUP_STAFF)) // unlisted factions
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
if (isset($this->category[1]))
$conditions[] = ['parentFactionId', $this->category[1]];
else if (isset($this->category[0]))
{
if (!$this->category[0])
$conditions[] = ['parentFactionId', [1118, 980, 1097, 469, 891, 67, 892, 169, 1037, 1052, 1117, 936], '!'];
else
{
$subs = DB::Aowow()->selectCol('SELECT id FROM ?_factions WHERE parentFactionId = ?d', $this->category[0]);
$conditions[] = ['OR', ['parentFactionId', $subs], ['id', $subs]];
}
}
$data = [];
$factions = new FactionList($conditions);
if (!$factions->error)
$data = $factions->getListviewData();
$this->lvData[] = array(
'file' => 'faction',
'data' => $data,
'params' => []
);
}
protected function generateTitle()
{
array_unshift($this->title, $this->name);
if ($this->category)
{
switch (count($this->category))
{
case 1:
$t = Lang::$faction['cat'][$this->category[0]];
array_unshift($this->title, is_array($t) ? $t[0] : $t);
break;
case 2:
array_unshift($this->title, Lang::$faction['cat'][$this->category[0]][$this->category[1]]);
break;
}
}
}
protected function generatePath()
{
foreach ($this->category as $c)
$this->path[] = $c;
}
} }
$smarty->updatePageVars($pageData['page']);
$smarty->assign('lang', Lang::$main);
$smarty->assign('lvData', $pageData['lv']);
// load the page
$smarty->display('list-page-generic.tpl');
?> ?>

View File

@@ -46,12 +46,7 @@ class ObjectPage extends GenericPage
if ($this->subject->error) if ($this->subject->error)
$this->notFound(Lang::$game['gameObject']); $this->notFound(Lang::$game['gameObject']);
$this->name = $this->subject->getField('name', true); $this->name = $this->subject->getField('name', true);
$this->gPageInfo = array(
'type' => $this->type,
'typeId' => $this->typeId,
'name' => $this->name
);
} }
protected function generatePath() protected function generatePath()
@@ -483,7 +478,6 @@ class ObjectPage extends GenericPage
} }
} }
protected function generateTooltip($asError = false) protected function generateTooltip($asError = false)
{ {
if ($asError) if ($asError)
@@ -499,7 +493,6 @@ class ObjectPage extends GenericPage
return $x; return $x;
} }
} }
?> ?>

View File

@@ -20,7 +20,7 @@ class ObjectsPage extends GenericPage
public function __construct($pageCall, $pageParam) public function __construct($pageCall, $pageParam)
{ {
$this->category = Util::extractURLParams($pageParam); $this->getCategoryFromUrl($pageParam);;
parent::__construct(); parent::__construct();

View File

@@ -20,20 +20,15 @@ class RacePage extends GenericPage
public function __construct($__, $id) public function __construct($__, $id)
{ {
parent::__construct();
$this->typeId = intVal($id); $this->typeId = intVal($id);
$this->subject = new CharRaceList(array(['id', $this->typeId])); $this->subject = new CharRaceList(array(['id', $this->typeId]));
if ($this->subject->error) if ($this->subject->error)
$this->notFound(Lang::$game['race']); $this->notFound(Lang::$game['race']);
$this->name = $this->subject->getField('name', true); $this->name = $this->subject->getField('name', true);
$this->gPageInfo = array(
'type' => $this->type,
'typeId' => $this->typeId,
'name' => $this->name
);
parent::__construct();
} }
protected function generatePath() protected function generatePath()

View File

@@ -789,7 +789,7 @@ span.breadcrumb-ellipsis {
padding: 0; padding: 0;
} }
.minibox .text .minibox
{ {
float: right; float: right;
margin: 0 0 4px 10px; margin: 0 0 4px 10px;
@@ -804,52 +804,53 @@ span.breadcrumb-ellipsis {
border-radius: 6px; border-radius: 6px;
} }
.minibox-left .text .minibox-left
{ {
float: left; float: left;
margin-left: 0; margin-left: 0;
margin-right: 10px; margin-right: 10px;
} }
.minibox h2 .text .minibox h2
{ {
margin: 0 0 5px 0; margin: 0 0 5px 0;
font-size: 15px; font-size: 15px;
border: none; border: none;
font-weight: bold; font-weight: bold;
padding: 0px;
} }
.minibox h2, .minibox h2 b, .text .minibox h2, .text .minibox h2 b,
.minibox h2 a:link, .minibox h2 a:visited { .text .minibox h2 a:link, .text .minibox h2 a:visited {
color: white !important; color: white !important;
} }
.minibox h2 a:link, .minibox h2 a:visited { .text .minibox h2 a:link, .text .minibox h2 a:visited {
color: white; color: white;
text-decoration: none; text-decoration: none;
} }
.minibox h2 a:hover { .text .minibox h2 a:hover {
text-decoration: underline; text-decoration: underline;
} }
.minibox h3, .text .minibox h3,
.minibox h3 a:link, .minibox h3 a:visited { .text .minibox h3 a:link, .text .minibox h3 a:visited {
color: #9d9d9d !important; color: #9d9d9d !important;
font-size: 11px; font-size: 11px;
font-weight: normal; font-weight: normal;
margin: 0px; margin: 0px;
} }
.minibox h3 img { .text .minibox h3 img {
vertical-align: middle; vertical-align: middle;
} }
.minibox h3 a:link, .minibox h3 a:visited { .text .minibox h3 a:link, .text .minibox h3 a:visited {
text-decoration: underline; text-decoration: underline;
} }
.minibox h3 a:hover { .text .minibox h3 a:hover {
color: white !important; color: white !important;
} }
h1 a.header-link, h2 a.header-link h1 a.header-link, h2 a.header-link

View File

@@ -6272,7 +6272,7 @@ Listview.extraCols = {
$WH.st(a, 'This'); $WH.st(a, 'This');
} }
else { else {
$WH.ae(a, l.name); $WH.ae(a, $WH.ct(l.name));
if (l.icon) { if (l.icon) {
a.className = 'icontiny tinyspecial'; a.className = 'icontiny tinyspecial';

View File

@@ -1,12 +1,14 @@
<?php <?php
foreach ($this->headIcons as $k => $v): if (!empty($this->headIcons)):
echo '<div id="h1-icon-'.$k."\" class=\"h1-icon\"></div>\n"; foreach ($this->headIcons as $k => $v):
endforeach; echo '<div id="h1-icon-'.$k."\" class=\"h1-icon\"></div>\n";
endforeach;
?> ?>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
<?php <?php
foreach ($this->headIcons as $k => $v): foreach ($this->headIcons as $k => $v):
echo "\$WH.ge('h1-icon-".$k."').appendChild(Icon.create('".Util::jsEscape($v)."', 1));\n"; echo "\$WH.ge('h1-icon-".$k."').appendChild(Icon.create('".Util::jsEscape($v)."', 1));\n";
endforeach; endforeach;
?> ?>
//]]></script> //]]></script>
<?php endif; ?>

View File

@@ -10,7 +10,7 @@ endif;
// ingame-links/markdown/ect // ingame-links/markdown/ect
if (isset($this->redButtons[BUTTON_LINKS])): if (isset($this->redButtons[BUTTON_LINKS])):
if ($b = $this->redButtons[BUTTON_WOWHEAD]): if ($b = $this->redButtons[BUTTON_LINKS]):
echo '<a href="javascript:;" id="open-links-button" class="button-red" onclick="this.blur(); Links.show({' . echo '<a href="javascript:;" id="open-links-button" class="button-red" onclick="this.blur(); Links.show({' .
(isset($b['color']) ? "linkColor: '".$b['color']."', " : null) . (isset($b['linkId']) ? "linkId: '".$b['linkId']."', " : null) . (isset($b['color']) ? "linkColor: '".$b['color']."', " : null) . (isset($b['linkId']) ? "linkId: '".$b['linkId']."', " : null) .
"linkName: '".Util::jsEscape(isset($b['name']) ? $b['name'] : $this->name)."', type: ".$this->type.', typeId: '.$this->typeId.' });"><em><b><i>'.Lang::$main['links'].'</i></b><span>'.Lang::$main['links'].'</span></em></a>'; "linkName: '".Util::jsEscape(isset($b['name']) ? $b['name'] : $this->name)."', type: ".$this->type.', typeId: '.$this->typeId.' });"><em><b><i>'.Lang::$main['links'].'</i></b><span>'.Lang::$main['links'].'</span></em></a>';

View File

@@ -1,19 +1,23 @@
<?php <?php
if ($this->rewards['title']):
echo $this->rewards['title'].Lang::$main['colon'].(isset($this->rewards['extra']) ? $this->rewards['extra'] : null); if (!isset($offset)) // in case we have multiple icons on the page (prominently quest-rewards)
$offset = 0;
if ($rewards['title']):
echo $rewards['title'].Lang::$main['colon'].(isset($rewards['extra']) ? $rewards['extra'] : null);
endif; endif;
if ($this->rewards['data']): if ($rewards['data']):
?> ?>
<div class="pad"></div> <div class="pad"></div>
<table class="icontab icontab-box"> <table class="icontab icontab-box">
<tr> <tr>
<?php <?php
foreach ($this->rewards['data'] as $k => $i): foreach ($rewards['data'] as $k => $i):
echo '<th id="icontab-icon'.($k + 1 + $offset).'"></th><td><span class="q'.(isset($i['quality']) ? $i['quality'] : null).'"><a href="?'.$i['typeStr'].'='.$i['id'].'">'.$i['name']."</a></span></td>\n"; echo '<th id="icontab-icon'.($k + 1 + $offset).'"></th><td><span class="q'.(isset($i['quality']) ? $i['quality'] : null).'"><a href="?'.$i['typeStr'].'='.$i['id'].'">'.$i['name']."</a></span></td>\n";
echo $k % 2 ? '</tr><tr>' : null; echo $k % 2 ? '</tr><tr>' : null;
endforeach; endforeach;
if (count($this->rewards['data']) % 2): if (count($rewards['data']) % 2):
echo '<th style="display: none"></th><td style="display: none"></td>'; echo '<th style="display: none"></th><td style="display: none"></td>';
endif; endif;
?> ?>
@@ -22,10 +26,8 @@ if ($this->rewards['data']):
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
<?php <?php
foreach ($this->rewards['data'] as $k => $i): foreach ($rewards['data'] as $k => $i):
if (isset()): echo ' $WH.ge(\'icontab-icon'.($k + 1 + $offset).'\').appendChild('.$i['globalStr'].'.createIcon('.$i['id'].', 1, '.(@$i['qty'] ?: 0)."));\n";
echo "\$WH.ge('icontab-icon".($k + 1 + $offset)."').appendChild(".$i['globalStr'].".createIcon(".$i['id'].", 1, ".(@$i['qty'] ?: 0)."));\n";
endif;
endforeach; endforeach;
?> ?>
//]]></script> //]]></script>

View File

@@ -1,4 +1,4 @@
<tr><th id="infobox-series"><?php echo $listTitle ?: Lang::$main['series']; ?></th></tr> <tr><th id="infobox-series"><?php echo $listTitle ?: Lang::$achievement['series']; ?></th></tr>
<tr><td> <tr><td>
<div class="infobox-spacer"></div> <div class="infobox-spacer"></div>
<table class="series"> <table class="series">

View File

@@ -5,6 +5,6 @@ foreach ($vars as $id => $data):
if (isset($data['namefemale'])): if (isset($data['namefemale'])):
echo ', namefemale_'.User::$localeString.':\''.Util::jsEscape($data['namefemale']).'\''; echo ', namefemale_'.User::$localeString.':\''.Util::jsEscape($data['namefemale']).'\'';
endif; endif;
echo '};' echo '};';
endforeach; endforeach;
?> ?>

View File

@@ -1,102 +0,0 @@
{include file='header.tpl'}
<div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents">
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<script type="text/javascript">//<![CDATA[
{include file='bricks/community.tpl'}
var g_pageInfo = {ldelim}type: {$type}, typeId: {$typeId}, name: '{$name|escape:"quotes"}'{rdelim}; // username:XXX in profiles
g_initPath({$path});
//]]></script>
{include file='bricks/infobox.tpl' info=$infobox series=$series}
<div class="text">
{include file='bricks/headIcons.tpl'}
{include file='bricks/redButtons.tpl'}
<h1{if isset($expansion)} class="h1-icon"><span class="icon-{$expansion}-right">{$name}</span>{else}>{$name}{/if}</h1>
{$description}
{if !empty($criteria)}<h3>{$lang.criteria}{if $count} &ndash; <small><b>{$lang.reqNumCrt} {$count} {$lang.outOf} {$nCriteria}</b></small>{/if}</h3>{/if}
<div style="float: left; margin-right: 25px">
<table class="iconlist">
{strip}
{foreach from=$criteria item=cr name=criteria}
<tr>
<th{if isset($cr.icon)} align="right" id="iconlist-icon{$cr.icon}"{/if}>
{* for reference and standard entries *}
{if !isset($cr.icon) && (isset($cr.link) || isset($cr.standard))}
<ul><li><var>&nbsp;</var></li></ul>
{/if}
</th>
<td>
{if isset($cr.link)}<a href="{$cr.link.href}"{if isset($cr.link.quality)} class="q{$cr.link.quality}"{/if}>{$cr.link.text|escape:"html"}</a>{if isset($cr.link.count) && $cr.link.count > 1} ({$cr.link.count}){/if}{/if}
{* STANDARD TEXT *}
{if isset($cr.extra_text)} {$cr.extra_text}{/if}
{if $user.roles > 0} <small title="{$lang.criteriaType} {$cr.type}" class="q0">[{$cr.id}]</small>{/if}
</td>
</tr>
{* If the first column is over (it may be a greater element) *}
{if $smarty.foreach.criteria.index+1 == round(count($criteria) / 2)}
</table>
</div>
<div style="float: left">
<table class="iconlist">
{/if}
{/foreach}
{/strip}
</table>
</div>
<script type="text/javascript">//<![CDATA[
{foreach from=$icons key=k item=ic}
$WH.ge('iconlist-icon{$ic.itr}').appendChild({$ic.type}.createIcon({$ic.id}, 0, {if isset($ic.count) && $ic.count > 0}{$ic.count}{else}0{/if}));
{/foreach}
//]]></script>
<div style="clear: left"></div>
{if $itemReward} {* for items *}
<h3>{$lang.rewards}</h3>
{include file='bricks/rewards.tpl' rewTitle=$lang.itemReward rewData=$itemReward offset=0}
{/if}
{if $titleReward} {* for titles *}
<h3>{$lang.gains}</h3>
<ul>
{foreach from=$titleReward item=i}
<li><div>{$i}</div></li>
{/foreach}
</ul>
{/if}
{if !$titleReward && !$itemReward && $reward}
<h3>{$lang.rewards}</h3>
<ul>
<li><div>{$reward}</div></li>
</ul>
{/if}
<h2 class="clear">{$lang.related}</h2>
</div>
{include file='bricks/tabsRelated.tpl' tabs=$lvData}
{include file='bricks/contribute.tpl'}
</div><!-- main-contents -->
</div><!-- main -->
{include file='footer.tpl'}

View File

@@ -0,0 +1,117 @@
<?php $this->brick('header'); ?>
<div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents">
<?php $this->brick('announcement'); ?>
<script type="text/javascript">//<![CDATA[
<?php
$this->brick('community');
echo "var g_pageInfo = ".json_encode($this->gPageInfo, JSON_NUMERIC_CHECK).";\n" .
"g_initPath(".json_encode($this->path, JSON_NUMERIC_CHECK).");\n";
?>
//]]></script>
<?php $this->brick('infobox', ['series' => $this->series]); ?>
<div class="text">
<?php
$this->brick('headIcons');
$this->brick('redButtons');
?>
<h1><?php echo $this->name; ?></h1>
<?php
echo $this->description;
echo '<h3>'.Lang::$achievement['criteria'].($this->criteria['reqQty'] ? ' &ndash; <small><b>'.Lang::$achievement['reqNumCrt'].' '.$this->criteria['reqQty'].' '.Lang::$achievement['outOf'].' '.count($this->criteria['data']).'</b></small>' : null)."</h3>\n";
?>
<div style="float: left; margin-right: 25px">
<table class="iconlist">
<?php
foreach ($this->criteria['data'] as $i => $cr):
echo '<tr><th'.(isset($cr['icon']) ? ' align="right" id="iconlist-icon'.$cr['icon'].'"' : null).'>';
if (!isset($cr['icon'])):
echo '<ul><li><var>&nbsp;</var></li></ul>';
endif;
echo '</th><td>';
if ($l = @$cr['link']):
echo '<a href="'.$l['href'].'"'.(isset($l['quality']) ? ' class="q'.$l['quality'].'"' : null).'>'.Util::htmlEscape($l['text']).'</a>';
endif;
if (!empty($l['count']) && $l['count'] > 1):
echo ' ('.$l['count'].')';
endif;
if (isset($cr['extraText'])):
echo ' '.$cr['extraText'];
endif;
if (User::isInGroup(U_GROUP_STAFF)):
echo ' <small title="'.Lang::$achievement['criteriaType'].' '.$cr['type'].'" class="q0">['.$cr['id'].']</small>';
endif;
echo '</td></tr>';
// every odd number of elements
if ($i + 1 == round(count($this->criteria['data']) / 2)):
echo '</table></div><div style="float: left"><table class="iconlist">';
endif;
endforeach;
?>
</table>
</div>
<script type="text/javascript">//<![CDATA[
<?php
foreach ($this->criteria['icons'] as $k => $ic):
echo ' $WH.ge(\'iconlist-icon'.$ic['itr'].'\').appendChild('.$ic['type'].'.createIcon('.$ic['id'].', 0, '.(@$ic['count'] ?: 0)."));\n";
endforeach;
?>
//]]></script>
<div style="clear: left"></div>
<?php
if ($r = $this->rewards):
if (!empty($r['item'])):
echo '<h3>'.Lang::$main['rewards']."</h3>\n";
$this->brick('rewards', ['rewards' => $this->rewards['item']]);
endif;
if (!empty($r['title'])):
echo '<h3>'.Lang::$main['gains']."</h3>\n<ul>";
foreach ($r['title'] as $i):
echo ' <li><div>'.$i."</div></li>\n";
endforeach;
echo "</ul>\n";
endif;
if (empty($r['title']) && empty($r['item']) && $r['text']):
echo '<h3>'.Lang::$main['rewards']."</h3>\n" .
'<ul><li><div><'.$r['text']."</div></li></ul>\n";
endif;
endif;
?>
<h2 class="clear"><?php echo Lang::$main['related']; ?></h2>
</div>
<?php
$this->brick('tabsRelated');
$this->brick('contribute');
?>
</div><!-- main-contents -->
</div><!-- main -->
<?php $this->brick('footer'); ?>

View File

@@ -1,83 +0,0 @@
{include file='header.tpl'}
<div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents">
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<script type="text/javascript">
g_initPath({$path}, {if empty($filter.query)}0{else}1{/if});
{if isset($filter.query)}
Menu.modifyUrl(Menu.findItem(mn_database, [9]), {ldelim} filter: '+={$filter.query|escape:'quotes'}' {rdelim}, {ldelim} onAppendCollision: fi_mergeFilterParams, onAppendEmpty: fi_setFilterParams, menuUrl: Menu.getItemUrl(Menu.findItem(mn_database, [9])) {rdelim});
{/if}
</script>
<div id="fi" style="display: {if empty($filter.query)}none{else}block{/if};">
<form action="?achievements{$subCat}&filter" method="post" name="fi" onsubmit="return fi_submit(this)" onreset="return fi_reset(this)">
<table>
<tr>
<td>{$lang.name|ucFirst}{$lang.colon}</td>
<td colspan="3">
<table><tr>
<td>&nbsp;<input type="text" name="na" size="30" {if isset($filter.na)}value="{$filter.na}"{/if}/></td>
<td>&nbsp; <input type="checkbox" name="ex" value="on" id="achievement-ex" {if isset($filter.ex)}checked="checked"{/if}/></td>
<td><label for="achievement-ex"><span class="tip" onmouseover="$WH.Tooltip.showAtCursor(event, LANG.tooltip_extendedachievementsearch, 0, 0, 'q')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()">{$lang.extSearch}</span></label></td>
</tr></table>
</td>
</tr><tr>
<td class="padded">{$lang.side}{$lang.colon}</td>
<td class="padded">&nbsp;<select name="si">
<option></option>
{foreach from=$lang.si key=i item=str}{if $str}
<option value="{$i}" {if isset($filter.si) && $filter.si == $i}selected{/if}>{$str}</option>
{/if}{/foreach}
</select>
</td>
<td class="padded"><table><tr>
<td>&nbsp;&nbsp;&nbsp;{$lang.points}{$lang.colon}</td>
<td>&nbsp;<input type="text" name="minpt" maxlength="2" class="smalltextbox" {if isset($filter.minpt)}value="{$filter.minpt}"{/if}/> - <input type="text" name="maxpt" maxlength="2" class="smalltextbox" {if isset($filter.maxpt)}value="{$filter.maxpt}"{/if}/></td>
</tr></table></td>
</tr>
</table>
<div id="fi_criteria" class="padded criteria"><div></div></div>
<div><a href="javascript:;" id="fi_addcriteria" onclick="fi_addCriterion(this); return false">{$lang.addFilter}</a></div>
<div class="padded2">
<div style="float: right">{$lang.refineSearch}</div>
{$lang.match}{$lang.colon}<input type="radio" name="ma" value="" id="ma-0" {if !isset($filter.ma)}checked="checked"{/if} /><label for="ma-0">{$lang.allFilter}</label><input type="radio" name="ma" value="1" id="ma-1" {if isset($filter.ma)}checked="checked"{/if} /><label for="ma-1">{$lang.oneFilter}</label>
</div>
<div class="clear"></div>
<div class="padded">
<input type="submit" value="{$lang.applyFilter}" />
<input type="reset" value="{$lang.resetForm}" />
</div>
</form>
<div class="pad"></div>
</div>
<script type="text/javascript">//<![CDATA[
fi_init('achievements');
{foreach from=$filter.fi item=str}
{$str}
{/foreach}
//]]></script>
<div id="lv-generic" class="listview"></div>
<script type="text/javascript">//<![CDATA[
{include file='listviews/achievement.tpl' data=$lvData.data params=$lvData.params}
//]]></script>
<div class="clear"></div>
</div><!-- main-contents -->
</div><!-- main -->
{include file='footer.tpl'}

View File

@@ -0,0 +1,90 @@
<?php
$this->brick('header');
$f = $this->filter; // shorthand
?>
<div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents">
<?php $this->brick('announcement'); ?>
<script type="text/javascript">
g_initPath(<?php echo json_encode($this->path, JSON_NUMERIC_CHECK).', '.(empty($f['query']) ? 0 : 1) ?>);
<?php
if (!empty($f['query'])):
// todo: update menu-class Menu.modifyUrl(Menu.findItem(mn_database, [9]), { filter: '+={$f['query']|escape:'quotes'}' }, { onAppendCollision: fi_mergeFilterParams, onAppendEmpty: fi_setFilterParams, menuUrl: Menu.getItemUrl(Menu.findItem(mn_database, [9])) });
endif;
?>
</script>
<div id="fi" style="display: <?php echo empty($f['query']) ? 'none' : 'block'; ?>;">
<form action="?achievements<?php echo $this->subCat; ?>&filter" method="post" name="fi" onsubmit="return fi_submit(this)" onreset="return fi_reset(this)">
<table>
<tr>
<td><?php echo Util::ucFirst(Lang::$main['name']).Lang::$main['colon']; ?></td>
<td colspan="3">
<table><tr>
<td>&nbsp;<input type="text" name="na" size="30" <?php echo isset($f['na']) ? 'value="'.$f['na'].'"' : null; ?>/></td>
<td>&nbsp; <input type="checkbox" name="ex" value="on" id="achievement-ex" <?php echo isset($f['ex']) ? 'checked="checked"' : null; ?>/></td>
<td><label for="achievement-ex"><span class="tip" onmouseover="$WH.Tooltip.showAtCursor(event, LANG.tooltip_extendedachievementsearch, 0, 0, 'q')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"><?php echo Lang::$main['extSearch']; ?></span></label></td>
</tr></table>
</td>
</tr><tr>
<td class="padded"><?php echo Lang::$main['side'].Lang::$main['colon']; ?></td>
<td class="padded">&nbsp;<select name="si">
<option></option>
<?php
foreach (Lang::$game['si'] as $i => $str):
if ($str):
echo ' <option value="'.$i.'" '.((isset($f['si']) && $f['si'] == $i) ? 'selected' : null).'>'.$str."</option>\n";
endif;
endforeach;
?>
</select>
</td>
<td class="padded"><table><tr>
<td>&nbsp;&nbsp;&nbsp;<?php echo Lang::$achievement['points'].Lang::$main['colon']; ?></td>
<td>&nbsp;<input type="text" name="minpt" maxlength="2" class="smalltextbox" <?php echo isset($f['minpt']) ? 'value="'.$f['minpt'].'"' : null; ?>/> - <input type="text" name="maxpt" maxlength="2" class="smalltextbox" <?php echo isset($f['maxpt']) ? 'value="'.$f['maxpt'].'"' : null; ?>/></td>
</tr></table></td>
</tr>
</table>
<div id="fi_criteria" class="padded criteria"><div></div></div>
<div><a href="javascript:;" id="fi_addcriteria" onclick="fi_addCriterion(this); return false"><?php echo Lang::$main['addFilter']; ?></a></div>
<div class="padded2">
<div style="float: right"><?php echo Lang::$main['refineSearch']; ?></div>
<?php echo Lang::$main['match'].Lang::$main['colon']; ?><input type="radio" name="ma" value="" id="ma-0" <?php echo !isset($f['ma']) ? 'checked="checked" ' : null ?>/><label for="ma-0"><?php echo Lang::$main['allFilter']; ?></label><input type="radio" name="ma" value="1" id="ma-1" <?php echo isset($f['ma']) ? 'checked="checked" ' : null ?> /><label for="ma-1"><?php echo Lang::$main['oneFilter']; ?></label>
</div>
<div class="clear"></div>
<div class="padded">
<input type="submit" value="<?php echo Lang::$main['applyFilter']; ?>" />
<input type="reset" value="<?php echo Lang::$main['resetForm']; ?>" />
</div>
</form>
<div class="pad"></div>
</div>
<script type="text/javascript">//<![CDATA[
fi_init('achievements');
<?php
foreach ($f['fi'] as $str):
echo ' '.$str."\n";
endforeach;
?>
//]]></script>
<div id="lv-generic" class="listview"></div>
<script type="text/javascript">//<![CDATA[
<?php $this->lvBrick('achievement', ['data' => $this->lvData['data'], 'params' => $this->lvData['params']] ); ?>
//]]></script>
<div class="clear"></div>
</div><!-- main-contents -->
</div><!-- main -->
<?php $this->brick('footer'); ?>

View File

@@ -31,7 +31,7 @@ if (!empty($this->lvData)):
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
<?php <?php
if (count($this->lvData) > 1): if (count($this->lvData) > 1):
echo 'var myTabs = new Tabs({parent: $WH.ge(\'tabs-generic\')})'; echo 'var myTabs = new Tabs({parent: $WH.ge(\'tabs-generic\')});';
endif; endif;
foreach ($this->lvData as $lv): foreach ($this->lvData as $lv):

View File

@@ -83,9 +83,11 @@ $this->brick('book');
<h2 class="clear"><?php echo Lang::$main['related']; ?></h2> <h2 class="clear"><?php echo Lang::$main['related']; ?></h2>
</div> </div>
<?php $this->brick('tabsRelated'); ?> <?php
$this->brick('tabsRelated');
<?php $this->brick('contribute'); ?> $this->brick('contribute');
?>
</div><!-- main-contents --> </div><!-- main-contents -->
</div><!-- main --> </div><!-- main -->

View File

@@ -1,4 +1,7 @@
<?php $this->brick('header'); ?> <?php
$this->brick('header');
$f = $this->filter; // shorthand
?>
<div class="main" id="main"> <div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div> <div class="main-precontents" id="main-precontents"></div>
@@ -7,18 +10,18 @@
<?php $this->brick('announcement'); ?> <?php $this->brick('announcement'); ?>
<script type="text/javascript"> <script type="text/javascript">
g_initPath(<?php echo json_encode($this->path, JSON_NUMERIC_CHECK).', '.(empty($this->filter['query']) ? 0 : 1) ?>); g_initPath(<?php echo json_encode($this->path, JSON_NUMERIC_CHECK).', '.(empty($f['query']) ? 0 : 1) ?>);
<?php <?php
if (!empty($this->filter['query'])): if (!empty($f['query'])):
// todo: update menu-class Menu.modifyUrl(Menu.findItem(mn_database, [5]), { filter: '+={$filter.query|escape:'quotes'}' }, { onAppendCollision: fi_mergeFilterParams, onAppendEmpty: fi_setFilterParams, menuUrl: Menu.getItemUrl(Menu.findItem(mn_database, [5])) }); // todo: update menu-class Menu.modifyUrl(Menu.findItem(mn_database, [5]), { filter: '+={$filter.query|escape:'quotes'}' }, { onAppendCollision: fi_mergeFilterParams, onAppendEmpty: fi_setFilterParams, menuUrl: Menu.getItemUrl(Menu.findItem(mn_database, [5])) });
endif; endif;
?> ?>
</script> </script>
<div id="fi" style="display: <?php echo empty($this->filter['query']) ? 'none' : 'block' ?>;"> <div id="fi" style="display: <?php echo empty($f['query']) ? 'none' : 'block' ?>;">
<form action="?objects<?php echo $this->subCat; ?>&filter" method="post" name="fi" onsubmit="return fi_submit(this)" onreset="return fi_reset(this)"> <form action="?objects<?php echo $this->subCat; ?>&filter" method="post" name="fi" onsubmit="return fi_submit(this)" onreset="return fi_reset(this)">
<table> <table>
<tr><td><?php echo Util::ucFirst(Lang::$main['name']).Lang::$main['colon']; ?></td><td>&nbsp;<input type="text" name="na" size="30" <?php echo isset($this->filter['na']) ? 'value="'.Util::htmlEscape($this->filter['na']).'" ' : null; ?>/></td></tr> <tr><td><?php echo Util::ucFirst(Lang::$main['name']).Lang::$main['colon']; ?></td><td>&nbsp;<input type="text" name="na" size="30" <?php echo isset($f['na']) ? 'value="'.Util::htmlEscape($f['na']).'" ' : null; ?>/></td></tr>
</table> </table>
<div id="fi_criteria" class="padded criteria"><div></div></div> <div id="fi_criteria" class="padded criteria"><div></div></div>
@@ -26,7 +29,7 @@ endif;
<div class="padded2 clear"> <div class="padded2 clear">
<div style="float: right"><?php echo Lang::$main['refineSearch']; ?></div> <div style="float: right"><?php echo Lang::$main['refineSearch']; ?></div>
<?php echo Lang::$main['match'].Lang::$main['colon']; ?><input type="radio" name="ma" value="" id="ma-0" <?php echo !isset($this->filter['ma']) ? 'checked="checked" ' : null ?>/><label for="ma-0"><?php echo Lang::$main['allFilter']; ?></label><input type="radio" name="ma" value="1" id="ma-1" <?php echo isset($this->filter['ma']) ? 'checked="checked" ' : null ?> /><label for="ma-1"><?php echo Lang::$main['oneFilter']; ?></label> <?php echo Lang::$main['match'].Lang::$main['colon']; ?><input type="radio" name="ma" value="" id="ma-0" <?php echo !isset($f['ma']) ? 'checked="checked" ' : null ?>/><label for="ma-0"><?php echo Lang::$main['allFilter']; ?></label><input type="radio" name="ma" value="1" id="ma-1" <?php echo isset($f['ma']) ? 'checked="checked" ' : null ?> /><label for="ma-1"><?php echo Lang::$main['oneFilter']; ?></label>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
@@ -43,7 +46,7 @@ endif;
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
fi_init('objects'); fi_init('objects');
<?php <?php
foreach ($this->filter['fi'] as $str): foreach ($f['fi'] as $str):
echo ' '.$str."\n"; echo ' '.$str."\n";
endforeach; endforeach;
?> ?>

View File

@@ -5,15 +5,15 @@
<div class="main-contents" id="main-contents"> <div class="main-contents" id="main-contents">
<?php <?php
$this->brick('announcements'); $this->brick('announcement');
if (isset($this->subject)): if (isset($this->typeStr)):
?> ?>
<div class="pad3"></div> <div class="pad3"></div>
<div class="inputbox"> <div class="inputbox">
<h1><?php echo Util::ucFirst($this->subject).' #'.$this->typeId; ?></h1> <h1><?php echo Util::ucFirst($this->typeStr).' #'.$this->typeId; ?></h1>
<div id="inputbox-error"><?php echo sprintf(Lang::$main['pageNotFound'], $this->subject); ?></div> <div id="inputbox-error"><?php echo sprintf(Lang::$main['pageNotFound'], $this->typeStr); ?></div>
<?php <?php
else: else:
?> ?>
@@ -28,7 +28,7 @@ else:
<?php <?php
$this->brick('article'); $this->brick('article');
if (isset($this->extraText)): if (isset($this->extraText)):
?> ?>
<div id="text-generic" class="left"></div> <div id="text-generic" class="left"></div>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[