function handleRSS($results) { $app =& Dataface_Application::getInstance(); $record =& $app->getRecord(); $query =& $app->getQuery(); import('feedcreator.class.php'); import('Dataface/FeedTool.php'); $ft = new Dataface_FeedTool(); $rss = new UniversalFeedCreator(); $rss->encoding = $app->_conf['oe']; //$rss->useCached(); // use cached version if age<1 hour $del =& $record->_table->getDelegate(); if (!$del or !method_exists($del, 'getSingleRecordSearchFeed')) { $del =& $app->getDelegate(); } if ($del and method_exists($del, 'getSingleRecordSearchFeed')) { $feedInfo = $del->getSingleRecordSearchFeed($record, $query); if (!$feedInfo) { $feedInfo = array(); } } if (isset($feedInfo['title'])) { $rss->title = $feedInfo['title']; } else { $rss->title = $record->getTitle() . '[ Search for "' . $query['--subsearch'] . '"]'; } if (isset($feedInfo['description'])) { $rss->description = $feedInfo['description']; } else { $rss->description = ''; } if (isset($feedInfo['link'])) { $rss->link = $feedInfo['link']; } else { $rss->link = htmlentities(df_absolute_url($app->url('') . '&--subsearch=' . urlencode($query['--subsearch']))); } $rss->syndicationURL = $rss->link; $records = array(); foreach ($results as $result) { foreach ($result as $rec) { $records[] = $rec->toRecord(); } } uasort($records, array($this, 'cmp_last_modified')); foreach ($records as $rec) { if ($rec->checkPermission('view') and $rec->checkPermission('view in rss')) { $rss->addItem($ft->createFeedItem($rec)); } } if (!$query['--subsearch']) { $rss->addItem($ft->createFeedItem($record)); } header("Content-Type: application/xml; charset=" . $app->_conf['oe']); echo $rss->createFeed('RSS2.0'); exit; }
/** * @ingroup actions */ function handle(&$params) { import('Dataface/FeedTool.php'); $app =& Dataface_Application::getInstance(); $ft = new Dataface_FeedTool(); $query = $app->getQuery(); if (@$query['-relationship']) { $record =& $app->getRecord(); $perms = $record->getPermissions(array('relationship' => $query['-relationship'])); if (!@$perms['related records feed']) { return Dataface_Error::permissionDenied('You don\'t have permission to view this relationship.'); } } header("Content-Type: application/xml; charset=" . $app->_conf['oe']); $conf = $ft->getConfig(); $query['-skip'] = 0; if (!isset($query['-sort']) and !@$query['-relationship']) { $table =& Dataface_Table::loadTable($query['-table']); $modifiedField = $table->getLastUpdatedField(true); if ($modifiedField) { $query['-sort'] = $modifiedField . ' desc'; } } if (!isset($query['-limit']) and !@$query['-relationship']) { $default_limit = $conf['default_limit']; if (!$default_limit) { $default_limit = 60; } $query['-limit'] = $default_limit; } if (isset($query['--format'])) { $format = $query['--format']; } else { $format = 'RSS1.0'; } echo $ft->getFeedXML($query, $format); exit; }