original_string: public function searchPosts()
      {
          $query = Vocabulary::find()->select('post_id, thread_id')->joinWith(['posts.author', 'posts.thread'])->andWhere(['is not', 'post_id', null]);
          if (Podium::getInstance()->user->isGuest) {
              $query->joinWith(['posts.forum' => function ($q) {
                  $q->andWhere([Forum::tableName() . '.visible' => 1])->joinWith(['category' => function ($q) {
                      $q->andWhere([Category::tableName() . '.visible' => 1]);
                  }]);
              }]);
          }
          if (!empty($this->query)) {
              $words = explode(' ', preg_replace('/\s+/', ' ', $this->query));
              $countWords = 0;
              foreach ($words as $word) {
                  $query->orWhere(['like', 'word', $word]);
                  $countWords++;
              }
              $query->groupBy('post_id');
              if ($this->match == 'all' && $countWords > 1) {
                  $query->select(['post_id', 'thread_id', 'COUNT(post_id) AS c'])->having(['>', 'c', $countWords - 1]);
              }
          }
          $this->prepareQuery($query);
          $sort = [
              'defaultOrder' => ['post_id' => SORT_DESC],
              'attributes' => [
                  'post_id' => [
                      'asc' => ['post_id' => SORT_ASC],
                      'desc' => ['post_id' => SORT_DESC],
                      'default' => SORT_DESC,
                  ],
              ]
          ];
          return new ActiveDataProvider([
              'query' => $query,
              'sort' => $sort,
          ]);
      }
code: public function searchPosts()
      {
          $query = Vocabulary::find()->select('post_id, thread_id')->joinWith(['posts.author', 'posts.thread'])->andWhere(['is not', 'post_id', null]);
          if (Podium::getInstance()->user->isGuest) {
              $query->joinWith(['posts.forum' => function ($q) {
                  $q->andWhere([Forum::tableName() . '.visible' => 1])->joinWith(['category' => function ($q) {
                      $q->andWhere([Category::tableName() . '.visible' => 1]);
                  }]);
              }]);
          }
          if (!empty($this->query)) {
              $words = explode(' ', preg_replace('/\s+/', ' ', $this->query));
              $countWords = 0;
              foreach ($words as $word) {
                  $query->orWhere(['like', 'word', $word]);
                  $countWords++;
              }
              $query->groupBy('post_id');
              if ($this->match == 'all' && $countWords > 1) {
                  $query->select(['post_id', 'thread_id', 'COUNT(post_id) AS c'])->having(['>', 'c', $countWords - 1]);
              }
          }
          $this->prepareQuery($query);
          $sort = [
              'defaultOrder' => ['post_id' => SORT_DESC],
              'attributes' => [
                  'post_id' => [
                      'asc' => ['post_id' => SORT_ASC],
                      'desc' => ['post_id' => SORT_DESC],
                      'default' => SORT_DESC,
                  ],
              ]
          ];
          return new ActiveDataProvider([
              'query' => $query,
              'sort' => $sort,
          ]);
      }
code_tokens: public function searchPosts ( ) { $ query = Vocabulary :: find ( ) -> select ( 'post_id, thread_id' ) -> joinWith ( [ 'posts.author' , 'posts.thread' ] ) -> andWhere ( [ 'is not' , 'post_id' , null ] ) ; if ( Podium :: getInstance ( ) -> user -> isGuest ) { $ query -> joinWith ( [ 'posts.forum' => function ( $ q ) { $ q -> andWhere ( [ Forum :: tableName ( ) . '.visible' => 1 ] ) -> joinWith ( [ 'category' => function ( $ q ) { $ q -> andWhere ( [ Category :: tableName ( ) . '.visible' => 1 ] ) ; } ] ) ; } ] ) ; } if ( ! empty ( $ this -> query ) ) { $ words = explode ( ' ' , preg_replace ( '/\s+/' , ' ' , $ this -> query ) ) ; $ countWords = 0 ; foreach ( $ words as $ word ) { $ query -> orWhere ( [ 'like' , 'word' , $ word ] ) ; $ countWords ++ ; } $ query -> groupBy ( 'post_id' ) ; if ( $ this -> match == 'all' && $ countWords > 1 ) { $ query -> select ( [ 'post_id' , 'thread_id' , 'COUNT(post_id) AS c' ] ) -> having ( [ '>' , 'c' , $ countWords - 1 ] ) ; } } $ this -> prepareQuery ( $ query ) ; $ sort = [ 'defaultOrder' => [ 'post_id' => SORT_DESC ] , 'attributes' => [ 'post_id' => [ 'asc' => [ 'post_id' => SORT_ASC ] , 'desc' => [ 'post_id' => SORT_DESC ] , 'default' => SORT_DESC , ] , ] ] ; return new ActiveDataProvider ( [ 'query' => $ query , 'sort' => $ sort , ] ) ; }
docstring: Advanced posts search.
  @return ActiveDataProvider
  @since 0.6
docstring_tokens: Advanced posts search .