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
<?php
//加载
require_once ("../manager_include.inc");
// 参数取得
$theme_id = ParamUtil::getRequestNumber("theme_id", 0);
$word_id = ParamUtil::getRequestNumber("word_id", 0);
$operate = ParamUtil::getRequestString("operate");
if($theme_id==0 || $word_id==0) {
exit;
}
//添加
if($operate == "add") {
//检查是否已经存在
$param = array();
$param["theme_id"] = $theme_id;
$param["word_id"] = $word_id;
$param["delete_flg"] = false;
$theme_word_list = WordThemeDat::getList($param, "display_order", "asc", 0, 1);
if(empty($theme_word_list)) {
$word_count = WordHandler::getWordCount($theme_id);
$theme_word_dat = new WordThemeDat();
$theme_word_dat->theme_id = $theme_id;
$theme_word_dat->word_id = $word_id;
$theme_word_dat->display_order = $word_count + 1;
$theme_word_dat->save();
}
}
//删除
if($operate == "remove") {
$param = array();
$param["theme_id"] = $theme_id;
$param["word_id"] = $word_id;
$param["delete_flg"] = false;
$theme_word_list = WordThemeDat::getList($param, "display_order", "asc", 0, 1);
if(!empty($theme_word_list)) {
$theme_word_list[0]->delete_flg = true;
$theme_word_list[0]->save();
}
}
//查找已经设定的单词列表
$param = array();
$param["theme_id"] = $theme_id;
$param["delete_flg"] = false;
$theme_word_list = WordThemeDat::getList($param, "display_order", "asc");
ob_start()
?>
<?
if(!empty($theme_word_list)) {
$index = 0;
foreach($theme_word_list as $theme_word) {
$index++;
$word_dat = WordDat::getById($theme_word->word_id);
?>
<div class="theme_word_item" onClick="removeWord('<?=$theme_id?>','<?=$theme_word->word_id?>');"><?=$index?>.<?=$word_dat->word?></div>
<?
}
}
?>
<?
$html = ob_get_contents();
ob_end_clean();
print json_encode(array("html"=>$html));