public function searchSnippets($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
            
            return $response;
        }
        
        
        $languages=SnippetLanguage::get();
        foreach($languages as $lang) {
            $searchEngine=Config::inst()->get('CodeBank', 'snippet_search_engine');
            if($searchEngine && class_exists($searchEngine) && in_array('ICodeBankSearchEngine', class_implements($searchEngine))) {
                $searchEngine=new $searchEngine();
            }else {
                //Class is missing or invalid so fallback to the default
                $searchEngine=new DefaultCodeBankSearchEngine();
            }
            
            $snippets=$searchEngine->doSnippetSearch($data->query, $lang->ID);
            
            
            if($snippets->Count()>0) {
                $snippets=$this->arrayUnmap($snippets->filter('FolderID', 0)->map('ID', 'Title')->toArray());
                $response['data'][]=array(
                                        'id'=>$lang->ID,
                                        'language'=>$lang->Name,
                                        'folders'=>$this->mapFolders($lang->Folders(), $data->query),
                                        'snippets'=>$snippets
                                    );
            }
        }
        
        
        return $response;
    }
public function searchSnippets($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
            
            return $response;
        }
        
        
        $languages=SnippetLanguage::get();
        foreach($languages as $lang) {
            $searchEngine=Config::inst()->get('CodeBank', 'snippet_search_engine');
            if($searchEngine && class_exists($searchEngine) && in_array('ICodeBankSearchEngine', class_implements($searchEngine))) {
                $searchEngine=new $searchEngine();
            }else {
                //Class is missing or invalid so fallback to the default
                $searchEngine=new DefaultCodeBankSearchEngine();
            }
            
            $snippets=$searchEngine->doSnippetSearch($data->query, $lang->ID);
            
            
            if($snippets->Count()>0) {
                $snippets=$this->arrayUnmap($snippets->filter('FolderID', 0)->map('ID', 'Title')->toArray());
                $response['data'][]=array(
                                        'id'=>$lang->ID,
                                        'language'=>$lang->Name,
                                        'folders'=>$this->mapFolders($lang->Folders(), $data->query),
                                        'snippets'=>$snippets
                                    );
            }
        }
        
        
        return $response;
    }
public function searchSnippets ( $ data ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; //Ensure logged in if ( ! Permission :: check ( 'CODE_BANK_ACCESS' ) ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.PERMISSION_DENINED' , '_Permission Denied' ) ; return $ response ; } $ languages = SnippetLanguage :: get ( ) ; foreach ( $ languages as $ lang ) { $ searchEngine = Config :: inst ( ) -> get ( 'CodeBank' , 'snippet_search_engine' ) ; if ( $ searchEngine && class_exists ( $ searchEngine ) && in_array ( 'ICodeBankSearchEngine' , class_implements ( $ searchEngine ) ) ) { $ searchEngine = new $ searchEngine ( ) ; } else { //Class is missing or invalid so fallback to the default $ searchEngine = new DefaultCodeBankSearchEngine ( ) ; } $ snippets = $ searchEngine -> doSnippetSearch ( $ data -> query , $ lang -> ID ) ; if ( $ snippets -> Count ( ) > 0 ) { $ snippets = $ this -> arrayUnmap ( $ snippets -> filter ( 'FolderID' , 0 ) -> map ( 'ID' , 'Title' ) -> toArray ( ) ) ; $ response [ 'data' ] [ ] = array ( 'id' => $ lang -> ID , 'language' => $ lang -> Name , 'folders' => $ this -> mapFolders ( $ lang -> Folders ( ) , $ data -> query ) , 'snippets' => $ snippets ) ; } } return $ response ; }
Searches for snippets that match the information the client in the search field
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base
Searches for snippets that match the information the client in the search field