コード例 #1
0
ファイル: MainController.php プロジェクト: maduhu/openbay
 /**
  * Returns SphinxQL search object, initialized for tag search
  *
  * @param SearchForm $model
  * @return \ESphinxQL
  */
 protected function getSphinxTagSearchObject(SearchForm $model)
 {
     $objCommon = new ESphinxQL();
     $objCommon->addField('id')->addIndex(Yii::app()->params['sphinx']['indexes']['torrents']);
     $tagPatterns = array();
     if ($model->tags) {
         $tagPatterns[] = '"=' . str_replace(' ', '+', $model->tags) . '"';
     }
     if ($model->category) {
         $tagPatterns[] = '"=' . str_replace(' ', '+', LCategory::getCategoryTag($model->category)) . '"';
         $objCommon->where('category_id', $model->category);
     }
     if (count($tagPatterns)) {
         $searchPattern = '@tags ' . join(' ', $tagPatterns);
     }
     $objCommon->option('ranker', 'MATCHANY');
     // Filter torrents by status
     if (!empty($model->status)) {
         $objCommon->where('torrent_status', Torrent::TORRENT_STATUS_GOOD);
     }
     // Filter torrents by age
     if (!empty($model->age)) {
         $objCommon->where('created_at', time() - $model->age * 86400, '>=', true);
     }
     if (!empty($model->popular)) {
         $objCommon->order('downloads_count', 'DESC');
     }
     if ($model->latest) {
         $objCommon->order('created_at', 'DESC');
         $objCommon->limit($model->latest);
     }
     // If no ordering is set - default weight+id sorting mode
     if (!$objCommon->getOrders()) {
         $objCommon->order('weight()', 'DESC');
         $objCommon->order('id', 'DESC');
     }
     if (!empty($searchPattern)) {
         $objCommon->search($searchPattern);
     }
     return $objCommon;
 }
コード例 #2
0
ファイル: LTorrent.php プロジェクト: maduhu/openbay
 public function getCategoryTag()
 {
     $tags = $this->getTags();
     if (empty($tags)) {
         return strtolower(LCategory::getCategoryTag(LCategory::OTHER));
     }
     return $tags[0];
 }