diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index efaaf3a3..c4f84b92 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -12,6 +12,7 @@ class Welcome extends CI_Controller { $this->load->model('Area_model'); $this->load->model('InfoStructures_model'); $this->load->model('Information_model'); + $this->load->model('InfoContents_model'); $this->load->model('Coupon_model'); } @@ -94,6 +95,106 @@ class Welcome extends CI_Controller { $this->load->view('bootstrap/footer'); } + public function get_infomation_urls($is_parent_id) { + $this->output->enable_profiler(FALSE); + $structure = $this->InfoStructures_model->Detail($is_parent_id); + if (empty($structure)) { + show_404(); + return false; + } + $data['all_information'] = $this->Information_model->get_list_by_path($structure->is_path); + $this->load->view('bootstrap/header', $data); + $this->load->view('bootstrap/static_url', $data); + $this->load->view('bootstrap/footer'); + } + + public function change_static_url($info_id) { + $information = $this->Information_model->Detail($info_id); + $htm_doc = new DOMDocument(); + libxml_use_internal_errors(true); + $htm_doc->strictErrorChecking = false; + if (empty($information->ic_content)) { + $this->echo_json([ + 'status' => 'error', + 'infoId' => $info_id, + 'message' => 'info content is empty' + ]); + return; + } + $htm_doc->loadHTML($information->ic_content); + $htm_doc->normalizeDocument(); + $img_list = $htm_doc->getElementsByTagName('img'); + foreach ($img_list as $img) { + $img_src = $img->getAttribute('src'); + $img_src = $this->check_url($img_src); + } + + $information->ic_content = $htm_doc->saveHTML(); + + $this->InfoContents_model->Update( + $information->is_ic_id, + $information->ic_url, + $information->ic_url_title, + $information->ic_type, + $information->ic_title, + $information->ic_content, + $information->ic_summary, + $information->ic_seo_title, + $information->ic_seo_description, + $information->ic_seo_keywords, + $information->ic_show_bread_crumbs, + $information->ic_status, + $information->ic_template, + $information->ic_photo, + $information->ic_photo_width, + $information->ic_photo_height, + $information->ic_recommend_tours, + $information->ic_recommend_packages, + $information->ic_ht_area_id, + $information->ic_ht_area_type, + $information->ic_ht_product_id, + $information->ic_ht_product_type, + $information->ic_author); + + $this->echo_json([ + 'status' => 'ok', + 'infoId' => $info_id, + 'message' => 'success' + ]); + } + + private function echo_json($obj) { + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($obj)); + } + + private function check_url($subject) { + $result = $subject; + $check_rules = array( + '/^\/image\/(.*)/' => '//images.chinahighlights.com/image/', + '/^http:\/\/images.chinahighlights.com(.*)/' => '//images.chinahighlights.com', + '/^http:\/\/data.chinahighlights.com(.*)/' => '//data.chinahighlights.com', + '/^http:\/\/www.chinahighlights.com(.*)/' => '//www.chinahighlights.com'); + + foreach ($check_rules as $pattern => $replace) { + // echo 'key: '.$pattern.'; val: '.$replace.''; + $result = $this->replace_url($pattern, $replace, $result); + } + return $result; + } + + private function replace_url($pattern, $replace, $subject) { + $result = $subject; + $match_result = array(); + preg_match($pattern, $subject, $match_result); + $result_count = count($match_result); + if ($result_count == 2) { + $result = $replace.$match_result[1]; + } + return $result; + } + //生肖促销订单查询 public function coupon() { $data['countryList'] = $this->Area_model->get_country_list(); diff --git a/application/views/bootstrap/static_url.php b/application/views/bootstrap/static_url.php new file mode 100644 index 00000000..ca584edf --- /dev/null +++ b/application/views/bootstrap/static_url.php @@ -0,0 +1,68 @@ + + +
#ID | +URL | ++ |
---|---|---|
is_ic_id; ?> | +ic_url; ?> | ++ |