审核
index.php
<?php
use yii\widgets\LinkPager;
?>
<center>
?? ?
?? ?<?php if(empty($res)){
?? ??? ?echo '<a href="http://localhost/copy/frontend/web/index.php?r=joke/login"><button>登錄</button></a><a href="http://localhost/copy/frontend/web/index.php?r=joke/reg"><button>注冊</button></a><br>';
?? ?}else{
?? ??? ?echo "你好,<a href='javascript:;'>".$res[0]['u_name']."</a><br>";
?? ?}
?? ??>
?? ?
?? ?<?php foreach($data as $val){?>
<a href="http://localhost/copy/frontend/web/index.php?r=joke/checkjoke"><button>管理員審核</button></a><a href="http://localhost/copy/frontend/web/index.php?r=joke/addjoke"><button>添加笑話</button></a><br>
<span style="font-size:24px;color:red;"><?=$val['u_name']?></span><br>
?? ?<a href="?r=joke/show&id=<?=$val['jid']?>">查看全文</a><br>
?? ?<div style="width:200px;height:100px;overflow:hidden;text-overflow:ellipsis;">
?? ??? ?<?=$val['comment']?>
?? ?</div>
?? ?
?? ?<p><a href="javascript:;" nowid="<?=$val['jid']?>" class="ding" >(<span class='d'><?=$val['ding_num']?></span>)頂 </a><a href="javascript:;" nowid="<?=$val['jid']?>" class="cai">(<span><?=$val['cai_num']?></span>)踩? </a><a href="javascript:;">(<?=$val['comment_num']?>)評論? </a></p>
<?php } ?>
<!-- 分類 -->
<div style="float:right;margin-top:-300px">
?? ?<form action="?r=joke/search_type" method="post">
?? ?<?php foreach($type as $val){?>
?? ??? ?<input type="checkbox"? name="id[]" value="<?=$val['type_id']?>"><?=$val['type']?><br>
?? ?<?php }?>
?? ?<input type="hidden" name="_csrf" value="<?=Yii::$app->request->getCsrfToken() ?>">
?? ?<input type="submit" value="篩選">
</form>
</div>
?<?= LinkPager::widget(['pagination' => $pages]); ?>
</center>
<script src="js/jquery-1.7.2.min.js"></script>
<script>
$('#bbb').click(function(){
?? ?var aa = $('.www').val();
?? ?alert(aa)
})
?? ?$('.ding').click(function(){
?? ??? ?var nowid=$(this).attr('nowid');//當前文章的id
?? ??? ?var ding_num=$(this).children('span').html();
?? ??? ?var obj=$(this);
?? ??? ?// alert(ding_num)
?? ??? ?$.ajax({
?? ??? ??? ?type:"post",
?? ??? ??? ?url:"http://localhost/copy/frontend/web/index.php?r=joke/ding_do",
?? ??? ??? ?data:{nowid:nowid,ding_num:ding_num},
?? ??? ??? ?success:function(msg){
?? ??? ??? ??? ?// alert(r);
?? ??? ??? ??? ?if(msg==0){
?? ??? ??? ??? ??? ?// alert(a);
?? ??? ??? ??? ??? ?// alert("點贊失敗");
?? ??? ??? ??? ?}else{
?? ??? ??? ??? ??? ?obj.children('span').html(msg);
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?})
?? ?})
?? ?//踩
?? ?$('.cai').click(function(){
?? ??? ?var nowid=$(this).attr('nowid');//當前文章的id
?? ??? ?var cai_num=$(this).children('span').html();
?? ??? ?var obj=$(this);
?? ??? ?// alert(ding_num)
?? ??? ?$.ajax({
?? ??? ??? ?type:"post",
?? ??? ??? ?url:"http://localhost/copy/frontend/web/index.php?r=joke/cai_do",
?? ??? ??? ?data:{nowid:nowid,cai_num:cai_num},
?? ??? ??? ?success:function(msg){
?? ??? ??? ??? ?// alert(r);
?? ??? ??? ??? ?if(msg==0){
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ?}else{
?? ??? ??? ??? ??? ?obj.children('span').html(msg);
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?})
?? ?})
</script>
login。php
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
$form = ActiveForm::begin([
??? 'id' => 'login-form',?? ?
??? 'options' => ['class' => 'form-horizontal'],
??? 'action'=>'?r=joke/login_do',
??? 'method'=>'post'
??? ])
??? ?>
??? <?= $form->field($model, 'username') ?>
??? <?= $form->field($model, 'password')->passwordInput() ?>
??? <div class="form-group">?????? ?
?? ??? ?<div class="col-lg-offset-1 col-lg-11">
??????????? <?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?>
??????? </div>?? ?
??? </div><?php ActiveForm::end() ?>
reg.php
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
$form = ActiveForm::begin([
??? 'id' => 'login-form',?? ?
??? 'options' => ['class' => 'form-horizontal'],
??? 'action'=>'?r=joke/reg_do',
??? 'method'=>'post'
??? ])
??? ?>
??? <?= $form->field($model, 'username') ?>
??? <?= $form->field($model, 'password')->passwordInput() ?>
??? <?= $form->field($model, 'password1')->passwordInput() ?>
??? <div class="form-group">?????? ?
?? ??? ?<div class="col-lg-offset-1 col-lg-11">
??????????? <?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?>
??????? </div>?? ?
</div><?php ActiveForm::end() ?>
show.php
<center>
?<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
??? <script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
??? <script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"> </script>
??? <!--建議手動加在語言,避免在ie下有時因為加載語言失敗導致編輯器加載失敗-->
??? <!--這里加載的語言文件會覆蓋你在配置項目里添加的語言類型,比如你在配置項目里配置的是英文,這里加載的中文,那最后就是中文-->
??? <script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script>
??? <style type="text/css">
??????? div{
??????????? width:100%;
??????? }
??? </style>
<span style="font-size:24px;color:red;"><?=$data['u_name']?></span><br>
?? ?
?? ?<!-- 百度編輯器 -->
?? ?? <script id="editor" type="text/plain" style="width:500px;height:500px;"><?=$data['comment']?></script>
?? ?<p><a href="javascript:;" nowid="<?=$data['jid']?>" class="ding" >(<span class='d'><?=$data['ding_num']?></span>)頂 </a><a href="javascript:;" nowid="<?=$data['jid']?>" class="cai">(<span><?=$data['cai_num']?></span>)踩? </a><a href="">(<?=$data['comment_num']?>)評論? </a></p>
?
</center>
<script src="js/jquery-1.7.2.min.js"></script>
<script>
?? ?$('.ding').click(function(){
?? ??? ?var nowid=$(this).attr('nowid');//當前文章的id
?? ??? ?var ding_num=$(this).children('span').html();
?? ??? ?var obj=$(this);
?? ??? ?// alert(ding_num)
?? ??? ?$.ajax({
?? ??? ??? ?type:"post",
?? ??? ??? ?url:"http://localhost/advanced/frontend/web/index.php?r=joke/ding_do",
?? ??? ??? ?data:{nowid:nowid,ding_num:ding_num},
?? ??? ??? ?success:function(msg){
?? ??? ??? ??? ?// alert(r);
?? ??? ??? ??? ?if(msg==0){
?? ??? ??? ??? ??? ?// alert(a);
?? ??? ??? ??? ??? ?// alert("點贊失敗");
?? ??? ??? ??? ?}else{
?? ??? ??? ??? ??? ?obj.children('span').html(msg);
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?})
?? ?})
?? ?//踩
?? ?$('.cai').click(function(){
?? ??? ?var nowid=$(this).attr('nowid');//當前文章的id
?? ??? ?var cai_num=$(this).children('span').html();
?? ??? ?var obj=$(this);
?? ??? ?// alert(ding_num)
?? ??? ?$.ajax({
?? ??? ??? ?type:"post",
?? ??? ??? ?url:"http://localhost/advanced/frontend/web/index.php?r=joke/cai_do",
?? ??? ??? ?data:{nowid:nowid,cai_num:cai_num},
?? ??? ??? ?success:function(msg){
?? ??? ??? ??? ?// alert(r);
?? ??? ??? ??? ?if(msg==0){
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ?}else{
?? ??? ??? ??? ??? ?obj.children('span').html(msg);
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?})
?? ?})
?? ? //實例化編輯器
??? //建議使用工廠方法getEditor創建和引用編輯器實例,如果在某個閉包下引用該編輯器,直接調用UE.getEditor('editor')就能拿到相關的實例
??? var ue = UE.getEditor('editor');
??? function isFocus(e){
??????? alert(UE.getEditor('editor').isFocus());
??????? UE.dom.domUtils.preventDefault(e)
??? }
??? function setblur(e){
??????? UE.getEditor('editor').blur();
??????? UE.dom.domUtils.preventDefault(e)
??? }
??? function insertHtml() {
??????? var value = prompt('插入html代碼', '');
??????? UE.getEditor('editor').execCommand('insertHtml', value)
??? }
??? function createEditor() {
??????? enableBtn();
??????? UE.getEditor('editor');
??? }
??? function getAllHtml() {
??????? alert(UE.getEditor('editor').getAllHtml())
??? }
??? function getContent() {
??????? var arr = [];
??????? arr.push("使用editor.getContent()方法可以獲得編輯器的內容");
??????? arr.push("內容為:");
??????? arr.push(UE.getEditor('editor').getContent());
??????? alert(arr.join("\n"));
??? }
??? function getPlainTxt() {
??????? var arr = [];
??????? arr.push("使用editor.getPlainTxt()方法可以獲得編輯器的帶格式的純文本內容");
??????? arr.push("內容為:");
??????? arr.push(UE.getEditor('editor').getPlainTxt());
??????? alert(arr.join('\n'))
??? }
??? function setContent(isAppendTo) {
??????? var arr = [];
??????? arr.push("使用editor.setContent('歡迎使用ueditor')方法可以設置編輯器的內容");
??????? UE.getEditor('editor').setContent('歡迎使用ueditor', isAppendTo);
??????? alert(arr.join("\n"));
??? }
??? function setDisabled() {
??????? UE.getEditor('editor').setDisabled('fullscreen');
??????? disableBtn("enable");
??? }
??? function setEnabled() {
??????? UE.getEditor('editor').setEnabled();
??????? enableBtn();
??? }
??? function getText() {
??????? //當你點擊按鈕時編輯區域已經失去了焦點,如果直接用getText將不會得到內容,所以要在選回來,然后取得內容
??????? var range = UE.getEditor('editor').selection.getRange();
??????? range.select();
??????? var txt = UE.getEditor('editor').selection.getText();
??????? alert(txt)
??? }
??? function getContentTxt() {
??????? var arr = [];
??????? arr.push("使用editor.getContentTxt()方法可以獲得編輯器的純文本內容");
??????? arr.push("編輯器的純文本內容為:");
??????? arr.push(UE.getEditor('editor').getContentTxt());
??????? alert(arr.join("\n"));
??? }
??? function hasContent() {
??????? var arr = [];
??????? arr.push("使用editor.hasContents()方法判斷編輯器里是否有內容");
??????? arr.push("判斷結果為:");
??????? arr.push(UE.getEditor('editor').hasContents());
??????? alert(arr.join("\n"));
??? }
??? function setFocus() {
??????? UE.getEditor('editor').focus();
??? }
??? function deleteEditor() {
??????? disableBtn();
??????? UE.getEditor('editor').destroy();
??? }
??? function disableBtn(str) {
??????? var div = document.getElementById('btns');
??????? var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
??????? for (var i = 0, btn; btn = btns[i++];) {
??????????? if (btn.id == str) {
??????????????? UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
??????????? } else {
??????????????? btn.setAttribute("disabled", "true");
??????????? }
??????? }
??? }
??? function enableBtn() {
??????? var div = document.getElementById('btns');
??????? var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
??????? for (var i = 0, btn; btn = btns[i++];) {
??????????? UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
??????? }
??? }
??? function getLocalData () {
??????? alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
??? }
??? function clearLocalData () {
??????? UE.getEditor('editor').execCommand( "clearlocaldata" );
??????? alert("已清空草稿箱")
??? }
</script>
轉載于:https://www.cnblogs.com/ruichenqwe123/p/7094994.html
總結
- 上一篇: jquery-easyui环境的搭建及测
- 下一篇: 05_传智播客iOS视频教程_类对象的使