mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-24 16:25:00 -04:00
API streamContents for categories and feeds
https://github.com/marienfressinaud/FreshRSS/issues/13
This commit is contained in:
@@ -44,7 +44,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
|
||||
'name' => $cat->name (),
|
||||
);
|
||||
|
||||
if ($catDAO->searchByName ($newCat) == false) {
|
||||
if ($catDAO->searchByName ($newCat) == null) {
|
||||
$catDAO->addCategory ($values);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
|
||||
if (isset ($cat[0])) {
|
||||
return $cat[0];
|
||||
} else {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function searchByName ($name) {
|
||||
@@ -80,7 +80,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
|
||||
if (isset ($cat[0])) {
|
||||
return $cat[0];
|
||||
} else {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
|
||||
public function checkDefault () {
|
||||
$def_cat = $this->searchById (1);
|
||||
|
||||
if ($def_cat === false) {
|
||||
if ($def_cat == null) {
|
||||
$cat = new FreshRSS_Category (Minz_Translate::t ('default_category'));
|
||||
$cat->_id (1);
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
|
||||
$stm->execute ($values);
|
||||
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
|
||||
$entries = self::daoToEntry ($res);
|
||||
return isset ($entries[0]) ? $entries[0] : false;
|
||||
return isset ($entries[0]) ? $entries[0] : null;
|
||||
}
|
||||
|
||||
public function searchById ($id) {
|
||||
@@ -320,7 +320,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
|
||||
$stm->execute ($values);
|
||||
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
|
||||
$entries = self::daoToEntry ($res);
|
||||
return isset ($entries[0]) ? $entries[0] : false;
|
||||
return isset ($entries[0]) ? $entries[0] : null;
|
||||
}
|
||||
|
||||
public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $keepHistoryDefault = 0) {
|
||||
|
||||
@@ -170,7 +170,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
|
||||
if (isset ($feed[$id])) {
|
||||
return $feed[$id];
|
||||
} else {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function searchByUrl ($url) {
|
||||
@@ -186,7 +186,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
|
||||
if (isset ($feed)) {
|
||||
return $feed;
|
||||
} else {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
|
||||
return self::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC));
|
||||
}
|
||||
|
||||
public function listCategoryNames() {
|
||||
public function arrayCategoryNames() {
|
||||
$sql = 'SELECT f.id, c.name as c_name FROM `' . $this->prefix . 'feed` f '
|
||||
. 'INNER JOIN `' . $this->prefix . 'category` c ON c.id = f.category';
|
||||
$stm = $this->bd->prepare ($sql);
|
||||
|
||||
@@ -58,7 +58,7 @@ function opml_import ($xml) {
|
||||
$title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');
|
||||
$catDAO = new FreshRSS_CategoryDAO ();
|
||||
$cat = $catDAO->searchByName ($title);
|
||||
if ($cat === false) {
|
||||
if ($cat == null) {
|
||||
$cat = new FreshRSS_Category ($title);
|
||||
$values = array (
|
||||
'name' => $cat->name ()
|
||||
|
||||
@@ -266,7 +266,7 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
|
||||
$feedDAO = new FreshRSS_FeedDAO();
|
||||
$feedCategoryNames = $feedDAO->listCategoryNames();
|
||||
$arrayFeedCategoryNames = $feedDAO->arrayCategoryNames();
|
||||
|
||||
switch ($path) {
|
||||
case 'reading-list':
|
||||
@@ -275,8 +275,14 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex
|
||||
case 'starred':
|
||||
$type = 's';
|
||||
break;
|
||||
case 'feed':
|
||||
$type = 'f';
|
||||
break;
|
||||
case 'label':
|
||||
$type = 'c';
|
||||
$categoryDAO = new FreshRSS_CategoryDAO();
|
||||
$cat = $categoryDAO->searchByName($include_target);
|
||||
$include_target = $cat == null ? -1 : $cat->id();
|
||||
break;
|
||||
default:
|
||||
$type = 'A';
|
||||
@@ -298,7 +304,7 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex
|
||||
$items = array();
|
||||
foreach ($entries as $entry) {
|
||||
$f_id = $entry->feed();
|
||||
$c_name = isset($feedCategoryNames[$f_id]) ? $feedCategoryNames[$f_id] : '_';
|
||||
$c_name = isset($arrayFeedCategoryNames[$f_id]) ? $arrayFeedCategoryNames[$f_id] : '_';
|
||||
$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->id(), 0, -3),
|
||||
@@ -352,9 +358,11 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude
|
||||
$type = 'f';
|
||||
$id = basename($streamId);
|
||||
} elseif (strpos($streamId, 'user/-/label/') === 0) {
|
||||
$type = 'C';
|
||||
$type = 'c';
|
||||
$c_name = basename($streamId);
|
||||
notImplemented(); //TODO
|
||||
$categoryDAO = new FreshRSS_CategoryDAO();
|
||||
$cat = $categoryDAO->searchByName($c_name);
|
||||
$id = $cat == null ? -1 : $cat->id();
|
||||
}
|
||||
|
||||
switch ($exclude_target) {
|
||||
@@ -441,7 +449,7 @@ function markAllAsRead($streamId, $olderThanId) {
|
||||
logMe('----------------------------------------------------------------'."\n");
|
||||
logMe(print_r($debugInfo, true));
|
||||
|
||||
$pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : $_SERVER['PATH_INFO'];
|
||||
$pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : urldecode($_SERVER['PATH_INFO']);
|
||||
$pathInfos = explode('/', $pathInfo);
|
||||
|
||||
logMe('pathInfos => ' . print_r($pathInfos, true));
|
||||
@@ -471,7 +479,9 @@ if ($user != null) {
|
||||
|
||||
Minz_Session::_param('currentUser', $user);
|
||||
|
||||
if (count($pathInfos)<3) badRequest();
|
||||
if (count($pathInfos) < 3) {
|
||||
badRequest();
|
||||
}
|
||||
elseif ($pathInfos[1] === 'accounts') {
|
||||
if (($pathInfos[2] === 'ClientLogin') && isset($_REQUEST['Email']) && isset($_REQUEST['Passwd']))
|
||||
clientLogin($_REQUEST['Email'], $_REQUEST['Passwd']);
|
||||
|
||||
Reference in New Issue
Block a user