|
@@ -99,6 +99,11 @@ function materio_search_api_access_search(){
|
|
return user_access('use materio search api for breves') || user_access('use materio search api');
|
|
return user_access('use materio search api for breves') || user_access('use materio search api');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+* - - - - - - - - - - - - SOLR - - - - - - - - - - - -
|
|
|
|
+*/
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Implements hook_search_api_data_type_info().
|
|
* Implements hook_search_api_data_type_info().
|
|
*
|
|
*
|
|
@@ -107,11 +112,18 @@ function materio_search_api_access_search(){
|
|
function materio_search_api_search_api_data_type_info() {
|
|
function materio_search_api_search_api_data_type_info() {
|
|
return array(
|
|
return array(
|
|
'edge_n2_kw_text' => array(
|
|
'edge_n2_kw_text' => array(
|
|
- 'name' => t('Fulltext (partial)'),
|
|
|
|
|
|
+ 'name' => t('Fulltext (partial matching)'),
|
|
'fallback' => 'text',
|
|
'fallback' => 'text',
|
|
|
|
+ 'prefix' => 'tem',
|
|
|
|
+ 'always multiValued' => TRUE,
|
|
|
|
+ ),
|
|
|
|
+ 'edge_n2_kw_mapped_text' => array(
|
|
|
|
+ 'name' => t('Fulltext without accents (partial matching)'),
|
|
|
|
+ 'fallback' => 'text',
|
|
|
|
+ 'prefix' => 'temmap',
|
|
|
|
+ 'always multiValued' => TRUE,
|
|
),
|
|
),
|
|
);
|
|
);
|
|
- return $types;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -125,20 +137,30 @@ function materio_search_api_search_api_solr_dynamic_field_info() {
|
|
'prefix' => 'tem',
|
|
'prefix' => 'tem',
|
|
'always multiValued' => TRUE,
|
|
'always multiValued' => TRUE,
|
|
),
|
|
),
|
|
|
|
+ 'edge_n2_kw_mapped_text' => array(
|
|
|
|
+ 'prefix' => 'temmap',
|
|
|
|
+ 'always multiValued' => TRUE,
|
|
|
|
+ ),
|
|
);
|
|
);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* hook_entity_property_info_alter().
|
|
* 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){
|
|
function materio_search_api_entity_property_info_alter(&$info){
|
|
// dsm($info, 'hook_entity_property_info_alter | info');
|
|
// dsm($info, 'hook_entity_property_info_alter | info');
|
|
// watchdog('materio solr', 'materio_search_api_entity_property_info_alter', array());
|
|
// watchdog('materio solr', 'materio_search_api_entity_property_info_alter', array());
|
|
- $properties = &$info['node']['properties'];
|
|
|
|
-
|
|
|
|
- for ($i=1; $i <= 5 ; $i++) {
|
|
|
|
- $properties['materio_search_api_onthologie_term_'.$i.'_text'] = array(
|
|
|
|
|
|
+ $node_props = &$info['node']['properties'];
|
|
|
|
+
|
|
|
|
+ for ($i=1; $i <= 5 ; $i++) {
|
|
|
|
+ $node_props['materio_search_api_onthologie_term_'.$i.'_text'] = array(
|
|
'type'=>'text',
|
|
'type'=>'text',
|
|
'label'=> t('Main onthologie term '.$i. ' as text (+ synonyms)'),
|
|
'label'=> t('Main onthologie term '.$i. ' as text (+ synonyms)'),
|
|
// 'query callback'=>'entity_metadata_table_query',
|
|
// 'query callback'=>'entity_metadata_table_query',
|
|
@@ -146,28 +168,42 @@ function materio_search_api_entity_property_info_alter(&$info){
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- $properties['materio_search_api_onthologie_term_others_text'] = array(
|
|
|
|
|
|
+ $node_props['materio_search_api_onthologie_term_others_text'] = array(
|
|
'type'=>'list<text>',
|
|
'type'=>'list<text>',
|
|
'label'=> t('Others onthologie terms as text (+ synonyms)'),
|
|
'label'=> t('Others onthologie terms as text (+ synonyms)'),
|
|
// 'query callback'=>'entity_metadata_table_query',
|
|
// 'query callback'=>'entity_metadata_table_query',
|
|
'getter callback'=>'materio_search_api_get_taxonomy_terms_others_text',
|
|
'getter callback'=>'materio_search_api_get_taxonomy_terms_others_text',
|
|
);
|
|
);
|
|
|
|
|
|
- $properties['materio_search_api_taglibres_text'] = array(
|
|
|
|
|
|
+ $node_props['materio_search_api_taglibres_text'] = array(
|
|
'type'=>'list<text>',
|
|
'type'=>'list<text>',
|
|
'label'=> t('Tag libres terms as text (+ synonyms)'),
|
|
'label'=> t('Tag libres terms as text (+ synonyms)'),
|
|
// 'query callback'=>'entity_metadata_table_query',
|
|
// 'query callback'=>'entity_metadata_table_query',
|
|
'getter callback'=>'materio_search_api_get_taglibres_terms_text',
|
|
'getter callback'=>'materio_search_api_get_taglibres_terms_text',
|
|
);
|
|
);
|
|
|
|
|
|
- $company_term_props = &$info['taxonomy_term']['bundles']['company']['properties'];
|
|
|
|
|
|
|
|
- $company_term_props['country'] = array(
|
|
|
|
- 'label' => t("Country"),
|
|
|
|
- 'description' => t("Company's Country get from tode node."),
|
|
|
|
- 'type' => 'text',
|
|
|
|
- 'getter callback' => 'company_term_property_country_get_props',
|
|
|
|
|
|
+
|
|
|
|
+ $node_materiau_props = &$info['node']['bundles']['materiau']['properties'];
|
|
|
|
+
|
|
|
|
+ $node_materiau_props['materio_search_api_node_propertie_companie'] = array(
|
|
|
|
+ 'type'=>'list<text>',
|
|
|
|
+ 'label'=> t('Manufacturers and distributors companies localised (dont addresse)'),
|
|
|
|
+ // 'query callback'=>'entity_metadata_table_query',
|
|
|
|
+ 'getter callback'=>'materio_search_api_get_node_propertie_companie',
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $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',
|
|
|
|
+ 'getter callback' => 'materio_search_api_term_property_dup_name',
|
|
|
|
+ );
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
function materio_search_api_get_onthologie_term_1_text($item){
|
|
function materio_search_api_get_onthologie_term_1_text($item){
|
|
@@ -216,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){
|
|
function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta){
|
|
// dsm($item, 'item');
|
|
// dsm($item, 'item');
|
|
// dsm($delta, 'delta');
|
|
// dsm($delta, 'delta');
|
|
-
|
|
|
|
|
|
+
|
|
if(isset($item->{$field_name}['und'][$delta])){
|
|
if(isset($item->{$field_name}['und'][$delta])){
|
|
// print '** item **'."\n";
|
|
// print '** item **'."\n";
|
|
// print_r($item);
|
|
// print_r($item);
|
|
@@ -246,25 +282,40 @@ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta)
|
|
|
|
|
|
return implode(" ", $keywords);
|
|
return implode(" ", $keywords);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-function company_term_property_country_get_props($term){
|
|
|
|
- // dsm($term, 'company_term_property_country_get_props : term');
|
|
|
|
- if( $node = company_get_tode_node($term) ){
|
|
|
|
- // $field_values = field_get_items('node',$node,'field_public_address');
|
|
|
|
- // dsm($field_values, 'field_values');
|
|
|
|
-
|
|
|
|
- $output = rip_tags(render(field_view_field('node',$node,'field_public_address')));
|
|
|
|
- // dsm($output, 'output');
|
|
|
|
-
|
|
|
|
- return $output;
|
|
|
|
|
|
+function materio_search_api_get_node_propertie_companie($item){
|
|
|
|
+ // dsm($item, '$item');
|
|
|
|
+ $lang = "fr";//$item->language;
|
|
|
|
+
|
|
|
|
+ $languages = language_list();
|
|
|
|
+ global $language;
|
|
|
|
+ $language = $languages[$lang];
|
|
|
|
+
|
|
|
|
+ $cies = array();
|
|
|
|
+ $cie_fields = array("field_company_fab", "field_company_distrib");
|
|
|
|
+ foreach ($cie_fields as $cie_field_name) {
|
|
|
|
+ $delta = 0;
|
|
|
|
+ while( isset($item->{$cie_field_name}['und'][$delta]) ){
|
|
|
|
+ $tid = $item->{$cie_field_name}['und'][$delta]['tid'];
|
|
|
|
+ $cie_term = taxonomy_term_load($tid);
|
|
|
|
+ if($cie_node = company_get_tode_node($cie_term)){
|
|
|
|
+ $cie_node->language = $lang;
|
|
|
|
+ $cie_view = node_view($cie_node, "full", $lang);
|
|
|
|
+ $cie_rendered = rip_tags(drupal_render($cie_view));
|
|
|
|
+ // dsm($cie_rendered, 'cie_rendered');
|
|
|
|
+ $cies[] = $cie_rendered;
|
|
|
|
+ }
|
|
|
|
+ $delta++;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return null;
|
|
|
|
|
|
+
|
|
|
|
+ return $cies;
|
|
}
|
|
}
|
|
|
|
+
|
|
function company_get_tode_node($term){
|
|
function company_get_tode_node($term){
|
|
if(module_exists('tode'))
|
|
if(module_exists('tode'))
|
|
if( $entitys = tode_get_nids_from_term($term))
|
|
if( $entitys = tode_get_nids_from_term($term))
|
|
@@ -274,19 +325,20 @@ function company_get_tode_node($term){
|
|
|
|
|
|
return false;
|
|
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("\r", '', $string); // --- replace with empty space
|
|
$string = str_replace("\n", ' ', $string); // --- replace with space
|
|
$string = str_replace("\n", ' ', $string); // --- replace with space
|
|
$string = str_replace("\t", ' ', $string); // --- replace with space
|
|
$string = str_replace("\t", ' ', $string); // --- replace with space
|
|
-
|
|
|
|
|
|
+
|
|
// $string = str_replace(" ", ' ', $string); // --- replace with space
|
|
// $string = str_replace(" ", ' ', $string); // --- replace with space
|
|
// $string = str_replace("'", '\'', $string); // --- replace with space
|
|
// $string = str_replace("'", '\'', $string); // --- replace with space
|
|
|
|
|
|
- // ----- remove multiple spaces -----
|
|
|
|
|
|
+ // ----- remove multiple spaces -----
|
|
$string = trim(preg_replace('/ {2,}/', ' ', $string));
|
|
$string = trim(preg_replace('/ {2,}/', ' ', $string));
|
|
|
|
|
|
// ----- remove html entities
|
|
// ----- remove html entities
|
|
@@ -294,10 +346,24 @@ function rip_tags($string) {
|
|
foreach ($entities[0] as $entity) {
|
|
foreach ($entities[0] as $entity) {
|
|
$string = str_replace($entity, mb_convert_encoding($entity, 'UTF-8', 'HTML-ENTITIES'), $string);
|
|
$string = str_replace($entity, mb_convert_encoding($entity, 'UTF-8', 'HTML-ENTITIES'), $string);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return $string;
|
|
return $string;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function materio_search_api_term_property_dup_name($term){
|
|
|
|
+ $lang = $term->language;
|
|
|
|
+ return $term->name_field[$lang][0]['value'];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * - - -- - - - - - - blocks - - - - - - - - - - -
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Implements hook_block_info().
|
|
* Implements hook_block_info().
|
|
*/
|
|
*/
|
|
@@ -312,7 +378,7 @@ function materio_search_api_block_info() {
|
|
'info' => t('Materio search api view mode selection'),
|
|
'info' => t('Materio search api view mode selection'),
|
|
'cache' => DRUPAL_NO_CACHE
|
|
'cache' => DRUPAL_NO_CACHE
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
// $blocks['materio_search_api_filters'] = array(
|
|
// $blocks['materio_search_api_filters'] = array(
|
|
// 'info' => t('Materio search api filters'),
|
|
// 'info' => t('Materio search api filters'),
|
|
// 'cache' => DRUPAL_NO_CACHE
|
|
// 'cache' => DRUPAL_NO_CACHE
|
|
@@ -337,7 +403,16 @@ function materio_search_api_block_view($delta = '') {
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 'materio_search_api_viewmode':
|
|
case 'materio_search_api_viewmode':
|
|
- if (user_access('use materio search api viewmode selection')) {
|
|
|
|
|
|
+ // restrict display on node page for materiau and breve
|
|
|
|
+ $block_is_visible = true;
|
|
|
|
+ $q = parse_url($_GET['q']);
|
|
|
|
+ $parts = explode('/', $q['path']);
|
|
|
|
+ if($parts[0] == "node"){
|
|
|
|
+ $node = node_load($parts[1]);
|
|
|
|
+ $block_is_visible = in_array($node->type, array('materiau','breve')) ? true : false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (user_access('use materio search api viewmode selection') && $block_is_visible) {
|
|
$block['subject'] = t('View mode');
|
|
$block['subject'] = t('View mode');
|
|
$block['content'] = theme('materio_search_api_select_viewmode_block', array());
|
|
$block['content'] = theme('materio_search_api_select_viewmode_block', array());
|
|
}
|
|
}
|
|
@@ -360,12 +435,12 @@ function materio_search_api_entity_info_alter(&$entity_info) {
|
|
'label' => t('Small cards'),
|
|
'label' => t('Small cards'),
|
|
'custom settings' => TRUE,
|
|
'custom settings' => TRUE,
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
$entity_info['node']['view modes']['cardmedium'] = array(
|
|
$entity_info['node']['view modes']['cardmedium'] = array(
|
|
'label' => t('Medium cards'),
|
|
'label' => t('Medium cards'),
|
|
'custom settings' => TRUE,
|
|
'custom settings' => TRUE,
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
$entity_info['node']['view modes']['cardbig'] = array(
|
|
$entity_info['node']['view modes']['cardbig'] = array(
|
|
'label' => t('Big cards'),
|
|
'label' => t('Big cards'),
|
|
'custom settings' => TRUE,
|
|
'custom settings' => TRUE,
|
|
@@ -389,7 +464,7 @@ function materio_search_api_node_view_alter(&$build) {
|
|
// dsm($viewmode, 'viewmode');
|
|
// dsm($viewmode, 'viewmode');
|
|
$node = $build['#node'];
|
|
$node = $build['#node'];
|
|
if($build['#view_mode'] != $viewmode && $build['#view_mode'] != "bookmark" & in_array($node->type, array('breve', 'materiau'))){
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -436,7 +511,7 @@ function materio_search_api_search_form($form, &$form_state){
|
|
|
|
|
|
$form['searchfield'] = array(
|
|
$form['searchfield'] = array(
|
|
'#type' => 'textfield',
|
|
'#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,
|
|
// '#value' => $keys,
|
|
'#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
|
|
'#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
|
|
//'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
|
|
//'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
|
|
@@ -446,15 +521,15 @@ function materio_search_api_search_form($form, &$form_state){
|
|
);
|
|
);
|
|
|
|
|
|
if(user_access('use materio search api filters')){
|
|
if(user_access('use materio search api filters')){
|
|
-
|
|
|
|
|
|
+
|
|
$index = search_api_index_load(variable_get('mainsearchindex', -1));
|
|
$index = search_api_index_load(variable_get('mainsearchindex', -1));
|
|
$indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
|
|
$indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($indexed_bundles as $bundle) {
|
|
foreach ($indexed_bundles as $bundle) {
|
|
$bundles_options[$bundle] = $bundle;
|
|
$bundles_options[$bundle] = $bundle;
|
|
$default_bundles[] = $bundle;
|
|
$default_bundles[] = $bundle;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$user_bundles_filter = isset($user->data['materiosearchapi_bundlesfilter']) ? $user->data['materiosearchapi_bundlesfilter'] : $default_bundles;
|
|
$user_bundles_filter = isset($user->data['materiosearchapi_bundlesfilter']) ? $user->data['materiosearchapi_bundlesfilter'] : $default_bundles;
|
|
|
|
|
|
$form['bundles_filter'] = array(
|
|
$form['bundles_filter'] = array(
|
|
@@ -464,7 +539,7 @@ function materio_search_api_search_form($form, &$form_state){
|
|
// '#attributes' => array('class'=>array('btn-group')),
|
|
// '#attributes' => array('class'=>array('btn-group')),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$form['create'] = array(
|
|
$form['create'] = array(
|
|
'#type' => 'image_button',
|
|
'#type' => 'image_button',
|
|
'#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png',
|
|
'#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png',
|
|
@@ -498,7 +573,7 @@ function materio_search_api_search_form_submit($form, &$form_state){
|
|
# if user have no access to filters
|
|
# if user have no access to filters
|
|
$index = search_api_index_load(variable_get('mainsearchindex', -1));
|
|
$index = search_api_index_load(variable_get('mainsearchindex', -1));
|
|
$indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
|
|
$indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($indexed_bundles as $bundle) {
|
|
foreach ($indexed_bundles as $bundle) {
|
|
$bundles[] = $bundle;
|
|
$bundles[] = $bundle;
|
|
}
|
|
}
|
|
@@ -534,7 +609,7 @@ function _materio_search_api_change_viewmode($vm){
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
-* - - - - - - - - - - - - THEME - - - - - - - - - - - -
|
|
|
|
|
|
+* - - - - - - - - - - - - THEME - - - - - - - - - - - -
|
|
*/
|
|
*/
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -558,7 +633,7 @@ function materio_search_api_theme($existing, $type, $theme, $path) {
|
|
// 'path' => drupal_get_path('module', 'materio_search_api').'/templates',
|
|
// 'path' => drupal_get_path('module', 'materio_search_api').'/templates',
|
|
// ),
|
|
// ),
|
|
'materio_search_api_results' => array(
|
|
'materio_search_api_results' => array(
|
|
- 'arguments' => array(),
|
|
|
|
|
|
+ 'arguments' => array(),
|
|
'template' => 'materio-search-api-results',
|
|
'template' => 'materio-search-api-results',
|
|
'path' => drupal_get_path('module', 'materio_search_api').'/templates',
|
|
'path' => drupal_get_path('module', 'materio_search_api').'/templates',
|
|
'variables' => array(
|
|
'variables' => array(
|
|
@@ -617,7 +692,7 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
|
|
|
|
|
|
$entity_infos = entity_get_info();
|
|
$entity_infos = entity_get_info();
|
|
// dsm($entity_infos, 'entity_infos');
|
|
// dsm($entity_infos, 'entity_infos');
|
|
-
|
|
|
|
|
|
+
|
|
$content = '<div class="btn-group btn-group-vertical">';
|
|
$content = '<div class="btn-group btn-group-vertical">';
|
|
foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
|
|
foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
|
|
if(in_array($viewmode, $availableviewmodes)){
|
|
if(in_array($viewmode, $availableviewmodes)){
|
|
@@ -654,9 +729,9 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
|
|
// // $entity_infos = entity_get_info($index->item_type);
|
|
// // $entity_infos = entity_get_info($index->item_type);
|
|
// // dsm($entity_infos, 'entity_infos');
|
|
// // dsm($entity_infos, 'entity_infos');
|
|
// $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
|
|
// $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
|
|
-
|
|
|
|
|
|
+
|
|
// dsm($indexed_bundles, 'indexed_bundles');
|
|
// dsm($indexed_bundles, 'indexed_bundles');
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
// $vars['content'] = drupal_get_form('materio_search_api_filters_form', $indexed_bundles);
|
|
// $vars['content'] = drupal_get_form('materio_search_api_filters_form', $indexed_bundles);
|
|
// }
|
|
// }
|
|
@@ -688,43 +763,64 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
|
|
*
|
|
*
|
|
* @see materio-search-api-results.tpl.php
|
|
* @see materio-search-api-results.tpl.php
|
|
*/
|
|
*/
|
|
-function template_preprocess_materio_search_api_results(array &$variables) {
|
|
|
|
- // dsm($variables, '$variables');
|
|
|
|
- $results = $variables['results'];
|
|
|
|
- $keys = $variables['keys'];
|
|
|
|
-
|
|
|
|
- // $variables['items'] = $variables['index']->loadItems(array_keys($variables['results']['results']));
|
|
|
|
- $variables['result_count'] = $results['result count'];
|
|
|
|
- $variables['sec'] = round($results['performance']['complete'], 3);
|
|
|
|
-
|
|
|
|
|
|
+function template_preprocess_materio_search_api_results(array &$vars) {
|
|
|
|
+ // dsm($vars, '$vars');
|
|
|
|
+ $results = $vars['results'];
|
|
|
|
+ $keys = $vars['keys'];
|
|
|
|
+
|
|
|
|
+ // $vars['items'] = $vars['index']->loadItems(array_keys($vars['results']['results']));
|
|
|
|
+ $vars['result_count'] = $results['result count'];
|
|
|
|
+ $vars['sec'] = round($results['performance']['complete'], 3);
|
|
|
|
+
|
|
|
|
+ $vars['keywords'] = implode(', ', $vars['keys']);
|
|
|
|
+
|
|
if(isset($results['breves count'])){
|
|
if(isset($results['breves count'])){
|
|
- $variables['search_performance'] = format_plural(
|
|
|
|
|
|
+ $vars['perfascard'] = true;
|
|
|
|
+ $vars['search_performance'] = format_plural(
|
|
$results['breves count'],
|
|
$results['breves count'],
|
|
'The search found 1 news ',
|
|
'The search found 1 news ',
|
|
'The search found @count news '
|
|
'The search found @count news '
|
|
);
|
|
);
|
|
- $variables['search_performance'] .= format_plural(
|
|
|
|
- $variables['result_count'] - $results['breves count'],
|
|
|
|
|
|
+ $vars['search_performance'] .= format_plural(
|
|
|
|
+ $vars['result_count'] - $results['breves count'],
|
|
'with 1 associated matter.',
|
|
'with 1 associated matter.',
|
|
'with @count associated matters.'
|
|
'with @count associated matters.'
|
|
);
|
|
);
|
|
- $variables['search_performance'] .= format_plural(
|
|
|
|
|
|
+ $vars['search_performance'] .= format_plural(
|
|
$results['could results']['result count'],
|
|
$results['could results']['result count'],
|
|
- ' You could find 1 result with a ',
|
|
|
|
- ' You could find <strong>@count results</strong> with a '
|
|
|
|
|
|
+ ' You could have found 1 result with a ',
|
|
|
|
+ ' You could have found <strong>@count results</strong> with a '
|
|
);
|
|
);
|
|
- $variables['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187');
|
|
|
|
|
|
+ $vars['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187');
|
|
|
|
+
|
|
|
|
+ $vars['search_performance'] .= l(t('Pricing'), 'node/11187', array("attributes"=>array("class"=>array('button'))));
|
|
|
|
|
|
}else{
|
|
}else{
|
|
- $variables['search_performance'] = format_plural(
|
|
|
|
- // $results['result count'],
|
|
|
|
- $variables['result_count'],
|
|
|
|
- 'The search found 1 result.',
|
|
|
|
- 'The search found @count results.'
|
|
|
|
|
|
+ $vars['perfascard'] = false;
|
|
|
|
+
|
|
|
|
+ // $vars['search_performance'] = format_plural(
|
|
|
|
+ // // $results['result count'],
|
|
|
|
+ // $vars['result_count'],
|
|
|
|
+ // 'The search found 1 result ',
|
|
|
|
+ // 'The search found @count results '
|
|
|
|
+ // )
|
|
|
|
+
|
|
|
|
+ $vars['search_performance'] = t('The search found @count result(s) with keywords @keys.', array(
|
|
|
|
+ "@count"=>$vars['result_count'],
|
|
|
|
+ "@keys"=>$vars['keywords'])
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ // TODO indicate how many materials and how many news
|
|
|
|
+ // $vars['search_performance'] = t('The search found @count result(s) with keywords @keys. @mat materials and @new news.', array(
|
|
|
|
+ // "@count"=>$vars['result_count'],
|
|
|
|
+ // "@keys"=>$vars['keywords'],
|
|
|
|
+ // "@mat"=>4,
|
|
|
|
+ // "@new"=>7)
|
|
|
|
+ // );
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- //dsm($variables, 'variables');
|
|
|
|
|
|
+ //dsm($vars, '$vars');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -736,7 +832,7 @@ function template_preprocess_materio_search_api_actuality(&$vars){
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
-* - - - - - - - - - - - - SEARCH API PAGE - - - - - - - - - - - -
|
|
|
|
|
|
+* - - - - - - - - - - - - SEARCH API PAGE - - - - - - - - - - - -
|
|
*/
|
|
*/
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -747,7 +843,7 @@ function materio_search_api_block_view_alter(&$data, $block) {
|
|
if ($block->module == 'search_api_page') {
|
|
if ($block->module == 'search_api_page') {
|
|
$page = search_api_page_load($block->delta);
|
|
$page = search_api_page_load($block->delta);
|
|
$item = menu_get_item();
|
|
$item = menu_get_item();
|
|
-
|
|
|
|
|
|
+
|
|
if (isset($page->path) && $page->path == $item['path']) {
|
|
if (isset($page->path) && $page->path == $item['path']) {
|
|
$keys = arg(count(arg(NULL, $page->path)));
|
|
$keys = arg(count(arg(NULL, $page->path)));
|
|
if ($keys) {
|
|
if ($keys) {
|