예제 #1
0
 function testFilterLanguage()
 {
     $index = new Search_Index_Memory();
     $query = new Search_Query();
     $query->filterLanguage('en or fr');
     $query->search($index);
     $expr = new Search_Expr_And(array(new Search_Expr_Or(array(new Search_Expr_Token('en', 'identifier', 'language'), new Search_Expr_Token('fr', 'identifier', 'language')))));
     $this->assertEquals($expr, $index->getLastQuery());
 }
예제 #2
0
 private function cs_dataappend_language(Search_Query $query, $config, $value)
 {
     if ($config['type'] != 'text') {
         if (!empty($config['_value'])) {
             $value = $config['_value'];
             $query->filterLanguage($value);
         } elseif ($value) {
             $query->filterLanguage($value);
         }
     }
 }
예제 #3
0
 function buildQuery(array $filter)
 {
     $categlib = TikiLib::lib('categ');
     $query = new Search_Query();
     $query->setWeightCalculator($this->getWeightCalculator());
     if (!Perms::get()->admin) {
         $query->filterPermissions(Perms::get()->getGroups());
     }
     $jail_query = '';
     if ($jail = $categlib->get_jail()) {
         $i = 0;
         foreach ($jail as $cat) {
             $i++;
             $jail_query .= $cat;
             if ($i < count($jail)) {
                 $jail_query .= ' or ';
             }
         }
         $query->filterCategory($jail_query, true);
     }
     if (isset($filter['type']) && $filter['type']) {
         $query->filterType($filter['type']);
     }
     if (isset($filter['categories']) && $filter['categories']) {
         $query->filterCategory($filter['categories'], isset($filter['deep']));
     }
     if (isset($filter['tags']) && $filter['tags']) {
         $query->filterTags($filter['tags']);
     }
     if (isset($filter['content']) && $filter['content']) {
         $query->filterContent($filter['content'], TikiLib::lib('tiki')->get_preference('unified_default_content', array('contents'), true));
     }
     if (isset($filter['autocomplete']) && $filter['autocomplete']) {
         $query->filterInitial($filter['autocomplete']);
     }
     if (isset($filter['language']) && $filter['language']) {
         $q = $filter['language'];
         if (preg_match('/^\\w+\\-\\w+$/', $q)) {
             $q = "\"{$q}\"";
         }
         if (isset($filter['language_unspecified'])) {
             $q = "({$q}) or unknown";
         }
         $query->filterLanguage($q);
     }
     unset($filter['type']);
     unset($filter['categories']);
     unset($filter['deep']);
     unset($filter['tags']);
     unset($filter['content']);
     unset($filter['language']);
     unset($filter['autocomplete']);
     foreach ($filter as $key => $value) {
         if ($value) {
             $query->filterContent($value, $key);
         }
     }
     return $query;
 }