Skip to content

Commit 71a44a9

Browse files
feat: use MenuItem label for page header titles
Look up the Menu_Items table label via displayLabel() for the page header h2, so custom labels set by users are respected. Falls back to hardcoded title for views without a menu entry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e1a9dde commit 71a44a9

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

web/skins/classic/includes/functions.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,27 @@ function getPageHelpData() {
297297
);
298298
}
299299

300+
// Map view names to Menu_Items MenuKey values
301+
function getViewMenuKeyMap() {
302+
return array(
303+
'console' => 'Console',
304+
'montage' => 'Montage',
305+
'montagereview' => 'MontageReview',
306+
'events' => 'Events',
307+
'options' => 'Options',
308+
'log' => 'Log',
309+
'devices' => 'Devices',
310+
'intelgpu' => 'IntelGpu',
311+
'quadra' => 'Quadra',
312+
'groups' => 'Groups',
313+
'filter' => 'Filters',
314+
'snapshots' => 'Snapshots',
315+
'reports' => 'Reports',
316+
'report_event_audit' => 'ReportEventAudit',
317+
'map' => 'Map',
318+
);
319+
}
320+
300321
function getPageHeaderHTML($viewName = null) {
301322
if ($viewName === null) {
302323
global $view;
@@ -306,9 +327,23 @@ function getPageHeaderHTML($viewName = null) {
306327
if (!isset($pages[$viewName])) return '';
307328

308329
$page = $pages[$viewName];
309-
$title = htmlspecialchars($page['title']);
310330
$help = htmlspecialchars($page['help']);
311331

332+
// Use MenuItem label if this view has a menu entry
333+
$title = null;
334+
$menuKeyMap = getViewMenuKeyMap();
335+
if (isset($menuKeyMap[$viewName])) {
336+
require_once('includes/MenuItem.php');
337+
$menuItem = ZM\MenuItem::find_one(array('MenuKey' => $menuKeyMap[$viewName]));
338+
if ($menuItem) {
339+
$title = htmlspecialchars($menuItem->displayLabel());
340+
}
341+
}
342+
// Fall back to hardcoded title
343+
if (!$title) {
344+
$title = htmlspecialchars($page['title']);
345+
}
346+
312347
return '<div class="page-header-help">'
313348
.'<h2>'.$title.'</h2>'
314349
.'<p class="page-help text-muted small">'.$help.'</p>'

0 commit comments

Comments
 (0)