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

82 lines
2.6 KiB
PHP
Raw Permalink Normal View History

2018-02-11 04:19:40 +00:00
<?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');
2013-06-02 03:56:12 +00:00
$this->view->messages = $this->messenger->getMessages();
2013-06-09 03:03:47 +00:00
$this->view->theme = new Theme();
2013-06-02 03:56:12 +00:00
$this->view->nav = array(
array('link'=>'/','title'=>'<i class="icon-home"></i>'),
array('link'=>'/data','title'=>$this->view->config->title->data),
2018-02-11 04:19:40 +00:00
);
}
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;
2012-12-16 08:40:08 +00:00
}
function suggestAction()
{
$q = isset($_GET['term']) ? trim($_GET['term']) : '';
$q = get_magic_quotes_gpc() ? stripslashes($q) : $q;
$search=new Search();
2018-02-11 04:19:40 +00:00
$this->_helper->layout->disableLayout();
2012-12-16 08:40:08 +00:00
$this->_helper->viewRenderer->setNoRender();
header("Content-Type: application/json; charset=utf-8");
echo $search->suggest($q);
2013-06-09 03:03:47 +00:00
}
2016-03-21 12:58:29 +00:00
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");
2016-03-21 13:36:13 +00:00
echo json_encode($rows);
2016-03-21 12:58:29 +00:00
}
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");
2016-03-21 13:36:13 +00:00
echo json_encode($rows);
2016-03-21 12:58:29 +00:00
}
2018-02-11 04:19:40 +00:00
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');
}
}