westdc-zf1/application/default/controllers/SearchController.php

54 lines
1.7 KiB
PHP

<?php
class SearchController extends Zend_Controller_Action
{
function preDispatch()
{
$this->db=Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
$this->view->theme = new Theme();
$this->view->nav = array(
array('link'=>'/','title'=>'<i class="icon-home"></i>'),
array('link'=>'/data','title'=>$this->view->config->title->data),
);
}
function indexAction()
{
$search=new Search();
$search->dosearch();
$this->view->hot=$search->hot;
$this->view->total_cost=$search->total_cost;
$this->view->count=$search->count;
$this->view->base_url=$search->base_url;
$this->view->error=$search->error;
$this->view->docs=$search->docs;
$this->view->search=$search->search;
$this->view->related=$search->related;
$this->view->pager=$search->pager;
$this->view->total=$search->total;
$this->view->expanded=$search->expanded;
}
function suggestAction()
{
$q = isset($_GET['term']) ? trim($_GET['term']) : '';
$q = get_magic_quotes_gpc() ? stripslashes($q) : $q;
$search=new Search();
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
header("Content-Type: application/json; charset=utf-8");
echo $search->suggest($q);
}
function advanceAction()
{
$this->view->east=$this->getParam('east');
$this->view->west=$this->getParam('west');
$this->view->south=$this->getParam('south');
$this->view->north=$this->getParam('north');
$this->view->begin=$this->getParam('begin');
$this->view->end=$this->getParam('end');
$this->view->q=$this->getParam('q');
}
}