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


PHP CategoryModel::CategoryWatch方法代码示例

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


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

示例1: Search

 public function Search($Search, $Offset = 0, $Limit = 20)
 {
     $BaseUrl = C('Plugins.Solr.SearchUrl', 'http://localhost:8983/solr/select/?');
     if (!$BaseUrl) {
         throw new Gdn_UserException("The search url has not been configured.");
     }
     if (!$Search) {
         return array();
     }
     // Escepe the search.
     $Search = preg_replace('`([][+&|!(){}^"~*?:\\\\-])`', "\\\\\$1", $Search);
     // Add the category watch.
     $Categories = CategoryModel::CategoryWatch();
     if ($Categories === FALSE) {
         return array();
     } elseif ($Categories !== TRUE) {
         $Search = 'CategoryID:(' . implode(' ', $Categories) . ') AND ' . $Search;
     }
     // Build the search url.
     $BaseUrl .= strpos($BaseUrl, '?') === FALSE ? '?' : '&';
     $Query = array('q' => $Search, 'start' => $Offset, 'rows' => $Limit);
     $Url = $BaseUrl . http_build_query($Query);
     // Grab the data.
     $Curl = curl_init($Url);
     curl_setopt($Curl, CURLOPT_RETURNTRANSFER, 1);
     $CurlResult = curl_exec($Curl);
     curl_close($Curl);
     // Parse the result into the form that the search controller expects.
     $Xml = new SimpleXMLElement($CurlResult);
     $Result = array();
     if (!isset($Xml->result)) {
         return array();
     }
     foreach ($Xml->result->children() as $Doc) {
         $Row = array();
         foreach ($Doc->children() as $Field) {
             $Name = (string) $Field['name'];
             $Row[$Name] = (string) $Field;
         }
         // Add the url.
         switch ($Row['DocType']) {
             case 'Discussion':
                 $Row['Url'] = '/discussion/' . $Row['PrimaryID'] . '/' . Gdn_Format::Url($Row['Title']);
                 break;
             case 'Comment':
                 $Row['Url'] = "/discussion/comment/{$Row['PrimaryID']}/#Comment_{$Row['PrimaryID']}";
                 break;
         }
         // Fix the time.
         $Row['DateInserted'] = strtotime($Row['DateInserted']);
         $Result[] = $Row;
     }
     // Join the users into the result.
     Gdn_DataSet::Join($Result, array('table' => 'User', 'parent' => 'UserID', 'prefix' => '', 'Name', 'Photo'));
     return $Result;
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:56,代码来源:class.searchmodel.php

示例2: getByDiscussionEventRange

 public function getByDiscussionEventRange($Offset = false, $Limit = false, $BeginDate = false, $EndDate = false, $Where = array())
 {
     $BeginDate = $BeginDate ? Date('Y-m-d', StrToTime($BeginDate)) : Date('Y-m-d');
     $EndDate = $EndDate ? Date('Y-m-d', StrToTime($EndDate)) : Date('Y-m-d', PHP_INT_MAX);
     $this->SQL->select('d.*')->from('Discussion d')->where('d.DiscussionEventDate >=', $BeginDate)->where('d.DiscussionEventDate <=', $EndDate)->orderBy('d.DiscussionEventDate');
     // Determine category watching
     if ($this->Watching && !isset($Where['d.CategoryID'])) {
         $Watch = CategoryModel::CategoryWatch();
         if ($Watch !== true) {
             $Where['d.CategoryID'] = $Watch;
         }
     }
     $this->SQL->where($Where);
     if ($Offset !== false && $Limit !== false) {
         $this->SQL->limit($Limit, $Offset);
     }
     return $this->SQL->get();
 }
开发者ID:pkonecki,项目名称:DiscussionEvent,代码行数:18,代码来源:class.discussioneventmodel.php

示例3: commentSql

 /**
  * Execute comment search query.
  *
  * @since 2.0.0
  * @access public
  *
  * @param object $SearchModel SearchModel (Dashboard)
  * @return object SQL result.
  */
 public function commentSql($SearchModel, $AddMatch = true)
 {
     if ($AddMatch) {
         // Get permission and limit search categories if necessary.
         $Perms = CategoryModel::CategoryWatch();
         if ($Perms !== true) {
             $this->SQL->whereIn('d.CategoryID', $Perms);
         }
         // Build search part of query
         $SearchModel->AddMatchSql($this->SQL, 'c.Body', 'c.DateInserted');
     }
     // Build base query
     $this->SQL->select('c.CommentID as PrimaryID, d.Name as Title, c.Body as Summary, c.Format, d.CategoryID, c.Score')->select("'/discussion/comment/', c.CommentID, '/#Comment_', c.CommentID", "concat", 'Url')->select('c.DateInserted')->select('c.InsertUserID as UserID')->select("'Comment'", '', 'RecordType')->from('Comment c')->join('Discussion d', 'd.DiscussionID = c.DiscussionID');
     if ($AddMatch) {
         // Exectute query
         $Result = $this->SQL->GetSelect();
         // Unset SQL
         $this->SQL->reset();
     } else {
         $Result = $this->SQL;
     }
     return $Result;
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:32,代码来源:class.vanillasearchmodel.php

示例4: getUnreadCount

 /**
  * Count how many discussions match the given criteria.
  *
  * @since 2.0.0
  * @access public
  *
  * @param array $Wheres SQL conditions.
  * @param bool $ForceNoAnnouncements Not used.
  * @return int Number of discussions.
  */
 public function getUnreadCount($Wheres = '', $ForceNoAnnouncements = false)
 {
     if (is_array($Wheres) && count($Wheres) == 0) {
         $Wheres = '';
     }
     // Check permission and limit to categories as necessary
     if ($this->Watching) {
         $Perms = CategoryModel::CategoryWatch();
     } else {
         $Perms = self::CategoryPermissions();
     }
     if (!$Wheres || count($Wheres) == 1 && isset($Wheres['d.CategoryID'])) {
         // Grab the counts from the faster category cache.
         if (isset($Wheres['d.CategoryID'])) {
             $CategoryIDs = (array) $Wheres['d.CategoryID'];
             if ($Perms === false) {
                 $CategoryIDs = array();
             } elseif (is_array($Perms)) {
                 $CategoryIDs = array_intersect($CategoryIDs, $Perms);
             }
             if (count($CategoryIDs) == 0) {
                 return 0;
             } else {
                 $Perms = $CategoryIDs;
             }
         }
         $Categories = CategoryModel::categories();
         $Count = 0;
         foreach ($Categories as $Cat) {
             if (is_array($Perms) && !in_array($Cat['CategoryID'], $Perms)) {
                 continue;
             }
             $Count += (int) $Cat['CountDiscussions'];
         }
         return $Count;
     }
     if ($Perms !== true) {
         $this->SQL->whereIn('c.CategoryID', $Perms);
     }
     $this->EventArguments['Wheres'] =& $Wheres;
     $this->fireEvent('BeforeGetUnreadCount');
     // @see 'BeforeGet' for consistency in count vs. results
     $this->SQL->select('d.DiscussionID', 'count', 'CountDiscussions')->from('Discussion d')->join('Category c', 'd.CategoryID = c.CategoryID')->join('UserDiscussion w', 'd.DiscussionID = w.DiscussionID and w.UserID = ' . Gdn::session()->UserID, 'left')->where('d.CountComments >', 'COALESCE(w.CountComments, 0)', true, false)->where($Wheres);
     $Result = $this->SQL->get()->firstRow()->CountDiscussions;
     return $Result;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:56,代码来源:class.discussionmodel.php

示例5: CommentSql

 /**
  * Execute comment search query.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param object $SearchModel SearchModel (Dashboard)
  * @return object SQL result.
  */
 public function CommentSql($SearchModel)
 {
     // Get permission and limit search categories if necessary
     $Perms = CategoryModel::CategoryWatch();
     if ($Perms !== TRUE) {
         $this->SQL->WhereIn('d.CategoryID', $Perms);
     }
     // Build search part of query
     $SearchModel->AddMatchSql($this->SQL, 'c.Body', 'c.DateInserted');
     // Build base query
     $this->SQL->Select('c.CommentID as PrimaryID, d.Name as Title, c.Body as Summary, c.Format, d.CategoryID')->Select("'/discussion/comment/', c.CommentID, '/#Comment_', c.CommentID", "concat", 'Url')->Select('c.DateInserted')->Select('c.InsertUserID as UserID')->From('Comment c')->Join('Discussion d', 'd.DiscussionID = c.DiscussionID');
     // Exectute query
     $Result = $this->SQL->GetSelect();
     // Unset SQL
     $this->SQL->Reset();
     return $Result;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:26,代码来源:class.vanillasearchmodel.php

示例6: GetCount

 /**
  * Count how many discussions match the given criteria.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param array $Wheres SQL conditions.
  * @param bool $ForceNoAnnouncements Not used.
  * @return int Number of discussions.
  */
 public function GetCount($Wheres = '', $ForceNoAnnouncements = FALSE)
 {
     $Session = Gdn::Session();
     $UserID = $Session->UserID > 0 ? $Session->UserID : 0;
     if (is_array($Wheres) && count($Wheres) == 0) {
         $Wheres = '';
     }
     // Check permission and limit to categories as necessary
     if ($this->Watching) {
         $Perms = CategoryModel::CategoryWatch();
     } else {
         $Perms = self::CategoryPermissions();
     }
     if (!$Wheres || count($Wheres) == 1 && isset($Wheres['d.CategoryID'])) {
         // Grab the counts from the faster category cache.
         if (isset($Wheres['d.CategoryID'])) {
             if (is_array($Perms) && !in_array($Wheres['d.CategoryID'], $Perms)) {
                 return 0;
             } else {
                 $Perms = array($Wheres['d.CategoryID']);
             }
         }
         $Categories = CategoryModel::Categories();
         $Count = 0;
         foreach ($Categories as $Cat) {
             if (is_array($Perms) && !in_array($Cat['CategoryID'], $Perms)) {
                 continue;
             }
             $Count += (int) $Cat['CountDiscussions'];
         }
         return $Count;
     }
     //      if($Perms !== TRUE) {
     //         $this->SQL->WhereIn('c.CategoryID', $Perms);
     //      }
     //
     //      $this->EventArguments['Wheres'] = &$Wheres;
     //		$this->FireEvent('BeforeGetCount'); // @see 'BeforeGet' for consistency in count vs. results
     //
     //      // Small optimization for basic queries
     //      if ($Wheres == '') {
     //         $this->SQL
     //            ->Select('c.CountDiscussions', 'sum', 'CountDiscussions')
     //            ->From('Category c');
     //      } else {
     //         $this->SQL
     //	         ->Select('d.DiscussionID', 'count', 'CountDiscussions')
     //	         ->From('Discussion d')
     //            ->Join('Category c', 'd.CategoryID = c.CategoryID')
     //	         ->Join('UserDiscussion w', 'd.DiscussionID = w.DiscussionID and w.UserID = '.$UserID, 'left')
     //            ->Where($Wheres);
     //      }
     //
     //      $Result = $this->SQL
     //         ->Get()
     //         ->FirstRow()
     //         ->CountDiscussions;
     //
     //      if (isset($Count) && $Result != $Count) {
     //         throw new Exception("Result: $Result, Count: $Count");
     //      }
     //
     //      return $Result;
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:74,代码来源:class.discussionmodel.php

示例7: GetCount

   /**
    * Count how many discussions match the given criteria.
    * 
    * @since 2.0.0
    * @access public
    * 
	 * @param array $Wheres SQL conditions.
	 * @param bool $ForceNoAnnouncements Not used.
	 * @return int Number of discussions.
	 */
   public function GetCount($Wheres = '', $ForceNoAnnouncements = FALSE) {
      $Session = Gdn::Session();
      $UserID = $Session->UserID > 0 ? $Session->UserID : 0;
      if (is_array($Wheres) && count($Wheres) == 0)
         $Wheres = '';
      
      // Check permission and limit to categories as necessary
      if ($this->Watching)
         $Perms = CategoryModel::CategoryWatch();
      else
         $Perms = self::CategoryPermissions();
      if($Perms !== TRUE) {
         $this->SQL->WhereIn('c.CategoryID', $Perms);
      }
      
      $this->EventArguments['Wheres'] = &$Wheres;
		$this->FireEvent('BeforeGetCount'); // @see 'BeforeGet' for consistency in count vs. results
         
      // Small optimization for basic queries
      if ($Wheres == '') {
         $this->SQL
            ->Select('c.CountDiscussions', 'sum', 'CountDiscussions')
            ->From('Category c');
      } else {
         $this->SQL
	         ->Select('d.DiscussionID', 'count', 'CountDiscussions')
	         ->From('Discussion d')
            ->Join('Category c', 'd.CategoryID = c.CategoryID')
	         ->Join('UserDiscussion w', 'd.DiscussionID = w.DiscussionID and w.UserID = '.$UserID, 'left')
            ->Where($Wheres);
      }
      
      return $this->SQL
         ->Get()
         ->FirstRow()
         ->CountDiscussions;
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:47,代码来源:class.discussionmodel.php

示例8: getUnreadCount

 /**
  * Count how many discussions match the given criteria.
  *
  * @since 2.0.0
  * @access public
  *
  * @param array $Wheres SQL conditions.
  * @param bool $ForceNoAnnouncements Not used.
  * @return stdObject containing:
  *           CountDiscussions => Number of unread discussions.
  *           CountComments => Number of unread comments.
  */
 public function getUnreadCount($Wheres = '', $ForceNoAnnouncements = false)
 {
     if (is_array($Wheres) && count($Wheres) == 0) {
         $Wheres = '';
     }
     // Check permission and limit to categories as necessary
     if ($this->Watching) {
         $Perms = CategoryModel::CategoryWatch();
     } else {
         $Perms = self::CategoryPermissions();
     }
     if ($Perms !== true) {
         $this->SQL->whereIn('c.CategoryID', $Perms);
     }
     $this->EventArguments['Wheres'] =& $Wheres;
     $this->fireEvent('BeforeGetUnreadCount');
     // @see 'BeforeGet' for consistency in count vs. results
     $this->SQL->select('d.DiscussionID', 'count', 'CountTotalDiscussions')->select('d.CountComments', 'sum', 'CountTotalComments')->select('w.CountComments', 'sum', 'CountReadComments')->select('w.DiscussionID', 'count', 'CountReadDiscussions')->from('Discussion d')->join('UserDiscussion w', 'd.DiscussionID = w.DiscussionID and w.UserID = ' . Gdn::session()->UserID, 'left')->where($Wheres);
     $TempResult = $this->SQL->get()->firstRow();
     $Result->CountDiscussions = (int) $TempResult->CountTotalDiscussions - (int) $TempResult->CountReadDiscussions;
     $Result->CountComments = (int) $TempResult->CountTotalComments - (int) $TempResult->CountReadComments;
     return $Result;
 }
开发者ID:GO3LIN,项目名称:vanilla,代码行数:35,代码来源:class.discussionmodel.php


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