<?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));