public function search($criteria)
    {
        $this->loadModel('Content.Contents');

        try {
            $contents = $this->Contents->search($criteria);
            if ($contents->clause('limit')) {
                $this->paginate['limit'] = $contents->clause('limit');
            }

            // TO-DO: ask search-engine for operator presence
            if (strpos($criteria, 'language:') === false) {
                $contents = $contents->where([
                    'Contents.status >' => 0,
                    'Contents.language IN' => ['', null, I18n::locale()] // any or concrete
                ]);
            }

            $contents = $this->paginate($contents);
        } catch (\Exception $e) {
            $contents = new Collection([]);
        }

        $this->set(compact('contents', 'criteria'));
        $this->viewMode('search-result');
    }
public function search($criteria)
    {
        $this->loadModel('Content.Contents');

        try {
            $contents = $this->Contents->search($criteria);
            if ($contents->clause('limit')) {
                $this->paginate['limit'] = $contents->clause('limit');
            }

            // TO-DO: ask search-engine for operator presence
            if (strpos($criteria, 'language:') === false) {
                $contents = $contents->where([
                    'Contents.status >' => 0,
                    'Contents.language IN' => ['', null, I18n::locale()] // any or concrete
                ]);
            }

            $contents = $this->paginate($contents);
        } catch (\Exception $e) {
            $contents = new Collection([]);
        }

        $this->set(compact('contents', 'criteria'));
        $this->viewMode('search-result');
    }
public function search ( $ criteria ) { $ this -> loadModel ( 'Content.Contents' ) ; try { $ contents = $ this -> Contents -> search ( $ criteria ) ; if ( $ contents -> clause ( 'limit' ) ) { $ this -> paginate [ 'limit' ] = $ contents -> clause ( 'limit' ) ; } // TO-DO: ask search-engine for operator presence if ( strpos ( $ criteria , 'language:' ) === false ) { $ contents = $ contents -> where ( [ 'Contents.status >' => 0 , 'Contents.language IN' => [ '' , null , I18n :: locale ( ) ] // any or concrete ] ) ; } $ contents = $ this -> paginate ( $ contents ) ; } catch ( \ Exception $ e ) { $ contents = new Collection ( [ ] ) ; } $ this -> set ( compact ( 'contents' , 'criteria' ) ) ; $ this -> viewMode ( 'search-result' ) ; }
Contents search engine page.

@param string $criteria A search criteria. e.g.: `"this phrase" -"but not this" OR -hello`
@return void
Contents search engine page .