Initial commit of HandBrakeCluster PHP framework
Replaced dodgy placeholder with a set of PHP classes for displaying a HandBrake webui. Current code uses Smarty as a templating engine, and includes an ugly but functional set of pages. The HandBrake classes are at present only placeholders, and offer no real functionality. Working class autoloader for the HandBrakeCluster_ hierarchy.
This commit is contained in:
41
HandBrakeCluster/Page.class.php
Normal file
41
HandBrakeCluster/Page.class.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Page {
|
||||
|
||||
private $smarty;
|
||||
private $request;
|
||||
|
||||
private $page;
|
||||
|
||||
public function __construct(Smarty $smarty, HandBrakeCluster_RequestParser $request) {
|
||||
$this->smarty = $smarty;
|
||||
$this->request = $request;
|
||||
$this->page = $request->page();
|
||||
}
|
||||
|
||||
public function page() {
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
public function template_filename() {
|
||||
$template_filename = $this->page() . '.tpl';
|
||||
|
||||
if (!$this->smarty->template_exists($template_filename)) {
|
||||
$template_filename = 'home.tpl';
|
||||
}
|
||||
|
||||
return $template_filename;
|
||||
}
|
||||
|
||||
public function evaluate() {
|
||||
$code_filename = 'pages/' . $this->page() . '.php';
|
||||
if (!file_exists($code_filename)) {
|
||||
throw Exception('Template code file does not exist!');
|
||||
}
|
||||
eval("include '$code_filename';");
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user