@@ -298,51 +298,6 @@ public static function sensorUrl($sensor, $vars = [])
298298 return self ::generate (['page ' => 'device ' , 'device ' => $ sensor ->device_id , 'tab ' => 'health ' , 'metric ' => $ sensor ->sensor_class ], $ vars );
299299 }
300300
301- /**
302- * @param Port $port
303- * @return string
304- */
305- public static function portThumbnail ($ port )
306- {
307- $ graph_array = [
308- 'port_id ' => $ port ->port_id ,
309- 'graph_type ' => 'port_bits ' ,
310- 'from ' => Carbon::now ()->subDay ()->timestamp ,
311- 'to ' => Carbon::now ()->timestamp ,
312- 'width ' => 150 ,
313- 'height ' => 21 ,
314- ];
315-
316- return self ::portImage ($ graph_array );
317- }
318-
319- /**
320- * @param Port $port
321- * @return string
322- */
323- public static function portErrorsThumbnail ($ port )
324- {
325- $ graph_array = [
326- 'port_id ' => $ port ->port_id ,
327- 'graph_type ' => 'port_errors ' ,
328- 'from ' => Carbon::now ()->subDay ()->timestamp ,
329- 'to ' => Carbon::now ()->timestamp ,
330- 'width ' => 150 ,
331- 'height ' => 21 ,
332- ];
333-
334- return self ::portImage ($ graph_array );
335- }
336-
337- public static function portImage ($ args )
338- {
339- if (empty ($ args ['bg ' ])) {
340- $ args ['bg ' ] = 'FFFFFF00 ' ;
341- }
342-
343- return '<img src="graph-image ' . url ('graph.php ' ) . '?type= ' . $ args ['graph_type ' ] . '&id= ' . $ args ['port_id ' ] . '&from= ' . $ args ['from ' ] . '&to= ' . $ args ['to ' ] . '&width= ' . $ args ['width ' ] . '&height= ' . $ args ['height ' ] . '&bg= ' . $ args ['bg ' ] . '"> ' ;
344- }
345-
346301 public static function generate ($ vars , $ new_vars = [])
347302 {
348303 $ vars = array_merge ($ vars , $ new_vars );
@@ -393,17 +348,12 @@ public static function graphPageUrl(string $type, array $args = []): string
393348 }
394349
395350 /**
396- * @param array $args
351+ * @param string[] $args
397352 * @return string
398353 */
399- public static function graphTag ($ args )
354+ public static function graphTag ($ args ): string
400355 {
401- $ urlargs = [];
402- foreach ($ args as $ key => $ arg ) {
403- $ urlargs [] = $ key . '= ' . ($ arg === null ? '' : urlencode ($ arg ));
404- }
405-
406- return '<img class="graph-image" src=" ' . url ('graph.php ' ) . '? ' . implode ('& ' , $ urlargs ) . '" style="border:0;" /> ' ;
356+ return '<img class="graph-image" src=" ' . route ('graph ' , $ args ) . '" style="border:0;" /> ' ;
407357 }
408358
409359 public static function graphPopup ($ args , $ content = null , $ link = null )
@@ -438,13 +388,7 @@ public static function graphPopup($args, $content = null, $link = null)
438388
439389 public static function lazyGraphTag ($ args , string $ class = 'img-responsive ' ): string
440390 {
441- $ urlargs = [];
442-
443- foreach ($ args as $ key => $ arg ) {
444- $ urlargs [] = $ key . '= ' . ($ arg === null ? '' : urlencode ($ arg ));
445- }
446-
447- $ tag = '<img class="graph-image ' . $ class . '" src=" ' . url ('graph.php ' ) . '? ' . implode ('& ' , $ urlargs ) . '" style="border:0;" ' ;
391+ $ tag = '<img class="graph-image ' . $ class . '" src=" ' . route ('graph ' , $ args ) . '" style="border:0;" ' ;
448392
449393 if (LibrenmsConfig::get ('enable_lazy_load ' , true )) {
450394 return $ tag . ' loading="lazy" /> ' ;
@@ -501,16 +445,24 @@ public static function overlibContent($graph_array, $text)
501445 * @param string $legend
502446 * @param int $width
503447 * @param int $height
504- * @param string $sep
505448 * @param string $class
506449 * @param int $absolute_size
507450 * @return string
508451 */
509- public static function minigraphImage ($ device , $ start , $ end , $ type , $ legend = 'no ' , $ width = 275 , $ height = 100 , $ sep = ' & ' , $ class = 'minigraph-image ' , $ absolute_size = 0 )
452+ public static function minigraphImage ($ device , $ start , $ end , $ type , $ legend = 'no ' , $ width = 275 , $ height = 100 , $ class = 'minigraph-image ' , $ absolute_size = 0 ): string
510453 {
511- $ vars = ['device= ' . $ device ->device_id , "from= $ start " , "to= $ end " , "width= $ width " , "height= $ height " , "type= $ type " , "legend= $ legend " , "absolute= $ absolute_size " ];
454+ $ vars = [
455+ 'device ' => $ device ->device_id ,
456+ 'from ' => $ start ,
457+ 'to ' => $ end ,
458+ 'width ' => $ width ,
459+ 'height ' => $ height ,
460+ 'type ' => $ type ,
461+ 'legend ' => $ legend ,
462+ 'absolute ' => $ absolute_size ,
463+ ];
512464
513- return '<img class="graph-image ' . $ class . '" width=" ' . $ width . '" height=" ' . $ height . '" src=" ' . url ('graph.php ' ) . ' ? ' . implode ( $ sep , $ vars ) . '"> ' ;
465+ return '<img class="graph-image ' . $ class . '" width=" ' . $ width . '" height=" ' . $ height . '" src=" ' . route ('graph ' , $ vars ) . '"> ' ;
514466 }
515467
516468 /**
0 commit comments