reduce duplication - only provide one system language setting

This commit is contained in:
friendica 2012-08-12 20:56:23 -07:00
parent 9899cfb5c7
commit 184cf51d2f
8 changed files with 36 additions and 49 deletions

View File

@ -755,6 +755,15 @@
$ret = api_format_items($r,$user_info); $ret = api_format_items($r,$user_info);
// We aren't going to try to figure out at the item, group, and page
// level which items you've seen and which you haven't. If you're looking
// at the network timeline just mark everything seen.
$r = q("UPDATE `item` SET `unseen` = 0
WHERE `unseen` = 1 AND `uid` = %d",
intval($user_info['uid'])
);
$data = array('$statuses' => $ret); $data = array('$statuses' => $ret);
switch($type){ switch($type){

View File

@ -323,6 +323,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text); $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
// Try to Oembed // Try to Oembed
if ($tryoembed) { if ($tryoembed) {
$Text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", '<video src="$1" controls="controls" width="' . $a->videowidth . '" height="' . $a->videoheight . '"><a href="$1">$1</a></video>', $Text); $Text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", '<video src="$1" controls="controls" width="' . $a->videowidth . '" height="' . $a->videoheight . '"><a href="$1">$1</a></video>', $Text);

View File

@ -100,7 +100,6 @@ function collecturls($message) {
function html2plain($html, $wraplength = 75, $compact = false) function html2plain($html, $wraplength = 75, $compact = false)
{ {
global $lang;
$message = str_replace("\r", "", $html); $message = str_replace("\r", "", $html);

View File

@ -2094,7 +2094,7 @@ function local_delivery($importer,$data) {
} }
} }
if((is_array($contact)) && ($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $importer['avatar-date'])) { if(($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $importer['avatar-date'])) {
logger('local_delivery: Updating photo for ' . $importer['name']); logger('local_delivery: Updating photo for ' . $importer['name']);
require_once("Photo.php"); require_once("Photo.php");
$photo_failure = false; $photo_failure = false;
@ -2152,7 +2152,7 @@ function local_delivery($importer,$data) {
} }
} }
if((is_array($contact)) && ($name_updated) && (strlen($new_name)) && ($name_updated > $contact['name-date'])) { if(($name_updated) && (strlen($new_name)) && ($name_updated > $importer['name-date'])) {
$r = q("select * from contact where uid = %d and id = %d limit 1", $r = q("select * from contact where uid = %d and id = %d limit 1",
intval($importer['importer_uid']), intval($importer['importer_uid']),
intval($importer['id']) intval($importer['id'])
@ -2971,7 +2971,8 @@ function local_delivery($importer,$data) {
$datarray['uid'] = $importer['importer_uid']; $datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id']; $datarray['contact-id'] = $importer['id'];
if(! link_compare($datarray['owner-link'],$contact['url'])) {
if(! link_compare($datarray['owner-link'],$importer['url'])) {
// The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery, // The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery,
// but otherwise there's a possible data mixup on the sender's system. // but otherwise there's a possible data mixup on the sender's system.
// the tgroup delivery code called from item_store will correct it if it's a forum, // the tgroup delivery code called from item_store will correct it if it's a forum,
@ -3246,7 +3247,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
if(strlen($item['owner-name'])) if(strlen($item['owner-name']))
$o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']); $o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']);
if(($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || ($item['thr-parent'])) { if(($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']); $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$o .= '<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['parent']) . '" />' . "\r\n"; $o .= '<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['parent']) . '" />' . "\r\n";
} }

View File

@ -68,11 +68,11 @@ function get_best_language() {
function push_lang($language) { function push_lang($language) {
global $lang, $a; global $a;
$a->langsave = $lang; $a->langsave = $a->language;
if($language === $lang) if($language === $a->language)
return; return;
if(isset($a->strings) && count($a->strings)) { if(isset($a->strings) && count($a->strings)) {
@ -80,14 +80,14 @@ function push_lang($language) {
} }
$a->strings = array(); $a->strings = array();
load_translation_table($language); load_translation_table($language);
$a->language = $lang = $language; $a->language = $language;
} }
function pop_lang() { function pop_lang() {
global $lang, $a; global $a;
if($lang === $a->langsave) if($a->language === $a->langsave)
return; return;
if(isset($a->stringsave)) if(isset($a->stringsave))
@ -95,7 +95,7 @@ function pop_lang() {
else else
$a->strings = array(); $a->strings = array();
$a->language = $lang = $a->langsave; $a->language = $a->langsave;
} }
@ -136,12 +136,11 @@ function t($s) {
if(! function_exists('tt')){ if(! function_exists('tt')){
function tt($singular, $plural, $count){ function tt($singular, $plural, $count){
global $lang;
$a = get_app(); $a = get_app();
if(x($a->strings,$singular)) { if(x($a->strings,$singular)) {
$t = $a->strings[$singular]; $t = $a->strings[$singular];
$f = 'string_plural_select_' . str_replace('-','_',$lang); $f = 'string_plural_select_' . str_replace('-','_',$a->language);
if(! function_exists($f)) if(! function_exists($f))
$f = 'string_plural_select_default'; $f = 'string_plural_select_default';
$k = $f($count); $k = $f($count);

View File

@ -387,38 +387,15 @@ function photo_new_resource() {
}} }}
// wrapper to load a view template, checking for alternate
// languages before falling back to the default
// obsolete, deprecated.
if(! function_exists('load_view_file')) {
function load_view_file($s) {
global $lang, $a;
if(! isset($lang))
$lang = 'en';
$b = basename($s);
$d = dirname($s);
if(file_exists("$d/$lang/$b"))
return file_get_contents("$d/$lang/$b");
$theme = current_theme();
if(file_exists("$d/theme/$theme/$b"))
return file_get_contents("$d/theme/$theme/$b");
return file_get_contents($s);
}}
if(! function_exists('get_intltext_template')) { if(! function_exists('get_intltext_template')) {
function get_intltext_template($s) { function get_intltext_template($s) {
global $lang; global $a;
if(! isset($lang)) if(! isset($a->language))
$lang = 'en'; $a->language = 'en';
if(file_exists("view/$lang/$s")) if(file_exists("view/{$a->language}/$s"))
return file_get_contents("view/$lang/$s"); return file_get_contents("view/{$a->language}/$s");
elseif(file_exists("view/en/$s")) elseif(file_exists("view/en/$s"))
return file_get_contents("view/en/$s"); return file_get_contents("view/en/$s");
else else
@ -1117,7 +1094,7 @@ function unamp($s) {
if(! function_exists('lang_selector')) { if(! function_exists('lang_selector')) {
function lang_selector() { function lang_selector() {
global $lang; global $a;
$langs = glob('view/*/strings.php'); $langs = glob('view/*/strings.php');
@ -1136,7 +1113,7 @@ function lang_selector() {
} }
$ll = substr($l,5); $ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/')); $ll = substr($ll,0,strrpos($ll,'/'));
$selected = (($ll === $lang && (x($_SESSION, 'language'))) ? $ll : $selected); $selected = (($ll === $a->language && (x($_SESSION, 'language'))) ? $ll : $selected);
$lang_options[$ll]=$ll; $lang_options[$ll]=$ll;
} }
} }

View File

@ -27,9 +27,9 @@ $install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false
@include(".htconfig.php"); @include(".htconfig.php");
$a->language = $lang = get_best_language(); $a->language = get_best_language();
load_translation_table($lang); load_translation_table($a->language);
/** /**
* *
@ -81,8 +81,8 @@ if(array_key_exists('system_language',$_POST)) {
unset($_SESSION['language']); unset($_SESSION['language']);
} }
if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) { if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
$lang = $_SESSION['language']; $a->language = $_SESSION['language'];
load_translation_table($lang); load_translation_table($a->language);
} }
if((x($_GET,'zrl')) && (! $install)) { if((x($_GET,'zrl')) && (! $install)) {

View File

@ -1 +1 @@
2012-08-11.43 2012-08-12.44