mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 05:20:30 +03:00
Show list of available updates at "About" page
This commit is contained in:
parent
e9d41c4869
commit
d4ebd68052
@ -1,40 +0,0 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function (Mibew, $) {
|
||||
Mibew.updateVersion = function(data) {
|
||||
if (!data.core || !data.core.stable) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
var currentVersion = $("#current-version").html(),
|
||||
core = data.core.stable;
|
||||
|
||||
if (currentVersion != core.version) {
|
||||
if (currentVersion < core.version) {
|
||||
$("#current-version").css("color", "red");
|
||||
}
|
||||
$("#latest-version").html(core.version + ", Download <a href=\"" + core.download + "\">" + core.title + "</a>");
|
||||
} else {
|
||||
$("#current-version").css("color", "green");
|
||||
$("#latest-version").html(core.version);
|
||||
}
|
||||
});
|
||||
}
|
||||
})(Mibew, jQuery);
|
@ -19,7 +19,7 @@
|
||||
|
||||
namespace Mibew\Controller;
|
||||
|
||||
use Mibew\Asset\AssetManagerInterface;
|
||||
use Mibew\Maintenance\AvailableUpdate;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
@ -43,16 +43,11 @@ class AboutController extends AbstractController
|
||||
'version' => MIBEW_VERSION,
|
||||
'title' => getlocal('About'),
|
||||
'menuid' => 'about',
|
||||
'availableUpdates' => $this->getAvailableUpdates(),
|
||||
),
|
||||
prepare_menu($this->getOperator())
|
||||
);
|
||||
|
||||
$this->getAssetManager()->attachJs('js/compiled/about.js');
|
||||
$this->getAssetManager()->attachJs(
|
||||
'https://mibew.org/api/updates',
|
||||
AssetManagerInterface::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
return $this->render('about', $page);
|
||||
}
|
||||
|
||||
@ -86,4 +81,39 @@ class AboutController extends AbstractController
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds list of available updates to display in the template.
|
||||
*
|
||||
* @return array List of updates data. Each item of the list is associative
|
||||
* array with the following keys:
|
||||
* - "title": string, title of the update.
|
||||
* - "version": string, the latest available version.
|
||||
* - "url": string, URL of the page the updated version can be downloaded
|
||||
* from.
|
||||
* - "description": string, description of the update.
|
||||
*/
|
||||
protected function getAvailableUpdates()
|
||||
{
|
||||
$updates = AvailableUpdate::all();
|
||||
if (!$updates) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
foreach ($updates as $update) {
|
||||
$title = ($update->target == 'core')
|
||||
? 'Mibew'
|
||||
: getlocal('{0} plugin', array($update->target));
|
||||
|
||||
$data[] = array(
|
||||
'title' => $title,
|
||||
'version' => $update->version,
|
||||
'url' => $update->url,
|
||||
'description' => $update->description,
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,6 @@
|
||||
|
||||
<br/>
|
||||
|
||||
<h3>{{l10n "Latest version:"}}</h3>
|
||||
<div id="latest-version"></div>
|
||||
|
||||
<br/>
|
||||
|
||||
<h3>{{l10n "Installed localizations:"}}</h3>
|
||||
{{#each localizations}}
|
||||
{{this}}
|
||||
@ -36,6 +31,23 @@
|
||||
|
||||
<h3>{{l10n "Environment:"}}</h3>
|
||||
PHP {{phpVersion}} {{#each extensions}}{{@key}}{{#if loaded}}{{#if version}}/{{version}}{{/if}}{{else}}/absent{{/if}} {{/each}}
|
||||
|
||||
<br/><br/>
|
||||
|
||||
{{#if availableUpdates}}
|
||||
<h2>{{l10n "Available updates"}}</h2>
|
||||
{{#each availableUpdates}}
|
||||
<h3>{{title}} ({{version}})</h3>
|
||||
{{#if description}}
|
||||
<div>{{description}}</div>
|
||||
{{/if}}
|
||||
<div>
|
||||
<a href="{{url}}">Download</a>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<div class="form-footer">
|
||||
|
Loading…
Reference in New Issue
Block a user