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

39 lines
1.2 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();
}
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);
}
}