zodiac 信息修改保存; ace版本?

hotfix/远程访问多媒体中心
lyt 8 years ago
parent bcaf99d015
commit 0f51fc1ae7

@ -7,18 +7,36 @@ class Zodiac extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('LunarNewYear_model');
}
public function index()
public function index($z='rat')
{
# code...
$this->edit_zodiac(mb_strtolower($z));
}
public function edit_zodiac()
public function edit_zodiac($z='rat')
{
$data['nav_view'] = $this->load->view('bootstrap/zodiac/nav', array('nav_active' => ''), true);
$data['nav_active'] = $data["current_zodiac"] = mb_strtolower($z);
$data["zodiac_fortune"] = $this->LunarNewYear_model->get_zodiac($data["current_zodiac"]);
// 预览编辑的问题
if (substr($data["zodiac_fortune"]->TheYearFortune, 0, 4) !== '<div') {
$data["zodiac_fortune"]->TheYearFortune = "<div>" . $data["zodiac_fortune"]->TheYearFortune . "</div>";
}
$this->load->view('bootstrap/header', $data);
$this->load->view('bootstrap/zodiac/edit',$data);
}
public function fortune_save()
{
$this->LunarNewYear_model->LNY_SX = trim($this->input->post("sx"));
$this->LunarNewYear_model->LNY_LuckyNumber = trim($this->input->post("lucky_num"));
$this->LunarNewYear_model->LNY_LuckyColor = trim($this->input->post("lucky_color"));
$this->LunarNewYear_model->LNY_LuckyFlower = trim($this->input->post("lucky_flo"));
$this->LunarNewYear_model->TheYearFortune = trim($this->input->post("theyearfortune"));
$this->LunarNewYear_model->theyearfortune_save();
$ret = array("name"=>"ok");
$this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
}

@ -0,0 +1,48 @@
<?php
class LunarNewYear_model extends CI_Model {
public $LNY_SX;
public $LNY_LuckyNumber;
public $LNY_LuckyColor;
public $LNY_LuckyFlower;
public $TheYearFortune;
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
public function get_zodiac($zodiac = 'rat')
{
$sql = "SELECT TOP 1 LNY_SN ,
LNY_SX ,
LNY_LuckyNumber ,
LNY_LuckyColor ,
LNY_LuckyFlower ,
TheYearFortune
FROM LunarNewYear
WHERE LOWER(LNY_SX)='$zodiac'";
$query = $this->HT->query($sql);
return $query->row();
}
public function theyearfortune_save()
{
$sql = "UPDATE LunarNewYear
SET LNY_LuckyNumber = ?,
LNY_LuckyColor = ?,
LNY_LuckyFlower = ?,
TheYearFortune = ?
WHERE LOWER(LNY_SX) = ?";
$query = $this->HT->query($sql, array(
$this->LNY_LuckyNumber,
$this->LNY_LuckyColor,
$this->LNY_LuckyFlower,
$this->TheYearFortune,
$this->LNY_SX
));
return $query;
}
}

