增加显示备份,单行更新,UTF-8转换

hotfix/远程访问多媒体中心
LiaoYijun 8 years ago
parent 209580184a
commit 8ec9ae25c7

@ -14,6 +14,7 @@ class Welcome extends CI_Controller {
$this->load->model('Information_model');
$this->load->model('InfoContents_model');
$this->load->model('Coupon_model');
$this->load->model('Logs_model');
}
public function index() {
@ -103,6 +104,7 @@ class Welcome extends CI_Controller {
return false;
}
$data['all_information'] = $this->Information_model->get_list_by_path($structure->is_path);
$data['last_backup'] = $this->Logs_model->get_last_backup($is_parent_id);
$this->load->view('bootstrap/header', $data);
$this->load->view('bootstrap/static_url', $data);
$this->load->view('bootstrap/footer');
@ -110,11 +112,12 @@ class Welcome extends CI_Controller {
public function change_static_url($info_id) {
$information = $this->Information_model->Detail($info_id);
$htm_doc = new DOMDocument();
$htm_doc = new DOMDocument();//('1.0', 'UTF-8');
//$htm_doc->encoding='UTF-8';
libxml_use_internal_errors(true);
$htm_doc->strictErrorChecking = false;
//$htm_doc->strictErrorChecking = false;
if (empty($information->ic_content)) {
$this->echo_json([
$this->echo_json(array[
'status' => 'error',
'infoId' => $info_id,
'message' => 'info content is empty'
@ -122,6 +125,11 @@ class Welcome extends CI_Controller {
return;
}
$htm_doc->loadHTML($information->ic_content);
$htm_doc->loadHTML(
mb_convert_encoding($information->ic_content, 'HTML-ENTITIES', 'UTF-8'));
// $htm_doc->loadHTML(
// utf8_decode($information->ic_content));
// $htm_doc->loadHTML($information->ic_content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$htm_doc->normalizeDocument();
$img_list = $htm_doc->getElementsByTagName('img');
foreach ($img_list as $img) {
@ -130,10 +138,10 @@ class Welcome extends CI_Controller {
$img->setAttribute('src', $img_src);
}
// $information->ic_content = utf8_encode($htm_doc->saveHTML());
$information->ic_content = $htm_doc->saveHTML();
$this->InfoContents_model->Update(
$information->is_ic_id,
$information->is_id,
$information->ic_url,
$information->ic_url_title,
$information->ic_type,
@ -157,10 +165,11 @@ class Welcome extends CI_Controller {
$information->ic_ht_product_type,
$information->ic_author);
$this->echo_json([
$this->echo_json(array[
'status' => 'ok',
'infoId' => $info_id,
'message' => 'success'
'message' => 'success',
'date' => date('Y-m-d h:i:s')
]);
}

@ -41,6 +41,15 @@ class Logs_model extends CI_Model {
return $this->get_list();
}
//获取最近的备份信息内容
function get_last_backup($is_id) {
$this->init();
$this->top_num = 1;
$this->log_res_id = " AND il.log_res_id =" . $this->HT->escape($is_id);
$this->log_action = " AND il.log_action = 'backup_info'";
return $this->get_list();
}
//获取所有备份信息内容
function get_all_backup_list($is_id) {
$this->init();
@ -76,13 +85,13 @@ class Logs_model extends CI_Model {
$map = '';
if ($last_id)
$map = " AND log_id > $last_id";
$sql = " SELECT log_id,is_sitecode,ic_url
FROM infoLogs
LEFT JOIN infoStructures ON is_id=log_res_id
LEFT JOIN infoContents ON is_ic_id=ic_id
WHERE ic_url != ''
AND log_action = 'backup_info'
$sql = " SELECT log_id,is_sitecode,ic_url
FROM infoLogs
LEFT JOIN infoStructures ON is_id=log_res_id
LEFT JOIN infoContents ON is_ic_id=ic_id
WHERE ic_url != ''
AND log_action = 'backup_info'
$map
ORDER BY log_id ASC";
$query = $this->HT->query($sql);
@ -170,7 +179,7 @@ class Logs_model extends CI_Model {
,log_datetime
)
VALUES
( ?,?,N?,?,?,GETDATE())
( ?,?,N?,?,?,GETDATE())
";
$query = $this->HT->query($sql, array('write_test', 0, '数据库写入测试', 'system', 'system'));

@ -5,7 +5,6 @@
$("td[data-id]").each(function(index, element) {
idList[index] = $(element).data("id");
});
console.info(idList);
$("#startButton").click(function() {
batch_update_cache(idList[index]);
});
@ -25,6 +24,17 @@
});
}
});
function update_content(infoId) {
var $statusLabel = $("#status" + infoId);
$statusLabel.html("\u7a0d\u7b49...");
console.info("infoId: " + infoId);
$.get("/info.php/welcome/change_static_url/" + infoId,
function(result) {
console.info(result);
$statusLabel.html(result.message);
});
}
</script>
<div class="row-fluid">
@ -39,7 +49,9 @@
<tr>
<th class="span1">#ID</th>
<th class="span9">URL</th>
<th class="span2"><button id="startButton">开始</button></th>
<th class="span2">备份</th>
<th class="span2">操作</th>
<th class="span2"><button id="startButton">开始批量</button></th>
</tr>
</thead>
<tbody>
@ -48,9 +60,11 @@
if ($info->ic_status == 1 && !empty($info->ic_url)) {
?>
<tr>
<td data-id='<?php echo $info->is_ic_id; ?>'><?php echo $info->is_ic_id; ?></td>
<td class="cache_url"><?php echo $info->ic_url; ?></a></td>
<td id="status<?php echo $info->is_ic_id; ?>"><i class="icon-refresh"></i></td>
<td data-id='<?php echo $info->is_id; ?>'><?php echo $info->is_id; ?></td>
<td class="cache_url"><?php echo $info->ic_url; ?></td>
<td><?php echo $last_backup->log_id; ?><a href="/info.php/information/backup_content/<?php echo $info->is_id; ?>);">查看</a></td>
<td><a href="javascript:update_content(<?php echo $info->is_id; ?>);">GO</a></td>
<td id="status<?php echo $info->is_id; ?>"><i class="icon-refresh"></i></td>
</tr>
<?php }
} ?>

Loading…
Cancel
Save