X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fapi.php;h=488e858445648baedf6eb8a0f2a7aa99b936451a;hb=6f72bc8d3a9d82f4762ff77fd008d7a9866ba07f;hp=8d74a4612df70bf6ae7120bcc8f6ff5a4f2184b0;hpb=34dc23b87115b34f1322a8f9c59dddc719bff121;p=friendica.git diff --git a/include/api.php b/include/api.php index 8d74a4612d..488e858445 100644 --- a/include/api.php +++ b/include/api.php @@ -24,6 +24,7 @@ require_once('include/group.php'); require_once('include/like.php'); require_once('include/NotificationsManager.php'); + require_once('include/plaintext.php'); define('API_METHOD_ANY','*'); @@ -1334,9 +1335,12 @@ $idlist = implode(",", $idarray); - if ($idlist != "") - $r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist); + if ($idlist != "") { + $unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `id` IN (%s)", $idlist); + if ($unseen) + $r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist); + } $data = array('$statuses' => $ret); switch($type){ @@ -2065,8 +2069,14 @@ $statushtml = trim(bbcode($body, false, false)); - $search = array("
", "
", "
"); - $replace = array("
\n", "\n
", "
\n"); + $search = array("
", "
", "
", + "

", "

", "

", "

", + "

", "

", "

", "

", + "
", "
", "
", "
"); + $replace = array("
\n", "\n
", "
\n", + "\n

", "

\n", "\n

", "

\n", + "\n

", "

\n", "\n

", "

\n", + "\n
", "
\n", "\n
", "
\n"); $statushtml = str_replace($search, $replace, $statushtml); if ($item['title'] != "") @@ -2861,7 +2871,7 @@ $scale_sql = ($scale === false ? "" : sprintf("and scale=%d",intval($scale))); $data_sql = ($scale === false ? "" : "data, "); - $r = q("select %s `resource-id`, `created`, `edited`, `title`, `desc`, `album`, `filename`, + $r = q("select %s `resource-id`, `created`, `edited`, `title`, `desc`, `album`, `filename`, `type`, `height`, `width`, `datasize`, `profile`, min(`scale`) as minscale, max(`scale`) as maxscale from photo where `uid` = %d and `resource-id` = '%s' %s group by `resource-id`", $data_sql, @@ -3115,42 +3125,37 @@ $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'[url=$1]$1[/url]',$Text); } - $Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","api_cleanup_share",$Text); + // Simplify "attachment" element + $Text = api_clean_attachments($Text); + return($Text); } - function api_cleanup_share($shared) { - if ($shared[2] != "type-link") - return($shared[0]); - - if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark)) - return($shared[0]); - - $title = ""; - $link = ""; - - if (isset($bookmark[2][0])) - $title = $bookmark[2][0]; - - if (isset($bookmark[1][0])) - $link = $bookmark[1][0]; + /** + * @brief Removes most sharing information for API text export + * + * @param string $body The original body + * + * @return string Cleaned body + */ + function api_clean_attachments($body) { + $data = get_attachment_data($body); - if (strpos($shared[1],$title) !== false) - $title = ""; + if (!$data) + return $body; - if (strpos($shared[1],$link) !== false) - $link = ""; + $body = ""; - $text = trim($shared[1]); + if (isset($data["text"])) + $body = $data["text"]; - //if (strlen($text) < strlen($title)) - if (($text == "") AND ($title != "")) - $text .= "\n\n".trim($title); + if (($body == "") AND (isset($data["title"]))) + $body = $data["title"]; - if ($link != "") - $text .= "\n".trim($link); + if (isset($data["url"])) + $body .= "\n".$data["url"]; - return(trim($text)); + return $body; } function api_best_nickname(&$contacts) {