Merge branch 'AMP编辑器'

hotfix/远程访问多媒体中心
尹诚诚 8 years ago
commit 179e1172be

@ -0,0 +1,62 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Amp extends CI_Controller {
function __construct() {
parent::__construct();
$this->permission->is_admin();
//$this->output->enable_profiler(TRUE);
$this->load->model('Information_model');
$this->load->model('InfoMetas_model');
}
public function index() {
$data = array();
$this->load->view('bootstrap3/header', $data);
$this->load->view('amp_editor');
$this->load->view('bootstrap3/footer');
}
public function edit($ic_id) {
$data = array();
$data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
if ($data['information'] == FALSE) {
show_404();
}
$this->load->view('bootstrap3/header', $data);
$this->load->view('amp_editor');
$this->load->view('bootstrap3/footer');
}
public function edit_save() {
$data = array();
$ic_id = $this->input->post('ic_id');
$textarea_htmlcode = $this->input->post('textarea_htmlcode');
$amp_status = $this->input->post('amp_status');
$data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
if ($data['information'] == FALSE) {
show_404();
}
$amp = $this->InfoMetas_model->get($ic_id, 'AMP');
if ($amp === false) {
$this->InfoMetas_model->add($ic_id, 'AMP', $textarea_htmlcode);
} else {
$this->InfoMetas_model->update($ic_id, 'AMP', $textarea_htmlcode);
}
$amp_status_value = $this->InfoMetas_model->get($ic_id, 'AMP_STATUS');
if ($amp_status_value === false) {
$this->InfoMetas_model->add($ic_id, 'AMP_STATUS', $amp_status);
} else {
$this->InfoMetas_model->update($ic_id, 'AMP_STATUS', $amp_status);
}
$data[] = array('name' => 'ok', 'value' => $this->lang->line('form_info_success'));
echo json_encode($data);
}
}

@ -0,0 +1,85 @@
<style>
.preview_box {
float: left;
width:375px;
height:600px;
margin-top:8px;
}
.code_editor {
overflow: hidden;
height:600px;
margin-top:8px;
}
</style>
<div class="container-fluid">
<div class="row">
<div class="preview_box" id="iframe_box" ></div>
<div class="code_editor" id="editor"></div>
</div>
<hr/>
<form name="form_amp_code" id="form_amp_code" method="post" action="<?php echo site_url('amp/edit_save') ?>">
<textarea id="textarea_htmlcode" name="textarea_htmlcode" style="display: none;"><?php echo get_meta($information->ic_id, 'AMP'); ?></textarea>
<input type="hidden" name="ic_id" value="<?php echo $information->ic_id; ?>" />
<div class="row">
<div class="col-sm-13" ><a href="https://validator.ampproject.org/" target="_blank">AMP代码验证</a></div>
<div class="col-sm-3">
<select name="amp_status" id="amp_status" class="form-control" >
<option value="0" <?php echo get_meta($information->ic_id, 'AMP_STATUS') === '0' ? 'selected' : FALSE; ?> >不发布</option>
<option value="1" <?php echo get_meta($information->ic_id, 'AMP_STATUS') === '1' ? 'selected' : FALSE; ?> >发布</option>
</select>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-primary" onclick="submit_amp_editor();">保存</button>
</div>
<div class="col-sm-4"> <button type="button" class="btn btn-default" onclick="meta('delete', '<?php echo $information->ic_id; ?>', 'AMP', ''); meta('delete', '<?php echo $information->ic_id; ?>', 'AMP_STATUS', '');">删除</button> </div>
</div>
</form>
<hr/>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/eclipse");
editor.session.setMode("ace/mode/html");
editor.setOptions({
autoScrollEditorIntoView: true,
wrap: true
});
editor.getSession().on('change', function (e) {
update_preview();
});
editor.session.setValue($('#textarea_htmlcode').html($('#textarea_htmlcode').html()).text());
function update_preview() {
//考虑做成异步操作,降低页面卡顿
var iframe = document.createElement('iframe');
iframe.setAttribute('frameBorder', '0');
iframe.setAttribute('id', 'previewIframe');
iframe.setAttribute('height', '100%');
iframe.setAttribute('width', '100%');
iframe.setAttribute('name', 'AMP Playground Output');
$('#iframe_box').html('');
$('#iframe_box').append(iframe);
var doc = iframe.contentDocument || iframe.document;
doc.open();
doc.write(editor.getValue());
doc.close();
}
function submit_amp_editor() {
$('#textarea_htmlcode').text(editor.getValue()).html();
submitForm('form_amp_code');
}
</script>

