Podcasts aangepast voor weergave op voorpagina

This commit is contained in:
2017-09-16 16:39:09 +02:00
parent fdcf6c0d7e
commit dd44ebd443
2 changed files with 9 additions and 7 deletions

View File

@@ -9,8 +9,8 @@ class Model {
// In that case $field will be an object
if(is_object($field)) {
$field = ($field->timezone)
? new \DateTime($field->date, new \DateTimeZone($field->timezone))
: (new \DateTime($field->date));
? new \DateTimeImmutable($field->date, new \DateTimeZone($field->timezone))
: (new \DateTimeImmutable($field->date));
} else {
// If $field is not an object, assume it's a plain, valid, string
$field = new \DateTime($field);

View File

@@ -2,8 +2,6 @@
namespace Model;
require "Program.php";
class Podcast extends Model {
public $id;
public $title;
@@ -36,6 +34,11 @@ class Podcast extends Model {
}
}
public function titleWithoutProgram() {
if(!$this->program) { return $this->title; }
return trim(str_replace($this->program->name, '', $this->title), "- \t\n\r\0\x0B");
}
public function isValidAuth($key) {
return ($key == $this->key);
}
@@ -45,9 +48,8 @@ class Podcast extends Model {
}
public function excerpt() {
$hasImages = count($this->images) > 0;
$maxLength = $hasImages ? 200 : 500;
return '<p class="news-excerpt ' . ($hasImages ? 'short' : 'long') . '">' .
$maxLength = 500;
return '<p class="news-excerpt long">' .
substr($this->content, 0, $maxLength) .
(strlen($this->content) > $maxLength ? '...' : '') .
'</p>';