-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathView.class.php
More file actions
127 lines (119 loc) · 3.16 KB
/
View.class.php
File metadata and controls
127 lines (119 loc) · 3.16 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* システム関連情報取得コンポーネント
*
* @package NetCommons Components
* @author Noriko Arai,Ryuji Masukawa
* @copyright 2006-2007 NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @project NetCommons Project, supported by National Institute of Informatics
* @access public
*/
class System_Components_View
{
/**
* @var DBオブジェクトを保持
*
* @access private
*/
var $_db = null;
/**
* @var DIコンテナを保持
*
* @access private
*/
var $_container = null;
/**
* コンストラクター
*
* @access public
*/
function System_Components_View()
{
$this->_container =& DIContainerFactory::getContainer();
$this->_db =& $this->_container->getComponent("DbObject");
$this->_usersView = & $this->_container->getComponent("usersView");
}
/**
* itemを取得する
*
* @param int $item_id 項目ID
* @return array
* @access public
*/
function &getItems($where_params=null, $order_params=null, $limit = null, $offset = null, $func=null, $func_param=null)
{
$sql = "SELECT {items}.*, {items_options}.options,{items_options}.default_selected".
" FROM {items} ".
" LEFT JOIN {items_options} ON ({items}.item_id={items_options}.item_id)";
$sql .= $this->_db->getWhereSQL($params, $where_params);
$sql .= $this->_db->getOrderSQL($order_params);
$result =$this->_db->execute($sql, $params, $limit, $offset, true, $func, $func_param);
if($result === false) {
// エラーが発生した場合、エラーリストに追加
$this->_db->addError();
return $result;
}
return $result;
}
/**
* autoregist_use_itemsから変更不可のIDだけを取り出す
* 1:1|2:1|3:1|4:0| -> (1, 2, 3)
*
* @param string
* @return array
* @access public
*/
function useItemsKeys($use_item)
{
return array_filter( array_map(
create_function('$mustflag',
'if(!$mustflag) return false;
list($item, $flag)=explode(":", $mustflag);
return ($flag)? $item : false;'
),
explode("|", $use_item)
));
}
/**
* autoregist_use_itemsをパースして連想配列を返す
* 1:1|2:1|3:1|4:0| -> {1 => 1, 2 => 1, 3 => 1, 4 => 0}
*
* @param string
* @return array
* @access public
*/
function parseUseItems($use_item)
{
$use_items = array();
foreach(explode("|", $use_item) as $element) {
$list=explode(":", $element);
if (count($list) == 2) {
$use_items[intval($list[0])] = intval($list[1]);
}
}
return $use_items;
}
/**
* itemが存在するかどうか
*
* @param int item_id
* @return bool
* @access public
*/
function itemStorable($item_id)
{
$item =& $this->_usersView->getItemById($item_id);
if ($item === false) {
return false;
}
// || $item["type"] == "system")
// if ($item["type"] == "label" || $item["define_flag"] != _ON) {
if ($item["type"] == "label") {
return false;
}
return true;
}
}
?>