-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathView.class.php
More file actions
423 lines (387 loc) · 13.1 KB
/
View.class.php
File metadata and controls
423 lines (387 loc) · 13.1 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Config表示用クラス
*
* @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 Config_View
{
/**
* @var DBオブジェクトを保持
*
* @access private
*/
var $_db = null;
/**
* @var DIコンテナを保持
*
* @access private
*/
var $_container = null;
/**
* @var Sessionオブジェクトを保持
*
* @access private
*/
var $_session = null;
/**
* @var NetCommonsのバージョンから、多言語対応有無を保持
*
* @access public
*/
var $isMultiLanguage = null;
/**
* コンストラクター
*
* @access public
*/
function Config_View()
{
$this->_container =& DIContainerFactory::getContainer();
$this->_db =& $this->_container->getComponent("DbObject");
$this->_session =& $this->_container->getComponent('Session');
$this->isMultiLanguage = false;
if (empty($this->_session)) {
return;
}
$params = array(
'version'
);
$sql = "SELECT conf_value ".
"FROM {config} ".
"WHERE conf_name = ?";
$configs = $this->_db->execute($sql, $params);
if ($configs === false) {
$this->_db->addError();
return false;
}
if (empty($configs)) {
return false;
}
$versions = explode('.', $configs[0]['conf_value']);
if (intval($versions[0]) >= 2
&& intval($versions[1]) >= 3) {
$this->isMultiLanguage = true;
}
}
/**
* META情報取得
* @return array
* @access public
*/
function getMetaHeader($page_id_arr = null, $dir_name_arr=null, $system_flag=false)
{
$getdata =& $this->_container->getComponent("GetData");
$token =& $this->_container->getComponent("Token");
$session =& $this->_container->getComponent("Session");
$common =& $this->_container->getComponent("commonMain");
$meta = $session->getParameter("_meta");
$getdata =& $this->_container->getComponent("GetData");
$request =& $this->_container->getComponent("Request");
$script_str =& $getdata->getParameter("script_str");
//$meta['script_header'] = "";
if($request->getParameter("_noscript") == _ON) {
$meta['script_header'] = "";
} else {
if(_SCRIPT_OUTPUT_POS == "header") {
$scriptStr = $this->_getScript($dir_name_arr, $system_flag);
//"<script type=\"text/javascript\">".$getdata->getParameter("script_str")."</script>";
} else {
$scriptStr = "";
}
$meta['script_header'] = $scriptStr;
}
//theme_name
//$meta['css_header'] = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"./themes/css/style.css" ."\" />";
//$meta['css_header'] .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"./themes/system/css/style.css" ."\" />";
$meta['css_header']["/themes/system/css/style.css"] = "/themes/system/css/style.css";
if(isset($page_id_arr) && $page_id_arr != 0) {
if(is_array($page_id_arr)) {
$page_id = $page_id_arr[0];
} else {
$page_id = $page_id_arr;
}
$pages = $getdata->getParameter("pages");
if(!isset($pages[$page_id])) {
// 再帰的(action:)に呼ぶ過程でpage_idを途中からセットした場合、setDafaultでセットしていないので取得
$pagesView =& $this->_container->getComponent("pagesView");
$buf_pages_obj =& $pagesView->getPageById($page_id);
$pages[$page_id] =& $buf_pages_obj;
}
$themeStr = $pages[$page_id]['theme_name'];
$tempStr = $pages[$page_id]['temp_name'];
//$meta['css_header'] .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"./themes/css/page_style.css" ."\" />";
$themeStrList = explode("_", $themeStr);
if(count($themeStrList) == 1) {
$themeCssPath = "/themes/".$themeStr."/css";
} else {
$bufthemeStr = array_shift ( $themeStrList );
$themeCssPath = "/themes/".$bufthemeStr."/css/".implode("/", $themeStrList);
}
$meta['css_header']["/pages/".$tempStr. "/page_style.css"] = "/pages/".$tempStr. "/page_style.css";
$meta['css_header'][$themeCssPath. "/page_style.css"] = $themeCssPath. "/page_style.css";
//$meta['css_header'] .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"." . $themeCssPath. "/page_style.css" ."\" />";
// カスタム用CSS
//$meta['css_header'] .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".CORE_BASE_URL.INDEX_FILE_NAME."?".ACTION_KEY."=common_download_css&dir_name=" . $themeStr ."&type="._CSS_TYPE_PAGE_CUSTOM."\" />";
//$footer['script_footer'] .= "<script type=\"text/javascript\">";
$page_token_arr = array();
$active_center_action = $request->getParameter("active_center");
if(isset($active_center_action)) $active_center = _ON;
else $active_center = _OFF;
$script_str .= "pagesCls.pageInit(".$active_center.");";
if($token) {
if(is_array($page_id_arr)) {
foreach($page_id_arr as $page_id) {
$page_id = intval($page_id);
if(isset($pages[$page_id])) {
$token->setName(array($page_id, DEFAULT_ACTION));
$script_str .= "pagesCls.setShowCount(" .$page_id.",". $pages[$page_id]['show_count'] . ");";
if($pages[$page_id]['display_position'] == _DISPLAY_POSITION_CENTER) {
$script_str .= "pagesCls.setToken(" .$page_id.",\"". $token->getValue() . "\",true);";
} else {
$script_str .= "pagesCls.setToken(" .$page_id.",\"". $token->getValue() . "\");";
}
}
}
} else {
$page_id_arr = intval($page_id_arr);
$token->setName(array($page_id_arr, DEFAULT_ACTION));
if(isset($pages[$page_id_arr])) {
$script_str .= "pagesCls.setShowCount(" .$page_id_arr.",". $pages[$page_id_arr]['show_count'] . ");";
}
$script_str .= "pagesCls.setToken(" .$page_id_arr.",\"". $token->getValue() . "\",true);";
}
}
//$footer['script_footer'] .= "</script>";
} else {
//
// サイト閉鎖中のアクション実行中の場合、page_style.cssを読み込む
//
$actionChain =& $this->_container->getComponent("ActionChain");
$action_name = $actionChain->getCurActionName();
if($action_name == "pages_view_closesite") {
$meta['css_header']['/css/page_style.css'] = '/css/page_style.css';
//$meta['css_header'] .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"./themes/css/page_style.css" ."\" />";
}
}
////$getdata->setParameter("script_str",$script_str);
return $meta;
}
/**
* Footer情報終了処理
* @param boolean $system_flag
* @return array
* @access public
*/
function terminateFooter($dir_name_arr=null, $system_flag=false)
{
$getdata =& $this->_container->getComponent("GetData");
$request =& $this->_container->getComponent("Request");
$footer =& $getdata->getParameter("footer_field");
if($request->getParameter("_noscript") == _ON) {
$footer['script_footer'] = "";
} else {
if(_SCRIPT_OUTPUT_POS == "footer") {
$scriptStrSrc = $this->_getScript($dir_name_arr, $system_flag);
$scriptStr = $getdata->getParameter("script_str_all");
$scriptStr .= "<script type=\"text/javascript\">".$getdata->getParameter("script_str")."</script>";
} else {
$scriptStrSrc = "";
$scriptStr = "";
$footer['script_header'] = "<script type=\"text/javascript\">".$getdata->getParameter("script_str")."</script>";
}
$footer['script_footer_src'] = $scriptStrSrc;
$footer['script_footer'] = $scriptStr;
}
return $footer;
}
/**
* Script文字列取得
* @param array $dir_name_arr
* @param boolean $system_flag
* @return string
* @access public
*/
function _getScript($dir_name_arr=array(), $system_flag=false)
{
$session =& $this->_container->getComponent("Session");
$lang = $session->getParameter("_lang");
if (CORE_BASE_URL == BASE_URL && isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
$base_url = BASE_URL_HTTPS;
} else {
$base_url = CORE_BASE_URL;
}
$script_name = $base_url.INDEX_FILE_NAME."?action=common_download_js";
// パラメータの順番を同じようにするためソート(できるだけCasheで表示してもらうため)
if($dir_name_arr != null) {
sort($dir_name_arr);
$script_name .= "&dir_name=" .htmlspecialchars(implode("|", $dir_name_arr), ENT_QUOTES);
}
if($session->getParameter("_system_flag") || $system_flag) {
$script_name .= "&system_flag=" . _ON;
} else {
$script_name .= "&system_flag=" . _OFF;
}
$lang_script_name = "";
if (defined("_JS_VERSION")) {
$script_name .= "&vs=" . _JS_VERSION;
$lang_script_name .= "?vs=" . _JS_VERSION;
}
$scriptStr = "<script type=\"text/javascript\" src=\"".$base_url."/js/".$lang."/lang_common.js".$lang_script_name."\"></script>".
"<script type=\"text/javascript\" src=\"".$script_name."\"></script>";
return $scriptStr;
}
/**
* conf_modidよりConfig情報取得
* @return array
* @access public
*/
function &getConfig($conf_modid, $catid_as_key = true)
{
$fetchFunction = array($this, "_fetchcallbackGetConfig");
$fetchFunctionParameters = array($catid_as_key);
if (!$this->isMultiLanguage) {
$where_params = array(
"conf_modid" => $conf_modid
);
$configs =& $this->_db->selectExecute("config", $where_params, null, null, null, $fetchFunction, $fetchFunctionParameters);
} else {
$params = array(
$this->_session->getParameter('_lang'),
$conf_modid,
);
$sql = $this->_getConfigSQL();
$configs = $this->_db->execute($sql, $params, null, null, true, $fetchFunction, $fetchFunctionParameters);
if ($configs === false) {
$this->_db->addError();
}
}
return $configs;
}
/**
* fetch時コールバックメソッド
* @result adodb object
* @array function parameter
* @return array configs
* @access private
*/
function _fetchcallbackGetConfig($result, $func_param=null)
{
$config = array();
$catid_as_key = null;
if(isset($func_param[0])) $catid_as_key = $func_param[0];
while ($row = $result->fetchRow()) {
if (isset($row['CLValue'])) {
$row['conf_value'] = $row['CLValue'];
}
if ($catid_as_key) {
$config[$row['conf_catid']][$row['conf_name']] = $row;
} else {
$config[$row['conf_name']] = $row;
}
}
return $config;
}
/**
* conf_catidよりConfig情報取得
*
* @param int $conf_modid モジュールID
* @param int $conf_catid カテゴリID
* @return array
* @access public
*/
function &getConfigByCatid($conf_modid, $conf_catid, $limit = null, $offset = null, $func=null, $func_param=null)
{
if ($func == null) {
$func = array($this, '_fetchcallbackGetConfig');
}
if (!$this->isMultiLanguage) {
$where_params = array(
"conf_modid"=>$conf_modid,
"conf_catid" => $conf_catid
);
$order_params = null;
$configs =& $this->_db->selectExecute("config", $where_params, $order_params, $limit, $offset, $func, $func_param);
} else {
$params = array(
$this->_session->getParameter('_lang'),
$conf_modid,
$conf_catid
);
$sql = $this->_getConfigSQL()
. "AND C.conf_catid = ?";
$configs = $this->_db->execute($sql, $params, $limit, $offset, true, $func, $func_param);
if ($configs === false) {
$this->_db->addError();
}
}
return $configs;
}
/**
* conf_nameよりConfig情報取得
*
* @param int $conf_modid モジュールID
* @param string $conf_name conf名
* @return array
* @access public
*/
function &getConfigByConfname($conf_modid, $conf_name)
{
if (!$this->isMultiLanguage) {
$where_params = array(
"conf_modid" => $conf_modid,
"conf_name" => $conf_name
);
$configs =& $this->_db->selectExecute("config", $where_params);
if ($configs === false) {
return $configs;
}
} else {
$params = array(
$this->_session->getParameter('_lang'),
$conf_modid,
$conf_name
);
$sql = $this->_getConfigSQL()
. "AND C.conf_name = ?";
$configs = $this->_db->execute($sql, $params);
if ($configs === false) {
$this->_db->addError();
return $configs;
}
}
if(empty($configs)) {
$configs = null;
return $configs;
}
$config = $configs[0];
if (isset($config['CLValue'])) {
$config['conf_value'] = $config['CLValue'];
}
return $config;
}
/**
* コンフィグテーブルとコンフィグ言語テーブルを結合するSQL文字列を取得する
*
* @return string SQL文字列
* @access private
*/
function &_getConfigSQL()
{
$sql = "SELECT C.*, "
. "CL.conf_value AS CLValue "
. "FROM {config} C "
. "LEFT JOIN {config_language} CL "
. "ON C.conf_name = CL.conf_name "
. "AND CL.lang_dirname = ? "
. "WHERE C.conf_modid = ? ";
return $sql;
}
}
?>