tra('Gauge'), 'documentation' => 'PluginGauge', 'description' => tra('Display a horizontal bar gauge'), 'prefs' => ['wikiplugin_gauge'], 'body' => tra('description'), 'iconname' => 'chart', 'tags' => [ 'basic' ], 'format' => 'html', 'introduced' => 1, 'params' => [ 'value' => [ 'required' => true, 'name' => tra('Value'), 'description' => tra('Current value to be represented by the gauge'), 'since' => '1', 'filter' => 'float', 'default' => '' ], 'max' => [ 'required' => false, 'name' => tra('Maximum Value'), 'description' => tr('Maximum possible value. Default: %0', '100'), 'since' => '1', 'filter' => 'digits', 'default' => 100 ], 'label' => [ 'required' => false, 'name' => tra('Label'), 'description' => tra('Label displayed on the left side of the gauge.'), 'since' => '1', 'filter' => 'text', 'default' => '' ], 'color' => [ 'required' => false, 'name' => tra('Color'), 'description' => tra('Main color of the gauge. Use HTML color codes or names.'), 'since' => '1', 'filter' => 'text', 'accepted' => tra('Valid CSS color name or hex code'), 'default' => '#FF0000' ], 'bgcolor' => [ 'required' => false, 'name' => tra('Background Color'), 'description' => tra('Background color of the gauge. Use HTML color codes or names.'), 'since' => '1', 'filter' => 'text', 'accepted' => tra('Valid CSS color name or hex code'), 'default' => '#0000FF' ], 'size' => [ 'required' => false, 'name' => tra('Width'), 'description' => tra('Bar width in pixels.'), 'since' => '1', 'filter' => 'digits', 'default' => 150 ], 'labelsize' => [ 'required' => false, 'name' => tra('Label Width'), 'description' => tra('Label width, in pixels.'), 'since' => '1', 'filter' => 'digits', 'default' => 50 ], 'perc' => [ 'required' => false, 'name' => tra('Display Percentage'), 'description' => tr('Set to %0 (Yes) to display a percentage of the maximum.', 'true'), 'since' => '1', 'default' => false, 'options' => [ ['text' => '', 'value' => ''], ['text' => tra('Yes'), 'value' => true], ['text' => tra('No'), 'value' => false] ] ], 'showvalue' => [ 'required' => false, 'name' => tra('Display Value'), 'description' => tr('Set to %1 (No) to hide the numeric value (shown by default).', 'false'), 'default' => true, 'since' => '3.0', 'options' => [ ['text' => '', 'value' => ''], ['text' => tra('Yes'), 'value' => true], ['text' => tra('No'), 'value' => false] ] ], 'height' => [ 'required' => false, 'name' => tra('Height'), 'description' => tra('Bar height in pixels.'), 'since' => '1', 'filter' => 'digits', 'default' => 14 ], ], ]; } function wikiplugin_gauge($data, $params) { extract($params, EXTR_SKIP); if (! isset($value)) { return ("missing value parameter for plugin
"); } if (! isset($size)) { $size = 150; } if (! isset($height)) { $height = 14; } if (! isset($bgcolor)) { $bgcolor = '#0000FF'; } if (! isset($color)) { $color = '#FF0000'; } if (! isset($perc)) { $perc = false; } if (isset($showvalue) && $showvalue == 'false') { $showvalue = false; } else { $showvalue = true; } if (! isset($max) or ! $max) { $max = 100; } if ($max < $value) { // maximum exceeded then change color $color = '#0E0E0E'; $maxexceeded = true; $max = $value; } else { $maxexceeded = false; } if (! isset($labelsize)) { $labelsize = 50; } if (! isset($label)) { $label_td = ''; } else { $label_td = '' . $label . ' '; } if ($maxexceeded) { $perc_td = '*******'; } else { if ($perc) { $perc = number_format($value / $max * 100, 2); $perc_td = ' ' . $perc . '%'; } else { $perc = number_format($value, 2); $perc_td = ' ' . $perc . ''; } } $h_size = floor($value / $max * 100); $h_size_rest = 100 - $h_size; if ($h_size == 100) { $h_td = ' '; } else { if ($h_size_rest == 100) { $h_td = ' '; } else { $h_td = ' '; $h_td .= ' '; } } $html = '' . $label_td . '' . ($showvalue ? $perc_td : '') . ''; if (! empty($data)) { $html .= ''; } $html .= "
'; $html .= '' . $h_td . '
'; $html .= '
 
' . $data . '
"; return $html; }