mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
cache two versions of page
- regular for normal users - extended info for employees search: format opensearch with json_encode instead of string concatenation
This commit is contained in:
@@ -13,8 +13,8 @@ trait DetailPage
|
||||
|
||||
protected function generateCacheKey()
|
||||
{
|
||||
// mode, type, typeId, localeId, category, filter
|
||||
$key = [$this->mode, $this->type, $this->typeId, User::$localeId, '-1', '-1'];
|
||||
// mode, type, typeId, employee-flag, localeId, category, filter
|
||||
$key = [$this->mode, $this->type, $this->typeId, intVal(User::isInGroup(U_GROUP_EMPLOYEE)), User::$localeId, '-1', '-1'];
|
||||
|
||||
// item special: can modify tooltips
|
||||
if (isset($this->enhancedTT))
|
||||
@@ -33,8 +33,8 @@ trait ListPage
|
||||
|
||||
protected function generateCacheKey()
|
||||
{
|
||||
// mode, type, typeId, localeId,
|
||||
$key = [$this->mode, $this->type, '-1', User::$localeId];
|
||||
// mode, type, typeId, employee-flag, localeId,
|
||||
$key = [$this->mode, $this->type, '-1', intVal(User::isInGroup(U_GROUP_EMPLOYEE)), User::$localeId];
|
||||
|
||||
//category
|
||||
$key[] = $this->category ? implode('.', $this->category) : '-1';
|
||||
@@ -361,7 +361,7 @@ class GenericPage
|
||||
$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);
|
||||
die(User::isInGroup(U_GROUP_EMPLOYEE) ? 'Error: nonexistant template requested: template/pages/'.$this->tpl.'.tpl.php' : null);
|
||||
|
||||
$this->addAnnouncements();
|
||||
|
||||
@@ -376,7 +376,7 @@ class GenericPage
|
||||
$$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;
|
||||
echo !User::isInGroup(U_GROUP_EMPLOYEE) ? "\n\nError: nonexistant template requested: template/globals/".$file.".tpl.php\n\n" : null;
|
||||
else
|
||||
include('template/globals/'.$file.'.tpl.php');
|
||||
}
|
||||
@@ -387,7 +387,7 @@ class GenericPage
|
||||
$$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;
|
||||
echo User::isInGroup(U_GROUP_EMPLOYEE) ? "\n\nError: nonexistant template requested: template/bricks/".$file.".tpl.php\n\n" : null;
|
||||
else
|
||||
include('template/bricks/'.$file.'.tpl.php');
|
||||
}
|
||||
@@ -398,7 +398,7 @@ class GenericPage
|
||||
$$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;
|
||||
echo User::isInGroup(U_GROUP_EMPLOYEE) ? "\n\nError: nonexistant template requested: template/listviews/".$file.".tpl.php\n\n" : null;
|
||||
else
|
||||
include('template/listviews/'.$file.'.tpl.php');
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ class Loot
|
||||
|
||||
if ($loot['content'] > 0) // regular drop
|
||||
{
|
||||
if (!User::isInGroup(U_GROUP_STAFF))
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
{
|
||||
if (!isset($this->results[$loot['content']]))
|
||||
$this->results[$loot['content']] = array_merge($foo[$loot['content']], $base, ['stack' => [$loot['min'], $loot['max']]]);
|
||||
@@ -257,7 +257,7 @@ class Loot
|
||||
else // in case of limited trash loot, check if $foo[<itemId>] exists
|
||||
$this->results[] = array_merge($foo[$loot['content']], $base, ['stack' => [$loot['min'], $loot['max']]]);
|
||||
}
|
||||
else if (User::isInGroup(U_GROUP_STAFF)) // create dummy for ref-drop
|
||||
else if (User::isInGroup(U_GROUP_EMPLOYEE)) // create dummy for ref-drop
|
||||
{
|
||||
$data = array(
|
||||
'id' => $loot['content'],
|
||||
@@ -272,7 +272,7 @@ class Loot
|
||||
}
|
||||
|
||||
// move excessive % to extra loot
|
||||
if (!User::isInGroup(U_GROUP_STAFF))
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
{
|
||||
foreach ($this->results as &$_)
|
||||
{
|
||||
|
||||
@@ -921,7 +921,7 @@ abstract class Filter
|
||||
$result = $this->genericBooleanFlags($gen[1], $gen[2], $cr[1]);
|
||||
break;
|
||||
case FILTER_CR_STAFFFLAG:
|
||||
if (User::isInGroup(U_GROUP_STAFF) && $cr[1] >= 0)
|
||||
if (User::isInGroup(U_GROUP_EMPLOYEE) && $cr[1] >= 0)
|
||||
$result = $this->genericBooleanFlags($gen[1], (1 << $cr[1]), true);
|
||||
break;
|
||||
case FILTER_CR_BOOLEAN:
|
||||
|
||||
@@ -171,6 +171,8 @@ class AchievementPage extends GenericPage
|
||||
|
||||
$this->rewards['text'] = $this->subject->getField('reward', true);
|
||||
|
||||
// todo (low): create pendant from player_factionchange_achievement
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
@@ -147,6 +147,8 @@ class FactionPage extends GenericPage
|
||||
$this->extraText .= '[h3 class=clear][Custom Reward Rate][/h3][table]'.$buff.'[/table]';
|
||||
}
|
||||
|
||||
// todo (low): create pendant from player_factionchange_reputations
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
@@ -35,7 +35,7 @@ class FactionsPage extends GenericPage
|
||||
{
|
||||
$conditions = [];
|
||||
|
||||
if (!User::isInGroup(U_GROUP_STAFF)) // unlisted factions
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE)) // unlisted factions
|
||||
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
||||
|
||||
if (isset($this->category[1]))
|
||||
|
||||
@@ -362,7 +362,7 @@ class ItemPage extends genericPage
|
||||
);
|
||||
|
||||
// merge identical stats and names for normal users (e.g. spellPower of a specific school became generel spellPower with 3.0)
|
||||
if (!User::isInGroup(U_GROUP_STAFF))
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
{
|
||||
for ($i = 1; $i < count($this->subItems['data']); $i++)
|
||||
{
|
||||
|
||||
@@ -190,7 +190,7 @@ class ObjectPage extends GenericPage
|
||||
}
|
||||
|
||||
// AI
|
||||
if (User::isInGroup(U_GROUP_STAFF))
|
||||
if (User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
{
|
||||
if ($_ = $this->subject->getField('ScriptName'))
|
||||
$infobox[] = 'Script'.Lang::$main['colon'].$_;
|
||||
|
||||
@@ -139,7 +139,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
protected function generateCacheKey()
|
||||
{
|
||||
$key = [$this->mode, $this->searchMask, md5($this->query), User::$localeId];
|
||||
$key = [$this->mode, $this->searchMask, md5($this->query), intVal(User::isInGroup(U_GROUP_EMPLOYEE)), User::$localeId];
|
||||
|
||||
return implode('_', $key);
|
||||
}
|
||||
@@ -299,7 +299,8 @@ class SearchPage extends GenericPage
|
||||
if (!$data)
|
||||
break;
|
||||
|
||||
$names[] = '"'.$data['name'].$set['appendix'].'"';
|
||||
$hasQ = is_numeric($data['name'][0]) || $data['name'][0] == '@';
|
||||
$names[] = ($hasQ ? substr($data['name'], 1) : $data['name']).$set['appendix'];
|
||||
$extra = [$set['type'], $data['id']];
|
||||
|
||||
if (isset($data['param1']))
|
||||
@@ -308,14 +309,14 @@ class SearchPage extends GenericPage
|
||||
if (isset($data['param2']))
|
||||
$extra[] = $data['param2'];
|
||||
|
||||
$info[] = '['.implode(', ', $extra).']';
|
||||
$info[] = $extra;
|
||||
}
|
||||
|
||||
if ($limit <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return '["'.Util::jsEscape($this->search).'", ['.implode(', ', $names).'], [], [], [], [], [], ['.implode(', ', $info).']]';
|
||||
return '["'.Util::jsEscape($this->search).'", '.json_encode($names).', [], [], [], [], [], '.json_encode($info, JSON_NUMERIC_CHECK).']';
|
||||
}
|
||||
|
||||
private function createLookup(array $fields = [])
|
||||
@@ -357,7 +358,7 @@ class SearchPage extends GenericPage
|
||||
$cndBase = ['AND', $this->maxResults];
|
||||
|
||||
// Exclude internal wow stuff
|
||||
if (!User::isInGroup(U_GROUP_STAFF))
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
$cndBase[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
||||
|
||||
$shared = [];
|
||||
@@ -377,7 +378,7 @@ class SearchPage extends GenericPage
|
||||
{
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($classes->iterate() as $__)
|
||||
$data[$classes->id]['param1'] = '"class_'.strToLower($classes->getField('fileString')).'"';
|
||||
$data[$classes->id]['param1'] = 'class_'.strToLower($classes->getField('fileString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_CLASS,
|
||||
@@ -508,7 +509,7 @@ class SearchPage extends GenericPage
|
||||
{
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($money->iterate() as $__)
|
||||
$data[$money->id]['param1'] = '"'.strToLower($money->getField('iconString')).'"';
|
||||
$data[$money->id]['param1'] = strToLower($money->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_CURRENCY,
|
||||
@@ -541,13 +542,8 @@ class SearchPage extends GenericPage
|
||||
$this->extendGlobalData($sets->getJSGlobals(GLOBALINFO_SELF));
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
{
|
||||
foreach ($sets->iterate() as $__)
|
||||
{
|
||||
$data[$sets->id]['param1'] = $sets->getField('quality');
|
||||
$data[$sets->id]['name'] = substr($data[$sets->id]['name'], 1);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_ITEMSET,
|
||||
@@ -618,9 +614,8 @@ class SearchPage extends GenericPage
|
||||
{
|
||||
foreach ($items->iterate() as $__)
|
||||
{
|
||||
$data[$items->id]['param1'] = '"'.$items->getField('iconString').'"';
|
||||
$data[$items->id]['param1'] = $items->getField('iconString');
|
||||
$data[$items->id]['param2'] = $items->getField('quality');
|
||||
$data[$items->id]['name'] = substr($data[$items->id]['name'], 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,8 +667,9 @@ class SearchPage extends GenericPage
|
||||
{
|
||||
foreach ($abilities->iterate() as $__)
|
||||
{
|
||||
$data[$abilities->id]['param1'] = '"'.strToLower($abilities->getField('iconString')).'"';
|
||||
$data[$abilities->id]['param2'] = '"'.$abilities->ranks[$abilities->id].'"';
|
||||
$data[$abilities->id]['param1'] = strToLower($abilities->getField('iconString'));
|
||||
$data[$abilities->id]['param2'] = $abilities->ranks[$abilities->id];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -728,8 +724,8 @@ class SearchPage extends GenericPage
|
||||
{
|
||||
foreach ($talents->iterate() as $__)
|
||||
{
|
||||
$data[$talents->id]['param1'] = '"'.strToLower($talents->getField('iconString')).'"';
|
||||
$data[$talents->id]['param2'] = '"'.$talents->ranks[$abilities->id].'"';
|
||||
$data[$talents->id]['param1'] = strToLower($talents->getField('iconString'));
|
||||
$data[$talents->id]['param2'] = $talents->ranks[$talents->id];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -778,7 +774,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($glyphs->iterate() as $__)
|
||||
$data[$glyphs->id]['param1'] = '"'.strToLower($glyphs->getField('iconString')).'"';
|
||||
$data[$glyphs->id]['param1'] = strToLower($glyphs->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_SPELL,
|
||||
@@ -825,7 +821,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($prof->iterate() as $__)
|
||||
$data[$prof->id]['param1'] = '"'.strToLower($prof->getField('iconString')).'"';
|
||||
$data[$prof->id]['param1'] = strToLower($prof->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_SPELL,
|
||||
@@ -872,7 +868,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($prof->iterate() as $__)
|
||||
$data[$prof->id]['param1'] = '"'.strToLower($prof->getField('iconString')).'"';
|
||||
$data[$prof->id]['param1'] = strToLower($prof->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_SPELL,
|
||||
@@ -919,7 +915,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($vPets->iterate() as $__)
|
||||
$data[$vPets->id]['param1'] = '"'.strToLower($vPets->getField('iconString')).'"';
|
||||
$data[$vPets->id]['param1'] = strToLower($vPets->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_SPELL,
|
||||
@@ -966,7 +962,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($mounts->iterate() as $__)
|
||||
$data[$mounts->id]['param1'] = '"'.strToLower($mounts->getField('iconString')).'"';
|
||||
$data[$mounts->id]['param1'] = strToLower($mounts->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_SPELL,
|
||||
@@ -1090,7 +1086,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($acvs->iterate() as $__)
|
||||
$data[$acvs->id]['param1'] = '"'.strToLower($acvs->getField('iconString')).'"';
|
||||
$data[$acvs->id]['param1'] = strToLower($acvs->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_ACHIEVEMENT,
|
||||
@@ -1270,7 +1266,7 @@ class SearchPage extends GenericPage
|
||||
{
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($skills->iterate() as $id => $__)
|
||||
$data[$id]['param1'] = '"'.$skills->getField('iconString').'"';
|
||||
$data[$id]['param1'] = $skills->getField('iconString');
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_SKILL,
|
||||
@@ -1303,7 +1299,7 @@ class SearchPage extends GenericPage
|
||||
{
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($pets->iterate() as $__)
|
||||
$data[$pets->id]['param1'] = '"'.$pets->getField('iconString').'"';
|
||||
$data[$pets->id]['param1'] = $pets->getField('iconString');
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_PET,
|
||||
@@ -1340,7 +1336,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($npcAbilities->iterate() as $__)
|
||||
$data[$npcAbilities->id]['param1'] = '"'.strToLower($npcAbilities->getField('iconString')).'"';
|
||||
$data[$npcAbilities->id]['param1'] = strToLower($npcAbilities->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_SPELL,
|
||||
@@ -1388,7 +1384,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
if ($this->searchMask & SEARCH_TYPE_OPEN)
|
||||
foreach ($misc->iterate() as $__)
|
||||
$data[$misc->id]['param1'] = '"'.strToLower($misc->getField('iconString')).'"';
|
||||
$data[$misc->id]['param1'] = strToLower($misc->getField('iconString'));
|
||||
|
||||
$result = array(
|
||||
'type' => TYPE_SPELL,
|
||||
|
||||
@@ -80,6 +80,8 @@ class TitlePage extends GenericPage
|
||||
BUTTON_LINKS => ['name' => $this->nameFixed]
|
||||
);
|
||||
|
||||
// todo (low): create pendant from player_factionchange_titles
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
@@ -30,7 +30,7 @@ class TitlesPage extends GenericPage
|
||||
{
|
||||
$conditions = [];
|
||||
|
||||
if (!User::isInGroup(U_GROUP_STAFF)) // hide unused titles
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE)) // hide unused titles
|
||||
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
||||
|
||||
if ($this->category)
|
||||
|
||||
@@ -80,7 +80,7 @@ endforeach;
|
||||
|
||||
<div id="lv-generic" class="listview"></div>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
<?php $this->lvBrick('achievement', ['data' => $this->lvData['data'], 'params' => $this->lvData['params']] ); ?>
|
||||
<?php $this->lvBrick($this->lvData['file'], ['data' => $this->lvData['data'], 'params' => $this->lvData['params']] ); ?>
|
||||
//]]></script>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
Reference in New Issue
Block a user