+ if(count($tags))
+ foreach($tags as $t)
+ if ($t[0] != "@")
+ xml::add_element($doc, $entry, "category", "", array("term" => $t[2]));
+
+ self::get_attachment($doc, $entry, $item);
+
+ if ($complete) {
+ $app = $item["app"];
+ if ($app == "")
+ $app = "web";
+
+ $attributes = array("local_id" => $item["id"], "source" => $app);
+
+ if (isset($parent["id"]))
+ $attributes["repeat_of"] = $parent["id"];
+
+ if ($item["coord"] != "")
+ xml::add_element($doc, $entry, "georss:point", $item["coord"]);
+
+ xml::add_element($doc, $entry, "statusnet:notice_info", "", $attributes);
+ }
+ }
+
+ /**
+ * @brief Creates the XML feed for a given nickname
+ *
+ * @param app $a The application class
+ * @param string $owner_nick Nickname of the feed owner
+ * @param string $last_update Date of the last update
+ *
+ * @return string XML feed
+ */
+ public static function feed(&$a, $owner_nick, $last_update) {
+
+ $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`
+ FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
+ WHERE `contact`.`self` AND `user`.`nickname` = '%s' LIMIT 1",
+ dbesc($owner_nick));
+ if (!$r)
+ return;
+
+ $owner = $r[0];
+
+ if(!strlen($last_update))
+ $last_update = 'now -30 days';
+
+ $check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
+
+ $items = q("SELECT STRAIGHT_JOIN `item`.*, `item`.`id` AS `item_id` FROM `item`
+ INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
+ LEFT JOIN `item` AS `thritem` ON `thritem`.`uri`=`item`.`thr-parent` AND `thritem`.`uid`=`item`.`uid`
+ WHERE `item`.`uid` = %d AND `item`.`received` > '%s' AND NOT `item`.`private` AND NOT `item`.`deleted`
+ AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
+ AND ((`item`.`wall` AND (`item`.`parent` = `item`.`id`))
+ OR (`item`.`network` = '%s' AND ((`thread`.`network` IN ('%s', '%s')) OR (`thritem`.`network` IN ('%s', '%s')))) AND `thread`.`mention`)
+ AND ((`item`.`owner-link` IN ('%s', '%s') AND (`item`.`parent` = `item`.`id`))
+ OR (`item`.`author-link` IN ('%s', '%s')))
+ ORDER BY `item`.`received` DESC
+ LIMIT 0, 300",
+ intval($owner["uid"]), dbesc($check_date), dbesc(NETWORK_DFRN),
+ //dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS),
+ //dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS),
+ dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN),
+ dbesc($owner["nurl"]), dbesc(str_replace("http://", "https://", $owner["nurl"])),
+ dbesc($owner["nurl"]), dbesc(str_replace("http://", "https://", $owner["nurl"]))
+ );
+
+ $doc = new DOMDocument('1.0', 'utf-8');
+ $doc->formatOutput = true;
+
+ $root = self::add_header($doc, $owner);
+
+ foreach ($items AS $item) {
+ $entry = self::entry($doc, $item, $owner);
+ $root->appendChild($entry);
+ }
+
+ return(trim($doc->saveXML()));
+ }
+
+ /**
+ * @brief Creates the XML for a salmon message
+ *
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ *
+ * @return string XML for the salmon
+ */
+ public static function salmon($item,$owner) {
+
+ $doc = new DOMDocument('1.0', 'utf-8');
+ $doc->formatOutput = true;
+
+ $entry = self::entry($doc, $item, $owner, true);
+
+ $doc->appendChild($entry);
+
+ return(trim($doc->saveXML()));
+ }