forked from netcommons/NetCommons2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView.class.php
More file actions
134 lines (123 loc) · 3.84 KB
/
View.class.php
File metadata and controls
134 lines (123 loc) · 3.84 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
128
129
130
131
132
133
134
<?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 Search_Components_View
{
/**
* @var DBオブジェクトを保持
*
* @access private
*/
var $_db = null;
/**
* @var DIコンテナを保持
*
* @access private
*/
var $_container = null;
/**
* @var Sessionオブジェクトを保持
*
* @access private
*/
var $_session = null;
/**
* @var モジュールオブジェクトを保持
*
* @access private
*/
var $_modulesView = null;
/**
* コンストラクター
*
* @access public
*/
function Search_Components_View() {
$this->_container =& DIContainerFactory::getContainer();
$this->_db =& $this->_container->getComponent("DbObject");
$this->_session =& $this->_container->getComponent("Session");
$this->_modulesView =& $this->_container->getComponent("modulesView");
}
/**
* ブロックのデータを取得
*
* @access public
*/
function &getBlock($block_id, $show_mode=null, $default_target_module=null, $detail_flag=null)
{
$block_id = intval($block_id);
$result =& $this->_db->selectExecute("search_blocks", array("block_id"=>$block_id));
if (empty($result)) {
return $result;
}
$search_blocks_obj = $result[0];
if (isset($show_mode)) {
$search_blocks_obj["show_mode"] = $show_mode;
}
if (isset($default_target_module)) {
$search_blocks_obj["default_target_module"] = $default_target_module;
}
$search_blocks_obj["default_target_module_arr"] = explode(",", $search_blocks_obj["default_target_module"]);
if (isset($detail_flag)) {
$search_blocks_obj["detail_flag"] = $detail_flag;
}
return $search_blocks_obj;
}
/**
* モジュールのデータを取得
*
* @access public
*/
function &getModules($search_blocks_obj=null)
{
$result =& $this->_modulesView->getModules(null, array("display_sequence"=>"ASC"), null, null, array($this, "_callbackModules"), array($search_blocks_obj));
if ($result === false) {
return $result;
}
return $result;
}
/**
* モジュールのデータを取得
*
* @access private
*/
function _callbackModules(&$recordSet, &$params)
{
$request = $actionChain =& $this->_container->getComponent("Request");
$block_id = $request->getParameter("block_id");
$target_modules = $this->_session->getParameter(array("search_select", $block_id, "target_modules"));
$actionChain =& $this->_container->getComponent("ActionChain");
$actionName = $actionChain->getCurActionName();
$search_blocks_obj = $params[0];
$ret = array();
while ($row = $recordSet->fetchRow()) {
if ($row["search_action"] == "") { continue; }
$pathList = explode("_", $row["action_name"]);
$row["dir_name"] = $pathList[0];
if ($actionName == "search_view_main_init" && $search_blocks_obj["show_mode"] == SEARCH_SHOW_MODE_SIMPLE &&
!in_array($row["dir_name"], $search_blocks_obj["default_target_module_arr"])) {
continue;
}
$row["module_name"] = $this->_modulesView->loadModuleName($row["dir_name"]);
if (isset($search_blocks_obj)) {
if (isset($target_modules) && in_array($row["module_id"], $target_modules) || !isset($target_modules) && in_array($row["dir_name"], $search_blocks_obj["default_target_module_arr"])) {
$row["target_module_flag"] = true;
} else {
$row["target_module_flag"] = false;
}
}
$ret[] = $row;
}
return $ret;
}
}
?>