handled ajax call for advanced search, handled permissions for advanced form display
This commit is contained in:
@@ -504,7 +504,10 @@ function materio_search_api_block_view($delta = '') {
|
||||
|
||||
switch ($delta) {
|
||||
case 'materio_search_api_search':
|
||||
if (user_access('use materio search api') || user_access('use materio search api for breves')) {
|
||||
if (user_access('use materio search api') && user_access('use materio advanced search')) {
|
||||
$block['subject'] = t('Search');
|
||||
$block['content'] = theme('materio_search_api_double_search_block', array());
|
||||
}else if (user_access('use materio search api') || user_access('use materio search api for breves')) {
|
||||
$block['subject'] = t('Search');
|
||||
$block['content'] = theme('materio_search_api_search_block', array());
|
||||
}
|
||||
@@ -617,20 +620,13 @@ function materio_search_api_search_form($form, &$form_state){
|
||||
|
||||
$args = arg();
|
||||
$path = array_shift($args);
|
||||
// dsm($args, 'args');
|
||||
// if(isset($args[0]) && $args[0] == "advanced"){
|
||||
// $advanced = true;
|
||||
// array_shift($args);
|
||||
// // dsm($args, 'shifted arsg');
|
||||
// // foreach ($args as $arg) {
|
||||
// // $typed[] = $arg;//(integer)$arg;
|
||||
// // }
|
||||
// $keys = implode(' +', $args);
|
||||
// }else{
|
||||
$keys = implode('/', $args);
|
||||
// }
|
||||
if (isset($args[0]) && $args[0] == "filters") {
|
||||
$path .= '/'.array_shift($args);
|
||||
}
|
||||
|
||||
$is_explore = $path == 'explore' || $path == 'explore/filters';
|
||||
|
||||
$keys = implode('/', $args);
|
||||
|
||||
if(user_access('use materio search api autocomplete')){ // use materio search api autocomplete | use materio search api filters
|
||||
$query = new EntityFieldQuery();
|
||||
@@ -646,7 +642,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' => $is_explore ? $keys : $default_value, // TODO: set the search page path global or a variable in settings
|
||||
'#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
|
||||
//'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
|
||||
'#size' => 30,
|
||||
@@ -681,7 +677,7 @@ function materio_search_api_search_form($form, &$form_state){
|
||||
);
|
||||
|
||||
// add a back to search/base home bouton if on explore/foo
|
||||
if ($path == 'explore' || $path == 'bookmarks' || $path == 'lists' ) {
|
||||
if ($path == 'explore' || $path == 'explore/filters' || $path == 'bookmarks' || $path == 'lists' ) {
|
||||
|
||||
// buttons form container
|
||||
$form['rightcol'] = array(
|
||||
@@ -1020,7 +1016,7 @@ function materio_search_api_advanced_search_form($form, &$form_state){
|
||||
'#type' => 'container',
|
||||
);
|
||||
// add a back to search/base home bouton if on explore/foo
|
||||
if ($path == 'explore' || $path == 'bookmarks' || $path == 'lists' ) {
|
||||
if ($path == 'explore' || $path == 'explore/filters' || $path == 'bookmarks' || $path == 'lists' ) {
|
||||
$link = l('<i class="fi-home"></i>', base_path().'actuality', array(
|
||||
'html'=>true,
|
||||
'attributes'=>array('class'=>'back-search-home')
|
||||
@@ -1137,6 +1133,11 @@ function materio_search_api_theme($existing, $type, $theme, $path) {
|
||||
'template' => 'materio-search-api-advanced-search-block',
|
||||
'path' => drupal_get_path('module', 'materio_search_api').'/templates',
|
||||
),
|
||||
'materio_search_api_double_search_block' => array(
|
||||
'arguments' => array(),
|
||||
'template' => 'materio-search-api-double-search-block',
|
||||
'path' => drupal_get_path('module', 'materio_search_api').'/templates',
|
||||
),
|
||||
'materio_search_api_select_viewmode_block' => array(
|
||||
'arguments' => array(),
|
||||
'template' => 'materio-search-api-select-viewmode-block',
|
||||
@@ -1193,15 +1194,11 @@ function materio_search_api_theme($existing, $type, $theme, $path) {
|
||||
|
||||
|
||||
/**
|
||||
* template_preprocess_materiobase_search_block();
|
||||
* template_preprocess_materiobase_advanced_search_block();
|
||||
*/
|
||||
function template_preprocess_materio_search_api_search_block(&$vars){
|
||||
// dsm($vars, '$vars');
|
||||
$vars['search_title'] = t("Text search");
|
||||
$vars['searchform'] = drupal_get_form("materio_search_api_search_form");
|
||||
|
||||
$vars['advanced_search_title'] = t("Filtered search");
|
||||
$vars['advanced_searchform'] = drupal_get_form("materio_search_api_advanced_search_form");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1212,6 +1209,18 @@ function template_preprocess_materio_search_api_advanced_search_block(&$vars){
|
||||
$vars['searchform'] = drupal_get_form("materio_search_api_advanced_search_form");
|
||||
}
|
||||
|
||||
/**
|
||||
* template_preprocess_materiobase_search_block();
|
||||
*/
|
||||
function template_preprocess_materio_search_api_double_search_block(&$vars){
|
||||
// dsm($vars, '$vars');
|
||||
$vars['search_title'] = t("Text search");
|
||||
$vars['searchform'] = drupal_get_form("materio_search_api_search_form");
|
||||
|
||||
$vars['advanced_search_title'] = t("Filtered search");
|
||||
$vars['advanced_searchform'] = drupal_get_form("materio_search_api_advanced_search_form");
|
||||
}
|
||||
|
||||
|
||||
function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
|
||||
global $user;
|
||||
|
||||
Reference in New Issue
Block a user