<?php
-function display_init(&$a) {
+use Friendica\App;
+
+require_once('include/dfrn.php');
+
+function display_init(App $a) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
$nick = (($a->argc > 1) ? $a->argv[1] : '');
$profiledata = array();
+ if ($a->argc == 3) {
+ if (substr($a->argv[2], -5) == '.atom') {
+ $item_id = substr($a->argv[2], 0, -5);
+ $xml = dfrn::itemFeed($item_id);
+ if ($xml == '') {
+ http_status_exit(500);
+ }
+ header("Content-type: application/atom+xml");
+ echo $xml;
+ killme();
+ }
+ }
+
// If there is only one parameter, then check if this parameter could be a guid
if ($a->argc == 2) {
$nick = "";
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `id` = %d", $r[0]["parent"]);
}
- if (($itemuid != local_user()) AND local_user()) {
+ if (($itemuid != local_user()) && local_user()) {
// Do we know this contact but we haven't got this item?
// Copy the wohle thread to our local storage so that we can interact.
// We really should change this need for the future since it scales very bad.
$profiledata = display_fetchauthor($a, $r[0]);
- if (strstr(normalise_link($profiledata["url"]), normalise_link($a->get_baseurl()))) {
- $nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
+ if (strstr(normalise_link($profiledata["url"]), normalise_link(App::get_baseurl()))) {
+ $nickname = str_replace(normalise_link(App::get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
if (($nickname != $a->user["nickname"])) {
$r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
}
profile_load($a, $nick, 0, $profiledata);
-
}
function display_fetchauthor($a, $item) {
// Skip if it isn't a pure repeated messages
// Does it start with a share?
- if (!$skip AND strpos($body, "[share") > 0) {
+ if (!$skip && strpos($body, "[share") > 0) {
$skip = true;
}
// Does it end with a share?
- if (!$skip AND (strlen($body) > (strrpos($body, "[/share]") + 8))) {
+ if (!$skip && (strlen($body) > (strrpos($body, "[/share]") + 8))) {
$skip = true;
}
if (!$skip) {
if (local_user()) {
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
- $profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
+ $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
}
} elseif ($profiledata["network"] == NETWORK_DFRN) {
$connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
return($profiledata);
}
-function display_content(&$a, $update = 0) {
+function display_content(App $a, $update = 0) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice(t('Public access denied.') . EOL);
$o = '';
- $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
-
-
if ($update) {
$nick = $_REQUEST['nick'];
} else {
}
}
- if ($item_id AND !is_numeric($item_id)) {
+ if ($item_id && !is_numeric($item_id)) {
$r = qu("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), intval($a->profile['uid']));
if (dbm::is_result($r)) {
return;
}
+ // We are displaying an "alternate" link if that post was public. See issue 2864
+ $items = q("SELECT `id` FROM `item` WHERE `id` = %d AND NOT `private` AND `wall`", intval($item_id));
+ if (dbm::is_result($items)) {
+ $alternate = App::get_baseurl().'/display/'.$nick.'/'.$item_id.'.atom';
+ } else {
+ $alternate = '';
+ }
+
+ $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'),
+ array('$alternate' => $alternate));
$groups = array();
$title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true));
$author_name = $r[0]["author-name"];
- $image = $a->remove_baseurl($r[0]["thumb"]);
+ $image = $a->remove_baseurl($r[0]["author-thumb"]);
if ($title == "") {
$title = $author_name;
}
+
+ // Limit the description to 160 characters
+ if (strlen($description) > 160) {
+ $description = substr($description, 0, 157) . '...';
+ }
+
$description = htmlspecialchars($description, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
$title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
$author_name = htmlspecialchars($author_name, ENT_COMPAT, 'UTF-8', true); // allow double encoding here