aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Updater.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2018-06-08 12:50:49 +0200
committerArthurHoaro <arthur@hoa.ro>2018-07-05 20:34:22 +0200
commit28f26524609338316cc6e51c743058e6e8c7b12b (patch)
treee03f1e5dde3779a47a682cf1461151fbd687e4bb /application/Updater.php
parent787faa42f3a2bcbf83a7853f23f3667a6febf9da (diff)
downloadShaarli-28f26524609338316cc6e51c743058e6e8c7b12b.tar.gz
Shaarli-28f26524609338316cc6e51c743058e6e8c7b12b.tar.zst
Shaarli-28f26524609338316cc6e51c743058e6e8c7b12b.zip
Add a page to update all thumbnails through AJAX requests in both templates
Diffstat (limited to 'application/Updater.php')
-rw-r--r--application/Updater.php25
1 files changed, 23 insertions, 2 deletions
diff --git a/application/Updater.php b/application/Updater.php
index 6fbe3e00..f6b9e205 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -31,6 +31,11 @@ class Updater
31 protected $isLoggedIn; 31 protected $isLoggedIn;
32 32
33 /** 33 /**
34 * @var array $_SESSION
35 */
36 protected $session;
37
38 /**
34 * @var ReflectionMethod[] List of current class methods. 39 * @var ReflectionMethod[] List of current class methods.
35 */ 40 */
36 protected $methods; 41 protected $methods;
@@ -42,13 +47,17 @@ class Updater
42 * @param LinkDB $linkDB LinkDB instance. 47 * @param LinkDB $linkDB LinkDB instance.
43 * @param ConfigManager $conf Configuration Manager instance. 48 * @param ConfigManager $conf Configuration Manager instance.
44 * @param boolean $isLoggedIn True if the user is logged in. 49 * @param boolean $isLoggedIn True if the user is logged in.
50 * @param array $session $_SESSION (by reference)
51 *
52 * @throws ReflectionException
45 */ 53 */
46 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn) 54 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn, &$session = [])
47 { 55 {
48 $this->doneUpdates = $doneUpdates; 56 $this->doneUpdates = $doneUpdates;
49 $this->linkDB = $linkDB; 57 $this->linkDB = $linkDB;
50 $this->conf = $conf; 58 $this->conf = $conf;
51 $this->isLoggedIn = $isLoggedIn; 59 $this->isLoggedIn = $isLoggedIn;
60 $this->session = &$session;
52 61
53 // Retrieve all update methods. 62 // Retrieve all update methods.
54 $class = new ReflectionClass($this); 63 $class = new ReflectionClass($this);
@@ -488,11 +497,23 @@ class Updater
488 */ 497 */
489 public function updateMethodWebThumbnailer() 498 public function updateMethodWebThumbnailer()
490 { 499 {
491 $this->conf->set('thumbnails.enabled', $this->conf->get('thumbnail.enable_thumbnails', true)); 500 if ($this->conf->exists('thumbnails.enabled')) {
501 return true;
502 }
503
504 $thumbnailsEnabled = $this->conf->get('thumbnail.enable_thumbnails', true);
505 $this->conf->set('thumbnails.enabled', $thumbnailsEnabled);
492 $this->conf->set('thumbnails.width', 125); 506 $this->conf->set('thumbnails.width', 125);
493 $this->conf->set('thumbnails.height', 90); 507 $this->conf->set('thumbnails.height', 90);
494 $this->conf->remove('thumbnail'); 508 $this->conf->remove('thumbnail');
495 $this->conf->write(true); 509 $this->conf->write(true);
510
511 if ($thumbnailsEnabled) {
512 $this->session['warnings'][] = t(
513 'You have enabled thumbnails. <a href="?do=thumbs_update">Please synchonize them</a>.'
514 );
515 }
516
496 return true; 517 return true;
497 } 518 }
498} 519}