Bachir Soussi Chiadmi 11 gadi atpakaļ
vecāks
revīzija
748548f8f4
1 mainītis faili ar 40 papildinājumiem un 40 dzēšanām
  1. 40 40
      materio_search_api.module

+ 40 - 40
materio_search_api.module

@@ -101,7 +101,7 @@ function materio_search_api_access_search(){
 
 
 /**
-* - - - - - - - - - - - -  SOLR  - - - - - - - - - - - - 
+* - - - - - - - - - - - -  SOLR  - - - - - - - - - - - -
 */
 
 /**
@@ -148,18 +148,18 @@ function materio_search_api_search_api_solr_dynamic_field_info() {
 
 /**
  * hook_entity_property_info_alter().
- * 
+ *
  * define own fields
  * - main taxonomy terms, the purpose is to be able to attribute differente boost on serach api depending on term order
  * - companies infos (address) : retrieve for materiau content type the companie info from the tode node
- * 
+ *
  */
 function materio_search_api_entity_property_info_alter(&$info){
   // dsm($info, 'hook_entity_property_info_alter | info');
   // watchdog('materio solr', 'materio_search_api_entity_property_info_alter', array());
   $node_props = &$info['node']['properties'];
-  
-  for ($i=1; $i <= 5 ; $i++) { 
+
+  for ($i=1; $i <= 5 ; $i++) {
     $node_props['materio_search_api_onthologie_term_'.$i.'_text'] = array(
       'type'=>'text',
       'label'=> t('Main onthologie term '.$i. ' as text (+ synonyms)'),
@@ -198,9 +198,9 @@ function materio_search_api_entity_property_info_alter(&$info){
   $term_props = &$info['taxonomy_term']['properties'];
 
   $term_props['materio_search_api_term_property_dup_name'] = array(
-    'label' => t("Term name field dup"), 
-    'description' => t("Duplicate the term name field to apply different filter in solr (remove accents for instance)"), 
-    'type' => 'text', 
+    'label' => t("Term name field dup"),
+    'description' => t("Duplicate the term name field to apply different filter in solr (remove accents for instance)"),
+    'type' => 'text',
     'getter callback' => 'materio_search_api_term_property_dup_name',
   );
 
@@ -252,7 +252,7 @@ function materio_search_api_get_taglibres_terms_text($item){
 function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta){
   // dsm($item, 'item');
   // dsm($delta, 'delta');
-  
+
   if(isset($item->{$field_name}['und'][$delta])){
     // print '** item **'."\n";
     // print_r($item);
@@ -282,7 +282,7 @@ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta)
 
     return implode(" ", $keywords);
   }
-    
+
 
   return null;
 }
@@ -290,7 +290,7 @@ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta)
 function materio_search_api_get_node_propertie_companie($item){
   // dsm($item, '$item');
   $lang = "fr";//$item->language;
-  
+
   $languages = language_list();
   global $language;
   $language = $languages[$lang];
@@ -312,7 +312,7 @@ function materio_search_api_get_node_propertie_companie($item){
       $delta++;
     }
   }
-  
+
   return $cies;
 }
 
@@ -326,19 +326,19 @@ function company_get_tode_node($term){
   return false;
 }
 
-function rip_tags($string) { 
-  // ----- remove HTML TAGs ----- 
-  $string = preg_replace ('/<[^>]*>/', ' ', $string); 
-  
-  // ----- remove control characters ----- 
+function rip_tags($string) {
+  // ----- remove HTML TAGs -----
+  $string = preg_replace ('/<[^>]*>/', ' ', $string);
+
+  // ----- remove control characters -----
   $string = str_replace("\r", '', $string);    // --- replace with empty space
   $string = str_replace("\n", ' ', $string);   // --- replace with space
   $string = str_replace("\t", ' ', $string);   // --- replace with space
-  
+
   // $string = str_replace("&nbsp;", ' ', $string);   // --- replace with space
   // $string = str_replace("&#039;", '\'', $string);   // --- replace with space
 
-  // ----- remove multiple spaces ----- 
+  // ----- remove multiple spaces -----
   $string = trim(preg_replace('/ {2,}/', ' ', $string));
 
   // ----- remove html entities
@@ -346,7 +346,7 @@ function rip_tags($string) {
   foreach ($entities[0] as $entity) {
     $string = str_replace($entity, mb_convert_encoding($entity, 'UTF-8', 'HTML-ENTITIES'), $string);
   }
-  
+
   return $string;
 }
 
@@ -360,8 +360,8 @@ function materio_search_api_term_property_dup_name($term){
 
 
 /**
- *  - - -- - - - - - -  blocks - - - - - - - - - - - 
- * 
+ *  - - -- - - - - - -  blocks - - - - - - - - - - -
+ *
  */
 
 /**
@@ -378,7 +378,7 @@ function materio_search_api_block_info() {
     'info' => t('Materio search api view mode selection'),
     'cache' => DRUPAL_NO_CACHE
   );
-  
+
   // $blocks['materio_search_api_filters'] = array(
   //   'info' => t('Materio search api filters'),
   //   'cache' => DRUPAL_NO_CACHE
@@ -426,12 +426,12 @@ function materio_search_api_entity_info_alter(&$entity_info) {
     'label' => t('Small cards'),
     'custom settings' => TRUE,
   );
-  
+
   $entity_info['node']['view modes']['cardmedium'] = array(
     'label' => t('Medium cards'),
     'custom settings' => TRUE,
   );
-  
+
   $entity_info['node']['view modes']['cardbig'] = array(
     'label' => t('Big cards'),
     'custom settings' => TRUE,
@@ -455,7 +455,7 @@ function materio_search_api_node_view_alter(&$build) {
     // dsm($viewmode, 'viewmode');
     $node = $build['#node'];
     if($build['#view_mode'] != $viewmode && $build['#view_mode'] != "bookmark" & in_array($node->type, array('breve', 'materiau'))){
-      $build = node_view($node, $viewmode);  
+      $build = node_view($node, $viewmode);
     }
   }
 }
@@ -502,7 +502,7 @@ function materio_search_api_search_form($form, &$form_state){
 
   $form['searchfield'] = array(
     '#type' => 'textfield',
-    '#default_value' => $path == 'explore' ? $keys : $default_value, // TODO:  set the search page path global or a variable in settings  
+    '#default_value' => $path == 'explore' ? $keys : $default_value, // TODO:  set the search page path global or a variable in settings
     // '#value' => $keys,
     '#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
     //'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
@@ -512,15 +512,15 @@ function materio_search_api_search_form($form, &$form_state){
   );
 
   if(user_access('use materio search api filters')){
-    
+
     $index = search_api_index_load(variable_get('mainsearchindex', -1));
     $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
-   
+
     foreach ($indexed_bundles as $bundle) {
       $bundles_options[$bundle] = $bundle;
       $default_bundles[] = $bundle;
     }
-    
+
     $user_bundles_filter = isset($user->data['materiosearchapi_bundlesfilter']) ? $user->data['materiosearchapi_bundlesfilter'] : $default_bundles;
 
     $form['bundles_filter'] = array(
@@ -530,7 +530,7 @@ function materio_search_api_search_form($form, &$form_state){
       // '#attributes' => array('class'=>array('btn-group')),
     );
   }
-  
+
   $form['create'] = array(
     '#type' => 'image_button',
     '#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png',
@@ -564,7 +564,7 @@ function materio_search_api_search_form_submit($form, &$form_state){
     # if user have no access to filters
     $index = search_api_index_load(variable_get('mainsearchindex', -1));
     $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
-   
+
     foreach ($indexed_bundles as $bundle) {
       $bundles[] = $bundle;
     }
@@ -600,7 +600,7 @@ function _materio_search_api_change_viewmode($vm){
 }
 
 /**
-* - - - - - - - - - - - -  THEME  - - - - - - - - - - - - 
+* - - - - - - - - - - - -  THEME  - - - - - - - - - - - -
 */
 
 /**
@@ -624,7 +624,7 @@ function materio_search_api_theme($existing, $type, $theme, $path) {
     //   'path' => drupal_get_path('module', 'materio_search_api').'/templates',
     // ),
     'materio_search_api_results' => array(
-      'arguments' => array(), 
+      'arguments' => array(),
       'template' => 'materio-search-api-results',
       'path' => drupal_get_path('module', 'materio_search_api').'/templates',
       'variables' => array(
@@ -683,7 +683,7 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
 
   $entity_infos = entity_get_info();
   // dsm($entity_infos, 'entity_infos');
-  
+
   $content = '<div class="btn-group btn-group-vertical">';
   foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
     if(in_array($viewmode, $availableviewmodes)){
@@ -720,9 +720,9 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
 //   // $entity_infos = entity_get_info($index->item_type);
 //   // dsm($entity_infos, 'entity_infos');
 //   $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
-  
+
 //   dsm($indexed_bundles, 'indexed_bundles');
-  
+
 
 //   $vars['content'] = drupal_get_form('materio_search_api_filters_form', $indexed_bundles);
 // }
@@ -762,7 +762,7 @@ function template_preprocess_materio_search_api_results(array &$variables) {
   // $variables['items'] = $variables['index']->loadItems(array_keys($variables['results']['results']));
   $variables['result_count'] = $results['result count'];
   $variables['sec'] = round($results['performance']['complete'], 3);
-  
+
   if(isset($results['breves count'])){
     $variables['search_performance'] = format_plural(
       $results['breves count'],
@@ -802,7 +802,7 @@ function template_preprocess_materio_search_api_actuality(&$vars){
 }
 
 /**
-* - - - - - - - - - - - -  SEARCH API PAGE  - - - - - - - - - - - - 
+* - - - - - - - - - - - -  SEARCH API PAGE  - - - - - - - - - - - -
 */
 
 /**
@@ -813,7 +813,7 @@ function materio_search_api_block_view_alter(&$data, $block) {
   if ($block->module == 'search_api_page') {
     $page = search_api_page_load($block->delta);
     $item = menu_get_item();
-    
+
     if (isset($page->path) && $page->path == $item['path']) {
       $keys = arg(count(arg(NULL, $page->path)));
       if ($keys) {