Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2013-10-29 05:25:15 +0400
committerThomas Steur <thomas.steur@gmail.com>2013-10-29 05:25:15 +0400
commitd3c0212c29e8db7eeb2edde6da785e0597e3f0d4 (patch)
tree2defe61c4d10ec3bc0530e305d2390667a662b13 /core/Twig.php
parentb7109c453e044e40c8cb220d60b764980bf7a72e (diff)
refs #4179 use a twig filter to generate html for notification so it is reusable
Diffstat (limited to 'core/Twig.php')
-rw-r--r--core/Twig.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/core/Twig.php b/core/Twig.php
index 9bc2447561..389a579a63 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -64,6 +64,7 @@ class Twig
$this->addFilter_sumTime();
$this->addFilter_money();
$this->addFilter_truncate();
+ $this->addFilter_notificiation();
$this->twig->addFilter(new Twig_SimpleFilter('implode', 'implode'));
$this->twig->addFilter(new Twig_SimpleFilter('ucwords', 'ucwords'));
@@ -157,6 +158,29 @@ class Twig
return $this->twig;
}
+ protected function addFilter_notificiation()
+ {
+ $twigEnv = $this->getTwigEnvironment();
+ $notificationFunction = new Twig_SimpleFilter('notification', function ($message, $options) use ($twigEnv) {
+
+ $template = '<div style="display:none" data-role="notification" ';
+
+ foreach ($options as $key => $value) {
+ if (ctype_alpha($key)) {
+ $template .= sprintf('data-%s="%s" ', $key, twig_escape_filter($twigEnv, $value, 'html_attr'));
+ }
+ }
+
+ $template .= '>';
+ $template .= $message;
+ $template .= '</div>';
+
+ return $template;
+
+ }, array('is_safe' => array('html')));
+ $this->twig->addFilter($notificationFunction);
+ }
+
protected function addFilter_truncate()
{
$truncateFilter = new Twig_SimpleFilter('truncate', function ($string, $size) {