From e108bda566099c02f14dc9f3252b8d653a108553 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Tue, 1 Jul 2025 00:43:16 +0300 Subject: [PATCH] Added support for "ZM_WEB_NAVBAR_LINKS" for the menu in the left sidebar (functions.php) --- web/skins/classic/includes/functions.php | 57 ++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 38d9dbd3c..e8c360790 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -218,7 +218,8 @@ function buildSidebarMenu() { getSnapshotsHTML($view, $forLeftBar = true) . getReportsHTML($view, $forLeftBar = true) . getRprtEvntAuditHTML($view, $forLeftBar = true) . - getMapHTML($view, $forLeftBar = true) + getMapHTML($view, $forLeftBar = true) . + getAdditionalLinksHTML($view, $forLeftBar = true) ; } else { // USER IS NOT AUTHORIZED! $menuForAuthUser = ''; @@ -258,7 +259,7 @@ function buildSidebarMenu() { ' . translate("zmNinja") . ' - '.PHP_EOL; + if ($forLeftBar) { + $doc = new DomDocument(); + fixAmps($link); + $doc->loadHTML('' . $link); + $url = $doc->getElementsByTagName('a')[0]; + $value_ = translate('Error in link string: "') . htmlspecialchars($link) . '"'; + $href_ = ''; + $icon_ = ''; + $class_ = ''; + $queryView = ''; + if ($url) { + $value_ = $url->nodeValue; + $href_ = $url->getAttribute( 'href' ); + $icon_ = $url->getAttribute('data-icon'); + $class_ = $url->getAttribute('class'); + $parts = parse_url($href_); + parse_str($parts['query'], $query); + $queryView = $query['view']; + } + + $result .= buildMenuItem( + $viewItemName = $queryView, + $id = '', + $itemName = $value_, + $href = $href_, + $icon = $icon_, + $classNameForTag_A = $class_, + $subMenu = '' + ); + } else { + $result .= ''.PHP_EOL; + } } } } @@ -1513,6 +1545,23 @@ function getCSRFinputHTML() { return $result; } +function fixAmps(&$html) { + //https://stackoverflow.com/questions/1685277/warning-domdocumentloadhtml-htmlparseentityref-expecting-in-entity + $positionAmp = strpos($html, '&'); + $positionSemiColumn = strpos($html, ';', $positionAmp+1); + $string = substr($html, $positionAmp, $positionSemiColumn-$positionAmp+1); + if ($positionAmp !== false) { // If an '&' can be found. + if ($positionSemiColumn === false) { // If no ';' can be found. + $html = substr_replace($html, '&', $positionAmp, 1); // Replace straight away. + } else if (preg_match('/&(#[0-9]+|[A-Z|a-z|0-9]+);/', $string) === 0) { // If a standard escape cannot be found. + $html = substr_replace($html, '&', $positionAmp, 1); // This mean we need to escape the '&' sign. + fixAmps($html, $positionAmp+5); // Recursive call from the new position. + } else { + fixAmps($html, $positionAmp+1); // Recursive call from the new position. + } + } +} + function xhtmlFooter() { global $useOldMenuView; if ($useOldMenuView !== true) {