Template/Update (Part 26)
* convert dbtype 'title'
This commit is contained in:
parent
e6980ce220
commit
f76869ecbe
4 changed files with 261 additions and 235 deletions
186
endpoints/title/title.php
Normal file
186
endpoints/title/title.php
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class TitleBaseResponse extends TemplateResponse implements ICache
|
||||
{
|
||||
use TrDetailPage, TrCache;
|
||||
|
||||
protected int $cacheType = CACHE_TYPE_PAGE;
|
||||
|
||||
protected string $template = 'detail-page-generic';
|
||||
protected array $breadcrumb = [0, 10];
|
||||
protected ?int $activeTab = parent::TAB_DATABASE;
|
||||
protected string $pageName = 'title';
|
||||
|
||||
public int $type = Type::TITLE;
|
||||
public int $typeId = 0;
|
||||
public ?string $expansion = null;
|
||||
|
||||
private TitleList $subject;
|
||||
|
||||
public function __construct(string $id)
|
||||
{
|
||||
parent::__construct($id);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
$this->contribute = Type::getClassAttrib($this->type, 'contribute') ?? CONTRIBUTE_NONE;
|
||||
}
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$this->subject = new TitleList(array(['id', $this->typeId]));
|
||||
if ($this->subject->error)
|
||||
$this->generateNotFound(Lang::game('title'), Lang::title('notFound'));
|
||||
|
||||
$this->h1 = $this->subject->getHtmlizedName();
|
||||
|
||||
$this->gPageInfo += array(
|
||||
'type' => $this->type,
|
||||
'typeId' => $this->typeId,
|
||||
'name' => $this->h1
|
||||
);
|
||||
|
||||
$_title = Util::ucFirst(trim(strtr($this->subject->getField('male', true), ['%s' => '', ',' => ''])));
|
||||
|
||||
|
||||
/*************/
|
||||
/* Menu Path */
|
||||
/*************/
|
||||
|
||||
$this->breadcrumb[] = $this->subject->getField('category');;
|
||||
|
||||
|
||||
/**************/
|
||||
/* Page Title */
|
||||
/**************/
|
||||
|
||||
array_unshift($this->title, $_title, Util::ucFirst(Lang::game('title')));
|
||||
|
||||
|
||||
/***********/
|
||||
/* Infobox */
|
||||
/***********/
|
||||
|
||||
$infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
|
||||
|
||||
$infobox[] = Lang::main('side') . match ($this->subject->getField('side'))
|
||||
{
|
||||
SIDE_ALLIANCE => '[span class=icon-alliance]'.Lang::game('si', SIDE_ALLIANCE).'[/span]',
|
||||
SIDE_HORDE => '[span class=icon-horde]'.Lang::game('si', SIDE_HORDE).'[/span]',
|
||||
default => Lang::game('si', SIDE_BOTH) // 0, 3
|
||||
};
|
||||
|
||||
if ($g = $this->subject->getField('gender'))
|
||||
$infobox[] = Lang::main('gender').Lang::main('colon').'[span class=icon-'.($g == 2 ? 'female' : 'male').']'.Lang::main('sex', $g).'[/span]';
|
||||
|
||||
if ($eId = $this->subject->getField('eventId'))
|
||||
{
|
||||
$this->extendGlobalIds(Type::WORLDEVENT, $eId);
|
||||
$infobox[] = Lang::game('eventShort', ['[event='.$eId.']']);
|
||||
}
|
||||
|
||||
if ($infobox)
|
||||
$this->infobox = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF, 'dbpage' => true], 'infobox-contents0');
|
||||
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
$this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
|
||||
$this->redButtons = array(
|
||||
BUTTON_WOWHEAD => true,
|
||||
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId]
|
||||
);
|
||||
|
||||
// factionchange-equivalent
|
||||
if ($pendant = DB::World()->selectCell('SELECT IF(`horde_id` = ?d, `alliance_id`, -`horde_id`) FROM player_factionchange_titles WHERE `alliance_id` = ?d OR `horde_id` = ?d', $this->typeId, $this->typeId, $this->typeId))
|
||||
{
|
||||
$altTitle = new TitleList(array(['id', abs($pendant)]));
|
||||
if (!$altTitle->error)
|
||||
{
|
||||
$this->transfer = Lang::title('_transfer', array(
|
||||
$altTitle->id,
|
||||
$altTitle->getHtmlizedName(),
|
||||
$pendant > 0 ? 'alliance' : 'horde',
|
||||
$pendant > 0 ? Lang::game('si', SIDE_ALLIANCE) : Lang::game('si', SIDE_HORDE)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated', true);
|
||||
|
||||
// tab: quest source
|
||||
$quests = new QuestList(array(['rewardTitleId', $this->typeId]));
|
||||
if (!$quests->error)
|
||||
{
|
||||
$this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_REWARDS));
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview(array(
|
||||
'data' => $quests->getListviewData(),
|
||||
'id' => 'reward-from-quest',
|
||||
'name' => '$LANG.tab_rewardfrom',
|
||||
'hiddenCols' => ['experience', 'money'],
|
||||
'visibleCols' => ['category']
|
||||
), QuestList::$brickFile));
|
||||
}
|
||||
|
||||
// tab: achievement source
|
||||
if ($aIds = DB::World()->selectCol('SELECT `ID` FROM achievement_reward WHERE `TitleA` = ?d OR `TitleH` = ?d', $this->typeId, $this->typeId))
|
||||
{
|
||||
$acvs = new AchievementList(array(['id', $aIds]));
|
||||
if (!$acvs->error)
|
||||
{
|
||||
$this->extendGlobalData($acvs->getJSGlobals());
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview(array(
|
||||
'data' => $acvs->getListviewData(),
|
||||
'id' => 'reward-from-achievement',
|
||||
'name' => '$LANG.tab_rewardfrom',
|
||||
'visibleCols' => ['category'],
|
||||
'sort' => ['reqlevel', 'name']
|
||||
), AchievementList::$brickFile));
|
||||
}
|
||||
}
|
||||
|
||||
// tab: criteria of
|
||||
if ($crt = DB::World()->selectCol('SELECT `criteria_id` FROM achievement_criteria_data WHERE `type` = 23 AND `value1` = ?d', $this->typeId))
|
||||
{
|
||||
$acvs = new AchievementList(array(['ac.id', $crt]));
|
||||
if (!$acvs->error)
|
||||
{
|
||||
$this->extendGlobalData($acvs->getJSGlobals());
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview(array(
|
||||
'data' => $acvs->getListviewData(),
|
||||
'id' => 'criteria-of',
|
||||
'name' => '$LANG.tab_criteriaof',
|
||||
'visibleCols' => ['category']
|
||||
), AchievementList::$brickFile));
|
||||
}
|
||||
}
|
||||
|
||||
// tab: condition-for
|
||||
$cnd = new Conditions();
|
||||
$cnd->getByCondition(Type::TITLE, $this->typeId)->prepare();
|
||||
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
|
||||
{
|
||||
$this->extendGlobalData($cnd->getJsGlobals());
|
||||
$this->lvTabs->addDataTab(...$tab);
|
||||
}
|
||||
|
||||
parent::generate();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
75
endpoints/titles/titles.php
Normal file
75
endpoints/titles/titles.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class TitlesBaseResponse extends TemplateResponse implements ICache
|
||||
{
|
||||
use TrListPage, TrCache;
|
||||
|
||||
protected int $type = Type::TITLE;
|
||||
protected int $cacheType = CACHE_TYPE_PAGE;
|
||||
|
||||
protected string $template = 'list-page-generic';
|
||||
protected string $pageName = 'titles';
|
||||
protected ?int $activeTab = parent::TAB_DATABASE;
|
||||
protected array $breadcrumb = [0, 10];
|
||||
|
||||
protected array $validCats = [0, 1, 2, 3, 4, 5, 6];
|
||||
|
||||
public function __construct(string $pageParam)
|
||||
{
|
||||
$this->getCategoryFromUrl($pageParam);
|
||||
|
||||
parent::__construct($pageParam);
|
||||
}
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$this->h1 = Util::ucFirst(Lang::game('titles'));
|
||||
|
||||
|
||||
if ($this->category)
|
||||
$this->breadcrumb[] = $this->category[0];
|
||||
|
||||
|
||||
array_unshift($this->title, $this->h1);
|
||||
if ($this->category)
|
||||
array_unshift($this->title, Lang::title('cat', $this->category[0]));
|
||||
|
||||
|
||||
$this->redButtons[BUTTON_WOWHEAD] = true;
|
||||
|
||||
$conditions = [];
|
||||
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE)) // hide unused titles
|
||||
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
||||
|
||||
if ($this->category)
|
||||
$conditions[] = ['category', $this->category[0]];
|
||||
|
||||
$tabData = ['data' => []];
|
||||
$titles = new TitleList($conditions);
|
||||
if (!$titles->error)
|
||||
{
|
||||
$tabData['data'] = $titles->getListviewData();
|
||||
|
||||
if ($titles->hasDiffFields('category'))
|
||||
$tabData['visibleCols'] = ['category'];
|
||||
|
||||
if (!$titles->hasAnySource())
|
||||
$tabData['hiddenCols'] = ['source'];
|
||||
}
|
||||
|
||||
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]);
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview($tabData, TitleList::$brickFile));
|
||||
|
||||
parent::generate();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
164
pages/title.php
164
pages/title.php
|
|
@ -1,164 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
// menuId 10: Title g_initPath()
|
||||
// tabId 0: Database g_initHeader()
|
||||
class TitlePage extends GenericPage
|
||||
{
|
||||
use TrDetailPage;
|
||||
|
||||
protected $type = Type::TITLE;
|
||||
protected $typeId = 0;
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 10];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
private $nameFixed = '';
|
||||
|
||||
public function __construct($pageCall, $id)
|
||||
{
|
||||
parent::__construct($pageCall, $id);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
|
||||
$this->subject = new TitleList(array(['id', $this->typeId]));
|
||||
if ($this->subject->error)
|
||||
$this->notFound(Lang::game('title'), Lang::title('notFound'));
|
||||
|
||||
$this->name = $this->subject->getHtmlizedName();
|
||||
$this->nameFixed = Util::ucFirst(trim(strtr($this->subject->getField('male', true), ['%s' => '', ',' => ''])));
|
||||
}
|
||||
|
||||
protected function generatePath()
|
||||
{
|
||||
$this->path[] = $this->subject->getField('category');
|
||||
}
|
||||
|
||||
protected function generateTitle()
|
||||
{
|
||||
array_unshift($this->title, $this->nameFixed, Util::ucFirst(Lang::game('title')));
|
||||
}
|
||||
|
||||
protected function generateContent()
|
||||
{
|
||||
/***********/
|
||||
/* Infobox */
|
||||
/***********/
|
||||
|
||||
$infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
|
||||
|
||||
if ($this->subject->getField('side') == SIDE_ALLIANCE)
|
||||
$infobox[] = Lang::main('side').Lang::main('colon').'[span class=icon-alliance]'.Lang::game('si', SIDE_ALLIANCE).'[/span]';
|
||||
else if ($this->subject->getField('side') == SIDE_HORDE)
|
||||
$infobox[] = Lang::main('side').Lang::main('colon').'[span class=icon-horde]'.Lang::game('si', SIDE_HORDE).'[/span]';
|
||||
else
|
||||
$infobox[] = Lang::main('side').Lang::main('colon').Lang::game('si', SIDE_BOTH);
|
||||
|
||||
if ($g = $this->subject->getField('gender'))
|
||||
$infobox[] = Lang::main('gender').Lang::main('colon').'[span class=icon-'.($g == 2 ? 'female' : 'male').']'.Lang::main('sex', $g).'[/span]';
|
||||
|
||||
if ($eId = $this->subject->getField('eventId'))
|
||||
{
|
||||
$this->extendGlobalIds(Type::WORLDEVENT, $eId);
|
||||
$infobox[] = Lang::game('eventShort').Lang::main('colon').'[event='.$eId.']';
|
||||
}
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
$this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null;
|
||||
$this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
|
||||
$this->redButtons = array(
|
||||
BUTTON_WOWHEAD => true,
|
||||
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId]
|
||||
);
|
||||
|
||||
// factionchange-equivalent
|
||||
if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_titles WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId))
|
||||
{
|
||||
$altTitle = new TitleList(array(['id', abs($pendant)]));
|
||||
if (!$altTitle->error)
|
||||
{
|
||||
$this->transfer = sprintf(
|
||||
Lang::title('_transfer'),
|
||||
$altTitle->id,
|
||||
$altTitle->getHtmlizedName(),
|
||||
$pendant > 0 ? 'alliance' : 'horde',
|
||||
$pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
// tab: quest source
|
||||
$quests = new QuestList(array(['rewardTitleId', $this->typeId]));
|
||||
if (!$quests->error)
|
||||
{
|
||||
$this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_REWARDS));
|
||||
|
||||
$this->lvTabs[] = [QuestList::$brickFile, array(
|
||||
'data' => array_values($quests->getListviewData()),
|
||||
'id' => 'reward-from-quest',
|
||||
'name' => '$LANG.tab_rewardfrom',
|
||||
'hiddenCols' => ['experience', 'money'],
|
||||
'visibleCols' => ['category']
|
||||
)];
|
||||
}
|
||||
|
||||
// tab: achievement source
|
||||
if ($aIds = DB::World()->selectCol('SELECT ID FROM achievement_reward WHERE TitleA = ?d OR TitleH = ?d', $this->typeId, $this->typeId))
|
||||
{
|
||||
$acvs = new AchievementList(array(['id', $aIds]));
|
||||
if (!$acvs->error)
|
||||
{
|
||||
$this->extendGlobalData($acvs->getJSGlobals());
|
||||
|
||||
$this->lvTabs[] = [AchievementList::$brickFile, array(
|
||||
'data' => array_values($acvs->getListviewData()),
|
||||
'id' => 'reward-from-achievement',
|
||||
'name' => '$LANG.tab_rewardfrom',
|
||||
'visibleCols' => ['category'],
|
||||
'sort' => ['reqlevel', 'name']
|
||||
)];
|
||||
}
|
||||
}
|
||||
|
||||
// tab: criteria of
|
||||
if ($crt = DB::World()->selectCol('SELECT `criteria_id` FROM achievement_criteria_data WHERE `type` = 23 AND `value1` = ?d', $this->typeId))
|
||||
{
|
||||
$acvs = new AchievementList(array(['ac.id', $crt]));
|
||||
if (!$acvs->error)
|
||||
{
|
||||
$this->extendGlobalData($acvs->getJSGlobals());
|
||||
|
||||
$this->lvTabs[] = [AchievementList::$brickFile, array(
|
||||
'data' => array_values($acvs->getListviewData()),
|
||||
'id' => 'criteria-of',
|
||||
'name' => '$LANG.tab_criteriaof',
|
||||
'visibleCols' => ['category']
|
||||
)];
|
||||
}
|
||||
}
|
||||
|
||||
// tab: condition-for
|
||||
$cnd = new Conditions();
|
||||
$cnd->getByCondition(Type::TITLE, $this->typeId)->prepare();
|
||||
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
|
||||
{
|
||||
$this->extendGlobalData($cnd->getJsGlobals());
|
||||
$this->lvTabs[] = $tab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
// menuId 10: Title g_initPath()
|
||||
// tabId 0: Database g_initHeader()
|
||||
class TitlesPage extends GenericPage
|
||||
{
|
||||
use TrListPage;
|
||||
|
||||
protected $type = Type::TITLE;
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 10];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [0, 1, 2, 3, 4, 5, 6];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
{
|
||||
$this->getCategoryFromUrl($pageParam);
|
||||
|
||||
parent::__construct($pageCall, $pageParam);
|
||||
|
||||
$this->name = Util::ucFirst(Lang::game('titles'));
|
||||
}
|
||||
|
||||
protected function generateContent()
|
||||
{
|
||||
$conditions = [];
|
||||
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE)) // hide unused titles
|
||||
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
||||
|
||||
if ($this->category)
|
||||
$conditions[] = ['category', $this->category[0]];
|
||||
|
||||
$tabData = ['data' => []];
|
||||
$titles = new TitleList($conditions);
|
||||
if (!$titles->error)
|
||||
{
|
||||
$tabData['data'] = array_values($titles->getListviewData());
|
||||
|
||||
if ($titles->hasDiffFields('category'))
|
||||
$tabData['visibleCols'] = ['category'];
|
||||
|
||||
if (!$titles->hasAnySource())
|
||||
$tabData['hiddenCols'] = ['source'];
|
||||
}
|
||||
|
||||
$this->lvTabs[] = [TitleList::$brickFile, $tabData];
|
||||
}
|
||||
|
||||
protected function generateTitle()
|
||||
{
|
||||
array_unshift($this->title, Util::ucFirst(Lang::game('titles')));
|
||||
if ($this->category)
|
||||
array_unshift($this->title, Lang::title('cat', $this->category[0]));
|
||||
}
|
||||
|
||||
protected function generatePath()
|
||||
{
|
||||
if ($this->category)
|
||||
$this->path[] = $this->category[0]; // should be only one parameter anyway
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue