From 23a55901313820142c80f8cb7b3262b116602dad Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Wed, 17 Mar 2010 02:49:57 +0000 Subject: [PATCH] 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. --- HandBrakeCluster/Job.class.php | 4 ++-- HandBrakeCluster/Page.class.php | 6 +++--- HandBrakeCluster/RequestParser.class.php | 5 ++++- pages/home.php | 2 +- pages/job-details.php | 8 ++++++++ templates/job-details.tpl | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/HandBrakeCluster/Job.class.php b/HandBrakeCluster/Job.class.php index f430527..f739033 100644 --- a/HandBrakeCluster/Job.class.php +++ b/HandBrakeCluster/Job.class.php @@ -4,8 +4,8 @@ class HandBrakeCluster_Job { private $id; - public function __construct() { - $this->id = 42; + public function __construct($id) { + $this->id = $id; } public function id() { diff --git a/HandBrakeCluster/Page.class.php b/HandBrakeCluster/Page.class.php index 6e40ee9..3d1c38b 100644 --- a/HandBrakeCluster/Page.class.php +++ b/HandBrakeCluster/Page.class.php @@ -18,7 +18,7 @@ class HandBrakeCluster_Page { } public function template_filename() { - $template_filename = $this->page() . '.tpl'; + $template_filename = $this->page . '.tpl'; if (!$this->smarty->template_exists($template_filename)) { $template_filename = 'home.tpl'; @@ -28,9 +28,9 @@ class HandBrakeCluster_Page { } public function evaluate() { - $code_filename = 'pages/' . $this->page() . '.php'; + $code_filename = 'pages/' . $this->page . '.php'; 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';"); diff --git a/HandBrakeCluster/RequestParser.class.php b/HandBrakeCluster/RequestParser.class.php index f831660..3d58a56 100644 --- a/HandBrakeCluster/RequestParser.class.php +++ b/HandBrakeCluster/RequestParser.class.php @@ -13,8 +13,11 @@ class HandBrakeCluster_RequestParser { } public function parse() { - $components = explode('/', $this->request_string); + if (!$this->request_string) { + return; + } + $components = explode('/', $this->request_string); if (!$components) { return; } diff --git a/pages/home.php b/pages/home.php index eb6d7ad..7fb848a 100644 --- a/pages/home.php +++ b/pages/home.php @@ -3,7 +3,7 @@ $running_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('completed_jobs;', $completed_jobs); diff --git a/pages/job-details.php b/pages/job-details.php index e69de29..6637f57 100644 --- a/pages/job-details.php +++ b/pages/job-details.php @@ -0,0 +1,8 @@ +request->get('id'); +$job = new HandBrakeCluster_Job($job_id); + +$this->smarty->assign('job', $job); + +?> diff --git a/templates/job-details.tpl b/templates/job-details.tpl index 304c0ed..da10d23 100644 --- a/templates/job-details.tpl +++ b/templates/job-details.tpl @@ -1 +1 @@ -Job details... +This is Job {$job->id()}...