diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 2c363099..f8d9d4c0 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -397,33 +397,29 @@ class DataController extends Zend_Controller_Action $this->view->addHelperPath('helper','Zend_View_Helper_'); $form=new SearchForm(); $this->view->form=$form; - $form->submit->setLabel('快速搜索'); - if ($this->_request->isPost()) { - $formData=$this->_request->getPost(); - include_once("bcspamblock.php"); - if (bcspamblock_verify() && $form->isValid($formData)) { - $page=@(int)$formData['page']; + //$form->submit->setLabel('快速搜索'); + $key=$this->_request->getParam('q'); + if (!empty($key)) { + //$formData=$this->_request->getPost(); + //include_once("bcspamblock.php"); + //if ($form->isValid($formData)) { + $page=@(int)$this->_request->getParam('page'); if (empty($page)) $page=1; $limit=10; $offset=$limit*($page-1); - $key=$formData['q']; if (!empty($key)) { $md=new MetadataTable(); $db=$md->getAdapter(); - $sql=$db->quoteInto('select count(*) from metadata where title ilike ? or description ilike ?','%'.$key.'%','%'.$key.'%'); + $sql=$db->quoteInto('select count(*) from metadata where title ilike ? or description ilike ?','%'.$key.'%'); $state=$db->query($sql); $row=$state->fetchAll(); $sum=$row[0]['count']; $select=$db->select(); - $select->from('metadata','*')->where('title ilike ? or description ilike ?','%'.$key.'%','%'.$key.'%')->order('id desc')->limit($limit,$offset); + $select->from('metadata','*')->where('title ilike ? or description ilike ?','%'.$key.'%')->order('id desc')->limit($limit,$offset); $this->view->metadata = $db->fetchAll($select); $this->view->page=new Pagination($sum,$page); $this->view->key=$key; } - - } - } else { - } } /* @@ -431,25 +427,44 @@ class DataController extends Zend_Controller_Action */ function advancesearchAction() { + $this->view->addHelperPath('helper','Zend_View_Helper_'); + $form=new SearchForm(); + $this->view->form=$form; + $md=new MetadataTable(); $db=$md->getAdapter(); $page=(int)$this->_request->getParam('page'); if (empty($page)) $page=1; $limit=10; $offset=$limit*($page-1); - $key=$this->_request->getParam('key'); - $searchtype=$this->_request->getParam('type'); - if (!empty($key)) { - $sql=$db->quoteInto('select count(*) from metadata where title ilike ? or description ilike ?','%'.$key.'%','%'.$key.'%'); - $state=$db->query($sql); - $row=$state->fetchAll(); + $key=$this->_request->getParam('q'); + $n=(int)$this->_request->getParam('n'); + $s=(int)$this->_request->getParam('s'); + $e=(int)$this->_request->getParam('e'); + $w=(int)$this->_request->getParam('w'); + if (!(empty($n) && empty($key))) { + if (empty($n)) $n=90; + if (empty($s)) $s=-90; + if (empty($e)) $e=180; + if (empty($w)) $w=-180; + $start=$this->_request->getParam('start'); + $end=$this->_request->getParam('end'); + if (!empty($key)) { + $sql='select count(*) from metadata where east and west>? and north and south>? and (title ilike ? or description ilike ?)'; + $row=$db->fetchAll($sql,array($e,$w,$n,$s,'%'.$key.'%','%'.$key.'%')); + } else { + $sql='select count(*) from metadata where east and west>? and north and south>?'; + $row=$db->fetchAll($sql,array($e,$w,$n,$s)); + } $sum=$row[0]['count']; $select=$db->select(); - $select->from('metadata','*')->where('title ilike ? or description ilike ?','%'.$key.'%','%'.$key.'%')->order('id desc')->limit($limit,$offset); + $select->from('metadata','*')->where('east',$e)->where('west>?',$w)->where('north',$n)->where('south>?',$s); + if (!empty($key)) $select->where('(title ilike ? or description ilike ?)','%'.$key.'%'); + $select->order('id desc')->limit($limit,$offset); $this->view->metadata = $db->fetchAll($select); $this->view->page=new Pagination($sum,$page); - $this->view->key=$key; - } + $this->view->key=$key; + } } /* * 根据id或uuid来查看元数据 diff --git a/application/default/views/scripts/data/advancesearch.phtml b/application/default/views/scripts/data/advancesearch.phtml new file mode 100644 index 00000000..e4766ad8 --- /dev/null +++ b/application/default/views/scripts/data/advancesearch.phtml @@ -0,0 +1,108 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->data); + +$this->headTitle('高级搜索'); +if (!empty($this->codename)) $this->headTitle($this->codename); +$this->headTitle()->setSeparator(' - '); +$this->headLink()->appendStylesheet('/css/metadata.css'); +$this->headLink()->appendStylesheet('/css/search.css'); +$this->breadcrumb('首页'); +$this->breadcrumb(''.$this->config->title->data.''); +$this->breadcrumb('高级搜索'); +$this->breadcrumb()->setSeparator(' > '); +?> +