diff --git a/libraries/controllers/server/ServerPluginsController.php b/libraries/controllers/server/ServerPluginsController.php
new file mode 100644
index 0000000000..a824eb37d6
--- /dev/null
+++ b/libraries/controllers/server/ServerPluginsController.php
@@ -0,0 +1,106 @@
+_setServerPlugins();
+ }
+
+ /**
+ * Index action
+ *
+ * @return void
+ */
+ public function indexAction()
+ {
+ include 'libraries/server_common.inc.php';
+
+ $header = $this->response->getHeader();
+ $scripts = $header->getScripts();
+ $scripts->addFile('jquery/jquery.tablesorter.js');
+ $scripts->addFile('server_plugins.js');
+
+ /**
+ * Displays the page
+ */
+ $this->response->addHTML(PMA_getHtmlForSubPageHeader('plugins'));
+ $this->response->addHTML($this->_getPluginsHtml());
+ }
+
+ /**
+ * Sets details about server plugins
+ *
+ * @return void
+ */
+ private function _setServerPlugins()
+ {
+ $sql = "SELECT plugin_name,
+ plugin_type,
+ (plugin_status = 'ACTIVE') AS is_active,
+ plugin_type_version,
+ plugin_author,
+ plugin_description,
+ plugin_license
+ FROM information_schema.plugins
+ ORDER BY plugin_type, plugin_name";
+
+ $res = $this->dbi->query($sql);
+ $this->plugins = array();
+ while ($row = $this->dbi->fetchAssoc($res)) {
+ $this->plugins[$row['plugin_type']][] = $row;
+ }
+ $this->dbi->freeResult($res);
+ ksort($this->plugins);
+ }
+
+ /**
+ * Returns the html for plugin Tab.
+ *
+ * @return string
+ */
+ private function _getPluginsHtml()
+ {
+ $html = '
';
+ $html .= Template::get('server/plugins/section_links')
+ ->render(array('plugins' => $this->plugins));
+
+ foreach ($this->plugins as $plugin_type => $plugin_list) {
+ $html .= Template::get('server/plugins/section')
+ ->render(
+ array(
+ 'plugin_type' => $plugin_type,
+ 'plugin_list' => $plugin_list,
+ )
+ );
+ }
+ $html .= '
';
+ return $html;
+ }
+}
\ No newline at end of file
diff --git a/libraries/server_plugins.lib.php b/libraries/server_plugins.lib.php
deleted file mode 100644
index 350dd8a3aa..0000000000
--- a/libraries/server_plugins.lib.php
+++ /dev/null
@@ -1,120 +0,0 @@
-query($sql);
- $plugins = array();
- while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
- $plugins[$row['plugin_type']][] = $row;
- }
- $GLOBALS['dbi']->freeResult($res);
- ksort($plugins);
- return $plugins;
-}
-
-/**
- * Returns the html for plugin Tab.
- *
- * @param array $plugins list
- *
- * @return string
- */
-function PMA_getPluginTab($plugins)
-{
- $html = '';
- $html .= '
';
-
- foreach ($plugins as $plugin_type => $plugin_list) {
- $key = 'plugins-'
- . preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type));
- $html .= '
'
- . htmlspecialchars($plugin_type) . '' . "\n";
- }
-
- $html .= '
';
- $html .= '
';
-
- foreach ($plugins as $plugin_type => $plugin_list) {
- $key = 'plugins-'
- . preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type));
- sort($plugin_list);
-
- $html .= '
';
- $html .= '';
- $html .= '';
- $html .= '';
- $html .= '| ' . __('Plugin') . ' | ';
- $html .= '' . __('Description') . ' | ';
- $html .= '' . __('Version') . ' | ';
- $html .= '' . __('Author') . ' | ';
- $html .= '' . __('License') . ' | ';
- $html .= '
';
- $html .= '';
- $html .= '';
-
- $html .= PMA_getPluginList($plugin_list);
-
- $html .= '';
- $html .= '
';
- }
- $html .= '
';
- return $html;
-}
-
-/**
- * Returns the html for plugin List.
- *
- * @param array $plugin_list list
- *
- * @return string
- */
-function PMA_getPluginList($plugin_list)
-{
- $html = "";
- $odd_row = false;
- foreach ($plugin_list as $plugin) {
- $odd_row = !$odd_row;
- $html .= '';
- $html .= '| ';
- $html .= htmlspecialchars($plugin['plugin_name']);
- if (! $plugin['is_active']) {
- $html .= ' ' . __('disabled') . '';
- }
- $html .= ' | ';
- $html .= '' . htmlspecialchars($plugin['plugin_description']) . ' | ';
- $html .= '' . htmlspecialchars($plugin['plugin_type_version']) . ' | ';
- $html .= '' . htmlspecialchars($plugin['plugin_author']) . ' | ';
- $html .= '' . htmlspecialchars($plugin['plugin_license']) . ' | ';
- $html .= '
';
- }
- return $html;
-}
\ No newline at end of file
diff --git a/server_plugins.php b/server_plugins.php
index c7860ab192..4392eed835 100644
--- a/server_plugins.php
+++ b/server_plugins.php
@@ -1,38 +1,32 @@
getHeader();
-$scripts = $header->getScripts();
-$scripts->addFile('jquery/jquery.tablesorter.js');
-$scripts->addFile('server_plugins.js');
+$container = \PMA\libraries\di\Container::getDefaultContainer();
+$container->factory(
+ 'PMA\libraries\controllers\server\ServerPluginsController'
+);
+$container->alias(
+ 'ServerPluginsController',
+ 'PMA\libraries\controllers\server\ServerPluginsController'
+);
+$container->set('PMA\libraries\Response', Response::getInstance());
+$container->alias('response', 'PMA\libraries\Response');
-/**
- * Does the common work
- */
-require 'libraries/server_common.inc.php';
-require 'libraries/server_plugins.lib.php';
-
-$plugins = PMA_getServerPlugins();
-
-/**
- * Displays the page
- */
-$response->addHTML(PMA_getHtmlForSubPageHeader('plugins'));
-$response->addHTML(PMA_getPluginTab($plugins));
-
-exit;
+/** @var ServerPluginsController $controller */
+$controller = $container->get(
+ 'ServerPluginsController', array()
+);
+$controller->indexAction();
diff --git a/templates/server/plugins/section.phtml b/templates/server/plugins/section.phtml
new file mode 100644
index 0000000000..fdd1e77e65
--- /dev/null
+++ b/templates/server/plugins/section.phtml
@@ -0,0 +1,33 @@
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
\ No newline at end of file
diff --git a/templates/server/plugins/section_links.phtml b/templates/server/plugins/section_links.phtml
new file mode 100644
index 0000000000..054d6b37f8
--- /dev/null
+++ b/templates/server/plugins/section_links.phtml
@@ -0,0 +1,8 @@
+
+ $plugin_list): ?>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/libraries/PMA_server_plugins_test.php b/test/classes/controllers/ServerPluginsControllerTest.php
similarity index 70%
rename from test/libraries/PMA_server_plugins_test.php
rename to test/classes/controllers/ServerPluginsControllerTest.php
index a0ee8d0d69..e2a5dd00f8 100644
--- a/test/libraries/PMA_server_plugins_test.php
+++ b/test/classes/controllers/ServerPluginsControllerTest.php
@@ -1,7 +1,7 @@
getMockBuilder('PMA_DatabaseInterface')
- ->disableOriginalConstructor()
- ->getMock();
-
- $GLOBALS['dbi'] = $dbi;
-
- //Call the test function
/**
* Prepare plugin list
*/
-
- $plugins = array();
-
$row = array();
$row["plugin_name"] = "plugin_name1";
$row["plugin_type"] = "plugin_type1";
@@ -86,9 +73,34 @@ class PMA_ServerPlugins_Test extends PHPUnit_Framework_TestCase
$row["plugin_license"] = "plugin_license1";
$row["plugin_description"] = "plugin_description1";
$row["is_active"] = true;
- $plugins[$row['plugin_type']][] = $row;
- $html = PMA_getPluginTab($plugins);
+ //Mock DBI
+ $dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dbi->expects($this->once())
+ ->method('query')
+ ->will($this->returnValue(true));
+ $dbi->expects($this->at(1))
+ ->method('fetchAssoc')
+ ->will($this->returnValue($row));
+ $dbi->expects($this->at(2))
+ ->method('fetchAssoc')
+ ->will($this->returnValue(false));
+ $dbi->expects($this->once())
+ ->method('freeResult')
+ ->will($this->returnValue(true));
+
+ $container = Container::getDefaultContainer();
+ $container->set('dbi', $dbi);
+
+ $class = new ReflectionClass('\PMA\libraries\controllers\server\ServerPluginsController');
+ $method = $class->getMethod('_getPluginsHtml');
+ $method->setAccessible(true);
+
+ $ctrl = new ServerPluginsController();
+ $html = $method->invoke($ctrl);
//validate 1:Items
$this->assertContains(