aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/MyTool.class.php9
-rw-r--r--inc/class.messages.php231
-rw-r--r--inc/config.php17
-rw-r--r--inc/db.php22
-rw-r--r--inc/functions.php180
-rw-r--r--inc/store/file.class.php51
-rw-r--r--inc/store/sqlite.class.php144
-rw-r--r--inc/store/store.class.php55
8 files changed, 555 insertions, 154 deletions
diff --git a/inc/MyTool.class.php b/inc/MyTool.class.php
index 8206f3f7..1f5051a4 100644
--- a/inc/MyTool.class.php
+++ b/inc/MyTool.class.php
@@ -1,4 +1,13 @@
1<?php 1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <support@inthepoche.com>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
2class MyTool 11class MyTool
3{ 12{
4 public static function initPhp() 13 public static function initPhp()
diff --git a/inc/class.messages.php b/inc/class.messages.php
new file mode 100644
index 00000000..6d515bf6
--- /dev/null
+++ b/inc/class.messages.php
@@ -0,0 +1,231 @@
1<?php
2//--------------------------------------------------------------------------------------------------
3// Session-Based Flash Messages v1.0
4// Copyright 2012 Mike Everhart (http://mikeeverhart.net)
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17//
18//------------------------------------------------------------------------------
19// Description:
20//------------------------------------------------------------------------------
21//
22// Stores messages in Session data to be easily retrieved later on.
23// This class includes four different types of messages:
24// - Success
25// - Error
26// - Warning
27// - Information
28//
29// See README for basic usage instructions, or see samples/index.php for more advanced samples
30//
31//--------------------------------------------------------------------------------------------------
32// Changelog
33//--------------------------------------------------------------------------------------------------
34//
35// 2011-05-15 - v1.0 - Initial Version
36//
37//--------------------------------------------------------------------------------------------------
38
39class Messages {
40
41 //-----------------------------------------------------------------------------------------------
42 // Class Variables
43 //-----------------------------------------------------------------------------------------------
44 var $msgId;
45 var $msgTypes = array( 'help', 'info', 'warning', 'success', 'error' );
46 var $msgClass = 'messages';
47 var $msgWrapper = "<div class='%s %s'><a href='#' class='closeMessage'></a>\n%s</div>\n";
48 var $msgBefore = '<p>';
49 var $msgAfter = "</p>\n";
50
51
52 /**
53 * Constructor
54 * @author Mike Everhart
55 */
56 public function __construct() {
57
58 // Generate a unique ID for this user and session
59 $this->msgId = md5(uniqid());
60
61 // Create the session array if it doesnt already exist
62 if( !array_key_exists('flash_messages', $_SESSION) ) $_SESSION['flash_messages'] = array();
63
64 }
65
66 /**
67 * Add a message to the queue
68 *
69 * @author Mike Everhart
70 *
71 * @param string $type The type of message to add
72 * @param string $message The message
73 * @param string $redirect_to (optional) If set, the user will be redirected to this URL
74 * @return bool
75 *
76 */
77 public function add($type, $message, $redirect_to=null) {
78
79 if( !isset($_SESSION['flash_messages']) ) return false;
80
81 if( !isset($type) || !isset($message[0]) ) return false;
82
83 // Replace any shorthand codes with their full version
84 if( strlen(trim($type)) == 1 ) {
85 $type = str_replace( array('h', 'i', 'w', 'e', 's'), array('help', 'info', 'warning', 'error', 'success'), $type );
86
87 // Backwards compatibility...
88 } elseif( $type == 'information' ) {
89 $type = 'info';
90 }
91
92 // Make sure it's a valid message type
93 if( !in_array($type, $this->msgTypes) ) die('"' . strip_tags($type) . '" is not a valid message type!' );
94
95 // If the session array doesn't exist, create it
96 if( !array_key_exists( $type, $_SESSION['flash_messages'] ) ) $_SESSION['flash_messages'][$type] = array();
97
98 $_SESSION['flash_messages'][$type][] = $message;
99
100 if( !is_null($redirect_to) ) {
101 header("Location: $redirect_to");
102 exit();
103 }
104
105 return true;
106
107 }
108
109 //-----------------------------------------------------------------------------------------------
110 // display()
111 // print queued messages to the screen
112 //-----------------------------------------------------------------------------------------------
113 /**
114 * Display the queued messages
115 *
116 * @author Mike Everhart
117 *
118 * @param string $type Which messages to display
119 * @param bool $print True = print the messages on the screen
120 * @return mixed
121 *
122 */
123 public function display($type='all', $print=true) {
124 $messages = '';
125 $data = '';
126
127 if( !isset($_SESSION['flash_messages']) ) return false;
128
129 if( $type == 'g' || $type == 'growl' ) {
130 $this->displayGrowlMessages();
131 return true;
132 }
133
134 // Print a certain type of message?
135 if( in_array($type, $this->msgTypes) ) {
136 foreach( $_SESSION['flash_messages'][$type] as $msg ) {
137 $messages .= $this->msgBefore . $msg . $this->msgAfter;
138 }
139
140 $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
141
142 // Clear the viewed messages
143 $this->clear($type);
144
145 // Print ALL queued messages
146 } elseif( $type == 'all' ) {
147 foreach( $_SESSION['flash_messages'] as $type => $msgArray ) {
148 $messages = '';
149 foreach( $msgArray as $msg ) {
150 $messages .= $this->msgBefore . $msg . $this->msgAfter;
151 }
152 $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
153 }
154
155 // Clear ALL of the messages
156 $this->clear();
157
158 // Invalid Message Type?
159 } else {
160 return false;
161 }
162
163 // Print everything to the screen or return the data
164 if( $print ) {
165 echo $data;
166 } else {
167 return $data;
168 }
169 }
170
171
172 /**
173 * Check to see if there are any queued error messages
174 *
175 * @author Mike Everhart
176 *
177 * @return bool true = There ARE error messages
178 * false = There are NOT any error messages
179 *
180 */
181 public function hasErrors() {
182 return empty($_SESSION['flash_messages']['error']) ? false : true;
183 }
184
185 /**
186 * Check to see if there are any ($type) messages queued
187 *
188 * @author Mike Everhart
189 *
190 * @param string $type The type of messages to check for
191 * @return bool
192 *
193 */
194 public function hasMessages($type=null) {
195 if( !is_null($type) ) {
196 if( !empty($_SESSION['flash_messages'][$type]) ) return $_SESSION['flash_messages'][$type];
197 } else {
198 foreach( $this->msgTypes as $type ) {
199 if( !empty($_SESSION['flash_messages']) ) return true;
200 }
201 }
202 return false;
203 }
204
205 /**
206 * Clear messages from the session data
207 *
208 * @author Mike Everhart
209 *
210 * @param string $type The type of messages to clear
211 * @return bool
212 *
213 */
214 public function clear($type='all') {
215 if( $type == 'all' ) {
216 unset($_SESSION['flash_messages']);
217 } else {
218 unset($_SESSION['flash_messages'][$type]);
219 }
220 return true;
221 }
222
223 public function __toString() { return $this->hasMessages(); }
224
225 public function __destruct() {
226 //$this->clear();
227 }
228
229
230} // end class
231?> \ No newline at end of file
diff --git a/inc/config.php b/inc/config.php
index c63b07b9..9d4b7fae 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -8,26 +8,32 @@
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
10 10
11define ('POCHE_VERSION', '0.11'); 11define ('POCHE_VERSION', '0.2');
12 12
13if (!is_dir('db/')) { 13if (!is_dir('db/')) {
14 @mkdir('db/',0705); 14 @mkdir('db/',0705);
15} 15}
16 16
17define ('DB_PATH', 'sqlite:./db/poche.sqlite');
18define ('ABS_PATH', 'assets/'); 17define ('ABS_PATH', 'assets/');
19define ('CONVERT_LINKS_FOOTNOTES', TRUE); 18define ('CONVERT_LINKS_FOOTNOTES', TRUE);
20define ('DOWNLOAD_PICTURES', TRUE); 19define ('DOWNLOAD_PICTURES', TRUE);
20$storage_type = 'sqlite'; # sqlite or file
21 21
22include 'db.php';
23include 'functions.php'; 22include 'functions.php';
24require_once 'Readability.php'; 23require_once 'Readability.php';
25require_once 'Encoding.php'; 24require_once 'Encoding.php';
26require_once 'rain.tpl.class.php'; 25require_once 'rain.tpl.class.php';
27require_once 'MyTool.class.php'; 26require_once 'MyTool.class.php';
28require_once 'Session.class.php'; 27require_once 'Session.class.php';
28require_once 'store/store.class.php';
29require_once 'store/sqlite.class.php';
30require_once 'store/file.class.php';
31require_once 'class.messages.php';
29 32
30$db = new db(DB_PATH); 33Session::init();
34
35$store = new $storage_type();
36$msg = new Messages();
31 37
32# initialisation de RainTPL 38# initialisation de RainTPL
33raintpl::$tpl_dir = './tpl/'; 39raintpl::$tpl_dir = './tpl/';
@@ -35,4 +41,5 @@ raintpl::$cache_dir = './cache/';
35raintpl::$base_url = get_poche_url(); 41raintpl::$base_url = get_poche_url();
36raintpl::configure('path_replace', false); 42raintpl::configure('path_replace', false);
37raintpl::configure('debug', false); 43raintpl::configure('debug', false);
38$tpl = new raintpl(); \ No newline at end of file 44$tpl = new raintpl();
45$tpl->assign('msg', $msg); \ No newline at end of file
diff --git a/inc/db.php b/inc/db.php
deleted file mode 100644
index 60d7c108..00000000
--- a/inc/db.php
+++ /dev/null
@@ -1,22 +0,0 @@
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <nicolas@loeuillet.org>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11class db {
12 var $handle;
13 function __construct($path) {
14 $this->handle = new PDO($path);
15 $this->handle->exec('CREATE TABLE IF NOT EXISTS "entries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "title" VARCHAR, "url" VARCHAR UNIQUE , "is_read" INTEGER DEFAULT 0, "is_fav" INTEGER DEFAULT 0, "content" BLOB)');
16 $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
17 }
18
19 public function getHandle() {
20 return $this->handle;
21 }
22} \ No newline at end of file
diff --git a/inc/functions.php b/inc/functions.php
index ef1fc0e2..205f3968 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -1,4 +1,12 @@
1<?php 1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <support@inthepoche.com>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
2 10
3/** 11/**
4 * Permet de générer l'URL de poche pour le bookmarklet 12 * Permet de générer l'URL de poche pour le bookmarklet
@@ -117,6 +125,7 @@ function prepare_url($url)
117 } 125 }
118 } 126 }
119 127
128 $msg->add('e', 'error during url preparation');
120 logm('error during url preparation'); 129 logm('error during url preparation');
121 return FALSE; 130 return FALSE;
122} 131}
@@ -228,20 +237,35 @@ function remove_directory($directory)
228 237
229function display_view($view, $id = 0, $full_head = 'yes') 238function display_view($view, $id = 0, $full_head = 'yes')
230{ 239{
231 global $tpl; 240 global $tpl, $store, $msg;
232 241
233 switch ($view) 242 switch ($view)
234 { 243 {
244 case 'export':
245 $entries = $store->retrieveAll();
246 $tpl->assign('export', myTool::renderJson($entries));
247 $tpl->draw('export');
248 logm('export view');
249 break;
250 case 'config':
251 $tpl->assign('load_all_js', 0);
252 $tpl->draw('head');
253 $tpl->draw('home');
254 $tpl->draw('config');
255 $tpl->draw('js');
256 $tpl->draw('footer');
257 logm('config view');
258 break;
235 case 'view': 259 case 'view':
236 $entry = get_article($id); 260 $entry = $store->retrieveOneById($id);
237 261
238 if ($entry != NULL) { 262 if ($entry != NULL) {
239 $tpl->assign('id', $entry[0]['id']); 263 $tpl->assign('id', $entry['id']);
240 $tpl->assign('url', $entry[0]['url']); 264 $tpl->assign('url', $entry['url']);
241 $tpl->assign('title', $entry[0]['title']); 265 $tpl->assign('title', $entry['title']);
242 $tpl->assign('content', $entry[0]['content']); 266 $tpl->assign('content', $entry['content']);
243 $tpl->assign('is_fav', $entry[0]['is_fav']); 267 $tpl->assign('is_fav', $entry['is_fav']);
244 $tpl->assign('is_read', $entry[0]['is_read']); 268 $tpl->assign('is_read', $entry['is_read']);
245 $tpl->assign('load_all_js', 0); 269 $tpl->assign('load_all_js', 0);
246 $tpl->draw('view'); 270 $tpl->draw('view');
247 } 271 }
@@ -252,7 +276,7 @@ function display_view($view, $id = 0, $full_head = 'yes')
252 logm('view link #' . $id); 276 logm('view link #' . $id);
253 break; 277 break;
254 default: # home view 278 default: # home view
255 $entries = get_entries($view); 279 $entries = $store->getEntriesByView($view);
256 280
257 $tpl->assign('entries', $entries); 281 $tpl->assign('entries', $entries);
258 282
@@ -277,7 +301,7 @@ function display_view($view, $id = 0, $full_head = 'yes')
277 */ 301 */
278function action_to_do($action, $url, $id = 0) 302function action_to_do($action, $url, $id = 0)
279{ 303{
280 global $db; 304 global $store, $msg;
281 305
282 switch ($action) 306 switch ($action)
283 { 307 {
@@ -285,140 +309,42 @@ function action_to_do($action, $url, $id = 0)
285 if ($url == '') 309 if ($url == '')
286 continue; 310 continue;
287 311
288 if($parametres_url = prepare_url($url)) { 312 if (MyTool::isUrl($url)) {
289 $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'; 313 if($parametres_url = prepare_url($url)) {
290 $params_action = array($url, $parametres_url['title'], $parametres_url['content']); 314 $store->add($url, $parametres_url['title'], $parametres_url['content']);
315 $last_id = $store->getLastId();
316 if (DOWNLOAD_PICTURES) {
317 $content = filtre_picture($parametres_url['content'], $url, $last_id);
318 }
319 $msg->add('s', 'the link has been added successfully');
320 }
321 }
322 else {
323 $msg->add('e', 'the link has been added successfully');
324 logm($url . ' is not a valid url');
291 } 325 }
292 326
293 logm('add link ' . $url); 327 logm('add link ' . $url);
294 break; 328 break;
295 case 'delete': 329 case 'delete':
296 remove_directory(ABS_PATH . $id); 330 remove_directory(ABS_PATH . $id);
297 $sql_action = "DELETE FROM entries WHERE id=?"; 331 $store->deleteById($id);
298 $params_action = array($id); 332 $msg->add('s', 'the link has been deleted successfully');
299 logm('delete link #' . $id); 333 logm('delete link #' . $id);
300 break; 334 break;
301 case 'toggle_fav' : 335 case 'toggle_fav' :
302 $sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?"; 336 $store->favoriteById($id);
303 $params_action = array($id); 337 $msg->add('s', 'the favorite toggle has been done successfully');
304 logm('mark as favorite link #' . $id); 338 logm('mark as favorite link #' . $id);
305 break; 339 break;
306 case 'toggle_archive' : 340 case 'toggle_archive' :
307 $sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?"; 341 $store->archiveById($id);
308 $params_action = array($id); 342 $msg->add('s', 'the archive toggle has been done successfully');
309 logm('archive link #' . $id); 343 logm('archive link #' . $id);
310 break; 344 break;
311 default: 345 default:
312 break; 346 break;
313 } 347 }
314
315 try
316 {
317 # action query
318 if (isset($sql_action))
319 {
320 $query = $db->getHandle()->prepare($sql_action);
321 $query->execute($params_action);
322 # if we add a link, we have to download pictures
323 if ($action == 'add') {
324 $last_id = $db->getHandle()->lastInsertId();
325 if (DOWNLOAD_PICTURES) {
326 $content = filtre_picture($parametres_url['content'], $url, $last_id);
327 $sql_update = "UPDATE entries SET content=? WHERE id=?";
328 $params_update = array($content, $last_id);
329 $query_update = $db->getHandle()->prepare($sql_update);
330 $query_update->execute($params_update);
331 }
332 }
333 }
334 }
335 catch (Exception $e)
336 {
337 logm('action query error : '.$e->getMessage());
338 }
339}
340
341/**
342 * Détermine quels liens afficher : home, fav ou archives
343 */
344function get_entries($view)
345{
346 global $db;
347
348 switch ($_SESSION['sort'])
349 {
350 case 'ia':
351 $order = 'ORDER BY id';
352 break;
353 case 'id':
354 $order = 'ORDER BY id DESC';
355 break;
356 case 'ta':
357 $order = 'ORDER BY lower(title)';
358 break;
359 case 'td':
360 $order = 'ORDER BY lower(title) DESC';
361 break;
362 default:
363 $order = 'ORDER BY id';
364 break;
365 }
366
367 switch ($view)
368 {
369 case 'archive':
370 $sql = "SELECT * FROM entries WHERE is_read=? " . $order;
371 $params = array(-1);
372 break;
373 case 'fav' :
374 $sql = "SELECT * FROM entries WHERE is_fav=? " . $order;
375 $params = array(-1);
376 break;
377 default:
378 $sql = "SELECT * FROM entries WHERE is_read=? " . $order;
379 $params = array(0);
380 break;
381 }
382
383 # view query
384 try
385 {
386 $query = $db->getHandle()->prepare($sql);
387 $query->execute($params);
388 $entries = $query->fetchAll();
389 }
390 catch (Exception $e)
391 {
392 logm('view query error : '.$e->getMessage());
393 }
394
395 return $entries;
396}
397
398/**
399 * Récupère un article en fonction d'un ID
400 */
401function get_article($id)
402{
403 global $db;
404
405 $entry = NULL;
406 $sql = "SELECT * FROM entries WHERE id=?";
407 $params = array(intval($id));
408
409 # view article query
410 try
411 {
412 $query = $db->getHandle()->prepare($sql);
413 $query->execute($params);
414 $entry = $query->fetchAll();
415 }
416 catch (Exception $e)
417 {
418 logm('get article query error : '.$e->getMessage());
419 }
420
421 return $entry;
422} 348}
423 349
424function logm($message) 350function logm($message)
diff --git a/inc/store/file.class.php b/inc/store/file.class.php
new file mode 100644
index 00000000..ad20937d
--- /dev/null
+++ b/inc/store/file.class.php
@@ -0,0 +1,51 @@
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <support@inthepoche.com>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11class File extends Store {
12 function __construct() {
13
14 }
15
16 public function add() {
17
18 }
19
20 public function retrieveOneById($id) {
21
22 }
23
24 public function retrieveOneByURL($url) {
25
26 }
27
28 public function deleteById($id) {
29
30 }
31
32 public function favoriteById($id) {
33
34 }
35
36 public function archiveById($id) {
37
38 }
39
40 public function getEntriesByView($view) {
41
42 }
43
44 public function getLastId() {
45
46 }
47
48 public function updateContentById($id) {
49
50 }
51}
diff --git a/inc/store/sqlite.class.php b/inc/store/sqlite.class.php
new file mode 100644
index 00000000..d5208a29
--- /dev/null
+++ b/inc/store/sqlite.class.php
@@ -0,0 +1,144 @@
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <support@inthepoche.com>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11class Sqlite extends Store {
12
13 public static $db_path = 'sqlite:./db/poche.sqlite';
14 var $handle;
15
16 function __construct() {
17 parent::__construct();
18
19 $this->handle = new PDO(self::$db_path);
20 $this->handle->exec('CREATE TABLE IF NOT EXISTS "entries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "title" VARCHAR, "url" VARCHAR UNIQUE , "is_read" INTEGER DEFAULT 0, "is_fav" INTEGER DEFAULT 0, "content" BLOB)');
21 $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
22 }
23
24 private function getHandle() {
25 return $this->handle;
26 }
27
28 private function executeQuery($sql, $params) {
29 try
30 {
31 $query = $this->getHandle()->prepare($sql);
32 $query->execute($params);
33 return $query;
34 }
35 catch (Exception $e)
36 {
37 logm('execute query error : '.$e->getMessage());
38 }
39 }
40
41 public function retrieveAll() {
42 $sql = "SELECT * FROM entries ORDER BY id";
43 $query = $this->executeQuery($sql, array());
44 $entries = $query->fetchAll();
45
46 return $entries;
47 }
48
49 public function retrieveOneById($id) {
50 parent::__construct();
51
52 $entry = NULL;
53 $sql = "SELECT * FROM entries WHERE id=?";
54 $params = array(intval($id));
55 $query = $this->executeQuery($sql, $params);
56 $entry = $query->fetchAll();
57
58 return $entry[0];
59 }
60
61 public function getEntriesByView($view) {
62 parent::__construct();
63
64 switch ($_SESSION['sort'])
65 {
66 case 'ia':
67 $order = 'ORDER BY id';
68 break;
69 case 'id':
70 $order = 'ORDER BY id DESC';
71 break;
72 case 'ta':
73 $order = 'ORDER BY lower(title)';
74 break;
75 case 'td':
76 $order = 'ORDER BY lower(title) DESC';
77 break;
78 default:
79 $order = 'ORDER BY id';
80 break;
81 }
82
83 switch ($view)
84 {
85 case 'archive':
86 $sql = "SELECT * FROM entries WHERE is_read=? " . $order;
87 $params = array(-1);
88 break;
89 case 'fav' :
90 $sql = "SELECT * FROM entries WHERE is_fav=? " . $order;
91 $params = array(-1);
92 break;
93 default:
94 $sql = "SELECT * FROM entries WHERE is_read=? " . $order;
95 $params = array(0);
96 break;
97 }
98
99 $query = $this->executeQuery($sql, $params);
100 $entries = $query->fetchAll();
101
102 return $entries;
103 }
104
105 public function add($url, $title, $content) {
106 parent::__construct();
107 $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
108 $params_action = array($url, $title, $content);
109 $query = $this->executeQuery($sql_action, $params_action);
110 }
111
112 public function deleteById($id) {
113 parent::__construct();
114 $sql_action = "DELETE FROM entries WHERE id=?";
115 $params_action = array($id);
116 $query = $this->executeQuery($sql_action, $params_action);
117 }
118
119 public function favoriteById($id) {
120 parent::__construct();
121 $sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?";
122 $params_action = array($id);
123 $query = $this->executeQuery($sql_action, $params_action);
124 }
125
126 public function archiveById($id) {
127 parent::__construct();
128 $sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?";
129 $params_action = array($id);
130 $query = $this->executeQuery($sql_action, $params_action);
131 }
132
133 public function getLastId() {
134 parent::__construct();
135 return $this->getHandle()->lastInsertId();
136 }
137
138 public function updateContentById($id) {
139 parent::__construct();
140 $sql_update = "UPDATE entries SET content=? WHERE id=?";
141 $params_update = array($content, $id);
142 $query = $this->executeQuery($sql_update, $params_update);
143 }
144}
diff --git a/inc/store/store.class.php b/inc/store/store.class.php
new file mode 100644
index 00000000..360ff7c2
--- /dev/null
+++ b/inc/store/store.class.php
@@ -0,0 +1,55 @@
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <support@inthepoche.com>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11class Store {
12 function __construct() {
13
14 }
15
16 public function add() {
17
18 }
19
20 public function retrieveAll() {
21
22 }
23
24 public function retrieveOneById($id) {
25
26 }
27
28 public function retrieveOneByURL($url) {
29
30 }
31
32 public function deleteById($id) {
33
34 }
35
36 public function favoriteById($id) {
37
38 }
39
40 public function archiveById($id) {
41
42 }
43
44 public function getEntriesByView($view) {
45
46 }
47
48 public function getLastId() {
49
50 }
51
52 public function updateContentById($id) {
53
54 }
55}