aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
Diffstat (limited to 'boot.php')
-rw-r--r--boot.php176
1 files changed, 132 insertions, 44 deletions
diff --git a/boot.php b/boot.php
index 389ea93a9..34be06c81 100644
--- a/boot.php
+++ b/boot.php
@@ -2,9 +2,9 @@
set_time_limit(0);
-define ( 'FRIENDIKA_VERSION', '2.1.921' );
-define ( 'DFRN_PROTOCOL_VERSION', '2.1' );
-define ( 'DB_UPDATE_VERSION', 1043 );
+define ( 'FRIENDIKA_VERSION', '2.1.939' );
+define ( 'DFRN_PROTOCOL_VERSION', '2.2' );
+define ( 'DB_UPDATE_VERSION', 1046 );
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");
+
/**
*
@@ -347,10 +352,12 @@ class App {
function init_pagehead() {
$this->page['title'] = $this->config['sitename'];
- $tpl = load_view_file("view/head.tpl");
+ $tpl = load_view_file('view/head.tpl');
$this->page['htmlhead'] = replace_macros($tpl,array(
'$baseurl' => $this->get_baseurl() . '/',
- '$generator' => 'Friendika' . ' ' . FRIENDIKA_VERSION
+ '$generator' => 'Friendika' . ' ' . FRIENDIKA_VERSION,
+ '$delitem' => t('Delete this item?'),
+ '$comment' => t('Comment')
));
}
@@ -601,28 +608,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.
@@ -1085,6 +1070,7 @@ function paginate(&$a) {
$stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string);
$stripped = str_replace('q=','',$stripped);
$stripped = trim($stripped,'/');
+ $pagenum = $a->pager['page'];
$url = $a->get_baseurl() . '/' . $stripped;
@@ -1097,7 +1083,7 @@ function paginate(&$a) {
$numpages = $a->pager['total'] / $a->pager['itemspage'];
- $numstart = 1;
+ $numstart = 1;
$numstop = $numpages;
if($numpages > 14) {
@@ -1620,9 +1606,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 +1837,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 +1852,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 +1865,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 +2022,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())
@@ -2409,9 +2405,7 @@ function get_birthdays() {
if(! local_user())
return $o;
- $bd_format = get_config('system','birthday_format');
- if(! $bd_format)
- $bd_format = 'g A l F d' ; // 8 AM Friday January 18
+ $bd_format = t('g A l F d') ; // 8 AM Friday January 18
$r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid`
@@ -2672,4 +2666,98 @@ function extract_item_authors($arr,$uid) {
}
}
return array();
-}} \ No newline at end of file
+}}
+
+if(! function_exists('item_photo_menu')){
+function item_photo_menu($item){
+ $a = get_app();
+
+ if (!isset($a->authors)){
+ $rr = q("SELECT id, network, url FROM contact WHERE uid=%d AND self!=1", intval(local_user()));
+ $authors = array();
+ foreach($rr as $r) $authors[$r['url']]= $r;
+ $a->authors = $authors;
+ }
+
+ $contact_url="";
+ $pm_url="";
+
+ $status_link="";
+ $photo_link="";
+ $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
+ $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
+
+ $contact_uid = ((x($item,'contact-uid')) && intval($item['contact-uid']) ? intval($item['contact-uid']) : 0);
+
+ // $item['contact-uid'] is only set on profile page.
+ // So we are checking for a profile page where the viewer owns the page,
+ // otherwise a logged in user if some other page that displays items.
+ // Then check if we can use a sparkle (redirect) link to the profile by virtue of it being our contact
+ // or a friend's contact that we both have a connection to.
+
+ if(((local_user() && (! $contact_uid)) || ($contact_uid && $contact_uid == local_user())) && strlen($item['author-link'])) {
+ if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) {
+ $status_link = $redirect_url."?url=status";
+ $profile_link = $redirect_url."?url=profile";
+ $photos_link = $redirect_url."?url=photos";
+ if (local_user() && (! link_compare($_SESSION['my_url'],$item['author-link']))) {
+ $pm_url = $a->get_baseurl() . '/message/new/' . $item['cid'];
+ $contact_url = $item['self']?"":$a->get_baseurl() . '/contacts/' . $item['cid'];
+ }
+ }
+ elseif(isset($a->authors[$item['author-link']])) {
+ $redirect_url = $a->get_baseurl() . '/redir/' . $a->authors[$item['author-link']]['id'];
+ $status_link = $redirect_url."?url=status";
+ $profile_link = $redirect_url."?url=profile";
+ $photos_link = $redirect_url."?url=photos";
+
+ if (local_user() && (! link_compare($_SESSION['my_url'],$a->authors[$item['author-link']]['url']))) {
+ if ($a->authors[$item['author-link']]['network']==='dfrn'){
+ $pm_url = $a->get_baseurl() . '/message/new/' . $a->authors[$item['author-link']]['id'];
+ }
+ $contact_url = $item['self']?"":$a->get_baseurl() . '/contacts/' . $a->authors[$item['author-link']]['id'] ;
+ }
+
+ }
+ }
+
+
+ $menu = Array(
+ t("View status") => $status_link,
+ t("View profile") => $profile_link,
+ t("View photos") => $photos_link,
+ t("Edit contact") => $contact_url,
+ t("Send PM") => $pm_url,
+ );
+
+
+ $args = array($item, &$menu);
+
+ call_hooks('item_photo_menu', $args);
+
+ $o = "";
+ foreach($menu as $k=>$v){
+ if ($v!="") $o .= "<li><a href='$v'>$k</a></li>\n";
+ }
+ return $o;
+}}
+
+if(! function_exists('lang_selector')) {
+function lang_selector() {
+ global $lang;
+ $o .= '<div id="language-selector" style="display: none;" >';
+ $o .= '<form action="" method="post" ><select name="system_language" onchange="this.form.submit();" >';
+ $langs = glob('view/*/strings.php');
+ if(is_array($langs) && count($langs)) {
+ if(! in_array('view/en/strings.php',$langs))
+ $langs[] = 'view/en/';
+ foreach($langs as $l) {
+ $ll = substr($l,5);
+ $ll = substr($ll,0,strrpos($ll,'/'));
+ $selected = (($ll === $lang) ? ' selected="selected" ' : '');
+ $o .= '<option value="' . $ll . '"' . $selected . '>' . $ll . '</option>';
+ }
+ }
+ $o .= '</select></form></div>';
+ return $o;
+}}