function alimsearch_view(){ global $facet_block ; $form_block = ''; $facet_block .= "<div class='facet-block' >"; drupal_set_title('Search Result'); $output = ""; $keys = search_get_keys(); $highlight_keys = explode(' ' , $keys ); $high_js = ''; foreach($highlight_keys as $ks){ $ks = strtolower($ks); if($ks != '' && $ks != 'or' && $ks != 'and' && $ks != 'nor' ) $high_js.='$(".search-snippet ,.search-snippet p , .search-snippet div").highlight("'.$ks.'");'; } if (!isset($_POST['form_id']) && $keys != '' ) { drupal_add_js(drupal_get_path('module', 'alimsearch') .'/jquery.highlight-3.js', 'module'); $script = $high_js; $sc = '<script type="text/javascript">'. '$(document).bind("popups_open_path_done", function() { '.$high_js.' });'. '</script>'; drupal_add_js($script, 'inline', 'footer'); $output = "<div >"; $form_block = drupal_get_form('search_form', NULL, $keys, $type); $output .= '<div style="clear:both" >'; // Only perform search if there is non-whitespace search term: $results = '';$outputresult = "";$newtypes = array(); $keys1 = trim($keys); $category = $_REQUEST['cat']; $catarr = explode('-' , $_REQUEST['cat']); $bookarr = array(); if(isset($_REQUEST['book'])){ $bookstr = $_REQUEST['book']; $bookarr = explode('-' , $bookstr ); } $addedkey = ''; $types=array(); if(isset($_REQUEST['cat']) && isset($_REQUEST['book']) ){ if(!isset($_REQUEST['cat'])){ // get book category of selected books .. } foreach($catarr as $scat ){ switch ($scat) { case "quran": $qbooks = alimsearch_getbooknames('quran'); foreach($bookarr as $sbook){ if(array_key_exists($sbook , $qbooks )){ $types = array_merge($types , array($sbook => $qbooks[$sbook] )); if($sbook == 'AY'){ $nn = $keys.' type:quran_ayah_theme'; } else if($sbook == 'QSI'){ $nn = $keys.' type:quran_surah_introduction'; } else if($sbook == 'QCC'){ $nn = $keys.' type:quran_ayah_elaboration'; } else if($sbook == 'QS'){ $nn = $keys.' type:quran_subject'; } else{ $nn = $keys.' '.$sbook .' type:quran_ayah'; } $output.=alimsearch_getsingleresult($nn , $qbooks[$sbook] ); } } break; case "hadith": $qbooks = alimsearch_getbooknames('hadith'); foreach($bookarr as $sbook){ if(array_key_exists($sbook , $qbooks )){ $types = array_merge($types , array($sbook => $qbooks[$sbook] )); $nn = $keys.' '.$sbook .' type:hadith_content,hadith_subject'; $output.=alimsearch_getsingleresult($nn , $qbooks[$sbook] ); } } break; case "fiqh": //$qbooks = alimsearch_getbooknames('biographies'); $nn = $keys.' type:fiqh_sunnah,hadith_subject'; $output.=alimsearch_getsingleresult($nn , 'Fiqh' ); break; case "islam": //$qbooks = alimsearch_getbooknames('article'); $nn = $keys.' type:article_content'; $output.=alimsearch_getsingleresult($nn , 'Islam Articles' ); break; case "biographies": $qbooks = alimsearch_getbooknames('biographies'); foreach($bookarr as $sbook){ if(array_key_exists($sbook , $qbooks )){ $types = array_merge($types , array($sbook => $qbooks[$sbook] )); $nn = $keys.' '.$sbook .' type:article_content'; $output.=alimsearch_getsingleresult($nn , $qbooks[$sbook] ); } } break; /*case "index": $qbooks = alimsearch_getbooknames('index'); foreach($bookarr as $sbook){ if(array_key_exists($sbook , $qbooks )){ $types = array_merge($types , array($sbook => $qbooks[$sbook] )); if($sbook == 'QS' ) $nn = $keys.' type:quran_subject'; else $nn = $keys.' type:hadith_subject'; //print $nn; $output.=alimsearch_getsingleresult($nn , $qbooks[$sbook] ); } } break;*/ default: /*$types = Array ( 'quran_ayah' => 'Qur\'an Ayah Translations' , 'quran_subject' => 'Qur\'an Subjects' , 'quran_ayah_elaboration' => 'Qur\'an Commentary' , 'quran_ayah_theme' => 'Qur\'an Ayat Themes' , 'quran_surah_introduction' => 'Qur\'an Surah Introductions' , 'hadith_content' => 'Ahadith' , 'hadith_subject' => 'Hadith Subjects', 'Fiqh-us-Sunnah' => 'Fiqh', 'Article_Content' => 'Articles/Biographies' ) ;*/ } } } else if( isset($_REQUEST['cat']) && !isset($_REQUEST['book']) ){ foreach($catarr as $scat ){ switch ($scat) { case "quran": //if( $module == 'quran_ayah' ){ $qbooks = alimsearch_getbooknames('quran'); // print_r($qbooks); foreach($qbooks as $sbook => $sname){ if($sbook == 'AY' || $sbook == 'QSI' || $sbook == 'QCC' ){ } else{ $nn = $keys.' '.$sbook .' type:quran_ayah'; $output.=alimsearch_getsingleresult($nn , $sname ); } } //} $s = Array ( // 'quran_ayah' => 'Qur\'an Ayah Translations' , //'quran_subject' => 'Qur\'an Subject Index' , 'quran_ayah_elaboration' => 'Qur\'an Commentary' , 'quran_ayah_theme' => 'Qur\'an Ayah Themes' , 'quran_surah_introduction' => 'Qur\'an Surah Introductions' , 'quran_ayah_elaboration' => 'Qur\'an Commentary' , 'quran_subject' => 'Qur\'an Subject Index' ) ; $newtypes = array_merge($newtypes , $s ); break; case "hadith": $s = Array ( 'hadith_content,hadith_subject' => 'Ahadith' , /*'hadith_subject' => 'Hadith Subjects',*/ ) ; $newtypes = array_merge($newtypes , $s ); break; case "fiqh": $s = Array ( 'fiqh_sunnah,hadith_subject' => 'Fiqh', ) ; $newtypes = array_merge($newtypes , $s ); break; case "islam": $s = Array ( 'article_content' => 'Islam articles' ) ; $newtypes = array_merge($newtypes , $s ); break; case "biographies": $s = Array ( 'article_content' => 'Biographies', ) ; $newtypes = array_merge($newtypes , $s ); break; /*case "index": $s = Array ( 'quran_subject' => 'Qur\'an Subjects' , 'hadith_subject' => 'Hadith Subjects' ) ; $newtypes = array_merge($newtypes , $s ); break;*/ default: } } } else { $newtypes = Array ( 'quran_ayah' => 'Qur\'an Ayah Translations' , 'quran_subject' => 'Qur\'an Subject Index' , 'quran_ayah_elaboration' => 'Qur\'an Commentary' , 'quran_ayah_theme' => 'Qur\'an Ayah Themes' , 'quran_surah_introduction' => 'Qur\'an Surah Introductions' , 'hadith_content,hadith_subject' => 'Ahadith' , /*'hadith_subject' => 'Hadith Subjects',*/ 'fiqh_sunnah,hadith_subject' => 'Fiqh', 'article_content' => 'Articles/Biographies' ) ; } if(count($newtypes) > 0 ){ foreach ($newtypes as $module => $type) { if( $module == 'quran_ayah' ){ $qbooks = alimsearch_getbooknames('quran'); // print_r($qbooks); foreach($qbooks as $sbook => $sname){ if($sbook == 'AY' || $sbook == 'QSI' || $sbook == 'QCC' || $sbook == 'QS' ){ } else{ $nn = $keys.' '.$sbook .' type:quran_ayah'; $output.=alimsearch_getsingleresult($nn , $sname ); } } } else{ $keys = $keys1.' type:'.$module; $output.=alimsearch_getsingleresult($keys , $type ); } $i++; } } $i=1; $output.='</div></div>'; $facet_block .= "</div>"; $out = "<div class='search-results' >"; $out .= '<table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" >'.$facet_block.'</td> <td><div class="result" >'.$form_block.$output.'</div></td> </tr> </table>'; $out .= "</div>"; return $out.$sc; } $output .= drupal_get_form('search_form', NULL, empty($keys) ? '' : $keys, 'node'); return $output; }
/** * Process variables for search-results.tpl.php. * * The $variables array contains the following arguments: * - $results * - $type * * @see search-results.tpl.php * default preprocess search function is altered for adding drupal collapsible fieldset to advanced search */ function alim_preprocess_search_results(&$variables) { $keys = search_get_keys(); $tot_res_cnt = 0; if($variables['type'] == 'alimsearch' ){ // only for advanced search groups the search results in to fieldsets $variables['search_results'] = ''; $crumb = drupal_get_breadcrumb(); $c = count($crumb); unset($crumb[$c-1]); drupal_set_breadcrumb($crumb); drupal_set_title('Search Results'); foreach($variables['results'] as $key => $val ){ $value = "";$ct =''; $value .= $val['pagerval']; if($val['empty']) $value .= $val['empty']; foreach ($val['results'] as $result) { $value .= theme('search_result', $result, $variables['type']); } $tot_res_cnt += $val['tot_res_cnt']; $ct .= '<div><a href="#search-'.$key.'" >'.$val['search_ind'].' </a></div>'; $variables['search_results'] .= theme('fieldset', // collpasible group of results in advanced search array( '#title' => $val['fullname'], '#collapsible' => TRUE, '#collapsed' => FALSE, '#value' => $value, '#attributes' => array('id' => 'search-'.$key) ) ); $variables['counter_left'] .= $ct ; } // Provide alternate search results template. $variables['template_files'][] = 'search-results-'. $variables['type']; // adding template sugessions }else{ // for simple search $variables['search_results'] = ''; $crumb = drupal_get_breadcrumb(); $c = count($crumb); unset($crumb[$c-1]); drupal_set_breadcrumb($crumb); drupal_set_title('Search Results'); // $variables['search_results'] = ''; foreach ($variables['results'] as $result) { $variables['search_results'] .= theme('search_result', $result, $variables['type']); } if(arg(0) == 'alimsearch' ){ $variables['pager'] = theme('pager', NULL, 10, 0); } else{ $variables['pager'] = theme('pager', NULL, 100, 0); } // Provide alternate search results template. $variables['template_files'][] = 'search-results-'. $variables['type']; // adding template sugessions global $pager_total_items; $tot_res_cnt = $pager_total_items[0]; } $script = "var search_key_value = '".$keys." => result count - ".substr($tot_res_cnt,0,30)."'"; drupal_add_js($script, 'inline', 'footer'); }
/** * Passes the positive keys found during the search, useful for adding * additional logging or analysis of Lucene searches. * * NOTE: This hook will be removed in the 3.0 API. * * @param $positive_keys * An array of positive keys matched in the search query. * @param $module * A string containing the Search Lucene API module handling the executed * search. * @param $type * A string containing the type of content indexed by $module. * @return * NULL * @deprecated */ function hook_luceneapi_positive_keys($positive_keys, $module, $type = NULL) { // This example logs the positive keys matched during a search. // Gets the search keys executed by the users. $keys = search_get_keys(); // The array of variables to replace in the watchdog message. $vars = array('%keys' => $keys, '%matches' => join(',', $positive_keys)); // Formats the link to the executed search. $link = sprintf('search/%s/%s', $module, $keys); // Logs the keys and positive matches via watchdog. watchdog($module, 'The following terms were matched by the query %keys: %matches', $vars, WATCHDOG_NOTICE, $link); }