Merge remote-tracking branch 'origin/master' into aris

This commit is contained in:
Aris Feryanto 2011-08-23 02:26:57 +08:00
commit 2b4acfa534
577 changed files with 51449 additions and 48729 deletions

View File

@ -57,6 +57,7 @@ phpMyAdmin - ChangeLog
- [core] Remove library PHPExcel, due to license issues
- [export] Remove native Excel export modules (xls and xlsx formats)
- [import] Remove native Excel import modules (xls and xlsx formats)
- bug #3392920 [edit] BLOB emptied after editing another column
3.4.4.0 (not yet released)
- bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes

View File

@ -4409,6 +4409,44 @@ chmod o+rwx tmp
</li>
</ul>
<h4 id="faq6_31">
<a href="#faq6_31">6.31 How do I create a relation in designer?</a></h4>
<p>To select relation, click :</p>
<img src="pmd/images/help_relation.png"></p>
<p>The display column is shown in pink. To set/unset a column as the display column, click the "Choose column to display" icon, then click on the appropriate column name.</p>
<h4 id="faq6_32">
<a href="#faq6_32">6.32 How can I use the zoom search feature?</a></h4>
<p> The Zoom search feature is an alternative to table search feature. It allows you to explore
a table by representing its data in a scatter plot. You can locate this feature by selecting
a table and clicking the 'Search' tab. One of the sub-tabs in the 'Table Search' page is
'Zoom Search'. <br/><br/>
Consider the table REL_persons in <a href="#faq6_6"><abbr title="Frequently Asked Questions">
FAQ</abbr> 6.6</a> for an example. To use zoom search, two columns need to be selected,
for example, id and town_code. The id values will be represented on one axis and town_code
values on the other axis. Each row will be represented as a point in a scatter plot based
on its id and town_code. You can include two additional search criteria apart from the two
fields to display.<br/><br/>
You can choose which field should be displayed as label for each point. If a display
column has been set for the table (see <a href="#faqdisplay"><abbr title="Frequently Asked
Questions">FAQ</abbr> 6.7</a>), it is taken as the label unless you specify otherwise.
You can also select the maximum number of rows you want to be displayed in the plot by
specifing it in the 'Max rows to plot' field. Once you have decided over your criteria,
click 'Go' to display the plot.<br/><br/>
After the plot is generated, you can use the mousewheel to zoom in and out of the plot.
In addition, panning feature is enabled to navigate through the plot. You can zoom-in to
a certail level of detail and use panning to locate your area of interest. Clicking on a
point opens a dialogue box, displaying field values of the data row represented by the point.
You can edit the values if required and click on submit to issue an update query. Basic
instructions on how to use can be viewed by clicking the 'How to use?' link located just above
the plot.</p>
<h3 id="faqproject">phpMyAdmin project</h3>
<h4 id="faq7_1">

View File

@ -11,7 +11,8 @@
require_once './libraries/common.inc.php';
if (! isset($selected_tbl)) {
require_once './libraries/header.inc.php';
require './libraries/db_common.inc.php';
require './libraries/db_info.inc.php';
}
@ -55,16 +56,15 @@ if ($cfgRelation['commwork']) {
* Selects the database and gets tables names
*/
PMA_DBI_select_db($db);
$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
$tables = PMA_DBI_get_tables($db);
$count = 0;
while ($row = PMA_DBI_fetch_row($rowset)) {
$table = $row[0];
foreach($tables as $table) {
$comments = PMA_getComments($db, $table);
echo '<div>' . "\n";
echo '<h2>' . $table . '</h2>' . "\n";
echo '<h2>' . htmlspecialchars($table) . '</h2>' . "\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)) {
<td nowrap="nowrap">
<?php
if (isset($pk_array[$row['Field']])) {
echo '<u>' . $field_name . '</u>';
echo '<u>' . htmlspecialchars($field_name) . '</u>';
} else {
echo $field_name;
echo htmlspecialchars($field_name);
}
?>
</td>

View File

@ -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

View File

@ -69,7 +69,7 @@ $lang_iso_code = $GLOBALS['available_languages'][$GLOBALS['lang']][1];
// start output
include ('./libraries/header_http.inc.php');
include './libraries/header_http.inc.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

View File

@ -1,11 +1,14 @@
CodeMirror.defineMode("mysql", function(config, parserConfig) {
var indentUnit = config.indentUnit,
keywords = parserConfig.keywords,
verbs = parserConfig.verbs,
functions = parserConfig.functions,
types = parserConfig.types,
attributes = parserConfig.attributes,
multiLineStrings = parserConfig.multiLineStrings;
attributes = parserConfig.attributes,
multiLineStrings = parserConfig.multiLineStrings,
multiPartKeywords= parserConfig.multiPartKeywords;
var isOperatorChar = /[+\-*&%=<>!?:\/|]/;
function chain(stream, state, f) {
state.tokenize = f;
return f(stream, state);
@ -64,14 +67,35 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
else {
// get the whole word
stream.eatWhile(/[\w\$_]/);
var word = stream.current().toLowerCase();
var oldPos = stream.pos;
// is it one of the listed verbs?
if (verbs && verbs.propertyIsEnumerable(word)) return ret("keyword", "statement-verb");
// is it one of the listed keywords?
if (keywords && keywords.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "keyword");
if (keywords && keywords.propertyIsEnumerable(word)) return ret("keyword", "keyword");
// is it one of the listed functions?
if (functions && functions.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "builtin");
if (functions && functions.propertyIsEnumerable(word)) {
// All functions begin with '('
stream.eatSpace();
if(stream.peek() == '(')
return ret("keyword", "builtin");
// Not func => restore old pos
stream.pos = oldPos;
}
// is it one of the listed types?
if (types && types.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-2");
if (types && types.propertyIsEnumerable(word)) return ret("keyword", "variable-2");
// is it one of the listed attributes?
if (attributes && attributes.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-3");
if (attributes && attributes.propertyIsEnumerable(word)) return ret("keyword", "variable-3");
// is it a multipart keyword? (currently only checks 2 word parts)
stream.eatSpace();
stream.eatWhile(/[\w\$_]/);
var doubleWord = stream.current().toLowerCase();
if (multiPartKeywords && multiPartKeywords.propertyIsEnumerable(doubleWord)) return ret("keyword", "keyword");
// restore old pos
stream.pos = oldPos;
// default: just a "word"
return ret("word", "mysql-word");
}
@ -122,11 +146,14 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
(function() {
function keywords(str) {
var obj = {}, words = str.split(" ");
var obj = {}, words = str;
if(typeof str == 'string') words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var cKeywords = "accessible add all alter analyze and as asc asensitive before between bigint binary blob both by call cascade case change char character check collate column condition constraint continue convert create cross current_date current_time current_timestamp current_user cursor database databases day_hour day_microsecond day_minute day_second dec decimal declare default delayed delete desc describe deterministic distinct distinctrow div double drop dual each else elseif enclosed escaped exists exit explain false fetch float float4 float8 for force foreign from fulltext grant group having high_priority hour_microsecond hour_minute hour_second if ignore in index infile inner inout insensitive insert int int1 int2 int3 int4 int8 integer interval into is iterate join key keys kill leading leave left like limit linear lines load localtime localtimestamp lock long longblob longtext loop low_priority master_ssl_verify_server_cert match maxvalue mediumblob mediumint mediumtext middleint minute_microsecond minute_second mod modifies natural not no_write_to_binlog null numeric on optimize option optionally or order out outer outfile precision primary procedure purge range read reads read_write real references regexp release rename repeat replace require resignal restrict return revoke right rlike schema schemas second_microsecond select sensitive separator set show signal smallint spatial specific sql sqlexception sqlstate sqlwarning sql_big_result sql_calc_found_rows sql_small_result ssl starting straight_join table terminated then tinyblob tinyint tinytext to trailing trigger true undo union unique unlock unsigned update usage use using utc_date utc_time utc_timestamp values varbinary varchar varcharacter varying when where while with write xor year_month zerofill";
var cKeywords = "accessible add all and as asc asensitive before between bigint binary blob both cascade case char character collate column condition constraint continue convert cross current_date current_time current_timestamp current_user cursor database databases day_hour day_microsecond day_minute day_second dec decimal declare default delayed desc deterministic distinct distinctrow div double dual each else elseif enclosed escaped exists exit explain false fetch float float4 float8 for force foreign fulltext from having high_priority hour_microsecond hour_minute hour_second if ignore in index infile inner inout insensitive int int1 int2 int3 int4 int8 integer interval is iterate join key keys leading leave left like limit linear lines localtime localtimestamp long longblob longtext loop low_priority master_ssl_verify_server_cert match maxvalue mediumblob mediumint mediumtext middleint minute_microsecond minute_second mod modifies natural not no_write_to_binlog null numeric on option optionally or out outer outfile precision primary procedure range read reads read_write real references regexp repeat require restrict return right rlike schema schemas second_microsecond sensitive separator smallint spatial specific sql sqlexception sqlstate sqlwarning sql_big_result sql_calc_found_rows sql_small_result ssl starting straight_join table terminated then tinyblob tinyint tinytext to trailing trigger true undo union unique unsigned usage using utc_date utc_time utc_timestamp values varbinary varchar varcharacter varying when where while with write xor year_month zerofill";
var cVerbs = "alter analyze begin binlog call change check checksum commit create deallocate describe do drop execute flush grant handler install kill load lock optimize cache partition prepare purge release rename repair replace reset resignal revoke rollback savepoint select set signal show start truncate uninstall unlock update use xa";
var cFunctions = "abs acos adddate addtime aes_decrypt aes_encrypt area asbinary ascii asin astext atan atan2 avg bdmpolyfromtext bdmpolyfromwkb bdpolyfromtext bdpolyfromwkb benchmark bin bit_and bit_count bit_length bit_or bit_xor boundary buffer cast ceil ceiling centroid char character_length charset char_length coalesce coercibility collation compress concat concat_ws connection_id contains conv convert convert_tz convexhull cos cot count crc32 crosses curdate current_date current_time current_timestamp current_user curtime database date datediff date_add date_diff date_format date_sub day dayname dayofmonth dayofweek dayofyear decode default degrees des_decrypt des_encrypt difference dimension disjoint distance elt encode encrypt endpoint envelope equals exp export_set exteriorring extract extractvalue field find_in_set floor format found_rows from_days from_unixtime geomcollfromtext geomcollfromwkb geometrycollection geometrycollectionfromtext geometrycollectionfromwkb geometryfromtext geometryfromwkb geometryn geometrytype geomfromtext geomfromwkb get_format get_lock glength greatest group_concat group_unique_users hex hour if ifnull inet_aton inet_ntoa insert instr interiorringn intersection intersects interval isclosed isempty isnull isring issimple is_free_lock is_used_lock last_day last_insert_id lcase least left length linefromtext linefromwkb linestring linestringfromtext linestringfromwkb ln load_file localtime localtimestamp locate log log10 log2 lower lpad ltrim makedate maketime make_set master_pos_wait max mbrcontains mbrdisjoint mbrequal mbrintersects mbroverlaps mbrtouches mbrwithin md5 microsecond mid min minute mlinefromtext mlinefromwkb mod month monthname mpointfromtext mpointfromwkb mpolyfromtext mpolyfromwkb multilinestring multilinestringfromtext multilinestringfromwkb multipoint multipointfromtext multipointfromwkb multipolygon multipolygonfromtext multipolygonfromwkb name_const now nullif numgeometries numinteriorrings numpoints oct octet_length old_password ord overlaps password period_add period_diff pi point pointfromtext pointfromwkb pointn pointonsurface polyfromtext polyfromwkb polygon polygonfromtext polygonfromwkb position pow power quarter quote radians rand related release_lock repeat replace reverse right round row_count rpad rtrim schema second sec_to_time session_user sha sha1 sign sin sleep soundex space sqrt srid startpoint std stddev stddev_pop stddev_samp strcmp str_to_date subdate substr substring substring_index subtime sum symdifference sysdate system_user tan time timediff timestamp timestampadd timestampdiff time_format time_to_sec touches to_days trim truncate ucase uncompress uncompressed_length unhex unique_users unix_timestamp updatexml upper user utc_date utc_time utc_timestamp uuid variance var_pop var_samp version week weekday weekofyear within x y year yearweek";
@ -134,11 +161,15 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
var cAttributes = "archive ascii auto_increment bdb berkeleydb binary blackhole csv default example federated heap innobase innodb isam maria memory merge mrg_isam mrg_myisam myisam national ndb ndbcluster precision undefined unicode unsigned varying zerofill";
var cmultiPartKeywords = ['insert into', 'group by', 'order by', 'delete from'];
CodeMirror.defineMIME("text/x-mysql", {
name: "mysql",
keywords: keywords(cKeywords),
multiPartKeywords: keywords(cmultiPartKeywords),
verbs: keywords(cVerbs),
functions: keywords(cFunctions),
types: keywords(cTypes),
attributes: keywords(cAttributes)
});
}());
}());

View File

@ -1617,7 +1617,13 @@ function PMA_createProfilingChart(data, options)
},options));
}
// Formats a profiling duration nicely. Used in PMA_createProfilingChart() and server_status.js
/**
* Formats a profiling duration nicely (in us and ms time). Used in PMA_createProfilingChart() and server_status.js
*
* @param integer Number to be formatted, should be in the range of microsecond to second
* @param integer Acuracy, how many numbers right to the comma should be
* @return string The formatted number
*/
function PMA_prettyProfilingNum(num, acc)
{
if (!acc) {
@ -1635,6 +1641,150 @@ function PMA_prettyProfilingNum(num, acc)
return num + 's';
}
/**
* Formats a SQL Query nicely with newlines and indentation. Depends on Codemirror and MySQL Mode!
*
* @param string Query to be formatted
* @return string The formatted query
*/
function PMA_SQLPrettyPrint(string)
{
var mode = CodeMirror.getMode({},"text/x-mysql");
var stream = new CodeMirror.StringStream(string);
var state = mode.startState();
var token, tokens = [];
var output = '';
var tabs = function(cnt) {
var ret = '';
for (var i=0; i<4*cnt; i++)
ret += " ";
return ret;
};
// "root-level" statements
var statements = {
'select': ['select', 'from','on','where','having','limit','order by','group by'],
'update': ['update', 'set','where'],
'insert into': ['insert into', 'values']
};
// don't put spaces before these tokens
var spaceExceptionsBefore = { ';':true, ',': true, '.': true, '(': true };
// don't put spaces after these tokens
var spaceExceptionsAfter = { '.': true };
// Populate tokens array
var str='';
while (! stream.eol()) {
stream.start = stream.pos;
token = mode.token(stream, state);
if(token != null) {
tokens.push([token, stream.current().toLowerCase()]);
}
}
var currentStatement = tokens[0][1];
if(! statements[currentStatement]) {
return string;
}
// Holds all currently opened code blocks (statement, function or generic)
var blockStack = [];
// Holds the type of block from last iteration (the current is in blockStack[0])
var previousBlock;
// If a new code block is found, newBlock contains its type for one iteration and vice versa for endBlock
var newBlock, endBlock;
// How much to indent in the current line
var indentLevel = 0;
// Holds the "root-level" statements
var statementPart, lastStatementPart = statements[currentStatement][0];
blockStack.unshift('statement');
// Iterate through every token and format accordingly
for (var i = 0; i < tokens.length; i++) {
previousBlock = blockStack[0];
// New block => push to stack
if (tokens[i][1] == '(') {
if (i < tokens.length - 1 && tokens[i+1][0] == 'statement-verb') {
blockStack.unshift(newBlock = 'statement');
} else if (i > 0 && tokens[i-1][0] == 'builtin') {
blockStack.unshift(newBlock = 'function');
} else {
blockStack.unshift(newBlock = 'generic');
}
} else {
newBlock = null;
}
// Block end => pop from stack
if (tokens[i][1] == ')') {
endBlock = blockStack[0];
blockStack.shift();
} else {
endBlock = null;
}
// A subquery is starting
if (i > 0 && newBlock == 'statement') {
indentLevel++;
output += "\n" + tabs(indentLevel) + tokens[i][1] + ' ' + tokens[i+1][1].toUpperCase() + "\n" + tabs(indentLevel + 1);
currentStatement = tokens[i+1][1];
i++;
continue;
}
// A subquery is ending
if (endBlock == 'statement' && indentLevel > 0) {
output += "\n" + tabs(indentLevel);
indentLevel--;
}
// One less indentation for statement parts (from, where, order by, etc.) and a newline
statementPart = statements[currentStatement].indexOf(tokens[i][1]);
if (statementPart != -1) {
if (i > 0) output += "\n";
output += tabs(indentLevel) + tokens[i][1].toUpperCase();
output += "\n" + tabs(indentLevel + 1);
lastStatementPart = tokens[i][1];
}
// Normal indentatin and spaces for everything else
else {
if (! spaceExceptionsBefore[tokens[i][1]]
&& ! (i > 0 && spaceExceptionsAfter[tokens[i-1][1]])
&& output.charAt(output.length -1) != ' ' ) {
output += " ";
}
if (tokens[i][0] == 'keyword') {
output += tokens[i][1].toUpperCase();
} else {
output += tokens[i][1];
}
}
// split columns in select and 'update set' clauses, but only inside statements blocks
if (( lastStatementPart == 'select' || lastStatementPart == 'where' || lastStatementPart == 'set')
&& tokens[i][1]==',' && blockStack[0] == 'statement') {
output += "\n" + tabs(indentLevel + 1);
}
// split conditions in where clauses, but only inside statements blocks
if (lastStatementPart == 'where'
&& (tokens[i][1]=='and' || tokens[i][1]=='or' || tokens[i][1]=='xor')) {
if (blockStack[0] == 'statement') {
output += "\n" + tabs(indentLevel + 1);
}
// Todo: Also split and or blocks in newlines & identation++
//if(blockStack[0] == 'generic')
// output += ...
}
}
return output;
}
/**
* jQuery function that uses jQueryUI's dialogs to confirm with user. Does not
* return a jQuery object yet and hence cannot be chained

View File

@ -170,7 +170,7 @@ $js_messages['strJumpToTable'] = __('Jump to Log table');
$js_messages['strNoDataFound'] = __('Log analysed, but no data found in this time span.');
/* l10n: A collection of available filters */
$js_messages['strFilters'] = __('Filters');
$js_messages['strFiltersForLogTable'] = __('Log table filter options');
/* l10n: Filter as in "Start Filtering" */
$js_messages['strFilter'] = __('Filter');
$js_messages['strFilterByWordRegexp'] = __('Filter queries by word/regexp:');
@ -265,7 +265,9 @@ $js_messages['strDisplayHelp'] = '<ul><li>'
. '</li><li>'
. __('Hovering over a point will show its label.')
. '</li><li>'
. __('Drag and select an area in the plot to zoom into it.')
. __('Use mousewheel to zoom in or out of the plot.')
. '</li><li>'
. __('Click and drag the mouse to navigate the plot.')
. '</li><li>'
. __('Click reset zoom link to come back to original state.')
. '</li><li>'
@ -445,10 +447,16 @@ PMA_printJsValue("$.datepicker.regional['']['dayNamesMin']",
__('Sa')));
/* l10n: Column header for week of the year in calendar */
PMA_printJsValue("$.datepicker.regional['']['weekHeader']", __('Wk'));
PMA_printJsValue("$.datepicker.regional['']['hourText']", __('Hour'));
PMA_printJsValue("$.datepicker.regional['']['minuteText']", __('Minute'));
PMA_printJsValue("$.datepicker.regional['']['secondText']", __('Second'));
?>
$.extend($.datepicker._defaults, $.datepicker.regional['']);
} /* if ($.datepicker) */
<?php
echo "if ($.timepicker) {\n";
PMA_printJsValue("$.timepicker.regional['']['timeText']", __('Time'));
PMA_printJsValue("$.timepicker.regional['']['hourText']", __('Hour'));
PMA_printJsValue("$.timepicker.regional['']['minuteText']", __('Minute'));
PMA_printJsValue("$.timepicker.regional['']['secondText']", __('Second'));
?>
$.extend($.timepicker._defaults, $.timepicker.regional['']);
} /* if ($.timepicker) */

View File

@ -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 = '<strong>' + PMA_messages['strAddOption'] +'"' +column_name+ '"</strong>';
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);

View File

@ -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);
}
}

View File

