diff options
Diffstat (limited to 'plugins/function.parse_service.php')
-rw-r--r-- | plugins/function.parse_service.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/plugins/function.parse_service.php b/plugins/function.parse_service.php new file mode 100644 index 0000000..1b02886 --- /dev/null +++ b/plugins/function.parse_service.php @@ -0,0 +1,25 @@ +<?php + +function smarty_function_parse_service($params, Smarty_Internal_Template $template) +{ + if (empty($params['var'])) { + trigger_error("assign: missing 'var' parameter"); + return; + } + + if (!in_array('value', array_keys($params))) { + trigger_error("assign: missing 'value' parameter"); + return; + } + + $name = $params['value']; + $port = null; + if (preg_match('/(.*): (.*)/', $params['value'], $match)) { + $name = $match[1]; + $port = $match[2]; + } + + $template->assign($params['var'], array('name' => $name, 'port' => $port)); +} + +?> |