-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.php
executable file
·51 lines (41 loc) · 1.18 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
<?
Class List_Model extends ORM {
private $fileFields = array('file', 'file2');
private $dbmap = null;
public function __constructor($id = null){
parent::__constructor($id);
}
public function find_by_page_id($page_id, $instance){
$this->where('page_id', $page_id)
->where('instance', $instance)
->where('activity', 'NULL')
->orderBy('sortorder')
->find_all();
}
/* for any GET we should know the instance beforehand
* and then can use this to dbmap
*
* for SET it's a little trickier, because the instance
* might not have been SET yet
*/
public function __get($column){
if(in_array($column, $this->fileFields) && !is_object(parent::__get($column)) ){
$file = ORM::Factory('file', parent::__get($column));
if($file->loaded){
parent::__set($column,ORM::Factory('file', parent::__get($column)));
} else {
parent::__set($column, ORM::Factory('file') );
}
} else if($this->loaded) {
//attempt to dbmap
if(!$this->dbmap){
$instance = parent::__get('instance');
$this->dbmap = Kohana::config($instance.'.dbmap');
}
if(isset($this->dbmap[$column])){
$column = $this->dbmap[$column];
}
}
return parent::__get($column);
}
}