public function classifySort() { $cus_id = Auth::id(); $indexlist = Input::get('indexlist'); foreach ($indexlist as $key => $value) { //dd($value['index']); $classify = Classify::find($value['id']); //dd($classify); $classify->sort = $value['index']; $classify->pushed = 1; $classify->save(); } $result = ['err' => 0, 'msg' => '']; return Response::json($result); }
/** * 显示栏目页的某个分页 * * @param int $id 栏目id * @param int $page 当前页码 */ public function categoryPreview($id, $page) { $result = $this->pagePublic($id); foreach ($result['navs'] as $nav) { if ($nav['current'] == 1) { $pagenavs = $nav['childmenu']; break; } else { $pagenavs = []; } } $classify = Classify::find($id); $result['title'] = $classify->name; $result['keywords'] = $classify->meta_keywords; $result['description'] = $classify->meta_description; $result['list']['name'] = $classify->name; $result['list']['en_name'] = $classify->en_name; $result['list']['description'] = $classify->meta_description; $result['list']['icon'] = '<i class="iconfont">' . $classify->icon . '</i>'; $result['list']['image'] = $this->source_dir . 's/category/' . $classify->img; $result['list']['type'] = $classify->type; if ($this->showtype == 'preview') { $result['list']['link'] = $this->domain . '/category/' . $id; } else { $result['list']['link'] = $this->domain . '/category/' . $id . '.html'; } $result['pagenavs'] = $pagenavs; $result['posnavs'] = $this->getPosNavs($id); if ($classify->type == 1) { //文字列表 $viewname = 'list-text'; } elseif ($classify->type == 2) { //图片列表 $viewname = 'list-image'; } elseif ($classify->type == 3) { //图文列表 $viewname = 'list-imagetext'; } elseif ($classify->type == 4) { //内容单页 $viewname = 'list-page'; } else { //跳转404 } //echo $viewname;exit; if (in_array($classify->type, array(1, 2, 3, 4))) { $sub = str_replace('-', '_', $viewname); $data = $this->pagedata($viewname); $index = $this->detailList($data); $result = array_add($result, $sub, $index); $data_index = $this->pagedata($viewname); $index_list = $this->pageList($id, $page); if ($classify->type == 4) { if ($this->showtype == 'preview') { $result['list']['content'] = Page::where('id', $classify->page_id)->pluck('content'); } else { $result['list']['content'] = preg_replace('/\\/customers\\/' . $this->customer . '/i', '', Page::where('id', $classify->page_id)->pluck('content')); } } else { $result['list']['data'] = $index_list['data']; } $result['page_links'] = $index_list['page_links']; $json_keys = $this->getJsonKey($viewname . '.html'); if (count($json_keys)) { foreach ($json_keys as $key) { $result[$key] = $this->detailList($this->pagedata($key)); } } $smarty = new Smarty(); $smarty->setTemplateDir(app_path('views/templates/' . $this->themename)); $smarty->setCompileDir(app_path('storage/views/compile')); $smarty->registerPlugin('function', 'mapExt', array('PrintController', 'createMap')); $smarty->registerPlugin('function', 'shareExt', array('PrintController', 'createShare')); $smarty->assign($result); $smarty->display($viewname . '.html'); //return View::make('templates.'.$this->themename.'.'.$viewname,$result); } }
/** * 推送栏目页的某个分页 * * @param int $id 栏目id * @param int $page 总页码 */ public function categoryPush($id, $page, $publicdata, $last_html_precent, $html_precent) { $paths = []; $result = $publicdata['result']; $result['navs'] = $this->publicnavs($id); $result['index_navs'] = $result['navs']; foreach ((array) $result['navs'] as $nav) { if ($nav['current'] == 1) { $pagenavs = $nav['childmenu']; break; } else { $pagenavs = []; } } $classify = Classify::find($id); $customerinfo = CustomerInfo::where("cus_id", $this->cus_id)->first(); $result['title'] = $customerinfo->title != "" ? $customerinfo->title . '-' . $classify->name : $classify->name; $result['keywords'] = $classify->meta_keywords != "" ? $classify->meta_keywords : $customerinfo->keywords; $result['description'] = $classify->meta_description != "" ? $classify->meta_description : $customerinfo->description; $result['list']['name'] = $classify->name; $result['list']['en_name'] = $classify->en_name; $result['list']['description'] = $classify->meta_description; $result['list']['icon'] = '<i class="iconfont">' . $classify->icon . '</i>'; $result['list']['image'] = $classify->img ? $this->source_dir . 's/category/' . $classify->img : ''; $result['list']['type'] = $classify->type; if ($this->showtype == 'preview') { $result['list']['link'] = $this->domain . '/category/' . $id; } else { $result['list']['link'] = $this->domain . '/category/' . $id . '.html'; } $result['pagenavs'] = $pagenavs; $result['posnavs'] = $this->getPosNavs($id); if ($classify->type == 1) { //文字列表 $viewname = 'list-text'; } elseif ($classify->type == 2) { //图片列表 $viewname = 'list-image'; } elseif ($classify->type == 3) { //图文列表 $viewname = 'list-imagetext'; } elseif ($classify->type == 4) { //内容单页 $viewname = 'list-page'; } elseif ($classify->type == 5) { //留言板 $viewname = 'list-page'; } elseif ($classify->type == 9) { //万用表单 //===获取数据=== $viewname = 'list-page'; $form_id = $classify->form_id; $formC = new FormController(); $formCdata = $formC->getFormdataForPrint($form_id); } else { //跳转404 } if (in_array($classify->type, array(1, 2, 3, 4, 5, 9))) { $sub = str_replace('-', '_', $viewname); $data = $this->pagedata($viewname, $publicdata['pagedata']); $index = $this->detailList($data); $result = array_add($result, $sub, $index); $data_index = $this->pagedata($viewname); if ($classify->type == 4) { if ($this->showtype == 'preview') { $result['list']['content'] = Page::where('id', $classify->page_id)->pluck('content'); } else { $result['list']['content'] = preg_replace('/\\/customers\\/' . $this->customer . '/i', '', Page::where('id', $classify->page_id)->pluck('content')); } } elseif ($classify->type == 5) { $customer_info = CustomerInfo::where('cus_id', $this->cus_id)->first(); if ($customer_info->lang == 'en') { $result['list']['content'] = '<form action="http://swap.5067.org/message/' . $this->cus_id . '" method="post" name="messageboard" onsubmit="return CheckPost();" class="elegant-aero"> <h1>' . $classify->name . ' <span>' . $classify->en_name . '</span> </h1> <label> <span>Name :</span> <input id="name" type="text" name="name" placeholder="Name" /> </label> <label> <span>Email :</span> <input id="email" type="email" name="email" placeholder="Email Address" /> </label> <label> <span>Tel :</span> <input id="telephone" type="tel" name="telephone" placeholder="Telephone" /> </label> <label> <label> <span>Content :</span> <textarea id="content" name="content" placeholder="You mind ...."></textarea> </label> <label> <span> </span> <input type="submit" class="button" name="submit" value="Submit" /> </label> </form>'; } else { $result['list']['content'] = '<form action="http://swap.5067.org/message/' . $this->cus_id . '" method="post" name="messageboard" onsubmit="return CheckPost();" class="elegant-aero"> <h1>' . $classify->name . ' <span>' . $classify->en_name . '</span> </h1> <label> <span>姓名 :</span> <input id="name" type="text" name="name" placeholder="Name" /> </label> <label> <span>Email :</span> <input id="email" type="email" name="email" placeholder="Email Address" /> </label> <label> <span>联系电话 :</span> <input id="telephone" type="tel" name="telephone" placeholder="Telephone" /> </label> <label> <span>内容 :</span> <textarea id="content" name="content" placeholder="You mind ...."></textarea> </label> <label> <span> </span> <input type="submit" class="button" name="submit" value="提交" /> </label> </form>'; } } elseif ($classify->type == 9) { //===显示前端=== $result['list']['content'] = $formC->showFormHtmlForPrint($formCdata); } $json_keys = $this->getJsonKey($viewname . '.html'); if (count($json_keys)) { foreach ($json_keys as $key) { $result[$key] = $this->detailList($this->pagedata($key)); } } if ($classify->type == 5) { $result['footscript'] .= '<STYLE TYPE="text/css"> <!-- .elegant-aero { margin-left:auto; margin-right:auto; width: 90%; max-width: 500px; /*background: #D2E9FF;*/ padding: 20px 20px 20px 20px; font: 12px Arial, Helvetica, sans-serif; /*color: #666;*/ } .input[placeholder]{color:#5c5c5c;} .elegant-aero h1 { font: 24px "Trebuchet MS", Arial, Helvetica, sans-serif; padding: 10px 10px 10px 20px; display: block; /*background: #C0E1FF;*/ border-bottom: 1px solid #B8DDFF; margin: -20px -20px 15px; } .elegant-aero h1>span { display: block; font-size: 11px; } .elegant-aero label>span { float: left; margin-top: 10px; /*color: #5E5E5E;*/ } .elegant-aero label { display: block; margin: 0px 0px 5px; } .elegant-aero label>span { float: left; width: 25%; text-align: right; padding-right: 10px; margin-top: 10px; font-weight: bold; } .elegant-aero input[type="text"], .elegant-aero input[type="tel"], .elegant-aero input[type="email"], .elegant-aero textarea, .elegant-aero select { color: #888; width: 65%; padding: 0px 0px 0px 5px; border: 1px solid #C5E2FF; background: #FBFBFB; outline: 0; -webkit-box-shadow:inset 0px 1px 6px #ECF3F5; box-shadow: inset 0px 1px 6px #ECF3F5; font: 200 12px/25px Arial, Helvetica, sans-serif; height: 30px; line-height:15px; margin: 2px 4px 16px 0px; } .elegant-aero textarea{ height:100px; padding: 5px 0px 0px 5px; width: 65%; } .elegant-aero select { background: #fbfbfb url(\'down-arrow.png\') no-repeat right; background: #fbfbfb url(\'down-arrow.png\') no-repeat right; appearance:none; -webkit-appearance:none; -moz-appearance: none; text-indent: 0.01px; text-overflow: \'\'; width: 70%; } .elegant-aero .button{ padding: 10px 30px 10px 30px; background: #ACB5B7; border: none; color: #FFF; box-shadow: 1px 1px 1px #4C6E91; -webkit-box-shadow: 1px 1px 1px #4C6E91; -moz-box-shadow: 1px 1px 1px #4C6E91; text-shadow: 1px 1px 1px #5079A3; } .elegant-aero .button:hover{ background: #C5CFD2; color: #6B6262; }--> </STYLE> <SCRIPT language=javascript> function CheckPost() { if (messageboard.name.value=="") { alert("请填写您的姓名"); messageboard.name.focus(); return false; } if (messageboard.content.value=="") { alert("必须要填写留言内容"); messageboard.content.focus(); return false; } if (messageboard.telephone.value!="") { if(isNaN(messageboard.telephone.value)){ alert("电话号码请填写数字"); messageboard.telephone.focus(); return false; } if(!(/^1[3|4|5|7|8]\\d{9}$/.test(messageboard.telephone.value))){ alert("手机号码有误"); messageboard.telephone.focus(); return false; } } } </SCRIPT>'; } if ($classify->type == 9) { //===加载css\js=== $result['footscript'] .= $formC->assignFormCSSandJSForPrint(); } $the_result = $result; $index_list = $this->pageList($id, 1); $the_result['page_links'] = $index_list['page_links']; //===显示类型不是'list-page'=== if ($classify->type != 5 && $classify->type != 4 && $classify->type != 9) { $the_result['list']['data'] = $index_list['data']; $the_result['list']['total'] = $index_list['page_links']['total']; } //===页面名字.html=== // if ($classify->view_name) { // $path = $this->type == 'pc' ? public_path('customers/' . $this->customer . '/category/v/' . $classify->view_name . '.html') : public_path('customers/' . $this->customer . '/mobile/category/v/' . $classify->view_name . '.html'); // } else { $path = $this->type == 'pc' ? public_path('customers/' . $this->customer . '/category/' . $id . '.html') : public_path('customers/' . $this->customer . '/mobile/category/' . $id . '.html'); // } $content = $publicdata['repleace'][$viewname . '.html']; $content = preg_replace($publicdata['pattern'], $publicdata['repleace'], $content); $output = $this->pushdisplay($the_result, $content); if (!count($result['footer_navs'])) { $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>首页<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>Home<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); } file_put_contents($path, $output); $paths[] = $path; $nowpercent = $last_html_precent + $html_precent; if (floor($nowpercent) !== floor($last_html_precent)) { echo '<div class="prompt">' . floor($nowpercent) . '%</div><script type="text/javascript">refresh(' . floor($nowpercent) . ');</script>'; ob_flush(); flush(); PushQueue::where('pushtime', '<', time() - 60)->delete(); PushQueue::where('cus_id', $this->cus_id)->update(['pushtime' => time()]); } $last_html_precent += $html_precent; //===显示类型不是'list-page'=== if ($classify->type != 5 && $classify->type != 4 && $classify->type != 9) { for ($i = 1; $i <= $page; $i++) { $the_result = $result; $index_list = $this->pageList($id, $i); $the_result['page_links'] = $index_list['page_links']; $the_result['list']['data'] = $index_list['data']; $the_result['list']['total'] = $index_list['page_links']['total']; //===页面名字.html=== if ($classify->view_name) { $path = $this->type == 'pc' ? public_path('customers/' . $this->customer . '/category/' . $classify->view_name . '_' . $i . '.html') : public_path('customers/' . $this->customer . '/mobile/category/' . $classify->view_name . '_' . $i . '.html'); } else { $path = $this->type == 'pc' ? public_path('customers/' . $this->customer . '/category/' . $id . '_' . $i . '.html') : public_path('customers/' . $this->customer . '/mobile/category/' . $id . '_' . $i . '.html'); } //===end=== $output = $this->pushdisplay($the_result, $content); if (!count($result['footer_navs'])) { $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>首页<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>Home<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); } file_put_contents($path, $output); $paths[] = $path; $nowpercent = $last_html_precent + $html_precent; if (floor($nowpercent) !== floor($last_html_precent)) { echo '<div class="prompt">' . floor($nowpercent) . '%</div><script type="text/javascript">refresh(' . floor($nowpercent) . ');</script>'; ob_flush(); flush(); PushQueue::where('pushtime', '<', time() - 60)->delete(); PushQueue::where('cus_id', $this->cus_id)->update(['pushtime' => time()]); } $last_html_precent += $html_precent; } } return $paths; //return View::make('templates.'.$this->themename.'.'.$viewname,$result); } }
private function delChildClassify($c_id) { $cus_id = Auth::id(); $del_imgs = array(); $child_ids = Classify::where('p_id', $c_id)->where('cus_id', $cus_id)->lists('id'); if (count($child_ids)) { foreach ($child_ids as $id) { $classify = Classify::find($id); $c_del_img = $classify->img; $ids = Articles::where('c_id', $id)->lists('id'); $a_del_imgs = Articles::where('c_id', $id)->lists('img'); if (count($ids)) { $m_del_imgs = MoreImg::whereIn('a_id', (array) $ids)->lists('img'); } else { $m_del_imgs = array(); } $del_imgs = array_merge((array) $a_del_imgs, (array) $m_del_imgs); Classify::where('id', $id)->where('cus_id', $cus_id)->delete(); Articles::where('c_id', $id)->where('cus_id', $cus_id)->delete(); foreach ((array) $del_imgs as $val) { $imgdel = new ImgDel(); $imgdel->mysave($val); } $imgdel = new ImgDel(); $imgdel->mysave($c_del_img, 'category'); $this->delMobileHomepage($id); $this->delChildClassify($id); } } }