diff --git a/libraries/classes/Server/Status/Processes.php b/libraries/classes/Server/Status/Processes.php
new file mode 100644
index 0000000000..7cb59745a8
--- /dev/null
+++ b/libraries/classes/Server/Status/Processes.php
@@ -0,0 +1,311 @@
+getDisplay();
+ $retval = $notice . '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= Util::getImage('play.png') . __('Start auto refresh');
+ $retval .= '';
+ $retval .= '
';
+ return $retval;
+ }
+
+ /**
+ * Prints Server Process list
+ *
+ * @return string
+ */
+ public static function getHtmlForServerProcesslist()
+ {
+ $url_params = array();
+
+ $show_full_sql = ! empty($_REQUEST['full']);
+ if ($show_full_sql) {
+ $url_params['full'] = 1;
+ $full_text_link = 'server_status_processes.php' . Url::getCommon(
+ array(), '?'
+ );
+ } else {
+ $full_text_link = 'server_status_processes.php' . Url::getCommon(
+ array('full' => 1)
+ );
+ }
+
+ // This array contains display name and real column name of each
+ // sortable column in the table
+ $sortable_columns = array(
+ array(
+ 'column_name' => __('ID'),
+ 'order_by_field' => 'Id'
+ ),
+ array(
+ 'column_name' => __('User'),
+ 'order_by_field' => 'User'
+ ),
+ array(
+ 'column_name' => __('Host'),
+ 'order_by_field' => 'Host'
+ ),
+ array(
+ 'column_name' => __('Database'),
+ 'order_by_field' => 'db'
+ ),
+ array(
+ 'column_name' => __('Command'),
+ 'order_by_field' => 'Command'
+ ),
+ array(
+ 'column_name' => __('Time'),
+ 'order_by_field' => 'Time'
+ ),
+ array(
+ 'column_name' => __('Status'),
+ 'order_by_field' => 'State'
+ ),
+ array(
+ 'column_name' => __('Progress'),
+ 'order_by_field' => 'Progress'
+ ),
+ array(
+ 'column_name' => __('SQL query'),
+ 'order_by_field' => 'Info'
+ )
+ );
+ $sortableColCount = count($sortable_columns);
+
+ $sql_query = $show_full_sql
+ ? 'SHOW FULL PROCESSLIST'
+ : 'SHOW PROCESSLIST';
+ if ((! empty($_REQUEST['order_by_field'])
+ && ! empty($_REQUEST['sort_order']))
+ || (! empty($_REQUEST['showExecuting']))
+ ) {
+ $sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ';
+ }
+ if (! empty($_REQUEST['showExecuting'])) {
+ $sql_query .= ' WHERE state != "" ';
+ }
+ if (!empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order'])) {
+ $sql_query .= ' ORDER BY '
+ . Util::backquote($_REQUEST['order_by_field'])
+ . ' ' . $_REQUEST['sort_order'];
+ }
+
+ $result = $GLOBALS['dbi']->query($sql_query);
+
+ $retval = '';
+ $retval .= '
';
+ $retval .= '
';
+
+ return $retval;
+ }
+
+ /**
+ * Returns the html for the list filter
+ *
+ * @return string
+ */
+ public static function getHtmlForProcessListFilter()
+ {
+ $showExecuting = '';
+ if (! empty($_REQUEST['showExecuting'])) {
+ $showExecuting = ' checked="checked"';
+ }
+
+ $url_params = array(
+ 'ajax_request' => true,
+ 'full' => (isset($_REQUEST['full']) ? $_REQUEST['full'] : ''),
+ 'column_name' => (isset($_REQUEST['column_name']) ? $_REQUEST['column_name'] : ''),
+ 'order_by_field'
+ => (isset($_REQUEST['order_by_field']) ? $_REQUEST['order_by_field'] : ''),
+ 'sort_order' => (isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : ''),
+ );
+
+ $retval = '';
+ $retval .= '';
+
+ return $retval;
+ }
+
+ /**
+ * Prints Every Item of Server Process
+ *
+ * @param array $process data of Every Item of Server Process
+ * @param bool $show_full_sql show full sql or not
+ *
+ * @return string
+ */
+ public static function getHtmlForServerProcessItem($process, $show_full_sql)
+ {
+ // Array keys need to modify due to the way it has used
+ // to display column values
+ if ((! empty($_REQUEST['order_by_field']) && ! empty($_REQUEST['sort_order']))
+ || (! empty($_REQUEST['showExecuting']))
+ ) {
+ foreach (array_keys($process) as $key) {
+ $new_key = ucfirst(mb_strtolower($key));
+ if ($new_key !== $key) {
+ $process[$new_key] = $process[$key];
+ unset($process[$key]);
+ }
+ }
+ }
+
+ $url_params = array(
+ 'kill' => $process['Id'],
+ 'ajax_request' => true
+ );
+ $kill_process = 'server_status_processes.php' . Url::getCommon($url_params);
+
+ $retval = '';
+ $retval .= '| '
+ . __('Kill') . ' | ';
+ $retval .= '' . $process['Id'] . ' | ';
+ $retval .= '' . htmlspecialchars($process['User']) . ' | ';
+ $retval .= '' . htmlspecialchars($process['Host']) . ' | ';
+ $retval .= '' . ((! isset($process['db'])
+ || strlen($process['db']) === 0)
+ ? '' . __('None') . ''
+ : htmlspecialchars($process['db'])) . ' | ';
+ $retval .= '' . htmlspecialchars($process['Command']) . ' | ';
+ $retval .= '' . $process['Time'] . ' | ';
+ $processStatusStr = empty($process['State']) ? '---' : $process['State'];
+ $retval .= '' . $processStatusStr . ' | ';
+ $processProgress = empty($process['Progress']) ? '---' : $process['Progress'];
+ $retval .= '' . $processProgress . ' | ';
+ $retval .= '';
+
+ if (empty($process['Info'])) {
+ $retval .= '---';
+ } else {
+ $retval .= Util::formatSql($process['Info'], ! $show_full_sql);
+ }
+ $retval .= ' | ';
+ $retval .= '
';
+
+ return $retval;
+ }
+}
diff --git a/libraries/server_status_processes.lib.php b/libraries/server_status_processes.lib.php
deleted file mode 100644
index 42c02f8cf6..0000000000
--- a/libraries/server_status_processes.lib.php
+++ /dev/null
@@ -1,301 +0,0 @@
-getDisplay();
- $retval = $notice . '';
- $retval .= '
';
- $retval .= '
';
- $retval .= Util::getImage('play.png') . __('Start auto refresh');
- $retval .= '';
- $retval .= '
';
- return $retval;
-}
-
-/**
- * Prints Server Process list
- *
- * @return string
- */
-function PMA_getHtmlForServerProcesslist()
-{
- $url_params = array();
-
- $show_full_sql = ! empty($_REQUEST['full']);
- if ($show_full_sql) {
- $url_params['full'] = 1;
- $full_text_link = 'server_status_processes.php' . Url::getCommon(
- array(), '?'
- );
- } else {
- $full_text_link = 'server_status_processes.php' . Url::getCommon(
- array('full' => 1)
- );
- }
-
- // This array contains display name and real column name of each
- // sortable column in the table
- $sortable_columns = array(
- array(
- 'column_name' => __('ID'),
- 'order_by_field' => 'Id'
- ),
- array(
- 'column_name' => __('User'),
- 'order_by_field' => 'User'
- ),
- array(
- 'column_name' => __('Host'),
- 'order_by_field' => 'Host'
- ),
- array(
- 'column_name' => __('Database'),
- 'order_by_field' => 'db'
- ),
- array(
- 'column_name' => __('Command'),
- 'order_by_field' => 'Command'
- ),
- array(
- 'column_name' => __('Time'),
- 'order_by_field' => 'Time'
- ),
- array(
- 'column_name' => __('Status'),
- 'order_by_field' => 'State'
- ),
- array(
- 'column_name' => __('Progress'),
- 'order_by_field' => 'Progress'
- ),
- array(
- 'column_name' => __('SQL query'),
- 'order_by_field' => 'Info'
- )
- );
- $sortableColCount = count($sortable_columns);
-
- $sql_query = $show_full_sql
- ? 'SHOW FULL PROCESSLIST'
- : 'SHOW PROCESSLIST';
- if ((! empty($_REQUEST['order_by_field'])
- && ! empty($_REQUEST['sort_order']))
- || (! empty($_REQUEST['showExecuting']))
- ) {
- $sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ';
- }
- if (! empty($_REQUEST['showExecuting'])) {
- $sql_query .= ' WHERE state != "" ';
- }
- if (!empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order'])) {
- $sql_query .= ' ORDER BY '
- . Util::backquote($_REQUEST['order_by_field'])
- . ' ' . $_REQUEST['sort_order'];
- }
-
- $result = $GLOBALS['dbi']->query($sql_query);
-
- $retval = '';
- $retval .= '
';
- $retval .= '
';
-
- return $retval;
-}
-
-/**
- * Returns the html for the list filter
- *
- * @return string
- */
-function PMA_getHtmlForProcessListFilter()
-{
- $showExecuting = '';
- if (! empty($_REQUEST['showExecuting'])) {
- $showExecuting = ' checked="checked"';
- }
-
- $url_params = array(
- 'ajax_request' => true,
- 'full' => (isset($_REQUEST['full']) ? $_REQUEST['full'] : ''),
- 'column_name' => (isset($_REQUEST['column_name']) ? $_REQUEST['column_name'] : ''),
- 'order_by_field'
- => (isset($_REQUEST['order_by_field']) ? $_REQUEST['order_by_field'] : ''),
- 'sort_order' => (isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : ''),
- );
-
- $retval = '';
- $retval .= '';
-
- return $retval;
-}
-
-/**
- * Prints Every Item of Server Process
- *
- * @param array $process data of Every Item of Server Process
- * @param bool $show_full_sql show full sql or not
- *
- * @return string
- */
-function PMA_getHtmlForServerProcessItem($process, $show_full_sql)
-{
- // Array keys need to modify due to the way it has used
- // to display column values
- if ((! empty($_REQUEST['order_by_field']) && ! empty($_REQUEST['sort_order']))
- || (! empty($_REQUEST['showExecuting']))
- ) {
- foreach (array_keys($process) as $key) {
- $new_key = ucfirst(mb_strtolower($key));
- if ($new_key !== $key) {
- $process[$new_key] = $process[$key];
- unset($process[$key]);
- }
- }
- }
-
- $url_params = array(
- 'kill' => $process['Id'],
- 'ajax_request' => true
- );
- $kill_process = 'server_status_processes.php' . Url::getCommon($url_params);
-
- $retval = '';
- $retval .= '| '
- . __('Kill') . ' | ';
- $retval .= '' . $process['Id'] . ' | ';
- $retval .= '' . htmlspecialchars($process['User']) . ' | ';
- $retval .= '' . htmlspecialchars($process['Host']) . ' | ';
- $retval .= '' . ((! isset($process['db'])
- || strlen($process['db']) === 0)
- ? '' . __('None') . ''
- : htmlspecialchars($process['db'])) . ' | ';
- $retval .= '' . htmlspecialchars($process['Command']) . ' | ';
- $retval .= '' . $process['Time'] . ' | ';
- $processStatusStr = empty($process['State']) ? '---' : $process['State'];
- $retval .= '' . $processStatusStr . ' | ';
- $processProgress = empty($process['Progress']) ? '---' : $process['Progress'];
- $retval .= '' . $processProgress . ' | ';
- $retval .= '';
-
- if (empty($process['Info'])) {
- $retval .= '---';
- } else {
- $retval .= Util::formatSql($process['Info'], ! $show_full_sql);
- }
- $retval .= ' | ';
- $retval .= '
';
-
- return $retval;
-}
diff --git a/server_status_processes.php b/server_status_processes.php
index f24b26ed58..84165a6fe9 100644
--- a/server_status_processes.php
+++ b/server_status_processes.php
@@ -8,10 +8,10 @@
use PhpMyAdmin\Response;
use PhpMyAdmin\Server\Status\Data;
+use PhpMyAdmin\Server\Status\Processes;
require_once 'libraries/common.inc.php';
require_once 'libraries/server_common.inc.php';
-require_once 'libraries/server_status_processes.lib.php';
/**
* Replication library
@@ -47,7 +47,7 @@ if ($response->isAjax() && !empty($_REQUEST['kill'])) {
$response->addJSON('message', $message);
} elseif ($response->isAjax() && !empty($_REQUEST['refresh'])) {
// Only sends the process list table
- $response->addHTML(PMA_getHtmlForServerProcessList());
+ $response->addHTML(Processes::getHtmlForServerProcesslist());
} else {
// Load the full page
$header = $response->getHeader();
@@ -55,9 +55,9 @@ if ($response->isAjax() && !empty($_REQUEST['kill'])) {
$scripts->addFile('server_status_processes.js');
$response->addHTML('');
$response->addHTML($serverStatusData->getMenuHtml());
- $response->addHTML(PMA_getHtmlForProcessListFilter());
- $response->addHTML(PMA_getHtmlForServerProcesslist());
- $response->addHTML(PMA_getHtmlForProcessListAutoRefresh());
+ $response->addHTML(Processes::getHtmlForProcessListFilter());
+ $response->addHTML(Processes::getHtmlForServerProcesslist());
+ $response->addHTML(Processes::getHtmlForProcessListAutoRefresh());
$response->addHTML('
');
}
exit;
diff --git a/test/libraries/PMA_server_status_processes_test.php b/test/classes/Server/Status/ProcessesTest.php
similarity index 86%
rename from test/libraries/PMA_server_status_processes_test.php
rename to test/classes/Server/Status/ProcessesTest.php
index f73c39d3ba..935de31b33 100644
--- a/test/libraries/PMA_server_status_processes_test.php
+++ b/test/classes/Server/Status/ProcessesTest.php
@@ -1,26 +1,25 @@
assertContains(
@@ -91,7 +90,7 @@ class PMA_ServerStatusProcesses_Test extends PHPUnit_Framework_TestCase
}
/**
- * Test for PMA_getHtmlForServerProcesslist
+ * Test for Processes::getHtmlForServerProcesslist
*
* @return void
* @group medium
@@ -112,7 +111,7 @@ class PMA_ServerStatusProcesses_Test extends PHPUnit_Framework_TestCase
$GLOBALS['dbi']->expects($this->any())->method('fetchAssoc')
->will($this->onConsecutiveCalls($process));
- $html = PMA_getHtmlForServerProcesslist();
+ $html = Processes::getHtmlForServerProcesslist();
// Test process table
$this->assertContains(
@@ -137,7 +136,7 @@ class PMA_ServerStatusProcesses_Test extends PHPUnit_Framework_TestCase
$_REQUEST['sort_order'] = 'ASC';
$_REQUEST['order_by_field'] = 'db';
$_REQUEST['column_name'] = 'Database';
- $html = PMA_getHtmlForServerProcesslist();
+ $html = Processes::getHtmlForServerProcesslist();
$this->assertContains(
'Truncate Shown Queries',
@@ -155,7 +154,7 @@ class PMA_ServerStatusProcesses_Test extends PHPUnit_Framework_TestCase
$_REQUEST['sort_order'] = 'DESC';
$_REQUEST['order_by_field'] = 'Host';
$_REQUEST['column_name'] = 'Host';
- $html = PMA_getHtmlForServerProcesslist();
+ $html = Processes::getHtmlForServerProcesslist();
$this->assertContains(
'Host',
@@ -168,7 +167,7 @@ class PMA_ServerStatusProcesses_Test extends PHPUnit_Framework_TestCase
}
/**
- * Test for PMA_getHtmlForServerProcessItem
+ * Test for Processes::getHtmlForServerProcessItem
*
* @return void
*/
@@ -192,7 +191,7 @@ class PMA_ServerStatusProcesses_Test extends PHPUnit_Framework_TestCase
$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 12;
//Call the test function
- $html = PMA_getHtmlForServerProcessItem($process, $show_full_sql);
+ $html = Processes::getHtmlForServerProcessItem($process, $show_full_sql);
//validate 1: $kill_process
$url_params = array(
@@ -257,7 +256,7 @@ class PMA_ServerStatusProcesses_Test extends PHPUnit_Framework_TestCase
);
unset($process['info']);
- $html = PMA_getHtmlForServerProcessItem($process, $show_full_sql);
+ $html = Processes::getHtmlForServerProcessItem($process, $show_full_sql);
$this->assertContains(
'---',