function rewrite_location($location) { global $config, $attribs; $location = str_replace(array('\\"', '"'), '', $location); // Allow override sysLocation from DB. if ($attribs['override_sysLocation_bool']) { $new_location = $attribs['override_sysLocation_string']; $by = 'DB override'; } // This will call a user-defineable function to rewrite the location however the user wants. if (!isset($new_location) && function_exists('custom_rewrite_location')) { $new_location = custom_rewrite_location($location); $by = 'function custom_rewrite_location()'; } // This uses a statically defined array to map locations. if (!isset($new_location)) { if (isset($config['location']['map'][$location])) { $new_location = $config['location']['map'][$location]; $by = '$config[\'location\'][\'map\']'; } else { if (isset($config['location']['map_regexp'])) { foreach ($config['location']['map_regexp'] as $pattern => $entry) { if (preg_match($pattern, $location)) { $new_location = $entry; $by = '$config[\'location\'][\'map_regexp\']'; break; // stop foreach } } } } } if (isset($new_location)) { print_debug("sysLocation rewritten from '{$location}' to '{$new_location}' by {$by}."); $location = $new_location; } return $location; }
function rewrite_location($location) { /// FIXME - also check the database for rewrites? // Also roll this all up into some kind of 'rewrite_device' function? - adama global $config; // This will call a user-defineable function to rewrite the location however the user wants. if (function_exists('custom_rewrite_location')) { $new_location = custom_rewrite_location($location); if ($new_location) { return $new_location; } } // This uses a statically defined array to map locations. if (isset($config['location_map'][$location])) { $location = $config['location_map'][$location]; } return $location; }
function rewrite_location($location) { global $config, $attribs; $location = str_replace(array('\\"', '"'), '', $location); // Allow override sysLocation from DB. if ($attribs['override_sysLocation_bool']) { $new_location = $attribs['override_sysLocation_string']; } // This will call a user-defineable function to rewrite the location however the user wants. if (function_exists('custom_rewrite_location') && !isset($new_location)) { $new_location = custom_rewrite_location($location); } // This uses a statically defined array to map locations. if (isset($config['location_map'][$location]) && !isset($new_location)) { $new_location = $config['location_map'][$location]; } if (isset($new_location)) { print_debug("sysLocation rewritten from '{$location}' to '{$new_location}'"); $location = $new_location; } return $location; }