@ -18,37 +18,35 @@ border-top: 1px solid #ccc;
</style>
<div class="row-fluid">
<div class="span2">
<?php echo $nav_view; ?>
<?php include 'nav.php'; ?>
</div>
<div class="span10 " style="padding-right:20px;">
<legend>编辑运势信息</legend>
<form action="" method="POST" class="form-inline" role="form">
<legend>编辑运势信息 - <?php echo $current_zodiac ?></legend>
<form action="<?php echo site_url('zodiac/fortune_save') ?>" method="POST" class="form-inline" role="form" name="zodiac_edit" id="zodiac_edit">
<input type="hidden" name="sx" value="<?php echo $current_zodiac ?>">
<div class="form-group">
<label class="sr-only" for="">幸运数字</label>
<input type="email" class="form-control" id="" name="lucky_num" placeholder="2, 3">
<input type="text" class="form-control" id="" name="lucky_num" placeholder="2, 3" value="<?php echo $zodiac_fortune->LNY_LuckyNumber ?>">
</div>
<div class="form-group">
<label class="sr-only" for="">幸运色</label>
<input type="email" class="form-control" id="" name="lucky_color" placeholder="blue, gold, green">
<input type="text" class="form-control" id="" name="lucky_color" placeholder="blue, gold, green" value="<?php echo $zodiac_fortune->LNY_LuckyColor ?>">
</div>
<div class="form-group">
<label class="sr-only" for="">幸运花</label>
<input type="email" class="form-control" id="" name="lucky_flo" placeholder="tulip, sacred lily">
<input type="text" class="form-control" id="" name="lucky_flo" placeholder="tulip, sacred lily" value="<?php echo $zodiac_fortune->LNY_LuckyFlower ?>">
</div>
<div class="form-group">
<input type="hidden" name="theyearfortune" id="theyearfortune">
<label class="sr-only" for="">运势</label>
<div id="toolbar-container">
<div id="editor-toolbar">
<div id="code-btn" class="w-e-menu code-menu" data-i=1 style="z-index:10001;">
<i class="w-e-icon-terminal"><i>
</i></i></div>
</div>
<!-- view -->
<div id="editor">
<div>
<h2>Fortune in 2017 — Great Effort Will Be Rewarded</h2>
The lucky star will not help Goats increase their fortunes in 2017. Youll need to expend great effort in order to be rewarded. Itll be a year of <strong>learning and study</strong> for Goats. You are recommended to learn new skills — skills sure to help in your future development.<strong>Business people, 2017 will be a good year for you</strong> if you are planning to expand your markets. You will take business trips frequently in order to expand.You will have a chance to make a fortune. But you are recommended <strong>not to set foot in unfamiliar fields</strong> and you should weigh things up very carefully before you decide to invest.You will have an opportunity to make <strong>unexpected gains</strong> on foreign stocks and shares, or foreign currencies. But youll have to consider your own situation carefully, along with fluctuations in economics and exchange rates.
</div>
<!-- custom toolbar -->
<?php include 'editor_toolbar.php'; ?>
<!-- view screen -->
<div id="editor" style="z-index: 1;">
<!-- <div> -->
<?php echo $zodiac_fortune->TheYearFortune ?>
<!-- </div> -->
</div>
<!-- code screen -->
<div id="code-screen" class="none"></div>
@ -57,14 +55,34 @@ border-top: 1px solid #ccc;
<div class="form-group">
</div>
<div>
<button type="submit" class="btn btn-primary">提交</button>
<input type="buttn" class="btn btn-primary" onclick="zodiac_sub()" value="提交">
</div>
</form>
</div>
</div>
<!-- 模态框Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">模态框Modal标题</h4>
</div>
<div class="modal-body">按下 ESC 按钮退出。</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary">提交更改</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<script src="/js/ace-editor-src/ace.js"></script>
<script src="/js/ace-editor-src/ext-language_tools.js"></script>
<script src="/js/ace-editor-src/ext-beautify.js"></script>
<script type="text/javascript">
<script defer type="text/javascript">
var E = window.wangEditor
// E(菜单, 编辑区)
var editor = new E('#editor-toolbar', '#editor')
@ -81,15 +99,9 @@ editor.customConfig.menus = [
'redo'
]
editor.create()
// 获取使用到的元素
var toolbarContaner = document.getElementById('toolbar-container')
var editorText = document.getElementById('editor-text')
var cover = document.getElementById('cover')
// var container = document.getElementById('container')
// turn code
function doCodeScreen() {
// alert(editor.txt.html());
code_editor.setValue(editor.txt.html());
$(".w-e-menu").hide();
$(".code-menu").show();
@ -117,6 +129,25 @@ codebtn.addEventListener('click', function () {
}
}, false)
function zodiac_sub() {
if (isCodeScreen == true) {
$("#theyearfortune").val(code_editor.getValue());
} else {
$("#theyearfortune").val(editor.txt.html());
}
$('#zodiac_edit').ajaxSubmit({
success:function() {
alert("提交成功")
},
error: function() {
alert("失败,请重试")
},
dataType: 'json',
timeout: 30000
});
return false;
}
// code >>
ace.require("ace/ext/language_tools");
var code_editor = ace.edit("code-screen");

@ -0,0 +1,5 @@
<div id="editor-toolbar">
<div id="code-btn" class="w-e-menu code-menu" data-i=1 style="z-index:10001;">
<i class="w-e-icon-terminal"><i></i></i>
</div>
</div>

@ -14,12 +14,4 @@
<li class="<?php echo $nav_active=='pig'?'active':false; ?>"><a href="<?php echo site_url('zodiac/index/pig'); ?>"></a></li>
<li class="divider"></li>
<li class="nav-header">生肖速配</li>
<li class="<?php echo $nav_active=='author_list'?'active':false; ?>"><a href="<?php echo site_url('author/author_list'); ?>">作者列表<?php $un_active_count=un_active_count(); if($un_active_count>0){ ?> <span class="label"><?php echo $un_active_count;?></span><?php } ?></a></li>
<li class="hide <?php echo $nav_active=='unactive_author_list'?'active':false; ?>"><a href="<?php echo site_url('author/unactive_author_list'); ?>">待审核作者</a></li>
<li class="divider"></li>
<li class="nav-header">公告管理</li>
<li class="<?php echo $nav_active=='announce_list'?'active':false; ?>"><a href="<?php echo site_url('author/announce_list'); ?>">公告列表</a></li>
<li class="<?php echo $nav_active=='announce_edit'?'active':false; ?>"><a href="<?php echo site_url('author/announce_edit'); ?>">新建公告</a></li>
</ul>

Loading…
Cancel
Save