From e8a84ca42841c0204469efcc0a7c20d4b64dec24 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Tue, 8 Apr 2025 13:17:09 -0700 Subject: [PATCH] refactor: reorganize HTML structure in DefaultPageLayout.php and MainContent.php for improved readability and maintainability --- .../dynamix/include/DefaultPageLayout.php | 15 ++- .../include/DefaultPageLayout/MainContent.php | 101 +++++++++--------- 2 files changed, 59 insertions(+), 57 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index feef9707b..b8dc82c4a 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -164,12 +164,11 @@ if (isset($myPage['Load'])) { -
- - - - - - - + + + + + + + diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout/MainContent.php b/emhttp/plugins/dynamix/include/DefaultPageLayout/MainContent.php index 20e32b70f..f76c4605a 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout/MainContent.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout/MainContent.php @@ -1,55 +1,58 @@ "; $tab = 1; if (isset($myPage['Tabs'])) $display['tabs'] = strtolower($myPage['Tabs'])=='true' ? 0 : 1; $tabbed = $display['tabs']==0 && count($pages)>1; - -foreach ($pages as $page) { - $close = false; - if (isset($page['Title'])) { - eval("\$title=\"".htmlspecialchars($page['Title'])."\";"); - if ($tabbed) { - echo "
"; - $close = true; - } else { - if ($tab==1) echo "
"; - echo "
"; - echo tab_title($title,$page['root'],_var($page,'Tag',false)); - echo "
"; - } - $tab++; - } - if (isset($page['Type']) && $page['Type']=='menu') { - $pgs = find_pages($page['name']); - foreach ($pgs as $pg) { - @eval("\$title=\"".htmlspecialchars($pg['Title'])."\";"); - $icon = _var($pg,'Icon',""); - if (substr($icon,-4)=='.png') { - $root = $pg['root']; - if (file_exists("$docroot/$root/images/$icon")) { - $icon = ""; - } elseif (file_exists("$docroot/$root/$icon")) { - $icon = ""; - } else { - $icon = ""; - } - } elseif (substr($icon,0,5)=='icon-') { - $icon = ""; - } elseif ($icon[0]!='<') { - if (substr($icon,0,3)!='fa-') $icon = "fa-$icon"; - $icon = ""; - } - echo ""; - } - } - annotate($page['file']); - // create page content - empty($page['Markdown']) || $page['Markdown']=='true' ? eval('?>'.Markdown(parse_text($page['text']))) : eval('?>'.parse_text($page['text'])); - if ($close) echo "
"; -} -unset($pages,$page,$pgs,$pg,$icon,$nchan,$running,$start,$stop,$row,$script,$opt,$nchan_run); ?> -
\ No newline at end of file +
+
+
"; + $close = true; + } else { + if ($tab==1) echo "
"; + echo "
"; + echo tab_title($title,$page['root'],_var($page,'Tag',false)); + echo "
"; + } + $tab++; + } + if (isset($page['Type']) && $page['Type']=='menu') { + $pgs = find_pages($page['name']); + foreach ($pgs as $pg) { + @eval("\$title=\"".htmlspecialchars($pg['Title'])."\";"); + $icon = _var($pg,'Icon',""); + if (substr($icon,-4)=='.png') { + $root = $pg['root']; + if (file_exists("$docroot/$root/images/$icon")) { + $icon = ""; + } elseif (file_exists("$docroot/$root/$icon")) { + $icon = ""; + } else { + $icon = ""; + } + } elseif (substr($icon,0,5)=='icon-') { + $icon = ""; + } elseif ($icon[0]!='<') { + if (substr($icon,0,3)!='fa-') $icon = "fa-$icon"; + $icon = ""; + } + echo ""; + } + } + annotate($page['file']); + // create page content + empty($page['Markdown']) || $page['Markdown']=='true' ? eval('?>'.Markdown(parse_text($page['text']))) : eval('?>'.parse_text($page['text'])); + if ($close) echo "
"; + } + unset($pages,$page,$pgs,$pg,$icon,$nchan,$running,$start,$stop,$row,$script,$opt,$nchan_run); + ?> +
+
\ No newline at end of file