From 30bc43ce24a4cc5898e41bd3aa96a579e4771ae2 Mon Sep 17 00:00:00 2001 From: Minitek Date: Thu, 24 Feb 2022 00:17:48 +0200 Subject: [PATCH] Use Registry class for reading section and topic parameters --- site/layouts/fb_leftnav.php | 24 +-- site/layouts/fb_topnav.php | 14 +- site/src/Helper/NavigationHelper.php | 11 +- site/src/Model/SectionModel.php | 10 +- site/src/Model/TopicModel.php | 2 +- site/src/View/Section/HtmlView.php | 265 ++++++++----------------- site/src/View/Sections/HtmlView.php | 15 +- site/src/View/Topic/HtmlView.php | 174 ++++------------ site/tmpl/sections/default_columns.php | 14 +- site/tmpl/sections/default_forum.php | 9 +- 10 files changed, 166 insertions(+), 372 deletions(-) diff --git a/site/layouts/fb_leftnav.php b/site/layouts/fb_leftnav.php index 98f1ded..a2dc7fc 100644 --- a/site/layouts/fb_leftnav.php +++ b/site/layouts/fb_leftnav.php @@ -18,18 +18,13 @@ use Joomla\Component\FAQBookPro\Site\Helper\NavigationHelper; use Joomla\Component\FAQBookPro\Site\Model\SectionModel; use Joomla\Component\FAQBookPro\Site\Helper\RouteHelper; +use Joomla\Registry\Registry; $sectionId = $displayData['sectionId']; $visible = $displayData['visible']; $section = Table::getInstance('SectionTable', 'Joomla\Component\FAQBookPro\Administrator\Table\\'); $section->load($sectionId); -$sectionParams = json_decode($section->attribs, false); - -if (!isset($sectionParams->browse_topics)) -{ - $sectionParams->browse_topics = false; -} - +$sectionParams = new Registry($section->attribs); $user = Factory::getUser(); $userid = $user->id; $sectionModel = new SectionModel; @@ -50,19 +45,14 @@ $fb_minimized = ''; $minimized_icon = ''; $section_title_html = ''; +$visible_class = $visible ? '' : 'leftnav-hidden'; -if ((!$is_minimized && $sectionParams->leftnav == '2') || $is_minimized == 'on') +if ((!$is_minimized && $sectionParams->get('leftnav', 1) == 2) || $is_minimized == 'on') { $fb_minimized = 'fb-minimized'; $minimized_icon = ''; } -$visible_class = ''; -if (!$visible) -{ - $visible_class = 'leftnav-hidden'; -} - ?>
browse_topics && isset($topics_tree) && $topics_tree) + if ($sectionParams->get('browse_topics', 1) && isset($topics_tree) && $topics_tree) { $browse_topics_class = ''; + if ($app->input->get('view', '') == 'section' && $app->input->get('tab', '') == 'topics') { $browse_topics_class = 'li_selected'; @@ -117,7 +107,6 @@
load($sectionId); $sectionTitle = $section->title; - $sectionParams = json_decode($section->attribs, false); + $sectionParams = new Registry($section->attribs); $menu = $app->getMenu(); $activeMenu = $menu->getActive(); - $topnav_sections = isset($sectionParams->topnav_sections) ? $sectionParams->topnav_sections : false; - $home_itemid = isset($sectionParams->topnav_root) ? $sectionParams->topnav_root : $activeMenu->id; + $home_itemid = $sectionParams->get('topnav_root', '') ? $sectionParams->get('topnav_root', '') : $activeMenu->id; $home_menuitem = $menu->getItem($home_itemid); $home_title = $home_menuitem->title; } @@ -52,7 +52,7 @@