From 59f98645e5d37b31806a0a05dfd371d9bfc7a509 Mon Sep 17 00:00:00 2001 From: Makis Tracend Date: Sun, 15 Apr 2012 14:33:22 -0700 Subject: [PATCH] Fixing the Archives controller --- app/controllers/archives.php | 11 ++++++++--- app/helpers/mvc.php | 2 ++ data/pages.sqlite | Bin 12288 -> 12288 bytes 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/archives.php b/app/controllers/archives.php index 8d6ea85..07fe889 100644 --- a/app/controllers/archives.php +++ b/app/controllers/archives.php @@ -6,9 +6,14 @@ class Archives extends Controller { public $date; //This function maps the controller name and function name to the file location of the .php file to include - function index( $path ) { + function index( $params ) { - $this->data['date'] = implode("-", $path); + // data is being passed as a key-value pair + foreach( $params as $k => $v ){ + $this->data['date'] = $k ."-". $v; + // only loop throught he first item + break; + } // load the index $this->render(); @@ -30,7 +35,7 @@ function requestAllPages() { $page=new Page(); $page->tablename = "pages"; - $pages = $page->retrieve_many("date LIKE '%".$this->date."%'"); + $pages = $page->retrieve_many("date LIKE '%".$this->data['date']."%'"); $view = getPath('views/archives/body.php'); foreach( $pages as $data ){ diff --git a/app/helpers/mvc.php b/app/helpers/mvc.php index 9f6a519..af1e05b 100644 --- a/app/helpers/mvc.php +++ b/app/helpers/mvc.php @@ -261,6 +261,8 @@ function beautify_array( $params ){ foreach( $params as $num => $param ){ if( $num%2 == 0 ){ $key = $param; + // stop if there is no more params + if( empty( $params[$num+1] ) ) continue; $value = $params[$num+1]; // save the new key/value pair $newparams[ $key ] = $value; diff --git a/data/pages.sqlite b/data/pages.sqlite index 31d63932e336f8dcee90452eb543a0f2c4115ca9..62109d9eed5a742a294284cd7e809114929a5aa8 100644 GIT binary patch delta 55 zcmZojXh@hK#bo$+qKp%e+?X(*pOI^m0Ji`uHv