public function articleBatchModify() { $ids = explode(',', Input::get('id')); $action = Input::get('action'); $value = Input::get('values'); $cus_id = Auth::id(); $relation = array('set_star' => 'is_star', 'set_top' => 'is_top', 'set_pcshow' => 'pc_show', 'set_mobileshow' => 'mobile_show', 'set_wechatshow' => 'wechat_show'); if (count($ids) > 1) { $data = array(); $err = false; foreach ($ids as $id) { $article = Articles::find($id); $article->{$relation}[$action] = $value; if ($relation[$action] == 'pc_show') { $pushed = websiteInfo::where('cus_id', $cus_id)->pluck('pushed'); if ($pushed == 1 || $pushed == '3') { $pushed = 1; } else { $pushed = 2; } } else { if ($relation[$action] == 'mobile_show') { $pushed = websiteInfo::where('cus_id', $cus_id)->pluck('pushed'); if ($pushed == 1 || $pushed == '2') { $pushed = 1; } else { $pushed = 3; } } else { $pushed = 1; $article->pushed = 1; } } websiteInfo::where('cus_id', $cus_id)->update(['pushed' => $pushed]); $result = $article->save(); if ($result) { $data[] = $id; } else { $err = true; } } if ($err) { $return_msg = array('err' => 3001, 'msg' => '部分变更失败', 'data' => $data); } else { $return_msg = array('err' => 0, 'msg' => ''); } } else { $article = Articles::find($ids[0]); $article->{$relation}[$action] = $value; if ($relation[$action] == 'pc_show') { $pushed = websiteInfo::where('cus_id', $cus_id)->pluck('pushed'); if ($pushed == 1 || $pushed == '3') { $pushed = 1; } else { $pushed = 2; } } else { if ($relation[$action] == 'mobile_show') { $pushed = websiteInfo::where('cus_id', $cus_id)->pluck('pushed'); if ($pushed == 1 || $pushed == '2') { $pushed = 1; } else { $pushed = 3; } } else { $pushed = 1; $article->pushed = 1; } } websiteInfo::where('cus_id', $cus_id)->update(['pushed' => $pushed]); $result = $article->save(); if ($result) { $return_msg = array('err' => 0, 'msg' => ''); } else { $return_mag = array('err' => 3001, 'msg' => '变更失败'); } } return Response::json($return_msg); }
public function homepageModify() { $cus_id = Auth::id(); $template_id = websiteInfo::where('cus_id', $cus_id)->pluck('pc_tpl_id'); $website_config = new WebsiteConfig(); $website_config->cus_id = $cus_id; $page = Input::get('page'); $website_config->key = $page; $count = $website_config->where('cus_id', $cus_id)->where('template_id', $template_id)->where('key', $page)->count(); $website_config->template_id = $template_id; $data = Input::get('data'); /* if(isset($data['slidepics']) && count($data['slidepics'])){ foreach($data['slidepics'] as &$arr){ $arr['link']=$arr['href']; $arr['image']=basename($arr['src']); unset($arr['href']); unset($arr['src']); } } */ foreach ($data as $key => $val) { if (is_array($data[$key]) && count($data[$key])) { if (array_key_exists("href", $data[$key]) || array_key_exists("src", $data[$key])) { $data[$key]['link'] = $data[$key]['href']; $data[$key]['image'] = basename($data[$key]['src']); unset($data[$key]['href']); unset($data[$key]['src']); } else { foreach ($data[$key] as &$arr) { if (is_array($arr)) { if (array_key_exists("href", $arr) || array_key_exists("src", $arr)) { $arr['link'] = $arr['href']; $arr['image'] = basename($arr['src']); unset($arr['href']); unset($arr['src']); } } } } } $temp_arr = $data[$key]; unset($data[$key]); $data[$key]['value'] = $temp_arr; } $website_config->value = serialize($data); if ($count) { $result = $website_config->where('cus_id', $cus_id)->where('template_id', $template_id)->where('key', $page)->update(['value' => $website_config->value]); } else { $result = $website_config->save(); } if ($result) { return Response::json(['err' => 0, 'msg' => '', 'data' => null]); } else { return Response::json(['err' => 1001, 'msg' => '数据保存失败', 'data' => null]); } }
/** * ===更换样式=== */ public function changeCss() { $colorArr = websiteInfo::where('cus_id', $this->cus_id)->select('pc_color_id', 'mobile_color_id')->first(); $color['pc'] = DB::table('color')->where('id', $colorArr->pc_color_id)->pluck('color_en'); $color['mobile'] = DB::table('color')->where('id', $colorArr->mobile_color_id)->pluck('color_en'); return $color; }
/** * 根据栏目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; }
public function classifyShow() { $cus_id = Auth::id(); $id = Input::get('id'); $operate = Input::get('operate'); $value = Input::get('value'); $operate_array = ['pc_show', 'mobile_show', 'wechat_show']; $classify = Classify::where('id', $id)->where('cus_id', $cus_id)->first(); if (in_array($operate, $operate_array)) { $update = [$operate => $value]; if ($operate == 'pc_show') { $pushed = websiteInfo::where('cus_id', $cus_id)->pluck('pushed'); if ($pushed == 1 || $pushed == '3') { $pushed = 1; } else { $pushed = 2; } } else { if ($operate == 'mobile_show') { $pushed = websiteInfo::where('cus_id', $cus_id)->pluck('pushed'); if ($pushed == 1 || $pushed == '2') { $pushed = 1; } else { $pushed = 3; } } } websiteInfo::where('cus_id', $cus_id)->update(['pushed' => $pushed]); if (!$value) { $this->closeChildClassify($id, $update, $operate); if (Classify::where('id', $id)->where('cus_id', $cus_id)->update($update)) { if ($operate == 'mobile_show') { @MobileHomepage::where('c_id', $c_id)->where('cus_id', $cus_id)->update(['index_show' => 0]); } $result = ['err' => 0, 'msg' => '']; } else { $result = ['err' => 1001, 'msg' => '栏目关闭操作失败']; } } else { $is_passed = true; if ($classify->p_id != 0) { $p_c_info = Classify::where('id', $classify->p_id)->first(); if ($p_c_info->{$operate} == 0) { $result = ['err' => 1001, 'msg' => '父级栏目未开启,栏目开启失败']; $is_passed = false; } } if ($is_passed) { if (Classify::where('id', $id)->where('cus_id', $cus_id)->update($update)) { $result = ['err' => 0, 'msg' => '']; } else { $result = ['err' => 1001, 'msg' => '栏目开启操作失败']; } } } } else { $result = ['err' => 1001, 'msg' => '栏目显隐控制错误操作']; } return Response::json($result); }
/** * ===模板更换=== * @return type */ public function templateChage() { $cus_id = Auth::id(); $type = Input::get('type'); $id = Input::get('id'); $color = Input::get('color'); $color_id = Color::where('color_en', $color)->pluck('id'); $template = Template::find($id); $websiteconfig = WebsiteConfig::where('cus_id', $cus_id)->where('type', 2)->where('template_id', '0')->where('key', 'quickbar')->pluck('value'); $websiteconfig = unserialize($websiteconfig); foreach ((array) $websiteconfig as $key => $val) { if ($val['type'] === 'colors') { //===?如果网站配置类型是颜色类型,则移除该配置项=== unset($websiteconfig[$key]); break; } } $websiteconfig = serialize($websiteconfig); $pushed = websiteInfo::where('cus_id', $cus_id)->pluck('pushed'); //===获取是否推送=== if ($template->type == $type) { if ($type == 1) { //===type:1 PC模板 if ($pushed == 1 || $pushed == '3') { //pushed:0-不需推送,1-pc+手机,2-pc,3-手机; $pushed = 1; } else { $pushed = 2; } $update = ['pc_tpl_id' => $id, 'pc_color_id' => $color_id, 'pushed' => $pushed]; } else { //===type:2 MOBILE模板 if ($pushed == 1 || $pushed == '2') { $pushed = 1; } else { $pushed = 3; } $update = ['mobile_tpl_id' => $id, 'mobile_color_id' => $color_id, 'pushed' => $pushed]; } $update_result = WebsiteInfo::where('cus_id', $cus_id)->update($update); if ($update_result) { WebsiteConfig::where('cus_id', $cus_id)->where('key', 'quickbar')->update(['value' => $websiteconfig, 'pushed' => 1]); $result = ['err' => 0, 'msg' => 'success']; } else { $result = ['err' => 1001, 'msg' => '更换模版失败']; } } else { $result = ['err' => 1001, 'msg' => '选择模版存在问题']; } return Response::json($result); }