diff --git a/index.php b/index.php
index ae12235b33..a4f7102470 100644
--- a/index.php
+++ b/index.php
@@ -9,15 +9,9 @@ declare(strict_types=1);
use PhpMyAdmin\Controllers\HomeController;
use PhpMyAdmin\Core;
-use PhpMyAdmin\Display\GitRevision;
-use PhpMyAdmin\Message;
-use PhpMyAdmin\RecentFavoriteTable;
-use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
-use PhpMyAdmin\ThemeManager;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
-use PhpMyAdmin\UserPreferences;
if (! defined('ROOT_PATH')) {
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
@@ -42,10 +36,9 @@ foreach ($drops as $each_drop) {
}
unset($drops, $each_drop);
-/*
+/**
* Black list of all scripts to which front-end must submit data.
* Such scripts must not be loaded on home page.
- *
*/
$target_blacklist = [
'import.php',
@@ -63,39 +56,32 @@ if (! empty($_REQUEST['target'])
exit;
}
+$response = Response::getInstance();
+
+$controller = new HomeController(
+ $response,
+ $GLOBALS['dbi'],
+ $GLOBALS['PMA_Config']
+);
+
if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
exit;
}
-// if user selected a theme
if (isset($_POST['set_theme'])) {
- $tmanager = ThemeManager::getInstance();
- $tmanager->setActiveTheme($_POST['set_theme']);
- $tmanager->setThemeCookie();
-
- $userPreferences = new UserPreferences();
- $prefs = $userPreferences->load();
- $prefs["config_data"]["ThemeDefault"] = $_POST['set_theme'];
- $userPreferences->save($prefs["config_data"]);
+ $controller->setTheme([
+ 'set_theme' => $_POST['set_theme'],
+ ]);
header('Location: index.php' . Url::getCommonRaw());
- exit();
-}
-// Change collation connection
-if (isset($_POST['collation_connection'])) {
- $GLOBALS['PMA_Config']->setUserValue(
- null,
- 'DefaultConnectionCollation',
- $_POST['collation_connection'],
- 'utf8mb4_unicode_ci'
- );
+} elseif (isset($_POST['collation_connection'])) {
+ $controller->setCollationConnection([
+ 'collation_connection' => $_POST['collation_connection'],
+ ]);
+
header('Location: index.php' . Url::getCommonRaw());
- exit();
-}
-
-
-// See FAQ 1.34
-if (! empty($_REQUEST['db'])) {
+} elseif (! empty($_REQUEST['db'])) {
+ // See FAQ 1.34
$page = null;
if (! empty($_REQUEST['table'])) {
$page = Util::getScriptNameForOption(
@@ -109,257 +95,22 @@ if (! empty($_REQUEST['db'])) {
);
}
include ROOT_PATH . $page;
- exit;
-}
-
-$response = Response::getInstance();
-
-$controller = new HomeController(
- $response,
- $GLOBALS['dbi']
-);
-
-/**
- * Check if it is an ajax request to reload the recent tables list.
- */
-if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
- $response->addJSON(
- 'list',
- RecentFavoriteTable::getInstance('recent')->getHtmlList()
- );
- exit;
-}
-
-if ($GLOBALS['PMA_Config']->isGitRevision()) {
- // If ajax request to get revision
- if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
- GitRevision::display();
- exit;
- }
- // Else show empty html
- echo '
';
-}
-
-// Handles some variables that may have been sent by the calling script
-$GLOBALS['db'] = '';
-$GLOBALS['table'] = '';
-$show_query = '1';
-
-// Any message to display?
-if (! empty($message)) {
- echo Util::getMessage($message);
- unset($message);
-}
-if (isset($_SESSION['partial_logout'])) {
- Message::success(
- __('You were logged out from one server, to logout completely from phpMyAdmin, you need to logout from all servers.')
- )->display();
- unset($_SESSION['partial_logout']);
-}
-
-if ($server > 0) {
- include ROOT_PATH . 'libraries/server_common.inc.php';
-}
-
-echo $controller->index();
-
-/**
- * mbstring is used for handling multibytes inside parser, so it is good
- * to tell user something might be broken without it, see bug #1063149.
- */
-if (! extension_loaded('mbstring')) {
- trigger_error(
- __(
- 'The mbstring PHP extension was not found and you seem to be using'
- . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
- . ' is unable to split strings correctly and it may result in'
- . ' unexpected results.'
- ),
- E_USER_WARNING
- );
-}
-
-/**
- * Missing functionality
- */
-if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
- trigger_error(
- __(
- 'The curl extension was not found and allow_url_fopen is '
- . 'disabled. Due to this some features such as error reporting '
- . 'or version check are disabled.'
- )
- );
-}
-
-if ($cfg['LoginCookieValidityDisableWarning'] == false) {
- /**
- * Check whether session.gc_maxlifetime limits session validity.
- */
- $gc_time = (int) ini_get('session.gc_maxlifetime');
- if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity']) {
- trigger_error(
- __(
- 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
- 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
- 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
- 'in phpMyAdmin, because of this, your login might expire sooner ' .
- 'than configured in phpMyAdmin.'
- ),
- E_USER_WARNING
- );
- }
-}
-
-/**
- * Check whether LoginCookieValidity is limited by LoginCookieStore.
- */
-if ($GLOBALS['cfg']['LoginCookieStore'] != 0
- && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
+} elseif ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
+ $response->addJSON($controller->reloadRecentTablesList());
+} elseif ($GLOBALS['PMA_Config']->isGitRevision()
+ && isset($_REQUEST['git_revision'])
+ && $response->isAjax()
) {
- trigger_error(
- __(
- 'Login cookie store is lower than cookie validity configured in ' .
- 'phpMyAdmin, because of this, your login will expire sooner than ' .
- 'configured in phpMyAdmin.'
- ),
- E_USER_WARNING
- );
-}
+ $response->addHTML($controller->gitRevision());
+} else {
+ // Handles some variables that may have been sent by the calling script
+ $GLOBALS['db'] = '';
+ $GLOBALS['table'] = '';
+ $show_query = '1';
-/**
- * Warning if using the default MySQL controluser account
- */
-if ($server != 0
- && isset($GLOBALS['cfg']['Server']['controluser']) && $GLOBALS['cfg']['Server']['controluser'] == 'pma'
- && isset($GLOBALS['cfg']['Server']['controlpass']) && $GLOBALS['cfg']['Server']['controlpass'] == 'pmapass'
-) {
- trigger_error(
- __('Your server is running with default values for the controluser and password (controlpass) and is open to intrusion; you really should fix this security weakness by changing the password for controluser \'pma\'.'),
- E_USER_WARNING
- );
-}
-
-
-/**
- * Check if user does not have defined blowfish secret and it is being used.
- */
-if (! empty($_SESSION['encryption_key'])) {
- if (empty($GLOBALS['cfg']['blowfish_secret'])) {
- trigger_error(
- __(
- 'The configuration file now needs a secret passphrase (blowfish_secret).'
- ),
- E_USER_WARNING
- );
- } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
- trigger_error(
- __(
- 'The secret passphrase in configuration (blowfish_secret) is too short.'
- ),
- E_USER_WARNING
- );
+ if ($server > 0) {
+ include ROOT_PATH . 'libraries/server_common.inc.php';
}
-}
-/**
- * Check for existence of config directory which should not exist in
- * production environment.
- */
-if (@file_exists(ROOT_PATH . 'config')) {
- trigger_error(
- __(
- 'Directory [code]config[/code], which is used by the setup script, ' .
- 'still exists in your phpMyAdmin directory. It is strongly ' .
- 'recommended to remove it once phpMyAdmin has been configured. ' .
- 'Otherwise the security of your server may be compromised by ' .
- 'unauthorized people downloading your configuration.'
- ),
- E_USER_WARNING
- );
-}
-
-$relation = new Relation($GLOBALS['dbi']);
-
-if ($server > 0) {
- $cfgRelation = $relation->getRelationsParam();
- if (! $cfgRelation['allworks']
- && $cfg['PmaNoRelation_DisableWarning'] == false
- ) {
- $msg_text = __(
- 'The phpMyAdmin configuration storage is not completely '
- . 'configured, some extended features have been deactivated. '
- . '%sFind out why%s. '
- );
- if ($cfg['ZeroConf'] == true) {
- $msg_text .= '
' .
- __(
- 'Or alternately go to \'Operations\' tab of any database '
- . 'to set it up there.'
- );
- }
- $msg = Message::notice($msg_text);
- $msg->addParamHtml('');
- $msg->addParamHtml('');
- /* Show error if user has configured something, notice elsewhere */
- if (! empty($cfg['Servers'][$server]['pmadb'])) {
- $msg->isError(true);
- }
- $msg->display();
- } // end if
-}
-
-/**
- * Warning about Suhosin only if its simulation mode is not enabled
- */
-if ($cfg['SuhosinDisableWarning'] == false
- && ini_get('suhosin.request.max_value_length')
- && ini_get('suhosin.simulation') == '0'
-) {
- trigger_error(
- sprintf(
- __(
- 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
- 'for possible issues.'
- ),
- '[doc@faq1-38]',
- '[/doc]'
- ),
- E_USER_WARNING
- );
-}
-
-/* Missing template cache */
-if (is_null($GLOBALS['PMA_Config']->getTempDir('twig'))) {
- trigger_error(
- sprintf(
- __('The $cfg[\'TempDir\'] (%s) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.'),
- $GLOBALS['PMA_Config']->get('TempDir')
- ),
- E_USER_WARNING
- );
-}
-
-/**
- * Warning about incomplete translations.
- *
- * The data file is created while creating release by ./scripts/remove-incomplete-mo
- */
-if (@file_exists(ROOT_PATH . 'libraries/language_stats.inc.php')) {
- include ROOT_PATH . 'libraries/language_stats.inc.php';
- /*
- * This message is intentionally not translated, because we're
- * handling incomplete translations here and focus on english
- * speaking users.
- */
- if (isset($GLOBALS['language_stats'][$lang])
- && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
- ) {
- trigger_error(
- 'You are using an incomplete translation, please help to make it '
- . 'better by [a@https://www.phpmyadmin.net/translate/'
- . '@_blank]contributing[/a].',
- E_USER_NOTICE
- );
- }
+ $response->addHTML($controller->index());
}
diff --git a/libraries/classes/Controllers/HomeController.php b/libraries/classes/Controllers/HomeController.php
index 3ba5cd1fd2..33f28f273c 100644
--- a/libraries/classes/Controllers/HomeController.php
+++ b/libraries/classes/Controllers/HomeController.php
@@ -11,11 +11,16 @@ namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\Charsets;
use PhpMyAdmin\CheckUserPrivileges;
+use PhpMyAdmin\Config;
+use PhpMyAdmin\Display\GitRevision;
use PhpMyAdmin\LanguageManager;
+use PhpMyAdmin\Message;
use PhpMyAdmin\RecentFavoriteTable;
+use PhpMyAdmin\Relation;
use PhpMyAdmin\Server\Select;
use PhpMyAdmin\ThemeManager;
use PhpMyAdmin\Url;
+use PhpMyAdmin\UserPreferences;
use PhpMyAdmin\Util;
/**
@@ -24,16 +29,54 @@ use PhpMyAdmin\Util;
*/
class HomeController extends AbstractController
{
+ /**
+ * @var Config
+ */
+ private $config;
+
+ /**
+ * @var ThemeManager
+ */
+ private $themeManager;
+
+ /**
+ * HomeController constructor.
+ *
+ * @param \PhpMyAdmin\Response $response Response instance
+ * @param \PhpMyAdmin\DatabaseInterface $dbi DatabaseInterface instance
+ * @param Config $config Config instance
+ */
+ public function __construct($response, $dbi, $config)
+ {
+ parent::__construct($response, $dbi);
+ $this->config = $config;
+ $this->themeManager = ThemeManager::getInstance();
+ }
+
+
/**
* @return string HTML
*/
public function index(): string
{
- global $cfg, $server, $collation_connection;
+ global $cfg, $server, $collation_connection, $message;
$languageManager = LanguageManager::getInstance();
- $syncFavoriteTables = RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
+ if (! empty($message)) {
+ $displayMessage = Util::getMessage($message);
+ unset($message);
+ }
+ if (isset($_SESSION['partial_logout'])) {
+ $partialLogout = Message::success(__(
+ 'You were logged out from one server, to logout completely '
+ . 'from phpMyAdmin, you need to logout from all servers.'
+ ))->getDisplay();
+ unset($_SESSION['partial_logout']);
+ }
+
+ $syncFavoriteTables = RecentFavoriteTable::getInstance('favorite')
+ ->getHtmlSyncFavoriteTables();
$hasServer = $server > 0 || count($cfg['Servers']) > 1;
if ($hasServer) {
@@ -100,7 +143,7 @@ class HomeController extends AbstractController
$themeSelection = '';
if ($cfg['ThemeManager']) {
- $themeSelection = ThemeManager::getInstance()->getHtmlSelectBox();
+ $themeSelection = $this->themeManager->getHtmlSelectBox();
}
$databaseServer = [];
@@ -141,12 +184,12 @@ class HomeController extends AbstractController
$webServer['software'] = $_SERVER['SERVER_SOFTWARE'];
if ($server > 0) {
- $client_version_str = $this->dbi->getClientInfo();
- if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
- $client_version_str = 'libmysql - ' . $client_version_str;
+ $clientVersion = $this->dbi->getClientInfo();
+ if (preg_match('#\d+\.\d+\.\d+#', $clientVersion)) {
+ $clientVersion = 'libmysql - ' . $clientVersion;
}
- $webServer['database'] = $client_version_str;
+ $webServer['database'] = $clientVersion;
$webServer['php_extensions'] = Util::listPHPExtensions();
$webServer['php_version'] = phpversion();
}
@@ -166,7 +209,41 @@ class HomeController extends AbstractController
]);
}
+ $relation = new Relation($this->dbi);
+ if ($server > 0) {
+ $cfgRelation = $relation->getRelationsParam();
+ if (! $cfgRelation['allworks']
+ && $cfg['PmaNoRelation_DisableWarning'] == false
+ ) {
+ $messageText = __(
+ 'The phpMyAdmin configuration storage is not completely '
+ . 'configured, some extended features have been deactivated. '
+ . '%sFind out why%s. '
+ );
+ if ($cfg['ZeroConf'] == true) {
+ $messageText .= '
' .
+ __(
+ 'Or alternately go to \'Operations\' tab of any database '
+ . 'to set it up there.'
+ );
+ }
+ $messageInstance = Message::notice($messageText);
+ $messageInstance->addParamHtml('');
+ $messageInstance->addParamHtml('');
+ /* Show error if user has configured something, notice elsewhere */
+ if (! empty($cfg['Servers'][$server]['pmadb'])) {
+ $messageInstance->isError(true);
+ }
+ $configStorageMessage = $messageInstance->getDisplay();
+ }
+ }
+
+ $this->checkRequirements();
+
return $this->template->render('home/index', [
+ 'message' => $displayMessage ?? '',
+ 'partial_logout' => $partialLogout ?? '',
+ 'is_git_revision' => $this->config->isGitRevision(),
'server' => $server,
'sync_favorite_tables' => $syncFavoriteTables,
'has_server' => $hasServer,
@@ -183,6 +260,245 @@ class HomeController extends AbstractController
'php_info' => $phpInfo ?? '',
'is_version_checked' => $cfg['VersionCheck'],
'phpmyadmin_version' => PMA_VERSION,
+ 'config_storage_message' => $configStorageMessage ?? '',
]);
}
+
+ /**
+ * @param array $params Request parameters
+ * @return void
+ */
+ public function setTheme(array $params): void
+ {
+ $this->themeManager->setActiveTheme($params['set_theme']);
+ $this->themeManager->setThemeCookie();
+
+ $userPreferences = new UserPreferences();
+ $preferences = $userPreferences->load();
+ $preferences['config_data']['ThemeDefault'] = $params['set_theme'];
+ $userPreferences->save($preferences['config_data']);
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return void
+ */
+ public function setCollationConnection(array $params): void
+ {
+ $this->config->setUserValue(
+ null,
+ 'DefaultConnectionCollation',
+ $params['collation_connection'],
+ 'utf8mb4_unicode_ci'
+ );
+ }
+
+ /**
+ * @return array JSON
+ */
+ public function reloadRecentTablesList(): array
+ {
+ return [
+ 'list' => RecentFavoriteTable::getInstance('recent')->getHtmlList(),
+ ];
+ }
+
+ /**
+ * @return string HTML
+ */
+ public function gitRevision(): string
+ {
+ return (new GitRevision(
+ $this->response,
+ $this->config,
+ $this->template
+ ))->display();
+ }
+
+ /**
+ * @return void
+ */
+ private function checkRequirements(): void
+ {
+ global $cfg, $server, $lang;
+
+ /**
+ * mbstring is used for handling multibytes inside parser, so it is good
+ * to tell user something might be broken without it, see bug #1063149.
+ */
+ if (! extension_loaded('mbstring')) {
+ trigger_error(
+ __(
+ 'The mbstring PHP extension was not found and you seem to be using'
+ . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
+ . ' is unable to split strings correctly and it may result in'
+ . ' unexpected results.'
+ ),
+ E_USER_WARNING
+ );
+ }
+
+ /**
+ * Missing functionality
+ */
+ if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
+ trigger_error(
+ __(
+ 'The curl extension was not found and allow_url_fopen is '
+ . 'disabled. Due to this some features such as error reporting '
+ . 'or version check are disabled.'
+ )
+ );
+ }
+
+ if ($cfg['LoginCookieValidityDisableWarning'] == false) {
+ /**
+ * Check whether session.gc_maxlifetime limits session validity.
+ */
+ $gc_time = (int) ini_get('session.gc_maxlifetime');
+ if ($gc_time < $cfg['LoginCookieValidity']) {
+ trigger_error(
+ __(
+ 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
+ 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
+ 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
+ 'in phpMyAdmin, because of this, your login might expire sooner ' .
+ 'than configured in phpMyAdmin.'
+ ),
+ E_USER_WARNING
+ );
+ }
+ }
+
+ /**
+ * Check whether LoginCookieValidity is limited by LoginCookieStore.
+ */
+ if ($cfg['LoginCookieStore'] != 0
+ && $cfg['LoginCookieStore'] < $cfg['LoginCookieValidity']
+ ) {
+ trigger_error(
+ __(
+ 'Login cookie store is lower than cookie validity configured in ' .
+ 'phpMyAdmin, because of this, your login will expire sooner than ' .
+ 'configured in phpMyAdmin.'
+ ),
+ E_USER_WARNING
+ );
+ }
+
+ /**
+ * Warning if using the default MySQL controluser account
+ */
+ if ($server != 0
+ && isset($cfg['Server']['controluser']) && $cfg['Server']['controluser'] == 'pma'
+ && isset($cfg['Server']['controlpass']) && $cfg['Server']['controlpass'] == 'pmapass'
+ ) {
+ trigger_error(
+ __(
+ 'Your server is running with default values for the ' .
+ 'controluser and password (controlpass) and is open to ' .
+ 'intrusion; you really should fix this security weakness' .
+ ' by changing the password for controluser \'pma\'.'
+ ),
+ E_USER_WARNING
+ );
+ }
+
+ /**
+ * Check if user does not have defined blowfish secret and it is being used.
+ */
+ if (! empty($_SESSION['encryption_key'])) {
+ if (empty($cfg['blowfish_secret'])) {
+ trigger_error(
+ __(
+ 'The configuration file now needs a secret passphrase (blowfish_secret).'
+ ),
+ E_USER_WARNING
+ );
+ } elseif (strlen($cfg['blowfish_secret']) < 32) {
+ trigger_error(
+ __(
+ 'The secret passphrase in configuration (blowfish_secret) is too short.'
+ ),
+ E_USER_WARNING
+ );
+ }
+ }
+
+ /**
+ * Check for existence of config directory which should not exist in
+ * production environment.
+ */
+ if (@file_exists(ROOT_PATH . 'config')) {
+ trigger_error(
+ __(
+ 'Directory [code]config[/code], which is used by the setup script, ' .
+ 'still exists in your phpMyAdmin directory. It is strongly ' .
+ 'recommended to remove it once phpMyAdmin has been configured. ' .
+ 'Otherwise the security of your server may be compromised by ' .
+ 'unauthorized people downloading your configuration.'
+ ),
+ E_USER_WARNING
+ );
+ }
+
+ /**
+ * Warning about Suhosin only if its simulation mode is not enabled
+ */
+ if ($cfg['SuhosinDisableWarning'] == false
+ && ini_get('suhosin.request.max_value_length')
+ && ini_get('suhosin.simulation') == '0'
+ ) {
+ trigger_error(
+ sprintf(
+ __(
+ 'Server running with Suhosin. Please refer ' .
+ 'to %sdocumentation%s for possible issues.'
+ ),
+ '[doc@faq1-38]',
+ '[/doc]'
+ ),
+ E_USER_WARNING
+ );
+ }
+
+ /* Missing template cache */
+ if (is_null($this->config->getTempDir('twig'))) {
+ trigger_error(
+ sprintf(
+ __(
+ 'The $cfg[\'TempDir\'] (%s) is not accessible. ' .
+ 'phpMyAdmin is not able to cache templates and will ' .
+ 'be slow because of this.'
+ ),
+ $this->config->get('TempDir')
+ ),
+ E_USER_WARNING
+ );
+ }
+
+ /**
+ * Warning about incomplete translations.
+ *
+ * The data file is created while creating release by ./scripts/remove-incomplete-mo
+ */
+ if (@file_exists(ROOT_PATH . 'libraries/language_stats.inc.php')) {
+ include ROOT_PATH . 'libraries/language_stats.inc.php';
+ /*
+ * This message is intentionally not translated, because we're
+ * handling incomplete translations here and focus on english
+ * speaking users.
+ */
+ if (isset($GLOBALS['language_stats'][$lang])
+ && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
+ ) {
+ trigger_error(
+ 'You are using an incomplete translation, please help to make it '
+ . 'better by [a@https://www.phpmyadmin.net/translate/'
+ . '@_blank]contributing[/a].',
+ E_USER_NOTICE
+ );
+ }
+ }
+ }
}
diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php
index 63f73dfcaf..86aeaafd86 100644
--- a/libraries/classes/Core.php
+++ b/libraries/classes/Core.php
@@ -1252,46 +1252,6 @@ class Core
}
}
- /**
- * prints list item for main page
- *
- * @param string $name displayed text
- * @param string $listId id, used for css styles
- * @param string $url make item as link with $url as target
- * @param string $mysql_help_page display a link to MySQL's manual
- * @param string $target special target for $url
- * @param string $a_id id for the anchor,
- * used for jQuery to hook in functions
- * @param string $class class for the li element
- * @param string $a_class class for the anchor element
- *
- * @return void
- */
- public static function printListItem(
- string $name,
- ?string $listId = null,
- ?string $url = null,
- ?string $mysql_help_page = null,
- ?string $target = null,
- ?string $a_id = null,
- ?string $class = null,
- ?string $a_class = null
- ): void {
- $template = new Template();
- echo $template->render('list/item', [
- 'content' => $name,
- 'id' => $listId,
- 'class' => $class,
- 'url' => [
- 'href' => $url,
- 'target' => $target,
- 'id' => $a_id,
- 'class' => $a_class,
- ],
- 'mysql_help_page' => $mysql_help_page,
- ]);
- }
-
/**
* Checks request and fails with fatal error if something problematic is found
*
diff --git a/libraries/classes/Display/GitRevision.php b/libraries/classes/Display/GitRevision.php
index 7db31a09e7..c60c7107d6 100644
--- a/libraries/classes/Display/GitRevision.php
+++ b/libraries/classes/Display/GitRevision.php
@@ -9,8 +9,10 @@ declare(strict_types=1);
namespace PhpMyAdmin\Display;
+use PhpMyAdmin\Config;
use PhpMyAdmin\Core;
use PhpMyAdmin\Response;
+use PhpMyAdmin\Template;
use PhpMyAdmin\Util;
/**
@@ -21,59 +23,85 @@ use PhpMyAdmin\Util;
class GitRevision
{
/**
- * Prints details about the current Git commit revision
- *
- * @return void
+ * @var Response
*/
- public static function display()
+ private $response;
+
+ /**
+ * @var Config
+ */
+ private $config;
+
+ /**
+ * @var Template
+ */
+ private $template;
+
+ /**
+ * GitRevision constructor.
+ * @param Response $response Response instance
+ * @param Config $config Config instance
+ * @param Template $template Template instance
+ */
+ public function __construct($response, $config, $template)
{
+ $this->response = $response;
+ $this->config = $config;
+ $this->template = $template;
+ }
+ /**
+ * Returns details about the current Git commit revision
+ *
+ * @return string HTML
+ */
+ public function display(): string
+ {
// load revision data from repo
- $GLOBALS['PMA_Config']->checkGitRevision();
+ $this->config->checkGitRevision();
- if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
- $response = Response::getInstance();
- $response->setRequestStatus(false);
- return;
+ if (! $this->config->get('PMA_VERSION_GIT')) {
+ $this->response->setRequestStatus(false);
+ return '';
}
// if using a remote commit fast-forwarded, link to GitHub
- $commit_hash = substr(
- $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'),
+ $commitHash = substr(
+ $this->config->get('PMA_VERSION_GIT_COMMITHASH'),
0,
7
);
- $commit_hash = '' . $commit_hash . '';
- if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
- $commit_hash = 'config->get('PMA_VERSION_GIT_MESSAGE'))
+ . '">' . $commitHash . '';
+ if ($this->config->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
+ $commitHash = '' . $commit_hash . '';
+ . '" rel="noopener noreferrer" target="_blank">' . $commitHash . '';
}
- $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
- if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
+ $branch = $this->config->get('PMA_VERSION_GIT_BRANCH');
+ if ($this->config->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
$branch = '' . $branch . '';
}
if ($branch !== false) {
- $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
+ $branch = sprintf(__('%1$s from %2$s branch'), $commitHash, $branch);
} else {
- $branch = $commit_hash . ' (' . __('no branch') . ')';
+ $branch = $commitHash . ' (' . __('no branch') . ')';
}
- $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
- $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
- Core::printListItem(
- __('Git revision:') . ' '
+ $committer = $this->config->get('PMA_VERSION_GIT_COMMITTER');
+ $author = $this->config->get('PMA_VERSION_GIT_AUTHOR');
+
+ $name = __('Git revision:') . ' '
. $branch . ',
'
. sprintf(
__('committed on %1$s by %2$s'),
@@ -93,11 +121,19 @@ class GitRevision
) . '">'
. htmlspecialchars($author['name']) . ''
)
- : ''),
- 'li_pma_version_git',
- null,
- null,
- null
- );
+ : '');
+
+ return $this->template->render('list/item', [
+ 'content' => $name,
+ 'id' => 'li_pma_version_git',
+ 'class' => null,
+ 'url' => [
+ 'href' => null,
+ 'target' => null,
+ 'id' => null,
+ 'class' => null,
+ ],
+ 'mysql_help_page' => null,
+ ]);
}
}
diff --git a/templates/home/index.twig b/templates/home/index.twig
index 66383c92f9..bb20fdbbdc 100644
--- a/templates/home/index.twig
+++ b/templates/home/index.twig
@@ -1,3 +1,11 @@
+{% if is_git_revision %}
+
+{% endif %}
+
+{{ message|raw }}
+
+{{ partial_logout|raw }}
+
{{ sync_favorite_tables|raw }}
@@ -182,3 +190,5 @@
+
+{{ config_storage_message|raw }}