corrections and adding format field

This commit is contained in:
Thomas Citharel 2014-08-26 10:35:17 +02:00
parent 774d7e1d4e
commit 2868115988
5 changed files with 13 additions and 21 deletions

View File

@ -422,10 +422,10 @@ class Database {
* @param integer $user_id
* @return integer $id of inserted record
*/
public function add($url, $title, $content, $dateorigin, $author, $language, $user_id, $isFavorite=0, $isRead=0)
public function add($url, $title, $content, $dateorigin, $author, $language, $format, $user_id, $isFavorite=0, $isRead=0)
{
$sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read, dateorigin, author, language ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)';
$params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead, $dateorigin, $author, $language);
$sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read, dateorigin, author, language, format ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
$params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead, $dateorigin, $author, $language, $format);
if ( !$this->executeQuery($sql_action, $params_action) ) {
$id = null;

View File

@ -148,21 +148,11 @@ class Poche
$title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled');
$body = $content['rss']['channel']['item']['description'];
// TODO : convert date
if ($content['rss']['channel']['item']['updated'] == '') { // ATOM
if ($content['rss']['channel']['item']['pubDate'] == '') { // RSS
if($content['rss']['channel']['item']['dc:date'] == '') { // other
$dateorigin = '';}
else {$dateorigin = $content['rss']['channel']['item']['dc:date'];}
}
else {$dateorigin = $content['rss']['channel']['item']['pubDate'];}
}
else {
$dateorigin = $content['rss']['channel']['item']['updated'];
}
$dateorigin = ($content['rss']['channel']['item']['dc:date'] != '') ? $content['rss']['channel']['item']['dc:date'] : '';
$author = ($content['rss']['channel']['item']['author'] != '') ? $content['rss']['channel']['item']['author'] : _('Unknown author');
// TODO : convert language with Tools::code2ToName() function
$language = ($content['rss']['channel']['item']['language'] != '') ? $content['rss']['channel']['item']['language'] : '';
$author = ($content['rss']['channel']['item']['author'] != '') ? $content['rss']['channel']['item']['author'] : _('Unknown');
$language = ($content['rss']['channel']['item']['dc_language'] != '') ? Tools::code2ToName($content['rss']['channel']['item']['language']) : _('Unknown');
$format = ($content['rss']['channel']['item']['dc_format'] != '') ? $content['rss']['channel']['item']['dc_format'] : '';
// clean content from prevent xss attack
$purifier = $this->_getPurifier();
@ -173,7 +163,7 @@ class Poche
$duplicate = NULL;
$duplicate = $this->store->retrieveOneByURL($url->getUrl(), $this->user->getId());
$last_id = $this->store->add($url->getUrl(), $title, $body, $dateorigin, $author, $language, $this->user->getId());
$last_id = $this->store->add($url->getUrl(), $title, $body, $dateorigin, $author, $language, $format, $this->user->getId());
if ( $last_id ) {
Tools::logm('add link ' . $url->getUrl());
if (DOWNLOAD_PICTURES) {

View File

@ -14,8 +14,9 @@ CREATE TABLE IF NOT EXISTS `entries` (
`content` blob NOT NULL,
`user_id` int(11) NOT NULL,
`dateorigin` DATETIME,
`author` TEXT,
`language` TEXT,
`author` TEXT,
`language` TEXT,
`format` TEXT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Binary file not shown.

View File

@ -14,7 +14,8 @@ CREATE TABLE IF NOT EXISTS entries (
user_id integer NOT NULL,
dateorigin DATETIME,
author TEXT,
language TEXT
language TEXT,
format TEXT
);
CREATE TABLE IF NOT EXISTS users (