Create getClassName(), update renderTemplate()

This commit is contained in:
billz 2024-11-05 18:21:31 -08:00
parent 2ec0738455
commit 3af68ca9a9

View file

@ -542,11 +542,15 @@ function ConvertToSecurity($security)
/**
* Renders a simple PHP template
*/
function renderTemplate($name, $__template_data = [])
function renderTemplate($name, $__template_data = [], $pluginName = null)
{
$file = realpath(dirname(__FILE__) . "/../templates/$name.php");
if (isset($pluginName)) {
$file = realpath(dirname(__FILE__) . "/../plugins/$pluginName/templates/$name.php");
} else {
$file = realpath(dirname(__FILE__) . "/../templates/$name.php");
}
if (!file_exists($file)) {
return "template $name ($file) not found";
return "<br>template $name ($file) not found";
}
if (is_array($__template_data)) {
@ -1029,3 +1033,10 @@ function renderStatus($hostapd_led, $hostapd_status, $memused_led, $memused, $cp
<?php
}
// Returns a classname without its associated namespace
function getClassName($class)
{
if ($pos = strrpos($class, '\\')) return substr($class, $pos + 1);
return $pos;
}