Files
zoneminder/web/includes/MenuItem.php
Isaac Connor 47cdb699ba feat: add 'none' icon type, show icons in navbar, fix console column dropdown
- Add 'none' as icon type option to hide icons on individual menu items
- Display custom icons in top navbar to match left sidebar appearance
- Fix console table Columns dropdown showing raw HTML by moving icon/link
  rendering to JS post-init (bootstrap-table captures th innerHTML for
  dropdown labels, so icons must be injected after initialization)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:59:40 -04:00

69 lines
1.9 KiB
PHP

<?php
namespace ZM;
require_once('database.php');
require_once('Object.php');
class MenuItem extends ZM_Object {
protected static $table = 'Menu_Items';
protected $defaults = array(
'Id' => null,
'MenuKey' => '',
'Enabled' => 1,
'Label' => null,
'SortOrder' => 0,
'Icon' => null,
'IconType' => 'material',
);
// Default material icons for each menu key
public static $defaultIcons = array(
'Console' => 'dashboard',
'Montage' => 'live_tv',
'MontageReview' => 'movie',
'Events' => 'event',
'Options' => 'settings',
'Log' => 'notification_important',
'Devices' => 'devices_other',
'IntelGpu' => 'memory',
'Groups' => 'group',
'Filters' => 'filter_alt',
'Snapshots' => 'preview',
'Reports' => 'report',
'ReportEventAudit' => 'shield',
'Map' => 'language',
);
public function effectiveIcon() {
if ($this->{'Icon'} !== null && $this->{'Icon'} !== '') {
return $this->{'Icon'};
}
return isset(self::$defaultIcons[$this->{'MenuKey'}]) ? self::$defaultIcons[$this->{'MenuKey'}] : 'menu';
}
public function effectiveIconType() {
if ($this->{'IconType'} == 'none') {
return 'none';
}
if ($this->{'Icon'} !== null && $this->{'Icon'} !== '') {
return $this->{'IconType'};
}
return 'material';
}
public static function find($parameters = array(), $options = array()) {
return ZM_Object::_find(self::class, $parameters, $options);
}
public static function find_one($parameters = array(), $options = array()) {
return ZM_Object::_find_one(self::class, $parameters, $options);
}
public function displayLabel() {
if ($this->{'Label'} !== null && $this->{'Label'} !== '') {
return $this->{'Label'};
}
return translate($this->{'MenuKey'});
}
}