Rajout d'une aide de vue
authorSébastien CHAZALLET <s.chazallet@gmail.com>
Sun, 18 Nov 2012 18:36:10 +0000 (19:36 +0100)
committerSébastien CHAZALLET <s.chazallet@gmail.com>
Sun, 18 Nov 2012 18:36:10 +0000 (19:36 +0100)
vendor/zf2biz/Custom/View/Helper/Format.php [new file with mode: 0644]

diff --git a/vendor/zf2biz/Custom/View/Helper/Format.php b/vendor/zf2biz/Custom/View/Helper/Format.php
new file mode 100644 (file)
index 0000000..abf634a
--- /dev/null
@@ -0,0 +1,70 @@
+<?php 
+
+namespace Custom\View\Helper; 
+use Zend\View\Helper\AbstractHelper; 
+class Format extends AbstractHelper 
+{ 
+
+    protected $text = null;
+
+    public function __invoke($text = null, $format = null)
+    {
+        $this->text = $text;
+        if (null === $text || null === $format) {
+            return $this;
+        }
+        switch ($format) {
+            case 'strong': return $this->strong();
+            case 'em': return $this->em();
+            case 'info': return $this->info();
+            case 'warning': return $this->warning();
+            case 'error': return $this->error();
+            default: return $text;
+        }
+    }
+
+    public function strong($text = null)
+    {
+        if (null === $text) {
+            $text = $this->text;
+        }
+        return "<strong>{$text}</strong>";
+    }
+
+    public function em($text = null)
+    {
+        if (null === $text) {
+            $text = $this->text;
+        }
+        return "<strong>{$text}</strong>";
+    }
+
+    public function info($text = null)
+    {
+        if (null === $text) {
+            $text = $this->text;
+        }
+        return '<div class="alert-info">' . $text . '</div>';
+    }
+
+
+    public function warning($text = null)
+    {
+        if (null === $text) {
+            $text = $this->text;
+        }
+        return '<div class="alert-warning">' . $text . '</div>';
+    }
+
+
+    public function error($text = null)
+    {
+        if (null === $text) {
+            $text = $this->text;
+        }
+        return '<div class="alert-error">' . $text . '</div>';
+    }
+
+}