ListviewTabs/Fixup

* filter empty tabs before trying to display, case in point
 * do not always assign conditions tab if empty
This commit is contained in:
Sarjuuk
2024-08-27 16:15:50 +02:00
parent 50f5af07f3
commit 5270e70cd1
11 changed files with 33 additions and 20 deletions

View File

@@ -268,10 +268,11 @@ class AchievementPage extends GenericPage
// tab: condition for // tab: condition for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::ACHIEVEMENT, $this->typeId)->prepare()) $cnd->getByCondition(Type::ACHIEVEMENT, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }

View File

@@ -233,10 +233,11 @@ class ClassPage extends GenericPage
// tab: condition-for // tab: condition-for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::CHR_CLASS, $this->typeId)->prepare()) $cnd->getByCondition(Type::CHR_CLASS, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }
} }
} }

View File

@@ -270,10 +270,11 @@ class EventPage extends GenericPage
// tab: condition for // tab: condition for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::WORLDEVENT, $this->typeId)->prepare()) $cnd->getByCondition(Type::WORLDEVENT, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }
} }

View File

@@ -297,10 +297,11 @@ class FactionPage extends GenericPage
// tab: condition-for // tab: condition-for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::FACTION, $this->typeId)->prepare()) $cnd->getByCondition(Type::FACTION, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }
} }
} }

View File

@@ -783,7 +783,10 @@ class GenericPage
$this->addAnnouncements(); $this->addAnnouncements();
if (isset($this->lvTabs)) if (isset($this->lvTabs))
{
$this->lvTabs = array_filter($this->lvTabs);
array_walk($this->lvTabs, function (&$x) { $x = array_pad($x, 3, null); }); array_walk($this->lvTabs, function (&$x) { $x = array_pad($x, 3, null); });
}
include('template/pages/'.$this->tpl.'.tpl.php'); include('template/pages/'.$this->tpl.'.tpl.php');
die(); die();

View File

@@ -1011,10 +1011,11 @@ class ItemPage extends genericPage
// tab: condition-for // tab: condition-for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::ITEM, $this->typeId)->prepare()) $cnd->getByCondition(Type::ITEM, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }

View File

@@ -475,10 +475,11 @@ class ObjectPage extends GenericPage
// tab: condition-for // tab: condition-for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::OBJECT, $this->typeId)->prepare()) $cnd->getByCondition(Type::OBJECT, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }
} }

View File

@@ -204,10 +204,11 @@ class RacePage extends GenericPage
// tab: condition-for // tab: condition-for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::CHR_RACE, $this->typeId)->prepare()) $cnd->getByCondition(Type::CHR_RACE, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }
} }
} }

View File

@@ -339,10 +339,11 @@ class SkillPage extends GenericPage
// tab: condition-for // tab: condition-for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::SKILL, $this->typeId)->prepare()) $cnd->getByCondition(Type::SKILL, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }
} }
} }

View File

@@ -150,10 +150,11 @@ class TitlePage extends GenericPage
// tab: condition-for // tab: condition-for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::TITLE, $this->typeId)->prepare()) $cnd->getByCondition(Type::TITLE, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }
} }
} }

View File

@@ -787,10 +787,11 @@ class ZonePage extends GenericPage
// tab: condition-for // tab: condition-for
$cnd = new Conditions(); $cnd = new Conditions();
if ($cnd->getByCondition(Type::ZONE, $this->typeId)->prepare()) $cnd->getByCondition(Type::ZONE, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); $this->lvTabs[] = $tab;
} }
} }