commit
c2989cc8db
1 changed files with 44 additions and 15 deletions
|
@ -1838,7 +1838,17 @@
|
||||||
|
|
||||||
return($entities);
|
return($entities);
|
||||||
}
|
}
|
||||||
|
function api_format_items_embeded_images($item, $text){
|
||||||
|
$a = get_app();
|
||||||
|
$text = preg_replace_callback(
|
||||||
|
"|data:image/([^;]+)[^=]+=*|m",
|
||||||
|
function($match) use ($a, $item) {
|
||||||
|
return $a->get_baseurl()."/display/".$item['guid'];
|
||||||
|
},
|
||||||
|
$text);
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
function api_format_items($r,$user_info, $filter_user = false) {
|
function api_format_items($r,$user_info, $filter_user = false) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
@ -1896,17 +1906,23 @@
|
||||||
//$statusbody = trim(html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 5, true), 0));
|
//$statusbody = trim(html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 5, true), 0));
|
||||||
$html = bbcode(api_clean_plain_items($item['body']), false, false, 2, true);
|
$html = bbcode(api_clean_plain_items($item['body']), false, false, 2, true);
|
||||||
$statusbody = trim(html2plain($html, 0));
|
$statusbody = trim(html2plain($html, 0));
|
||||||
|
|
||||||
|
// handle data: images
|
||||||
|
$statusbody = api_format_items_embeded_images($item,$statusbody);
|
||||||
|
|
||||||
$statustitle = trim($item['title']);
|
$statustitle = trim($item['title']);
|
||||||
|
|
||||||
if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))
|
if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))
|
||||||
$statustext = trim($statusbody);
|
$statustext = trim($statusbody);
|
||||||
else
|
else
|
||||||
$statustext = trim($statustitle."\n\n".$statusbody);
|
$statustext = trim($statustitle."\n\n".$statusbody);
|
||||||
|
|
||||||
if (($item["network"] == NETWORK_FEED) and (strlen($statustext)> 1000))
|
if (($item["network"] == NETWORK_FEED) and (strlen($statustext)> 1000))
|
||||||
$statustext = substr($statustext, 0, 1000)."... \n".$item["plink"];
|
$statustext = substr($statustext, 0, 1000)."... \n".$item["plink"];
|
||||||
|
|
||||||
|
$statushtml = trim(bbcode($item['body'], false, false));
|
||||||
|
|
||||||
|
|
||||||
$status = array(
|
$status = array(
|
||||||
'text' => $statustext,
|
'text' => $statustext,
|
||||||
'truncated' => False,
|
'truncated' => False,
|
||||||
|
@ -1924,7 +1940,7 @@
|
||||||
//'attachments' => array(),
|
//'attachments' => array(),
|
||||||
'user' => $status_user ,
|
'user' => $status_user ,
|
||||||
//'entities' => NULL,
|
//'entities' => NULL,
|
||||||
'statusnet_html' => trim(bbcode($item['body'], false, false)),
|
'statusnet_html' => $statushtml,
|
||||||
'statusnet_conversation_id' => $item['parent'],
|
'statusnet_conversation_id' => $item['parent'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2246,13 +2262,6 @@
|
||||||
function api_direct_messages_box(&$a, $type, $box) {
|
function api_direct_messages_box(&$a, $type, $box) {
|
||||||
if (api_user()===false) return false;
|
if (api_user()===false) return false;
|
||||||
|
|
||||||
unset($_REQUEST["user_id"]);
|
|
||||||
unset($_GET["user_id"]);
|
|
||||||
|
|
||||||
unset($_REQUEST["screen_name"]);
|
|
||||||
unset($_GET["screen_name"]);
|
|
||||||
|
|
||||||
$user_info = api_get_user($a);
|
|
||||||
|
|
||||||
// params
|
// params
|
||||||
$count = (x($_GET,'count')?$_GET['count']:20);
|
$count = (x($_GET,'count')?$_GET['count']:20);
|
||||||
|
@ -2262,11 +2271,25 @@
|
||||||
$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
|
$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
|
||||||
$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
|
$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
|
||||||
|
|
||||||
$start = $page*$count;
|
$user_id = (x($_REQUEST,'user_id')?$_REQUEST['user_id']:"");
|
||||||
|
$screen_name = (x($_REQUEST,'screen_name')?$_REQUEST['screen_name']:"");
|
||||||
|
|
||||||
|
// caller user info
|
||||||
|
unset($_REQUEST["user_id"]);
|
||||||
|
unset($_GET["user_id"]);
|
||||||
|
|
||||||
|
unset($_REQUEST["screen_name"]);
|
||||||
|
unset($_GET["screen_name"]);
|
||||||
|
|
||||||
|
$user_info = api_get_user($a);
|
||||||
//$profile_url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
|
//$profile_url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
|
||||||
$profile_url = $user_info["url"];
|
$profile_url = $user_info["url"];
|
||||||
|
|
||||||
|
|
||||||
|
// pagination
|
||||||
|
$start = $page*$count;
|
||||||
|
|
||||||
|
// filters
|
||||||
if ($box=="sentbox") {
|
if ($box=="sentbox") {
|
||||||
$sql_extra = "`mail`.`from-url`='".dbesc( $profile_url )."'";
|
$sql_extra = "`mail`.`from-url`='".dbesc( $profile_url )."'";
|
||||||
}
|
}
|
||||||
|
@ -2283,11 +2306,19 @@
|
||||||
if ($max_id > 0)
|
if ($max_id > 0)
|
||||||
$sql_extra .= ' AND `mail`.`id` <= '.intval($max_id);
|
$sql_extra .= ' AND `mail`.`id` <= '.intval($max_id);
|
||||||
|
|
||||||
|
if ($user_id !="") {
|
||||||
|
$sql_extra .= ' AND `mail`.`contact-id` = ' . intval($user_id);
|
||||||
|
}
|
||||||
|
elseif($screen_name !=""){
|
||||||
|
$sql_extra .= " AND `contact`.`nick` = '" . dbesc($screen_name). "'";
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT `mail`.*, `contact`.`nurl` AS `contact-url` FROM `mail`,`contact` WHERE `mail`.`contact-id` = `contact`.`id` AND `mail`.`uid`=%d AND $sql_extra AND `mail`.`id` > %d ORDER BY `mail`.`id` DESC LIMIT %d,%d",
|
$r = q("SELECT `mail`.*, `contact`.`nurl` AS `contact-url` FROM `mail`,`contact` WHERE `mail`.`contact-id` = `contact`.`id` AND `mail`.`uid`=%d AND $sql_extra AND `mail`.`id` > %d ORDER BY `mail`.`id` DESC LIMIT %d,%d",
|
||||||
intval(api_user()),
|
intval(api_user()),
|
||||||
intval($since_id),
|
intval($since_id),
|
||||||
intval($start), intval($count)
|
intval($start), intval($count)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$ret = Array();
|
$ret = Array();
|
||||||
foreach($r as $item) {
|
foreach($r as $item) {
|
||||||
|
@ -2298,6 +2329,7 @@
|
||||||
elseif ($box == "sentbox" || $item['from-url'] == $profile_url){
|
elseif ($box == "sentbox" || $item['from-url'] == $profile_url){
|
||||||
$recipient = api_get_user($a,normalise_link($item['contact-url']));
|
$recipient = api_get_user($a,normalise_link($item['contact-url']));
|
||||||
$sender = $user_info;
|
$sender = $user_info;
|
||||||
|
|
||||||
}
|
}
|
||||||
$ret[]=api_format_messages($item, $recipient, $sender);
|
$ret[]=api_format_messages($item, $recipient, $sender);
|
||||||
}
|
}
|
||||||
|
@ -2396,9 +2428,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function api_share_as_retweet($a, $uid, &$item) {
|
function api_share_as_retweet($a, $uid, &$item) {
|
||||||
$body = trim($item["body"]);
|
$body = trim($item["body"]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue