1 | <?php |
||
66 | class Feed extends Entity implements IAPI, \JsonSerializable { |
||
67 | |||
68 | use EntityJSONSerializer; |
||
69 | |||
70 | protected $userId; |
||
71 | protected $urlHash; |
||
72 | protected $url; |
||
73 | protected $title; |
||
74 | protected $faviconLink; |
||
75 | protected $added; |
||
76 | protected $folderId; |
||
77 | protected $unreadCount; |
||
78 | protected $link; |
||
79 | protected $preventUpdate; |
||
80 | protected $deletedAt; |
||
81 | protected $articlesPerUpdate; |
||
82 | protected $httpLastModified; |
||
83 | protected $httpEtag; |
||
84 | protected $location; |
||
85 | protected $ordering; |
||
86 | protected $fullTextEnabled; |
||
87 | protected $pinned; |
||
88 | protected $updateMode; |
||
89 | protected $updateErrorCount; |
||
90 | protected $lastUpdateError; |
||
91 | protected $basicAuthUser; |
||
92 | protected $basicAuthPassword; |
||
93 | |||
94 | 14 | public function __construct(){ |
|
95 | 14 | $this->addType('parentId', 'integer'); |
|
96 | 14 | $this->addType('added', 'integer'); |
|
97 | 14 | $this->addType('folderId', 'integer'); |
|
98 | 14 | $this->addType('unreadCount', 'integer'); |
|
99 | 14 | $this->addType('preventUpdate', 'boolean'); |
|
100 | 14 | $this->addType('pinned', 'boolean'); |
|
101 | 14 | $this->addType('deletedAt', 'integer'); |
|
102 | 14 | $this->addType('articlesPerUpdate', 'integer'); |
|
103 | 14 | $this->addType('ordering', 'integer'); |
|
104 | 14 | $this->addType('fullTextEnabled', 'boolean'); |
|
105 | 14 | $this->addType('updateMode', 'integer'); |
|
106 | 14 | $this->addType('updateErrorCount', 'integer'); |
|
107 | 14 | } |
|
108 | |||
109 | |||
110 | /** |
||
111 | * Turns entitie attributes into an array |
||
112 | */ |
||
113 | public function jsonSerialize() { |
||
114 | $serialized = $this->serializeFields([ |
||
115 | 'id', |
||
116 | 'userId', |
||
117 | 'urlHash', |
||
118 | 'url', |
||
119 | 'title', |
||
120 | 'faviconLink', |
||
121 | 'added', |
||
122 | 'folderId', |
||
123 | 'unreadCount', |
||
124 | 'link', |
||
125 | 'preventUpdate', |
||
126 | 'deletedAt', |
||
127 | 'articlesPerUpdate', |
||
128 | 'location', |
||
129 | 'ordering', |
||
130 | 'fullTextEnabled', |
||
131 | 'pinned', |
||
132 | 'updateMode', |
||
133 | 'updateErrorCount', |
||
134 | 'lastUpdateError', |
||
135 | 'basicAuthUser', |
||
136 | 'basicAuthPassword' |
||
137 | ]); |
||
138 | |||
139 | $url = parse_url($this->link)['host']; |
||
140 | |||
141 | // strip leading www. to avoid css class confusion |
||
142 | if (strpos($url, 'www.') === 0) { |
||
143 | $url = substr($url, 4); |
||
144 | } |
||
145 | |||
146 | $serialized['cssClass'] = 'custom-' . str_replace('.', '-', $url); |
||
147 | |||
148 | return $serialized; |
||
149 | } |
||
150 | |||
151 | |||
152 | public function toAPI() { |
||
153 | return $this->serializeFields([ |
||
154 | 'id', |
||
155 | 'url', |
||
156 | 'title', |
||
157 | 'faviconLink', |
||
158 | 'added', |
||
159 | 'folderId', |
||
160 | 'unreadCount', |
||
161 | 'ordering', |
||
162 | 'link', |
||
163 | 'pinned', |
||
164 | 'updateErrorCount', |
||
165 | 'lastUpdateError' |
||
166 | ]); |
||
167 | } |
||
168 | |||
169 | |||
170 | 14 | public function setUrl($url) { |
|
177 | |||
178 | |||
179 | 14 | public function setLink($url) { |
|
185 | |||
186 | |||
187 | } |
||
188 |