Skip to content

Commit

Permalink
Merge branch 'master' into templates
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Nov 1, 2017
2 parents d223781 + 069cb02 commit 569ee91
Show file tree
Hide file tree
Showing 34 changed files with 207 additions and 262 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ phpMyAdmin - ChangeLog
- issue Support JSON datatype on MariaDB 10.2.7 and newer

4.7.6 (not yet released)
- issue #13517 Fixed check all interaction with filtering

4.7.5 (2017-10-23)
- issue #13615 Avoid problems with browsing unknown query types
Expand Down
3 changes: 3 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,7 @@
r'https://software.opensuse.org/package/.*',
# They have messed up SSL setup
r'https://php-myadmin.ru/.*',
# There seems to be some problem with SNI on Travis CI
r'https://www.phpmyadmin.net/.*',
r'https://files.phpmyadmin.net/.*',
]
10 changes: 5 additions & 5 deletions gis_data_editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ function escape($variable)
echo Url::getHiddenInputs();

echo '<!-- Visualization section -->';
echo '<div id="placeholder" style="width:450px;height:300px;'
, ($srid != 0 ? 'display:none;' : '') , '">';
echo '<div id="placeholder" '
, ($srid != 0 ? 'class="hide' : '') , '">';
echo $visualization;
echo '</div>';

echo '<div id="openlayersmap" style="width:450px;height:300px;'
, ($srid == 0 ? 'display:none;' : '') , '">';
echo '<div id="openlayersmap" '
, ($srid == 0 ? 'class="hide' : '') , '">';
echo '</div>';

echo '<div class="choice floatright" style="clear:right;">';
echo '<div class="choice floatright">';
echo '<input type="checkbox" id="choice" value="useBaseLayer"'
, ($srid != 0 ? ' checked="checked"' : '') , '/>';
echo '<label for="choice">' , __("Use OpenStreetMaps as Base Layer") , '</label>';
Expand Down
21 changes: 0 additions & 21 deletions js/db_structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ AJAX.registerTeardown('db_structure.js', function () {
$('a.real_row_count').off('click');
$('a.row_count_sum').off('click');
$('select[name=submit_mult]').off('change');
$('#filterText').off('keyup');
});

/**
Expand Down Expand Up @@ -212,26 +211,6 @@ AJAX.registerOnload('db_structure.js', function () {
});
};

/**
* Filtering tables on table listing of particular database
*
*/
$('#filterText').keyup(function () {
var filterInput = $(this).val().toUpperCase();
var structureTable = $('#structureTable')[0];
$('#structureTable tbody tr').each(function () {
var tr = $(this);
var a = tr.find('a')[0];
if (a) {
if (a.text.trim().toUpperCase().indexOf(filterInput) > -1) {
tr[0].style.display = '';
} else {
tr[0].style.display = 'none';
}
}
});
});

/**
* Event handler on select of "Make consistent with central list"
*/
Expand Down
85 changes: 46 additions & 39 deletions js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,44 +1091,6 @@ AJAX.registerOnload('functions.js', function () {
}
});

/**
* Row highlighting in horizontal mode (use "on"
* so that it works also for pages reached via AJAX)
*/
/* AJAX.registerOnload('functions.js', function () {
$(document).on('hover', 'tr',function (event) {
var $tr = $(this);
$tr.toggleClass('hover',event.type=='mouseover');
$tr.children().toggleClass('hover',event.type=='mouseover');
});
})*/

/**
* marks all rows and selects its first checkbox inside the given element
* the given element is usually a table or a div containing the table or tables
*
* @param container DOM element
*/
function markAllRows (container_id) {
$('#' + container_id).find('input:checkbox:enabled').prop('checked', true)
.trigger('change')
.parents('tr').addClass('marked');
return true;
}

/**
* marks all rows and selects its first checkbox inside the given element
* the given element is usually a table or a div containing the table or tables
*
* @param container DOM element
*/
function unMarkAllRows (container_id) {
$('#' + container_id).find('input:checkbox:enabled').prop('checked', false)
.trigger('change')
.parents('tr').removeClass('marked');
return true;
}

