mirror of
https://github.com/friendica/friendica
synced 2025-04-27 05:10:10 +00:00
revamp of item structure
This commit is contained in:
parent
3c0c8a2dc1
commit
9b0584e593
8 changed files with 108 additions and 111 deletions
|
@ -95,7 +95,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
|
|||
foreach($items as $item) {
|
||||
if($item['deleted']) {
|
||||
$atom .= replace_macros($tomb_template, array(
|
||||
'$id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")),
|
||||
'$id' => xmlify($item['uri']),
|
||||
'$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
|
||||
));
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
|
|||
'$owner_name' => xmlify($item['owner-name']),
|
||||
'$owner_profile_page' => xmlify($item['owner-link']),
|
||||
'$owner_thumb' => xmlify($item['owner-avatar']),
|
||||
'$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")),
|
||||
'$item_id' => xmlify($item['uri']),
|
||||
'$title' => xmlify($item['name']),
|
||||
'$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
|
||||
'$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
|
||||
|
@ -122,14 +122,12 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
|
|||
'$name' => xmlify($item['name']),
|
||||
'$profile_page' => xmlify($item['url']),
|
||||
'$thumb' => xmlify($item['thumb']),
|
||||
'$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")),
|
||||
'$item_id' => xmlify($item['uri']),
|
||||
'$title' => xmlify($item['title']),
|
||||
'$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
|
||||
'$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
|
||||
'$content' =>xmlify($item['body']),
|
||||
|
||||
// ......this is wrong!!!!
|
||||
'$parent_id' => xmlify("urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$items[0]['hash']}"),
|
||||
'$parent_id' => xmlify($item['parent-uri']),
|
||||
'$comment_allow' => (($item['last-child']) ? 1 : 0)
|
||||
));
|
||||
}
|
||||
|
@ -149,10 +147,10 @@ function get_atom_elements($item) {
|
|||
$res = array();
|
||||
|
||||
$author = $item->get_author();
|
||||
$res['remote-name'] = unxmlify($author->get_name());
|
||||
$res['remote-link'] = unxmlify($author->get_link());
|
||||
$res['remote-avatar'] = unxmlify($author->get_avatar());
|
||||
$res['remote-id'] = unxmlify($item->get_id());
|
||||
$res['author-name'] = unxmlify($author->get_name());
|
||||
$res['author-link'] = unxmlify($author->get_link());
|
||||
$res['author-avatar'] = unxmlify($author->get_avatar());
|
||||
$res['uri'] = unxmlify($item->get_id());
|
||||
$res['title'] = unxmlify($item->get_title());
|
||||
$res['body'] = unxmlify($item->get_content());
|
||||
|
||||
|
@ -187,19 +185,16 @@ function get_atom_elements($item) {
|
|||
|
||||
function post_remote($a,$arr) {
|
||||
|
||||
$arr['hash'] = random_string();
|
||||
|
||||
if(! x($arr,'type'))
|
||||
$arr['type'] = 'remote';
|
||||
$arr['remote-name'] = notags(trim($arr['remote-name']));
|
||||
$arr['remote-link'] = notags(trim($arr['remote-link']));
|
||||
$arr['remote-avatar'] = notags(trim($arr['remote-avatar']));
|
||||
$arr['uri'] = notags(trim($arr['uri']));
|
||||
$arr['author-name'] = notags(trim($arr['author-name']));
|
||||
$arr['author-link'] = notags(trim($arr['author-link']));
|
||||
$arr['author-avatar'] = notags(trim($arr['author-avatar']));
|
||||
$arr['owner-name'] = notags(trim($arr['owner-name']));
|
||||
$arr['owner-link'] = notags(trim($arr['owner-link']));
|
||||
$arr['owner-avatar'] = notags(trim($arr['owner-avatar']));
|
||||
if(! strlen($arr['remote-avatar']))
|
||||
$arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg';
|
||||
if(! strlen($arr['owner-avatar']))
|
||||
$arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg';
|
||||
$arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s');
|
||||
$arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s');
|
||||
$arr['title'] = notags(trim($arr['title']));
|
||||
|
@ -207,18 +202,7 @@ function post_remote($a,$arr) {
|
|||
$arr['last-child'] = intval($arr['last-child']);
|
||||
$arr['visible'] = 1;
|
||||
$arr['deleted'] = 0;
|
||||
|
||||
$local_parent = false;
|
||||
|
||||
if(isset($arr['parent_hash'])) {
|
||||
$local_parent = true;
|
||||
$parent = $arr['parent_hash'];
|
||||
unset($arr['parent_hash']);
|
||||
}
|
||||
else {
|
||||
$parent = $arr['parent_urn'];
|
||||
unset($arr['parent_urn']);
|
||||
}
|
||||
$arr['parent-uri'] = notags(trim($arr['parent-uri']));
|
||||
|
||||
$parent_id = 0;
|
||||
|
||||
|
@ -230,24 +214,19 @@ dbg(3);
|
|||
. implode("', '", array_values($arr))
|
||||
. "')" );
|
||||
|
||||
if($local_parent) {
|
||||
$r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($parent),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
}
|
||||
else {
|
||||
$r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($parent),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
}
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($arr['parent-uri']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
|
||||
if(count($r))
|
||||
$parent_id = $r[0]['id'];
|
||||
|
||||
else {
|
||||
// if parent is missing, what do we do?
|
||||
}
|
||||
|
||||
$r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$arr['remote-id'],
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$arr['uri'],
|
||||
intval($arr['uid'])
|
||||
);
|
||||
if(count($r))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue