]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/poche/Database.class.php
WHAT. A. BIG. REFACTOR. + new license (we moved to MIT one)
[github/wallabag/wallabag.git] / inc / poche / Database.class.php
index a222ed39b76017fc8b758b2d486b429f5e645f92..9c1c0286b4fd2feafebea8e04b94c83c2bc2be3f 100755 (executable)
@@ -5,7 +5,7 @@
  * @category   wallabag
  * @author     Nicolas LÅ“uillet <nicolas@loeuillet.org>
  * @copyright  2013
- * @license    http://www.wtfpl.net/ see COPYING file
+ * @license    http://opensource.org/licenses/MIT see COPYING file
  */
 
 class Database {
@@ -38,6 +38,7 @@ class Database {
         }
 
         $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+        $this->_checkTags();
         Tools::logm('storage type ' . STORAGE);
     }
 
@@ -45,21 +46,7 @@ class Database {
         return $this->handle;
     }
 
-    public function isInstalled() {
-        $sql = "SELECT username FROM users";
-        $query = $this->executeQuery($sql, array());
-        if ($query == false) {
-            die(STORAGE . ' database looks empty. You have to create it (you can find database structure in install folder).');
-        }
-        $hasAdmin = count($query->fetchAll());
-
-        if ($hasAdmin == 0)
-            return false;
-
-        return true;
-    }
-
-    public function checkTags() {
+    private function _checkTags() {
 
         if (STORAGE == 'sqlite') {
             $sql = '
@@ -398,21 +385,6 @@ 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
@@ -422,12 +394,9 @@ class Database {
      * @return integer $id of inserted record
      */
     public function add($url, $title, $content, $user_id, $isFavorite=0, $isRead=0) {
-        $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 ) VALUES (?, ?, ?, ?, ?, ?)';
+        $params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead);
 
-        $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;
         }