mirror of
https://gitee.com/tawords/tawords
synced 2025-09-14 06:11:38 +08:00
45 lines
2.1 KiB
PHP
45 lines
2.1 KiB
PHP
<?php
|
|
/*
|
|
* 组件: 单词展示框
|
|
* 版本号: 1.0.0
|
|
* 修改时间: 2020.08.16
|
|
* 备注: 不可上线,部分信息来源还未确定
|
|
*
|
|
* 调用函数示例:
|
|
* 【show($msg_array)】*/
|
|
// $word_block = new word_block();
|
|
// $word_block -> show($word/*单词*/, true/*显示单词*/, true/*显示音标*/, true/*显示中文*/, true/*显示信息*/, true/*显示刷新按钮*/, true/*显示控制按钮*/);
|
|
?>
|
|
|
|
<?php
|
|
class word_block {
|
|
public function show($word = ""/*单词*/, $word_ = true/*显示单词*/, $phonetic_ = true/*显示音标*/, $translation_ = true/*显示中文*/, $info_ = true/*显示信息*/, $refresh_btn = true/*显示刷新按钮*/, $button_ = true/*显示控制按钮*/) {
|
|
if(!isset($word) || !$word || trim($word) == "") {
|
|
// $word = "congratulations";
|
|
echo '<h2 style="text-align: center;">未查到单词信息,请重试</h2>';
|
|
return;
|
|
} else { ?>
|
|
<!-- 正文开始 -->
|
|
<div id="main" style="text-align: center; width: 100%;">
|
|
<?php
|
|
if($word_)
|
|
require "word.php"; // 单词 & 刷新按钮
|
|
if($phonetic_)
|
|
require "phonetic.php"; // 单词音标
|
|
if($translation_)
|
|
require "translation.php"; // 中文意思
|
|
if($info_)
|
|
require "info.php"; // 单词信息
|
|
|
|
if($refresh_btn) // 刷新按钮
|
|
echo <<<EOF
|
|
<a class="mdui-btn mdui-btn-icon mdui-color-theme mdui-ripple mdui-btn-raised" mdui-tooltip="{content: '刷新'}" onclick="location.reload();"><i class="mdui-icon material-icons">refresh</i></a>
|
|
EOF;
|
|
if($button_)
|
|
require "button.php"; // 控制按钮
|
|
?>
|
|
</div>
|
|
<!--正文结束-->
|
|
<?php }
|
|
}
|
|
}
|