]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
Merge branch 'master' of github.com:fabrixxm/friendika
[friendica.git] / boot.php
index bbaa8324d6743af3334cfaefb73c59df1c11273b..0b5787abac4678fd0ff18ca4e2b38032b0e3afc7 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2,9 +2,9 @@
 
 set_time_limit(0);
 
-define ( 'FRIENDIKA_VERSION',      '2.1.915' );
+define ( 'FRIENDIKA_VERSION',      '2.1.925' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.1'  );
-define ( 'DB_UPDATE_VERSION',      1040   );
+define ( 'DB_UPDATE_VERSION',      1044   );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
@@ -159,6 +159,11 @@ if (get_magic_quotes_gpc()) {
     unset($process);
 }
 
+/*
+ * translation system
+ */
+require_once("include/pgettext.php");
+
 
 /**
  *
@@ -601,28 +606,6 @@ function replace_macros($s,$r) {
 }}
 
 
-// load string translation table for alternate language
-
-if(! function_exists('load_translation_table')) {
-function load_translation_table($lang) {
-       global $a;
-
-       if(file_exists("view/$lang/strings.php"))
-               include("view/$lang/strings.php");
-}}
-
-// translate string if translation exists
-
-if(! function_exists('t')) {
-function t($s) {
-
-       $a = get_app();
-
-       if(x($a->strings,$s))
-               return $a->strings[$s];
-       return $s;
-}}
-
 // curl wrapper. If binary flag is true, return binary
 // results. 
 
@@ -1620,9 +1603,15 @@ function lrdd($uri) {
 if(! function_exists('fetch_lrdd_template')) {
 function fetch_lrdd_template($host) {
        $tpl = '';
-       $url = 'http://' . $host . '/.well-known/host-meta' ;
-       $links = fetch_xrd_links($url);
-logger('template: ' . print_r($links,true));
+
+       $url1 = 'https://' . $host . '/.well-known/host-meta' ;
+       $url2 = 'http://' . $host . '/.well-known/host-meta' ;
+       $links = fetch_xrd_links($url1);
+       logger('template (https): ' . print_r($links,true));
+       if(! count($links)) {
+               $links = fetch_xrd_links($url2);
+               logger('template (http): ' . print_r($links,true));
+       }
        if(count($links)) {
                foreach($links as $link)
                        if($link['@attributes']['rel'] && $link['@attributes']['rel'] === 'lrdd')
@@ -1845,10 +1834,14 @@ if(! function_exists('format_like')) {
 function format_like($cnt,$arr,$type,$id) {
        $o = '';
        if($cnt == 1)
-               $o .= $arr[0] . (($type === 'like') ? t(' likes this.') : t(' doesn\'t like this.')) . EOL ;
+               $o .= (($type === 'like') ? sprintf( t('%s likes this.'), $arr[0]) : sprintf( t('%s doesn\'t like this.'), $arr[0])) . EOL ;
        else {
-               $o .= '<span class="fakelink" onclick="openClose(\'' . $type . 'list-' . $id . '\');" >' 
-                       . $cnt . ' ' . t('people') . '</span> ' . (($type === 'like') ? t('like this.') : t('don\'t like this.')) . EOL ;
+               $spanatts = 'class="fakelink" onclick="openClose(\'' . $type . 'list-' . $id . '\');"';
+               $o .= (($type === 'like') ? 
+                                       sprintf( t('<span  %1$s>%2$d people</span> like this.'), $spanatts, $cnt)
+                                        : 
+                                       sprintf( t('<span  %1$s>%2$d people</span> don\'t like this.'), $spanatts, $cnt) ); 
+               $o .= EOL ;
                $total = count($arr);
                if($total >= MAX_LIKERS)
                        $arr = array_slice($arr, 0, MAX_LIKERS - 1);
@@ -1856,8 +1849,8 @@ function format_like($cnt,$arr,$type,$id) {
                        $arr[count($arr)-1] = t('and') . ' ' . $arr[count($arr)-1];
                $str = implode(', ', $arr);
                if($total >= MAX_LIKERS)
-                       $str .= t(', and ') . $total - MAX_LIKERS . t(' other people');
-               $str .= (($type === 'like') ? t(' like this.') : t(' don\'t like this.'));
+                       $str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS );
+               $str = (($type === 'like') ? sprintf( t('%s like this.'), $str) : sprintf( t('%s don\'t like this.'), $str));
                $o .= "\t" . '<div id="' . $type . 'list-' . $id . '" style="display: none;" >' . $str . '</div>';
        }
        return $o;
@@ -1869,11 +1862,11 @@ function format_like($cnt,$arr,$type,$id) {
 
 if(! function_exists('load_view_file')) {
 function load_view_file($s) {
+       global $lang;
+       if(! isset($lang))
+               $lang = 'en';
        $b = basename($s);
        $d = dirname($s);
-       $lang = get_config('system','language');
-       if($lang === false)
-               $lang = 'en';
        if(file_exists("$d/$lang/$b"))
                return file_get_contents("$d/$lang/$b");
        return file_get_contents($s);
@@ -2026,7 +2019,7 @@ function contact_block() {
                        intval($shown)
        );
        if(count($r)) {
-               $o .= '<h4 class="contact-h4">' . $total . ' ' . t('Contacts') . '</h4><div id="contact-block">';
+               $o .= '<h4 class="contact-h4">' .  sprintf(tt('%d Contact','%d Contacts', $total),$total) . '</h4><div id="contact-block">';
                foreach($r as $rr) {
                        $redirect_url = $a->get_baseurl() . '/redir/' . $rr['id'];
                        if(local_user() && ($rr['uid'] == local_user())
@@ -2423,11 +2416,19 @@ function get_birthdays() {
        );
 
        if($r && count($r)) {
-               $o .= '<div id="birthday-wrapper"><div id="birthday-title">' . t('Birthdays this week:') . '</div>'; 
+               $total = 0;
+               foreach($r as $rr)
+                       if(strlen($rr['name']))
+                               $total ++;
+
+               $o .= '<div id="birthday-notice" class="birthday-notice fakelink" onclick=openClose(\'birthday-wrapper\'); >' . t('Birthday Reminders') . ' ' . '(' . $total . ')' . '</div>'; 
+               $o .= '<div id="birthday-wrapper" style="display: none;" ><div id="birthday-title">' . t('Birthdays this week:') . '</div>'; 
                $o .= '<div id="birthday-adjust">' . t("\x28Adjusted for local time\x29") . '</div>';
                $o .= '<div id="birthday-title-end"></div>';
 
                foreach($r as $rr) {
+                       if(! strlen($rr['name']))
+                               continue;
                        $now = strtotime('now');
                        $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false); 
 
@@ -2437,7 +2438,7 @@ function get_birthdays() {
                        . '</div>' ;
                }
 
-               $o .= '</div>';
+               $o .= '</div></div>';
        }
 
   return $o;
@@ -2664,4 +2665,4 @@ function extract_item_authors($arr,$uid) {
                }
        }
        return array();         
-}}
\ No newline at end of file
+}}