hooks to allow changing RSS content
This commit is contained in:
parent
91c914fa3b
commit
ed8d8eb5ee
@ -1056,3 +1056,11 @@ EndNoticeSaveWeb: after saving a notice through the Web interface
|
||||
- $action: action being executed (instance of NewNoticeAction)
|
||||
- $notice: notice that was saved
|
||||
|
||||
StartRssEntryArray: at the start of copying a notice to an array
|
||||
- $notice: the notice being copied
|
||||
- &$entry: the entry (empty at beginning)
|
||||
|
||||
EndRssEntryArray: at the end of copying a notice to an array
|
||||
- $notice: the notice being copied
|
||||
- &$entry: the entry, with all the fields filled up
|
||||
|
||||
|
@ -462,66 +462,71 @@ class ApiAction extends Action
|
||||
|
||||
function twitterRssEntryArray($notice)
|
||||
{
|
||||
$profile = $notice->getProfile();
|
||||
|
||||
$entry = array();
|
||||
|
||||
// We trim() to avoid extraneous whitespace in the output
|
||||
if (Event::handle('StartRssEntryArray', array($notice, &$entry))) {
|
||||
|
||||
$entry['content'] = common_xml_safe_str(trim($notice->rendered));
|
||||
$entry['title'] = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
|
||||
$entry['link'] = common_local_url('shownotice', array('notice' => $notice->id));
|
||||
$entry['published'] = common_date_iso8601($notice->created);
|
||||
$profile = $notice->getProfile();
|
||||
|
||||
$taguribase = TagURI::base();
|
||||
$entry['id'] = "tag:$taguribase:$entry[link]";
|
||||
// We trim() to avoid extraneous whitespace in the output
|
||||
|
||||
$entry['updated'] = $entry['published'];
|
||||
$entry['author'] = $profile->getBestName();
|
||||
$entry['content'] = common_xml_safe_str(trim($notice->rendered));
|
||||
$entry['title'] = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
|
||||
$entry['link'] = common_local_url('shownotice', array('notice' => $notice->id));
|
||||
$entry['published'] = common_date_iso8601($notice->created);
|
||||
|
||||
// Enclosures
|
||||
$attachments = $notice->attachments();
|
||||
$enclosures = array();
|
||||
$taguribase = TagURI::base();
|
||||
$entry['id'] = "tag:$taguribase:$entry[link]";
|
||||
|
||||
foreach ($attachments as $attachment) {
|
||||
$enclosure_o=$attachment->getEnclosure();
|
||||
if ($enclosure_o) {
|
||||
$enclosure = array();
|
||||
$enclosure['url'] = $enclosure_o->url;
|
||||
$enclosure['mimetype'] = $enclosure_o->mimetype;
|
||||
$enclosure['size'] = $enclosure_o->size;
|
||||
$enclosures[] = $enclosure;
|
||||
$entry['updated'] = $entry['published'];
|
||||
$entry['author'] = $profile->getBestName();
|
||||
|
||||
// Enclosures
|
||||
$attachments = $notice->attachments();
|
||||
$enclosures = array();
|
||||
|
||||
foreach ($attachments as $attachment) {
|
||||
$enclosure_o=$attachment->getEnclosure();
|
||||
if ($enclosure_o) {
|
||||
$enclosure = array();
|
||||
$enclosure['url'] = $enclosure_o->url;
|
||||
$enclosure['mimetype'] = $enclosure_o->mimetype;
|
||||
$enclosure['size'] = $enclosure_o->size;
|
||||
$enclosures[] = $enclosure;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($enclosures)) {
|
||||
$entry['enclosures'] = $enclosures;
|
||||
}
|
||||
|
||||
// Tags/Categories
|
||||
$tag = new Notice_tag();
|
||||
$tag->notice_id = $notice->id;
|
||||
if ($tag->find()) {
|
||||
$entry['tags']=array();
|
||||
while ($tag->fetch()) {
|
||||
$entry['tags'][]=$tag->tag;
|
||||
if (!empty($enclosures)) {
|
||||
$entry['enclosures'] = $enclosures;
|
||||
}
|
||||
}
|
||||
$tag->free();
|
||||
|
||||
// RSS Item specific
|
||||
$entry['description'] = $entry['content'];
|
||||
$entry['pubDate'] = common_date_rfc2822($notice->created);
|
||||
$entry['guid'] = $entry['link'];
|
||||
// Tags/Categories
|
||||
$tag = new Notice_tag();
|
||||
$tag->notice_id = $notice->id;
|
||||
if ($tag->find()) {
|
||||
$entry['tags']=array();
|
||||
while ($tag->fetch()) {
|
||||
$entry['tags'][]=$tag->tag;
|
||||
}
|
||||
}
|
||||
$tag->free();
|
||||
|
||||
if (isset($notice->lat) && isset($notice->lon)) {
|
||||
// This is the format that GeoJSON expects stuff to be in.
|
||||
// showGeoRSS() below uses it for XML output, so we reuse it
|
||||
$entry['geo'] = array('type' => 'Point',
|
||||
'coordinates' => array((float) $notice->lat,
|
||||
(float) $notice->lon));
|
||||
} else {
|
||||
$entry['geo'] = null;
|
||||
// RSS Item specific
|
||||
$entry['description'] = $entry['content'];
|
||||
$entry['pubDate'] = common_date_rfc2822($notice->created);
|
||||
$entry['guid'] = $entry['link'];
|
||||
|
||||
if (isset($notice->lat) && isset($notice->lon)) {
|
||||
// This is the format that GeoJSON expects stuff to be in.
|
||||
// showGeoRSS() below uses it for XML output, so we reuse it
|
||||
$entry['geo'] = array('type' => 'Point',
|
||||
'coordinates' => array((float) $notice->lat,
|
||||
(float) $notice->lon));
|
||||
} else {
|
||||
$entry['geo'] = null;
|
||||
}
|
||||
|
||||
Event::handle('EndRssEntryArray', array($notice, &$entry));
|
||||
}
|
||||
|
||||
return $entry;
|
||||
|
Loading…
Reference in New Issue
Block a user