close #69: in the config page, you are notified of the release of a new version

This commit is contained in:
Nicolas Lœuillet 2013-08-05 12:34:16 +02:00
parent 21e0af98eb
commit 3252078501
3 changed files with 31 additions and 1 deletions

View file

@ -130,6 +130,16 @@ class Poche
switch ($view) switch ($view)
{ {
case 'config': 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'); Tools::logm('config view');
break; break;
case 'view': case 'view':
@ -315,4 +325,16 @@ class Poche
)); ));
Tools::logm('export view'); 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;
}
} }

View file

@ -36,7 +36,7 @@ require_once './vendor/autoload.php';
require_once './inc/3rdparty/simple_html_dom.php'; require_once './inc/3rdparty/simple_html_dom.php';
if (DOWNLOAD_PICTURES) { if (DOWNLOAD_PICTURES) {
require_once './inc/poche/pochePicture.php'; require_once './inc/poche/pochePictures.php';
} }
$poche = new Poche($storage_type); $poche = new Poche($storage_type);

View file

@ -17,6 +17,14 @@
<p>{% trans "Drag & drop this link to your bookmarks bar and have fun with poche." %}</p> <p>{% trans "Drag & drop this link to your bookmarks bar and have fun with poche." %}</p>
<p><a ondragend="this.click();" style="cursor: move; border: 1px dashed grey; background: white;" title="i am a bookmarklet, use me !" href="javascript:if(top['bookmarklet-url@inthepoche.com']){top['bookmarklet-url@inthepoche.com'];}else{(function(){var%20url%20=%20location.href%20||%20url;window.open('{{ poche_url }}?action=add&url='%20+%20btoa(url),'_self');})();void(0);}">{% trans "poche it!" %}</a></p> <p><a ondragend="this.click();" style="cursor: move; border: 1px dashed grey; background: white;" title="i am a bookmarklet, use me !" href="javascript:if(top['bookmarklet-url@inthepoche.com']){top['bookmarklet-url@inthepoche.com'];}else{(function(){var%20url%20=%20location.href%20||%20url;window.open('{{ poche_url }}?action=add&url='%20+%20btoa(url),'_self');})();void(0);}">{% trans "poche it!" %}</a></p>
<h2>{% trans "Updating poche" %}</h2>
<p><ul>
<li>{% trans "your version" %} : <strong>{{ constant('POCHE_VERSION') }}</strong></li>
<li>{% trans "latest stable version" %} : {{ prod }}. {% if compare_prod == -1 %}<strong>{% trans "a more recent stable version is available." %}</strong>{% else %}{% trans "you are up to date." %}{% endif %}</li>
<li>{% trans "latest dev version" %} : {{ dev }}. {% if compare_dev == -1 %}<strong>{% trans "a more recent development version is available." %}</strong>{% else %}{% trans "you are up to date." %}{% endif %}</li>
</ul>
</p>
<h2>{% trans "Change your password" %}</h2> <h2>{% trans "Change your password" %}</h2>
<form method="post" action="?config" name="loginform"> <form method="post" action="?config" name="loginform">
<fieldset class="w500p"> <fieldset class="w500p">