aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-07 14:24:07 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-07 14:24:07 +0200
commitbc1ee8524e0769ad37e3c4c02cfe96d2f60e52f6 (patch)
tree5ea9d0f0560e84c07ab84c86b9e5fd4dd6ebb039 /inc/poche/Poche.class.php
parent8d3275bee488d058c6ff0efe6e81d20a584d3709 (diff)
downloadwallabag-bc1ee8524e0769ad37e3c4c02cfe96d2f60e52f6.tar.gz
wallabag-bc1ee8524e0769ad37e3c4c02cfe96d2f60e52f6.tar.zst
wallabag-bc1ee8524e0769ad37e3c4c02cfe96d2f60e52f6.zip
postgres
Diffstat (limited to 'inc/poche/Poche.class.php')
-rw-r--r--inc/poche/Poche.class.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index ce5bb54a..0a43df71 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -16,9 +16,9 @@ class Poche
16 public $messages; 16 public $messages;
17 public $pagination; 17 public $pagination;
18 18
19 function __construct($storage_type) 19 function __construct()
20 { 20 {
21 $this->store = new $storage_type(); 21 $this->store = new Database();
22 $this->init(); 22 $this->init();
23 $this->messages = new Messages(); 23 $this->messages = new Messages();
24 24
@@ -52,9 +52,13 @@ class Poche
52 52
53 # template engine 53 # template engine
54 $loader = new Twig_Loader_Filesystem(TPL); 54 $loader = new Twig_Loader_Filesystem(TPL);
55 $this->tpl = new Twig_Environment($loader, array( 55 if (DEBUG_POCHE) {
56 'cache' => CACHE, 56 $twig_params = array();
57 )); 57 }
58 else {
59 $twig_params = array('cache' => CACHE);
60 }
61 $this->tpl = new Twig_Environment($loader, $twig_params);
58 $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); 62 $this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
59 # filter to display domain name of an url 63 # filter to display domain name of an url
60 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); 64 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
@@ -124,18 +128,19 @@ class Poche
124 Tools::redirect(); 128 Tools::redirect();
125 break; 129 break;
126 case 'delete': 130 case 'delete':
131 $msg = 'delete link #' . $id;
127 if ($this->store->deleteById($id, $this->user->getId())) { 132 if ($this->store->deleteById($id, $this->user->getId())) {
128 if (DOWNLOAD_PICTURES) { 133 if (DOWNLOAD_PICTURES) {
129 remove_directory(ABS_PATH . $id); 134 remove_directory(ABS_PATH . $id);
130 } 135 }
131 $this->messages->add('s', _('the link has been deleted successfully')); 136 $this->messages->add('s', _('the link has been deleted successfully'));
132 Tools::logm('delete link #' . $id);
133 } 137 }
134 else { 138 else {
135 $this->messages->add('e', _('the link wasn\'t deleted')); 139 $this->messages->add('e', _('the link wasn\'t deleted'));
136 Tools::logm('error : can\'t delete link #' . $id); 140 $msg = 'error : can\'t delete link #' . $id;
137 } 141 }
138 Tools::redirect(); 142 Tools::logm($msg);
143 Tools::redirect('?');
139 break; 144 break;
140 case 'toggle_fav' : 145 case 'toggle_fav' :
141 $this->store->favoriteById($id, $this->user->getId()); 146 $this->store->favoriteById($id, $this->user->getId());
@@ -385,7 +390,7 @@ class Poche
385 if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 86400 ))) { 390 if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 86400 ))) {
386 $version = file_get_contents($cache_file); 391 $version = file_get_contents($cache_file);
387 } else { 392 } else {
388 $version = file_get_contents('http://www.inthepoche.com/' . $which); 393 $version = file_get_contents('http://static.inthepoche.com/versions/' . $which);
389 file_put_contents($cache_file, $version, LOCK_EX); 394 file_put_contents($cache_file, $version, LOCK_EX);
390 } 395 }
391 return $version; 396 return $version;