A free, self-hostable news aggregator…
Show existing extensions in admin panel (#1708)
Kevin Papst3902d3f43330
diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phpindex 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.phtmlindex 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"' : ''; ?>