当前位置: 首页>>代码示例>>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;未经允许,请勿转载。