This commit is contained in:
Franck Allimant
2014-04-15 17:41:33 +02:00
parent 7e251d7265
commit 87ed08dc6f
2 changed files with 25 additions and 0 deletions

View File

@@ -16,6 +16,10 @@
<default key="_controller">Thelia\Controller\Admin\HomeController::defaultAction</default>
</route>
<route id="admin.home.view" path="/admin/latest-thelia-version">
<default key="_controller">Thelia\Controller\Admin\HomeController::getLatestTheliaVersion</default>
</route>
<route id="admin.home.stats" path="/admin/home/stats">
<default key="_controller">Thelia\Controller\Admin\HomeController::loadStatsAjaxAction</default>
</route>

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Security\AccessManager;
use Thelia\Model\CustomerQuery;
use Thelia\Model\OrderQuery;
@@ -39,6 +40,26 @@ class HomeController extends BaseAdminController
return $this->render('home');
}
/**
* Get the latest available Thelia version from the Thelia web site.
*
* @return Thelia\Core\HttpFoundation\Response the response
*/
public function getLatestTheliaVersion()
{
if (null !== $response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW)) return $response;
// get the latest version
$version = @file_get_contents("http://thelia.net/version.php");
if ($version === false)
$version = $this->getTranslator()->trans("Not found");
else if (! preg_match("/^[0-9.]*$/", $version))
$version = $this->getTranslator()->trans("Unavailable");
return Response::create($version);
}
public function loadStatsAjaxAction()
{
if (null !== $response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW)) return $response;