diff options
| author | 2017-12-06 21:04:45 +0100 | |
|---|---|---|
| committer | 2017-12-06 21:04:45 +0100 | |
| commit | 3902d3f43330504945e78627b4c49e67ae88aea9 (patch) | |
| tree | 6b86f0c0bd9563f3cb7ffc8756b6eef0d18025f6 | |
| 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
| -rw-r--r-- | app/Controllers/extensionController.php | 37 | ||||
| -rw-r--r-- | app/i18n/cz/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/de/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/en/admin.php | 7 | ||||
| -rwxr-xr-x | app/i18n/es/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/fr/admin.php | 13 | ||||
| -rw-r--r-- | app/i18n/it/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/kr/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/nl/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/pt-br/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/ru/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/tr/admin.php | 7 | ||||
| -rw-r--r-- | app/i18n/zh-cn/admin.php | 7 | ||||
| -rw-r--r-- | app/views/extension/index.phtml | 37 |
14 files changed, 159 insertions, 5 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; } /** diff --git a/app/i18n/cz/admin.php b/app/i18n/cz/admin.php index 63cee3cca..dbfebd4c9 100644 --- a/app/i18n/cz/admin.php +++ b/app/i18n/cz/admin.php @@ -155,6 +155,13 @@ return array( 'help' => '0 znamená žádná omezení účtu', 'number' => 'Maximální počet účtů', ), + 'community' => 'Available community extensions', // @todo translate + 'name' => 'Name', // @todo translate + 'version' => 'Version', // @todo translate + 'description' => 'Description', // @todo translate + 'author' => 'Author', // @todo translate + 'latest' => 'Installed', // @todo translate + 'update' => 'Update available', // @todo translate ), 'update' => array( '_' => 'Aktualizace systému', diff --git a/app/i18n/de/admin.php b/app/i18n/de/admin.php index b5deea989..bb2c9352d 100644 --- a/app/i18n/de/admin.php +++ b/app/i18n/de/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => 'Erweiterungen', 'user' => 'Benutzer-Erweiterungen', + 'community' => 'Verfügbare Community Erweiterungen', + 'name' => 'Name', + 'version' => 'Version', + 'description' => 'Beschreibungen', + 'author' => 'Autor', + 'latest' => 'Installiert', + 'update' => 'Update verfügbar', ), 'stats' => array( '_' => 'Statistiken', diff --git a/app/i18n/en/admin.php b/app/i18n/en/admin.php index 707627782..d92a016af 100644 --- a/app/i18n/en/admin.php +++ b/app/i18n/en/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => 'Extensions', 'user' => 'User extensions', + 'community' => 'Available community extensions', + 'name' => 'Name', + 'version' => 'Version', + 'description' => 'Description', + 'author' => 'Author', + 'latest' => 'Installed', + 'update' => 'Update available' ), 'stats' => array( '_' => 'Statistics', diff --git a/app/i18n/es/admin.php b/app/i18n/es/admin.php index c9d9368eb..93b1e6e5c 100755 --- a/app/i18n/es/admin.php +++ b/app/i18n/es/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => 'Extensiones', 'user' => 'Extensiones de usuario', + 'community' => 'Available community extensions', // @todo translate + 'name' => 'Name', // @todo translate + 'version' => 'Version', // @todo translate + 'description' => 'Description', // @todo translate + 'author' => 'Author', // @todo translate + 'latest' => 'Installed', // @todo translate + 'update' => 'Update available', // @todo translate ), 'stats' => array( '_' => 'Estadísticas', diff --git a/app/i18n/fr/admin.php b/app/i18n/fr/admin.php index 9a13ecc21..b2bc48209 100644 --- a/app/i18n/fr/admin.php +++ b/app/i18n/fr/admin.php @@ -103,15 +103,22 @@ return array( ), 'extensions' => array( 'disabled' => 'Désactivée', - 'empty_list' => 'Il n’y a aucune extension installée.', + 'empty_list' => 'Aucune extension installée', 'enabled' => 'Activée', - 'no_configure_view' => 'Cette extension ne peut pas être configurée.', + 'no_configure_view' => 'Cette extension n’a pas à être configurée', 'system' => array( '_' => 'Extensions système', - 'no_rights' => 'Extension système (vous n’avez aucun droit dessus)', + 'no_rights' => 'Extensions système (contrôlées par l’administrateur)', ), 'title' => 'Extensions', 'user' => 'Extensions utilisateur', + 'community' => 'Extensions utilisateur disponibles', + 'name' => 'Nom', + 'version' => 'Version', + 'description' => 'Description', + 'author' => 'Auteur', + 'latest' => 'Installée', + 'update' => 'Mise à jour disponible', ), 'stats' => array( '_' => 'Statistiques', diff --git a/app/i18n/it/admin.php b/app/i18n/it/admin.php index ae46818ae..0248d9317 100644 --- a/app/i18n/it/admin.php +++ b/app/i18n/it/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => 'Estensioni', 'user' => 'Estensioni utente', + 'community' => 'Available community extensions', // @todo translate + 'name' => 'Name', // @todo translate + 'version' => 'Version', // @todo translate + 'description' => 'Description', // @todo translate + 'author' => 'Author', // @todo translate + 'latest' => 'Installed', // @todo translate + 'update' => 'Update available', // @todo translate ), 'stats' => array( '_' => 'Statistiche', diff --git a/app/i18n/kr/admin.php b/app/i18n/kr/admin.php index 13f4695e1..9781fb640 100644 --- a/app/i18n/kr/admin.php +++ b/app/i18n/kr/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => '확장 기능', 'user' => '사용자 확장 기능', + 'community' => 'Available community extensions', // @todo translate + 'name' => 'Name', // @todo translate + 'version' => 'Version', // @todo translate + 'description' => 'Description', // @todo translate + 'author' => 'Author', // @todo translate + 'latest' => 'Installed', // @todo translate + 'update' => 'Update available', // @todo translate ), 'stats' => array( '_' => '통계', diff --git a/app/i18n/nl/admin.php b/app/i18n/nl/admin.php index fdfe6e3bc..384242b4d 100644 --- a/app/i18n/nl/admin.php +++ b/app/i18n/nl/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => 'Uitbreidingen', 'user' => 'Gebruikersuitbreidingen', + 'community' => 'Gebruikersuitbreidingen beschikbaar', + 'name' => 'Naam', + 'version' => 'Versie', + 'description' => 'Beschrijving', + 'author' => 'Auteur', + 'latest' => 'Geïnstalleerd', + 'update' => 'Update beschikbaar', ), 'stats' => array( '_' => 'Statistieken', diff --git a/app/i18n/pt-br/admin.php b/app/i18n/pt-br/admin.php index 1076534b2..e62718e80 100644 --- a/app/i18n/pt-br/admin.php +++ b/app/i18n/pt-br/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => 'Extensões', 'user' => 'Extensões do usuário', + 'community' => 'Available community extensions', // @todo translate + 'name' => 'Name', // @todo translate + 'version' => 'Version', // @todo translate + 'description' => 'Description', // @todo translate + 'author' => 'Author', // @todo translate + 'latest' => 'Installed', // @todo translate + 'update' => 'Update available', // @todo translate ), 'stats' => array( '_' => 'Estatísticas', diff --git a/app/i18n/ru/admin.php b/app/i18n/ru/admin.php index f5da97371..d877c5006 100644 --- a/app/i18n/ru/admin.php +++ b/app/i18n/ru/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => 'Расширения', 'user' => 'Расширения пользователя', + 'community' => 'Available community extensions', // @todo translate + 'name' => 'Name', // @todo translate + 'version' => 'Version', // @todo translate + 'description' => 'Description', // @todo translate + 'author' => 'Author', // @todo translate + 'latest' => 'Installed', // @todo translate + 'update' => 'Update available', // @todo translate ), 'stats' => array( '_' => 'Статистика', diff --git a/app/i18n/tr/admin.php b/app/i18n/tr/admin.php index 9d10ef9dd..aa3aad7b7 100644 --- a/app/i18n/tr/admin.php +++ b/app/i18n/tr/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => 'Eklentiler', 'user' => 'Kullanıcı eklentileri', + 'community' => 'Available community extensions', // @todo translate + 'name' => 'Name', // @todo translate + 'version' => 'Version', // @todo translate + 'description' => 'Description', // @todo translate + 'author' => 'Author', // @todo translate + 'latest' => 'Installed', // @todo translate + 'update' => 'Update available', // @todo translate ), 'stats' => array( '_' => 'İstatistikler', diff --git a/app/i18n/zh-cn/admin.php b/app/i18n/zh-cn/admin.php index 4ecc52e64..ca18bf63d 100644 --- a/app/i18n/zh-cn/admin.php +++ b/app/i18n/zh-cn/admin.php @@ -112,6 +112,13 @@ return array( ), 'title' => '扩展', 'user' => '用户扩展', + 'community' => 'Available community extensions', // @todo translate + 'name' => 'Name', // @todo translate + 'version' => 'Version', // @todo translate + 'description' => 'Description', // @todo translate + 'author' => 'Author', // @todo translate + 'latest' => 'Installed', // @todo translate + 'update' => 'Update available', // @todo translate ), 'stats' => array( '_' => '统计', diff --git a/app/views/extension/index.phtml b/app/views/extension/index.phtml index 7cb16bfff..6439a0333 100644 --- a/app/views/extension/index.phtml +++ b/app/views/extension/index.phtml @@ -26,13 +26,46 @@ } ?> <?php - } + } - if (empty($this->extension_list['system']) && empty($this->extension_list['user'])) { + if (empty($this->extension_list['system']) && empty($this->extension_list['user'])) { ?> <p class="alert alert-warn"><?php echo _t('admin.extensions.empty_list'); ?></p> <?php } ?> </form> + + <?php if (!empty($this->available_extensions)) { ?> + <h2><?php echo _t('admin.extensions.community'); ?></h2> + <table> + <tr> + <th><?php echo _t('admin.extensions.name'); ?></th> + <th><?php echo _t('admin.extensions.version'); ?></th> + <th><?php echo _t('admin.extensions.author'); ?></th> + <th><?php echo _t('admin.extensions.description'); ?></th> + </tr> + <?php foreach ($this->available_extensions as $ext) { ?> + <tr> + <td><a href="<?php echo $ext['url']; ?>" target="_blank"><?php echo $ext['name']; ?></a></td> + <td><?php echo $ext['version']; ?></td> + <td><?php echo $ext['author']; ?></td> + <td> + <?php echo $ext['description']; ?> + <?php if (isset($this->extensions_installed[$ext['name']])) { ?> + <?php if (version_compare($this->extensions_installed[$ext['name']], $ext['version']) >= 0) { ?> + <span class="alert alert-success"> + <?php echo _t('admin.extensions.latest'); ?> + </span> + <?php } else if ($this->extensions_installed[$ext['name']] != $ext['version']) { ?> + <span class="alert alert-warn"> + <?php echo _t('admin.extensions.update'); ?> + </span> + <?php } ?> + <?php } ?> + </td> + </tr> + <?php } ?> + </table> + <?php } ?> </div> <?php $class = isset($this->extension) ? ' class="active"' : ''; ?> |
