<?php
/**
 * 单词列表
 * $Id: product_category_list.inc,v 1.1 2015/10/08 11:18:53 wanggb Exp $
 * @author zhouhj
 * @access public
 * @package manager.templates
 */

?>
<script type="text/javascript">
    function copyToClipBoard(copyCotent) {
        document.addEventListener('copy', save); // 监听浏览器copy事件
        document.execCommand('copy'); // 执行copy事件，这时监听函数会执行save函数。
        document.removeEventListener('copy', save); // 移除copy事件

        // 保存方法
        function save(e) {
            e.clipboardData.setData('text/plain', copyCotent); // 剪贴板内容设置
            e.preventDefault();
        }
    }
</script>
<b>词集列表</b><br />
<br />
<form name="search_input" method="post" action="?">
	<table>
		<tr>
			<td>系列</td>
			<td>
				<select name="theme_type">
					<?
						foreach ($theme_type_list as $theme_type_obj) {
					?>
						<option value="<?=$theme_type_obj->id ?>"<?=$theme_type_obj->id == $theme_type ? " selected " : "" ?>><?=$theme_type_obj->title ?></option>
					<?
						}
					?>
				</select>
			</td>
			<td><input type="button" value="搜索" onclick="searchWordTheme()" /></td>
		</tr>
	</table>
</form>
<a class="flatbutton" href="word_theme_edit.php">添加词集</a>
<br /><br />
<div id="result_list">
	<table>
		<tr>
			<th class="contents_title" width="12%">类型</th>
			<th class="contents_title" width="12%">名称</th>
			<th class="contents_title" width="15%">封面</th>
			<th class="contents_title" width="10%">排序</th>
			<th class="contents_title" width="10%">单词数量</th>
			<th class="contents_title" width="25%">备注</th>
			<th class="contents_title">操作</th>
		</tr>

		<?
		if (count($word_theme_list) > 0) {
			foreach ($word_theme_list as $word_theme_mst) {
				$word_count = WordHandler::getWordCount($word_theme_mst->id);
				$url = "http://" . HOST_NAME . "/words.php?theme_id=" . $word_theme_mst->id;
				
				$theme_type_title = WordThemeType::getTitleById($word_theme_mst->theme_type);
		?>
				<tr>
					<td align="center"><?=$theme_type_title ?></td>
					<td align="center"><?=$word_theme_mst->title ?></td>
					<td align="center">
						<?
							if(!empty($word_theme_mst->front)) {
						?>
						<img src="<?=KoalaHandler::getImageUrl($word_theme_mst->front, "theme", "") ?>" style="width:60px;" />
						<?
							}
						?>
					</td>
					<td align="center">
						<a class="flatbutton" href="word_theme_change_display_order.php?id=<?=$word_theme_mst->id ?>&type=up">↑</a>
						<a class="flatbutton" href="word_theme_change_display_order.php?id=<?=$word_theme_mst->id ?>&type=down">↓</a>
					</td>
					<td align="center"><?=$word_count ?></td>
					<!--
					<td align="left">
						<?=$url?>
						<input type="button" value="复制" class="button_width_normal" onClick="copyToClipBoard('<?=$url?>');"/>
					</td>
					-->
					<td align="left"><?=htmlspecialchars($word_theme_mst->comment) ?></td>
					<td align="center">
						<a class="flatbutton" href="word_theme_edit.php?id=<?=$word_theme_mst->id ?>">编集</a>
						<a class="flatbutton" href="word_theme_dat_edit.php?id=<?=$word_theme_mst->id ?>">单词设定</a>
					</td>
				</tr>
				<?
			}
		}
		?>
	</table>
</div>