82 lines
2.6 KiB
PHP
82 lines
2.6 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 hotAction()
|
|
{
|
|
$sql="select m.uuid,title from normalmetadata m left join mdstat s on m.uuid=s.uuid order by s.viewed desc limit 10";
|
|
$sth = $this->db->prepare($sql);
|
|
$sth ->execute();
|
|
$rows = $sth->fetchAll();
|
|
|
|
$this->_helper->layout->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
header("Content-Type: application/json; charset=utf-8");
|
|
echo json_encode($rows);
|
|
}
|
|
|
|
function latestAction()
|
|
{
|
|
$sql="select uuid,title from normalmetadata order by ts_created desc limit 10";
|
|
$sth = $this->db->prepare($sql);
|
|
$sth ->execute();
|
|
$rows = $sth->fetchAll();
|
|
|
|
$this->_helper->layout->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
header("Content-Type: application/json; charset=utf-8");
|
|
echo json_encode($rows);
|
|
}
|
|
|
|
function advanceAction(){
|
|
$this->_helper->layout->setLayout('layout-sanji');
|
|
|
|
$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');
|
|
}
|
|
}
|