全站AMP更新功能

hotfix/远程访问多媒体中心
尹诚诚 7 years ago
parent bbcc94c88f
commit 388db4ef2e

@ -108,8 +108,7 @@ class Amp extends CI_Controller
$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);
echo json_encode(array('name' => 'ok', 'value' => $this->lang->line('form_info_success')));
}
}

@ -74,6 +74,16 @@ class Welcome extends CI_Controller {
$this->load->view('bootstrap/cache_url', $data);
$this->load->view('bootstrap/footer');
}
//获取所有信息URL,用来批量静态化更新
public function create_all_amp_urls() {
set_time_limit(0);
$this->output->enable_profiler(false);
$data['all_information'] = $this->Information_model->GetList('ic_id,ic_status,ic_url,ic_sitecode');
$this->load->view('bootstrap3/header', $data);
$this->load->view('bootstrap3/refresh_amp_urls');
$this->load->view('bootstrap3/footer');
}
//获取某个信息节点和子节点url
public function create_infomation_urls($is_parent_id) {

@ -33,6 +33,21 @@ class InfoMetas_model extends CI_Model {
$query = $this->HT->query($sql, array($im_ic_id, $im_key));
return $query->result();
}
function get_list_by_key($im_key) {
$sql = "
SELECT im.im_id
,im.im_ic_id
,im.im_key
,im.im_value
FROM infoMetas im
WHERE im.im_ic_id = ?
AND im.im_key = ?
ORDER BY im.im_id ASC
";
$query = $this->HT->query($sql, array($im_ic_id, $im_key));
return $query->result();
}
//列表所有含AMPmeta的信息。
public function list_amp($site_code) {

@ -42,6 +42,7 @@
<li><a href="<?php echo site_url('sendmail') ?>" >订单邮件管理</a> </li>
<li><a href="http://share.chtcdn.com/info.php/infoshare/" target="_blank" >信息分享平台</a> </li>
<li><a href="<?php echo site_url('welcome/create_all_urls') ?>" target="_blank" >全站静态化更新</a> </li>
<li><a href="<?php echo site_url('welcome/create_all_amp_urls') ?>" target="_blank" >全站AMP更新</a> </li>
<li class="divider"></li>

@ -0,0 +1,104 @@
<script language="javascript">
function batch_update_amp(index) {
var ic_id = $('#cache_ic_id_' + index).val();
var msg_obj = "#cache" + index;
var amp_code = '';
$(msg_obj).html("\u7a0d\u7b49...");
$.ajax({
type: "get",
dataType: "json",
url: "<?php echo site_url('amp/auto_create/') ?>/" + ic_id,
success: function (result, textStatus) {
$.each(result, function (i, field) {
if (i === 'data') {
amp_code = field.amp;
}
});
$(msg_obj).html("\u0041\u004d\u0050\u8f6c\u6362\u6210\u529f\u0021\u6b63\u5728\u4fdd\u5b58\u2026\u2026");
//保存转换的AMP代码 begin
$.ajax({
type: "post",
dataType: "json",
url: "<?php echo site_url('amp/edit_save/') ?>",
data: {
"ic_id": ic_id,
"textarea_htmlcode": amp_code,
"amp_status": 1
},
success: function (result, textStatus) {
$(msg_obj).html("\u0041\u004d\u0050\u66f4\u65b0\u6210\u529f\u0021");
create_amp_data(++index);
},
error: function () {
$(msg_obj).html("<a href='javascript:void(0);' onclick='create_amp_data(" + index + ");' >发生错误,请重试</a>");
create_amp_data(++index);
}
});
//保存转换的AMP代码 end
},
error: function () {
$(msg_obj).html("<a href='javascript:void(0);' onclick='create_amp_data(" + index + ");' >发生错误,请重试</a>");
create_amp_data(++index);
}
});
}
function create_amp_data(index) {
if ($('#cache_url' + index).length > 0) {
if ($('#cache' + index).html() !== '\u0041\u004d\u0050\u66f4\u65b0\u6210\u529f\u0021') {
batch_update_amp(index);
}
}
}
</script>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
</div>
<div class="col-sm-16">
<table class="table table-striped">
<thead>
<tr>
<th class="col-sm-2">#</th>
<th class="col-sm-18">URL</th>
<th class="col-sm-4">更新进度</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($all_information as $key => $info) {
if ($info->ic_status == 1 && !empty($info->ic_url)) {
$i++;
?>
<tr>
<td><?php echo $i; ?></td>
<td id="cache_url<?php echo $i; ?>" name="cache_url<?php echo $i; ?>" class="cache_url"><?php echo $info->ic_url; ?></a></td>
<td id="cache<?php echo $i; ?>" name="cache<?php echo $i; ?>"><i class="icon-refresh"></i></td>
<input type="hidden" id="cache_ic_id_<?php echo $i; ?>" value="<?php echo $info->ic_id; ?>" />
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
<div class="col-sm-4">
<a href="javascript:void(0);" class="btn btn-danger" onclick="batch_update_amp(1);">开始更新</a>
</div>
</div>
</div>
Loading…
Cancel
Save