예제 #1
0
파일: Home.php 프로젝트: xxjuan/php-coffee
 /**
  * 首页
  */
 public function index()
 {
     // 搜索参数
     $get = $this->input->get(NULL, TRUE);
     $get = isset($get['rewrite']) ? dr_rewrite_decode($get['rewrite']) : $get;
     $get['keyword'] = str_replace(array('%', ' '), array('', '%'), $get['keyword']);
     unset($get['c'], $get['m'], $get['page']);
     $where = '';
     if ($get) {
         foreach ($get as $name => $v) {
             $where .= $name . '=' . $v . ' ';
         }
     }
     $this->template->assign(array('get' => $get, 'where' => $where, 'params' => $get, 'urlrule' => dr_space_search_url($get, 'page', '[page]'), 'meta_title' => $this->space['title'], 'meta_keywords' => $this->space['keywords'], 'meta_description' => $this->space['description']));
     $this->template->display('index.html');
 }
예제 #2
0
 /**
  * 搜索跳转
  */
 public function index()
 {
     $mod = $this->get_module(SITE_ID);
     //echo SITE_ID;
     if ($mod) {
         // 搜索参数
         $get = $this->input->get(NULL, TRUE);
         $get = isset($get['rewrite']) ? dr_rewrite_decode($get['rewrite']) : $get;
         $dir = $get['module'];
         $module = array();
         foreach ($mod as $mdir => $t) {
             if (!$t['setting']['search']['close']) {
                 $module[$mdir]['dir'] = $mdir;
                 $module[$mdir]['url'] = $t['url'];
                 $module[$mdir]['name'] = $t['name'];
                 $module[$mdir]['search'] = $this->_search($mdir);
                 if (!$dir && isset($module[$mdir]['search']['data']['params']['keyword'])) {
                     $dir = $module[$mdir]['search']['data']['params']['keyword'];
                 }
             }
         }
         if ($dir && isset($module[$dir])) {
             $now = $module[$dir];
         } else {
             $now = reset($module);
         }
         $dir = $now['dir'];
         $now = $now['search'];
         //var_dump($now);
         if ($get['keyword'] != '' || $now['data']['keyword'] != '') {
             $this->template->assign(array('module' => $module, 'dirname' => $dir, 'keyword' => $now['data']['keyword'] ? $now['data']['keyword'] : $get['keyword']));
             $this->template->assign($now['seoinfo']);
             $this->template->assign($now['data']);
             unset($now['seoinfo'], $now['data'], $now['keyword']);
             $this->template->assign($now);
             $this->template->display($get['name'] ? $get['name'] : 'solist.html');
         } else {
             if ($get['name']) {
                 exit('error');
             }
             $this->template->display('so.html');
         }
     } else {
         $this->msg('您还没有安装任何模块呢~');
     }
 }
 protected function _index()
 {
     // 搜索参数
     $get = $this->input->get(NULL, TRUE);
     $get = isset($get['rewrite']) ? dr_rewrite_decode($get['rewrite']) : $get;
     $_GET['page'] = max(1, (int) $get['page']);
     $get['keyword'] = str_replace(array('%', ' '), array('', '%'), $get['keyword']);
     unset($get['c'], $get['m'], $get['page']);
     $where = '';
     if ($get) {
         $field = $this->get_cache('member', 'field');
         $space = $this->get_cache('member', 'spacefield');
         foreach ($get as $name => $v) {
             if (isset($space[$name]) && $space[$name]['fieldtype'] == 'Linkage') {
                 // 组合空间字段的联动菜单
                 $link = dr_linkage($space[$name]['setting']['option']['linkage'], $v);
                 if ($link) {
                     if ($link['child']) {
                         $where .= 'IN_' . $name . '=' . $link['childids'] . ' ';
                     } else {
                         $where .= $name . '=' . $link['ii'] . ' ';
                     }
                 }
             } elseif (isset($field[$name]) && $field[$name]['fieldtype'] == 'Linkage') {
                 // 组合会员字段的联动菜单
                 $link = dr_linkage($field[$name]['setting']['option']['linkage'], $v);
                 if ($link) {
                     if ($link['child']) {
                         $where .= 'IN_' . $name . '=' . $link['childids'] . ' ';
                     } else {
                         $where .= $name . '=' . $link['ii'] . ' ';
                     }
                 }
             } else {
                 $where .= $name . '=' . $v . ' ';
             }
         }
     }
     $this->template->assign(array('get' => $get, 'where' => $where, 'params' => $get, 'keyword' => $get['keyword'], 'urlrule' => dr_space_search_url($get, 'page', '[page]'), 'meta_title' => $this->space['title'], 'meta_keywords' => $this->space['keywords'], 'meta_description' => $this->space['description']));
     $this->template->display('index.html');
 }
