当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_Ad::getComments方法代码示例

本文整理汇总了PHP中Model_Ad::getComments方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Ad::getComments方法的具体用法?PHP Model_Ad::getComments怎么用?PHP Model_Ad::getComments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model_Ad的用法示例。


在下文中一共展示了Model_Ad::getComments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showAction

 public function showAction()
 {
     $this->view->userRole = $this->_helper->checkUserRole->check();
     $id = $this->_request->getParam('id');
     $model = new Model_Ad();
     //check if the ad exists in memcached
     $oBackend = new Zend_Cache_Backend_Memcached(array('servers' => array(array('host' => '127.0.0.1', 'port' => '11211')), 'compression' => true));
     // configure caching frontend strategy
     $oFrontend = new Zend_Cache_Core(array('lifetime' => 3600 * 24 * 7, 'caching' => true, 'cache_id_prefix' => 'singleAd', 'logging' => false, 'write_control' => true, 'automatic_serialization' => true, 'ignore_user_abort' => true));
     // build a caching object
     $cacheAd = Zend_Cache::factory($oFrontend, $oBackend);
     $cacheTest = $cacheAd->test((int) $id);
     if ($cacheTest == false) {
         //if not exists in cache lets query to db
         $this->view->ad = $model->getAd((int) $id);
         $cacheAd->save($this->view->ad, (int) $id);
     } else {
         //load ad from memcached
         $this->view->ad = $cacheAd->load((int) $id);
     }
     //lets count the comments number and update
     $modelComments = new Model_Comment();
     $this->view->checkCountAd = $count = $modelComments->countCommentsAd((int) $id);
     //let's increment +1 the ad view counter
     $model->updateReadedAd($id);
     $this->view->countReadedAd = $model->countReadedAd($id);
     if ($this->view->checkCountAd > 0) {
         $modelComments->updateCommentsAd($id, $count);
     }
     if ($this->view->ad != null) {
         // if the id ad exists then render the ad and comments
         if ($this->view->ad['type'] == 1) {
             $this->view->page_title .= $this->view->translate('give') . ' ' . $this->view->translate('second hand') . ' ';
         }
         if ($this->view->ad['type'] == 2) {
             $this->view->page_title .= $this->view->translate('want') . ' ' . $this->view->translate('second hand') . ' ';
         }
         $this->view->comments = $model->getComments($id);
         $this->view->woeidName = $this->_helper->woeid->name($this->view->ad['woeid_code'], $this->lang);
         $this->view->page_title .= $this->view->ad['title'];
         $this->view->page_title .= ' ' . $this->view->translate('free') . ' ';
         $this->view->page_title .= ' ' . $this->view->woeidName;
         //add meta description to head
         $this->view->metaDescription = $this->view->page_title . '. ' . $this->view->ad['body'];
         //add link rel canonical , better seo
         $this->view->canonicalUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang . '/ad/' . $id . '/' . $this->view->slugTitle($this->view->ad['title']);
         //if user logged in, show the comment form, if not show the login link
         $auth = Zend_Auth::getInstance();
         if (!$auth->hasIdentity()) {
             $this->view->createcomment = '<a href="/' . $this->lang . '/auth/login">' . $this->view->translate('login to post a comment') . '</a> ';
         } else {
             require_once APPLICATION_PATH . '/forms/Comment.php';
             $form = new Form_Comment();
             $form->setAction('/' . $this->lang . '/comment/create/ad_id/' . $id);
             $this->view->createcomment = $form;
         }
     } else {
         $urlChunks = explode('/', $_SERVER['REQUEST_URI']);
         $urlChunks = str_replace('.html', '', $urlChunks);
         $urlChunks = str_replace('-', ' ', $urlChunks);
         //redir to search
         $this->_redirect('/' . $this->lang . '/search/?q=' . $urlChunks[sizeof($urlChunks) - 1] . '&ad_type=1&woeid=' . $this->location, array('code' => 301));
     }
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:64,代码来源:AdController.php


注:本文中的Model_Ad::getComments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。