NewsItem images: file / url
This commit is contained in:
@@ -24,7 +24,7 @@ SELECT `news`.`id`, `content`.`title`, `content`.`content`, `news`.`podcast`
|
|||||||
QUERY;
|
QUERY;
|
||||||
|
|
||||||
private static $LOAD_IMAGES =
|
private static $LOAD_IMAGES =
|
||||||
'SELECT `id`, `file` AS `url`, `description` AS `title` FROM `news_pictures` WHERE `news` = ? AND `active` = 1';
|
'SELECT `id`, `file`, `description` AS `title` FROM `news_pictures` WHERE `news` = ? AND `active` = 1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new controller instance.
|
* Create a new controller instance.
|
||||||
|
|||||||
@@ -16,11 +16,17 @@ class NewsSource {
|
|||||||
|
|
||||||
class NewsImage extends Model {
|
class NewsImage extends Model {
|
||||||
public $id;
|
public $id;
|
||||||
public $url;
|
|
||||||
public $title;
|
public $title;
|
||||||
|
public $url;
|
||||||
|
|
||||||
public function getUrl() {
|
public function __construct($data, $urlPrefix = '/') {
|
||||||
return '/img/news/' . $this->url;
|
parent::__construct($data);
|
||||||
|
|
||||||
|
// Deserialisatie van JSON heeft url in data,
|
||||||
|
// lezen uit database heeft file en (als het goed is) urlPrefix
|
||||||
|
if(isset($data->file)) {
|
||||||
|
$this->url = $urlPrefix . $data->file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user