More url helper fixes (#10241)

* More url helpers
graph links
ajax search

* Fix for non-Laravel pages using the url helper

* fix widget settings
This commit is contained in:
Tony Murray
2019-05-21 08:50:45 -05:00
committed by GitHub
parent 2dc05ee501
commit c9748b166e
5 changed files with 12 additions and 11 deletions

View File

@@ -59,7 +59,8 @@ class Laravel
$kernel = $app->make(\Illuminate\Contracts\Http\Kernel::class);
$request = \Illuminate\Http\Request::capture();
$request->server->set('REQUEST_URI', '/blank'); // load an empty page since it will be discarded
// strip .php to make the url helper in non-laravel pages
$request->server->set('REQUEST_URI', str_replace('.php', '', $_SERVER['REQUEST_URI']));
$response = $kernel->handle($request);
// $response->send(); // don't send response, legacy code will

View File

@@ -201,7 +201,7 @@ class Url
$args['bg'] = 'FFFFFF00';
}
return "<img src='graph.php?type=" . $args['graph_type'] . '&amp;id=' . $args['port_id'] . '&amp;from=' . $args['from'] . '&amp;to=' . $args['to'] . '&amp;width=' . $args['width'] . '&amp;height=' . $args['height'] . '&amp;bg=' . $args['bg'] . "'>";
return '<img src="' . url('graph.php') . '?type=' . $args['graph_type'] . '&amp;id=' . $args['port_id'] . '&amp;from=' . $args['from'] . '&amp;to=' . $args['to'] . '&amp;width=' . $args['width'] . '&amp;height=' . $args['height'] . '&amp;bg=' . $args['bg'] . '">';
}
public static function generate($vars, $new_vars = [])
@@ -231,7 +231,7 @@ class Url
$urlargs[] = $key . '=' . urlencode($arg);
}
return '<img src="graph.php?' . implode('&amp;', $urlargs) . '" style="border:0;" />';
return '<img src="' . url('graph.php') . '?' . implode('&amp;', $urlargs) . '" style="border:0;" />';
}
public static function lazyGraphTag($args)
@@ -244,10 +244,10 @@ class Url
if (Config::get('enable_lazy_load', true)) {
return '<img class="lazy img-responsive" data-original="graph.php?' . implode('&amp;', $urlargs) . '" style="border:0;" />';
return '<img class="lazy img-responsive" data-original="' . url('graph.php') . '?' . implode('&amp;', $urlargs) . '" style="border:0;" />';
}
return '<img class="img-responsive" src="graph.php?' . implode('&amp;', $urlargs) . '" style="border:0;" />';
return '<img class="img-responsive" src="' . url('graph.php') . '?' . implode('&amp;', $urlargs) . '" style="border:0;" />';
}
public static function overlibLink($url, $text, $contents, $class = null)
@@ -306,7 +306,7 @@ class Url
public static function minigraphImage($device, $start, $end, $type, $legend = 'no', $width = 275, $height = 100, $sep = '&amp;', $class = 'minigraph-image', $absolute_size = 0)
{
$vars = ['device=' . $device->device_id, "from=$start", "to=$end", "width=$width", "height=$height", "type=$type", "legend=$legend", "absolute=$absolute_size"];
return '<img class="' . $class . '" width="' . $width . '" height="' . $height . '" src="graph.php?' . implode($sep, $vars) . '">';
return '<img class="' . $class . '" width="' . $width . '" height="' . $height . '" src="' . url('graph.php') . '?' . implode($sep, $vars) . '">';
}
private static function getOverviewGraphsForDevice($device)

View File

@@ -377,7 +377,7 @@ function getLogo($device)
*/
function getLogoTag($device, $class = null)
{
$tag = '<img src="' . getLogo($device) . '" title="' . getImageTitle($device) . '"';
$tag = '<img src="' . url(getLogo($device)) . '" title="' . getImageTitle($device) . '"';
if (isset($class)) {
$tag .= " class=\"$class\" ";
}

View File

@@ -611,7 +611,7 @@ if (empty($vars['bare']) || $vars['bare'] == "no") {
if( widget_id > 0 && widget_settings != {} ) {
$.ajax({
type: 'PUT',
url: '<?php echo url('/ajax/form/widget-settings/'); ?>' + widget_id,
url: '<?php echo url('/ajax/form/widget-settings/'); ?>/' + widget_id,
data: {settings: widget_settings},
dataType: "json",
success: function (data) {

View File

@@ -410,7 +410,7 @@
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "ajax_search.php?search=%QUERY&type=device",
url: ajax_url + "_search.php?search=%QUERY&type=device",
filter: function (devices) {
return $.map(devices, function (device) {
return {
@@ -433,7 +433,7 @@
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "ajax_search.php?search=%QUERY&type=ports",
url: ajax_url + "_search.php?search=%QUERY&type=ports",
filter: function (ports) {
return $.map(ports, function (port) {
return {
@@ -453,7 +453,7 @@
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "ajax_search.php?search=%QUERY&type=bgp",
url: ajax_url + "_search.php?search=%QUERY&type=bgp",
filter: function (bgp_sessions) {
return $.map(bgp_sessions, function (bgp) {
return {