diff --git a/checkin_notes b/checkin_notes index a14e2788ec..96a7d7b1f1 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7621,3 +7621,20 @@ Rom 22 Sep 2008 / configure.ac version.h + +David 22 Sept 2008 + - web: sub_sentence() went into an infinite loop + for a particular (non-ASCII) profile text. + Not sure why, but I rewrote sub_sentence() in + less obscure way and it works now + - web: slight cleanup of translation code. + Can we please replace this with gettext()?? + + html/ + inc/ + translation.inc + util.inc + ops/ + update_profile_pages.php + user/ + language_select.php diff --git a/html/inc/translation.inc b/html/inc/translation.inc index e2086895d4..03f693fa43 100644 --- a/html/inc/translation.inc +++ b/html/inc/translation.inc @@ -31,12 +31,10 @@ $lang_log_file = $lang_language_dir."translator.log"; function getSupportedLanguages(){ global $lang_language_dir, $lang_compiled_dir; if (is_dir($lang_language_dir.$lang_compiled_dir)) { - if ($dh = opendir($lang_language_dir.$lang_compiled_dir)) { //If dir exists - while (($file = readdir($dh)) !== false) { - //read contents - if (substr($file,-7)!=".po.inc") continue; + if ($dh = opendir($lang_language_dir.$lang_compiled_dir)) { + while ($file = readdir($dh)) { + if (substr($file, -7) != ".po.inc") continue; if (is_numeric(substr($file, 0, 5))) continue; - $list[] = substr($file,0,-7); } } @@ -50,10 +48,9 @@ function getSupportedLanguages(){ function trSpecific($token, $language=""){ global $lang_language_dir, $lang_compiled_dir; $language= substr($language,0,5); - if ($language!="" && file_exists($lang_language_dir.$lang_compiled_dir.$language.".po.inc")){ - //If we have the language, include it - //echo "[$language]"; - require($lang_language_dir.$lang_compiled_dir.$language.".po.inc"); + $fname = $lang_language_dir.$lang_compiled_dir.$language.".po.inc"; + if ($language!="" && file_exists($fname)){ + require($fname); if (array_key_exists($token, $language_lookup_array)) { return $language_lookup_array[$token]; } diff --git a/html/inc/util.inc b/html/inc/util.inc index f2d679138b..ce553e7e3a 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -433,21 +433,23 @@ function get_legal_filename($name) { function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { $words = explode($delimiter, $sentence); $total_chars = 0; - $count = 0; - $result = ''; + $trunc = false; + $result = null; - do { - if ($count > 0) { - $result = $result . ' ' . $words[$count]; - } else { - $result = $result . $words[$count]; + foreach ($words as $word) { + if (strlen($result) + strlen($word) > $max_chars) { + $trunc = true; + break; } - $total_chars += strlen($words[$count]) + 1; - $count++; - } while ($count < count($words) && ($total_chars + strlen($words[$count])) <= $max_chars); + if ($result) { + $result .= " $word"; + } else { + $result = $word; + } + } - if ($ellipsis && ($count < count($words))) { - $result = $result . '...'; + if ($ellipsis && $trunc) { + $result .= "..."; } return $result; diff --git a/html/ops/update_profile_pages.php b/html/ops/update_profile_pages.php index 74b5e38871..7d140d0eaa 100755 --- a/html/ops/update_profile_pages.php +++ b/html/ops/update_profile_pages.php @@ -23,7 +23,8 @@ require_once("../inc/uotd.inc"); require_once("../inc/db.inc"); require_once("../inc/profile.inc"); -echo date(DATE_RFC822), ": Starting\n"; +// this causes "cannot modify header" errors +//echo date(DATE_RFC822), ": Starting\n"; set_time_limit(0); ini_set("memory_limit", "1024M"); diff --git a/html/user/language_select.php b/html/user/language_select.php index 1ae8870ec8..91a8b4a6d3 100644 --- a/html/user/language_select.php +++ b/html/user/language_select.php @@ -63,7 +63,7 @@ row2("Language symbol", "Language name (click to select)"); row2("", "Use browser language setting" ); -for ($i=0; $i"; -// } else { -// $im=""; -// } -// row3($im, row2( "".$languages[$i]."", "".$lang_international[$i].""