/**
* Checks/unchecks all options of a <select> element
*
Expand Down Expand Up @@ -4687,10 +4649,19 @@ $(document).on('change', checkboxes_sel, checkboxes_changed);

$(document).on('change', 'input.checkall_box', function () {
var is_checked = $(this).is(':checked');
$(this.form).find(checkboxes_sel).prop('checked', is_checked)
$(this.form).find(checkboxes_sel).not('.row-hidden').prop('checked', is_checked)
.parents('tr').toggleClass('marked', is_checked);
});

$(document).on('click', '.checkall-filter', function () {
var $this = $(this);
var selector = $this.data('checkall-selector');
$('input.checkall_box').prop('checked', false);
$this.parents('form').find(checkboxes_sel).filter(selector).prop('checked', true).trigger('change')
.parents('tr').toggleClass('marked', true);
return false;
});

/**
* Watches checkboxes in a sub form to set the sub checkall box accordingly
*/
Expand Down Expand Up @@ -4718,6 +4689,42 @@ $(document).on('change', 'input.sub_checkall_box', function () {
.parents('tr').toggleClass('marked', is_checked);
});

/**
* Rows filtering
*
* - rows to filter are identified by data-filter-row attribute
* which contains uppercase string to filter
* - it is simple substring case insensitive search
* - optionally number of matching rows is written to element with
* id filter-rows-count
*/
$(document).on('keyup', '#filterText', function () {
var filterInput = $(this).val().toUpperCase();
var count = 0;
$('[data-filter-row]').each(function () {
var $row = $(this);
console.log($row);
/* Can not use data() here as it does magic conversion to int for numeric values */
if ($row.attr('data-filter-row').indexOf(filterInput) > -1) {
count += 1;
$row.show();
$row.find('input.checkall').removeClass('row-hidden').trigger('change');
} else {
$row.hide();
$row.find('input.checkall').addClass('row-hidden').prop('checked', false).trigger('change');
$row.removeClass('marked');
}
});
$('#filter-rows-count').html(count);
});
AJAX.registerOnload('functions.js', function () {
/* Trigger filtering of the list based on incoming database name */
var $filter = $('#filterText');
if ($filter.val()) {
$filter.trigger('keyup').select();
}
});

/**
* Formats a byte number to human-readable form
*
Expand Down
49 changes: 3 additions & 46 deletions js/server_databases.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
AJAX.registerTeardown('server_databases.js', function () {
$(document).off('submit', '#dbStatsForm');
$(document).off('submit', '#create_database_form.ajax');
$('#filterText').off('keyup');
});

/**
Expand Down Expand Up @@ -71,7 +70,7 @@ AJAX.registerOnload('server_databases.js', function () {
PMA_ajaxShowMessage(data.message);

var $rowsToRemove = $form.find('tr.removeMe');
var $databasesCount = $('#databases_count');
var $databasesCount = $('#filter-rows-count');
var newCount = parseInt($databasesCount.text(), 10) - $rowsToRemove.length;
$databasesCount.text(newCount);

Expand Down Expand Up @@ -115,7 +114,7 @@ AJAX.registerOnload('server_databases.js', function () {
if (typeof data !== 'undefined' && data.success === true) {
PMA_ajaxShowMessage(data.message);

var $databases_count_object = $('#databases_count');
var $databases_count_object = $('#filter-rows-count');
var databases_count = parseInt($databases_count_object.text(), 10) + 1;
$databases_count_object.text(databases_count);
PMA_reloadNavigation();
Expand All @@ -135,53 +134,11 @@ AJAX.registerOnload('server_databases.js', function () {
}); // end $(document).on()

/* Don't show filter if number of databases are very few */
var databasesCount = $('#databases_count').html();
var databasesCount = $('#filter-rows-count').html();
if (databasesCount <= 10) {
$('#tableFilter').hide();
}

var $filterField = $('#filterText');
/* Event handler for database filter */
$filterField.keyup(function () {
var textFilter = null;
var val = $(this).val();
if (val.length !== 0) {
try {
textFilter = new RegExp(val.replace(/_/g, ' '), 'i');
$(this).removeClass('error');
} catch (e) {
if (e instanceof SyntaxError) {
$(this).addClass('error');
textFilter = null;
}
}
}
filterVariables(textFilter);
});

/* Trigger filtering of the list based on incoming database name */
if ($filterField.val()) {
$filterField.trigger('keyup').select();
}

/* Filters the rows by the user given regexp */
function filterVariables (textFilter) {
var $row;
var databasesCount = 0;
$('#tabledatabases').find('.db-row').each(function () {
$row = $(this);
if (textFilter === null ||
textFilter.exec($row.find('.name').text())
) {
$row.css('display', '');
databasesCount += 1;
} else {
$row.css('display', 'none');
}
$('#databases_count').html(databasesCount);
});
}

