aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-27 14:52:56 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-27 14:52:56 +0100
commitf52ccf7038199f1eb2f82d7e1f26d2a10caa867b (patch)
tree7c8235198b6b587574b41175a167103d31740a9a /app/Models
parent7b4451912e2a9008a49854a2496cf9bb99b7ed10 (diff)
parentb99979cef78f7cd0c1cb4ae81115d09881e85926 (diff)
Merge remote-tracking branch 'origin/dev' into beta
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/CategoryDAO.php2
-rw-r--r--app/Models/Configuration.php16
-rw-r--r--app/Models/Entry.php7
-rw-r--r--app/Models/Feed.php39
-rw-r--r--app/Models/FeedDAO.php6
5 files changed, 38 insertions, 32 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index 6b07ab063..1cc616ac0 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -90,7 +90,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
if ($prePopulateFeeds) {
$sql = 'SELECT c.id AS c_id, c.name AS c_name, '
. ($details ? 'c.color AS c_color, ' : '')
- . ($details ? 'f.* ' : 'f.id, f.name, f.website, f.priority, f.error, f.cache_nbEntries, f.cache_nbUnreads ')
+ . ($details ? 'f.* ' : 'f.id, f.name, f.url, f.website, f.priority, f.error, f.cache_nbEntries, f.cache_nbUnreads ')
. 'FROM `' . $this->prefix . 'category` c '
. 'LEFT OUTER JOIN `' . $this->prefix . 'feed` f ON f.category = c.id '
. 'GROUP BY f.id '
diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php
index 47509636f..cb2f90655 100644
--- a/app/Models/Configuration.php
+++ b/app/Models/Configuration.php
@@ -220,19 +220,13 @@ class FreshRSS_Configuration extends Minz_Model {
public function _sortOrder ($value) {
$this->sort_order = $value === 'ASC' ? 'ASC' : 'DESC';
}
- public function _oldEntries ($value) {
- if (ctype_digit ($value) && $value > 0) {
- $this->old_entries = intval($value);
- } else {
- $this->old_entries = 3;
- }
+ public function _oldEntries($value) {
+ $value = intval($value);
+ $this->old_entries = $value > 0 ? $value : 3;
}
public function _keepHistoryDefault($value) {
- if (ctype_digit($value) && $value >= -1) {
- $this->keep_history_default = intval($value);
- } else {
- $this->keep_history_default = 0;
- }
+ $value = intval($value);
+ $this->keep_history_default = $value >= -1 ? $value : 0;
}
public function _shortcuts ($values) {
foreach ($values as $key => $value) {
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index ed31ef2b1..ab9605eb1 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -106,11 +106,8 @@ class FreshRSS_Entry extends Minz_Model {
$this->link = $value;
}
public function _date ($value) {
- if (ctype_digit ($value)) {
- $this->date = intval ($value);
- } else {
- $this->date = time ();
- }
+ $value = intval($value);
+ $this->date = $value > 1 ? $value : time();
}
public function _isRead ($value) {
$this->is_read = $value;
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index dcf97d4ec..32f8546dd 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -16,6 +16,7 @@ class FreshRSS_Feed extends Minz_Model {
private $httpAuth = '';
private $error = false;
private $keep_history = -2;
+ private $hash = null;
public function __construct ($url, $validate=true) {
if ($validate) {
@@ -28,6 +29,14 @@ class FreshRSS_Feed extends Minz_Model {
public function id () {
return $this->id;
}
+
+ public function hash() {
+ if ($this->hash === null) {
+ $this->hash = hash('crc32b', Minz_Configuration::salt() . $this->url);
+ }
+ return $this->hash;
+ }
+
public function url () {
return $this->url;
}
@@ -96,7 +105,7 @@ class FreshRSS_Feed extends Minz_Model {
return $this->nbNotRead;
}
public function faviconPrepare() {
- $file = DATA_PATH . '/favicons/' . $this->id () . '.txt';
+ $file = DATA_PATH . '/favicons/' . $this->hash() . '.txt';
if (!file_exists ($file)) {
$t = $this->website;
if (empty($t)) {
@@ -105,13 +114,13 @@ class FreshRSS_Feed extends Minz_Model {
file_put_contents($file, $t);
}
}
- public static function faviconDelete($id) {
- $path = DATA_PATH . '/favicons/' . $id;
+ public static function faviconDelete($hash) {
+ $path = DATA_PATH . '/favicons/' . $hash;
@unlink($path . '.ico');
@unlink($path . '.txt');
}
public function favicon () {
- return Minz_Url::display ('/f.php?' . $this->id ());
+ return Minz_Url::display ('/f.php/' . $this->hash());
}
public function _id ($value) {
@@ -127,7 +136,8 @@ class FreshRSS_Feed extends Minz_Model {
$this->url = $value;
}
public function _category ($value) {
- $this->category = $value;
+ $value = intval($value);
+ $this->category = $value >= 0 ? $value : 0;
}
public function _name ($value) {
if (is_null ($value)) {
@@ -154,7 +164,8 @@ class FreshRSS_Feed extends Minz_Model {
$this->lastUpdate = $value;
}
public function _priority ($value) {
- $this->priority = ctype_digit ($value) ? intval ($value) : 10;
+ $value = intval($value);
+ $this->priority = $value >= 0 ? $value : 10;
}
public function _pathEntries ($value) {
$this->pathEntries = $value;
@@ -172,13 +183,13 @@ class FreshRSS_Feed extends Minz_Model {
$this->keep_history = $value;
}
public function _nbNotRead ($value) {
- $this->nbNotRead = ctype_digit ($value) ? intval ($value) : -1;
+ $this->nbNotRead = intval($value);
}
public function _nbEntries ($value) {
- $this->nbEntries = ctype_digit ($value) ? intval ($value) : -1;
+ $this->nbEntries = intval($value);
}
- public function load () {
+ public function load ($loadDetails = false) {
if (!is_null ($this->url)) {
if (CACHE_PATH === false) {
throw new Minz_FileNotExistException (
@@ -250,11 +261,13 @@ class FreshRSS_Feed extends Minz_Model {
$this->_url ($subscribe_url);
}
- $title = htmlspecialchars(html_only_entity_decode($feed->get_title()), ENT_COMPAT, 'UTF-8');
- $this->_name (!is_null ($title) ? $title : $this->url);
+ if ($loadDetails) {
+ $title = htmlspecialchars(html_only_entity_decode($feed->get_title()), ENT_COMPAT, 'UTF-8');
+ $this->_name (!is_null ($title) ? $title : $this->url);
- $this->_website(html_only_entity_decode($feed->get_link()));
- $this->_description(html_only_entity_decode($feed->get_description()));
+ $this->_website(html_only_entity_decode($feed->get_link()));
+ $this->_description(html_only_entity_decode($feed->get_description()));
+ }
// et on charge les articles du flux
$this->loadEntries ($feed);
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index d517f9580..e102da4ec 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -316,11 +316,13 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
$key = $dao['id'];
}
if ($catID === null) {
- $catID = isset($dao['category']) ? $dao['category'] : 0;
+ $category = isset($dao['category']) ? $dao['category'] : 0;
+ } else {
+ $category = $catID ;
}
$myFeed = new FreshRSS_Feed(isset($dao['url']) ? $dao['url'] : '', false);
- $myFeed->_category(intval($catID));
+ $myFeed->_category($category);
$myFeed->_name($dao['name']);
$myFeed->_website(isset($dao['website']) ? $dao['website'] : '', false);
$myFeed->_description(isset($dao['description']) ? $dao['description'] : '');