diff --git a/common/classes/Model.php b/common/classes/Model.php index 768cb91..49ddb73 100644 --- a/common/classes/Model.php +++ b/common/classes/Model.php @@ -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); diff --git a/common/classes/Podcast.php b/common/classes/Podcast.php index 7c5a520..aea724c 100644 --- a/common/classes/Podcast.php +++ b/common/classes/Podcast.php @@ -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 '

' . + $maxLength = 500; + return '

' . substr($this->content, 0, $maxLength) . (strlen($this->content) > $maxLength ? '...' : '') . '

';