Add page to show the list of plugins

This commit is contained in:
Frederic Guillot 2015-09-26 15:57:39 -04:00
parent 47c1bc9652
commit 9ca4b43a97
30 changed files with 194 additions and 2 deletions

View File

@ -77,6 +77,19 @@ class Config extends Base
)));
}
/**
* Display the plugin page
*
* @access public
*/
public function plugins()
{
$this->response->html($this->layout('config/plugins', array(
'plugins' => $this->pluginLoader->plugins,
'title' => t('Settings').' > '.t('Plugins'),
)));
}
/**
* Display the application settings page
*

View File

@ -23,6 +23,7 @@ use Pimple\Container;
* @property \Core\ObjectStorage\ObjectStorageInterface $objectStorage
* @property \Core\Cache\Cache $memoryCache
* @property \Core\Plugin\Hook $hook
* @property \Core\Plugin\Loader $pluginLoader
* @property \Integration\BitbucketWebhook $bitbucketWebhook
* @property \Integration\GithubWebhook $githubWebhook
* @property \Integration\GitlabWebhook $gitlabWebhook

View File

@ -44,4 +44,56 @@ abstract class Base extends \Core\Base
call_user_func($callback, $container);
});
}
/**
* Get plugin name
*
* This method should be overrided by your Plugin class
*
* @access public
* @return string
*/
public function getPluginName()
{
return ucfirst(substr(get_called_class(), 7, -7));
}
/**
* Get plugin description
*
* This method should be overrided by your Plugin class
*
* @access public
* @return string
*/
public function getPluginDescription()
{
return '';
}
/**
* Get plugin author
*
* This method should be overrided by your Plugin class
*
* @access public
* @return string
*/
public function getPluginAuthor()
{
return '?';
}
/**
* Get plugin version
*
* This method should be overrided by your Plugin class
*
* @access public
* @return string
*/
public function getPluginVersion()
{
return '?';
}
}

View File

@ -21,6 +21,14 @@ class Loader extends \Core\Base
*/
const TABLE_SCHEMA = 'plugin_schema_versions';
/**
* Plugin instances
*
* @access public
* @var array
*/
public $plugins = array();
/**
* Scan plugin folder and load plugins
*
@ -55,6 +63,7 @@ class Loader extends \Core\Base
Tool::buildDic($this->container, $instance->getClasses());
$instance->initialize();
$this->plugins[] = $instance;
}
/**

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
'Table of contents' => 'Tabla de contenido',
'Gantt' => 'Gantt',
'Help with project permissions' => 'Ayuda con permisos del proyecto',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1014,4 +1014,8 @@ return array(
'Table of contents' => 'Table des matières',
'Gantt' => 'Gantt',
'Help with project permissions' => 'Aide avec les permissions des projets',
'Author' => 'Auteur',
'Version' => 'Version',
'Plugins' => 'Extensions',
'There is no plugin loaded.' => 'Il n\'y a aucune extension chargée.',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
'Table of contents' => 'Daftar isi',
'Gantt' => 'Gantt',
'Help with project permissions' => 'Bantuan dengan izin proyek',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
'Table of contents' => 'Innholdsfortegnelse',
'Gantt' => 'Gantt',
'Help with project permissions' => 'Hjelp med prosjekttilganger',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
'Table of contents' => 'Índice',
'Gantt' => 'Gantt',
'Help with project permissions' => 'Ajuda com as permissões dos projetos',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
'Table of contents' => 'Tabela de conteúdos',
'Gantt' => 'Gantt',
'Help with project permissions' => 'Ajuda com permissões de projecto',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
'Table of contents' => 'Сожержание',
'Gantt' => 'Гантт',
'Help with project permissions' => 'Помощь с правами доступа по проекту',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -1012,4 +1012,8 @@ return array(
// 'Table of contents' => '',
// 'Gantt' => '',
// 'Help with project permissions' => '',
// 'Author' => '',
// 'Version' => '',
// 'Plugins' => '',
// 'There is no plugin loaded.' => '',
);

View File

@ -2,6 +2,7 @@
namespace ServiceProvider;
use Core\Plugin\Loader;
use Core\ObjectStorage\FileStorage;
use Core\Paginator;
use Core\OAuth2;
@ -117,5 +118,7 @@ class ClassProvider implements ServiceProviderInterface
$container['objectStorage'] = function() {
return new FileStorage(FILES_DIR);
};
$container['pluginLoader'] = new Loader($container);
}
}

View File

@ -0,0 +1,24 @@
<div class="page-header">
<h2><?= t('Plugins') ?></h2>
</div>
<?php if (empty($plugins)): ?>
<p class="alert"><?= t('There is no plugin loaded.') ?></p>
<?php else: ?>
<table class="table-stripped">
<tr>
<th class="column-20"><?= t('Name') ?></th>
<th class="column-20"><?= t('Author') ?></th>
<th class="column-10"><?= t('Version') ?></th>
<th><?= t('Description') ?></th>
</tr>
<?php foreach($plugins as $plugin): ?>
<tr>
<td><?= $this->e($plugin->getPluginName()) ?></td>
<td><?= $this->e($plugin->getPluginAuthor()) ?></td>
<td><?= $this->e($plugin->getPluginVersion()) ?></td>
<td><?= $this->e($plugin->getPluginDescription()) ?></td>
</tr>
<?php endforeach ?>
<?php endif ?>

View File

@ -4,6 +4,9 @@
<li <?= $this->app->getRouterAction() === 'index' ? 'class="active"' : '' ?>>
<?= $this->url->link(t('About'), 'config', 'index') ?>
</li>
<li <?= $this->app->getRouterAction() === 'plugins' ? 'class="active"' : '' ?>>
<?= $this->url->link(t('Plugins'), 'config', 'plugins') ?>
</li>
<li <?= $this->app->getRouterAction() === 'application' ? 'class="active"' : '' ?>>
<?= $this->url->link(t('Application settings'), 'config', 'application') ?>
</li>

View File

@ -33,5 +33,4 @@ if (ENABLE_URL_REWRITE) {
require __DIR__.'/routes.php';
}
$plugin = new Core\Plugin\Loader($container);
$plugin->scan();
$container['pluginLoader']->scan();

View File

@ -70,6 +70,10 @@ Available methods from `Core\Plugin\Base`:
- `initialize()`: Executed when the plugin is loaded
- `getClasses()`: Return all classes that should be stored in the dependency injection container
- `on($event, $callback)`: Listen on internal events
- `getPluginName()`: Get plugin name
- `getPluginAuthor()`: Get plugin author
- `getPluginVersion()`: Get plugin version
- `getPluginDescription()`: Get plugin description
Your plugin registration class also inherit from `Core\Base`, that means you can access to all classes and methods of Kanboard easily.