public function render($template = '', $scope = '') { $model = $this->_load()->model(); $template = $this->_load()->template(); $template->set('model', $model); $this->setRenderer($template); return parent::render(); }
function actionsetsrenderer($locator) { //$view = $this->_load()->view(); $template = $this->_load()->template('setsrenderertemplate.html'); $template->set('content', 'This is content set in the the action actionsetsrenderer.'); $view = new A_Http_View(); $view->setRenderer($template); echo $view->render(); }
public function render($template = '', $scope = '') { if ($this->headers) { foreach ($this->headers as $name => $values) { header("{$name}: " . implode(',', $values)); } } if ($this->cookies) { foreach ($this->cookies as $args) { call_user_func_array('setcookie', $args); } } if ($this->redirect) { $host = $_SERVER['SERVER_NAME']; $script = $host . dirname($_SERVER['SCRIPT_NAME']); if (!preg_match('/^https?\\:\\/\\//i', $this->redirect) && strpos($this->redirect, $script) === false) { $protocol = 'http://'; if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) { $protocol = 'https://'; } if ($this->redirect[0] == '/') { $base = rtrim($host, '/') . '/'; } else { $base = rtrim($script, '/') . '/'; } $this->redirect = $protocol . $base . $this->redirect; } # astions Google Chrome caching redirects fix # header("Cache-Control: max-age=0, no-cache, no-store, must-revalidate"); // HTTP/1.1 # header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past # header("Location: $url", true, 302); # or just # header("Location: $url", true, 303); header("Cache-Control: max-age=0, no-cache, no-store, must-revalidate"); // HTTP/1.1 header('Location: ' . $this->redirect, true, 303); } else { parent::render($template, $scope); foreach ($this->headers as $field => $params) { if (!is_null($params)) { header($field . ': ' . implode(', ', $params)); } } return $this->content; } }
function testHttp_ViewSetEscape() { $locator = new A_Locator(); $view = new A_Http_View($locator); $str = '<hr style="foo"> &'; $str_escaped = '<hr style="foo"> &'; $file = 'foobar.php'; $view->setTemplate($file); $view->setTemplatePath(dirname(__FILE__) . '/templates'); $view->setEscape('foo', $str); $view->set('bar', ''); $this->assertEqual($str_escaped, $view->render()); $view->escapeField('foo'); $view->set('foo', $str); $view->set('bar', ''); $this->assertEqual($str_escaped, $view->render()); $view->escapeField(array('foo', 'bar')); $view->set('foo', $str); $view->set('bar', $str); $this->assertEqual($str_escaped . $str_escaped, $view->render()); }