36 lines
866 B
PHP
36 lines
866 B
PHP
<?php
|
|
|
|
namespace Model;
|
|
|
|
class NewsItem extends Model {
|
|
public $id;
|
|
public $title;
|
|
public $content;
|
|
public $published;
|
|
public $edited;
|
|
public $images;
|
|
|
|
public function __construct($data) {
|
|
parent::__construct($data);
|
|
parent::ConvertToDateTime($this->published);
|
|
parent::ConvertToDateTime($this->edited);
|
|
|
|
//$this->image = new stdClass();
|
|
//$this->image->url = "";
|
|
//$this->image->title = $this->title;
|
|
}
|
|
|
|
public function detailsUrl() {
|
|
return "/{$this->id}/" . urlencode($this->title);
|
|
}
|
|
|
|
public function excerpt() {
|
|
$hasImages = count($this->images) > 0;
|
|
$maxLength = $hasImages ? 200 : 500;
|
|
return '<p class="news-excerpt ' . ($hasImages ? 'short' : 'long') . '">' .
|
|
substr($this->content, 0, $maxLength) .
|
|
(strlen($this->content) > $maxLength ? '...' : '') .
|
|
'</p>';
|
|
}
|
|
}
|