aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php30
1 files changed, 17 insertions, 13 deletions
diff --git a/inc/functions.php b/inc/functions.php
index f572d983..936ec6ea 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -88,7 +88,7 @@ function get_external_file($url)
88/** 88/**
89 * Préparation de l'URL avec récupération du contenu avant insertion en base 89 * Préparation de l'URL avec récupération du contenu avant insertion en base
90 */ 90 */
91function prepare_url($url, $id) 91function prepare_url($url)
92{ 92{
93 $parametres = array(); 93 $parametres = array();
94 $url = html_entity_decode(trim($url)); 94 $url = html_entity_decode(trim($url));
@@ -107,14 +107,11 @@ function prepare_url($url, $id)
107 if (isset($html) and strlen($html) > 0) 107 if (isset($html) and strlen($html) > 0)
108 { 108 {
109 $r = new Readability($html, $url); 109 $r = new Readability($html, $url);
110 $r->convertLinksToFootnotes = TRUE; 110 $r->convertLinksToFootnotes = CONVERT_LINKS_FOOTNOTES;
111 if($r->init()) 111 if($r->init())
112 { 112 {
113 $content = $r->articleContent->innerHTML; 113 $content = $r->articleContent->innerHTML;
114 $parametres['title'] = $r->articleTitle->innerHTML; 114 $parametres['title'] = $r->articleTitle->innerHTML;
115 if (DOWNLOAD_PICTURES) {
116 $content = filtre_picture($content, $url, $id);
117 }
118 $parametres['content'] = $content; 115 $parametres['content'] = $content;
119 return $parametres; 116 return $parametres;
120 } 117 }
@@ -233,7 +230,7 @@ function remove_directory($directory)
233 * Appel d'une action (mark as fav, archive, delete) 230 * Appel d'une action (mark as fav, archive, delete)
234 */ 231 */
235 232
236function action_to_do($action, $id, $url, $token) 233function action_to_do($action, $url, $token, $id = 0)
237{ 234{
238 global $db; 235 global $db;
239 236
@@ -243,13 +240,9 @@ function action_to_do($action, $id, $url, $token)
243 if ($url == '') 240 if ($url == '')
244 continue; 241 continue;
245 242
246 # FIXME corriger cette génération d'ID 243 if($parametres_url = prepare_url($url)) {
247 $req = $db->getHandle()->query("SELECT id FROM entries ORDER BY id DESC"); 244 $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
248 $id = $req->fetchColumn()+1; 245 $params_action = array($url, $parametres_url['title'], $parametres_url['content']);
249
250 if($parametres_url = prepare_url($url, $id)) {
251 $sql_action = 'INSERT INTO entries ( id, url, title, content ) VALUES (?,?, ?, ?)';
252 $params_action = array($id,$url, $parametres_url['title'], $parametres_url['content']);
253 } 246 }
254 247
255 logm('add link ' . $url); 248 logm('add link ' . $url);
@@ -290,6 +283,17 @@ function action_to_do($action, $id, $url, $token)
290 { 283 {
291 $query = $db->getHandle()->prepare($sql_action); 284 $query = $db->getHandle()->prepare($sql_action);
292 $query->execute($params_action); 285 $query->execute($params_action);
286 # if we add a link, we have to download pictures
287 if ($action == 'add') {
288 $last_id = $db->getHandle()->lastInsertId();
289 if (DOWNLOAD_PICTURES) {
290 $content = filtre_picture($parametres_url['content'], $url, $last_id);
291 $sql_update = "UPDATE entries SET content=? WHERE id=?";
292 $params_update = array($content, $last_id);
293 $query_update = $db->getHandle()->prepare($sql_update);
294 $query_update->execute($params_update);
295 }
296 }
293 } 297 }
294 } 298 }
295 catch (Exception $e) 299 catch (Exception $e)