本文整理汇总了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));
}
}