diff options
-rw-r--r-- | js/server_plugins.js | 18 | ||||
-rw-r--r-- | libraries/Menu.class.php | 7 | ||||
-rw-r--r-- | libraries/server_plugins.lib.php | 100 | ||||
-rw-r--r-- | server_modules.php | 31 | ||||
-rw-r--r-- | server_plugins.php | 28 | ||||
-rw-r--r-- | test/libraries/PMA_server_plugins_test.php | 35 |
6 files changed, 136 insertions, 83 deletions
diff --git a/js/server_plugins.js b/js/server_plugins.js index 4867bda938..dc63827fec 100644 --- a/js/server_plugins.js +++ b/js/server_plugins.js @@ -2,24 +2,8 @@ /** * Functions used in server plugins pages */ -var pma_theme_image; // filled in server_plugins.php - AJAX.registerOnload('server_plugins.js', function () { - // Add tabs - $('#pluginsTabs').tabs({ - // Tab persistence - cookie: { name: 'pma_serverStatusTabs', expires: 1 }, - show: function (event, ui) { - // Fixes line break in the menu bar when the page overflows and scrollbar appears - $('#topmenu').menuResizer('resize'); - // 'Plugins' tab is too high due to hiding of 'Modules' by negative left position, - // hide tabs by changing display to fix it - $(ui.panel).closest('.ui-tabs').find('> div').not(ui.panel).css('display', 'none'); - $(ui.panel).css('display', 'block'); - } - }); - - // Make columns sortable, but only for tables with more than 1 data row + // Make columns sortable, but only for tables with more than 1 data row var $tables = $('#plugins_plugins table:has(tbody tr + tr)'); $tables.tablesorter({ sortList: [[0, 0]], diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 5472ce32b7..51ee5ee1bf 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -612,6 +612,13 @@ class PMA_Menu $tabs['plugins']['icon'] = 'b_engine.png'; $tabs['plugins']['link'] = 'server_plugins.php'; $tabs['plugins']['text'] = __('Plugins'); + $tabs['plugins']['active'] = in_array( + basename($GLOBALS['PMA_PHP_SELF']), + array( + 'server_plugins.php', + 'server_modules.php', + ) + ); } else { $tabs['engine']['icon'] = 'b_engine.png'; $tabs['engine']['link'] = 'server_engines.php'; diff --git a/libraries/server_plugins.lib.php b/libraries/server_plugins.lib.php index 7c978f6c3c..a09c2a7884 100644 --- a/libraries/server_plugins.lib.php +++ b/libraries/server_plugins.lib.php @@ -13,28 +13,94 @@ if (! defined('PHPMYADMIN')) { } /** - * Returns the html for plugin and module Info. + * Get the HTML for the sub tabs * - * @param Array $plugins Plugin list + * @param string $activeUrl url of the active sub tab * - * @param Array $modules Module list + * @return string HTML for sub tabs + */ +function PMA_getHtmlForPluginsSubTabs($activeUrl) +{ + $url_params = PMA_URL_getCommon(); + $items = array( + array( + 'name' => __('Plugins'), + 'url' => 'server_plugins.php' + ), + array( + 'name' => __('Modules'), + 'url' => 'server_modules.php' + ) + ); + + $retval = '<ul id="topmenu2">'; + foreach ($items as $item) { + $class = ''; + if ($item['url'] === $activeUrl) { + $class = ' class="tabactive"'; + } + $retval .= '<li>'; + $retval .= '<a' . $class; + $retval .= ' href="' . $item['url'] . $url_params . '">'; + $retval .= $item['name']; + $retval .= '</a>'; + $retval .= '</li>'; + } + $retval .= '</ul>'; + $retval .= '<div class="clearfloat"></div>'; + + return $retval; +} + +/** + * Returns the common SQL used to retrieve plugin and modules data * - * @return string + * @return string SQL */ -function PMA_getPluginAndModuleInfo($plugins, $modules) +function PMA_getServerPluginModuleSQL() { - $html = '<script type="text/javascript">'; - $html .= 'pma_theme_image = "' . $GLOBALS['pmaThemeImage'] . '"'; - $html .= '</script>'; - $html .= '<div id="pluginsTabs">'; - $html .= '<ul>'; - $html .= '<li><a href="#plugins_plugins">' . __('Plugins') . '</a></li>'; - $html .= '<li><a href="#plugins_modules">' . __('Modules') . '</a></li>'; - $html .= '</ul>'; - $html .= PMA_getPluginTab($plugins); - $html .= PMA_getModuleTab($modules); - $html .= '</div>'; - return $html; + return "SELECT p.plugin_name, p.plugin_type, p.is_active, m.module_name, + m.module_library, m.module_version, m.module_author, + m.module_description, m.module_license + FROM data_dictionary.plugins p + JOIN data_dictionary.modules m USING (module_name) + ORDER BY m.module_name, p.plugin_type, p.plugin_name"; +} + +/** + * Returns details about server plugins + * + * @return array server plugins data + */ +function PMA_getServerPlugins() +{ + $sql = PMA_getServerPluginModuleSQL(); + $res = $GLOBALS['dbi']->query($sql); + $plugins = array(); + while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { + $plugins[$row['plugin_type']][] = $row; + } + $GLOBALS['dbi']->freeResult($res); + ksort($plugins); + return $plugins; +} + +/** + * Returns details about server modules + * + * @return array server modules data + */ +function PMA_getServerModules() +{ + $sql = PMA_getServerPluginModuleSQL(); + $res = $GLOBALS['dbi']->query($sql); + $modules = array(); + while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { + $modules[$row['module_name']]['info'] = $row; + $modules[$row['module_name']]['plugins'][$row['plugin_type']][] = $row; + } + $GLOBALS['dbi']->freeResult($res); + return $modules; } /** diff --git a/server_modules.php b/server_modules.php new file mode 100644 index 0000000000..b167b9f133 --- /dev/null +++ b/server_modules.php @@ -0,0 +1,31 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * object the server modules page + * + * @package PhpMyAdmin + */ + +/** + * requirements + */ +require_once 'libraries/common.inc.php'; + +/** + * Does the common work + */ +require 'libraries/server_common.inc.php'; +require 'libraries/server_plugins.lib.php'; + +$modules = PMA_getServerModules(); + +/** + * Displays the page + */ +$response = PMA_Response::getInstance(); +$response->addHTML('<div>'); +$response->addHTML(PMA_getHtmlForPluginsSubTabs('server_modules.php')); +$response->addHTML(PMA_getModuleTab($modules)); +$response->addHTML('</div>'); + +exit; diff --git a/server_plugins.php b/server_plugins.php index 480ddeec2d..11654b8f8d 100644 --- a/server_plugins.php +++ b/server_plugins.php @@ -26,32 +26,14 @@ $scripts->addFile('server_plugins.js'); require 'libraries/server_common.inc.php'; require 'libraries/server_plugins.lib.php'; -/** - * Prepare plugin list - */ -$sql = "SELECT p.plugin_name, p.plugin_type, p.is_active, m.module_name, - m.module_library, m.module_version, m.module_author, - m.module_description, m.module_license - FROM data_dictionary.plugins p - JOIN data_dictionary.modules m USING (module_name) - ORDER BY m.module_name, p.plugin_type, p.plugin_name"; -$res = $GLOBALS['dbi']->query($sql); -$plugins = array(); -$modules = array(); -while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { - $plugins[$row['plugin_type']][] = $row; - $modules[$row['module_name']]['info'] = $row; - $modules[$row['module_name']]['plugins'][$row['plugin_type']][] = $row; -} -$GLOBALS['dbi']->freeResult($res); - -// sort plugin list (modules are already sorted) -ksort($plugins); +$plugins = PMA_getServerPlugins(); /** * Displays the page */ -$response->addHTML(PMA_getHtmlForSubPageHeader('plugins')); -$response->addHTML(PMA_getPluginAndModuleInfo($plugins, $modules)); +$response->addHTML('<div>'); +$response->addHTML(PMA_getHtmlForPluginsSubTabs('server_plugins.php')); +$response->addHTML(PMA_getPluginTab($plugins)); +$response->addHTML('</div>'); exit; diff --git a/test/libraries/PMA_server_plugins_test.php b/test/libraries/PMA_server_plugins_test.php index 300dadfec0..38412bc92d 100644 --- a/test/libraries/PMA_server_plugins_test.php +++ b/test/libraries/PMA_server_plugins_test.php @@ -79,7 +79,6 @@ class PMA_ServerPlugins_Test extends PHPUnit_Framework_TestCase */ $plugins = array(); - $modules = array(); $row = array(); $row["plugin_name"] = "plugin_name1"; @@ -92,22 +91,10 @@ class PMA_ServerPlugins_Test extends PHPUnit_Framework_TestCase $row["module_description"] = "module_description1"; $row["is_active"] = true; $plugins[$row['plugin_type']][] = $row; - $modules[$row['module_name']]['info'] = $row; - $modules[$row['module_name']]['plugins'][$row['plugin_type']][] = $row; - $html = PMA_getPluginAndModuleInfo($plugins, $modules); + $html = PMA_getPluginTab($plugins); - //validate 1: PMA_getPluginTab - $this->assertContains( - '<a href="#plugins_plugins">Plugins</a>', - $html - ); - //validate 2: PMA_getModuleTab - $this->assertContains( - '<a href="#plugins_modules">Modules</a>', - $html - ); - //validate 3:Items + //validate 1:Items $this->assertContains( '<th>Plugin</th>', $html @@ -117,18 +104,10 @@ class PMA_ServerPlugins_Test extends PHPUnit_Framework_TestCase $html ); $this->assertContains( - '<th>Plugin</th>', - $html - ); - $this->assertContains( '<th>Library</th>', $html ); $this->assertContains( - '<th>Plugin</th>', - $html - ); - $this->assertContains( '<th>Version</th>', $html ); @@ -141,12 +120,16 @@ class PMA_ServerPlugins_Test extends PHPUnit_Framework_TestCase $html ); - //validate 4: one Item HTML + //validate 2: one Item HTML $this->assertContains( '<th>plugin_name1</th>', $html ); $this->assertContains( + '<td>module_name1</td>', + $html + ); + $this->assertContains( '<td>module_library1</td>', $html ); @@ -155,11 +138,11 @@ class PMA_ServerPlugins_Test extends PHPUnit_Framework_TestCase $html ); $this->assertContains( - '<td>module_description1</td>', + '<td>module_author1</td>', $html ); $this->assertContains( - '<td>module_author1</td>', + '<td>module_license1</td>', $html ); } |