Navigation panel settings
Signed-off-by: Nisarg Jhaveri <nisargjhaveri@gmail.com>
This commit is contained in:
parent
aa57d15ca7
commit
9c77ec694e
@ -333,6 +333,12 @@ var AJAX = {
|
||||
} else if (data._menuHash) {
|
||||
AJAX.cache.menus.replace(AJAX.cache.menus.get(data._menuHash));
|
||||
}
|
||||
if (data._disableNaviSettings) {
|
||||
PMA_disableNaviSettings();
|
||||
}
|
||||
else {
|
||||
PMA_ensureNaviSettings(data._selflink);
|
||||
}
|
||||
|
||||
// Remove all containers that may have
|
||||
// been added outside of #page_content
|
||||
|
||||
82
js/config.js
82
js/config.js
@ -423,7 +423,7 @@ function validate_field(field, isKeyUp, errors)
|
||||
args = [];
|
||||
}
|
||||
args.unshift(isKeyUp);
|
||||
result = functions[i][0].apply(field[0], args);
|
||||
result = functions[i][0].apply($field[0], args);
|
||||
if (result !== true) {
|
||||
if (typeof result == 'string') {
|
||||
result = [result];
|
||||
@ -477,9 +477,22 @@ function setRestoreDefaultBtn(field, display)
|
||||
$el[display ? 'show' : 'hide']();
|
||||
}
|
||||
|
||||
AJAX.registerOnload('config.js', function () {
|
||||
if (typeof configInlineParams === 'function') {
|
||||
configInlineParams();
|
||||
function loadInlineConfig() {
|
||||
if (!Array.isArray(configInlineParams)) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < configInlineParams.length; ++i) {
|
||||
if (typeof configInlineParams[i] === 'function') {
|
||||
configInlineParams[i]();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setupValidation() {
|
||||
validate = {};
|
||||
configScriptLoaded = true;
|
||||
if (configScriptLoaded && typeof configInlineParams !== "undefined") {
|
||||
loadInlineConfig();
|
||||
}
|
||||
// register validators and mark custom values
|
||||
var $elements = $('input[id], select[id], textarea[id]');
|
||||
@ -522,6 +535,10 @@ AJAX.registerOnload('config.js', function () {
|
||||
} else if ($check_page_refresh) {
|
||||
$check_page_refresh.val('1');
|
||||
}
|
||||
}
|
||||
|
||||
AJAX.registerOnload('config.js', function () {
|
||||
setupValidation();
|
||||
});
|
||||
|
||||
//
|
||||
@ -539,27 +556,42 @@ AJAX.registerOnload('config.js', function () {
|
||||
*/
|
||||
function setTab(tab_id)
|
||||
{
|
||||
$('ul.tabs li').removeClass('active').find('a[href=#' + tab_id + ']').parent().addClass('active');
|
||||
$('div.tabs_contents fieldset').hide().filter('#' + tab_id).show();
|
||||
location.hash = 'tab_' + tab_id;
|
||||
$('form.config-form input[name=tab_hash]').val(location.hash);
|
||||
$('ul.tabs').each(function() {
|
||||
$this = $(this);
|
||||
if (!$this.find('li a[href=#' + tab_id + ']').length) {
|
||||
return;
|
||||
}
|
||||
$this.find('li').removeClass('active').find('a[href=#' + tab_id + ']').parent().addClass('active');
|
||||
$this.parent().find('div.tabs_contents fieldset').hide().filter('#' + tab_id).show();
|
||||
location.hash = 'tab_' + tab_id;
|
||||
$this.parent().find('input[name=tab_hash]').val(location.hash);
|
||||
});
|
||||
}
|
||||
|
||||
function setupConfigTabs() {
|
||||
var forms = $('form.config-form');
|
||||
forms.each(function() {
|
||||
$this = $(this);
|
||||
var $tabs = $this.find('ul.tabs');
|
||||
if (!$tabs.length) {
|
||||
return;
|
||||
}
|
||||
// add tabs events and activate one tab (the first one or indicated by location hash)
|
||||
$tabs.find('li').removeClass('active');
|
||||
$tabs.find('a')
|
||||
.click(function (e) {
|
||||
e.preventDefault();
|
||||
setTab($(this).attr('href').substr(1));
|
||||
})
|
||||
.filter(':first')
|
||||
.parent()
|
||||
.addClass('active');
|
||||
$this.find('div.tabs_contents fieldset').hide().filter(':first').show();
|
||||
});
|
||||
}
|
||||
|
||||
AJAX.registerOnload('config.js', function () {
|
||||
var $tabs = $('ul.tabs');
|
||||
if (!$tabs.length) {
|
||||
return;
|
||||
}
|
||||
// add tabs events and activate one tab (the first one or indicated by location hash)
|
||||
$tabs.find('a')
|
||||
.click(function (e) {
|
||||
e.preventDefault();
|
||||
setTab($(this).attr('href').substr(1));
|
||||
})
|
||||
.filter(':first')
|
||||
.parent()
|
||||
.addClass('active');
|
||||
$('div.tabs_contents fieldset').hide().filter(':first').show();
|
||||
setupConfigTabs();
|
||||
|
||||
// tab links handling, check each 200ms
|
||||
// (works with history in FF, further browser support here would be an overkill)
|
||||
@ -615,7 +647,7 @@ function restoreField(field_id)
|
||||
setFieldValue($field, getFieldType($field), defaultValues[field_id]);
|
||||
}
|
||||
|
||||
AJAX.registerOnload('config.js', function () {
|
||||
function setupRestoreField() {
|
||||
$('div.tabs_contents')
|
||||
.delegate('.restore-default, .set-value', 'mouseenter', function () {
|
||||
$(this).css('opacity', 1);
|
||||
@ -640,6 +672,10 @@ AJAX.registerOnload('config.js', function () {
|
||||
.find('.restore-default, .set-value')
|
||||
// inline-block for IE so opacity inheritance works
|
||||
.css({display: 'inline-block', opacity: 0.25});
|
||||
}
|
||||
|
||||
AJAX.registerOnload('config.js', function () {
|
||||
setupRestoreField();
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
@ -823,6 +823,46 @@ function PMA_showCurrentNavigation() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable navigation panel settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_disableNaviSettings() {
|
||||
$('#pma_navigation_settings_icon').addClass('hide');
|
||||
$('#pma_navigation_settings').remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that navigation panel settings is properly setup.
|
||||
* If not, set it up
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_ensureNaviSettings(selflink) {
|
||||
$('#pma_navigation_settings_icon').removeClass('hide');
|
||||
|
||||
if (!$('#pma_navigation_settings').length) {
|
||||
var params = {
|
||||
getNaviSettings: true
|
||||
};
|
||||
var url = $('#pma_navigation').find('a.navigation_url').attr('href');
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success) {
|
||||
$('#pma_navi_settings_container').html(data.message);
|
||||
setupRestoreField();
|
||||
setupValidation();
|
||||
setupConfigTabs();
|
||||
$('#pma_navigation_settings').find('form').attr('action', selflink);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#pma_navigation_settings').find('form').attr('action', selflink);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the whole navigation tree while preserving its state
|
||||
*
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
* @required js/functions.js
|
||||
*/
|
||||
|
||||
function show_settings() {
|
||||
function showSettings(selector) {
|
||||
var buttons = {};
|
||||
buttons[PMA_messages.strApply] = function() {
|
||||
$('.config-form').submit();
|
||||
@ -18,7 +18,7 @@ function show_settings() {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
||||
$('.page_settings_modal')
|
||||
$(selector)
|
||||
.dialog({
|
||||
title: PMA_messages.strPageSettings,
|
||||
width: 700,
|
||||
@ -31,12 +31,24 @@ function show_settings() {
|
||||
});
|
||||
}
|
||||
|
||||
function showPageSettings() {
|
||||
showSettings('#page_settings_modal');
|
||||
}
|
||||
|
||||
function showNaviSettings() {
|
||||
showSettings('#pma_navigation_settings');
|
||||
}
|
||||
|
||||
AJAX.registerTeardown('page_settings.js', function () {
|
||||
$('#page_settings_icon').css('display', 'none');
|
||||
$('#page_settings_icon').unbind('click');
|
||||
$('#pma_navigation_settings_icon').unbind('click');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('page_settings.js', function () {
|
||||
$('#page_settings_icon').css('display', 'inline');
|
||||
$('#page_settings_icon').bind('click', show_settings);
|
||||
if ($('#page_settings_modal').length) {
|
||||
$('#page_settings_icon').css('display', 'inline');
|
||||
$('#page_settings_icon').bind('click', showPageSettings);
|
||||
}
|
||||
$('#pma_navigation_settings_icon').bind('click', showNaviSettings);
|
||||
});
|
||||
|
||||
@ -205,6 +205,8 @@ class PMA_Header
|
||||
$this->_scripts->addFile('navigation.js');
|
||||
$this->_scripts->addFile('indexes.js');
|
||||
$this->_scripts->addFile('common.js');
|
||||
$this->_scripts->addFile('config.js');
|
||||
$this->_scripts->addFile('page_settings.js');
|
||||
$this->_scripts->addCode($this->getJsParamsCode());
|
||||
}
|
||||
|
||||
|
||||
@ -4518,6 +4518,7 @@ class PMA_Util
|
||||
* @param string $linkId Value to use for the ID attribute
|
||||
* @param boolean $disableAjax Whether to disable ajax page loading for this link
|
||||
* @param string $linkTarget The name of the target frame for the link
|
||||
* @param string $classes HTML classes to apply
|
||||
*
|
||||
* @return string HTML code for one link
|
||||
*/
|
||||
@ -4529,7 +4530,8 @@ class PMA_Util
|
||||
$icon,
|
||||
$linkId = '',
|
||||
$disableAjax = false,
|
||||
$linkTarget = ''
|
||||
$linkTarget = '',
|
||||
$classes = array()
|
||||
) {
|
||||
$retval = '<a href="' . $link . '"';
|
||||
if (! empty($linkId)) {
|
||||
@ -4539,7 +4541,10 @@ class PMA_Util
|
||||
$retval .= ' target="' . $linkTarget . '"';
|
||||
}
|
||||
if ($disableAjax) {
|
||||
$retval .= ' class="disableAjax"';
|
||||
$classes[] = 'disableAjax';
|
||||
}
|
||||
if (!empty($classes)) {
|
||||
$retval .= ' class="' . join(" ", $classes) . '"';
|
||||
}
|
||||
$retval .= ' title="' . $text . '">';
|
||||
if ($showIcon) {
|
||||
|
||||
@ -1212,4 +1212,8 @@ if (! defined('PMA_MINIMUM_COMMON')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
include_once 'libraries/config/page_settings.class.php';
|
||||
}
|
||||
?>
|
||||
|
||||
@ -481,9 +481,13 @@ function PMA_displayJavascript($js_array)
|
||||
return;
|
||||
}
|
||||
$htmlOutput = '<script type="text/javascript">' . "\n"
|
||||
. 'function configInlineParams() {' . "\n"
|
||||
. 'if (typeof configInlineParams === "undefined"'
|
||||
. ' || !Array.isArray(configInlineParams)) configInlineParams = [];' . "\n"
|
||||
. 'configInlineParams.push(function() {' . "\n"
|
||||
. implode(";\n", $js_array) . ";\n"
|
||||
. '};' . "\n"
|
||||
. '});' . "\n"
|
||||
. 'if (typeof configScriptLoaded !== "undefined"'
|
||||
. ' && configInlineParams) loadInlineConfig();' . "\n"
|
||||
. '</script>' . "\n";
|
||||
return $htmlOutput;
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/user_preferences.lib.php';
|
||||
require_once 'libraries/config/config_functions.lib.php';
|
||||
require_once 'libraries/config/messages.inc.php';
|
||||
@ -23,32 +22,48 @@ require 'libraries/config/page_settings.forms.php';
|
||||
*/
|
||||
class PMA_PageSettings
|
||||
{
|
||||
|
||||
/**
|
||||
* Is class initiated
|
||||
*
|
||||
* @access private
|
||||
* @static
|
||||
* @var bool
|
||||
* Contains id of the form element
|
||||
* @var string
|
||||
*/
|
||||
private static $_initiated = false;
|
||||
private $_elemId = 'page_settings_modal';
|
||||
|
||||
/**
|
||||
* Name of the group to show
|
||||
* @var string
|
||||
*/
|
||||
private $_groupName = '';
|
||||
|
||||
/**
|
||||
* Contains HTML of errors
|
||||
* @var string
|
||||
*/
|
||||
private $_errorHTML = '';
|
||||
|
||||
/**
|
||||
* Contains HTML of settings
|
||||
* @var string
|
||||
*/
|
||||
private $_HTML = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $formGroupName The name of config form group to display
|
||||
* @param string $elemId Id of the div containing settings
|
||||
*/
|
||||
public function __construct($formGroupName)
|
||||
public function __construct($formGroupName, $elemId = null)
|
||||
{
|
||||
global $forms;
|
||||
|
||||
if (self::$_initiated) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($forms[$formGroupName])) {
|
||||
return;
|
||||
}
|
||||
self::$_initiated = true;
|
||||
|
||||
if (!empty($elemId)) {
|
||||
$this->_elemId = $elemId;
|
||||
}
|
||||
$this->_groupName = $formGroupName;
|
||||
|
||||
$cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
|
||||
PMA_userprefsPageInit($cf);
|
||||
@ -66,18 +81,20 @@ class PMA_PageSettings
|
||||
|
||||
// Process form
|
||||
$error = null;
|
||||
$this->_processPageSettings($form_display, $cf, $error);
|
||||
if (isset($_POST['submit_save']) && $_POST['submit_save'] == $formGroupName) {
|
||||
$this->_processPageSettings($form_display, $cf, $error);
|
||||
}
|
||||
|
||||
// Display forms
|
||||
$this->_displayPageSettings($form_display, $error);
|
||||
$this->_HTML = $this->_getPageSettingsDisplay($form_display, $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process response to form
|
||||
*
|
||||
* @param FormDisplay $form_display Form
|
||||
* @param ConfigFile $cf Configuration file
|
||||
* @param PMA_Message $error Error message
|
||||
* @param FormDisplay &$form_display Form
|
||||
* @param ConfigFile &$cf Configuration file
|
||||
* @param PMA_Message|null &$error Error message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -97,62 +114,109 @@ class PMA_PageSettings
|
||||
}
|
||||
|
||||
/**
|
||||
* Display page-related settings
|
||||
* Store errors in _errorHTML
|
||||
*
|
||||
* @param FormDisplay $form_display Form
|
||||
* @param PMA_Message $error Error message
|
||||
* @param FormDisplay &$form_display Form
|
||||
* @param PMA_Message|null &$error Error message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _displayPageSettings(&$form_display, &$error)
|
||||
private function _storeError(&$form_display, &$error)
|
||||
{
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('config.js');
|
||||
$scripts->addFile('page_settings.js');
|
||||
|
||||
$retval = '';
|
||||
if ($error) {
|
||||
$response->addHTML($error->getDisplay());
|
||||
$retval .= $error->getDisplay();
|
||||
}
|
||||
if ($form_display->hasErrors()) {
|
||||
// form has errors
|
||||
$response->addHTML(
|
||||
'<div class="error config-form">'
|
||||
$retval .= '<div class="error config-form">'
|
||||
. '<b>' . __(
|
||||
'Cannot save settings, submitted configuration form contains '
|
||||
. 'errors!'
|
||||
) . '</b>'
|
||||
. $form_display->displayErrors()
|
||||
. '</div>'
|
||||
);
|
||||
. '</div>';
|
||||
}
|
||||
$this->_errorHTML = $retval;
|
||||
}
|
||||
|
||||
$response->addHTML('<div class="page_settings_modal">');
|
||||
$response->addHTML(
|
||||
$form_display->getDisplay(
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
$response->getFooter()->getSelfUrl('unencoded'),
|
||||
array(
|
||||
'submit_save' => 'Submit'
|
||||
)
|
||||
/**
|
||||
* Display page-related settings
|
||||
*
|
||||
* @param FormDisplay $form_display Form
|
||||
* @param PMA_Message $error Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getPageSettingsDisplay(&$form_display, &$error)
|
||||
{
|
||||
$response = PMA_Response::getInstance();
|
||||
|
||||
$retval = '';
|
||||
|
||||
$this->_storeError($form_display, $error);
|
||||
|
||||
$retval .= '<div id="' . $this->_elemId . '">';
|
||||
$retval .= $form_display->getDisplay(
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
$response->getFooter()->getSelfUrl('unencoded'),
|
||||
array(
|
||||
'submit_save' => $this->_groupName
|
||||
)
|
||||
);
|
||||
$response->addHTML('</div>');
|
||||
$retval .= '</div>';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHTML()
|
||||
{
|
||||
return $this->_HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error HTML output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorHTML()
|
||||
{
|
||||
return $this->_errorHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Group to show for Page-related settings
|
||||
* @param string $formGroupName The name of config form group to display
|
||||
* @return PMA_PageSettings|false
|
||||
* @return PMA_PageSettings
|
||||
*/
|
||||
public static function showGroup($formGroupName)
|
||||
{
|
||||
if (!self::$_initiated) {
|
||||
return new PMA_PageSettings($formGroupName);
|
||||
}
|
||||
return false;
|
||||
$object = new PMA_PageSettings($formGroupName);
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addHTML($object->getErrorHTML());
|
||||
$response->addHTML($object->getHTML());
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML for navigation settings
|
||||
* @return string
|
||||
*/
|
||||
public static function getNaviSettings()
|
||||
{
|
||||
$object = new PMA_PageSettings('Navi_panel', 'pma_navigation_settings');
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addHTML($object->getErrorHTML());
|
||||
return $object->getHTML();
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +60,11 @@ class PMA_Navigation
|
||||
if (! PMA_Response::getInstance()->isAjax()) {
|
||||
// closes the tags that were opened by the navigation header
|
||||
$retval .= '</div>'; // pma_navigation_tree
|
||||
$retval .= '<div id="pma_navi_settings_container">';
|
||||
if (!defined('PMA_disableNaviSettings')) {
|
||||
$retval .= PMA_PageSettings::getNaviSettings();
|
||||
}
|
||||
$retval .= '</div>'; //pma_navi_settings_container
|
||||
$retval .= '</div>'; // pma_navigation_content
|
||||
$retval .= $this->_getDropHandler();
|
||||
$retval .= '</div>'; // pma_navigation
|
||||
|
||||
@ -186,6 +186,17 @@ class PMA_NavigationHeader
|
||||
false,
|
||||
'mysql_doc'
|
||||
);
|
||||
$retval .= PMA_Util::getNavigationLink(
|
||||
'#',
|
||||
$showText,
|
||||
__('Navigation panel settings'),
|
||||
$showIcon,
|
||||
's_cog.png',
|
||||
'pma_navigation_settings_icon',
|
||||
false,
|
||||
'',
|
||||
defined('PMA_disableNaviSettings') ? array('hide') : array()
|
||||
);
|
||||
$retval .= PMA_Util::getNavigationLink(
|
||||
'#',
|
||||
$showText,
|
||||
|
||||
@ -23,6 +23,11 @@ if (! $response->isAjax()) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['getNaviSettings']) && $_REQUEST['getNaviSettings']) {
|
||||
$response->addJSON('message', PMA_PageSettings::getNaviSettings());
|
||||
exit();
|
||||
}
|
||||
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
if (isset($cfgRelation['navwork']) && $cfgRelation['navwork']) {
|
||||
if (isset($_REQUEST['hideNavItem'])) {
|
||||
|
||||
@ -90,3 +90,9 @@ if ($form_display->hasErrors()) {
|
||||
<?php
|
||||
}
|
||||
echo $form_display->getDisplay(true, true);
|
||||
|
||||
if ($response->isAjax()) {
|
||||
$response->addJSON('_disableNaviSettings', true);
|
||||
} else {
|
||||
define('PMA_disableNaviSettings', true);
|
||||
}
|
||||
|
||||
@ -375,3 +375,10 @@ if (file_exists('setup/index.php')) {
|
||||
</div>
|
||||
<br class="clearfloat" />
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($response->isAjax()) {
|
||||
$response->addJSON('_disableNaviSettings', true);
|
||||
} else {
|
||||
define('PMA_disableNaviSettings', true);
|
||||
}
|
||||
|
||||
@ -556,12 +556,16 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase
|
||||
$result = PMA_displayJavascript(array('var i = 1', 'i++'));
|
||||
|
||||
$this->assertEquals(
|
||||
"<script type=\"text/javascript\">\n" .
|
||||
"function configInlineParams() {\n" .
|
||||
"var i = 1;\n" .
|
||||
"i++;\n" .
|
||||
"};\n" .
|
||||
"</script>\n",
|
||||
'<script type="text/javascript">' . "\n"
|
||||
. 'if (typeof configInlineParams === "undefined"'
|
||||
. ' || !Array.isArray(configInlineParams)) configInlineParams = [];' . "\n"
|
||||
. 'configInlineParams.push(function() {' . "\n"
|
||||
. 'var i = 1;' . "\n"
|
||||
. 'i++;' . "\n"
|
||||
. '});' . "\n"
|
||||
. 'if (typeof configScriptLoaded !== "undefined"'
|
||||
. ' && configInlineParams) loadInlineConfig();' . "\n"
|
||||
. '</script>' . "\n",
|
||||
$result
|
||||
);
|
||||
}
|
||||
|
||||
89
test/libraries/PMA_page_settings_test.php
Normal file
89
test/libraries/PMA_page_settings_test.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for Page-related settings
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/config/page_settings.class.php';
|
||||
|
||||
/**
|
||||
* Tests for Page-related settings
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class PMA_PageSettings_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Setup tests
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$GLOBALS['server'] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test showGroup when group passed does not exist
|
||||
*/
|
||||
public function testShowGroupNonExistent()
|
||||
{
|
||||
$object = PMA_PageSettings::showGroup('NonExistent');
|
||||
|
||||
$this->assertEquals('', $object->getHTML());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test showGroup with a known group name
|
||||
*/
|
||||
public function testShowGroupBrowse()
|
||||
{
|
||||
$object = PMA_PageSettings::showGroup('Browse');
|
||||
|
||||
$html = $object->getHTML();
|
||||
|
||||
// Test some sample parts
|
||||
$this->assertContains(
|
||||
'<div id="page_settings_modal">'
|
||||
. '<form method="post" '
|
||||
. 'action="phpunit?db=&table=&server=1&target=&lang=en&token=token" '
|
||||
. 'class="config-form disableAjax">',
|
||||
$html
|
||||
);
|
||||
|
||||
$this->assertContains(
|
||||
'<input type="hidden" name="submit_save" value="Browse" />',
|
||||
$html
|
||||
);
|
||||
|
||||
$this->assertContains(
|
||||
"validateField('MaxRows', 'PMA_validatePositiveNumber', true);\n"
|
||||
. "validateField('RepeatCells', 'PMA_validateNonNegativeNumber', true);\n"
|
||||
. "validateField('LimitChars', 'PMA_validatePositiveNumber', true);\n",
|
||||
$html
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getNaviSettings
|
||||
*/
|
||||
function testGetNaviSettings()
|
||||
{
|
||||
$html = PMA_PageSettings::getNaviSettings();
|
||||
|
||||
// Test some sample parts
|
||||
$this->assertContains(
|
||||
'<div id="pma_navigation_settings">',
|
||||
$html
|
||||
);
|
||||
|
||||
$this->assertContains(
|
||||
'<input type="hidden" name="submit_save" value="Navi_panel" />',
|
||||
$html
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -43,7 +43,7 @@ class PMA_MessagesIncTest extends PHPUnit_Framework_TestCase
|
||||
$strConfigSQLQuery_Explain_name = '';
|
||||
$strConfigSendErrorReports_name = '';
|
||||
|
||||
include_once 'libraries/config/messages.inc.php';
|
||||
include 'libraries/config/messages.inc.php';
|
||||
|
||||
$this->assertEquals(
|
||||
'Allow login to any MySQL server',
|
||||
|
||||
@ -838,7 +838,11 @@ div#tablestatistics table {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page_settings_modal {
|
||||
#page_settings_modal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#pma_navigation_settings {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@ -1164,7 +1164,11 @@ div#tablestatistics table {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page_settings_modal {
|
||||
#page_settings_modal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#pma_navigation_settings {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user