Skip to content

Commit

Permalink
Show list of available updates at "About" page
Browse files Browse the repository at this point in the history
  • Loading branch information
JustBlackBird committed May 26, 2015
1 parent e9d41c4 commit d4ebd68
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 52 deletions.
40 changes: 0 additions & 40 deletions src/mibew/js/source/about.js

This file was deleted.

44 changes: 37 additions & 7 deletions src/mibew/libs/classes/Mibew/Controller/AboutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Mibew\Controller;

use Mibew\Asset\AssetManagerInterface;
use Mibew\Maintenance\AvailableUpdate;
use Symfony\Component\HttpFoundation\Request;

/**
Expand All @@ -43,16 +43,11 @@ public function indexAction(Request $request)
'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);
}

Expand Down Expand Up @@ -86,4 +81,39 @@ protected function getExtensionsInfo()

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@

<br/>

<h3>{{l10n "Latest version:"}}</h3>
<div id="latest-version"></div>

<br/>

<h3>{{l10n "Installed localizations:"}}</h3>
{{#each localizations}}
{{this}}
Expand All @@ -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">
Expand Down

0 comments on commit d4ebd68

Please sign in to comment.