Skip to content

Commit

Permalink
Remove $cfg['ThemePath']
Browse files Browse the repository at this point in the history
Fixes #12196

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Apr 20, 2016
1 parent 05c723a commit 8dbb454
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 90 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -13,6 +13,7 @@ phpMyAdmin - ChangeLog
+ issue #12129 Improve performance with SkipLockedTables
- issue #12173 Do not hide indexes under a slider
- issue Improve performance of zip file import
- issue #12196 Removed $cfg['ThemePath']

4.6.1 (not yet released)
- issue #12120 PMA_Util not found in insert_edit.lib.php
Expand Down
10 changes: 1 addition & 9 deletions doc/config.rst
Expand Up @@ -2815,14 +2815,6 @@ Page titles
Theme manager settings
----------------------

.. config:option:: $cfg['ThemePath']
:type: string
:default: ``'./themes'``

If theme manager is active, use this as the path of the subdirectory
containing all the themes.

.. config:option:: $cfg['ThemeManager']
:type: boolean
Expand All @@ -2835,7 +2827,7 @@ Theme manager settings
:type: string
:default: ``'pmahomme'``

The default theme (a subdirectory under :config:option:`$cfg['ThemePath']`).
The default theme (a subdirectory under :file:`./themes/`).

.. config:option:: $cfg['ThemePerServer']
Expand Down
20 changes: 9 additions & 11 deletions doc/faq.rst
Expand Up @@ -736,20 +736,18 @@ doesn't work in this configuration with port forwarding. If you enter
2.7 Using and creating themes
-----------------------------

Themes are configured with :config:option:`$cfg['ThemePath']`,
:config:option:`$cfg['ThemeManager']` and :config:option:`$cfg['ThemeDefault']`.
Under :config:option:`$cfg['ThemePath']`, you should not delete the
directory ``pmahomme`` or its underlying structure, because this is the
system theme used by phpMyAdmin. ``pmahomme`` contains all images and
styles, for backwards compatibility and for all themes that would not
include images or css-files. If :config:option:`$cfg['ThemeManager']`
is enabled, you can select your favorite theme on the main page. Your selected
theme will be stored in a cookie.
Themes are configured with :config:option:`$cfg['ThemeManager']` and
:config:option:`$cfg['ThemeDefault']`. Under :file:`./themes/`, you should not
delete the directory ``pmahomme`` or its underlying structure, because this is
the system theme used by phpMyAdmin. ``pmahomme`` contains all images and
styles, for backwards compatibility and for all themes that would not include
images or css-files. If :config:option:`$cfg['ThemeManager']` is enabled, you
can select your favorite theme on the main page. Your selected theme will be
stored in a cookie.

To create a theme:

* make a new subdirectory (for example "your\_theme\_name") under :config:option:`$cfg['ThemePath']` (by
default ``themes``)
* make a new subdirectory (for example "your\_theme\_name") under :file:`./themes/`.
* copy the files and directories from ``pmahomme`` to "your\_theme\_name"
* edit the css-files in "your\_theme\_name/css"
* put your new images in "your\_theme\_name/img"
Expand Down
7 changes: 2 additions & 5 deletions libraries/Theme.php
Expand Up @@ -156,9 +156,7 @@ public function checkImgPath()
}

// try fallback theme
$fallback = $GLOBALS['cfg']['ThemePath'] . '/'
. ThemeManager::FALLBACK_THEME
. '/img/';
$fallback = './themes/' . ThemeManager::FALLBACK_THEME . '/img/';
if (is_dir($fallback)) {
$this->setImgPath($fallback);
return true;
Expand Down Expand Up @@ -329,8 +327,7 @@ public function getImgPath($file = null)
return $this->img_path . $file;
}

return $GLOBALS['cfg']['ThemePath'] . '/'
. ThemeManager::FALLBACK_THEME . '/img/' . $file;
return './themes/' . ThemeManager::FALLBACK_THEME . '/img/' . $file;
}

/**
Expand Down
26 changes: 7 additions & 19 deletions libraries/ThemeManager.php
Expand Up @@ -20,7 +20,7 @@ class ThemeManager
* @var string path to theme folder
* @access protected
*/
private $_themes_path;
private $_themes_path = './themes/';

/**
* @var array available themes
Expand Down Expand Up @@ -85,17 +85,6 @@ public function setThemesPath($path)
return true;
}

/**
* Returns path to folder containing themes
*
* @access public
* @return string theme path
*/
public function getThemesPath()
{
return $this->_themes_path;
}