@ -1,4 +1,4 @@
<?php // 代码各服务器已经同步 2016.06.01 ycc ?>
<?php // 代码各服务器已经同步 2016.06.01 ycc ?>
<script src="/js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var content_length = 0;
@ -65,12 +65,12 @@
sObj.append(addStr);
var btn = $("#addBtn_" + treeNode.id);
if (btn)
btn.bind("click", function() {
btn.bind("click", function () {
var urlReQuery = "<?php echo site_url('information/add/'); ?>";
$.ajax({
type: "get",
url: urlReQuery + '/' + treeNode.id,
success: function(data, textStatus) {
success: function (data, textStatus) {
var dataArray = $.parseJSON(data);//JSON.parse(data);
for (var key in dataArray) {
if (dataArray[key].name == 'ok') {
@ -82,7 +82,7 @@
}
}
},
error: function() {
error: function () {
alert('发生错误请联系YCC');
}
});
@ -138,10 +138,10 @@
type: "post",
url: urlReQuery,
data: {'pid': treeNodes[0].getParentNode().id, 'ids': idStr},
success: function(data, textStatus) {
success: function (data, textStatus) {
return true;
},
error: function() {
error: function () {
$.modaldialog.error('发生错误请联系YCC');
return false;
}
@ -160,11 +160,11 @@
type: "post",
url: urlReQuery,
data: {'is_id': is_id, 'is_parent_id': is_parent_id},
success: function(data, textStatus) {
success: function (data, textStatus) {
window.location.href = "<?php echo site_url('information/edit'); ?>/" + is_id;
return true;
},
error: function() {
error: function () {
$.modaldialog.error('发生错误请联系YCC');
return false;
}
@ -180,12 +180,12 @@
$.ajax({
type: "get",
url: urlReQuery + '/' + is_id,
success: function(data, textStatus) {
success: function (data, textStatus) {
var dataArray = $.parseJSON(data);//JSON.parse(data);
for (var key in dataArray) {
if (dataArray[key].name == 'ok') {
$.modaldialog.success('删除成功!,程序正在刷新...');
setTimeout(function() {
setTimeout(function () {
window.location.href = dataArray[key].value;
}, 500);
return true;
@ -195,7 +195,7 @@
}
}
},
error: function() {
error: function () {
$.modaldialog.error('发生错误请联系YCC');
return false;
}
@ -278,7 +278,7 @@
dataType: "json",
url: "<?php echo site_url('information/get_products/'); ?>",
data: {'product_type': product_type, 'product_name': product_name},
success: function(data, textStatus) {
success: function (data, textStatus) {
for (var key in data) {
if (data[key].name == 'ok') {
$("#product_list_ul").html(data[key].value);
@ -286,7 +286,7 @@
}
}
},
error: function() {
error: function () {
$.modaldialog.error('发生错误请联系YCC');
return false;
}
@ -315,7 +315,7 @@
$.ajax({
type: "get",
url: urlReQuery + '/' + area_id + '/' + lsi_sn,
success: function(data, textStatus) {
success: function (data, textStatus) {
var dataArray = $.parseJSON(data);//JSON.parse(data);
for (var key in dataArray) {
if (dataArray[key].name == 'ok') {
@ -327,7 +327,7 @@
}
}
},
error: function() {
error: function () {
$.modaldialog.error('发生错误请联系YCC');
return false;
}
@ -365,13 +365,13 @@
$(elem).popover({
'container': container,
'title': 'title',
'content': function() {
'content': function () {
},
'placement': 'bottom',
'trigger': 'click',
'template': '<div class="popover recommend_info_popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title hidden"></h3><div class="popover-content" style="width:500px;"></div><div class="col-xs-24" style="background:#eee;padding: 8px 10px;margin-top: -19px;border-bottom:1px solid #ddd;"><div class="col-xs-22" style="padding-left:0;"><div class="input-group"><input type="text" class="form-control" id="article_key" name="article_key" placeholder="文章URL、标题或关键词"><span class="input-group-btn"><button class="btn btn-default" id="btn_search_article_list" type="button">搜索</button></span></div></div><div class="col-xs-2" style="border-left:1px solid #bbb;height:32px;line-height:38px;font-size:18px;"><a href="javascript:void(0);" onclick="$(\'#meta_recommend_info\').popover(\'hide\');$(\'#meta_related_info\').popover(\'hide\');$(\'#meta_bread_info\').popover(\'hide\');" class="glyphicon glyphicon-remove text-danger"></a></div></div><div class="col-xs-24" id="recommended_list"></div><div class="col-xs-24" id="recommend_list" style="padding-left:0;"></div></div>'
});
$(elem).on('shown.bs.popover', function() {
$(elem).on('shown.bs.popover', function () {
var right_offset = document.documentElement["clientWidth"] - $(elem)[0].getBoundingClientRect().right;
if (right_offset < 300) {
$(elem).next(".recommend_info_popover").attr('style', "left:" + (-(400 - right_offset)) + "px !important;display: block;");
@ -384,39 +384,39 @@
;
$("#recommended_list").html('<img src="/css/images/loading.gif" >');
var url = "<?php echo site_url('/welcome/search_by_icid/'); ?>";
$.post(url, {"ic_id_list": ic_id_list}, function(html) {
$.post(url, {"ic_id_list": ic_id_list}, function (html) {
$("#recommended_list").html(html);
});
}).on('hidden.bs.popover', function() {
setTimeout(function() {
}).on('hidden.bs.popover', function () {
setTimeout(function () {
$(".recommend_info_popover").remove();
}, 0);
});
$("body").on("click", "#btn_search_article_list", function() {
$("body").on("click", "#btn_search_article_list", function () {
$("#recommend_list").html('<img src="/css/images/loading.gif" >');
var url = "<?php echo site_url('/welcome/search/1'); ?>";
var key = $("#article_key").val();
var ic_id_list = $(elem).val();
$.post(url, {'keywords': key, "ic_id_list": ic_id_list}, function(html) {
$.post(url, {'keywords': key, "ic_id_list": ic_id_list}, function (html) {
$("#recommend_list").html(html);
});
});
}
//初始化树形菜单
$(document).ready(function() {
$("#history_log_toggle").hover(function() {
$(document).ready(function () {
$("#history_log_toggle").hover(function () {
$(".history_log").css({"display": "block"});
}, function() {
}, function () {
});
$(".history_log").hover(function() {
$(".history_log").hover(function () {
},
function() {
function () {
$(".history_log").css({"display": "none"});
});
setTimeout(function() {
setTimeout(function () {
$("#treeDemo").css({"overflow-y": "hidden"});
}, 100);
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
@ -448,13 +448,13 @@
init_recommend_popover("#meta_bread_info", ".meta_bread_info_box");
//自动读取google网页性能评分
setTimeout(function() {
setTimeout(function () {
mobile_friendly(), 1000
});
});
var editor;
KindEditor.ready(function(K) {
KindEditor.ready(function (K) {
editor = K.create('#ic_content', {
width: '100%',
height: '560px',
@ -468,7 +468,7 @@
'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', '|',
'clearhtml', 'removeformat', '|', 'plainpaste', 'wordpaste', '|', 'table', 'hr', 'image', 'template', 'link', 'unlink', 'mediacits', 'character', 'undo', 'source', 'fullscreen'
],
afterChange: function() {
afterChange: function () {
K('#display_count').html(getWordCount(editor.text()));
content_length = this.count('text');
$("iframe.ke-edit-iframe").contents().find(".ke-content").css({"padding-right": "25px", "padding-top": "12px"});
@ -479,28 +479,28 @@
//新闻日历
$(function() {
$(function () {
$("#meta_news_createdate").datepicker({
showButtonPanel: true
});
})
//节庆开始日期
$(function() {
$(function () {
$("#meta_festival_start").datepicker({
showButtonPanel: true
});
})
//节庆结束日期
$(function() {
$(function () {
$("#meta_festival_end").datepicker({
showButtonPanel: true
});
})
//团购结束时间
$(function() {
$(function () {
$("#meta_groupon_end").datepicker({
showButtonPanel: true
});
@ -535,12 +535,19 @@
<label>
信息标题 &nbsp;
<?php if (is_series_site()) { ?>
<button type="button" class="btn btn-xs none" data-toggle="modal" data-target="#tagM">
+ 标签(国际站)
</button>
<button type="button" class="btn btn-xs none" data-toggle="modal" data-target="#tagM">
+ 标签(国际站)
</button>
<?php } ?>
</label>
</div>
<div class="col-xs-17 text-right">
<?php if(get_meta($information->ic_id, 'AMP_STATUS') === '1'){ ?>
<label title="AMP页面编辑"><a href="<?php echo site_url('amp/edit/'.$information->ic_id); ?>" target="_blank"><i class="glyphicon glyphicon-flash"></i></a></label>
<?php }else{ ?>
<label title="创建AMP页面"><a href="<?php echo site_url('amp/edit/'.$information->ic_id); ?>" target="_blank"><i class="glyphicon glyphicon-plus"></i></a></label>
<?php } ?>
</div>
<div class="col-xs-24">
<input class="form-control" type="text" id="ic_title" style="<?php if ($embody == 1) echo 'border-color:green;'; ?>" name="ic_title" value="<?php echo $information->ic_title; ?>" >
</div>
@ -558,7 +565,7 @@
<a href="javascript:void(0);" onclick="goto_page();" id="goto_page_button" name="goto_page_button" target="_blank" title="查看" ><i class="glyphicon glyphtext-muted glyphicon glyphicon-eye-open text-muted"></i></a>
<?php if ($information->ic_sitecode == 'cht') { ?>
<a href="javascript:void(0);" onclick="goto_test_page();" id="goto_test_page_button" name="goto_test_page_button" target="_blank" title="查看测试页面" ><i class="glyphicon glyphtext-muted glyphicon glyphicon-random text-muted"></i></a>
<?php } ?>
<?php } ?>
</div>
<input class="form-control col-xs-24" type="text" id="ic_url" name="ic_url" value="<?php echo $information->ic_url; ?>" >
</div>
@ -715,7 +722,7 @@
</div>
<?php if ($information->ic_sitecode == 'cht') { ?>
<?php if ($information->ic_sitecode == 'cht') { ?>
<div class="row">
<div class="col-sm-5">
@ -798,7 +805,7 @@
</div>
<?php } ?>
<?php } ?>
<label>信息备注
@ -891,7 +898,7 @@
</div>
<?php if (is_series_site()) { ?>
<?php if (is_series_site()) { ?>
<div class="row">
<div class="col-sm-8">
<label>机票目的地
@ -932,7 +939,7 @@
<option selected="selected" value="<?php echo $meta_subnavi; ?>"><?php echo $meta_subnavi_arr[$meta_subnavi]; ?></option>
<?php } else { ?>
<option selected="selected" value="info"><?php echo $meta_subnavi_arr['info']; ?></option>
<?php } ?>
<?php } ?>
<option value="index"><?php echo($meta_subnavi_arr['index']); ?></option>
<option value="tour"><?php echo($meta_subnavi_arr['tour']); ?></option>
<option value="dest"><?php echo($meta_subnavi_arr['dest']); ?></option>
@ -964,7 +971,7 @@
<?php } else { ?>
<option value="noshow">不显示</option>
<option selected="selected" value="show">显示</option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="col-sm-8">
@ -975,7 +982,7 @@
</label>
<input name="meta_top_img" id="meta_top_img" type="text" class="form-control" value="<?php echo get_meta($information->ic_id, 'meta_top_img'); ?>" />
</div>
<?php if ($information->ic_ht_area_type == 'err') { ?>
<?php if ($information->ic_ht_area_type == 'err') { ?>
<div class="col-sm-8">
<label>自定义样式
<a href="javascript:void(0);" onclick="meta('delete', '<?php echo $information->ic_id; ?>', 'meta_my_class', $('#meta_my_class').val())"><i class="text-muted glyphicon glyphicon-remove"></i></a>
@ -997,11 +1004,11 @@
</label>
<input class="form-control" type="text" name="meta_z_res" value="<?php echo get_meta($information->ic_id, 'meta_z_res'); ?>" id="meta_z_res"/>
</div>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php if ($information->ic_ht_area_type == 'g') { ?>
<?php if ($information->ic_ht_area_type == 'g') { ?>
<div class="row">
@ -1042,7 +1049,7 @@
</div>
</div>
<?php } ?>
<?php } ?>
<div class="row">
<div class="col-sm-5">
<label>展示打赏功能
@ -1116,9 +1123,9 @@
$value == $information->ic_type ? $select_str = 'selected' : $select_str = '';
?>
<option <?php echo $select_str; ?> value="<?php echo $value; ?>" ><?php echo $key; ?></option>
<?php } ?>
<?php } ?>
</select>
<?php if ($rootInformation->ic_ht_area_type == 'pd') { ?>
<?php if ($rootInformation->ic_ht_area_type == 'pd') { ?>
<div id="bind_product_code">
<br/>
<div class="input-group">
@ -1127,7 +1134,7 @@
<a href="javascript:void(0);" class="input-group-addon" onclick="meta('delete', '<?php echo $information->ic_id; ?>', 'meta_product_code', $('#meta_product_code').val())"><i class="text-muted glyphicon glyphtext-muted glyphicon glyphicon-remove"></i></a>
</div>
</div>
<?php } ?>
<?php } ?>
<label style="width:48px;">模板</label>
<select name="ic_template" id="ic_template" class="form-control">
<?php
@ -1135,7 +1142,7 @@
$value == $information->ic_template ? $select_str = 'selected' : $select_str = '';
?>
<option <?php echo $select_str; ?> value="<?php echo $value; ?>" ><?php echo $key; ?></option>
<?php } ?>
<?php } ?>
</select>
<label>是否作为面包屑显示</label>
@ -1190,13 +1197,13 @@
<input type="checkbox" name="ignore_url_check" id="ignore_url_check" />忽略URL重复
</label>
<div class="clearfix"></div>
<?php if (is_series_site() || ($this->config->item('site_code') == 'ah') || ($this->config->item('site_code') == 'gm') ) { ?>
<?php if (is_series_site() || ($this->config->item('site_code') == 'ah') || ($this->config->item('site_code') == 'gm')) { ?>
<label class="col-xs-24">本站会自动更新静态页面</label>
<?php } else { ?>
<?php } else { ?>
<label class="checkbox col-xs-24" style="font-weight: normal;margin-top:0;padding-left: 21px;">
<input type="checkbox" name="auto_update_cache_checkbox" id="auto_update_cache_checkbox" onclick="get_update_cache_url();" value="<?php echo $information->ic_url; ?>" />静态更新
</label>
<?php } ?>
<?php } ?>
<div class="clearfix"></div>
<p class="col-xs-24 nopadding">
@ -1234,7 +1241,7 @@
<ul class="dropdown-menu history_log" style="right: 157px;left: inherit;top: 83px;">
<?php foreach ($content_backup_list as $item) { ?>
<li><a href="<?php echo site_url('information/backup_content/' . $item->log_id); ?>" target="_blank"><?php echo $item->log_datetime ?>, <?php echo $item->log_ht_username ?></a></li>
<?php } ?>
<?php } ?>
</ul>
</li>
</ul>
@ -1263,30 +1270,30 @@
<?php //标签模态框 ?>
<div class="modal fade" id="tagM" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<style type="text/css">
.tagLabel {background: #eee;padding: 5px 15px 5px 35px!important;border-radius: 5px;border: 1px solid #aaa; margin-right:2px;box-shadow: 0px 0px 2px #ddd;}
.myTag {background: #d2eafb; color:#108ee9; border-color: #108ee9;}
.tagLabel.newLabel {padding: 5px 10px!important;border: 1px dashed #000;}
.tagLabel {background: #eee;padding: 5px 15px 5px 35px!important;border-radius: 5px;border: 1px solid #aaa; margin-right:2px;box-shadow: 0px 0px 2px #ddd;}
.myTag {background: #d2eafb; color:#108ee9; border-color: #108ee9;}
.tagLabel.newLabel {padding: 5px 10px!important;border: 1px dashed #000;}
</style>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">添加标签</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">添加标签</h4>
</div>
<div class="modal-body">
<div class="checkbox">
<?php foreach ($my_tags as $tag) { ?>
<label class="tagLabel myTag">
<input type="checkbox" value="<?php echo($tag->it_title)?>" data-it-id="<?php echo($tag->it_id)?>" checked>
<span><?php echo($tag->it_title)?></span>
<input type="checkbox" value="<?php echo($tag->it_title) ?>" data-it-id="<?php echo($tag->it_id) ?>" checked>
<span><?php echo($tag->it_title) ?></span>
</label>
<?php } ?>
</div>
<div class="checkbox">
<?php foreach ($all_tags as $tag) { ?>
<label class="tagLabel">
<input type="checkbox" value="<?php echo($tag->it_title)?>" data-it-id="<?php echo($tag->it_id)?>">
<span><?php echo($tag->it_title)?></span>
<input type="checkbox" value="<?php echo($tag->it_title) ?>" data-it-id="<?php echo($tag->it_id) ?>">
<span><?php echo($tag->it_title) ?></span>
</label>
<?php } ?>
<label class="tagLabel newLabel">
@ -1303,33 +1310,33 @@
</div>
<script type="text/javascript">
//标签更新
$('[data-it-id]').on('change', function() {
$('[data-it-id]').on('change', function () {
if ($(this).is(':checked')) {
$.post('/info.php/info_tags/add_tag_to_content/', {
'it_id' : $(this).attr('data-it-id'),
'ic_id' : <?php echo $information->ic_id; ?>,
'it_id': $(this).attr('data-it-id'),
'ic_id': <?php echo $information->ic_id; ?>,
});
$(this).parent().addClass('myTag');
} else {
$.post('/info.php/info_tags/remove_tag_to_content/', {
'it_id' : $(this).attr('data-it-id'),
'ic_id' : <?php echo $information->ic_id; ?>,
'it_id': $(this).attr('data-it-id'),
'ic_id': <?php echo $information->ic_id; ?>,
});
$(this).parent().removeClass('myTag');
}
});
//新标签
$('.newTagA').on('click', function() {
$('.newTagA').on('click', function () {
$(this).hide();
$('.newTagI').show();
});
$('.newTagI').on('blur', function() {
$('.newTagI').on('blur', function () {
$(this).hide();
if ($(this).val()) {
var yes = confirm("确认添加新标签:" + $(this).val())
//添加标签
if (yes) {
$.post('/info.php/info_tags/add_tag/', {'title':$(this).val(),'memo':'test'}, function(json) {
$.post('/info.php/info_tags/add_tag/', {'title': $(this).val(), 'memo': 'test'}, function (json) {
if (json.statu != '-1') {
$clone = $('.tagLabel').eq(0).clone(true);
$clone.removeClass('myTag');
@ -1352,7 +1359,7 @@
}
});
//添加新模板
$('#newTemp').on('click', function() {
$('#newTemp').on('click', function () {
alert('ok');
});
</script>

Loading…
Cancel
Save