|
@@ -2,22 +2,22 @@
|
|
|
|
|
|
/**
|
|
|
* materiobase_search_autocomplete_dbselect()
|
|
|
- *
|
|
|
+ *
|
|
|
* inspired by taxonomy_autocomplete()
|
|
|
- *
|
|
|
+ *
|
|
|
* OBSOLETE : this fonction use a direct dbselect request to provide results forautocomplete
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
function materio_search_api_autocomplete_dbselect($typed = ''){
|
|
|
// If the request has a '/' in the search text, then the menu system will have
|
|
|
// split it into multiple arguments, recover the intended $tags_typed.
|
|
|
$args = func_get_args();
|
|
|
$typed = implode('/', $args);
|
|
|
-
|
|
|
+
|
|
|
/*
|
|
|
TODO riche serach engine + \\ etc gmail like
|
|
|
*/
|
|
|
-
|
|
|
+
|
|
|
if ($typed != '') {
|
|
|
|
|
|
// Part of the criteria for the query come from the field's own settings.
|
|
@@ -56,7 +56,7 @@ function materio_search_api_autocomplete_dbselect($typed = ''){
|
|
|
|
|
|
/**
|
|
|
* materio_search_api_autocomplete_searchapi($typed = '')
|
|
|
-*
|
|
|
+*
|
|
|
* GOOD one using searchapi (SOLR)
|
|
|
*/
|
|
|
function materio_search_api_autocomplete_searchapi($typed = ''){
|
|
@@ -64,7 +64,7 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
|
|
|
// split it into multiple arguments, recover the intended $tags_typed.
|
|
|
$args = func_get_args();
|
|
|
$typed = implode('/', $args);
|
|
|
-
|
|
|
+
|
|
|
// dsm($typed, 'typed');
|
|
|
if ($typed != '') {
|
|
|
|
|
@@ -78,7 +78,7 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
|
|
|
global $language;
|
|
|
$index_machine_name = variable_get('autocompletesearchindex_'.$language->language, -1);
|
|
|
$query = search_api_query($index_machine_name);
|
|
|
-
|
|
|
+
|
|
|
// $query_filter = $query->createFilter();
|
|
|
// $query_filter->condition('name', $tosearch);
|
|
|
// $query_filter->condition('type', 'article');
|
|
@@ -96,14 +96,14 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
|
|
|
//dsm($item, '$item');
|
|
|
//$term_matches[$item->tid] = check_plain($item->name);
|
|
|
// $term_matches[check_plain($item->name)] = check_plain($item->name);
|
|
|
- // TODO: leave tags with nodes
|
|
|
+ // TODO: leave tags with nodes
|
|
|
$term_matches[ trim(implode(' ', $adv_search_q[0]).' '.$last[1].$item->name)] = check_plain($item->name);
|
|
|
|
|
|
$delta++;
|
|
|
if($delta > 15)
|
|
|
break;
|
|
|
- }
|
|
|
- drupal_json_output($term_matches);
|
|
|
+ }
|
|
|
+ drupal_json_output($term_matches);
|
|
|
}else{
|
|
|
drupal_json_output(array());
|
|
|
}
|
|
@@ -111,15 +111,15 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
// dsm($term_matches, 'term_matches');
|
|
|
// return 'debug mode of materio_search_api_autocomplete_searchapi';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* materio_search_api_results_search()
|
|
|
-*
|
|
|
-*
|
|
|
+*
|
|
|
+*
|
|
|
*/
|
|
|
function materio_search_api_results_search(){
|
|
|
global $user;
|
|
@@ -138,11 +138,11 @@ function materio_search_api_results_search(){
|
|
|
// else{
|
|
|
// $page = 0;
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
preg_match_all('/\s?[^\s]+\s?/', $typed, $words);
|
|
|
// dsm($words, "words");
|
|
|
|
|
|
-
|
|
|
+
|
|
|
// $match = array('\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '*', '?', ':', '"', ';', ' ');
|
|
|
// $replace = array('\\\\', '\\+', '\\-', '\\&', '\\|', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\~', '\\*', '\\?', '\\:', '\\"', '\\;', '\\ ');
|
|
|
foreach ($words[0] as $word) {
|
|
@@ -197,7 +197,7 @@ function materio_search_api_results_search(){
|
|
|
// dsm($viewmode, 'viewmode');
|
|
|
|
|
|
if ($keys) {
|
|
|
- // TODO: cache the results with cache graceful : http://drupal.org/project/cache_graceful
|
|
|
+ // TODO: cache the results with cache graceful : http://drupal.org/project/cache_graceful
|
|
|
try {
|
|
|
$limit = variable_get($viewmode.'_limite', '10');
|
|
|
$offset = pager_find_page() * $limit; //$page*$limit;//
|
|
@@ -244,7 +244,7 @@ function materio_search_api_results_search(){
|
|
|
// $results['results'] = $accessible_results;
|
|
|
// $results['result count'] = count($accessible_results);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if(user_access('use materio search api')){
|
|
|
$items = $index->loadItems(array_keys($results['results']));
|
|
@@ -296,7 +296,7 @@ function materio_search_api_results_search(){
|
|
|
|
|
|
if (!empty($results['ignored'])) {
|
|
|
drupal_set_message(
|
|
|
- t('The following search keys are too short or too common and were therefore ignored: "@list".',
|
|
|
+ t('The following search keys are too short or too common and were therefore ignored: "@list".',
|
|
|
array( '@list' => implode(t('", "'), $results['ignored']) ) ),
|
|
|
'warning'
|
|
|
);
|
|
@@ -320,7 +320,7 @@ function materio_search_api_actuality(){
|
|
|
global $user;
|
|
|
|
|
|
if(isset($user->roles[1])){
|
|
|
- $date_limit = strtotime('-6 month');
|
|
|
+ $date_limit = strtotime('-6 month');
|
|
|
// dsm(date('d m y', $date_limit));
|
|
|
}
|
|
|
|
|
@@ -361,7 +361,7 @@ function materio_search_api_actuality(){
|
|
|
if(isset($result['node'])){
|
|
|
foreach ($result['node'] as $nid => $n) {
|
|
|
$breve = node_load($nid);
|
|
|
-
|
|
|
+
|
|
|
if(!node_access('view', $breve))
|
|
|
continue;
|
|
|
|
|
@@ -377,7 +377,7 @@ function materio_search_api_actuality(){
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// drupal_set_title(t('Actualities'));
|
|
|
drupal_set_title(t(''));
|
|
|
|