/**
* sets if there are different themes per server
*
Expand All @@ -121,7 +110,7 @@ public function init()
$this->theme_default = self::FALLBACK_THEME;
$this->active_theme = '';

if (! $this->setThemesPath($GLOBALS['cfg']['ThemePath'])) {
if (! $this->setThemesPath('./themes/')) {
return;
}

Expand Down Expand Up @@ -166,8 +155,7 @@ public function init()
*/
public function checkConfig()
{
if ($this->_themes_path != trim($GLOBALS['cfg']['ThemePath'])
|| $this->theme_default != $GLOBALS['cfg']['ThemeDefault']
if ($this->theme_default != $GLOBALS['cfg']['ThemeDefault']
) {
$this->init();
} else {
Expand Down Expand Up @@ -292,10 +280,10 @@ public function loadThemes()
{
$this->themes = array();

if (false === ($handleThemes = opendir($this->getThemesPath()))) {
if (false === ($handleThemes = opendir($this->_themes_path))) {
trigger_error(
'phpMyAdmin-ERROR: cannot open themes folder: '
. $this->getThemesPath(),
. $this->_themes_path,
E_USER_WARNING
);
return false;
Expand All @@ -306,15 +294,15 @@ public function loadThemes()
// Skip non dirs, . and ..
if ($PMA_Theme == '.'
|| $PMA_Theme == '..'
|| ! is_dir($this->getThemesPath() . '/' . $PMA_Theme)
|| ! is_dir($this->_themes_path . $PMA_Theme)
) {
continue;
}
if (array_key_exists($PMA_Theme, $this->themes)) {
continue;
}
$new_theme = Theme::load(
$this->getThemesPath() . '/' . $PMA_Theme
$this->_themes_path . $PMA_Theme
);
if ($new_theme) {
$new_theme->setId($PMA_Theme);
Expand Down
9 changes: 1 addition & 8 deletions libraries/config.default.php
Expand Up @@ -2865,13 +2865,6 @@
* theme manager
*/

/**
* using themes manager please set up here the path to 'themes' else leave empty
*
* @global string $cfg['ThemePath']
*/
$cfg['ThemePath'] = './themes';

/**
* if you want to use selectable themes and if ThemesPath not empty
* set it to true, else set it to false (default is false);
Expand All @@ -2881,7 +2874,7 @@
$cfg['ThemeManager'] = true;

/**
* set up default theme, if ThemePath not empty you can set up here an valid
* set up default theme, you can set up here an valid
* path to themes or 'original' for the original pma-theme
*
* @global string $cfg['ThemeDefault']
Expand Down
2 changes: 1 addition & 1 deletion libraries/config/FormDisplay.tpl.php
Expand Up @@ -178,7 +178,7 @@ function PMA_displayInput($path, $name, $type, $value, $description = '',
$icons[$k] = sprintf(
'<img alt="%s" src="%s"%s />',
$v[1],
".{$GLOBALS['cfg']['ThemePath']}/original/img/{$v[0]}",
"./themes/original/img/{$v[0]}",
$title
);
}
Expand Down
1 change: 0 additions & 1 deletion test/classes/ThemeManagerTest.php
Expand Up @@ -27,7 +27,6 @@ class ThemeManagerTest extends PMATestCase
*/
public function setup()
{
$GLOBALS['cfg']['ThemePath'] = './themes';
$GLOBALS['cfg']['ThemePerServer'] = false;
$GLOBALS['cfg']['ThemeDefault'] = 'pmahomme';
$GLOBALS['cfg']['ServerDefault'] = 0;
Expand Down
36 changes: 2 additions & 34 deletions test/classes/ThemeTest.php
Expand Up @@ -176,14 +176,11 @@ public function testLoadNotExisted()
* Test fir Theme::checkImgPath
*
* @return void
* @expectedException PHPUnit_Framework_Error
*/
public function testCheckImgPathBad()
public function testCheckImgPathFallback()
{
$GLOBALS['cfg']['ThemePath'] = 'nowhere';
$this->object->setPath('path/to/nowhere');

$this->assertFalse($this->object->checkImgPath());
$this->assertTrue($this->object->checkImgPath());
}

/**
Expand All @@ -197,35 +194,6 @@ public function testCheckImgPath()
$this->assertTrue($this->object->checkImgPath());
}

/**
* Test for Theme::checkImgPath
*
* @return void
*/
public function testCheckImgPathGlobals()
{
$this->object->setPath('/this/is/wrong/path');
$GLOBALS['cfg']['ThemePath'] = 'themes';
$this->assertTrue($this->object->checkImgPath());
}

/**
* Test for Theme::checkImgPath
*
* @return void
* @expectedException PHPUnit_Framework_Error
*/
public function testCheckImgPathGlobalsWrongPath()
{
$prevThemePath = $GLOBALS['cfg']['ThemePath'];
$GLOBALS['cfg']['ThemePath'] = 'no_themes';

$this->object->setPath('/this/is/wrong/path');
$this->object->checkImgPath();

$GLOBALS['cfg']['ThemePath'] = $prevThemePath;
}

/**
* Test for Theme::getPath
*
Expand Down
2 changes: 0 additions & 2 deletions test/libraries/PMA_FormDisplay_tpl_test.php
Expand Up @@ -211,7 +211,6 @@ public function testDisplayInput()

define('PMA_SETUP', true);
$GLOBALS['_FormDislayGroup'] = 0;
$GLOBALS['cfg']['ThemePath'] = 'themePath';
$opts = array();
$opts['errors'] = array();
$opts['setvalue'] = 'setVal';
Expand Down Expand Up @@ -255,7 +254,6 @@ public function testDisplayInput()

// short_text
$GLOBALS['_FormDislayGroup'] = 0;
$GLOBALS['cfg']['ThemePath'] = 'themePath';
$opts = array();
$opts['errors'] = array();

Expand Down

0 comments on commit 8dbb454

Please sign in to comment.