aboutsummaryrefslogtreecommitdiff
path: root/app/Models/FeedDAO.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-03-29 20:18:57 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-03-29 20:18:57 +0100
commit9ea3819402746d8425d4a608f2d5f3c0f5bc29fb (patch)
treea4836c792d14e5489ebabe6e5d9f46e9b098ce93 /app/Models/FeedDAO.php
parent7676a197a4767f735dabae6ad9cf40ef65e91aa7 (diff)
Better OPML import / export
- use a new OPML library (https://github.com/marienfressinaud/lib_opml) - import has been completely rewritten (far better!) - introduce addFeedObject and addCategoryObject (in DAO for the moment). Permit to add easily feeds and categories (check if they already exist in DB) - introduce html_chars_utf8 (wrap htmlspecialchars for UTF-8)
Diffstat (limited to 'app/Models/FeedDAO.php')
-rw-r--r--app/Models/FeedDAO.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index ca25c3aeb..eac21df7e 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -24,6 +24,35 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
}
}
+ public function addFeedObject($feed) {
+ // TODO: not sure if we should write this method in DAO since DAO
+ // should not be aware about feed class
+
+ // Add feed only if we don't find it in DB
+ if (!$this->searchByUrl($feed->url())) {
+ $values = array(
+ 'id' => $feed->id(),
+ 'url' => $feed->url(),
+ 'category' => $feed->category(),
+ 'name' => $feed->name(),
+ 'website' => $feed->website(),
+ 'description' => $feed->description(),
+ 'lastUpdate' => 0,
+ 'httpAuth' => $feed->httpAuth()
+ );
+
+ $id = $this->addFeed($values);
+ if ($id) {
+ $feed->_id($id);
+ $feed->faviconPrepare();
+ }
+
+ return $id;
+ }
+
+ return false;
+ }
+
public function updateFeed ($id, $valuesTmp) {
$set = '';
foreach ($valuesTmp as $key => $v) {