예제 #4
0
 /**
  * 模块内容搜索页
  */
 protected function _search($call = '')
 {
     // 对指定模块搜索
     if ($call) {
         $this->dir = $call;
     }
     $mod = $this->get_cache('module-' . SITE_ID . '-' . $this->dir);
     if (isset($mod['setting']['search']['close']) && $mod['setting']['search']['close']) {
         if ($call) {
             return NULL;
         } else {
             $this->msg(lang('m-125'));
         }
     }
     // 加载搜索模型
     if (is_file(FCPATH . $this->dir . 'models/Search_model.php')) {
         require_once FCPATH . $this->dir . 'models/Search_model.php';
     } else {
         require_once FCPATH . 'dayrui/models/Search_model.php';
     }
     $this->search_model = new Search_model();
     // 清除过期缓存
     $this->search_model->clear($mod['setting']['search']['cache']);
     // 搜索参数
     $get = $this->input->get(NULL, TRUE);
     $get = isset($get['rewrite']) ? dr_rewrite_decode($get['rewrite']) : $get;
     $id = $get['id'];
     $catid = (int) $get['catid'];
     $_GET['page'] = $get['page'];
     $get['keyword'] = str_replace(array('%', ' '), array('', '%'), $get['keyword']);
     unset($get['c'], $get['m'], $get['id'], $get['page']);
     // 关键字个数判断
     if ($get['keyword'] && strlen($get['keyword']) < (int) $mod['setting']['search']['length']) {
         if ($call) {
             return NULL;
         } else {
             $this->msg(lang('mod-31'));
         }
     }
     if ($id) {
         // 读缓存数据
         $data = $this->search_model->get($id);
         $catid = $data['catid'];
         $data['get'] = $data['params'];
         if (!$data) {
             if ($call) {
                 return NULL;
             } else {
                 $this->msg(lang('mod-32'));
             }
         }
     } else {
         // 实时组合搜索条件
         $data = $this->search_model->set($get);
     }
     list($parent, $related) = $this->_related_cat($mod, $catid);
     $seoinfo = dr_category_seo($mod, $mod['category'][$catid], max(1, (int) $this->input->get('page')));
     if ($call) {
         $urlrule = $mod['setting']['search']['rewrite'] ? SITE_URL . 'so-module-' . $this->dir . '-id-{id}-page-{page}.html' : SITE_URL . 'index.php?c=so&module=' . $this->dir . '&id={id}&page={page}';
         return array('cat' => $mod['category'][$catid], 'data' => $data, 'caitd' => $catid, 'parent' => $parent, 'seoinfo' => $seoinfo, 'keyword' => $get['keyword'], 'urlrule' => str_replace('{id}', $data['id'], $urlrule), 'sototal' => $data['contentid'] ? substr_count($data['contentid'], ',') + 1 : 0, 'searchid' => $data['id']);
     } else {
         $urlrule = $mod['setting']['search']['rewrite'] ? 'search-id-{id}-page-{page}.html' : 'index.php?c=search&id={id}&page={page}';
         $this->template->assign($seoinfo);
         $this->template->assign(array('cat' => $mod['category'][$catid], 'caitd' => $catid, 'parent' => $parent, 'related' => $related, 'keyword' => $get['keyword'], 'urlrule' => str_replace('{id}', $data['id'], $urlrule), 'sototal' => $data['contentid'] ? substr_count($data['contentid'], ',') + 1 : 0, 'searchid' => $data['id']));
         $this->template->assign($data);
         $this->template->display('search.html');
     }
 }
