Example #1
0
 public function getFlashMessage($default = "")
 {
     $message = Application::session()->get('hflash');
     Application::session()->remove('hflash');
     Application::session()->remove('hcode');
     return $message ? $message : $default;
 }
Example #2
0
File: Twig.php Project: h1soft/h
 private function initFunctions()
 {
     $link_to = new \Twig_SimpleFunction('link_to', function ($_url, $_params = NULL) {
         return url_to($_url, $_params);
     });
     $this->_twigEnv->addFunction($link_to);
     $url_for = new \Twig_SimpleFunction('url_to', function ($_url, $_params = NULL) {
         return url_to($_url, $_params);
     });
     $this->_twigEnv->addFunction($url_for);
     $repeat = new \Twig_SimpleFunction('repeat', function ($_str, $_num = 0) {
         return str_repeat($_str, $_num);
     });
     $this->_twigEnv->addFunction($repeat);
     $url_ref = new \Twig_SimpleFunction('urlRef', function () {
         $rtn = Application::session()->get('hurlref');
         return $rtn ? $rtn : Application::app()->request()->curUrl();
     });
     $this->_twigEnv->addFunction($url_ref);
     $flash = new \Twig_SimpleFunction('flash', function ($_remove = true) {
         $flashmessage = Application::session()->get('hflash');
         if ($_remove) {
             Application::session()->remove('hflash');
         }
         return $flashmessage;
     });
     $this->_twigEnv->addFunction($flash);
     $flashCode = new \Twig_SimpleFunction('flashCode', function ($_remove = true) {
         $hcode = Application::session()->get('hcode');
         if ($_remove) {
             Application::session()->remove('hcode');
         }
         return $hcode;
     });
     $this->_twigEnv->addFunction($flashCode);
     $dateFormat = new \Twig_SimpleFunction('dateFormat', function ($_timestamp = NULL, $format = 'Y-m-d') {
         if ($_timestamp) {
             return date($format, $_timestamp);
         } else {
             return NULL;
         }
     });
     $this->_twigEnv->addFunction($dateFormat);
 }