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
$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);
}
}
@ -65,10 +69,6 @@ class GenericPage
private $gUser = [];
private $community = ['co' => [], 'sc' => [], 'vi' => []];
protected function generatePath() {}
protected function generateTitle() {}
protected function generateContent() {}
public function __construct()
{
// restricted access
@ -87,118 +87,22 @@ class GenericPage
$this->mode = CACHETYPE_XML;
else
{
if (!$this->isValidPage() || !$this->tpl)
$this->error();
$this->gUser = User::getUserGlobals();
$this->gLocale = array(
'id' => User::$localeId,
'name' => User::$localeString
);
if (!$this->isValidPage() || !$this->tpl)
$this->error();
}
}
private function prepareContent()
{
if (!$this->loadCache())
{
// run generators
$this->addArticle();
/**********/
/* Checks */
/**********/
$this->generatePath();
$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)
private function isSaneInclude($path, $file) // "template_exists"
{
if (preg_match('/[^\w\-]/i', $file))
return false;
@ -209,17 +113,17 @@ class GenericPage
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;
switch (count($this->category))
{
case 0: // no params works always
return true;
case 1: // null is avalid || value in a 1-dim-array || key in 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]]));
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) || !empty($this->validCats[$this->category[0]]);
case 2: // first param has to be a key. otherwise invalid
if (!isset($this->validCats[$this->category[0]]))
return false;
@ -236,6 +140,40 @@ class GenericPage
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)
{
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))
return;
@ -284,7 +222,7 @@ class GenericPage
{
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)
{
@ -318,7 +256,7 @@ class GenericPage
}
}
private function addAnnouncements()
private function addAnnouncements() // get announcements and notes for user
{
// display occured notices
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)
return false;
@ -371,7 +455,7 @@ class GenericPage
$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)
{
@ -396,7 +480,7 @@ class GenericPage
$this->jsGlobals[$type][2] = $extra;
}
private function initJSGlobal($type)
private function initJSGlobal($type) // init store for type
{
$jsg = &$this->jsGlobals; // shortcut
@ -415,7 +499,7 @@ class GenericPage
case TYPE_PET: $jsg[TYPE_PET] = ['pet', [], []]; break;
case TYPE_ACHIEVEMENT: $jsg[TYPE_ACHIEVEMENT] = ['achievement', [], []]; 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_RACE: $jsg[TYPE_RACE] = ['race', [], []]; 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)
{
@ -435,7 +519,25 @@ class GenericPage
continue;
$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)
{
@ -461,46 +563,11 @@ class GenericPage
}
}
public function notFound($subject)
{
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();
/*********/
/* Cache */
/*********/
$this->display('text-page-generic');
}
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)
public function saveCache($saveString = null) // visible properties or given strings are cached
{
if ($this->mode == CACHETYPE_NONE)
return false;
@ -521,7 +588,7 @@ class GenericPage
if ((new ReflectionProperty($this, $key))->getModifiers() & 0x1300)
$cache[$key] = $val;
}
catch (ReflectionException $e) { } // shut up!
catch (ReflectionException $e) { } // shut up!
}
$data .= serialize($cache);
@ -532,8 +599,7 @@ class GenericPage
file_put_contents($file, $data);
}
// loads and evaluates the cache file
public function loadCache(&$saveVar = null)
public function loadCache(&$saveString = null)
{
if ($this->mode == CACHETYPE_NONE)
return false;
@ -565,7 +631,7 @@ class GenericPage
}
else if ($type == '1')
{
$saveVar = $cache[1];
$saveString = $cache[1];
return true;
}

View file

@ -65,7 +65,14 @@ class Loot
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 = [];
$rawItems = [];
@ -118,7 +125,7 @@ class Loot
// bandaid.. remove when propperly handling lootmodes
if (!in_array($entry['mincountOrRef'], $handledRefs))
{ // 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'];
@ -157,7 +164,7 @@ class Loot
}
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;
}
@ -171,7 +178,7 @@ class Loot
$sum = 0;
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;
}
@ -202,7 +209,7 @@ class Loot
modes:{"mode":1,"1":{"count":4408,"outof":16013},"4":{"count":4408,"outof":22531}}
*/
$handledRefs = [];
$struct = self::getByItemIdRecursive($table, $entry, $handledRefs);
$struct = self::getByContainerRecursive($table, $entry, $handledRefs);
if (!$struct)
return false;
@ -496,7 +503,7 @@ class Loot
$srcObj = new QuestList($conditions);
if (!$srcObj->error)
{
$srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS);
self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS));
$srcData = $srcObj->getListviewData();
foreach ($srcObj->iterate() as $_)
@ -517,7 +524,7 @@ class Loot
$srcObj = new SpellList($conditions);
if (!$srcObj->error)
{
$srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED);
self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$srcData = $srcObj->getListviewData();
if (!empty($result))
@ -544,8 +551,8 @@ class Loot
$srcObj = new $oName(array([$field, $ids]));
if (!$srcObj->error)
{
$srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED);
$srcData = $srcObj->getListviewData();
self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
foreach ($srcObj->iterate() as $curTpl)
{

View file

@ -44,6 +44,8 @@ class AchievementList extends BaseType
$_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 $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(
'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']
);

View file

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

View file

@ -696,7 +696,7 @@ class Util
public static $tcEncoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789';
public static $wowheadLink = '';
private static $notes = [];
private static $notes = [];
// creates an announcement; use if minor issues arise
public static function addNote($uGroupMask, $str)
@ -895,7 +895,7 @@ class Util
// pageText for Books (Item or GO) and questText
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(
'<HTML>' => '',
@ -915,9 +915,9 @@ class Util
'/\|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
'/\$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)
'/<([^\"=\/>]+\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(
@ -1031,18 +1031,6 @@ class Util
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
public static function setRatingLevel($level, $type, $val)
{

View file

@ -19,406 +19,394 @@ if (!defined('AOWOW_REVISION'))
* }
*/
require 'includes/community.class.php';
$_id = intVal($pageParam);
$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']))
// menuId 9: Achievement g_initPath()
// tabId 0: Database g_initHeader()
class AchievementPage extends GenericPage
{
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]));
if ($acv->error)
die('$WowheadPower.registerAchievement(\''.$_id.'\', '.User::$localeId.', {})');
parent::__construct();
$x = '$WowheadPower.registerAchievement('.$_id.', '.User::$localeId.",{\n";
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($acv->getField('name', true))."',\n";
$x .= "\ticon: '".urlencode($acv->getField('iconString'))."',\n";
$x .= "\ttooltip_".User::$localeString.": '".$acv->renderTooltip()."'\n";
$x .= "});";
// temp locale
if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain']))
Util::powerUseLocale($_GET['domain']);
$smarty->saveCache($cacheKeyTooltip, $x);
}
die($x);
}
$this->typeId = intVal($id);
// regular page
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{
$acv = new AchievementList(array(['id', $_id]));
if ($acv->error)
$smarty->notFound(Lang::$game['achievement'], $_id);
$this->subject = new AchievementList(array(['id', $this->typeId]));
if ($this->subject->error)
$this->notFound(Lang::$game['achievement']);
// create page title and path
$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);
$this->extendGlobalData($this->subject->getJSGlobals(GLOBALINFO_REWARDS));
array_unshift($path, 0, 9);
$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];
$this->name = $this->subject->getField('name', true);
}
// todo (low): crosslink with charactersDB to check if realmFirsts are still available
$infobox = array_merge($infobox, Lang::getInfoBoxForFlags($acv->getField('cuFlags')));
/**********/
/* Series */
/**********/
$series = [];
if ($c = $acv->getField('chainId'))
protected function generatePath()
{
$chainAcv = new AchievementList(array(['chainId', $c]));
foreach ($chainAcv->iterate() as $aId => $__)
// create page title and path
$curCat = $this->subject->getField('category');
do
{
$pos = $chainAcv->getField('chainPos');
if (!isset($series[$pos]))
$series[$pos] = [];
$series[$pos][] = array(
'side' => $chainAcv->getField('faction'),
'typeStr' => Util::$typeStrings[TYPE_ACHIEVEMENT],
'typeId' => $aId,
'name' => $chainAcv->getField('name', true)
);
array_unshift($this->path, $curCat);
$curCat = DB::Aowow()->SelectCell('SELECT parentCategory FROM ?_achievementcategory WHERE id = ?d', $curCat);
}
while ($curCat > 0);
array_unshift($this->path, 0, 9);
$this->path[] = $this->subject->getField('typeCat');
}
/****************/
/* 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])
protected function generateTitle()
{
$bar = new ItemList(array(['i.id', $foo]));
foreach ($bar->iterate() as $id => $__)
array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['achievement']));
}
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(
'name' => $bar->getField('name', true),
'quality' => $bar->getField('quality'),
'typeStr' => Util::$typeStrings[TYPE_ITEM],
'id' => $id,
'globalStr' => 'g_items'
);
case 1:
$infobox[] = Lang::$main['side'].Lang::$main['colon'].'[span class=icon-alliance]'.Lang::$game['si'][SIDE_ALLIANCE].'[/span]';
break;
case 2:
$infobox[] = Lang::$main['side'].Lang::$main['colon'].'[span class=icon-horde]'.Lang::$game['si'][SIDE_HORDE].'[/span]';
break;
default: // case 3
$infobox[] = Lang::$main['side'].Lang::$main['colon'].Lang::$game['si'][SIDE_BOTH];
}
}
if ($foo = $acv->getField('rewards')[TYPE_TITLE])
{
$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))));
}
// todo (low): crosslink with charactersDB to check if realmFirsts are still available
/**************/
/* Extra Tabs */
/**************/
$infobox = array_merge($infobox, Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')));
// tab: see also
$conditions = array(
['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'
)
);
/**********/
/* Series */
/**********/
$saList->addGlobalsToJscript();
$series = [];
// tab: criteria of
$refs = DB::Aowow()->SelectCol('SELECT refAchievementId FROM ?_achievementcriteria WHERE Type = ?d AND value1 = ?d',
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT,
$_id
);
if (!empty($refs))
{
$coList = new AchievementList(array(['id', $refs]));
$pageData['relTabs'][] = array(
if ($c = $this->subject->getField('chainId'))
{
$chainAcv = new AchievementList(array(['chainId', $c]));
foreach ($chainAcv->iterate() as $aId => $__)
{
$pos = $chainAcv->getField('chainPos');
if (!isset($series[$pos]))
$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',
'data' => $coList->getListviewData(),
'data' => $saList->getListviewData(),
'params' => array(
'id' => 'criteria-of',
'name' => '$LANG.tab_criteriaof',
'id' => 'see-also',
'name' => '$LANG.tab_seealso',
'visibleCols' => "$['category']",
'tabs' => '$tabsRelated'
)
);
$this->extendGlobalData($saList->getJSGlobals());
$coList->addGlobalsToJscript();
}
/*****************/
/* 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'],
// tab: criteria of
$refs = DB::Aowow()->SelectCol('SELECT refAchievementId FROM ?_achievementcriteria WHERE Type = ?d AND value1 = ?d',
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT,
$this->typeId
);
$obj = (int)$crt['value1'];
$qty = (int)$crt['value2'];
switch ($crt['type'])
if (!empty($refs))
{
// link to npc
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE:
$tmp['link'] = array(
'href' => '?npc='.$obj,
'text' => $crtName,
);
$tmp['extra_text'] = Lang::$achievement['slain'];
break;
// link to area (by map)
case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA:
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))
$coList = new AchievementList(array(['id', $refs]));
$this->lvData[] = array(
'file' => 'achievement',
'data' => $coList->getListviewData(),
'params' => array(
'id' => 'criteria-of',
'name' => '$LANG.tab_criteriaof',
'visibleCols' => "$['category']",
'tabs' => '$tabsRelated'
)
);
$this->extendGlobalData($coList->getJSGlobals());
}
/*****************/
/* 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(
'href' => '?zone='.$zoneId,
'href' => '?npc='.$obj,
'text' => $crtName,
);
else
$tmp['extra_text'] = $crtName;
break;
// link to area
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE:
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA:
$tmp['link'] = array(
'href' => '?zone='.$obj,
'text' => $crtName,
);
break;
// link to skills
case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
$tmp['link'] = array(
'href' => '?skill='.$obj,
'text' => $crtName,
);
break;
// link to class
case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
$tmp['link'] = array(
'href' => '?class='.$obj,
'text' => $crtName,
);
break;
// link to race
case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
$tmp['link'] = array(
'href' => '?race='.$obj,
'text' => $crtName,
);
break;
// link to title - todo (low): crosslink
case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE:
$tmp['extra_text'] = Util::ucFirst(Lang::$game['title']).Lang::$colon.$crtName;
break;
// link to achivement (/w icon)
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT:
$tmp['link'] = array(
'href' => '?achievement='.$obj,
'text' => $crtName,
);
$tmp['icon'] = $iconId;
$pageData['page']['icons'][] = array(
'itr' => $iconId++,
'type' => 'g_achievements',
'id' => $obj,
);
$smarty->extendGlobalIds(TYPE_ACHIEVEMENT, $obj);
break;
// link to quest
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
// $crtName = ;
$tmp['link'] = array(
'href' => '?quest='.$obj,
'text' => $crtName ? $crtName : QuestList::getName($obj),
);
break;
// link to spell (/w icon)
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
$text = $crtName ? $crtName : SpellList::getName($obj);
$tmp['link'] = array(
'href' => '?spell='.$obj,
'text' => $text
);
$smarty->extendGlobalIds(TYPE_SPELL, $obj);
$tmp['icon'] = $iconId;
$pageData['page']['icons'][] = array(
'itr' => $iconId++,
'type' => 'g_spells',
'id' => $obj,
);
break;
// link to item (/w icon)
case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
$crtItm = new ItemList(array(['i.id', $obj]));
$text = $crtName ? $crtName : $crtItm->getField('name', true);
$tmp['link'] = array(
'href' => '?item='.$obj,
'text' => $text,
'quality' => $crtItm->getField('quality'),
'count' => $qty,
);
$crtItm->addGlobalsToJscript();
$tmp['icon'] = $iconId;
$pageData['page']['icons'][] = array(
'itr' => $iconId++,
'type' => 'g_items',
'id' => $obj,
'count' => $qty,
);
break;
// link to faction (/w target reputation)
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
$tmp['link'] = array(
'href' => '?faction='.$obj,
'text' => $crtName ? $crtName : FactionList::getName($obj),
);
$tmp['extra_text'] = ' ('.Lang::getReputationLevelForPoints($qty).')';
break;
// link to GObject
case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT:
case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT:
$tmp['link'] = array(
'href' => '?object='.$obj,
'text' => $crtName,
);
break;
default:
$tmp['standard'] = true;
// Add a gold coin icon
$tmp['extra_text'] = $displayMoney ? Util::formatMoney($qty) : $crtName;
break;
$tmp['extraText'] = Lang::$achievement['slain'];
break;
// link to area (by map)
case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA:
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))
$tmp['link'] = array(
'href' => '?zone='.$zoneId,
'text' => $crtName,
);
else
$tmp['extraText'] = $crtName;
break;
// link to area
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE:
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA:
$tmp['link'] = array(
'href' => '?zone='.$obj,
'text' => $crtName,
);
break;
// link to skills
case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
$tmp['link'] = array(
'href' => '?skill='.$obj,
'text' => $crtName,
);
break;
// link to class
case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
$tmp['link'] = array(
'href' => '?class='.$obj,
'text' => $crtName,
);
break;
// link to race
case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
$tmp['link'] = array(
'href' => '?race='.$obj,
'text' => $crtName,
);
break;
// link to title - todo (low): crosslink
case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE:
$tmp['extraText'] = Util::ucFirst(Lang::$game['title']).Lang::$main['colon'].$crtName;
break;
// link to achivement (/w icon)
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT:
$tmp['link'] = array(
'href' => '?achievement='.$obj,
'text' => $crtName,
);
$tmp['icon'] = $iconId;
$this->criteria['icons'][] = array(
'itr' => $iconId++,
'type' => 'g_achievements',
'id' => $obj,
);
$this->extendGlobalIds(TYPE_ACHIEVEMENT, $obj);
break;
// link to quest
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
// $crtName = ;
$tmp['link'] = array(
'href' => '?quest='.$obj,
'text' => $crtName ?: QuestList::getName($obj),
);
break;
// link to spell (/w icon)
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
$tmp['link'] = array(
'href' => '?spell='.$obj,
'text' => ($crtName ?: SpellList::getName($obj))
);
$this->extendGlobalIds(TYPE_SPELL, $obj);
$tmp['icon'] = $iconId;
$this->criteria['icons'][] = array(
'itr' => $iconId++,
'type' => 'g_spells',
'id' => $obj,
);
break;
// link to item (/w icon)
case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
$crtItm = new ItemList(array(['i.id', $obj]));
$tmp['link'] = array(
'href' => '?item='.$obj,
'text' => ($crtName ?: $crtItm->getField('name', true)),
'quality' => $crtItm->getField('quality'),
'count' => $qty,
);
$this->extendGlobalData($crtItm->getJSGlobals());
$tmp['icon'] = $iconId;
$this->criteria['icons'][] = array(
'itr' => $iconId++,
'type' => 'g_items',
'id' => $obj,
'count' => $qty,
);
break;
// link to faction (/w target reputation)
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
$tmp['link'] = array(
'href' => '?faction='.$obj,
'text' => $crtName ?: FactionList::getName($obj),
);
$tmp['extraText'] = ' ('.Lang::getReputationLevelForPoints($qty).')';
break;
// link to GObject
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)
$pageData['page']['criteria'][] = $tmp;
else
$rightCol[] = $tmp;
// If you found the second column - merge data from it to the end of the main body
if ($rightCol)
$this->criteria['data'] = array_merge($this->criteria['data'], $rightCol);
}
// If you found the second column - merge data from it to the end of the main body
if ($rightCol)
$pageData['page']['criteria'] = array_merge($pageData['page']['criteria'], $rightCol);
protected function generateTooltip($asError = false)
{
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');
$cats = Util::extractURLParams($pageParam);
$path = [0, 9];
$title = [];
$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))
// menuId 9: Object g_initPath()
// tabId 0: Database g_initHeader()
class AchievementsPage extends GenericPage
{
$acvFilter = new AchievementListFilter();
use ListPage;
// include child categories if current category is empty
$condition = !empty($cats) ? [['category', (int)end($cats)]] : [];
$fiCnd = $acvFilter->getConditions();
if ($fiCnd)
$condition[] = $fiCnd;
$acvList = new AchievementList($condition);
if (!$acvList->getMatches())
{
$curCats = $catList = [!empty($cats) ? (int)end($cats) : 0];
while ($curCats)
{
$curCats = DB::Aowow()->SelectCol('SELECT Id FROM ?_achievementCategory WHERE parentCategory IN (?a)', $curCats);
$catList = array_merge($catList, $curCats);
}
$condition = [];
if ($fiCnd)
$condition[] = $fiCnd;
if ($catList)
$condition[] = ['category', $catList];
$acvList = new AchievementList($condition);
}
// recreate form selection
$filter = array_merge($acvFilter->getForm('form'), $filter);
$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' => []
protected $type = TYPE_ACHIEVEMENT;
protected $tpl = 'achievements';
protected $path = [0, 9];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
protected $js = ['filters.js'];
protected $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]
)
);
// fill g_items, g_titles, g_achievements
$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)
public function __construct($pageCall, $pageParam)
{
$pageData['lv']['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), CFG_SQL_LIMIT_DEFAULT);
$pageData['lv']['params']['_truncated'] = 1;
$this->getCategoryFromUrl($pageParam);
parent::__construct();
$this->name = Util::ucFirst(Lang::$game['achievements']);
$this->subCat = $pageParam ? '='.$pageParam : '';
}
if ($acvFilter->error)
$pageData['lv']['params']['_errors'] = '$1';
protected function generateContent()
{
$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)
$this->notFound(Lang::$game['class']);
$this->name = $this->subject->getField('name', true);
$this->gPageInfo = array(
'type' => $this->type,
'typeId' => $this->typeId,
'name' => $this->name
);
$this->name = $this->subject->getField('name', true);
}
protected function generatePath()

View file

@ -4,52 +4,54 @@ if (!defined('AOWOW_REVISION'))
die('illegal access');
$cat = Util::extractURLParams($pageParam);
$path = [0, 15];
$validCats = [1, 2, 3, 22];
$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)
// menuId 15: Currency g_initPath()
// tabId 0: Database g_initHeader()
class CurrenciesPage extends GenericPage
{
$path[] = $cat[0]; // should be only one parameter anyway
array_unshift($title, Lang::$currency['cat'][$cat[0]]);
use ListPage;
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');
require 'includes/community.class.php';
$_id = intVal($pageParam);
$_path = [0, 15];
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_CURRENCY, $_id, -1, User::$localeId]);
if (!$smarty->loadCache($cacheKeyPage, $pageData))
// menuId 15: Currency g_initPath()
// tabId 0: Database g_initHeader()
class CurrencyPage extends GenericPage
{
$currency = new CurrencyList(array(['id', $_id]));
if ($currency->error)
$smarty->notFound(Lang::$game['skill'], $_id);
use DetailPage;
$_cat = $currency->getField('category');
$_itemId = $currency->getField('itemId');
$_isSpecial = $_id == 103 || $_id == 104; // honor && arena points are not handled as items
$_path[] = $_cat;
protected $type = TYPE_CURRENCY;
protected $typeId = 0;
protected $tpl = 'detail-page-generic';
protected $path = [0, 15];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
/***********/
/* 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)
public function __construct($__, $id)
{
// tabs: this currency is contained in..
$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
]
);
}
parent::__construct();
// tab: sold by
$itemObj = new ItemList(array(['id', $_itemId]));
if ($vendors = @$itemObj->getExtendedCost()[$_itemId])
$this->typeId = intVal($id);
$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)]));
if (!$soldBy->error)
include 'includes/loot.class.php';
// tabs: this currency is contained in..
$lootTabs = Loot::getByItem($_itemId);
$this->extendGlobalData(Loot::$jsGlobals);
foreach ($lootTabs as $tab)
{
$soldBy->addGlobalsToJScript(GLOBALINFO_SELF);
$sbData = $soldBy->getListviewData();
$this->lvData[] = 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
]
);
}
$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 = [];
foreach ($sbData as $k => &$row)
$soldBy = new CreatureList(array(['id', array_keys($vendors)]));
if (!$soldBy->error)
{
$currency = [];
$tokens = [];
foreach ($vendors[$k] as $id => $qty)
$sbData = $soldBy->getListviewData();
$extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost'];
$holidays = [];
foreach ($sbData as $k => &$row)
{
if (is_string($id))
continue;
$this->subject = [];
$tokens = [];
foreach ($vendors[$k] as $id => $qty)
{
if (is_string($id))
continue;
if ($id > 0)
$tokens[] = [$id, $qty];
else if ($id < 0)
$currency[] = [-$id, $qty];
}
if ($id > 0)
$tokens[] = [$id, $qty];
else if ($id < 0)
$this->subject[] = [-$id, $qty];
}
if ($_ = $vendors[$k]['event'])
{
if (count($extraCols) == 3) // not already pushed
$extraCols[] = 'Listview.extraCols.condition';
if ($_ = $vendors[$k]['event'])
{
if (count($extraCols) == 3) // not already pushed
$extraCols[] = 'Listview.extraCols.condition';
$holidays[$_] = 0; // applied as back ref.
$holidays[$_] = 0; // applied as back ref.
$row['condition'][] = array(
'type' => TYPE_WORLDEVENT,
'typeId' => &$holidays[$_],
'status' => 1
$row['condition'][] = array(
'type' => TYPE_WORLDEVENT,
'typeId' => &$holidays[$_],
'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'];
$row['stack'] = $itemObj->getField('buyCount');
$row['cost'] = array(
$itemObj->getField('buyPrice'),
$currency ? $currency : null,
$tokens ? $tokens : null
if ($holidays)
{
$hObj = new WorldEventList(array(['id', array_keys($holidays)]));
$this->extendGlobalData($hObj->getJSGlobals());
foreach ($hObj->iterate() as $id => $tpl)
{
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)
{
$hObj = new WorldEventList(array(['id', array_keys($holidays)]));
$hObj->addGlobalsToJscript();
foreach ($hObj->iterate() as $id => $tpl)
{
if ($_ = $tpl['holidayId'])
$holidays[$tpl['eventBak']] = $_;
else
$holidays[-$id] = $id;
}
}
// tab: created by (spell) [for items its handled in Util::getLootSource()]
if ($this->typeId == 104)
{
$createdBy = new SpellList(array(['effect1Id', 45], ['effect2Id', 45], ['effect3Id', 45], 'OR'));
if (!$createdBy->error)
{
$this->extendGlobalData($createdBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$pageData['relTabs'][] = array(
'file' => 'creature',
'data' => $sbData,
if ($createdBy->hasSetFields(['reagent1']))
$visCols = ['reagents'];
$this->lvData[] = array(
'file' => 'spell',
'data' => $createdBy->getListviewData(),
'params' => [
'tabs' => '$tabsRelated',
'name' => '$LANG.tab_soldby',
'id' => 'sold-by-npc',
'extraCols' => '$['.implode(', ', $extraCols).']',
'hiddenCols' => "$['level', 'type']"
'tabs' => '$tabsRelated',
'name' => '$LANG.tab_createdby',
'id' => 'created-by',
'visibleCols' => isset($visCols) ? '$'.json_encode($visCols) : null
]
);
}
}
}
// tab: created by (spell) [for items its handled in Util::getLootSource()]
if ($_id == 104)
{
$createdBy = new SpellList(array(['effect1Id', 45], ['effect2Id', 45], ['effect3Id', 45], 'OR'));
if (!$createdBy->error)
// tab: currency for
if ($this->typeId == 103)
{
if ($createdBy->hasSetFields(['reagent1']))
$visCols = ['reagents'];
$n = '?items&filter=cr=145;crs=1;crv=0';
$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(
'file' => 'spell',
'data' => $createdBy->getListviewData(),
'params' => [
'tabs' => '$tabsRelated',
'name' => '$LANG.tab_createdby',
'id' => 'created-by',
'visibleCols' => isset($visCols) ? '$'.json_encode($visCols) : null
]
);
$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)
{
$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');
require 'includes/community.class.php';
$_id = intVal($pageParam);
$_path = [0, 11];
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_WORLDEVENT, $_id, -1, User::$localeId]);
if (!$smarty->loadCache($cacheKeyPage, $pageData))
// menuId 11: Object g_initPath()
// tabId 0: Database g_initHeader()
class EventPage extends GenericPage
{
$conditions = [];
if ($_id < 0)
$conditions[] = ['id', -$_id];
else
$conditions[] = ['holidayId', $_id];
use DetailPage;
$event = new WorldEventList($conditions);
if ($event->error)
$smarty->notFound(Lang::$game['event'], $_id);
protected $type = TYPE_WORLDEVENT;
protected $typeId = 0;
protected $tpl = 'detail-page-generic';
protected $path = [0, 11];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
$_hId = $event->getField('holidayId');
$_eId = $event->getField('eventBak');
private $hId = 0;
private $eId = 0;
// redirect if associated with a holiday
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)
public function __construct($__, $id)
{
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 1: $_path[] = 2; break;
case 2: $_path[] = 3; break;
case 1: $this->path[] = 2; break;
case 2: $this->path[] = 3; break;
}
}
else
$_path[] = 0;
/***********/
/* Infobox */
/***********/
$infobox = [];
// boss
if ($_ = $event->getField('bossCreature'))
protected function generateTitle()
{
Util::$pageTemplate->extendGlobalIds(TYPE_NPC, $_);
$infobox[] = Lang::$npc['rank'][3].Lang::$colon.'[npc='.$_.']';
array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['event']));
}
// finalized after the cache is handled
/****************/
/* 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))
protected function generateContent()
{
$creatures = new CreatureList(array(['id', array_keys($npcIds)]));
if (!$creatures->error)
/***********/
/* Infobox */
/***********/
$this->infobox = [];
// boss
if ($_ = $this->subject->getField('bossCreature'))
{
$data = $creatures->getListviewData();
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
)
);
$this->extendGlobalIds(TYPE_NPC, $_);
$this->infobox[] = Lang::$npc['rank'][3].Lang::$main['colon'].'[npc='.$_.']';
}
}
// 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))
{
$objects = new GameObjectList(array(['id', array_keys($objectIds)]));
if (!$objects->error)
{
$data = $objects->getListviewData();
foreach ($data as &$d)
$d['method'] = $objectIds[$d['id']];
/****************/
/* Main Content */
/****************/
$pageData['relTabs'][] = array(
'file' => GameObjectList::$brickFile,
'data' => $data,
'params' => array(
'tabs' => '$tabsRelated',
'note' => $hasFilter ? sprintf(Util::$filterResultString, '?objects&filter=cr=16;crs='.$_hId.';crv=0') : null
)
);
}
}
// 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
$this->headIcons = [$this->subject->getField('iconString')];
$this->redButtons = array(
BUTTON_WOWHEAD => $this->typeId > 0,
BUTTON_LINKS => true
);
$this->dates = array(
'firstDate' => $this->subject->getField('startTime'),
'lastDate' => $this->subject->getField('endTime'),
'length' => $this->subject->getField('length'),
'rec' => $this->subject->getField('occurence')
);
// tab: quests (by table, go & creature)
$quests = new QuestList(array(['holidayId', $_hId]));
if (!$quests->error)
/**************/
/* Extra Tabs */
/**************/
$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);
$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 => $__)
$creatures = new CreatureList(array(['id', array_keys($npcIds)]));
if (!$creatures->error)
{
$relData[$id]['condition'] = array(
'type' => TYPE_WORLDEVENT,
'typeId' => -$_eId,
'status' => 2
$data = $creatures->getListviewData();
foreach ($data as &$d)
$d['method'] = $npcIds[$d['id']];
$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();
foreach ($rel as $r)
// 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', $this->eId))
{
$objects = new GameObjectList(array(['id', array_keys($objectIds)]));
if (!$objects->error)
{
if ($r >= 0)
continue;
$data = $objects->getListviewData();
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);
$d[-$_eId]['condition'][] = array(
'type' => TYPE_WORLDEVENT,
'typeId' => $r,
'status' => 2
// tab: achievements
if ($_ = $this->subject->getField('achievementCatOrId'))
{
$condition = $_ > 0 ? [['category', $_]] : [['id', -$_]];
$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(
'file' => WorldEventList::$brickFile,
'data' => $relData,
'params' => array(
'id' => 'see-also',
'name' => '$LANG.tab_seealso',
'tabs' => '$tabsRelated',
'hiddenCols' => "$['date']",
'extraCols' => '$[Listview.extraCols.condition]'
)
);
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)
{
$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');
$cat = Util::extractURLParams($pageParam);
$condition = [];
$path = [0, 11];
$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))
// menuId 11: Event g_initPath()
// tabId 0: Database g_initHeader()
class EventsPage extends GenericPage
{
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];
array_unshift($title, Lang::$event['category'][$cat[0]]);
switch ($cat[0])
{
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;
}
$this->getCategoryFromUrl($pageParam);;
parent::__construct();
$this->name = Util::ucFirst(Lang::$game['events']);
}
$events = new WorldEventList($condition);
$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)
protected function generateContent()
{
// is a followUp-event
if (!empty($pageData['deps'][$data['id']]))
$condition = [];
if ($this->category)
{
$data['startDate'] = $data['endDate'] = false;
unset($data['_date']);
continue;
switch ($this->category[0])
{
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']);
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'];
$events = new WorldEventList($condition);
$this->extendGlobalData($events->getJSGlobals());
$this->deps = [];
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');
require 'includes/community.class.php';
$_id = intVal($pageParam);
$_path = [0, 7];
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_FACTION, $_id, -1, User::$localeId]);
if (!$smarty->loadCache($cacheKeyPage, $pageData))
// menuId 7: Faction g_initPath()
// tabId 0: Database g_initHeader()
class FactionPage extends GenericPage
{
$faction = new FactionList(array(['id', $_id]));
if ($faction->error)
$smarty->notFound(Lang::$game['faction'], $_id);
use DetailPage;
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'))
$_path[] = $bar;
parent::__construct();
$_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);
}
/***********/
/* Infobox */
/***********/
$infobox = [];
// Quartermaster if any
if ($ids = $faction->getField('qmNpcIds'))
protected function generatePath()
{
Util::$pageTemplate->extendGlobalIds(TYPE_NPC, $ids);
$qmStr = Lang::$faction['quartermaster'].Lang::$colon;
if (count($ids) == 1)
$qmStr .= '[npc='.$ids[0].']';
else if (count($ids) > 1)
if ($foo = $this->subject->getField('cat'))
{
$qmStr .= '[ul]';
foreach ($ids as $id)
$qmStr .= '[li][npc='.$id.'][/li]';
if ($bar = $this->subject->getField('cat2'))
$this->path[] = $bar;
$qmStr .= '[/ul]';
$this->path[] = $foo;
}
$infobox[] = $qmStr;
}
// side if any
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))
protected function generateTitle()
{
$buff = '';
foreach ($rates as $k => $v)
{
if ($v == 1)
continue;
array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['faction']));
}
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;
case 'quest_daily_rate': $buff .= '[tr][td]'.Lang::$game['quests'].' ('.Lang::$quest['daily'].')'.Lang::$colon.'[/td]'; break;
case 'quest_weekly_rate': $buff .= '[tr][td]'.Lang::$game['quests'].' ('.Lang::$quest['weekly'].')'.Lang::$colon.'[/td]'; break;
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;
case 'spell_rate': $buff .= '[tr][td]'.Lang::$game['spells'].Lang::$colon.'[/td]'; break;
$qmStr .= '[ul]';
foreach ($ids as $id)
$qmStr .= '[li][npc='.$id.'][/li]';
$qmStr .= '[/ul]';
}
$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)
$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
$items = new ItemList(array(['requiredFaction', $_id]));
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)
// reward rates
if ($rates = DB::Aowow()->selectRow('SELECT * FROM reputation_reward_rate WHERE faction = ?d', $this->typeId))
{
$killCreatures = new CreatureList(array(['id', $cIds]));
if (!$killCreatures->error)
$buff = '';
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(
'file' => 'creature',
'data' => $killCreatures->getListviewData(),
'data' => $members->getListviewData(),
'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(
'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
if ($_ = $faction->getField('templateIds'))
{
$members = new CreatureList(array(['faction', $_]));
if (!$members->error)
// tab: quests
$conditions = array(
['AND', ['rewardFactionId1', $this->typeId], ['rewardFactionValue1', 0, '>']],
['AND', ['rewardFactionId2', $this->typeId], ['rewardFactionValue2', 0, '>']],
['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(
'file' => 'creature',
'data' => $members->getListviewData(),
'file' => 'quest',
'data' => $quests->getListviewData($this->typeId),
'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(
'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');
$cats = Util::extractURLParams($pageParam);
$path = [0, 7];
$title = [Util::ucFirst(Lang::$game['factions'])];
$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))
// menuId 7: Faction g_initPath()
// tabId 0: Database g_initHeader()
class FactionsPage extends GenericPage
{
$conditions = [];
use ListPage;
if (!User::isInGroup(U_GROUP_STAFF)) // unlisted factions
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
if (isset($cats[0]) && empty($cats[1]))
{
if (!$cats[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', $cats[0]);
$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' => []
)
)
protected $type = TYPE_FACTION;
protected $tpl = 'list-page-generic';
protected $path = [0, 7];
protected $tabId = 0;
protected $mode = CACHETYPE_PAGE;
protected $validCats = array(
1118 => [469, 891, 67, 892, 169],
980 => [936],
1097 => [1037, 1052, 1117],
0 => true
);
$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)
$this->notFound(Lang::$game['gameObject']);
$this->name = $this->subject->getField('name', true);
$this->gPageInfo = array(
'type' => $this->type,
'typeId' => $this->typeId,
'name' => $this->name
);
$this->name = $this->subject->getField('name', true);
}
protected function generatePath()
@ -483,7 +478,6 @@ class ObjectPage extends GenericPage
}
}
protected function generateTooltip($asError = false)
{
if ($asError)
@ -499,7 +493,6 @@ class ObjectPage extends GenericPage
return $x;
}
}
?>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,7 +10,7 @@ endif;
// ingame-links/markdown/ect
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({' .
(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>';

View file

@ -1,19 +1,23 @@
<?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;
if ($this->rewards['data']):
if ($rewards['data']):
?>
<div class="pad"></div>
<table class="icontab icontab-box">
<tr>
<?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 $k % 2 ? '</tr><tr>' : null;
endforeach;
if (count($this->rewards['data']) % 2):
if (count($rewards['data']) % 2):
echo '<th style="display: none"></th><td style="display: none"></td>';
endif;
?>
@ -22,10 +26,8 @@ if ($this->rewards['data']):
<script type="text/javascript">//<![CDATA[
<?php
foreach ($this->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";
endif;
foreach ($rewards['data'] as $k => $i):
echo ' $WH.ge(\'icontab-icon'.($k + 1 + $offset).'\').appendChild('.$i['globalStr'].'.createIcon('.$i['id'].', 1, '.(@$i['qty'] ?: 0)."));\n";
endforeach;
?>
//]]></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>
<div class="infobox-spacer"></div>
<table class="series">

View file

@ -5,6 +5,6 @@ foreach ($vars as $id => $data):
if (isset($data['namefemale'])):
echo ', namefemale_'.User::$localeString.':\''.Util::jsEscape($data['namefemale']).'\'';
endif;
echo '};'
echo '};';
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[
<?php
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;
foreach ($this->lvData as $lv):

View file

@ -83,9 +83,11 @@ $this->brick('book');
<h2 class="clear"><?php echo Lang::$main['related']; ?></h2>
</div>
<?php $this->brick('tabsRelated'); ?>
<?php
$this->brick('tabsRelated');
<?php $this->brick('contribute'); ?>
$this->brick('contribute');
?>
</div><!-- main-contents -->
</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-precontents" id="main-precontents"></div>
@ -7,18 +10,18 @@
<?php $this->brick('announcement'); ?>
<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
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])) });
endif;
?>
</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)">
<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>
<div id="fi_criteria" class="padded criteria"><div></div></div>
@ -26,7 +29,7 @@ endif;
<div class="padded2 clear">
<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 class="clear"></div>
@ -43,7 +46,7 @@ endif;
<script type="text/javascript">//<![CDATA[
fi_init('objects');
<?php
foreach ($this->filter['fi'] as $str):
foreach ($f['fi'] as $str):
echo ' '.$str."\n";
endforeach;
?>

View file

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