@ -43,6 +43,19 @@ $(function() {
},
type: "numeric"
});
jQuery.tablesorter.addParser({
id: "withinSpanNumber",
is: function(s) {
return /<span class="original"/.test(s);
},
format: function(s, table, html) {
var res = html.innerHTML.match(/<span(\s*style="display:none;"\s*)?\s*class="original">(.*)?<\/span>/);
return (res && res.length >= 3) ? res[2] : 0;
},
type: "numeric"
});
// faster zebra widget: no row visibility check, faster css class switching, no cssChildRow check
jQuery.tablesorter.addWidget({
id: "fast-zebra",
@ -394,7 +407,7 @@ $(function() {
if (word.length == 0) {
textFilter = null;
}
else textFilter = new RegExp("(^|_)" + word, 'i');
else textFilter = new RegExp("(^| )" + word, 'i');
text = word;
@ -507,7 +520,7 @@ $(function() {
sortList: [[0, 0]],
widgets: ['fast-zebra'],
headers: {
1: { sorter: 'fancyNumber' }
1: { sorter: 'withinSpanNumber' }
}
};
break;

View File

@ -9,6 +9,10 @@ $(function() {
codemirror_editor = CodeMirror.fromTextArea(elm[0], { lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql" });
}
}
// Timepicker is loaded on demand so we need to initialize datetime fields from the 'load log' dialog
$('div#logAnalyseDialog .datetimefield').each(function() {
PMA_addDatepicker($(this));
});
/**** Monitor charting implementation ****/
/* Saves the previous ajax response for differential values */
@ -1022,8 +1026,6 @@ $(function() {
removeVariables: $('input#removeVariables').prop('checked'),
limitTypes: $('input#limitTypes').prop('checked')
});
$('#logAnalyseDialog').find('dateStart,dateEnd').datepicker('destroy');
}
$('#logAnalyseDialog').dialog({
@ -1388,7 +1390,7 @@ $(function() {
if (logData.numRows > 12) {
$('div#logTable').prepend(
'<fieldset id="logDataFilter">' +
' <legend>' + PMA_messages['strFilters'] + '</legend>' +
' <legend>' + PMA_messages['strFiltersForLogTable'] + '</legend>' +
' <div class="formelement">' +
' <label for="filterQueryText">' + PMA_messages['strFilterByWordRegexp'] + '</label>' +
' <input name="filterQueryText" type="text" id="filterQueryText" style="vertical-align: baseline;" />' +
@ -1688,33 +1690,18 @@ $(function() {
return cols;
}
/* Opens the query analyzer dialog */
function openQueryAnalyzer() {
var rowData = $(this).parent().data('query');
var query = rowData.argument || rowData.sql_text;
/* A very basic SQL Formatter. Totally fails in the cases of
- Any string appearance containing a MySQL Keyword, surrounded by whitespaces, e.g. WHERE bar = "This where the formatter fails"
- Subqueries too probably
*/
// Matches the columns to be selected
// .* selector doesn't include whitespace and we have no PCRE_DOTALL modifier, (.|\s)+ crashes Chrome (reported and confirmed),
// [^]+ results in JS error in IE8, thus we use [^\0]+ for matching each column since the zero-byte char (hopefully) doesn't appear in column names ;)
var sLists = query.match(/SELECT\s+[^\0]+\s+FROM\s+/gi);
if (sLists) {
for (var i = 0; i < sLists.length; i++) {
query = query.replace(sLists[i], sLists[i].replace(/\s*((`|'|"|).*?\1,)\s*/gi, '$1\n\t'));
}
query = query
.replace(/(\s+|^)(SELECT|FROM|WHERE|GROUP BY|HAVING|ORDER BY|LIMIT)(\s+|$)/gi, '\n$2\n\t')
.replace(/\s+UNION\s+/gi, '\n\nUNION\n\n')
.replace(/\s+(AND)\s+/gi, ' $1\n\t')
.trim();
}
query = PMA_SQLPrettyPrint(query);
codemirror_editor.setValue(query);
// Codemirror is bugged, it doesn't refresh properly sometimes. Following lines seem to fix that
setTimeout(function() {
codemirror_editor.refresh()
},50);
var profilingChart = null;
var dlgBtns = {};

View File

@ -173,9 +173,20 @@ function editVariable(link)
// hide original content
$cell.html('<span class="oldContent" style="display:none;">' + $cell.html() + '</span>');
// put edit field and save/cancel link
$cell.prepend('<table class="serverVariableEditTable" border="0"><tr><td></td><td style="width:100%;"><input type="text" value="' + data + '"/></td></tr</table>');
$cell.prepend('<table class="serverVariableEditTable" border="0"><tr><td></td><td style="width:100%;">' +
'<input type="text" id="variableEditArea" value="' + data + '" /></td></tr</table>');
$cell.find('table td:first').append(mySaveLink);
$cell.find('table td:first').append(' ');
$cell.find('table td:first').append(myCancelLink);
// Keyboard shortcuts to the rescue
$('input#variableEditArea').focus();
$('input#variableEditArea').keydown(function(event) {
// Enter key
if(event.keyCode == 13) mySaveLink.trigger('click');
// Escape key
if(event.keyCode == 27) myCancelLink.trigger('click');
});
});
return false;

View File

@ -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
**/
$('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
@ -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;
}
}
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;
}
it++
}//End data update
//Update the chart series and replot
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];
$.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++;
});
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;
currentChart = PMA_createChart(currentSettings);
}
}
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);
}
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' )
newSeries[0].data.push({ name: value[dataLabel], x: value[xLabel], y: tempY[0][i], 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++;
});
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();
else if(xType == 'time') {
currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel],$('#types_0').val())});
}
//End plot update
else {
var tempX = getCord(xCord);
var tempY = getCord(yCord);
var i = 0;
newSeries[0].data = new Array();
xCord = tempX[2];
yCord = tempY[2];
//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 + ' ,';
$.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++;
});
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;
currentChart = PMA_createChart(currentSettings);
}
}
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);
}
}
sql_query = sql_query.substring(0, sql_query.length - 1);
sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']);
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];
//Post SQL query to sql.php
$.post('sql.php', {
$.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
newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: 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.series = newSeries;
currentChart = PMA_createChart(currentSettings);
}
}
currentChart.series[0].data[currentData].select();
}
//End plot update
//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', {
'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
}
else {
currentSettings.yAxis.labels = { formatter : function() {
return getDate(this.value, $('#types_1').val());
}}
}
xCord = tempX[2];
if(yType == 'numeric') {
currentSettings.yAxis.max = Array.max(yCord) + 6
currentSettings.yAxis.min = Array.min(yCord) - 6
}
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());
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());
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
}
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];
}
}
yCord = tempY[2];
if(xType == 'numeric') {
currentSettings.xAxis.max = Array.max(xCord) + 6
currentSettings.xAxis.min = Array.min(xCord) - 6
}
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++;
});
else {
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 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];
}
}};
xCord = tempX[2];
yCord = tempY[2];
}
}
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++;
});
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 = $('<a href="#">Reset zoom</a>')
.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();
}
});

View File

@ -22,7 +22,7 @@ class Advisor
PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1)
);
// Add total memory to variables as well
require_once('libraries/sysinfo.lib.php');
require_once 'libraries/sysinfo.lib.php';
$sysinfo = getSysInfo();
$memory = $sysinfo->memory();
$this->variables['system_memory'] = $memory['MemTotal'];
@ -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();

View File

@ -9,7 +9,7 @@
/**
* Load vendor configuration.
*/
require('./libraries/vendor_config.php');
require './libraries/vendor_config.php';
/**
* Configuration class
@ -75,7 +75,7 @@ class PMA_Config
/**
* constructor
*
* @param string source to read config from
* @param string $source source to read config from
*/
function __construct($source = null)
{
@ -93,6 +93,8 @@ class PMA_Config
/**
* sets system and application settings
*
* @return nothing
*/
function checkSystem()
{
@ -118,6 +120,8 @@ class PMA_Config
/**
* whether to use gzip output compression or not
*
* @return nothing
*/
function checkOutputCompression()
{
@ -130,8 +134,9 @@ class PMA_Config
// disable output-buffering (if set to 'auto') for IE6, else enable it.
if (strtolower($this->get('OBGzip')) == 'auto') {
if ($this->get('PMA_USR_BROWSER_AGENT') == 'IE'
&& $this->get('PMA_USR_BROWSER_VER') >= 6
&& $this->get('PMA_USR_BROWSER_VER') < 7) {
&& $this->get('PMA_USR_BROWSER_VER') >= 6
&& $this->get('PMA_USR_BROWSER_VER') < 7
) {
$this->set('OBGzip', false);
} else {
$this->set('OBGzip', true);
@ -142,7 +147,10 @@ class PMA_Config
/**
* Determines platform (OS), browser and version of the user
* Based on a phpBuilder article:
*
* @see http://www.phpbuilder.net/columns/tim20000821.php
*
* @return nothing
*/
function checkClient()
{
@ -170,28 +178,52 @@ class PMA_Config
// 2. browser and version
// (must check everything else before Mozilla)
if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
if (preg_match(
'@Opera(/| )([0-9].[0-9]{1,2})@',
$HTTP_USER_AGENT,
$log_version)
) {
$this->set('PMA_USR_BROWSER_VER', $log_version[2]);
$this->set('PMA_USR_BROWSER_AGENT', 'OPERA');
} elseif (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
} elseif (preg_match(
'@MSIE ([0-9].[0-9]{1,2})@',
$HTTP_USER_AGENT,
$log_version)
) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'IE');
} elseif (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
} elseif (preg_match(
'@OmniWeb/([0-9].[0-9]{1,2})@',
$HTTP_USER_AGENT,
$log_version)
) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'OMNIWEB');
// Konqueror 2.2.2 says Konqueror/2.2.2
// Konqueror 3.0.3 says Konqueror/3
} elseif (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) {
} elseif (preg_match(
'@(Konqueror/)(.*)(;)@',
$HTTP_USER_AGENT,
$log_version)
) {
$this->set('PMA_USR_BROWSER_VER', $log_version[2]);
$this->set('PMA_USR_BROWSER_AGENT', 'KONQUEROR');
} elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)
&& preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version2)) {
} elseif (preg_match(
'@Mozilla/([0-9].[0-9]{1,2})@',
$HTTP_USER_AGENT,
$log_version)
&& preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version2)
) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1] . '.' . $log_version2[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'SAFARI');
} elseif (preg_match('@rv:1.9(.*)Gecko@', $HTTP_USER_AGENT)) {
$this->set('PMA_USR_BROWSER_VER', '1.9');
$this->set('PMA_USR_BROWSER_AGENT', 'GECKO');
} elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
} elseif (
preg_match('@Mozilla/([0-9].[0-9]{1,2})@',
$HTTP_USER_AGENT,
$log_version)
) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'MOZILLA');
} else {
@ -202,6 +234,8 @@ class PMA_Config
/**
* Whether GD2 is present
*
* @return nothing
*/
function checkGd2()
{
@ -243,14 +277,17 @@ class PMA_Config
/**
* Whether the Web server php is running on is IIS
*
* @return nothing
*/
function checkWebServer()
{
if (PMA_getenv('SERVER_SOFTWARE')
// some versions return Microsoft-IIS, some Microsoft/IIS
// we could use a preg_match() but it's slower
&& stristr(PMA_getenv('SERVER_SOFTWARE'), 'Microsoft')
&& stristr(PMA_getenv('SERVER_SOFTWARE'), 'IIS')) {
// some versions return Microsoft-IIS, some Microsoft/IIS
// we could use a preg_match() but it's slower
&& stristr(PMA_getenv('SERVER_SOFTWARE'), 'Microsoft')
&& stristr(PMA_getenv('SERVER_SOFTWARE'), 'IIS')
) {
$this->set('PMA_IS_IIS', 1);
} else {
$this->set('PMA_IS_IIS', 0);
@ -259,6 +296,8 @@ class PMA_Config
/**
* Whether the os php is running on is windows or not
*
* @return nothing
*/
function checkWebServerOs()
{
@ -278,14 +317,22 @@ class PMA_Config
/**
* detects PHP version
*
* @return nothing
*/
function checkPhpVersion()
{
$match = array();
if (! preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@',
phpversion(), $match)) {
preg_match('@([0-9]{1,2}).([0-9]{1,2})@',
phpversion(), $match);
if (! preg_match(
'@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@',
phpversion(),
$match)
) {
preg_match(
'@([0-9]{1,2}).([0-9]{1,2})@',
phpversion(),
$match
);
}
if (isset($match) && ! empty($match[1])) {
if (! isset($match[2])) {
@ -294,8 +341,10 @@ class PMA_Config
if (! isset($match[3])) {
$match[3] = 0;
}
$this->set('PMA_PHP_INT_VERSION',
(int) sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
$this->set(
'PMA_PHP_INT_VERSION',
(int) sprintf('%d%02d%02d', $match[1], $match[2], $match[3])
);
} else {
$this->set('PMA_PHP_INT_VERSION', 0);
}
@ -333,7 +382,8 @@ class PMA_Config
* loads configuration from $source, usally the config file
* should be called on object creation
*
* @param string $source config file
* @param string $source config file
*
* @return bool
*/
function load($source = null)
@ -369,10 +419,26 @@ class PMA_Config
* Backward compatibility code
*/
if (!empty($cfg['DefaultTabTable'])) {
$cfg['DefaultTabTable'] = str_replace('_properties', '', str_replace('tbl_properties.php', 'tbl_sql.php', $cfg['DefaultTabTable']));
$cfg['DefaultTabTable'] = str_replace(
'_properties',
'',
str_replace(
'tbl_properties.php',
'tbl_sql.php',
$cfg['DefaultTabTable']
)
);
}
if (!empty($cfg['DefaultTabDatabase'])) {
$cfg['DefaultTabDatabase'] = str_replace('_details', '', str_replace('db_details.php', 'db_sql.php', $cfg['DefaultTabDatabase']));
$cfg['DefaultTabDatabase'] = str_replace(
'_details',
'',
str_replace(
'db_details.php',
'db_sql.php',
$cfg['DefaultTabDatabase']
)
);
}
$this->settings = PMA_array_merge_recursive($this->settings, $cfg);
@ -424,16 +490,20 @@ class PMA_Config
$config_mtime = max($this->default_source_mtime, $this->source_mtime);
// cache user preferences, use database only when needed
if (! isset($_SESSION['cache'][$cache_key]['userprefs'])
|| $_SESSION['cache'][$cache_key]['config_mtime'] < $config_mtime) {
|| $_SESSION['cache'][$cache_key]['config_mtime'] < $config_mtime
) {
// load required libraries
require_once './libraries/user_preferences.lib.php';
include_once './libraries/user_preferences.lib.php';
$prefs = PMA_load_userprefs();
$_SESSION['cache'][$cache_key]['userprefs'] = PMA_apply_userprefs($prefs['config_data']);
$_SESSION['cache'][$cache_key]['userprefs']
= PMA_apply_userprefs($prefs['config_data']);
$_SESSION['cache'][$cache_key]['userprefs_mtime'] = $prefs['mtime'];
$_SESSION['cache'][$cache_key]['userprefs_type'] = $prefs['type'];
$_SESSION['cache'][$cache_key]['config_mtime'] = $config_mtime;
}
} else if ($server == 0 || ! isset($_SESSION['cache'][$cache_key]['userprefs'])) {
} elseif ($server == 0
|| ! isset($_SESSION['cache'][$cache_key]['userprefs'])
) {
$this->set('user_preferences', false);
return;
}
@ -458,30 +528,45 @@ class PMA_Config
// save theme
$tmanager = $_SESSION['PMA_Theme_Manager'];
if ($tmanager->getThemeCookie() || isset($_REQUEST['set_theme'])) {
if ((! isset($config_data['ThemeDefault']) && $tmanager->theme->getId() != 'original')
|| isset($config_data['ThemeDefault']) && $config_data['ThemeDefault'] != $tmanager->theme->getId()) {
if ((! isset($config_data['ThemeDefault'])
&& $tmanager->theme->getId() != 'original')
|| isset($config_data['ThemeDefault'])
&& $config_data['ThemeDefault'] != $tmanager->theme->getId()
) {
// new theme was set in common.inc.php
$this->setUserValue(null, 'ThemeDefault', $tmanager->theme->getId(), 'original');
$this->setUserValue(
null,
'ThemeDefault',
$tmanager->theme->getId(),
'original'
);
}
} else {
// no cookie - read default from settings
if ($this->settings['ThemeDefault'] != $tmanager->theme->getId()
&& $tmanager->checkTheme($this->settings['ThemeDefault'])) {
&& $tmanager->checkTheme($this->settings['ThemeDefault'])
) {
$tmanager->setActiveTheme($this->settings['ThemeDefault']);
$tmanager->setThemeCookie();
}
}
// save font size
if ((! isset($config_data['fontsize']) && $org_fontsize != '82%')
|| isset($config_data['fontsize']) && $org_fontsize != $config_data['fontsize']) {
if ((! isset($config_data['fontsize'])
&& $org_fontsize != '82%')
|| isset($config_data['fontsize'])
&& $org_fontsize != $config_data['fontsize']
) {
$this->setUserValue(null, 'fontsize', $org_fontsize, '82%');
}
// save language
if (isset($_COOKIE['pma_lang']) || isset($_POST['lang'])) {
if ((! isset($config_data['lang']) && $GLOBALS['lang'] != 'en')
|| isset($config_data['lang']) && $GLOBALS['lang'] != $config_data['lang']) {
if ((! isset($config_data['lang'])
&& $GLOBALS['lang'] != 'en')
|| isset($config_data['lang'])
&& $GLOBALS['lang'] != $config_data['lang']
) {
$this->setUserValue(null, 'lang', $GLOBALS['lang'], 'en');
}
} else {
@ -492,16 +577,30 @@ class PMA_Config
}
// save connection collation
if (isset($_COOKIE['pma_collation_connection']) || isset($_POST['collation_connection'])) {
if ((! isset($config_data['collation_connection']) && $GLOBALS['collation_connection'] != 'utf8_general_ci')
|| isset($config_data['collation_connection']) && $GLOBALS['collation_connection'] != $config_data['collation_connection']) {
$this->setUserValue(null, 'collation_connection', $GLOBALS['collation_connection'], 'utf8_general_ci');
if (isset($_COOKIE['pma_collation_connection'])
|| isset($_POST['collation_connection'])
) {
if ((! isset($config_data['collation_connection'])
&& $GLOBALS['collation_connection'] != 'utf8_general_ci')
|| isset($config_data['collation_connection'])
&& $GLOBALS['collation_connection'] != $config_data['collation_connection']
) {
$this->setUserValue(
null,
'collation_connection',
$GLOBALS['collation_connection'],
'utf8_general_ci'
);
}
} else {
// read collation from settings
if (isset($config_data['collation_connection'])) {
$GLOBALS['collation_connection'] = $config_data['collation_connection'];
$this->setCookie('pma_collation_connection', $GLOBALS['collation_connection']);
$GLOBALS['collation_connection']
= $config_data['collation_connection'];
$this->setCookie(
'pma_collation_connection',
$GLOBALS['collation_connection']
);
}
}
}
@ -516,13 +615,15 @@ class PMA_Config
* @param string $cfg_path
* @param mixed $new_cfg_value
* @param mixed $default_value
*
* @return nothing
*/
function setUserValue($cookie_name, $cfg_path, $new_cfg_value, $default_value = null)
{
// use permanent user preferences if possible
$prefs_type = $this->get('user_preferences');
if ($prefs_type) {
require_once './libraries/user_preferences.lib.php';
include_once './libraries/user_preferences.lib.php';
if ($default_value === null) {
$default_value = PMA_array_read($cfg_path, $this->default);
}
@ -544,6 +645,7 @@ class PMA_Config
*
* @param string $cookie_name
* @param mixed $cfg_value
*
* @return mixed
*/
function getUserValue($cookie_name, $cfg_value)
@ -564,7 +666,10 @@ class PMA_Config
/**
* set source
*
* @param string $source
*
* @return nothing
*/
function setSource($source)
{
@ -573,6 +678,8 @@ class PMA_Config
/**
* checks if the config folder still exists and terminates app if true
*
* @return nothing
*/
function checkConfigFolder()
{
@ -595,20 +702,16 @@ class PMA_Config
}
if (! file_exists($this->getSource())) {
// do not trigger error here
// https://sf.net/tracker/?func=detail&aid=1370269&group_id=23067&atid=377408
/*
trigger_error(
'phpMyAdmin-ERROR: unkown configuration source: ' . $source,
E_USER_WARNING);
*/
$this->source_mtime = 0;
return false;
}
if (! is_readable($this->getSource())) {
$this->source_mtime = 0;
die('Existing configuration file (' . $this->getSource() . ') is not readable.');
die(
'Existing configuration file ('
. $this->getSource() . ') is not readable.'
);
}
return true;
@ -617,6 +720,8 @@ class PMA_Config
/**
* verifies the permissions on config file (if asked by configuration)
* (must be called after config.inc.php has been merged)
*
* @return nothing
*/
function checkPermissions()
{
@ -636,8 +741,10 @@ class PMA_Config
/**
* returns specific config setting
* @param string $setting
* @return mixed value
*
* @param string $setting
*
* @return mixed value
*/
function get($setting)
{
@ -650,12 +757,16 @@ class PMA_Config
/**
* sets configuration variable
*
* @param string $setting configuration option
* @param string $value new value for configuration option
* @param string $setting configuration option
* @param string $value new value for configuration option
*
* @return nothing
*/
function set($setting, $value)
{
if (! isset($this->settings[$setting]) || $this->settings[$setting] != $value) {
if (! isset($this->settings[$setting])
|| $this->settings[$setting] != $value
) {
$this->settings[$setting] = $value;
$this->set_mtime = time();
}
@ -663,6 +774,7 @@ class PMA_Config
/**
* returns source for current config
*
* @return string config source
*/
function getSource()
@ -675,7 +787,9 @@ class PMA_Config
* or the theme changes
* must also check the pma_fontsize cookie in case there is no
* config file
* @return int Summary of unix timestamps and fontsize, to be unique on theme parameters change
*
* @return int Summary of unix timestamps and fontsize,
* to be unique on theme parameters change
*/
function getThemeUniqueValue()
{
@ -712,18 +826,6 @@ class PMA_Config
if (strlen($pma_absolute_uri) < 5) {
$url = array();
// At first we try to parse REQUEST_URI, it might contain full URL
/**
* REQUEST_URI contains PATH_INFO too, this is not what we want
* script-php/pathinfo/
if (PMA_getenv('REQUEST_URI')) {
$url = @parse_url(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
if ($url === false) {
$url = array('path' => $_SERVER['REQUEST_URI']);
}
}
*/
// If we don't have scheme, we didn't have full URL so we need to
// dig deeper
if (empty($url['scheme'])) {
@ -731,16 +833,19 @@ class PMA_Config
if (PMA_getenv('HTTP_SCHEME')) {
$url['scheme'] = PMA_getenv('HTTP_SCHEME');
} else {
$url['scheme'] =
PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
$url['scheme'] = PMA_getenv('HTTPS')
&& strtolower(PMA_getenv('HTTPS')) != 'off'
? 'https'
: 'http';
}
// Host and port
if (PMA_getenv('HTTP_HOST')) {
// Prepend the scheme before using parse_url() since this is not part of the RFC2616 Host request-header
$parsed_url = parse_url($url['scheme'] . '://' . PMA_getenv('HTTP_HOST'));
// Prepend the scheme before using parse_url() since this
// is not part of the RFC2616 Host request-header
$parsed_url = parse_url(
$url['scheme'] . '://' . PMA_getenv('HTTP_HOST')
);
if (!empty($parsed_url['host'])) {
$url = $parsed_url;
} else {
@ -760,17 +865,7 @@ class PMA_Config
// And finally the path could be already set from REQUEST_URI
if (empty($url['path'])) {
/**
* REQUEST_URI contains PATH_INFO too, this is not what we want
* script-php/pathinfo/
if (PMA_getenv('PATH_INFO')) {
$path = parse_url(PMA_getenv('PATH_INFO'));
} else {
// PHP_SELF in CGI often points to cgi executable, so use it
// as last choice
*/
$path = parse_url($GLOBALS['PMA_PHP_SELF']);
//}
$path = parse_url($GLOBALS['PMA_PHP_SELF']);
$url['path'] = $path['path'];
}
}
@ -789,8 +884,9 @@ class PMA_Config
$pma_absolute_uri .= $url['host'];
// Add port, if it not the default one
if (! empty($url['port'])
&& (($url['scheme'] == 'http' && $url['port'] != 80)
|| ($url['scheme'] == 'https' && $url['port'] != 443))) {
&& (($url['scheme'] == 'http' && $url['port'] != 80)
|| ($url['scheme'] == 'https' && $url['port'] != 443))
) {
$pma_absolute_uri .= ':' . $url['port'];
}
// And finally path, without script name, the 'a' is there not to
@ -814,7 +910,8 @@ class PMA_Config
}
}
// PHP's dirname function would have returned a dot when $path contains no slash
// PHP's dirname function would have returned a dot
// when $path contains no slash
if ($path == '.') {
$path = '';
}
@ -843,7 +940,8 @@ class PMA_Config
// If URI doesn't start with http:// or https://, we will add
// this.
if (substr($pma_absolute_uri, 0, 7) != 'http://'
&& substr($pma_absolute_uri, 0, 8) != 'https://') {
&& substr($pma_absolute_uri, 0, 8) != 'https://'
) {
$pma_absolute_uri =
($is_https ? 'https' : 'http')
. ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//')
@ -855,19 +953,25 @@ class PMA_Config
/**
* check selected collation_connection
*
* @todo check validity of $_REQUEST['collation_connection']
*
* @return nothing
*/
function checkCollationConnection()
{
if (! empty($_REQUEST['collation_connection'])) {
$this->set('collation_connection',
strip_tags($_REQUEST['collation_connection']));
$this->set(
'collation_connection',
strip_tags($_REQUEST['collation_connection'])
);
}
}
/**
* checks for font size configuration, and sets font size as requested by user
*
* @return nothing
*/
function checkFontsize()
{
@ -895,8 +999,8 @@ class PMA_Config
/**
* checks if upload is enabled
*
* @return nothing
*/
function checkUpload()
{
if (ini_get('file_uploads')) {
@ -916,6 +1020,8 @@ class PMA_Config
* Used with permission from Moodle (http://moodle.org) by Martin Dougiamas
*
* this section generates $max_upload_size in bytes
*
* @return nothing
*/
function checkUploadSize()
{
@ -924,8 +1030,10 @@ class PMA_Config
}
if ($postsize = ini_get('post_max_size')) {
$this->set('max_upload_size',
min(PMA_get_real_size($filesize), PMA_get_real_size($postsize)));
$this->set(
'max_upload_size',
min(PMA_get_real_size($filesize), PMA_get_real_size($postsize))
);
} else {
$this->set('max_upload_size', PMA_get_real_size($filesize));
}
@ -933,6 +1041,8 @@ class PMA_Config
/**
* check for https
*
* @return nothing
*/
function checkIsHttps()
{
@ -952,8 +1062,7 @@ class PMA_Config
$url = parse_url($this->get('PmaAbsoluteUri'));
if (isset($url['scheme'])
&& $url['scheme'] == 'https') {
if (isset($url['scheme']) && $url['scheme'] == 'https') {
$is_https = true;
} else {
$is_https = false;
@ -978,7 +1087,8 @@ class PMA_Config
// At first we try to parse REQUEST_URI, it might contain full URL,
if (PMA_getenv('REQUEST_URI')) {
$url = @parse_url(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
// produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
$url = @parse_url(PMA_getenv('REQUEST_URI'));
if ($url === false) {
$url = array();
}
@ -998,8 +1108,7 @@ class PMA_Config
}
}
if (isset($url['scheme'])
&& $url['scheme'] == 'https') {
if (isset($url['scheme']) && $url['scheme'] == 'https') {
$is_https = true;
} else {
$is_https = false;
@ -1010,6 +1119,8 @@ class PMA_Config
/**
* detect correct cookie path
*
* @return nothing
*/
function checkCookiePath()
{
@ -1036,6 +1147,8 @@ class PMA_Config
/**
* enables backward compatibility
*
* @return nothing
*/
function enableBc()
{
@ -1071,6 +1184,8 @@ class PMA_Config
/**
* @todo finish
*
* @return nothing
*/
function save()
{
@ -1080,8 +1195,9 @@ class PMA_Config
* returns options for font size selection
*
* @static
* @param string $current_size current selected font size with unit
* @return array selectable font sizes
* @param string $current_size current selected font size with unit
*
* @return array selectable font sizes
*/
static protected function _getFontsizeOptions($current_size = '82%')
{
@ -1127,7 +1243,8 @@ class PMA_Config
$option_inc += $factor;
$option_dec -= $factor;
if (isset($factors[$key + 1])
&& $option_inc >= $value + $factors[$key + 1]) {
&& $option_inc >= $value + $factors[$key + 1]
) {
break;
}
}
@ -1140,8 +1257,9 @@ class PMA_Config
* returns html selectbox for font sizes
*
* @static
* @param string $current_size currently slected font size with unit
* @return string html selectbox
* @param string $current_size currently slected font size with unit
*
* @return string html selectbox
*/
static protected function _getFontsizeSelection()
{
@ -1174,8 +1292,9 @@ class PMA_Config
* return complete font size selection form
*
* @static
* @param string $current_size currently slected font size with unit
* @return string html selectbox
* @param string $current_size currently slected font size with unit
*
* @return string html selectbox
*/
static public function getFontsizeForm()
{
@ -1192,25 +1311,33 @@ class PMA_Config
/**
* removes cookie
*
* @param string $cookie name of cookie to remove
* @return boolean result of setcookie()
* @param string $cookie name of cookie to remove
*
* @return boolean result of setcookie()
*/
function removeCookie($cookie)
{
return setcookie($cookie, '', time() - 3600,
$this->getCookiePath(), '', $this->isHttps());
return setcookie(
$cookie,
'',
time() - 3600,
$this->getCookiePath(),
'',
$this->isHttps()
);
}
/**
* sets cookie if value is different from current cokkie value,
* or removes if value is equal to default
*
* @param string $cookie name of cookie to remove
* @param mixed $value new cookie value
* @param string $default default value
* @param int $validity validity of cookie in seconds (default is one month)
* @param bool $httponlt whether cookie is only for HTTP (and not for scripts)
* @return boolean result of setcookie()
* @param string $cookie name of cookie to remove
* @param mixed $value new cookie value
* @param string $default default value
* @param int $validity validity of cookie in seconds (default is one month)
* @param bool $httponly whether cookie is only for HTTP (and not for scripts)
*
* @return boolean result of setcookie()
*/
function setCookie($cookie, $value, $default = null, $validity = null, $httponly = true)
{
@ -1239,8 +1366,15 @@ class PMA_Config
} else {
$v = time() + $validity;
}
return setcookie($cookie, $value, $v,
$this->getCookiePath(), '', $this->isHttps(), $httponly);
return setcookie(
$cookie,
$value,
$v,
$this->getCookiePath(),
'',
$this->isHttps(),
$httponly
);
}
// cookie has already $value as value

View File

@ -77,9 +77,9 @@ class PMA_PDF extends TCPDF
*/
function Error($error_message = '')
{
include('./libraries/header.inc.php');
include './libraries/header.inc.php';
PMA_Message::error(__('Error while creating PDF:') . ' ' . $error_message)->display();
include('./libraries/footer.inc.php');
include './libraries/footer.inc.php';
}
/**

View File

@ -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('<br /><br />');
$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('<br /><br />');
$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();
}
}

View File

@ -344,5 +344,81 @@ class PMA_Theme
.'</p>'
.'</div>';
}
/**
* Remove filter for IE.
*
* @return string CSS code.
*/
function getCssIEClearFilter() {
return PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 6 && PMA_USR_BROWSER_VER <= 8
? 'filter: none'
: '';
}
/**
* Generates code for CSS gradient using various browser extensions.
*
* @param string $start_color Color of gradient start, hex value without #
* @param string $end_color Color of gradient end, hex value without #
*
* @return string CSS code.
*/
function getCssGradient($start_color, $end_color)
{
$result = array();
$result[] = 'background-image: url(./themes/svg_gradient.php?from=' . $start_color . '&to=' . $end_color . ');';
$result[] = 'background-size: 100% 100%;';
$result[] = 'background: -webkit-gradient(linear, left top, left bottom, from(#' . $start_color . '), to(#' . $end_color . '));';
$result[] = 'background: -moz-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
$result[] = 'background: -o-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 6 && PMA_USR_BROWSER_VER <= 8) {
$result[] = 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#' . $start_color . '", endColorstr="#' . $end_color . '");';
}
return implode("\n", $result);
}
/**
* Returns CSS styles for CodeMirror editor based on query formatter colors.
*
* @return string CSS code.
*/
function getCssCodeMirror()
{
$result[] = 'span.cm-keyword, span.cm-statement-verb {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_reservedWord'] . ';';
$result[] = '}';
$result[] = 'span.cm-variable {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
$result[] = '}';
$result[] = 'span.cm-comment {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['comment'] . ';';
$result[] = '}';
$result[] = 'span.cm-mysql-string {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['quote'] . ';';
$result[] = '}';
$result[] = 'span.cm-operator {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
$result[] = '}';
$result[] = 'span.cm-mysql-word {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
$result[] = '}';
$result[] = 'span.cm-builtin {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_functionName'] . ';';
$result[] = '}';
$result[] = 'span.cm-variable-2 {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnType'] . ';';
$result[] = '}';
$result[] = 'span.cm-variable-3 {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnAttrib'] . ';';
$result[] = '}';
$result[] = 'span.cm-separator {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
$result[] = '}';
$result[] = 'span.cm-number {';
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['digit_integer'] . ';';
$result[] = '}';
return implode("\n", $result);
}
}
?>

View File

@ -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') {

View File

@ -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))
@ -127,11 +127,11 @@ rule 'Query cache disabled'
The query cache is known to greatly improve performance if configured correctly. Enable it by setting {query_cache_size} to a 2 digit MiB value and setting {query_cache_type} to 'ON'. <b>Note:</b> If you are using memcached, ignore this recommendation.
query_cache_size is set to 0 or query_cache_type is set to 'OFF'
rule 'Query cache usage' [!fired('Query cache disabled')]
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 <a href="http://dev.mysql.com/doc/refman/5.1/en/ha-memcached.html">memcached</a> 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 <a href="http://dev.mysql.com/doc/refman/5.5/en/ha-memcached.html">memcached</a> 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')]
@ -141,7 +141,7 @@ rule 'Query cache efficiency (%)' [Com_select + Qcache_hits > 0 && !fired('Query
Consider increasing {query_cache_limit}.
The current query cache hit rate of %s% is below 20% | round(value,1)
rule 'Query Cache usage' [!fired('Query cache disabled')]
rule 'Query cache usage' [!fired('Query cache disabled')]
100 - Qcache_free_memory / query_cache_size * 100
value < 80
Less than 80% of the query cache is being utilized.
@ -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 <a href="http://dev.mysql.com/doc/refman/5.0/en/internal-temporary-tables.html">MySQL Documentation</a>
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 <a href="http://dev.mysql.com/doc/refman/5.5/en/internal-temporary-tables.html">MySQL Documentation</a>
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 <a href="http://dev.mysql.com/doc/refman/5.0/en/internal-temporary-tables.html">MySQL Documentation</a>. 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 <a href="http://dev.mysql.com/doc/refman/5.5/en/internal-temporary-tables.html">MySQL Documentation</a>. 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 <a href="http://dev.mysql.com/doc/refman/5.0/en/concurrent-inserts.html">MySQL Documentation</a>
Setting {concurrent_insert} to 1 reduces contention between readers and writers for a given table. See also <a href="http://dev.mysql.com/doc/refman/5.5/en/concurrent-inserts.html">MySQL Documentation</a>
concurrent_insert is set to 0
# INSERT DELAYED USAGE

File diff suppressed because it is too large Load Diff

View File

@ -223,7 +223,7 @@ function PMA_fatalError($error_message, $message_args = null)
$GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
}
require('./libraries/error.inc.php');
require './libraries/error.inc.php';
if (!defined('TESTSUITE')) {
exit;
@ -708,13 +708,28 @@ 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
* @param bool $escape Whether to escape value or keep it as it is (for inclusion of js code)
*
*/
function PMA_AddJSVar($key, $value, $escape = true)
{
PMA_AddJsCode(PMA_getJsValue($key, $value, $escape));
}
?>

View File

@ -38,7 +38,7 @@ foreach ($plugins as $plugin) {
if ($check()) {
$_SESSION[$SESSION_KEY]["handler"] = $plugin;
include_once("import/upload/" . $plugin . ".php");
include_once "import/upload/" . $plugin . ".php";
break;
}
}

View File

@ -578,8 +578,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
echo '<input id="col_visib" type="hidden" value="' . implode(',', $col_visib) . '" />';
}
// generate table create time
echo '<input id="table_create_time" type="hidden" value="' .
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
if (! PMA_Table::isView($GLOBALS['table'], $GLOBALS['db'])) {
echo '<input id="table_create_time" type="hidden" value="' .
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
}
}

View File

@ -56,25 +56,67 @@ 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
* @param bool $escape Whether to escape value or keep it as it is (for inclusion of js code)
*
* @return string Javascript code.
*/
function PMA_getJsValue($key, $value, $escape = true)
{
$result = $key . ' = ';
if (!$escape) {
$result .= $value;
} elseif (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);
}
?>

View File

@ -47,7 +47,7 @@ if (! empty($submit_mult)
break;
case 'export':
unset($submit_mult);
require('db_export.php');
require 'db_export.php';
exit;
break;
} // end switch

View File

@ -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) {

View File

@ -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(
'<dia:attribute name="background">
<dia:color val="#ffffff"/>
</dia:attribute>
@ -85,22 +86,22 @@ class PMA_DIA extends XMLWriter
<dia:attribute name="paper">
<dia:composite type="paper">
<dia:attribute name="name">
<dia:string>#'.$paper.'#</dia:string>
<dia:string>#' . $paper . '#</dia:string>
</dia:attribute>
<dia:attribute name="tmargin">
<dia:real val="'.$topMargin.'"/>
<dia:real val="' . $topMargin . '"/>
</dia:attribute>
<dia:attribute name="bmargin">
<dia:real val="'.$bottomMargin.'"/>
<dia:real val="' . $bottomMargin . '"/>
</dia:attribute>
<dia:attribute name="lmargin">
<dia:real val="'.$leftMargin.'"/>
<dia:real val="' . $leftMargin . '"/>
</dia:attribute>
<dia:attribute name="rmargin">
<dia:real val="'.$rightMargin.'"/>
<dia:real val="' . $rightMargin . '"/>
</dia:attribute>
<dia:attribute name="is_portrait">
<dia:boolean val="'.$isPortrait.'"/>
<dia:boolean val="' . $isPortrait . '"/>
</dia:attribute>
<dia:attribute name="scaling">
<dia:real val="1"/>
@ -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(
'<dia:attribute name="obj_pos">
<dia:point val="'.($this->x * $factor).','.($this->y * $factor).'"/>
<dia:point val="'
. ($this->x * $factor) . ',' . ($this->y * $factor) . '"/>
</dia:attribute>
<dia:attribute name="obj_bb">
<dia:rectangle val="'.($this->x * $factor).','.($this->y * $factor).';9.97,9.2"/>
<dia:rectangle val="'
.($this->x * $factor) . ',' . ($this->y * $factor) . ';9.97,9.2"/>
</dia:attribute>
<dia:attribute name="meta">
<dia:composite type="dict"/>
</dia:attribute>
<dia:attribute name="elem_corner">
<dia:point val="'.($this->x * $factor).','.($this->y * $factor).'"/>
<dia:point val="'
. ($this->x * $factor) . ',' . ($this->y * $factor) . '"/>
</dia:attribute>
<dia:attribute name="elem_width">
<dia:real val="5.9199999999999999"/>
@ -332,7 +362,7 @@ class Table_Stats
<dia:real val="3.5"/>
</dia:attribute>
<dia:attribute name="text_colour">
<dia:color val="'.$this->tableColor.'"/>
<dia:color val="' . $this->tableColor . '"/>
</dia:attribute>
<dia:attribute name="line_colour">
<dia:color val="#000000"/>
@ -344,7 +374,7 @@ class Table_Stats
<dia:real val="0.10000000000000001"/>
</dia:attribute>
<dia:attribute name="name">
<dia:string>#'.$this->tableName.'#</dia:string>
<dia:string>#' . $this->tableName . '#</dia:string>
</dia:attribute>
<dia:attribute name="comment">
<dia:string>##</dia:string>
@ -379,44 +409,44 @@ class Table_Stats
<dia:attribute name="comment_font_height">
<dia:real val="0.69999999999999996"/>
</dia:attribute>'
);
);
$dia->startElement('dia:attribute');
$dia->writeAttribute('name', 'attributes');
foreach ($this->fields as $field) {
$dia->writeRaw(
'<dia:composite type="table_attribute">
<dia:attribute name="name">
<dia:string>#'.$field.'#</dia:string>
</dia:attribute>
<dia:attribute name="type">
<dia:string>##</dia:string>
</dia:attribute>
<dia:attribute name="comment">
$dia->writeRaw(
'<dia:composite type="table_attribute">
<dia:attribute name="name">
<dia:string>#' . $field . '#</dia:string>
</dia:attribute>
<dia:attribute name="type">
<dia:string>##</dia:string>
</dia:attribute>'
);
unset($pm);
$pm = 'false';
if (in_array($field, $this->primary)) {
$pm = 'true';
}
if ($field == $this->displayfield) {
$pm = 'false';
}
$dia->writeRaw(
'<dia:attribute name="primary_key">
<dia:boolean val="'.$pm.'"/>
</dia:attribute>
<dia:attribute name="nullable">
<dia:boolean val="false"/>
</dia:attribute>
<dia:attribute name="unique">
<dia:boolean val="'.$pm.'"/>
</dia:attribute>
</dia:composite>'
);
</dia:attribute>
<dia:attribute name="comment">
<dia:string>##</dia:string>
</dia:attribute>'
);
unset($pm);
$pm = 'false';
if (in_array($field, $this->primary)) {
$pm = 'true';
}
if ($field == $this->displayfield) {
$pm = 'false';
}
$dia->writeRaw(
'<dia:attribute name="primary_key">
<dia:boolean val="' . $pm . '"/>
</dia:attribute>
<dia:attribute name="nullable">
<dia:boolean val="false"/>
</dia:attribute>
<dia:attribute name="unique">
<dia:boolean val="' . $pm . '"/>
</dia:attribute>
</dia:composite>'
);
}
$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(
'<dia:object type="Database - Reference" version="0" id="'.PMA_Dia_Relation_Schema::$objectId.'">
'<dia:object type="Database - Reference" version="0" id="'
. PMA_Dia_Relation_Schema::$objectId . '">
<dia:attribute name="obj_pos">
<dia:point val="3.27,18.9198"/>
</dia:attribute>
@ -576,7 +612,7 @@ class Relation_Stats
<dia:color val="#000000"/>
</dia:attribute>
<dia:attribute name="line_colour">
<dia:color val="'.$this->referenceColor.'"/>
<dia:color val="' . $this->referenceColor . '"/>
</dia:attribute>
<dia:attribute name="line_width">
<dia:real val="0.10000000000000001"/>
@ -610,11 +646,15 @@ class Relation_Stats
<dia:real val="0.59999999999999998"/>
</dia:attribute>
<dia:connections>
<dia:connection handle="0" to="'.$this->masterTableId.'" connection="'.$this->srcConnPointsRight.'"/>
<dia:connection handle="1" to="'.$this->foreignTableId.'" connection="'.$this->destConnPointsRight.'"/>
<dia:connection handle="0" to="'
. $this->masterTableId . '" connection="'
. $this->srcConnPointsRight . '"/>
<dia:connection handle="1" to="'
. $this->foreignTableId . '" connection="'
. $this->destConnPointsRight . '"/>
</dia:connections>
</dia:object>'
);
);
}
}
@ -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()
*/

View File

@ -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 $size sets the size of the font e.g 10
*
* @return void
*
* @access public
*/
function setFont($value,$size)
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.'<br />';
$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()
*/

View File

@ -10,7 +10,6 @@
* It contains those methods which are common in them
* it works like factory pattern
*/
class PMA_Export_Relation_Schema
{
private $_pageTitle;
@ -27,8 +26,10 @@ class PMA_Export_Relation_Schema
/**
* Set Page Number
*
* @param integer value Page Number of the document to be created
* @param integer $value Page Number of the document to be created
*
* @return void
*
* @access public
*/
public function setPageNumber($value)
@ -39,8 +40,10 @@ class PMA_Export_Relation_Schema
/**
* Set Show Grid
*
* @param boolean value show grid of the document or not
* @param boolean $value show grid of the document or not
*
* @return void
*
* @access public
*/
public function setShowGrid($value)
@ -48,6 +51,13 @@ class PMA_Export_Relation_Schema
$this->showGrid = (isset($value) && $value == 'on') ? 1 : 0;
}
/**
* Sets showColor
*
* @param string $value 'on' to set the the variable
*
* @return nothing
*/
public function setShowColor($value)
{
$this->showColor = (isset($value) && $value == 'on') ? 1 : 0;
@ -56,8 +66,10 @@ class PMA_Export_Relation_Schema
/**
* Set Table Dimension
*
* @param boolean value show table co-ordinates or not
* @param boolean $value show table co-ordinates or not
*
* @return void
*
* @access public
*/
public function setTableDimension($value)
@ -68,8 +80,10 @@ class PMA_Export_Relation_Schema
/**
* Set same width of All Tables
*
* @param boolean value set same width of all tables or not
* @param boolean $value set same width of all tables or not
*
* @return void
*
* @access public
*/
public function setAllTableSameWidth($value)
@ -80,8 +94,10 @@ class PMA_Export_Relation_Schema
/**
* Set Data Dictionary
*
* @param boolean value show selected database data dictionary or not
* @param boolean $value show selected database data dictionary or not
*
* @return void
*
* @access public
*/
public function setWithDataDictionary($value)
@ -92,8 +108,10 @@ class PMA_Export_Relation_Schema
/**
* Set Show only keys
*
* @param boolean value show only keys or not
* @param boolean $value show only keys or not
*
* @return void
*
* @access public
*/
public function setShowKeys($value)
@ -104,8 +122,10 @@ class PMA_Export_Relation_Schema
/**
* Set Orientation
*
* @param string value Orientation will be portrait or landscape
* @param string $value Orientation will be portrait or landscape
*
* @return void
*
* @access public
*/
public function setOrientation($value)
@ -116,8 +136,10 @@ class PMA_Export_Relation_Schema
/**
* Set type of paper
*
* @param string value paper type can be A4 etc
* @param string $value paper type can be A4 etc
*
* @return void
*
* @access public
*/
public function setPaper($value)
@ -128,8 +150,10 @@ class PMA_Export_Relation_Schema
/**
* Set title of the page
*
* @param string value title of the page displayed at top of the document
* @param string $title title of the page displayed at top of the document
*
* @return void
*
* @access public
*/
public function setPageTitle($title)
@ -140,8 +164,10 @@ class PMA_Export_Relation_Schema
/**
* Set type of export relational schema
*
* @param string value can be pdf,svg,dia,visio,eps etc
* @param string $value can be pdf,svg,dia,visio,eps etc
*
* @return void
*
* @access public
*/
public function setExportType($value)
@ -152,22 +178,26 @@ class PMA_Export_Relation_Schema
/**
* get all tables involved or included in page
*
* @param string db name of the database
* @param integer pageNumber page number whose tables will be fetched in an array
* @param string $db name of the database
* @param integer $pageNumber page no. whose tables will be fetched in an array
*
* @return Array an array of tables
*
* @access public
*/
public function getAllTables($db,$pageNumber)
public function getAllTables($db, $pageNumber)
{
global $cfgRelation;
// Get All tables
$tab_sql = 'SELECT table_name FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$tab_sql = 'SELECT table_name FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$tab_rs = PMA_query_as_controluser($tab_sql, null, PMA_DBI_QUERY_STORE);
if (!$tab_rs || !PMA_DBI_num_rows($tab_rs) > 0) {
$this->dieSchema('',__('This page does not contain any tables!'));
$this->dieSchema('', __('This page does not contain any tables!'));
}
while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
$alltables[] = PMA_sqlAddSlashes($curr_table['table_name']);
@ -178,12 +208,15 @@ class PMA_Export_Relation_Schema
/**
* Displays an error message
*
* @param integer pageNumber ID of the chosen page
* @param string type Schema Type
* @param string error_message the error mesage
* @param integer $pageNumber ID of the chosen page
* @param string $type Schema Type
* @param string $error_message The error mesage
*
* @global array the PMA configuration array
* @global string the current database name
*
* @access public
*
* @return void
*/
function dieSchema($pageNumber, $type = '', $error_message = '')
@ -191,18 +224,19 @@ class PMA_Export_Relation_Schema
global $cfg;
global $db;
require_once './libraries/header.inc.php';
echo "<p><strong>" . __("SCHEMA ERROR: ") . $type ."</strong></p>" . "\n";
include_once './libraries/header.inc.php';
echo "<p><strong>" . __("SCHEMA ERROR: ") . $type . "</strong></p>" . "\n";
if (!empty($error_message)) {
$error_message = htmlspecialchars($error_message);
}
echo '<p>' . "\n";
echo ' ' . $error_message . "\n";
echo '</p>' . "\n";
echo '<a href="schema_edit.php?' . PMA_generate_common_url($db).'&do=selectpage&chpage='.$pageNumber.'&action_choose=0'
. '">' . __('Back') . '</a>';
echo '<a href="schema_edit.php?' . PMA_generate_common_url($db)
. '&do=selectpage&chpage=' . $pageNumber . '&action_choose=0'
. '">' . __('Back') . '</a>';
echo "\n";
require_once './libraries/footer.inc.php';
include_once './libraries/footer.inc.php';
exit();
}
}

View File

@ -5,8 +5,7 @@
* @package phpMyAdmin
*/
include_once("Export_Relation_Schema.class.php");
require_once 'Export_Relation_Schema.class.php';
require_once './libraries/PDF.class.php';
/**
@ -32,6 +31,13 @@ class PMA_Schema_PDF extends PMA_PDF
var $widths;
private $_ff = PMA_PDF_FONT;
/**
* Sets the value for margins
*
* @param float $c_margin margin
*
* @return nothing
*/
public function setCMargin($c_margin)
{
$this->cMargin = $c_margin;
@ -40,12 +46,15 @@ class PMA_Schema_PDF extends PMA_PDF
/**
* Sets the scaling factor, defines minimum coordinates and margins
*
* @param float scale The scaling factor
* @param float _xMin The minimum X coordinate
* @param float _yMin The minimum Y coordinate
* @param float leftMargin The left margin
* @param float topMargin The top margin
* @param float $scale The scaling factor
* @param float $xMin The minimum X coordinate
* @param float $yMin The minimum Y coordinate
* @param float $leftMargin The left margin
* @param float $topMargin The top margin
*
* @access public
*
* @return nothing
*/
function PMA_PDF_setScale($scale = 1, $xMin = 0, $yMin = 0, $leftMargin = -1, $topMargin = -1)
{
@ -63,14 +72,19 @@ class PMA_Schema_PDF extends PMA_PDF
/**
* Outputs a scaled cell
*
* @param float w The cell width
* @param float h The cell height
* @param string txt The text to output
* @param mixed border Whether to add borders or not
* @param integer ln Where to put the cursor once the output is done
* @param string align Align mode
* @param integer fill Whether to fill the cell with a color or not
* @param float $w The cell width
* @param float $h The cell height
* @param string $txt The text to output
* @param mixed $border Whether to add borders or not
* @param integer $ln Where to put the cursor once the output is done
* @param string $align Align mode
* @param integer $fill Whether to fill the cell with a color or not
* @param string $link Link
*
* @access public
*
* @return nothing
*
* @see TCPDF::Cell()
*/
function PMA_PDF_cellScale($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = 0, $link = '')
@ -83,11 +97,15 @@ class PMA_Schema_PDF extends PMA_PDF
/**
* Draws a scaled line
*
* @param float x1 The horizontal position of the starting point
* @param float y1 The vertical position of the starting point
* @param float x2 The horizontal position of the ending point
* @param float y2 The vertical position of the ending point
* @param float $x1 The horizontal position of the starting point
* @param float $y1 The vertical position of the starting point
* @param float $x2 The horizontal position of the ending point
* @param float $y2 The vertical position of the ending point
*
* @access public
*
* @return nothing
*
* @see TCPDF::Line()
*/
function PMA_PDF_lineScale($x1, $y1, $x2, $y2)
@ -102,9 +120,13 @@ class PMA_Schema_PDF extends PMA_PDF
/**
* Sets x and y scaled positions
*
* @param float x The x position
* @param float y The y position
* @param float $x The x position
* @param float $y The y position
*
* @access public
*
* @return nothing
*
* @see TCPDF::SetXY()
*/
function PMA_PDF_setXyScale($x, $y)
@ -117,8 +139,12 @@ class PMA_Schema_PDF extends PMA_PDF
/**
* Sets the X scaled positions
*
* @param float x The x position
* @param float $x The x position
*
* @access public
*
* @return nothing
*
* @see TCPDF::SetX()
*/
function PMA_PDF_setXScale($x)
@ -130,8 +156,12 @@ class PMA_Schema_PDF extends PMA_PDF
/**
* Sets the scaled font size
*
* @param float size The font size (in points)
* @param float $size The font size (in points)
*
* @access public
*
* @return nothing
*
* @see TCPDF::SetFontSize()
*/
function PMA_PDF_setFontSizeScale($size)
@ -145,7 +175,11 @@ class PMA_Schema_PDF extends PMA_PDF
* Sets the scaled line width
*
* @param float $width The line width
*
* @access public
*
* @return nothing
*
* @see TCPDF::SetLineWidth()
*/
function PMA_PDF_setLineWidthScale($width)
@ -154,6 +188,13 @@ class PMA_Schema_PDF extends PMA_PDF
$this->SetLineWidth($width);
}
/**
* This method is used to render the page header.
*
* @return nothing
*
* @see TCPDF::Header()
*/
function Header()
{
// We only show this if we find something in the new pdf_pages table
@ -161,9 +202,11 @@ class PMA_Schema_PDF extends PMA_PDF
// This function must be named "Header" to work with the TCPDF library
global $cfgRelation, $db, $pdf_page_number, $with_doc;
if ($with_doc) {
$test_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND page_nr = \'' . $pdf_page_number . '\'';
$test_query = 'SELECT * FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND page_nr = \'' . $pdf_page_number . '\'';
$test_rs = PMA_query_as_controluser($test_query);
$pages = @PMA_DBI_fetch_assoc($test_rs);
$this->SetFont($this->_ff, 'B', 14);
@ -175,6 +218,10 @@ class PMA_Schema_PDF extends PMA_PDF
/**
* This function must be named "Footer" to work with the TCPDF library
*
* @return nothing
*
* @see PMA_PDF::Footer()
*/
function Footer()
{
@ -184,6 +231,13 @@ class PMA_Schema_PDF extends PMA_PDF
}
}
/**
* Sets widths
*
* @param array $w array of widths
*
* @return nothing
*/
function SetWidths($w)
{
// column widths
@ -195,8 +249,9 @@ class PMA_Schema_PDF extends PMA_PDF
// line height
$nb = 0;
$data_cnt = count($data);
for ($i = 0;$i < $data_cnt;$i++)
$nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
for ($i = 0;$i < $data_cnt;$i++) {
$nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
}
$il = $this->FontSize;
$h = ($il + 1) * $nb;
// page break if necessary
@ -225,8 +280,9 @@ class PMA_Schema_PDF extends PMA_PDF
/**
* Compute number of lines used by a multicell of width w
*
* @param int $w
* @param string $txt
* @param int $w width
* @param string $txt text
*
* @return int
*/
function NbLines($w, $txt)
@ -309,18 +365,22 @@ class Table_Stats
/**
* The "Table_Stats" constructor
*
* @param string table_name The table name
* @param integer fontSize The font size
* @param integer pageNumber The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @param integer sameWideWidth The max. with 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 integer $fontSize The font size
* @param integer $pageNumber The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @param integer &$sameWideWidth The max. with 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 PDF document
* @global array The relations settings
* @global string The current db name
*
* @return nothing
*
* @see PMA_Schema_PDF, Table_Stats::Table_Stats_setWidth,
Table_Stats::Table_Stats_setHeight
* Table_Stats::Table_Stats_setHeight
*/
function __construct($tableName, $fontSize, $pageNumber, &$sameWideWidth, $showKeys = false, $showInfo = false)
{
@ -329,7 +389,7 @@ class Table_Stats
$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)) {
if (! $result || ! PMA_DBI_num_rows($result)) {
$pdf->Error(sprintf(__('The %s table doesn\'t exist!'), $tableName));
}
// load fields
@ -338,7 +398,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 {
@ -358,13 +421,19 @@ class Table_Stats
$sameWideWidth = $this->width;
}
$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)) {
$pdf->Error(sprintf(__('Please configure the coordinates for table %s'), $tableName));
if (! $result || ! PMA_DBI_num_rows($result)) {
$pdf->Error(
sprintf(
__('Please configure the coordinates for table %s'),
$tableName
)
);
}
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x;
@ -376,7 +445,10 @@ 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') {
@ -400,9 +472,14 @@ class Table_Stats
/**
* Sets the width of the table
*
* @param integer fontSize The font size
* @param integer $fontSize The font size
*
* @global object The current PDF document
*
* @access private
*
* @return nothing
*
* @see PMA_Schema_PDF
*/
private function _setWidth($fontSize)
@ -427,6 +504,8 @@ class Table_Stats
/**
* Sets the height of the table
*
* @return nothing
*
* @access private
*/
private function _setHeight()
@ -437,10 +516,16 @@ class Table_Stats
/**
* Do draw the table
*
* @param integer fontSize The font size
* @param boolean setColor Whether to display color
* @global object The current PDF document
* @param integer $fontSize The font size
* @param boolean $withDoc
* @param boolean $setColor Whether to display color
*
* @global object The current PDF document
*
* @access public
*
* @return nothing
*
* @see PMA_Schema_PDF
*/
public function tableDraw($fontSize, $withDoc, $setColor = 0)
@ -459,7 +544,16 @@ class Table_Stats
$pdf->PMA_links['doc'][$this->_tableName]['-'] = '';
}
$pdf->PMA_PDF_cellScale($this->width, $this->heightCell, $this->_getTitle(), 1, 1, 'C', $setColor, $pdf->PMA_links['doc'][$this->_tableName]['-']);
$pdf->PMA_PDF_cellScale(
$this->width,
$this->heightCell,
$this->_getTitle(),
1,
1,
'C',
$setColor,
$pdf->PMA_links['doc'][$this->_tableName]['-']
);
$pdf->PMA_PDF_setXScale($this->x);
$pdf->SetFont($this->_ff, '', $fontSize);
$pdf->SetTextColor(0);
@ -480,12 +574,23 @@ class Table_Stats
$pdf->PMA_links['doc'][$this->_tableName][$field] = '';
}
$pdf->PMA_PDF_cellScale($this->width, $this->heightCell, ' ' . $field, 1, 1, 'L', $setColor, $pdf->PMA_links['doc'][$this->_tableName][$field]);
$pdf->PMA_PDF_cellScale(
$this->width,
$this->heightCell,
' ' . $field,
1,
1,
'L',
$setColor,
$pdf->PMA_links['doc'][$this->_tableName][$field]
);
$pdf->PMA_PDF_setXScale($this->x);
$pdf->SetFillColor(255);
}
/*if ($pdf->PageNo() > 1) {
$pdf->PMA_PDF_die(__('The scale factor is too small to fit the schema on one page'));
$pdf->PMA_PDF_die(
__('The scale factor is too small to fit the schema on one page')
);
} */
}
}
@ -499,7 +604,8 @@ class Table_Stats
* in PDF document.
*
* @name Relation_Stats
* @see PMA_Schema_PDF::SetDrawColor,PMA_Schema_PDF::PMA_PDF_setLineWidthScale,PMA_Schema_PDF::PMA_PDF_lineScale
* @see PMA_Schema_PDF::SetDrawColor, PMA_Schema_PDF::PMA_PDF_setLineWidthScale,
* PMA_Schema_PDF::PMA_PDF_lineScale
*/
class Relation_Stats
{
@ -515,10 +621,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 nothing
*
* @see Relation_Stats::_getXy
*/
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
@ -569,9 +678,11 @@ 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)
@ -582,13 +693,17 @@ class Relation_Stats
}
/**
* draws relation links and arrows
* shows foreign key relations
* draws relation links and arrows shows foreign key relations
*
* @param boolean $changeColor Whether to use one color per relation or not
* @param integer $i The id of the link to draw
*
* @param boolean changeColor Whether to use one color per relation or not
* @param integer i The id of the link to draw
* @global object The current PDF document
*
* @access public
*
* @return nothing
*
* @see PMA_Schema_PDF
*/
public function relationDraw($changeColor, $i)
@ -607,7 +722,7 @@ class Relation_Stats
array(1, 1, 0),
array(1, 0, 1),
array(0, 1, 1)
);
);
list ($a, $b, $c) = $case[$d];
$e = (1 - ($j - 1) / 6);
$pdf->SetDrawColor($a * 255 * $e, $b * 255 * $e, $c * 255 * $e);
@ -615,19 +730,54 @@ class Relation_Stats
$pdf->SetDrawColor(0);
}
$pdf->PMA_PDF_setLineWidthScale(0.2);
$pdf->PMA_PDF_lineScale($this->xSrc, $this->ySrc, $this->xSrc + $this->srcDir * $this->wTick, $this->ySrc);
$pdf->PMA_PDF_lineScale($this->xDest + $this->destDir * $this->wTick, $this->yDest, $this->xDest, $this->yDest);
$pdf->PMA_PDF_lineScale(
$this->xSrc,
$this->ySrc,
$this->xSrc + $this->srcDir * $this->wTick,
$this->ySrc
);
$pdf->PMA_PDF_lineScale(
$this->xDest + $this->destDir * $this->wTick,
$this->yDest,
$this->xDest,
$this->yDest
);
$pdf->PMA_PDF_setLineWidthScale(0.1);
$pdf->PMA_PDF_lineScale($this->xSrc + $this->srcDir * $this->wTick, $this->ySrc, $this->xDest + $this->destDir * $this->wTick, $this->yDest);
$pdf->PMA_PDF_lineScale(
$this->xSrc + $this->srcDir * $this->wTick,
$this->ySrc,
$this->xDest + $this->destDir * $this->wTick,
$this->yDest
);
/*
* Draws arrows ->
*/
$root2 = 2 * sqrt(2);
$pdf->PMA_PDF_lineScale($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);
$pdf->PMA_PDF_lineScale($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);
$pdf->PMA_PDF_lineScale(
$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
);
$pdf->PMA_PDF_lineScale(
$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
);
$pdf->PMA_PDF_lineScale($this->xDest + $this->destDir * $this->wTick / 2, $this->yDest, $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick, $this->yDest + $this->wTick / $root2);
$pdf->PMA_PDF_lineScale($this->xDest + $this->destDir * $this->wTick / 2, $this->yDest, $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick, $this->yDest - $this->wTick / $root2);
$pdf->PMA_PDF_lineScale(
$this->xDest + $this->destDir * $this->wTick / 2,
$this->yDest,
$this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
$this->yDest + $this->wTick / $root2
);
$pdf->PMA_PDF_lineScale(
$this->xDest + $this->destDir * $this->wTick / 2,
$this->yDest,
$this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
$this->yDest - $this->wTick / $root2
);
$pdf->SetDrawColor(0);
}
}
@ -688,11 +838,17 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
// Initializes a new document
$pdf = new PMA_Schema_PDF($this->orientation, 'mm', $this->paper);
$pdf->SetTitle(sprintf(__('Schema of the %s database - Page %s'), $GLOBALS['db'], $this->pageNumber));
$pdf->SetTitle(
sprintf(
__('Schema of the %s database - Page %s'),
$GLOBALS['db'],
$this->pageNumber
)
);
$pdf->setCMargin(0);
$pdf->Open();
$pdf->SetAutoPageBreak('auto');
$alltables = $this->getAllTables($db,$this->pageNumber);
$alltables = $this->getAllTables($db, $this->pageNumber);
if ($this->withDoc) {
$pdf->SetAutoPageBreak('auto', 15);
@ -707,7 +863,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
if ($this->withDoc) {
$pdf->SetLink($pdf->PMA_links['RT']['-'], -1);
$pdf->Bookmark(__('Relational schema'));
$pdf->SetAlias('{00}', $pdf->PageNo()) ;
$pdf->SetAlias('{00}', $pdf->PageNo());
$this->topMargin = 28;
$this->bottomMargin = 28;
}
@ -715,7 +871,13 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/* snip */
foreach ($alltables as $table) {
if (! isset($this->tables[$table])) {
$this->tables[$table] = new Table_Stats($table, $this->_ff, $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension);
$this->tables[$table] = new Table_Stats(
$table, $this->_ff,
$this->pageNumber,
$this->_tablewidth,
$this->showKeys,
$this->tableDimension
);
}
if ($this->sameWide) {
$this->tables[$table]->width = $this->_tablewidth;
@ -727,10 +889,17 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$this->scale = ceil(
max(
($this->_xMax - $this->_xMin) / ($pdf->getPageWidth() - $this->rightMargin - $this->leftMargin),
($this->_yMax - $this->_yMin) / ($pdf->getPageHeight() - $this->topMargin - $this->bottomMargin))
* 100) / 100;
($this->_yMax - $this->_yMin) / ($pdf->getPageHeight() - $this->topMargin - $this->bottomMargin)
) * 100
) / 100;
$pdf->PMA_PDF_setScale($this->scale, $this->_xMin, $this->_yMin, $this->leftMargin, $this->topMargin);
$pdf->PMA_PDF_setScale(
$this->scale,
$this->_xMin,
$this->_yMin,
$this->leftMargin,
$this->topMargin
);
// Builds and save the PDF document
$pdf->PMA_PDF_setLineWidthScale(0.1);
@ -753,7 +922,13 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
// (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->tableDimension);
$this->_addRelation(
$one_table,
$master_field,
$rel['foreign_table'],
$rel['foreign_field'],
$this->tableDimension
);
}
} // end while
} // end if
@ -770,7 +945,10 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Sets X and Y minimum and maximum for a table cell
*
* @param string table The table name of which sets XY co-ordinates
* @param string $table The table name of which sets XY co-ordinates
*
* @return nothing
*
* @access private
*/
private function _setMinMax($table)
@ -784,32 +962,49 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Defines relation objects
*
* @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
* @param boolean show_info Whether to display table position or not
* @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
*
* @access private
*
* @return nothing
*
* @see _setMinMax
*/
private function _addRelation($masterTable, $masterField, $foreignTable, $foreignField, $showInfo)
{
if (! isset($this->tables[$masterTable])) {
$this->tables[$masterTable] = new Table_Stats($masterTable, $this->_ff, $this->pageNumber, $this->_tablewidth, false, $showInfo);
$this->tables[$masterTable] = new Table_Stats(
$masterTable, $this->_ff, $this->pageNumber,
$this->_tablewidth, false, $showInfo
);
$this->_setMinMax($this->tables[$masterTable]);
}
if (! isset($this->tables[$foreignTable])) {
$this->tables[$foreignTable] = new Table_Stats($foreignTable, $this->_ff, $this->pageNumber, $this->_tablewidth, false, $showInfo);
$this->tables[$foreignTable] = new Table_Stats(
$foreignTable, $this->_ff, $this->pageNumber,
$this->_tablewidth, false, $showInfo
);
$this->_setMinMax($this->tables[$foreignTable]);
}
$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 the grid
*
* @global object the current PMA_Schema_PDF instance
*
* @access private
*
* @return nothing
*
* @see PMA_Schema_PDF
*/
private function _strokeGrid()
@ -831,19 +1026,35 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$pdf->SetDrawColor(200, 200, 200);
// Draws horizontal lines
for ($l = 0; $l <= intval(($pdf->getPageHeight() - $topSpace - $bottomSpace) / $gridSize); $l++) {
$pdf->line(0, $l * $gridSize + $topSpace, $pdf->getPageWidth(), $l * $gridSize + $topSpace);
$pdf->line(
0, $l * $gridSize + $topSpace,
$pdf->getPageWidth(), $l * $gridSize + $topSpace
);
// Avoid duplicates
if ($l > 0 && $l <= intval(($pdf->getPageHeight() - $topSpace - $bottomSpace - $labelHeight) / $gridSize)) {
if ($l > 0
&& $l <= intval(($pdf->getPageHeight() - $topSpace - $bottomSpace - $labelHeight) / $gridSize)
) {
$pdf->SetXY(0, $l * $gridSize + $topSpace);
$label = (string) sprintf('%.0f', ($l * $gridSize + $topSpace - $this->topMargin) * $this->scale + $this->_yMin);
$label = (string) sprintf(
'%.0f',
($l * $gridSize + $topSpace - $this->topMargin) * $this->scale + $this->_yMin
);
$pdf->Cell($labelWidth, $labelHeight, ' ' . $label);
} // end if
} // end for
// Draws vertical lines
for ($j = 0; $j <= intval($pdf->getPageWidth() / $gridSize); $j++) {
$pdf->line($j * $gridSize, $topSpace, $j * $gridSize, $pdf->getPageHeight() - $bottomSpace);
$pdf->line(
$j * $gridSize,
$topSpace,
$j * $gridSize,
$pdf->getPageHeight() - $bottomSpace
);
$pdf->SetXY($j * $gridSize, $topSpace);
$label = (string) sprintf('%.0f', ($j * $gridSize - $this->leftMargin) * $this->scale + $this->_xMin);
$label = (string) sprintf(
'%.0f',
($j * $gridSize - $this->leftMargin) * $this->scale + $this->_xMin
);
$pdf->Cell($labelWidth, $labelHeight, $label);
}
}
@ -851,8 +1062,12 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Draws relation arrows
*
* @param boolean changeColor Whether to use one color per relation or not
* @param boolean $changeColor Whether to use one color per relation or not
*
* @access private
*
* @return nothing
*
* @see Relation_Stats::relationdraw()
*/
private function _drawRelations($changeColor)
@ -867,8 +1082,12 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Draws tables
*
* @param boolean changeColor Whether to display table position or not
* @param boolean $changeColor Whether to display table position or not
*
* @access private
*
* @return nothing
*
* @see Table_Stats::tableDraw()
*/
private function _drawTables($changeColor = 0)
@ -882,11 +1101,16 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
* Ouputs the PDF document to a file
* or sends the output to browser
*
* @param integer $pageNumber page number
*
* @global object The current PDF document
* @global string The current database name
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* $cfg['Servers'][$i]['table_coords'] table)
* @access private
*
* @return nothing
*
* @see PMA_Schema_PDF
*/
private function _showOutput($pageNumber)
@ -894,8 +1118,10 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
global $pdf, $db, $cfgRelation;
// Get the name of this pdfpage to use as filename
$_name_sql = 'SELECT page_descr FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE page_nr = ' . $pageNumber;
$_name_sql = 'SELECT page_descr FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE page_nr = ' . $pageNumber;
$_name_rs = PMA_query_as_controluser($_name_sql);
if ($_name_rs) {
$_name_row = PMA_DBI_fetch_row($_name_rs);
@ -919,36 +1145,54 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink();
$pdf->SetX(10);
// $pdf->Ln(1);
$pdf->Cell(0, 6, __('Page number:') . ' {' . sprintf("%02d", $i) . '}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$table]['-']);
$pdf->Cell(
0, 6, __('Page number:') . ' {' . sprintf("%02d", $i) . '}', 0, 0,
'R', 0, $pdf->PMA_links['doc'][$table]['-']
);
$pdf->SetX(10);
$pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links['doc'][$table]['-']);
$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();
// $pdf->Cell(0, 6, $field_name,0,1,'L',0, $pdf->PMA_links['doc'][$table][$field_name]);
//$pdf->Cell(
// 0, 6, $field_name, 0, 1,
// 'L', 0, $pdf->PMA_links['doc'][$table][$field_name]
//);
}
$lasttable = $table;
$i++;
}
$pdf->PMA_links['RT']['-'] = $pdf->AddLink();
$pdf->SetX(10);
$pdf->Cell(0, 6, __('Page number:') . ' {00}', 0, 0, 'R', 0, $pdf->PMA_links['RT']['-']);
$pdf->Cell(
0, 6, __('Page number:') . ' {00}', 0, 0,
'R', 0, $pdf->PMA_links['RT']['-']
);
$pdf->SetX(10);
$pdf->Cell(0, 6, $i . ' ' . __('Relational schema'), 0, 1, 'L', 0, $pdf->PMA_links['RT']['-']);
$pdf->Cell(
0, 6, $i . ' ' . __('Relational schema'), 0, 1,
'L', 0, $pdf->PMA_links['RT']['-']
);
$z = 0;
foreach ($alltables as $table) {
$z++;
$pdf->SetAutoPageBreak(true, 15);
$pdf->addpage($GLOBALS['orientation']);
$pdf->Bookmark($table);
$pdf->SetAlias('{' . sprintf("%02d", $z) . '}', $pdf->PageNo()) ;
$pdf->SetAlias('{' . sprintf("%02d", $z) . '}', $pdf->PageNo());
$pdf->PMA_links['RT'][$table]['-'] = $pdf->AddLink();
$pdf->SetLink($pdf->PMA_links['doc'][$table]['-'], -1);
$pdf->SetFont($this->_ff, 'B', 18);
$pdf->Cell(0, 8, $z . ' ' . $table, 1, 1, 'C', 0, $pdf->PMA_links['RT'][$table]['-']);
$pdf->Cell(
0, 8, $z . ' ' . $table, 1, 1,
'C', 0, $pdf->PMA_links['RT'][$table]['-']
);
$pdf->SetFont($this->_ff, '', 8);
$pdf->ln();
@ -962,11 +1206,21 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
* Gets table informations
*/
$showtable = PMA_Table::sGetStatusInfo($db, $table);
$num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
$show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
$create_time = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : '');
$update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '');
$check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '');
$num_rows = isset($showtable['Rows'])
? $showtable['Rows']
: 0;
$show_comment = isset($showtable['Comment'])
? $showtable['Comment']
: '';
$create_time = isset($showtable['Create_time'])
? PMA_localisedDate(strtotime($showtable['Create_time']))
: '';
$update_time = isset($showtable['Update_time'])
? PMA_localisedDate(strtotime($showtable['Update_time']))
: '';
$check_time = isset($showtable['Check_time'])
? PMA_localisedDate(strtotime($showtable['Check_time']))
: '';
/**
* Gets table keys and retains them
@ -996,7 +1250,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
}
// I don't know what does following column mean....
// $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
// $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
$indexes_info[$row['Key_name']]['Comment'] = $row['Comment'];
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
@ -1032,22 +1286,22 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
*/
$break = false;
if (!empty($show_comment)) {
if (! empty($show_comment)) {
$pdf->Cell(0, 3, __('Table comments') . ' : ' . $show_comment, 0, 1);
$break = true;
}
if (!empty($create_time)) {
if (! empty($create_time)) {
$pdf->Cell(0, 3, __('Creation') . ': ' . $create_time, 0, 1);
$break = true;
}
if (!empty($update_time)) {
if (! empty($update_time)) {
$pdf->Cell(0, 3, __('Last update') . ': ' . $update_time, 0, 1);
$break = true;
}
if (!empty($check_time)) {
if (! empty($check_time)) {
$pdf->Cell(0, 3, __('Last check') . ': ' . $check_time, 0, 1);
$break = true;
}
@ -1095,8 +1349,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
foreach ($columns as $row) {
$extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
$type = $extracted_fieldspec['print_type'];
$attribute = $extracted_fieldspec['attribute'];
$type = $extracted_fieldspec['print_type'];
$attribute = $extracted_fieldspec['attribute'];
if (! isset($row['Default'])) {
if ($row['Null'] != '' && $row['Null'] != 'NO') {
$row['Default'] = 'NULL';
@ -1107,22 +1361,28 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$pdf->PMA_links['RT'][$table][$field_name] = $pdf->AddLink();
$pdf->Bookmark($field_name, 1, -1);
$pdf->SetLink($pdf->PMA_links['doc'][$table][$field_name], -1);
$pdf_row = array($field_name,
$pdf_row = array(
$field_name,
$type,
$attribute,
($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes'),
((isset($row['Default'])) ? $row['Default'] : ''),
(isset($row['Default']) ? $row['Default'] : ''),
$row['Extra'],
((isset($res_rel[$field_name])) ? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : ''),
((isset($comments[$field_name])) ? $comments[$field_name] : ''),
((isset($mime_map) && isset($mime_map[$field_name])) ? str_replace('_', '/', $mime_map[$field_name]['mimetype']) : '')
);
(isset($res_rel[$field_name])
? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field']
: ''),
(isset($comments[$field_name])
? $comments[$field_name]
: ''),
(isset($mime_map) && isset($mime_map[$field_name])
? str_replace('_', '/', $mime_map[$field_name]['mimetype'])
: '')
);
$links[0] = $pdf->PMA_links['RT'][$table][$field_name];
if (isset($res_rel[$field_name]['foreign_table']) AND
isset($res_rel[$field_name]['foreign_field']) AND
isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])
)
{
if (isset($res_rel[$field_name]['foreign_table'])
AND isset($res_rel[$field_name]['foreign_field'])
AND isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])
) {
$links[6] = $pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']];
} else {
unset($links[6]);

View File

@ -5,7 +5,7 @@
* @package phpMyAdmin
*/
include_once("Export_Relation_Schema.class.php");
require_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_SVG extends XMLWriter
{
public $title;
@ -44,15 +43,19 @@ class PMA_SVG extends XMLWriter
* Create the XML document
*/
$this->startDocument('1.0','UTF-8');
$this->startDtd('svg','-//W3C//DTD SVG 1.1//EN','http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
$this->startDocument('1.0', 'UTF-8');
$this->startDtd(
'svg', '-//W3C//DTD SVG 1.1//EN',
'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'
);
$this->endDtd();
}
/**
* Set document title
*
* @param string value sets the title text
* @param string $value sets the title text
*
* @return void
* @access public
*/
@ -64,7 +67,8 @@ class PMA_SVG extends XMLWriter
/**
* Set document author
*
* @param string value sets the author
* @param string $value sets the author
*
* @return void
* @access public
*/
@ -76,7 +80,8 @@ class PMA_SVG extends XMLWriter
/**
* Set document font
*
* @param string value sets the font e.g Arial, Sans-serif etc
* @param string $value sets the font e.g Arial, Sans-serif etc
*
* @return void
* @access public
*/
@ -99,7 +104,8 @@ class PMA_SVG extends XMLWriter
/**
* Set document font size
*
* @param string value sets the font size in pixels
* @param string $value sets the font size in pixels
*
* @return void
* @access public
*/
@ -126,10 +132,12 @@ class PMA_SVG extends XMLWriter
* which contains all the attributes and namespace that needed
* to define the svg document
*
* @param integer width total width of the Svg document
* @param integer height total height of the Svg document
* @param integer $width total width of the Svg document
* @param integer $height total height of the Svg document
*
* @return void
* @access public
*
* @see XMLWriter::startElement(),XMLWriter::writeAttribute()
*/
function startSvgDoc($width,$height)
@ -161,6 +169,8 @@ class PMA_SVG extends XMLWriter
* Svg document saved in .svg extension and can be
* easily changeable by using any svg IDE
*
* @param string $fileName file name
*
* @return void
* @access public
* @see XMLWriter::startElement(),XMLWriter::writeAttribute()
@ -180,31 +190,32 @@ class PMA_SVG extends XMLWriter
* and other elements who have x,y co-ordinates are drawn.
* specify their width and height and can give styles too.
*
* @param string name Svg element name
* @param integer x The x attribute defines the left position of the element
(e.g. x="0" places the element 0 pixels from the left of
the browser window)
* @param integer y The y attribute defines the top position of the element
(e.g. y="0" places the element 0 pixels from the top of
the browser window)
* @param integer width The width attribute defines the width the element
* @param integer height The height attribute defines the height the element
* @param string text The text attribute defines the text the element
* @param string styles The style attribute defines the style the element
styles can be defined like CSS styles
* @param string $name Svg element name
* @param integer $x The x attr defines the left position of the element
* (e.g. x="0" places the element 0 pixels from the left of the browser window)
* @param integer $y The y attribute defines the top position of the element
* (e.g. y="0" places the element 0 pixels from the top of the browser window)
* @param integer $width The width attribute defines the width the element
* @param integer $height The height attribute defines the height the element
* @param string $text The text attribute defines the text the element
* @param string $styles The style attribute defines the style the element
* styles can be defined like CSS styles
*
* @return void
* @access public
* @see XMLWriter::startElement(),XMLWriter::writeAttribute(),XMLWriter::text(),XMLWriter::endElement()
*
* @see XMLWriter::startElement(), XMLWriter::writeAttribute(),
* XMLWriter::text(), XMLWriter::endElement()
*/
function printElement($name,$x,$y,$width = '',$height = '',$text = '',$styles = '')
function printElement($name, $x, $y, $width = '', $height = '', $text = '', $styles = '')
{
$this->startElement($name);
$this->writeAttribute('width',$width);
$this->writeAttribute('height',$height);
$this->writeAttribute('width', $width);
$this->writeAttribute('height', $height);
$this->writeAttribute('x', $x);
$this->writeAttribute('y', $y);
$this->writeAttribute('style', $styles);
if(isset($text)){
if (isset($text)) {
$this->writeAttribute('font-family', $this->font);
$this->writeAttribute('font-size', $this->fontSize);
$this->text($text);
@ -219,22 +230,25 @@ class PMA_SVG extends XMLWriter
* arrows are also drawn by specify its start and ending
* co-ordinates
*
* @param string name Svg element name i.e line
* @param integer x1 The x1 attribute defines the start of the line on the x-axis
* @param integer y1 The y1 attribute defines the start of the line on the y-axis
* @param integer x2 The x2 attribute defines the end of the line on the x-axis
* @param integer y2 The y2 attribute defines the end of the line on the y-axis
* @param string styles The style attribute defines the style the element
styles can be defined like CSS styles
* @param string $name Svg element name i.e line
* @param integer $x1 Defines the start of the line on the x-axis
* @param integer $y1 Defines the start of the line on the y-axis
* @param integer $x2 Defines the end of the line on the x-axis
* @param integer $y2 Defines the end of the line on the y-axis
* @param string $styles The style attribute defines the style the element
* styles can be defined like CSS styles
*
* @return void
* @access public
* @see XMLWriter::startElement(),XMLWriter::writeAttribute(),XMLWriter::endElement()
*
* @see XMLWriter::startElement(), XMLWriter::writeAttribute(),
* XMLWriter::endElement()
*/
function printElementLine($name,$x1,$y1,$x2,$y2,$styles)
{
$this->startElement($name);
$this->writeAttribute('x1',$x1);
$this->writeAttribute('y1',$y1);
$this->writeAttribute('x1', $x1);
$this->writeAttribute('y1', $y1);
$this->writeAttribute('x2', $x2);
$this->writeAttribute('y2', $y2);
$this->writeAttribute('style', $styles);
@ -250,9 +264,10 @@ class PMA_SVG extends XMLWriter
*
* This is a bit hardcore method. I didn't found any other than this.
*
* @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
*/
@ -262,22 +277,22 @@ class PMA_SVG extends XMLWriter
* 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);
@ -287,7 +302,7 @@ class PMA_SVG extends XMLWriter
*/
case 'arial':
case 'sans-serif':
break;
break;
/*
* .92 modifer for time, serif, brushscriptstd, and californian fb
*/
@ -296,13 +311,13 @@ class PMA_SVG extends XMLWriter
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);
@ -338,29 +353,39 @@ class Table_Stats
/**
* The "Table_Stats" constructor
*
* @param string table_name The table name
* @param integer ff The font size
* @param integer samewidth The max. with among tables
* @param boolean show_keys Whether to display keys or not
* @param boolean show_info Whether to display table position or not
* @param string $tableName The table name
* @param string $font Font face
* @param integer $fontSize The font size
* @param integer $pageNumber Page number
* @param integer &$same_wide_width The max. with 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 SVG image document
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* $cfg['Servers'][$i]['table_coords'] table)
* @global array The relations settings
* @global string The current db name
*
* @access private
*
* @see PMA_SVG, 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 $svg, $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)) {
$svg->dieSchema($pageNumber,"SVG",sprintf(__('The %s table doesn\'t exist!'), $tableName));
if (! $result || ! PMA_DBI_num_rows($result)) {
$svg->dieSchema(
$pageNumber,
"SVG",
sprintf(__('The %s table doesn\'t exist!'), $tableName)
);
}
/*
@ -372,7 +397,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 {
@ -388,21 +416,29 @@ 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'])
. 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)) {
$svg->dieSchema($pageNumber,"SVG",sprintf(__('Please configure the coordinates for table %s'), $tableName));
$svg->dieSchema(
$pageNumber,
"SVG",
sprintf(
__('Please configure the coordinates for table %s'),
$tableName
)
);
}
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x;
@ -410,7 +446,11 @@ 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') {
@ -428,16 +468,23 @@ 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 size
* @param integer fontSize The font size
* @param string $font The font size
* @param integer $fontSize The font size
*
* @global object The current SVG image document
*
* @return nothing
* @access private
*
* @see PMA_SVG
*/
private function _setWidthTable($font,$fontSize)
@ -445,14 +492,18 @@ class Table_Stats
global $svg;
foreach ($this->fields as $field) {
$this->width = max($this->width, $svg->getStringWidth($field,$font,$fontSize));
$this->width = max(
$this->width,
$svg->getStringWidth($field, $font, $fontSize)
);
}
$this->width += $svg->getStringWidth(' ',$font,$fontSize);
$this->width += $svg->getStringWidth(' ', $font, $fontSize);
/*
* it is unknown what value must be added, because
* table title is affected by the tabe width value
*/
while ($this->width < $svg->getStringWidth($this->_getTitle(),$font,$fontSize)) {
while ($this->width < $svg->getStringWidth($this->_getTitle(), $font, $fontSize)) {
$this->width += 7;
}
}
@ -460,6 +511,9 @@ class Table_Stats
/**
* Sets the height of the table
*
* @param integer $fontSize font size
*
* @return nothing
* @access private
*/
function _setHeightTable($fontSize)
@ -471,45 +525,46 @@ class Table_Stats
/**
* draw the table
*
* @param boolean showColor Whether to display color
* @param boolean $showColor Whether to display color
*
* @global object The current SVG image document
*
* @access public
* @return nothing
*
* @see PMA_SVG,PMA_SVG::printElement
*/
public function tableDraw($showColor)
{
global $svg;
//echo $this->_tableName.'<br />';
$svg->printElement('rect',$this->x,$this->y,
$this->width,$this->heightCell,
NULL,'fill:red;stroke:black;'
);
$svg->printElement('text',$this->x + 5,$this->y+ 14,
$this->width,$this->heightCell,
$this->_getTitle(),
'fill:none;stroke:black;'
);
$svg->printElement(
'rect', $this->x, $this->y, $this->width,
$this->heightCell, null, 'fill:red;stroke:black;'
);
$svg->printElement(
'text', $this->x + 5, $this->y+ 14, $this->width, $this->heightCell,
$this->_getTitle(), 'fill:none;stroke:black;'
);
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';
}
$svg->printElement('rect', $this->x,$this->y + $this->currentCell,
$this->width, $this->heightCell,
NULL,
'fill:'.$showColor.';stroke:black;'
);
$svg->printElement('text', $this->x + 5, $this->y + 14 + $this->currentCell,
$this->width, $this->heightCell,
$field,
'fill:none;stroke:black;'
);
if ($field == $this->displayfield) {
$showColor = 'none';
}
}
$svg->printElement(
'rect', $this->x, $this->y + $this->currentCell, $this->width,
$this->heightCell, null, 'fill:'.$showColor.';stroke:black;'
);
$svg->printElement(
'text', $this->x + 5, $this->y + 14 + $this->currentCell,
$this->width, $this->heightCell, $field, 'fill:none;stroke:black;'
);
}
}
}
@ -540,10 +595,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 nothing
*
* @see Relation_Stats::_getXy
*/
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
@ -594,8 +652,9 @@ 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
*/
@ -603,16 +662,23 @@ class Relation_Stats
{
$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
* 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 SVG image document
* @param boolean $changeColor Whether to use one color per relation or not
*
* @global object The current SVG image document
*
* @return nothing
* @access public
*
* @see PMA_SVG
*/
public function relationDraw($changeColor)
@ -635,38 +701,46 @@ class Relation_Stats
$color = 'black';
}
$svg->printElementLine('line',$this->xSrc,$this->ySrc,
$this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
'fill:'.$color.';stroke:black;stroke-width:2;'
);
$svg->printElementLine('line',$this->xDest + $this->destDir * $this->wTick, $this->yDest,
$this->xDest, $this->yDest,
'fill:'.$color.';stroke:black;stroke-width:2;'
);
$svg->printElementLine('line',$this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
$svg->printElementLine(
'line', $this->xSrc, $this->ySrc,
$this->xSrc + $this->srcDir * $this->wTick, $this->ySrc,
'fill:' . $color . ';stroke:black;stroke-width:2;'
);
$svg->printElementLine(
'line', $this->xDest + $this->destDir * $this->wTick,
$this->yDest, $this->xDest, $this->yDest,
'fill:' . $color . ';stroke:black;stroke-width:2;'
);
$svg->printElementLine(
'line', $this->xSrc + $this->srcDir * $this->wTick, $this->ySrc,
$this->xDest + $this->destDir * $this->wTick, $this->yDest,
'fill:'.$color.';stroke:'.$color.';stroke-width:1;'
);
'fill:' . $color . ';stroke:' . $color . ';stroke-width:1;'
);
$root2 = 2 * sqrt(2);
$svg->printElementLine('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 ,
'fill:'.$color.';stroke:black;stroke-width:2;'
);
$svg->printElementLine('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 ,
'fill:'.$color.';stroke:black;stroke-width:2;'
);
$svg->printElementLine('line',$this->xDest + $this->destDir * $this->wTick / 2 , $this->yDest ,
$svg->printElementLine(
'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,
'fill:' . $color . ';stroke:black;stroke-width:2;'
);
$svg->printElementLine(
'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,
'fill:' . $color . ';stroke:black;stroke-width:2;'
);
$svg->printElementLine(
'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 ,
'fill:'.$color.';stroke:black;stroke-width:2;');
$svg->printElementLine('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 ,
'fill:'.$color.';stroke:black;stroke-width:2;'
);
$this->yDest + $this->wTick / $root2,
'fill:' . $color . ';stroke:black;stroke-width:2;'
);
$svg->printElementLine(
'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,
'fill:' . $color . ';stroke:black;stroke-width:2;'
);
}
}
/*
@ -724,22 +798,31 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
$this->setExportType($_POST['export_type']);
$svg = new PMA_SVG();
$svg->setTitle(sprintf(__('Schema of the %s database - Page %s'), $db, $this->pageNumber));
$svg->setTitle(
sprintf(
__('Schema of the %s database - Page %s'),
$db,
$this->pageNumber
)
);
$svg->SetAuthor('phpMyAdmin ' . PMA_VERSION);
$svg->setFont('Arial');
$svg->setFontSize('16px');
$svg->startSvgDoc('1000px','1000px');
$alltables = $this->getAllTables($db,$this->pageNumber);
$svg->startSvgDoc('1000px', '1000px');
$alltables = $this->getAllTables($db, $this->pageNumber);
foreach ($alltables AS $table) {
if (! isset($this->tables[$table])) {
$this->tables[$table] = new Table_Stats($table,$svg->getFont(),$svg->getFontSize(), $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension);
$this->tables[$table] = new Table_Stats(
$table, $svg->getFont(), $svg->getFontSize(), $this->pageNumber,
$this->_tablewidth, $this->showKeys, $this->tableDimension
);
}
if ($this->sameWide) {
$this->tables[$table]->width = $this->_tablewidth;
}
$this->_setMinMax($this->tables[$table]);
$this->_setMinMax($this->tables[$table]);
}
$seen_a_relation = false;
foreach ($alltables as $one_table) {
@ -753,7 +836,11 @@ class PMA_Svg_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,$svg->getFont(),$svg->getFontSize(), $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->tableDimension);
$this->_addRelation(
$one_table, $svg->getFont(), $svg->getFontSize(),
$master_field, $rel['foreign_table'],
$rel['foreign_field'], $this->tableDimension
);
}
}
}
@ -771,7 +858,9 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Sets X and Y minimum and maximum for a table cell
*
* @param string table The table name
* @param string $table The table name
*
* @return nothing
* @access private
*/
private function _setMinMax($table)
@ -785,25 +874,40 @@ class PMA_Svg_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 face
* @param int $fontSize 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
*
* @access private
* @return nothing
*
* @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
);
$this->_setMinMax($this->tables[$masterTable]);
}
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->_setMinMax($this->tables[$foreignTable]);
}
$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
);
}
/**
@ -811,8 +915,11 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
* 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 nothing
* @access private
*
* @see Relation_Stats::relationDraw()
*/
private function _drawRelations($changeColor)
@ -825,8 +932,11 @@ class PMA_Svg_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 nothing
* @access private
*
* @see Table_Stats::Table_Stats_tableDraw()
*/
private function _drawTables($changeColor)

View File

@ -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;
?>
<script type="text/javascript" src="./js/dom-drag.js"></script>
<form method="post" action="schema_edit.php" name="dragdrop">
@ -505,22 +505,14 @@ class PMA_User_Schema
$reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
$reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . (15 * $i) . '"' . "\n";
$local_query = 'SHOW FIELDS FROM '
. PMA_backquote($temp_sh_page['table_name'])
. ' FROM ' . PMA_backquote($db);
$fields_rs = PMA_DBI_query($local_query);
unset($local_query);
$fields_cnt = PMA_DBI_num_rows($fields_rs);
echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
if (isset($with_field_names)) {
while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
echo '<br />' . htmlspecialchars($row['Field']) . "\n";
$fields = PMA_DBI_get_columns($db, $temp_sh_page['table_name']);
foreach ($fields as $row) {
echo '<br />' . htmlspecialchars($row['Field']) . "\n";
}
}
echo '</div>' . "\n";
PMA_DBI_free_result($fields_rs);
unset($fields_rs);
$i++;
}
?>
@ -593,7 +585,7 @@ class PMA_User_Schema
PMA_DBI_select_db($db);
include("./libraries/schema/".ucfirst($export_type)."_Relation_Schema.class.php");
include "./libraries/schema/".ucfirst($export_type)."_Relation_Schema.class.php";
$obj_schema = eval("new PMA_".ucfirst($export_type)."_Relation_Schema();");
}

View File

@ -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

View File

@ -213,9 +213,7 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
// Get the list and number of fields
// we do a try_query here, because we could be in the query window,
// trying to synchonize and the table has not yet been created
$fields_list = PMA_DBI_fetch_result(
'SHOW FULL COLUMNS FROM ' . PMA_backquote($db)
. '.' . PMA_backquote($GLOBALS['table']));
$fields_list = PMA_DBI_get_columns($db, $GLOBALS['table'], true);
$tmp_db_link = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
. '?' . PMA_generate_common_url($db) . '"';

View File

@ -101,7 +101,7 @@ if (false !== $possibly_uploaded_val) {
}
// The Null checkbox was unchecked for this field
if (empty($val) && isset($me_fields_null_prev[$key]) && ! isset($me_fields_null[$key])) {
if (empty($val) && ! empty($me_fields_null_prev[$key]) && ! isset($me_fields_null[$key])) {
$val = "''";
}
} // end else (field value in the form)

View File

@ -11,72 +11,64 @@
require_once 'url_generating.lib.php';
/**
* PMA_tbl_setTitle() sets the title for foreign keys display link
/**
* Sets the title for foreign keys display link.
*
* @param $propertiesIconic Type of icon property
* @param $themeImage Icon Image
* @return string $str Value of the Title
* @param mixed $propertiesIconic Type of icon property
* @param string $pmaThemeImage Icon Image
*
* @return string $str Value of the Title
*/
function PMA_tbl_setTitle($propertiesIconic,$pmaThemeImage){
function PMA_tbl_setTitle($propertiesIconic, $pmaThemeImage)
{
if ($propertiesIconic == true) {
$str = '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
.'b_browse.png" alt="' . __('Browse foreign values') . '" title="'
. __('Browse foreign values') . '" />';
.'b_browse.png" alt="' . __('Browse foreign values') . '" title="'
. __('Browse foreign values') . '" />';
if ($propertiesIconic === 'both') {
$str .= __('Browse foreign values');
return $str;
}
} else {
return __('Browse foreign values');
}
if ($propertiesIconic === 'both') {
$str .= __('Browse foreign values');
}
return $str;
} else {
return __('Browse foreign values');
}
}
/**
* PMA_tbl_getFields() gets all the fields of a table along with their types,collations and whether null or not.
/**
* Gets all the fields of a table along with their types, collations
* and whether null or not.
*
* @uses PMA_DBI_query()
* @uses PMA_backquote()
* @uses PMA_DBI_num_rows()
* @uses PMA_DBI_fetch_assoc()
* @uses PMA_DBI_free_result()
* @uses preg_replace()
* @uses str_replace()
* @uses strncasecmp()
* @uses empty()
*
* @param $db Selected database
* @param $table Selected table
*
* @return array($fields_list,$fields_type,$fields_collation,$fields_null) Array containing the field list, field types, collations and null constatint
* @param string $table Selected table
* @param string $db Selected database
*
* @return array Array containing the field list, field types, collations
* and null constraint
*/
function PMA_tbl_getFields($table,$db) {
function PMA_tbl_getFields($table,$db)
{
// Gets the list and number of fields
$result = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($result);
$fields = PMA_DBI_get_columns($db, $table, true);
$fields_list = $fields_null = $fields_type = $fields_collation = array();
$geom_column_present = false;
$geom_types = PMA_getGISDatatypes();
while ($row = PMA_DBI_fetch_assoc($result)) {
foreach ($fields as $row) {
$fields_list[] = $row['Field'];
$type = $row['Type'];
// check whether table contains geometric columns
if (in_array($type, $geom_types)) {
$geom_column_present = true;
}
// reformat mysql query output
if (strncasecmp($type, 'set', 3) == 0
|| strncasecmp($type, 'enum', 4) == 0) {
|| strncasecmp($type, 'enum', 4) == 0
) {
$type = str_replace(',', ', ', $type);
} else {
// strip the "BINARY" attribute, except if we find "BINARY(" because
// this would be a BINARY or VARBINARY field type
if (!preg_match('@BINARY[\(]@i', $type)) {
@ -92,53 +84,49 @@ function PMA_tbl_getFields($table,$db) {
}
$fields_null[] = $row['Null'];
$fields_type[] = $type;
$fields_collation[] = !empty($row['Collation']) && $row['Collation'] != 'NULL'
? $row['Collation']
: '';
$fields_collation[] = ! empty($row['Collation']) && $row['Collation'] != 'NULL'
? $row['Collation']
: '';
} // end while
PMA_DBI_free_result($result);
unset($result, $type);
return array($fields_list,$fields_type,$fields_collation,$fields_null, $geom_column_present);
return array($fields_list, $fields_type, $fields_collation, $fields_null, $geom_column_present);
}
/* PMA_tbl_setTableHeader() sets the table header for displaying a table in query-by-example format
/**
* Sets the table header for displaying a table in query-by-example format.
*
* @return HTML content, the tags and content for table header
* @param bool $geom_column_present whether a geometry column is present
*
* @return HTML content, the tags and content for table header
*/
function PMA_tbl_setTableHeader($geom_column_present = false){
function PMA_tbl_setTableHeader($geom_column_present = false)
{
// Display the Function column only if there is alteast one geomety colum
$func = '';
if ($geom_column_present) {
$func = '<th>' . __('Function') . '</th>';
}
return '<thead>
return '<thead>
<tr>' . $func . '<th>' . __('Column') . '</th>
<th>' . __('Type') . '</th>
<th>' . __('Collation') . '</th>
<th>' . __('Operator') . '</th>
<th>' . __('Value') . '</th>
</tr>
</tr>
</thead>';
}
/* PMA_tbl_getSubTabs() returns an array with necessary configrations to create sub-tabs(Table Search and Zoom Search) in the table_select page
*
* @return array $subtabs Array containing configuration (icon,text,link,id,args) of sub-tabs for Table Search and Zoom search
/**
* Returns an array with necessary configrations to create
* sub-tabs(Table Search and Zoom Search) in the table_select page.
*
* @return array Array containing configuration (icon, text, link, id, args)
* of sub-tabs for Table Search and Zoom search
*/
function PMA_tbl_getSubTabs(){
function PMA_tbl_getSubTabs()
{
$subtabs = array();
$subtabs['search']['icon'] = 'b_search.png';
$subtabs['search']['text'] = __('Table Search');
$subtabs['search']['link'] = 'tbl_select.php';
@ -151,74 +139,65 @@ function PMA_tbl_getSubTabs(){
$subtabs['zoom']['id'] = 'zoom_search_id';
return $subtabs;
}
/* PMA_tbl_getForeignFields_Values() creates the HTML content for: 1) Browsing foreign data for a field. 2) Creating elements for search criteria input on fields.
/**
* Creates the HTML content for:
* 1) Browsing foreign data for a field.
* 2) Creating elements for search criteria input on fields.
*
* @uses PMA_foreignDropdown
* @uses PMA_generate_common_url
* @uses isset()
* @uses is_array()
* @uses in_array()
* @uses urlencode()
* @uses str_replace()
* @uses stbstr()
*
* @param $foreigners Array of foreign keys
* @param $foreignData Foreign keys data
* @param $field Column name
* @param $tbl_fields_type Column type
* @param $i Column index
* @param $db Selected database
* @param $table Selected table
* @param $titles Selected title
* @param $foreignMaxLimit Max limit of displaying foreign elements
* @param $fields Array of search criteria inputs
* @param $in_fbs In function based search
*
* @return string $str HTML content for viewing foreing data and elements for search criteria input.
* @param array $foreigners Array of foreign keys
* @param array $foreignData Foreign keys data
* @param string $field Column name
* @param string $tbl_fields_type Column type
* @param int $i Column index
* @param string $db Selected database
* @param string $table Selected table
* @param array $titles Selected title
* @param int $foreignMaxLimit Max limit of displaying foreign elements
* @param array $fields Array of search criteria inputs
* @param bool $in_fbs Whether we are in 'function based search'
*
* @return string HTML content for viewing foreing data and elements
* for search criteria input.
*/
function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false){
function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false)
{
$str = '';
if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) {
// f o r e i g n k e y s
$str .= ' <select name="fields[' . $i . ']" id="fieldID_' . $i .'">' . "\n";
$str .= '<select name="fields[' . $i . ']" id="fieldID_' . $i .'">' . "\n";
// go back to first row
// here, the 4th parameter is empty because there is no current
// value of data for the dropdown (the search page initial values
// are displayed empty)
$str .= PMA_foreignDropdown($foreignData['disp_row'],
$foreignData['foreign_field'],
$foreignData['foreign_display'],
'', $foreignMaxLimit);
$str .= ' </select>' . "\n";
}
elseif ($foreignData['foreign_link'] == true) {
$str .= PMA_foreignDropdown(
$foreignData['disp_row'], $foreignData['foreign_field'],
$foreignData['foreign_display'], '', $foreignMaxLimit
);
$str .= '</select>' . "\n";
} elseif ($foreignData['foreign_link'] == true) {
if(isset($fields[$i]) && is_string($fields[$i])){
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] " value="' . $fields[$i] . '"';
'id="field_' . md5($field) . '[' . $i .']"
class="textfield"/>' ;
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . ']" value="' . $fields[$i] . '"';
'id="field_' . md5($field) . '[' . $i .']"
class="textfield"/>' ;
}
else{
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] "';
'id="field_' . md5($field) . '[' . $i .']"
class="textfield" />' ;
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . ']"';
'id="field_' . md5($field) . '[' . $i .']"
class="textfield" />' ;
}
?>
<?php $str .= '<script type="text/javascript">';
<?php $str .= '<script type="text/javascript">';
// <![CDATA[
$str .= <<<EOT
$str .= <<<EOT
<a target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes'); return false" href="browse_foreigners.php?
EOT;
$str .= '' . PMA_generate_common_url($db, $table) . '&amp;field=' . urlencode($field) . '&amp;fieldkey=' . $i . '">' . str_replace("'", "\'", $titles['Browse']) . '</a>';
// ]]
$str .= '</script>';
} elseif (in_array($tbl_fields_type[$i], PMA_getGISDatatypes())) {
// g e o m e t r y
$str .= '<input type="text" name="fields[' . $i . ']"'
@ -231,72 +210,68 @@ EOT;
$str .= PMA_linkOrButton($edit_url, $edit_str, array(), false, false, '_blank');
$str .= '</span>';
}
} elseif (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0) {
// e n u m s
$enum_value=explode(', ', str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)));
$cnt_enum_value = count($enum_value);
$str .= '<select name="fields[' . ($i) . '][]" id="fieldID_' . $i .'"'
.' multiple="multiple" size="' . min(3, $cnt_enum_value) . '">' . "\n";
for ($j = 0; $j < $cnt_enum_value; $j++) {
if(isset($fields[$i]) && is_array($fields[$i]) && in_array($enum_value[$j],$fields[$i])){
$str .= ' <option value="' . $enum_value[$j] . '" Selected>'
. $enum_value[$j] . '</option>';
}
else{
$str .= ' <option value="' . $enum_value[$j] . '">'
. $enum_value[$j] . '</option>';
}
} // end for
$str .= ' </select>' . "\n";
}
else {
.' multiple="multiple" size="' . min(3, $cnt_enum_value) . '">' . "\n";
for ($j = 0; $j < $cnt_enum_value; $j++) {
if (isset($fields[$i])
&& is_array($fields[$i])
&& in_array($enum_value[$j], $fields[$i])
) {
$str .= '<option value="' . $enum_value[$j] . '" Selected>'
. $enum_value[$j] . '</option>';
} else {
$str .= '<option value="' . $enum_value[$j] . '">'
. $enum_value[$j] . '</option>';
}
} // end for
$str .= '</select>' . "\n";
} else {
// o t h e r c a s e s
$the_class = 'textfield';
$type = $tbl_fields_type[$i];
if ($type == 'date') {
$the_class .= ' datefield';
} elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
$the_class .= ' datetimefield';
}
if(isset($fields[$i]) && is_string($fields[$i])){
$str .= ' <input type="text" name="fields[' . $i . ']" '
.' size="40" class="' . $the_class . '" id="fieldID_' . $i .'" value = "' . $fields[$i] . '"/>' . "\n";
}
else{
$str .= ' <input type="text" name="fields[' . $i . ']"'
.' size="40" class="' . $the_class . '" id="fieldID_' . $i .'" />' . "\n";
}
};
return $str;
if (isset($fields[$i]) && is_string($fields[$i])) {
$str .= '<input type="text" name="fields[' . $i . ']"'
.' size="40" class="' . $the_class . '" id="fieldID_'
. $i .'" value = "' . $fields[$i] . '"/>' . "\n";
} else {
$str .= '<input type="text" name="fields[' . $i . ']"'
.' size="40" class="' . $the_class . '" id="fieldID_'
. $i .'" />' . "\n";
}
}
return $str;
}
/* PMA_tbl_search_getWhereClause() Return the where clause for query generation based on the inputs provided.
/**
* Return the where clause for query generation based on the inputs provided.
*
* @uses PMA_backquote
* @uses PMA_sqlAddslashes
* @uses preg_match
* @uses isset()
* @uses in_array()
* @uses str_replace()
* @uses strpos()
* @uses explode()
* @uses trim()
*
* @param $fields Search criteria input
* @param $names Name of the field(column) on which search criteria is submitted
* @param $types Type of the field
* @param $collations Field collation
* @param $func_type Search fucntion/operator
* @param $unaryFlag Whether operator unary or not
*
* @return string $str HTML content for viewing foreing data and elements for search criteria input.
* @param mixed $fields Search criteria input
* @param string $names Name of the column on which search is submitted
* @param string $types Type of the field
* @param string $collations Field collation
* @param string $func_type Search fucntion/operator
* @param bool $unaryFlag Whether operator unary or not
* @param bool $geom_func Whether geometry functions should be applied
*
* @return string HTML content for viewing foreing data and elements
* for search criteria input.
*/
function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type, $unaryFlag, $geom_func = null){
function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type, $unaryFlag, $geom_func = null)
{
/**
* @todo move this to a more apropriate place
*/
@ -308,7 +283,6 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
);
$w = '';
// If geometry function is set apply it to the field name
if ($geom_func != null && trim($geom_func) != '') {
// Get details about the geometry fucntions
@ -317,8 +291,8 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
// If the function takes a single parameter
if ($geom_funcs[$geom_func]['params'] == 1) {
$backquoted_name = $geom_func . '(' . PMA_backquote($names) . ')';
// If the function takes two parameters
} else {
// If the function takes two parameters
// create gis data from the string
$gis_data = PMA_createGISData($fields);
@ -329,7 +303,7 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
// New output type is the output type of the function being applied
$types = $geom_funcs[$geom_func]['type'];
// If the intended where clause is something like 'IsEmpty(`spatial_col_name`)'
// If the where clause is something like 'IsEmpty(`spatial_col_name`)'
if (isset($geom_unary_functions[$geom_func]) && trim($fields) == '') {
$w = $backquoted_name;
return $w;
@ -338,11 +312,11 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
$backquoted_name = PMA_backquote($names);
}
if($unaryFlag){
if ($unaryFlag) {
$fields = '';
$w = $backquoted_name . ' ' . $func_type;
$w = $backquoted_name . ' ' . $func_type;
} elseif (in_array($types, PMA_getGISDatatypes())) {
} elseif (in_array($types, PMA_getGISDatatypes()) && ! empty($fields)) {
// create gis data from the string
$gis_data = PMA_createGISData($fields);
$w = $backquoted_name . ' ' . $func_type . ' ' . $gis_data;
@ -363,23 +337,25 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
$parens_open = '(';
$parens_close = ')';
} else {
$parens_open = '';
$parens_close = '';
}
$enum_where = '\'' . PMA_sqlAddslashes($fields[0]) . '\'';
for ($e = 1; $e < $enum_selected_count; $e++) {
$enum_where .= ', \'' . PMA_sqlAddslashes($fields[$e]) . '\'';
}
} else {
$parens_open = '';
$parens_close = '';
}
$enum_where = '\'' . PMA_sqlAddslashes($fields[0]) . '\'';
for ($e = 1; $e < $enum_selected_count; $e++) {
$enum_where .= ', \'' . PMA_sqlAddslashes($fields[$e]) . '\'';
}
$w = $backquoted_name . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close;
$w = $backquoted_name . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close;
}
} elseif ($fields != '') {
// For these types we quote the value. Even if it's another type (like INT),
// for a LIKE we always quote the value. MySQL converts strings to numbers
// and numbers to strings as necessary during the comparison
if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types) || strpos(' ' . $func_type, 'LIKE')) {
if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types)
|| strpos(' ' . $func_type, 'LIKE')
) {
$quot = '\'';
} else {
$quot = '';
@ -395,23 +371,28 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
$fields = '^' . $fields . '$';
}
if ($func_type == 'IN (...)' || $func_type == 'NOT IN (...)' || $func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN') {
if ($func_type == 'IN (...)'
|| $func_type == 'NOT IN (...)'
|| $func_type == 'BETWEEN'
|| $func_type == 'NOT BETWEEN'
) {
$func_type = str_replace(' (...)', '', $func_type);
// quote values one by one
$values = explode(',', $fields);
foreach ($values as &$value)
$value = $quot . PMA_sqlAddslashes(trim($value)) . $quot;
// quote values one by one
$values = explode(',', $fields);
foreach ($values as &$value) {
$value = $quot . PMA_sqlAddslashes(trim($value)) . $quot;
}
if ($func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN')
$w = $backquoted_name . ' ' . $func_type . ' ' . (isset($values[0]) ? $values[0] : '') . ' AND ' . (isset($values[1]) ? $values[1] : '');
else
if ($func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN') {
$w = $backquoted_name . ' ' . $func_type . ' ' . (isset($values[0]) ? $values[0] : '')
. ' AND ' . (isset($values[1]) ? $values[1] : '');
} else {
$w = $backquoted_name . ' ' . $func_type . ' (' . implode(',', $values) . ')';
}
else {
}
} else {
$w = $backquoted_name . ' ' . $func_type . ' ' . $quot . PMA_sqlAddslashes($fields) . $quot;;
}
} // end if
return $w;
@ -420,14 +401,14 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
/**
* Formats a SVG plot for the query results.
*
* @param array $data Data for the status chart
* @param array &$settings Settings used to generate the chart
* @param array $data Data for the status chart
* @param array &$settings Settings used to generate the chart
*
* @return string HTML and JS code for the SVG plot
*/
function PMA_SVG_scatter_plot($data, &$settings)
{
require_once './libraries/svg_plot/pma_scatter_plot.php';
include_once './libraries/svg_plot/pma_scatter_plot.php';
if (empty($data)) {
// empty data
@ -444,15 +425,5 @@ function PMA_SVG_scatter_plot($data, &$settings)
}
return $scatter_plot->asSVG();
}
}
?>

View File

@ -19,23 +19,26 @@
* // }
* </code>
*
* @param string $option_string comma separated options
* @return array options
* @param string $option_string comma separated options
*
* @return array options
*/
function PMA_transformation_getOptions($option_string)
{
$result = array();
if (! strlen($option_string)
|| ! $transform_options = preg_split('/,/', $option_string)) {
|| ! $transform_options = preg_split('/,/', $option_string)
) {
return $result;
}
while (($option = array_shift($transform_options)) !== null) {
$trimmed = trim($option);
if (strlen($trimmed) > 1
&& $trimmed[0] == "'"
&& $trimmed[strlen($trimmed) - 1] == "'") {
&& $trimmed[0] == "'"
&& $trimmed[strlen($trimmed) - 1] == "'"
) {
// '...'
$option = substr($trimmed, 1, -1);
} elseif (isset($trimmed[0]) && $trimmed[0] == "'") {
@ -117,11 +120,13 @@ function PMA_getAvailableMIMEtypes()
/**
* Gets the mimetypes for all columns of a table
*
* @param string $db the name of the db to check for
* @param string $table the name of the table to check for
* @param string $strict whether to include only results having a mimetype set
*
* @access public
* @param string $db the name of the db to check for
* @param string $table the name of the table to check for
* @param string $strict whether to include only results having a mimetype set
* @return array [field_name][field_key] = field_value
*
* @return array [field_name][field_key] = field_value
*/
function PMA_getMIME($db, $table, $strict = false)
{
@ -136,7 +141,7 @@ function PMA_getMIME($db, $table, $strict = false)
`mimetype`,
`transformation`,
`transformation_options`
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\'
AND ( `mimetype` != \'\'' . (!$strict ? '
@ -148,14 +153,17 @@ function PMA_getMIME($db, $table, $strict = false)
/**
* Set a single mimetype to a certain value.
*
* @param string $db the name of the db
* @param string $table the name of the table
* @param string $key the name of the column
* @param string $mimetype the mimetype of the column
* @param string $transformation the transformation of the column
* @param string $transformation_options the transformation options of the column
* @param string $forcedelete force delete, will erase any existing
* comments for this column
*
* @access public
* @param string $db the name of the db
* @param string $table the name of the table
* @param string $key the name of the column
* @param string $mimetype the mimetype of the column
* @param string $transformation the transformation of the column
* @param string $transformation_options the transformation options of the column
* @param string $forcedelete force delete, will erase any existing comments for this column
*
* @return boolean true, if comment-query was made.
*/
function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
@ -181,8 +189,9 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
PMA_DBI_free_result($test_rs);
if (! $forcedelete
&& (strlen($mimetype) || strlen($transformation)
|| strlen($transformation_options) || strlen($row['comment']))) {
&& (strlen($mimetype) || strlen($transformation)
|| strlen($transformation_options) || strlen($row['comment']))
) {
$upd_query = '
UPDATE ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
SET `mimetype` = \'' . PMA_sqlAddSlashes($mimetype) . '\',

View File

@ -9,13 +9,14 @@
/**
* Generates text with hidden inputs.
*
* @see PMA_generate_common_url()
* @param string optional database name
* (can also be an array of parameters)
* @param string optional table name
* @param int indenting level
* @param string do not generate a hidden field for this parameter
* (can be an array of strings)
* @param string $db optional database name
* (can also be an array of parameters)
* @param string $table optional table name
* @param int $indent indenting level
* @param string $skip do not generate a hidden field for this parameter
* (can be an array of strings)
*
* @see PMA_generate_common_url()
*
* @return string string with input fields
*
@ -27,7 +28,6 @@
* @global boolean whether recoding is allowed or not
*
* @access public
*
*/
function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $skip = array())
{
@ -48,15 +48,16 @@ function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $
}
if (! empty($GLOBALS['server'])
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']) {
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']
) {
$params['server'] = $GLOBALS['server'];
}
if (empty($_COOKIE['pma_lang'])
&& ! empty($GLOBALS['lang'])) {
if (empty($_COOKIE['pma_lang']) && ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
if (empty($_COOKIE['pma_collation_connection'])
&& ! empty($GLOBALS['collation_connection'])) {
&& ! empty($GLOBALS['collation_connection'])
) {
$params['collation_connection'] = $GLOBALS['collation_connection'];
}
@ -102,8 +103,9 @@ function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $
* <input type="hidden" name="ccc[b]" Value="ccc_b" />
* </code>
*
* @param array $values
* @param string $pre
* @param array $values hidden values
* @param string $pre prefix
*
* @return string form fields of type hidden
*/
function PMA_getHiddenFields($values, $pre = '')
@ -160,19 +162,20 @@ function PMA_getHiddenFields($values, $pre = '')
* // script.php?server=1&amp;lang=en
* </code>
*
* @param mixed assoc. array with url params or optional string with database name
* if first param is an array there is also an ? prefixed to the url
* @param mixed assoc. array with url params or optional string with database name
* if first param is an array there is also an ? prefixed to the url
*
* @param string - if first param is array: 'html' to use htmlspecialchars()
* on the resulting URL (for a normal URL displayed in HTML)
* or something else to avoid using htmlspecialchars() (for
* a URL sent via a header); if not set,'html' is assumed
* - if first param is not array: optional table name
* @param string - if first param is array: 'html' to use htmlspecialchars()
* on the resulting URL (for a normal URL displayed in HTML)
* or something else to avoid using htmlspecialchars() (for
* a URL sent via a header); if not set,'html' is assumed
* - if first param is not array: optional table name
*
* @param string - if first param is array: optional character to
* use instead of '?'
* - if first param is not array: optional character to use
* instead of '&amp;' for dividing URL parameters
*
* @param string - if first param is array: optional character to
* use instead of '?'
* - if first param is not array: optional character to use
* instead of '&amp;' for dividing URL parameters
* @return string string with URL parameters
* @access public
*/
@ -219,17 +222,18 @@ function PMA_generate_common_url()
if (isset($GLOBALS['server'])
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']
// avoid overwriting when creating navi panel links to servers
&& ! isset($params['server'])) {
// avoid overwriting when creating navi panel links to servers
&& ! isset($params['server'])
) {
$params['server'] = $GLOBALS['server'];
}
if (empty($_COOKIE['pma_lang'])
&& ! empty($GLOBALS['lang'])) {
if (empty($_COOKIE['pma_lang']) && ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
if (empty($_COOKIE['pma_collation_connection'])
&& ! empty($GLOBALS['collation_connection'])) {
&& ! empty($GLOBALS['collation_connection'])
) {
$params['collation_connection'] = $GLOBALS['collation_connection'];
}
@ -256,7 +260,9 @@ function PMA_generate_common_url()
* extracted from arg_separator.input as set in php.ini
* we do not use arg_separator.output to avoid problems with &amp; and &
*
* @param string whether to encode separator or not, currently 'none' or 'html'
* @param string $encode whether to encode separator or not,
* currently 'none' or 'html'
*
* @return string character used for separating url parts usally ; or &
* @access public
*/
@ -278,13 +284,13 @@ function PMA_get_arg_separator($encode = 'none')
}
switch ($encode) {
case 'html':
return htmlentities($separator);
break;
case 'text' :
case 'none' :
default :
return $separator;
case 'html':
return htmlentities($separator);
break;
case 'text' :
case 'none' :
default :
return $separator;
}
}

View File

@ -27,9 +27,12 @@ $tabs_icons = array(
'Import' => 'ic_b_import',
'Export' => 'ic_b_export');
echo '<ul id="topmenu2">';
echo PMA_generate_html_tab(array(
'link' => 'prefs_manage.php',
'text' => __('Manage your settings'))) . "\n";
echo PMA_generate_html_tab(
array(
'link' => 'prefs_manage.php',
'text' => __('Manage your settings')
)
) . "\n";
echo '<li>&nbsp; &nbsp;</li>' . "\n";
$script_name = basename($GLOBALS['PMA_PHP_SELF']);
foreach (array_keys($forms) as $formset) {

View File

@ -16,9 +16,12 @@ function PMA_userprefs_pageinit()
$cf = ConfigFile::getInstance();
$cf->resetConfigData(); // start with a clean instance
$cf->setAllowedKeys($forms_all_keys);
$cf->setCfgUpdateReadMapping(array(
'Server/hide_db' => 'Servers/1/hide_db',
'Server/only_db' => 'Servers/1/only_db'));
$cf->setCfgUpdateReadMapping(
array(
'Server/hide_db' => 'Servers/1/hide_db',
'Server/only_db' => 'Servers/1/only_db'
)
);
$cf->updateWithGlobalConfig($GLOBALS['cfg']);
}
@ -64,7 +67,8 @@ function PMA_load_userprefs()
/**
* Saves user preferences
*
* @param array $config_data
* @param array $config_array configuration array
*
* @return true|PMA_Message
*/
function PMA_save_userprefs(array $config_array)
@ -80,7 +84,7 @@ function PMA_save_userprefs(array $config_array)
'db' => $config_array,
'ts' => time());
if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
unset($_SESSION['cache'][$cache_key]['userprefs']);
unset($_SESSION['cache'][$cache_key]['userprefs']);
}
return true;
}
@ -122,6 +126,7 @@ function PMA_save_userprefs(array $config_array)
* (blacklist) and keys from user preferences form (whitelist)
*
* @param array $config_data path => value pairs
*
* @return array
*/
function PMA_apply_userprefs(array $config_data)
@ -155,6 +160,7 @@ function PMA_apply_userprefs(array $config_data)
* Reads user preferences field names
*
* @param array|null $forms
*
* @return array
*/
function PMA_read_userprefs_fieldnames(array $forms = null)
@ -185,8 +191,10 @@ function PMA_read_userprefs_fieldnames(array $forms = null)
*
* No validation is done!
*
* @param string $cfg_name
* @param mixed $value
* @param string $path configuration
* @param mixed $value value
* @param mixed $default_value default value
*
* @return void
*/
function PMA_persist_option($path, $value, $default_value)
@ -222,12 +230,16 @@ function PMA_userprefs_redirect(array $forms, array $old_settings, $file_name, $
? $old_settings['config_data']
: array();
$new_settings = ConfigFile::getInstance()->getConfigArray();
$diff_keys = array_keys(array_diff_assoc($old_settings, $new_settings)
+ array_diff_assoc($new_settings, $old_settings));
$diff_keys = array_keys(
array_diff_assoc($old_settings, $new_settings)
+ array_diff_assoc($new_settings, $old_settings)
);
$check_keys = array('NaturalOrder', 'MainPageIconic', 'DefaultTabDatabase',
'Server/hide_db', 'Server/only_db');
$check_keys = array_merge($check_keys, $forms['Left_frame']['Left_frame'],
$forms['Left_frame']['Left_databases']);
$check_keys = array_merge(
$check_keys, $forms['Left_frame']['Left_frame'],
$forms['Left_frame']['Left_databases']
);
$diff = array_intersect($check_keys, $diff_keys);
$reload_left_frame = !empty($diff);
}
@ -242,8 +254,10 @@ function PMA_userprefs_redirect(array $forms, array $old_settings, $file_name, $
if ($hash) {
$hash = '#' . urlencode($hash);
}
PMA_sendHeaderLocation($GLOBALS['cfg']['PmaAbsoluteUri'] . $file_name
. PMA_generate_common_url($url_params, '&') . $hash);
PMA_sendHeaderLocation(
$GLOBALS['cfg']['PmaAbsoluteUri'] . $file_name
. PMA_generate_common_url($url_params, '&') . $hash
);
}
/**

View File

@ -62,8 +62,11 @@ class zipfile
* "echo $zipfile;" command
*
* @access public
*
* @return nothing
*/
function setDoWrite() {
function setDoWrite()
{
$this -> doWrite = true;
} // end of the 'setDoWrite()' method
@ -71,13 +74,14 @@ class zipfile
* Converts an Unix timestamp to a four byte DOS date and time format (date
* in high two bytes, time in low two bytes allowing magnitude comparison).
*
* @param integer the current Unix timestamp
* @param integer $unixtime the current Unix timestamp
*
* @return integer the current date in a four byte DOS format
* @return integer the current date in a four byte DOS format
*
* @access private
*/
function unix2DosTime($unixtime = 0) {
function unix2DosTime($unixtime = 0)
{
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) {
@ -97,17 +101,19 @@ class zipfile
/**
* Adds "file" to archive
*
* @param string file contents
* @param string name of the file in the archive (may contains the path)
* @param integer the current timestamp
* @param string $data file contents
* @param string $name name of the file in the archive (may contains the path)
* @param integer $time the current timestamp
*
* @access public
*
* @return nothing
*/
function addFile($data, $name, $time = 0)
{
$name = str_replace('\\', '/', $name);
$dtime = substr( "00000000" . dechex($this->unix2DosTime($time)), -8);
$dtime = substr("00000000" . dechex($this->unix2DosTime($time)), -8);
$hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3]

View File

@ -7,13 +7,14 @@
*/
/**
* Gets zip file contents
*
* @param string $specific_entry regular expression to match a file
* @return array ($error_message, $file_data); $error_message
* is empty if no error
*/
* Gets zip file contents
*
* @param string $file zip file
* @param string $specific_entry regular expression to match a file
*
* @return array ($error_message, $file_data); $error_message
* is empty if no error
*/
function PMA_getZipContents($file, $specific_entry = null)
{
$error_message = '';
@ -77,6 +78,8 @@ function PMA_getZipContents($file, $specific_entry = null)
*
* @param string $file_regexp regular expression for the file name to match
* @param string $file zip archive
*
* @return string the file name of the first file that matches the given regexp
*/
function PMA_findFileFromZipArchive ($file_regexp, $file)
{
@ -100,7 +103,9 @@ function PMA_findFileFromZipArchive ($file_regexp, $file)
/**
* Returns the number of files in the zip archive.
*
* @param string $file
* @param string $file zip archive
*
* @return int the number of files in the zip archive
*/
function PMA_getNoOfFilesInZip($file)
{
@ -121,11 +126,14 @@ function PMA_getNoOfFilesInZip($file)
/**
* Extracts a set of files from the given zip archive to a given destinations.
*
* @param string $zip_path
* @param string $destination
* @param array $entries
* @param string $zip_path path to the zip archive
* @param string $destination destination to extract files
* @param array $entries files in archive that should be extracted
*
* @return bool true on sucess, false otherwise
*/
function PMA_zipExtract($zip_path, $destination, $entries) {
function PMA_zipExtract($zip_path, $destination, $entries)
{
$zip = new ZipArchive;
if ($zip->open($zip_path) === true) {
$zip->extractTo($destination, $entries);
@ -138,30 +146,31 @@ function PMA_zipExtract($zip_path, $destination, $entries) {
/**
* Gets zip error message
*
* @param integer error code
* @return string error message
* @param integer $code error code
*
* @return string error message
*/
function PMA_getZipError($code)
{
// I don't think this needs translation
switch ($code) {
case ZIPARCHIVE::ER_MULTIDISK:
$message = 'Multi-disk zip archives not supported';
break;
case ZIPARCHIVE::ER_READ:
$message = 'Read error';
break;
case ZIPARCHIVE::ER_CRC:
$message = 'CRC error';
break;
case ZIPARCHIVE::ER_NOZIP:
$message = 'Not a zip archive';
break;
case ZIPARCHIVE::ER_INCONS:
$message = 'Zip archive inconsistent';
break;
default:
$message = $code;
case ZIPARCHIVE::ER_MULTIDISK:
$message = 'Multi-disk zip archives not supported';
break;
case ZIPARCHIVE::ER_READ:
$message = 'Read error';
break;
case ZIPARCHIVE::ER_CRC:
$message = 'CRC error';
break;
case ZIPARCHIVE::ER_NOZIP:
$message = 'Not a zip archive';
break;
case ZIPARCHIVE::ER_INCONS:
$message = 'Zip archive inconsistent';
break;
default:
$message = $code;
}
return $message;
}

View File

@ -354,7 +354,7 @@ if (!function_exists('mcrypt_encrypt') && !$GLOBALS['cfg']['McryptDisableWarning
* The data file is created while creating release by ./scripts/remove-incomplete-mo
*/
if (file_exists('./libraries/language_stats.inc.php')) {
include('./libraries/language_stats.inc.php');
include './libraries/language_stats.inc.php';
/*
* This message is intentionally not translated, because we're
* handling incomplete translations here and focus on english

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

View File

@ -1,582 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* @package phpMyAdmin-Designer
*/
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #EAEEF0;
color: #000000;
margin: 0;
}
img {
border: 0;
}
.input_tab {
background-color: #A6C7E1;
color: #000000;
}
table {
font-size: 12px;
}
#canvas {
background-color: #FFFFFF;
color: #000000;
}
canvas {
display: inline-block;
overflow: hidden;
text-align: left;
}
canvas * {
behavior: url(#default#VML);
}
.tab {
background-color: #FFFFFF;
color: #000000;
border-collapse: collapse;
border: 1px solid #AAAAAA;
font-family: Tahoma, sans-serif;
font-size: 10px;
z-index: 1;
-moz-user-select: none;
}
.tab_zag {
background-image: url(images/Header.png);
background-repeat: repeat-x;
text-align: center;
cursor: move;
padding: 1px;
font-weight: bold;
}
.tab_zag_2 {
background-image: url(images/Header_Linked.png);
background-repeat: repeat-x;
text-align: center;
cursor: move;
padding: 1px;
font-weight: bold;
}
.tab_field {
background: #FFFFFF;
color: #000000;
cursor: default;
}
.tab_field_2 {
background-color: #CCFFCC;
color: #000000;
background-repeat: repeat-x;
cursor: default;
}
.tab_field_3 {
background-color: #FFE6E6; /*#DDEEFF*/
color: #000000;
cursor: default;
}
#hint {
white-space: nowrap;
position: absolute;
background-color: #99FF99;
color: #000000;
left: 200px;
top: 50px;
z-index: 3;
border: #00CC66 solid 1px;
visibility: hidden;
}
form {
margin: 0;
}
.scroll_tab {
overflow: auto;
width: 100%;
height: 500px;
}
.Tabs {
cursor: default;
font-family: Tahoma, sans-serif;
font-size: 10px;
color: #0055bb;
white-space: nowrap;
text-decoration: none;
text-indent: 3px;
font-weight: bold;
margin-left: 2px;
text-align: left;
background-color: #FFFFFF;
background-image: url(images/left_panel_butt.png);
border: #CCCCCC solid 1px;
}
.Tabs2 {
cursor: default;
font-family: Tahoma, sans-serif;
font-size: 10px;
color: #0055bb;
background: #FFEE99;
text-indent: 3px;
font-weight: bold;
white-space: nowrap;
text-decoration: none;
border: #9999FF solid 1px;
text-align: left;
}
.owner {
font-family: Tahoma, sans-serif;
font-size: 9px;
font-weight: normal;
/* background-color: #ffffff;*/
color: #888888;
}
.option_tab {
padding-left: 2px;
padding-right: 2px;
width: 5px;
}
.select_all {
vertical-align: top;
padding-left: 2px;
padding-right: 2px;
cursor: default;
width: 1px;
color: #000000;
background-image: url(images/Header.png);
background-repeat: repeat-x;
}
.small_tab {
vertical-align: top;
background-color: #0064ea;
color: #FFFFFF;
background-image: url(images/small_tab.png);
cursor: default;
text-align: center;
font-weight: bold;
padding-left: 2px;
padding-right: 2px;
width: 1px;
text-decoration: none;
}
.small_tab2 {
vertical-align: top;
color: #FFFFFF;
background-color: #FF9966;
cursor: default;
padding-left: 2px;
padding-right: 2px;
text-align: center;
font-weight: bold;
width: 1px;
text-decoration: none;
}
.small_tab_pref {
background-image: url(images/Header.png);
background-repeat: repeat-x;
text-align: center;
width: 1px;
}
.small_tab_pref2 {
vertical-align: top;
color: #FFFFFF;
background-color: #FF9966;
cursor: default;
text-align: center;
font-weight: bold;
width: 1px;
text-decoration: none;
}
input, select, textarea {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
border: #6699CC solid 1px;
background-color: #FFFFFF;
color: #000000;
}
.butt {
border: #4477aa solid 1px;
font-size: 11px;
font-weight: bold;
height: 19px;
width: 70px;
background-color: #FFFFFF;
color: #000000;
vertical-align: baseline;
}
.L_butt2_1 {
font-size: 12px;
padding: 1px;
text-decoration: none;
background-color: #ffffff;
color: #000000;
vertical-align: middle;
cursor: default;
}
.L_butt2_2 {
font-size: 12px;
padding: 0;
border: #0099CC solid 1px;
background: #FFEE99;
text-decoration: none;
color: #000000;
cursor: default;
}
/* ---------------------------------------------------------------------------*/
.bor {
width: 10px;
height: 10px;
}
.frams1 {
background: url(images/1.png) no-repeat right bottom;
}
.frams2 {
background: url(images/2.png) no-repeat left bottom;
}
.frams3 {
background: url(images/3.png) no-repeat left top;
}
.frams4 {
background: url(images/4.png) no-repeat right top;
}
.frams5 {
background: url(images/5.png) repeat-x center bottom;
}
.frams6 {
background: url(images/6.png) repeat-y left;
}
.frams7 {
background: url(images/7.png) repeat-x top;
}
.frams8 {
background: url(images/8.png) repeat-y right;
}
#osn_tab {
background-color: #FFFFFF;
color: #000000;
border: #A9A9A9 solid 1px;
}
.header {
/* width: 350px; */
background-color: #EAEEF0;
color: #000000;
text-align: center;
font-weight: bold;
left: 0;
top: 0;
position: fixed;
margin: 0;
z-index: 1001;
padding: 0;
background-image: url(images/top_panel.png);
background-position: top;
background-repeat: repeat-x;
border-right: #999999 solid 1px;
/* border-bottom:#999999 solid 1px;*/
border-left: #999999 solid 1px;
height: 28px;
}
.header a {
display: block;
float: left;
margin: 3px 1px 4px 1px;
height: 20px;
border: 1px dotted #ffffff;
}
.header .M_bord {
display: block;
float: left;
margin: 4px;
height: 20px;
width: 2px;
}
.header a.first {
margin-right: 1em;
}
.header a.last {
margin-left: 1em;
}
a.M_butt_Selected_down_IE,
a.M_butt_Selected_down {
border: 1px solid #C0C0BB;
background-color: #99FF99;
color: #000000;
}
a.M_butt_Selected_down_IE:hover,
a.M_butt_Selected_down:hover,
a.M_butt:hover {
border: 1px solid #0099CC;
background-color: #FFEE99;
color: #000000;
}
#layer_menu {
left: 0;
top: 28px;
width: 150px;
position: fixed;
z-index: 1000;
background-color: #EAEEF0;
border: #999999 solid 1px;
}
#layer_action {
position: absolute;
left: 638px;
top: 52px;
z-index: 1000;
background-color: #CCFF99;
padding: 3px;
border: #009933 solid 1px;
white-space: nowrap;
font-weight: bold;
}
#layer_upd_relation {
position: absolute;
left: 637px;
top: 224px;
z-index: 1000;
}
#layer_new_relation {
position: absolute;
left: 636px;
top: 85px;
z-index: 1000;
width: 153px;
}
#pmd_optionse {
position: absolute;
left: 636px;
top: 85px;
z-index: 1000;
width: 153px;
}
#layer_menu_sizer {
background-image: url(../../images/resize.png);
cursor: nw-resize;
width: 16px;
height: 16px;
}
.panel {
position: fixed;
top: 50px;
right: 0;
display: none;
background: #FFF;
border:1px solid #F5F5F5;
width: 350 px;
height: auto;
padding: 30px 170px 30px 30px;
color:#FFF;
z-index:99;
}
a.trigger{
position: fixed;
text-decoration: none;
top: 60px; right: 0;
font-size: 16px;
font-family: verdana, helvetica, arial, sans-serif;
color:#fff;
padding: 10px 40px 10px 15px;
font-weight: 700;
background:#333333 url(images/plus.png) 85% 55% no-repeat;
border:1px solid #444444;
display: block;
}
a.trigger:hover{
position: fixed;
text-decoration: none;
top: 60px; right: 0;
font-size: 16px;
font-family: verdana, helvetica, arial, sans-serif;
color:#080808;
padding: 10px 40px 10px 15px;
font-weight: 700;
background:#fff696 url(images/plus.png) 85% 55% no-repeat;
border:1px solid #999;
display: block;
}
a.active.trigger {
background:#222222 url(images/minus.png) 85% 55% no-repeat;
z-index:999;
}
a.active.trigger:hover {
background:#fff696 url(images/minus.png) 85% 55% no-repeat;
z-index:999;
}
h2.tiger{
background-repeat: repeat-x;
padding: 1px;
font-weight: bold;
font-size:14px;
padding: 50 20 50 20px;
margin: 0 0 5px 0;
width: 250px;
float: left;
color : #333;
text-align: center;
}
h2.tiger a {
background-image: url(images/Header.png);
text-align: center;
text-decoration: none;
color : #333;
display: block;
}
h2.tiger a:hover {
color: #000;
background-image: url(images/Header_Linked.png);
}
h2.active {
background-image: url(images/Header.png);
background-repeat: repeat-x;
padding: 1px;
background-position: left bottom;
}
.toggle_container {
margin: 0 0 5px;
padding: 0;
border-top: 1px solid #d6d6d6;
background: #FFF ;
width: 250px;
overflow: hidden;
font-size: 1.2em;
clear: both;
}
.toggle_container .block {
background-color: #DBE4E8;
padding:40 15 40 15px; /*--Padding of Container--*/
border:1px solid #999;
color:#000;
}
.history_table {
text-align: center;
background-color: #9999CC;
}
.history_table2 {
text-align: center;
background-color: #DBE4E8;
}
#filter {
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: #CCA;
z-index:10;
opacity:0.5;
filter: alpha(opacity=50);
}
#box {
display: none;
position: absolute;
top: 20%;
left: 30%;
width: 500px;
height: 220px;
padding: 48px;
margin:0;
border: 1px solid black;
background-color: white;
z-index:101;
overflow: visible;
}
#boxtitle {
position:absolute;
float:center;
top:0;
left:0;
width:593px;
height:20px;
padding:0;
padding-top:4px;
left-padding:8px;
margin:0;
border-bottom:4px solid #3CF;
background-color: #D0DCE0; //#09c;
color:black;
font-weight:bold;
padding-left: 2px;
font-family:"Times New Roman", Times, serif;
font-size:16px;
text-align:left;
}
#tblfooter {
background-color: D3DCE3;
float: right;
padding-top:10px;
color: black;
font-weight: normal;
}
input.btn {
color:#333;
font: bold 84%'trebuchet ms',helvetica,sans-serif;
background-color: #D0DCE0;
}

View File

@ -7,7 +7,7 @@
/**
*
*/
include_once 'pmd_common.php';
include_once './libraries/pmd_common.php';
$table = $T;

View File

@ -7,7 +7,9 @@
/**
*
*/
require_once "./pmd_common.php";
require_once './libraries/pmd_common.php';
require './libraries/db_common.inc.php';
require './libraries/db_info.inc.php';
$tab_column = get_tab_info();
$script_tabs = get_script_tabs();
@ -15,19 +17,7 @@ $script_contr = get_script_contr();
$tab_pos = get_tab_pos();
$tables_pk_or_unique_keys = get_pk_or_unique_keys();
$tables_all_keys = get_all_keys();
$hidden = "hidden";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][1]; ?>" lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][1]; ?>" dir="<?php echo $GLOBALS['text_dir']; ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" href="pmd/images/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="pmd/images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="pmd/styles/<?php echo $GLOBALS['PMD']['STYLE'] ?>/style1.css" />
<title>Designer</title>
<?php
$params = array('lang' => $GLOBALS['lang']);
if (isset($GLOBALS['db'])) {
$params['db'] = $GLOBALS['db'];
@ -42,7 +32,7 @@ echo '
var db = "' . PMA_escapeJsString($db) . '";
var token = "' . PMA_escapeJsString($token) . '";';
echo "\n";
if ($_REQUEST['query']) {
if (isset($_REQUEST['query'])) {
echo '
$(document).ready(function() {
$(".trigger").click(function() {
@ -68,7 +58,7 @@ echo $script_tabs . $script_contr . $script_display_field;
</head>
<body onload="Main()" class="general_body" id="pmd_body">
<div class="header" id="top_menu">
<div class="pmd_header" id="top_menu">
<a href="javascript:Show_left_menu(document.getElementById('key_Show_left_menu'));"
onmousedown="return false;" class="M_butt first" target="_self">
<img id='key_Show_left_menu' title="<?php echo __('Show/Hide left menu'); ?>"
@ -88,7 +78,7 @@ echo $script_tabs . $script_contr . $script_display_field;
/></a><a href="javascript:location.reload();" onmousedown="return false;"
class="M_butt" target="_self"
><img title="<?php echo __('Reload'); ?>" src="pmd/images/reload.png" alt=""
/></a><a href="javascript:Help();" onmousedown="return false;"
/></a><a href="Documentation.html#faq6_31" target="documentation"
class="M_butt" target="_self"
><img title="<?php echo __('Help'); ?>" src="pmd/images/help.png" alt=""
/></a><img class="M_bord" src="pmd/images/bord.png" alt=""
@ -113,7 +103,7 @@ echo $script_tabs . $script_contr . $script_display_field;
><img src="pmd/images/pdf.png" alt="key" width="20" height="20"
title="<?php echo __('Import/Export coordinates for PDF schema'); ?>" /></a
>
<?php if ($_REQUEST['query']) {
<?php if (isset($_REQUEST['query'])) {
echo '<a href="#" onClick="build_query(\'SQL Query on Database\', 0)" onmousedown="return false;"
class="M_butt" target="_self">';
echo '<img src="pmd/images/query_builder.png" alt="key" width="20" height="20" title="';
@ -125,12 +115,11 @@ echo $script_tabs . $script_contr . $script_display_field;
title="<?php echo __('Move Menu'); ?>" /></a>
</div>
<div id="osn_tab">
<CANVAS id="canvas" width="100" height="100" onclick="Canvas_click(this)"></CANVAS>
</div>
<form action="" method="post" name="form1">
<div id="layer_menu" style="visibility:<?php echo $hidden ?>;">
<div id="osn_tab">
<canvas class="pmd" id="canvas" width="100" height="100" onclick="Canvas_click(this)"></canvas>
</div>
<div id="layer_menu" style="display:none;">
<div align="center" style="padding-top:5px;">
<a href="javascript:Hide_tab_all(document.getElementById('key_HS_all'));"
onmousedown="return false;" class="M_butt" target="_self">
@ -166,8 +155,8 @@ for ($i = 0; $i < $name_cnt; $i++) {
echo 'checked="checked"';
}
?> /></td>
<td class="Tabs" onmouseover="this.className='Tabs2'"
onmouseout="this.className='Tabs'"
<td class="pmd_Tabs" onmouseover="this.className='pmd_Tabs2'"
onmouseout="this.className='pmd_Tabs'"
onclick="Select_tab('<?php echo $GLOBALS['PMD_URL']["TABLE_NAME"][$i]; ?>');">
<?php echo $GLOBALS['PMD_OUT']["TABLE_NAME"][$i]; ?></td>
</tr>
@ -185,6 +174,8 @@ for ($i = 0; $i < $name_cnt; $i++) {
</div>
</div>
</div>
<?php
for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
$t_n = $GLOBALS['PMD']["TABLE_NAME"][$i];
@ -196,7 +187,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
<input name="t_v[<?php echo $t_n_url ?>]" type="hidden" id="t_v_<?php echo $t_n_url ?>_" />
<input name="t_h[<?php echo $t_n_url ?>]" type="hidden" id="t_h_<?php echo $t_n_url ?>_" />
<table id="<?php echo $t_n_url ?>" cellpadding="0" cellspacing="0" class="tab"
<table id="<?php echo $t_n_url ?>" cellpadding="0" cellspacing="0" class="pmd_tab"
style="position: absolute;
left: <?php if (isset($tab_pos[$t_n])) echo $tab_pos[$t_n]["X"]; else echo rand(180, 800); ?>px;
top: <?php if (isset($tab_pos[$t_n])) echo $tab_pos[$t_n]["Y"]; else echo rand(30, 500); ?>px;
@ -246,7 +237,10 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tr>
</thead>
<tbody id="id_tbody_<?php echo $t_n_url ?>"
<?php if ( isset($tab_pos[$t_n])) echo 'style="display: none;"'; ?>>
<?php
if (isset($tab_pos[$t_n]) && empty($tab_pos[$t_n]["V"])) {
echo 'style="display: none;"';
}?>>
<?php
$display_field = PMA_getDisplayField($db, $GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]);
for ($j = 0, $id_cnt = count($tab_column[$t_n]["COLUMN_ID"]); $j < $id_cnt; $j++) {
@ -287,12 +281,12 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
<?php
if (isset($tables_pk_or_unique_keys[$t_n.".".$tab_column[$t_n]["COLUMN_NAME"][$j]])) {
?>
<img src="pmd/styles/<?php echo $GLOBALS['PMD']['STYLE'];?>/images/FieldKey_small.png"
<img src="<?php echo $_SESSION['PMA_Theme']->getImgPath(); ?>pmd/FieldKey_small.png"
alt="*" />
<?php
} else {
?>
<img src="pmd/styles/<?php echo $GLOBALS['PMD']['STYLE']?>/images/Field_small<?php
<img src="<?php echo $_SESSION['PMA_Theme']->getImgPath(); ?>pmd/Field_small<?php
if (strstr($tab_column[$t_n]["TYPE"][$j],'char')
|| strstr($tab_column[$t_n]["TYPE"][$j],'text')) {
echo '_char';
@ -332,10 +326,10 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
}
?>
</form>
<div id="hint"></div>
<div id='layer_action' style="visibility:<?php echo $hidden ?>;">Load...</div>
<div id="pmd_hint"></div>
<div id='layer_action' style="display:none;">Load...</div>
<table id="layer_new_relation" style="visibility:<?php echo $hidden ?>;"
<table id="layer_new_relation" style="display:none;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -386,7 +380,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
value="<?php echo __('OK'); ?>" onclick="New_relation()" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('layer_new_relation').style.visibility = 'hidden';" />
onclick="document.getElementById('layer_new_relation').style.display = 'none';" />
</td>
</tr>
</tbody>
@ -402,7 +396,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tbody>
</table>
<table id="layer_upd_relation" style="visibility:<?PHP echo $hidden ?>;"
<table id="layer_upd_relation" style="display:none;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -423,7 +417,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
onclick="Upd_relation()" value="<?php echo __('Delete'); ?>" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('layer_upd_relation').style.visibility = 'hidden'; Re_load();" />
onclick="document.getElementById('layer_upd_relation').style.display = 'none'; Re_load();" />
</td>
</tr>
</table></td>
@ -437,7 +431,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tbody>
</table>
<table id="pmd_optionse" style="visibility:<?php echo $hidden ?>;"
<table id="pmd_optionse" style="display:none;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -559,7 +553,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tbody>
</table>
<table id="query_rename_to" style="visibility:<?php echo $hidden ?>;"
<table id="query_rename_to" style="display:none;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -591,7 +585,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
value="<?php echo __('OK'); ?>" onclick="edit('Rename')" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('query_rename_to').style.visibility = 'hidden';" />
onclick="document.getElementById('query_rename_to').style.display = 'none';" />
</td>
</tr>
</tbody>
@ -607,7 +601,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tbody>
</table>
<table id="query_having" style="visibility:<?php echo $hidden ?>;"
<table id="query_having" style="display:none;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -667,7 +661,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
value="<?php echo __('OK'); ?>" onclick="edit('Having')" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('query_having').style.visibility = 'hidden';" />
onclick="document.getElementById('query_having').style.display = 'none';" />
</td>
</tr>
</tbody>
@ -683,7 +677,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tbody>
</table>
<table id="query_Aggregate" style="visibility:<?php echo $hidden ?>;"
<table id="query_Aggregate" style="display:none;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -721,7 +715,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
value="<?php echo __('OK'); ?>" onclick="edit('Aggregate')" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('query_Aggregate').style.visibility = 'hidden';" />
onclick="document.getElementById('query_Aggregate').style.display = 'none';" />
</td>
</tr>
</tbody>
@ -737,7 +731,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tbody>
</table>
<table id="query_where" style="visibility:<?php echo $hidden ?>;"
<table id="query_where" style="display:none;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -784,7 +778,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
value="<?php echo __('OK'); ?>" onclick="edit('Where')" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('query_where').style.visibility = 'hidden';" />
onclick="document.getElementById('query_where').style.display = 'none';" />
</td>
</tr>
</tbody>

View File

@ -1,27 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
*
* @package phpMyAdmin-Designer
*/
/**
*
*/
require_once 'pmd_common.php';
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="./libraries/pmd/styles/<?php echo $GLOBALS['PMD']['STYLE'] ?>/style1.css">
<title>Designer</title>
</head>
<body>
<?php
echo '<p>' . __('To select relation, click :') . '<br />';
echo '<img src="pmd/images/help_relation.png" border="1"></p>';
echo '<p>' . __('The display column is shown in pink. To set/unset a column as the display column, click the "Choose column to display" icon, then click on the appropriate column name.') . '</p>';
?>
</body>
</html>

View File

@ -5,7 +5,7 @@
* @package phpMyAdmin-Designer
*/
include_once 'pmd_common.php';
include_once './libraries/pmd_common.php';
/**
* If called directly from the designer, first save the positions

View File

@ -8,7 +8,7 @@
/**
*
*/
include_once 'pmd_common.php';
include_once './libraries/pmd_common.php';
$die_save_pos = 0;
include_once 'pmd_save_pos.php';
extract($_POST, EXTR_SKIP);

View File

@ -8,7 +8,7 @@
/**
*
*/
include_once 'pmd_common.php';
include_once './libraries/pmd_common.php';
extract($_POST, EXTR_SKIP);
extract($_GET, EXTR_SKIP);
$die_save_pos = 0;

View File

@ -8,7 +8,7 @@
/**
*
*/
include_once 'pmd_common.php';
include_once './libraries/pmd_common.php';
$cfgRelation = PMA_getRelationsParam();

1366
po/af.po

File diff suppressed because it is too large Load Diff

1367
po/ar.po

File diff suppressed because it is too large Load Diff

1364
po/az.po

File diff suppressed because it is too large Load Diff

1392
po/be.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1378
po/bg.po

File diff suppressed because it is too large Load Diff

1369
po/bn.po

File diff suppressed because it is too large Load Diff

1422
po/br.po

File diff suppressed because it is too large Load Diff

1365
po/bs.po

File diff suppressed because it is too large Load Diff

1386
po/ca.po

File diff suppressed because it is too large Load Diff

1383
po/cs.po

File diff suppressed because it is too large Load Diff

1371
po/cy.po

File diff suppressed because it is too large Load Diff

1818
po/da.po

File diff suppressed because it is too large Load Diff

1518
po/de.po

File diff suppressed because it is too large Load Diff

1385
po/el.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1897
po/es.po

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More