@@ -227,6 +227,21 @@ function materio_search_api_search_form($form, &$form_state){
|
||||
global $user;
|
||||
$form = array();
|
||||
|
||||
|
||||
$args = arg();
|
||||
$path = array_shift($args);
|
||||
$keys = implode('/', $args);
|
||||
|
||||
$form['searchfield'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $path == 'explore' ? $keys : "", // TODO: set the search page path global or a variable in settings
|
||||
// '#value' => $keys,
|
||||
'#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
|
||||
//'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
|
||||
'#size' => 30,
|
||||
'#maxlength' => 1024,
|
||||
);
|
||||
|
||||
if(user_access('use materio search api filters')){
|
||||
|
||||
$index = search_api_index_load(variable_get('mainsearchindex', -1));
|
||||
@@ -247,20 +262,6 @@ function materio_search_api_search_form($form, &$form_state){
|
||||
);
|
||||
}
|
||||
|
||||
$args = arg();
|
||||
$path = array_shift($args);
|
||||
$keys = implode('/', $args);
|
||||
|
||||
$form['searchfield'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $path == 'explore' ? $keys : "", // TODO: set the search page path global or a variable in settings
|
||||
// '#value' => $keys,
|
||||
'#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
|
||||
//'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
|
||||
'#size' => 30,
|
||||
'#maxlength' => 1024,
|
||||
);
|
||||
|
||||
$form['create'] = array(
|
||||
'#type' => 'image_button',
|
||||
'#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png',
|
||||
@@ -307,22 +308,27 @@ function materio_search_api_search_form_submit($form, &$form_state){
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*
|
||||
* Adds language fields to user forms.
|
||||
* viewmode
|
||||
*/
|
||||
// TODO: user can choose preferred view mode
|
||||
// function materio_search_api_form_alter(&$form, &$form_state, $form_id) {
|
||||
// if (user_access('use materio search api viewmode selection')) {
|
||||
// if ($form_id == 'user_register_form' || ($form_id == 'user_profile_form' && $form['#user_category'] == 'account')) {
|
||||
// materio_search_api_viewmode_selector_form($form, $form_state, $form['#user']);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// function materio_search_api_viewmode_selector_form(&$form, &$form_state, $user) {
|
||||
function _materio_search_api_change_viewmode($vm){
|
||||
// dsm($vm, '_materio_search_api_change_viewmode');
|
||||
|
||||
// }
|
||||
global $user;
|
||||
// dsm($user, 'user');
|
||||
|
||||
$entity_infos = entity_get_info();
|
||||
// dsm($entity_infos, 'entity_infos');
|
||||
|
||||
if (in_array($vm, variable_get('availableviewmodes', array()))) {
|
||||
user_save($user, array("data"=>array('materiosearchapi_viewmode' => $vm)));
|
||||
$rep = array('statut'=>'saved');
|
||||
}else{
|
||||
$rep = array('statut'=>'viewmode not allowed');
|
||||
}
|
||||
|
||||
return $rep;
|
||||
}
|
||||
|
||||
/**
|
||||
* - - - - - - - - - - - - THEME - - - - - - - - - - - -
|
||||
@@ -409,10 +415,29 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
|
||||
$entity_infos = entity_get_info();
|
||||
// dsm($entity_infos, 'entity_infos');
|
||||
|
||||
// TODO: refaire les boutons view modes pour qu'il fonctionne sans javascript
|
||||
// faire un lien vers l'enregistrement du mode puis un reload de la page courante
|
||||
$content = '<div class="btn-group btn-group-vertical">';
|
||||
foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
|
||||
if(in_array($viewmode, $availableviewmodes)){
|
||||
$content .= '<div class="viewmode-link viewmode-'.$viewmode.($active == $viewmode ? " active" : '').'" rel="'.$viewmode.'"><span class="inner">'.$value['label'].'</span></div>';
|
||||
$link = l(
|
||||
'<span class="inner">'.$value['label'].'</span>',
|
||||
'materiosearchapi/viewmode/change/'.$viewmode,
|
||||
array(
|
||||
'query' => drupal_get_destination(),
|
||||
'html' => true,
|
||||
'attributes' => array(
|
||||
'class' => array(
|
||||
'viewmode-link',
|
||||
'viewmode-'.$viewmode,
|
||||
$active == $viewmode ? " active" : ''
|
||||
),
|
||||
'rel' => $viewmode
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$content .= $link;
|
||||
}
|
||||
}
|
||||
$content .= '</div>';
|
||||
@@ -471,11 +496,11 @@ function template_preprocess_materio_search_api_results(array &$variables) {
|
||||
$variables['result_count'] = $results['result count'];
|
||||
$variables['sec'] = round($results['performance']['complete'], 3);
|
||||
$variables['search_performance'] = format_plural(
|
||||
$results['result count'],
|
||||
'The search found 1 result.', // in @sec seconds
|
||||
'The search found @count results.', // in @sec seconds
|
||||
array('@sec' => $variables['sec'])
|
||||
);
|
||||
$results['result count'],
|
||||
'The search found 1 result.', // in @sec seconds
|
||||
'The search found @count results.', // in @sec seconds
|
||||
array('@sec' => $variables['sec'])
|
||||
);
|
||||
|
||||
// $variables['search_results'] = array(
|
||||
// '#theme' => 'search_results_list',
|
||||
@@ -497,7 +522,7 @@ function template_preprocess_materio_search_api_actuality(&$vars){
|
||||
// $items[] = node_load($nid);
|
||||
// }
|
||||
// $vars['items'] = $items;
|
||||
|
||||
$vars['actualities_infos'] = t('Actualities by materiO\'');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user