Example #1
0
File: Form.php Project: fem/spof
 /**
  * Render the form and return as HTML-string.
  *
  * @api
  *
  * @return string
  */
 public final function render()
 {
     $template = HtmlTemplate::getInstance();
     $template->assign('route', $this->route);
     $template->assign('routeContext', $this->routeContext);
     $template->assign('fieldsets', $this->fieldset);
     $template->assign('buttons', $this->button);
     return $template->fetch('form/form.tpl');
 }
Example #2
0
 /**
  * This function is the final step to render a website, it passes the final arguments to the template, including
  * all error messages, gathered so far. And finally flushes the website content.
  *
  * @api
  */
 public function display()
 {
     // minify js
     $jsFile = template\JavascriptTemplate::combine($this->jsFiles);
     if ($jsFile !== false) {
         $this->assign('customjsfile', [$jsFile]);
     } else {
         $this->assign('customjsfile', []);
     }
     // minify css
     $cssFile = template\CssTemplate::combine($this->cssFiles);
     if ($cssFile !== false) {
         $this->assign('customcssfile', [$cssFile]);
     } else {
         $this->assign('customcssfile', []);
     }
     // this code is not safe for use in different tabs
     foreach (Session::getErrorMsg() as $error) {
         $this->append('errors', ($error['field'] ? '"' . $error['field'] . '" - ' : '') . $error['content']);
     }
     foreach (Session::getSuccessMsg() as $success) {
         $this->append('success', $success);
     }
     // we need a relative dir from smarty templates
     template\HtmlTemplate::getInstance()->display('layout.tpl');
     // after we've displayed them, we may reset them
     Session::resetErrorMsg();
     Session::resetSuccessMsg();
 }
Example #3
0
File: Logger.php Project: fem/spof
 /**
  * Add current smarty settings to the log.
  */
 public function addSmarty()
 {
     $vars = template\HtmlTemplate::getInstance()->getTemplateVars();
     foreach ($vars as &$var) {
         if ($var === '') {
             $var = '(empty)';
         } elseif ($var === false) {
             $var = '(bool: false)';
         } elseif ($var === true) {
             $var = '(bool: true)';
         } elseif ($var === null) {
             $var = '(nil)';
         }
     }
     ksort($vars);
     $this->debugBar->addCollector(new Collector\ConfigCollector($vars, 'Smarty'));
 }
Example #4
0
 /**
  * Render this element.
  *
  * @api
  *
  * @return string
  */
 public function render()
 {
     try {
         $this->renderPrepare();
         return HtmlTemplate::getInstance()->fetch('form/html_tag.tpl');
     } catch (\Exception $e) {
         //Logger::getInstance()->exception($e);
         return '';
     }
 }