News - last edited working; added future and past week relative dates
This commit is contained in:
@@ -12,7 +12,7 @@ class NewsController extends Controller
|
||||
// TODO: Include podcast
|
||||
private static $BASE_SQL = <<<QUERY
|
||||
SELECT `news`.`id`, `content`.`title`, `content`.`content`, `news`.`podcast`, `news`.`video`, `news`.`keywords`, `news`.`titlewithdate`,
|
||||
`content`.`publishingdt` AS `published`, `content`.`creator`, `content`.`editingdt` AS `edited`, `content`.`editor`,
|
||||
`news`.`creationdt` AS `published`, `content`.`creator`, `content`.`editingdt` AS `edited`, `content`.`editor`,
|
||||
`content`.`showsource`, `sources`.`title` AS `source`, `sources`.`url` AS `source_url`,
|
||||
`themes`.`title` AS `theme`, `themes`.`thumbnail` AS `theme_thumbnail`, `regions`.`title` AS `region`
|
||||
FROM `news`
|
||||
@@ -53,6 +53,8 @@ QUERY;
|
||||
|
||||
$result = array();
|
||||
foreach($newsItems as $newsItem) {
|
||||
// Note: content is stored in the database with an additional addslashes() - don't ask why, just remove it :)
|
||||
$newsItem->content = stripslashes($newsItem->content);
|
||||
$pictures = app('db')->select(self::$LOAD_IMAGES, ['newsId' => $newsItem->id]);
|
||||
$result[] = new \Model\NewsItem($newsItem, $pictures);
|
||||
}
|
||||
@@ -71,6 +73,8 @@ QUERY;
|
||||
if(count($newsItem) != 1) {
|
||||
return abort(404);
|
||||
} else {
|
||||
// Note: content is stored in the database with an additional addslashes() - don't ask why, just remove it :)
|
||||
$newsItem[0]->content = stripslashes($newsItem[0]->content);
|
||||
$images = app('db')->select(self::$LOAD_IMAGES, ['newsId' => $id]);
|
||||
return response()->json(new \Model\NewsItem($newsItem[0], $images));
|
||||
}
|
||||
|
||||
@@ -29,6 +29,11 @@ class NewsItem extends Model {
|
||||
parent::ConvertToDateTime($this->published);
|
||||
parent::ConvertToDateTime($this->edited);
|
||||
|
||||
if($this->edited && ($this->edited->getTimestamp() - $this->published->getTimestamp() < 1800 /* == 30 minutes */)) {
|
||||
// If last edit was within grace period, consider it unedited (note: currently RES always saves edited == published on creation)
|
||||
$this->edited = null;
|
||||
}
|
||||
|
||||
$this->source = null;
|
||||
if($data->source)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user