From 1ed87c004e93dd18d8e7fbe0e36a3c14b2d6f525 Mon Sep 17 00:00:00 2001 From: John Clarke Date: Thu, 5 May 2011 10:59:10 +0200 Subject: [PATCH] BUGFIX: support for legacy installations for the date based blog entry listing using slashes rather than dashes. PATCH via jcinteractive. (#5) --- code/BlogTree.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/code/BlogTree.php b/code/BlogTree.php index 30d2ce4..758d828 100644 --- a/code/BlogTree.php +++ b/code/BlogTree.php @@ -162,9 +162,17 @@ class BlogTree extends Page { } if($date) { - if(strpos($date, '-')) { - $year = (int) substr($date, 0, strpos($date, '-')); - $month = (int) substr($date, strpos($date, '-') + 1); + // Some systems still use the / seperator for date presentation + if( strpos($date, '-') ) $seperator = '-'; + elseif( strpos($date, '/') ) $seperator = '/'; + + if(isset($seperator) && !empty($seperator)) { + // The 2 in the explode argument will tell it to only create 2 elements + // i.e. in this instance the $year and $month fields respectively + list($year,$month) = explode( $seperator, $date, 2); + + $year = (int)$year; + $month = (int)$month; if($year && $month) { if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {