Ejemplo n.º 1
0
 public function render(Register &$parameters, XMLDocument &$document = null)
 {
     $this->template = $this->view->template;
     $cache = Cache::instance();
     // Load previously saved states:
     $this->states = $cache->read('debug-saved-states');
     if ($this->states === false || is_null($this->states)) {
         $this->states = array();
     } else {
         $this->states = array_slice($this->states, -9);
     }
     if (is_null($this->state)) {
         try {
             $this->output = $this->view->render($parameters, $document);
         } catch (Exception $e) {
             //throw $e;
         }
         // Force sane headers:
         header('content-type: text/html');
         $document->formatOutput = true;
         $this->input = $document->saveXML();
         $this->params = $parameters;
         // Save current state:
         $state = substr((string) time(), -6);
         $state = substr($state, 0, 2) . strtr(substr($state, 2, 2), '0123456789', 'abcdefghij') . substr($state, 4);
         $data = (object) array('input' => $this->input, 'output' => $this->output, 'params' => $this->params);
         $this->state = $state;
         $this->states[$state] = time();
         $cache->write($this->state, $data, 604800);
         $cache->write('debug-saved-states', $this->states, 604800);
     } else {
         $data = $cache->read($this->state);
         $this->input = $data->input;
         $this->output = $data->output;
         $this->params = $data->params;
         if ($this->show == 'iframe') {
             echo $this->output;
             exit;
         }
     }
     return parent::render($parameters, $document);
 }
Ejemplo n.º 2
0
 public function render(Register &$parameters, XMLDocument &$document = null)
 {
     $this->template = $this->view->template;
     $cache = Cache::instance();
     if (is_null($this->state)) {
         try {
             $this->output = $this->view->render($parameters, $document);
         } catch (Exception $e) {
             throw $e;
         }
         $document->formatOutput = true;
         $this->input = $document->saveXML();
         $this->params = $parameters;
         // Save current state:
         $this->state = substr(uniqid(), 8);
         $data = (object) array('input' => $this->input, 'output' => $this->output, 'params' => $this->params);
         $cache->write($this->state, serialize($data), 604800);
     } else {
         $data = $cache->read($this->state);
         $data = unserialize($data->data);
         $this->input = $data->input;
         $this->output = $data->output;
         $this->params = $data->params;
         if ($this->show == 'iframe') {
             echo $this->output;
             exit;
         }
     }
     return parent::render($parameters, $document);
 }