diff --git a/db_operations.php b/db_operations.php
index 174a36f09b..19744a7075 100644
--- a/db_operations.php
+++ b/db_operations.php
@@ -12,6 +12,7 @@
* @package PhpMyAdmin
*/
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Display\CreateTable;
use PhpMyAdmin\Message;
use PhpMyAdmin\Operations;
use PhpMyAdmin\Plugins\Export\ExportSql;
@@ -23,7 +24,6 @@ use PhpMyAdmin\Util;
* requirements
*/
require_once 'libraries/common.inc.php';
-require_once 'libraries/display_create_table.lib.php';
/**
* functions implementation for this script
@@ -247,7 +247,7 @@ if (!$is_information_schema) {
}
$response->addHTML('
');
- $response->addHTML(PMA_getHtmlForCreateTable($db));
+ $response->addHTML(CreateTable::getHtml($db));
$response->addHTML('
');
/**
diff --git a/db_tracking.php b/db_tracking.php
index 32cbbe7ad7..2b059343c3 100644
--- a/db_tracking.php
+++ b/db_tracking.php
@@ -5,6 +5,7 @@
*
* @package PhpMyAdmin
*/
+use PhpMyAdmin\Display\CreateTable;
use PhpMyAdmin\Message;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
@@ -16,7 +17,6 @@ use PhpMyAdmin\Util;
* Run common work
*/
require_once 'libraries/common.inc.php';
-require_once 'libraries/display_create_table.lib.php';
//Get some js files needed for Ajax requests
$response = Response::getInstance();
@@ -105,7 +105,7 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) {
echo '' , __('No tables found in database.') , '
' , "\n";
if (empty($db_is_system_schema)) {
- echo PMA_getHtmlForCreateTable($db);
+ echo CreateTable::getHtml($db);
}
exit;
}
diff --git a/import_status.php b/import_status.php
index 415052c83b..02e39d45ca 100644
--- a/import_status.php
+++ b/import_status.php
@@ -7,6 +7,7 @@
*/
use PhpMyAdmin\Core;
+use PhpMyAdmin\Display\ImportAjax;
/* PHP 5.4 stores upload progress data only in the default session.
* After calling session_name(), we won't find the progress data anymore.
@@ -51,12 +52,11 @@ if (ini_get('session.upload_progress.enabled')) {
define('PMA_MINIMUM_COMMON', 1);
require_once 'libraries/common.inc.php';
-require_once 'libraries/display_import_ajax.lib.php';
list(
$SESSION_KEY,
$upload_id,
$plugins
-) = PMA_uploadProgressSetup();
+) = ImportAjax::uploadProgressSetup();
/*
if (defined('SESSIONUPLOAD')) {
@@ -117,5 +117,5 @@ if (isset($_GET["message"]) && $_GET["message"]) {
echo '' , "\n";
} else {
- PMA_importAjaxStatus($_GET["id"]);
+ ImportAjax::status($_GET["id"]);
}
diff --git a/index.php b/index.php
index 8c36ea173e..b67f5402fa 100644
--- a/index.php
+++ b/index.php
@@ -8,6 +8,7 @@
use PhpMyAdmin\Charsets;
use PhpMyAdmin\Core;
+use PhpMyAdmin\Display\GitRevision;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\Message;
use PhpMyAdmin\RecentFavoriteTable;
@@ -22,11 +23,6 @@ use PhpMyAdmin\Url;
*/
require_once 'libraries/common.inc.php';
-/**
- * display Git revision if requested
- */
-require_once 'libraries/display_git_revision.lib.php';
-
/**
* pass variables to child pages
*/
@@ -98,7 +94,7 @@ if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
if ($GLOBALS['PMA_Config']->isGitRevision()) {
if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
- PMA_printGitRevision();
+ GitRevision::print();
exit;
}
echo '';
diff --git a/js/functions.js b/js/functions.js
index bfffac67f0..5dfd74ba63 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -604,7 +604,7 @@ function PMA_display_git_revision()
}
/**
- * for libraries/display_change_password.lib.php
+ * for PhpMyAdmin\Display\ChangePassword
* libraries/user_password.php
*
*/
@@ -2893,7 +2893,7 @@ AJAX.registerTeardown('functions.js', function () {
/**
* jQuery coding for 'Create Table'. Used on db_operations.php,
* db_structure.php and db_tracking.php (i.e., wherever
- * libraries/display_create_table.lib.php is used)
+ * PhpMyAdmin\Display\CreateTable is used)
*
* Attach Ajax Event handlers for Create Table
*/
diff --git a/libraries/classes/Controllers/Database/DatabaseStructureController.php b/libraries/classes/Controllers/Database/DatabaseStructureController.php
index 3377473327..ea1b0904b6 100644
--- a/libraries/classes/Controllers/Database/DatabaseStructureController.php
+++ b/libraries/classes/Controllers/Database/DatabaseStructureController.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\Charsets;
use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\Controllers\DatabaseController;
use PhpMyAdmin\Core;
+use PhpMyAdmin\Display\CreateTable;
use PhpMyAdmin\Message;
use PhpMyAdmin\RecentFavoriteTable;
use PhpMyAdmin\Relation;
@@ -23,8 +24,6 @@ use PhpMyAdmin\Tracker;
use PhpMyAdmin\Util;
use PhpMyAdmin\Url;
-require_once 'libraries/display_create_table.lib.php';
-
/**
* Handles database structure logic
*
@@ -150,7 +149,7 @@ class DatabaseStructureController extends DatabaseController
Message::notice(__('No tables found in database.'))
);
if (empty($this->_db_is_system_schema)) {
- $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
+ $this->response->addHTML(CreateTable::getHtml($this->db));
}
return;
}
@@ -210,7 +209,7 @@ class DatabaseStructureController extends DatabaseController
);
if (empty($this->_db_is_system_schema)) {
- $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
+ $this->response->addHTML(CreateTable::getHtml($this->db));
}
}
diff --git a/libraries/classes/Display/ChangePassword.php b/libraries/classes/Display/ChangePassword.php
new file mode 100644
index 0000000000..4284b80915
--- /dev/null
+++ b/libraries/classes/Display/ChangePassword.php
@@ -0,0 +1,165 @@
+';
+
+ $html .= Url::getHiddenInputs();
+
+ if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
+ $html .= ''
+ . '';
+ }
+ $html .= ''
+ . ''
+ . '';
+ return $html;
+ }
+}
diff --git a/libraries/display_create_table.lib.php b/libraries/classes/Display/CreateTable.php
similarity index 74%
rename from libraries/display_create_table.lib.php
rename to libraries/classes/Display/CreateTable.php
index 5b68de8191..649083b44b 100644
--- a/libraries/display_create_table.lib.php
+++ b/libraries/classes/Display/CreateTable.php
@@ -24,25 +24,30 @@
*
* @package PhpMyAdmin
*/
-if (! defined('PHPMYADMIN')) {
- exit;
-}
+namespace PhpMyAdmin\Display;
+
+use PhpMyAdmin\Template;
-/**
- *
- */
require_once './libraries/check_user_privileges.lib.php';
/**
- * Returns the html for create table.
+ * PhpMyAdmin\Display\CreateTable class
*
- * @param string $db database name
- *
- * @return string
+ * @package PhpMyAdmin
*/
-function PMA_getHtmlForCreateTable($db)
+class CreateTable
{
- return PhpMyAdmin\Template::get('database/create_table')->render(
- array('db' => $db)
- );
+ /**
+ * Returns the html for create table.
+ *
+ * @param string $db database name
+ *
+ * @return string
+ */
+ public static function getHtml($db)
+ {
+ return Template::get('database/create_table')->render(
+ array('db' => $db)
+ );
+ }
}
diff --git a/libraries/classes/Display/GitRevision.php b/libraries/classes/Display/GitRevision.php
new file mode 100644
index 0000000000..f20939e6e2
--- /dev/null
+++ b/libraries/classes/Display/GitRevision.php
@@ -0,0 +1,97 @@
+get('PMA_VERSION_GIT')) {
+ $response = Response::getInstance();
+ $response->setRequestStatus(false);
+ return;
+ }
+
+ // load revision data from repo
+ $GLOBALS['PMA_Config']->checkGitRevision();
+
+ // if using a remote commit fast-forwarded, link to GitHub
+ $commit_hash = substr(
+ $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'),
+ 0,
+ 7
+ );
+ $commit_hash = '' . $commit_hash . '';
+ if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
+ $commit_hash = '' . $commit_hash . '';
+ }
+
+ $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
+ if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
+ $branch = '' . $branch . '';
+ }
+ if ($branch !== false) {
+ $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
+ } else {
+ $branch = $commit_hash . ' (' . __('no branch') . ')';
+ }
+
+ $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
+ $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
+ PMA_printListItem(
+ __('Git revision:') . ' '
+ . $branch . ',
'
+ . sprintf(
+ __('committed on %1$s by %2$s'),
+ Util::localisedDate(strtotime($committer['date'])),
+ ''
+ . htmlspecialchars($committer['name']) . ''
+ )
+ . ($author != $committer
+ ? ',
'
+ . sprintf(
+ __('authored on %1$s by %2$s'),
+ Util::localisedDate(strtotime($author['date'])),
+ ''
+ . htmlspecialchars($author['name']) . ''
+ )
+ : ''),
+ 'li_pma_version_git', null, null, null
+ );
+ }
+}
diff --git a/libraries/classes/Display/Import.php b/libraries/classes/Display/Import.php
index bd9775fef9..65a4c8a97a 100644
--- a/libraries/classes/Display/Import.php
+++ b/libraries/classes/Display/Import.php
@@ -9,6 +9,7 @@ namespace PhpMyAdmin\Display;
use PhpMyAdmin\Charsets;
use PhpMyAdmin\Core;
+use PhpMyAdmin\Display\ImportAjax;
use PhpMyAdmin\Encoding;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\ImportPlugin;
@@ -652,11 +653,10 @@ class Import
include_once './libraries/file_listing.lib.php';
include_once './libraries/plugin_interface.lib.php';
- include_once './libraries/display_import_ajax.lib.php';
list(
$SESSION_KEY,
$upload_id,
- ) = PMA_uploadProgressSetup();
+ ) = ImportAjax::uploadProgressSetup();
/* Scan for plugins */
/* @var $import_list ImportPlugin[] */
diff --git a/libraries/classes/Display/ImportAjax.php b/libraries/classes/Display/ImportAjax.php
new file mode 100644
index 0000000000..acebebad3d
--- /dev/null
+++ b/libraries/classes/Display/ImportAjax.php
@@ -0,0 +1,141 @@
+';
-
- $html .= Url::getHiddenInputs();
-
- if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
- $html .= ''
- . '';
- }
- $html .= ''
- . ''
- . '';
- return $html;
-}
diff --git a/libraries/display_git_revision.lib.php b/libraries/display_git_revision.lib.php
deleted file mode 100644
index c2f3521e5f..0000000000
--- a/libraries/display_git_revision.lib.php
+++ /dev/null
@@ -1,87 +0,0 @@
-get('PMA_VERSION_GIT')) {
- $response = Response::getInstance();
- $response->setRequestStatus(false);
- return;
- }
-
- // load revision data from repo
- $GLOBALS['PMA_Config']->checkGitRevision();
-
- // if using a remote commit fast-forwarded, link to GitHub
- $commit_hash = substr(
- $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'),
- 0,
- 7
- );
- $commit_hash = '' . $commit_hash . '';
- if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
- $commit_hash = '' . $commit_hash . '';
- }
-
- $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
- if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
- $branch = '' . $branch . '';
- }
- if ($branch !== false) {
- $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
- } else {
- $branch = $commit_hash . ' (' . __('no branch') . ')';
- }
-
- $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
- $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
- PMA_printListItem(
- __('Git revision:') . ' '
- . $branch . ',
'
- . sprintf(
- __('committed on %1$s by %2$s'),
- PhpMyAdmin\Util::localisedDate(strtotime($committer['date'])),
- ''
- . htmlspecialchars($committer['name']) . ''
- )
- . ($author != $committer
- ? ',
'
- . sprintf(
- __('authored on %1$s by %2$s'),
- PhpMyAdmin\Util::localisedDate(strtotime($author['date'])),
- ''
- . htmlspecialchars($author['name']) . ''
- )
- : ''),
- 'li_pma_version_git', null, null, null
- );
-}
diff --git a/libraries/display_import_ajax.lib.php b/libraries/display_import_ajax.lib.php
deleted file mode 100644
index 79119036ab..0000000000
--- a/libraries/display_import_ajax.lib.php
+++ /dev/null
@@ -1,137 +0,0 @@
-isAjax() && ! isset($_POST['ajax_page_request'])) {
* If we are in grid editing, we need to process the relational and
* transformed fields, if they were edited. After that, output the correct
* link/transformed value and exit
- *
- * Logic taken from libraries/DisplayResults.php
*/
-
if (isset($_REQUEST['rel_fields_list']) && $_REQUEST['rel_fields_list'] != '') {
$map = Relation::getForeigners($db, $table, '', 'both');
diff --git a/test/libraries/PMA_display_change_password_test.php b/test/classes/Display/ChangePasswordTest.php
similarity index 79%
rename from test/libraries/PMA_display_change_password_test.php
rename to test/classes/Display/ChangePasswordTest.php
index 1881ed3749..1c37d3fcab 100644
--- a/test/libraries/PMA_display_change_password_test.php
+++ b/test/classes/Display/ChangePasswordTest.php
@@ -1,31 +1,27 @@
enableBc();
$GLOBALS['cfg']['MaxRows'] = 10;
$GLOBALS['cfg']['ServerDefault'] = "PMA_server";
@@ -55,17 +51,17 @@ class PMA_DisplayChangePassword_Test extends PHPUnit_Framework_TestCase
}
/**
- * Test for PMA_getHtmlForChangePassword
+ * Test for ChangePassword::getHtml
*
* @return void
*/
- public function testPMAGetHtmlForChangePassword()
+ public function testGetHtml()
{
$username = "pma_username";
$hostname = "pma_hostname";
//Call the test function
- $html = PMA_getHtmlForChangePassword('change_pw', $username, $hostname);
+ $html = ChangePassword::getHtml('change_pw', $username, $hostname);
//PMA_PHP_SELF
$this->assertContains(
diff --git a/test/libraries/PMA_display_create_table_test.php b/test/classes/Display/CreateTableTest.php
similarity index 75%
rename from test/libraries/PMA_display_create_table_test.php
rename to test/classes/Display/CreateTableTest.php
index 39b2b4d540..40977257b2 100644
--- a/test/libraries/PMA_display_create_table_test.php
+++ b/test/classes/Display/CreateTableTest.php
@@ -1,31 +1,25 @@
assertContains(
- PhpMyAdmin\Util::getImage('b_table_add.png'),
+ Util::getImage('b_table_add.png'),
$html
);
diff --git a/test/classes/DisplayResultsTest.php b/test/classes/Display/ResultsTest.php
similarity index 98%
rename from test/classes/DisplayResultsTest.php
rename to test/classes/Display/ResultsTest.php
index 9816b6293e..f3eb93260a 100644
--- a/test/classes/DisplayResultsTest.php
+++ b/test/classes/Display/ResultsTest.php
@@ -4,14 +4,21 @@
*
* @package PhpMyAdmin-test
*/
+namespace PhpMyAdmin\Tests\Display;
+
+use PhpMyAdmin\Config;
+use PhpMyAdmin\Core;
+use PhpMyAdmin\Display\Results as DisplayResults;
+use PhpMyAdmin\Plugins\Transformations\Text_Plain_Link;
+use PhpMyAdmin\SqlParser\Parser;
+use PhpMyAdmin\SqlParser\Utils\Query;
+use PhpMyAdmin\Transformations;
+use ReflectionClass;
+use stdClass;
/*
- * Include to test.
- */
-use PhpMyAdmin\Core;
-use PhpMyAdmin\DisplayResults;
-use PhpMyAdmin\Plugins\Transformations\Text_Plain_Link;
-
+* Include to test.
+*/
require_once 'test/PMATestCase.php';
/**
@@ -19,7 +26,7 @@ require_once 'test/PMATestCase.php';
*
* @package PhpMyAdmin-test
*/
-class DisplayResultsTest extends PMATestCase
+class ResultsTest extends \PMATestCase
{
/**
* @access protected
@@ -37,7 +44,7 @@ class DisplayResultsTest extends PMATestCase
{
$GLOBALS['server'] = 0;
$this->object = new DisplayResults('as', '', '', '');
- $GLOBALS['PMA_Config'] = new PhpMyAdmin\Config();
+ $GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['collation_connection'] = 'utf-8';
@@ -87,7 +94,7 @@ class DisplayResultsTest extends PMATestCase
*/
public function testisSelect()
{
- $parser = new \PhpMyAdmin\SqlParser\Parser('SELECT * FROM pma');
+ $parser = new Parser('SELECT * FROM pma');
$this->assertTrue(
$this->_callPrivateFunction(
'_isSelect',
@@ -1211,7 +1218,7 @@ class DisplayResultsTest extends PMATestCase
*/
public function dataProviderForTestSetHighlightedColumnGlobalField()
{
- $parser = new PhpMyAdmin\SqlParser\Parser(
+ $parser = new Parser(
'SELECT * FROM db_name WHERE `db_name`.`tbl`.id > 0 AND `id` < 10'
);
return array(
@@ -1301,7 +1308,7 @@ class DisplayResultsTest extends PMATestCase
public function dataProviderForTestHandleNonPrintableContents()
{
$transformation_plugin = new Text_Plain_Link();
- $meta = new StdClass();
+ $meta = new stdClass();
$meta->type = 'BLOB';
$meta->orgtable = 'bar';
$url_params = array('db' => 'foo', 'table' => 'bar');
@@ -1434,7 +1441,7 @@ class DisplayResultsTest extends PMATestCase
public function dataProviderForTestGetDataCellForNonNumericColumns()
{
$transformation_plugin = new Text_Plain_Link();
- $meta = new StdClass();
+ $meta = new stdClass();
$meta->db = 'foo';
$meta->table = 'tbl';
$meta->orgtable = 'tbl';
@@ -1443,7 +1450,7 @@ class DisplayResultsTest extends PMATestCase
$meta->name = 'tblob';
$meta->orgname = 'tblob';
- $meta2 = new StdClass();
+ $meta2 = new stdClass();
$meta2->db = 'foo';
$meta2->table = 'tbl';
$meta2->orgtable = 'tbl';
@@ -1608,7 +1615,7 @@ class DisplayResultsTest extends PMATestCase
$this->object->__set('fields_cnt', 2);
// Field meta information
- $meta = new StdClass();
+ $meta = new stdClass();
$meta->db = 'db';
$meta->table = 'table';
$meta->orgtable = 'table';
@@ -1620,7 +1627,7 @@ class DisplayResultsTest extends PMATestCase
$meta->numeric = true;
$meta->primary_key = false;
$meta->unique_key = false;
- $meta2 = new StdClass();
+ $meta2 = new stdClass();
$meta2->db = 'db';
$meta2->table = 'table';
$meta2->orgtable = 'table';
@@ -1652,7 +1659,7 @@ class DisplayResultsTest extends PMATestCase
);
$this->object->__set(
'mime_map',
- \PhpMyAdmin\Transformations::getMIME('db', 'table')
+ Transformations::getMIME('db', 'table')
);
// Actually invoke tested method
@@ -1661,7 +1668,7 @@ class DisplayResultsTest extends PMATestCase
array(
&$result, array(3600, true), 0, false, array(),
'', false, $query,
- PhpMyAdmin\SqlParser\Utils\Query::getAll($query)
+ Query::getAll($query)
)
);
diff --git a/user_password.php b/user_password.php
index 1654d33c9a..7eaba6db7c 100644
--- a/user_password.php
+++ b/user_password.php
@@ -8,9 +8,10 @@
*/
use PhpMyAdmin\Core;
-use PhpMyAdmin\Url;
+use PhpMyAdmin\Display\ChangePassword;
use PhpMyAdmin\Response;
use PhpMyAdmin\Server\Privileges;
+use PhpMyAdmin\Url;
/**
* Gets some core libraries
@@ -67,9 +68,7 @@ if (isset($msg)) {
unset($msg);
}
-require_once './libraries/display_change_password.lib.php';
-
-echo PMA_getHtmlForChangePassword('change_pw', $username, $hostname);
+echo ChangePassword::getHtml('change_pw', $username, $hostname);
exit;
/**