Rename PMA_Theme global variable to theme

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2021-03-07 15:15:27 -03:00
parent 3a161651ea
commit 2c2127b369
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
11 changed files with 35 additions and 29 deletions

View File

@ -69,7 +69,7 @@ class BrowseForeigners
int $indexByDescription,
string $currentValue
): array {
global $PMA_Theme;
global $theme;
$horizontalCount++;
$output = '';
@ -124,7 +124,7 @@ class BrowseForeigners
]);
$output .= '<td width="20%"><img src="'
. ($PMA_Theme instanceof Theme ? $PMA_Theme->getImgPath('spacer.png') : '')
. ($theme instanceof Theme ? $theme->getImgPath('spacer.png') : '')
. '" alt="" width="1" height="1"></td>';
$output .= $this->template->render('table/browse_foreigners/column_element', [

View File

@ -893,14 +893,14 @@ class Config
*/
public function getThemeUniqueValue(): int
{
global $PMA_Theme;
global $theme;
return (int) (
$this->sourceMtime +
$this->defaultSourceMtime +
$this->get('user_preferences_mtime') +
($PMA_Theme->mtimeInfo ?? 0) +
($PMA_Theme->filesizeInfo ?? 0)
($theme->mtimeInfo ?? 0) +
($theme->filesizeInfo ?? 0)
);
}

View File

@ -28,9 +28,9 @@ final class JavaScriptMessagesController
private function setMessages(): void
{
global $cfg, $PMA_Theme;
global $cfg, $theme;
$ajaxClockSmallGifPath = $PMA_Theme instanceof Theme ? $PMA_Theme->getImgPath('ajax_clock_small.gif') : '';
$ajaxClockSmallGifPath = $theme instanceof Theme ? $theme->getImgPath('ajax_clock_small.gif') : '';
$this->messages = [
/* For confirmations */

View File

@ -1545,7 +1545,7 @@ class Results
*/
private function getFullOrPartialTextButtonOrLink()
{
global $PMA_Theme;
global $theme;
$urlParamsFullText = [
'db' => $this->properties['db'],
@ -1567,7 +1567,7 @@ class Results
}
$tmpImage = '<img class="fulltext" src="'
. ($PMA_Theme instanceof Theme ? $PMA_Theme->getImgPath($tmpImageFile) : '')
. ($theme instanceof Theme ? $theme->getImgPath($tmpImageFile) : '')
. '" alt="' . $tmpTxt . '" title="' . $tmpTxt . '">';
$tmpUrl = Url::getFromRoute('/sql', $urlParamsFullText);

View File

@ -380,7 +380,7 @@ class Header
*/
public function getDisplay(): string
{
global $db, $table, $PMA_Theme, $dbi;
global $db, $table, $theme, $dbi;
if ($this->headerIsSent || ! $this->isEnabled) {
return '';
@ -399,7 +399,7 @@ class Header
$baseDir = defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : '';
$uniqueValue = $GLOBALS['PMA_Config']->getThemeUniqueValue();
$themePath = $PMA_Theme instanceof Theme ? $PMA_Theme->getPath() : '';
$themePath = $theme instanceof Theme ? $theme->getPath() : '';
$version = self::getVersionParameter();
// The user preferences have been merged at this point

View File

@ -277,15 +277,15 @@ class Navigation
*/
private function getLogoSource(): string
{
global $PMA_Theme;
global $theme;
if ($PMA_Theme instanceof Theme) {
if (@file_exists($PMA_Theme->getFsPath() . 'img/logo_left.png')) {
return $PMA_Theme->getPath() . '/img/logo_left.png';
if ($theme instanceof Theme) {
if (@file_exists($theme->getFsPath() . 'img/logo_left.png')) {
return $theme->getPath() . '/img/logo_left.png';
}
if (@file_exists($PMA_Theme->getFsPath() . 'img/pma_logo2.png')) {
return $PMA_Theme->getPath() . '/img/pma_logo2.png';
if (@file_exists($theme->getFsPath() . 'img/pma_logo2.png')) {
return $theme->getPath() . '/img/pma_logo2.png';
}
}

View File

@ -22,12 +22,12 @@ final class AssetExtension extends AbstractExtension
public function getImagePath(?string $filename = null, ?string $fallback = null): string
{
global $PMA_Theme;
global $theme;
if (! $PMA_Theme instanceof Theme) {
if (! $theme instanceof Theme) {
return '';
}
return $PMA_Theme->getImgPath($filename, $fallback);
return $theme->getImgPath($filename, $fallback);
}
}

View File

@ -48,7 +48,7 @@ use PhpMyAdmin\ThemeManager;
use PhpMyAdmin\Tracker;
global $containerBuilder, $error_handler, $PMA_Config, $server, $dbi;
global $lang, $cfg, $isConfigLoading, $auth_plugin, $route, $PMA_Theme;
global $lang, $cfg, $isConfigLoading, $auth_plugin, $route, $theme;
global $url_params, $goto, $back, $db, $table, $sql_query, $token_mismatch;
/**
@ -226,7 +226,7 @@ $PMA_Config->enableBc();
/* setup themes LABEL_theme_setup */
$PMA_Theme = ThemeManager::initializeTheme();
$theme = ThemeManager::initializeTheme();
/** @var DatabaseInterface $dbi */
$dbi = null;

View File

@ -133,8 +133,8 @@ abstract class AbstractTestCase extends TestCase
protected function setTheme(): void
{
global $PMA_Theme;
$PMA_Theme = Theme::load('pmahomme');
global $theme;
$theme = Theme::load('pmahomme');
}
protected function setLanguage(string $code = 'en'): void

View File

@ -951,11 +951,13 @@ class ConfigTest extends AbstractTestCase
*/
public function testGetThemeUniqueValue(): void
{
global $theme;
$partial_sum = $this->object->sourceMtime +
$this->object->defaultSourceMtime +
$this->object->get('user_preferences_mtime') +
$GLOBALS['PMA_Theme']->mtimeInfo +
$GLOBALS['PMA_Theme']->filesizeInfo;
$theme->mtimeInfo +
$theme->filesizeInfo;
$this->assertEquals($partial_sum, $this->object->getThemeUniqueValue());
}

View File

@ -22,12 +22,14 @@ class ThemeTest extends AbstractTestCase
*/
protected function setUp(): void
{
global $theme;
parent::setUp();
parent::defineVersionConstants();
parent::setTheme();
$this->object = new Theme();
$this->backup = $GLOBALS['PMA_Theme'];
$GLOBALS['PMA_Theme'] = $this->object;
$this->backup = $theme;
$theme = $this->object;
parent::setGlobalConfig();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['text_dir'] = 'ltr';
@ -40,8 +42,10 @@ class ThemeTest extends AbstractTestCase
*/
protected function tearDown(): void
{
global $theme;
parent::tearDown();
$GLOBALS['PMA_Theme'] = $this->backup;
$theme = $this->backup;
}
/**