Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add server plugins page. Recovered partially from Drizzle support
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
- Loading branch information
Showing
5 changed files
with
319 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* vim: set expandtab sw=4 ts=4 sts=4: */ | ||
/** | ||
* Functions used in server plugins pages | ||
*/ | ||
AJAX.registerOnload('server_plugins.js', function () { | ||
// 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]], | ||
headers: { | ||
1: {sorter: false} | ||
}, | ||
widgets: ['zebra'] | ||
}); | ||
$tables.find('thead th') | ||
.append('<div class="sorticon"></div>'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
/* vim: set expandtab sw=4 ts=4 sts=4: */ | ||
|
||
/** | ||
* functions for displaying server plugins | ||
* | ||
* @usedby server_plugins.php | ||
* | ||
* @package PhpMyAdmin | ||
*/ | ||
if (! defined('PHPMYADMIN')) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Returns the common SQL used to retrieve plugin data | ||
* | ||
* @return string SQL | ||
*/ | ||
function PMA_getServerPluginSQL() | ||
{ | ||
return "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"; | ||
} | ||
|
||
/** | ||
* Returns details about server plugins | ||
* | ||
* @return array server plugins data | ||
*/ | ||
function PMA_getServerPlugins() | ||
{ | ||
$sql = PMA_getServerPluginSQL(); | ||
$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 the html for plugin Tab. | ||
* | ||
* @param Array $plugins list | ||
* | ||
* @return string | ||
*/ | ||
function PMA_getPluginTab($plugins) | ||
{ | ||
$html = '<br /><div id="plugins_plugins">'; | ||
$html .= '<div id="sectionlinks">'; | ||
|
||
foreach ($plugins as $plugin_type => $plugin_list) { | ||
$key = 'plugins-' | ||
. preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type)); | ||
$html .= '<a href="#' . $key . '">' | ||
. htmlspecialchars($plugin_type) . '</a>' . "\n"; | ||
} | ||
|
||
$html .= '</div>'; | ||
$html .= '<br />'; | ||
|
||
foreach ($plugins as $plugin_type => $plugin_list) { | ||
$key = 'plugins-' | ||
. preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type)); | ||
sort($plugin_list); | ||
|
||
$html .= '<table class="data_full_width" id="' . $key . '">'; | ||
$html .= '<caption class="tblHeaders">'; | ||
$html .= htmlspecialchars($plugin_type); | ||
$html .= '</caption>'; | ||
$html .= '<thead>'; | ||
$html .= '<tr>'; | ||
$html .= '<th>' . __('Plugin') . '</th>'; | ||
$html .= '<th>' . __('Description') . '</th>'; | ||
$html .= '<th>' . __('Version') . '</th>'; | ||
$html .= '<th>' . __('Author') . '</th>'; | ||
$html .= '<th>' . __('License') . '</th>'; | ||
$html .= '</tr>'; | ||
$html .= '</thead>'; | ||
$html .= '<tbody>'; | ||
|
||
$html .= PMA_getPluginList($plugin_list); | ||
|
||
$html .= '</tbody>'; | ||
$html .= '</table>'; | ||
} | ||
$html .= '</div>'; | ||
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 .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">'; | ||
$html .= '<th>'; | ||
$html .= htmlspecialchars($plugin['plugin_name']); | ||
if (! $plugin['is_active']) { | ||
$html .= ' <small class="attention">' . __('disabled') . '</small>'; | ||
} | ||
$html .= '</th>'; | ||
$html .= '<td>' . htmlspecialchars($plugin['plugin_description']) . '</td>'; | ||
$html .= '<td>' . htmlspecialchars($plugin['plugin_type_version']) . '</td>'; | ||
$html .= '<td>' . htmlspecialchars($plugin['plugin_author']) . '</td>'; | ||
$html .= '<td>' . htmlspecialchars($plugin['plugin_license']) . '</td>'; | ||
$html .= '</tr>'; | ||
} | ||
return $html; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/* vim: set expandtab sw=4 ts=4 sts=4: */ | ||
/** | ||
* object the server plugin page | ||
* | ||
* @package PhpMyAdmin | ||
*/ | ||
|
||
/** | ||
* requirements | ||
*/ | ||
require_once 'libraries/common.inc.php'; | ||
|
||
/** | ||
* JS includes | ||
*/ | ||
$response = PMA_Response::getInstance(); | ||
$header = $response->getHeader(); | ||
$scripts = $header->getScripts(); | ||
$scripts->addFile('jquery/jquery.tablesorter.js'); | ||
$scripts->addFile('server_plugins.js'); | ||
|
||
/** | ||
* 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_getPluginTab($plugins)); | ||
|
||
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?php | ||
/* vim: set expandtab sw=4 ts=4 sts=4: */ | ||
/** | ||
* tests for server_plugins.lib.php | ||
* | ||
* @package PhpMyAdmin-test | ||
*/ | ||
|
||
/* | ||
* Include to test. | ||
*/ | ||
require_once 'libraries/Util.class.php'; | ||
require_once 'libraries/php-gettext/gettext.inc'; | ||
require_once 'libraries/url_generating.lib.php'; | ||
require_once 'libraries/server_plugins.lib.php'; | ||
require_once 'libraries/Theme.class.php'; | ||
require_once 'libraries/database_interface.inc.php'; | ||
require_once 'libraries/Message.class.php'; | ||
require_once 'libraries/sanitizing.lib.php'; | ||
require_once 'libraries/js_escape.lib.php'; | ||
|
||
/** | ||
* PMA_ServerPlugins_Test class | ||
* | ||
* this class is for testing server_plugins.lib.php functions | ||
* | ||
* @package PhpMyAdmin-test | ||
*/ | ||
class PMA_ServerPlugins_Test extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Prepares environment for the test. | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
//$_REQUEST | ||
$_REQUEST['log'] = "index1"; | ||
$_REQUEST['pos'] = 3; | ||
|
||
//$GLOBALS | ||
$GLOBALS['cfg']['MaxRows'] = 10; | ||
$GLOBALS['cfg']['ServerDefault'] = "server"; | ||
$GLOBALS['cfg']['RememberSorting'] = true; | ||
$GLOBALS['cfg']['SQP'] = array(); | ||
$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; | ||
$GLOBALS['cfg']['ShowSQL'] = true; | ||
$GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; | ||
$GLOBALS['cfg']['LimitChars'] = 100; | ||
$GLOBALS['cfg']['DBG']['sql'] = false; | ||
|
||
$GLOBALS['table'] = "table"; | ||
$GLOBALS['pmaThemeImage'] = 'image'; | ||
|
||
//$_SESSION | ||
$_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); | ||
$_SESSION['PMA_Theme'] = new PMA_Theme(); | ||
} | ||
|
||
/** | ||
* Test for PMA_getPluginAndModuleInfo | ||
* | ||
* @return void | ||
*/ | ||
public function testPMAGetPluginAndModuleInfo() | ||
{ | ||
//Mock DBI | ||
$dbi = $this->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"; | ||
$row["plugin_type_version"] = "plugin_version1"; | ||
$row["plugin_author"] = "plugin_author1"; | ||
$row["plugin_license"] = "plugin_license1"; | ||
$row["plugin_description"] = "plugin_description1"; | ||
$row["is_active"] = true; | ||
$plugins[$row['plugin_type']][] = $row; | ||
|
||
$html = PMA_getPluginTab($plugins); | ||
|
||
//validate 1:Items | ||
$this->assertContains( | ||
'<th>Plugin</th>', | ||
$html | ||
); | ||
$this->assertContains( | ||
'<th>Description</th>', | ||
$html | ||
); | ||
$this->assertContains( | ||
'<th>Version</th>', | ||
$html | ||
); | ||
$this->assertContains( | ||
'<th>Author</th>', | ||
$html | ||
); | ||
$this->assertContains( | ||
'<th>License</th>', | ||
$html | ||
); | ||
|
||
//validate 2: one Item HTML | ||
$this->assertContains( | ||
'<th>plugin_name1</th>', | ||
$html | ||
); | ||
$this->assertContains( | ||
'<td>plugin_description1</td>', | ||
$html | ||
); | ||
$this->assertContains( | ||
'<td>plugin_type_version1</td>', | ||
$html | ||
); | ||
$this->assertContains( | ||
'<td>plugin_author1</td>', | ||
$html | ||
); | ||
$this->assertContains( | ||
'<td>plugin_license1</td>', | ||
$html | ||
); | ||
} | ||
} |