diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index dddb251..a222ed3 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -398,6 +398,21 @@ class Database { return $query; } + + private function _getDomain($url) + { + return parse_url($url, PHP_URL_HOST); + } + + private function _getReadingTime($text) { + $word = str_word_count(strip_tags($text)); + $minutes = floor($word / 200); + $seconds = floor($word % 200 / (200 / 60)); + $time = array('minutes' => $minutes, 'seconds' => $seconds); + + return $minutes; + } + /** * * @param string $url @@ -407,8 +422,12 @@ class Database { * @return integer $id of inserted record */ public function add($url, $title, $content, $user_id, $isFavorite=0, $isRead=0) { - $sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read ) VALUES (?, ?, ?, ?, ?, ?)'; - $params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead); + $readingTime = $this->_getReadingTime($content); + $domainName = $this->_getDomain($url); + $date = date('Y-m-d H:i:s'); + + $sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read, date, reading_time, domain_name ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; + $params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead, $date, $readingTime, $domainName); if ( !$this->executeQuery($sql_action, $params_action) ) { $id = null; } diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 09a9f5f..e8c3202 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -232,14 +232,6 @@ class Poche $this->tpl = new Twig_Environment($loaderChain, $twigParams); $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); - - # filter to display domain name of an url - $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); - $this->tpl->addFilter($filter); - - # filter for reading time - $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); - $this->tpl->addFilter($filter); } public function createNewUser() { diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 1ef875c..13f4890 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -214,20 +214,6 @@ class Tools return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default); } - public static function getDomain($url) - { - return parse_url($url, PHP_URL_HOST); - } - - public static function getReadingTime($text) { - $word = str_word_count(strip_tags($text)); - $minutes = floor($word / 200); - $seconds = floor($word % 200 / (200 / 60)); - $time = array('minutes' => $minutes, 'seconds' => $seconds); - - return $minutes; - } - public static function getDocLanguage($userlanguage) { $lang = explode('.', $userlanguage); return str_replace('_', '-', $lang[0]); diff --git a/install/poche.sqlite b/install/poche.sqlite old mode 100755 new mode 100644 index f2b79b6..4c0f813 Binary files a/install/poche.sqlite and b/install/poche.sqlite differ diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig index 3942d3b..b819d80 100755 --- a/themes/baggy/home.twig +++ b/themes/baggy/home.twig @@ -40,16 +40,17 @@ {% for entry in entries %}

{{ entry.title|raw }}

- {% if entry.content| getReadingTime > 0 %} -
{% trans "estimated reading time :" %} {{ entry.content| getReadingTime }} min
+
{{ entry.date }}
+ {% if entry.reading_time > 0 %} +
{% trans "estimated reading time :" %} {{ entry.reading_time }} min
{% else %} -
{% trans "estimated reading time :" %} < 1 min
+
{% trans "estimated reading time :" %} < 1 min
{% endif %}

{{ entry.content|striptags|slice(0, 300) }}...