/**
  * Method to display global configuration.
  *
  * @return  boolean  True on success, false on failure.
  *
  * @since   3.2
  */
 public function execute()
 {
     // Get the application
     $app = $this->getApplication();
     // Get the document object.
     $document = JFactory::getDocument();
     $viewName = $this->input->getWord('view', 'templates');
     $viewFormat = $document->getType();
     $layoutName = $this->input->getWord('layout', 'default');
     // Access backend com_config
     JLoader::register('TemplatesController', JPATH_ADMINISTRATOR . '/components/com_templates/controller.php');
     JLoader::register('TemplatesViewStyle', JPATH_ADMINISTRATOR . '/components/com_templates/views/style/view.json.php');
     JLoader::register('TemplatesModelStyle', JPATH_ADMINISTRATOR . '/components/com_templates/models/style.php');
     $displayClass = new TemplatesController();
     // Set backend required params
     $document->setType('json');
     $this->input->set('id', $app->getTemplate('template')->id);
     // Execute backend controller
     $serviceData = json_decode($displayClass->display(), true);
     // Reset params back after requesting from service
     $document->setType('html');
     $this->input->set('view', $viewName);
     // Register the layout paths for the view
     $paths = new SplPriorityQueue();
     $paths->insert(JPATH_COMPONENT . '/view/' . $viewName . '/tmpl', 'normal');
     $viewClass = 'ConfigView' . ucfirst($viewName) . ucfirst($viewFormat);
     $modelClass = 'ConfigModel' . ucfirst($viewName);
     if (class_exists($viewClass)) {
         if ($viewName != 'close') {
             $model = new $modelClass();
             // Access check.
             if (!JFactory::getUser()->authorise('core.admin', $model->getState('component.option'))) {
                 $app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
                 return;
             }
         }
         $view = new $viewClass($model, $paths);
         $view->setLayout($layoutName);
         // Push document object into the view.
         $view->document = $document;
         // Load form and bind data
         $form = $model->getForm();
         if ($form) {
             $form->bind($serviceData);
         }
         // Set form and data to the view
         $view->form =& $form;
         // Render view.
         echo $view->render();
     }
     return true;
 }
