예제 #1
0
 /**
  * 计算生成html文件的数量
  * 
  * @param array $pc_classify_ids  pc栏目id
  * @param array $mobile_classify_ids 手机栏目id
  * @param array $pc_article_ids  pc文章id
  * @param array $mobile_article_ids 手机文章id
  * @return int
  */
 private function htmlPagecount($pc_classify_ids = [], $mobile_classify_ids = [], $pc_article_ids = [], $mobile_article_ids = [])
 {
     $template = new PrintController();
     $page_count = 2;
     $pc_per_page = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_page_count');
     foreach ($pc_classify_ids as $id) {
         $c_ids = explode(',', $template->getChirldenCid($id));
         $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('pc_show', '1')->count();
         if ($total) {
             $page_count += ceil($total / $pc_per_page);
         } else {
             $page_count++;
         }
     }
     $mobileper_page = CustomerInfo::where('cus_id', $this->cus_id)->pluck('mobile_page_count');
     foreach ($pc_classify_ids as $id) {
         $c_ids = explode(',', $template->getChirldenCid($id));
         $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('mobile_show', '1')->count();
         if ($total) {
             $page_count += ceil($total / $mobileper_page);
         } else {
             $page_count++;
         }
     }
     $page_count += count($pc_article_ids);
     $page_count += count($mobile_article_ids);
     return $page_count;
 }
예제 #2
0
 /**
  * 
  * @param type $c_id
  * @param type $is_star
  * @param type $per_page
  * @param type $search_word ===搜索关键字===
  * @return type
  */
 public function articleListData($c_id = 0, $is_star = 0, $per_page = 15, $search_word = '')
 {
     $cus_id = Auth::id();
     if (!empty($search_word)) {
         if ($c_id) {
             $cus_data = new PrintController();
             $c_ids = explode(',', $cus_data->getChirldenCid($c_id));
             if ($is_star) {
                 $article_list = Articles::whereIn('c_id', $c_ids)->where('title', 'like', '%' . $search_word . '%')->where('is_star', '=', $is_star)->orderBy('is_top', 'DESC')->orderBy('sort', 'ASC')->orderBy('created_at', 'DESC')->paginate($per_page);
             } else {
                 $article_list = Articles::whereIn('c_id', $c_ids)->where('title', 'like', '%' . $search_word . '%')->orderBy('is_top', 'DESC')->orderBy('sort', 'ASC')->orderBy('created_at', 'DESC')->paginate($per_page);
             }
         } else {
             if ($is_star) {
                 $article_list = Articles::where('cus_id', '=', $cus_id)->where('title', 'like', '%' . $search_word . '%')->where('is_star', '=', $is_star)->orderBy('is_top', 'DESC')->orderBy('sort', 'ASC')->orderBy('created_at', 'DESC')->paginate($per_page);
             } else {
                 $article_list = Articles::where('cus_id', '=', $cus_id)->where('title', 'like', '%' . $search_word . '%')->orderBy('is_top', 'DESC')->orderBy('sort', 'ASC')->orderBy('created_at', 'DESC')->paginate($per_page);
             }
         }
     } else {
         if ($c_id) {
             $cus_data = new PrintController();
             $c_ids = explode(',', $cus_data->getChirldenCid($c_id));
             if ($is_star) {
                 $article_list = Articles::whereIn('c_id', $c_ids)->where('is_star', '=', $is_star)->orderBy('is_top', 'DESC')->orderBy('sort', 'ASC')->orderBy('created_at', 'DESC')->paginate($per_page);
             } else {
                 $article_list = Articles::whereIn('c_id', $c_ids)->orderBy('is_top', 'DESC')->orderBy('sort', 'ASC')->orderBy('created_at', 'DESC')->paginate($per_page);
             }
         } else {
             if ($is_star) {
                 $article_list = Articles::where('cus_id', '=', $cus_id)->where('is_star', '=', $is_star)->orderBy('is_top', 'DESC')->orderBy('sort', 'ASC')->orderBy('created_at', 'DESC')->paginate($per_page);
             } else {
                 $article_list = Articles::where('cus_id', '=', $cus_id)->orderBy('is_top', 'DESC')->orderBy('sort', 'ASC')->orderBy('created_at', 'DESC')->paginate($per_page);
             }
         }
     }
     $article_arr = $article_list->toArray();
     if (count($article_arr['data'])) {
         foreach ($article_arr['data'] as $k => $v) {
             $moring = [];
             $article_arr['data'][$k]['c_name'] = Classify::where('id', $v['c_id'])->pluck('name');
             $moring = Moreimg::where('a_id', $v['id'])->orderBy('sort')->lists('img');
             array_unshift($moring, $v['img']);
             $article_arr['data'][$k]['img'] = $moring;
             unset($moring);
         }
         return $article_arr;
     }
 }
예제 #3
0
 /**
  * 计算生成html文件的数量
  * 
  * @param array $pc_classify_ids  pc栏目id
  * @param array $mobile_classify_ids 手机栏目id
  * @param array $pc_article_ids  pc文章id
  * @param array $mobile_article_ids 手机文章id
  * @return int
  */
 private function htmlPagecount($pc_classify_ids = [], $mobile_classify_ids = [], $pc_article_ids = [], $mobile_article_ids = [])
 {
     $template = new PrintController();
     $page_count = 2;
     $pc_per_page = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_page_count');
     foreach ((array) $pc_classify_ids as $id) {
         $c_ids = explode(',', ltrim($template->getChirldenCid($id, 1)));
         $a_c_type = Classify::where('id', $id)->pluck('type');
         //取得栏目的type
         $pc_page_count_switch = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_page_count_switch');
         //页面图文列表图文显示个数是否分开控制开关
         if (isset($pc_page_count_switch) && $pc_page_count_switch == 1 && $a_c_type <= 3) {
             if ($a_c_type == 1) {
                 $page_number = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_page_txt_count');
                 //每页文字显示个数
                 $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('pc_show', '1')->count();
                 if ($total) {
                     $page_count += ceil($total / $page_number) + 1;
                 } else {
                     $page_count += 2;
                 }
             }
             if ($a_c_type == 3) {
                 $page_number = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_page_imgtxt_count');
                 //每页图文显示个数
                 $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('pc_show', '1')->count();
                 if ($total) {
                     $page_count += ceil($total / $page_number) + 1;
                 } else {
                     $page_count += 2;
                 }
             }
             if ($a_c_type == 2) {
                 $page_number = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_page_img_count');
                 //每页图片显示个数
                 $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('pc_show', '1')->count();
                 if ($total) {
                     $page_count += ceil($total / $page_number) + 1;
                 } else {
                     $page_count += 2;
                 }
             }
         } else {
             $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('pc_show', '1')->count();
             if ($total) {
                 $page_count += ceil($total / $pc_per_page) + 1;
             } else {
                 $page_count += 2;
             }
         }
     }
     $mobileper_page = CustomerInfo::where('cus_id', $this->cus_id)->pluck('mobile_page_count');
     if (!empty($mobile_classify_ids)) {
         foreach ((array) $mobile_classify_ids as $id) {
             $c_ids = explode(',', $template->getChirldenCid($id, 1));
             $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('mobile_show', '1')->count();
             if ($total) {
                 $page_count += ceil($total / $mobileper_page);
             } else {
                 $page_count++;
             }
         }
     }
     $page_count += count($pc_article_ids);
     $page_count += count($mobile_article_ids);
     return $page_count;
 }