var tableRows = $('.server_databases');
$.each(tableRows, function (index, item) {
$(this).click(function () {
Expand Down
45 changes: 0 additions & 45 deletions js/server_variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Unbind all event handlers before tearing down a page
*/
AJAX.registerTeardown('server_variables.js', function () {
$('#filterText').off('keyup');
$(document).off('click', 'a.editLink');
$('#serverVariables').find('.var-name').find('a img').remove();
});
Expand All @@ -13,8 +12,6 @@ AJAX.registerOnload('server_variables.js', function () {
var $editLink = $('a.editLink');
var $saveLink = $('a.saveLink');
var $cancelLink = $('a.cancelLink');
var $filterField = $('#filterText');


$('#serverVariables').find('.var-name').find('a').append(
$('#docImage').clone().show()
Expand All @@ -26,48 +23,6 @@ AJAX.registerOnload('server_variables.js', function () {
editVariable(this);
});

/* Event handler for variables filter */
$filterField.keyup(function () {
var textFilter = null;
var val = $(this).val();
if (val.length !== 0) {
try {
textFilter = new RegExp('(^| )' + val.replace(/_/g, ' '), 'i');
$(this).removeClass('error');
} catch (e) {
if (e instanceof SyntaxError) {
$(this).addClass('error');
textFilter = null;
}
}
}
filterVariables(textFilter);
});

/* Trigger filtering of the list based on incoming variable name */
if ($filterField.val()) {
$filterField.trigger('keyup').select();
}

/* Filters the rows by the user given regexp */
function filterVariables (textFilter) {
var mark_next = false;
var $row;
$('#serverVariables').find('.var-row').not('.var-header').each(function () {
$row = $(this);
if (mark_next || textFilter === null ||
textFilter.exec($row.find('.var-name').text())
) {
// If current global value is different from session value
// (has class diffSession), then display that one too
mark_next = $row.hasClass('diffSession') && ! mark_next;
$row.css('display', '');
} else {
$row.css('display', 'none');
}
});
}

/* Allows the user to edit a server variable */
function editVariable (link) {
var $link = $(link);
Expand Down
6 changes: 4 additions & 2 deletions libraries/classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1025,18 +1025,19 @@ public function loadUserPreferences()
* @param mixed $new_cfg_value new value
* @param mixed $default_value default value
*
* @return void
* @return true|PhpMyAdmin\Message
*/
public function setUserValue($cookie_name, $cfg_path, $new_cfg_value,
$default_value = null
) {
$result = true;
// use permanent user preferences if possible
$prefs_type = $this->get('user_preferences');
if ($prefs_type) {
if ($default_value === null) {
$default_value = Core::arrayRead($cfg_path, $this->default);
}
UserPreferences::persistOption($cfg_path, $new_cfg_value, $default_value);
$result = UserPreferences::persistOption($cfg_path, $new_cfg_value, $default_value);
}
if ($prefs_type != 'db' && $cookie_name) {
// fall back to cookies
Expand All @@ -1047,6 +1048,7 @@ public function setUserValue($cookie_name, $cfg_path, $new_cfg_value,
}
Core::arrayWrite($cfg_path, $GLOBALS['cfg'], $new_cfg_value);
Core::arrayWrite($cfg_path, $this->settings, $new_cfg_value);
return $result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ protected function displayTableList()
);

$i = $sum_entries = 0;
$overhead_check = '';
$overhead_check = false;
$create_time_all = '';
$update_time_all = '';
$check_time_all = '';
Expand All @@ -410,6 +410,7 @@ protected function displayTableList()
$drop_query = '';
$drop_message = '';
$overhead = '';
$input_class = ['checkall'];

$table_is_view = false;
// Sets parameters for links
Expand Down Expand Up @@ -445,8 +446,8 @@ protected function displayTableList()
. '<span>' . $formatted_overhead . '</span>&nbsp;'
. '<span class="unit">' . $overhead_unit . '</span>'
. '</a>' . "\n";
$overhead_check .=
"markAllRows('row_tbl_" . ($i + 1) . "');";
$overhead_check = true;
$input_class[] = 'tbl-overhead';
} else {
$overhead = '-';
}
Expand Down Expand Up @@ -637,6 +638,7 @@ protected function displayTableList()
array(
'db' => $this->db,
'curr' => $i,
'input_class' => implode(' ', $input_class),
'table_is_view' => $table_is_view,
'current_table' => $current_table,
'browse_table_label' => $browse_table_label,
Expand Down
Loading

0 comments on commit 569ee91

Please sign in to comment.