1;
$contentInclude = $tabbed ? 'MainContentTabbed.php' : 'MainContentTabless.php';
$defaultIcon = "";
/**
* Safely processes page titles by replacing PHP variables with their values
*
* @param string $rawTitle The unprocessed title that may contain variable references
* @return string Processed title with variables substituted
*/
function processTitle($rawTitle) {
// Safely replace any variables in the title without eval
$title = htmlspecialchars((string)$rawTitle);
return preg_replace_callback(
'/\$([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/',
function($matches) {
return isset($GLOBALS[$matches[1]]) ?
htmlspecialchars((string)$GLOBALS[$matches[1]]) :
'$'.$matches[1];
},
$title
);
}
function process_icon($icon, $docroot, $root) {
global $defaultIcon;
if (substr($icon, -4) == '.png') {
if (file_exists("$docroot/$root/images/$icon")) {
return "";
} elseif (file_exists("$docroot/$root/$icon")) {
return "
";
}
return $defaultIcon;
} elseif (substr($icon, 0, 5) == 'icon-') {
return "";
} elseif ($icon[0] != '<') {
if (substr($icon, 0, 3) != 'fa-') {
$icon = "fa-$icon";
}
return "";
}
return $icon;
}
/**
* Generates a Panel DOM element for menu items
*
* @param array $pg Page data array containing name, Title, Icon
* @param string $path Current path
* @param string $defaultIcon Default icon to use if none specified
* @param string $docroot Document root path
* @param bool $useTabCookie Whether to add tab cookie onclick handler
* @return string HTML for the Panel element
*/
function generatePanel($pg, $path, $defaultIcon, $docroot, $useTabCookie = false) {
// Process title using our safe variable substitution function
$panelTitle = processTitle($pg['Title']);
$icon = _var($pg, 'Icon', $defaultIcon);
$icon = process_icon($icon, $docroot, $pg['root']);
$onclick = $useTabCookie ? ' onclick="$.cookie(\'one\',\'tab1\')"' : '';
return sprintf(
'