share issue on zot6 side

This commit is contained in:
zotlabs 2018-10-17 15:51:23 -07:00
parent 6b1f3eeae6
commit cd2c3f7127
2 changed files with 109 additions and 8 deletions

View file

@ -91,19 +91,16 @@ class Share extends \Zotlabs\Web\Controller {
$arr['aid'] = $owner_aid;
$arr['uid'] = $owner_uid;
$arr['item_thread_top'] = 1;
$arr['item_origin'] = 1;
$arr['item_wall'] = 1;
$arr['item_wall'] = $item['item_wall'];
$arr['mid'] = item_message_id();
$arr['parent_mid'] = $arr['mid'];
$arr['parent_mid'] = $item['mid'];
$arr['title'] = $item['title'];
$arr['summary'] = $item['summary'];
$arr['body'] = $item['body'];
$arr['author_xchan'] = $item['author_xchan'];
$arr['owner_xchan'] = $channel['channel_hash'];
$arr['source_xchan'] = $item['author_xchan'];
$arr['item_uplink'] = 1;
$arr['author_xchan'] = $channel['channel_hash'];
$arr['owner_xchan'] = $item['author_xchan'];
$arr['obj'] = $item['obj'];
$arr['obj_type'] = $item['obj_type'];
$arr['verb'] = 'Announce';

View file

@ -282,6 +282,110 @@ function translate_design_element($type) {
}
function getAttachmentData($body) {
$data = [];
if (!preg_match("/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/ism", $body, $match)) {
return null;
}
$attributes = $match[2];
$data["text"] = trim($match[1]);
$type = "";
preg_match("/type='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
$type = strtolower($matches[1]);
}
preg_match('/type="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
$type = strtolower($matches[1]);
}
if ($type == "") {
return [];
}
if (!in_array($type, ["link", "audio", "photo", "video"])) {
return [];
}
if ($type != "") {
$data["type"] = $type;
}
$url = "";
preg_match("/url='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
$url = $matches[1];
}
preg_match('/url="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
$url = $matches[1];
}
if ($url != "") {
$data["url"] = html_entity_decode($url, ENT_QUOTES, 'UTF-8');
}
$title = "";
preg_match("/title='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
$title = $matches[1];
}
preg_match('/title="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
$title = $matches[1];
}
if ($title != "") {
// $title = self::convert(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, true);
$title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
$title = str_replace(["[", "]"], ["[", "]"], $title);
$data["title"] = $title;
}
$image = "";
preg_match("/image='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
$image = $matches[1];
}
preg_match('/image="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
$image = $matches[1];
}
if ($image != "") {
$data["image"] = html_entity_decode($image, ENT_QUOTES, 'UTF-8');
}
$preview = "";
preg_match("/preview='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
$preview = $matches[1];
}
preg_match('/preview="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
$preview = $matches[1];
}
if ($preview != "") {
$data["preview"] = html_entity_decode($preview, ENT_QUOTES, 'UTF-8');
}
$data["description"] = trim($match[3]);
$data["after"] = trim($match[4]);
return $data;
}
function bb_ShareAttributes($match) {
$matches = array();