removing smarty - part IX

- readded search
- moved custom displayers (tooltip, xml) to subclasses
- added more info to footer
This commit is contained in:
Sarjuuk
2014-06-29 16:32:23 +02:00
parent f6b68a4092
commit 663597a7a0
16 changed files with 1009 additions and 638 deletions

View File

@@ -11,7 +11,7 @@ trait DetailPage
private $subject = null; // so it will not get cached
function generateCacheKey()
protected function generateCacheKey()
{
// mode, type, typeId, localeId, category, filter
$key = [$this->mode, $this->type, $this->typeId, User::$localeId, '-1', '-1'];
@@ -31,7 +31,7 @@ trait ListPage
protected $typeId = 0;
protected $filter = [];
function generateCacheKey()
protected function generateCacheKey()
{
// mode, type, typeId, localeId,
$key = [$this->mode, $this->type, '-1', User::$localeId];
@@ -62,6 +62,8 @@ class GenericPage
protected $css = [];
// private vars don't get cached
private $time = 0;
private $isCached = false;
private $cacheDir = 'cache/template/';
private $jsgBuffer = [];
private $gLocale = [];
@@ -71,6 +73,8 @@ class GenericPage
public function __construct()
{
$this->time = microtime(true);
// restricted access
if ($this->restrictedGroups && !User::isInGroup($this->restrictedGroups))
$this->error();
@@ -158,6 +162,8 @@ class GenericPage
$this->saveCache();
}
else
$this->isCached = true;
if (isset($this->type) && isset($this->typeId))
$this->gPageInfo = array( // varies slightly for special pages like maps, user-dashboard or profiler
@@ -172,6 +178,7 @@ class GenericPage
if (!empty($this->hasComContent)) // get comments, screenshots, videos
$this->community = CommunityContent::getAll($this->type, $this->typeId);
$this->time = microtime(true) - $this->time;
$this->mysql = DB::Aowow()->getStatistics();
}
@@ -271,7 +278,7 @@ class GenericPage
'status' => 1,
'name' => 'internal error',
'style' => 'padding-left: 40px; background-image: url(static/images/announcements/warn-small.png); background-size: 15px 15px; background-position: 12px center; border: dashed 2px #C03030;',
'text' => '[span id=inputbox-error]'.implode("<br>", $_).'[/span]',
'text' => '[span id=inputbox-error]'.implode("[br]", $_).'[/span]',
);
}
@@ -308,24 +315,10 @@ class GenericPage
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');
}
$this->typeStr = $typeStr;
$this->mysql = DB::Aowow()->getStatistics();
$this->display('text-page-generic');
exit();
}
@@ -363,28 +356,6 @@ class GenericPage
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();

View File

@@ -22,7 +22,7 @@ class ItemList extends BaseType
private $vendors = [];
private $jsGlobals = []; // getExtendedCost creates some and has no access to template
protected $queryBase = 'SELECT i.*, `is`.*, i.id AS ARRAY_KEY FROM ?_items i';
protected $queryBase = 'SELECT i.*, `is`.*, i.id AS id, i.id AS ARRAY_KEY FROM ?_items i';
protected $queryOpts = array(
'is' => ['j' => ['?_item_stats AS `is` ON `is`.`id` = `i`.`id`', true]],
's' => ['j' => ['?_spell AS `s` ON s.effect1CreateItemId = i.id', true], 'g' => 'i.id'],
@@ -1291,23 +1291,33 @@ class ItemList extends BaseType
{
$jsonEquip = [];
$jsonText = [];
$enchIds = [];
for ($i = 1; $i < 6; $i++)
{
$enchId = $data['enchantId'.$i];
if ($enchId <= 0)
continue;
// subitems may share enchantmentIds
if (!isset($this->rndEnchIds[$enchId]))
{
$stats = Util::parseItemEnchantment($enchId, false, $misc);
$this->rndEnchIds[$enchId] = array(
'text' => $misc[$enchId]['name'],
'stats' => $stats
);
}
if (isset($this->rndEnchIds[$enchId]))
continue;
$enchIds[] = $enchId;
}
foreach (Util::parseItemEnchantment($enchIds, false, $misc) as $eId => $stats)
{
$this->rndEnchIds[$eId] = array(
'text' => $misc[$eId]['name'],
'stats' => $stats
);
}
for ($i = 1; $i < 6; $i++)
{
$enchId = $data['enchantId'.$i];
if ($enchId <= 0)
continue;
if ($data['allocationPct'.$i] > 0) // RandomSuffix: scaling Enchantment; enchId < 0
{

View File

@@ -11,8 +11,8 @@ class WorldEventList extends BaseType
protected $queryBase = 'SELECT *, -e.id as id, -e.id AS ARRAY_KEY FROM ?_events e';
protected $queryOpts = array(
'e' => ['j' => ['?_holidays h2 ON e.holidayId = h2.id', true], 'o' => '-e.id ASC'],
'h' => ['j' => ['?_holidays h ON e.holidayId = h.id']]
'e' => [['h']],
'h' => ['j' => ['?_holidays h ON e.holidayId = h.id', true], 'o' => '-e.id ASC']
);
public function __construct($conditions = [])