當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model_Ad::getAdforSearch方法代碼示例

本文整理匯總了PHP中Model_Ad::getAdforSearch方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Ad::getAdforSearch方法的具體用法?PHP Model_Ad::getAdforSearch怎麽用?PHP Model_Ad::getAdforSearch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model_Ad的用法示例。


在下文中一共展示了Model_Ad::getAdforSearch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexAction

 public function indexAction()
 {
     $this->lang = $this->view->lang = $this->_helper->checklang->check();
     $this->location = $this->_helper->checklocation->check();
     $this->check_messages = $this->_helper->checkMessages;
     $this->notifications = $this->_helper->Notifications;
     $this->view->ad_type = $ad_type = $this->_request->getParam('ad_type');
     $page = $this->_request->getParam('page');
     $woeid = $this->view->woeid = $this->_request->getParam('woeid');
     $this->view->woeidName = $this->_helper->woeid->name($woeid, $this->lang);
     $qw = stripcslashes(strip_tags($this->_getParam('q')));
     require_once APPLICATION_PATH . '../../library/Sphinx/sphinxapi.php';
     $this->cl = new SphinxClient();
     $this->cl->SetServer('127.0.0.1', 3312);
     $this->cl->SetMatchMode(SPH_MATCH_EXTENDED2);
     $this->cl->SetRankingMode(SPH_RANK_PROXIMITY);
     $this->cl->SetSortMode(SPH_SORT_EXTENDED, "@id DESC");
     $this->cl->SetMaxQueryTime(1000);
     // Create a filter chain and add filters
     $encoding = array('quotestyle' => ENT_QUOTES, 'charset' => 'UTF-8');
     $f = new Zend_Filter();
     $f->addFilter(new Zend_Filter_StringTrim());
     $f->addFilter(new Zend_Filter_StripTags($encoding));
     $q = $this->view->q = $f->filter(trim($qw));
     $this->view->page_title .= $this->view->translate('search');
     $this->view->page_title .= ' ' . $q;
     $this->view->page_title .= ' ' . $this->view->translate('free') . ' ' . $this->view->woeidName;
     if ($page) {
         $this->view->page_title .= ' ' . $this->view->translate('page') . ' ' . $page;
     }
     $form = new Form_Search();
     if (!$q) {
         // check if query search is empty
         $this->_helper->_flashMessenger->addMessage($this->view->translate('Hey! Write something'));
         $this->_redirect('/' . $this->lang . '/woeid/' . $woeid . '/give');
         return;
     }
     $form->getElement('q')->setValue(trim($q));
     $form->loadDefaultDecoratorsIsDisabled(false);
     foreach ($form->getElements() as $element) {
         $element->removeDecorator('DtDdWrapper');
         $element->removeDecorator('Label');
     }
     $this->view->form = $form;
     $this->cl->SetFilter('type', array($ad_type));
     $this->cl->SetFilter('woeid_code', array($woeid));
     $itemsPerSphinxPage = 1000;
     $offset = 0;
     $this->cl->SetLimits($offset, $itemsPerSphinxPage, MAX_RESULTS, MAX_HITS);
     $result = $this->cl->Query($q, 'ads');
     $modelAd = new Model_Ad();
     if (!is_null($result["matches"])) {
         foreach ($result["matches"] as $doc => $docinfo) {
             $resultzs[$doc] = $modelAd->getAdforSearch($doc, $ad_type, $woeid);
         }
         // $this->getResponse()->setHttpResponseCode(301);
         $this->view->query_time = $result['time'];
         $this->view->total_found = $result['total_found'];
         $paginator = Zend_Paginator::factory($resultzs);
         //resultzs = results in LOLCAT language
         $paginator->setDefaultScrollingStyle('Elastic');
         $paginator->setItemCountPerPage(10);
         $paginator->setCurrentPageNumber($page);
         $this->view->search = $paginator;
     } else {
         $this->_helper->_flashMessenger->addMessage($this->view->translate('Sorry, no results for search:') . ' <b>"' . $q . '"</b>');
         $this->_redirect('/' . $this->lang . '/woeid/' . $woeid . '/give', array('code' => 301));
     }
 }
開發者ID:Arteaga2k,項目名稱:nolotiro,代碼行數:69,代碼來源:SearchController.php


注:本文中的Model_Ad::getAdforSearch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。