From 20dbda082919e107a5956e1567a1dbdf56385c3f Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sat, 14 Jan 2017 16:14:33 -0600 Subject: [PATCH] Update os icon the handling. Add title to the os image (#5424) --- html/pages/device/edit/icon.inc.php | 74 ----------------------------- includes/functions.php | 12 ++--- 2 files changed, 5 insertions(+), 81 deletions(-) delete mode 100644 html/pages/device/edit/icon.inc.php diff --git a/html/pages/device/edit/icon.inc.php b/html/pages/device/edit/icon.inc.php deleted file mode 100644 index a3d5ef86e8..0000000000 --- a/html/pages/device/edit/icon.inc.php +++ /dev/null @@ -1,74 +0,0 @@ - '7') { - $param = array('icon' => $_POST['icon']); - - $rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id'])); - - if ($rows_updated > 0 || $updated) { - $update_message = 'Device icon updated.'; - $updated = 1; - $device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); - } elseif ($rows_updated = '-1') { - $update_message = 'Device icon unchanged. No update necessary.'; - $updated = -1; - } else { - $update_message = 'Device icon update error.'; - } - } else { - include 'includes/error-no-perm.inc.php'; - } -} - -if ($updated && $update_message) { - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); -} - -?> - -

Device icon

- - - - - - - -
-
- - -\n"; - -// Default icon -$icon = $config['os'][$device['os']]['icon']; -echo ' '."\n"; - -for ($i = 0; $i < count($config['os'][$device['os']]['icons']); $i++) { - $icon = $config['os'][$device['os']]['icons'][$i]; - echo ' '."\n"; -} - -if (($numicons % 10) == 0) { - echo " \n"; - echo " \n"; -} -?> - - - - -

'.nicecase($icon).'

'; -echo '


'.nicecase($icon).'

'; - echo '

-
- -
-
-
-
diff --git a/includes/functions.php b/includes/functions.php index d250ea257b..601e5b2597 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -214,7 +214,8 @@ function interface_errors($rrd_file, $period = '-1d') function getImage($device) { - return ''; + $title = $device['icon'] ? str_replace(array('.svg', '.png'), '', $device['icon']) : $device['os']; + return ''; } function getImageSrc($device) @@ -229,7 +230,7 @@ function getImageName($device, $use_database = true) $device['os'] = strtolower($device['os']); // fetch from the database - if ($use_database && $device['icon'] != 'generic.png' && is_file($config['html_dir'] . '/images/os/' . $device['icon'])) { + if ($use_database && is_file($config['html_dir'] . '/images/os/' . $device['icon'])) { return $device['icon']; } @@ -238,9 +239,6 @@ function getImageName($device, $use_database = true) if ($device['os'] == "linux") { $features = strtolower(trim($device['features'])); list($distro) = explode(" ", $features); - if (file_exists($config['html_dir'] . "/images/os/$distro" . ".png")) { - return $distro; - } } $possibilities = array( @@ -250,8 +248,8 @@ function getImageName($device, $use_database = true) ); foreach ($possibilities as $basename) { - foreach (array("svg", "png") as $ext) { - $name = $basename . '.' . $ext; + foreach (array('.svg', '.png') as $ext) { + $name = $basename . $ext; if (is_file($config['html_dir'] . '/images/os/' . $name)) { return $name; }