-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathView.class.php
More file actions
111 lines (102 loc) · 2.56 KB
/
View.class.php
File metadata and controls
111 lines (102 loc) · 2.56 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
<?php
/**
* カウンタテーブル表示用クラス
*
* @package NetCommons
* @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 Counter_Components_View {
/**
* @var DBオブジェクトを保持
*
* @access private
*/
var $_db = null;
/**
* @var Requestオブジェクトを保持
*
* @access private
*/
var $_request = null;
/**
* コンストラクター
*
* @access public
*/
function Counter_Components_View() {
$container =& DIContainerFactory::getContainer();
$this->_db =& $container->getComponent("DbObject");
$this->_request =& $container->getComponent("Request");
}
/**
* カウンタが存在するか判断する
*
* @return boolean true:存在する、false:存在しない
* @access public
*/
function counterExists()
{
$params = array(
$this->_request->getParameter("block_id")
);
$sql = "SELECT block_id ".
"FROM {counter} ".
"WHERE block_id = ?";
$blockIDs = $this->_db->execute($sql, $params);
if ($blockIDs === false) {
$this->_db->addError();
return $blockIDs;
}
if (count($blockIDs) > 0) {
return true;
}
return false;
}
/**
* ブロックIDからカウンタデータ取得
*
* @access public
*/
function getCounter() {
$params = array(
$this->_request->getParameter("block_id")
);
$result = $this->_db->execute("SELECT " .
" block_id," .
" counter_digit," .
" counter_num," .
" show_type, " .
" show_char_before," .
" show_char_after," .
" comment " .
" FROM {counter} " .
" WHERE block_id=?" ,$params);
if(!$result) {
return false;
}
return $result[0];
}
/**
* カウンタ画像データ配列を取得する
*
* @param array $counter カウンタデータ配列
* @return array カウンタ画像データ配列
* @access public
*/
function getImgSrcs($counter)
{
$imgPath = get_image_url(). "/images/counter/common/". $counter["show_type"]. "/";
$strNum = sprintf("%0" . $counter["counter_digit"] ."d", $counter["counter_num"]);
$imgSrcs = array();
for ( $i=0; $i < strlen($strNum); $i++ ){
$n = substr($strNum, $i, 1);
$imgSrcs[] = $imgPath. $n. ".gif";;
}
return $imgSrcs;
}
}
?>