Esempio n. 1
0
 /**
  * The default render() doesn't work here
  * @return null|string
  */
 public function render()
 {
     // render specific template id if cache_id is set
     if ($this->smarty->cache_id) {
         $this->content = $this->smarty->fetch($this->template, $this->smarty->cache_id);
     } else {
         $this->content = $this->smarty->fetch($this->template);
     }
     // render the envelope too if requested
     if (!is_null($this->envelope)) {
         $envelope = new ResponseSmarty($this->envelope, null);
         $envelope->clearHeaders();
         // assign child variables
         foreach ($this->getTemplateVars() as $k => $v) {
             $envelope->assign($k, $v);
         }
         // copy headers
         foreach ($this->getAllHeaders() as $headerType => $header) {
             $envelope->setHeader($headerType, $header);
         }
         foreach ($this->getAllHttpHeaders() as $headerCode => $header) {
             $envelope->setHttpHeader($headerCode);
         }
         // assigned rendered template
         $envelope->assign($this->envelopeVariable, $this->content);
         return $envelope->smarty->fetch($this->envelope);
     }
     return $this->content;
 }
Esempio n. 2
0
 /**
  * smarty sample
  * url: /de/
  */
 public function default_action($rq, $params)
 {
     // the default action to display
     // url: /de/
     $resp = new ResponseSmarty('index.tpl', 'envelopes/default.tpl', 'CONTENT');
     $resp->enableCache();
     $resp->setCacheLifetime(60);
     if ($resp->isCached()) {
         // templates are cached, expensive database procedure not needed
         return $resp;
     }
     $resp->sampleContent = _('das ist bloss etwas Beispieltext');
     return $resp;
 }