/** * 公共数据 * @return string */ public function publicdata() { // $color = $this->changeCss(); // DB::table('color') // dd($color); $customer_info = CustomerInfo::where('cus_id', $this->cus_id)->first(); //===显示版本切换链接=== $templatesC = new TemplatesController(); $tempname = $templatesC->getTemplatesName($this->type); $flagPlatform = substr($tempname, 0, 2); $flagLanguage = substr($tempname, 2, 1); $tempscript = ''; $customerC = new CustomerController(); $domain = $customerC->getSwitchCustomer(); //双站用户 $current_url = '#'; $language_url = '#'; $tempscript_star = '<script>$(function(){'; $tempscript_end = '});</script>'; if (!empty($domain)) { if ($flagPlatform == 'GM') { //===手机 $language_url = $domain['switch_mobile_domain']; $current_url = $domain['current_mobile_domain']; } elseif ($flagPlatform == 'GP') { //===PC $language_url = $domain['switch_pc_domain']; $current_url = $domain['current_pc_domain']; } if ($flagLanguage == 9) { //===英文 $language = '<li><a href="' . $language_url . '">中文版</a></li>'; $language .= '<li><a href="' . $current_url . '">English</a></li>'; } elseif ($flagLanguage == 0) { //===中文 $language = '<li><a href="' . $current_url . '">中文版</a></li>'; $language .= '<li><a href="' . $language_url . '">English</a></li>'; } $language_div = '<div class="language_div">' . '<ul>' . $language . '</ul>' . '</div>'; // $tempscript = '$("#header").prepend(\'' . $language_div . '\');' // . '$("#header").css("position","relative");'; } $language_css = '<link rel="stylesheet" href="http://swap.5067.org/css/language.css">'; //===显示版本切换链接-end=== $formC = new FormController(); $formJS = $this->insetForm(); //===表单嵌入=== if ($this->type == 'pc') { $stylecolor = websiteInfo::leftJoin('color', 'color.id', '=', 'website_info.pc_color_id')->where('cus_id', $this->cus_id)->pluck('color_en'); $logo = $this->showtype == 'preview' ? '/customers/' . $this->customer . '/images/l/common/' . $customer_info->logo : $this->domain . '/images/l/common/' . $customer_info->logo; //'preview' ? asset('customers/' . $this->customer . '/images/l/common/' . $customer_info->logo) : $this->domain . '/images/l/common/' . $customer_info->logo; $floatadv = json_decode($customer_info->floatadv); //===浮动类型=== if (!empty($floatadv)) { foreach ((array) $floatadv as $key => $val) { if (!isset($val->type) || $val->type == 'adv') { if ($this->showtype == 'preview') { $floatadv[$key]->url = '/customers/' . $this->customer . '/images/l/common/' . $val->adv; //asset('customers/' . $this->customer . '/images/l/common/' . $val->adv); } else { $floatadv[$key]->url = $this->domain . '/images/l/common/' . $val->adv; } } elseif ($val->type == 'form') { $form_id = $val->adv; $formCdata = $formC->getFormdataForPrint($form_id); if (!empty($formCdata)) { $form_content = $formC->showFormHtmlForPrint($formCdata, 'float'); $floatadv[$key]->content = $form_content; $floatadv[$key]->cssjs = $formC->assignFormCSSandJSForPrint(); } } } } if (count($floatadv)) { $url = "http://swap.5067.org/floatadv_new.php"; // $url = "http://swap.5067.org/floatadv.php"; $post_data = json_encode($floatadv); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, array("data" => $post_data)); $floatadvprint = curl_exec($ch); curl_close($ch); } $headscript = $customer_info->pc_header_script; // $headscript .= $language_css; //===版权选择=== switch ($customer_info->copyright) { case 'en_xiamen': $_href = 'http://www.12t.cn/'; $_copyright = 'XIAMEN 12t NETWORK TECHNOLOGY CO., LTD.'; break; case 'en_huizhou': $_href = 'http://www.ydbaidu.net/'; $_copyright = 'HUIZHOU YIRUITONG NETWORK TECHNOLOGY CO., LTD.'; break; case 'cn_xiamen': $_href = 'http://www.12t.cn/'; $_copyright = '厦门易尔通网络科技有限公司'; break; case 'cn_huizhou': $_href = 'http://www.ydbaidu.net/'; $_copyright = '惠州易瑞通网络科技有限公司'; break; default: $_href = 'http://www.12t.cn/'; $_copyright = '厦门易尔通网络科技有限公司'; break; } switch ($customer_info->talent_support) { case 'en_rencai': $talent_support = 'Talent support:<a href="http://www.xgzrc.com/">www.xgzrc.com</a>'; break; case 'en_null': $talent_support = ''; break; case 'cn_rencai': $talent_support = '人才支持:<a href="http://www.xgzrc.com/">厦门人才网</a>'; break; case 'cn_null': $talent_support = ''; break; default: $talent_support = '人才支持:<a href="http://www.xgzrc.com/">厦门人才网</a>'; break; } if ($customer_info->lang == 'en') { $footprint = $customer_info->footer . '<p>Technology support:<a href="' . $_href . '">' . $_copyright . '</a> ' . $talent_support . '</p>'; } else { $footprint = $customer_info->footer . '<p>技术支持:<a href="' . $_href . '">' . $_copyright . '</a> ' . $talent_support . '</p>'; } //===版权选择_end=== $footscript = $customer_info->pc_footer_script; $footscript .= $formJS; $footscript .= '<script type="text/javascript" src="/quickbar/js/quickbar.js?' . $this->cus_id . 'pc"></script>'; // $footscript .= '<script type="text/javascript" src="http://swap.5067.org/admin/statis.php?cus_id=' . $this->cus_id . '&platform=pc"></script>'; //===添加统计代码PC=== if ($customer_info->background_music) { $bgm = str_replace('"', "", $customer_info->background_music); $footscript .= '<script type="text/javascript">$("body").append("<div id=\\"bg-music\\">' . $bgm . '</div>") $("#bg-music").css("display","none"); </script>'; } // $footscript .= $tempscript_star . $tempscript . $tempscript_end; // $footscript .= $language_css; $site_another_url = $this->showtype == 'preview' ? '' : $customer_info->mobile_domain; } else { $logo = $this->showtype == 'preview' ? '/customers/' . $this->customer . '/images/l/common/' . $customer_info->logo_small : $this->domain . '/images/l/common/' . $customer_info->logo_small; //'preview' ? asset('customers/' . $this->customer . '/images/l/common/' . $customer_info->logo_small) : $this->domain . '/images/l/common/' . $customer_info->logo_small; $stylecolor = websiteInfo::leftJoin('color', 'color.id', '=', 'website_info.mobile_color_id')->where('cus_id', $this->cus_id)->pluck('color_en'); $headscript = $customer_info->mobile_header_script; // $headscript .= $language_css; $footprint = $customer_info->mobile_footer; $footscript = $customer_info->mobile_footer_script; // $footscript .= $formJS; $footscript .= '<script type="text/javascript" src="/quickbar/js/quickbar.js?' . $this->cus_id . 'mobile"></script>'; // $footscript .= '<script type="text/javascript" src="http://swap.5067.org/admin/statis.php?cus_id=' . $this->cus_id . '&platform=mobile"></script>'; //===添加统计代码MOBILE=== // $footscript .= $tempscript; $site_another_url = $this->showtype == 'preview' ? '' : $customer_info->pc_domain; $config_arr = parse_ini_file(public_path('/templates/' . $this->themename) . '/config.ini', true); if (!is_array($config_arr)) { dd('【config.ini】文件不存在!文件格式说明详见:http://pme.eexx.me/doku.php?id=ued:template:config'); } } //获取global信息 if ($this->type == 'pc') { $global_data = $this->pagedata('global'); $global_data = $this->detailList($global_data); } else { $global_data = WebsiteConfig::where('cus_id', $this->cus_id)->where('type', 2)->where('template_id', $this->tpl_id)->pluck('value'); if ($global_data) { $global_data = unserialize($global_data); } else { $global_data = $this->mobilePageList('global', true); } //===对多图进行排序=== if (is_array($global_data)) { foreach ($global_data as $key => &$value) { if ($key == 'slidepics') { $slidepics_data = $value['value']; if (is_array($slidepics_data)) { foreach ($slidepics_data as $k => $v) { if (isset($v['sort'])) { $sort[$k] = is_numeric($v['sort']) ? $v['sort'] : 100; $value['value'][$k]['sort'] = is_numeric($v['sort']) ? $v['sort'] : 100; } else { $sort[$k] = 100; $value['value'][$k]['sort'] = 100; } } } array_multisort($sort, $slidepics_data); $value['value'] = $slidepics_data; } } } //===对多图进行排序_end=== if (count($global_data) > 0) { $quickbarKey = false; foreach ($global_data as $gkey => $gval) { if ($global_data[$gkey]['type'] == 'quickbar') { $quickbar = WebsiteConfig::where('cus_id', $this->cus_id)->where('key', 'quickbar')->pluck('value'); if ($quickbar) { $quickbar = unserialize($quickbar); foreach ($quickbar as $key => $val) { $quickbar[$key]['enable'] = intval($quickbar[$key]['enable_mobile']); if ($quickbar[$key]['type'] == 'tel') { $quickbar[$key]['link'] = "tel:" . $quickbar[$key]['data']; } elseif ($quickbar[$key]['type'] == 'sms') { $quickbar[$key]['link'] = "sms:" . $quickbar[$key]['data']; } elseif ($quickbar[$key]['type'] == 'im') { $qq = explode('|', $quickbar[$key]['data']); $qq = explode(':', $qq[0]); $qq = explode('@', $qq[1]); $quickbar[$key]['link'] = 'http://wpd.b.qq.com/cgi/get_m_sign.php?uin=' . $qq[0]; } elseif ($quickbar[$key]['type'] == 'map') { if ($quickbar[$key]['data'] != null) { $location = explode('|', $quickbar[$key]['data']); $address = explode(',', $location[1]); $quickbar[$key]['link'] = 'http://api.map.baidu.com/marker?location=' . $address[1] . ',' . $address[0] . '&title=目标位置&content=' . $location[0] . '&output=html'; } else { $address = CustomerInfo::where('cus_id', $this->cus_id)->pluck('address'); $quickbar[$key]['link'] = 'http://api.map.baidu.com/geocoder?address=' . $address . '&output=html'; } } elseif ($quickbar[$key]['type'] == 'link') { if ($quickbar[$key]['data'] != null) { $url_arr = explode('|', $quickbar[$key]['data']); $quickbar[$key]['link'] = $url_arr[0]; } } //TODO:删除enable_pc/enable_mobile键值 unset($quickbar[$key]['enable_pc']); unset($quickbar[$key]['enable_mobile']); } $quickbarKey = $gkey; } else { foreach ($global_data[$gkey]['value'] as $key => $val) { if ($global_data[$gkey]['value'][$key]['type'] == 'tel') { $global_data[$gkey]['value'][$key]['link'] = "tel:" . $global_data[$gkey]['value'][$key]['data']; } elseif ($global_data[$gkey]['value'][$key]['type'] == 'sms') { $global_data[$gkey]['value'][$key]['link'] = "sms:" . $global_data[$gkey]['value'][$key]['data']; } elseif ($global_data[$gkey]['value'][$key]['type'] == 'im') { $qq = explode('|', $global_data[$gkey]['value'][$key]['data']); $qq = explode(':', $qq[0]); $qq = explode('@', $qq[1]); $global_data[$gkey]['value'][$key]['link'] = 'http://wpd.b.qq.com/cgi/get_m_sign.php?uin=' . $qq[0]; } elseif ($global_data[$gkey]['value'][$key]['type'] == 'link') { $address = CustomerInfo::where('cus_id', $this->cus_id)->pluck('address'); $global_data[$gkey]['value'][$key]['link'] = 'http://api.map.baidu.com/geocoder?address=' . $address . '&output=html'; } } $quickbarKey = $gkey; $quickbar = $global_data[$gkey]['value']; } } elseif ($global_data[$gkey]['type'] == 'images' or $global_data[$gkey]['type'] == 'image') { $img = 1; foreach ($global_data[$gkey]['value'] as $img_key => $img_value) { if ($img_value) { $img = 0; } } if ($img) { $global_data[$gkey]['value'] = array(); } } } } $global_data = $this->detailList($global_data); $this->replaceUrl($global_data); if (!empty($quickbarKey)) { $global_data[$quickbarKey] = $quickbar; } } $contact = CustomerInfo::where('cus_id', $this->cus_id)->select('company', 'contact_name as name', 'mobile', 'telephone', 'fax', 'email as mail', 'qq', 'address')->first()->toArray(); if ($this->showtype == 'preview') { if ($this->type == 'pc') { $pc_domain = 'http://' . $_SERVER['HTTP_HOST'] . '/search-preview'; } else { $pc_domain = 'http://' . $_SERVER['HTTP_HOST'] . '/mobile/search-preview'; } } else { $pc_domain = $this->domain . '/search.php'; } $result = ['stylecolor' => $stylecolor, 'favicon' => $customer_info->favicon ? rtrim($this->source_dir, 'images/') . '/images/l/common/' . $customer_info->favicon : '', 'logo' => $logo, 'floatadvprint' => isset($floatadvprint) ? $floatadvprint : '', 'headscript' => $headscript, 'footprint' => $footprint, 'footscript' => $footscript, 'global' => $global_data, 'site_url' => $this->site_url, 'site_another_url' => str_replace('http://', '', $site_another_url) ? $site_another_url : '', 'contact' => $contact, 'search_action' => $pc_domain]; if ($this->type == 'pc') { $footer_navs = Classify::where('cus_id', $this->cus_id)->where('footer_show', 1)->select('id', 'type', 'img', 'icon', 'name', 'url', 'p_id', 'en_name', 'meta_description as description', 'open_page')->OrderBy('sort', 'asc')->get()->toArray(); $footer_navs = $this->toFooter($footer_navs, 0); $result['footer_navs'] = $footer_navs; $result['type'] = 'pc'; } return $result; }
/** * 根据栏目id获取页面的公共数据,包括logo、path、stylecolor、navs、logo、footprint等 * * @param int $c_id 栏目id,只为用于导航navs的状态 * @return array 返回一个包含公共数据的数组 */ private function pagePublic($c_id = 0) { if ($this->type == 'pc') { $navs = Classify::where('cus_id', $this->cus_id)->where('pc_show', 1)->whereIN('type', [1, 2, 3, 4, 6])->select('id', 'type', 'img', 'icon', 'name', 'url', 'p_id', 'en_name', 'meta_description as description')->OrderBy('sort', 'asc')->get()->toArray(); } else { $navs = Classify::where('cus_id', $this->cus_id)->where('mobile_show', 1)->select('id', 'type', 'img', 'icon', 'name', 'url', 'p_id', 'en_name', 'meta_description as description')->OrderBy('sort', 'asc')->get()->toArray(); } $navs = $this->toTree($navs, 0, TRUE); if ($c_id) { $current_arr = $this->currentCidArray($c_id); $navs = $this->addCurrent($navs, $current_arr); } $customer_info = CustomerInfo::where('cus_id', $this->cus_id)->first(); if ($this->type == 'pc') { $stylecolor = websiteInfo::leftJoin('color', 'color.id', '=', 'website_info.pc_color_id')->where('cus_id', $this->cus_id)->pluck('color_en'); $logo = $this->showtype == 'preview' ? asset('customers/' . $this->customer . '/images/l/common/' . $customer_info->logo) : $this->domain . '/images/l/common/' . $customer_info->logo; $headscript = $customer_info->pc_header_script; $footprint = $customer_info->footer . '<p>技术支持:<a href="http://www.12t.cn/">厦门易尔通网络科技有限公司</a> 人才支持:<a href="http://www.xgzrc.com/">厦门人才网</a></p>'; $footscript = $customer_info->pc_footer_script; $footscript .= '<script type="text/javascript" src="http://chanpin.xm12t.com.cn/js/quickbar-1.js"></script>'; $site_another_url = $this->showtype == 'preview' ? '' : $customer_info->mobile_domain; } else { $logo = $this->showtype == 'preview' ? asset('customers/' . $this->customer . '/images/l/common/' . $customer_info->logo_small) : $this->domain . '/images/l/common/' . $customer_info->logo_small; $stylecolor = websiteInfo::leftJoin('color', 'color.id', '=', 'website_info.mobile_color_id')->where('cus_id', $this->cus_id)->pluck('color_en'); $headscript = $customer_info->mobile_header_script; $footprint = $customer_info->mobile_footer; $footscript = $customer_info->mobile_footer_script; $footscript .= '<script type="text/javascript" src="http://chanpin.xm12t.com.cn/js/quickbar.js?' . $this->cus_id . '"></script>'; $site_another_url = $this->showtype == 'preview' ? '' : $customer_info->pc_domain; $config_arr = parse_ini_file(public_path('/templates/' . $this->themename) . '/config.ini', true); if (!is_array($config_arr)) { dd('【config.ini】文件不存在!文件格式说明详见:http://pme/wiki/doku.php?id=ued:template:config'); } } //获取global信息 if ($this->type == 'pc') { $global_data = $this->pagedata('global'); $global_data = $this->detailList($global_data); } else { $global_data = WebsiteConfig::where('cus_id', $this->cus_id)->where('type', 2)->where('template_id', $this->tpl_id)->pluck('value'); if ($global_data) { $global_data = unserialize($global_data); $global_data = $this->detailList($global_data); } else { $global_data = $this->mobilePageList('global', true); $global_data = $this->detailList($global_data); } $this->replaceUrl($global_data); if (isset($global_data['bottomnavs']) && is_array($global_data['bottomnavs'])) { foreach ($global_data['bottomnavs'] as &$val) { $val['id'] = isset($val['id']) ? $val['id'] : ''; $val['icon'] = isset($val['icon']) ? $val['icon'] : ''; switch ($val['type']) { case "tel": $val['link'] = "tel:" . $val['data']; break; case "sms": $val['link'] = "sms:" . $val['data']; break; case "im": $val['link'] = $val['data']; break; case "share": $val['link'] = 'javascript:void(0);'; break; case "link": if (isset($val['childmenu']) && count($val['childmenu']) > 0) { $val['link'] = 'javascript:void(0);'; foreach ($val['childmenu'] as &$menu) { $menu['link'] = $menu['data']; } } else { $val['link'] = $val['data']; } break; } } } } $contact = CustomerInfo::where('cus_id', $this->cus_id)->select('company', 'contact_name as name', 'mobile', 'telephone', 'fax', 'email as mail', 'qq', 'address')->first()->toArray(); $pc_domain = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_domain'); if (!empty($pc_domain)) { $domain_arr = parse_url($pc_domain); $pc_domain = $domain_arr['host']; $pc_domain = "http://wwvv." . ltrim($pc_domain, 'www.'); } $result = ['stylecolor' => $stylecolor, 'navs' => $navs, 'favicon' => rtrim($this->source_dir, 'images/') . '/images/l/common/' . $customer_info->favicon, 'logo' => $logo, 'headscript' => $headscript, 'footprint' => $footprint, 'footscript' => $footscript, 'global' => $global_data, 'site_url' => $this->site_url, 'site_another_url' => $site_another_url, 'contact' => $contact, 'search_action' => $pc_domain . '/search.html']; return $result; }