From 32520785018e3ec3a2ce200689e863099e9646f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 5 Aug 2013 12:34:16 +0200 Subject: [PATCH] close #69: in the config page, you are notified of the release of a new version --- inc/poche/Poche.class.php | 22 ++++++++++++++++++++++ inc/poche/config.inc.php | 2 +- tpl/config.twig | 8 ++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 12cb1b42..f9bcf85b 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -130,6 +130,16 @@ class Poche switch ($view) { case 'config': + $dev = $this->getPocheVersion('dev'); + $prod = $this->getPocheVersion('prod'); + $compare_dev = version_compare(POCHE_VERSION, $dev); + $compare_prod = version_compare(POCHE_VERSION, $prod); + $tpl_vars = array( + 'dev' => $dev, + 'prod' => $prod, + 'compare_dev' => $compare_dev, + 'compare_prod' => $compare_prod, + ); Tools::logm('config view'); break; case 'view': @@ -315,4 +325,16 @@ class Poche )); Tools::logm('export view'); } + + private function getPocheVersion($which = 'prod') + { + $cache_file = CACHE . '/' . $which; + if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 86400 ))) { + $version = file_get_contents($cache_file); + } else { + $version = file_get_contents('http://www.inthepoche.com/' . $which); + file_put_contents($cache_file, $version, LOCK_EX); + } + return $version; + } } \ No newline at end of file diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php index eb0c1bb5..27be1857 100644 --- a/inc/poche/config.inc.php +++ b/inc/poche/config.inc.php @@ -36,7 +36,7 @@ require_once './vendor/autoload.php'; require_once './inc/3rdparty/simple_html_dom.php'; if (DOWNLOAD_PICTURES) { - require_once './inc/poche/pochePicture.php'; + require_once './inc/poche/pochePictures.php'; } $poche = new Poche($storage_type); \ No newline at end of file diff --git a/tpl/config.twig b/tpl/config.twig index dc49ee39..a17a4b17 100644 --- a/tpl/config.twig +++ b/tpl/config.twig @@ -17,6 +17,14 @@

{% trans "Drag & drop this link to your bookmarks bar and have fun with poche." %}

{% trans "poche it!" %}

+

{% trans "Updating poche" %}

+

+

+

{% trans "Change your password" %}

-- 2.41.0