批量更新静态页面功能

ct-mobile-first
ycc 5 years ago
parent 13d2243c0d
commit ba2cf34618

@ -564,8 +564,25 @@ class Information extends CI_Controller
return true;
}
public function update_www_cache($ic_id){
$information = $this->Information_model->detail_by_ic_id($ic_id);
if(empty($information)){
echo json_encode(array('name' => 'no', 'data' => '找不到这个页面'));
return false;
}
if($this->html_file_helper('find',$information->ic_url)){
$this->make_www_cache('pc',$information);
$this->make_www_cache('mobile',$information);
echo json_encode(array('name' => 'yes', 'data' => '更新成功!'));
return true;
}else{
echo json_encode(array('name' => 'no', 'data' => '没有发布静态页面'));
return false;
}
}
//静态文件操作
public function html_file_helper($active = 'find', $ic_url = false)
function html_file_helper($active = 'find', $ic_url = false)
{
if (empty($ic_url)) {
$ic_url = $this->input->get_post('ic_url');

@ -106,15 +106,19 @@ class Welcome extends CI_Controller {
return false;
}
$data['all_information'] = $this->Information_model->get_list_by_path($structure->is_path);
if ($view == 'amp') {
$this->load->view('bootstrap3/header', $data);
$this->load->view('bootstrap3/refresh_amp_urls');
$this->load->view('bootstrap3/footer');
} else {
$this->load->view('bootstrap/header', $data);
$this->load->view('bootstrap/cache_url', $data);
$this->load->view('bootstrap/footer');
$this->load->view('bootstrap3/header', $data);
switch ($view){
case 'amp':
$this->load->view('bootstrap3/refresh_amp_urls');
break;
case 'mobile-first':
$this->load->view('bootstrap3/refresh_mobile_first_urls');
break;
default:
$this->load->view('bootstrap/cache_url', $data);
}
$this->load->view('bootstrap/footer');
}
//根据信息节点ID获取信息用于搜索结果的批量更新静态页面

@ -569,12 +569,18 @@
<ul id="treeDemo" name="treeDemo" class="ztree" style="height:1035px;overflow-x:auto;"></ul>
<ul class="nav nav-list">
<li class="nav-header">
<?php if($this->config->item('site_code')!=='ch'){ ?>
<a href="<?php echo site_url('welcome/create_infomation_urls/' . $information->is_id); ?>"
target="_blank" class="col-sm-5" title="批量更新静态化页面"><i
class="text-muted glyphicon glyphicon-retweet"></i></a>
<a href="<?php echo site_url('welcome/create_infomation_urls/' . $information->is_id . '/amp'); ?>"
target="_blank" class="col-sm-5" title="批量更新AMP页面"><i
class="glyphicon glyphicon-flash"></i></a>
<?php }else{ ?>
<a href="<?php echo site_url('welcome/create_infomation_urls/' . $information->is_id . '/mobile-first'); ?>"
target="_blank" class="col-sm-5" title="批量更新静态页面"><i
class="glyphicon glyphicon-flash"></i></a>
<?php } ?>
</li>
</ul>
</div>
@ -598,7 +604,7 @@
<a href="javascript:void(0);" onclick="update_preview()" title="刷新预览"><i
class="glyphicon glyphicon-refresh text-muted"></i></a>
<label>
信息标题(H1) & IC_ID: <?php echo $information->ic_id; ?>
信息标题(H1)
</label>
</div>
<div class="col-xs-17 text-right">

@ -0,0 +1,92 @@
<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('information/update_www_cache/') ?>/" + ic_id,
success: function (result, textStatus) {
//当result为空的时候跳过
if (result.length == 0 || result == '' || undefined || null) {
$(msg_obj).html("<a href='javascript:void(0);' onclick='create_amp_data(" + index + ");' >发生错误,请重试</a>");
create_amp_data(++index);
return;
}
if (result.name === 'no') {
$(msg_obj).html("更新失败: " + result.data);
} else {
$(msg_obj).html("更新成功!");
}
create_amp_data(++index);
},
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) {
setTimeout("batch_update_amp(" + index + ")", 500);
}
}
</script>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
</div>
<div class="col-sm-12">
<table class="table table-striped">
<thead>
<tr>
<th class="col-sm-2">#</th>
<th class="col-sm-14">URL</th>
<th class="col-sm-6">更新进度</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"><a
href="<?php echo site_url('information/edit/' . $info->is_id) ?>"
target="_blank"><?php echo $info->ic_url; ?></a></td>
<td id="cache<?php echo $i; ?>" name="cache<?php echo $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="create_amp_data(1);">开始更新</a>
</div>
</div>
</div>
Loading…
Cancel
Save