Пример #2
0
    case 'save_source':
    case 'apply_source':
        TemplatesController::saveTemplateSource();
        break;
    case 'choose_css':
        TemplatesController::chooseTemplateCSS();
        break;
    case 'edit_css':
        TemplatesController::editTemplateCSS();
        break;
    case 'save_css':
    case 'apply_css':
        TemplatesController::saveTemplateCSS();
        break;
    case 'publish':
    case 'default':
        TemplatesController::publishTemplate();
        break;
    case 'cancel':
        TemplatesController::cancelTemplate();
        break;
    case 'save_positions':
        TemplatesController::savePositions();
        break;
    case 'preview':
        TemplatesController::previewTemplate();
        break;
    default:
        TemplatesController::viewTemplates();
        break;
}
Пример #3
0
 /**
  * 推送
  * 
  * 
  */
 public function pushPrecent()
 {
     if (ob_get_level() == 0) {
         ob_start();
     }
     $indexhtml = $this->homgepagehtml('pc');
     $customer_data_get = CustomerPushfile::where('cus_id', $this->cus_id)->pluck('files');
     if ($customer_data_get) {
         $new_data = 0;
         $customer_data = unserialize($customer_data_get);
     } else {
         $new_data = 1;
         $customer_data = [];
     }
     $mindexhtml = $this->homgepagehtml('mobile');
     $pc_classify_ids = Classify::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id');
     $mobile_classify_ids = Classify::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id');
     $pc_article_ids = Articles::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id');
     $mobile_article_ids = Articles::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id');
     $count = $this->htmlPagecount($pc_classify_ids, $mobile_classify_ids, $pc_article_ids, $mobile_article_ids);
     $this->html_precent = 70 / $count;
     $categoryhtml = $this->categoryhtml($pc_classify_ids, 'pc');
     $mcategoryhtml = $this->categoryhtml($mobile_classify_ids, 'mobile');
     $articlehtml = $this->articlehtml($pc_article_ids, 'pc');
     $marticlehtml = $this->articlehtml($mobile_article_ids, 'mobile');
     $this->percent = 20 / $count;
     $path = public_path('customers/' . $this->customer . '/' . $this->customer . '.zip');
     $template = new PrintController('online', 'mobile');
     $quickbar_json = $template->quickBarJson();
     $zip = new ZipArchive();
     if ($zip->open($path, ZipArchive::CREATE) === TRUE) {
         $zip->addFile($indexhtml, 'index.html');
         $nowpercent = $this->percent + $this->lastpercent;
         if (floor($nowpercent) != $this->lastpercent) {
             echo floor($nowpercent) . '%<script type="text/javascript">parent.refresh(' . floor($nowpercent) . ');</script><br />';
             ob_flush();
             flush();
         }
         $this->lastpercent += 70 + $this->percent;
         $zip->addFile($mindexhtml, 'mobile/index.html');
         $nowpercent = $this->percent + $this->lastpercent;
         if (floor($nowpercent) != floor($this->lastpercent)) {
             echo floor($nowpercent) . '%<script type="text/javascript">parent.refresh(' . floor($nowpercent) . ');</script><br />';
             ob_flush();
             flush();
         }
         $this->lastpercent += $this->percent;
         $zip->close();
     }
     //$customer_data = $this->compareZip($categoryhtml,$customer_data,'p','category',$path);
     //$customer_data = $this->compareZip($mcategoryhtml,$customer_data,'m','mobile/category',$path);
     //$customer_data = $this->compareZip($articlehtml,$customer_data,'pf','detail',$path);
     //$customer_data = $this->compareZip($marticlehtml,$customer_data,'mf','mobile/detail',$path);
     $this->compareZip($categoryhtml, $customer_data, 'p', 'category', $path);
     $this->compareZip($mcategoryhtml, $customer_data, 'm', 'mobile/category', $path);
     $this->compareZip($articlehtml, $customer_data, 'pf', 'detail', $path);
     $this->compareZip($marticlehtml, $customer_data, 'mf', 'mobile/detail', $path);
     if (90 > floor($this->lastpercent)) {
         echo '90%<script type="text/javascript">parent.refresh(90);</script><br />';
         ob_flush();
         flush();
     }
     if ($zip->open($path, ZipArchive::CREATE) === TRUE) {
         $pc_dir = Template::where('website_info.cus_id', $this->cus_id)->Leftjoin('website_info', 'website_info.pc_tpl_id', '=', 'template.id')->pluck('name');
         $mobile_dir = Template::where('website_info.cus_id', $this->cus_id)->Leftjoin('website_info', 'template.id', '=', 'website_info.mobile_tpl_id')->pluck('name');
         $aim_dir = public_path("templates/{$pc_dir}/");
         $maim_dir = public_path("templates/{$mobile_dir}/");
         //$images_dir=public_path("customers/".$this->customer."/images/");
         $this->addDir($aim_dir, $zip);
         //$this->addDir($images_dir,$zip,'images/');
         $this->addDir($maim_dir, $zip, 'mobile/');
         $zip->close();
         $data = serialize($customer_data);
         if ($new_data) {
             $customerpushfile = new CustomerPushfile();
             $customerpushfile->cus_id = $this->cus_id;
             $customerpushfile->files = $data;
             $customerpushfile->save();
         } else {
             CustomerPushfile::where('cus_id', $this->cus_id)->update(['files' => $data]);
         }
         $customerinfo = Customer::find($this->cus_id);
         $ftp_array = explode(':', $customerinfo->ftp_address);
         $ftp_array[1] = isset($ftp_array[1]) ? $ftp_array[1] : '21';
         $conn = ftp_connect($ftp_array[0], $ftp_array[1]);
         if ($conn) {
             ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd);
             ftp_pasv($conn, 1);
             ftp_put($conn, "site.zip", $path, FTP_BINARY);
             ftp_put($conn, "unzip.php", public_path("packages/unzip.php"), FTP_ASCII);
             ftp_put($conn, "quickbar.json", public_path('customers/' . $this->customer . '/quickbar.json'), FTP_ASCII);
             ftp_put($conn, "mobile/quickbar.json", public_path('customers/' . $this->customer . '/quickbar.json'), FTP_ASCII);
             ftp_close($conn);
         }
         echo '100%<script type="text/javascript">parent.refresh(100);</script><br />';
         Classify::where('cus_id', $this->cus_id)->where('pushed', 1)->update(['pushed' => 0]);
         Articles::where('cus_id', $this->cus_id)->where('pushed', 1)->update(['pushed' => 0]);
         $search_data = new TemplatesController();
         $search_data->sendData();
         $pc_domain = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_domain');
         @file_get_contents("{$pc_domain}/unzip.php");
     } else {
         echo '打包失败';
     }
     ob_end_flush();
 }
Пример #4
0
 /**
  * 公共数据
  * @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;
 }
Пример #5
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;
 }
Пример #6
0
 /**
  * 代理平台下载模板
  * @param type name 用户名
  * @return string
  */
 public function DownloadTemplate()
 {
     if (Input::has("token") && Input::get("token") == md5("linshimingma")) {
         $template = new TemplatesController();
         return $template->downloadTemplate(Input::get("name"));
     } else {
         return json_encode(array("err" => 1, "msg" => "err!"));
     }
 }