From 587cc39e0362719332d410b7a4d5ddcc68788eeb Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Tue, 15 Nov 2016 14:03:59 +1300 Subject: Update Marketplace to work with new API (#10799) * starting to port marketplace to piwik 3 * updating tests * fix translation key * fix various issues * use material select * fix plugin upload * deprecate license_homepage plugin metadata and link to a LICENSE[.md|.txt] file if found (#10756) * deprecate license_homepage plugin metadata, and link to a LICENSE[.md|.txt] file if found * Make license view HTML only without menu * fix tests and update * fix some links did not work * we need to show warnings even when plugin is installed, not only when activated. otherwise it is not clear why something is not downloadable * fix install was not working * improved responsiveness of marketplace * fix more tests * fix search was shown when only a few plugins are there * fix ui tests * fix some translations * fix tests and remove duplicated test --- core/Twig.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'core/Twig.php') diff --git a/core/Twig.php b/core/Twig.php index 5ac84993f1..ce8085f23c 100755 --- a/core/Twig.php +++ b/core/Twig.php @@ -176,6 +176,9 @@ class Twig $this->addFilter_prettyDate(); $this->addFilter_safeDecodeRaw(); $this->addFilter_number(); + $this->addFilter_nonce(); + $this->addFilter_md5(); + $this->addFilter_onlyDomain(); $this->twig->addFilter(new Twig_SimpleFilter('implode', 'implode')); $this->twig->addFilter(new Twig_SimpleFilter('ucwords', 'ucwords')); $this->twig->addFilter(new Twig_SimpleFilter('lcfirst', 'lcfirst')); @@ -428,6 +431,29 @@ class Twig $this->twig->addFilter($formatter); } + protected function addFilter_nonce() + { + $nonce = new Twig_SimpleFilter('nonce', array('Piwik\\Nonce', 'getNonce')); + $this->twig->addFilter($nonce); + } + + private function addFilter_md5() + { + $md5 = new \Twig_SimpleFilter('md5', function ($value) { + return md5($value); + }); + $this->twig->addFilter($md5); + } + + private function addFilter_onlyDomain() + { + $domainOnly = new \Twig_SimpleFilter('domainOnly', function ($url) { + $parsed = parse_url($url); + return $parsed['scheme'] . '://' . $parsed['host']; + }); + $this->twig->addFilter($domainOnly); + } + protected function addFilter_truncate() { $truncateFilter = new Twig_SimpleFilter('truncate', function ($string, $size) { -- cgit v1.2.3