Added support for redirects in Page class

This commit is contained in:
2010-04-03 22:57:15 +01:00
parent df5721181f
commit b0c6302538
3 changed files with 58 additions and 4 deletions

View File

@@ -27,13 +27,17 @@ class HandBrakeCluster_Page {
try {
$this->render($template_filename, $code_filename, $template_variables);
} catch (HandBrakeCluster_Exception_AbortEntirePage $e) {
return false;
} catch (HandBrakeCluster_Exception_FileNotFound $e) {
$this->render('errors/404.tpl', 'errors/404.php');
} catch (HandBrakeCluster_Exception_TemplateException $e) {
} catch (HandBrakeCluster_Exception $e) {
$this->render('errors/unhandled-exception.tpl', 'errors/unhandled-exception.php', array(
'exception' => $e,
));
}
return true;
}
protected function render($template_filename, $code_filename = null, $template_variables = array()) {
@@ -56,6 +60,14 @@ class HandBrakeCluster_Page {
// Now execute the template itself, which will render the results of the code file
$this->smarty->assign('page_content', $this->smarty->fetch($template_filename));
}
public static function redirect($relative_url) {
$absolute_url = HandBrakeCluster_Main::instance()->absoluteUrl($relative_url);
header("Location: $absolute_url");
throw new HandBrakeCluster_Exception_AbortEntirePage();
}
};