diff --git a/js/config.js b/js/config.js
index 6c7e7bb5e1..d6afdf1ab0 100644
--- a/js/config.js
+++ b/js/config.js
@@ -331,6 +331,10 @@ function getFieldValidators(field_id, onKeyUpOnly)
*/
function displayErrors(error_list)
{
+ var tempIsEmpty = function (item) {
+ return item !== '';
+ };
+
for (var field_id in error_list) {
var errors = error_list[field_id];
var field = $('#' + field_id);
@@ -343,9 +347,7 @@ function displayErrors(error_list)
}
// remove empty errors (used to clear error list)
- errors = $.grep(errors, function (item) {
- return item !== '';
- });
+ errors = $.grep(errors, tempIsEmpty);
// CSS error class
if (!isFieldset) {
diff --git a/js/functions.js b/js/functions.js
index dc445dac0e..3c2df6aaa9 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -434,7 +434,6 @@ function confirmQuery(theForm1, sqlQuery1)
*/
function checkSqlQuery(theForm)
{
- var sqlQuery;
// get the textarea element containing the query
var sqlQuery;
if (codemirror_editor) {
@@ -3107,6 +3106,18 @@ AJAX.registerOnload('functions.js', function () {
.closest('fieldset')
.find('.slider')
.slider('value');
+
+ var tempEmptyVal = function () {
+ $(this).val('');
+ };
+
+ var tempSetFocus = function () {
+ if ($(this).find("option:selected").val() === '') {
+ return true;
+ }
+ $(this).closest("tr").find("input").focus();
+ };
+
while (rows_to_add--) {
var $newrow = $('#index_columns')
.find('tbody > tr:first')
@@ -3114,16 +3125,9 @@ AJAX.registerOnload('functions.js', function () {
.appendTo(
$('#index_columns').find('tbody')
);
- $newrow.find(':input').each(function () {
- $(this).val('');
- });
+ $newrow.find(':input').each(tempEmptyVal);
// focus index size input on column picked
- $newrow.find('select').change(function () {
- if ($(this).find("option:selected").val() === '') {
- return true;
- }
- $(this).closest("tr").find("input").focus();
- });
+ $newrow.find('select').change(tempSetFocus);
}
});
});
diff --git a/js/makegrid.js b/js/makegrid.js
index 569dbee045..aedaae3131 100644
--- a/js/makegrid.js
+++ b/js/makegrid.js
@@ -1607,6 +1607,13 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
// add column visibility control
g.cList.innerHTML = '
';
var $listDiv = $(g.cList).find('div');
+
+ var tempClick = function () {
+ if (g.toggleCol($(this).index())) {
+ g.afterToggleCol();
+ }
+ };
+
for (var i = 0; i < $firstRowCols.length; i++) {
var currHeader = $firstRowCols[i];
var listElmt = document.createElement('div');
@@ -1614,11 +1621,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
.prepend('');
$listDiv.append(listElmt);
// add event on click
- $(listElmt).click(function () {
- if (g.toggleCol($(this).index())) {
- g.afterToggleCol();
- }
- });
+ $(listElmt).click(tempClick);
}
// add "show all column" button
var showAll = document.createElement('div');
diff --git a/js/navigation.js b/js/navigation.js
index 912ac5b324..b7b037e61a 100644
--- a/js/navigation.js
+++ b/js/navigation.js
@@ -240,20 +240,20 @@ $(function () {
event.preventDefault();
$self = $(this);
var anchor_id = $self.attr("id");
- if($self.data("favtargetn") !== null)
+ if($self.data("favtargetn") !== null) {
if($('a[data-favtargets="' + $self.data("favtargetn") + '"]').length > 0)
{
$('a[data-favtargets="' + $self.data("favtargetn") + '"]').trigger('click');
return;
}
+ }
$.ajax({
url: $self.attr('href'),
cache: false,
type: 'POST',
data: {
- favorite_tables: (window.localStorage.favorite_tables
- !== undefined)
+ favorite_tables: (window.localStorage.favorite_tables !== undefined)
? window.localStorage.favorite_tables
: ''
},
@@ -268,8 +268,7 @@ $(function () {
);
// Update localStorage.
if (window.localStorage !== undefined) {
- window.localStorage.favorite_tables
- = data.favorite_tables;
+ window.localStorage.favorite_tables = data.favorite_tables;
}
} else {
PMA_ajaxShowMessage(data.message);
@@ -1252,8 +1251,9 @@ function PMA_showFullName($containerELem) {
/** mouseenter */
var $this = $(this);
var thisOffset = $this.offset();
- if($this.text() === '')
+ if($this.text() === '') {
return;
+ }
var $parent = $this.parent();
if( ($parent.offset().left + $parent.outerWidth())
< (thisOffset.left + $this.outerWidth()))
diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js
index 2f0b090696..3325ab5875 100644
--- a/js/server_status_monitor.js
+++ b/js/server_status_monitor.js
@@ -413,18 +413,27 @@ AJAX.registerOnload('server_status_monitor.js', function () {
var numColumns;
var $tr = $('#chartGrid tr:first');
var row = 0;
+
+ var tempManageCols = function () {
+ if (numColumns > monitorSettings.columns) {
+ if ($tr.next().length === 0) {
+ $tr.after('
');
+ }
+ $tr.next().prepend($(this));
+ }
+ numColumns++;
+ };
+
+ var tempAddCol = function () {
+ if ($(this).next().length !== 0) {
+ $(this).append($(this).next().find('td:first'));
+ }
+ };
+
while ($tr.length !== 0) {
numColumns = 1;
// To many cells in one row => put into next row
- $tr.find('td').each(function () {
- if (numColumns > monitorSettings.columns) {
- if ($tr.next().length === 0) {
- $tr.after('
');
- }
- $tr.next().prepend($(this));
- }
- numColumns++;
- });
+ $tr.find('td').each(tempManageCols);
// To little cells in one row => for each cell to little,
// move all cells backwards by 1
@@ -432,11 +441,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
var cnt = monitorSettings.columns - $tr.find('td').length;
for (var i = 0; i < cnt; i++) {
$tr.append($tr.next().find('td:first'));
- $tr.nextAll().each(function () {
- if ($(this).next().length !== 0) {
- $(this).append($(this).next().find('td:first'));
- }
- });
+ $tr.nextAll().each(tempAddCol);
}
}
@@ -1150,44 +1155,46 @@ AJAX.registerOnload('server_status_monitor.js', function () {
series.push([[0, 0]]);
}
+ var tempTooltipContentEditor = function (str, seriesIndex, pointIndex, plot) {
+ var j;
+ // TODO: move style to theme CSS
+ var tooltipHtml = '
';
+ // x value i.e. time
+ var timeValue = str.split(",")[0];
+ var seriesValue;
+ tooltipHtml += 'Time: ' + timeValue;
+ tooltipHtml += '';
+ // Add y values to the tooltip per series
+ for (j in plot.series) {
+ // get y value if present
+ if (plot.series[j].data.length > pointIndex) {
+ seriesValue = plot.series[j].data[pointIndex][1];
+ } else {
+ return;
+ }
+ var seriesLabel = plot.series[j].label;
+ var seriesColor = plot.series[j].color;
+ // format y value
+ if (plot.series[0]._yaxis.tickOptions.formatter) {
+ // using formatter function
+ seriesValue = plot.series[0]._yaxis.tickOptions.formatter('%s', seriesValue);
+ } else if (plot.series[0]._yaxis.tickOptions.formatString) {
+ // using format string
+ seriesValue = $.sprintf(plot.series[0]._yaxis.tickOptions.formatString, seriesValue);
+ }
+ tooltipHtml += ' ' +
+ seriesLabel + ': ' + seriesValue + '';
+ }
+ tooltipHtml += '
';
+ return tooltipHtml;
+ };
+
// set Tooltip for each series
for (i in settings.series) {
settings.series[i].highlighter = {
show: true,
- tooltipContentEditor: function (str, seriesIndex, pointIndex, plot) {
- var j;
- // TODO: move style to theme CSS
- var tooltipHtml = '
';
- // x value i.e. time
- var timeValue = str.split(",")[0];
- var seriesValue;
- tooltipHtml += 'Time: ' + timeValue;
- tooltipHtml += '';
- // Add y values to the tooltip per series
- for (j in plot.series) {
- // get y value if present
- if (plot.series[j].data.length > pointIndex) {
- seriesValue = plot.series[j].data[pointIndex][1];
- } else {
- return;
- }
- var seriesLabel = plot.series[j].label;
- var seriesColor = plot.series[j].color;
- // format y value
- if (plot.series[0]._yaxis.tickOptions.formatter) {
- // using formatter function
- seriesValue = plot.series[0]._yaxis.tickOptions.formatter('%s', seriesValue);
- } else if (plot.series[0]._yaxis.tickOptions.formatString) {
- // using format string
- seriesValue = $.sprintf(plot.series[0]._yaxis.tickOptions.formatString, seriesValue);
- }
- tooltipHtml += ' ' +
- seriesLabel + ': ' + seriesValue + '';
- }
- tooltipHtml += '
';
- return tooltipHtml;
- }
+ tooltipContentEditor: tempTooltipContentEditor
};
}
@@ -1854,6 +1861,10 @@ AJAX.registerOnload('server_status_monitor.js', function () {
$('#logTable').html($table);
+ var tempPushKey = function (key, value) {
+ cols.push(key);
+ };
+
var formatValue = function (name, value) {
if (name == 'user_host') {
return value.replace(/(\[.*?\])+/g, '');
@@ -1863,9 +1874,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
for (var i = 0, l = rows.length; i < l; i++) {
if (i === 0) {
- $.each(rows[0], function (key, value) {
- cols.push(key);
- });
+ $.each(rows[0], tempPushKey);
$table.append('' +
'
' + cols.join('
') + '
' +
''
@@ -2011,19 +2020,22 @@ AJAX.registerOnload('server_status_monitor.js', function () {
explain += ')';
}
explain += '';
+
+ var tempExplain = function (key, value) {
+ value = (value === null) ? 'null' : value;
+
+ if (key == 'type' && value.toLowerCase() == 'all') {
+ value = '' + value + '';
+ }
+ if (key == 'Extra') {
+ value = value.replace(/(using (temporary|filesort))/gi, '$1');
+ }
+ explain += key + ': ' + value + ' ';
+ };
+
for (i = 0, l = data.explain.length; i < l; i++) {
explain += '
0 ? 'style="display:none;"' : '') + '>';
- $.each(data.explain[i], function (key, value) {
- value = (value === null) ? 'null' : value;
-
- if (key == 'type' && value.toLowerCase() == 'all') {
- value = '' + value + '';
- }
- if (key == 'Extra') {
- value = value.replace(/(using (temporary|filesort))/gi, '$1');
- }
- explain += key + ': ' + value + ' ';
- });
+ $.each(data.explain[i], tempExplain);
explain += '
';
}
diff --git a/js/tbl_change.js b/js/tbl_change.js
index 3a9111e96a..c8d684e901 100644
--- a/js/tbl_change.js
+++ b/js/tbl_change.js
@@ -362,6 +362,109 @@ AJAX.registerOnload('tbl_change.js', function () {
});
if (curr_rows < target_rows) {
+
+ var tempIncrementIndex = function () {
+
+ var $this_element = $(this);
+ /**
+ * Extract the index from the name attribute for all input/select fields and increment it
+ * name is of format funcs[multi_edit][10][]
+ */
+
+ /**
+ * @var this_name String containing name of the input/select elements
+ */
+ var this_name = $this_element.attr('name');
+ /** split {@link this_name} at [10], so we have the parts that can be concatenated later */
+ var name_parts = this_name.split(/\[\d+\]/);
+ /** extract the [10] from {@link name_parts} */
+ var old_row_index_string = this_name.match(/\[\d+\]/)[0];
+ /** extract 10 - had to split into two steps to accomodate double digits */
+ var old_row_index = parseInt(old_row_index_string.match(/\d+/)[0], 10);
+
+ /** calculate next index i.e. 11 */
+ new_row_index = old_row_index + 1;
+ /** generate the new name i.e. funcs[multi_edit][11][foobarbaz] */
+ var new_name = name_parts[0] + '[' + new_row_index + ']' + name_parts[1];
+
+ var hashed_field = name_parts[1].match(/\[(.+)\]/)[1];
+ $this_element.attr('name', new_name);
+
+ /** If element is select[name*='funcs'], update id */
+ if ($this_element.is("select[name*='funcs']")) {
+ var this_id = $this_element.attr("id");
+ var id_parts = this_id.split(/\_/);
+ var old_id_index = id_parts[1];
+ var prevSelectedValue = $("#field_" + old_id_index + "_1").val();
+ var new_id_index = parseInt(old_id_index) + columnCount;
+ var new_id = 'field_' + new_id_index + '_1';
+ $this_element.attr('id', new_id);
+ $this_element.find("option").filter(function () {
+ return $(this).text() === prevSelectedValue;
+ }).attr("selected","selected");
+
+ // If salt field is there then update its id.
+ var nextSaltInput = $this_element.parent().next("td").next("td").find("input[name*='salt']");
+ if (nextSaltInput.length !== 0) {
+ nextSaltInput.attr("id", "salt_" + new_id);
+ }
+ }
+
+ // handle input text fields and textareas
+ if ($this_element.is('.textfield') || $this_element.is('.char')) {
+ // do not remove the 'value' attribute for ENUM columns
+ if ($this_element.closest('tr').find('span.column_type').html() != 'enum') {
+ $this_element.val($this_element.closest('tr').find('span.default_value').html());
+ }
+ $this_element
+ .unbind('change')
+ // Remove onchange attribute that was placed
+ // by tbl_change.php; it refers to the wrong row index
+ .attr('onchange', null)
+ // Keep these values to be used when the element
+ // will change
+ .data('hashed_field', hashed_field)
+ .data('new_row_index', new_row_index)
+ .bind('change', function (e) {
+ var $changed_element = $(this);
+ verificationsAfterFieldChange(
+ $changed_element.data('hashed_field'),
+ $changed_element.data('new_row_index'),
+ $changed_element.closest('tr').find('span.column_type').html()
+ );
+ });
+ }
+
+ if ($this_element.is('.checkbox_null')) {
+ $this_element
+ // this event was bound earlier by jQuery but
+ // to the original row, not the cloned one, so unbind()
+ .unbind('click')
+ // Keep these values to be used when the element
+ // will be clicked
+ .data('hashed_field', hashed_field)
+ .data('new_row_index', new_row_index)
+ .bind('click', function (e) {
+ var $changed_element = $(this);
+ nullify(
+ $changed_element.siblings('.nullify_code').val(),
+ $this_element.closest('tr').find('input:hidden').first().val(),
+ $changed_element.data('hashed_field'),
+ '[multi_edit][' + $changed_element.data('new_row_index') + ']'
+ );
+ });
+ }
+ };
+
+ var tempReplaceAnchor = function () {
+ var $anchor = $(this);
+ var new_value = 'rownumber=' + new_row_index;
+ // needs improvement in case something else inside
+ // the href contains this pattern
+ var new_href = $anchor.attr('href').replace(/rownumber=\d+/, new_value);
+ $anchor.attr('href', new_href);
+ };
+
while (curr_rows < target_rows) {
/**
@@ -379,108 +482,10 @@ AJAX.registerOnload('tbl_change.js', function () {
.clone(true, true)
.insertBefore("#actions_panel")
.find('input[name*=multi_edit],select[name*=multi_edit],textarea[name*=multi_edit]')
- .each(function () {
-
- var $this_element = $(this);
- /**
- * Extract the index from the name attribute for all input/select fields and increment it
- * name is of format funcs[multi_edit][10][]
- */
-
- /**
- * @var this_name String containing name of the input/select elements
- */
- var this_name = $this_element.attr('name');
- /** split {@link this_name} at [10], so we have the parts that can be concatenated later */
- var name_parts = this_name.split(/\[\d+\]/);
- /** extract the [10] from {@link name_parts} */
- var old_row_index_string = this_name.match(/\[\d+\]/)[0];
- /** extract 10 - had to split into two steps to accomodate double digits */
- var old_row_index = parseInt(old_row_index_string.match(/\d+/)[0], 10);
-
- /** calculate next index i.e. 11 */
- new_row_index = old_row_index + 1;
- /** generate the new name i.e. funcs[multi_edit][11][foobarbaz] */
- var new_name = name_parts[0] + '[' + new_row_index + ']' + name_parts[1];
-
- var hashed_field = name_parts[1].match(/\[(.+)\]/)[1];
- $this_element.attr('name', new_name);
-
- /** If element is select[name*='funcs'], update id */
- if ($this_element.is("select[name*='funcs']")) {
- var this_id = $this_element.attr("id");
- var id_parts = this_id.split(/\_/);
- var old_id_index = id_parts[1];
- var prevSelectedValue = $("#field_" + old_id_index + "_1").val();
- var new_id_index = parseInt(old_id_index) + columnCount;
- var new_id = 'field_' + new_id_index + '_1';
- $this_element.attr('id', new_id);
- $this_element.find("option").filter(function () {
- return $(this).text() === prevSelectedValue;
- }).attr("selected","selected");
-
- // If salt field is there then update its id.
- var nextSaltInput = $this_element.parent().next("td").next("td").find("input[name*='salt']");
- if (nextSaltInput.length !== 0) {
- nextSaltInput.attr("id", "salt_" + new_id);
- }
- }
-
- // handle input text fields and textareas
- if ($this_element.is('.textfield') || $this_element.is('.char')) {
- // do not remove the 'value' attribute for ENUM columns
- if ($this_element.closest('tr').find('span.column_type').html() != 'enum') {
- $this_element.val($this_element.closest('tr').find('span.default_value').html());
- }
- $this_element
- .unbind('change')
- // Remove onchange attribute that was placed
- // by tbl_change.php; it refers to the wrong row index
- .attr('onchange', null)
- // Keep these values to be used when the element
- // will change
- .data('hashed_field', hashed_field)
- .data('new_row_index', new_row_index)
- .bind('change', function (e) {
- var $changed_element = $(this);
- verificationsAfterFieldChange(
- $changed_element.data('hashed_field'),
- $changed_element.data('new_row_index'),
- $changed_element.closest('tr').find('span.column_type').html()
- );
- });
- }
-
- if ($this_element.is('.checkbox_null')) {
- $this_element
- // this event was bound earlier by jQuery but
- // to the original row, not the cloned one, so unbind()
- .unbind('click')
- // Keep these values to be used when the element
- // will be clicked
- .data('hashed_field', hashed_field)
- .data('new_row_index', new_row_index)
- .bind('click', function (e) {
- var $changed_element = $(this);
- nullify(
- $changed_element.siblings('.nullify_code').val(),
- $this_element.closest('tr').find('input:hidden').first().val(),
- $changed_element.data('hashed_field'),
- '[multi_edit][' + $changed_element.data('new_row_index') + ']'
- );
- });
- }
- }) // end each
+ .each(tempIncrementIndex)
.end()
.find('.foreign_values_anchor')
- .each(function () {
- var $anchor = $(this);
- var new_value = 'rownumber=' + new_row_index;
- // needs improvement in case something else inside
- // the href contains this pattern
- var new_href = $anchor.attr('href').replace(/rownumber=\d+/, new_value);
- $anchor.attr('href', new_href);
- });
+ .each(tempReplaceAnchor);
//Insert/Clone the ignore checkboxes
if (curr_rows == 1) {
diff --git a/js/tbl_chart.js b/js/tbl_chart.js
index d41764a666..c7415bc724 100644
--- a/js/tbl_chart.js
+++ b/js/tbl_chart.js
@@ -116,8 +116,8 @@ function PMA_queryChart(data, columnNames, settings) {
});
var valueMap = {}, xValue, value;
- var mainAxisName = columnNames[settings.mainAxis]
- var valueColumnName = columnNames[settings.valueColumn]
+ var mainAxisName = columnNames[settings.mainAxis];
+ var valueColumnName = columnNames[settings.valueColumn];
for (var i = 0; i < data.length; i++) {
xValue = data[i][mainAxisName];
value = valueMap[xValue];
diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js
index e7aff887f7..2540efea94 100644
--- a/js/tbl_zoom_plot_jqplot.js
+++ b/js/tbl_zoom_plot_jqplot.js
@@ -287,13 +287,14 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function () {
var xChange = false;
var yChange = false;
var key;
+ var tempGetVal = function () {
+ return $(this).val();
+ };
for (key in selectedRow) {
var oldVal = selectedRow[key];
var newVal = ($('#edit_fields_null_id_' + it).prop('checked')) ? null : $('#edit_fieldID_' + it).val();
if (newVal instanceof Array) { // when the column is of type SET
- newVal = $('#edit_fieldID_' + it).map(function () {
- return $(this).val();
- }).get().join(",");
+ newVal = $('#edit_fieldID_' + it).map(tempGetVal).get().join(",");
}
if (oldVal != newVal) {
selectedRow[key] = newVal;
diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php
index 53536ac515..61ce36ec71 100644
--- a/libraries/Advisor.class.php
+++ b/libraries/Advisor.class.php
@@ -187,7 +187,7 @@ class Advisor
/**
* Splits justification to text and formula.
*
- * @param string $rule the rule
+ * @param array $rule the rule
*
* @return string[]
*/
diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php
index ba17c3e171..06092e53cf 100644
--- a/libraries/DisplayResults.class.php
+++ b/libraries/DisplayResults.class.php
@@ -630,7 +630,6 @@ class PMA_DisplayResults
) {
$table_navigation_html = '';
- $showtable = $this->__get('showtable'); // To use in isset
// here, using htmlentities() would cause problems if the query
// contains accented characters
diff --git a/libraries/PMA.php b/libraries/PMA.php
index d69a8ce78e..d59d66b1e8 100644
--- a/libraries/PMA.php
+++ b/libraries/PMA.php
@@ -20,6 +20,9 @@ require_once './libraries/List_Database.class.php';
* phpMyAdmin main Controller
*
* @package PhpMyAdmin
+ *
+ * @property resource $userlink
+ * @property resource $controllink
*/
class PMA
{
diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php
index 0466a65013..3648ea224a 100644
--- a/libraries/central_columns.lib.php
+++ b/libraries/central_columns.lib.php
@@ -315,7 +315,6 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
$message = true;
$colNotExist = array();
$fields = array();
- $cols ="";
if ($isTable) {
$cols = '';
foreach ($field_select as $table) {
diff --git a/libraries/dbi/drizzle-wrappers.lib.php b/libraries/dbi/drizzle-wrappers.lib.php
index a712e7d35c..aef9404eb2 100644
--- a/libraries/dbi/drizzle-wrappers.lib.php
+++ b/libraries/dbi/drizzle-wrappers.lib.php
@@ -59,14 +59,6 @@ class PMA_Drizzle extends Drizzle
*/
const BUFFER_ROW = 2;
- /**
- * Constructor
- */
- public function __construct()
- {
- parent::__construct();
- }
-
/**
* Creates a new database conection using TCP
*
diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php
index fb4cec139e..a5b3dbdfac 100644
--- a/libraries/mysql_charsets.lib.php
+++ b/libraries/mysql_charsets.lib.php
@@ -13,8 +13,8 @@ if (! defined('PHPMYADMIN')) {
* Generate charset dropdown box
*
* @param int $type Type
- * @param null $name Element name
- * @param null $id Element id
+ * @param string $name Element name
+ * @param string $id Element id
* @param null|string $default Default value
* @param bool $label Label
* @param int $indent Indent