forked from pkeane/lists
/
List.php
51 lines (45 loc) · 1.22 KB
/
List.php
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
<?php
require_once 'Dase/DBO/Autogen/List.php';
class Dase_DBO_List extends Dase_DBO_Autogen_List
{
public $items = array();
public $count;
public function getItems($omit_hidden = false)
{
$items = new Dase_DBO_Item($this->db);
$items->list_id = $this->id;
$items->orderBy('timestamp DESC');
if ($omit_hidden) {
$items->addWhere('hidden',1,'!=');
}
$this->items = $items->findAll(1);
return $this->items;
}
public function asJson()
{
$set = array();
$set['name'] = $this->name;
$set['timestamp'] = $this->timestamp;
$set['uniq_id'] = $this->uniq_id;
$set['items'] = array();
foreach ($this->getItems() as $item) {
$set['items'][] = $item->text;
}
return Dase_Json::get($set);
}
public function expunge()
{
foreach ($this->getItems() as $item) {
$item->delete();
}
$this->delete();
}
public function getCount()
{
$items = new Dase_DBO_Item($this->db);
$items->list_id = $this->id;
$items->hidden = false;
$this->count = $items->findCount();
return $this->count;
}
}