/[drupal]/contributions/modules/dynosearcho/dynosearcho.module
ViewVC logotype

Diff of /contributions/modules/dynosearcho/dynosearcho.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Sun Jan 20 17:19:43 2008 UTC revision 1.3, Mon Oct 27 17:21:46 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: dynosearcho.module,v 1.10 2008/01/20 17:18:23 manello Exp $  // $Id: dynosearcho.module,v 1.2 2008/01/20 17:19:43 ultimike Exp $
3    
4  /**  /**
5   * @file   * @file
6   * DynoSearcho lets users dynamically search for different types of content.   * DynoSearcho lets users dynamically search for different types of content.
7   *   *
8   * This module allows the site admin to display various blocks on the site that provide   * This module allows the site admin to display various blocks on the site that provide
9   * a dynamic way to search for content. DynoSearch uses AHAH to display results as the   * a dynamic way to search for content. DynoSearch uses AHAH to display results as the
10   * user enters them (similar to Drupal's most-excellent autocomplete feature). Each block   * user enters them (similar to Drupal's most-excellent autocomplete feature). Each block
11   * can be configured to display a configurable number of results from specific node types.   * can be configured to display a configurable number of results from specific node types.
12   */   */
# Line 22  function dynosearcho_help($section) { Line 22  function dynosearcho_help($section) {
22      case 'admin/modules#description':      case 'admin/modules#description':
23        return t('DynoSearcho provides a dynamic (AHAH) way to search for content by title and tags.');        return t('DynoSearcho provides a dynamic (AHAH) way to search for content by title and tags.');
24      case 'admin/help#dynosearcho':      case 'admin/help#dynosearcho':
25        return t('DynoSearcho provides a dynamic (AHAH) way to search for content.        return t('DynoSearcho provides a dynamic (AHAH) way to search for content.
26  This module allows the site admin to display various blocks on the site that provide a dynamic  This module allows the site admin to display various blocks on the site that provide a dynamic
27  way to search for content. DynoSearch uses AHAH to display results as the user enters them  way to search for content. DynoSearch uses AHAH to display results as the user enters them
28  (similar to Drupal\'s most-excellent autocomplete feature). Each block can be configured  (similar to Drupal\'s most-excellent autocomplete feature). Each block can be configured
29  to display a configurable number of results from <strong>specific node types</strong> as well as the information returned.  to display a configurable number of results from <strong>specific node types</strong> as well as the information returned.
30  The module only searches title and tags to find matches.  The module only searches title and tags to find matches.
31  <br/><br/>  <br/><br/>
32  DynoSearcho is not a replacement for the search module, it is much simpler and doesn\'t search the  DynoSearcho is not a replacement for the search module, it is much simpler and doesn\'t search the
33  body of the content. It is meant to be a faster, lightweight search agent for quick searches over  body of the content. It is meant to be a faster, lightweight search agent for quick searches over
34  a <strong>limited</strong> set of nodes.  a <strong>limited</strong> set of nodes.
35  <br/><br/>  <br/><br/>
36  The site admin can select how many DynoSearcho blocks are available from '. l('DynoSearcho\'s settings page', 'admin/settings/dynosearcho') .'. '.  The site admin can select how many DynoSearcho blocks are available from '. l('DynoSearcho\'s settings page', 'admin/settings/dynosearcho') .'. '.
37  'Each block can then be configured from the '. l('Block Configuration Page', 'admin/block') .'.  'Each block can then be configured from the '. l('Block Configuration Page', 'admin/block') .'.
38  <br/><br/>  <br/><br/>
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  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,  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  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.  search query to the full Drupal search system.
46  <br/><br/>  <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/>
50  ');  ');
# Line 56  present and the search results are shown Line 56  present and the search results are shown
56   */   */
57  function dynosearcho_menu($may_cache) {  function dynosearcho_menu($may_cache) {
58    $items = array();    $items = array();
59    
60    if ($may_cache) {    if ($may_cache) {
61      $items[] = array(      $items[] = array(
62          'title' => 'DynoSearcho',          'title' => 'DynoSearcho',
# Line 67  function dynosearcho_menu($may_cache) { Line 67  function dynosearcho_menu($may_cache) {
67          'access' => user_access('administer site configuration'),          'access' => user_access('administer site configuration'),
68          'type' => MENU_NORMAL_ITEM,          'type' => MENU_NORMAL_ITEM,
69      );      );
70    }    }
71    else {    else {
72      $items[] = array(      $items[] = array(
73          'description' => 'Perform a DynoSearch search.',          'description' => 'Perform a DynoSearch search.',
# Line 96  function dynosearcho_block($op = 'list', Line 96  function dynosearcho_block($op = 'list',
96        $blocks[$i] = array('info' => t('DynoSearcho block #') . (string)($i + 1));        $blocks[$i] = array('info' => t('DynoSearcho block #') . (string)($i + 1));
97      }      }
98      return $blocks;      return $blocks;
99    
100    }    }
101    elseif ($op == 'configure') {    elseif ($op == 'configure') {
102      return dynosearcho_block_settings_form($delta);      return dynosearcho_block_settings_form($delta);
# Line 121  function dynosearcho_block($op = 'list', Line 121  function dynosearcho_block($op = 'list',
121  }  }
122    
123  function dynosearcho_block_settings_form($delta) {  function dynosearcho_block_settings_form($delta) {
124    drupal_add_js(drupal_get_path('module', 'dynosearcho') .'/dynosearcho.js');    drupal_add_js(drupal_get_path('module', 'dynosearcho') .'/dynosearcho.js');
125    
126    $form['search_box_title'] = array(    $form['search_box_title'] = array(
127      '#type' => 'textfield',      '#type' => 'textfield',
128      '#title' => t('Search box title'),      '#title' => t('Search box title'),
# Line 130  function dynosearcho_block_settings_form Line 130  function dynosearcho_block_settings_form
130      '#maxlength' => 50,      '#maxlength' => 50,
131      '#description' => t('This text will be the title of the actual search box.'),      '#description' => t('This text will be the title of the actual search box.'),
132    );    );
133    
134    $form['results_returned'] = array(    $form['results_returned'] = array(
135      '#type' => 'select',      '#type' => 'select',
136      '#title' => t('Number of results returned'),      '#title' => t('Number of results returned'),
# Line 147  function dynosearcho_block_settings_form Line 147  function dynosearcho_block_settings_form
147      ),      ),
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(    $form['integrated_search'] = array(
152      '#type' => 'checkbox',      '#type' => 'checkbox',
153      '#title' => t('Integrated with Drupal\'s standard search'),      '#title' => t('Integrated with Drupal\'s standard search'),
154      '#default_value' => variable_get('dynosearcho_integrated_search_'. $delta, '0'),      '#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.'),      '#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')) {    if (!module_exists('search')) {
159      $form['integrated_search']['#value'] = 0;      $form['integrated_search']['#value'] = 0;
160      $form['integrated_search']['#disabled'] = true;      $form['integrated_search']['#disabled'] = true;
161      $form['integrated_search']['#description'] = t('The search module must be enabled for this option to be available.');      $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'),
# Line 168  function dynosearcho_block_settings_form Line 168  function dynosearcho_block_settings_form
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    );    );
171    
172    $form['results_info_text'] = array(    $form['results_info_text'] = array(
173      '#type' => 'textfield',      '#type' => 'textfield',
174      '#title' => t('Results Info Text'),      '#title' => t('Results Info Text'),
# Line 176  function dynosearcho_block_settings_form Line 176  function dynosearcho_block_settings_form
176      '#maxlength' => 250,      '#maxlength' => 250,
177      '#description' => t('This is the text that will be shown to the user when the number of results is greater than the Number of Results Returned field above. %totalmatches and %resultsreturned wild cards available.'),      '#description' => t('This is the text that will be shown to the user when the number of results is greater than the Number of Results Returned field above. %totalmatches and %resultsreturned wild cards available.'),
178    );    );
179    
180    $form['no_results'] = array(    $form['no_results'] = array(
181      '#type' => 'textfield',      '#type' => 'textfield',
182      '#title' => t('No Results Text'),      '#title' => t('No Results Text'),
# Line 184  function dynosearcho_block_settings_form Line 184  function dynosearcho_block_settings_form
184      '#maxlength' => 250,      '#maxlength' => 250,
185      '#description' => t('This is the text that will be shown if there are no results to be displayed.'),      '#description' => t('This is the text that will be shown if there are no results to be displayed.'),
186    );    );
187    
188    $form['search_type'] = array(    $form['search_type'] = array(
189      '#type' => 'radios',      '#type' => 'radios',
190      '#title' => t('Search Type'),      '#title' => t('Search Type'),
191      '#default_value' => variable_get('dynosearcho_search_type_'. $delta, 'node'),      '#default_value' => variable_get('dynosearcho_search_type_'. $delta, 'node'),
192      '#options' => array(      '#options' => array(
193                      'node' => t('node'),                      'node' => t('node'),
194                      'menu' => t('menu')                      'menu' => t('menu')
195                    ),                    ),
196      '#description' => t('Select the type of search this DynoSearcho block will perform.'),      '#description' => t('Select the type of search this DynoSearcho block will perform.'),
197      '#attributes' => array('class' => 'dynosearcho_searchtype'),      '#attributes' => array('class' => 'dynosearcho_searchtype'),
198    );    );
199    
200    $form['node_search'] = array(    $form['node_search'] = array(
201      '#type' => 'fieldset',      '#type' => 'fieldset',
202      '#title' => 'Node Search Settings',      '#title' => 'Node Search Settings',
# Line 204  function dynosearcho_block_settings_form Line 204  function dynosearcho_block_settings_form
204      '#collapsible' => false,      '#collapsible' => false,
205      '#attributes' => array('id' => 'dynosearcho_nodesearch'),      '#attributes' => array('id' => 'dynosearcho_nodesearch'),
206    );    );
207    
208    $form['node_search']['searchable_node_types'] = array(    $form['node_search']['searchable_node_types'] = array(
209      '#type' => 'checkboxes',      '#type' => 'checkboxes',
210      '#title' => t('Node types to search'),      '#title' => t('Node types to search'),
# Line 212  function dynosearcho_block_settings_form Line 212  function dynosearcho_block_settings_form
212      '#options' => node_get_types('names'),      '#options' => node_get_types('names'),
213      '#description' => t('The more nodes types selected, the slower the response.'),      '#description' => t('The more nodes types selected, the slower the response.'),
214    );    );
215    
216    $form['node_search']['display_relevant_tags'] = array(    $form['node_search']['display_relevant_tags'] = array(
217      '#type' => 'checkbox',      '#type' => 'checkbox',
218      '#title' => t('Display relevant tags in results'),      '#title' => t('Display relevant tags in results'),
219      '#default_value' => variable_get('dynosearcho_display_relevant_tags_'. $delta, '1'),      '#default_value' => variable_get('dynosearcho_display_relevant_tags_'. $delta, '1'),
220      '#description' => t('If selected, tags that match search query will be displayed next to the title of the content returned.'),      '#description' => t('If selected, tags that match search query will be displayed next to the title of the content returned.'),
221    );    );
222    
223    $form['node_search']['teaser_length'] = array(    $form['node_search']['teaser_length'] = array(
224      '#type' => 'select',      '#type' => 'select',
225      '#title' => t('Length of teaser displayed'),      '#title' => t('Length of teaser displayed'),
# Line 234  function dynosearcho_block_settings_form Line 234  function dynosearcho_block_settings_form
234      ),      ),
235      '#description' => t('HTML tags will be automatically stripped out of teaser content.'),      '#description' => t('HTML tags will be automatically stripped out of teaser content.'),
236    );    );
237    
238    $form['node_search']['sort_by_date'] = array(    $form['node_search']['sort_by_date'] = array(
239      '#type' => 'checkbox',      '#type' => 'checkbox',
240      '#title' => t('Sort results by last modified date.'),      '#title' => t('Sort results by last modified date.'),
241      '#default_value' => variable_get('dynosearcho_sort_by_date_'. $delta, '0'),      '#default_value' => variable_get('dynosearcho_sort_by_date_'. $delta, '0'),
242      '#description' => t('Displays most recent first. Overrides default sort order of alphabetically by node title.'),      '#description' => t('Displays most recent first. Overrides default sort order of alphabetically by node title.'),
243    );    );
244    
245    $form['node_search']['display_edit_links'] = array(    $form['node_search']['display_edit_links'] = array(
246      '#type' => 'checkbox',      '#type' => 'checkbox',
247      '#title' => t('Display edit links'),      '#title' => t('Display edit links'),
248      '#default_value' => variable_get('dynosearcho_display_edit_links_'. $delta, '0'),      '#default_value' => variable_get('dynosearcho_display_edit_links_'. $delta, '0'),
249      '#description' => t('This will display edit links for nodes returned in the search results providing that the user has the "administer nodes" permission.'),      '#description' => t('This will display edit links for nodes returned in the search results providing that the user has the "administer nodes" permission.'),
250    );    );
251    
252    $form['node_search']['use_og_desc'] = array(    $form['node_search']['use_og_desc'] = array(
253      '#type' => 'checkbox',      '#type' => 'checkbox',
254      '#title' => t('Use Organic Groups description field for teaser text.'),      '#title' => t('Use Organic Groups description field for teaser text.'),
255      '#default_value' => variable_get('dynosearcho_use_og_desc_'. $delta, '0'),      '#default_value' => variable_get('dynosearcho_use_og_desc_'. $delta, '0'),
256      '#description' => t('This will replace the teaser text with the Organic Groups description. <strong>This should only be checked if the DynoSearcho box is only going to be searching groups.</strong>'),      '#description' => t('This will replace the teaser text with the Organic Groups description. <strong>This should only be checked if the DynoSearcho box is only going to be searching groups.</strong>'),
257    );    );
258    
259    $form['menu_search'] = array(    $form['menu_search'] = array(
260      '#type' => 'fieldset',      '#type' => 'fieldset',
261      '#title' => 'Menu Search Settings',      '#title' => 'Menu Search Settings',
# Line 263  function dynosearcho_block_settings_form Line 263  function dynosearcho_block_settings_form
263      '#collapsible' => false,      '#collapsible' => false,
264      '#attributes' => array('id' => 'dynosearcho_menusearch'),      '#attributes' => array('id' => 'dynosearcho_menusearch'),
265    );    );
266    
267    $form['menu_search']['display_menu_paths'] = array(    $form['menu_search']['display_menu_paths'] = array(
268      '#type' => 'checkbox',      '#type' => 'checkbox',
269      '#title' => t('Display menu paths in results'),      '#title' => t('Display menu paths in results'),
# Line 283  function _dynosearcho_settings() { Line 283  function _dynosearcho_settings() {
283    );    );
284    
285    return system_settings_form($form);    return system_settings_form($form);
286  }  }
287    
288  function dynosearcho_search_form($delta, $matches = NULL) {  function dynosearcho_search_form($delta, $matches = NULL) {
289    drupal_add_js(drupal_get_path('module', 'dynosearcho') .'/dynosearcho.js');    drupal_add_js(drupal_get_path('module', 'dynosearcho') .'/dynosearcho.js');
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');    $form['#attributes'] = array('class' => 'dynosearcho');
294    
295    if (variable_get('dynosearcho_integrated_search_'. $delta, '0')) {    if (variable_get('dynosearcho_integrated_search_'. $delta, '0')) {
296      $form['dynosearcho_integrated_search_'. $delta] = array(      $form['dynosearcho_integrated_search_'. $delta] = array(
297        '#type' => 'hidden',        '#type' => 'hidden',
# Line 299  function dynosearcho_search_form($delta, Line 299  function dynosearcho_search_form($delta,
299      );      );
300    }    }
301    if (!module_exists('search')) $form['dynosearcho_integrated_search_'. $delta]['#value'] = 0;    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    );    );
306    
307    if ((arg(0) == 'dynosearcho') && (arg(3) == '1')) {    if ((arg(0) == 'dynosearcho') && (arg(3) == '1')) {
308      $default_value = arg(2);      $default_value = arg(2);
309    }    }
# Line 311  function dynosearcho_search_form($delta, Line 311  function dynosearcho_search_form($delta,
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,
317      '#attributes' => array('class' => 'dynosearcho_searchbox'),      '#attributes' => array('class' => 'dynosearcho_searchbox'),
318    );    );
319    
320    $form['dynosearcho_delta'] = array(    $form['dynosearcho_delta'] = array(
321      '#type' => 'hidden',      '#type' => 'hidden',
322      '#value' => $delta,      '#value' => $delta,
323    );    );
324    
325    $form['dynosearcho_url_'. $delta] = array(    $form['dynosearcho_url_'. $delta] = array(
326      '#type' => 'hidden',      '#type' => 'hidden',
327      '#value' => url('dynosearcho'),      '#value' => url('dynosearcho'),
328    );    );
329    
330    $form['dynosearcho_basepath_'. $delta] = array(    $form['dynosearcho_basepath_'. $delta] = array(
331      '#type' => 'hidden',      '#type' => 'hidden',
332      '#value' => base_path(),      '#value' => base_path(),
333      '#attributes' => array('class' => 'dynosearcho_basepath'),      '#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    );    );
339    
340    $form['submit'] = array(    $form['submit'] = array(
341      '#type' => 'submit',      '#type' => 'submit',
342      '#value' => t('Search')      '#value' => t('Search')
343    );    );
344    
345    return $form;    return $form;
346  }  }
347    
# Line 354  function dynosearcho_search_form_submit( Line 354  function dynosearcho_search_form_submit(
354  function dynosearcho_dosearch($delta = 0, $string, $whole_page = false) {  function dynosearcho_dosearch($delta = 0, $string, $whole_page = false) {
355    // separate out multiple keywords if necessary    // separate out multiple keywords if necessary
356    $keywords = explode(',', $string);    $keywords = explode(',', $string);
357    
358    switch (variable_get('dynosearcho_search_type_'. $delta, 'node')) {    switch (variable_get('dynosearcho_search_type_'. $delta, 'node')) {
359      case 'node':      case 'node':
360        return dynosearcho_nodesearch($delta, $keywords, $whole_page);        return dynosearcho_nodesearch($delta, $keywords, $whole_page);
# Line 371  function _dynosearcho_menu_search_preg($ Line 371  function _dynosearcho_menu_search_preg($
371      foreach ($in_array as $key => $val) {      foreach ($in_array as $key => $val) {
372        if (is_array($val)) {        if (is_array($val)) {
373          $keys_found = _dynosearcho_menu_search_preg($find, $val, $keys_found);          $keys_found = _dynosearcho_menu_search_preg($find, $val, $keys_found);
374        }        }
375        else {        else {
376          if (preg_match('/'. $find .'/i', $val)) {          if (preg_match('/'. $find .'/i', $val)) {
377            $keys_found[] = $theitem;            $keys_found[] = $theitem;
# Line 384  function _dynosearcho_menu_search_preg($ Line 384  function _dynosearcho_menu_search_preg($
384  }  }
385    
386  //----- Thanks to a.fotoglidis (http://us2.php.net/manual/en/function.array-unique.php#68339) for this function  //----- Thanks to a.fotoglidis (http://us2.php.net/manual/en/function.array-unique.php#68339) for this function
387  function _dynosearcho_menu_elim_dups($array, $row_element) {  function _dynosearcho_menu_elim_dups($array, $row_element) {
388    $new_array[0] = $array[0];    $new_array[0] = $array[0];
389    foreach ($array as $current) {    foreach ($array as $current) {
390      $add_flag = 1;      $add_flag = 1;
# Line 401  function _dynosearcho_menu_elim_dups($ar Line 401  function _dynosearcho_menu_elim_dups($ar
401  function dynosearcho_menusearch($delta, $keywords, $whole_page) {  function dynosearcho_menusearch($delta, $keywords, $whole_page) {
402    // build one query for each keyword, then run and merge the results    // build one query for each keyword, then run and merge the results
403    $rawmatches = array();    $rawmatches = array();
404    
405    $menu = menu_get_menu();    $menu = menu_get_menu();
406    
407    foreach ($keywords as $keyword) {    foreach ($keywords as $keyword) {
408      $keyword = trim($keyword);      $keyword = trim($keyword);
409      $rawmatches = _dynosearcho_menu_search_preg($keyword, $menu['visible'], $rawmatches);      $rawmatches = _dynosearcho_menu_search_preg($keyword, $menu['visible'], $rawmatches);
# Line 419  function dynosearcho_menusearch($delta, Line 419  function dynosearcho_menusearch($delta,
419      }      }
420      $matches[] = $item;      $matches[] = $item;
421    }    }
422    
423    //----- get the total number of matches for display    //----- get the total number of matches for display
424    $total_matches = count($matches);    $total_matches = count($matches);
425    // only return the desired number of matches - this has to be done here and not with db_query_range because of array_intersect_key stuff    // only return the desired number of matches - this has to be done here and not with db_query_range because of array_intersect_key stuff
# Line 435  function dynosearcho_menusearch($delta, Line 435  function dynosearcho_menusearch($delta,
435      $array_text['title'] = '<span class="dynosearcho_info">'. strtr($temp, $variables) .'</span>';      $array_text['title'] = '<span class="dynosearcho_info">'. strtr($temp, $variables) .'</span>';
436      $matches[] = $array_text;      $matches[] = $array_text;
437    }    }
438    
439    if (!$whole_page) {    if (!$whole_page) {
440      $jsoutput = array();      $jsoutput = array();
441      foreach ($matches as $match) {      foreach ($matches as $match) {
# Line 462  function dynosearcho_nodesearch($delta, Line 462  function dynosearcho_nodesearch($delta,
462    // build one query for each keyword, then run and merge the results    // build one query for each keyword, then run and merge the results
463    $matches = array();    $matches = array();
464    if (user_access('access content')) {    if (user_access('access content')) {
465      $sql = "SELECT DISTINCT n.nid, n.changed, ";      $sql = "SELECT DISTINCT n.nid, n.changed, r.format, ";
466      if (variable_get('dynosearcho_display_relevant_tags_'. $delta, '1')) {      if (variable_get('dynosearcho_display_relevant_tags_'. $delta, '1')) {
467        $sql .= "td.name, ";        $sql .= "td.name, ";
468      }      }
# Line 471  function dynosearcho_nodesearch($delta, Line 471  function dynosearcho_nodesearch($delta,
471        $breakpoints = array('</p>' => 4, '<br />' => 0, '<br>' => 0, "\n" => 0, '. ' => 1, '! ' => 1, '? ' => 1, '。' => 3, '؟ ' => 1);        $breakpoints = array('</p>' => 4, '<br />' => 0, '<br>' => 0, "\n" => 0, '. ' => 1, '! ' => 1, '? ' => 1, '。' => 3, '؟ ' => 1);
472        if (variable_get('dynosearcho_use_og_desc_'. $delta, '0')) {        if (variable_get('dynosearcho_use_og_desc_'. $delta, '0')) {
473          $sql .= "og.description AS teaser, ";          $sql .= "og.description AS teaser, ";
474        }        }
475        else {        else {
476          $sql .= "r.teaser AS teaser, ";          $sql .= "r.teaser AS teaser, ";
477        }        }
# Line 510  function dynosearcho_nodesearch($delta, Line 510  function dynosearcho_nodesearch($delta,
510                }                }
511              }              }
512            }            }
513            $item['teaser'] = $node->teaser;            $item['teaser'] = check_markup($node->teaser, $node->format, FALSE);
514          }          }
515          $tempmatches[$node->nid] = $item;          $tempmatches[$node->nid] = $item;
516        }        }
517        // this effectively provides the logical "and" for multiple keywords        // this effectively provides the logical "and" for multiple keywords
518        if (count($matches)) {        if (count($matches)) {
519          $matches = array_intersect_key($matches, $tempmatches);          $matches = array_intersect_key($matches, $tempmatches);
520        }        }
521        else {        else {
522          $matches = $tempmatches;          $matches = $tempmatches;
523        }        }
524        // this sorts the matches        // this sorts the matches
525        if (variable_get('dynosearcho_sort_by_date_'. $delta, '0')) {        if (variable_get('dynosearcho_sort_by_date_'. $delta, '0')) {
526          uasort($matches, "_dynosearcho_datemod_compare");          uasort($matches, "_dynosearcho_datemod_compare");
527        }        }
528        else {        else {
529          asort($matches);          asort($matches);
530        }        }
531    
532        //----- get the total number of matches for display        //----- get the total number of matches for display
533        $total_matches = count($matches);        $total_matches = count($matches);
534        // only return the desired number of matches - this has to be done here and not with db_query_range because of array_intersect_key stuff        // only return the desired number of matches - this has to be done here and not with db_query_range because of array_intersect_key stuff
# Line 558  function dynosearcho_nodesearch($delta, Line 558  function dynosearcho_nodesearch($delta,
558      }      }
559      print drupal_to_js($jsoutput);      print drupal_to_js($jsoutput);
560      exit();      exit();
561    }    }
562    else {    else {
563      $output = theme('dynosearcho_results', $matches);      $output = theme('dynosearcho_results', $matches);
564      return drupal_get_form('dynosearcho_search_form', $delta, $output);      return drupal_get_form('dynosearcho_search_form', $delta, $output);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2