admincp_click.php
4.53 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_click.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$operation = $operation ? $operation : '';
cpheader();
if(empty($operation)) {
$idtype = in_array($_GET['idtype'], array('blogid', 'picid', 'aid')) ? trim($_GET['idtype']) : 'blogid';
if(!submitcheck('clicksubmit')) {
shownav('style', 'click_edit');
showsubmenu('nav_click', array(
array('click_edit_blogid', 'click&idtype=blogid', $idtype == 'blogid' ? 1 : 0),
array('click_edit_picid', 'click&idtype=picid', $idtype == 'picid' ? 1 : 0),
array('click_edit_aid', 'click&idtype=aid', $idtype == 'aid' ? 1 : 0),
));
showtips('click_edit_tips');
showformheader('click&idtype='.$idtype);
showtableheader();
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
'',
cplang('display_order'),
'',
cplang('available'),
cplang('name'),
cplang('click_edit_image'),
cplang('click_edit_type'),
));
print <<<EOF
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
[1,'', 'td25'],
[1,'<input type="checkbox" name="newavailable[]" value="1">', 'td25'],
[1,'<input type="text" class="txt" name="newname[]" size="10">'],
[1,'<input type="text" class="txt" name="newicon[]" size="20">'],
[1,'', 'td23']
]
];
</script>
EOF;
foreach(C::t('home_click')->fetch_all_by_idtype($idtype) as $click) {
$checkavailable = $click['available'] ? 'checked' : '';
$click['idtype'] = cplang('click_edit_'.$click['idtype']);
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$click[clickid]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$click[clickid]]\" value=\"$click[displayorder]\">",
"<img src=\"static/image/click/$click[icon]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$click[clickid]]\" value=\"1\" $checkavailable>",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"name[$click[clickid]]\" value=\"$click[name]\">",
"<input type=\"text\" class=\"txt\" size=\"20\" name=\"icon[$click[clickid]]\" value=\"$click[icon]\">",
$click['idtype']
));
}
echo '<tr><td></td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['click_edit_addnew'].'</a></div></td></tr>';
showsubmit('clicksubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
$ids = array();
if(is_array($_GET['delete'])) {
foreach($_GET['delete'] as $id) {
$ids[] = $id;
}
if($ids) {
C::t('home_click')->delete($ids, true);
}
}
if(is_array($_GET['name'])) {
foreach($_GET['name'] as $id => $val) {
$id = intval($id);
$updatearr = array(
'name' => dhtmlspecialchars($_GET['name'][$id]),
'icon' => $_GET['icon'][$id],
'idtype' => $idtype,
'available' => intval($_GET['available'][$id]),
'displayorder' => intval($_GET['displayorder'][$id]),
);
C::t('home_click')->update($id, $updatearr);
}
}
if(is_array($_GET['newname'])) {
foreach($_GET['newname'] as $key => $value) {
if($value != '' && $_GET['newicon'][$key] != '') {
$data = array(
'name' => dhtmlspecialchars($value),
'icon' => $_GET['newicon'][$key],
'idtype' => $idtype,
'available' => intval($_GET['newavailable'][$key]),
'displayorder' => intval($_GET['newdisplayorder'][$key])
);
C::t('home_click')->insert($data);
}
}
}
$keys = $ids = $_G['cache']['click'] = array();
foreach(C::t('home_click')->fetch_all_by_available() as $value) {
if(count($_G['cache']['click'][$value['idtype']]) < 8) {
$keys[$value['idtype']] = $keys[$value['idtype']] ? ++$keys[$value['idtype']] : 1;
$_G['cache']['click'][$value['idtype']][$keys[$value['idtype']]] = $value;
} else {
$ids[] = $value['clickid'];
}
}
if($ids) {
C::t('home_click')->update($ids, array('available'=>0), true);
}
updatecache('click');
cpmsg('click_edit_succeed', 'action=click&idtype='.$idtype, 'succeed');
}
}
?>