diff options
| author | 2017-12-06 21:04:45 +0100 | |
|---|---|---|
| committer | 2017-12-06 21:04:45 +0100 | |
| commit | 3902d3f43330504945e78627b4c49e67ae88aea9 (patch) | |
| tree | 6b86f0c0bd9563f3cb7ffc8756b6eef0d18025f6 /app/Controllers/extensionController.php | |
| parent | 4f06b17e005456515768f46b3cc3130428f579bf (diff) | |
Show existing extensions in admin panel (#1708)
* first draft
* display installed extension state
* fixed whitespace vs tabs
* added translation in all languages
* added error checks and log messages
* fixed tabs vs whitespace
* another try in fixing whitespaces
* another try in fixing whitespaces
* improved extension list translations
* using JSON from official extension repo
* improved version compare
* updated translations
* French translation
Diffstat (limited to 'app/Controllers/extensionController.php')
| -rw-r--r-- | app/Controllers/extensionController.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index b6d2d3fe4..bb846e921 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -25,10 +25,47 @@ class FreshRSS_extension_Controller extends Minz_ActionController { 'user' => array(), ); + $this->view->extensions_installed = array(); + $extensions = Minz_ExtensionManager::listExtensions(); foreach ($extensions as $ext) { $this->view->extension_list[$ext->getType()][] = $ext; + $this->view->extensions_installed[$ext->getEntrypoint()] = $ext->getVersion(); + } + + $availableExtensions = $this->getAvailableExtensionList(); + $this->view->available_extensions = $availableExtensions; + } + + /** + * fetch extension list from GitHub + */ + protected function getAvailableExtensionList() { + $extensionListUrl = 'https://raw.githubusercontent.com/FreshRSS/Extensions/master/extensions.json'; + $json = file_get_contents($extensionListUrl); + + // we ran into problems, simply ignore them + if ($json === false) { + Minz_Log::error('Could not fetch available extension from GitHub'); + return array(); + } + + // fetch the list as an array + $list = json_decode($json, true); + if (empty($list)) { + Minz_Log::warning('Failed to convert extension file list'); + return array(); } + + // we could use that for comparing and caching later + $version = $list['version']; + + // By now, all the needed data is kept in the main extension file. + // In the future we could fetch detail information from the extensions metadata.json, but I tend to stick with + // the current implementation for now, unless it becomes too much effort maintain the extension list manually + $extensions = $list['extensions']; + + return $extensions; } /** |
