From 5270e70cd1f3998de4344ae93028f73c7d7d3072 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Tue, 27 Aug 2024 16:15:50 +0200 Subject: [PATCH] ListviewTabs/Fixup * filter empty tabs before trying to display, case in point * do not always assign conditions tab if empty --- pages/achievement.php | 5 +++-- pages/class.php | 5 +++-- pages/event.php | 5 +++-- pages/faction.php | 5 +++-- pages/genericPage.class.php | 3 +++ pages/item.php | 5 +++-- pages/object.php | 5 +++-- pages/race.php | 5 +++-- pages/skill.php | 5 +++-- pages/title.php | 5 +++-- pages/zone.php | 5 +++-- 11 files changed, 33 insertions(+), 20 deletions(-) diff --git a/pages/achievement.php b/pages/achievement.php index f41bc550..b2b854d3 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -268,10 +268,11 @@ class AchievementPage extends GenericPage // tab: condition for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } diff --git a/pages/class.php b/pages/class.php index a4e6bb6b..d92d6ada 100644 --- a/pages/class.php +++ b/pages/class.php @@ -233,10 +233,11 @@ class ClassPage extends GenericPage // tab: condition-for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } } } diff --git a/pages/event.php b/pages/event.php index 246bd83a..bea2cfa5 100644 --- a/pages/event.php +++ b/pages/event.php @@ -270,10 +270,11 @@ class EventPage extends GenericPage // tab: condition for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } } diff --git a/pages/faction.php b/pages/faction.php index efd75f40..987ecb9a 100644 --- a/pages/faction.php +++ b/pages/faction.php @@ -297,10 +297,11 @@ class FactionPage extends GenericPage // tab: condition-for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } } } diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index 88bd4908..07f1a8c8 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -783,7 +783,10 @@ class GenericPage $this->addAnnouncements(); if (isset($this->lvTabs)) + { + $this->lvTabs = array_filter($this->lvTabs); array_walk($this->lvTabs, function (&$x) { $x = array_pad($x, 3, null); }); + } include('template/pages/'.$this->tpl.'.tpl.php'); die(); diff --git a/pages/item.php b/pages/item.php index 89fc4af6..b5acacca 100644 --- a/pages/item.php +++ b/pages/item.php @@ -1011,10 +1011,11 @@ class ItemPage extends genericPage // tab: condition-for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } diff --git a/pages/object.php b/pages/object.php index 803028a7..b1cf479e 100644 --- a/pages/object.php +++ b/pages/object.php @@ -475,10 +475,11 @@ class ObjectPage extends GenericPage // tab: condition-for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } } diff --git a/pages/race.php b/pages/race.php index a2e12498..b8b6b334 100644 --- a/pages/race.php +++ b/pages/race.php @@ -204,10 +204,11 @@ class RacePage extends GenericPage // tab: condition-for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } } } diff --git a/pages/skill.php b/pages/skill.php index 2b53d74d..b80a8de4 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -339,10 +339,11 @@ class SkillPage extends GenericPage // tab: condition-for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } } } diff --git a/pages/title.php b/pages/title.php index d9381706..d2b63c50 100644 --- a/pages/title.php +++ b/pages/title.php @@ -150,10 +150,11 @@ class TitlePage extends GenericPage // tab: condition-for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } } } diff --git a/pages/zone.php b/pages/zone.php index cdef4f67..8b8eacd6 100644 --- a/pages/zone.php +++ b/pages/zone.php @@ -787,10 +787,11 @@ class ZonePage extends GenericPage // tab: condition-for $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->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } }