aboutsummaryrefslogtreecommitdiff
path: root/p/api/greader.php
diff options
context:
space:
mode:
Diffstat (limited to 'p/api/greader.php')
-rw-r--r--p/api/greader.php86
1 files changed, 11 insertions, 75 deletions
diff --git a/p/api/greader.php b/p/api/greader.php
index 9a96823d7..1ceb68f0d 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -30,13 +30,6 @@ $ORIGINAL_INPUT = file_get_contents('php://input', false, null, 0, 1048576);
if (PHP_INT_SIZE < 8) { //32-bit
/**
- * @param string|int $dec
- * @return string
- */
- function dec2hex($dec) {
- return str_pad(gmp_strval(gmp_init($dec, 10), 16), 16, '0', STR_PAD_LEFT);
- }
- /**
* @param string $hex
* @return string
*/
@@ -46,14 +39,6 @@ if (PHP_INT_SIZE < 8) { //32-bit
}
} else { //64-bit
/**
- * @param string|int $dec
- * @return string
- */
- function dec2hex($dec) {
- //http://code.google.com/p/google-reader-api/wiki/ItemId
- return str_pad(dechex($dec), 16, '0', STR_PAD_LEFT);
- }
- /**
* @param string $hex
* @return string
*/
@@ -526,8 +511,9 @@ function entriesToArray($entries) {
if (empty($entries)) {
return array();
}
- $feedDAO = FreshRSS_Factory::createFeedDao();
- $arrayFeedCategoryNames = $feedDAO->arrayFeedCategoryNames();
+ $catDAO = FreshRSS_Factory::createCategoryDao();
+ $categories = $catDAO->listCategories(true);
+
$tagDAO = FreshRSS_Factory::createTagDao();
$entryIdsTagNames = $tagDAO->getEntryIdsTagNames($entries);
if ($entryIdsTagNames == false) {
@@ -541,65 +527,15 @@ function entriesToArray($entries) {
if ($entry == null) {
continue;
}
- $f_id = $entry->feed();
- if (isset($arrayFeedCategoryNames[$f_id])) {
- $c_name = $arrayFeedCategoryNames[$f_id]['c_name'];
- $f_name = $arrayFeedCategoryNames[$f_id]['name'];
- } else {
- $c_name = '_';
- $f_name = '_';
- }
- $item = array(
- 'id' => 'tag:google.com,2005:reader/item/' . dec2hex($entry->id()), //64-bit hexa http://code.google.com/p/google-reader-api/wiki/ItemId
- 'crawlTimeMsec' => substr($entry->dateAdded(true, true), 0, -3),
- 'timestampUsec' => '' . $entry->dateAdded(true, true), //EasyRSS & Reeder
- 'published' => $entry->date(true),
- 'title' => escapeToUnicodeAlternative($entry->title(), false),
- 'summary' => array('content' => $entry->content()),
- 'canonical' => array(
- array('href' => htmlspecialchars_decode($entry->link(), ENT_QUOTES)),
- ),
- 'alternate' => array(
- array('href' => htmlspecialchars_decode($entry->link(), ENT_QUOTES)),
- ),
- 'categories' => array(
- 'user/-/state/com.google/reading-list',
- 'user/-/label/' . htmlspecialchars_decode($c_name, ENT_QUOTES),
- ),
- 'origin' => array(
- 'streamId' => 'feed/' . $f_id,
- 'title' => escapeToUnicodeAlternative($f_name, true), //EasyRSS
- //'htmlUrl' => $line['f_website'],
- ),
- );
- foreach ($entry->enclosures() as $enclosure) {
- if (!empty($enclosure['url']) && !empty($enclosure['type'])) {
- $media = [
- 'href' => $enclosure['url'],
- 'type' => $enclosure['type'],
- ];
- if (!empty($enclosure['length'])) {
- $media['length'] = intval($enclosure['length']);
- }
- $item['enclosure'][] = $media;
- }
- }
- $author = $entry->authors(true);
- $author = trim($author, '; ');
- if ($author != '') {
- $item['author'] = escapeToUnicodeAlternative($author, false);
- }
- if ($entry->isRead()) {
- $item['categories'][] = 'user/-/state/com.google/read';
- }
- if ($entry->isFavorite()) {
- $item['categories'][] = 'user/-/state/com.google/starred';
- }
- $tagNames = isset($entryIdsTagNames['e_' . $entry->id()]) ? $entryIdsTagNames['e_' . $entry->id()] : array();
- foreach ($tagNames as $tagName) {
- $item['categories'][] = 'user/-/label/' . htmlspecialchars_decode($tagName, ENT_QUOTES);
+
+ $feed = FreshRSS_CategoryDAO::findFeed($categories, $entry->feedId());
+ $entry->_feed($feed);
+
+ if (isset($entryIdsTagNames['e_' . $entry->id()])) {
+ $entry->_tags($entryIdsTagNames['e_' . $entry->id()]);
}
- $items[] = $item;
+
+ $items[] = $entry->toGReader('compat');
}
return $items;
}