Exemplo n.º 1
0
 public function executeSearch(sfWebRequest $request)
 {
     $sa = new CCSearchAgent($request->getParameter('q'));
     // currently both searches use the same normalize strategy since SQL is similar
     $sa->normalizeQuery($this->_comp_suffix);
     $is_ajax = $request->isXmlHttpRequest();
     if ($request->getParameter('for') == 'customer') {
         $this->serps = $sa->searchCustomers($is_ajax);
         $partial = 'quickCustSearchBox';
         $data_type = 'customers';
     } else {
         $this->serps = $sa->searchTickets($request->getParameter('category'), $is_ajax);
         $partial = 'quickTicketSearchBox';
         $data_type = 'tickets';
     }
     if ($is_ajax) {
         sfProjectConfiguration::getActive()->loadHelpers('Partial');
         $this->setLayout(false);
         $html = get_partial($partial, array($data_type => $this->serps));
         $response = $this->getResponse();
         $response->addCacheControlHttpHeader('no-cache');
         $response->setContentType('text/html');
         $response->sendHttpHeaders();
         return $this->renderText($html);
     } else {
         return sfView::SUCCESS;
     }
 }