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 north? 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 north?'; + $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('eastwhere('west>?',$w)->where('northwhere('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(' > '); +?> +
+partial('data/tools.phtml'); ?> +
+form; ?> +高级搜索 +metadata)) : ?> +page->getNavigation(); +foreach($this->metadata as $md) : ?> +
+
+
+

escape($md['title']);?> +

+ 400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']);?> +
+ +
+page->getNavigation();?> + + + +
+
+ +
+ + + + +
+
搜索说明
+
+ + + + \ No newline at end of file diff --git a/application/default/views/scripts/data/search.phtml b/application/default/views/scripts/data/search.phtml index 105e9904..af8ee3ae 100755 --- a/application/default/views/scripts/data/search.phtml +++ b/application/default/views/scripts/data/search.phtml @@ -26,4 +26,7 @@ foreach($this->metadata as $md) : ?> 400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']);?> - \ No newline at end of file + +
+page->getNavigation();?> + \ No newline at end of file diff --git a/application/models/SearchForm.php b/application/models/SearchForm.php index 95fbaee8..ad7f9464 100755 --- a/application/models/SearchForm.php +++ b/application/models/SearchForm.php @@ -13,15 +13,10 @@ class SearchForm extends Zend_Form ->addFilter('StringTrim') ->addValidator('NotEmpty'); - $spam=new element_bcSpamBlock('spam'); - $spam->addPrefixPath('Validator','validator/','validate') - ->addValidator('SpamBlock'); - - $id = new Zend_Form_Element_Hidden('id'); - + $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('搜索'); - $this->addElements(array($q,$submit,$spam,$id)); + $this->addElements(array($q,$submit)); $this->clearDecorators(); $this->addDecorator('FormElements') ->addDecorator('HtmlTag', array('tag' => '