""){ $args['error'] = $err; debug($err); } return $return; } function translate_inline($in,$namespace=FALSE){ $out = translate($in,$namespace); rawoutput(tlbutton_clear()); return $out; } function translate_mail($in,$to=0){ global $session; tlschema("mail"); // should be same schema like systemmails! if (!is_array($in)) $in=array($in); //this is done by sprintf_translate. //$in[0] = str_replace("`%","`%%",$in[0]); if ($to>0){ $language = db_fetch_assoc(db_query("SELECT prefs FROM ".db_prefix("accounts")." WHERE acctid=$to")); $language['prefs'] = unserialize($language['prefs']); $session['tlanguage'] = $language['prefs']['language']?$language['prefs']['language']:getsetting("defaultlanguage","en"); } reset($in); // translation offered within translation tool here is in language // of sender! // translation of mails can't be done in language of recipient by // the sender via translation tool. $out = call_user_func_array("sprintf_translate", $in); tlschema(); unset($session['tlanguage']); return $out; } function tl($in){ $out = translate($in); return tlbutton_clear().$out; } function translate_loadnamespace($namespace,$language=false){ if ($language===false) $language = LANGUAGE; $page = translator_page($namespace); $uri = translator_uri($namespace); if ($page==$uri) $where = "uri = '$page'"; else $where = "(uri='$page' OR uri='$uri')"; $sql = " SELECT intext,outtext FROM ".db_prefix("translations")." WHERE language='$language' AND $where"; /* debug(nl2br(htmlentities($sql, ENT_COMPAT, getsetting("charset", "ISO-8859-1")))); */ if (!getsetting("cachetranslations",0)) { $result = db_query($sql); } else { $result = db_query_cached($sql,"translations-".$namespace."-".$language,600); //store it for 10 Minutes, normally you don't need to refresh this often } $out = array(); while ($row = db_fetch_assoc($result)){ $out[$row['intext']] = $row['outtext']; } return $out; } $translatorbuttons = array(); $seentlbuttons = array(); function tlbutton_push($indata,$hot=false,$namespace=FALSE){ global $translatorbuttons; global $translation_is_enabled,$seentlbuttons,$session; if (!$translation_is_enabled) return; if (!$namespace) $namespace="unknown"; if ($session['user']['superuser'] & SU_IS_TRANSLATOR){ if (preg_replace("/[ \n\r]|`./",'',$indata)>""){ if (isset($seentlbuttons[$namespace][$indata])){ $link = ""; }else{ $seentlbuttons[$namespace][$indata] = true; require_once("lib/sanitize.php"); $uri = cmd_sanitize($namespace); $uri = comscroll_sanitize($uri); $link = "translatortool.php?u=". rawurlencode($uri)."&t=".rawurlencode($indata); $link = "T"; } array_push($translatorbuttons,$link); } return true; }else{ //when user is not a translator, return false. return false; } } function tlbutton_pop(){ global $translatorbuttons,$session; if ($session['user']['superuser'] & SU_IS_TRANSLATOR){ return array_pop($translatorbuttons); }else{ return ""; } } function tlbutton_clear(){ global $translatorbuttons,$session; if ($session['user']['superuser'] & SU_IS_TRANSLATOR){ $return = tlbutton_pop().join("",$translatorbuttons); $translatorbuttons = array(); return $return; }else{ return ""; } } $translation_is_enabled = true; function enable_translation($enable=true){ global $translation_is_enabled; $translation_is_enabled = $enable; } $translation_namespace = ""; $translation_namespace_stack = array(); function tlschema($schema=false){ global $translation_namespace,$translation_namespace_stack,$REQUEST_URI; if ($schema===false){ $translation_namespace = array_pop($translation_namespace_stack); if ($translation_namespace=="") $translation_namespace = translator_uri($REQUEST_URI); }else{ array_push($translation_namespace_stack,$translation_namespace); $translation_namespace = $schema; } } function translator_check_collect_texts() { $tlmax = getsetting("tl_maxallowed",0); if (getsetting("permacollect", 0)) { savesetting("collecttexts", 1); } elseif ($tlmax && getsetting("OnlineCount", 0) <= $tlmax) { savesetting("collecttexts", 1); } else { savesetting("collecttexts", 0); } } ?>