' . "\n";
- echo '
' . $table . ' ' . "\n";
+ echo '
' . htmlspecialchars($table) . ' ' . "\n";
/**
* Gets table informations
@@ -204,7 +204,7 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
} else {
$row['Default'] = htmlspecialchars($row['Default']);
}
- $field_name = htmlspecialchars($row['Field']);
+ $field_name = $row['Field'];
if (PMA_MYSQL_INT_VERSION < 50025
&& ! empty($analyzed_sql[0]['create_table_fields'][$field_name]['type'])
@@ -226,9 +226,9 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
' . $field_name . '';
+ echo '' . htmlspecialchars($field_name) . ' ';
} else {
- echo $field_name;
+ echo htmlspecialchars($field_name);
}
?>
diff --git a/db_search.php b/db_search.php
index c0f2c082af..6242a53d9b 100644
--- a/db_search.php
+++ b/db_search.php
@@ -128,8 +128,7 @@ if (isset($_REQUEST['submit_search'])) {
$sqlstr_delete = 'DELETE';
// Fields to select
- $tblfields = PMA_DBI_fetch_result('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']),
- null, 'Field');
+ $tblfields = PMA_DBI_get_columns($GLOBALS['db'], $table);
// Table to use
$sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
@@ -148,8 +147,8 @@ if (isset($_REQUEST['submit_search'])) {
$thefieldlikevalue = array();
foreach ($tblfields as $tblfield) {
- if (! isset($field) || strlen($field) == 0 || $tblfield == $field) {
- $thefieldlikevalue[] = 'CONVERT(' . PMA_backquote($tblfield) . ' USING utf8)'
+ if (! isset($field) || strlen($field) == 0 || $tblfield['Field'] == $field) {
+ $thefieldlikevalue[] = 'CONVERT(' . PMA_backquote($tblfield['Field']) . ' USING utf8)'
. ' ' . $like_or_regex . ' '
. "'" . $automatic_wildcard
. $search_word
diff --git a/js/functions.js b/js/functions.js
index 92c4caf21b..022cb808c1 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -3307,8 +3307,6 @@ function PMA_getCellValue(td) {
return '';
} else if (! $(td).is('.to_be_saved') && $(td).data('original_data')) {
return $(td).data('original_data');
- } else if ($(td).is(':not(.transformed, .relation, .enum, .set, .null)')) {
- return unescape($(td).find('span').html()).replace(/
/g, "\n");
} else {
return $(td).text();
}
diff --git a/js/makegrid.js b/js/makegrid.js
index aabe9b59cd..70e9b9adb1 100644
--- a/js/makegrid.js
+++ b/js/makegrid.js
@@ -564,7 +564,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
!g.colRsz && !g.colReorder)
{
if (!g.isCellEditActive) {
- $cell = $(cell);
+ var $cell = $(cell);
// remove all edit area and hide it
$(g.cEdit).find('.edit_area').empty().hide();
// reposition the cEdit element
@@ -573,24 +573,19 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
left: $cell.position().left
})
.show()
- .find('input')
+ .find('.edit_box')
.css({
width: $cell.outerWidth(),
height: $cell.outerHeight()
});
- // fill the cell edit with text from
, if it is not null
- var value = $cell.is(':not(.null)') ? PMA_getCellValue(cell) : '';
- $(g.cEdit).find('input')
- .val(value);
+ // fill the cell edit with text from
+ var value = PMA_getCellValue(cell);
+ $(g.cEdit).find('.edit_box').val(value);
g.currentEditCell = cell;
- $(g.cEdit).find('input[type=text]').focus();
+ $(g.cEdit).find('.edit_box').focus();
$(g.cEdit).find('*').removeAttr('disabled');
}
- } else {
- if (g.isCellEditActive) {
- g.hideEditCell();
- }
}
},
@@ -605,7 +600,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
*/
hideEditCell: function(force, data, field) {
if (g.isCellEditActive && !force) {
- // cell is being edited, post the edited data
+ // cell is being edited, save or post the edited data
g.saveOrPostEditedCell();
return;
}
@@ -620,21 +615,19 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
if (g.currentEditCell) { // save value of currently edited cell
// replace current edited field with the new value
var $this_field = $(g.currentEditCell);
- var new_html = $this_field.data('value');
var is_null = $this_field.data('value') == null;
if (is_null) {
$this_field.find('span').html('NULL');
$this_field.addClass('null');
} else {
$this_field.removeClass('null');
+ var new_html = $this_field.data('value');
if ($this_field.is('.truncated')) {
if (new_html.length > g.maxTruncatedLen) {
new_html = new_html.substring(0, g.maxTruncatedLen) + '...';
}
}
- // replace '\n' with
- new_html = new_html.replace(/\n/g, ' ');
- $this_field.find('span').html(new_html);
+ $this_field.find('span').text(new_html);
}
}
if (data.transformations != undefined) {
@@ -657,7 +650,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
// hide the cell editing area
$(g.cEdit).hide();
- $(g.cEdit).find('input[type=text]').blur();
+ $(g.cEdit).find('.edit_box').blur();
g.isCellEditActive = false;
g.currentEditCell = null;
// destroy datepicker in edit area, if exist
@@ -671,8 +664,17 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
if (!g.isCellEditActive) { // make sure the edit area has not been shown
g.isCellEditActive = true;
g.isEditCellTextEditable = false;
+ /**
+ * @var $td current edited cell
+ */
var $td = $(g.currentEditCell);
+ /**
+ * @var $editArea the editing area
+ */
var $editArea = $(g.cEdit).find('.edit_area');
+ /**
+ * @var where_clause WHERE clause for the edited cell
+ */
var where_clause = $td.parent('tr').find('.where_clause').val();
/**
* @var field_name String containing the name of this field.
@@ -720,24 +722,24 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
if ($td.is('.enum, .set')) {
$editArea.find('select').live('change', function(e) {
$checkbox.attr('checked', false);
- })
+ });
} else if ($td.is('.relation')) {
$editArea.find('select').live('change', function(e) {
$checkbox.attr('checked', false);
- })
+ });
$editArea.find('.browse_foreign').live('click', function(e) {
$checkbox.attr('checked', false);
- })
+ });
} else {
- $(g.cEdit).find('input[type=text]').live('keypress change', function(e) {
+ $(g.cEdit).find('.edit_box').live('keypress change', function(e) {
$checkbox.attr('checked', false);
- })
+ });
$editArea.find('textarea').live('keydown', function(e) {
$checkbox.attr('checked', false);
- })
+ });
}
- // if 'checkbox_null__' is clicked empty the corresponding select/editor.
+ // if null checkbox is clicked empty the corresponding select/editor.
$checkbox.click(function(e) {
if ($td.is('.enum')) {
$editArea.find('select').attr('value', '');
@@ -745,7 +747,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
$editArea.find('select').find('option').each(function() {
var $option = $(this);
$option.attr('selected', false);
- })
+ });
} else if ($td.is('.relation')) {
// if the dropdown is there to select the foreign value
if ($editArea.find('select').length > 0) {
@@ -754,12 +756,11 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
} else {
$editArea.find('textarea').val('');
}
- $(g.cEdit).find('input[type=text]').val('');
- })
+ $(g.cEdit).find('.edit_box').val('');
+ });
}
- if($td.is('.relation')) {
- /** @lends jQuery */
+ if ($td.is('.relation')) {
//handle relations
$editArea.addClass('edit_area_loading');
@@ -770,15 +771,15 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
* @var post_params Object containing parameters for the POST request
*/
var post_params = {
- 'ajax_request' : true,
- 'get_relational_values' : true,
- 'server' : g.server,
- 'db' : g.db,
- 'table' : g.table,
- 'column' : field_name,
- 'token' : g.token,
- 'curr_value' : relation_curr_value,
- 'relation_key_or_display_column' : relation_key_or_display_column
+ 'ajax_request' : true,
+ 'get_relational_values' : true,
+ 'server' : g.server,
+ 'db' : g.db,
+ 'table' : g.table,
+ 'column' : field_name,
+ 'token' : g.token,
+ 'curr_value' : relation_curr_value,
+ 'relation_key_or_display_column' : relation_key_or_display_column
}
g.lastXHR = $.post('sql.php', post_params, function(data) {
@@ -788,18 +789,18 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
var value = $(data.dropdown).val();
$td.data('original_data', value);
// update the text input field, in case where the "Relational display column" is checked
- $(g.cEdit).find('input[type=text]').val(value);
+ $(g.cEdit).find('.edit_box').val(value);
$editArea.append(data.dropdown);
$editArea.append('' + g.cellEditHint + '
');
}) // end $.post()
$editArea.find('select').live('change', function(e) {
- $(g.cEdit).find('input[type=text]').val($(this).val());
+ $(g.cEdit).find('.edit_box').val($(this).val());
})
+ $editArea.show();
}
else if($td.is('.enum')) {
- /** @lends jQuery */
//handle enum fields
$editArea.addClass('edit_area_loading');
@@ -824,11 +825,11 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
}) // end $.post()
$editArea.find('select').live('change', function(e) {
- $(g.cEdit).find('input[type=text]').val($(this).val());
+ $(g.cEdit).find('.edit_box').val($(this).val());
})
+ $editArea.show();
}
else if($td.is('.set')) {
- /** @lends jQuery */
//handle set fields
$editArea.addClass('edit_area_loading');
@@ -854,23 +855,25 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
}) // end $.post()
$editArea.find('select').live('change', function(e) {
- $(g.cEdit).find('input[type=text]').val($(this).val());
+ $(g.cEdit).find('.edit_box').val($(this).val());
})
+ $editArea.show();
}
else if($td.is('.truncated, .transformed')) {
if ($td.is('.to_be_saved')) { // cell has been edited
var value = $td.data('value');
- $(g.cEdit).find('input[type=text]').val(value);
- $editArea.append('');
- $editArea.find('textarea').live('keyup', function(e) {
- $(g.cEdit).find('input[type=text]').val($(this).val());
- });
- $(g.cEdit).find('input[type=text]').live('keyup', function(e) {
+ $(g.cEdit).find('.edit_box').val(value);
+ $editArea.append('');
+ $editArea.find('textarea')
+ .val(value)
+ .live('keyup', function(e) {
+ $(g.cEdit).find('.edit_box').val($(this).val());
+ });
+ $(g.cEdit).find('.edit_box').live('keyup', function(e) {
$editArea.find('textarea').val($(this).val());
});
$editArea.append('' + g.cellEditHint + '
');
} else {
- /** @lends jQuery */
//handle truncated/transformed values values
$editArea.addClass('edit_area_loading');
@@ -900,12 +903,14 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
}
$td.data('original_data', data.value);
- $(g.cEdit).find('input[type=text]').val(data.value);
- $editArea.append('');
- $editArea.find('textarea').live('keyup', function(e) {
- $(g.cEdit).find('input[type=text]').val($(this).val());
- });
- $(g.cEdit).find('input[type=text]').live('keyup', function(e) {
+ $(g.cEdit).find('.edit_box').val(data.value);
+ $editArea.append('');
+ $editArea.find('textarea')
+ .val(data.value)
+ .live('keyup', function(e) {
+ $(g.cEdit).find('.edit_box').val($(this).val());
+ });
+ $(g.cEdit).find('.edit_box').live('keyup', function(e) {
$editArea.find('textarea').val($(this).val());
});
$editArea.append('' + g.cellEditHint + '
');
@@ -916,8 +921,9 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
}) // end $.post()
}
g.isEditCellTextEditable = true;
+ $editArea.show();
} else if ($td.is('.datefield, .datetimefield, .timestampfield')) {
- var $input_field = $(g.cEdit).find('input[type=text]');
+ var $input_field = $(g.cEdit).find('.edit_box');
// remember current datetime value in $input_field, if it is not null
var is_null = $td.is('.null');
@@ -943,19 +949,10 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
} else {
$input_field.val('');
}
+ $editArea.show();
} else {
- $editArea.append('');
- $editArea.find('textarea').live('keyup', function(e) {
- $(g.cEdit).find('input[type=text]').val($(this).val());
- });
- $(g.cEdit).find('input[type=text]').live('keyup', function(e) {
- $editArea.find('textarea').val($(this).val());
- });
- $editArea.append('' + g.cellEditHint + '
');
g.isEditCellTextEditable = true;
}
-
- $editArea.show();
}
},
@@ -1138,7 +1135,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
if (!g.saveCellsAtOnce) {
$(g.cEdit).find('*').attr('disabled', 'disabled');
var $editArea = $(g.cEdit).find('.edit_area');
- $editArea.addClass('edit_area_posting');
+ $(g.cEdit).find('.edit_box').addClass('edit_box_posting');
} else {
$('.save_edited').addClass('saving_edited_data')
.find('input').attr('disabled', 'disabled'); // disable the save button
@@ -1153,52 +1150,52 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
g.isSaving = false;
if (!g.saveCellsAtOnce) {
$(g.cEdit).find('*').removeAttr('disabled');
- $editArea.removeClass('edit_area_posting');
+ $(g.cEdit).find('.edit_box').removeClass('edit_box_posting');
} else {
$('.save_edited').removeClass('saving_edited_data')
.find('input').removeAttr('disabled'); // enable the save button back
}
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
- $('.to_be_saved').each(function() {
- var new_clause = $(this).parent('tr').data('new_clause');
- if (new_clause != '') {
- var $where_clause = $(this).parent('tr').find('.where_clause');
- var old_clause = $where_clause.attr('value');
- var decoded_old_clause = PMA_urldecode(old_clause);
- var decoded_new_clause = PMA_urldecode(new_clause);
+ // update where_clause related data in each edited row
+ $('.to_be_saved').parents('tr').each(function() {
+ var new_clause = $(this).data('new_clause');
+ var $where_clause = $(this).find('.where_clause');
+ var old_clause = $where_clause.attr('value');
+ var decoded_old_clause = PMA_urldecode(old_clause);
+ var decoded_new_clause = PMA_urldecode(new_clause);
- $where_clause.attr('value', new_clause);
- // update Edit, Copy, and Delete links also
- $(this).parent('tr').find('a').each(function() {
- $(this).attr('href', $(this).attr('href').replace(old_clause, new_clause));
- // update delete confirmation in Delete link
- if ($(this).attr('href').indexOf('DELETE') > -1) {
- $(this).removeAttr('onclick')
- .unbind('click')
- .bind('click', function() {
- return confirmLink(this, 'DELETE FROM `' + g.db + '`.`' + g.table + '` WHERE ' +
- decoded_new_clause + (is_unique ? '' : ' LIMIT 1'));
- });
- }
- });
- // update the multi edit checkboxes
- $(this).parent('tr').find('input[type=checkbox]').each(function() {
- var $checkbox = $(this);
- var checkbox_name = $checkbox.attr('name');
- var checkbox_value = $checkbox.attr('value');
+ $where_clause.attr('value', new_clause);
+ // update Edit, Copy, and Delete links also
+ $(this).find('a').each(function() {
+ $(this).attr('href', $(this).attr('href').replace(old_clause, new_clause));
+ // update delete confirmation in Delete link
+ if ($(this).attr('href').indexOf('DELETE') > -1) {
+ $(this).removeAttr('onclick')
+ .unbind('click')
+ .bind('click', function() {
+ return confirmLink(this, 'DELETE FROM `' + g.db + '`.`' + g.table + '` WHERE ' +
+ decoded_new_clause + (is_unique ? '' : ' LIMIT 1'));
+ });
+ }
+ });
+ // update the multi edit checkboxes
+ $(this).find('input[type=checkbox]').each(function() {
+ var $checkbox = $(this);
+ var checkbox_name = $checkbox.attr('name');
+ var checkbox_value = $checkbox.attr('value');
- $checkbox.attr('name', checkbox_name.replace(old_clause, new_clause));
- $checkbox.attr('value', checkbox_value.replace(decoded_old_clause, decoded_new_clause));
- });
- }
+ $checkbox.attr('name', checkbox_name.replace(old_clause, new_clause));
+ $checkbox.attr('value', checkbox_value.replace(decoded_old_clause, decoded_new_clause));
+ });
});
- // remove possible previous feedback message
+ // update the display of executed SQL query command
$('#result_query').remove();
if (typeof data.sql_query != 'undefined') {
// display feedback
$('#sqlqueryresults').prepend(data.sql_query);
}
+ // hide and/or update the successfully saved cells
g.hideEditCell(true, data);
// remove the "Save edited cells" button
@@ -1247,6 +1244,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
var value;
if ($(g.cEdit).find('.edit_area').is('.edit_area_loading')) {
+ // the edit area is still loading (retrieving cell data), no need to post
need_to_post = false;
} else if (is_null) {
if (!g.wasEditedCellNull) {
@@ -1255,7 +1253,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
}
} else {
if ($this_field.is('.bit')) {
- this_field_params[field_name] = '0b' + $(g.cEdit).find('textarea').val();
+ this_field_params[field_name] = '0b' + $(g.cEdit).find('.edit_box').val();
} else if ($this_field.is('.set')) {
$test_element = $(g.cEdit).find('select');
this_field_params[field_name] = $test_element.map(function(){
@@ -1273,10 +1271,8 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
if ($test_element.length != 0) {
this_field_params[field_name] = $test_element.text();
}
- } else if ($this_field.is('.datefield, .datetimefield, .timestampfield')) {
- this_field_params[field_name] = $(g.cEdit).find('input[type=text]').val();
} else {
- this_field_params[field_name] = $(g.cEdit).find('textarea').val();
+ this_field_params[field_name] = $(g.cEdit).find('.edit_box').val();
}
if (g.wasEditedCellNull || this_field_params[field_name] != PMA_getCellValue(g.currentEditCell)) {
need_to_post = true;
@@ -1533,7 +1529,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
// adjust g.cEdit
g.cEdit.className = 'cEdit';
- $(g.cEdit).html('
');
+ $(g.cEdit).html('
');
$(g.cEdit).hide();
// assign cell editing hint
@@ -1560,10 +1556,10 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
e.preventDefault();
}
});
- $(g.cEdit).find('input[type=text]').focus(function(e) {
+ $(g.cEdit).find('.edit_box').focus(function(e) {
g.showEditArea();
});
- $(g.cEdit).find('input[type=text], select').live('keydown', function(e) {
+ $(g.cEdit).find('.edit_box, select').live('keydown', function(e) {
if (e.which == 13) {
// post on pressing "Enter"
e.preventDefault();
@@ -1614,9 +1610,6 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
* Initialize grid
******************/
- // add relative position to table so that resize handlers are correctly positioned
- $(t).css('position', 'relative');
-
// wrap all data cells, except actions cell, with span
$(t).find('th, td:not(:has(span))')
.wrapInner(' ');
@@ -1658,6 +1651,9 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
// add table class
$(t).addClass('pma_table');
+ // add relative position to global div so that resize handlers are correctly positioned
+ $(g.gDiv).css('position', 'relative');
+
// link the global div
$(t).before(g.gDiv);
$(g.gDiv).append(t);
diff --git a/js/messages.php b/js/messages.php
index 7bb7bd3fa1..8a606dc6eb 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -265,7 +265,9 @@ $js_messages['strDisplayHelp'] = ''
. ' '
. __('Hovering over a point will show its label.')
. ' '
- . __('Drag and select an area in the plot to zoom into it.')
+ . __('Use mousewheel to zoom in or out of the plot.')
+ . ' '
+ . __('Click and drag the mouse to navigate the plot.')
. ' '
. __('Click reset zoom link to come back to original state.')
. ' '
diff --git a/js/pmd/move.js b/js/pmd/move.js
index eb2b246476..6c3f56e832 100644
--- a/js/pmd/move.js
+++ b/js/pmd/move.js
@@ -113,7 +113,7 @@ function MouseDown(e)
dx = offsetx - parseInt(cur_click.style.left);
dy = offsety - parseInt(cur_click.style.top);
//alert(" dx = " + dx + " dy = " +dy);
- document.getElementById("canvas").style.visibility = 'hidden';
+ document.getElementById("canvas").style.display = 'none';
/*
var left = parseInt(cur_click.style.left);
var top = parseInt(cur_click.style.top);
@@ -159,8 +159,8 @@ function MouseMove(e)
}
if (ON_relation || ON_display_field) {
- document.getElementById('hint').style.left = (Glob_X + 20) + 'px';
- document.getElementById('hint').style.top = (Glob_Y + 20) + 'px';
+ document.getElementById('pmd_hint').style.left = (Glob_X + 20) + 'px';
+ document.getElementById('pmd_hint').style.top = (Glob_Y + 20) + 'px';
}
if (layer_menu_cur_click) {
@@ -173,7 +173,7 @@ function MouseMove(e)
function MouseUp(e)
{
if (cur_click != null) {
- document.getElementById("canvas").style.visibility = 'visible';
+ document.getElementById("canvas").style.display = 'inline-block';
Re_load();
cur_click.style.zIndex = 1;
cur_click = null;
@@ -225,7 +225,7 @@ function Main()
Canvas_pos();
Small_tab_refresh();
Re_load();
- id_hint = document.getElementById('hint');
+ id_hint = document.getElementById('pmd_hint');
if (isIE) {
General_scroll();
}
@@ -535,12 +535,12 @@ function Start_relation()
if (!ON_relation) {
document.getElementById('foreign_relation').style.display = '';
ON_relation = 1;
- document.getElementById('hint').innerHTML = PMA_messages['strSelectReferencedKey'];
- document.getElementById('hint').style.visibility = "visible";
+ document.getElementById('pmd_hint').innerHTML = PMA_messages['strSelectReferencedKey'];
+ document.getElementById('pmd_hint').style.display = 'block';
document.getElementById('rel_button').className = 'M_butt_Selected_down';
} else {
- document.getElementById('hint').innerHTML = "";
- document.getElementById('hint').style.visibility = "hidden";
+ document.getElementById('pmd_hint').innerHTML = "";
+ document.getElementById('pmd_hint').style.display = 'none';
document.getElementById('rel_button').className = 'M_butt';
click_field = 0;
ON_relation = 0;
@@ -551,7 +551,7 @@ function Click_field(T, f, PK) // table field
{
if (ON_relation) {
if (!click_field) {
- //.style.display=='none' .style.visibility = "hidden"
+ //.style.display=='none' .style.display = 'none'
if (!PK) {
alert(PMA_messages['strPleaseSelectPrimaryOrUniqueKey']);
return;// 0;
@@ -561,7 +561,7 @@ function Click_field(T, f, PK) // table field
}
click_field = 1;
link_relation = "T1=" + T + "&F1=" + f;
- document.getElementById('hint').innerHTML = PMA_messages['strSelectForeignKey'];
+ document.getElementById('pmd_hint').innerHTML = PMA_messages['strSelectForeignKey'];
} else {
Start_relation(); // hidden hint...
if (j_tabs[db + '.' + T] != '1' || !PK) {
@@ -571,7 +571,7 @@ function Click_field(T, f, PK) // table field
document.getElementById('layer_new_relation').style.left = left + 'px';
var top = Glob_Y - document.getElementById('layer_new_relation').offsetHeight + 40;
document.getElementById('layer_new_relation').style.top = top + 'px';
- document.getElementById('layer_new_relation').style.visibility = "visible";
+ document.getElementById('layer_new_relation').style.display = 'block';
link_relation += '&T2=' + T + '&F2=' + f;
}
}
@@ -596,8 +596,8 @@ function Click_field(T, f, PK) // table field
display_field[T] = f;
}
ON_display_field = 0;
- document.getElementById('hint').innerHTML = "";
- document.getElementById('hint').style.visibility = "hidden";
+ document.getElementById('pmd_hint').innerHTML = "";
+ document.getElementById('pmd_hint').style.display = 'none';
document.getElementById('display_field_button').className = 'M_butt';
makeRequest('pmd_display_field.php', 'T=' + T + '&F=' + f + '&server=' + server + '&db=' + db + '&token=' + token);
}
@@ -605,7 +605,7 @@ function Click_field(T, f, PK) // table field
function New_relation()
{
- document.getElementById('layer_new_relation').style.visibility = 'hidden';
+ document.getElementById('layer_new_relation').style.display = 'none';
link_relation += '&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=0';
link_relation += '&on_delete=' + document.getElementById('on_delete').value + '&on_update=' + document.getElementById('on_update').value;
link_relation += Get_url_pos();
@@ -776,14 +776,14 @@ function Canvas_click(id)
document.getElementById('layer_upd_relation').style.left = left + 'px';
var top = Glob_Y - document.getElementById('layer_upd_relation').offsetHeight - 10;
document.getElementById('layer_upd_relation').style.top = top + 'px';
- document.getElementById('layer_upd_relation').style.visibility = 'visible';
+ document.getElementById('layer_upd_relation').style.display = 'block';
link_relation = 'T1=' + Key0 + '&F1=' + Key1 + '&T2=' + Key2 + '&F2=' + Key3 + '&K=' + Key;
}
}
function Upd_relation()
{
- document.getElementById('layer_upd_relation').style.visibility = 'hidden';
+ document.getElementById('layer_upd_relation').style.display = 'none';
link_relation += '&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=0';
link_relation += Get_url_pos();
makeRequest('pmd_relation_upd.php', link_relation);
@@ -792,9 +792,9 @@ function Upd_relation()
function VisibleTab(id, t_n)
{
if (id.checked) {
- document.getElementById(t_n).style.visibility = 'visible';
+ document.getElementById(t_n).style.display = 'block';
} else {
- document.getElementById(t_n).style.visibility = 'hidden';
+ document.getElementById(t_n).style.display = 'none';
}
Re_load();
}
@@ -813,10 +813,10 @@ function Hide_tab_all(id_this) // max/min all tables
if (E.elements[i].type == "checkbox" && E.elements[i].id.substring(0, 10) == 'check_vis_') {
if (id_this.alt == 'v') {
E.elements[i].checked = true;
- document.getElementById(E.elements[i].value).style.visibility = 'visible';
+ document.getElementById(E.elements[i].value).style.display = 'block';
} else {
E.elements[i].checked = false;
- document.getElementById(E.elements[i].value).style.visibility = 'hidden';
+ document.getElementById(E.elements[i].value).style.display = 'none';
}
}
}
@@ -859,20 +859,15 @@ function No_have_constr(id_this)
if (!in_array_k(E.elements[i].value, a))
if (id_this.alt == 'v') {
E.elements[i].checked = true;
- document.getElementById(E.elements[i].value).style.visibility = 'visible';
+ document.getElementById(E.elements[i].value).style.display = 'block';
} else {
E.elements[i].checked = false;
- document.getElementById(E.elements[i].value).style.visibility = 'hidden';
+ document.getElementById(E.elements[i].value).style.display = 'none';
}
}
}
}
-function Help()
-{
- var WinHelp = window.open("pmd_help.php", "wind1", "top=200,left=400,width=300,height=200,resizable=yes,scrollbars=yes,menubar=no");
-}
-
function PDF_save()
{
// var WinPDF =
@@ -884,7 +879,7 @@ function General_scroll()
{
/*
if (!document.getElementById('show_relation_olways').checked) {
- document.getElementById("canvas").style.visibility = 'hidden';
+ document.getElementById("canvas").style.display = 'none';
clearTimeout(timeoutID);
timeoutID = setTimeout(General_scroll_end, 500);
}
@@ -913,15 +908,18 @@ function General_scroll_end()
document.getElementById('layer_menu').style.left = document.body.scrollLeft;
document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
}
- document.getElementById("canvas").style.visibility = 'visible';
+ document.getElementById("canvas").style.display = 'block';
}
*/
function Show_left_menu(id_this) // max/min all tables
{
if (id_this.alt == "v") {
- document.getElementById("layer_menu").style.top = document.getElementById('top_menu').offsetHeight + 'px';
- document.getElementById("layer_menu").style.visibility = 'visible';
+ var pos = $("#top_menu").offset();
+ var height = $("#top_menu").height();
+ document.getElementById("layer_menu").style.top = (pos.top + height) + 'px';
+ document.getElementById("layer_menu").style.left = pos.left + 'px';
+ document.getElementById("layer_menu").style.display = 'block';
id_this.alt = ">";
id_this.src = "pmd/images/uparrow2_m.png";
if (isIE) {
@@ -929,7 +927,7 @@ function Show_left_menu(id_this) // max/min all tables
}
} else {
document.getElementById("layer_menu").style.top = -1000 + 'px'; //fast scroll
- document.getElementById("layer_menu").style.visibility = 'hidden';
+ document.getElementById("layer_menu").style.display = 'none';
id_this.alt = "v";
id_this.src = "pmd/images/downarrow2_m.png";
}
@@ -955,16 +953,16 @@ function Start_display_field()
}
if (!ON_display_field) {
ON_display_field = 1;
- document.getElementById('hint').innerHTML = PMA_messages['strChangeDisplay'];
- document.getElementById('hint').style.visibility = "visible";
+ document.getElementById('pmd_hint').innerHTML = PMA_messages['strChangeDisplay'];
+ document.getElementById('pmd_hint').style.display = 'block';
document.getElementById('display_field_button').className = 'M_butt_Selected_down';//'#FFEE99';gray #AAAAAA
if (isIE) { // correct for IE
document.getElementById('display_field_button').className = 'M_butt_Selected_down_IE';
}
} else {
- document.getElementById('hint').innerHTML = "";
- document.getElementById('hint').style.visibility = "hidden";
+ document.getElementById('pmd_hint').innerHTML = "";
+ document.getElementById('pmd_hint').style.display = 'none';
document.getElementById('display_field_button').className = 'M_butt';
ON_display_field = 0;
}
@@ -1021,7 +1019,7 @@ function Click_option(id_this,column_name,table_name)
document.getElementById(id_this).style.left = left + 'px';
// var top = Glob_Y - document.getElementById(id_this).offsetHeight - 10;
document.getElementById(id_this).style.top = (screen.height / 4) + 'px';
- document.getElementById(id_this).style.visibility = "visible";
+ document.getElementById(id_this).style.display = 'block';
document.getElementById('option_col_name').innerHTML = '' + PMA_messages['strAddOption'] +'"' +column_name+ '" ';
col_name = column_name;
tab_name = table_name;
@@ -1029,7 +1027,7 @@ function Click_option(id_this,column_name,table_name)
function Close_option()
{
- document.getElementById('pmd_optionse').style.visibility = "hidden";
+ document.getElementById('pmd_optionse').style.display = 'none';
}
function Select_all(id_this,owner)
@@ -1136,8 +1134,8 @@ function add_object()
var init = history_array.length;
if (rel.value != '--') {
if (document.getElementById('Query').value == "") {
- document.getElementById('hint').innerHTML = "value/subQuery is empty" ;
- document.getElementById('hint').style.visibility = "visible";
+ document.getElementById('pmd_hint').innerHTML = "value/subQuery is empty" ;
+ document.getElementById('pmd_hint').style.display = 'block';
return;
}
var p = document.getElementById('Query');
@@ -1168,8 +1166,8 @@ function add_object()
}
if (document.getElementById('h_rel_opt').value != '--') {
if (document.getElementById('having').value == "") {
- document.getElementById('hint').innerHTML = "value/subQuery is empty" ;
- document.getElementById('hint').style.visibility = "visible";
+ document.getElementById('pmd_hint').innerHTML = "value/subQuery is empty" ;
+ document.getElementById('pmd_hint').style.display = 'block';
return;
}
var p = document.getElementById('having');
@@ -1186,8 +1184,8 @@ function add_object()
document.getElementById('orderby').checked = false;
//make orderby
}
- document.getElementById('hint').innerHTML = sum + "object created" ;
- document.getElementById('hint').style.visibility = "visible";
+ document.getElementById('pmd_hint').innerHTML = sum + "object created" ;
+ document.getElementById('pmd_hint').style.display = 'block';
//output sum new objects created
var existingDiv = document.getElementById('ab');
existingDiv.innerHTML = display(init,history_array.length);
diff --git a/js/querywindow.js b/js/querywindow.js
index ba9fe6e18f..55c895a061 100644
--- a/js/querywindow.js
+++ b/js/querywindow.js
@@ -7,36 +7,35 @@ function PMA_queryAutoCommit()
function PMA_querywindowCommit(tab)
{
- document.getElementById('hiddenqueryform').querydisplay_tab.value = tab;
- document.getElementById('hiddenqueryform').submit();
+ $('#hiddenqueryform').find("input[name='querydisplay_tab']").attr("value" ,tab);
+ $('#hiddenqueryform').submit();
return false;
}
function PMA_querywindowSetFocus()
{
- document.getElementById('sqlquery').focus();
+ $('#sqlquery').focus();
}
function PMA_querywindowResize()
{
// for Gecko
- if (typeof(self.sizeToContent) == 'function') {
- self.sizeToContent();
+ if (typeof($(this)[0].sizeToContent) == 'function') {
+ $(this)[0].sizeToContent();
//self.scrollbars.visible = false;
// give some more space ... to prevent 'fli(pp/ck)ing'
- self.resizeBy(10, 50);
+ $(this)[0].resizeBy(10, 50);
return;
}
// for IE, Opera
- if (document.getElementById && typeof(document.getElementById('querywindowcontainer')) != 'undefined') {
-
+ if ($('#querywindowcontainer') != 'undefined') {
// get content size
- var newWidth = document.getElementById('querywindowcontainer').offsetWidth;
- var newHeight = document.getElementById('querywindowcontainer').offsetHeight;
+ var newWidth = $("#querywindowcontainer")[0].offsetWidth;
+ var newHeight = $("#querywindowcontainer")[0].offsetHeight;
// set size to contentsize
// plus some offset for scrollbars, borders, statusbar, menus ...
- self.resizeTo(newWidth + 45, newHeight + 75);
+ $(this)[0].resizeTo(newWidth + 45, newHeight + 75);
}
}
diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js
index 796b543ba2..e773175d7a 100644
--- a/js/tbl_zoom_plot.js
+++ b/js/tbl_zoom_plot.js
@@ -35,7 +35,7 @@ Array.min = function (array) {
/**
** Checks if a string contains only numeric value
- ** @param n: String (to be checked)
+ ** @param n: String (to be checked)
**/
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
@@ -43,7 +43,7 @@ function isNumeric(n) {
/**
** Checks if an object is empty
- ** @param n: Object (to be checked)
+ ** @param n: Object (to be checked)
**/
function isEmpty(obj) {
var name;
@@ -59,15 +59,15 @@ function isEmpty(obj) {
** @param type String Field type(datetime/timestamp/time/date)
**/
function getDate(val,type) {
- if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
- return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val)
- }
- else if (type.toString().search(/time/i) != -1) {
- return Highcharts.dateFormat('%H:%M:%S', val + 19800000)
- }
+ if(type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
+ return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val)
+ }
+ else if(type.toString().search(/time/i) != -1) {
+ return Highcharts.dateFormat('%H:%M:%S', val)
+ }
else if (type.toString().search(/date/i) != -1) {
return Highcharts.dateFormat('%Y-%m-%e', val)
- }
+ }
}
/**
@@ -76,30 +76,30 @@ function getDate(val,type) {
** @param type Sring Field type(datetime/timestamp/time/date)
**/
function getTimeStamp(val,type) {
- if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
- return getDateFromFormat(val,'yyyy-MM-dd HH:mm:ss', val)
- }
- else if (type.toString().search(/time/i) != -1) {
- return getDateFromFormat('1970-01-01 ' + val,'yyyy-MM-dd HH:mm:ss')
- }
+ if(type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
+ return getDateFromFormat(val,'yyyy-MM-dd HH:mm:ss', val)
+ }
+ else if(type.toString().search(/time/i) != -1) {
+ return getDateFromFormat('1970-01-01 ' + val,'yyyy-MM-dd HH:mm:ss')
+ }
else if (type.toString().search(/date/i) != -1) {
- return getDateFromFormat(val,'yyyy-MM-dd')
- }
+ return getDateFromFormat(val,'yyyy-MM-dd')
+ }
}
/**
** Classifies the field type into numeric,timeseries or text
** @param field: field type (as in database structure)
- **/
+ **/
function getType(field) {
- if (field.toString().search(/int/i) != -1 || field.toString().search(/decimal/i) != -1 || field.toString().search(/year/i) != -1)
- return 'numeric';
- else if (field.toString().search(/time/i) != -1 || field.toString().search(/date/i) != -1)
- return 'time';
- else
- return 'text';
+ if(field.toString().search(/int/i) != -1 || field.toString().search(/decimal/i) != -1 || field.toString().search(/year/i) != -1)
+ return 'numeric';
+ else if(field.toString().search(/time/i) != -1 || field.toString().search(/date/i) != -1)
+ return 'time';
+ else
+ return 'text';
}
-/**
+/**
** Converts a categorical array into numeric array
** @param array categorical values array
**/
@@ -121,6 +121,51 @@ function scrollToChart() {
$('html,body').animate({scrollTop: x}, 500);
}
+/**
+ ** Handlers for panning feature
+ **/
+function includePan(currentChart) {
+ var mouseDown;
+ var lastX;
+ var lastY;
+ var chartWidth = $('#resizer').width() - 3;
+ var chartHeight = $('#resizer').height() - 20;
+ $('#querychart').mousedown(function() {
+ mouseDown = 1;
+ });
+
+ $('#querychart').mouseup(function() {
+ mouseDown = 0;
+ });
+ $('#querychart').mousemove(function(e) {
+ if (mouseDown == 1) {
+ if (e.pageX > lastX) {
+ var xExtremes = currentChart.xAxis[0].getExtremes();
+ var diff = (e.pageX - lastX) * (xExtremes.max - xExtremes.min) / chartWidth;
+ currentChart.xAxis[0].setExtremes(xExtremes.min - diff, xExtremes.max - diff);
+ }
+ else if (e.pageX < lastX) {
+ var xExtremes = currentChart.xAxis[0].getExtremes();
+ var diff = (lastX - e.pageX) * (xExtremes.max - xExtremes.min) / chartWidth;
+ currentChart.xAxis[0].setExtremes(xExtremes.min + diff, xExtremes.max + diff);
+ }
+
+ if (e.pageY > lastY) {
+ var yExtremes = currentChart.yAxis[0].getExtremes();
+ var ydiff = 1.0 * (e.pageY - lastY) * (yExtremes.max - yExtremes.min) / chartHeight;
+ currentChart.yAxis[0].setExtremes(yExtremes.min + ydiff, yExtremes.max + ydiff);
+ }
+ else if (e.pageY < lastY) {
+ var yExtremes = currentChart.yAxis[0].getExtremes();
+ var ydiff = 1.0 * (lastY - e.pageY) * (yExtremes.max - yExtremes.min) / chartHeight;
+ currentChart.yAxis[0].setExtremes(yExtremes.min - ydiff, yExtremes.max - ydiff);
+ }
+ }
+ lastX = e.pageX;
+ lastY = e.pageY;
+ });
+}
+
$(document).ready(function() {
/**
@@ -131,7 +176,7 @@ $(document).ready(function() {
cache: 'false'
});
- var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer';
+ var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer';
var currentChart = null;
var currentData = null;
var xLabel = $('#tableid_0').val();
@@ -139,8 +184,12 @@ $(document).ready(function() {
var xType = $('#types_0').val();
var yType = $('#types_1').val();
var dataLabel = $('#dataLabel').val();
+ var lastX;
+ var lastY;
+ var zoomRatio = 1;
- // Get query result
+
+ // Get query result
var data = jQuery.parseJSON($('#querydata').html());
/**
@@ -164,16 +213,16 @@ $(document).ready(function() {
/**
* Input form validation
- **/
+ **/
$('#inputFormSubmitId').click(function() {
- if ($('#tableid_0').get(0).selectedIndex == 0 || $('#tableid_1').get(0).selectedIndex == 0)
- PMA_ajaxShowMessage(PMA_messages['strInputNull']);
- else if (xLabel == yLabel)
+ if ($('#tableid_0').get(0).selectedIndex == 0 || $('#tableid_1').get(0).selectedIndex == 0)
+ PMA_ajaxShowMessage(PMA_messages['strInputNull']);
+ else if (xLabel == yLabel)
PMA_ajaxShowMessage(PMA_messages['strSameInputs']);
});
/**
- ** Prepare a div containing a link, otherwise it's incorrectly displayed
+ ** Prepare a div containing a link, otherwise it's incorrectly displayed
** after a couple of clicks
**/
$('')
@@ -191,177 +240,177 @@ $(document).ready(function() {
} else {
$link.text(PMA_messages['strHideSearchCriteria']);
}
- // avoid default click action
- return false;
- });
-
- /**
+ // avoid default click action
+ return false;
+ });
+
+ /**
** Set dialog properties for the data display form
**/
$("#dataDisplay").dialog({
autoOpen: false,
- title: 'Data point content',
+ title: 'Data point content',
modal: false, //false otherwise other dialogues like timepicker may not function properly
height: $('#dataDisplay').height() + 80,
width: $('#dataDisplay').width() + 80
});
/*
- * Handle submit of zoom_display_form
+ * Handle submit of zoom_display_form
*/
-
+
$("#submitForm").click(function(event) {
-
+
//Prevent default submission of form
event.preventDefault();
-
- //Find changed values by comparing form values with selectedRow Object
- var newValues = new Array();//Stores the values changed from original
+
+ //Find changed values by comparing form values with selectedRow Object
+ var newValues = new Array();//Stores the values changed from original
var it = 4;
var xChange = false;
var yChange = false;
- for (key in selectedRow) {
- if (key != 'where_clause'){
- var oldVal = selectedRow[key];
- var newVal = ($('#fields_null_id_' + it).attr('checked')) ? null : $('#fieldID_' + it).val();
- if (oldVal != newVal){
- selectedRow[key] = newVal;
- newValues[key] = newVal;
- if (key == xLabel) {
- xChange = true;
- data[currentData][xLabel] = newVal;
- }
- else if (key == yLabel) {
- yChange = true;
- data[currentData][yLabel] = newVal;
- }
- }
- }
- it++
- }//End data update
-
- //Update the chart series and replot
+ for (key in selectedRow) {
+ if (key != 'where_clause'){
+ var oldVal = selectedRow[key];
+ var newVal = ($('#fields_null_id_' + it).attr('checked')) ? null : $('#fieldID_' + it).val();
+ if (oldVal != newVal){
+ selectedRow[key] = newVal;
+ newValues[key] = newVal;
+ if(key == xLabel) {
+ xChange = true;
+ data[currentData][xLabel] = newVal;
+ }
+ else if(key == yLabel) {
+ yChange = true;
+ data[currentData][yLabel] = newVal;
+ }
+ }
+ }
+ it++
+ }//End data update
+
+ //Update the chart series and replot
if (xChange || yChange) {
- var newSeries = new Array();
- newSeries[0] = new Object();
+ var newSeries = new Array();
+ newSeries[0] = new Object();
newSeries[0].marker = {
symbol: 'circle'
};
- //Logic similar to plot generation, replot only if xAxis changes or yAxis changes. Code includes a lot of checks so as to replot only when necessary
- if (xChange) {
- xCord[currentData] = selectedRow[xLabel];
- if (xType == 'numeric') {
- currentChart.series[0].data[currentData].update({ x : selectedRow[xLabel] });
- currentChart.xAxis[0].setExtremes(Array.min(xCord) - 6,Array.max(xCord) + 6);
+ //Logic similar to plot generation, replot only if xAxis changes or yAxis changes. Code includes a lot of checks so as to replot only when necessary
+ if(xChange) {
+ xCord[currentData] = selectedRow[xLabel];
+ if(xType == 'numeric') {
+ currentChart.series[0].data[currentData].update({ x : selectedRow[xLabel] });
+ currentChart.xAxis[0].setExtremes(Array.min(xCord) - 6,Array.max(xCord) + 6);
}
- else if (xType == 'time') {
- currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel],$('#types_0').val())});
- }
- else {
- var tempX = getCord(xCord);
- var tempY = getCord(yCord);
- var i = 0;
- newSeries[0].data = new Array();
- xCord = tempX[2];
- yCord = tempY[2];
+ else if(xType == 'time') {
+ currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel],$('#types_0').val())});
+ }
+ else {
+ var tempX = getCord(xCord);
+ var tempY = getCord(yCord);
+ var i = 0;
+ newSeries[0].data = new Array();
+ xCord = tempX[2];
+ yCord = tempY[2];
- $.each(data,function(key,value) {
- if (yType != 'text')
- newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: value[yLabel], marker: {fillColor: colorCodes[i % 8]} , id: i } );
- else
+ $.each(data,function(key,value) {
+ if(yType != 'text')
+ newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: value[yLabel], marker: {fillColor: colorCodes[i % 8]} , id: i } );
+ else
newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } );
- i++;
+ i++;
});
- currentSettings.xAxis.labels = { formatter : function() {
- if (tempX[1][this.value] && tempX[1][this.value].length > 10)
- return tempX[1][this.value].substring(0,10)
- else
- return tempX[1][this.value];
+ currentSettings.xAxis.labels = { formatter : function() {
+ if(tempX[1][this.value] && tempX[1][this.value].length > 10)
+ return tempX[1][this.value].substring(0,10)
+ else
+ return tempX[1][this.value];
}
}
- currentSettings.series = newSeries;
+ currentSettings.series = newSeries;
currentChart = PMA_createChart(currentSettings);
- }
+ }
- }
- if (yChange) {
+ }
+ if(yChange) {
- yCord[currentData] = selectedRow[yLabel];
- if (yType == 'numeric') {
- currentChart.series[0].data[currentData].update({ y : selectedRow[yLabel] });
- currentChart.yAxis[0].setExtremes(Array.min(yCord) - 6,Array.max(yCord) + 6);
+ yCord[currentData] = selectedRow[yLabel];
+ if(yType == 'numeric') {
+ currentChart.series[0].data[currentData].update({ y : selectedRow[yLabel] });
+ currentChart.yAxis[0].setExtremes(Array.min(yCord) - 6,Array.max(yCord) + 6);
}
- else if (yType =='time') {
- currentChart.series[0].data[currentData].update({ y : getTimeStamp(selectedRow[yLabel],$('#types_1').val())});
- }
- else {
- var tempX = getCord(xCord);
- var tempY = getCord(yCord);
- var i = 0;
- newSeries[0].data = new Array();
- xCord = tempX[2];
- yCord = tempY[2];
+ else if(yType =='time') {
+ currentChart.series[0].data[currentData].update({ y : getTimeStamp(selectedRow[yLabel],$('#types_1').val())});
+ }
+ else {
+ var tempX = getCord(xCord);
+ var tempY = getCord(yCord);
+ var i = 0;
+ newSeries[0].data = new Array();
+ xCord = tempX[2];
+ yCord = tempY[2];
- $.each(data,function(key,value) {
- if (xType != 'text' )
+ $.each(data,function(key,value) {
+ if(xType != 'text' )
newSeries[0].data.push({ name: value[dataLabel], x: value[xLabel], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } );
- else
+ else
newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } );
- i++;
+ i++;
});
- currentSettings.yAxis.labels = { formatter : function() {
- if (tempY[1][this.value] && tempY[1][this.value].length > 10)
- return tempY[1][this.value].substring(0,10)
- else
- return tempY[1][this.value];
+ currentSettings.yAxis.labels = { formatter : function() {
+ if(tempY[1][this.value] && tempY[1][this.value].length > 10)
+ return tempY[1][this.value].substring(0,10)
+ else
+ return tempY[1][this.value];
}
}
- currentSettings.series = newSeries;
- currentChart = PMA_createChart(currentSettings);
- }
- }
- currentChart.series[0].data[currentData].select();
+ currentSettings.series = newSeries;
+ currentChart = PMA_createChart(currentSettings);
+ }
+ }
+ currentChart.series[0].data[currentData].select();
}
- //End plot update
+ //End plot update
- //Generate SQL query for update
- if (!isEmpty(newValues)) {
+ //Generate SQL query for update
+ if (!isEmpty(newValues)) {
var sql_query = 'UPDATE `' + window.parent.table + '` SET ';
- for (key in newValues) {
- if (key != 'where_clause') {
- sql_query += '`' + key + '`=' ;
- var value = newValues[key];
- if (!isNumeric(value) && value != null)
- sql_query += '\'' + value + '\' ,';
- else
- sql_query += value + ' ,';
- }
- }
- sql_query = sql_query.substring(0, sql_query.length - 1);
- sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']);
-
- //Post SQL query to sql.php
- $.post('sql.php', {
+ for (key in newValues) {
+ if(key != 'where_clause') {
+ sql_query += '`' + key + '`=' ;
+ var value = newValues[key];
+ if(!isNumeric(value) && value != null)
+ sql_query += '\'' + value + '\' ,';
+ else
+ sql_query += value + ' ,';
+ }
+ }
+ sql_query = sql_query.substring(0, sql_query.length - 1);
+ sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']);
+
+ //Post SQL query to sql.php
+ $.post('sql.php', {
'token' : window.parent.token,
'db' : window.parent.db,
'ajax_request' : true,
'sql_query' : sql_query,
- 'inline_edit' : false
- }, function(data) {
- if (data.success == true) {
- $('#sqlqueryresults').html(data.sql_query);
- $("#sqlqueryresults").trigger('appendAnchor');
- }
- else
- PMA_ajaxShowMessage(data.error);
- })//End $.post
- }//End database update
- $("#dataDisplay").dialog("close");
- });//End submit handler
+ 'inline_edit' : false
+ }, function(data) {
+ if(data.success == true) {
+ $('#sqlqueryresults').html(data.sql_query);
+ $("#sqlqueryresults").trigger('appendAnchor');
+ }
+ else
+ PMA_ajaxShowMessage(data.error);
+ })//End $.post
+ }//End database update
+ $("#dataDisplay").dialog("close");
+ });//End submit handler
/*
* Generate plot using Highcharts
- */
+ */
if (data != null) {
$('#zoom_search_form')
@@ -369,87 +418,101 @@ $(document).ready(function() {
.hide();
$('#togglesearchformlink')
.text(PMA_messages['strShowSearchCriteria'])
- $('#togglesearchformdiv').show();
+ $('#togglesearchformdiv').show();
var selectedRow;
- var columnNames = new Array();
- var colorCodes = ['#FF0000','#00FFFF','#0000FF','#0000A0','#FF0080','#800080','#FFFF00','#00FF00','#FF00FF'];
- var series = new Array();
- var xCord = new Array();
- var yCord = new Array();
- var xCat = new Array();
- var yCat = new Array();
- var tempX, tempY;
- var it = 0;
+ var colorCodes = ['#FF0000','#00FFFF','#0000FF','#0000A0','#FF0080','#800080','#FFFF00','#00FF00','#FF00FF'];
+ var series = new Array();
+ var xCord = new Array();
+ var yCord = new Array();
+ var tempX, tempY;
+ var it = 0;
+ var xMax; // xAxis extreme max
+ var xMin; // xAxis extreme min
+ var yMax; // yAxis extreme max
+ var yMin; // yAxis extreme min
// Set the basic plot settings
var currentSettings = {
chart: {
- renderTo: 'querychart',
- type: 'scatter',
- zoomType: 'xy',
- width:$('#resizer').width() -3,
- height:$('#resizer').height()-20
+ renderTo: 'querychart',
+ type: 'scatter',
+ //zoomType: 'xy',
+ width:$('#resizer').width() -3,
+ height:$('#resizer').height()-20
+ },
+ credits: {
+ enabled: false
},
- credits: {
- enabled: false
- },
- exporting: { enabled: false },
+ exporting: { enabled: false },
label: { text: $('#dataLabel').val() },
- plotOptions: {
- series: {
- allowPointSelect: true,
+ plotOptions: {
+ series: {
+ allowPointSelect: true,
cursor: 'pointer',
- showInLegend: false,
+ showInLegend: false,
dataLabels: {
- enabled: false
+ enabled: false,
},
- point: {
+ point: {
events: {
click: function() {
- var id = this.id;
- var fid = 4;
- currentData = id;
- // Make AJAX request to tbl_zoom_select.php for getting the complete row info
- var post_params = {
+ var id = this.id;
+ var fid = 4;
+ currentData = id;
+ // Make AJAX request to tbl_zoom_select.php for getting the complete row info
+ var post_params = {
'ajax_request' : true,
'get_data_row' : true,
'db' : window.parent.db,
'table' : window.parent.table,
'where_clause' : data[id]['where_clause'],
- 'token' : window.parent.token
+ 'token' : window.parent.token,
}
$.post('tbl_zoom_select.php', post_params, function(data) {
- // Row is contained in data.row_info, now fill the displayResultForm with row values
- for ( key in data.row_info) {
- if (data.row_info[key] == null)
- $('#fields_null_id_' + fid).attr('checked', true);
- else
- $('#fieldID_' + fid).val(data.row_info[key]);
- fid++;
- }
- selectedRow = new Object();
- selectedRow = data.row_info;
+ // Row is contained in data.row_info, now fill the displayResultForm with row values
+ for ( key in data.row_info) {
+ if (data.row_info[key] == null)
+ $('#fields_null_id_' + fid).attr('checked', true);
+ else
+ $('#fieldID_' + fid).val(data.row_info[key]);
+ fid++;
+ }
+ selectedRow = new Object();
+ selectedRow = data.row_info;
});
- $("#dataDisplay").dialog("open");
- }
+ $("#dataDisplay").dialog("open");
+ },
}
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return this.point.name;
+ }
+ },
+ title: { text: 'Query Results' },
+ xAxis: {
+ title: { text: $('#tableid_0').val() },
+ events: {
+ setExtremes: function(e){
+ this.resetZoom.show();
}
}
- },
- tooltip: {
- formatter: function() {
- return this.point.name;
- }
- },
- title: { text: 'Query Results' },
- xAxis: {
- title: { text: $('#tableid_0').val() }
+
},
yAxis: {
- min: null,
- title: { text: $('#tableid_1').val() }
- }
+ min: null,
+ title: { text: $('#tableid_1').val() },
+ endOnTick: false,
+ startOnTick: false,
+ events: {
+ setExtremes: function(e){
+ this.resetZoom.show();
+ }
+ }
+ },
}
$('#resizer').resizable({
@@ -461,145 +524,185 @@ $(document).ready(function() {
);
}
});
+
+ // Classify types as either numeric,time,text
+ xType = getType(xType);
+ yType = getType(yType);
- // Classify types as either numeric,time,text
- xType = getType(xType);
- yType = getType(yType);
-
- //Set the axis type based on the field
- currentSettings.xAxis.type = (xType == 'time') ? 'datetime' : 'linear';
- currentSettings.yAxis.type = (yType == 'time') ? 'datetime' : 'linear';
+ //Set the axis type based on the field
+ currentSettings.xAxis.type = (xType == 'time') ? 'datetime' : 'linear';
+ currentSettings.yAxis.type = (yType == 'time') ? 'datetime' : 'linear';
// Formulate series data for plot
series[0] = new Object();
series[0].data = new Array();
- series[0].marker = {
+ series[0].marker = {
symbol: 'circle'
};
- if (xType != 'text' && yType != 'text') {
- $.each(data,function(key,value) {
- var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val());
- var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val());
+ if (xType != 'text' && yType != 'text') {
+ $.each(data,function(key,value) {
+ var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val());
+ var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val());
series[0].data.push({ name: value[dataLabel], x: xVal, y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } );
- xCord.push(value[xLabel]);
- yCord.push(value[yLabel]);
- it++;
+ xCord.push(value[xLabel]);
+ yCord.push(value[yLabel]);
+ it++;
});
- if (xType == 'numeric') {
- currentSettings.xAxis.max = Array.max(xCord) + 6
- currentSettings.xAxis.min = Array.min(xCord) - 6
+ if(xType == 'numeric') {
+ currentSettings.xAxis.max = Array.max(xCord) + 6
+ currentSettings.xAxis.min = Array.min(xCord) - 6
+ }
+ else {
+ currentSettings.xAxis.labels = { formatter : function() {
+ return getDate(this.value, $('#types_0').val());
+ }}
}
- else {
- currentSettings.xAxis.labels = { formatter : function() {
- return getDate(this.value, $('#types_0').val());
- }}
- }
- if (yType == 'numeric') {
- currentSettings.yAxis.max = Array.max(yCord) + 6
- currentSettings.yAxis.min = Array.min(yCord) - 6
- }
- else {
- currentSettings.yAxis.labels = { formatter : function() {
- return getDate(this.value, $('#types_1').val());
- }}
+ if(yType == 'numeric') {
+ currentSettings.yAxis.max = Array.max(yCord) + 6
+ currentSettings.yAxis.min = Array.min(yCord) - 6
+ }
+ else {
+ currentSettings.yAxis.labels = { formatter : function() {
+ return getDate(this.value, $('#types_1').val());
+ }}
}
}
-
- else if (xType =='text' && yType !='text') {
- $.each(data,function(key,value) {
- xCord.push(value[xLabel]);
- yCord.push(value[yLabel]);
- });
-
- tempX = getCord(xCord);
- $.each(data,function(key,value) {
- var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val());
+
+ else if (xType =='text' && yType !='text') {
+ $.each(data,function(key,value) {
+ xCord.push(value[xLabel]);
+ yCord.push(value[yLabel]);
+ });
+
+ tempX = getCord(xCord);
+ $.each(data,function(key,value) {
+ var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val());
series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } );
- it++;
+ it++;
});
-
- currentSettings.xAxis.labels = { formatter : function() {
- if (tempX[1][this.value] && tempX[1][this.value].length > 10)
- return tempX[1][this.value].substring(0,10)
- else
- return tempX[1][this.value];
- }
+
+ currentSettings.xAxis.labels = { formatter : function() {
+ if(tempX[1][this.value] && tempX[1][this.value].length > 10)
+ return tempX[1][this.value].substring(0,10)
+ else
+ return tempX[1][this.value];
+ }
}
- if (yType == 'numeric') {
- currentSettings.yAxis.max = Array.max(yCord) + 6
- currentSettings.yAxis.min = Array.min(yCord) - 6
+ if(yType == 'numeric') {
+ currentSettings.yAxis.max = Array.max(yCord) + 6
+ currentSettings.yAxis.min = Array.min(yCord) - 6
+ }
+ else {
+ currentSettings.yAxis.labels = { formatter : function() {
+ return getDate(this.value, $('#types_1').val());
+ }}
}
- else {
- currentSettings.yAxis.labels = { formatter : function() {
- return getDate(this.value, $('#types_1').val());
- }}
- }
- xCord = tempX[2];
- }
-
- else if (xType !='text' && yType =='text') {
- $.each(data,function(key,value) {
- xCord.push(value[xLabel]);
- yCord.push(value[yLabel]);
- });
- tempY = getCord(yCord);
- $.each(data,function(key,value) {
- var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val());
+ xCord = tempX[2];
+ }
+
+ else if (xType !='text' && yType =='text') {
+ $.each(data,function(key,value) {
+ xCord.push(value[xLabel]);
+ yCord.push(value[yLabel]);
+ });
+ tempY = getCord(yCord);
+ $.each(data,function(key,value) {
+ var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val());
series[0].data.push({ name: value[dataLabel], y: tempY[0][it], x: xVal, marker: {fillColor: colorCodes[it % 8]} , id: it } );
- it++;
+ it++;
});
- if (xType == 'numeric') {
- currentSettings.xAxis.max = Array.max(xCord) + 6
- currentSettings.xAxis.min = Array.min(xCord) - 6
+ if(xType == 'numeric') {
+ currentSettings.xAxis.max = Array.max(xCord) + 6
+ currentSettings.xAxis.min = Array.min(xCord) - 6
+ }
+ else {
+ currentSettings.xAxis.labels = { formatter : function() {
+ return getDate(this.value, $('#types_0').val());
+ }}
}
- else {
- currentSettings.xAxis.labels = { formatter : function() {
- return getDate(this.value, $('#types_0').val());
- }}
+ currentSettings.yAxis.labels = { formatter : function() {
+ if(tempY[1][this.value] && tempY[1][this.value].length > 10)
+ return tempY[1][this.value].substring(0,10)
+ else
+ return tempY[1][this.value];
+ }
}
- currentSettings.yAxis.labels = { formatter : function() {
- if (tempY[1][this.value] && tempY[1][this.value].length > 10)
- return tempY[1][this.value].substring(0,10)
- else
- return tempY[1][this.value];
- }
- }
- yCord = tempY[2];
- }
-
- else if (xType =='text' && yType =='text') {
- $.each(data,function(key,value) {
- xCord.push(value[xLabel]);
- yCord.push(value[yLabel]);
- });
- tempX = getCord(xCord);
- tempY = getCord(yCord);
- $.each(data,function(key,value) {
+ yCord = tempY[2];
+ }
+
+ else if (xType =='text' && yType =='text') {
+ $.each(data,function(key,value) {
+ xCord.push(value[xLabel]);
+ yCord.push(value[yLabel]);
+ });
+ tempX = getCord(xCord);
+ tempY = getCord(yCord);
+ $.each(data,function(key,value) {
series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: tempY[0][it], marker: {fillColor: colorCodes[it % 8]} , id: it } );
- it++;
+ it++;
});
- currentSettings.xAxis.labels = { formatter : function() {
- if (tempX[1][this.value] && tempX[1][this.value].length > 10) {
- return tempX[1][this.value].substring(0,10)
- } else {
- return tempX[1][this.value];
- }
- }};
- currentSettings.yAxis.labels = { formatter : function() {
- if (tempY[1][this.value] && tempY[1][this.value].length > 10) {
- return tempY[1][this.value].substring(0,10);
- } else {
- return tempY[1][this.value];
- }
- }};
- xCord = tempX[2];
- yCord = tempY[2];
+ currentSettings.xAxis.labels = { formatter : function() {
+ if(tempX[1][this.value] && tempX[1][this.value].length > 10)
+ return tempX[1][this.value].substring(0,10)
+ else
+ return tempX[1][this.value];
+ }
+ }
+ currentSettings.yAxis.labels = { formatter : function() {
+ if(tempY[1][this.value] && tempY[1][this.value].length > 10)
+ return tempY[1][this.value].substring(0,10)
+ else
+ return tempY[1][this.value];
+ }
+ }
+ xCord = tempX[2];
+ yCord = tempY[2];
- }
+ }
- currentSettings.series = series;
+ currentSettings.series = series;
currentChart = PMA_createChart(currentSettings);
- scrollToChart();
+ xMin = currentChart.xAxis[0].getExtremes().min;
+ xMax = currentChart.xAxis[0].getExtremes().max;
+ yMin = currentChart.yAxis[0].getExtremes().min;
+ yMax = currentChart.yAxis[0].getExtremes().max;
+ includePan(currentChart); //Enable panning feature
+ var setZoom = function() {
+ var newxm = xMin + (xMax - xMin) * (1 - zoomRatio) / 2;
+ var newxM = xMax - (xMax - xMin) * (1 - zoomRatio) / 2;
+ var newym = yMin + (yMax - yMin) * (1 - zoomRatio) / 2;
+ var newyM = yMax - (yMax - yMin) * (1 - zoomRatio) / 2;
+ currentChart.xAxis[0].setExtremes(newxm,newxM);
+ currentChart.yAxis[0].setExtremes(newym,newyM);
+ };
+ //Enable zoom feature
+ $("#querychart").mousewheel(function(objEvent, intDelta) {
+ if (intDelta > 0) {
+ if (zoomRatio > 0.1) {
+ zoomRatio = zoomRatio - 0.1;
+ setZoom();
+ }
+ }
+ else if (intDelta < 0) {
+ zoomRatio = zoomRatio + 0.1;
+ setZoom();
+ }
+ });
+ //Add reset zoom feature
+ currentChart.yAxis[0].resetZoom = currentChart.xAxis[0].resetZoom = $('Reset zoom ')
+ .appendTo(currentChart.container)
+ .css({
+ position: 'absolute',
+ top: 10,
+ right: 20,
+ display: 'none'
+ })
+ .click(function(){
+ currentChart.xAxis[0].setExtremes(null, null)
+ currentChart.yAxis[0].setExtremes(null, null)
+ this.style.display = 'none'
+ });
+ scrollToChart();
}
});
diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php
index 61592863c0..b681155ac6 100644
--- a/libraries/Advisor.class.php
+++ b/libraries/Advisor.class.php
@@ -174,6 +174,22 @@ class Advisor
$this->runResult[$type][] = $rule;
}
+ private function ruleExprEvaluate_var1($matches)
+ {
+ // '/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie'
+ return '1'; //isset($this->runResult[\'fired\']
+ }
+
+ private function ruleExprEvaluate_var2($matches)
+ {
+ // '/\b(\w+)\b/e'
+ return isset($this->variables[$matches[1]])
+ ? (is_numeric($this->variables[$matches[1]])
+ ? $this->variables[$matches[1]]
+ : '"'.$this->variables[$matches[1]].'"')
+ : $matches[1];
+ }
+
// Runs a code expression, replacing variable names with their respective values
// ignoreUntil: if > 0, it doesn't replace any variables until that string position, but still evaluates the whole expr
function ruleExprEvaluate($expr, $ignoreUntil = 0)
@@ -182,13 +198,14 @@ class Advisor
$exprIgnore = substr($expr,0,$ignoreUntil);
$expr = substr($expr,$ignoreUntil);
}
- $expr = preg_replace('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie','1',$expr); //isset($this->runResult[\'fired\']
- $expr = preg_replace('/\b(\w+)\b/e','isset($this->variables[\'\1\']) ? (!is_numeric($this->variables[\'\1\']) ? \'"\'.$this->variables[\'\1\'].\'"\' : $this->variables[\'\1\']) : \'\1\'', $expr);
+ $expr = preg_replace_callback('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Ui', array($this, 'ruleExprEvaluate_var1'), $expr);
+ $expr = preg_replace_callback('/\b(\w+)\b/', array($this, 'ruleExprEvaluate_var2'), $expr);
if ($ignoreUntil > 0) {
$expr = $exprIgnore . $expr;
}
$value = 0;
$err = 0;
+
ob_start();
eval('$value = '.$expr.';');
$err = ob_get_contents();
diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index d018cd762f..46ebb91171 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -63,8 +63,8 @@ class PMA_Table
/**
* Constructor
*
- * @param string $table_name table name
- * @param string $db_name database name
+ * @param string $table_name table name
+ * @param string $db_name database name
*/
function __construct($table_name, $db_name)
{
@@ -83,11 +83,21 @@ class PMA_Table
return $this->getName();
}
+ /**
+ * return the last error
+ *
+ * @return the last error
+ */
function getLastError()
{
return end($this->errors);
}
+ /**
+ * return the last message
+ *
+ * @return the last message
+ */
function getLastMessage()
{
return end($this->messages);
@@ -96,7 +106,9 @@ class PMA_Table
/**
* sets table name
*
- * @param string $table_name new table name
+ * @param string $table_name new table name
+ *
+ * @return nothing
*/
function setName($table_name)
{
@@ -107,6 +119,7 @@ class PMA_Table
* returns table name
*
* @param boolean $backquoted whether to quote name with backticks ``
+ *
* @return string table name
*/
function getName($backquoted = false)
@@ -120,7 +133,9 @@ class PMA_Table
/**
* sets database name for this table
*
- * @param string $db_name
+ * @param string $db_name database name
+ *
+ * @return nothing
*/
function setDbName($db_name)
{
@@ -131,6 +146,7 @@ class PMA_Table
* returns database name for this table
*
* @param boolean $backquoted whether to quote name with backticks ``
+ *
* @return string database name for this table
*/
function getDbName($backquoted = false)
@@ -145,6 +161,7 @@ class PMA_Table
* returns full name for table, including database name
*
* @param boolean $backquoted whether to quote name with backticks ``
+ *
* @return string
*/
function getFullName($backquoted = false)
@@ -152,6 +169,14 @@ class PMA_Table
return $this->getDbName($backquoted) . '.' . $this->getName($backquoted);
}
+ /**
+ * returns whether the table is actually a view
+ *
+ * @param string $db database
+ * @param string $table table
+ *
+ * @return whether the given is a view
+ */
static public function isView($db = null, $table = null)
{
if (strlen($db) && strlen($table)) {
@@ -166,6 +191,8 @@ class PMA_Table
*
* @param string $param name
* @param mixed $value value
+ *
+ * @return nothing
*/
function set($param, $value)
{
@@ -176,6 +203,7 @@ class PMA_Table
* returns value for given setting/param
*
* @param string $param name for value to return
+ *
* @return mixed value for $param
*/
function get($param)
@@ -204,8 +232,10 @@ class PMA_Table
$this->settings = $table_info;
if ($this->get('TABLE_ROWS') === null) {
- $this->set('TABLE_ROWS', PMA_Table::countRecords($this->getDbName(),
- $this->getName(), true));
+ $this->set(
+ 'TABLE_ROWS',
+ PMA_Table::countRecords($this->getDbName(), $this->getName(), true)
+ );
}
$create_options = explode(' ', $this->get('TABLE_ROWS'));
@@ -224,10 +254,12 @@ class PMA_Table
/**
* Checks if this "table" is a view
*
+ * @param string $db the database name
+ * @param string $table the table name
+ *
* @deprecated
* @todo see what we could do with the possible existence of $table_is_view
- * @param string $db the database name
- * @param string $table the table name
+ *
* @return boolean whether this is a view
*/
static protected function _isView($db, $table)
@@ -237,7 +269,8 @@ class PMA_Table
return true;
}
- // Since phpMyAdmin 3.2 the field TABLE_TYPE is properly filled by PMA_DBI_get_tables_full()
+ // Since phpMyAdmin 3.2 the field TABLE_TYPE is properly filled by
+ // PMA_DBI_get_tables_full()
$type = PMA_Table::sGetStatusInfo($db, $table, 'TABLE_TYPE');
return $type == 'VIEW';
}
@@ -245,10 +278,12 @@ class PMA_Table
/**
* Checks if this is a merge table
*
- * If the ENGINE of the table is MERGE or MRG_MYISAM (alias), this is a merge table.
+ * If the ENGINE of the table is MERGE or MRG_MYISAM (alias),
+ * this is a merge table.
+ *
+ * @param string $db the database name
+ * @param string $table the table name
*
- * @param string $db the database name
- * @param string $table the table name
* @return boolean true if it is a merge table
*/
static public function isMerge($db = null, $table = null)
@@ -270,15 +305,17 @@ class PMA_Table
/**
* Returns full table status info, or specific if $info provided
- *
* this info is collected from information_schema
*
- * @todo PMA_DBI_get_tables_full needs to be merged somehow into this class or at least better documented
- * @param string $db
- * @param string $table
- * @param string $info
- * @param boolean $force_read
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $info
+ * @param boolean $force_read read new rather than serving from cache
* @param boolean $disable_error if true, disables error message
+ *
+ * @todo PMA_DBI_get_tables_full needs to be merged somehow into this class
+ * or at least better documented
+ *
* @return mixed
*/
static public function sGetStatusInfo($db, $table, $info = null, $force_read = false, $disable_error = false)
@@ -311,21 +348,24 @@ class PMA_Table
/**
* generates column specification for ALTER or CREATE TABLE syntax
*
+ * @param string $name name
+ * @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
+ * @param string $length length ('2', '5,2', '', ...)
+ * @param string $attribute attribute
+ * @param string $collation collation
+ * @param bool|string $null with 'NULL' or 'NOT NULL'
+ * @param string $default_type whether default is CURRENT_TIMESTAMP,
+ * NULL, NONE, USER_DEFINED
+ * @param string $default_value default value for USER_DEFINED default type
+ * @param string $extra 'AUTO_INCREMENT'
+ * @param string $comment field comment
+ * @param array &$field_primary list of fields for PRIMARY KEY
+ * @param string $index
+ *
* @todo move into class PMA_Column
- * @todo on the interface, some js to clear the default value when the default current_timestamp is checked
- * @param string $name name
- * @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
- * @param string $length length ('2', '5,2', '', ...)
- * @param string $attribute
- * @param string $collation
- * @param bool|string $null with 'NULL' or 'NOT NULL'
- * @param string $default_type whether default is CURRENT_TIMESTAMP,
- * NULL, NONE, USER_DEFINED
- * @param string $default_value default value for USER_DEFINED default type
- * @param string $extra 'AUTO_INCREMENT'
- * @param string $comment field comment
- * @param array &$field_primary list of fields for PRIMARY KEY
- * @param string $index
+ * @todo on the interface, some js to clear the default value when the default
+ * current_timestamp is checked
+ *
* @return string field specification
*/
static function generateFieldSpec($name, $type, $length = '', $attribute = '',
@@ -339,8 +379,9 @@ class PMA_Table
$query = PMA_backquote($name) . ' ' . $type;
if ($length != ''
- && !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT'
- . '|SERIAL|BOOLEAN)$@i', $type)) {
+ && ! preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|'
+ . 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN)$@i', $type)
+ ) {
$query .= '(' . $length . ')';
}
@@ -348,8 +389,9 @@ class PMA_Table
$query .= ' ' . $attribute;
}
- if (!empty($collation) && $collation != 'NULL'
- && preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)) {
+ if (! empty($collation) && $collation != 'NULL'
+ && preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)
+ ) {
$query .= PMA_generateCharsetQueryPart($collation);
}
@@ -362,24 +404,26 @@ class PMA_Table
}
switch ($default_type) {
- case 'USER_DEFINED' :
- if ($is_timestamp && $default_value === '0') {
- // a TIMESTAMP does not accept DEFAULT '0'
- // but DEFAULT 0 works
- $query .= ' DEFAULT 0';
- } elseif ($type == 'BIT') {
- $query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default_value) . '\'';
- } else {
- $query .= ' DEFAULT \'' . PMA_sqlAddSlashes($default_value) . '\'';
- }
- break;
- case 'NULL' :
- case 'CURRENT_TIMESTAMP' :
- $query .= ' DEFAULT ' . $default_type;
- break;
- case 'NONE' :
- default :
- break;
+ case 'USER_DEFINED' :
+ if ($is_timestamp && $default_value === '0') {
+ // a TIMESTAMP does not accept DEFAULT '0'
+ // but DEFAULT 0 works
+ $query .= ' DEFAULT 0';
+ } elseif ($type == 'BIT') {
+ $query .= ' DEFAULT b\''
+ . preg_replace('/[^01]/', '0', $default_value)
+ . '\'';
+ } else {
+ $query .= ' DEFAULT \'' . PMA_sqlAddSlashes($default_value) . '\'';
+ }
+ break;
+ case 'NULL' :
+ case 'CURRENT_TIMESTAMP' :
+ $query .= ' DEFAULT ' . $default_type;
+ break;
+ case 'NONE' :
+ default :
+ break;
}
if (!empty($extra)) {
@@ -389,16 +433,18 @@ class PMA_Table
if ($extra == 'AUTO_INCREMENT') {
$primary_cnt = count($field_primary);
if (1 == $primary_cnt) {
- for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) {
- //void
+ for ($j = 0; $j < $primary_cnt; $j++) {
+ if ($field_primary[$j] == $index) {
+ break;
+ }
}
if (isset($field_primary[$j]) && $field_primary[$j] == $index) {
$query .= ' PRIMARY KEY';
unset($field_primary[$j]);
}
- // but the PK could contain other columns so do not append
- // a PRIMARY KEY clause, just add a member to $field_primary
} else {
+ // but the PK could contain other columns so do not append
+ // a PRIMARY KEY clause, just add a member to $field_primary
$found_in_pk = false;
for ($j = 0; $j < $primary_cnt; $j++) {
if ($field_primary[$j] == $index) {
@@ -424,13 +470,13 @@ class PMA_Table
* Revision 13 July 2001: Patch for limiting dump size from
* vinay@sanisoft.com & girish@sanisoft.com
*
- * @param string $db the current database name
- * @param string $table the current table name
- * @param bool $force_exact whether to force an exact count
- * @param bool $is_view
+ * @param string $db the current database name
+ * @param string $table the current table name
+ * @param bool $force_exact whether to force an exact count
+ * @param bool $is_view whether the table is a view
*
- * @return mixed the number of records if "retain" param is true,
- * otherwise true
+ * @return mixed the number of records if "retain" param is true,
+ * otherwise true
*/
static public function countRecords($db, $table, $force_exact = false, $is_view = null)
{
@@ -462,7 +508,8 @@ class PMA_Table
if (! $is_view) {
$row_count = PMA_DBI_fetch_value(
'SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.'
- . PMA_backquote($table));
+ . PMA_backquote($table)
+ );
} else {
// For complex views, even trying to get a partial record
// count could bring down a server, so we offer an
@@ -478,9 +525,11 @@ class PMA_Table
// based on a table that no longer exists)
$result = PMA_DBI_try_query(
'SELECT 1 FROM ' . PMA_backquote($db) . '.'
- . PMA_backquote($table) . ' LIMIT '
- . $GLOBALS['cfg']['MaxExactCountViews'],
- null, PMA_DBI_QUERY_STORE);
+ . PMA_backquote($table) . ' LIMIT '
+ . $GLOBALS['cfg']['MaxExactCountViews'],
+ null,
+ PMA_DBI_QUERY_STORE
+ );
if (!PMA_DBI_getError()) {
$row_count = PMA_DBI_num_rows($result);
PMA_DBI_free_result($result);
@@ -497,22 +546,24 @@ class PMA_Table
/**
* Generates column specification for ALTER syntax
*
+ * @param string $oldcol old column name
+ * @param string $newcol new column name
+ * @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
+ * @param string $length length ('2', '5,2', '', ...)
+ * @param string $attribute attribute
+ * @param string $collation collation
+ * @param bool|string $null with 'NULL' or 'NOT NULL'
+ * @param string $default_type whether default is CURRENT_TIMESTAMP,
+ * NULL, NONE, USER_DEFINED
+ * @param string $default_value default value for USER_DEFINED default type
+ * @param string $extra 'AUTO_INCREMENT'
+ * @param string $comment field comment
+ * @param array &$field_primary list of fields for PRIMARY KEY
+ * @param string $index
+ * @param mixed $default_orig
+ *
* @see PMA_Table::generateFieldSpec()
- * @param string $oldcol old column name
- * @param string $newcol new column name
- * @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
- * @param string $length length ('2', '5,2', '', ...)
- * @param string $attribute
- * @param string $collation
- * @param bool|string $null with 'NULL' or 'NOT NULL'
- * @param string $default_type whether default is CURRENT_TIMESTAMP,
- * NULL, NONE, USER_DEFINED
- * @param string $default_value default value for USER_DEFINED default type
- * @param string $extra 'AUTO_INCREMENT'
- * @param string $comment field comment
- * @param array &$field_primary list of fields for PRIMARY KEY
- * @param string $index
- * @param mixed $default_orig
+ *
* @return string field specification
*/
static public function generateAlter($oldcol, $newcol, $type, $length,
@@ -520,26 +571,32 @@ class PMA_Table
$extra, $comment = '', &$field_primary, $index, $default_orig)
{
return PMA_backquote($oldcol) . ' '
- . PMA_Table::generateFieldSpec($newcol, $type, $length, $attribute,
+ . PMA_Table::generateFieldSpec(
+ $newcol, $type, $length, $attribute,
$collation, $null, $default_type, $default_value, $extra,
- $comment, $field_primary, $index, $default_orig);
+ $comment, $field_primary, $index, $default_orig
+ );
} // end function
/**
* Inserts existing entries in a PMA_* table by reading a value from an old entry
*
+ * @param string $work The array index, which Relation feature to check
+ * ('relwork', 'commwork', ...)
+ * @param string $pma_table The array index, which PMA-table to update
+ * ('bookmark', 'relation', ...)
+ * @param array $get_fields Which fields will be SELECT'ed from the old entry
+ * @param array $where_fields Which fields will be used for the WHERE query
+ * (array('FIELDNAME' => 'FIELDVALUE'))
+ * @param array $new_fields Which fields will be used as new VALUES. These are
+ * the important keys which differ from the old entry
+ * (array('FIELDNAME' => 'NEW FIELDVALUE'))
+ *
* @global relation variable
- * @param string $work The array index, which Relation feature to check ('relwork', 'commwork', ...)
- * @param string $pma_table The array index, which PMA-table to update ('bookmark', 'relation', ...)
- * @param array $get_fields Which fields will be SELECT'ed from the old entry
- * @param array $where_fields Which fields will be used for the WHERE query (array('FIELDNAME' => 'FIELDVALUE'))
- * @param array $new_fields Which fields will be used as new VALUES. These are the important
- * keys which differ from the old entry.
- * (array('FIELDNAME' => 'NEW FIELDVALUE'))
+ *
* @return int|true
*/
- static public function duplicateInfo($work, $pma_table, $get_fields, $where_fields,
- $new_fields)
+ static public function duplicateInfo($work, $pma_table, $get_fields, $where_fields, $new_fields)
{
$last_id = -1;
@@ -572,8 +629,9 @@ class PMA_Table
// must use PMA_DBI_QUERY_STORE here, since we execute another
// query inside the loop
- $table_copy_rs = PMA_query_as_controluser($table_copy_query, true,
- PMA_DBI_QUERY_STORE);
+ $table_copy_rs = PMA_query_as_controluser(
+ $table_copy_query, true, PMA_DBI_QUERY_STORE
+ );
while ($table_copy_row = @PMA_DBI_fetch_assoc($table_copy_rs)) {
$value_parts = array();
@@ -583,9 +641,9 @@ class PMA_Table
}
}
- $new_table_query = '
- INSERT IGNORE INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
- . '.' . PMA_backquote($GLOBALS['cfgRelation'][$pma_table]) . '
+ $new_table_query = 'INSERT IGNORE INTO '
+ . PMA_backquote($GLOBALS['cfgRelation']['db'])
+ . '.' . PMA_backquote($GLOBALS['cfgRelation'][$pma_table]) . '
(' . implode(', ', $select_parts) . ',
' . implode(', ', $new_parts) . ')
VALUES
@@ -608,14 +666,15 @@ class PMA_Table
/**
* Copies or renames table
*
- * @param $source_db
- * @param $source_table
- * @param $target_db
- * @param $target_table
- * @param $what
- * @param $move
- * @param $mode
- * @return bool
+ * @param string $source_db source database
+ * @param string $source_table source table
+ * @param string $target_db target database
+ * @param string $target_table target table
+ * @param string $what what to be moved or copied (data, dataonly)
+ * @param bool $move whether to move
+ * @param string $mode mode
+ *
+ * @return bool true if success, false otherwise
*/
static public function moveCopy($source_db, $source_table, $target_db, $target_table, $what, $move, $mode)
{
@@ -624,7 +683,10 @@ class PMA_Table
/* Try moving table directly */
if ($move && $what == 'data') {
$tbl = new PMA_Table($source_table, $source_db);
- $result = $tbl->rename($target_table, $target_db, PMA_Table::isView($source_db, $source_table));
+ $result = $tbl->rename(
+ $target_table, $target_db,
+ PMA_Table::isView($source_db, $source_table)
+ );
if ($result) {
$GLOBALS['message'] = $tbl->getLastMessage();
return true;
@@ -638,12 +700,14 @@ class PMA_Table
// Ensure the target is valid
if (! $GLOBALS['pma']->databases->exists($source_db, $target_db)) {
if (! $GLOBALS['pma']->databases->exists($source_db)) {
- $GLOBALS['message'] = PMA_Message::rawError('source database `'
- . htmlspecialchars($source_db) . '` not found');
+ $GLOBALS['message'] = PMA_Message::rawError(
+ 'source database `' . htmlspecialchars($source_db) . '` not found'
+ );
}
if (! $GLOBALS['pma']->databases->exists($target_db)) {
- $GLOBALS['message'] = PMA_Message::rawError('target database `'
- . htmlspecialchars($target_db) . '` not found');
+ $GLOBALS['message'] = PMA_Message::rawError(
+ 'target database `' . htmlspecialchars($target_db) . '` not found'
+ );
}
return false;
}
@@ -661,21 +725,25 @@ class PMA_Table
// do not create the table if dataonly
if ($what != 'dataonly') {
- require_once './libraries/export/sql.php';
+ include_once './libraries/export/sql.php';
$no_constraints_comments = true;
$GLOBALS['sql_constraints_query'] = '';
- $sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url, false, false);
+ $sql_structure = PMA_getTableDef(
+ $source_db, $source_table, "\n", $err_url, false, false
+ );
unset($no_constraints_comments);
$parsed_sql = PMA_SQP_parse($sql_structure);
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
$i = 0;
if (empty($analyzed_sql[0]['create_table_fields'])) {
- // this is not a CREATE TABLE, so find the first VIEW
+ // this is not a CREATE TABLE, so find the first VIEW
$target_for_view = PMA_backquote($target_db);
while (true) {
- if ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'VIEW') {
+ if ($parsed_sql[$i]['type'] == 'alpha_reservedWord'
+ && $parsed_sql[$i]['data'] == 'VIEW'
+ ) {
break;
}
$i++;
@@ -709,8 +777,10 @@ class PMA_Table
$last = $parsed_sql['len'] - 1;
$backquoted_source_db = PMA_backquote($source_db);
for (++$i; $i <= $last; $i++) {
- if ($parsed_sql[$i]['type'] == $table_delimiter && $parsed_sql[$i]['data'] == $backquoted_source_db) {
- $parsed_sql[$i]['data'] = $target_for_view;
+ if ($parsed_sql[$i]['type'] == $table_delimiter
+ && $parsed_sql[$i]['data'] == $backquoted_source_db
+ ) {
+ $parsed_sql[$i]['data'] = $target_for_view;
}
}
unset($last,$backquoted_source_db);
@@ -723,8 +793,9 @@ class PMA_Table
// If table exists, and 'add drop table' is selected: Drop it!
$drop_query = '';
if (isset($GLOBALS['drop_if_exists'])
- && $GLOBALS['drop_if_exists'] == 'true') {
- if (PMA_Table::_isView($target_db,$target_table)) {
+ && $GLOBALS['drop_if_exists'] == 'true'
+ ) {
+ if (PMA_Table::_isView($target_db, $target_table)) {
$drop_query = 'DROP VIEW';
} else {
$drop_query = 'DROP TABLE';
@@ -745,7 +816,8 @@ class PMA_Table
$GLOBALS['sql_query'] .= "\n" . $sql_structure . ';';
if (($move || isset($GLOBALS['add_constraints']))
- && !empty($GLOBALS['sql_constraints_query'])) {
+ && !empty($GLOBALS['sql_constraints_query'])
+ ) {
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints_query']);
$i = 0;
@@ -768,7 +840,8 @@ class PMA_Table
for ($j = $i; $j < $cnt; $j++) {
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
- && strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT') {
+ && strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT'
+ ) {
if ($parsed_sql[$j+1]['type'] == $table_delimiter) {
$parsed_sql[$j+1]['data'] = '';
}
@@ -776,8 +849,9 @@ class PMA_Table
}
// Generate query back
- $GLOBALS['sql_constraints_query'] = PMA_SQP_formatHtml($parsed_sql,
- 'query_only');
+ $GLOBALS['sql_constraints_query'] = PMA_SQP_formatHtml(
+ $parsed_sql, 'query_only'
+ );
if ($mode == 'one_table') {
PMA_DBI_query($GLOBALS['sql_constraints_query']);
}
@@ -791,9 +865,10 @@ class PMA_Table
}
// Copy the data unless this is a VIEW
- if (($what == 'data' || $what == 'dataonly') && ! PMA_Table::_isView($target_db,$target_table)) {
- $sql_insert_data =
- 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
+ if (($what == 'data' || $what == 'dataonly')
+ && ! PMA_Table::_isView($target_db, $target_table)
+ ) {
+ $sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
PMA_DBI_query($sql_insert_data);
$GLOBALS['sql_query'] .= "\n\n" . $sql_insert_data . ';';
}
@@ -807,7 +882,7 @@ class PMA_Table
// moving table from replicated one to not replicated one
PMA_DBI_select_db($source_db);
- if (PMA_Table::_isView($source_db,$source_table)) {
+ if (PMA_Table::_isView($source_db, $source_table)) {
$sql_drop_query = 'DROP VIEW';
} else {
$sql_drop_query = 'DROP TABLE';
@@ -902,7 +977,7 @@ class PMA_Table
}
$GLOBALS['sql_query'] .= "\n\n" . $sql_drop_query . ';';
- // end if ($move)
+ // end if ($move)
} else {
// we are copying
// Create new entries as duplicates from old PMA DBs
@@ -993,9 +1068,11 @@ class PMA_Table
* checks if given name is a valid table name,
* currently if not empty, trailing spaces, '.', '/' and '\'
*
- * @todo add check for valid chars in filename on current system/os
- * @see http://dev.mysql.com/doc/refman/5.0/en/legal-names.html
- * @param string $table_name name to check
+ * @param string $table_name name to check
+ *
+ * @todo add check for valid chars in filename on current system/os
+ * @see http://dev.mysql.com/doc/refman/5.0/en/legal-names.html
+ *
* @return boolean whether the string is valid or not
*/
function isValidName($table_name)
@@ -1021,10 +1098,11 @@ class PMA_Table
/**
* renames table
*
- * @param string $new_name new table name
- * @param string $new_db new database name
- * @param bool $is_view is this for a VIEW rename?
- * @return bool success
+ * @param string $new_name new table name
+ * @param string $new_db new database name
+ * @param bool $is_view is this for a VIEW rename?
+ *
+ * @return bool success
*/
function rename($new_name, $new_db = null, $is_view = false)
{
@@ -1060,7 +1138,11 @@ class PMA_Table
}
// I don't think a specific error message for views is necessary
if (! PMA_DBI_query($GLOBALS['sql_query'])) {
- $this->errors[] = sprintf(__('Error renaming table %1$s to %2$s'), $this->getFullName(), $new_table->getFullName());
+ $this->errors[] = sprintf(
+ __('Error renaming table %1$s to %2$s'),
+ $this->getFullName(),
+ $new_table->getFullName()
+ );
return false;
}
@@ -1143,8 +1225,11 @@ class PMA_Table
unset($table_query);
}
- $this->messages[] = sprintf(__('Table %s has been renamed to %s'),
- htmlspecialchars($old_name), htmlspecialchars($new_name));
+ $this->messages[] = sprintf(
+ __('Table %s has been renamed to %s'),
+ htmlspecialchars($old_name),
+ htmlspecialchars($new_name)
+ );
return true;
}
@@ -1160,8 +1245,8 @@ class PMA_Table
* - PRIMARY(fk_id1, fk_id2) // NONE
* - UNIQUE(x,y) // NONE
*
+ * @param bool $backquoted whether to quote name with backticks ``
*
- * @param bool $backquoted whether to quote name with backticks ``
* @return array
*/
public function getUniqueColumns($backquoted = true)
@@ -1174,7 +1259,8 @@ class PMA_Table
if (count($index) > 1) {
continue;
}
- $return[] = $this->getFullName($backquoted) . '.' . ($backquoted ? PMA_backquote($index[0]) : $index[0]);
+ $return[] = $this->getFullName($backquoted) . '.'
+ . ($backquoted ? PMA_backquote($index[0]) : $index[0]);
}
return $return;
@@ -1188,7 +1274,8 @@ class PMA_Table
*
* e.g. index(col1, col2) would only return col1
*
- * @param bool $backquoted whether to quote name with backticks ``
+ * @param bool $backquoted whether to quote name with backticks ``
+ *
* @return array
*/
public function getIndexedColumns($backquoted = true)
@@ -1198,7 +1285,8 @@ class PMA_Table
$return = array();
foreach ($indexed as $column) {
- $return[] = $this->getFullName($backquoted) . '.' . ($backquoted ? PMA_backquote($column) : $column);
+ $return[] = $this->getFullName($backquoted) . '.'
+ . ($backquoted ? PMA_backquote($column) : $column);
}
return $return;
@@ -1209,7 +1297,8 @@ class PMA_Table
*
* returns an array with all columns
*
- * @param bool $backquoted whether to quote name with backticks ``
+ * @param bool $backquoted whether to quote name with backticks ``
+ *
* @return array
*/
public function getColumns($backquoted = true)
@@ -1219,7 +1308,8 @@ class PMA_Table
$return = array();
foreach ($indexed as $column) {
- $return[] = $this->getFullName($backquoted) . '.' . ($backquoted ? PMA_backquote($column) : $column);
+ $return[] = $this->getFullName($backquoted) . '.'
+ . ($backquoted ? PMA_backquote($column) : $column);
}
return $return;
@@ -1228,7 +1318,6 @@ class PMA_Table
/**
* Return UI preferences for this table from phpMyAdmin database.
*
- *
* @return array
*/
protected function getUiPrefsFromDb()
@@ -1237,11 +1326,10 @@ class PMA_Table
PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
// Read from phpMyAdmin database
- $sql_query =
- " SELECT `prefs` FROM " . $pma_table .
- " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'" .
- " AND `db_name` = '" . PMA_sqlAddSlashes($this->db_name) . "'" .
- " AND `table_name` = '" . PMA_sqlAddSlashes($this->name) . "'";
+ $sql_query = " SELECT `prefs` FROM " . $pma_table
+ . " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'"
+ . " AND `db_name` = '" . PMA_sqlAddSlashes($this->db_name) . "'"
+ . " AND `table_name` = '" . PMA_sqlAddSlashes($this->name) . "'";
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
if (isset($row[0])) {
@@ -1258,22 +1346,23 @@ class PMA_Table
*/
protected function saveUiPrefsToDb()
{
- $pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".".
- PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
+ $pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "."
+ . PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
$username = $GLOBALS['cfg']['Server']['user'];
- $sql_query =
- " REPLACE INTO " . $pma_table .
- " VALUES ('" . $username . "', '" . PMA_sqlAddSlashes($this->db_name) . "', '" .
- PMA_sqlAddSlashes($this->name) . "', '" .
- PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)";
+ $sql_query = " REPLACE INTO " . $pma_table
+ . " VALUES ('" . $username . "', '" . PMA_sqlAddSlashes($this->db_name)
+ . "', '" . PMA_sqlAddSlashes($this->name) . "', '"
+ . PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)";
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
if (!$success) {
$message = PMA_Message::error(__('Could not save table UI preferences'));
$message->addMessage(' ');
- $message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
+ $message->addMessage(
+ PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink']))
+ );
return $message;
}
@@ -1290,13 +1379,15 @@ class PMA_Table
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
if (!$success) {
- $message = PMA_Message::error(sprintf(
- __('Failed to cleanup table UI preferences (see $cfg[\'Servers\'][$i][\'MaxTableUiprefs\'] %s)'),
- PMA_showDocu('cfg_Servers_MaxTableUiprefs')
- ));
+ $message = PMA_Message::error(
+ sprintf(
+ __('Failed to cleanup table UI preferences (see $cfg[\'Servers\'][$i][\'MaxTableUiprefs\'] %s)'),
+ PMA_showDocu('cfg_Servers_MaxTableUiprefs')
+ )
+ );
$message->addMessage(' ');
$message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
- print_r($message);
+ print_r($message);
return $message;
}
}
@@ -1309,6 +1400,7 @@ class PMA_Table
* If pmadb and table_uiprefs is set, it will load the UI preferences from
* phpMyAdmin database.
*
+ * @return nothing
*/
protected function loadUiPrefs()
{
@@ -1316,10 +1408,11 @@ class PMA_Table
// set session variable if it's still undefined
if (! isset($_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name])) {
$_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name] =
- // check whether we can get from pmadb
- (strlen($GLOBALS['cfg']['Server']['pmadb'])
- && strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) ?
- $this->getUiPrefsFromDb() : array();
+ // check whether we can get from pmadb
+ (strlen($GLOBALS['cfg']['Server']['pmadb'])
+ && strlen($GLOBALS['cfg']['Server']['table_uiprefs']))
+ ? $this->getUiPrefsFromDb()
+ : array();
}
$this->uiprefs =& $_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name];
}
@@ -1332,8 +1425,8 @@ class PMA_Table
* - PROP_COLUMN_ORDER
* - PROP_COLUMN_VISIB
*
+ * @param string $property property
*
- * @param string $property
* @return mixed
*/
public function getUiProp($property)
@@ -1350,8 +1443,7 @@ class PMA_Table
$avail_columns = $this->getColumns();
foreach ($avail_columns as $each_col) {
// check if $each_col ends with $colname
- if (substr_compare($each_col, $colname,
- strlen($each_col) - strlen($colname)) === 0) {
+ if (substr_compare($each_col, $colname, strlen($each_col) - strlen($colname)) === 0) {
return $this->uiprefs[$property];
}
}
@@ -1361,12 +1453,12 @@ class PMA_Table
} else {
return false;
}
- } else if ($property == self::PROP_COLUMN_ORDER ||
- $property == self::PROP_COLUMN_VISIB) {
+ } elseif ($property == self::PROP_COLUMN_ORDER
+ || $property == self::PROP_COLUMN_VISIB
+ ) {
if (! PMA_Table::isView($this->db_name, $this->name) && isset($this->uiprefs[$property])) {
// check if the table has not been modified
- if (self::sGetStatusInfo($this->db_name, $this->name, 'Create_time') ==
- $this->uiprefs['CREATE_TIME']) {
+ if (self::sGetStatusInfo($this->db_name, $this->name, 'Create_time') == $this->uiprefs['CREATE_TIME']) {
return $this->uiprefs[$property];
} else {
// remove the property, since the table has been modified
@@ -1390,9 +1482,10 @@ class PMA_Table
* - PROP_COLUMN_ORDER
* - PROP_COLUMN_VISIB
*
- * @param string $property
- * @param mixed $value
+ * @param string $property Property
+ * @param mixed $value Value for the property
* @param string $table_create_time Needed for PROP_COLUMN_ORDER and PROP_COLUMN_VISIB
+ *
* @return boolean|PMA_Message
*/
public function setUiProp($property, $value, $table_create_time = null)
@@ -1401,12 +1494,13 @@ class PMA_Table
$this->loadUiPrefs();
}
// we want to save the create time if the property is PROP_COLUMN_ORDER
- if (! PMA_Table::isView($this->db_name, $this->name) && ($property == self::PROP_COLUMN_ORDER ||
- $property == self::PROP_COLUMN_VISIB)) {
-
+ if (! PMA_Table::isView($this->db_name, $this->name)
+ && ($property == self::PROP_COLUMN_ORDER || $property == self::PROP_COLUMN_VISIB)
+ ) {
$curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME');
- if (isset($table_create_time) &&
- $table_create_time == $curr_create_time) {
+ if (isset($table_create_time)
+ && $table_create_time == $curr_create_time
+ ) {
$this->uiprefs['CREATE_TIME'] = $curr_create_time;
} else {
// there is no $table_create_time, or
@@ -1419,7 +1513,8 @@ class PMA_Table
$this->uiprefs[$property] = $value;
// check if pmadb is set
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
- && strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) {
+ && strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
+ ) {
return $this->saveUiprefsToDb();
}
return true;
@@ -1428,7 +1523,8 @@ class PMA_Table
/**
* Remove a property from UI preferences.
*
- * @param string $property
+ * @param string $property the property
+ *
* @return true|PMA_Message
*/
public function removeUiProp($property)
@@ -1440,7 +1536,8 @@ class PMA_Table
unset($this->uiprefs[$property]);
// check if pmadb is set
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
- && strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) {
+ && strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
+ ) {
return $this->saveUiprefsToDb();
}
}
diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php
index de216ab9c5..e71b7d601e 100644
--- a/libraries/Tracker.class.php
+++ b/libraries/Tracker.class.php
@@ -71,6 +71,7 @@ class PMA_Tracker
*
* @static
*
+ * @return nothing
*/
static public function init()
{
@@ -86,15 +87,15 @@ class PMA_Tracker
self::$default_tracking_set = $GLOBALS['cfg']['Server']['tracking_default_statements'];
self::$version_auto_create = $GLOBALS['cfg']['Server']['tracking_version_auto_create'];
-
}
/**
- * Actually enables tracking. This needs to be done after all
+ * Actually enables tracking. This needs to be done after all
* underlaying code is initialized.
*
* @static
*
+ * @return nothing
*/
static public function enable()
{
@@ -133,9 +134,9 @@ class PMA_Tracker
/**
* Parses the name of a table from a SQL statement substring.
*
- * @static
+ * @param string $string part of SQL statement
*
- * @param string $string part of SQL statement
+ * @static
*
* @return string the name of table
*/
@@ -144,8 +145,7 @@ class PMA_Tracker
if (strstr($string, '.')) {
$temp = explode('.', $string);
$tablename = $temp[1];
- }
- else {
+ } else {
$tablename = $string;
}
@@ -163,10 +163,10 @@ class PMA_Tracker
/**
* Gets the tracking status of a table, is it active or deactive ?
*
- * @static
+ * @param string $dbname name of database
+ * @param string $tablename name of table
*
- * @param string $dbname name of database
- * @param string $tablename name of table
+ * @static
*
* @return boolean true or false
*/
@@ -184,8 +184,7 @@ class PMA_Tracker
return false;
}
- $sql_query =
- " SELECT tracking_active FROM " . self::$pma_table .
+ $sql_query = " SELECT tracking_active FROM " . self::$pma_table .
" WHERE db_name = '" . PMA_sqlAddSlashes($dbname) . "' " .
" AND table_name = '" . PMA_sqlAddSlashes($tablename) . "' " .
" ORDER BY version DESC";
@@ -215,14 +214,14 @@ class PMA_Tracker
* Creates tracking version of a table / view
* (in other words: create a job to track future changes on the table).
*
- * @static
- *
* @param string $dbname name of database
* @param string $tablename name of table
* @param string $version version
* @param string $tracking_set set of tracking statements
* @param bool $is_view if table is a view
*
+ * @static
+ *
* @return int result of version insertion
*/
static public function createVersion($dbname, $tablename, $version, $tracking_set = '', $is_view = false)
@@ -233,7 +232,7 @@ class PMA_Tracker
$tracking_set = self::$default_tracking_set;
}
- require_once './libraries/export/sql.php';
+ include_once './libraries/export/sql.php';
$sql_backquotes = true;
@@ -256,7 +255,7 @@ class PMA_Tracker
$indexes = array();
- while($row = PMA_DBI_fetch_assoc($sql_result)) {
+ while ($row = PMA_DBI_fetch_assoc($sql_result)) {
$indexes[] = $row;
}
@@ -284,8 +283,7 @@ class PMA_Tracker
// Save version
- $sql_query =
- "/*NOTRACK*/\n" .
+ $sql_query = "/*NOTRACK*/\n" .
"INSERT INTO" . self::$pma_table . " (" .
"db_name, " .
"table_name, " .
@@ -320,19 +318,18 @@ class PMA_Tracker
/**
- * Removes all tracking data for a table
+ * Removes all tracking data for a table
+ *
+ * @param string $dbname name of database
+ * @param string $tablename name of table
*
* @static
*
- * @param string $dbname name of database
- * @param string $tablename name of table
- *
* @return int result of version insertion
*/
static public function deleteTracking($dbname, $tablename)
{
- $sql_query =
- "/*NOTRACK*/\n" .
+ $sql_query = "/*NOTRACK*/\n" .
"DELETE FROM " . self::$pma_table . " WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "'";
$result = PMA_query_as_controluser($sql_query);
@@ -343,13 +340,13 @@ class PMA_Tracker
* Creates tracking version of a database
* (in other words: create a job to track future changes on the database).
*
- * @static
- *
* @param string $dbname name of database
* @param string $version version
* @param string $query query
* @param string $tracking_set set of tracking statements
*
+ * @static
+ *
* @return int result of version insertion
*/
static public function createDatabaseVersion($dbname, $version, $query, $tracking_set = 'CREATE DATABASE,ALTER DATABASE,DROP DATABASE')
@@ -360,7 +357,7 @@ class PMA_Tracker
$tracking_set = self::$default_tracking_set;
}
- require_once './libraries/export/sql.php';
+ include_once './libraries/export/sql.php';
$create_sql = "";
@@ -372,8 +369,7 @@ class PMA_Tracker
$create_sql .= self::getLogComment() . $query;
// Save version
- $sql_query =
- "/*NOTRACK*/\n" .
+ $sql_query = "/*NOTRACK*/\n" .
"INSERT INTO" . self::$pma_table . " (" .
"db_name, " .
"table_name, " .
@@ -406,19 +402,18 @@ class PMA_Tracker
/**
* Changes tracking of a table.
*
- * @static
+ * @param string $dbname name of database
+ * @param string $tablename name of table
+ * @param string $version version
+ * @param integer $new_state the new state of tracking
*
- * @param string $dbname name of database
- * @param string $tablename name of table
- * @param string $version version
- * @param integer $new_state the new state of tracking
+ * @static
*
* @return int result of SQL query
*/
- static private function changeTracking($dbname, $tablename, $version, $new_state)
+ static private function _changeTracking($dbname, $tablename, $version, $new_state)
{
- $sql_query =
- " UPDATE " . self::$pma_table .
+ $sql_query = " UPDATE " . self::$pma_table .
" SET `tracking_active` = '" . $new_state . "' " .
" WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' " .
@@ -432,38 +427,38 @@ class PMA_Tracker
/**
* Changes tracking data of a table.
*
- * @static
+ * @param string $dbname name of database
+ * @param string $tablename name of table
+ * @param string $version version
+ * @param string $type type of data(DDL || DML)
+ * @param string|array $new_data the new tracking data
*
- * @param string $dbname name of database
- * @param string $tablename name of table
- * @param string $version version
- * @param string $type type of data(DDL || DML)
- * @param string|array $new_data the new tracking data
+ * @static
*
* @return bool result of change
*/
static public function changeTrackingData($dbname, $tablename, $version, $type, $new_data)
{
- if ($type == 'DDL')
+ if ($type == 'DDL') {
$save_to = 'schema_sql';
- elseif ($type == 'DML')
+ } elseif ($type == 'DML') {
$save_to = 'data_sql';
- else
+ } else {
return false;
-
+ }
$date = date('Y-m-d H:i:s');
$new_data_processed = '';
if (is_array($new_data)) {
foreach ($new_data as $data) {
- $new_data_processed .= '# log ' . $date . ' ' . $data['username'] . PMA_sqlAddSlashes($data['statement']) . "\n";
+ $new_data_processed .= '# log ' . $date . ' ' . $data['username']
+ . PMA_sqlAddSlashes($data['statement']) . "\n";
}
} else {
$new_data_processed = $new_data;
}
- $sql_query =
- " UPDATE " . self::$pma_table .
+ $sql_query = " UPDATE " . self::$pma_table .
" SET `" . $save_to . "` = '" . $new_data_processed . "' " .
" WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' " .
@@ -477,34 +472,34 @@ class PMA_Tracker
/**
* Activates tracking of a table.
*
- * @static
+ * @param string $dbname name of database
+ * @param string $tablename name of table
+ * @param string $version version
*
- * @param string $dbname name of database
- * @param string $tablename name of table
- * @param string $version version
+ * @static
*
* @return int result of SQL query
*/
static public function activateTracking($dbname, $tablename, $version)
{
- return self::changeTracking($dbname, $tablename, $version, 1);
+ return self::_changeTracking($dbname, $tablename, $version, 1);
}
/**
* Deactivates tracking of a table.
*
- * @static
+ * @param string $dbname name of database
+ * @param string $tablename name of table
+ * @param string $version version
*
- * @param string $dbname name of database
- * @param string $tablename name of table
- * @param string $version version
+ * @static
*
* @return int result of SQL query
*/
static public function deactivateTracking($dbname, $tablename, $version)
{
- return self::changeTracking($dbname, $tablename, $version, 0);
+ return self::_changeTracking($dbname, $tablename, $version, 0);
}
@@ -512,18 +507,17 @@ class PMA_Tracker
* Gets the newest version of a tracking job
* (in other words: gets the HEAD version).
*
- * @static
+ * @param string $dbname name of database
+ * @param string $tablename name of table
+ * @param string $statement tracked statement
*
- * @param string $dbname name of database
- * @param string $tablename name of table
- * @param string $statement tracked statement
+ * @static
*
* @return int (-1 if no version exists | > 0 if a version exists)
*/
static public function getVersion($dbname, $tablename, $statement = null)
{
- $sql_query =
- " SELECT MAX(version) FROM " . self::$pma_table .
+ $sql_query = " SELECT MAX(version) FROM " . self::$pma_table .
" WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' ";
@@ -540,11 +534,11 @@ class PMA_Tracker
/**
* Gets the record of a tracking job.
*
- * @static
+ * @param string $dbname name of database
+ * @param string $tablename name of table
+ * @param string $version version number
*
- * @param string $dbname name of database
- * @param string $tablename name of table
- * @param string $version version number
+ * @static
*
* @return mixed record DDM log, DDL log, structure snapshot, tracked statements.
*/
@@ -644,12 +638,12 @@ class PMA_Tracker
* - type of statement, is it part of DDL or DML ?
* - tablename
*
+ * @param string $query query
+ *
* @static
* @todo: using PMA SQL Parser when possible
* @todo: support multi-table/view drops
*
- * @param string $query
- *
* @return mixed Array containing identifier, type and tablename.
*
*/
@@ -684,9 +678,10 @@ class PMA_Tracker
$result['type'] = 'DDL';
// Parse CREATE VIEW statement
- if (in_array('CREATE', $tokens) == true &&
- in_array('VIEW', $tokens) == true &&
- in_array('AS', $tokens) == true) {
+ if (in_array('CREATE', $tokens) == true
+ && in_array('VIEW', $tokens) == true
+ && in_array('AS', $tokens) == true
+ ) {
$result['identifier'] = 'CREATE VIEW';
$index = array_search('VIEW', $tokens);
@@ -695,10 +690,11 @@ class PMA_Tracker
}
// Parse ALTER VIEW statement
- if (in_array('ALTER', $tokens) == true &&
- in_array('VIEW', $tokens) == true &&
- in_array('AS', $tokens) == true &&
- ! isset($result['identifier'])) {
+ if (in_array('ALTER', $tokens) == true
+ && in_array('VIEW', $tokens) == true
+ && in_array('AS', $tokens) == true
+ && ! isset($result['identifier'])
+ ) {
$result['identifier'] = 'ALTER VIEW';
$index = array_search('VIEW', $tokens);
@@ -778,11 +774,10 @@ class PMA_Tracker
}
// Parse CREATE INDEX statement
- if (! isset($result['identifier']) &&
- ( substr($query, 0, 12) == 'CREATE INDEX' ||
- substr($query, 0, 19) == 'CREATE UNIQUE INDEX' ||
- substr($query, 0, 20) == 'CREATE SPATIAL INDEX'
- )
+ if (! isset($result['identifier'])
+ && (substr($query, 0, 12) == 'CREATE INDEX'
+ || substr($query, 0, 19) == 'CREATE UNIQUE INDEX'
+ || substr($query, 0, 20) == 'CREATE SPATIAL INDEX')
) {
$result['identifier'] = 'CREATE INDEX';
$prefix = explode('ON ', $query);
@@ -822,7 +817,7 @@ class PMA_Tracker
}
// Parse INSERT INTO statement
- if (! isset($result['identifier']) && substr($query, 0, 11 ) == 'INSERT INTO') {
+ if (! isset($result['identifier']) && substr($query, 0, 11) == 'INSERT INTO') {
$result['identifier'] = 'INSERT';
$prefix = explode('INSERT INTO', $query);
$suffix = explode('(', $prefix[1]);
@@ -830,7 +825,7 @@ class PMA_Tracker
}
// Parse DELETE statement
- if (! isset($result['identifier']) && substr($query, 0, 6 ) == 'DELETE') {
+ if (! isset($result['identifier']) && substr($query, 0, 6) == 'DELETE') {
$result['identifier'] = 'DELETE';
$prefix = explode('FROM ', $query);
$suffix = explode(' ', $prefix[1]);
@@ -838,7 +833,7 @@ class PMA_Tracker
}
// Parse TRUNCATE statement
- if (! isset($result['identifier']) && substr($query, 0, 8 ) == 'TRUNCATE') {
+ if (! isset($result['identifier']) && substr($query, 0, 8) == 'TRUNCATE') {
$result['identifier'] = 'TRUNCATE';
$prefix = explode('TRUNCATE', $query);
$result['tablename'] = self::getTableName($prefix[1]);
@@ -851,8 +846,11 @@ class PMA_Tracker
/**
* Analyzes a given SQL statement and saves tracking data.
*
- * @static
* @param string $query a SQL query
+ *
+ * @static
+ *
+ * @return nothing
*/
static public function handleQuery($query)
{
@@ -881,8 +879,9 @@ class PMA_Tracker
// If version not exists and auto-creation is enabled
if (self::$version_auto_create == true
- && self::isTracked($dbname, $result['tablename']) == false
- && $version == -1) {
+ && self::isTracked($dbname, $result['tablename']) == false
+ && $version == -1
+ ) {
// Create the version
switch ($result['identifier']) {
@@ -916,11 +915,10 @@ class PMA_Tracker
$query = self::getLogComment() . $query ;
// Mark it as untouchable
- $sql_query =
- " /*NOTRACK*/\n" .
+ $sql_query = " /*NOTRACK*/\n" .
" UPDATE " . self::$pma_table .
- " SET " . PMA_backquote($save_to) ." = CONCAT( " . PMA_backquote($save_to) . ",'\n" . PMA_sqlAddSlashes($query) . "') ," .
- " `date_updated` = '" . $date . "' ";
+ " SET " . PMA_backquote($save_to) ." = CONCAT( " . PMA_backquote($save_to) . ",'\n"
+ . PMA_sqlAddSlashes($query) . "') ," . " `date_updated` = '" . $date . "' ";
// If table was renamed we have to change the tablename attribute in pma_tracking too
if ($result['identifier'] == 'RENAME TABLE') {
diff --git a/libraries/advisory_rules.txt b/libraries/advisory_rules.txt
index bbc8d5c6fd..58c75d185c 100644
--- a/libraries/advisory_rules.txt
+++ b/libraries/advisory_rules.txt
@@ -74,9 +74,9 @@ rule 'Slow query logging'
#
# versions
-rule 'Release Series'
+rule 'Release Series' [!PMA_DRIZZLE]
version
- !PMA_DRIZZLE && substr(value,0,1) <= 5 && substr(value,2,1) < 1
+ substr(value,0,1) <= 5 && substr(value,2,1) < 1
The MySQL server version less then 5.1.
You should upgrade, as MySQL 5.1 has improved performance, and MySQL 5.5 even more so.
Current version: %s | value
@@ -111,7 +111,7 @@ rule 'Distribution'
rule 'MySQL Architecture'
system_memory
- value > 3072*1024 && !preg_match('/64/',version_compile_machine)
+ value > 3072*1024 && !preg_match('/64/',version_compile_machine) && !preg_match('/64/',version_compile_os)
MySQL is not compiled as a 64-bit package.
Your memory capacity is above 3 GiB (assuming the Server is on localhost), so MySQL might not be able to access all of your memory. You might want to consider installing the 64-bit version of MySQL.
Available memory on this host: %s | implode(' ',PMA_formatByteDown(value*1024, 2, 2))
@@ -131,7 +131,7 @@ rule 'Query caching method' [!fired('Query cache disabled')]
Questions / Uptime
value > 100
Suboptimal caching method.
- You are using the MySQL Query cache with a fairly high traffic database. It might be worth considering to use memcached instead of the MySQL Query cache, especially if you have multiple slaves.
+ You are using the MySQL Query cache with a fairly high traffic database. It might be worth considering to use memcached instead of the MySQL Query cache, especially if you have multiple slaves.
The query cache is enabled and the server receives %d queries per second. This rule fires if there is more than 100 queries per second. | round(value,1)
rule 'Query cache efficiency (%)' [Com_select + Qcache_hits > 0 && !fired('Query cache disabled')]
@@ -247,19 +247,19 @@ rule 'Temp disk rate'
Created_tmp_disk_tables / Uptime
value * 60 * 60 > 1
Many temporary tables are being written to disk instead of being kept in memory.
- Increasing {max_heap_table_size} and {tmp_table_size} might help. However some temporary tables are always being written to disk, independent of the value of these variables. To eliminate these you will have to rewrite your queries to avoid those conditions (Within a temprorary table: Presence of a BLOB or TEXT column or presence of a column bigger than 512 bytes) as mentioned in in the MySQL Documentation
+ Increasing {max_heap_table_size} and {tmp_table_size} might help. However some temporary tables are always being written to disk, independent of the value of these variables. To eliminate these you will have to rewrite your queries to avoid those conditions (Within a temprorary table: Presence of a BLOB or TEXT column or presence of a column bigger than 512 bytes) as mentioned in in the MySQL Documentation
Rate of temporay tables being written to disk: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
# I couldn't find any source on the internet that suggests a direct relation between high counts of temporary tables and any of these variables.
# Several independent Blog entries suggest (http://ronaldbradford.com/blog/more-on-understanding-sort_buffer_size-2010-05-10/ and http://www.xaprb.com/blog/2010/05/09/how-to-tune-mysqls-sort_buffer_size/)
# that sort_buffer_size should be left as it is. And increasing read_buffer_size is only suggested when there are a lot of
-# table scans (http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_read_buffer_size and other sources) though
+# table scans (http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_read_buffer_size and other sources) though
# setting it too high is bad too (http://www.mysqlperformanceblog.com/2007/09/17/mysql-what-read_buffer_size-value-is-optimal/).
#rule 'Temp table rate'
# Created_tmp_tables / Uptime
# value * 60 * 60 > 1
# Many intermediate temporary tables are being created.
-# This may be caused by queries under certain conditions as mentioned in the MySQL Documentation . Consider increasing {sort_buffer_size} (sorting), {read_rnd_buffer_size} (random read buffer, ie, post-sort), {read_buffer_size} (sequential scan).
+# This may be caused by queries under certain conditions as mentioned in the MySQL Documentation . Consider increasing {sort_buffer_size} (sorting), {read_rnd_buffer_size} (random read buffer, ie, post-sort), {read_buffer_size} (sequential scan).
#
# MyISAM index cache
@@ -428,9 +428,9 @@ rule 'InnoDB buffer pool size' [system_memory > 0]
# other
rule 'MyISAM concurrent inserts'
concurrent_insert
- value == 0
+ value === 0 || value === 'NEVER'
Enable concurrent_insert by setting it to 1
- Setting {concurrent_insert} to 1 reduces contention between readers and writers for a given table. See also MySQL Documentation
+ Setting {concurrent_insert} to 1 reduces contention between readers and writers for a given table. See also MySQL Documentation
concurrent_insert is set to 0
# INSERT DELAYED USAGE
diff --git a/libraries/core.lib.php b/libraries/core.lib.php
index dcc5208bc6..a277f29629 100644
--- a/libraries/core.lib.php
+++ b/libraries/core.lib.php
@@ -708,13 +708,27 @@ function PMA_includeJS($url)
}
/**
- * Adds JS code snippets to be displayed by header.inc.php. Adds a newline to each snippet.
+ * Adds JS code snippets to be displayed by header.inc.php. Adds a
+ * newline to each snippet.
*
* @param string $str Js code to be added (e.g. "token=1234;")
*
*/
-function PMA_AddJSCode($str) {
+function PMA_AddJSCode($str)
+{
$GLOBALS['js_script'][] = $str;
}
+/**
+ * Adds JS code snippet for variable assignment to be displayed by header.inc.php.
+ *
+ * @param string $key Name of value to set
+ * @param mixed $value Value to set, can be either string or array of strings
+ *
+ */
+function PMA_AddJSVar($key, $value)
+{
+ PMA_AddJsCode(PMA_getJsValue($key, $value));
+}
+
?>
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index ddcfb7a175..e7488ffd61 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -578,8 +578,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
echo ' ';
}
// generate table create time
- echo ' ';
+ if (! PMA_Table::isView($GLOBALS['table'], $GLOBALS['db'])) {
+ echo ' ';
+ }
}
diff --git a/libraries/js_escape.lib.php b/libraries/js_escape.lib.php
index 656794f819..87d88552a6 100644
--- a/libraries/js_escape.lib.php
+++ b/libraries/js_escape.lib.php
@@ -56,25 +56,64 @@ function PMA_escapeJsString($string)
"\r" => '\r')));
}
+/**
+ * Formats a value for javascript code.
+ *
+ * @param string $value String to be formatted.
+ *
+ * @retrun string formatted value.
+ */
+function PMA_formatJsVal($value)
+{
+ if (is_bool($value)) {
+ if ($value) {
+ return 'true';
+ } else {
+ return 'false';
+ }
+ } elseif (is_int($value)) {
+ return (int)$value;
+ } else {
+ return '"' . PMA_escapeJsString($value) . '"';
+ }
+}
+
+/**
+ * Formats an javascript assignment with proper escaping of a value
+ * and support for assigning array of strings.
+ *
+ * @param string $key Name of value to set
+ * @param mixed $value Value to set, can be either string or array of strings
+ *
+ * @return string Javascript code.
+ */
+function PMA_getJsValue($key, $value)
+{
+ $result = $key . ' = ';
+ if (is_array($value)) {
+ $result .= '[';
+ foreach ($value as $id => $val) {
+ $result .= PMA_formatJsVal($value) . ",";
+ }
+ $result .= "];\n";
+ } else {
+ $result .= PMA_formatJsVal($value) . ";\n";
+ }
+ return $result;
+}
+
/**
* Prints an javascript assignment with proper escaping of a value
* and support for assigning array of strings.
*
* @param string $key Name of value to set
* @param mixed $value Value to set, can be either string or array of strings
+ *
+ * @return nothing
*/
function PMA_printJsValue($key, $value)
{
- echo $key . ' = ';
- if (is_array($value)) {
- echo '[';
- foreach ($value as $id => $val) {
- echo "'" . PMA_escapeJsString($val) . "',";
- }
- echo "];\n";
- } else {
- echo "'" . PMA_escapeJsString($value) . "';\n";
- }
+ echo PMA_getJsValue($key, $value);
}
?>
diff --git a/pmd_common.php b/libraries/pmd_common.php
similarity index 100%
rename from pmd_common.php
rename to libraries/pmd_common.php
diff --git a/libraries/replication.inc.php b/libraries/replication.inc.php
index 58ed7c5acc..857f4dc8da 100644
--- a/libraries/replication.inc.php
+++ b/libraries/replication.inc.php
@@ -298,21 +298,14 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
{
$src_db = $trg_db = $db;
- $src_connection = PMA_DBI_select_db($src_db, $src_link);
- $trg_connection = PMA_DBI_select_db($trg_db, $trg_link);
-
$src_tables = PMA_DBI_get_tables($src_db, $src_link);
- $source_tables_num = sizeof($src_tables);
$trg_tables = PMA_DBI_get_tables($trg_db, $trg_link);
- $target_tables_num = sizeof($trg_tables);
/**
* initializing arrays to save table names
*/
- $unmatched_num_src = 0;
$source_tables_uncommon = array();
- $unmatched_num_trg = 0;
$target_tables_uncommon = array();
$matching_tables = array();
$matching_tables_num = 0;
@@ -367,6 +360,7 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
$source_indexes = array();
$target_indexes = array();
$add_indexes_array = array();
+ $alter_indexes_array = array();
$remove_indexes_array = array();
$criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment');
@@ -378,17 +372,11 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
$add_indexes_array, $alter_indexes_array,$remove_indexes_array, $counter);
}
- $matching_table_data_diff = array();
- $matching_table_structure_diff = array();
- $uncommon_table_structure_diff = array();
- $uncommon_table_data_diff = array();
- $uncommon_tables = $source_tables_uncommon;
-
/**
* Generating Create Table query for all the non-matching tables present in Source but not in Target and populating tables.
*/
for ($q = 0; $q < sizeof($source_tables_uncommon); $q++) {
- if (isset($uncommon_tables[$q])) {
+ if (isset($source_tables_uncommon[$q])) {
PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $q, $uncommon_tables_fields, false);
}
if (isset($row_count[$q]) && $data) {
diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php
index fa2884d977..11c03ec5bb 100644
--- a/libraries/schema/Dia_Relation_Schema.class.php
+++ b/libraries/schema/Dia_Relation_Schema.class.php
@@ -5,7 +5,7 @@
* @package phpMyAdmin
*/
-include_once("Export_Relation_Schema.class.php");
+include_once "Export_Relation_Schema.class.php";
/**
* This Class inherits the XMLwriter class and
@@ -14,7 +14,6 @@ include_once("Export_Relation_Schema.class.php");
* @access public
* @see http://php.net/manual/en/book.xmlwriter.php
*/
-
class PMA_DIA extends XMLWriter
{
public $title;
@@ -44,7 +43,7 @@ class PMA_DIA extends XMLWriter
* Create the XML document
*/
- $this->startDocument('1.0','UTF-8');
+ $this->startDocument('1.0', 'UTF-8');
}
/**
@@ -55,27 +54,29 @@ class PMA_DIA extends XMLWriter
* to define the document, then finally a Layer starts which
* holds all the objects.
*
- * @param string paper The size of the paper/document
- * @param float topMargin top margin of the paper/document in cm
- * @param float bottomMargin bottom margin of the paper/document in cm
- * @param float leftMargin left margin of the paper/document in cm
- * @param float rightMargin right margin of the paper/document in cm
- * @param string portrait document will be portrait or landscape
+ * @param string $paper the size of the paper/document
+ * @param float $topMargin top margin of the paper/document in cm
+ * @param float $bottomMargin bottom margin of the paper/document in cm
+ * @param float $leftMargin left margin of the paper/document in cm
+ * @param float $rightMargin right margin of the paper/document in cm
+ * @param string $portrait document will be portrait or landscape
+ *
* @return void
+ *
* @access public
* @see XMLWriter::startElement(),XMLWriter::writeAttribute(),XMLWriter::writeRaw()
*/
function startDiaDoc($paper,$topMargin,$bottomMargin,$leftMargin,$rightMargin,$portrait)
{
- if($portrait == 'P'){
+ if ($portrait == 'P') {
$isPortrait='true';
- }else{
+ } else {
$isPortrait='false';
}
$this->startElement('dia:diagram');
$this->writeAttribute('xmlns:dia', 'http://www.lysator.liu.se/~alla/dia/');
$this->startElement('dia:diagramdata');
- $this->writeRaw (
+ $this->writeRaw(
'
@@ -85,22 +86,22 @@ class PMA_DIA extends XMLWriter
- #'.$paper.'#
+ #' . $paper . '#
-
+
-
+
-
+
-
+
-
+
@@ -160,18 +161,21 @@ class PMA_DIA extends XMLWriter
/**
* Output Dia Document for download
*
- * @param string fileName name of the dia document
+ * @param string $fileName name of the dia document
+ *
* @return void
* @access public
* @see XMLWriter::flush()
*/
function showOutput($fileName)
{
- if(ob_get_clean()){
+ if (ob_get_clean()) {
ob_end_clean();
}
$output = $this->flush();
- PMA_download_header($fileName . '.dia', 'application/x-dia-diagram', strlen($output));
+ PMA_download_header(
+ $fileName . '.dia', 'application/x-dia-diagram', strlen($output)
+ );
print $output;
}
}
@@ -200,14 +204,17 @@ class Table_Stats
/**
* The "Table_Stats" constructor
*
- * @param string table_name The table name
- * @param integer pageNumber The current page number (from the
- * $cfg['Servers'][$i]['table_coords'] table)
- * @param boolean showKeys Whether to display ONLY keys or not
+ * @param string $tableName The table name
+ * @param integer $pageNumber The current page number (from the
+ * $cfg['Servers'][$i]['table_coords'] table)
+ * @param boolean $showKeys Whether to display ONLY keys or not
+ *
* @return void
+ *
* @global object The current dia document
* @global array The relations settings
* @global string The current db name
+ *
* @see PMA_DIA
*/
function __construct($tableName, $pageNumber, $showKeys = false)
@@ -218,7 +225,10 @@ class Table_Stats
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
- $dia->dieSchema($pageNumber,"DIA",sprintf(__('The %s table doesn\'t exist!'), $tableName));
+ $dia->dieSchema(
+ $pageNumber, "DIA",
+ sprintf(__('The %s table doesn\'t exist!'), $tableName)
+ );
}
/*
* load fields
@@ -228,7 +238,10 @@ class Table_Stats
$indexes = PMA_Index::getFromTable($this->tableName, $db);
$all_columns = array();
foreach ($indexes as $index) {
- $all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
+ $all_columns = array_merge(
+ $all_columns,
+ array_flip(array_keys($index->getColumns()))
+ );
}
$this->fields = array_keys($all_columns);
} else {
@@ -238,13 +251,21 @@ class Table_Stats
}
$sql = 'SELECT x, y FROM '
- . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
+ . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
- if (!$result || !PMA_DBI_num_rows($result)) {
- $dia->dieSchema($pageNumber,"DIA",sprintf(__('Please configure the coordinates for table %s'), $tableName));
+ if (! $result || ! PMA_DBI_num_rows($result)) {
+ $dia->dieSchema(
+ $pageNumber,
+ "DIA",
+ sprintf(
+ __('Please configure the coordinates for table %s'),
+ $tableName
+ )
+ );
}
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x;
@@ -256,7 +277,11 @@ class Table_Stats
/*
* index
*/
- $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
+ $result = PMA_DBI_query(
+ 'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
+ null,
+ PMA_DBI_QUERY_STORE
+ );
if (PMA_DBI_num_rows($result) > 0) {
while ($row = PMA_DBI_fetch_assoc($result)) {
if ($row['Key_name'] == 'PRIMARY') {
@@ -280,13 +305,15 @@ class Table_Stats
* is used to generate the XML of Dia Document. Database Table
* Object and their attributes are involved in the combination
* of displaing Database - Table on Dia Document.
-
- * @param boolean changeColor Whether to show color for tables text or not
- if changeColor is true then an array of $listOfColors
- will be used to choose the random colors for tables text
- we can change/add more colors to this array
- @return void
- * @global object The current Dia document
+ *
+ * @param boolean $changeColor Whether to show color for tables text or not
+ * if changeColor is true then an array of $listOfColors will be used to choose
+ * the random colors for tables text we can change/add more colors to this array
+ *
+ * @return void
+ *
+ * @global object The current Dia document
+ *
* @access public
* @see PMA_DIA
*/
@@ -301,7 +328,7 @@ class Table_Stats
'00FF00'
);
shuffle($listOfColors);
- $this->tableColor = '#'.$listOfColors[0].'';
+ $this->tableColor = '#' . $listOfColors[0] . '';
} else {
$this->tableColor = '#000000';
}
@@ -311,19 +338,22 @@ class Table_Stats
$dia->startElement('dia:object');
$dia->writeAttribute('type', 'Database - Table');
$dia->writeAttribute('version', '0');
- $dia->writeAttribute('id', ''.$this->tableId.'');
+ $dia->writeAttribute('id', '' . $this->tableId . '');
$dia->writeRaw(
'
-
+
-
+
-
+
@@ -332,7 +362,7 @@ class Table_Stats
-
+
@@ -344,7 +374,7 @@ class Table_Stats
- #'.$this->tableName.'#
+ #' . $this->tableName . '#
##
@@ -379,44 +409,44 @@ class Table_Stats
'
- );
+ );
$dia->startElement('dia:attribute');
$dia->writeAttribute('name', 'attributes');
foreach ($this->fields as $field) {
- $dia->writeRaw(
- '
-
- #'.$field.'#
-
-
- ##
-
-
+ $dia->writeRaw(
+ '
+
+ #' . $field . '#
+
+
##
- '
- );
- unset($pm);
- $pm = 'false';
- if (in_array($field, $this->primary)) {
- $pm = 'true';
- }
- if ($field == $this->displayfield) {
- $pm = 'false';
- }
- $dia->writeRaw(
- '
-
-
-
-
-
-
-
-
- '
- );
+
+
+ ##
+ '
+ );
+ unset($pm);
+ $pm = 'false';
+ if (in_array($field, $this->primary)) {
+ $pm = 'true';
+ }
+ if ($field == $this->displayfield) {
+ $pm = 'false';
+ }
+ $dia->writeRaw(
+ '
+
+
+
+
+
+
+
+
+ '
+ );
}
$dia->endElement();
$dia->endElement();
@@ -452,11 +482,13 @@ class Relation_Stats
/**
* The "Relation_Stats" constructor
*
- * @param string master_table The master table name
- * @param string master_field The relation field in the master table
- * @param string foreign_table The foreign table name
- * @param string foreigh_field The relation field in the foreign table
+ * @param string $master_table The master table name
+ * @param string $master_field The relation field in the master table
+ * @param string $foreign_table The foreign table name
+ * @param string $foreign_field The relation field in the foreign table
+ *
* @return void
+ *
* @see Relation_Stats::_getXy
*/
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
@@ -480,9 +512,11 @@ class Relation_Stats
* then determines its left and right connection
* points.
*
- * @param string table The current table name
- * @param string column The relation column name
+ * @param string $table The current table name
+ * @param string $column The relation column name
+ *
* @return array Table right,left connection points and key position
+ *
* @access private
*/
private function _getXy($table, $column)
@@ -490,8 +524,7 @@ class Relation_Stats
$pos = array_search($column, $table->fields);
// left, right, position
$value = 12;
- if($pos != 0)
- {
+ if ($pos != 0) {
return array($pos + $value + $pos, $pos + $value + $pos + 1, $pos);
}
return array($pos + $value , $pos + $value + 1, $pos);
@@ -506,12 +539,14 @@ class Relation_Stats
* Database reference Object and their attributes are involved
* in the combination of displaing Database - reference on Dia Document.
*
- * @param boolean changeColor Whether to use one color per relation or not
- if changeColor is true then an array of $listOfColors
- will be used to choose the random colors for references
- lines. we can change/add more colors to this array
+ * @param boolean $changeColor Whether to use one color per relation or not
+ * if changeColor is true then an array of $listOfColors will be used to choose
+ * the random colors for references lines. we can change/add more colors to this
+ *
* @return void
- * @global object The current Dia document
+ *
+ * @global object The current Dia document
+ *
* @access public
* @see PMA_PDF
*/
@@ -525,8 +560,8 @@ class Relation_Stats
* points are same then return it false and don't draw that
* relation
*/
- if ( $this->srcConnPointsRight == $this->destConnPointsRight ){
- if ( $this->srcConnPointsLeft == $this->destConnPointsLeft ){
+ if ( $this->srcConnPointsRight == $this->destConnPointsRight) {
+ if ( $this->srcConnPointsLeft == $this->destConnPointsLeft) {
return false;
}
}
@@ -538,13 +573,14 @@ class Relation_Stats
'00FF00'
);
shuffle($listOfColors);
- $this->referenceColor = '#'.$listOfColors[0].'';
+ $this->referenceColor = '#' . $listOfColors[0] . '';
} else {
$this->referenceColor = '#000000';
}
$dia->writeRaw(
- '
+ '
@@ -576,7 +612,7 @@ class Relation_Stats
-
+
@@ -610,11 +646,15 @@ class Relation_Stats
-
-
+
+
'
- );
+ );
}
}
@@ -667,11 +707,16 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
$this->setExportType($_POST['export_type']);
$dia = new PMA_DIA();
- $dia->startDiaDoc($this->paper,$this->_topMargin,$this->_bottomMargin,$this->_leftMargin,$this->_rightMargin,$this->orientation);
- $alltables = $this->getAllTables($db,$this->pageNumber);
+ $dia->startDiaDoc(
+ $this->paper, $this->_topMargin, $this->_bottomMargin,
+ $this->_leftMargin, $this->_rightMargin, $this->orientation
+ );
+ $alltables = $this->getAllTables($db, $this->pageNumber);
foreach ($alltables as $table) {
if (! isset($this->tables[$table])) {
- $this->tables[$table] = new Table_Stats($table, $this->pageNumber, $this->showKeys);
+ $this->tables[$table] = new Table_Stats(
+ $table, $this->pageNumber, $this->showKeys
+ );
}
}
@@ -682,12 +727,15 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
$seen_a_relation = true;
foreach ($exist_rel as $master_field => $rel) {
/* put the foreign table on the schema only if selected
- * by the user
- * (do not use array_search() because we would have to
- * to do a === false and this is not PHP3 compatible)
- */
+ * by the user
+ * (do not use array_search() because we would have to
+ * to do a === false and this is not PHP3 compatible)
+ */
if (in_array($rel['foreign_table'], $alltables)) {
- $this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field'],$this->showKeys);
+ $this->_addRelation(
+ $one_table, $master_field, $rel['foreign_table'],
+ $rel['foreign_field'], $this->showKeys
+ );
}
}
}
@@ -698,30 +746,40 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
$this->_drawRelations($this->showColor);
}
$dia->endDiaDoc();
- $dia->showOutput($db.'-'.$this->pageNumber);
+ $dia->showOutput($db . '-' . $this->pageNumber);
exit();
}
/**
* Defines relation objects
*
- * @param string masterTable The master table name
- * @param string masterField The relation field in the master table
- * @param string foreignTable The foreign table name
- * @param string foreignField The relation field in the foreign table
+ * @param string $masterTable The master table name
+ * @param string $masterField The relation field in the master table
+ * @param string $foreignTable The foreign table name
+ * @param string $foreignField The relation field in the foreign table
+ * @param bool $showKeys Whether to display ONLY keys or not
+ *
* @return void
+ *
* @access private
* @see Table_Stats::__construct(),Relation_Stats::__construct()
*/
private function _addRelation($masterTable, $masterField, $foreignTable, $foreignField, $showKeys)
{
if (! isset($this->tables[$masterTable])) {
- $this->tables[$masterTable] = new Table_Stats($masterTable, $this->pageNumber, $showKeys);
+ $this->tables[$masterTable] = new Table_Stats(
+ $masterTable, $this->pageNumber, $showKeys
+ );
}
if (! isset($this->tables[$foreignTable])) {
- $this->tables[$foreignTable] = new Table_Stats($foreignTable, $this->pageNumber, $showKeys);
+ $this->tables[$foreignTable] = new Table_Stats(
+ $foreignTable, $this->pageNumber, $showKeys
+ );
}
- $this->_relations[] = new Relation_Stats($this->tables[$masterTable], $masterField, $this->tables[$foreignTable], $foreignField);
+ $this->_relations[] = new Relation_Stats(
+ $this->tables[$masterTable], $masterField,
+ $this->tables[$foreignTable], $foreignField
+ );
}
/**
@@ -731,8 +789,10 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
* foreign table's forein field using Dia object
* type Database - Reference
*
- * @param boolean changeColor Whether to use one color per relation or not
+ * @param boolean $changeColor Whether to use one color per relation or not
+ *
* @return void
+ *
* @access private
* @see Relation_Stats::relationDraw()
*/
@@ -749,8 +809,10 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
* Tables are generated using Dia object type Database - Table
* primary fields are underlined and bold in tables
*
- * @param boolean changeColor Whether to show color for tables text or not
+ * @param boolean $changeColor Whether to show color for tables text or not
+ *
* @return void
+ *
* @access private
* @see Table_Stats::tableDraw()
*/
diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php
index 367b8c28be..be70889ea4 100644
--- a/libraries/schema/Eps_Relation_Schema.class.php
+++ b/libraries/schema/Eps_Relation_Schema.class.php
@@ -5,7 +5,7 @@
* @package phpMyAdmin
*/
-include_once("Export_Relation_Schema.class.php");
+include_once "Export_Relation_Schema.class.php";
/**
* This Class is EPS Library and
@@ -42,8 +42,10 @@ class PMA_EPS
/**
* Set document title
*
- * @param string value sets the title text
+ * @param string $value sets the title text
+ *
* @return void
+ *
* @access public
*/
function setTitle($value)
@@ -54,8 +56,10 @@ class PMA_EPS
/**
* Set document author
*
- * @param string value sets the author
+ * @param string $value sets the author
+ *
* @return void
+ *
* @access public
*/
function setAuthor($value)
@@ -66,8 +70,10 @@ class PMA_EPS
/**
* Set document creation date
*
- * @param string value sets the date
+ * @param string $value sets the date
+ *
* @return void
+ *
* @access public
*/
function setDate($value)
@@ -78,17 +84,19 @@ class PMA_EPS
/**
* Set document orientation
*
- * @param string value sets the author
+ * @param string $value sets the author
+ *
* @return void
+ *
* @access public
*/
function setOrientation($value)
{
$this->stringCommands .= "%%PageOrder: Ascend \n";
- if($value == "L"){
+ if ($value == "L") {
$value = "Landscape";
$this->stringCommands .= '%%Orientation: ' . $value . "\n";
- }else{
+ } else {
$value = "Portrait";
$this->stringCommands .= '%%Orientation: ' . $value . "\n";
}
@@ -102,17 +110,19 @@ class PMA_EPS
*
* font can be set whenever needed in EPS
*
- * @param string value sets the font name e.g Arial
- * @param integer value sets the size of the font e.g 10
+ * @param string $value sets the font name e.g Arial
+ * @param integer $value sets the size of the font e.g 10
+ *
* @return void
+ *
* @access public
*/
function setFont($value,$size)
{
$this->font = $value;
$this->fontSize = $size;
- $this->stringCommands .= "/".$value." findfont % Get the basic font\n";
- $this->stringCommands .= "".$size." scalefont % Scale the font to $size points\n";
+ $this->stringCommands .= "/" . $value . " findfont % Get the basic font\n";
+ $this->stringCommands .= "" . $size . " scalefont % Scale the font to $size points\n";
$this->stringCommands .= "setfont % Make it the current font\n";
}
@@ -144,19 +154,21 @@ class PMA_EPS
* drawing the lines from x,y source to x,y destination and set the
* width of the line. lines helps in showing relationships of tables
*
- * @param integer x_from The x_from attribute defines the start
- left position of the element
- * @param integer y_from The y_from attribute defines the start
- right position of the element
- * @param integer x_to The x_to attribute defines the end
- left position of the element
- * @param integer y_to The y_to attribute defines the end
- right position of the element
- * @param integer lineWidth sets the width of the line e.g 2
+ * @param integer $x_from The x_from attribute defines the start
+ * left position of the element
+ * @param integer $y_from The y_from attribute defines the start
+ * right position of the element
+ * @param integer $x_to The x_to attribute defines the end
+ * left position of the element
+ * @param integer $y_to The y_to attribute defines the end
+ * right position of the element
+ * @param integer $lineWidth Sets the width of the line e.g 2
+ *
* @return void
+ *
* @access public
*/
- function line($x_from=0, $y_from=0, $x_to=0, $y_to=0, $lineWidth=0)
+ function line($x_from = 0, $y_from = 0, $x_to = 0, $y_to = 0, $lineWidth = 0)
{
$this->stringCommands .= $lineWidth . " setlinewidth \n";
$this->stringCommands .= $x_from . ' ' . $y_from . " moveto \n";
@@ -170,28 +182,30 @@ class PMA_EPS
* drawing the rectangle from x,y source to x,y destination and set the
* width of the line. rectangles drawn around the text shown of fields
*
- * @param integer x_from The x_from attribute defines the start
- left position of the element
- * @param integer y_from The y_from attribute defines the start
- right position of the element
- * @param integer x_to The x_to attribute defines the end
- left position of the element
- * @param integer y_to The y_to attribute defines the end
- right position of the element
- * @param integer lineWidth sets the width of the line e.g 2
+ * @param integer $x_from The x_from attribute defines the start
+ left position of the element
+ * @param integer $y_from The y_from attribute defines the start
+ right position of the element
+ * @param integer $x_to The x_to attribute defines the end
+ left position of the element
+ * @param integer $y_to The y_to attribute defines the end
+ right position of the element
+ * @param integer $lineWidth Sets the width of the line e.g 2
+ *
* @return void
+ *
* @access public
*/
function rect($x_from, $y_from, $x_to, $y_to, $lineWidth)
{
- $this->stringCommands .= $lineWidth . " setlinewidth \n";
- $this->stringCommands .= "newpath \n";
- $this->stringCommands .= $x_from . " " . $y_from . " moveto \n";
- $this->stringCommands .= "0 " . $y_to . " rlineto \n";
- $this->stringCommands .= $x_to . " 0 rlineto \n";
- $this->stringCommands .= "0 -" . $y_to . " rlineto \n";
- $this->stringCommands .= "closepath \n";
- $this->stringCommands .= "stroke \n";
+ $this->stringCommands .= $lineWidth . " setlinewidth \n";
+ $this->stringCommands .= "newpath \n";
+ $this->stringCommands .= $x_from . " " . $y_from . " moveto \n";
+ $this->stringCommands .= "0 " . $y_to . " rlineto \n";
+ $this->stringCommands .= $x_to . " 0 rlineto \n";
+ $this->stringCommands .= "0 -" . $y_to . " rlineto \n";
+ $this->stringCommands .= "closepath \n";
+ $this->stringCommands .= "stroke \n";
}
/**
@@ -201,11 +215,11 @@ class PMA_EPS
* them as x and y coordinates to which to move. The coordinates
* specified become the current point.
*
- * @param integer x The x attribute defines the
- left position of the element
- * @param integer y The y attribute defines the
- right position of the element
+ * @param integer $x The x attribute defines the left position of the element
+ * @param integer $y The y attribute defines the right position of the element
+ *
* @return void
+ *
* @access public
*/
function moveTo($x, $y)
@@ -216,31 +230,33 @@ class PMA_EPS
/**
* Output/Display the text
*
- * @param string text The string to be displayed
+ * @param string $text The string to be displayed
+ *
* @return void
+ *
* @access public
*/
- function show($text)
- {
- $this->stringCommands .= '(' . $text . ") show \n";
- }
+ function show($text)
+ {
+ $this->stringCommands .= '(' . $text . ") show \n";
+ }
/**
* Output the text at specified co-ordinates
*
- * @param string text The string to be displayed
- * @param integer x The x attribute defines the
- left position of the element
- * @param integer y The y attribute defines the
- right position of the element
+ * @param string $text String to be displayed
+ * @param integer $x X attribute defines the left position of the element
+ * @param integer $y Y attribute defines the right position of the element
+ *
* @return void
+ *
* @access public
*/
- function showXY($text, $x, $y)
- {
- $this->moveTo($x, $y);
- $this->show($text);
- }
+ function showXY($text, $x, $y)
+ {
+ $this->moveTo($x, $y);
+ $this->show($text);
+ }
/**
* get width of string/text
@@ -252,10 +268,12 @@ class PMA_EPS
* This is a bit hardcore method. I didn't found any other better than this.
* if someone found better than this. would love to hear that method
*
- * @param string text string that width will be calculated
- * @param integer font name of the font like Arial,sans-serif etc
- * @param integer fontSize size of font
+ * @param string $text string that width will be calculated
+ * @param integer $font name of the font like Arial,sans-serif etc
+ * @param integer $fontSize size of font
+ *
* @return integer width of the text
+ *
* @access public
*/
function getStringWidth($text,$font,$fontSize)
@@ -264,22 +282,22 @@ class PMA_EPS
* Start by counting the width, giving each character a modifying value
*/
$count = 0;
- $count = $count + ((strlen($text) - strlen(str_replace(array("i","j","l"),"",$text)))*0.23);//ijl
- $count = $count + ((strlen($text) - strlen(str_replace(array("f"),"",$text)))*0.27);//f
- $count = $count + ((strlen($text) - strlen(str_replace(array("t","I"),"",$text)))*0.28);//tI
- $count = $count + ((strlen($text) - strlen(str_replace(array("r"),"",$text)))*0.34);//r
- $count = $count + ((strlen($text) - strlen(str_replace(array("1"),"",$text)))*0.49);//1
- $count = $count + ((strlen($text) - strlen(str_replace(array("c","k","s","v","x","y","z","J"),"",$text)))*0.5);//cksvxyzJ
- $count = $count + ((strlen($text) - strlen(str_replace(array("a","b","d","e","g","h","n","o","p","q","u","L","0","2","3","4","5","6","7","8","9"),"",$text)))*0.56);//abdeghnopquL023456789
- $count = $count + ((strlen($text) - strlen(str_replace(array("F","T","Z"),"",$text)))*0.61);//FTZ
- $count = $count + ((strlen($text) - strlen(str_replace(array("A","B","E","K","P","S","V","X","Y"),"",$text)))*0.67);//ABEKPSVXY
- $count = $count + ((strlen($text) - strlen(str_replace(array("w","C","D","H","N","R","U"),"",$text)))*0.73);//wCDHNRU
- $count = $count + ((strlen($text) - strlen(str_replace(array("G","O","Q"),"",$text)))*0.78);//GOQ
- $count = $count + ((strlen($text) - strlen(str_replace(array("m","M"),"",$text)))*0.84);//mM
- $count = $count + ((strlen($text) - strlen(str_replace("W","",$text)))*.95);//W
- $count = $count + ((strlen($text) - strlen(str_replace(" ","",$text)))*.28);//" "
- $text = str_replace(" ","",$text);//remove the " "'s
- $count = $count + (strlen(preg_replace("/[a-z0-9]/i","",$text))*0.3); //all other chrs
+ $count = $count + ((strlen($text) - strlen(str_replace(array("i", "j", "l"), "", $text))) * 0.23);//ijl
+ $count = $count + ((strlen($text) - strlen(str_replace(array("f"), "", $text))) * 0.27);//f
+ $count = $count + ((strlen($text) - strlen(str_replace(array("t", "I"), "", $text))) * 0.28);//tI
+ $count = $count + ((strlen($text) - strlen(str_replace(array("r"), "", $text))) * 0.34);//r
+ $count = $count + ((strlen($text) - strlen(str_replace(array("1"), "", $text))) * 0.49);//1
+ $count = $count + ((strlen($text) - strlen(str_replace(array("c", "k", "s", "v", "x", "y", "z", "J"), "", $text))) * 0.5);//cksvxyzJ
+ $count = $count + ((strlen($text) - strlen(str_replace(array("a", "b", "d", "e", "g", "h", "n", "o", "p", "q", "u", "L", "0", "2", "3", "4", "5", "6", "7", "8", "9"), "", $text))) * 0.56);//abdeghnopquL023456789
+ $count = $count + ((strlen($text) - strlen(str_replace(array("F", "T", "Z"), "", $text))) * 0.61);//FTZ
+ $count = $count + ((strlen($text) - strlen(str_replace(array("A", "B", "E", "K", "P", "S", "V", "X", "Y"), "", $text))) * 0.67);//ABEKPSVXY
+ $count = $count + ((strlen($text) - strlen(str_replace(array("w", "C", "D", "H", "N", "R", "U"), "", $text))) * 0.73);//wCDHNRU
+ $count = $count + ((strlen($text) - strlen(str_replace(array("G", "O", "Q"), "", $text))) * 0.78);//GOQ
+ $count = $count + ((strlen($text) - strlen(str_replace(array("m", "M"), "", $text))) * 0.84);//mM
+ $count = $count + ((strlen($text) - strlen(str_replace("W", "", $text))) * .95);//W
+ $count = $count + ((strlen($text) - strlen(str_replace(" ", "", $text))) * .28);//" "
+ $text = str_replace(" ", "", $text);//remove the " "'s
+ $count = $count + (strlen(preg_replace("/[a-z0-9]/i", "", $text)) * 0.3); //all other chrs
$modifier = 1;
$font = strtolower($font);
@@ -289,7 +307,7 @@ class PMA_EPS
*/
case 'arial':
case 'sans-serif':
- break;
+ break;
/*
* .92 modifer for time, serif, brushscriptstd, and californian fb
*/
@@ -298,13 +316,13 @@ class PMA_EPS
case 'brushscriptstd':
case 'californian fb':
$modifier = .92;
- break;
+ break;
/*
* 1.23 modifier for broadway
*/
case 'broadway':
$modifier = 1.23;
- break;
+ break;
}
$textWidth = $count*$fontSize;
return ceil($textWidth*$modifier);
@@ -324,8 +342,10 @@ class PMA_EPS
/**
* Output EPS Document for download
*
- * @param string fileName name of the eps document
+ * @param string $fileName name of the eps document
+ *
* @return void
+ *
* @access public
*/
function showOutput($fileName)
@@ -368,30 +388,37 @@ class Table_Stats
/**
* The "Table_Stats" constructor
*
- * @param string tableName The table name
- * @param string font The font name
- * @param integer fontSize The font size
- * @param integer same_wide_width The max width among tables
- * @param boolean showKeys Whether to display keys or not
- * @param boolean showInfo Whether to display table position or not
+ * @param string $tableName The table name
+ * @param string $font The font name
+ * @param integer $fontSize The font size
+ * @param integer $pageNumber Page number
+ * @param integer &$same_wide_width The max width among tables
+ * @param boolean $showKeys Whether to display keys or not
+ * @param boolean $showInfo Whether to display table position or not
+ *
* @global object The current eps document
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @global array The relations settings
* @global string The current db name
+ *
* @access private
* @see PMA_EPS, Table_Stats::Table_Stats_setWidth,
- Table_Stats::Table_Stats_setHeight
+ * Table_Stats::Table_Stats_setHeight
*/
- function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false)
+ function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
+ $showKeys = false, $showInfo = false)
{
global $eps, $cfgRelation, $db;
$this->_tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
- if (!$result || !PMA_DBI_num_rows($result)) {
- $eps->dieSchema($pageNumber,"EPS",sprintf(__('The %s table doesn\'t exist!'), $tableName));
+ if (! $result || ! PMA_DBI_num_rows($result)) {
+ $eps->dieSchema(
+ $pageNumber, "EPS",
+ sprintf(__('The %s table doesn\'t exist!'), $tableName)
+ );
}
/*
@@ -402,7 +429,10 @@ class Table_Stats
$indexes = PMA_Index::getFromTable($this->_tableName, $db);
$all_columns = array();
foreach ($indexes as $index) {
- $all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
+ $all_columns = array_merge(
+ $all_columns,
+ array_flip(array_keys($index->getColumns()))
+ );
}
$this->fields = array_keys($all_columns);
} else {
@@ -418,21 +448,28 @@ class Table_Stats
// setWidth must me after setHeight, because title
// can include table height which changes table width
- $this->_setWidthTable($font,$fontSize);
+ $this->_setWidthTable($font, $fontSize);
if ($same_wide_width < $this->width) {
$same_wide_width = $this->width;
}
// x and y
$sql = 'SELECT x, y FROM '
- . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
- . ' AND pdf_page_number = ' . $pageNumber;
+ . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['table_coords'])
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
+ . ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
- if (!$result || !PMA_DBI_num_rows($result)) {
- $eps->dieSchema($pageNumber,"EPS",sprintf(__('Please configure the coordinates for table %s'), $tableName));
+ if (! $result || ! PMA_DBI_num_rows($result)) {
+ $eps->dieSchema(
+ $pageNumber, "EPS",
+ sprintf(
+ __('Please configure the coordinates for table %s'),
+ $tableName
+ )
+ );
}
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x;
@@ -440,7 +477,10 @@ class Table_Stats
// displayfield
$this->displayfield = PMA_getDisplayField($db, $tableName);
// index
- $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
+ $result = PMA_DBI_query(
+ 'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
+ null, PMA_DBI_QUERY_STORE
+ );
if (PMA_DBI_num_rows($result) > 0) {
while ($row = PMA_DBI_fetch_assoc($result)) {
if ($row['Key_name'] == 'PRIMARY') {
@@ -459,16 +499,21 @@ class Table_Stats
*/
private function _getTitle()
{
- return ($this->_showInfo ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) : '') . ' ' . $this->_tableName;
+ return ($this->_showInfo
+ ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell)
+ : '') . ' ' . $this->_tableName;
}
/**
* Sets the width of the table
*
- * @param string font The font name
- * @param integer fontSize The font size
+ * @param string $font The font name
+ * @param integer $fontSize The font size
+ *
* @global object The current eps document
+ *
* @return void
+ *
* @access private
* @see PMA_EPS
*/
@@ -477,14 +522,17 @@ class Table_Stats
global $eps;
foreach ($this->fields as $field) {
- $this->width = max($this->width, $eps->getStringWidth($field,$font,$fontSize));
+ $this->width = max(
+ $this->width,
+ $eps->getStringWidth($field, $font, $fontSize)
+ );
}
- $this->width += $eps->getStringWidth(' ',$font,$fontSize);
+ $this->width += $eps->getStringWidth(' ', $font, $fontSize);
/*
* it is unknown what value must be added, because
* table title is affected by the tabe width value
*/
- while ($this->width < $eps->getStringWidth($this->_getTitle(),$font,$fontSize)) {
+ while ($this->width < $eps->getStringWidth($this->_getTitle(), $font, $fontSize)) {
$this->width += 7;
}
}
@@ -492,7 +540,8 @@ class Table_Stats
/**
* Sets the height of the table
*
- * @param integer fontSize The font size
+ * @param integer $fontSize The font size
+ *
* @return void
* @access private
*/
@@ -505,9 +554,12 @@ class Table_Stats
/**
* Draw the table
*
- * @param boolean showColor Whether to display color
+ * @param boolean $showColor Whether to display color
+ *
* @global object The current eps document
+ *
* @return void
+ *
* @access public
* @see PMA_EPS,PMA_EPS::line,PMA_EPS::rect
*/
@@ -515,25 +567,24 @@ class Table_Stats
{
global $eps;
//echo $this->_tableName.' ';
- $eps->rect($this->x,$this->y + 12,
- $this->width,$this->heightCell,
- 1
- );
- $eps->showXY($this->_getTitle(),$this->x + 5,$this->y + 14);
+ $eps->rect($this->x, $this->y + 12, $this->width, $this->heightCell, 1);
+ $eps->showXY($this->_getTitle(), $this->x + 5, $this->y + 14);
foreach ($this->fields as $field) {
- $this->currentCell += $this->heightCell;
- $showColor = 'none';
- if ($showColor) {
- if (in_array($field, $this->primary)) {
- $showColor = '#0c0';
- }
- if ($field == $this->displayfield) {
- $showColor = 'none';
- }
+ $this->currentCell += $this->heightCell;
+ $showColor = 'none';
+ if ($showColor) {
+ if (in_array($field, $this->primary)) {
+ $showColor = '#0c0';
}
- $eps->rect($this->x,$this->y + 12 + $this->currentCell,
- $this->width, $this->heightCell,1);
- $eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
+ if ($field == $this->displayfield) {
+ $showColor = 'none';
+ }
+ }
+ $eps->rect(
+ $this->x, $this->y + 12 + $this->currentCell,
+ $this->width, $this->heightCell, 1
+ );
+ $eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
}
}
}
@@ -563,10 +614,11 @@ class Relation_Stats
/**
* The "Relation_Stats" constructor
*
- * @param string master_table The master table name
- * @param string master_field The relation field in the master table
- * @param string foreign_table The foreign table name
- * @param string foreigh_field The relation field in the foreign table
+ * @param string $master_table The master table name
+ * @param string $master_field The relation field in the master table
+ * @param string $foreign_table The foreign table name
+ * @param string $foreign_field The relation field in the foreign table
+ *
* @see Relation_Stats::_getXy
*/
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
@@ -617,26 +669,36 @@ class Relation_Stats
/**
* Gets arrows coordinates
*
- * @param string table The current table name
- * @param string column The relation column name
+ * @param string $table The current table name
+ * @param string $column The relation column name
+ *
* @return array Arrows coordinates
+ *
* @access private
*/
private function _getXy($table, $column)
{
$pos = array_search($column, $table->fields);
// x_left, x_right, y
- return array($table->x, $table->x + $table->width, $table->y + ($pos + 1.5) * $table->heightCell);
+ return array(
+ $table->x,
+ $table->x + $table->width,
+ $table->y + ($pos + 1.5) * $table->heightCell
+ );
}
/**
* draws relation links and arrows
* shows foreign key relations
*
- * @param boolean changeColor Whether to use one color per relation or not
- * @global object The current EPS document
+ * @param boolean $changeColor Whether to use one color per relation or not
+ *
+ * @global object The current EPS document
+ *
* @access public
* @see PMA_EPS
+ *
+ * @return void
*/
public function relationDraw($changeColor)
{
@@ -658,40 +720,58 @@ class Relation_Stats
$color = 'black';
}
// draw a line like -- to foreign field
- $eps->line($this->xSrc,$this->ySrc,
- $this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
+ $eps->line(
+ $this->xSrc,
+ $this->ySrc,
+ $this->xSrc + $this->srcDir * $this->wTick,
+ $this->ySrc,
1
- );
+ );
// draw a line like -- to master field
- $eps->line($this->xDest + $this->destDir * $this->wTick, $this->yDest,
- $this->xDest, $this->yDest,
+ $eps->line(
+ $this->xDest + $this->destDir * $this->wTick,
+ $this->yDest,
+ $this->xDest,
+ $this->yDest,
1
- );
+ );
// draw a line that connects to master field line and foreign field line
- $eps->line($this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
- $this->xDest + $this->destDir * $this->wTick, $this->yDest,
+ $eps->line(
+ $this->xSrc + $this->srcDir * $this->wTick,
+ $this->ySrc,
+ $this->xDest + $this->destDir * $this->wTick,
+ $this->yDest,
1
- );
+ );
$root2 = 2 * sqrt(2);
- $eps->line($this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
- $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick ,
- $this->ySrc + $this->wTick / $root2 ,
+ $eps->line(
+ $this->xSrc + $this->srcDir * $this->wTick * 0.75,
+ $this->ySrc,
+ $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
+ $this->ySrc + $this->wTick / $root2,
1
- );
- $eps->line($this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
- $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick ,
- $this->ySrc - $this->wTick / $root2 ,
+ );
+ $eps->line(
+ $this->xSrc + $this->srcDir * $this->wTick * 0.75,
+ $this->ySrc,
+ $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
+ $this->ySrc - $this->wTick / $root2,
1
- );
- $eps->line($this->xDest + $this->destDir * $this->wTick / 2 , $this->yDest ,
+ );
+ $eps->line(
+ $this->xDest + $this->destDir * $this->wTick / 2,
+ $this->yDest,
$this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
- $this->yDest + $this->wTick / $root2 ,
- 1);
- $eps->line($this->xDest + $this->destDir * $this->wTick / 2 ,
- $this->yDest , $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick ,
- $this->yDest - $this->wTick / $root2 ,
+ $this->yDest + $this->wTick / $root2,
1
- );
+ );
+ $eps->line(
+ $this->xDest + $this->destDir * $this->wTick / 2,
+ $this->yDest,
+ $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
+ $this->yDest - $this->wTick / $root2,
+ 1
+ );
}
}
/*
@@ -738,19 +818,26 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
$this->setExportType($_POST['export_type']);
$eps = new PMA_EPS();
- $eps->setTitle(sprintf(__('Schema of the %s database - Page %s'), $db, $this->pageNumber));
+ $eps->setTitle(
+ sprintf(
+ __('Schema of the %s database - Page %s'),
+ $db,
+ $this->pageNumber
+ )
+ );
$eps->setAuthor('phpMyAdmin ' . PMA_VERSION);
$eps->setDate(date("j F Y, g:i a"));
$eps->setOrientation($this->orientation);
- $eps->setFont('Verdana','10');
+ $eps->setFont('Verdana', '10');
-
-
- $alltables = $this->getAllTables($db,$this->pageNumber);
+ $alltables = $this->getAllTables($db, $this->pageNumber);
foreach ($alltables AS $table) {
if (! isset($this->tables[$table])) {
- $this->tables[$table] = new Table_Stats($table,$eps->getFont(),$eps->getFontSize(), $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension);
+ $this->tables[$table] = new Table_Stats(
+ $table, $eps->getFont(), $eps->getFontSize(), $this->pageNumber,
+ $this->_tablewidth, $this->showKeys, $this->tableDimension
+ );
}
if ($this->sameWide) {
@@ -770,7 +857,11 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
* to do a === false and this is not PHP3 compatible)
*/
if (in_array($rel['foreign_table'], $alltables)) {
- $this->_addRelation($one_table,$eps->getFont(),$eps->getFontSize(), $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->tableDimension);
+ $this->_addRelation(
+ $one_table, $eps->getFont(), $eps->getFontSize(),
+ $master_field, $rel['foreign_table'],
+ $rel['foreign_field'], $this->tableDimension
+ );
}
}
}
@@ -788,33 +879,48 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Defines relation objects
*
- * @param string masterTable The master table name
- * @param string masterField The relation field in the master table
- * @param string foreignTable The foreign table name
- * @param string foreignField The relation field in the foreign table
- * @param boolean showInfo Whether to display table position or not
+ * @param string $masterTable The master table name
+ * @param string $font The font
+ * @param int $fontSize The font size
+ * @param string $masterField The relation field in the master table
+ * @param string $foreignTable The foreign table name
+ * @param string $foreignField The relation field in the foreign table
+ * @param boolean $showInfo Whether to display table position or not
+ *
* @return void
+ *
* @access private
* @see _setMinMax,Table_Stats::__construct(),Relation_Stats::__construct()
*/
- private function _addRelation($masterTable,$font,$fontSize, $masterField, $foreignTable, $foreignField, $showInfo)
+ private function _addRelation($masterTable, $font, $fontSize, $masterField,
+ $foreignTable, $foreignField, $showInfo)
{
if (! isset($this->tables[$masterTable])) {
- $this->tables[$masterTable] = new Table_Stats($masterTable, $font, $fontSize, $this->pageNumber, $this->_tablewidth, false, $showInfo);
+ $this->tables[$masterTable] = new Table_Stats(
+ $masterTable, $font, $fontSize, $this->pageNumber,
+ $this->_tablewidth, false, $showInfo
+ );
}
if (! isset($this->tables[$foreignTable])) {
- $this->tables[$foreignTable] = new Table_Stats($foreignTable,$font,$fontSize,$this->pageNumber, $this->_tablewidth, false, $showInfo);
+ $this->tables[$foreignTable] = new Table_Stats(
+ $foreignTable, $font, $fontSize, $this->pageNumber,
+ $this->_tablewidth, false, $showInfo
+ );
}
- $this->_relations[] = new Relation_Stats($this->tables[$masterTable], $masterField, $this->tables[$foreignTable], $foreignField);
+ $this->_relations[] = new Relation_Stats(
+ $this->tables[$masterTable], $masterField,
+ $this->tables[$foreignTable], $foreignField
+ );
}
/**
- * Draws relation arrows and lines
- * connects master table's master field to
+ * Draws relation arrows and lines connects master table's master field to
* foreign table's forein field
*
- * @param boolean changeColor Whether to use one color per relation or not
+ * @param boolean $changeColor Whether to use one color per relation or not
+ *
* @return void
+ *
* @access private
* @see Relation_Stats::relationDraw()
*/
@@ -828,8 +934,10 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Draws tables
*
- * @param boolean changeColor Whether to show color for primary fields or not
+ * @param boolean $changeColor Whether to show color for primary fields or not
+ *
* @return void
+ *
* @access private
* @see Table_Stats::Table_Stats_tableDraw()
*/
diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php
index e74c14d126..ed96efd053 100644
--- a/libraries/schema/Pdf_Relation_Schema.class.php
+++ b/libraries/schema/Pdf_Relation_Schema.class.php
@@ -923,8 +923,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$pdf->SetX(10);
$pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links['doc'][$table]['-']);
// $pdf->Ln(1);
- $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
- while ($row = PMA_DBI_fetch_assoc($result)) {
+ $fields = PMA_DBI_get_columns($GLOBALS['db'], $table);
+ foreach($fields as $row) {
$pdf->SetX(20);
$field_name = $row['Field'];
$pdf->PMA_links['doc'][$table][$field_name] = $pdf->AddLink();
diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php
index 95d60e127b..41a2b9e6fe 100644
--- a/libraries/schema/User_Schema.class.php
+++ b/libraries/schema/User_Schema.class.php
@@ -38,7 +38,7 @@ class PMA_User_Schema
public function processUserChoice()
{
- global $action_choose,$db,$cfgRelation,$cfg;
+ global $action_choose, $db, $cfgRelation;
if (isset($this->action)) {
switch ($this->action) {
@@ -207,7 +207,7 @@ class PMA_User_Schema
*/
public function showTableDashBoard()
{
- global $db,$cfgRelation,$table,$cfg,$with_field_names;
+ global $db, $cfgRelation, $table, $with_field_names;
/*
* We will need an array of all tables in this db
*/
@@ -479,7 +479,7 @@ class PMA_User_Schema
*/
private function _displayScratchboardTables($array_sh_page)
{
- global $with_field_names,$cfg,$db;
+ global $with_field_names, $db;
?>