module.php
2.42 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
<?php
/**
* 微相册模块定义
*
* @author WeEngine Team
* @url http://www.we7.cc
*/
defined('IN_IA') or exit('Access Denied');
class We7_albumModule extends WeModule {
public function fieldsFormDisplay($rid = 0) {
//要嵌入规则编辑页的自定义内容,这里 $rid 为对应的规则编号,新增时为 0
global $_W, $_GPC;
if (!empty($rid)) {
$reply = pdo_fetchall("SELECT * FROM " . tablename('album_reply') . " WHERE rid = :rid ORDER BY ID ASC", array(':rid' => $rid));
if (!empty($reply)) {
foreach ($reply as $row) {
$albumids[$row['albumid']] = $row['albumid'];
}
$album = pdo_fetchall("SELECT id, title, thumb, content FROM " . tablename('album') . " WHERE id IN (" . implode(',', $albumids) . ")", array(), 'id');
}
}
include $this->template('rule');
}
public function fieldsFormValidate($rid = 0) {
//规则编辑保存时,要进行的数据验证,返回空串表示验证无误,返回其他字符串将呈现为错误提示。这里 $rid 为对应的规则编号,新增时为 0
return '';
}
public function fieldsFormSubmit($rid) {
//规则验证无误保存入库时执行,这里应该进行自定义字段的保存。这里 $rid 为对应的规则编号
global $_W, $_GPC;
//删除旧的
pdo_query("delete from ".tablename('album_reply')." where rid=:rid",array(':rid'=>$rid));
if (!empty($_GPC['albumid'])) {
foreach ($_GPC['albumid'] as $aid) {
pdo_insert('album_reply', array(
'rid' => $rid,
'albumid' => $aid,
));
}
}
}
public function ruleDeleted($rid) {
//删除规则时调用,这里 $rid 为对应的规则编号
}
public function settingsDisplay($settings){
global $_GPC, $_W;
load()->func('tpl');
if (checksubmit('submit')) {
$cfg = $settings;
$cfg['album']['listtype'] = $_GPC['album']['listtype'];
$cfg['album']['toppic'] = $_GPC['toppic'];
$cfg['album']['status'] = intval($_GPC['status']);
if ($this->saveSettings($cfg)) {
message('微相册参数保存成功', 'refresh');
}
}
include $this->template('setting');
}
}