From 981dc9ffb49d04f3d03978f15215141b13f40c0f Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Sun, 26 Nov 2017 16:04:57 +0100 Subject: [PATCH] set not found parameters, and changes on date class --- bl-kernel/helpers/date.class.php | 7 +++++++ bl-kernel/page.class.php | 1 + bl-kernel/url.class.php | 8 ++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bl-kernel/helpers/date.class.php b/bl-kernel/helpers/date.class.php index 8d91ff62..171a2809 100644 --- a/bl-kernel/helpers/date.class.php +++ b/bl-kernel/helpers/date.class.php @@ -35,6 +35,13 @@ class Date { return false; } + public static function convertToUTC($date, $currentFormat, $outputFormat) + { + $Date = DateTime::createFromFormat($currentFormat, $date); + $Date->setTimezone(new DateTimeZone('UTC')); + return $Date->format($outputFormat); + } + public static function timeago($time) { $time = time() - $time; diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php index 5efdd1ad..4b6bbf3b 100644 --- a/bl-kernel/page.class.php +++ b/bl-kernel/page.class.php @@ -296,6 +296,7 @@ class Page { $tmp['contentRaw'] = $this->contentRaw(); // No Markdown parsed $tmp['description'] = $this->description(); $tmp['date'] = $this->dateRaw(); + $tmp['dateUTC'] = Date::convertToUTC($this->dateRaw(), DB_DATE_FORMAT, DB_DATE_FORMAT); $tmp['permalink'] = $this->permalink(true); if($returnsArray) { diff --git a/bl-kernel/url.class.php b/bl-kernel/url.class.php index 18faaccd..afa33d32 100644 --- a/bl-kernel/url.class.php +++ b/bl-kernel/url.class.php @@ -155,12 +155,12 @@ class Url return 1; } - public function setNotFound() + public function setNotFound($notFound=true, $httpCode=404, $httpMessage='Not Found') { $this->setWhereAmI('page'); - $this->notFound = true; - $this->httpCode = 404; - $this->httpMessage = 'Not Found'; + $this->notFound = $notFound; + $this->httpCode = $httpCode; + $this->httpMessage = $httpMessage; } public function httpCode()