-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathArticles.php
More file actions
62 lines (52 loc) · 1.9 KB
/
Copy pathArticles.php
File metadata and controls
62 lines (52 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php defined('SYSPATH') or die('No Direct Script Access');
class Model_Feed_Articles extends Model_Feed_Abstract
{
protected $timeline_key = 'feed';
/**
* Добавляем элемент в фид, передав в score дату создания
*
* @param int $item_id
* @param int $item_dt_create
*
* @return bool|int
*/
public function add($item_id, $item_dt_create)
{
return parent::add($item_id, strtotime($item_dt_create));
}
/**
* Получаем массив моделей статей и курсов.
*
* @param int $numberOfItems - количество элементов, которое хотим получить. Если не указан - получаем все
*
* @return bool|array
* @throws Exception
*/
public function get($numberOfItems = 0, $offset = 0)
{
$items = parent::get($numberOfItems, $offset);
if (is_array($items)) {
$models_list = array();
foreach ($items as $item_identity) {
list($prefix, $id) = $this->decomposeValueIdentity($item_identity);
switch ($prefix) {
case Model_Article::FEED_PREFIX:
if (!Model_Article::isIncludedInCourse($id)) {
$models_list[] = Model_Article::get($id);
}
break;
case Model_Courses::FEED_PREFIX:
if (Model_Courses::containsArticles($id)) {
$models_list[] = Model_Courses::get($id);
}
break;
default:
$error_text = 'Invalid feed type';
throw new Exception($error_text);
}
}
return $models_list;
}
return false;
}
}