A free, self-hostable news aggregator…
Fix extension interface
Marien Fressinaud2f1116818d7d
diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.phpindex 5dd7eac89..ec5eecadb 100644--- a/app/Controllers/extensionController.php+++ b/app/Controllers/extensionController.php@@ -20,7 +20,15 @@ class FreshRSS_extension_Controller extends Minz_ActionController {*/public function indexAction() {Minz_View::prependTitle(_t('admin.extensions.title') . ' · ');- $this->view->extension_list = Minz_ExtensionManager::list_extensions();+ $this->view->extension_list = array(+ 'system' => array(),+ 'user' => array(),+ );++ $extensions = Minz_ExtensionManager::list_extensions();+ foreach ($extensions as $ext) {+ $this->view->extension_list[$ext->getType()][] = $ext;+ }}/**@@ -36,6 +44,9 @@ class FreshRSS_extension_Controller extends Minz_ActionController {public function configureAction() {if (Minz_Request::param('ajax')) {$this->view->_useLayout(false);+ } else {+ $this->indexAction();+ $this->view->change_view('extension', 'index');}$ext_name = urldecode(Minz_Request::param('e'));diff --git a/app/i18n/en/admin.php b/app/i18n/en/admin.phpindex 3161683a8..947d0e6c7 100644--- a/app/i18n/en/admin.php+++ b/app/i18n/en/admin.php@@ -103,10 +103,16 @@ return array(),),'extensions' => array(+ 'disabled' => 'Disabled','empty_list' => 'There is no installed extension',+ 'enabled' => 'Enabled','no_configure_view' => 'This extension cannot be configured.',- 'system' => 'System extension (you have no rights on it)',+ 'system' => array(+ '_' => 'System extensions',+ 'no_rights' => 'System extension (you have no rights on it)',+ ),'title' => 'Extensions',+ 'user' => 'User extensions',),'stats' => array('_' => 'Statistics',diff --git a/app/i18n/fr/admin.php b/app/i18n/fr/admin.phpindex 3d69e4daf..980f1fccf 100644--- a/app/i18n/fr/admin.php+++ b/app/i18n/fr/admin.php@@ -103,10 +103,16 @@ return array(),),'extensions' => array(+ 'disabled' => 'Désactivée','empty_list' => 'Il n’y a aucune extension installée.',+ 'enabled' => 'Activée','no_configure_view' => 'Cette extension ne peut pas être configurée.',- 'system' => 'Extension système (vous n’avez aucun droit dessus)',+ 'system' => array(+ '_' => 'Extensions système',+ 'no_rights' => 'Extension système (vous n’avez aucun droit dessus)',+ ),'title' => 'Extensions',+ 'user' => 'Extensions utilisateur',),'stats' => array('_' => 'Statistiques',diff --git a/app/views/extension/configure.phtml b/app/views/extension/configure.phtmlindex c03439a75..8933eeae5 100644--- a/app/views/extension/configure.phtml+++ b/app/views/extension/configure.phtml@@ -1,23 +1,3 @@<?php-if (!Minz_Request::param('ajax')) {- $this->partial('aside_configure');-}--?>--<div class="post">- <h1><?php echo $this->extension->getName(); ?> (<?php echo $this->extension->getVersion(); ?>) — <?php echo $this->extension->getType(); ?></h1>-- <p class="alert alert-warn"><?php echo $this->extension->getDescription(); ?> — <?php echo _t('gen.short.by_author', $this->extension->getAuthor()); ?></p>-- <h2><?php echo _t('gen.action.manage'); ?></h2>- <?php- $configure_view = $this->extension->getConfigureView();- if ($configure_view !== false) {- echo $configure_view;- } else {- ?>- <p class="alert alert-warn"><?php echo _t('admin.extensions.no_configure_view'); ?></p>- <?php } ?>-</div>+$this->renderHelper('extension/configure');diff --git a/app/views/extension/index.phtml b/app/views/extension/index.phtmlindex 25b0eb9ee..f2d05028f 100644--- a/app/views/extension/index.phtml+++ b/app/views/extension/index.phtml@@ -5,35 +5,40 @@<h1><?php echo _t('admin.extensions.title'); ?></h1>- <?php if (!empty($this->extension_list)) { ?><form id="form-extension" method="post" style="display: none"></form>- <?php foreach ($this->extension_list as $ext) { ?>- <ul class="horizontal-list">- <li class="item">- <?php if ($ext->getType() === 'user' || FreshRSS_Auth::hasAccess('admin')) { ?>- <?php $name_encoded = urlencode($ext->getName()); ?>- <div class="stick">- <a class="btn open-slider" href="<?php echo _url('extension', 'configure', 'e', $name_encoded); ?>"><?php echo _i('configure'); ?> <?php echo _t('gen.action.manage'); ?></a>- <?php if ($ext->isEnabled()) { ?>- <button class="btn active" form="form-extension" formaction="<?php echo _url('extension', 'disable', 'e', $name_encoded); ?>"><?php echo _t('gen.action.disable'); ?></button>- <?php } else { ?>- <button class="btn" form="form-extension" formaction="<?php echo _url('extension', 'enable', 'e', $name_encoded); ?>"><?php echo _t('gen.action.enable'); ?></button>- <?php } ?>- <?php if (FreshRSS_Auth::hasAccess('admin')) { ?>- <button class="btn btn-attention confirm" form="form-extension" formaction="<?php echo _url('extension', 'remove', 'e', $name_encoded); ?>"><?php echo _t('gen.action.remove'); ?></button>- <?php } ?>- </div>- <?php } else { ?>- <?php echo _t('admin.extensions.system'); ?>- <?php } ?>- </li>- <li class="item"><?php echo $ext->getName(); ?></li>- </ul>+ <?php if (!empty($this->extension_list['system'])) { ?>+ <h2><?php echo _t('admin.extensions.system'); ?></h2>+ <?php+ foreach ($this->extension_list['system'] as $ext) {+ $this->ext_details = $ext;+ $this->renderHelper('extension/details');+ }+ ?><?php } ?>- <?php } else { ?>++ <?php if (!empty($this->extension_list['user'])) { ?>+ <h2><?php echo _t('admin.extensions.user'); ?></h2>+ <?php+ foreach ($this->extension_list['user'] as $ext) {+ $this->ext_details = $ext;+ $this->renderHelper('extension/details');+ }+ ?>+ <?php+ }++ 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 } ?></div>-<a href="#" id="close-slider"></a>-<div id="slider"></div>+<?php $class = isset($this->extension) ? ' class="active"' : ''; ?>+<a href="#" id="close-slider"<?php echo $class; ?>></a>+<div id="slider"<?php echo $class; ?>>+<?php+ if (isset($this->extension)) {+ $this->renderHelper('extension/configure');+ }+?>+</div>diff --git a/app/views/helpers/extension/configure.phtml b/app/views/helpers/extension/configure.phtmlnew file mode 100644index 000000000..95d968aba--- /dev/null+++ b/app/views/helpers/extension/configure.phtml@@ -0,0 +1,19 @@+<div class="post">+ <h1>+ <?php echo $this->extension->getName(); ?> (<?php echo $this->extension->getVersion(); ?>) —+ <?php echo $this->extension->isEnabled() ? _t('admin.extensions.enabled')+ : _t('admin.extensions.disabled'); ?>+ </h1>++ <p class="alert alert-warn"><?php echo $this->extension->getDescription(); ?> — <?php echo _t('gen.short.by_author', $this->extension->getAuthor()); ?></p>++ <h2><?php echo _t('gen.action.manage'); ?></h2>+ <?php+ $configure_view = $this->extension->getConfigureView();+ if ($configure_view !== false) {+ echo $configure_view;+ } else {+ ?>+ <p class="alert alert-warn"><?php echo _t('admin.extensions.no_configure_view'); ?></p>+ <?php } ?>+</div>diff --git a/app/views/helpers/extension/details.phtml b/app/views/helpers/extension/details.phtmlnew file mode 100644index 000000000..acba4e816--- /dev/null+++ b/app/views/helpers/extension/details.phtml@@ -0,0 +1,21 @@+<ul class="horizontal-list">+ <li class="item">+ <?php if ($this->ext_details->getType() === 'user' || FreshRSS_Auth::hasAccess('admin')) { ?>+ <?php $name_encoded = urlencode($this->ext_details->getName()); ?>+ <div class="stick">+ <a class="btn open-slider" href="<?php echo _url('extension', 'configure', 'e', $name_encoded); ?>"><?php echo _i('configure'); ?> <?php echo _t('gen.action.manage'); ?></a>+ <?php if ($this->ext_details->isEnabled()) { ?>+ <button class="btn active" form="form-extension" formaction="<?php echo _url('extension', 'disable', 'e', $name_encoded); ?>"><?php echo _t('gen.action.disable'); ?></button>+ <?php } else { ?>+ <button class="btn" form="form-extension" formaction="<?php echo _url('extension', 'enable', 'e', $name_encoded); ?>"><?php echo _t('gen.action.enable'); ?></button>+ <?php } ?>+ <?php if (FreshRSS_Auth::hasAccess('admin')) { ?>+ <button class="btn btn-attention confirm" form="form-extension" formaction="<?php echo _url('extension', 'remove', 'e', $name_encoded); ?>"><?php echo _t('gen.action.remove'); ?></button>+ <?php } ?>+ </div>+ <?php } else { ?>+ <?php echo _t('admin.extensions.system.no_rights'); ?>+ <?php } ?>+ </li>+ <li class="item"><?php echo $this->ext_details->getName(); ?></li>+</ul>