From: <par...@us...> - 2010-02-09 18:06:41
|
Update of /cvsroot/phpicalendar/phpicalendar In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24782 Modified Files: search.php Log Message: Some fixes for the search page Index: search.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/search.php,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** search.php 26 Dec 2008 09:05:15 -0000 1.44 --- search.php 9 Feb 2010 18:06:33 -0000 1.45 *************** *** 12,18 **** $back_page = $_SERVER['HTTP_REFERER']; } else { ! $back_page = BASE.$default_view.'.php?cal='.$cal.'&getdate='.$getdate; } $search_valid = false; if (isset($_GET['query']) && $_GET['query'] != '') { --- 12,19 ---- $back_page = $_SERVER['HTTP_REFERER']; } else { ! $back_page = BASE.$phpiCal_config->default_view.'.php?cal='.$cal.'&getdate='.$getdate; } + $query = ''; $search_valid = false; if (isset($_GET['query']) && $_GET['query'] != '') { *************** *** 22,26 **** $search_box = ''; ! $search_box .= '<form action="search.php" method="get">'."\n". '<input type="hidden" name="cpath" value="'.$cpath.'">'."\n". --- 23,27 ---- $search_box = ''; ! $search_box .= '<form action="search.php" method="get">'."\n". '<input type="hidden" name="cpath" value="'.$cpath.'">'."\n". *************** *** 48,55 **** if (!isset($the_arr[$uid_tmp]) || isset($event_tmp['exception'])) { #print_r($format_search_arr); #echo "<br>this event:".$event_tmp['event_text']."<br>"; ! $results1 = search_boolean($format_search_arr,$event_tmp['event_text']); ! ! if (!$results1) { $results2 = search_boolean($format_search_arr,$event_tmp['description']); } --- 49,61 ---- if (!isset($the_arr[$uid_tmp]) || isset($event_tmp['exception'])) { #print_r($format_search_arr); + #print_r($event_tmp); #echo "<br>this event:".$event_tmp['event_text']."<br>"; ! $results1 = false; ! $results2 = false; ! if (isset($event_tmp['event_text'])) { ! $results1 = search_boolean($format_search_arr,$event_tmp['event_text']); ! } ! ! if (!$results1 && isset($event_tmp['description'])) { $results2 = search_boolean($format_search_arr,$event_tmp['description']); } *************** *** 74,78 **** } } else { ! $formatted_search = '<b>'.$no_query_lang.'</b>'; } $search_ended = getmicrotime(); --- 80,84 ---- } } else { ! $formatted_search = '<b>'.$lang['l_no_query'].'</b>'; } $search_ended = getmicrotime(); *************** *** 90,96 **** $search_str = strtolower($search_str); ! if ($search_str == ' ') return array(false,$and_arr,$or_arr,$not_arr); ! // clean up search string $search_str = trim($search_str); --- 96,102 ---- $search_str = strtolower($search_str); ! if ($search_str == ' ') return array(false,$and_arr,$or_arr,$not_arr); ! // clean up search string $search_str = trim($search_str); *************** *** 99,108 **** $search_str = ereg_replace('[[:space:]]+',' ', $search_str); $search_str = str_replace(' not ', ' -', $search_str); ! // start out with an AND array of all the items $and_arr = explode(' ', $search_str); $count = count($and_arr); $j = 0; ! // build an OR array from the items in AND for($i=0;$i<$count;$i++) { --- 105,114 ---- $search_str = ereg_replace('[[:space:]]+',' ', $search_str); $search_str = str_replace(' not ', ' -', $search_str); ! // start out with an AND array of all the items $and_arr = explode(' ', $search_str); $count = count($and_arr); $j = 0; ! // build an OR array from the items in AND for($i=0;$i<$count;$i++) { *************** *** 132,136 **** } } ! // prepare our formatted search string if (count($and_arr) > 1) { --- 138,142 ---- } } ! // prepare our formatted search string if (count($and_arr) > 1) { *************** *** 139,143 **** $final_str_arr[] = $and_arr[0]; } ! if (count($or_str_arr) > 1) { $final_str_arr[] = implode('</b> AND <b>', $or_str_arr); --- 145,149 ---- $final_str_arr[] = $and_arr[0]; } ! if (count($or_str_arr) > 1) { $final_str_arr[] = implode('</b> AND <b>', $or_str_arr); *************** *** 145,149 **** $final_str_arr[] = $or_str_arr[0]; } ! if (count($not_arr) > 1) { $final_str_arr[] = '-'.implode('</b> AND <b>-', $not_arr); --- 151,155 ---- $final_str_arr[] = $or_str_arr[0]; } ! if (count($not_arr) > 1) { $final_str_arr[] = '-'.implode('</b> AND <b>-', $not_arr); *************** *** 151,155 **** $final_str_arr[] = '-'.$not_arr[0]; } ! if (count($final_str_arr) > 1) { $formatted_search = '<b>'.implode('</b> AND <b>', $final_str_arr).'</b>'; --- 157,161 ---- $final_str_arr[] = '-'.$not_arr[0]; } ! if (count($final_str_arr) > 1) { $formatted_search = '<b>'.implode('</b> AND <b>', $final_str_arr).'</b>'; *************** *** 157,165 **** $formatted_search = '<b>'.$final_str_arr[0].'</b>'; } ! return array($formatted_search, $and_arr, $or_arr, $not_arr); } ! // takes an array made by format_search() and checks to see if it // it matches against a string function search_boolean($needle_arr, $haystack) { --- 163,171 ---- $formatted_search = '<b>'.$final_str_arr[0].'</b>'; } ! return array($formatted_search, $and_arr, $or_arr, $not_arr); } ! // takes an array made by format_search() and checks to see if it // it matches against a string function search_boolean($needle_arr, $haystack) { *************** *** 168,177 **** $or_arr = $needle_arr[2]; $not_arr = $needle_arr[3]; ! if (!$needle_arr[0]) return false; if ((sizeof($and_arr) == 0) && (sizeof($or_arr) == 0) && (sizeof($not_arr) == 0)) return false; ! // compare lowercase versions of the strings $haystack = strtolower($haystack); --- 174,183 ---- $or_arr = $needle_arr[2]; $not_arr = $needle_arr[3]; ! if (!$needle_arr[0]) return false; if ((sizeof($and_arr) == 0) && (sizeof($or_arr) == 0) && (sizeof($not_arr) == 0)) return false; ! // compare lowercase versions of the strings $haystack = strtolower($haystack); *************** *** 183,187 **** } } ! // check against the AND foreach($and_arr as $s) { --- 189,193 ---- } } ! // check against the AND foreach($and_arr as $s) { *************** *** 191,195 **** } } ! // check against the OR foreach($or_arr as $or) { --- 197,201 ---- } } ! // check against the OR foreach($or_arr as $or) { *************** *** 200,204 **** $is_false = false; break; ! } } elseif (is_string(strstr($haystack,$s)) == true) { $is_false = false; --- 206,210 ---- $is_false = false; break; ! } } elseif (is_string(strstr($haystack,$s)) == true) { $is_false = false; *************** *** 206,210 **** } } ! if ($is_false) return false; } // if we haven't returned false, then we return true --- 212,216 ---- } } ! if ($is_false) return false; } // if we haven't returned false, then we return true *************** *** 215,235 **** function format_recur($arr) { global $format_recur_lang, $monthsofyear_lang, $daysofweek_lang; ! $d = $format_recur_lang['delimiter']; ! $int = $arr['INTERVAL']; ! $tmp = (($int == '1') ? 0 : 1); ! ! $freq = $arr['FREQ']; ! $freq = $format_recur_lang[$freq][$tmp]; ! if (isset($arr['COUNT'])) $for = str_replace('%int%',$arr['COUNT'],$format_recur_lang['count']); elseif (isset($arr['UNTIL'])) $for = str_replace('%date%',$arr['UNTIL'], $format_recur_lang['until']); else $for = ''; ! $print = $format_recur_lang['start']; $print = str_replace('%int%', $int, $print); $print = str_replace('%freq%', $freq, $print); $print = str_replace('%for%', $for, $print); ! if (isset($arr['BYMONTH'])) { $list = ''; --- 221,246 ---- function format_recur($arr) { global $format_recur_lang, $monthsofyear_lang, $daysofweek_lang; ! $d = $format_recur_lang['delimiter']; ! ! $int = ''; ! $freq = ''; ! if (isset($arr['INTERVAL']) && isset($arr['FREQ'])) { ! $int = $arr['INTERVAL']; ! $tmp = (($int == '1') ? 0 : 1); ! ! $freq = $arr['FREQ']; ! $freq = $format_recur_lang[$freq][$tmp]; ! } ! if (isset($arr['COUNT'])) $for = str_replace('%int%',$arr['COUNT'],$format_recur_lang['count']); elseif (isset($arr['UNTIL'])) $for = str_replace('%date%',$arr['UNTIL'], $format_recur_lang['until']); else $for = ''; ! $print = $format_recur_lang['start']; $print = str_replace('%int%', $int, $print); $print = str_replace('%freq%', $freq, $print); $print = str_replace('%for%', $for, $print); ! if (isset($arr['BYMONTH'])) { $list = ''; *************** *** 242,246 **** $print .= str_replace('%list%', $list, $format_recur_lang['bymonth']); } ! if (isset($arr['BYMONTHDAY'])) { $list = ''; --- 253,257 ---- $print .= str_replace('%list%', $list, $format_recur_lang['bymonth']); } ! if (isset($arr['BYMONTHDAY'])) { $list = ''; *************** *** 257,261 **** $print .= str_replace('%list%', $list, $format_recur_lang['bymonthday']); } ! if (isset($arr['BYDAY'])) { $list = ''; --- 268,272 ---- $print .= str_replace('%list%', $list, $format_recur_lang['bymonthday']); } ! if (isset($arr['BYDAY'])) { $list = ''; *************** *** 273,277 **** $print .= str_replace('%list%', $list, $format_recur_lang['byday']); } ! return $print; } --- 284,288 ---- $print .= str_replace('%list%', $list, $format_recur_lang['byday']); } ! return $print; } *************** *** 282,286 **** $page->draw_search($page); ! $page->replace_files(array( 'header' => BASE.'templates/'.$phpiCal_config->template.'/header.tpl', --- 293,297 ---- $page->draw_search($page); ! $page->replace_files(array( 'header' => BASE.'templates/'.$phpiCal_config->template.'/header.tpl', *************** *** 316,333 **** 'rss_available' => '', 'rss_valid' => '', - 'show_search' => $show_search, - 'next_month' => $next_month, - 'prev_month' => $prev_month, 'show_goto' => '', 'is_logged_in' => '', - 'list_jumps' => $list_jumps, - 'list_icals' => $list_icals, - 'list_years' => $list_years, - 'list_months' => $list_months, - 'list_weeks' => $list_weeks, - 'legend' => $list_calcolors, 'current_view' => $current_view, ! 'style_select' => $style_select, ! 'sidebar_date' => $sidebar_date, 'l_goprint' => $lang['l_goprint'], 'l_preferences' => $lang['l_preferences'], --- 327,334 ---- 'rss_available' => '', 'rss_valid' => '', 'show_goto' => '', 'is_logged_in' => '', 'current_view' => $current_view, ! 'style_select' => '', 'l_goprint' => $lang['l_goprint'], 'l_preferences' => $lang['l_preferences'], *************** *** 345,349 **** 'l_this_months' => $lang['l_this_months'], 'l_powered_by' => $lang['l_powered_by'], ! 'l_this_site_is' => $lang['l_this_site_is'] )); --- 346,350 ---- 'l_this_months' => $lang['l_this_months'], 'l_powered_by' => $lang['l_powered_by'], ! 'l_this_site_is' => $lang['l_this_site_is'] )); *************** *** 354,356 **** #print_r($the_arr); #echo "</pre>"; ! ?> \ No newline at end of file --- 355,357 ---- #print_r($the_arr); #echo "</pre>"; ! ?> |