diff options
Diffstat (limited to 'inc/poche')
-rw-r--r-- | inc/poche/Database.class.php | 7 | ||||
-rw-r--r-- | inc/poche/Poche.class.php | 18 | ||||
-rw-r--r-- | inc/poche/Tools.class.php | 10 | ||||
-rw-r--r-- | inc/poche/config.inc.php | 2 |
4 files changed, 30 insertions, 7 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index cd5a9a31..84916b83 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -184,6 +184,13 @@ class Database { | |||
184 | return $entries; | 184 | return $entries; |
185 | } | 185 | } |
186 | 186 | ||
187 | public function updateContent($id, $content, $user_id) { | ||
188 | $sql_action = 'UPDATE entries SET content = ? WHERE id=? AND user_id=?'; | ||
189 | $params_action = array($content, $id, $user_id); | ||
190 | $query = $this->executeQuery($sql_action, $params_action); | ||
191 | return $query; | ||
192 | } | ||
193 | |||
187 | public function add($url, $title, $content, $user_id) { | 194 | public function add($url, $title, $content, $user_id) { |
188 | $sql_action = 'INSERT INTO entries ( url, title, content, user_id ) VALUES (?, ?, ?, ?)'; | 195 | $sql_action = 'INSERT INTO entries ( url, title, content, user_id ) VALUES (?, ?, ?, ?)'; |
189 | $params_action = array($url, $title, $content, $user_id); | 196 | $params_action = array($url, $title, $content, $user_id); |
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 56910bc0..2af49acd 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -18,6 +18,11 @@ class Poche | |||
18 | 18 | ||
19 | function __construct() | 19 | function __construct() |
20 | { | 20 | { |
21 | if (file_exists('./install') && !DEBUG_POCHE) { | ||
22 | Tools::logm('folder /install exists'); | ||
23 | die('To install your poche with sqlite, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.'); | ||
24 | } | ||
25 | |||
21 | $this->store = new Database(); | 26 | $this->store = new Database(); |
22 | $this->init(); | 27 | $this->init(); |
23 | $this->messages = new Messages(); | 28 | $this->messages = new Messages(); |
@@ -31,11 +36,6 @@ class Poche | |||
31 | 36 | ||
32 | private function init() | 37 | private function init() |
33 | { | 38 | { |
34 | if (file_exists('./install') && !DEBUG_POCHE) { | ||
35 | Tools::logm('folder /install exists'); | ||
36 | die('the folder /install exists, you have to delete it before using poche.'); | ||
37 | } | ||
38 | |||
39 | Tools::initPhp(); | 39 | Tools::initPhp(); |
40 | Session::init(); | 40 | Session::init(); |
41 | 41 | ||
@@ -69,6 +69,10 @@ class Poche | |||
69 | $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); | 69 | $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); |
70 | $this->tpl->addFilter($filter); | 70 | $this->tpl->addFilter($filter); |
71 | 71 | ||
72 | # filter for reading time | ||
73 | $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); | ||
74 | $this->tpl->addFilter($filter); | ||
75 | |||
72 | # Pagination | 76 | # Pagination |
73 | $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p'); | 77 | $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p'); |
74 | } | 78 | } |
@@ -122,6 +126,8 @@ class Poche | |||
122 | $last_id = $this->store->getLastId($sequence); | 126 | $last_id = $this->store->getLastId($sequence); |
123 | if (DOWNLOAD_PICTURES) { | 127 | if (DOWNLOAD_PICTURES) { |
124 | $content = filtre_picture($parametres_url['content'], $url->getUrl(), $last_id); | 128 | $content = filtre_picture($parametres_url['content'], $url->getUrl(), $last_id); |
129 | Tools::logm('updating content article'); | ||
130 | $this->store->updateContent($last_id, $content, $this->user->getId()); | ||
125 | } | 131 | } |
126 | if (!$import) { | 132 | if (!$import) { |
127 | $this->messages->add('s', _('the link has been added successfully')); | 133 | $this->messages->add('s', _('the link has been added successfully')); |
@@ -213,7 +219,7 @@ class Poche | |||
213 | ); | 219 | ); |
214 | } | 220 | } |
215 | else { | 221 | else { |
216 | Tools::logm('error in view call : entry is NULL'); | 222 | Tools::logm('error in view call : entry is null'); |
217 | } | 223 | } |
218 | break; | 224 | break; |
219 | default: # home view | 225 | default: # home view |
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index d0e43166..0eb0d9ea 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php | |||
@@ -170,6 +170,7 @@ class Tools | |||
170 | preg_match('#charset="?(.*)"#si', $meta[0], $encoding); | 170 | preg_match('#charset="?(.*)"#si', $meta[0], $encoding); |
171 | # if charset is found set it otherwise, set it to utf-8 | 171 | # if charset is found set it otherwise, set it to utf-8 |
172 | $html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8'; | 172 | $html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8'; |
173 | if (empty($encoding[1])) $encoding[1] = 'utf-8'; | ||
173 | } else { | 174 | } else { |
174 | $html_charset = 'utf-8'; | 175 | $html_charset = 'utf-8'; |
175 | $encoding[1] = ''; | 176 | $encoding[1] = ''; |
@@ -223,4 +224,13 @@ class Tools | |||
223 | 224 | ||
224 | return FALSE; | 225 | return FALSE; |
225 | } | 226 | } |
227 | |||
228 | public static function getReadingTime($text) { | ||
229 | $word = str_word_count(strip_tags($text)); | ||
230 | $minutes = floor($word / 200); | ||
231 | $seconds = floor($word % 200 / (200 / 60)); | ||
232 | $time = array('minutes' => $minutes, 'seconds' => $seconds); | ||
233 | |||
234 | return $minutes; | ||
235 | } | ||
226 | } \ No newline at end of file | 236 | } \ No newline at end of file |
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php index 0958600f..321784d7 100644 --- a/inc/poche/config.inc.php +++ b/inc/poche/config.inc.php | |||
@@ -18,7 +18,7 @@ define ('STORAGE_PASSWORD', 'postgres'); # leave blank for sqlite | |||
18 | 18 | ||
19 | define ('POCHE_VERSION', '1.0-beta1'); | 19 | define ('POCHE_VERSION', '1.0-beta1'); |
20 | define ('MODE_DEMO', FALSE); | 20 | define ('MODE_DEMO', FALSE); |
21 | define ('DEBUG_POCHE', TRUE); | 21 | define ('DEBUG_POCHE', FALSE); |
22 | define ('CONVERT_LINKS_FOOTNOTES', FALSE); | 22 | define ('CONVERT_LINKS_FOOTNOTES', FALSE); |
23 | define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); | 23 | define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); |
24 | define ('DOWNLOAD_PICTURES', FALSE); | 24 | define ('DOWNLOAD_PICTURES', FALSE); |