-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathView.class.php
More file actions
131 lines (114 loc) · 3.21 KB
/
View.class.php
File metadata and controls
131 lines (114 loc) · 3.21 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
<?php
/**
* チャットテーブル表示用クラス
*
* @package [[package名]]
* @author Ryuji Masukawa
* @copyright copyright (c) 2006 NetCommons.org
* @license [[license]]
* @access public
*/
class Chat_Components_View {
/**
* @var DBオブジェクトを保持
*
* @access private
*/
var $_db = null;
var $_container = null;
/**
* コンストラクター
*
* @access public
*/
function Chat_Components_View() {
$this->_container =& DIContainerFactory::getContainer();
$this->_db =& $this->_container->getComponent("DbObject");
}
/**
* ブロックIDからチャット管理データ取得
* @param int block_id
* @access public
*/
function &getChatById($id) {
$params = array(
"block_id" => $id
);
$sql = "SELECT {chat}.*,{chat_login}.block_id as login " .
"FROM {chat} LEFT OUTER JOIN {chat_login} " .
"ON {chat}.block_id={chat_login}.block_id " .
"WHERE {chat}.block_id=? ";
$result = $this->_db->execute($sql ,$params);
if($result === false) {
return $result;
}
return $result[0];
}
/**
* チャット用デフォルトデータを取得する
*
* @return array チャット用デフォルトデータ配列
* @access public
*/
function &getDefaultChat() {
$configView =& $this->_container->getComponent("configView");
$request =& $this->_container->getComponent("Request");
$module_id = $request->getParameter("module_id");
$config = $configView->getConfig($module_id, false);
if ($config === false) {
return $config;
}
$chat = array(
"height" => $config["height"]["conf_value"],
"width" => $config["width"]["conf_value"],
"reload" => $config["reload"]["conf_value"],
"status" => constant($config["status"]["conf_value"]),
"display_type" => constant($config["display_type"]["conf_value"]),
"line_num" => $config["line_num"]["conf_value"]
);
return $chat;
}
/**
* ブロックIDからチャットテキストデータ取得
* @param int block_id,chat_id
* @access public
*/
function &getChatText($block_id, $line_num, $chat_id = "" ) {
$params = array(
"block_id" => $block_id
);
$sql = "SELECT * " .
"FROM {chat_contents} " .
"WHERE {chat_contents}.block_id=?";
if ($chat_id) {
$now_chat_id = $this->_db->countExecute("chat_contents", $params);
if($now_chat_id < $chat_id) {
$chat_arr = array("chat_id" => 0);
}else {
$chat_arr = array("chat_id" => $chat_id);
}
$params = array_merge($params, $chat_arr);
$sql .= " AND {chat_contents}.chat_id>?";
}
$sql .= " ORDER BY {chat_contents}.chat_id DESC";
if (!$chat_id && $line_num) {
$sql .= " LIMIT ".$line_num;
}
$result = $this->_db->execute($sql ,$params);
return $result;
}
/**
* 携帯用ブロックデータを取得
*
* @access public
*/
function getBlocksForMobile($block_id_arr)
{
$sql = "SELECT block.*" .
" FROM {blocks} block" .
" WHERE block.block_id IN (".implode(",",$block_id_arr).")" .
" ORDER BY block.col_num ASC, block.row_num ASC";
return $this->_db->execute($sql, null);
}
}
?>