From daaf87749dae9c70ccd46911a08c6da1d9ad8150 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 9 Sep 2014 18:56:31 +0200 Subject: add css custom classes --- db/feed.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/feed.php b/db/feed.php index d5c7314c2..32565f09b 100644 --- a/db/feed.php +++ b/db/feed.php @@ -73,7 +73,7 @@ class Feed extends Entity implements IAPI, \JsonSerializable { * Turns entitie attributes into an array */ public function jsonSerialize() { - return $this->serializeFields([ + $serialized = $this->serializeFields([ 'id', 'userId', 'urlHash', @@ -88,6 +88,17 @@ class Feed extends Entity implements IAPI, \JsonSerializable { 'deletedAt', 'articlesPerUpdate', ]); + + $url = parse_url($this->link)['host']; + + // strip leading www. to avoid css class confusion + if (strpos($url, 'www.') === 0) { + $url = substr($url, 4); + } + + $serialized['cssClass'] = str_replace('.', '-', $url); + + return $serialized; } public function toAPI() { -- cgit v1.2.3