improved the message to people who access to the serach tool without an account

cf link from daily materiO'
This commit is contained in:
Bachir Soussi Chiadmi
2014-07-15 19:45:08 +02:00
parent 488d4c19aa
commit 2e1e0cc05b
3 changed files with 144 additions and 124 deletions

View File

@@ -96,7 +96,8 @@ function materio_search_api_menu() {
}
function materio_search_api_access_search(){
return user_access('use materio search api for breves') || user_access('use materio search api');
return true;
// return user_access('use materio search api for breves') || user_access('use materio search api');
}
@@ -355,10 +356,6 @@ function materio_search_api_term_property_dup_name($term){
return $term->name_field[$lang][0]['value'];
}
/**
* - - -- - - - - - - blocks - - - - - - - - - - -
*
@@ -766,60 +763,79 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
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);
if(isset($results['result count'])){
// $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']);
$vars['keywords'] = $vars['keys'];
if(isset($results['breves count'])){
if(isset($results['breves count'])){
// for free users
$vars['perfascard'] = true;
$vars['search_performance'] = format_plural(
$results['breves count'],
'The search found 1 news ',
'The search found @count news '
);
$vars['search_performance'] .= format_plural(
$vars['result_count'] - $results['breves count'],
'with 1 associated matter.',
'with @count associated matters.'
);
$vars['search_performance'] .= format_plural(
$results['could results']['result count'],
' You could have found 1 result with a ',
' You could have found <strong>@count results</strong> with a '
);
$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{
// for members
$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)
// );
}
}else{
//for anonymous
$vars['perfascard'] = true;
$vars['search_performance'] = format_plural(
$results['breves count'],
'The search found 1 news ',
'The search found @count news '
);
$vars['search_performance'] .= format_plural(
$vars['result_count'] - $results['breves count'],
'with 1 associated matter.',
'with @count associated matters.'
);
$vars['search_performance'] .= format_plural(
$perfoutput = t('Your can\'t access to the materiO\' search tool without an account.').'<br />';
$perfoutput .= format_plural(
$results['could results']['result count'],
' You could have found 1 result with a ',
' You could have found <strong>@count results</strong> with a '
);
$vars['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187');
$perfoutput .= l(t('full access to materiO\'.'), 'node/11187');
$vars['search_performance'] .= l(t('Pricing'), 'node/11187', array("attributes"=>array("class"=>array('button'))));
}else{
$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)
// );
$perfoutput .= l(t('Pricing'), 'node/11187', array("attributes"=>array("class"=>array('button'))));
$vars['search_performance'] = $perfoutput;
}
//dsm($vars, '$vars');
}