]> git.mxchange.org Git - friendica.git/blobdiff - mod/display.php
Merge pull request #3743 from MrPetovan/task/update-languagedetect
[friendica.git] / mod / display.php
index 4adb860f39ed29f1bfb87b7e980e1dc3e5471b1a..37d3a123a88d5ba3f0f172bc238475e217515ac1 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use Friendica\App;
+use Friendica\Core\System;
 
 require_once('include/dfrn.php');
 
@@ -16,13 +17,7 @@ function display_init(App $a) {
        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();
+                       displayShowFeed($item_id);
                }
        }
 
@@ -69,6 +64,12 @@ function display_init(App $a) {
                                        AND `item`.`guid` = ? LIMIT 1", $a->argv[1]);
                }
                if (dbm::is_result($r)) {
+
+                       if (strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
+                               logger('Directly serving XML for id '.$r["id"], LOGGER_DEBUG);
+                               displayShowFeed($r["id"]);
+                       }
+
                        if ($r["id"] != $r["parent"]) {
                                $r = dba::fetch_first("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
                                        WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
@@ -99,8 +100,8 @@ function display_init(App $a) {
 
                        $profiledata = display_fetchauthor($a, $r);
 
-                       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 (strstr(normalise_link($profiledata["url"]), normalise_link(System::baseUrl()))) {
+                               $nickname = str_replace(normalise_link(System::baseUrl())."/profile/", "", normalise_link($profiledata["url"]));
 
                                if (($nickname != $a->user["nickname"])) {
                                        $r = dba::fetch_first("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
@@ -197,11 +198,11 @@ function display_fetchauthor($a, $item) {
 
        $profiledata = get_contact_details_by_url($profiledata["url"], local_user(), $profiledata);
 
-       $profiledata["photo"] = App::remove_baseurl($profiledata["photo"]);
+       $profiledata["photo"] = System::removedBaseUrl($profiledata["photo"]);
 
        if (local_user()) {
                if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
-                       $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
+                       $profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
                }
        } elseif ($profiledata["network"] == NETWORK_DFRN) {
                $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
@@ -292,9 +293,9 @@ function display_content(App $a, $update = 0) {
        }
 
        // We are displaying an "alternate" link if that post was public. See issue 2864
-       $is_public = dba::exists('item', array('id' => $item_id, 'private' => false, 'wall' => true));
+       $is_public = dba::exists('item', array('id' => $item_id, 'private' => false));
        if ($is_public) {
-               $alternate = App::get_baseurl().'/display/'.$nick.'/'.$item_id.'.atom';
+               $alternate = System::baseUrl().'/display/'.$nick.'/'.$item_id.'.atom';
        } else {
                $alternate = '';
        }
@@ -381,11 +382,9 @@ function display_content(App $a, $update = 0) {
                }
        }
 
-       $r = dba::p(item_query()." AND `item`.`uid` = ?
-               AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = ?)
+       $r = dba::p(item_query()."AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = ?)
                $sql_extra
                ORDER BY `parent` DESC, `gravity` ASC, `id` ASC",
-               $a->profile['uid'],
                $item_id
        );
 
@@ -483,12 +482,11 @@ function display_content(App $a, $update = 0) {
 
                return $o;
        }
-
        $r = dba::fetch_first("SELECT `id`,`deleted` FROM `item` WHERE `id` = ? OR `uri` = ? LIMIT 1",
                $item_id,
                $item_id
        );
-       if ($r) {
+       if (dbm::is_result($r)) {
                if ($r['deleted']) {
                        notice(t('Item has been removed.') . EOL);
                } else {
@@ -501,3 +499,12 @@ function display_content(App $a, $update = 0) {
        return $o;
 }
 
+function displayShowFeed($item_id) {
+       $xml = dfrn::itemFeed($item_id);
+       if ($xml == '') {
+               http_status_exit(500);
+       }
+       header("Content-type: application/atom+xml");
+       echo $xml;
+       killme();
+}