예제 #5
0
 /**
  * 模块内容搜索页
  */
 protected function _search($call = '')
 {
     //$call = $call.'dxal';
     //echo $call;
     //zjp添加,动态显示日期天气温度
     //$city="宜春";
     //$content = file_get_contents("http://api.map.baidu.com/telematics/v3/weather?location=宜春&output=json&ak=i8GFDZTM22uqICZbtioaVbnk");
     //$de_json = json_decode($content,TRUE);
     // 对指定模块搜索
     //8.13
     $type = $this->input->get('type');
     if ($type == "wsxf") {
         require_once FCPATH . $this->dir . '/models/Search_model.php';
         $this->search_model = new Search_model();
         // 清除过期缓存
         $this->search_model->clear($mod['setting']['search']['cache']);
         $get = $this->input->get(NULL);
         $get = isset($get['rewrite']) ? dr_rewrite_decode($get['rewrite']) : $get;
         $theme = $get['theme'];
         $_GET['page'] = $get['page'];
         $get['keyword'] = str_replace(array('%', ' '), array('', '%'), $get['keyword']);
         $keyword = $get['keyword'];
         // 关键字个数判断
         // 实时组合搜索条件
         $data = $this->search_model->set($get);
         list($parent, $related) = $this->_related_cat($mod, $catid);
         $seoinfo = dr_category_seo($mod, $mod['category'][$catid], max(1, (int) $this->input->get('page')));
         $urlrule = $mod['setting']['search']['rewrite'] ? 'search-id-{id}-page-{page}.html' : 'index.php?c=search&id={id}&page={page}';
         $this->template->assign($seoinfo);
         $this->template->assign(array('cat' => $mod['category'][$catid], 'get' => array_merge($get, $data['params']), 'caitd' => $catid, 'parent' => $parent, 'related' => $related, 'keyword' => $get['keyword'], 'urlrule' => str_replace('{id}', $data['id'], $urlrule), 'sototal' => $data['contentid'] ? substr_count($data['contentid'], ',') + 1 : 0, 'searchid' => $data['id'], 'theme' => $theme, 'keyword' => $keyword, 'de_json' => $de_json, 'pagenow' => $_GET['page']));
         $this->template->assign($data);
         $tpl = $catid && $mod['category'][$catid]['setting']['template']['search'] ? $mod['category'][$catid]['setting']['template']['search'] : 'search.html';
         $this->template->display($tpl);
     } elseif ($type == "question") {
         require_once FCPATH . $this->dir . '/models/Search_model.php';
         $this->search_model = new Search_model();
         // 清除过期缓存
         $this->search_model->clear($mod['setting']['search']['cache']);
         $get = $this->input->get(NULL);
         $get = isset($get['rewrite']) ? dr_rewrite_decode($get['rewrite']) : $get;
         $theme = $get['theme'];
         $_GET['page'] = $get['page'];
         $get['keyword'] = str_replace(array('%', ' '), array('', '%'), $get['keyword']);
         $keyword = $get['keyword'];
         // 关键字个数判断
         // 实时组合搜索条件
         $data = $this->search_model->set($get);
         list($parent, $related) = $this->_related_cat($mod, $catid);
         $seoinfo = dr_category_seo($mod, $mod['category'][$catid], max(1, (int) $this->input->get('page')));
         $urlrule = $mod['setting']['search']['rewrite'] ? 'search-id-{id}-page-{page}.html' : 'index.php?c=search&id={id}&page={page}';
         $this->template->assign($seoinfo);
         $this->template->assign(array('cat' => $mod['category'][$catid], 'get' => array_merge($get, $data['params']), 'caitd' => $catid, 'parent' => $parent, 'related' => $related, 'keyword' => $get['keyword'], 'urlrule' => str_replace('{id}', $data['id'], $urlrule), 'sototal' => $data['contentid'] ? substr_count($data['contentid'], ',') + 1 : 0, 'searchid' => $data['id'], 'theme' => $theme, 'keyword' => $keyword, 'de_json' => $de_json, 'pagenow' => $_GET['page']));
         $this->template->assign($data);
         $tpl = $catid && $mod['category'][$catid]['setting']['template']['search'] ? $mod['category'][$catid]['setting']['template']['search'] : 'search.html';
         $this->template->display($tpl);
     } else {
         if ($call) {
             $this->dir = $call;
         }
         $mod = $this->get_cache('module-' . SITE_ID . '-' . $this->dir);
         if (isset($mod['setting']['search']['close']) && $mod['setting']['search']['close']) {
             if ($call) {
                 return NULL;
             } else {
                 $this->msg(lang('m-125'));
             }
         }
         // 加载搜索模型
         if (is_file(FCPATH . $this->dir . 'models/Search_model.php')) {
             require_once FCPATH . $this->dir . 'models/Search_model.php';
         } else {
             require_once FCPATH . 'dayrui/models/Search_model.php';
         }
         $this->search_model = new Search_model();
         // 清除过期缓存
         $this->search_model->clear($mod['setting']['search']['cache']);
         // 搜索参数
         $get = $this->input->get(NULL);
         $get = isset($get['rewrite']) ? dr_rewrite_decode($get['rewrite']) : $get;
         $id = $get['id'];
         $catid = (int) $get['catid'];
         $_GET['page'] = $get['page'];
         $get['keyword'] = str_replace(array('%', ' '), array('', '%'), $get['keyword']);
         unset($get['c'], $get['m'], $get['id'], $get['page']);
         // 关键字个数判断
         if ($get['keyword'] && strlen($get['keyword']) < (int) $mod['setting']['search']['length']) {
             if ($call) {
                 return NULL;
             } else {
                 $this->msg(lang('mod-31'));
             }
         }
         if ($id) {
             // 读缓存数据
             $data = $this->search_model->get($id);
             $catid = $data['catid'];
             $data['get'] = $data['params'];
             if (!$data) {
                 if ($call) {
                     return NULL;
                 } else {
                     $this->msg(lang('mod-32'));
                 }
             }
         } else {
             // 实时组合搜索条件
             $data = $this->search_model->set($get);
         }
         list($parent, $related) = $this->_related_cat($mod, $catid);
         $seoinfo = dr_category_seo($mod, $mod['category'][$catid], max(1, (int) $this->input->get('page')));
         if ($call) {
             $urlrule = $mod['setting']['search']['rewrite'] ? SITE_URL . 'so-module-' . $this->dir . '-id-{id}-page-{page}.html' : SITE_URL . 'index.php?c=so&module=' . $this->dir . '&id={id}&page={page}';
             return array('cat' => $mod['category'][$catid], 'get' => array_merge($get, $data['params']), 'data' => $data, 'caitd' => $catid, 'parent' => $parent, 'seoinfo' => $seoinfo, 'keyword' => $get['keyword'], 'urlrule' => str_replace('{id}', $data['id'], $urlrule), 'sototal' => $data['contentid'] ? substr_count($data['contentid'], ',') + 1 : 0, 'searchid' => $data['id'], 'de_json' => $_SESSION["de_json"], 'pagenow' => $_GET['page']);
         } else {
             $urlrule = $mod['setting']['search']['rewrite'] ? 'search-id-{id}-page-{page}.html' : 'index.php?c=search&id={id}&page={page}';
             $this->template->assign($seoinfo);
             $this->template->assign(array('cat' => $mod['category'][$catid], 'get' => array_merge($get, $data['params']), 'caitd' => $catid, 'parent' => $parent, 'related' => $related, 'keyword' => $get['keyword'], 'urlrule' => str_replace('{id}', $data['id'], $urlrule), 'sototal' => $data['contentid'] ? substr_count($data['contentid'], ',') + 1 : 0, 'searchid' => $data['id'], 'de_json' => $de_json, 'pagenow' => $_GET['page']));
             $this->template->assign($data);
             $tpl = $catid && $mod['category'][$catid]['setting']['template']['search'] ? $mod['category'][$catid]['setting']['template']['search'] : 'search.html';
             $this->template->display($tpl);
         }
     }
 }