- 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()??

svn path=/trunk/boinc/; revision=16035
This commit is contained in:
David Anderson 2008-09-22 17:14:03 +00:00
parent a8d2c599d0
commit e432bb1182
5 changed files with 40 additions and 29 deletions

View File

@ -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

View File

@ -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];
}

View File

@ -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;

View File

@ -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");

View File

@ -63,7 +63,7 @@ row2("Language symbol", "Language name (click to select)");
row2("",
"<a href=language_select.php?set_lang=auto>Use browser language setting</a>"
);
for ($i=0; $i<sizeof($languages);$i++){
for ($i=0; $i<sizeof($languages); $i++){
$lang_native[$i] = trSpecific(LANG_NAME_NATIVE, $languages[$i]);
$lang_international[$i] = trSpecific(LANG_NAME_INTERNATIONAL, $languages[$i]);
}
@ -71,12 +71,6 @@ for ($i=0; $i<sizeof($languages);$i++){
array_multisort($lang_international, $languages, $lang_native);
for ($i=0; $i<sizeof($languages);$i++){
// if (file_exists($imgdir.$languages[$i].".png")){
// $im = "<a href=\"language_select.php?set_lang=".$languages[$i]."\"><img src=\"".$imgdir.$languages[$i].".png\" border=0></a>";
// } else {
// $im="";
// }
// row3($im,
row2(
"<a href=\"language_select.php?set_lang=".$languages[$i]."\">".$languages[$i]."</a>",
"<a href=\"language_select.php?set_lang=".$languages[$i]."\">".$lang_international[$i]."</a>"