Hi Attila,
Thanks, it does indeed make sense to remove the coordinates from the string before splitting!
Tom
On 09/01/2017 19:13, Attila Nagy wrote:
Hi everyone!
We recently updated to the latest CE version and happily saw the new improvements, the new map really rocks, and the small things are awesome too.
What I would like to point out is one small glitch in the new (at least for us) nested location menu. We use $config['location_map'] to mass override the location strings of most devices (lots of devices don't cope with accented/special characters, so we limit the on device sysLocation and add human readable address later on), and we include exact coordinates in square brackets at the end of the new location string. And here comes the glitch, the split char for the nested menu is by default comma, so the new location string gets one extra split in the middle of the coordinates like: Locations > Some place > some other place [43.53 > 15.25]
A solution that I found is to completely drop any coordinates from the end of the location string. For this I changed /opt/observium/html/includes/navbar.inc.php and added to the line 165: $location = preg_replace('/[[[:digit:]NWSE,. -]+]$/','',$location);
As seen in context:
foreach (get_locations() as $location) {
$location = preg_replace('/\[[[:digit:]NWSE,.
-]+]$/','',$location); // If location is empty, substitute by OBS_VAR_UNSET as empty location parameter would be ignored $name = ($location === '' ? OBS_VAR_UNSET : escape_html($location));
Another solution that came into my mind - and one that is more general
- is to include an option, something like
$config['location']['menu']['nested_end_string'] = ' - '; where the location string would be truncated at the first occurrence of this subtring. This way one can enter extra information in the location string be it from the sysLocation of a device or from $config['location_map'] and have it displayed in the Location entry of a device but ignore it during the composition of the Location menu.
/opt/observium/html/includes/navbar.inc.php line 165: (together with the previous changes)
foreach (get_locations() as $location) {
$location = preg_replace('/\[[[:digit:]NWSE,.
-]+]$/','',$location);
if (strlen($config['location']['menu']['nested_end_string']) > 0)
$location =
preg_replace('/'.$config['location']['menu']['nested_end_string'].'.*$/', '', $location); // If location is empty, substitute by OBS_VAR_UNSET as empty location parameter would be ignored $name = ($location === '' ? OBS_VAR_UNSET : escape_html($location));
I hope you'll find these changes usable (and you didn't already addressed these - in this case sorry for robbing your time).
Regards, Tylla
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium