Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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]);
     }
 }
Exemplo n.º 3
0
 /**
  * ===更换样式===
  */
 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;
 }
Exemplo n.º 4
0
 /**
  * 合并页面请求,合并json和数据库内容,返回合并后的数组
  *
  * @param string $themename 模版名称
  * @param string $pagename 页面名称
  * @return array 合并后的数组
  */
 public function pagedata($pagename)
 {
     if ($this->type == 'pc') {
         $tpl_id = websiteInfo::where('id', $this->cus_id)->pluck('pc_tpl_id');
     } else {
         $tpl_id = websiteInfo::where('id', $this->cus_id)->pluck('mobile_tpl_id');
     }
     $website_confige = WebsiteConfig::where('cus_id', $this->cus_id)->where('key', $pagename)->where('type', 1)->where('template_id', $tpl_id)->pluck('value');
     $website_confige_value = unserialize($website_confige);
     $json_path = public_path('templates/' . $this->themename . '/json/' . $pagename . '.json');
     $json = file_exists($json_path) ? file_get_contents($json_path) : '{}';
     if ($website_confige_value) {
         $default = json_decode(trim($json), TRUE);
         $result = $this->array_merge_recursive_new($default, $website_confige_value);
         //$result = $website_confige_value;
         $this->replaceUrl($result);
         $result = $this->dataDeal($result);
         foreach ($result as &$v) {
             if ($v['type'] == 'list') {
                 if (isset($v['config']['filter'])) {
                     if ($v['config']['filter'] == 'list') {
                         $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                     } else {
                         $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                     }
                 } else {
                     $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                 }
             } elseif ($v['type'] == 'navs') {
                 $v['config']['ids'] = array_merge($v['config']['ids']);
             }
         }
     } else {
         $result = json_decode(trim($json), TRUE);
         if ($result === NULL) {
             dd("{$pagename}.json文件错误");
         }
         $this->replaceUrl($result);
         //dd($result);
         $result = $this->dataDeal($result);
         $classify = new Classify();
         $templates = new TemplatesController();
         $c_arr = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3, 4, 5, 6))->where('pc_show', '=', 1)->get()->toArray();
         foreach ($result as &$v) {
             if ($v['type'] == 'list') {
                 if (isset($v['config']['mustchild']) && $v['config']['mustchild'] == true) {
                     if (isset($v['config']['filter'])) {
                         if ($v['config']['filter'] == 'page') {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(4));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                         } elseif ($v['config']['filter'] == 'list') {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(1, 2, 3));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         } elseif ($v['config']['filter'] == 'feedback') {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(5));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                         } elseif ($v['config']['filter'] == 'ALL') {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(1, 2, 3, 4, 5, 6));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         } else {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(1, 2, 3, 4));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         }
                     } else {
                         $c_arr = $classify->toTree($c_arr);
                         $templates->unsetFalseClassify($c_arr, array(1, 2, 3));
                         $templates->unsetLastClassify($c_arr);
                         $c_arr = array_merge($c_arr);
                         $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                     }
                     if (count($c_arr)) {
                         $v['config']['id'] = $c_arr[0]['id'];
                     }
                 } else {
                     if (isset($v['config']['filter'])) {
                         if ($v['config']['filter'] == 'page') {
                             $v['config']['id'] = Classify::where('cus_id', $this->cus_id)->where('type', 4)->where('pc_show', 1)->pluck('id');
                         } elseif ($v['config']['filter'] == 'list') {
                             $v['config']['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3))->where('pc_show', 1)->pluck('id');
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         } elseif ($v['config']['filter'] == 'feedback') {
                             $v['config']['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(5))->where('pc_show', 1)->pluck('id');
                         } elseif ($v['config']['filter'] == 'ALL') {
                             $v['config']['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3, 4, 5, 6))->where('pc_show', 1)->pluck('id');
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         } else {
                             $v['config']['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3, 4))->where('pc_show', 1)->pluck('id');
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         }
                     } else {
                         $v['config']['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3))->where('pc_show', 1)->pluck('id');
                         $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                     }
                 }
             } elseif ($v['type'] == 'page') {
                 if (isset($v['config']['mustchild']) && $v['config']['mustchild'] == true) {
                     $c_arr = Classify::where('cus_id', $this->cus_id)->where('type', 4)->where('pc_show', 1)->get()->toArray();
                     $c_arr = $classify->toTree($c_arr);
                     $templates->unsetLastClassify($c_arr);
                     $c_arr = array_merge($c_arr);
                     if (count($c_arr)) {
                         $v['config']['id'] = $c_arr[0]['id'];
                     }
                 } else {
                     $v['config']['id'] = Classify::where('cus_id', $this->cus_id)->where('type', 4)->where('pc_show', 1)->pluck('id');
                 }
             } elseif ($v['type'] == 'navs') {
                 if (isset($v['config']['mustchild']) && $v['config']['mustchild'] == true) {
                     if (isset($v['config']['filter'])) {
                         if ($v['config']['filter'] == 'page') {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(4));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                         } elseif ($v['config']['filter'] == 'list') {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(1, 2, 3));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         } elseif ($v['config']['filter'] == 'ALL') {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(1, 2, 3, 4, 6));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         } else {
                             $c_arr = $classify->toTree($c_arr);
                             $templates->unsetFalseClassify($c_arr, array(1, 2, 3, 4));
                             $templates->unsetLastClassify($c_arr);
                             $c_arr = array_merge($c_arr);
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         }
                     } else {
                         $c_arr = $classify->toTree($c_arr);
                         $templates->unsetFalseClassify($c_arr, array(1, 2, 3));
                         $templates->unsetLastClassify($c_arr);
                         $c_arr = array_merge($c_arr);
                         $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                     }
                 } else {
                     if (isset($v['config']['filter'])) {
                         if ($v['config']['filter'] == 'page') {
                             $c_arr[0]['id'] = Classify::where('cus_id', $this->cus_id)->where('type', 4)->where('pc_show', 1)->pluck('id');
                         } elseif ($v['config']['filter'] == 'list') {
                             $c_arr[0]['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3))->where('pc_show', 1)->pluck('id');
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         } elseif ($v['config']['filter'] == 'ALL') {
                             $c_arr[0]['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3, 4, 6))->where('pc_show', 1)->pluck('id');
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         } else {
                             $c_arr[0]['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3, 4))->where('pc_show', 1)->pluck('id');
                             $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                         }
                     } else {
                         $c_arr[0]['id'] = Classify::where('cus_id', $this->cus_id)->whereIn('type', array(1, 2, 3))->where('pc_show', 1)->pluck('id');
                         $v['config']['limit'] = isset($v['config']['limit']) ? $v['config']['limit'] : 20;
                     }
                 }
                 $ids = "";
                 $num = $v['config']['limit'];
                 if (count($c_arr)) {
                     $ids = array();
                     for ($i = 0; $i < $num; $i++) {
                         $ids[$i] = $c_arr[0]['id'];
                     }
                 }
                 $v['config']['ids'] = $ids;
             }
         }
     }
     return $result;
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 /**
  * ===模板更换===
  * @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);
 }