Job details page shows the job id, fixed bug

Job details page now shows the id number for the current job, reading it
from the URL using the RequestParser
Fixed a bug where if no query string was provided (index.php was
accessed directly) then a blank pagename was used (instead of 'home') and an
exception was thrown.
This commit is contained in:
2010-03-17 02:49:57 +00:00
parent 8db695166e
commit 23a5590131
6 changed files with 19 additions and 8 deletions

View File

@@ -4,8 +4,8 @@ class HandBrakeCluster_Job {
private $id; private $id;
public function __construct() { public function __construct($id) {
$this->id = 42; $this->id = $id;
} }
public function id() { public function id() {

View File

@@ -18,7 +18,7 @@ class HandBrakeCluster_Page {
} }
public function template_filename() { public function template_filename() {
$template_filename = $this->page() . '.tpl'; $template_filename = $this->page . '.tpl';
if (!$this->smarty->template_exists($template_filename)) { if (!$this->smarty->template_exists($template_filename)) {
$template_filename = 'home.tpl'; $template_filename = 'home.tpl';
@@ -28,9 +28,9 @@ class HandBrakeCluster_Page {
} }
public function evaluate() { public function evaluate() {
$code_filename = 'pages/' . $this->page() . '.php'; $code_filename = 'pages/' . $this->page . '.php';
if (!file_exists($code_filename)) { if (!file_exists($code_filename)) {
throw Exception('Template code file does not exist!'); throw new Exception("Template code file does not exist: '$code_filename'");
} }
eval("include '$code_filename';"); eval("include '$code_filename';");

View File

@@ -13,8 +13,11 @@ class HandBrakeCluster_RequestParser {
} }
public function parse() { public function parse() {
$components = explode('/', $this->request_string); if (!$this->request_string) {
return;
}
$components = explode('/', $this->request_string);
if (!$components) { if (!$components) {
return; return;
} }

View File

@@ -3,7 +3,7 @@
$running_jobs = array(); $running_jobs = array();
$completed_jobs = array(); $completed_jobs = array();
$running_jobs[] = new HandBrakeCluster_Job(); $running_jobs[] = new HandBrakeCluster_Job(42);
$this->smarty->assign('running_jobs', $running_jobs); $this->smarty->assign('running_jobs', $running_jobs);
$this->smarty->assign('completed_jobs;', $completed_jobs); $this->smarty->assign('completed_jobs;', $completed_jobs);

View File

@@ -0,0 +1,8 @@
<?php
$job_id = $this->request->get('id');
$job = new HandBrakeCluster_Job($job_id);
$this->smarty->assign('job', $job);
?>

View File

@@ -1 +1 @@
Job details... This is Job {$job->id()}...