diff --git a/Lib/Formatter/Html.php b/Lib/Formatter/Html.php index f92c6cb..2d1270d 100644 --- a/Lib/Formatter/Html.php +++ b/Lib/Formatter/Html.php @@ -13,12 +13,13 @@ class Html extends Formatter { private function result($data) { // the format is array('result' => array('funcname' => DATA)) // so take the first element of the 'result' array + $func = key($data['result']); $data = reset($data['result']); $first = reset($data); $single = ! is_array($first); - $content = ''; + $content = '
'; if($single) { $content .= ""; } else { @@ -52,7 +53,11 @@ class Html extends Formatter { } $content .= '
FieldValue
'; - return $content; + return array( + 'title' => $func, + 'content' => $content, + 'status' => 'success', + ); } private function error($data) { @@ -60,17 +65,22 @@ class Html extends Formatter { $name = $data['error']['name']; $msg = $data['error']['reason']; - return '

An error occured

'. - "

[$code] $name

". - "

$msg

"; + return array( + 'title' => 'Error', + 'content' => "

[$code] $name : $msg

", + 'status' => 'warning', + ); } private function failure($data) { $code = $data['failure']['code']; $name = $data['failure']['reason']; - return '

A failure occured

'. - "

[$code] $name

"; + return array( + 'title' => 'Failure', + 'content' => "

[$code] $name

", + 'status' => 'danger', + ); } public function render($data) @@ -78,18 +88,17 @@ class Html extends Formatter { $type = key($data); if (method_exists($this, $type)) { - $content = call_user_func_array(array($this, $type), array($data)); + $context = call_user_func_array(array($this, $type), array($data)); } else { - $content = '

Unable to render this

'; + $context = array( + 'title' => 'Formatter error', + 'content' => '

Unable to render this

', + 'status' => 'info', + ); } $html = file_get_contents('template.html'); - $context = array( - 'title' => 'BSR - WebService', - 'content' => $content - ); - foreach($context as $k => $v) { $html = str_replace("{{ $k }}", $v, $html); } diff --git a/template.html b/template.html index 210b161..3430264 100644 --- a/template.html +++ b/template.html @@ -2,12 +2,43 @@ + BSR WebService - {{ title }} - {{ content }} + + +
+
+
+

{{ title }}

+
+
+ {{ content }} +
+
+