Calendar added

This commit is contained in:
2017-08-02 23:58:49 +02:00
parent 9201c50812
commit 4f3490367f
6 changed files with 70 additions and 148 deletions

View File

@@ -10,13 +10,26 @@ class CalendarEvent extends Model {
public $starts;
public $ends;
public $images;
public $podcast;
public $keywords;
public $url;
public function __construct($data, $images = null) {
parent::__construct($data);
parent::ConvertToDateTime($this->starts);
parent::ConvertToDateTime($this->ends);
$this->keywords = null;
if(isset($data->keywords)) {
if(is_array($data->keywords)) {
$this->keywords = $data->keywords;
} else if(trim($data->keywords)) {
$this->keywords = explode(' ', $data->keywords);
}
}
$this->podcast = isset($data->podcast) && $data->podcast ? $data->podcast : null;
$images = ($images != null) ? $images
: (isset($data->images) ? $data->images : null);
if($images) {

View File

@@ -16,7 +16,7 @@ class Model {
$field = new \DateTime($field);
}
if($field === false || $field->getTimestamp() == 0) {
if($field === false || $field->getTimestamp() <= 0) {
// If field had data but is invalid DateTime or is 0000-00-00 00:00, set it to null.
$field = null;
} else {

View File

@@ -63,10 +63,6 @@ class NewsItem extends Model {
$this->url = "/nieuws/{$this->id}/" . parent::url_slug($this->title);
}
public function detailsUrl() {
return "/{$this->id}/" . urlencode($this->title);
}
public function excerpt() {
$hasImages = count($this->images) > 0;
$maxLength = $hasImages ? 200 : 500;