diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index 432d143a5..d4886b654 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -1,4 +1,4 @@ - -getThemeName(); // keep $theme, $themes1, $themes2 vars for plugin backwards compatibility for the time being @@ -18,7 +18,7 @@ $themes1 = $themeHelper->isTopNavTheme(); $themes2 = $themeHelper->isSidebarTheme(); $themeHelper->updateDockerLogColor($docroot); -$display['font'] = filter_var($_COOKIE['fontSize'] ?? $display['font'] ?? '',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); +$display['font'] = filter_var($_COOKIE['fontSize'] ?? $display['font'] ?? '', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $header = $display['header']; // keep $header, $backgnd vars for plugin backwards compatibility for the time being $backgnd = $display['background']; @@ -29,28 +29,38 @@ $alerts = '/tmp/plugins/my_alerts.txt'; $wlan0 = file_exists('/sys/class/net/wlan0'); $nchan = ['webGui/nchan/notify_poller','webGui/nchan/session_check']; -if ($wlan0) $nchan[] = 'webGui/nchan/wlan0'; -$safemode = _var($var,'safeMode')=='yes'; +if ($wlan0) { + $nchan[] = 'webGui/nchan/wlan0'; +} +$safemode = _var($var, 'safeMode') == 'yes'; $banner = "$config/plugins/dynamix/banner.png"; $notes = '/var/tmp/unRAIDServer.txt'; -if (!file_exists($notes)) file_put_contents($notes,shell_exec("$docroot/plugins/dynamix.plugin.manager/scripts/plugin changes $docroot/plugins/unRAIDServer/unRAIDServer.plg")); +if (!file_exists($notes)) { + file_put_contents($notes, shell_exec("$docroot/plugins/dynamix.plugin.manager/scripts/plugin changes $docroot/plugins/unRAIDServer/unRAIDServer.plg")); +} $taskPages = find_pages('Tasks'); $buttonPages = find_pages('Buttons'); -function annotate($text) {echo "\n\n";} +function annotate($text) +{ + echo "\n\n"; +} -function generateReloadScript($loadMinutes) { - if ($loadMinutes <= 0) return ''; +function generateReloadScript($loadMinutes) +{ + if ($loadMinutes <= 0) { + return ''; + } $interval = $loadMinutes * 60000; return "\n\n"; } ?> -lang="" class="getThemeHtmlClass() ?>"> +lang="" class="getThemeHtmlClass() ?>"> -<?=_var($var,'NAME')?>/<?=_var($myPage,'name')?> +<?=_var($var, 'NAME')?>/<?=_var($myPage, 'name')?> @@ -58,7 +68,7 @@ function generateReloadScript($loadMinutes) { - + "> "> "> @@ -86,10 +96,10 @@ function generateReloadScript($loadMinutes) { } -isSidebarTheme()) { - echo generate_sidebar_icon_css($taskPages, $buttonPages); + echo generate_sidebar_icon_css($taskPages, $buttonPages); } ?> @@ -101,24 +111,46 @@ if ($themeHelper->isSidebarTheme()) { - + -',"\n"; - if (is_file($docroot.$css_theme)) echo '',"\n"; - // create page content - eval('?>'.parse_text($button['text'])); + annotate($button['file']); + // include page specific stylesheets (if existing) + $css = "/{$button['root']}/sheets/{$button['name']}"; + $css_stock = "$css.css"; + $css_theme = "$css-$theme.css"; // @todo add syslog for deprecation notice + if (is_file($docroot.$css_stock)) { + echo '',"\n"; + } + if (is_file($docroot.$css_theme)) { + echo '',"\n"; + } + // create page content + eval('?>'.parse_text($button['text'])); } // Reload page every X minutes during extended viewing? -if (isset($myPage['Load'])) { - echo generateReloadScript($myPage['Load']); +if (isset($myPage['Load']) && $myPage['Load'] > 0) { + ?> + + @@ -136,51 +168,63 @@ if (isset($myPage['Load'])) { -"; -if ($themeHelper->isSidebarTheme()) echo ""; unset($buttonPages,$button); @@ -189,83 +233,105 @@ unset($buttonPages,$button); echo "
"; $tab = 1; $pages = []; -if (!empty($myPage['text'])) $pages[$myPage['name']] = $myPage; -if (_var($myPage,'Type')=='xmenu') $pages = array_merge($pages, find_pages($myPage['name'])); -if (isset($myPage['Tabs'])) $display['tabs'] = strtolower($myPage['Tabs'])=='true' ? 0 : 1; -$tabbed = $display['tabs']==0 && count($pages)>1; +if (!empty($myPage['text'])) { + $pages[$myPage['name']] = $myPage; +} +if (_var($myPage, 'Type') == 'xmenu') { + $pages = array_merge($pages, find_pages($myPage['name'])); +} +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 = ""; + $close = false; + if (isset($page['Title'])) { + eval("\$title=\"".htmlspecialchars($page['Title'])."\";"); + if ($tabbed) { + echo "
"; + $close = true; } else { - $icon = ""; + if ($tab == 1) { + echo "
"; + } + echo "
"; + echo tab_title($title, $page['root'], _var($page, 'Tag', false)); + echo "
"; } - } elseif (substr($icon,0,5)=='icon-') { - $icon = ""; - } elseif ($icon[0]!='<') { - if (substr($icon,0,3)!='fa-') $icon = "fa-$icon"; - $icon = ""; - } - 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 ""; + } + } + // create list of nchan scripts to be started + if (isset($page['Nchan'])) { + nchan_merge($page['root'], $page['Nchan']); + } + annotate($page['file']); + // include page specific stylesheets (if existing) + $css = "/{$page['root']}/sheets/{$page['name']}"; + $css_stock = "$css.css"; + $css_theme = "$css-$theme.css"; + if (is_file($docroot.$css_stock)) { + echo '',"\n"; + } + if (is_file($docroot.$css_theme)) { + echo '',"\n"; + } + // create page content + empty($page['Markdown']) || $page['Markdown'] == 'true' ? eval('?>'.Markdown(parse_text($page['text']))) : eval('?>'.parse_text($page['text'])); + if ($close) { + echo "
"; } - } - // create list of nchan scripts to be started - if (isset($page['Nchan'])) nchan_merge($page['root'], $page['Nchan']); - annotate($page['file']); - // include page specific stylesheets (if existing) - $css = "/{$page['root']}/sheets/{$page['name']}"; - $css_stock = "$css.css"; - $css_theme = "$css-$theme.css"; - if (is_file($docroot.$css_stock)) echo '',"\n"; - if (is_file($docroot.$css_theme)) echo '',"\n"; - // create page content - empty($page['Markdown']) || $page['Markdown']=='true' ? eval('?>'.Markdown(parse_text($page['text']))) : eval('?>'.parse_text($page['text'])); - if ($close) echo "
"; } if (count($pages)) { - $running = file_exists($nchan_pid) ? file($nchan_pid,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES) : []; - $start = array_diff($nchan, $running); // returns any new scripts to be started - $stop = array_diff($running, $nchan); // returns any old scripts to be stopped - $running = array_merge($start, $running); // update list of current running nchan scripts - // start nchan scripts which are new - foreach ($start as $row) { - $script = explode(':',$row)[0]; - exec("$docroot/$script &>/dev/null &"); - } - // stop nchan scripts with the :stop option - foreach ($stop as $row) { - [$script,$opt] = my_explode(':',$row); - if ($opt == 'stop') { - exec("pkill -f $docroot/$script &>/dev/null &"); - array_splice($running,array_search($row,$running),1); + $running = file_exists($nchan_pid) ? file($nchan_pid, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : []; + $start = array_diff($nchan, $running); // returns any new scripts to be started + $stop = array_diff($running, $nchan); // returns any old scripts to be stopped + $running = array_merge($start, $running); // update list of current running nchan scripts + // start nchan scripts which are new + foreach ($start as $row) { + $script = explode(':', $row)[0]; + exec("$docroot/$script &>/dev/null &"); + } + // stop nchan scripts with the :stop option + foreach ($stop as $row) { + [$script,$opt] = my_explode(':', $row); + if ($opt == 'stop') { + exec("pkill -f $docroot/$script &>/dev/null &"); + array_splice($running, array_search($row, $running), 1); + } + } + if (count($running)) { + file_put_contents($nchan_pid, implode("\n", $running)."\n"); + } else { + @unlink($nchan_pid); } - } - if (count($running)) file_put_contents($nchan_pid,implode("\n",$running)."\n"); else @unlink($nchan_pid); } unset($pages,$page,$pgs,$pg,$icon,$nchan,$running,$start,$stop,$row,$script,$opt,$nchan_run); ?> @@ -274,7 +340,7 @@ unset($pages,$page,$pgs,$pg,$icon,$nchan,$running,$start,$stop,$row,$script,$opt
- - + + diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout/BodyInlineJS.php b/emhttp/plugins/dynamix/include/DefaultPageLayout/BodyInlineJS.php index 1412956a3..4ec20cfc3 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout/BodyInlineJS.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout/BodyInlineJS.php @@ -434,7 +434,13 @@ document.addEventListener("visibilitychange", (event) => { nchanFocusStop(); } else { 0):?> - window.location.reload(); + if ( dialogOpen() ) { + clearInterval(timers.reload); + setTimerReload(); + nchanFocusStart(); + } else { + window.location.reload(); + } nchanFocusStart();