| 1 |
<?php |
<?php |
| 2 |
// $Id: dynosearcho.module,v 1.9 2007/12/05 19:39:07 manello Exp $ |
// $Id: dynosearcho.module,v 1.10 2008/01/20 17:18:23 manello Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 39 |
The search results are cached on the client to minimize trips back to the server. This is possible |
The search results are cached on the client to minimize trips back to the server. This is possible |
| 40 |
since much of the JavaScript (JQuery) code was borrowed from the autocomplete module. |
since much of the JavaScript (JQuery) code was borrowed from the autocomplete module. |
| 41 |
<br/><br/> |
<br/><br/> |
| 42 |
|
Each DynoSearcho block has extensive configuration settings from the block administration page. DynoSearcho |
| 43 |
|
also integrates nicely with the standard Drupal search. If this option is selected in the block configuration, |
| 44 |
|
a user can enter some terms into the DynoSearcho box and press the "enter" key to submit their |
| 45 |
|
search query to the full Drupal search system. |
| 46 |
|
<br/><br/> |
| 47 |
Finally, the module uses unobtrusive JavaScript. When JavaScript is not available, a "search" button is |
Finally, the module uses unobtrusive JavaScript. When JavaScript is not available, a "search" button is |
| 48 |
present and the search results are shown on a new page (after a round-trip to the server, of course). |
present and the search results are shown on a new page (after a round-trip to the server, of course). |
| 49 |
<br/><br/> |
<br/><br/> |
| 115 |
variable_set('dynosearcho_header_'. $delta, $edit['header']); |
variable_set('dynosearcho_header_'. $delta, $edit['header']); |
| 116 |
variable_set('dynosearcho_display_menu_paths_'. $delta, $edit['display_menu_paths']); |
variable_set('dynosearcho_display_menu_paths_'. $delta, $edit['display_menu_paths']); |
| 117 |
variable_set('dynosearcho_search_type_'. $delta, $edit['search_type']); |
variable_set('dynosearcho_search_type_'. $delta, $edit['search_type']); |
| 118 |
|
variable_set('dynosearcho_integrated_search_'. $delta, $edit['integrated_search']); |
| 119 |
return; |
return; |
| 120 |
} |
} |
| 121 |
} |
} |
| 148 |
'#description' => t('The higher the value, the slower the response.'), |
'#description' => t('The higher the value, the slower the response.'), |
| 149 |
); |
); |
| 150 |
|
|
| 151 |
|
$form['integrated_search'] = array( |
| 152 |
|
'#type' => 'checkbox', |
| 153 |
|
'#title' => t('Integrated with Drupal\'s standard search'), |
| 154 |
|
'#default_value' => variable_get('dynosearcho_integrated_search_'. $delta, '0'), |
| 155 |
|
'#description' => t('If selected, when the presses the "enter" key, the search terms in the DynoSearch box will be submitted to the standard Drupal search module.'), |
| 156 |
|
); |
| 157 |
|
|
| 158 |
|
if (!module_exists('search')) { |
| 159 |
|
$form['integrated_search']['#value'] = 0; |
| 160 |
|
$form['integrated_search']['#disabled'] = true; |
| 161 |
|
$form['integrated_search']['#description'] = t('The search module must be enabled for this option to be available.'); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
$form['header'] = array( |
$form['header'] = array( |
| 165 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 166 |
'#title' => t('Header'), |
'#title' => t('Header'), |
| 167 |
'#default_value' => variable_get('dynosearcho_header_'. $delta, 'Enter keywords or title in box to find content.'), |
'#default_value' => variable_get('dynosearcho_header_'. $delta, 'Enter keywords or title in box to find content. Press "Enter" key for full results.'), |
| 168 |
'#maxlength' => 250, |
'#maxlength' => 250, |
| 169 |
'#description' => t('This text will be displayed above the search box.'), |
'#description' => t('This text will be displayed above the search box.'), |
| 170 |
); |
); |
| 290 |
drupal_add_css(drupal_get_path('module', 'dynosearcho') .'/dynosearcho.css'); |
drupal_add_css(drupal_get_path('module', 'dynosearcho') .'/dynosearcho.css'); |
| 291 |
|
|
| 292 |
$form['#id'] = 'dynosearcho_search_form_' . $delta; |
$form['#id'] = 'dynosearcho_search_form_' . $delta; |
| 293 |
|
$form['#attributes'] = array('class' => 'dynosearcho'); |
| 294 |
|
|
| 295 |
|
if (variable_get('dynosearcho_integrated_search_'. $delta, '0')) { |
| 296 |
|
$form['dynosearcho_integrated_search_'. $delta] = array( |
| 297 |
|
'#type' => 'hidden', |
| 298 |
|
'#value' => 1, |
| 299 |
|
); |
| 300 |
|
} |
| 301 |
|
if (!module_exists('search')) $form['dynosearcho_integrated_search_'. $delta]['#value'] = 0; |
| 302 |
|
|
| 303 |
$form['header'] = array( |
$form['header'] = array( |
| 304 |
'#value' => variable_get('dynosearcho_header_'. $delta, 'Enter keywords to begin.'), |
'#value' => variable_get('dynosearcho_header_'. $delta, 'Enter keywords to begin.'), |
| 305 |
); |
); |
| 310 |
$form['dynosearcho_search_'. $delta] = array( |
$form['dynosearcho_search_'. $delta] = array( |
| 311 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 312 |
'#title' => variable_get('dynosearcho_search_box_title_'. $delta, 'Keywords'), |
'#title' => variable_get('dynosearcho_search_box_title_'. $delta, 'Keywords'), |
| 313 |
'#description' => t('Use commas to separate multiple keywords'), |
'#description' => t('Use commas to separate multiple keywords.'), |
| 314 |
'#maxlength' => 60, |
'#maxlength' => 60, |
| 315 |
'#size' => 10, |
'#size' => 10, |
| 316 |
'#default_value' => $default_value, |
'#default_value' => $default_value, |
| 327 |
'#value' => url('dynosearcho'), |
'#value' => url('dynosearcho'), |
| 328 |
); |
); |
| 329 |
|
|
| 330 |
|
$form['dynosearcho_basepath_'. $delta] = array( |
| 331 |
|
'#type' => 'hidden', |
| 332 |
|
'#value' => base_path(), |
| 333 |
|
'#attributes' => array('class' => 'dynosearcho_basepath'), |
| 334 |
|
); |
| 335 |
|
|
| 336 |
$form['dynosearcho_results_' . $delta] = array( |
$form['dynosearcho_results_' . $delta] = array( |
| 337 |
'#value' => '<div class="dynosearcho_results" id="dynosearcho_results_' . $delta . '">' . $matches . '</div>', |
'#value' => '<div class="dynosearcho_results" id="dynosearcho_results_' . $delta . '">' . $matches . '</div>', |
| 338 |
); |
); |
| 346 |
} |
} |
| 347 |
|
|
| 348 |
function dynosearcho_search_form_submit($form_id, $form_values) { |
function dynosearcho_search_form_submit($form_id, $form_values) { |
| 349 |
echo 'form_id: ' . $form_id . '<br/>'; |
//echo 'form_id: ' . $form_id . '<br/>'; |
| 350 |
print_r($form_values);exit; |
//print_r($form_values);exit; |
| 351 |
return 'dynosearcho/'. $form_values['dynosearcho_delta'] .'/'. $form_values['dynosearcho_search_'. $form_values['dynosearcho_delta']] .'/1'; |
return 'dynosearcho/'. $form_values['dynosearcho_delta'] .'/'. $form_values['dynosearcho_search_'. $form_values['dynosearcho_delta']] .'/1'; |
| 352 |
} |
} |
| 353 |
|
|