From 0bc96facfc2c2e021dde81984e6a67dbb836367f Mon Sep 17 00:00:00 2001 From: jwangen Date: Wed, 30 Oct 2002 05:03:47 +0000 Subject: updated search to support localization, added localization vars to english and japanese, updated rss files to find their own $default_path --- search.php | 124 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 60 insertions(+), 64 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index b85e3ca..c755d0c 100644 --- a/search.php +++ b/search.php @@ -44,7 +44,7 @@ $search_started = getmicrotime(); if ($search_valid) { $format_search_arr = format_search($query); if (!$format_search_arr[0]) { - $formatted_search = 'No query given'; + $formatted_search = ''.$no_query_lang.''; } else { $formatted_search = $format_search_arr[0]; } @@ -80,7 +80,7 @@ if ($search_valid) { } } } else { - $formatted_search = 'No query given'; + $formatted_search = ''.$no_query_lang.''; } $search_ended = getmicrotime(); @@ -137,7 +137,7 @@ $search_took = number_format(($search_ended-$search_started),3); - +   @@ -196,12 +196,13 @@ $search_took = number_format(($search_ended-$search_started),3); echo "\n"; echo "\n"; if (isset($val['exceptions'])) { + echo "\n"; foreach($val['exceptions'] as $val2) { $key = $val2['date']; $dayofmonth = strtotime ($key); $dayofmonth = localizeDate ($dateFormat_day, $dayofmonth); - echo "\n"; - echo ""; + echo "\n"; + echo ""; echo "\n"; if ($val2["event_text"]) { @@ -223,24 +224,24 @@ $search_took = number_format(($search_ended-$search_started),3); echo "\n"; } } + echo "
Exception: $dayofmonth
$exception_lang: $dayofmonth
\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; if (isset($val2['recur'])) { $recur = $val2['recur']; echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; } if ($val2["description"]) { echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; } echo "
$time_lang:$event_start$time_lang:$event_start
$summary_lang:$event_text$summary_lang:$event_text
Recurring event:$recur$recurring_event_lang:$recur
$description_lang:$description$description_lang:$description
\n"; @@ -249,6 +250,7 @@ $search_took = number_format(($search_ended-$search_started),3); echo "
\n"; } } } @@ -267,7 +269,7 @@ $search_took = number_format(($search_ended-$search_started),3); Search took '.$search_took.' seconds

'; + echo ''.sprintf($search_took_lang,$search_took).'

'; ?> @@ -416,71 +418,65 @@ function search_boolean($needle_arr, $haystack) { } function format_recur($arr) { - global $monthsofyearshort_lang, $daysofweekshort_lang; - $freq = $arr['FREQ'].(($arr['INTERVAL'] == 1) ? ' ' : 's '); + global $format_recur_lang, $monthsofyear_lang, $daysofweek_lang; + + $d = $format_recur_lang['delimiter']; $int = $arr['INTERVAL']; - if (isset($arr['COUNT'])) $times = $arr['COUNT'].' time'.(($arr['COUNT'] == 1) ? ' ' : 's '); - if (isset($arr['UNTIL'])) $until = 'until '.$arr['UNTIL'].' '; - $by = ''; + $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'])) { - $by .= 'on '; - $count = count($arr['BYMONTH']); - $last = $count - 1; - if ($count == 1) { - $month = $arr['BYMONTH'][0]; - $by .= $monthsofyearshort_lang[($month-1)]; - } else { - foreach ($arr['BYMONTH'] as $key => $month) { - if ($key == $last) $by .= $monthsofyearshort_lang[($month-1)]; - else $by .= $monthsofyearshort_lang[($month-1)].', '; - } + $list = ''; + $last = count($arr['BYMONTH']) - 1; + foreach ($arr['BYMONTH'] as $key => $month) { + if ($key == $last) $list .= $monthsofyear_lang[($month-1)]; + else $list .= $monthsofyear_lang[($month-1)].$d; } - $by .= ' '; + $print .= '
'."\n"; + $print .= str_replace('%list%', $list, $format_recur_lang['bymonth']); } if (isset($arr['BYMONTHDAY'])) { - $by .= 'on '; + $list = ''; + if ($arr['BYMONTHDAY'][(count($arr['BYMONTHDAY']) - 1)] == '0') unset($arr['BYMONTHDAY'][$last]); $last = count($arr['BYMONTHDAY']) - 1; - if ($arr['BYMONTHDAY'][$last] == '0') unset($arr['BYMONTHDAY'][$last]); - $count = count($arr['BYMONTHDAY']); - $last = $count - 1; - if ($count == 1) { - ereg('([\-]{0,1})([0-9]{1,2})',$arr['BYMONTHDAY'][0],$regs); + foreach ($arr['BYMONTHDAY'] as $key => $day) { + ereg('([\-]{0,1})([0-9]{1,2})',$day,$regs); list($junk,$sign,$day) = $regs; - $by .= $day; - } else { - foreach ($arr['BYMONTHDAY'] as $key => $day) { - ereg('([\-]{0,1})([0-9]{1,2})',$day,$regs); - list($junk,$sign,$day) = $regs; - if ($key == $last) $by .= $day; - else $by .= $day.', '; - } + if ($key == $last) $list .= $day; + else $list .= $day.$d; } - $by .= ' '; + $print .= '
'."\n"; + $print .= str_replace('%list%', $list, $format_recur_lang['bymonthday']); } + if (isset($arr['BYDAY'])) { - $by .= 'on '; - $count = count($arr['BYDAY']); - $last = $count-1; - if ($count == 1) { - ereg('([\-]{0,1})([0-9]{0,1})([A-Z]{2})',$arr['BYDAY'][0],$regs); + $list = ''; + $last = count($arr['BYDAY']) - 1; + foreach ($arr['BYDAY'] as $key => $day) { + ereg('([\-]{0,1})([0-9]{0,1})([A-Z]{2})',$day,$regs); list($junk,$sign,$day_num,$day_txt) = $regs; $num = two2threeCharDays($day_txt,false); - if ($day_num != '') $by .= $day_num.' '; - $by .= $daysofweekshort_lang[$num]; - } else { - foreach ($arr['BYDAY'] as $key => $day) { - ereg('([\-]{0,1})([0-9]{0,1})([A-Z]{2})',$day,$regs); - list($junk,$sign,$day_num,$day_txt) = $regs; - $num = two2threeCharDays($day_txt,false); - if ($day_num != '') $by .= $day_num.' '; - if ($key == $last) $by .= $daysofweekshort_lang[$num]; - else $by .= $daysofweekshort_lang[$num].', '; - } + if ($day_num != '') $list .= $day_num.' '; + if ($key == $last) $list .= $daysofweek_lang[$num]; + else $list .= $daysofweek_lang[$num].$d; } - $by .= ' '; + $print .= '
'."\n"; + $print .= str_replace('%list%', $list, $format_recur_lang['byday']); } - return 'Every '.$int.' '.$freq.$times.$until.$by; + + return $print; } function getmicrotime() { -- cgit v1.2.3