You've already forked phpmyadmin
mirror of
https://github.com/phpmyadmin/phpmyadmin.git
synced 2026-10-28 07:41:55 +03:00
remove warning messages
This commit is contained in:
@@ -50,6 +50,12 @@ VerboseMultiSubmit, ReplaceHelpImg
|
||||
- bug #3522930 [browse] Missing validation in Ajax mode
|
||||
- bug Fix popup message on build SQL of import
|
||||
- bug #3523499 [core] Make X-WebKit-CSP work better
|
||||
- replace Highcharts with jqplot for query profiling, zoom search
|
||||
- bug #3531584 [interface] No form validation in change password dialog
|
||||
- bug #3531585 [interface] Broken password validation in copy user form
|
||||
- bug #3531586 [unterface] Add user form prints JSON when user presses enter
|
||||
- bug #3534121 [config] duplicate line in config.sample.inc.php
|
||||
- bug #3534311 [interface] Grid editing incorrectly parses ENUM/SET values
|
||||
|
||||
3.5.1.0 (2012-05-03)
|
||||
- bug #3510784 [edit] Limit clause ignored when sort order is remembered
|
||||
|
||||
@@ -2700,9 +2700,8 @@ setfacl -d -m "g:www-data:rwx" tmp
|
||||
|
||||
<p> This seems to be a PWS bug. Filippo Simoncini found a workaround (at this
|
||||
time there is no better fix): remove or comment the <code>DOCTYPE</code>
|
||||
declarations (2 lines) from the scripts <em>libraries/header.inc.php</em>,
|
||||
<em>libraries/header_printview.inc.php</em>, <em>index.php</em>,
|
||||
<em>navigation.php</em> and <em>libraries/common.lib.php</em>.</p>
|
||||
declarations (2 lines) from the scripts <em>libraries/Header.class.php</em>
|
||||
and <em>index.php</em>.</p>
|
||||
|
||||
<h4 id="faq1_7">
|
||||
<a href="#faq1_7">1.7 How can I GZip or Bzip a dump or a
|
||||
@@ -3298,9 +3297,9 @@ RewriteRule .* - [F]
|
||||
<a href="#cfg_ThemeDefault" class="configrule">$cfg['ThemeDefault']</a>.<br />
|
||||
<br />
|
||||
Under <a href="#cfg_ThemePath" class="configrule">$cfg['ThemePath']</a>, you
|
||||
should not delete the directory "original" or its underlying
|
||||
should not delete the directory "pmahomme" or its underlying
|
||||
structure, because this is the system theme used by phpMyAdmin.
|
||||
"original" contains all images and styles, for backwards
|
||||
"pmahomme" contains all images and styles, for backwards
|
||||
compatibility and for all themes that would not include images or css-files.
|
||||
<br /><br />
|
||||
|
||||
@@ -3313,7 +3312,7 @@ RewriteRule .* - [F]
|
||||
<ul><li>make a new subdirectory (for example "your_theme_name") under
|
||||
<a href="#cfg_ThemePath" class="configrule">$cfg['ThemePath']</a>
|
||||
(by default <code>themes</code>)</li>
|
||||
<li>copy the files and directories from "original" to
|
||||
<li>copy the files and directories from "pmahomme" to
|
||||
"your_theme_name"</li>
|
||||
<li>edit the css-files in "your_theme_name/css"</li>
|
||||
<li>put your new images in "your_theme_name/img"</li>
|
||||
@@ -3333,7 +3332,7 @@ RewriteRule .* - [F]
|
||||
|
||||
<p> If you do not want to use your own symbols and buttons, remove the
|
||||
directory "img" in "your_theme_name". phpMyAdmin will
|
||||
use the default icons and buttons (from the system-theme "original").
|
||||
use the default icons and buttons (from the system-theme "pmahomme").
|
||||
</p>
|
||||
|
||||
<h4 id="faqmissingparameters">
|
||||
@@ -4433,7 +4432,7 @@ chmod o+rwx tmp
|
||||
<a href="#faq6_31">6.31 How do I create a relation in designer?</a></h4>
|
||||
|
||||
<p>To select relation, click:<br />
|
||||
<img src="themes/original/img/pmd/help_relation.png" width="100" height="100" alt="[relation icon]" /><br />
|
||||
<img src="themes/pmahomme/img/pmd/help_relation.png" width="100" height="100" alt="[relation icon]" /><br />
|
||||
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">
|
||||
|
||||
@@ -6,22 +6,23 @@
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets a core script and starts output buffering work
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/transformations.lib.php';
|
||||
|
||||
$field = $_REQUEST['field'];
|
||||
|
||||
PMA_checkParameters(array('db', 'table', 'field'));
|
||||
|
||||
require_once 'libraries/ob.lib.php';
|
||||
PMA_outBufferPre();
|
||||
|
||||
require_once 'libraries/header_http.inc.php';
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->getFooter()->setMinimal();
|
||||
$header = $response->getHeader();
|
||||
$header->disableMenu();
|
||||
$header->setBodyId('body_browse_foreigners');
|
||||
|
||||
/**
|
||||
* Displays the frame
|
||||
*/
|
||||
require_once 'libraries/transformations.lib.php'; // Transformations
|
||||
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
$foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : false);
|
||||
|
||||
@@ -77,93 +78,79 @@ if (is_array($foreignData['disp_row'])) {
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$current_language = $available_languages[$lang][1];
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="<?php echo $current_language; ?>" dir="<?php echo $text_dir; ?>">
|
||||
|
||||
<head>
|
||||
<title>phpMyAdmin</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&nocache=<?php echo $GLOBALS['PMA_Config']->getThemeUniqueValue(); ?>" />
|
||||
<?php
|
||||
// includes everything asked for by libraries/common.inc.php
|
||||
require_once 'libraries/header_scripts.inc.php';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
self.focus();
|
||||
function formupdate(fieldmd5, key) {
|
||||
var $inline = window.opener.jQuery('.browse_foreign_clicked');
|
||||
if ($inline.length != 0) {
|
||||
$inline.removeClass('browse_foreign_clicked')
|
||||
// for grid editing,
|
||||
// puts new value in the previous element which is
|
||||
// a span with class curr_value
|
||||
.prev('.curr_value').text(key);
|
||||
// for zoom-search editing, puts new value in the previous
|
||||
// element which is an input field
|
||||
$inline.prev('input[type=text]').val(key);
|
||||
|
||||
|
||||
if (isset($rownumber)) {
|
||||
$element_name = " var element_name = field + '[multi_edit]["
|
||||
. htmlspecialchars($rownumber) . "][' + fieldmd5 + ']';\n"
|
||||
. " var null_name = field_null + '[multi_edit]["
|
||||
. htmlspecialchars($rownumber) . "][' + fieldmd5 + ']';\n";
|
||||
} else {
|
||||
$element_name = "var element_name = field + '[]'";
|
||||
}
|
||||
$error = PMA_jsFormat(
|
||||
__(
|
||||
'The target browser window could not be updated. '
|
||||
. 'Maybe you have closed the parent window, or '
|
||||
. 'your browser\'s security settings are '
|
||||
. 'configured to block cross-window updates.'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (! isset($fieldkey) || ! is_numeric($fieldkey)) {
|
||||
$fieldkey = 0;
|
||||
}
|
||||
|
||||
$code = <<<EOC
|
||||
self.focus();
|
||||
function formupdate(fieldmd5, key) {
|
||||
var \$inline = window.opener.jQuery('.browse_foreign_clicked');
|
||||
if (\$inline.length != 0) {
|
||||
\$inline.removeClass('browse_foreign_clicked')
|
||||
// for grid editing,
|
||||
// puts new value in the previous element which is
|
||||
// a span with class curr_value
|
||||
.prev('.curr_value').text(key);
|
||||
// for zoom-search editing, puts new value in the previous
|
||||
// element which is an input field
|
||||
\$inline.prev('input[type=text]').val(key);
|
||||
self.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (opener && opener.document && opener.document.insertForm) {
|
||||
var field = 'fields';
|
||||
var field_null = 'fields_null';
|
||||
|
||||
$element_name
|
||||
|
||||
var element_name_alt = field + '[$fieldkey]';
|
||||
|
||||
if (opener.document.insertForm.elements[element_name]) {
|
||||
// Edit/Insert form
|
||||
opener.document.insertForm.elements[element_name].value = key;
|
||||
if (opener.document.insertForm.elements[null_name]) {
|
||||
opener.document.insertForm.elements[null_name].checked = false;
|
||||
}
|
||||
self.close();
|
||||
return false;
|
||||
} else if (opener.document.insertForm.elements[element_name_alt]) {
|
||||
// Search form
|
||||
opener.document.insertForm.elements[element_name_alt].value = key;
|
||||
self.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (opener && opener.document && opener.document.insertForm) {
|
||||
var field = 'fields';
|
||||
var field_null = 'fields_null';
|
||||
|
||||
<?php
|
||||
if (isset($rownumber)) {
|
||||
?>
|
||||
var element_name = field + '[multi_edit][<?php echo htmlspecialchars($rownumber); ?>][' + fieldmd5 + ']';
|
||||
var null_name = field_null + '[multi_edit][<?php echo htmlspecialchars($rownumber); ?>][' + fieldmd5 + ']';
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
var element_name = field + '[]';
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (isset($fieldkey) && is_numeric($fieldkey)) {
|
||||
?>
|
||||
var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
var element_name_alt = field + '[0]';
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
if (opener.document.insertForm.elements[element_name]) {
|
||||
// Edit/Insert form
|
||||
opener.document.insertForm.elements[element_name].value = key;
|
||||
if (opener.document.insertForm.elements[null_name]) {
|
||||
opener.document.insertForm.elements[null_name].checked = false;
|
||||
}
|
||||
self.close();
|
||||
return false;
|
||||
} else if (opener.document.insertForm.elements[element_name_alt]) {
|
||||
// Search form
|
||||
opener.document.insertForm.elements[element_name_alt].value = key;
|
||||
self.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
alert('<?php echo PMA_jsFormat(__('The target browser window could not be updated. Maybe you have closed the parent window, or your browser\'s security settings are configured to block cross-window updates.')); ?>');
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body id="body_browse_foreigners">
|
||||
alert('$error');
|
||||
}
|
||||
EOC;
|
||||
|
||||
$header->getScripts()->addCode($code);
|
||||
|
||||
?>
|
||||
<form action="browse_foreigners.php" method="post">
|
||||
<fieldset>
|
||||
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
|
||||
@@ -335,6 +322,3 @@ if (is_array($foreignData['disp_row'])) {
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
19
chk_rel.php
19
chk_rel.php
@@ -6,21 +6,10 @@
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets some core libraries
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/header.inc.php';
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addHTML(
|
||||
PMA_getRelationsParamDiagnostic(PMA_getRelationsParam())
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the relation settings
|
||||
*/
|
||||
$cfgRelation = PMA_getRelationsParam(true);
|
||||
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
@@ -58,7 +58,6 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false;
|
||||
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
|
||||
// $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
|
||||
// $cfg['Servers'][$i]['recent'] = 'pma_recent';
|
||||
// $cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs';
|
||||
/* Contrib / Swekey authentication */
|
||||
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
* Gets some core libraries
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
$GLOBALS['js_include'][] = 'functions.js';
|
||||
|
||||
require_once 'libraries/mysql_charsets.lib.php';
|
||||
if (! PMA_DRIZZLE) {
|
||||
@@ -62,14 +61,15 @@ if (! $result) {
|
||||
$GLOBALS['table'] = '';
|
||||
|
||||
/**
|
||||
* If in an Ajax request, just display the message with {@link PMA_ajaxResponse}
|
||||
* If in an Ajax request, just display the message with {@link PMA_Response}
|
||||
*/
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
PMA_ajaxResponse($message, false);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess(false);
|
||||
$response->addJSON('message', $message);
|
||||
} else {
|
||||
include_once 'main.php';
|
||||
}
|
||||
|
||||
include_once 'libraries/header.inc.php';
|
||||
include_once 'main.php';
|
||||
} else {
|
||||
$message = PMA_Message::success(__('Database %1$s has been created.'));
|
||||
$message->addParam($new_db);
|
||||
@@ -79,14 +79,6 @@ if (! $result) {
|
||||
* If in an Ajax request, build the output and send it
|
||||
*/
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
|
||||
/**
|
||||
* String containing the SQL Query formatted in pretty HTML
|
||||
* @global array $GLOBALS['extra_data']
|
||||
* @name $extra_data
|
||||
*/
|
||||
$extra_data['sql_query'] = PMA_getMessage(null, $sql_query, 'success');
|
||||
|
||||
//Construct the html for the new database, so that it can be appended to
|
||||
// the list of databases on server_databases.php
|
||||
|
||||
@@ -140,12 +132,12 @@ if (! $result) {
|
||||
|
||||
$new_db_string .= '</tr>';
|
||||
|
||||
$extra_data['new_db_string'] = $new_db_string;
|
||||
|
||||
PMA_ajaxResponse($message, true, $extra_data);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addJSON('message', $message);
|
||||
$response->addJSON('new_db_string', $new_db_string);
|
||||
$response->addJSON('sql_query', PMA_getMessage(null, $sql_query, 'success'));
|
||||
} else {
|
||||
include_once '' . $cfg['DefaultTabDatabase'];
|
||||
}
|
||||
|
||||
include_once 'libraries/header.inc.php';
|
||||
include_once '' . $cfg['DefaultTabDatabase'];
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -283,5 +283,4 @@ foreach ($tables as $table) {
|
||||
*/
|
||||
PMA_printButton();
|
||||
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
@@ -15,9 +15,12 @@ require_once 'libraries/common.lib.php';
|
||||
/**
|
||||
* Include JavaScript libraries
|
||||
*/
|
||||
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
|
||||
$GLOBALS['js_include'][] = 'rte/common.js';
|
||||
$GLOBALS['js_include'][] = 'rte/events.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('jquery/timepicker.js');
|
||||
$scripts->addFile('rte/common.js');
|
||||
$scripts->addFile('rte/events.js');
|
||||
|
||||
/**
|
||||
* Include all other files
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
$GLOBALS['js_include'][] = 'export.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('export.js');
|
||||
|
||||
// $sub_part is also used in db_info.inc.php to see if we are coming from
|
||||
// db_export.php, in which case we don't obey $cfg['MaxTableList']
|
||||
@@ -28,7 +31,6 @@ $export_page_title = __('View dump (schema) of database');
|
||||
// exit if no tables in db found
|
||||
if ($num_tables < 1) {
|
||||
PMA_Message::error(__('No tables found in database.'))->display();
|
||||
include 'libraries/footer.inc.php';
|
||||
exit;
|
||||
} // end if
|
||||
|
||||
@@ -81,8 +83,4 @@ $multi_values .= '</select></div>';
|
||||
$export_type = 'database';
|
||||
require_once 'libraries/display_export.lib.php';
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
$GLOBALS['js_include'][] = 'import.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('import.js');
|
||||
|
||||
/**
|
||||
* Gets tables informations and displays top links
|
||||
@@ -21,9 +24,5 @@ require 'libraries/db_info.inc.php';
|
||||
$import_type = 'database';
|
||||
require 'libraries/display_import.lib.php';
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/mysql_charsets.lib.php';
|
||||
|
||||
// add a javascript file for jQuery functions to handle Ajax actions
|
||||
$GLOBALS['js_include'][] = 'db_operations.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('db_operations.js');
|
||||
|
||||
/**
|
||||
* Sets globals from $_REQUEST (we're using GET on ajax, POST otherwise)
|
||||
@@ -337,13 +340,16 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
||||
|
||||
/**
|
||||
* Database has been successfully renamed/moved. If in an Ajax request,
|
||||
* generate the output with {@link PMA_ajaxResponse} and exit
|
||||
* generate the output with {@link PMA_Response} and exit
|
||||
*/
|
||||
if ( $GLOBALS['is_ajax_request'] == true) {
|
||||
$extra_data['newname'] = $newname;
|
||||
$extra_data['sql_query'] = PMA_getMessage(null, $sql_query);
|
||||
PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
|
||||
};
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess($message->isSuccess());
|
||||
$response->addJSON('message', $message);
|
||||
$response->addJSON('newname', $newname);
|
||||
$response->addJSON('sql_query', PMA_getMessage(null, $sql_query));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -633,8 +639,4 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
|
||||
echo __('Edit or export relational schema') . '</a></fieldset></div>';
|
||||
} // end if
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
/**
|
||||
* Gets the variables sent or posted to this script, then displays headers
|
||||
*/
|
||||
require_once 'libraries/header_printview.inc.php';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$header->enablePrintView();
|
||||
|
||||
PMA_checkParameters(array('db'));
|
||||
|
||||
@@ -248,6 +247,4 @@ if ($num_tables == 0) {
|
||||
PMA_printButton();
|
||||
|
||||
echo "<div id='PMA_disable_floating_menubar'></div>\n";
|
||||
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
45
db_qbe.php
45
db_qbe.php
@@ -102,7 +102,6 @@ $tbl_result = PMA_DBI_query(
|
||||
$tbl_result_cnt = PMA_DBI_num_rows($tbl_result);
|
||||
if (0 == $tbl_result_cnt) {
|
||||
PMA_Message::error(__('No tables found in database.'))->display();
|
||||
include 'libraries/footer.inc.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -168,29 +167,21 @@ function showColumnSelectCell($columns, $column_number, $selected = '')
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
<?php if (! empty($tab_designer['link'])) {
|
||||
$tab_designer['link'] = htmlentities($tab_designer['link']);
|
||||
$tab_designer['link'] = $tab_designer['link'] . PMA_generate_common_url($url_params);
|
||||
if (! empty($tab_designer['args'])) {
|
||||
foreach ($tab_designer['args'] as $param => $value) {
|
||||
$tab_designer['link'] .= PMA_get_arg_separator('html') . urlencode($param) . '='
|
||||
. urlencode($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! empty($tab['fragment'])) {
|
||||
$tab['link'] .= $tab['fragment'];
|
||||
}
|
||||
if (isset($tab_designer['link'])) {
|
||||
?>
|
||||
<div id="visual_builder_anchor" class="notice hide">
|
||||
<span id="footnote_1">
|
||||
<?php printf(__('Switch to %svisual builder%s'), ' <a href="' . $tab_designer['link'] . PMA_get_arg_separator('html') . 'query=1">', '</a>'); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
if ($cfgRelation['designerwork']) {
|
||||
$url = 'pmd_general.php' . PMA_generate_common_url(
|
||||
array_merge(
|
||||
$url_params,
|
||||
array('query' => 1)
|
||||
)
|
||||
);
|
||||
PMA_Message::notice(
|
||||
sprintf(
|
||||
__('Switch to %svisual builder%s'),
|
||||
'<a href="' . $url . '">',
|
||||
'</a>'
|
||||
)
|
||||
)->display();
|
||||
}
|
||||
?>
|
||||
<form action="db_qbe.php" method="post">
|
||||
<fieldset>
|
||||
@@ -957,9 +948,3 @@ if (! empty($qry_orderby)) {
|
||||
</fieldset>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
@@ -16,9 +16,12 @@ require_once 'libraries/mysql_charsets.lib.php';
|
||||
/**
|
||||
* Include JavaScript libraries
|
||||
*/
|
||||
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
|
||||
$GLOBALS['js_include'][] = 'rte/common.js';
|
||||
$GLOBALS['js_include'][] = 'rte/routines.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('jquery/timepicker.js');
|
||||
$scripts->addFile('rte/common.js');
|
||||
$scripts->addFile('rte/routines.js');
|
||||
|
||||
/**
|
||||
* Include all other files
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
$GLOBALS['js_include'][] = 'db_search.js';
|
||||
$GLOBALS['js_include'][] = 'sql.js';
|
||||
$GLOBALS['js_include'][] = 'makegrid.js';
|
||||
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('db_search.js');
|
||||
$scripts->addFile('sql.js');
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('jquery/timepicker.js');
|
||||
|
||||
/**
|
||||
* Gets some core libraries and send headers
|
||||
@@ -368,9 +371,3 @@ $alter_select
|
||||
<!-- toggle query box link-->
|
||||
<a id="togglequerybox"></a>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
13
db_sql.php
13
db_sql.php
@@ -13,9 +13,12 @@ require_once 'libraries/common.inc.php';
|
||||
/**
|
||||
* Runs common work
|
||||
*/
|
||||
$GLOBALS['js_include'][] = 'functions.js';
|
||||
$GLOBALS['js_include'][] = 'makegrid.js';
|
||||
$GLOBALS['js_include'][] = 'sql.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('functions.js');
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('sql.js');
|
||||
|
||||
require 'libraries/db_common.inc.php';
|
||||
require_once 'libraries/sql_query_form.lib.php';
|
||||
@@ -59,8 +62,4 @@ PMA_sqlQueryForm(
|
||||
isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';'
|
||||
);
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
$GLOBALS['js_include'][] = 'db_structure.js';
|
||||
$GLOBALS['js_include'][] = 'tbl_change.js';
|
||||
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('db_structure.js');
|
||||
$scripts->addFile('tbl_change.js');
|
||||
$scripts->addFile('jquery/timepicker.js');
|
||||
|
||||
/**
|
||||
* Sets globals from $_POST
|
||||
@@ -86,11 +89,6 @@ if ($num_tables == 0) {
|
||||
if (empty($db_is_information_schema)) {
|
||||
include 'libraries/display_create_table.lib.php';
|
||||
} // end if (Create Table dialog)
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
include_once 'libraries/footer.inc.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -756,8 +754,4 @@ if (empty($db_is_information_schema)) {
|
||||
include 'libraries/display_create_table.lib.php';
|
||||
} // end if (Create Table dialog)
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
@@ -63,5 +63,6 @@ foreach ($tables_full as $key => $table) {
|
||||
}
|
||||
}
|
||||
|
||||
PMA_ajaxResponse('', true, array('tables' => $tables_response));
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addJSON('tables', $tables_response);
|
||||
?>
|
||||
|
||||
@@ -10,15 +10,18 @@
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
//Get some js files needed for Ajax requests
|
||||
$GLOBALS['js_include'][] = 'db_structure.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('db_structure.js');
|
||||
|
||||
/**
|
||||
* If we are not in an Ajax request, then do the common work and show the links etc.
|
||||
*/
|
||||
if ($GLOBALS['is_ajax_request'] != true) {
|
||||
include 'libraries/db_common.inc.php';
|
||||
$url_query .= '&goto=tbl_tracking.php&back=db_tracking.php';
|
||||
}
|
||||
$url_query .= '&goto=tbl_tracking.php&back=db_tracking.php';
|
||||
|
||||
// Get the database structure
|
||||
$sub_part = '_structure';
|
||||
@@ -31,11 +34,12 @@ if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
|
||||
|
||||
/**
|
||||
* If in an Ajax request, generate the success message and use
|
||||
* {@link PMA_ajaxResponse()} to send the output
|
||||
* {@link PMA_Response()} to send the output
|
||||
*/
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
$message = PMA_Message::success();
|
||||
PMA_ajaxResponse($message, true);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addJSON('message', PMA_Message::success());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +53,6 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) {
|
||||
if (empty($db_is_information_schema)) {
|
||||
include 'libraries/display_create_table.lib.php';
|
||||
}
|
||||
|
||||
// Display the footer
|
||||
include 'libraries/footer.inc.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -228,8 +229,4 @@ if (count($data['ddlog']) > 0) {
|
||||
echo PMA_getMessage(__('Database Log'), $log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
?>
|
||||
|
||||
@@ -10,13 +10,15 @@
|
||||
* Include required files
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/common.lib.php';
|
||||
|
||||
/**
|
||||
* Include JavaScript libraries
|
||||
*/
|
||||
$GLOBALS['js_include'][] = 'rte/common.js';
|
||||
$GLOBALS['js_include'][] = 'rte/triggers.js';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('rte/common.js');
|
||||
$scripts->addFile('rte/triggers.js');
|
||||
|
||||
/**
|
||||
* Include all other files
|
||||
|
||||
219
export.php
219
export.php
@@ -2,6 +2,7 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Main export handling code
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
@@ -71,7 +72,9 @@ if ($_REQUEST['output_format'] == 'astext') {
|
||||
$compression = $_REQUEST['compression'];
|
||||
$buffer_needed = true;
|
||||
}
|
||||
if (($quick_export && !empty($_REQUEST['quick_export_onserver'])) || (!$quick_export && !empty($_REQUEST['onserver']))) {
|
||||
if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
|
||||
|| (! $quick_export && ! empty($_REQUEST['onserver']))
|
||||
) {
|
||||
if ($quick_export) {
|
||||
$onserver = $_REQUEST['quick_export_onserver'];
|
||||
} else {
|
||||
@@ -85,7 +88,6 @@ if ($_REQUEST['output_format'] == 'astext') {
|
||||
// Does export require to be into file?
|
||||
if (isset($export_list[$type]['force_file']) && ! $asfile) {
|
||||
$message = PMA_Message::error(__('Selected export type has to be saved in file!'));
|
||||
include_once 'libraries/header.inc.php';
|
||||
if ($export_type == 'server') {
|
||||
$active_page = 'server_export.php';
|
||||
include 'server_export.php';
|
||||
@@ -123,7 +125,7 @@ require 'libraries/export/' . PMA_securePath($type) . '.php';
|
||||
* Increase time limit for script execution and initializes some variables
|
||||
*/
|
||||
@set_time_limit($cfg['ExecTimeLimit']);
|
||||
if (!empty($cfg['MemoryLimit'])) {
|
||||
if (! empty($cfg['MemoryLimit'])) {
|
||||
@ini_set('memory_limit', $cfg['MemoryLimit']);
|
||||
}
|
||||
|
||||
@@ -149,7 +151,11 @@ function PMA_exportOutputHandler($line)
|
||||
|
||||
// Kanji encoding convert feature
|
||||
if ($GLOBALS['output_kanji_conversion']) {
|
||||
$line = PMA_kanji_str_conv($line, $GLOBALS['knjenc'], isset($GLOBALS['xkana']) ? $GLOBALS['xkana'] : '');
|
||||
$line = PMA_kanji_str_conv(
|
||||
$line,
|
||||
$GLOBALS['knjenc'],
|
||||
isset($GLOBALS['xkana']) ? $GLOBALS['xkana'] : ''
|
||||
);
|
||||
}
|
||||
// If we have to buffer data, we will perform everything at once at the end
|
||||
if ($GLOBALS['buffer_needed']) {
|
||||
@@ -161,20 +167,30 @@ function PMA_exportOutputHandler($line)
|
||||
|
||||
if ($dump_buffer_len > $GLOBALS['memory_limit']) {
|
||||
if ($GLOBALS['output_charset_conversion']) {
|
||||
$dump_buffer = PMA_convert_string('utf-8', $GLOBALS['charset_of_file'], $dump_buffer);
|
||||
$dump_buffer = PMA_convert_string(
|
||||
'utf-8',
|
||||
$GLOBALS['charset_of_file'],
|
||||
$dump_buffer
|
||||
);
|
||||
}
|
||||
// as bzipped
|
||||
if ($GLOBALS['compression'] == 'bzip2' && @function_exists('bzcompress')) {
|
||||
if ($GLOBALS['compression'] == 'bzip2'
|
||||
&& @function_exists('bzcompress')
|
||||
) {
|
||||
$dump_buffer = bzcompress($dump_buffer);
|
||||
} elseif ($GLOBALS['compression'] == 'gzip' && @function_exists('gzencode')) {
|
||||
} elseif ($GLOBALS['compression'] == 'gzip'
|
||||
&& @function_exists('gzencode')
|
||||
) {
|
||||
// as a gzipped file
|
||||
// without the optional parameter level because it bug
|
||||
$dump_buffer = gzencode($dump_buffer);
|
||||
}
|
||||
if ($GLOBALS['save_on_server']) {
|
||||
$write_result = @fwrite($GLOBALS['file_handle'], $dump_buffer);
|
||||
if (!$write_result || ($write_result != strlen($dump_buffer))) {
|
||||
$GLOBALS['message'] = PMA_Message::error(__('Insufficient space to save the file %s.'));
|
||||
if (! $write_result || ($write_result != strlen($dump_buffer))) {
|
||||
$GLOBALS['message'] = PMA_Message::error(
|
||||
__('Insufficient space to save the file %s.')
|
||||
);
|
||||
$GLOBALS['message']->addParam($save_filename);
|
||||
return false;
|
||||
}
|
||||
@@ -194,12 +210,18 @@ function PMA_exportOutputHandler($line)
|
||||
} else {
|
||||
if ($GLOBALS['asfile']) {
|
||||
if ($GLOBALS['output_charset_conversion']) {
|
||||
$line = PMA_convert_string('utf-8', $GLOBALS['charset_of_file'], $line);
|
||||
$line = PMA_convert_string(
|
||||
'utf-8',
|
||||
$GLOBALS['charset_of_file'],
|
||||
$line
|
||||
);
|
||||
}
|
||||
if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
|
||||
$write_result = @fwrite($GLOBALS['file_handle'], $line);
|
||||
if (!$write_result || ($write_result != strlen($line))) {
|
||||
$GLOBALS['message'] = PMA_Message::error(__('Insufficient space to save the file %s.'));
|
||||
if (! $write_result || ($write_result != strlen($line))) {
|
||||
$GLOBALS['message'] = PMA_Message::error(
|
||||
__('Insufficient space to save the file %s.')
|
||||
);
|
||||
$GLOBALS['message']->addParam($save_filename);
|
||||
return false;
|
||||
}
|
||||
@@ -220,7 +242,8 @@ function PMA_exportOutputHandler($line)
|
||||
return true;
|
||||
} // end of the 'PMA_exportOutputHandler()' function
|
||||
|
||||
// Defines the default <CR><LF> format. For SQL always use \n as MySQL wants this on all platforms.
|
||||
// Defines the default <CR><LF> format.
|
||||
// For SQL always use \n as MySQL wants this on all platforms.
|
||||
if ($what == 'sql') {
|
||||
$crlf = "\n";
|
||||
} else {
|
||||
@@ -230,12 +253,14 @@ if ($what == 'sql') {
|
||||
$output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
|
||||
|
||||
// Do we need to convert charset?
|
||||
$output_charset_conversion = $asfile && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
|
||||
$output_charset_conversion = $asfile
|
||||
&& $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
|
||||
&& isset($charset_of_file) && $charset_of_file != 'utf-8'
|
||||
&& $type != 'xls';
|
||||
|
||||
// Use on the fly compression?
|
||||
$onfly_compression = $GLOBALS['cfg']['CompressOnFly'] && ($compression == 'gzip' || $compression == 'bzip2');
|
||||
$onfly_compression = $GLOBALS['cfg']['CompressOnFly']
|
||||
&& ($compression == 'gzip' || $compression == 'bzip2');
|
||||
if ($onfly_compression) {
|
||||
$memory_limit = trim(@ini_get('memory_limit'));
|
||||
// 2 MB as default
|
||||
@@ -296,7 +321,8 @@ if ($asfile) {
|
||||
$filename = PMA_sanitize_filename($filename);
|
||||
|
||||
// Grab basic dump extension and mime type
|
||||
// Check if the user already added extension; get the substring where the extension would be if it was included
|
||||
// Check if the user already added extension;
|
||||
// get the substring where the extension would be if it was included
|
||||
$extension_start_pos = strlen($filename) - strlen($export_list[$type]['extension']) - 1;
|
||||
$user_extension = substr($filename, $extension_start_pos, strlen($filename));
|
||||
$required_extension = "." . $export_list[$type]['extension'];
|
||||
@@ -321,24 +347,27 @@ if ($asfile) {
|
||||
|
||||
// Open file on server if needed
|
||||
if ($save_on_server) {
|
||||
$save_filename = PMA_userDir($cfg['SaveDir']) . preg_replace('@[/\\\\]@', '_', $filename);
|
||||
$save_filename = PMA_userDir($cfg['SaveDir'])
|
||||
. preg_replace('@[/\\\\]@', '_', $filename);
|
||||
unset($message);
|
||||
if (file_exists($save_filename) && ((!$quick_export && empty($onserverover)) || ($quick_export && $_REQUEST['quick_export_onserverover'] != 'saveitover'))) {
|
||||
if (file_exists($save_filename)
|
||||
&& ((! $quick_export && empty($onserverover))
|
||||
|| ($quick_export && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
|
||||
) {
|
||||
$message = PMA_Message::error(__('File %s already exists on server, change filename or check overwrite option.'));
|
||||
$message->addParam($save_filename);
|
||||
} else {
|
||||
if (is_file($save_filename) && !is_writable($save_filename)) {
|
||||
if (is_file($save_filename) && ! is_writable($save_filename)) {
|
||||
$message = PMA_Message::error(__('The web server does not have permission to save the file %s.'));
|
||||
$message->addParam($save_filename);
|
||||
} else {
|
||||
if (!$file_handle = @fopen($save_filename, 'w')) {
|
||||
if (! $file_handle = @fopen($save_filename, 'w')) {
|
||||
$message = PMA_Message::error(__('The web server does not have permission to save the file %s.'));
|
||||
$message->addParam($save_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($message)) {
|
||||
include_once 'libraries/header.inc.php';
|
||||
if ($export_type == 'server') {
|
||||
$active_page = 'server_export.php';
|
||||
include 'server_export.php';
|
||||
@@ -357,7 +386,7 @@ if ($save_on_server) {
|
||||
* Send headers depending on whether the user chose to download a dump file
|
||||
* or not
|
||||
*/
|
||||
if (!$save_on_server) {
|
||||
if (! $save_on_server) {
|
||||
if ($asfile) {
|
||||
// Download
|
||||
// (avoid rewriting data containing HTML with anchors and forms;
|
||||
@@ -365,28 +394,27 @@ if (!$save_on_server) {
|
||||
@ini_set('url_rewriter.tags', '');
|
||||
$filename = PMA_sanitize_filename($filename);
|
||||
|
||||
PMA_download_header($filename, $mime_type);
|
||||
PMA_downloadHeader($filename, $mime_type);
|
||||
} else {
|
||||
// HTML
|
||||
if ($export_type == 'database') {
|
||||
$num_tables = count($tables);
|
||||
if ($num_tables == 0) {
|
||||
$message = PMA_Message::error(__('No tables found in database.'));
|
||||
include_once 'libraries/header.inc.php';
|
||||
$active_page = 'db_export.php';
|
||||
include 'db_export.php';
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$backup_cfgServer = $cfg['Server'];
|
||||
include_once 'libraries/header.inc.php';
|
||||
$cfg['Server'] = $backup_cfgServer;
|
||||
unset($backup_cfgServer);
|
||||
echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
|
||||
//echo ' <pre>' . "\n";
|
||||
|
||||
/**
|
||||
* Displays a back button with all the $_REQUEST data in the URL (store in a variable to also display after the textarea)
|
||||
* Displays a back button with all the $_REQUEST data in the URL
|
||||
* (store in a variable to also display after the textarea)
|
||||
*/
|
||||
$back_button = '<p>[ <a href="';
|
||||
if ($export_type == 'server') {
|
||||
@@ -424,7 +452,7 @@ if (!$save_on_server) {
|
||||
do {
|
||||
|
||||
// Add possibly some comments to export
|
||||
if (!PMA_exportHeader()) {
|
||||
if (! PMA_exportHeader()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -453,29 +481,35 @@ do {
|
||||
}
|
||||
// Walk over databases
|
||||
foreach ($GLOBALS['pma']->databases as $current_db) {
|
||||
if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
|
||||
if ((isset($tmp_select)
|
||||
&& strpos(' ' . $tmp_select, '|' . $current_db . '|'))
|
||||
|| ! isset($tmp_select)
|
||||
) {
|
||||
if (!PMA_exportDBHeader($current_db)) {
|
||||
if (! PMA_exportDBHeader($current_db)) {
|
||||
break 2;
|
||||
}
|
||||
if (!PMA_exportDBCreate($current_db)) {
|
||||
if (! PMA_exportDBCreate($current_db)) {
|
||||
break 2;
|
||||
}
|
||||
if (function_exists('PMA_exportRoutines') && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && isset($GLOBALS['sql_procedure_function'])) {
|
||||
if (function_exists('PMA_exportRoutines')
|
||||
&& strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
|
||||
&& isset($GLOBALS['sql_procedure_function'])
|
||||
) {
|
||||
PMA_exportRoutines($current_db);
|
||||
}
|
||||
|
||||
$tables = PMA_DBI_get_tables($current_db);
|
||||
$views = array();
|
||||
foreach ($tables as $table) {
|
||||
// if this is a view, collect it for later; views must be exported
|
||||
// after the tables
|
||||
// if this is a view, collect it for later;
|
||||
// views must be exported after the tables
|
||||
$is_view = PMA_Table::isView($current_db, $table);
|
||||
if ($is_view) {
|
||||
$views[] = $table;
|
||||
}
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
// for a view, export a stand-in definition of the table
|
||||
// to resolve view dependencies
|
||||
if (! PMA_exportStructure(
|
||||
@@ -487,15 +521,21 @@ do {
|
||||
}
|
||||
}
|
||||
// if this is a view or a merge table, don't export data
|
||||
if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && !($is_view || PMA_Table::isMerge($current_db, $table))) {
|
||||
$local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
|
||||
if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
|
||||
if (($GLOBALS[$what . '_structure_or_data'] == 'data'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
|
||||
&& ! ($is_view || PMA_Table::isMerge($current_db, $table))
|
||||
) {
|
||||
$local_query = 'SELECT * FROM ' . PMA_backquote($current_db)
|
||||
. '.' . PMA_backquote($table);
|
||||
if (! PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
// now export the triggers (needs to be done after the data because
|
||||
// triggers can modify already imported tables)
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
// now export the triggers (needs to be done after the data
|
||||
// because triggers can modify already imported tables)
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! PMA_exportStructure(
|
||||
$current_db, $table, $crlf, $err_url,
|
||||
'triggers', $export_type,
|
||||
@@ -507,7 +547,9 @@ do {
|
||||
}
|
||||
foreach ($views as $view) {
|
||||
// no data export for a view
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! PMA_exportStructure(
|
||||
$current_db, $view, $crlf, $err_url,
|
||||
'create_view', $export_type,
|
||||
@@ -517,17 +559,20 @@ do {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!PMA_exportDBFooter($current_db)) {
|
||||
if (! PMA_exportDBFooter($current_db)) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($export_type == 'database') {
|
||||
if (!PMA_exportDBHeader($db)) {
|
||||
if (! PMA_exportDBHeader($db)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (function_exists('PMA_exportRoutines') && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && isset($GLOBALS['sql_procedure_function'])) {
|
||||
if (function_exists('PMA_exportRoutines')
|
||||
&& strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
|
||||
&& isset($GLOBALS['sql_procedure_function'])
|
||||
) {
|
||||
PMA_exportRoutines($db);
|
||||
}
|
||||
|
||||
@@ -541,7 +586,9 @@ do {
|
||||
if ($is_view) {
|
||||
$views[] = $table;
|
||||
}
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
// for a view, export a stand-in definition of the table
|
||||
// to resolve view dependencies
|
||||
if (! PMA_exportStructure(
|
||||
@@ -553,15 +600,21 @@ do {
|
||||
}
|
||||
}
|
||||
// if this is a view or a merge table, don't export data
|
||||
if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && !($is_view || PMA_Table::isMerge($db, $table))) {
|
||||
$local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
|
||||
if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
|
||||
if (($GLOBALS[$what . '_structure_or_data'] == 'data'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
|
||||
&& ! ($is_view || PMA_Table::isMerge($db, $table))
|
||||
) {
|
||||
$local_query = 'SELECT * FROM ' . PMA_backquote($db)
|
||||
. '.' . PMA_backquote($table);
|
||||
if (! PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
// now export the triggers (needs to be done after the data because
|
||||
// triggers can modify already imported tables)
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! PMA_exportStructure(
|
||||
$db, $table, $crlf, $err_url,
|
||||
'triggers', $export_type,
|
||||
@@ -573,7 +626,9 @@ do {
|
||||
}
|
||||
foreach ($views as $view) {
|
||||
// no data export for a view
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! PMA_exportStructure(
|
||||
$db, $view, $crlf, $err_url,
|
||||
'create_view', $export_type,
|
||||
@@ -584,11 +639,11 @@ do {
|
||||
}
|
||||
}
|
||||
|
||||
if (!PMA_exportDBFooter($db)) {
|
||||
if (! PMA_exportDBFooter($db)) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (!PMA_exportDBHeader($db)) {
|
||||
if (! PMA_exportDBHeader($db)) {
|
||||
break;
|
||||
}
|
||||
// We export just one table
|
||||
@@ -602,7 +657,9 @@ do {
|
||||
}
|
||||
|
||||
$is_view = PMA_Table::isView($db, $table);
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! PMA_exportStructure(
|
||||
$db, $table, $crlf, $err_url,
|
||||
$is_view ? 'create_view' : 'create_table', $export_type,
|
||||
@@ -614,25 +671,31 @@ do {
|
||||
// If this is an export of a single view, we have to export data;
|
||||
// for example, a PDF report
|
||||
// if it is a merge table, no data is exported
|
||||
if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && ! PMA_Table::isMerge($db, $table)) {
|
||||
if (!empty($sql_query)) {
|
||||
if (($GLOBALS[$what . '_structure_or_data'] == 'data'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
|
||||
&& ! PMA_Table::isMerge($db, $table)
|
||||
) {
|
||||
if (! empty($sql_query)) {
|
||||
// only preg_replace if needed
|
||||
if (!empty($add_query)) {
|
||||
if (! empty($add_query)) {
|
||||
// remove trailing semicolon before adding a LIMIT
|
||||
$sql_query = preg_replace('%;\s*$%', '', $sql_query);
|
||||
}
|
||||
$local_query = $sql_query . $add_query;
|
||||
PMA_DBI_select_db($db);
|
||||
} else {
|
||||
$local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query;
|
||||
$local_query = 'SELECT * FROM ' . PMA_backquote($db)
|
||||
. '.' . PMA_backquote($table) . $add_query;
|
||||
}
|
||||
if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
|
||||
if (! PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// now export the triggers (needs to be done after the data because
|
||||
// triggers can modify already imported tables)
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! PMA_exportStructure(
|
||||
$db, $table, $crlf, $err_url,
|
||||
'triggers', $export_type,
|
||||
@@ -641,11 +704,11 @@ do {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
if (!PMA_exportDBFooter($db)) {
|
||||
if (! PMA_exportDBFooter($db)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!PMA_exportFooter()) {
|
||||
if (! PMA_exportFooter()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -653,7 +716,6 @@ do {
|
||||
// End of fake loop
|
||||
|
||||
if ($save_on_server && isset($message)) {
|
||||
include_once 'libraries/header.inc.php';
|
||||
if ($export_type == 'server') {
|
||||
$active_page = 'server_export.php';
|
||||
include 'server_export.php';
|
||||
@@ -670,10 +732,14 @@ if ($save_on_server && isset($message)) {
|
||||
/**
|
||||
* Send the dump as a file...
|
||||
*/
|
||||
if (!empty($asfile)) {
|
||||
if (! empty($asfile)) {
|
||||
// Convert the charset if required.
|
||||
if ($output_charset_conversion) {
|
||||
$dump_buffer = PMA_convert_string('utf-8', $GLOBALS['charset_of_file'], $dump_buffer);
|
||||
$dump_buffer = PMA_convert_string(
|
||||
'utf-8',
|
||||
$GLOBALS['charset_of_file'],
|
||||
$dump_buffer
|
||||
);
|
||||
}
|
||||
|
||||
// Do the compression
|
||||
@@ -691,23 +757,32 @@ if (!empty($asfile)) {
|
||||
}
|
||||
} elseif ($compression == 'gzip') {
|
||||
// 3. as a gzipped file
|
||||
if (@function_exists('gzencode') && !@ini_get('zlib.output_compression')) {
|
||||
if (@function_exists('gzencode') && ! @ini_get('zlib.output_compression')) {
|
||||
// without the optional parameter level because it bug
|
||||
$dump_buffer = gzencode($dump_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/* If ve saved on server, we have to close file now */
|
||||
/* If we saved on server, we have to close file now */
|
||||
if ($save_on_server) {
|
||||
$write_result = @fwrite($file_handle, $dump_buffer);
|
||||
fclose($file_handle);
|
||||
if (strlen($dump_buffer) !=0 && (!$write_result || ($write_result != strlen($dump_buffer)))) {
|
||||
$message = new PMA_Message(__('Insufficient space to save the file %s.'), PMA_Message::ERROR, $save_filename);
|
||||
if (strlen($dump_buffer) !=0
|
||||
&& (! $write_result || ($write_result != strlen($dump_buffer)))
|
||||
) {
|
||||
$message = new PMA_Message(
|
||||
__('Insufficient space to save the file %s.'),
|
||||
PMA_Message::ERROR,
|
||||
$save_filename
|
||||
);
|
||||
} else {
|
||||
$message = new PMA_Message(__('Dump has been saved to file %s.'), PMA_Message::SUCCESS, $save_filename);
|
||||
$message = new PMA_Message(
|
||||
__('Dump has been saved to file %s.'),
|
||||
PMA_Message::SUCCESS,
|
||||
$save_filename
|
||||
);
|
||||
}
|
||||
|
||||
include_once 'libraries/header.inc.php';
|
||||
if ($export_type == 'server') {
|
||||
$active_page = 'server_export.php';
|
||||
include_once 'server_export.php';
|
||||
@@ -720,6 +795,7 @@ if (!empty($asfile)) {
|
||||
}
|
||||
exit();
|
||||
} else {
|
||||
PMA_Response::getInstance()->disable();
|
||||
echo $dump_buffer;
|
||||
}
|
||||
} else {
|
||||
@@ -742,7 +818,7 @@ if (!empty($asfile)) {
|
||||
if (document.getElementById('textSQLDUMP')) {
|
||||
bodyWidth = self.innerWidth;
|
||||
bodyHeight = self.innerHeight;
|
||||
if (!bodyWidth && !bodyHeight) {
|
||||
if (! bodyWidth && ! bodyHeight) {
|
||||
if (document.compatMode && document.compatMode == "BackCompat") {
|
||||
bodyWidth = document.body.clientWidth;
|
||||
bodyHeight = document.body.clientHeight;
|
||||
@@ -757,6 +833,5 @@ if (!empty($asfile)) {
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
include 'libraries/footer.inc.php';
|
||||
} // end if
|
||||
?>
|
||||
|
||||
@@ -54,13 +54,13 @@ if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) {
|
||||
/* Send data */
|
||||
echo $data;
|
||||
|
||||
/* For monitor chart config export */
|
||||
} else if (isset($_REQUEST['monitorconfig'])) {
|
||||
/* For monitor chart config export */
|
||||
PMA_download_header('monitor.cfg', 'application/force-download');
|
||||
echo urldecode($_REQUEST['monitorconfig']);
|
||||
|
||||
/* For monitor chart config import */
|
||||
} else if (isset($_REQUEST['import'])) {
|
||||
/* For monitor chart config import */
|
||||
header('Content-type: text/plain');
|
||||
if (!file_exists($_FILES['file']['tmp_name'])) {
|
||||
exit();
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! isset($_REQUEST['get_gis_editor']) && ! isset($_REQUEST['generate'])) {
|
||||
include_once 'libraries/header_http.inc.php';
|
||||
include_once 'libraries/header_meta_style.inc.php';
|
||||
}
|
||||
require_once 'libraries/gis/pma_gis_factory.php';
|
||||
require_once 'libraries/gis_visualization.lib.php';
|
||||
|
||||
@@ -66,18 +62,12 @@ if (isset($_REQUEST['generate']) && $_REQUEST['generate'] == true) {
|
||||
'visualization' => $visualization,
|
||||
'openLayers' => $open_layers,
|
||||
);
|
||||
PMA_ajaxResponse(null, true, $extra_data);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addJSON($extra_data);
|
||||
exit;
|
||||
}
|
||||
|
||||
// If the call is to get the whole content, start buffering, skipping </head> and <body> tags
|
||||
if (isset($_REQUEST['get_gis_editor']) && $_REQUEST['get_gis_editor'] == true) {
|
||||
ob_start();
|
||||
} else {
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
}
|
||||
ob_start();
|
||||
?>
|
||||
<form id="gis_data_editor_form" action="gis_data_editor.php" method="post">
|
||||
<input type="hidden" id="pmaThemeImage" value="<?php echo($GLOBALS['pmaThemeImage']); ?>" />
|
||||
@@ -323,18 +313,7 @@ if (isset($_REQUEST['get_gis_editor']) && $_REQUEST['get_gis_editor'] == true) {
|
||||
</form>
|
||||
<?php
|
||||
|
||||
// If the call is to get the whole content, get the content in the buffer and make and AJAX response.
|
||||
if (isset($_REQUEST['get_gis_editor']) && $_REQUEST['get_gis_editor'] == true) {
|
||||
$extra_data['gis_editor'] = ob_get_contents();
|
||||
PMA_ajaxResponse(null, ob_end_clean(), $extra_data);
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
require 'libraries/footer.inc.php';
|
||||
PMA_Response::getInstance()->addJSON('gis_editor', ob_get_contents());
|
||||
ob_end_clean();
|
||||
|
||||
?>
|
||||
|
||||
203
import.php
203
import.php
@@ -47,7 +47,8 @@ $_SESSION['Import_message']['go_back_url'] = null;
|
||||
// default values
|
||||
$GLOBALS['reload'] = false;
|
||||
|
||||
// Are we just executing plain query or sql file? (eg. non import, but query box/window run)
|
||||
// Are we just executing plain query or sql file?
|
||||
// (eg. non import, but query box/window run)
|
||||
if (! empty($sql_query)) {
|
||||
// run SQL query
|
||||
$import_text = $sql_query;
|
||||
@@ -82,7 +83,6 @@ if (! empty($sql_query)) {
|
||||
// upload limit has been reached, let's assume the second possibility.
|
||||
;
|
||||
if ($_POST == array() && $_GET == array()) {
|
||||
include_once 'libraries/header.inc.php';
|
||||
$message = PMA_Message::error(__('You probably tried to upload too large file. Please refer to %sdocumentation%s for ways to workaround this limit.'));
|
||||
$message->addParam('[a@./Documentation.html#faq1_16@_blank]');
|
||||
$message->addParam('[/a]');
|
||||
@@ -92,7 +92,7 @@ if ($_POST == array() && $_GET == array()) {
|
||||
$_SESSION['Import_message']['go_back_url'] = $goto;
|
||||
|
||||
$message->display();
|
||||
include 'libraries/footer.inc.php';
|
||||
exit; // the footer is displayed automatically
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,9 +151,10 @@ if ($import_type == 'table') {
|
||||
} else {
|
||||
$common = PMA_generate_common_url();
|
||||
}
|
||||
$err_url = $goto
|
||||
. '?' . $common
|
||||
. (preg_match('@^tbl_[a-z]*\.php$@', $goto) ? '&table=' . htmlspecialchars($table) : '');
|
||||
$err_url = $goto . '?' . $common
|
||||
. (preg_match('@^tbl_[a-z]*\.php$@', $goto)
|
||||
? '&table=' . htmlspecialchars($table)
|
||||
: '');
|
||||
$_SESSION['Import_message']['go_back_url'] = $err_url;
|
||||
}
|
||||
|
||||
@@ -196,42 +197,57 @@ if (! empty($id_bookmark)) {
|
||||
$id_bookmark = (int)$id_bookmark;
|
||||
include_once 'libraries/bookmark.lib.php';
|
||||
switch ($action_bookmark) {
|
||||
case 0: // bookmarked query that have to be run
|
||||
$import_text = PMA_Bookmark_get($db, $id_bookmark, 'id', isset($action_bookmark_all));
|
||||
if (isset($bookmark_variable) && ! empty($bookmark_variable)) {
|
||||
$import_text = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddSlashes($bookmark_variable) . '${2}', $import_text);
|
||||
}
|
||||
case 0: // bookmarked query that have to be run
|
||||
$import_text = PMA_Bookmark_get(
|
||||
$db,
|
||||
$id_bookmark,
|
||||
'id',
|
||||
isset($action_bookmark_all)
|
||||
);
|
||||
if (isset($bookmark_variable) && ! empty($bookmark_variable)) {
|
||||
$import_text = preg_replace(
|
||||
'|/\*(.*)\[VARIABLE\](.*)\*/|imsU',
|
||||
'${1}' . PMA_sqlAddSlashes($bookmark_variable) . '${2}',
|
||||
$import_text
|
||||
);
|
||||
}
|
||||
|
||||
// refresh left frame on changes in table or db structure
|
||||
if (preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $import_text)) {
|
||||
$GLOBALS['reload'] = true;
|
||||
}
|
||||
// refresh left frame on changes in table or db structure
|
||||
if (preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $import_text)) {
|
||||
$GLOBALS['reload'] = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1: // bookmarked query that have to be displayed
|
||||
$import_text = PMA_Bookmark_get($db, $id_bookmark);
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
$extra_data['sql_query'] = $import_text;
|
||||
$extra_data['action_bookmark'] = $action_bookmark;
|
||||
$message = PMA_Message::success(__('Showing bookmark'));
|
||||
PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
|
||||
} else {
|
||||
$run_query = false;
|
||||
}
|
||||
break;
|
||||
case 2: // bookmarked query that have to be deleted
|
||||
$import_text = PMA_Bookmark_get($db, $id_bookmark);
|
||||
PMA_Bookmark_delete($db, $id_bookmark);
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
$message = PMA_Message::success(__('The bookmark has been deleted.'));
|
||||
$extra_data['action_bookmark'] = $action_bookmark;
|
||||
$extra_data['id_bookmark'] = $id_bookmark;
|
||||
PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
|
||||
} else {
|
||||
$run_query = false;
|
||||
$error = true; // this is kind of hack to skip processing the query
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 1: // bookmarked query that have to be displayed
|
||||
$import_text = PMA_Bookmark_get($db, $id_bookmark);
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
$message = PMA_Message::success(__('Showing bookmark'));
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess($message->isSuccess());
|
||||
$response->addJSON('message', $message);
|
||||
$response->addJSON('sql_query', $import_text);
|
||||
$response->addJSON('action_bookmark', $action_bookmark);
|
||||
exit;
|
||||
} else {
|
||||
$run_query = false;
|
||||
}
|
||||
break;
|
||||
case 2: // bookmarked query that have to be deleted
|
||||
$import_text = PMA_Bookmark_get($db, $id_bookmark);
|
||||
PMA_Bookmark_delete($db, $id_bookmark);
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
$message = PMA_Message::success(__('The bookmark has been deleted.'));
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess($message->isSuccess());
|
||||
$response->addJSON('message', $message);
|
||||
$response->addJSON('action_bookmark', $action_bookmark);
|
||||
$response->addJSON('id_bookmark', $id_bookmark);
|
||||
exit;
|
||||
} else {
|
||||
$run_query = false;
|
||||
$error = true; // this is kind of hack to skip processing the query
|
||||
}
|
||||
break;
|
||||
}
|
||||
} // end bookmarks reading
|
||||
|
||||
@@ -263,7 +279,8 @@ if (strtolower(substr($memory_limit, -1)) == 'm') {
|
||||
$memory_limit = (int)$memory_limit;
|
||||
}
|
||||
|
||||
$read_limit = $memory_limit / 8; // Just to be sure, there might be lot of memory needed for uncompression
|
||||
// Just to be sure, there might be lot of memory needed for uncompression
|
||||
$read_limit = $memory_limit / 8;
|
||||
|
||||
// handle filenames
|
||||
if (isset($_FILES['import_file'])) {
|
||||
@@ -316,51 +333,51 @@ if ($import_file != 'none' && ! $error) {
|
||||
$error = true;
|
||||
} else {
|
||||
switch ($compression) {
|
||||
case 'application/bzip2':
|
||||
if ($cfg['BZipDump'] && @function_exists('bzopen')) {
|
||||
$import_handle = @bzopen($import_file, 'r');
|
||||
} else {
|
||||
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
|
||||
$message->addParam($compression);
|
||||
$error = true;
|
||||
}
|
||||
break;
|
||||
case 'application/gzip':
|
||||
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
|
||||
$import_handle = @gzopen($import_file, 'r');
|
||||
} else {
|
||||
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
|
||||
$message->addParam($compression);
|
||||
$error = true;
|
||||
}
|
||||
break;
|
||||
case 'application/zip':
|
||||
if ($cfg['ZipDump'] && @function_exists('zip_open')) {
|
||||
/**
|
||||
* Load interface for zip extension.
|
||||
*/
|
||||
include_once 'libraries/zip_extension.lib.php';
|
||||
$result = PMA_getZipContents($import_file);
|
||||
if (! empty($result['error'])) {
|
||||
$message = PMA_Message::rawError($result['error']);
|
||||
$error = true;
|
||||
} else {
|
||||
$import_text = $result['data'];
|
||||
}
|
||||
} else {
|
||||
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
|
||||
$message->addParam($compression);
|
||||
$error = true;
|
||||
}
|
||||
break;
|
||||
case 'none':
|
||||
$import_handle = @fopen($import_file, 'r');
|
||||
break;
|
||||
default:
|
||||
case 'application/bzip2':
|
||||
if ($cfg['BZipDump'] && @function_exists('bzopen')) {
|
||||
$import_handle = @bzopen($import_file, 'r');
|
||||
} else {
|
||||
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
|
||||
$message->addParam($compression);
|
||||
$error = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'application/gzip':
|
||||
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
|
||||
$import_handle = @gzopen($import_file, 'r');
|
||||
} else {
|
||||
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
|
||||
$message->addParam($compression);
|
||||
$error = true;
|
||||
}
|
||||
break;
|
||||
case 'application/zip':
|
||||
if ($cfg['ZipDump'] && @function_exists('zip_open')) {
|
||||
/**
|
||||
* Load interface for zip extension.
|
||||
*/
|
||||
include_once 'libraries/zip_extension.lib.php';
|
||||
$result = PMA_getZipContents($import_file);
|
||||
if (! empty($result['error'])) {
|
||||
$message = PMA_Message::rawError($result['error']);
|
||||
$error = true;
|
||||
} else {
|
||||
$import_text = $result['data'];
|
||||
}
|
||||
} else {
|
||||
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
|
||||
$message->addParam($compression);
|
||||
$error = true;
|
||||
}
|
||||
break;
|
||||
case 'none':
|
||||
$import_handle = @fopen($import_file, 'r');
|
||||
break;
|
||||
default:
|
||||
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
|
||||
$message->addParam($compression);
|
||||
$error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// use isset() because zip compression type does not use a handle
|
||||
@@ -385,7 +402,8 @@ if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE && isset($charset_of_fil
|
||||
}
|
||||
} elseif (isset($charset_of_file) && $charset_of_file != 'utf8') {
|
||||
if (PMA_DRIZZLE) {
|
||||
// Drizzle doesn't support other character sets, so we can't fallback to SET NAMES - throw an error
|
||||
// Drizzle doesn't support other character sets,
|
||||
// so we can't fallback to SET NAMES - throw an error
|
||||
$error = true;
|
||||
$message = PMA_Message::error(__('Cannot convert file\'s character set without character set conversion library'));
|
||||
} else {
|
||||
@@ -401,7 +419,8 @@ if (! $error && isset($skip)) {
|
||||
$original_skip = $skip;
|
||||
while ($skip > 0) {
|
||||
PMA_importGetNextChunk($skip < $read_limit ? $skip : $read_limit);
|
||||
$read_multiply = 1; // Disable read progresivity, otherwise we eat all memory!
|
||||
// Disable read progresivity, otherwise we eat all memory!
|
||||
$read_multiply = 1;
|
||||
$skip -= $read_limit;
|
||||
}
|
||||
unset($skip);
|
||||
@@ -431,7 +450,9 @@ if ($file_to_unlink != '') {
|
||||
// Reset charset back, if we did some changes
|
||||
if ($reset_charset) {
|
||||
PMA_DBI_query('SET CHARACTER SET utf8');
|
||||
PMA_DBI_query('SET SESSION collation_connection =\'' . $collation_connection . '\'');
|
||||
PMA_DBI_query(
|
||||
'SET SESSION collation_connection =\'' . $collation_connection . '\''
|
||||
);
|
||||
}
|
||||
|
||||
// Show correct message
|
||||
@@ -442,7 +463,10 @@ if (! empty($id_bookmark) && $action_bookmark == 2) {
|
||||
} elseif (! empty($id_bookmark) && $action_bookmark == 1) {
|
||||
$message = PMA_Message::notice(__('Showing bookmark'));
|
||||
} elseif ($bookmark_created) {
|
||||
$special_message = '[br]' . sprintf(__('Bookmark %s created'), htmlspecialchars($bkm_label));
|
||||
$special_message = '[br]' . sprintf(
|
||||
__('Bookmark %s created'),
|
||||
htmlspecialchars($bkm_label)
|
||||
);
|
||||
} elseif ($finished && ! $error) {
|
||||
if ($import_type == 'query') {
|
||||
$message = PMA_Message::success();
|
||||
@@ -469,10 +493,10 @@ if ($timeout_passed) {
|
||||
}
|
||||
}
|
||||
|
||||
// if there is any message, copy it into $_SESSION as well, so we can obtain it by AJAX call
|
||||
// if there is any message, copy it into $_SESSION as well,
|
||||
// so we can obtain it by AJAX call
|
||||
if (isset($message)) {
|
||||
$_SESSION['Import_message']['message'] = $message->getDisplay();
|
||||
// $_SESSION['Import_message']['go_back_url'] = $goto.'?'. PMA_generate_common_url();
|
||||
}
|
||||
// Parse and analyze the query, for correct db and table name
|
||||
// in case of a query typed in the query window
|
||||
@@ -504,5 +528,4 @@ if ($go_sql) {
|
||||
$active_page = $goto;
|
||||
include '' . $goto;
|
||||
}
|
||||
exit();
|
||||
?>
|
||||
|
||||
@@ -97,14 +97,15 @@ foreach ($get_params as $one_get_param) {
|
||||
}
|
||||
|
||||
// AJAX requests can't be cached!
|
||||
PMA_no_cache_header();
|
||||
PMA_noCacheHeader();
|
||||
|
||||
// $GLOBALS["message"] is used for asking for an import message
|
||||
if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
|
||||
|
||||
header('Content-type: text/html');
|
||||
|
||||
// wait 0.3 sec before we check for $_SESSION variable, which is set inside import.php
|
||||
// wait 0.3 sec before we check for $_SESSION variable,
|
||||
// which is set inside import.php
|
||||
usleep(300000);
|
||||
|
||||
// wait until message is available
|
||||
@@ -114,7 +115,8 @@ if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
|
||||
|
||||
echo $_SESSION['Import_message']['message'];
|
||||
echo '<fieldset class="tblFooters">' . "\n";
|
||||
echo ' [ <a href="' . $_SESSION['Import_message']['go_back_url'] . '">' . __('Back') . '</a> ]' . "\n";
|
||||
echo ' [ <a href="' . $_SESSION['Import_message']['go_back_url']
|
||||
. '">' . __('Back') . '</a> ]' . "\n";
|
||||
echo '</fieldset>'."\n";
|
||||
|
||||
} else {
|
||||
|
||||
23
index.php
23
index.php
@@ -52,12 +52,17 @@ if (! strlen($GLOBALS['db'])) {
|
||||
} else {
|
||||
$_GET['db'] = $GLOBALS['db'];
|
||||
$_GET['table'] = $GLOBALS['table'];
|
||||
$main_target = ! empty($GLOBALS['goto']) ? $GLOBALS['goto'] : $GLOBALS['cfg']['DefaultTabTable'];
|
||||
$main_target = ! empty($GLOBALS['goto'])
|
||||
? $GLOBALS['goto']
|
||||
: $GLOBALS['cfg']['DefaultTabTable'];
|
||||
}
|
||||
|
||||
$url_query = PMA_generate_common_url($_GET);
|
||||
|
||||
if (! empty($_REQUEST['target']) && is_string($_REQUEST['target']) && in_array($_REQUEST['target'], $goto_whitelist)) {
|
||||
if (! empty($_REQUEST['target'])
|
||||
&& is_string($_REQUEST['target'])
|
||||
&& in_array($_REQUEST['target'], $goto_whitelist)
|
||||
) {
|
||||
$main_target = $_REQUEST['target'];
|
||||
}
|
||||
|
||||
@@ -67,7 +72,11 @@ $lang_iso_code = $GLOBALS['available_languages'][$GLOBALS['lang']][1];
|
||||
|
||||
|
||||
// start output
|
||||
require 'libraries/header_http.inc.php';
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$header->sendHttpHeaders();
|
||||
$response->disable();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
@@ -130,9 +139,11 @@ require 'libraries/header_http.inc.php';
|
||||
// ]]>
|
||||
</script>
|
||||
<?php
|
||||
echo PMA_includeJS('jquery/jquery-1.6.2.js');
|
||||
echo PMA_includeJS('update-location.js');
|
||||
echo PMA_includeJS('common.js');
|
||||
$scripts = new PMA_Scripts();
|
||||
$scripts->addFile('jquery/jquery-1.6.2.js');
|
||||
$scripts->addFile('update-location.js');
|
||||
$scripts->addFile('common.js');
|
||||
echo $scripts->getDisplay();
|
||||
?>
|
||||
</head>
|
||||
<frameset cols="<?php
|
||||
|
||||
@@ -159,7 +159,7 @@ function markDbTable(db, table)
|
||||
}
|
||||
|
||||
/**
|
||||
* sets current selected server, table and db (called from libraries/footer.inc.php)
|
||||
* sets current selected server, table and db (called from the footer)
|
||||
*/
|
||||
function setAll( new_lang, new_collation_connection, new_server, new_db, new_table, new_token )
|
||||
{
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
// default values for fields
|
||||
var defaultValues = {};
|
||||
|
||||
// language strings
|
||||
var PMA_messages = {};
|
||||
|
||||
/**
|
||||
* Returns field type
|
||||
*
|
||||
@@ -693,6 +690,7 @@ function savePrefsToLocalStorage(form)
|
||||
cache: false,
|
||||
type: 'POST',
|
||||
data: {
|
||||
ajax_request: true,
|
||||
token: form.find('input[name=token]').val(),
|
||||
submit_get_json: true
|
||||
},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Conditionally called from libraries/header_scripts.inc.php
|
||||
* if third-party framing is not allowed
|
||||
* Conditionally included if third-party framing is not allowed
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -13,8 +12,7 @@ try {
|
||||
alert("Redirecting...");
|
||||
top.location.replace(self.document.URL.substring(0, self.document.URL.lastIndexOf("/")+1));
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
} catch(e) {
|
||||
alert("Redirecting... (error: " + e);
|
||||
top.location.replace(self.document.URL.substring(0, self.document.URL.lastIndexOf("/")+1));
|
||||
}
|
||||
|
||||
@@ -69,8 +69,7 @@ $(function() {
|
||||
$("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
|
||||
buttons: button_options
|
||||
}) //end dialog options
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}) // end $.get()
|
||||
@@ -106,8 +105,7 @@ $(function() {
|
||||
// not refresh it
|
||||
window.parent.refreshNavigation(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('#floating_menubar').after(data.error);
|
||||
}
|
||||
|
||||
@@ -131,8 +129,7 @@ $(function() {
|
||||
$.get($form.attr('action'), $form.serialize() + "&submitcollation=" + $form.find("input[name=submitcollation]").val(), function(data) {
|
||||
if(data.success == true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}) // end $.get()
|
||||
|
||||
@@ -193,10 +193,10 @@ $(function() {
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
|
||||
var url = $form.serialize() + "&submit_search=" + $("#buttonGo").val();
|
||||
$.post($form.attr('action'), url, function(response) {
|
||||
if (typeof response == 'string') {
|
||||
$.post($form.attr('action'), url, function(data) {
|
||||
if (data.success == true) {
|
||||
// found results
|
||||
$("#searchresults").html(response);
|
||||
$("#searchresults").html(data.message);
|
||||
|
||||
$('#togglesearchresultlink')
|
||||
// always start with the Show message
|
||||
@@ -219,7 +219,7 @@ $(function() {
|
||||
.show();
|
||||
} else {
|
||||
// error message (zero rows)
|
||||
$("#sqlqueryresults").html(response['message']);
|
||||
$("#sqlqueryresults").html(data.error);
|
||||
}
|
||||
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
|
||||
@@ -173,7 +173,7 @@ $(function() {
|
||||
}); // end dialog options
|
||||
} else {
|
||||
var $dialog = $div
|
||||
.append(data)
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
title: PMA_messages['strInsertTable'],
|
||||
height: 600,
|
||||
@@ -194,7 +194,7 @@ $(function() {
|
||||
$("table.insertRowTable").addClass("ajax");
|
||||
$("#buttonYes").addClass("ajax");
|
||||
$div = $("#insert_table_dialog");
|
||||
PMA_convertFootnotesToTooltips($div);
|
||||
PMA_showHints($div);
|
||||
}
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}); // end $.get()
|
||||
|
||||
260
js/functions.js
260
js/functions.js
@@ -157,10 +157,9 @@ function PMA_display_git_revision()
|
||||
$.get("main.php?token="
|
||||
+ $("input[type=hidden][name=token]").val()
|
||||
+ "&git_revision=1&ajax_request=true", function (data) {
|
||||
if (data.error != "undefined" && data.error) {
|
||||
return;
|
||||
if (data.success == true) {
|
||||
$(data.message).insertAfter('#li_pma_version');
|
||||
}
|
||||
$(data.message).insertAfter('#li_pma_version');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -617,15 +616,8 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Add a date/time picker to each element that needs it
|
||||
* (only when timepicker.js is loaded)
|
||||
*/
|
||||
if ($.timepicker != undefined) {
|
||||
$('input.datefield, input.datetimefield').each(function() {
|
||||
PMA_addDatepicker($(this));
|
||||
});
|
||||
}
|
||||
addDateTimePicker();
|
||||
|
||||
/**
|
||||
* Add attribute to text boxes for iOS devices (based on bugID: 3508912)
|
||||
*/
|
||||
@@ -834,6 +826,18 @@ function insertValueQuery()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a date/time picker to each element that needs it
|
||||
* (only when timepicker.js is loaded)
|
||||
*/
|
||||
function addDateTimePicker() {
|
||||
if ($.timepicker != undefined) {
|
||||
$('input.datefield, input.datetimefield').each(function() {
|
||||
PMA_addDatepicker($(this));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* listbox redirection
|
||||
*/
|
||||
@@ -1607,12 +1611,11 @@ function PMA_createTableDialog( $div, url , target)
|
||||
})// end dialog options
|
||||
//remove the redundant [Back] link in the error message.
|
||||
.find('fieldset').remove();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var size = getWindowSize();
|
||||
var timeout;
|
||||
$div
|
||||
.append(data)
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
dialogClass: 'create-table',
|
||||
resizable: false,
|
||||
@@ -1668,7 +1671,7 @@ function PMA_createTableDialog( $div, url , target)
|
||||
buttons: button_options
|
||||
}); // end dialog options
|
||||
}
|
||||
PMA_convertFootnotesToTooltips($div);
|
||||
PMA_showHints($div);
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}); // end $.get()
|
||||
|
||||
@@ -1725,7 +1728,7 @@ function PMA_createChart(passedSettings)
|
||||
thisChart.options.realtime.postData,
|
||||
function(data) {
|
||||
try {
|
||||
curValue = jQuery.parseJSON(data);
|
||||
curValue = jQuery.parseJSON(data.message);
|
||||
} catch (err) {
|
||||
if (thisChart.options.realtime.error) {
|
||||
thisChart.options.realtime.error(err);
|
||||
@@ -1830,7 +1833,7 @@ function PMA_createChart(passedSettings)
|
||||
|
||||
|
||||
/*
|
||||
* Creates a Profiling Chart. Used in sql.php and server_status.js
|
||||
* Creates a Profiling Chart. Used in server_status_monitor.js
|
||||
*/
|
||||
function PMA_createProfilingChart(data, options)
|
||||
{
|
||||
@@ -1866,6 +1869,48 @@ function PMA_createProfilingChart(data, options)
|
||||
}, options));
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a Profiling Chart with jqplot. Used in sql.js
|
||||
*/
|
||||
function PMA_createProfilingChartJqplot(target, data)
|
||||
{
|
||||
return $.jqplot(target, [data],
|
||||
{
|
||||
seriesDefaults: {
|
||||
renderer: $.jqplot.PieRenderer,
|
||||
rendererOptions: {
|
||||
showDataLabels: true
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: true,
|
||||
location: 'e'
|
||||
},
|
||||
// from http://tango.freedesktop.org/Tango_Icon_Theme_Guidelines#Color_Palette
|
||||
seriesColors: [
|
||||
'#fce94f',
|
||||
'#fcaf3e',
|
||||
'#e9b96e',
|
||||
'#8ae234',
|
||||
'#729fcf',
|
||||
'#ad7fa8',
|
||||
'#ef2929',
|
||||
'#eeeeec',
|
||||
'#888a85',
|
||||
'#c4a000',
|
||||
'#ce5c00',
|
||||
'#8f5902',
|
||||
'#4e9a06',
|
||||
'#204a87',
|
||||
'#5c3566',
|
||||
'#a40000',
|
||||
'#babdb6',
|
||||
'#2e3436'
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a profiling duration nicely (in us and ms time). Used in PMA_createProfilingChart() and server_status.js
|
||||
*
|
||||
@@ -2288,11 +2333,11 @@ $(function() {
|
||||
$.post($form.attr('action'), $form.serialize() + "&submit_num_fields=" + $(this).val(), function(data) {
|
||||
// if 'create_table_dialog' exists
|
||||
if ($("#create_table_dialog").length > 0) {
|
||||
$("#create_table_dialog").html(data);
|
||||
$("#create_table_dialog").html(data.message);
|
||||
}
|
||||
// if 'create_table_div' exists
|
||||
if ($("#create_table_div").length > 0) {
|
||||
$("#create_table_div").html(data);
|
||||
$("#create_table_div").html(data.message);
|
||||
}
|
||||
PMA_verifyColumnsProperties();
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
@@ -2328,7 +2373,7 @@ $(function() {
|
||||
$("<div id='sqlqueryresults'></div>").insertAfter("#floating_menubar");
|
||||
$("#sqlqueryresults").html(data.sql_query);
|
||||
$("#result_query .notice").remove();
|
||||
$("#result_query").prepend((data.message));
|
||||
$("#result_query").prepend(data.message);
|
||||
} else {
|
||||
var $temp_div = $("<div id='temp_div'></div>");
|
||||
$temp_div.html(data.error);
|
||||
@@ -2364,7 +2409,7 @@ $(function() {
|
||||
$("<div id='sqlqueryresults'></div>").insertAfter("#floating_menubar");
|
||||
$("#sqlqueryresults").html(data.sql_query);
|
||||
$("#result_query .notice").remove();
|
||||
$("#result_query").prepend((data.message));
|
||||
$("#result_query").prepend(data.message);
|
||||
$("#copyTable").find("select[name='target_db'] option").filterByValue(data.db).prop('selected', true);
|
||||
|
||||
//Refresh navigation frame when the table is coppied
|
||||
@@ -2372,10 +2417,7 @@ $(function() {
|
||||
window.parent.frame_navigation.location.reload();
|
||||
}
|
||||
} else {
|
||||
var $temp_div = $("<div id='temp_div'></div>");
|
||||
$temp_div.html(data.error);
|
||||
var $error = $temp_div.find("code").addClass("error");
|
||||
PMA_ajaxShowMessage($error, false);
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}
|
||||
@@ -2397,19 +2439,19 @@ $(function() {
|
||||
}
|
||||
//variables which stores the common attributes
|
||||
$.post(href[0], href[1]+"&ajax_request=true", function(data) {
|
||||
if (data.success == undefined) {
|
||||
var $temp_div = $("<div id='temp_div'></div>");
|
||||
$temp_div.html(data);
|
||||
var $success = $temp_div.find("#result_query .success");
|
||||
PMA_ajaxShowMessage($success);
|
||||
$("<div id='sqlqueryresults' class='ajax'></div>").insertAfter("#floating_menubar");
|
||||
$("#sqlqueryresults").html(data);
|
||||
PMA_init_slider();
|
||||
$("#sqlqueryresults").children("fieldset").remove();
|
||||
} else if (data.success == true ) {
|
||||
if (data.success == true && data.sql_query != undefined) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
$("<div id='sqlqueryresults' class='ajax'></div>").insertAfter("#floating_menubar");
|
||||
$("#sqlqueryresults").html(data.sql_query);
|
||||
} else if (data.success == true) {
|
||||
var $temp_div = $("<div id='temp_div'></div>");
|
||||
$temp_div.html(data.message);
|
||||
var $success = $temp_div.find("#result_query .success");
|
||||
PMA_ajaxShowMessage($success);
|
||||
$("<div id='sqlqueryresults' class='ajax'></div>").insertAfter("#floating_menubar");
|
||||
$("#sqlqueryresults").html(data.message);
|
||||
PMA_init_slider();
|
||||
$("#sqlqueryresults").children("fieldset").remove();
|
||||
} else {
|
||||
var $temp_div = $("<div id='temp_div'></div>");
|
||||
$temp_div.html(data.error);
|
||||
@@ -2488,14 +2530,53 @@ $(function() {
|
||||
if (window.parent && window.parent.frame_navigation) {
|
||||
window.parent.frame_navigation.location.reload();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end $().live()
|
||||
}); // end $() for Create Database
|
||||
|
||||
/**
|
||||
* Validates the password field in a form
|
||||
*
|
||||
* @see PMA_messages['strPasswordEmpty']
|
||||
* @see PMA_messages['strPasswordNotSame']
|
||||
* @param object $the_form The form to be validated
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_checkPassword($the_form)
|
||||
{
|
||||
// Did the user select 'no password'?
|
||||
if ($the_form.find('#nopass_1').is(':checked')) {
|
||||
return true;
|
||||
} else {
|
||||
var $pred = $the_form.find('#select_pred_password');
|
||||
if ($pred.length && ($pred.val() == 'none' || $pred.val() == 'keep')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var $password = $the_form.find('input[name=pma_pw]');
|
||||
var $password_repeat = $the_form.find('input[name=pma_pw2]');
|
||||
var alert_msg = false;
|
||||
|
||||
if ($password.val() == '') {
|
||||
alert_msg = PMA_messages['strPasswordEmpty'];
|
||||
} else if ($password.val() != $password_repeat.val()) {
|
||||
alert_msg = PMA_messages['strPasswordNotSame'];
|
||||
}
|
||||
|
||||
if (alert_msg) {
|
||||
alert(alert_msg);
|
||||
$password.val('');
|
||||
$password_repeat.val('');
|
||||
$password.focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach Ajax event handlers for 'Change Password' on main.php
|
||||
*/
|
||||
@@ -2505,16 +2586,11 @@ $(function() {
|
||||
* Attach Ajax event handler on the change password anchor
|
||||
* @see $cfg['AjaxEnable']
|
||||
*/
|
||||
$('#change_password_anchor.dialog_active').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
$('#change_password_anchor.ajax').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $msgbox = PMA_ajaxShowMessage();
|
||||
|
||||
$(this).removeClass('ajax').addClass('dialog_active');
|
||||
/**
|
||||
* @var button_options Object containing options to be passed to jQueryUI's dialog
|
||||
*/
|
||||
@@ -2528,6 +2604,10 @@ $(function() {
|
||||
*/
|
||||
var $the_form = $("#change_password_form");
|
||||
|
||||
if (! PMA_checkPassword($the_form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var this_value String containing the value of the submit button.
|
||||
* Need to append this for the change password form on Server Privileges
|
||||
@@ -2540,10 +2620,9 @@ $(function() {
|
||||
|
||||
$.post($the_form.attr('action'), $the_form.serialize() + '&change_pw='+ this_value, function(data) {
|
||||
if (data.success == true) {
|
||||
$("#floating_menubar").after(data.sql_query);
|
||||
$("#floating_menubar").after(data.message);
|
||||
$("#change_password_dialog").hide().remove();
|
||||
$("#edit_user_dialog").dialog("close").remove();
|
||||
$('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax');
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}
|
||||
else {
|
||||
@@ -2564,11 +2643,9 @@ $(function() {
|
||||
$(this).remove();
|
||||
},
|
||||
buttons : button_options,
|
||||
beforeClose: function(ev, ui) {
|
||||
$('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax');
|
||||
}
|
||||
modal: true
|
||||
})
|
||||
.append(data);
|
||||
.append(data.message);
|
||||
// for this dialog, we remove the fieldset wrapping due to double headings
|
||||
$("fieldset#fieldset_change_password")
|
||||
.find("legend").remove().end()
|
||||
@@ -2577,14 +2654,16 @@ $(function() {
|
||||
displayPasswordGenerateButton();
|
||||
$('#fieldset_change_password_footer').hide();
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
$('#change_password_form').bind('submit', function (e) {
|
||||
e.preventDefault();
|
||||
$(this)
|
||||
.closest('.ui-dialog')
|
||||
.find('.ui-dialog-buttonpane .ui-button')
|
||||
.first()
|
||||
.click();
|
||||
});
|
||||
}); // end $.get()
|
||||
}); // end handler for change password anchor
|
||||
|
||||
/**
|
||||
* Attach Ajax event handler for Change Password form submission
|
||||
*
|
||||
* @see $cfg['AjaxEnable']
|
||||
*/
|
||||
}); // end $() for Change Password
|
||||
|
||||
/**
|
||||
@@ -2829,10 +2908,6 @@ $(function() {
|
||||
});
|
||||
});
|
||||
|
||||
$(function() {
|
||||
PMA_convertFootnotesToTooltips();
|
||||
});
|
||||
|
||||
/**
|
||||
* Ensures indexes names are valid according to their type and, for a primary
|
||||
* key, lock index name to 'PRIMARY'
|
||||
@@ -2868,55 +2943,22 @@ function checkIndexName(form_id)
|
||||
} // end of the 'checkIndexName()' function
|
||||
|
||||
/**
|
||||
* function to convert the footnotes to tooltips
|
||||
* Function to display tooltips that were
|
||||
* generated on the PHP side by PMA_showHint()
|
||||
*
|
||||
* @param jquery-Object $div a div jquery object which specifies the
|
||||
* domain for searching footnootes. If we
|
||||
* ommit this parameter the function searches
|
||||
* the footnotes in the whole body
|
||||
* @param object $div a div jquery object which specifies the
|
||||
* domain for searching for tooltips. If we
|
||||
* omit this parameter the function searches
|
||||
* in the whole body
|
||||
**/
|
||||
function PMA_convertFootnotesToTooltips($div)
|
||||
function PMA_showHints($div)
|
||||
{
|
||||
// Hide the footnotes from the footer (which are displayed for
|
||||
// JavaScript-disabled browsers) since the tooltip is sufficient
|
||||
|
||||
if ($div == undefined || ! $div instanceof jQuery || $div.length == 0) {
|
||||
$div = $("body");
|
||||
}
|
||||
|
||||
$footnotes = $div.find(".footnotes");
|
||||
|
||||
$footnotes.hide();
|
||||
$footnotes.find('span').each(function() {
|
||||
$(this).children("sup").remove();
|
||||
});
|
||||
// The border and padding must be removed otherwise a thin yellow box remains visible
|
||||
$footnotes.css("border", "none");
|
||||
$footnotes.css("padding", "0px");
|
||||
|
||||
// Replace the superscripts with the help icon
|
||||
$div.find("sup.footnotemarker").hide();
|
||||
$div.find("img.footnotemarker").show();
|
||||
|
||||
$div.find("img.footnotemarker").each(function() {
|
||||
var img_class = $(this).attr("class");
|
||||
/** img contains two classes, as example "footnotemarker footnote_1".
|
||||
* We split it by second class and take it for the id of span
|
||||
*/
|
||||
img_class = img_class.split(" ");
|
||||
for (i = 0; i < img_class.length; i++) {
|
||||
if (img_class[i].split("_")[0] == "footnote") {
|
||||
var span_id = img_class[i].split("_")[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Now we get the #id of the span with span_id variable. As an example if we
|
||||
* initially get the img class as "footnotemarker footnote_2", now we get
|
||||
* #2 as the span_id. Using that we can find footnote_2 in footnotes.
|
||||
* */
|
||||
var tooltip_text = $footnotes.find("span#footnote_" + span_id).html();
|
||||
$(this).qtip({
|
||||
content: tooltip_text,
|
||||
$div.find('.pma_hint').each(function () {
|
||||
$(this).children('img').qtip({
|
||||
content: $(this).children('span').html(),
|
||||
show: { delay: 0 },
|
||||
hide: { delay: 1000 },
|
||||
style: { background: '#ffffcc' }
|
||||
@@ -2924,6 +2966,10 @@ function PMA_convertFootnotesToTooltips($div)
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
PMA_showHints();
|
||||
});
|
||||
|
||||
/**
|
||||
* This function handles the resizing of the content frame
|
||||
* and adjusts the top menu according to the new size of the frame
|
||||
@@ -3273,12 +3319,6 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Reveal visual builder anchor
|
||||
*/
|
||||
|
||||
$('#visual_builder_anchor').show();
|
||||
|
||||
/**
|
||||
* Page selector in db Structure (non-AJAX)
|
||||
*/
|
||||
@@ -3752,13 +3792,13 @@ $(document).ready(function () {
|
||||
buttonOptions[PMA_messages['strClose']] = function () {
|
||||
$(this).dialog("close");
|
||||
};
|
||||
var $dialog = $('<div/>').attr('id', 'createViewDialog').append(data).dialog({
|
||||
var $dialog = $('<div/>').attr('id', 'createViewDialog').append(data.message).dialog({
|
||||
width: 500,
|
||||
minWidth: 300,
|
||||
maxWidth: 620,
|
||||
modal: true,
|
||||
buttons: buttonOptions,
|
||||
title: $('legend', $(data)).html(),
|
||||
title: $('legend', $(data.message)).html(),
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
|
||||
@@ -142,7 +142,8 @@ function loadGISEditor(value, field, type, input_name, token) {
|
||||
'type' : type,
|
||||
'input_name' : input_name,
|
||||
'get_gis_editor' : true,
|
||||
'token' : token
|
||||
'token' : token,
|
||||
'ajax_request': true
|
||||
}, function(data) {
|
||||
if (data.success == true) {
|
||||
$gis_editor.html(data.gis_editor);
|
||||
@@ -190,7 +191,7 @@ function insertDataAndClose() {
|
||||
var $form = $('form#gis_data_editor_form');
|
||||
var input_name = $form.find("input[name='input_name']").val();
|
||||
|
||||
$.post('gis_data_editor.php', $form.serialize() + "&generate=true", function(data) {
|
||||
$.post('gis_data_editor.php', $form.serialize() + "&generate=true&ajax_request=true", function(data) {
|
||||
if(data.success == true) {
|
||||
$("input[name='" + input_name + "']").val(data.result);
|
||||
} else {
|
||||
@@ -226,7 +227,7 @@ $(function() {
|
||||
*/
|
||||
$('#gis_editor').find("input[type='text']").live('change', function() {
|
||||
var $form = $('form#gis_data_editor_form');
|
||||
$.post('gis_data_editor.php', $form.serialize() + "&generate=true", function(data) {
|
||||
$.post('gis_data_editor.php', $form.serialize() + "&generate=true&ajax_request=true", function(data) {
|
||||
if(data.success == true) {
|
||||
$('#gis_data_textarea').val(data.result);
|
||||
$('#placeholder').empty().removeClass('hasSVG').html(data.visualization);
|
||||
@@ -246,7 +247,7 @@ $(function() {
|
||||
var $gis_editor = $("#gis_editor");
|
||||
var $form = $('form#gis_data_editor_form');
|
||||
|
||||
$.post('gis_data_editor.php', $form.serialize() + "&get_gis_editor=true", function(data) {
|
||||
$.post('gis_data_editor.php', $form.serialize() + "&get_gis_editor=true&ajax_request=true", function(data) {
|
||||
if(data.success == true) {
|
||||
$gis_editor.html(data.gis_editor);
|
||||
initGISEditorVisualization();
|
||||
|
||||
10901
js/jqplot/jquery.jqplot.js
Normal file
10901
js/jqplot/jquery.jqplot.js
Normal file
File diff suppressed because it is too large
Load Diff
202
js/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js
Normal file
202
js/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js
Normal file
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* jqPlot
|
||||
* Pure JavaScript plotting plugin using jQuery
|
||||
*
|
||||
* Version: 1.0.0b2_r1012
|
||||
*
|
||||
* Copyright (c) 2009-2011 Chris Leonello
|
||||
* jqPlot is currently available for use in all personal or commercial projects
|
||||
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
||||
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
||||
* choose the license that best suits your project and use it accordingly.
|
||||
*
|
||||
* Although not required, the author would appreciate an email letting him
|
||||
* know of any substantial use of jqPlot. You can reach the author at:
|
||||
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
||||
*
|
||||
* If you are feeling kind and generous, consider supporting the project by
|
||||
* making a donation at: http://www.jqplot.com/donate.php .
|
||||
*
|
||||
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
||||
*
|
||||
* version 2007.04.27
|
||||
* author Ash Searle
|
||||
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
||||
* http://hexmen.com/js/sprintf.js
|
||||
* The author (Ash Searle) has placed this code in the public domain:
|
||||
* "This code is unrestricted: you are free to use it however you like."
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
/**
|
||||
* Class: $.jqplot.CanvasAxisLabelRenderer
|
||||
* Renderer to draw axis labels with a canvas element to support advanced
|
||||
* featrues such as rotated text. This renderer uses a separate rendering engine
|
||||
* to draw the text on the canvas. Two modes of rendering the text are available.
|
||||
* If the browser has native font support for canvas fonts (currently Mozila 3.5
|
||||
* and Safari 4), you can enable text rendering with the canvas fillText method.
|
||||
* You do so by setting the "enableFontSupport" option to true.
|
||||
*
|
||||
* Browsers lacking native font support will have the text drawn on the canvas
|
||||
* using the Hershey font metrics. Even if the "enableFontSupport" option is true
|
||||
* non-supporting browsers will still render with the Hershey font.
|
||||
*
|
||||
*/
|
||||
$.jqplot.CanvasAxisLabelRenderer = function(options) {
|
||||
// Group: Properties
|
||||
|
||||
// prop: angle
|
||||
// angle of text, measured clockwise from x axis.
|
||||
this.angle = 0;
|
||||
// name of the axis associated with this tick
|
||||
this.axis;
|
||||
// prop: show
|
||||
// wether or not to show the tick (mark and label).
|
||||
this.show = true;
|
||||
// prop: showLabel
|
||||
// wether or not to show the label.
|
||||
this.showLabel = true;
|
||||
// prop: label
|
||||
// label for the axis.
|
||||
this.label = '';
|
||||
// prop: fontFamily
|
||||
// CSS spec for the font-family css attribute.
|
||||
// Applies only to browsers supporting native font rendering in the
|
||||
// canvas tag. Currently Mozilla 3.5 and Safari 4.
|
||||
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
||||
// prop: fontSize
|
||||
// CSS spec for font size.
|
||||
this.fontSize = '11pt';
|
||||
// prop: fontWeight
|
||||
// CSS spec for fontWeight: normal, bold, bolder, lighter or a number 100 - 900
|
||||
this.fontWeight = 'normal';
|
||||
// prop: fontStretch
|
||||
// Multiplier to condense or expand font width.
|
||||
// Applies only to browsers which don't support canvas native font rendering.
|
||||
this.fontStretch = 1.0;
|
||||
// prop: textColor
|
||||
// css spec for the color attribute.
|
||||
this.textColor = '#666666';
|
||||
// prop: enableFontSupport
|
||||
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
||||
// If true, label will be drawn with canvas tag native support for fonts.
|
||||
// If false, label will be drawn with Hershey font metrics.
|
||||
this.enableFontSupport = true;
|
||||
// prop: pt2px
|
||||
// Point to pixel scaling factor, used for computing height of bounding box
|
||||
// around a label. The labels text renderer has a default setting of 1.4, which
|
||||
// should be suitable for most fonts. Leave as null to use default. If tops of
|
||||
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
||||
// This is an issue only with the native font renderering capabilities of Mozilla
|
||||
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
||||
this.pt2px = null;
|
||||
|
||||
this._elem;
|
||||
this._ctx;
|
||||
this._plotWidth;
|
||||
this._plotHeight;
|
||||
this._plotDimensions = {height:null, width:null};
|
||||
|
||||
$.extend(true, this, options);
|
||||
|
||||
if (options.angle == null && this.axis != 'xaxis' && this.axis != 'x2axis') {
|
||||
this.angle = -90;
|
||||
}
|
||||
|
||||
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
||||
if (this.pt2px) {
|
||||
ropts.pt2px = this.pt2px;
|
||||
}
|
||||
|
||||
if (this.enableFontSupport) {
|
||||
if ($.jqplot.support_canvas_text()) {
|
||||
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
||||
}
|
||||
|
||||
else {
|
||||
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
||||
}
|
||||
};
|
||||
|
||||
$.jqplot.CanvasAxisLabelRenderer.prototype.init = function(options) {
|
||||
$.extend(true, this, options);
|
||||
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
||||
};
|
||||
|
||||
// return width along the x axis
|
||||
// will check first to see if an element exists.
|
||||
// if not, will return the computed text box width.
|
||||
$.jqplot.CanvasAxisLabelRenderer.prototype.getWidth = function(ctx) {
|
||||
if (this._elem) {
|
||||
return this._elem.outerWidth(true);
|
||||
}
|
||||
else {
|
||||
var tr = this._textRenderer;
|
||||
var l = tr.getWidth(ctx);
|
||||
var h = tr.getHeight(ctx);
|
||||
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
||||
return w;
|
||||
}
|
||||
};
|
||||
|
||||
// return height along the y axis.
|
||||
$.jqplot.CanvasAxisLabelRenderer.prototype.getHeight = function(ctx) {
|
||||
if (this._elem) {
|
||||
return this._elem.outerHeight(true);
|
||||
}
|
||||
else {
|
||||
var tr = this._textRenderer;
|
||||
var l = tr.getWidth(ctx);
|
||||
var h = tr.getHeight(ctx);
|
||||
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
||||
return w;
|
||||
}
|
||||
};
|
||||
|
||||
$.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad = function() {
|
||||
var a = this.angle * Math.PI/180;
|
||||
return a;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasAxisLabelRenderer.prototype.draw = function(ctx, plot) {
|
||||
// Memory Leaks patch
|
||||
if (this._elem) {
|
||||
if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
|
||||
window.G_vmlCanvasManager.uninitElement(this._elem.get(0));
|
||||
}
|
||||
|
||||
this._elem.emptyForce();
|
||||
this._elem = null;
|
||||
}
|
||||
|
||||
// create a canvas here, but can't draw on it untill it is appended
|
||||
// to dom for IE compatability.
|
||||
var elem = plot.canvasManager.getCanvas();
|
||||
|
||||
this._textRenderer.setText(this.label, ctx);
|
||||
var w = this.getWidth(ctx);
|
||||
var h = this.getHeight(ctx);
|
||||
elem.width = w;
|
||||
elem.height = h;
|
||||
elem.style.width = w;
|
||||
elem.style.height = h;
|
||||
|
||||
elem = plot.canvasManager.initCanvas(elem);
|
||||
|
||||
this._elem = $(elem);
|
||||
this._elem.css({ position: 'absolute'});
|
||||
this._elem.addClass('jqplot-'+this.axis+'-label');
|
||||
|
||||
elem = null;
|
||||
return this._elem;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasAxisLabelRenderer.prototype.pack = function() {
|
||||
this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label);
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
448
js/jqplot/plugins/jqplot.canvasTextRenderer.js
Normal file
448
js/jqplot/plugins/jqplot.canvasTextRenderer.js
Normal file
@@ -0,0 +1,448 @@
|
||||
/**
|
||||
* jqPlot
|
||||
* Pure JavaScript plotting plugin using jQuery
|
||||
*
|
||||
* Version: 1.0.0b2_r1012
|
||||
*
|
||||
* Copyright (c) 2009-2011 Chris Leonello
|
||||
* jqPlot is currently available for use in all personal or commercial projects
|
||||
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
||||
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
||||
* choose the license that best suits your project and use it accordingly.
|
||||
*
|
||||
* Although not required, the author would appreciate an email letting him
|
||||
* know of any substantial use of jqPlot. You can reach the author at:
|
||||
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
||||
*
|
||||
* If you are feeling kind and generous, consider supporting the project by
|
||||
* making a donation at: http://www.jqplot.com/donate.php .
|
||||
*
|
||||
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
||||
*
|
||||
* version 2007.04.27
|
||||
* author Ash Searle
|
||||
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
||||
* http://hexmen.com/js/sprintf.js
|
||||
* The author (Ash Searle) has placed this code in the public domain:
|
||||
* "This code is unrestricted: you are free to use it however you like."
|
||||
*
|
||||
* included jsDate library by Chris Leonello:
|
||||
*
|
||||
* Copyright (c) 2010-2011 Chris Leonello
|
||||
*
|
||||
* jsDate is currently available for use in all personal or commercial projects
|
||||
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
||||
* choose the license that best suits your project and use it accordingly.
|
||||
*
|
||||
* jsDate borrows many concepts and ideas from the Date Instance
|
||||
* Methods by Ken Snyder along with some parts of Ken's actual code.
|
||||
*
|
||||
* Ken's origianl Date Instance Methods and copyright notice:
|
||||
*
|
||||
* Ken Snyder (ken d snyder at gmail dot com)
|
||||
* 2008-09-10
|
||||
* version 2.0.2 (http://kendsnyder.com/sandbox/date/)
|
||||
* Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
|
||||
*
|
||||
* jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
|
||||
* Larry has generously given permission to adapt his code for inclusion
|
||||
* into jqPlot.
|
||||
*
|
||||
* Larry's original code can be found here:
|
||||
*
|
||||
* https://github.com/lsiden/export-jqplot-to-png
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
// This code is a modified version of the canvastext.js code, copyright below:
|
||||
//
|
||||
// This code is released to the public domain by Jim Studt, 2007.
|
||||
// He may keep some sort of up to date copy at http://www.federated.com/~jim/canvastext/
|
||||
//
|
||||
$.jqplot.CanvasTextRenderer = function(options){
|
||||
this.fontStyle = 'normal'; // normal, italic, oblique [not implemented]
|
||||
this.fontVariant = 'normal'; // normal, small caps [not implemented]
|
||||
this.fontWeight = 'normal'; // normal, bold, bolder, lighter, 100 - 900
|
||||
this.fontSize = '10px';
|
||||
this.fontFamily = 'sans-serif';
|
||||
this.fontStretch = 1.0;
|
||||
this.fillStyle = '#666666';
|
||||
this.angle = 0;
|
||||
this.textAlign = 'start';
|
||||
this.textBaseline = 'alphabetic';
|
||||
this.text;
|
||||
this.width;
|
||||
this.height;
|
||||
this.pt2px = 1.28;
|
||||
|
||||
$.extend(true, this, options);
|
||||
this.normalizedFontSize = this.normalizeFontSize(this.fontSize);
|
||||
this.setHeight();
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.init = function(options) {
|
||||
$.extend(true, this, options);
|
||||
this.normalizedFontSize = this.normalizeFontSize(this.fontSize);
|
||||
this.setHeight();
|
||||
};
|
||||
|
||||
// convert css spec into point size
|
||||
// returns float
|
||||
$.jqplot.CanvasTextRenderer.prototype.normalizeFontSize = function(sz) {
|
||||
sz = String(sz);
|
||||
var n = parseFloat(sz);
|
||||
if (sz.indexOf('px') > -1) {
|
||||
return n/this.pt2px;
|
||||
}
|
||||
else if (sz.indexOf('pt') > -1) {
|
||||
return n;
|
||||
}
|
||||
else if (sz.indexOf('em') > -1) {
|
||||
return n*12;
|
||||
}
|
||||
else if (sz.indexOf('%') > -1) {
|
||||
return n*12/100;
|
||||
}
|
||||
// default to pixels;
|
||||
else {
|
||||
return n/this.pt2px;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.fontWeight2Float = function(w) {
|
||||
// w = normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
||||
// return values adjusted for Hershey font.
|
||||
if (Number(w)) {
|
||||
return w/400;
|
||||
}
|
||||
else {
|
||||
switch (w) {
|
||||
case 'normal':
|
||||
return 1;
|
||||
break;
|
||||
case 'bold':
|
||||
return 1.75;
|
||||
break;
|
||||
case 'bolder':
|
||||
return 2.25;
|
||||
break;
|
||||
case 'lighter':
|
||||
return 0.75;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.getText = function() {
|
||||
return this.text;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.setText = function(t, ctx) {
|
||||
this.text = t;
|
||||
this.setWidth(ctx);
|
||||
return this;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.getWidth = function(ctx) {
|
||||
return this.width;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.setWidth = function(ctx, w) {
|
||||
if (!w) {
|
||||
this.width = this.measure(ctx, this.text);
|
||||
}
|
||||
else {
|
||||
this.width = w;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
// return height in pixels.
|
||||
$.jqplot.CanvasTextRenderer.prototype.getHeight = function(ctx) {
|
||||
return this.height;
|
||||
};
|
||||
|
||||
// w - height in pt
|
||||
// set heigh in px
|
||||
$.jqplot.CanvasTextRenderer.prototype.setHeight = function(w) {
|
||||
if (!w) {
|
||||
//height = this.fontSize /0.75;
|
||||
this.height = this.normalizedFontSize * this.pt2px;
|
||||
}
|
||||
else {
|
||||
this.height = w;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.letter = function (ch)
|
||||
{
|
||||
return this.letters[ch];
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.ascent = function()
|
||||
{
|
||||
return this.normalizedFontSize;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.descent = function()
|
||||
{
|
||||
return 7.0*this.normalizedFontSize/25.0;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.measure = function(ctx, str)
|
||||
{
|
||||
var total = 0;
|
||||
var len = str.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var c = this.letter(str.charAt(i));
|
||||
if (c) {
|
||||
total += c.width * this.normalizedFontSize / 25.0 * this.fontStretch;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.draw = function(ctx,str)
|
||||
{
|
||||
var x = 0;
|
||||
// leave room at bottom for descenders.
|
||||
var y = this.height*0.72;
|
||||
var total = 0;
|
||||
var len = str.length;
|
||||
var mag = this.normalizedFontSize / 25.0;
|
||||
|
||||
ctx.save();
|
||||
var tx, ty;
|
||||
|
||||
// 1st quadrant
|
||||
if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) {
|
||||
tx = 0;
|
||||
ty = -Math.sin(this.angle) * this.width;
|
||||
}
|
||||
// 4th quadrant
|
||||
else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) {
|
||||
tx = Math.sin(this.angle) * this.height;
|
||||
ty = 0;
|
||||
}
|
||||
// 2nd quadrant
|
||||
else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) {
|
||||
tx = -Math.cos(this.angle) * this.width;
|
||||
ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height;
|
||||
}
|
||||
// 3rd quadrant
|
||||
else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) {
|
||||
tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width;
|
||||
ty = -Math.cos(this.angle) * this.height;
|
||||
}
|
||||
|
||||
ctx.strokeStyle = this.fillStyle;
|
||||
ctx.fillStyle = this.fillStyle;
|
||||
ctx.translate(tx, ty);
|
||||
ctx.rotate(this.angle);
|
||||
ctx.lineCap = "round";
|
||||
// multiplier was 2.0
|
||||
var fact = (this.normalizedFontSize > 30) ? 2.0 : 2 + (30 - this.normalizedFontSize)/20;
|
||||
ctx.lineWidth = fact * mag * this.fontWeight2Float(this.fontWeight);
|
||||
|
||||
for ( var i = 0; i < len; i++) {
|
||||
var c = this.letter( str.charAt(i));
|
||||
if ( !c) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
|
||||
var penUp = 1;
|
||||
var needStroke = 0;
|
||||
for ( var j = 0; j < c.points.length; j++) {
|
||||
var a = c.points[j];
|
||||
if ( a[0] == -1 && a[1] == -1) {
|
||||
penUp = 1;
|
||||
continue;
|
||||
}
|
||||
if ( penUp) {
|
||||
ctx.moveTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag);
|
||||
penUp = false;
|
||||
} else {
|
||||
ctx.lineTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag);
|
||||
}
|
||||
}
|
||||
ctx.stroke();
|
||||
x += c.width*mag*this.fontStretch;
|
||||
}
|
||||
ctx.restore();
|
||||
return total;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasTextRenderer.prototype.letters = {
|
||||
' ': { width: 16, points: [] },
|
||||
'!': { width: 10, points: [[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] },
|
||||
'"': { width: 16, points: [[4,21],[4,14],[-1,-1],[12,21],[12,14]] },
|
||||
'#': { width: 21, points: [[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]] },
|
||||
'$': { width: 20, points: [[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]] },
|
||||
'%': { width: 24, points: [[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]] },
|
||||
'&': { width: 26, points: [[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]] },
|
||||
'\'': { width: 10, points: [[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]] },
|
||||
'(': { width: 14, points: [[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]] },
|
||||
')': { width: 14, points: [[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]] },
|
||||
'*': { width: 16, points: [[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]] },
|
||||
'+': { width: 26, points: [[13,18],[13,0],[-1,-1],[4,9],[22,9]] },
|
||||
',': { width: 10, points: [[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] },
|
||||
'-': { width: 18, points: [[6,9],[12,9]] },
|
||||
'.': { width: 10, points: [[5,2],[4,1],[5,0],[6,1],[5,2]] },
|
||||
'/': { width: 22, points: [[20,25],[2,-7]] },
|
||||
'0': { width: 20, points: [[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]] },
|
||||
'1': { width: 20, points: [[6,17],[8,18],[11,21],[11,0]] },
|
||||
'2': { width: 20, points: [[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]] },
|
||||
'3': { width: 20, points: [[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]] },
|
||||
'4': { width: 20, points: [[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]] },
|
||||
'5': { width: 20, points: [[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]] },
|
||||
'6': { width: 20, points: [[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]] },
|
||||
'7': { width: 20, points: [[17,21],[7,0],[-1,-1],[3,21],[17,21]] },
|
||||
'8': { width: 20, points: [[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]] },
|
||||
'9': { width: 20, points: [[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]] },
|
||||
':': { width: 10, points: [[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] },
|
||||
';': { width: 10, points: [[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] },
|
||||
'<': { width: 24, points: [[20,18],[4,9],[20,0]] },
|
||||
'=': { width: 26, points: [[4,12],[22,12],[-1,-1],[4,6],[22,6]] },
|
||||
'>': { width: 24, points: [[4,18],[20,9],[4,0]] },
|
||||
'?': { width: 18, points: [[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]] },
|
||||
'@': { width: 27, points: [[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]] },
|
||||
'A': { width: 18, points: [[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]] },
|
||||
'B': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]] },
|
||||
'C': { width: 21, points: [[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]] },
|
||||
'D': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]] },
|
||||
'E': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]] },
|
||||
'F': { width: 18, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]] },
|
||||
'G': { width: 21, points: [[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]] },
|
||||
'H': { width: 22, points: [[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]] },
|
||||
'I': { width: 8, points: [[4,21],[4,0]] },
|
||||
'J': { width: 16, points: [[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]] },
|
||||
'K': { width: 21, points: [[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]] },
|
||||
'L': { width: 17, points: [[4,21],[4,0],[-1,-1],[4,0],[16,0]] },
|
||||
'M': { width: 24, points: [[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]] },
|
||||
'N': { width: 22, points: [[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]] },
|
||||
'O': { width: 22, points: [[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]] },
|
||||
'P': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]] },
|
||||
'Q': { width: 22, points: [[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]] },
|
||||
'R': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]] },
|
||||
'S': { width: 20, points: [[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]] },
|
||||
'T': { width: 16, points: [[8,21],[8,0],[-1,-1],[1,21],[15,21]] },
|
||||
'U': { width: 22, points: [[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]] },
|
||||
'V': { width: 18, points: [[1,21],[9,0],[-1,-1],[17,21],[9,0]] },
|
||||
'W': { width: 24, points: [[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]] },
|
||||
'X': { width: 20, points: [[3,21],[17,0],[-1,-1],[17,21],[3,0]] },
|
||||
'Y': { width: 18, points: [[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]] },
|
||||
'Z': { width: 20, points: [[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]] },
|
||||
'[': { width: 14, points: [[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]] },
|
||||
'\\': { width: 14, points: [[0,21],[14,-3]] },
|
||||
']': { width: 14, points: [[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]] },
|
||||
'^': { width: 16, points: [[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]] },
|
||||
'_': { width: 16, points: [[0,-2],[16,-2]] },
|
||||
'`': { width: 10, points: [[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]] },
|
||||
'a': { width: 19, points: [[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
|
||||
'b': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]] },
|
||||
'c': { width: 18, points: [[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
|
||||
'd': { width: 19, points: [[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
|
||||
'e': { width: 18, points: [[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
|
||||
'f': { width: 12, points: [[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]] },
|
||||
'g': { width: 19, points: [[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
|
||||
'h': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] },
|
||||
'i': { width: 8, points: [[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]] },
|
||||
'j': { width: 10, points: [[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]] },
|
||||
'k': { width: 17, points: [[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]] },
|
||||
'l': { width: 8, points: [[4,21],[4,0]] },
|
||||
'm': { width: 30, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]] },
|
||||
'n': { width: 19, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] },
|
||||
'o': { width: 19, points: [[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]] },
|
||||
'p': { width: 19, points: [[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]] },
|
||||
'q': { width: 19, points: [[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
|
||||
'r': { width: 13, points: [[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]] },
|
||||
's': { width: 17, points: [[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]] },
|
||||
't': { width: 12, points: [[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]] },
|
||||
'u': { width: 19, points: [[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]] },
|
||||
'v': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0]] },
|
||||
'w': { width: 22, points: [[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]] },
|
||||
'x': { width: 17, points: [[3,14],[14,0],[-1,-1],[14,14],[3,0]] },
|
||||
'y': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]] },
|
||||
'z': { width: 17, points: [[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]] },
|
||||
'{': { width: 14, points: [[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]] },
|
||||
'|': { width: 8, points: [[4,25],[4,-7]] },
|
||||
'}': { width: 14, points: [[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]] },
|
||||
'~': { width: 24, points: [[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]] }
|
||||
};
|
||||
|
||||
$.jqplot.CanvasFontRenderer = function(options) {
|
||||
options = options || {};
|
||||
if (!options.pt2px) {
|
||||
options.pt2px = 1.5;
|
||||
}
|
||||
$.jqplot.CanvasTextRenderer.call(this, options);
|
||||
};
|
||||
|
||||
$.jqplot.CanvasFontRenderer.prototype = new $.jqplot.CanvasTextRenderer({});
|
||||
$.jqplot.CanvasFontRenderer.prototype.constructor = $.jqplot.CanvasFontRenderer;
|
||||
|
||||
$.jqplot.CanvasFontRenderer.prototype.measure = function(ctx, str)
|
||||
{
|
||||
// var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily;
|
||||
var fstyle = this.fontSize+' '+this.fontFamily;
|
||||
ctx.save();
|
||||
ctx.font = fstyle;
|
||||
var w = ctx.measureText(str).width;
|
||||
ctx.restore();
|
||||
return w;
|
||||
};
|
||||
|
||||
$.jqplot.CanvasFontRenderer.prototype.draw = function(ctx, str)
|
||||
{
|
||||
var x = 0;
|
||||
// leave room at bottom for descenders.
|
||||
var y = this.height*0.72;
|
||||
//var y = 12;
|
||||
|
||||
ctx.save();
|
||||
var tx, ty;
|
||||
|
||||
// 1st quadrant
|
||||
if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) {
|
||||
tx = 0;
|
||||
ty = -Math.sin(this.angle) * this.width;
|
||||
}
|
||||
// 4th quadrant
|
||||
else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) {
|
||||
tx = Math.sin(this.angle) * this.height;
|
||||
ty = 0;
|
||||
}
|
||||
// 2nd quadrant
|
||||
else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) {
|
||||
tx = -Math.cos(this.angle) * this.width;
|
||||
ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height;
|
||||
}
|
||||
// 3rd quadrant
|
||||
else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) {
|
||||
tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width;
|
||||
ty = -Math.cos(this.angle) * this.height;
|
||||
}
|
||||
ctx.strokeStyle = this.fillStyle;
|
||||
ctx.fillStyle = this.fillStyle;
|
||||
// var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily;
|
||||
var fstyle = this.fontSize+' '+this.fontFamily;
|
||||
ctx.font = fstyle;
|
||||
ctx.translate(tx, ty);
|
||||
ctx.rotate(this.angle);
|
||||
ctx.fillText(str, x, y);
|
||||
// ctx.strokeText(str, x, y);
|
||||
|
||||
ctx.restore();
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
1093
js/jqplot/plugins/jqplot.cursor.js
Normal file
1093
js/jqplot/plugins/jqplot.cursor.js
Normal file
File diff suppressed because it is too large
Load Diff
702
js/jqplot/plugins/jqplot.dateAxisRenderer.js
Normal file
702
js/jqplot/plugins/jqplot.dateAxisRenderer.js
Normal file
@@ -0,0 +1,702 @@
|
||||
/**
|
||||
* jqPlot
|
||||
* Pure JavaScript plotting plugin using jQuery
|
||||
*
|
||||
* Version: 1.0.0b2_r1012
|
||||
*
|
||||
* Copyright (c) 2009-2011 Chris Leonello
|
||||
* jqPlot is currently available for use in all personal or commercial projects
|
||||
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
||||
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
||||
* choose the license that best suits your project and use it accordingly.
|
||||
*
|
||||
* Although not required, the author would appreciate an email letting him
|
||||
* know of any substantial use of jqPlot. You can reach the author at:
|
||||
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
||||
*
|
||||
* If you are feeling kind and generous, consider supporting the project by
|
||||
* making a donation at: http://www.jqplot.com/donate.php .
|
||||
*
|
||||
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
||||
*
|
||||
* version 2007.04.27
|
||||
* author Ash Searle
|
||||
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
||||
* http://hexmen.com/js/sprintf.js
|
||||
* The author (Ash Searle) has placed this code in the public domain:
|
||||
* "This code is unrestricted: you are free to use it however you like."
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
/**
|
||||
* Class: $.jqplot.DateAxisRenderer
|
||||
* A plugin for a jqPlot to render an axis as a series of date values.
|
||||
* This renderer has no options beyond those supplied by the <Axis> class.
|
||||
* It supplies it's own tick formatter, so the tickOptions.formatter option
|
||||
* should not be overridden.
|
||||
*
|
||||
* Thanks to Ken Synder for his enhanced Date instance methods which are
|
||||
* included with this code <http://kendsnyder.com/sandbox/date/>.
|
||||
*
|
||||
* To use this renderer, include the plugin in your source
|
||||
* > <script type="text/javascript" language="javascript" src="plugins/jqplot.dateAxisRenderer.js"></script>
|
||||
*
|
||||
* and supply the appropriate options to your plot
|
||||
*
|
||||
* > {axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}}}
|
||||
*
|
||||
* Dates can be passed into the axis in almost any recognizable value and
|
||||
* will be parsed. They will be rendered on the axis in the format
|
||||
* specified by tickOptions.formatString. e.g. tickOptions.formatString = '%Y-%m-%d'.
|
||||
*
|
||||
* Accecptable format codes
|
||||
* are:
|
||||
*
|
||||
* > Code Result Description
|
||||
* > == Years ==
|
||||
* > %Y 2008 Four-digit year
|
||||
* > %y 08 Two-digit year
|
||||
* > == Months ==
|
||||
* > %m 09 Two-digit month
|
||||
* > %#m 9 One or two-digit month
|
||||
* > %B September Full month name
|
||||
* > %b Sep Abbreviated month name
|
||||
* > == Days ==
|
||||
* > %d 05 Two-digit day of month
|
||||
* > %#d 5 One or two-digit day of month
|
||||
* > %e 5 One or two-digit day of month
|
||||
* > %A Sunday Full name of the day of the week
|
||||
* > %a Sun Abbreviated name of the day of the week
|
||||
* > %w 0 Number of the day of the week (0 = Sunday, 6 = Saturday)
|
||||
* > %o th The ordinal suffix string following the day of the month
|
||||
* > == Hours ==
|
||||
* > %H 23 Hours in 24-hour format (two digits)
|
||||
* > %#H 3 Hours in 24-hour integer format (one or two digits)
|
||||
* > %I 11 Hours in 12-hour format (two digits)
|
||||
* > %#I 3 Hours in 12-hour integer format (one or two digits)
|
||||
* > %p PM AM or PM
|
||||
* > == Minutes ==
|
||||
* > %M 09 Minutes (two digits)
|
||||
* > %#M 9 Minutes (one or two digits)
|
||||
* > == Seconds ==
|
||||
* > %S 02 Seconds (two digits)
|
||||
* > %#S 2 Seconds (one or two digits)
|
||||
* > %s 1206567625723 Unix timestamp (Seconds past 1970-01-01 00:00:00)
|
||||
* > == Milliseconds ==
|
||||
* > %N 008 Milliseconds (three digits)
|
||||
* > %#N 8 Milliseconds (one to three digits)
|
||||
* > == Timezone ==
|
||||
* > %O 360 difference in minutes between local time and GMT
|
||||
* > %Z Mountain Standard Time Name of timezone as reported by browser
|
||||
* > %G -06:00 Hours and minutes between GMT
|
||||
* > == Shortcuts ==
|
||||
* > %F 2008-03-26 %Y-%m-%d
|
||||
* > %T 05:06:30 %H:%M:%S
|
||||
* > %X 05:06:30 %H:%M:%S
|
||||
* > %x 03/26/08 %m/%d/%y
|
||||
* > %D 03/26/08 %m/%d/%y
|
||||
* > %#c Wed Mar 26 15:31:00 2008 %a %b %e %H:%M:%S %Y
|
||||
* > %v 3-Sep-2008 %e-%b-%Y
|
||||
* > %R 15:31 %H:%M
|
||||
* > %r 3:31:00 PM %I:%M:%S %p
|
||||
* > == Characters ==
|
||||
* > %n \n Newline
|
||||
* > %t \t Tab
|
||||
* > %% % Percent Symbol
|
||||
*/
|
||||
$.jqplot.DateAxisRenderer = function() {
|
||||
$.jqplot.LinearAxisRenderer.call(this);
|
||||
this.date = new $.jsDate();
|
||||
};
|
||||
|
||||
var second = 1000;
|
||||
var minute = 60 * second;
|
||||
var hour = 60 * minute;
|
||||
var day = 24 * hour;
|
||||
var week = 7 * day;
|
||||
|
||||
// these are less definitive
|
||||
var month = 30.4368499 * day;
|
||||
var year = 365.242199 * day;
|
||||
|
||||
var daysInMonths = [31,28,31,30,31,30,31,30,31,30,31,30];
|
||||
// array of consistent nice intervals. Longer intervals
|
||||
// will depend on days in month, days in year, etc.
|
||||
var niceFormatStrings = ['%M:%S.%#N', '%M:%S.%#N', '%M:%S.%#N', '%M:%S', '%M:%S', '%M:%S', '%M:%S', '%H:%M:%S', '%H:%M:%S', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%a %H:%M', '%a %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%v', '%v', '%v', '%v', '%v', '%v', '%v'];
|
||||
var niceIntervals = [0.1*second, 0.2*second, 0.5*second, second, 2*second, 5*second, 10*second, 15*second, 30*second, minute, 2*minute, 5*minute, 10*minute, 15*minute, 30*minute, hour, 2*hour, 4*hour, 6*hour, 8*hour, 12*hour, day, 2*day, 3*day, 4*day, 5*day, week, 2*week];
|
||||
|
||||
var niceMonthlyIntervals = [];
|
||||
|
||||
function bestDateInterval(min, max, titarget) {
|
||||
// iterate through niceIntervals to find one closest to titarget
|
||||
var badness = Number.MAX_VALUE;
|
||||
var temp, bestTi, bestfmt;
|
||||
for (var i=0, l=niceIntervals.length; i < l; i++) {
|
||||
temp = Math.abs(titarget - niceIntervals[i]);
|
||||
if (temp < badness) {
|
||||
badness = temp;
|
||||
bestTi = niceIntervals[i];
|
||||
bestfmt = niceFormatStrings[i];
|
||||
}
|
||||
}
|
||||
|
||||
return [bestTi, bestfmt];
|
||||
}
|
||||
|
||||
$.jqplot.DateAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
|
||||
$.jqplot.DateAxisRenderer.prototype.constructor = $.jqplot.DateAxisRenderer;
|
||||
|
||||
$.jqplot.DateTickFormatter = function(format, val) {
|
||||
if (!format) {
|
||||
format = '%Y/%m/%d';
|
||||
}
|
||||
return $.jsDate.strftime(val, format);
|
||||
};
|
||||
|
||||
$.jqplot.DateAxisRenderer.prototype.init = function(options){
|
||||
// prop: tickRenderer
|
||||
// A class of a rendering engine for creating the ticks labels displayed on the plot,
|
||||
// See <$.jqplot.AxisTickRenderer>.
|
||||
// this.tickRenderer = $.jqplot.AxisTickRenderer;
|
||||
// this.labelRenderer = $.jqplot.AxisLabelRenderer;
|
||||
this.tickOptions.formatter = $.jqplot.DateTickFormatter;
|
||||
// prop: tickInset
|
||||
// Controls the amount to inset the first and last ticks from
|
||||
// the edges of the grid, in multiples of the tick interval.
|
||||
// 0 is no inset, 0.5 is one half a tick interval, 1 is a full
|
||||
// tick interval, etc.
|
||||
this.tickInset = 0;
|
||||
// prop: drawBaseline
|
||||
// True to draw the axis baseline.
|
||||
this.drawBaseline = true;
|
||||
// prop: baselineWidth
|
||||
// width of the baseline in pixels.
|
||||
this.baselineWidth = null;
|
||||
// prop: baselineColor
|
||||
// CSS color spec for the baseline.
|
||||
this.baselineColor = null;
|
||||
this.daTickInterval = null;
|
||||
this._daTickInterval = null;
|
||||
|
||||
$.extend(true, this, options);
|
||||
|
||||
var db = this._dataBounds,
|
||||
stats,
|
||||
sum,
|
||||
s,
|
||||
d,
|
||||
pd,
|
||||
sd,
|
||||
intv;
|
||||
|
||||
// Go through all the series attached to this axis and find
|
||||
// the min/max bounds for this axis.
|
||||
for (var i=0; i<this._series.length; i++) {
|
||||
stats = {intervals:[], frequencies:{}, sortedIntervals:[], min:null, max:null, mean:null};
|
||||
sum = 0;
|
||||
s = this._series[i];
|
||||
d = s.data;
|
||||
pd = s._plotData;
|
||||
sd = s._stackData;
|
||||
intv = 0;
|
||||
|
||||
for (var j=0; j<d.length; j++) {
|
||||
if (this.name == 'xaxis' || this.name == 'x2axis') {
|
||||
d[j][0] = new $.jsDate(d[j][0]).getTime();
|
||||
pd[j][0] = new $.jsDate(d[j][0]).getTime();
|
||||
sd[j][0] = new $.jsDate(d[j][0]).getTime();
|
||||
if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) {
|
||||
db.min = d[j][0];
|
||||
}
|
||||
if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) {
|
||||
db.max = d[j][0];
|
||||
}
|
||||
if (j>0) {
|
||||
intv = Math.abs(d[j][0] - d[j-1][0]);
|
||||
stats.intervals.push(intv);
|
||||
if (stats.frequencies.hasOwnProperty(intv)) {
|
||||
stats.frequencies[intv] += 1;
|
||||
}
|
||||
else {
|
||||
stats.frequencies[intv] = 1;
|
||||
}
|
||||
}
|
||||
sum += intv;
|
||||
|
||||
}
|
||||
else {
|
||||
d[j][1] = new $.jsDate(d[j][1]).getTime();
|
||||
pd[j][1] = new $.jsDate(d[j][1]).getTime();
|
||||
sd[j][1] = new $.jsDate(d[j][1]).getTime();
|
||||
if ((d[j][1] != null && d[j][1] < db.min) || db.min == null) {
|
||||
db.min = d[j][1];
|
||||
}
|
||||
if ((d[j][1] != null && d[j][1] > db.max) || db.max == null) {
|
||||
db.max = d[j][1];
|
||||
}
|
||||
if (j>0) {
|
||||
intv = Math.abs(d[j][1] - d[j-1][1]);
|
||||
stats.intervals.push(intv);
|
||||
if (stats.frequencies.hasOwnProperty(intv)) {
|
||||
stats.frequencies[intv] += 1;
|
||||
}
|
||||
else {
|
||||
stats.frequencies[intv] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
sum += intv;
|
||||
}
|
||||
|
||||
if (s.renderer.bands) {
|
||||
if (s.renderer.bands.hiData.length) {
|
||||
var bd = s.renderer.bands.hiData;
|
||||
for (var j=0, l=bd.length; j < l; j++) {
|
||||
if (this.name === 'xaxis' || this.name === 'x2axis') {
|
||||
bd[j][0] = new $.jsDate(bd[j][0]).getTime();
|
||||
if ((bd[j][0] != null && bd[j][0] > db.max) || db.max == null) {
|
||||
db.max = bd[j][0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
bd[j][1] = new $.jsDate(bd[j][1]).getTime();
|
||||
if ((bd[j][1] != null && bd[j][1] > db.max) || db.max == null) {
|
||||
db.max = bd[j][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (s.renderer.bands.lowData.length) {
|
||||
var bd = s.renderer.bands.lowData;
|
||||
for (var j=0, l=bd.length; j < l; j++) {
|
||||
if (this.name === 'xaxis' || this.name === 'x2axis') {
|
||||
bd[j][0] = new $.jsDate(bd[j][0]).getTime();
|
||||
if ((bd[j][0] != null && bd[j][0] < db.min) || db.min == null) {
|
||||
db.min = bd[j][0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
bd[j][1] = new $.jsDate(bd[j][1]).getTime();
|
||||
if ((bd[j][1] != null && bd[j][1] < db.min) || db.min == null) {
|
||||
db.min = bd[j][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tempf = 0,
|
||||
tempn=0;
|
||||
for (var n in stats.frequencies) {
|
||||
stats.sortedIntervals.push({interval:n, frequency:stats.frequencies[n]});
|
||||
}
|
||||
stats.sortedIntervals.sort(function(a, b){
|
||||
return b.frequency - a.frequency;
|
||||
});
|
||||
|
||||
stats.min = $.jqplot.arrayMin(stats.intervals);
|
||||
stats.max = $.jqplot.arrayMax(stats.intervals);
|
||||
stats.mean = sum/d.length;
|
||||
this._intervalStats.push(stats);
|
||||
stats = sum = s = d = pd = sd = null;
|
||||
}
|
||||
db = null;
|
||||
|
||||
};
|
||||
|
||||
// called with scope of an axis
|
||||
$.jqplot.DateAxisRenderer.prototype.reset = function() {
|
||||
this.min = this._options.min;
|
||||
this.max = this._options.max;
|
||||
this.tickInterval = this._options.tickInterval;
|
||||
this.numberTicks = this._options.numberTicks;
|
||||
this._autoFormatString = '';
|
||||
if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) {
|
||||
this.tickOptions.formatString = '';
|
||||
}
|
||||
this.daTickInterval = this._daTickInterval;
|
||||
// this._ticks = this.__ticks;
|
||||
};
|
||||
|
||||
$.jqplot.DateAxisRenderer.prototype.createTicks = function(plot) {
|
||||
// we're are operating on an axis here
|
||||
var ticks = this._ticks;
|
||||
var userTicks = this.ticks;
|
||||
var name = this.name;
|
||||
// databounds were set on axis initialization.
|
||||
var db = this._dataBounds;
|
||||
var iv = this._intervalStats;
|
||||
var dim = (this.name.charAt(0) === 'x') ? this._plotDimensions.width : this._plotDimensions.height;
|
||||
var interval;
|
||||
var min, max;
|
||||
var pos1, pos2;
|
||||
var tt, i;
|
||||
var threshold = 30;
|
||||
var insetMult = 1;
|
||||
|
||||
var tickInterval = this.tickInterval;
|
||||
|
||||
// if we already have ticks, use them.
|
||||
// ticks must be in order of increasing value.
|
||||
|
||||
min = ((this.min != null) ? new $.jsDate(this.min).getTime() : db.min);
|
||||
max = ((this.max != null) ? new $.jsDate(this.max).getTime() : db.max);
|
||||
|
||||
// see if we're zooming. if we are, don't use the min and max we're given,
|
||||
// but compute some nice ones. They will be reset later.
|
||||
|
||||
var cursor = plot.plugins.cursor;
|
||||
|
||||
if (cursor && cursor._zoom && cursor._zoom.zooming) {
|
||||
this.min = null;
|
||||
this.max = null;
|
||||
}
|
||||
|
||||
var range = max - min;
|
||||
|
||||
if (this.tickOptions == null || !this.tickOptions.formatString) {
|
||||
this._overrideFormatString = true;
|
||||
}
|
||||
|
||||
if (userTicks.length) {
|
||||
// ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed
|
||||
for (i=0; i<userTicks.length; i++){
|
||||
var ut = userTicks[i];
|
||||
var t = new this.tickRenderer(this.tickOptions);
|
||||
if (ut.constructor == Array) {
|
||||
t.value = new $.jsDate(ut[0]).getTime();
|
||||
t.label = ut[1];
|
||||
if (!this.showTicks) {
|
||||
t.showLabel = false;
|
||||
t.showMark = false;
|
||||
}
|
||||
else if (!this.showTickMarks) {
|
||||
t.showMark = false;
|
||||
}
|
||||
t.setTick(t.value, this.name);
|
||||
this._ticks.push(t);
|
||||
}
|
||||
|
||||
else {
|
||||
t.value = new $.jsDate(ut).getTime();
|
||||
if (!this.showTicks) {
|
||||
t.showLabel = false;
|
||||
t.showMark = false;
|
||||
}
|
||||
else if (!this.showTickMarks) {
|
||||
t.showMark = false;
|
||||
}
|
||||
t.setTick(t.value, this.name);
|
||||
this._ticks.push(t);
|
||||
}
|
||||
}
|
||||
this.numberTicks = userTicks.length;
|
||||
this.min = this._ticks[0].value;
|
||||
this.max = this._ticks[this.numberTicks-1].value;
|
||||
this.daTickInterval = [(this.max - this.min) / (this.numberTicks - 1)/1000, 'seconds'];
|
||||
}
|
||||
|
||||
////////
|
||||
// We don't have any ticks yet, let's make some!
|
||||
////////
|
||||
|
||||
// if user specified min and max are null, we set those to make best ticks.
|
||||
else if (this.min == null && this.max == null) {
|
||||
var opts = $.extend(true, {}, this.tickOptions, {name: this.name, value: null});
|
||||
// want to find a nice interval
|
||||
var nttarget,
|
||||
titarget;
|
||||
|
||||
// if no tickInterval or numberTicks options specified, make a good guess.
|
||||
if (!this.tickInterval && !this.numberTicks) {
|
||||
var tdim = Math.max(dim, threshold+1);
|
||||
// how many ticks to put on the axis?
|
||||
// date labels tend to be long. If ticks not rotated,
|
||||
// don't use too many and have a high spacing factor.
|
||||
// If we are rotating ticks, use a lower factor.
|
||||
var spacingFactor = 115;
|
||||
if (this.tickRenderer === $.jqplot.CanvasAxisTickRenderer && this.tickOptions.angle) {
|
||||
spacingFactor = 115 - 40 * Math.abs(Math.sin(this.tickOptions.angle/180*Math.PI));
|
||||
}
|
||||
|
||||
nttarget = Math.ceil((tdim-threshold)/spacingFactor + 1);
|
||||
titarget = (max - min) / (nttarget - 1);
|
||||
}
|
||||
|
||||
// If tickInterval is specified, we'll try to honor it.
|
||||
// Not gauranteed to get this interval, but we'll get as close as
|
||||
// we can.
|
||||
// tickInterval will be used before numberTicks, that is if
|
||||
// both are specified, numberTicks will be ignored.
|
||||
else if (this.tickInterval) {
|
||||
titarget = this.tickInterval;
|
||||
}
|
||||
|
||||
// if numberTicks specified, try to honor it.
|
||||
// Not gauranteed, but will try to get close.
|
||||
else if (this.numberTicks) {
|
||||
nttarget = this.numberTicks;
|
||||
titarget = (max - min) / (nttarget - 1);
|
||||
}
|
||||
|
||||
// If we can use an interval of 2 weeks or less, pick best one
|
||||
if (titarget <= 19*day) {
|
||||
var ret = bestDateInterval(min, max, titarget);
|
||||
var tempti = ret[0];
|
||||
this._autoFormatString = ret[1];
|
||||
|
||||
min = Math.floor(min/tempti) * tempti;
|
||||
min = new $.jsDate(min);
|
||||
min = min.getTime() + min.getUtcOffset();
|
||||
|
||||
nttarget = Math.ceil((max - min) / tempti) + 1;
|
||||
this.min = min;
|
||||
this.max = min + (nttarget - 1) * tempti;
|
||||
|
||||
// if max is less than max, add an interval
|
||||
if (this.max < max) {
|
||||
this.max += tempti;
|
||||
nttarget += 1;
|
||||
}
|
||||
this.tickInterval = tempti;
|
||||
this.numberTicks = nttarget;
|
||||
|
||||
for (var i=0; i<nttarget; i++) {
|
||||
opts.value = this.min + i * tempti;
|
||||
t = new this.tickRenderer(opts);
|
||||
|
||||
if (this._overrideFormatString && this._autoFormatString != '') {
|
||||
t.formatString = this._autoFormatString;
|
||||
}
|
||||
if (!this.showTicks) {
|
||||
t.showLabel = false;
|
||||
t.showMark = false;
|
||||
}
|
||||
else if (!this.showTickMarks) {
|
||||
t.showMark = false;
|
||||
}
|
||||
this._ticks.push(t);
|
||||
}
|
||||
|
||||
insetMult = this.tickInterval;
|
||||
}
|
||||
|
||||
// should we use a monthly interval?
|
||||
else if (titarget <= 9 * month) {
|
||||
|
||||
this._autoFormatString = '%v';
|
||||
|
||||
// how many months in an interval?
|
||||
var intv = Math.round(titarget/month);
|
||||
if (intv < 1) {
|
||||
intv = 1;
|
||||
}
|
||||
else if (intv > 6) {
|
||||
intv = 6;
|
||||
}
|
||||
|
||||
// figure out the starting month and ending month.
|
||||
var mstart = new $.jsDate(min).setDate(1).setHours(0,0,0,0);
|
||||
|
||||
// See if max ends exactly on a month
|
||||
var tempmend = new $.jsDate(max);
|
||||
var mend = new $.jsDate(max).setDate(1).setHours(0,0,0,0);
|
||||
|
||||
if (tempmend.getTime() !== mend.getTime()) {
|
||||
mend = mend.add(1, 'month');
|
||||
}
|
||||
|
||||
var nmonths = mend.diff(mstart, 'month');
|
||||
|
||||
nttarget = Math.ceil(nmonths/intv) + 1;
|
||||
|
||||
this.min = mstart.getTime();
|
||||
this.max = mstart.clone().add((nttarget - 1) * intv, 'month').getTime();
|
||||
this.numberTicks = nttarget;
|
||||
|
||||
for (var i=0; i<nttarget; i++) {
|
||||
if (i === 0) {
|
||||
opts.value = mstart.getTime();
|
||||
}
|
||||
else {
|
||||
opts.value = mstart.add(intv, 'month').getTime();
|
||||
}
|
||||
t = new this.tickRenderer(opts);
|
||||
|
||||
if (this._overrideFormatString && this._autoFormatString != '') {
|
||||
t.formatString = this._autoFormatString;
|
||||
}
|
||||
if (!this.showTicks) {
|
||||
t.showLabel = false;
|
||||
t.showMark = false;
|
||||
}
|
||||
else if (!this.showTickMarks) {
|
||||
t.showMark = false;
|
||||
}
|
||||
this._ticks.push(t);
|
||||
}
|
||||
|
||||
insetMult = intv * month;
|
||||
}
|
||||
|
||||
// use yearly intervals
|
||||
else {
|
||||
|
||||
this._autoFormatString = '%v';
|
||||
|
||||
// how many years in an interval?
|
||||
var intv = Math.round(titarget/year);
|
||||
if (intv < 1) {
|
||||
intv = 1;
|
||||
}
|
||||
|
||||
// figure out the starting and ending years.
|
||||
var mstart = new $.jsDate(min).setMonth(0, 1).setHours(0,0,0,0);
|
||||
var mend = new $.jsDate(max).add(1, 'year').setMonth(0, 1).setHours(0,0,0,0);
|
||||
|
||||
var nyears = mend.diff(mstart, 'year');
|
||||
|
||||
nttarget = Math.ceil(nyears/intv) + 1;
|
||||
|
||||
this.min = mstart.getTime();
|
||||
this.max = mstart.clone().add((nttarget - 1) * intv, 'year').getTime();
|
||||
this.numberTicks = nttarget;
|
||||
|
||||
for (var i=0; i<nttarget; i++) {
|
||||
if (i === 0) {
|
||||
opts.value = mstart.getTime();
|
||||
}
|
||||
else {
|
||||
opts.value = mstart.add(intv, 'year').getTime();
|
||||
}
|
||||
t = new this.tickRenderer(opts);
|
||||
|
||||
if (this._overrideFormatString && this._autoFormatString != '') {
|
||||
t.formatString = this._autoFormatString;
|
||||
}
|
||||
if (!this.showTicks) {
|
||||
t.showLabel = false;
|
||||
t.showMark = false;
|
||||
}
|
||||
else if (!this.showTickMarks) {
|
||||
t.showMark = false;
|
||||
}
|
||||
this._ticks.push(t);
|
||||
}
|
||||
|
||||
insetMult = intv * year;
|
||||
}
|
||||
}
|
||||
|
||||
////////
|
||||
// Some option(s) specified, work around that.
|
||||
////////
|
||||
|
||||
else {
|
||||
if (name == 'xaxis' || name == 'x2axis') {
|
||||
dim = this._plotDimensions.width;
|
||||
}
|
||||
else {
|
||||
dim = this._plotDimensions.height;
|
||||
}
|
||||
|
||||
// if min, max and number of ticks specified, user can't specify interval.
|
||||
if (this.min != null && this.max != null && this.numberTicks != null) {
|
||||
this.tickInterval = null;
|
||||
}
|
||||
|
||||
// if user specified a tick interval, convert to usable.
|
||||
if (this.tickInterval != null)
|
||||
{
|
||||
// if interval is a number or can be converted to one, use it.
|
||||
// Assume it is in SECONDS!!!
|
||||
if (Number(this.tickInterval)) {
|
||||
this.daTickInterval = [Number(this.tickInterval), 'seconds'];
|
||||
}
|
||||
// else, parse out something we can build from.
|
||||
else if (typeof this.tickInterval == "string") {
|
||||
var parts = this.tickInterval.split(' ');
|
||||
if (parts.length == 1) {
|
||||
this.daTickInterval = [1, parts[0]];
|
||||
}
|
||||
else if (parts.length == 2) {
|
||||
this.daTickInterval = [parts[0], parts[1]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if min and max are same, space them out a bit
|
||||
if (min == max) {
|
||||
var adj = 24*60*60*500; // 1/2 day
|
||||
min -= adj;
|
||||
max += adj;
|
||||
}
|
||||
|
||||
range = max - min;
|
||||
|
||||
var optNumTicks = 2 + parseInt(Math.max(0, dim-100)/100, 10);
|
||||
|
||||
|
||||
var rmin, rmax;
|
||||
|
||||
rmin = (this.min != null) ? new $.jsDate(this.min).getTime() : min - range/2*(this.padMin - 1);
|
||||
rmax = (this.max != null) ? new $.jsDate(this.max).getTime() : max + range/2*(this.padMax - 1);
|
||||
this.min = rmin;
|
||||
this.max = rmax;
|
||||
range = this.max - this.min;
|
||||
|
||||
if (this.numberTicks == null){
|
||||
// if tickInterval is specified by user, we will ignore computed maximum.
|
||||
// max will be equal or greater to fit even # of ticks.
|
||||
if (this.daTickInterval != null) {
|
||||
var nc = new $.jsDate(this.max).diff(this.min, this.daTickInterval[1], true);
|
||||
this.numberTicks = Math.ceil(nc/this.daTickInterval[0]) +1;
|
||||
// this.max = new $.jsDate(this.min).add(this.numberTicks-1, this.daTickInterval[1]).getTime();
|
||||
this.max = new $.jsDate(this.min).add((this.numberTicks-1) * this.daTickInterval[0], this.daTickInterval[1]).getTime();
|
||||
}
|
||||
else if (dim > 200) {
|
||||
this.numberTicks = parseInt(3+(dim-200)/100, 10);
|
||||
}
|
||||
else {
|
||||
this.numberTicks = 2;
|
||||
}
|
||||
}
|
||||
|
||||
insetMult = range / (this.numberTicks-1)/1000;
|
||||
|
||||
if (this.daTickInterval == null) {
|
||||
this.daTickInterval = [insetMult, 'seconds'];
|
||||
}
|
||||
|
||||
|
||||
for (var i=0; i<this.numberTicks; i++){
|
||||
var min = new $.jsDate(this.min);
|
||||
tt = min.add(i*this.daTickInterval[0], this.daTickInterval[1]).getTime();
|
||||
var t = new this.tickRenderer(this.tickOptions);
|
||||
// var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
|
||||
if (!this.showTicks) {
|
||||
t.showLabel = false;
|
||||
t.showMark = false;
|
||||
}
|
||||
else if (!this.showTickMarks) {
|
||||
t.showMark = false;
|
||||
}
|
||||
t.setTick(tt, this.name);
|
||||
this._ticks.push(t);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tickInset) {
|
||||
this.min = this.min - this.tickInset * insetMult;
|
||||
this.max = this.max + this.tickInset * insetMult;
|
||||
}
|
||||
|
||||
if (this._daTickInterval == null) {
|
||||
this._daTickInterval = this.daTickInterval;
|
||||
}
|
||||
|
||||
ticks = null;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
454
js/jqplot/plugins/jqplot.highlighter.js
Normal file
454
js/jqplot/plugins/jqplot.highlighter.js
Normal file
@@ -0,0 +1,454 @@
|
||||
/**
|
||||
* jqPlot
|
||||
* Pure JavaScript plotting plugin using jQuery
|
||||
*
|
||||
* Version: 1.0.0b2_r1012
|
||||
*
|
||||
* Copyright (c) 2009-2011 Chris Leonello
|
||||
* jqPlot is currently available for use in all personal or commercial projects
|
||||
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
||||
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
||||
* choose the license that best suits your project and use it accordingly.
|
||||
*
|
||||
* Although not required, the author would appreciate an email letting him
|
||||
* know of any substantial use of jqPlot. You can reach the author at:
|
||||
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
||||
*
|
||||
* If you are feeling kind and generous, consider supporting the project by
|
||||
* making a donation at: http://www.jqplot.com/donate.php .
|
||||
*
|
||||
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
||||
*
|
||||
* version 2007.04.27
|
||||
* author Ash Searle
|
||||
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
||||
* http://hexmen.com/js/sprintf.js
|
||||
* The author (Ash Searle) has placed this code in the public domain:
|
||||
* "This code is unrestricted: you are free to use it however you like."
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
$.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]);
|
||||
|
||||
/**
|
||||
* Class: $.jqplot.Highlighter
|
||||
* Plugin which will highlight data points when they are moused over.
|
||||
*
|
||||
* To use this plugin, include the js
|
||||
* file in your source:
|
||||
*
|
||||
* > <script type="text/javascript" src="plugins/jqplot.highlighter.js"></script>
|
||||
*
|
||||
* A tooltip providing information about the data point is enabled by default.
|
||||
* To disable the tooltip, set "showTooltip" to false.
|
||||
*
|
||||
* You can control what data is displayed in the tooltip with various
|
||||
* options. The "tooltipAxes" option controls wether the x, y or both
|
||||
* data values are displayed.
|
||||
*
|
||||
* Some chart types (e.g. hi-low-close) have more than one y value per
|
||||
* data point. To display the additional values in the tooltip, set the
|
||||
* "yvalues" option to the desired number of y values present (3 for a hlc chart).
|
||||
*
|
||||
* By default, data values will be formatted with the same formatting
|
||||
* specifiers as used to format the axis ticks. A custom format code
|
||||
* can be supplied with the tooltipFormatString option. This will apply
|
||||
* to all values in the tooltip.
|
||||
*
|
||||
* For more complete control, the "formatString" option can be set. This
|
||||
* Allows conplete control over tooltip formatting. Values are passed to
|
||||
* the format string in an order determined by the "tooltipAxes" and "yvalues"
|
||||
* options. So, if you have a hi-low-close chart and you just want to display
|
||||
* the hi-low-close values in the tooltip, you could set a formatString like:
|
||||
*
|
||||
* > highlighter: {
|
||||
* > tooltipAxes: 'y',
|
||||
* > yvalues: 3,
|
||||
* > formatString:'<table class="jqplot-highlighter">
|
||||
* > <tr><td>hi:</td><td>%s</td></tr>
|
||||
* > <tr><td>low:</td><td>%s</td></tr>
|
||||
* > <tr><td>close:</td><td>%s</td></tr></table>'
|
||||
* > }
|
||||
*
|
||||
*/
|
||||
$.jqplot.Highlighter = function(options) {
|
||||
// Group: Properties
|
||||
//
|
||||
//prop: show
|
||||
// true to show the highlight.
|
||||
this.show = $.jqplot.config.enablePlugins;
|
||||
// prop: markerRenderer
|
||||
// Renderer used to draw the marker of the highlighted point.
|
||||
// Renderer will assimilate attributes from the data point being highlighted,
|
||||
// so no attributes need set on the renderer directly.
|
||||
// Default is to turn off shadow drawing on the highlighted point.
|
||||
this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false});
|
||||
// prop: showMarker
|
||||
// true to show the marker
|
||||
this.showMarker = true;
|
||||
// prop: lineWidthAdjust
|
||||
// Pixels to add to the lineWidth of the highlight.
|
||||
this.lineWidthAdjust = 2.5;
|
||||
// prop: sizeAdjust
|
||||
// Pixels to add to the overall size of the highlight.
|
||||
this.sizeAdjust = 5;
|
||||
// prop: showTooltip
|
||||
// Show a tooltip with data point values.
|
||||
this.showTooltip = true;
|
||||
// prop: tooltipLocation
|
||||
// Where to position tooltip, 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'
|
||||
this.tooltipLocation = 'nw';
|
||||
// prop: fadeTooltip
|
||||
// true = fade in/out tooltip, flase = show/hide tooltip
|
||||
this.fadeTooltip = true;
|
||||
// prop: tooltipFadeSpeed
|
||||
// 'slow', 'def', 'fast', or number of milliseconds.
|
||||
this.tooltipFadeSpeed = "fast";
|
||||
// prop: tooltipOffset
|
||||
// Pixel offset of tooltip from the highlight.
|
||||
this.tooltipOffset = 2;
|
||||
// prop: tooltipAxes
|
||||
// Which axes to display in tooltip, 'x', 'y' or 'both', 'xy' or 'yx'
|
||||
// 'both' and 'xy' are equivalent, 'yx' reverses order of labels.
|
||||
this.tooltipAxes = 'both';
|
||||
// prop; tooltipSeparator
|
||||
// String to use to separate x and y axes in tooltip.
|
||||
this.tooltipSeparator = ', ';
|
||||
// prop; tooltipContentEditor
|
||||
// Function used to edit/augment/replace the formatted tooltip contents.
|
||||
// Called as str = tooltipContentEditor(str, seriesIndex, pointIndex)
|
||||
// where str is the generated tooltip html and seriesIndex and pointIndex identify
|
||||
// the data point being highlighted. Should return the html for the tooltip contents.
|
||||
this.tooltipContentEditor = null;
|
||||
// prop: useAxesFormatters
|
||||
// Use the x and y axes formatters to format the text in the tooltip.
|
||||
this.useAxesFormatters = true;
|
||||
// prop: tooltipFormatString
|
||||
// sprintf format string for the tooltip.
|
||||
// Uses Ash Searle's javascript sprintf implementation
|
||||
// found here: http://hexmen.com/blog/2007/03/printf-sprintf/
|
||||
// See http://perldoc.perl.org/functions/sprintf.html for reference.
|
||||
// Additional "p" and "P" format specifiers added by Chris Leonello.
|
||||
this.tooltipFormatString = '%.5P';
|
||||
// prop: formatString
|
||||
// alternative to tooltipFormatString
|
||||
// will format the whole tooltip text, populating with x, y values as
|
||||
// indicated by tooltipAxes option. So, you could have a tooltip like:
|
||||
// 'Date: %s, number of cats: %d' to format the whole tooltip at one go.
|
||||
// If useAxesFormatters is true, values will be formatted according to
|
||||
// Axes formatters and you can populate your tooltip string with
|
||||
// %s placeholders.
|
||||
this.formatString = null;
|
||||
// prop: yvalues
|
||||
// Number of y values to expect in the data point array.
|
||||
// Typically this is 1. Certain plots, like OHLC, will
|
||||
// have more y values in each data point array.
|
||||
this.yvalues = 1;
|
||||
// prop: bringSeriesToFront
|
||||
// This option requires jQuery 1.4+
|
||||
// True to bring the series of the highlighted point to the front
|
||||
// of other series.
|
||||
this.bringSeriesToFront = false;
|
||||
this._tooltipElem;
|
||||
this.isHighlighting = false;
|
||||
this.currentNeighbor = null;
|
||||
|
||||
$.extend(true, this, options);
|
||||
};
|
||||
|
||||
var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
|
||||
var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7};
|
||||
var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];
|
||||
|
||||
// axis.renderer.tickrenderer.formatter
|
||||
|
||||
// called with scope of plot
|
||||
$.jqplot.Highlighter.init = function (target, data, opts){
|
||||
var options = opts || {};
|
||||
// add a highlighter attribute to the plot
|
||||
this.plugins.highlighter = new $.jqplot.Highlighter(options.highlighter);
|
||||
};
|
||||
|
||||
// called within scope of series
|
||||
$.jqplot.Highlighter.parseOptions = function (defaults, options) {
|
||||
// Add a showHighlight option to the series
|
||||
// and set it to true by default.
|
||||
this.showHighlight = true;
|
||||
};
|
||||
|
||||
// called within context of plot
|
||||
// create a canvas which we can draw on.
|
||||
// insert it before the eventCanvas, so eventCanvas will still capture events.
|
||||
$.jqplot.Highlighter.postPlotDraw = function() {
|
||||
// Memory Leaks patch
|
||||
if (this.plugins.highlighter && this.plugins.highlighter.highlightCanvas) {
|
||||
this.plugins.highlighter.highlightCanvas.resetCanvas();
|
||||
this.plugins.highlighter.highlightCanvas = null;
|
||||
}
|
||||
|
||||
if (this.plugins.highlighter && this.plugins.highlighter._tooltipElem) {
|
||||
this.plugins.highlighter._tooltipElem.emptyForce();
|
||||
this.plugins.highlighter._tooltipElem = null;
|
||||
}
|
||||
|
||||
this.plugins.highlighter.highlightCanvas = new $.jqplot.GenericCanvas();
|
||||
|
||||
this.eventCanvas._elem.before(this.plugins.highlighter.highlightCanvas.createElement(this._gridPadding, 'jqplot-highlight-canvas', this._plotDimensions, this));
|
||||
this.plugins.highlighter.highlightCanvas.setContext();
|
||||
|
||||
var elem = document.createElement('div');
|
||||
this.plugins.highlighter._tooltipElem = $(elem);
|
||||
elem = null;
|
||||
this.plugins.highlighter._tooltipElem.addClass('jqplot-highlighter-tooltip');
|
||||
this.plugins.highlighter._tooltipElem.css({position:'absolute', display:'none'});
|
||||
|
||||
this.eventCanvas._elem.before(this.plugins.highlighter._tooltipElem);
|
||||
};
|
||||
|
||||
$.jqplot.preInitHooks.push($.jqplot.Highlighter.init);
|
||||
$.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Highlighter.parseOptions);
|
||||
$.jqplot.postDrawHooks.push($.jqplot.Highlighter.postPlotDraw);
|
||||
|
||||
function draw(plot, neighbor) {
|
||||
var hl = plot.plugins.highlighter;
|
||||
var s = plot.series[neighbor.seriesIndex];
|
||||
var smr = s.markerRenderer;
|
||||
var mr = hl.markerRenderer;
|
||||
mr.style = smr.style;
|
||||
mr.lineWidth = smr.lineWidth + hl.lineWidthAdjust;
|
||||
mr.size = smr.size + hl.sizeAdjust;
|
||||
var rgba = $.jqplot.getColorComponents(smr.color);
|
||||
var newrgb = [rgba[0], rgba[1], rgba[2]];
|
||||
var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]);
|
||||
mr.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')';
|
||||
mr.init();
|
||||
mr.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], hl.highlightCanvas._ctx);
|
||||
}
|
||||
|
||||
function showTooltip(plot, series, neighbor) {
|
||||
// neighbor looks like: {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}
|
||||
// gridData should be x,y pixel coords on the grid.
|
||||
// add the plot._gridPadding to that to get x,y in the target.
|
||||
var hl = plot.plugins.highlighter;
|
||||
var elem = hl._tooltipElem;
|
||||
var serieshl = series.highlighter || {};
|
||||
|
||||
var opts = $.extend(true, {}, hl, serieshl);
|
||||
|
||||
if (opts.useAxesFormatters) {
|
||||
var xf = series._xaxis._ticks[0].formatter;
|
||||
var yf = series._yaxis._ticks[0].formatter;
|
||||
var xfstr = series._xaxis._ticks[0].formatString;
|
||||
var yfstr = series._yaxis._ticks[0].formatString;
|
||||
var str;
|
||||
var xstr = xf(xfstr, neighbor.data[0]);
|
||||
var ystrs = [];
|
||||
for (var i=1; i<opts.yvalues+1; i++) {
|
||||
ystrs.push(yf(yfstr, neighbor.data[i]));
|
||||
}
|
||||
if (typeof opts.formatString === 'string') {
|
||||
switch (opts.tooltipAxes) {
|
||||
case 'both':
|
||||
case 'xy':
|
||||
ystrs.unshift(xstr);
|
||||
ystrs.unshift(opts.formatString);
|
||||
str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
|
||||
break;
|
||||
case 'yx':
|
||||
ystrs.push(xstr);
|
||||
ystrs.unshift(opts.formatString);
|
||||
str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
|
||||
break;
|
||||
case 'x':
|
||||
str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString, xstr]);
|
||||
break;
|
||||
case 'y':
|
||||
ystrs.unshift(opts.formatString);
|
||||
str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
|
||||
break;
|
||||
default: // same as xy
|
||||
ystrs.unshift(xstr);
|
||||
ystrs.unshift(opts.formatString);
|
||||
str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (opts.tooltipAxes) {
|
||||
case 'both':
|
||||
case 'xy':
|
||||
str = xstr;
|
||||
for (var i=0; i<ystrs.length; i++) {
|
||||
str += opts.tooltipSeparator + ystrs[i];
|
||||
}
|
||||
break;
|
||||
case 'yx':
|
||||
str = '';
|
||||
for (var i=0; i<ystrs.length; i++) {
|
||||
str += ystrs[i] + opts.tooltipSeparator;
|
||||
}
|
||||
str += xstr;
|
||||
break;
|
||||
case 'x':
|
||||
str = xstr;
|
||||
break;
|
||||
case 'y':
|
||||
str = ystrs.join(opts.tooltipSeparator);
|
||||
break;
|
||||
default: // same as 'xy'
|
||||
str = xstr;
|
||||
for (var i=0; i<ystrs.length; i++) {
|
||||
str += opts.tooltipSeparator + ystrs[i];
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var str;
|
||||
if (typeof opts.formatString === 'string') {
|
||||
str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString].concat(neighbor.data));
|
||||
}
|
||||
|
||||
else {
|
||||
if (opts.tooltipAxes == 'both' || opts.tooltipAxes == 'xy') {
|
||||
str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]) + opts.tooltipSeparator + $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]);
|
||||
}
|
||||
else if (opts.tooltipAxes == 'yx') {
|
||||
str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]) + opts.tooltipSeparator + $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]);
|
||||
}
|
||||
else if (opts.tooltipAxes == 'x') {
|
||||
str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]);
|
||||
}
|
||||
else if (opts.tooltipAxes == 'y') {
|
||||
str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($.isFunction(opts.tooltipContentEditor)) {
|
||||
// args str, seriesIndex, pointIndex are essential so the hook can look up
|
||||
// extra data for the point.
|
||||
str = opts.tooltipContentEditor(str, neighbor.seriesIndex, neighbor.pointIndex, plot);
|
||||
}
|
||||
elem.html(str);
|
||||
var gridpos = {x:neighbor.gridData[0], y:neighbor.gridData[1]};
|
||||
var ms = 0;
|
||||
var fact = 0.707;
|
||||
if (series.markerRenderer.show == true) {
|
||||
ms = (series.markerRenderer.size + opts.sizeAdjust)/2;
|
||||
}
|
||||
|
||||
var loc = locations;
|
||||
if (series.fillToZero && series.fill && neighbor.data[1] < 0) {
|
||||
loc = oppositeLocations;
|
||||
}
|
||||
|
||||
switch (loc[locationIndicies[opts.tooltipLocation]]) {
|
||||
case 'nw':
|
||||
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
|
||||
var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
|
||||
break;
|
||||
case 'n':
|
||||
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2;
|
||||
var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - ms;
|
||||
break;
|
||||
case 'ne':
|
||||
var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + fact * ms;
|
||||
var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
|
||||
break;
|
||||
case 'e':
|
||||
var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + ms;
|
||||
var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2;
|
||||
break;
|
||||
case 'se':
|
||||
var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + fact * ms;
|
||||
var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + fact * ms;
|
||||
break;
|
||||
case 's':
|
||||
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2;
|
||||
var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + ms;
|
||||
break;
|
||||
case 'sw':
|
||||
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
|
||||
var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + fact * ms;
|
||||
break;
|
||||
case 'w':
|
||||
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - ms;
|
||||
var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2;
|
||||
break;
|
||||
default: // same as 'nw'
|
||||
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
|
||||
var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
|
||||
break;
|
||||
}
|
||||
elem.css('left', x);
|
||||
elem.css('top', y);
|
||||
if (opts.fadeTooltip) {
|
||||
// Fix for stacked up animations. Thnanks Trevor!
|
||||
elem.stop(true,true).fadeIn(opts.tooltipFadeSpeed);
|
||||
}
|
||||
else {
|
||||
elem.show();
|
||||
}
|
||||
elem = null;
|
||||
|
||||
}
|
||||
|
||||
function handleMove(ev, gridpos, datapos, neighbor, plot) {
|
||||
var hl = plot.plugins.highlighter;
|
||||
var c = plot.plugins.cursor;
|
||||
if (hl.show) {
|
||||
if (neighbor == null && hl.isHighlighting) {
|
||||
var ctx = hl.highlightCanvas._ctx;
|
||||
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
if (hl.fadeTooltip) {
|
||||
hl._tooltipElem.fadeOut(hl.tooltipFadeSpeed);
|
||||
}
|
||||
else {
|
||||
hl._tooltipElem.hide();
|
||||
}
|
||||
if (hl.bringSeriesToFront) {
|
||||
plot.restorePreviousSeriesOrder();
|
||||
}
|
||||
hl.isHighlighting = false;
|
||||
hl.currentNeighbor = null;
|
||||
ctx = null;
|
||||
}
|
||||
else if (neighbor != null && plot.series[neighbor.seriesIndex].showHighlight && !hl.isHighlighting) {
|
||||
hl.isHighlighting = true;
|
||||
hl.currentNeighbor = neighbor;
|
||||
if (hl.showMarker) {
|
||||
draw(plot, neighbor);
|
||||
}
|
||||
if (hl.showTooltip && (!c || !c._zoom.started)) {
|
||||
showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor);
|
||||
}
|
||||
if (hl.bringSeriesToFront) {
|
||||
plot.moveSeriesToFront(neighbor.seriesIndex);
|
||||
}
|
||||
}
|
||||
// check to see if we're highlighting the wrong point.
|
||||
else if (neighbor != null && hl.isHighlighting && hl.currentNeighbor != neighbor) {
|
||||
// highlighting the wrong point.
|
||||
|
||||
// if new series allows highlighting, highlight new point.
|
||||
if (plot.series[neighbor.seriesIndex].showHighlight) {
|
||||
var ctx = hl.highlightCanvas._ctx;
|
||||
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
hl.isHighlighting = true;
|
||||
hl.currentNeighbor = neighbor;
|
||||
if (hl.showMarker) {
|
||||
draw(plot, neighbor);
|
||||
}
|
||||
if (hl.showTooltip && (!c || !c._zoom.started)) {
|
||||
showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor);
|
||||
}
|
||||
if (hl.bringSeriesToFront) {
|
||||
plot.moveSeriesToFront(neighbor.seriesIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})(jQuery);
|
||||
899
js/jqplot/plugins/jqplot.pieRenderer.js
Normal file
899
js/jqplot/plugins/jqplot.pieRenderer.js
Normal file
@@ -0,0 +1,899 @@
|
||||
/**
|
||||
* jqPlot
|
||||
* Pure JavaScript plotting plugin using jQuery
|
||||
*
|
||||
* Version: 1.0.0b2_r1012
|
||||
*
|
||||
* Copyright (c) 2009-2011 Chris Leonello
|
||||
* jqPlot is currently available for use in all personal or commercial projects
|
||||
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
||||
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
||||
* choose the license that best suits your project and use it accordingly.
|
||||
*
|
||||
* Although not required, the author would appreciate an email letting him
|
||||
* know of any substantial use of jqPlot. You can reach the author at:
|
||||
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
||||
*
|
||||
* If you are feeling kind and generous, consider supporting the project by
|
||||
* making a donation at: http://www.jqplot.com/donate.php .
|
||||
*
|
||||
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
||||
*
|
||||
* version 2007.04.27
|
||||
* author Ash Searle
|
||||
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
||||
* http://hexmen.com/js/sprintf.js
|
||||
* The author (Ash Searle) has placed this code in the public domain:
|
||||
* "This code is unrestricted: you are free to use it however you like."
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
/**
|
||||
* Class: $.jqplot.PieRenderer
|
||||
* Plugin renderer to draw a pie chart.
|
||||
* x values, if present, will be used as slice labels.
|
||||
* y values give slice size.
|
||||
*
|
||||
* To use this renderer, you need to include the
|
||||
* pie renderer plugin, for example:
|
||||
*
|
||||
* > <script type="text/javascript" src="plugins/jqplot.pieRenderer.js"></script>
|
||||
*
|
||||
* Properties described here are passed into the $.jqplot function
|
||||
* as options on the series renderer. For example:
|
||||
*
|
||||
* > plot2 = $.jqplot('chart2', [s1, s2], {
|
||||
* > seriesDefaults: {
|
||||
* > renderer:$.jqplot.PieRenderer,
|
||||
* > rendererOptions:{
|
||||
* > sliceMargin: 2,
|
||||
* > startAngle: -90
|
||||
* > }
|
||||
* > }
|
||||
* > });
|
||||
*
|
||||
* A pie plot will trigger events on the plot target
|
||||
* according to user interaction. All events return the event object,
|
||||
* the series index, the point (slice) index, and the point data for
|
||||
* the appropriate slice.
|
||||
*
|
||||
* 'jqplotDataMouseOver' - triggered when user mouseing over a slice.
|
||||
* 'jqplotDataHighlight' - triggered the first time user mouses over a slice,
|
||||
* if highlighting is enabled.
|
||||
* 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of
|
||||
* a highlighted slice.
|
||||
* 'jqplotDataClick' - triggered when the user clicks on a slice.
|
||||
* 'jqplotDataRightClick' - tiggered when the user right clicks on a slice if
|
||||
* the "captureRightClick" option is set to true on the plot.
|
||||
*/
|
||||
$.jqplot.PieRenderer = function(){
|
||||
$.jqplot.LineRenderer.call(this);
|
||||
};
|
||||
|
||||
$.jqplot.PieRenderer.prototype = new $.jqplot.LineRenderer();
|
||||
$.jqplot.PieRenderer.prototype.constructor = $.jqplot.PieRenderer;
|
||||
|
||||
// called with scope of a series
|
||||
$.jqplot.PieRenderer.prototype.init = function(options, plot) {
|
||||
// Group: Properties
|
||||
//
|
||||
// prop: diameter
|
||||
// Outer diameter of the pie, auto computed by default
|
||||
this.diameter = null;
|
||||
// prop: padding
|
||||
// padding between the pie and plot edges, legend, etc.
|
||||
this.padding = 20;
|
||||
// prop: sliceMargin
|
||||
// angular spacing between pie slices in degrees.
|
||||
this.sliceMargin = 0;
|
||||
// prop: fill
|
||||
// true or false, wether to fil the slices.
|
||||
this.fill = true;
|
||||
// prop: shadowOffset
|
||||
// offset of the shadow from the slice and offset of
|
||||
// each succesive stroke of the shadow from the last.
|
||||
this.shadowOffset = 2;
|
||||
// prop: shadowAlpha
|
||||
// transparency of the shadow (0 = transparent, 1 = opaque)
|
||||
this.shadowAlpha = 0.07;
|
||||
// prop: shadowDepth
|
||||
// number of strokes to apply to the shadow,
|
||||
// each stroke offset shadowOffset from the last.
|
||||
this.shadowDepth = 5;
|
||||
// prop: highlightMouseOver
|
||||
// True to highlight slice when moused over.
|
||||
// This must be false to enable highlightMouseDown to highlight when clicking on a slice.
|
||||
this.highlightMouseOver = true;
|
||||
// prop: highlightMouseDown
|
||||
// True to highlight when a mouse button is pressed over a slice.
|
||||
// This will be disabled if highlightMouseOver is true.
|
||||
this.highlightMouseDown = false;
|
||||
// prop: highlightColors
|
||||
// an array of colors to use when highlighting a slice.
|
||||
this.highlightColors = [];
|
||||
// prop: dataLabels
|
||||
// Either 'label', 'value', 'percent' or an array of labels to place on the pie slices.
|
||||
// Defaults to percentage of each pie slice.
|
||||
this.dataLabels = 'percent';
|
||||
// prop: showDataLabels
|
||||
// true to show data labels on slices.
|
||||
this.showDataLabels = false;
|
||||
// prop: dataLabelFormatString
|
||||
// Format string for data labels. If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage.
|
||||
this.dataLabelFormatString = null;
|
||||
// prop: dataLabelThreshold
|
||||
// Threshhold in percentage (0-100) of pie area, below which no label will be displayed.
|
||||
// This applies to all label types, not just to percentage labels.
|
||||
this.dataLabelThreshold = 3;
|
||||
// prop: dataLabelPositionFactor
|
||||
// A Multiplier (0-1) of the pie radius which controls position of label on slice.
|
||||
// Increasing will slide label toward edge of pie, decreasing will slide label toward center of pie.
|
||||
this.dataLabelPositionFactor = 0.52;
|
||||
// prop: dataLabelNudge
|
||||
// Number of pixels to slide the label away from (+) or toward (-) the center of the pie.
|
||||
this.dataLabelNudge = 2;
|
||||
// prop: dataLabelCenterOn
|
||||
// True to center the data label at its position.
|
||||
// False to set the inside facing edge of the label at its position.
|
||||
this.dataLabelCenterOn = true;
|
||||
// prop: startAngle
|
||||
// Angle to start drawing pie in degrees.
|
||||
// According to orientation of canvas coordinate system:
|
||||
// 0 = on the positive x axis
|
||||
// -90 = on the positive y axis.
|
||||
// 90 = on the negaive y axis.
|
||||
// 180 or - 180 = on the negative x axis.
|
||||
this.startAngle = 0;
|
||||
this.tickRenderer = $.jqplot.PieTickRenderer;
|
||||
// Used as check for conditions where pie shouldn't be drawn.
|
||||
this._drawData = true;
|
||||
this._type = 'pie';
|
||||
|
||||
// if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
|
||||
if (options.highlightMouseDown && options.highlightMouseOver == null) {
|
||||
options.highlightMouseOver = false;
|
||||
}
|
||||
|
||||
$.extend(true, this, options);
|
||||
|
||||
if (this.sliceMargin < 0) {
|
||||
this.sliceMargin = 0;
|
||||
}
|
||||
|
||||
this._diameter = null;
|
||||
this._radius = null;
|
||||
// array of [start,end] angles arrays, one for each slice. In radians.
|
||||
this._sliceAngles = [];
|
||||
// index of the currenty highlighted point, if any
|
||||
this._highlightedPoint = null;
|
||||
|
||||
// set highlight colors if none provided
|
||||
if (this.highlightColors.length == 0) {
|
||||
for (var i=0; i<this.seriesColors.length; i++){
|
||||
var rgba = $.jqplot.getColorComponents(this.seriesColors[i]);
|
||||
var newrgb = [rgba[0], rgba[1], rgba[2]];
|
||||
var sum = newrgb[0] + newrgb[1] + newrgb[2];
|
||||
for (var j=0; j<3; j++) {
|
||||
// when darkening, lowest color component can be is 60.
|
||||
newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
|
||||
newrgb[j] = parseInt(newrgb[j], 10);
|
||||
}
|
||||
this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')');
|
||||
}
|
||||
}
|
||||
|
||||
this.highlightColorGenerator = new $.jqplot.ColorGenerator(this.highlightColors);
|
||||
|
||||
plot.postParseOptionsHooks.addOnce(postParseOptions);
|
||||
plot.postInitHooks.addOnce(postInit);
|
||||
plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
|
||||
plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
|
||||
plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
|
||||
plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
|
||||
plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
|
||||
plot.postDrawHooks.addOnce(postPlotDraw);
|
||||
};
|
||||
|
||||
$.jqplot.PieRenderer.prototype.setGridData = function(plot) {
|
||||
// set gridData property. This will hold angle in radians of each data point.
|
||||
var stack = [];
|
||||
var td = [];
|
||||
var sa = this.startAngle/180*Math.PI;
|
||||
var tot = 0;
|
||||
// don't know if we have any valid data yet, so set plot to not draw.
|
||||
this._drawData = false;
|
||||
for (var i=0; i<this.data.length; i++){
|
||||
if (this.data[i][1] != 0) {
|
||||
// we have data, O.K. to draw.
|
||||
this._drawData = true;
|
||||
}
|
||||
stack.push(this.data[i][1]);
|
||||
td.push([this.data[i][0]]);
|
||||
if (i>0) {
|
||||
stack[i] += stack[i-1];
|
||||
}
|
||||
tot += this.data[i][1];
|
||||
}
|
||||
var fact = Math.PI*2/stack[stack.length - 1];
|
||||
|
||||
for (var i=0; i<stack.length; i++) {
|
||||
td[i][1] = stack[i] * fact;
|
||||
td[i][2] = this.data[i][1]/tot;
|
||||
}
|
||||
this.gridData = td;
|
||||
};
|
||||
|
||||
$.jqplot.PieRenderer.prototype.makeGridData = function(data, plot) {
|
||||
var stack = [];
|
||||
var td = [];
|
||||
var tot = 0;
|
||||
var sa = this.startAngle/180*Math.PI;
|
||||
// don't know if we have any valid data yet, so set plot to not draw.
|
||||
this._drawData = false;
|
||||
for (var i=0; i<data.length; i++){
|
||||
if (this.data[i][1] != 0) {
|
||||
// we have data, O.K. to draw.
|
||||
this._drawData = true;
|
||||
}
|
||||
stack.push(data[i][1]);
|
||||
td.push([data[i][0]]);
|
||||
if (i>0) {
|
||||
stack[i] += stack[i-1];
|
||||
}
|
||||
tot += data[i][1];
|
||||
}
|
||||
var fact = Math.PI*2/stack[stack.length - 1];
|
||||
|
||||
for (var i=0; i<stack.length; i++) {
|
||||
td[i][1] = stack[i] * fact;
|
||||
td[i][2] = data[i][1]/tot;
|
||||
}
|
||||
return td;
|
||||
};
|
||||
|
||||
function calcRadiusAdjustment(ang) {
|
||||
return Math.sin((ang - (ang-Math.PI) / 8 / Math.PI )/2.0);
|
||||
}
|
||||
|
||||
function calcRPrime(ang1, ang2, sliceMargin, fill, lineWidth) {
|
||||
var rprime = 0;
|
||||
var ang = ang2 - ang1;
|
||||
var absang = Math.abs(ang);
|
||||
var sm = sliceMargin;
|
||||
if (fill == false) {
|
||||
sm += lineWidth;
|
||||
}
|
||||
|
||||
if (sm > 0 && absang > 0.01 && absang < 6.282) {
|
||||
rprime = parseFloat(sm) / 2.0 / calcRadiusAdjustment(ang);
|
||||
}
|
||||
|
||||
return rprime;
|
||||
}
|
||||
|
||||
$.jqplot.PieRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) {
|
||||
if (this._drawData) {
|
||||
var r = this._radius;
|
||||
var fill = this.fill;
|
||||
var lineWidth = this.lineWidth;
|
||||
var sm = this.sliceMargin;
|
||||
if (this.fill == false) {
|
||||
sm += this.lineWidth;
|
||||
}
|
||||
ctx.save();
|
||||
ctx.translate(this._center[0], this._center[1]);
|
||||
|
||||
var rprime = calcRPrime(ang1, ang2, this.sliceMargin, this.fill, this.lineWidth);
|
||||
|
||||
var transx = rprime * Math.cos((ang1 + ang2) / 2.0);
|
||||
var transy = rprime * Math.sin((ang1 + ang2) / 2.0);
|
||||
|
||||
if ((ang2 - ang1) <= Math.PI) {
|
||||
r -= rprime;
|
||||
}
|
||||
else {
|
||||
r += rprime;
|
||||
}
|
||||
|
||||
ctx.translate(transx, transy);
|
||||
|
||||
if (isShadow) {
|
||||
for (var i=0, l=this.shadowDepth; i<l; i++) {
|
||||
ctx.save();
|
||||
ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
|
||||
doDraw(r);
|
||||
}
|
||||
for (var i=0, l=this.shadowDepth; i<l; i++) {
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
doDraw(r);
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function doDraw (rad) {
|
||||
// Fix for IE and Chrome that can't seem to draw circles correctly.
|
||||
// ang2 should always be <= 2 pi since that is the way the data is converted.
|
||||
// 2Pi = 6.2831853, Pi = 3.1415927
|
||||
if (ang2 > 6.282 + this.startAngle) {
|
||||
ang2 = 6.282 + this.startAngle;
|
||||
if (ang1 > ang2) {
|
||||
ang1 = 6.281 + this.startAngle;
|
||||
}
|
||||
}
|
||||
// Fix for IE, where it can't seem to handle 0 degree angles. Also avoids
|
||||
// ugly line on unfilled pies.
|
||||
if (ang1 >= ang2) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = color;
|
||||
ctx.strokeStyle = color;
|
||||
ctx.lineWidth = lineWidth;
|
||||
ctx.arc(0, 0, rad, ang1, ang2, false);
|
||||
ctx.lineTo(0,0);
|
||||
ctx.closePath();
|
||||
|
||||
if (fill) {
|
||||
ctx.fill();
|
||||
}
|
||||
else {
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// called with scope of series
|
||||
$.jqplot.PieRenderer.prototype.draw = function (ctx, gd, options, plot) {
|
||||
var i;
|
||||
var opts = (options != undefined) ? options : {};
|
||||
// offset and direction of offset due to legend placement
|
||||
var offx = 0;
|
||||
var offy = 0;
|
||||
var trans = 1;
|
||||
var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
|
||||
if (options.legendInfo && options.legendInfo.placement == 'insideGrid') {
|
||||
var li = options.legendInfo;
|
||||
switch (li.location) {
|
||||
case 'nw':
|
||||
offx = li.width + li.xoffset;
|
||||
break;
|
||||
case 'w':
|
||||
offx = li.width + li.xoffset;
|
||||
break;
|
||||
case 'sw':
|
||||
offx = li.width + li.xoffset;
|
||||
break;
|
||||
case 'ne':
|
||||
offx = li.width + li.xoffset;
|
||||
trans = -1;
|
||||
break;
|
||||
case 'e':
|
||||
offx = li.width + li.xoffset;
|
||||
trans = -1;
|
||||
break;
|
||||
case 'se':
|
||||
offx = li.width + li.xoffset;
|
||||
trans = -1;
|
||||
break;
|
||||
case 'n':
|
||||
offy = li.height + li.yoffset;
|
||||
break;
|
||||
case 's':
|
||||
offy = li.height + li.yoffset;
|
||||
trans = -1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
|
||||
var fill = (opts.fill != undefined) ? opts.fill : this.fill;
|
||||
var cw = ctx.canvas.width;
|
||||
var ch = ctx.canvas.height;
|
||||
var w = cw - offx - 2 * this.padding;
|
||||
var h = ch - offy - 2 * this.padding;
|
||||
var mindim = Math.min(w,h);
|
||||
var d = mindim;
|
||||
|
||||
// Fixes issue #272. Thanks hugwijst!
|
||||
// reset slice angles array.
|
||||
this._sliceAngles = [];
|
||||
|
||||
var sm = this.sliceMargin;
|
||||
if (this.fill == false) {
|
||||
sm += this.lineWidth;
|
||||
}
|
||||
|
||||
var rprime;
|
||||
var maxrprime = 0;
|
||||
|
||||
var ang, ang1, ang2, shadowColor;
|
||||
var sa = this.startAngle / 180 * Math.PI;
|
||||
|
||||
// have to pre-draw shadows, so loop throgh here and calculate some values also.
|
||||
for (var i=0, l=gd.length; i<l; i++) {
|
||||
ang1 = (i == 0) ? sa : gd[i-1][1] + sa;
|
||||
ang2 = gd[i][1] + sa;
|
||||
|
||||
this._sliceAngles.push([ang1, ang2]);
|
||||
|
||||
rprime = calcRPrime(ang1, ang2, this.sliceMargin, this.fill, this.lineWidth);
|
||||
|
||||
if (Math.abs(ang2-ang1) > Math.PI) {
|
||||
maxrprime = Math.max(rprime, maxrprime);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.diameter != null && this.diameter > 0) {
|
||||
this._diameter = this.diameter - 2*maxrprime;
|
||||
}
|
||||
else {
|
||||
this._diameter = d - 2*maxrprime;
|
||||
}
|
||||
|
||||
// Need to check for undersized pie. This can happen if
|
||||
// plot area too small and legend is too big.
|
||||
if (this._diameter < 6) {
|
||||
$.jqplot.log('Diameter of pie too small, not rendering.');
|
||||
return;
|
||||
}
|
||||
|
||||
var r = this._radius = this._diameter/2;
|
||||
|
||||
this._center = [(cw - trans * offx)/2 + trans * offx + maxrprime * Math.cos(sa), (ch - trans*offy)/2 + trans * offy + maxrprime * Math.sin(sa)];
|
||||
|
||||
if (this.shadow) {
|
||||
for (var i=0, l=gd.length; i<l; i++) {
|
||||
shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
|
||||
this.renderer.drawSlice.call (this, ctx, this._sliceAngles[i][0], this._sliceAngles[i][1], shadowColor, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=0; i<gd.length; i++) {
|
||||
|
||||
this.renderer.drawSlice.call (this, ctx, this._sliceAngles[i][0], this._sliceAngles[i][1], colorGenerator.next(), false);
|
||||
|
||||
if (this.showDataLabels && gd[i][2]*100 >= this.dataLabelThreshold) {
|
||||
var fstr, avgang = (this._sliceAngles[i][0] + this._sliceAngles[i][1])/2, label;
|
||||
|
||||
if (this.dataLabels == 'label') {
|
||||
fstr = this.dataLabelFormatString || '%s';
|
||||
label = $.jqplot.sprintf(fstr, gd[i][0]);
|
||||
}
|
||||
else if (this.dataLabels == 'value') {
|
||||
fstr = this.dataLabelFormatString || '%d';
|
||||
label = $.jqplot.sprintf(fstr, this.data[i][1]);
|
||||
}
|
||||
else if (this.dataLabels == 'percent') {
|
||||
fstr = this.dataLabelFormatString || '%d%%';
|
||||
label = $.jqplot.sprintf(fstr, gd[i][2]*100);
|
||||
}
|
||||
else if (this.dataLabels.constructor == Array) {
|
||||
fstr = this.dataLabelFormatString || '%s';
|
||||
label = $.jqplot.sprintf(fstr, this.dataLabels[i]);
|
||||
}
|
||||
|
||||
var fact = (this._radius ) * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge;
|
||||
|
||||
var x = this._center[0] + Math.cos(avgang) * fact + this.canvas._offsets.left;
|
||||
var y = this._center[1] + Math.sin(avgang) * fact + this.canvas._offsets.top;
|
||||
|
||||
var labelelem = $('<div class="jqplot-pie-series jqplot-data-label" style="position:absolute;">' + label + '</div>').insertBefore(plot.eventCanvas._elem);
|
||||
if (this.dataLabelCenterOn) {
|
||||
x -= labelelem.width()/2;
|
||||
y -= labelelem.height()/2;
|
||||
}
|
||||
else {
|
||||
x -= labelelem.width() * Math.sin(avgang/2);
|
||||
y -= labelelem.height()/2;
|
||||
}
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
labelelem.css({left: x, top: y});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.jqplot.PieAxisRenderer = function() {
|
||||
$.jqplot.LinearAxisRenderer.call(this);
|
||||
};
|
||||
|
||||
$.jqplot.PieAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
|
||||
$.jqplot.PieAxisRenderer.prototype.constructor = $.jqplot.PieAxisRenderer;
|
||||
|
||||
|
||||
// There are no traditional axes on a pie chart. We just need to provide
|
||||
// dummy objects with properties so the plot will render.
|
||||
// called with scope of axis object.
|
||||
$.jqplot.PieAxisRenderer.prototype.init = function(options){
|
||||
//
|
||||
this.tickRenderer = $.jqplot.PieTickRenderer;
|
||||
$.extend(true, this, options);
|
||||
// I don't think I'm going to need _dataBounds here.
|
||||
// have to go Axis scaling in a way to fit chart onto plot area
|
||||
// and provide u2p and p2u functionality for mouse cursor, etc.
|
||||
// for convienence set _dataBounds to 0 and 100 and
|
||||
// set min/max to 0 and 100.
|
||||
this._dataBounds = {min:0, max:100};
|
||||
this.min = 0;
|
||||
this.max = 100;
|
||||
this.showTicks = false;
|
||||
this.ticks = [];
|
||||
this.showMark = false;
|
||||
this.show = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
$.jqplot.PieLegendRenderer = function(){
|
||||
$.jqplot.TableLegendRenderer.call(this);
|
||||
};
|
||||
|
||||
$.jqplot.PieLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
|
||||
$.jqplot.PieLegendRenderer.prototype.constructor = $.jqplot.PieLegendRenderer;
|
||||
|
||||
/**
|
||||
* Class: $.jqplot.PieLegendRenderer
|
||||
* Legend Renderer specific to pie plots. Set by default
|
||||
* when user creates a pie plot.
|
||||
*/
|
||||
$.jqplot.PieLegendRenderer.prototype.init = function(options) {
|
||||
// Group: Properties
|
||||
//
|
||||
// prop: numberRows
|
||||
// Maximum number of rows in the legend. 0 or null for unlimited.
|
||||
this.numberRows = null;
|
||||
// prop: numberColumns
|
||||
// Maximum number of columns in the legend. 0 or null for unlimited.
|
||||
this.numberColumns = null;
|
||||
$.extend(true, this, options);
|
||||
};
|
||||
|
||||
// called with context of legend
|
||||
$.jqplot.PieLegendRenderer.prototype.draw = function() {
|
||||
var legend = this;
|
||||
if (this.show) {
|
||||
var series = this._series;
|
||||
|
||||
|
||||
this._elem = $(document.createElement('table'));
|
||||
this._elem.addClass('jqplot-table-legend');
|
||||
|
||||
var ss = {position:'absolute'};
|
||||
if (this.background) {
|
||||
ss['background'] = this.background;
|
||||
}
|
||||
if (this.border) {
|
||||
ss['border'] = this.border;
|
||||
}
|
||||
if (this.fontSize) {
|
||||
ss['fontSize'] = this.fontSize;
|
||||
}
|
||||
if (this.fontFamily) {
|
||||
ss['fontFamily'] = this.fontFamily;
|
||||
}
|
||||
if (this.textColor) {
|
||||
ss['textColor'] = this.textColor;
|
||||
}
|
||||
if (this.marginTop != null) {
|
||||
ss['marginTop'] = this.marginTop;
|
||||
}
|
||||
if (this.marginBottom != null) {
|
||||
ss['marginBottom'] = this.marginBottom;
|
||||
}
|
||||
if (this.marginLeft != null) {
|
||||
ss['marginLeft'] = this.marginLeft;
|
||||
}
|
||||
if (this.marginRight != null) {
|
||||
ss['marginRight'] = this.marginRight;
|
||||
}
|
||||
|
||||
this._elem.css(ss);
|
||||
|
||||
// Pie charts legends don't go by number of series, but by number of data points
|
||||
// in the series. Refactor things here for that.
|
||||
|
||||
var pad = false,
|
||||
reverse = false,
|
||||
nr,
|
||||
nc;
|
||||
var s = series[0];
|
||||
var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
|
||||
|
||||
if (s.show) {
|
||||
var pd = s.data;
|
||||
if (this.numberRows) {
|
||||
nr = this.numberRows;
|
||||
if (!this.numberColumns){
|
||||
nc = Math.ceil(pd.length/nr);
|
||||
}
|
||||
else{
|
||||
nc = this.numberColumns;
|
||||
}
|
||||
}
|
||||
else if (this.numberColumns) {
|
||||
nc = this.numberColumns;
|
||||
nr = Math.ceil(pd.length/this.numberColumns);
|
||||
}
|
||||
else {
|
||||
nr = pd.length;
|
||||
nc = 1;
|
||||
}
|
||||
|
||||
var i, j;
|
||||
var tr, td1, td2;
|
||||
var lt, rs, color;
|
||||
var idx = 0;
|
||||
var div0, div1;
|
||||
|
||||
for (i=0; i<nr; i++) {
|
||||
tr = $(document.createElement('tr'));
|
||||
tr.addClass('jqplot-table-legend');
|
||||
|
||||
if (reverse){
|
||||
tr.prependTo(this._elem);
|
||||
}
|
||||
|
||||
else{
|
||||
tr.appendTo(this._elem);
|
||||
}
|
||||
|
||||
for (j=0; j<nc; j++) {
|
||||
if (idx < pd.length){
|
||||
lt = this.labels[idx] || pd[idx][0].toString();
|
||||
color = colorGenerator.next();
|
||||
if (!reverse){
|
||||
if (i>0){
|
||||
pad = true;
|
||||
}
|
||||
else{
|
||||
pad = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (i == nr -1){
|
||||
pad = false;
|
||||
}
|
||||
else{
|
||||
pad = true;
|
||||
}
|
||||
}
|
||||
rs = (pad) ? this.rowSpacing : '0';
|
||||
|
||||
|
||||
|
||||
td1 = $(document.createElement('td'));
|
||||
td1.addClass('jqplot-table-legend jqplot-table-legend-swatch');
|
||||
td1.css({textAlign: 'center', paddingTop: rs});
|
||||
|
||||
div0 = $(document.createElement('div'));
|
||||
div0.addClass('jqplot-table-legend-swatch-outline');
|
||||
div1 = $(document.createElement('div'));
|
||||
div1.addClass('jqplot-table-legend-swatch');
|
||||
div1.css({backgroundColor: color, borderColor: color});
|
||||
td1.append(div0.append(div1));
|
||||
|
||||
td2 = $(document.createElement('td'));
|
||||
td2.addClass('jqplot-table-legend jqplot-table-legend-label');
|
||||
td2.css('paddingTop', rs);
|
||||
|
||||
if (this.escapeHtml){
|
||||
td2.text(lt);
|
||||
}
|
||||
else {
|
||||
td2.html(lt);
|
||||
}
|
||||
if (reverse) {
|
||||
td2.prependTo(tr);
|
||||
td1.prependTo(tr);
|
||||
}
|
||||
else {
|
||||
td1.appendTo(tr);
|
||||
td2.appendTo(tr);
|
||||
}
|
||||
pad = true;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._elem;
|
||||
};
|
||||
|
||||
$.jqplot.PieRenderer.prototype.handleMove = function(ev, gridpos, datapos, neighbor, plot) {
|
||||
if (neighbor) {
|
||||
var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
|
||||
plot.target.trigger('jqplotDataMouseOver', ins);
|
||||
if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
|
||||
plot.target.trigger('jqplotDataHighlight', ins);
|
||||
highlight (plot, ins[0], ins[1]);
|
||||
}
|
||||
}
|
||||
else if (neighbor == null) {
|
||||
unhighlight (plot);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// this.eventCanvas._elem.bind($.jqplot.eventListenerHooks[i][0], {plot:this}, $.jqplot.eventListenerHooks[i][1]);
|
||||
|
||||
// setup default renderers for axes and legend so user doesn't have to
|
||||
// called with scope of plot
|
||||
function preInit(target, data, options) {
|
||||
options = options || {};
|
||||
options.axesDefaults = options.axesDefaults || {};
|
||||
options.legend = options.legend || {};
|
||||
options.seriesDefaults = options.seriesDefaults || {};
|
||||
// only set these if there is a pie series
|
||||
var setopts = false;
|
||||
if (options.seriesDefaults.renderer == $.jqplot.PieRenderer) {
|
||||
setopts = true;
|
||||
}
|
||||
else if (options.series) {
|
||||
for (var i=0; i < options.series.length; i++) {
|
||||
if (options.series[i].renderer == $.jqplot.PieRenderer) {
|
||||
setopts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (setopts) {
|
||||
options.axesDefaults.renderer = $.jqplot.PieAxisRenderer;
|
||||
options.legend.renderer = $.jqplot.PieLegendRenderer;
|
||||
options.legend.preDraw = true;
|
||||
options.seriesDefaults.pointLabels = {show: false};
|
||||
}
|
||||
}
|
||||
|
||||
function postInit(target, data, options) {
|
||||
for (var i=0; i<this.series.length; i++) {
|
||||
if (this.series[i].renderer.constructor == $.jqplot.PieRenderer) {
|
||||
// don't allow mouseover and mousedown at same time.
|
||||
if (this.series[i].highlightMouseOver) {
|
||||
this.series[i].highlightMouseDown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// called with scope of plot
|
||||
function postParseOptions(options) {
|
||||
for (var i=0; i<this.series.length; i++) {
|
||||
this.series[i].seriesColors = this.seriesColors;
|
||||
this.series[i].colorGenerator = $.jqplot.colorGenerator;
|
||||
}
|
||||
}
|
||||
|
||||
function highlight (plot, sidx, pidx) {
|
||||
var s = plot.series[sidx];
|
||||
var canvas = plot.plugins.pieRenderer.highlightCanvas;
|
||||
canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
|
||||
s._highlightedPoint = pidx;
|
||||
plot.plugins.pieRenderer.highlightedSeriesIndex = sidx;
|
||||
s.renderer.drawSlice.call(s, canvas._ctx, s._sliceAngles[pidx][0], s._sliceAngles[pidx][1], s.highlightColorGenerator.get(pidx), false);
|
||||
}
|
||||
|
||||
function unhighlight (plot) {
|
||||
var canvas = plot.plugins.pieRenderer.highlightCanvas;
|
||||
canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
|
||||
for (var i=0; i<plot.series.length; i++) {
|
||||
plot.series[i]._highlightedPoint = null;
|
||||
}
|
||||
plot.plugins.pieRenderer.highlightedSeriesIndex = null;
|
||||
plot.target.trigger('jqplotDataUnhighlight');
|
||||
}
|
||||
|
||||
function handleMove(ev, gridpos, datapos, neighbor, plot) {
|
||||
if (neighbor) {
|
||||
var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
|
||||
var evt1 = jQuery.Event('jqplotDataMouseOver');
|
||||
evt1.pageX = ev.pageX;
|
||||
evt1.pageY = ev.pageY;
|
||||
plot.target.trigger(evt1, ins);
|
||||
if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
|
||||
var evt = jQuery.Event('jqplotDataHighlight');
|
||||
evt.pageX = ev.pageX;
|
||||
evt.pageY = ev.pageY;
|
||||
plot.target.trigger(evt, ins);
|
||||
highlight (plot, ins[0], ins[1]);
|
||||
}
|
||||
}
|
||||
else if (neighbor == null) {
|
||||
unhighlight (plot);
|
||||
}
|
||||
}
|
||||
|
||||
function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
|
||||
if (neighbor) {
|
||||
var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
|
||||
if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
|
||||
var evt = jQuery.Event('jqplotDataHighlight');
|
||||
evt.pageX = ev.pageX;
|
||||
evt.pageY = ev.pageY;
|
||||
plot.target.trigger(evt, ins);
|
||||
highlight (plot, ins[0], ins[1]);
|
||||
}
|
||||
}
|
||||
else if (neighbor == null) {
|
||||
unhighlight (plot);
|
||||
}
|
||||
}
|
||||
|
||||
function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
|
||||
var idx = plot.plugins.pieRenderer.highlightedSeriesIndex;
|
||||
if (idx != null && plot.series[idx].highlightMouseDown) {
|
||||
unhighlight(plot);
|
||||
}
|
||||
}
|
||||
|
||||
function handleClick(ev, gridpos, datapos, neighbor, plot) {
|
||||
if (neighbor) {
|
||||
var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
|
||||
var evt = jQuery.Event('jqplotDataClick');
|
||||
evt.pageX = ev.pageX;
|
||||
evt.pageY = ev.pageY;
|
||||
plot.target.trigger(evt, ins);
|
||||
}
|
||||
}
|
||||
|
||||
function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
|
||||
if (neighbor) {
|
||||
var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
|
||||
var idx = plot.plugins.pieRenderer.highlightedSeriesIndex;
|
||||
if (idx != null && plot.series[idx].highlightMouseDown) {
|
||||
unhighlight(plot);
|
||||
}
|
||||
var evt = jQuery.Event('jqplotDataRightClick');
|
||||
evt.pageX = ev.pageX;
|
||||
evt.pageY = ev.pageY;
|
||||
plot.target.trigger(evt, ins);
|
||||
}
|
||||
}
|
||||
|
||||
// called within context of plot
|
||||
// create a canvas which we can draw on.
|
||||
// insert it before the eventCanvas, so eventCanvas will still capture events.
|
||||
function postPlotDraw() {
|
||||
// Memory Leaks patch
|
||||
if (this.plugins.pieRenderer && this.plugins.pieRenderer.highlightCanvas) {
|
||||
this.plugins.pieRenderer.highlightCanvas.resetCanvas();
|
||||
this.plugins.pieRenderer.highlightCanvas = null;
|
||||
}
|
||||
|
||||
this.plugins.pieRenderer = {highlightedSeriesIndex:null};
|
||||
this.plugins.pieRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
|
||||
|
||||
// do we have any data labels? if so, put highlight canvas before those
|
||||
var labels = $(this.targetId+' .jqplot-data-label');
|
||||
if (labels.length) {
|
||||
$(labels[0]).before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions, this));
|
||||
}
|
||||
// else put highlight canvas before event canvas.
|
||||
else {
|
||||
this.eventCanvas._elem.before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions, this));
|
||||
}
|
||||
|
||||
var hctx = this.plugins.pieRenderer.highlightCanvas.setContext();
|
||||
this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
|
||||
}
|
||||
|
||||
$.jqplot.preInitHooks.push(preInit);
|
||||
|
||||
$.jqplot.PieTickRenderer = function() {
|
||||
$.jqplot.AxisTickRenderer.call(this);
|
||||
};
|
||||
|
||||
$.jqplot.PieTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
|
||||
$.jqplot.PieTickRenderer.prototype.constructor = $.jqplot.PieTickRenderer;
|
||||
|
||||
})(jQuery);
|
||||
|
||||
|
||||
@@ -950,8 +950,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
|
||||
$editArea.find('textarea').val($(this).val());
|
||||
});
|
||||
$editArea.append('<div class="cell_edit_hint">' + g.cellEditHint + '</div>');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
|
||||
@@ -294,24 +294,20 @@ $js_messages['strSave'] = __('Save');
|
||||
$js_messages['strHideSearchCriteria'] = __('Hide search criteria');
|
||||
$js_messages['strShowSearchCriteria'] = __('Show search criteria');
|
||||
|
||||
/* For tbl_zoom_plot.js */
|
||||
/* For tbl_zoom_plot_jqplot.js */
|
||||
$js_messages['strZoomSearch'] = __('Zoom Search');
|
||||
$js_messages['strDisplayHelp'] = '<ul><li>'
|
||||
. __('Each point represents a data row.')
|
||||
. '</li><li>'
|
||||
. __('Hovering over a point will show its label.')
|
||||
. '</li><li>'
|
||||
. __('Use mousewheel to zoom in or out of the plot.')
|
||||
. __('To zoom in, select a section of the plot with the mouse.')
|
||||
. '</li><li>'
|
||||
. __('Click and drag the mouse to navigate the plot.')
|
||||
. '</li><li>'
|
||||
. __('Click reset zoom link to come back to original state.')
|
||||
. __('Click reset zoom button to come back to original state.')
|
||||
. '</li><li>'
|
||||
. __('Click a data point to view and possibly edit the data row.')
|
||||
. '</li><li>'
|
||||
. __('The plot can be resized by dragging it along the bottom right corner.')
|
||||
. '</li><li>'
|
||||
. __('Strings are converted into integer for plotting')
|
||||
. '</li></ul>';
|
||||
$js_messages['strInputNull'] = '<strong>' . __('Select two columns') . '</strong>';
|
||||
$js_messages['strSameInputs'] = '<strong>' . __('Select two different columns') . '</strong>';
|
||||
|
||||
@@ -180,12 +180,14 @@ function fast_filter(value)
|
||||
}
|
||||
fast_filter.ajax_semaphore = true;
|
||||
$.get('db_tables_search.php?db=' + db +'&table=' + lowercase_value, function(data) {
|
||||
if (data.tables) {
|
||||
var tables = data.tables;
|
||||
var l = tables.length;
|
||||
for(var i = 0; i < l; i++) {
|
||||
$('#subel0').append(tables[i].line);
|
||||
}
|
||||
fast_filter.ajax_semaphore = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ $(function() {
|
||||
window.parent.frame_navigation.location.reload();
|
||||
}
|
||||
$('#tableslistcontainer').load('server_databases.php form#dbStatsForm');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + ": " + data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
|
||||
@@ -9,48 +9,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Validates the password field in a form
|
||||
*
|
||||
* @see PMA_messages['strPasswordEmpty']
|
||||
* @see PMA_messages['strPasswordNotSame']
|
||||
* @param object the form
|
||||
* @return boolean whether the field value is valid or not
|
||||
*/
|
||||
function checkPassword(the_form)
|
||||
{
|
||||
// Did the user select 'no password'?
|
||||
if (typeof(the_form.elements['nopass']) != 'undefined'
|
||||
&& the_form.elements['nopass'][0].checked) {
|
||||
return true;
|
||||
} else if (typeof(the_form.elements['pred_password']) != 'undefined'
|
||||
&& (the_form.elements['pred_password'].value == 'none'
|
||||
|| the_form.elements['pred_password'].value == 'keep')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var password = the_form.elements['pma_pw'];
|
||||
var password_repeat = the_form.elements['pma_pw2'];
|
||||
var alert_msg = false;
|
||||
|
||||
if (password.value == '') {
|
||||
alert_msg = PMA_messages['strPasswordEmpty'];
|
||||
} else if (password.value != password_repeat.value) {
|
||||
alert_msg = PMA_messages['strPasswordNotSame'];
|
||||
}
|
||||
|
||||
if (alert_msg) {
|
||||
alert(alert_msg);
|
||||
password.value = '';
|
||||
password_repeat.value = '';
|
||||
password.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // end of the 'checkPassword()' function
|
||||
|
||||
|
||||
/**
|
||||
* Validates the "add a user" form
|
||||
*
|
||||
@@ -70,7 +28,7 @@ function checkAddUser(the_form)
|
||||
return false;
|
||||
}
|
||||
|
||||
return checkPassword(the_form);
|
||||
return PMA_checkPassword($(the_form));
|
||||
} // end of the 'checkAddUser()' function
|
||||
|
||||
/**
|
||||
@@ -167,7 +125,6 @@ $(function() {
|
||||
var $form = $(this).find("form[name=usersForm]").last();
|
||||
|
||||
if (! checkAddUser($form.get(0))) {
|
||||
PMA_ajaxShowMessage(PMA_messages['strFormEmpty']);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -212,22 +169,12 @@ $(function() {
|
||||
} else {
|
||||
$("#usersForm").remove();
|
||||
}
|
||||
var $user_div = $('<div id="userFormDiv"></div>');
|
||||
/*If the JSON string parsed correctly*/
|
||||
if (typeof priv_data.success != 'undefined') {
|
||||
if (priv_data.success == true) {
|
||||
$user_div
|
||||
.html(priv_data.user_form)
|
||||
.insertAfter('#result_query');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + priv_data.error, false);
|
||||
}
|
||||
if (priv_data.success == true) {
|
||||
$('<div id="userFormDiv"></div>')
|
||||
.html(priv_data.user_form)
|
||||
.insertAfter('#result_query');
|
||||
} else {
|
||||
/*parse the JSON string*/
|
||||
var obj = $.parseJSON(priv_data);
|
||||
$user_div
|
||||
.html(obj.user_form)
|
||||
.insertAfter('#result_query');
|
||||
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + priv_data.error, false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -242,7 +189,7 @@ $(function() {
|
||||
|
||||
$.get($(this).attr("href"), {'ajax_request':true}, function(data) {
|
||||
var $div = $('<div id="add_user_dialog"></div>')
|
||||
.prepend(data)
|
||||
.prepend(data.message)
|
||||
.find("#fieldset_add_user_footer").hide() //showing the "Go" and "Create User" buttons together will confuse the user
|
||||
.end()
|
||||
.find("form[name=usersForm]").append('<input type="hidden" name="ajax_request" value="true" />')
|
||||
@@ -261,9 +208,18 @@ $(function() {
|
||||
}
|
||||
}); //dialog options end
|
||||
displayPasswordGenerateButton();
|
||||
PMA_convertFootnotesToTooltips($div);
|
||||
PMA_showHints($div);
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
$div.find("input[autofocus]").focus();
|
||||
|
||||
$div.find('form[name=usersForm]').bind('submit', function (e) {
|
||||
e.preventDefault();
|
||||
$(this)
|
||||
.closest('.ui-dialog')
|
||||
.find('.ui-dialog-buttonpane .ui-button')
|
||||
.first()
|
||||
.click();
|
||||
});
|
||||
}); // end $.get()
|
||||
|
||||
});//end of Add New User AJAX event handler
|
||||
@@ -285,8 +241,7 @@ $(function() {
|
||||
$.get($(this).attr("href"), {'ajax_request': true}, function(data) {
|
||||
if(data.success == true) {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); //end $.get()
|
||||
@@ -334,8 +289,7 @@ $(function() {
|
||||
.find('tr:even')
|
||||
.removeClass('odd').addClass('even');
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
@@ -377,7 +331,7 @@ $(function() {
|
||||
},
|
||||
function(data) {
|
||||
var $div = $('<div id="edit_user_dialog"></div>')
|
||||
.append(data)
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
width: 900,
|
||||
height: 600,
|
||||
@@ -388,7 +342,7 @@ $(function() {
|
||||
}); //dialog options end
|
||||
displayPasswordGenerateButton();
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
PMA_convertFootnotesToTooltips($div);
|
||||
PMA_showHints($div);
|
||||
}); // end $.get()
|
||||
});
|
||||
|
||||
@@ -404,10 +358,14 @@ $(function() {
|
||||
/** @lends jQuery */
|
||||
event.preventDefault();
|
||||
|
||||
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
|
||||
|
||||
var $t = $(this);
|
||||
|
||||
if ($t.is('.copyUserForm') && ! PMA_checkPassword($t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
|
||||
|
||||
$t.append('<input type="hidden" name="ajax_request" value="true" />');
|
||||
|
||||
/**
|
||||
@@ -466,8 +424,7 @@ $(function() {
|
||||
$("#usersForm")
|
||||
.find('.current_row')
|
||||
.removeClass('current_row');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
@@ -592,7 +549,7 @@ $(function() {
|
||||
$("#usersForm").hide("medium").remove();
|
||||
$("#fieldset_add_user").hide("medium").remove();
|
||||
$("#initials_table")
|
||||
.after(data).show("medium")
|
||||
.after(data.message).show("medium")
|
||||
.siblings("h2").not(":first").remove();
|
||||
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
|
||||
@@ -130,10 +130,6 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$.ajaxSetup({
|
||||
cache: false
|
||||
});
|
||||
|
||||
// Add tabs
|
||||
$('#serverStatusTabs').tabs({
|
||||
// Tab persistence
|
||||
@@ -224,7 +220,7 @@ $(function() {
|
||||
|
||||
$.get($(this).attr('href'), { ajax_request: 1 }, function(data) {
|
||||
$(that).find('img').hide();
|
||||
initTab(tab, data);
|
||||
initTab(tab, data.message);
|
||||
});
|
||||
|
||||
tabStatus[tab.attr('id')] = 'data';
|
||||
@@ -441,7 +437,7 @@ $(function() {
|
||||
if (data != null) {
|
||||
tab.find('.tabInnerContent').html(data);
|
||||
}
|
||||
PMA_convertFootnotesToTooltips();
|
||||
PMA_showHints();
|
||||
break;
|
||||
case 'statustabs_queries':
|
||||
if (data != null) {
|
||||
@@ -650,7 +646,7 @@ $(function() {
|
||||
$.get('server_status.php?' + url_query, { ajax_request: true, advisor: true }, function(data) {
|
||||
var $tbody, $tr, str, even = true;
|
||||
|
||||
data = $.parseJSON(data);
|
||||
data = $.parseJSON(data.message);
|
||||
|
||||
$cnt.html('');
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ $(function() {
|
||||
|
||||
$.get('server_status.php?' + url_query, vars,
|
||||
function(data) {
|
||||
var logVars = $.parseJSON(data),
|
||||
var logVars = $.parseJSON(data.message),
|
||||
icon = PMA_getImage('s_success.png'), msg='', str='';
|
||||
|
||||
if (logVars['general_log'] == 'ON') {
|
||||
@@ -1202,7 +1202,7 @@ $(function() {
|
||||
}, function(data) {
|
||||
var chartData;
|
||||
try {
|
||||
chartData = $.parseJSON(data);
|
||||
chartData = $.parseJSON(data.message);
|
||||
} catch(err) {
|
||||
return serverResponseError();
|
||||
}
|
||||
@@ -1388,7 +1388,7 @@ $(function() {
|
||||
function(data) {
|
||||
var logData;
|
||||
try {
|
||||
logData = $.parseJSON(data);
|
||||
logData = $.parseJSON(data.message);
|
||||
} catch(err) {
|
||||
return serverResponseError();
|
||||
}
|
||||
@@ -1773,7 +1773,7 @@ $(function() {
|
||||
query: codemirror_editor ? codemirror_editor.getValue() : $('#sqlquery').val(),
|
||||
database: db
|
||||
}, function(data) {
|
||||
data = $.parseJSON(data);
|
||||
data = $.parseJSON(data.message);
|
||||
var totalTime = 0;
|
||||
|
||||
if (data.error) {
|
||||
|
||||
@@ -174,7 +174,7 @@ function editVariable(link)
|
||||
$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" id="variableEditArea" value="' + data + '" /></td></tr</table>');
|
||||
'<input type="text" id="variableEditArea" value="' + data.message + '" /></td></tr></table>');
|
||||
$cell.find('table td:first').append(mySaveLink);
|
||||
$cell.find('table td:first').append(' ');
|
||||
$cell.find('table td:first').append(myCancelLink);
|
||||
|
||||
58
js/sql.js
58
js/sql.js
@@ -197,6 +197,7 @@ $(function() {
|
||||
//
|
||||
// fade out previous messages, if any
|
||||
$('div.success, div.sqlquery_message').fadeOut();
|
||||
|
||||
// show a message that stays on screen
|
||||
if (typeof data.action_bookmark != 'undefined') {
|
||||
// view only
|
||||
@@ -209,7 +210,9 @@ $(function() {
|
||||
if ('2' == data.action_bookmark) {
|
||||
$("#id_bookmark option[value='" + data.id_bookmark + "']").remove();
|
||||
}
|
||||
$('#sqlqueryform').before(data.message);
|
||||
$sqlqueryresults
|
||||
.show()
|
||||
.html(data.message);
|
||||
} else if (typeof data.sql_query != 'undefined') {
|
||||
$('<div class="sqlquery_message"></div>')
|
||||
.html(data.sql_query)
|
||||
@@ -217,9 +220,22 @@ $(function() {
|
||||
// unnecessary div that came from data.sql_query
|
||||
$('div.notice').remove();
|
||||
} else {
|
||||
$('#sqlqueryform').before(data.message);
|
||||
$sqlqueryresults
|
||||
.show()
|
||||
.html(data.message);
|
||||
}
|
||||
$sqlqueryresults.show();
|
||||
$sqlqueryresults.show().trigger('makegrid');
|
||||
$('#togglequerybox').show();
|
||||
PMA_init_slider();
|
||||
|
||||
if (typeof data.action_bookmark == 'undefined') {
|
||||
if( $('#sqlqueryform input[name="retain_query_box"]').is(':checked') != true ) {
|
||||
if ($("#togglequerybox").siblings(":visible").length > 0) {
|
||||
$("#togglequerybox").trigger('click');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this happens if a USE command was typed
|
||||
if (typeof data.reload != 'undefined') {
|
||||
// Unbind the submit event before reloading. See bug #3295529
|
||||
@@ -236,29 +252,6 @@ $(function() {
|
||||
// show an error message that stays on screen
|
||||
$('#sqlqueryform').before(data.error);
|
||||
$sqlqueryresults.hide();
|
||||
} else {
|
||||
// real results are returned
|
||||
// fade out previous messages, if any
|
||||
$('div.success, div.sqlquery_message').fadeOut();
|
||||
var $received_data = $(data);
|
||||
var $zero_row_results = $received_data.find('textarea[name="sql_query"]');
|
||||
// if zero rows are returned from the query execution
|
||||
if ($zero_row_results.length > 0) {
|
||||
$('#sqlquery').val($zero_row_results.val());
|
||||
setQuery($('#sqlquery').val());
|
||||
} else {
|
||||
$sqlqueryresults
|
||||
.show()
|
||||
.html(data)
|
||||
.trigger('makegrid');
|
||||
$('#togglequerybox').show();
|
||||
if( $('#sqlqueryform input[name="retain_query_box"]').is(':checked') != true ) {
|
||||
if ($("#togglequerybox").siblings(":visible").length > 0) {
|
||||
$("#togglequerybox").trigger('click');
|
||||
}
|
||||
}
|
||||
PMA_init_slider();
|
||||
}
|
||||
}
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}); // end $.post()
|
||||
@@ -302,10 +295,9 @@ $(function() {
|
||||
|
||||
$.post($form.attr('action'), $form.serialize(), function(data) {
|
||||
$("#sqlqueryresults")
|
||||
.html(data)
|
||||
.html(data.message)
|
||||
.trigger('makegrid');
|
||||
PMA_init_slider();
|
||||
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}); // end $.post()
|
||||
}
|
||||
@@ -327,7 +319,7 @@ $(function() {
|
||||
|
||||
$.post($form.attr('action'), $form.serialize() + '&ajax_request=true', function(data) {
|
||||
$("#sqlqueryresults")
|
||||
.html(data)
|
||||
.html(data.message)
|
||||
.trigger('makegrid');
|
||||
PMA_init_slider();
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
@@ -353,7 +345,7 @@ $(function() {
|
||||
|
||||
$.get($anchor.attr('href'), $anchor.serialize() + '&ajax_request=true', function(data) {
|
||||
$("#sqlqueryresults")
|
||||
.html(data)
|
||||
.html(data.message)
|
||||
.trigger('makegrid');
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}); // end $.get()
|
||||
@@ -372,7 +364,7 @@ $(function() {
|
||||
|
||||
$.post($form.attr('action'), $form.serialize() + '&ajax_request=true' , function(data) {
|
||||
$("#sqlqueryresults")
|
||||
.html(data)
|
||||
.html(data.message)
|
||||
.trigger('makegrid');
|
||||
PMA_init_slider();
|
||||
}); // end $.post()
|
||||
@@ -422,7 +414,7 @@ $(function() {
|
||||
}); // end dialog options
|
||||
} else {
|
||||
$div
|
||||
.append(data)
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
title: PMA_messages['strChangeTbl'],
|
||||
height: 600,
|
||||
@@ -609,7 +601,7 @@ function makeProfilingChart()
|
||||
// Prevent the user from seeing the JSON code
|
||||
$('div#profilingchart').html('').show();
|
||||
|
||||
PMA_createProfilingChart(data);
|
||||
PMA_createProfilingChartJqplot('profilingchart', data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -322,6 +322,9 @@ $(function() {
|
||||
* to previous page" and "insert another new row" actions, using AJAX
|
||||
* has no obvious advantage. If inserting, the "go back to previous"
|
||||
* action needs a page refresh anyway.
|
||||
*
|
||||
* 3. The handling of the response is also broken because PMA
|
||||
* no longher returns plain HTML for an ajax request
|
||||
*/
|
||||
$("#insertFormDEACTIVATED").live('submit', function(event) {
|
||||
|
||||
|
||||
@@ -52,11 +52,11 @@ $(function() {
|
||||
|
||||
PMA_prepareForAjaxRequest($search_form);
|
||||
|
||||
$.post($search_form.attr('action'), $search_form.serialize(), function(response) {
|
||||
$.post($search_form.attr('action'), $search_form.serialize(), function(data) {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
if (typeof response == 'string') {
|
||||
if (data.success == true) {
|
||||
// found results
|
||||
$("#sqlqueryresults").html(response);
|
||||
$("#sqlqueryresults").html(data.message);
|
||||
$("#sqlqueryresults").trigger('makegrid');
|
||||
$('#tbl_search_form')
|
||||
// workaround for bug #3168569 - Issue on toggling the "Hide search criteria" in chrome.
|
||||
@@ -71,14 +71,7 @@ $(function() {
|
||||
// needed for the display options slider in the results
|
||||
PMA_init_slider();
|
||||
} else {
|
||||
// error message (zero rows)
|
||||
if (response.message != undefined) {
|
||||
$("#sqlqueryresults").html(response['message']);
|
||||
}
|
||||
// other error (syntax error?)
|
||||
if (response.error != undefined) {
|
||||
$("#sqlqueryresults").html(response['error']);
|
||||
}
|
||||
$("#sqlqueryresults").html(data.error);
|
||||
}
|
||||
}); // end $.post()
|
||||
});
|
||||
|
||||
@@ -64,8 +64,7 @@ $(function() {
|
||||
$curr_row.hide("medium").remove();
|
||||
// refresh the list of indexes (comes from sql.php)
|
||||
$('#indexes').html(data.indexes_list);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false);
|
||||
}
|
||||
}); // end $.get()
|
||||
@@ -104,8 +103,7 @@ $(function() {
|
||||
if (typeof data.reload != 'undefined') {
|
||||
window.parent.frame_content.location.reload();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false);
|
||||
}
|
||||
}); // end $.get()
|
||||
@@ -158,8 +156,7 @@ $(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false);
|
||||
}
|
||||
}); // end $.get()
|
||||
@@ -265,7 +262,7 @@ $(function() {
|
||||
$("#edit_index_dialog").dialog("close");
|
||||
}
|
||||
$('div.no_indexes_defined').hide();
|
||||
} else if (data.error != undefined) {
|
||||
} else {
|
||||
var $temp_div = $("<div id='temp_div'><div>").append(data.error);
|
||||
if ($temp_div.find(".error code").length != 0) {
|
||||
var $error = $temp_div.find(".error code").addClass("error");
|
||||
@@ -281,14 +278,14 @@ $(function() {
|
||||
};
|
||||
var $msgbox = PMA_ajaxShowMessage();
|
||||
$.get("tbl_indexes.php", url, function(data) {
|
||||
if (data.error) {
|
||||
if (data.success == false) {
|
||||
//in the case of an error, show the error message returned.
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
// Show dialog if the request was successful
|
||||
$div
|
||||
.append(data)
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
title: title,
|
||||
width: 450,
|
||||
@@ -301,7 +298,7 @@ $(function() {
|
||||
});
|
||||
checkIndexType();
|
||||
checkIndexName("index_frm");
|
||||
PMA_convertFootnotesToTooltips($div);
|
||||
PMA_showHints($div);
|
||||
// Add a slider for selecting how many columns to add to the index
|
||||
$div.find('.slider').slider({
|
||||
animate: true,
|
||||
@@ -390,7 +387,7 @@ $(function() {
|
||||
}
|
||||
|
||||
$.post($form.prop("action"), serialized + "&ajax_request=true", function (data) {
|
||||
if (data.success != undefined && data.success == false) {
|
||||
if (data.success == false) {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
$this
|
||||
.clone()
|
||||
@@ -410,8 +407,7 @@ $(function() {
|
||||
// loop through the correct order
|
||||
for (var i in data.columns) {
|
||||
var the_column = data.columns[i];
|
||||
var $the_row
|
||||
= $rows
|
||||
var $the_row = $rows
|
||||
.find("input:checkbox[value=" + the_column + "]")
|
||||
.closest("tr");
|
||||
// append the row for this column to the table
|
||||
@@ -526,7 +522,7 @@ $(function() {
|
||||
}); // end dialog options
|
||||
} else {
|
||||
$div
|
||||
.append(data)
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
title: PMA_messages['strAddColumns'],
|
||||
height: 600,
|
||||
@@ -542,7 +538,7 @@ $(function() {
|
||||
$div = $("#add_columns");
|
||||
/*changed the z-index of the enum editor to allow the edit*/
|
||||
$("#enum_editor").css("z-index", "1100");
|
||||
PMA_convertFootnotesToTooltips($div);
|
||||
PMA_showHints($div);
|
||||
// set focus on first column name input
|
||||
$div.find("input.textfield").eq(0).focus();
|
||||
}
|
||||
@@ -604,7 +600,7 @@ function changeColumns(action,url)
|
||||
}); // end dialog options
|
||||
} else {
|
||||
$div
|
||||
.append(data)
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
title: PMA_messages['strChangeTbl'],
|
||||
height: 600,
|
||||
@@ -620,7 +616,7 @@ function changeColumns(action,url)
|
||||
/*changed the z-index of the enum editor to allow the edit*/
|
||||
$("#enum_editor").css("z-index", "1100");
|
||||
$div = $("#change_column_dialog");
|
||||
PMA_convertFootnotesToTooltips($div);
|
||||
PMA_showHints($div);
|
||||
}
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}); // end $.get()
|
||||
@@ -673,7 +669,7 @@ $(function() {
|
||||
/*Reload the field form*/
|
||||
reloadFieldForm(data.message);
|
||||
} else {
|
||||
var $temp_div = $("<div id='temp_div'><div>").append(data);
|
||||
var $temp_div = $("<div id='temp_div'><div>").append(data.error);
|
||||
var $error = $temp_div.find(".error code").addClass("error");
|
||||
PMA_ajaxShowMessage($error, false);
|
||||
}
|
||||
@@ -693,7 +689,7 @@ $(function() {
|
||||
*/
|
||||
function reloadFieldForm(message) {
|
||||
$.post($("#fieldsForm").attr('action'), $("#fieldsForm").serialize()+"&ajax_request=true", function(form_data) {
|
||||
var $temp_div = $("<div id='temp_div'><div>").append(form_data);
|
||||
var $temp_div = $("<div id='temp_div'><div>").append(form_data.message);
|
||||
$("#fieldsForm").replaceWith($temp_div.find("#fieldsForm"));
|
||||
$("#addColumns").replaceWith($temp_div.find("#addColumns"));
|
||||
$('#move_columns_dialog ul').replaceWith($temp_div.find("#move_columns_dialog ul"));
|
||||
|
||||
@@ -1,878 +0,0 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
** @fileoverview JavaScript functions used on tbl_select.php
|
||||
**
|
||||
** @requires jQuery
|
||||
** @requires js/functions.js
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
** Display Help/Info
|
||||
**/
|
||||
function displayHelp() {
|
||||
var msgbox = PMA_ajaxShowMessage(PMA_messages['strDisplayHelp'], 10000);
|
||||
msgbox.click(function() {
|
||||
PMA_ajaxRemoveMessage(msgbox);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
** Extend the array object for max function
|
||||
** @param array
|
||||
**/
|
||||
Array.max = function (array) {
|
||||
return Math.max.apply( Math, array );
|
||||
};
|
||||
|
||||
/**
|
||||
** Extend the array object for min function
|
||||
** @param array
|
||||
**/
|
||||
Array.min = function (array) {
|
||||
return Math.min.apply( Math, array );
|
||||
};
|
||||
|
||||
/**
|
||||
** Checks if a string contains only numeric value
|
||||
** @param n: String (to be checked)
|
||||
**/
|
||||
function isNumeric(n) {
|
||||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||
}
|
||||
|
||||
/**
|
||||
** Checks if an object is empty
|
||||
** @param n: Object (to be checked)
|
||||
**/
|
||||
function isEmpty(obj) {
|
||||
var name;
|
||||
for (name in obj) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
** Converts a timestamp into the format of its field type
|
||||
** @param val Integer Timestamp
|
||||
** @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);
|
||||
}
|
||||
else if (type.toString().search(/date/i) != -1) {
|
||||
return Highcharts.dateFormat('%Y-%m-%e', val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Converts a date/time into timestamp
|
||||
** @param val String Date
|
||||
** @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');
|
||||
}
|
||||
else if (type.toString().search(/date/i) != -1) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
/**
|
||||
** Converts a categorical array into numeric array
|
||||
** @param array categorical values array
|
||||
**/
|
||||
function getCord(arr) {
|
||||
var newCord = new Array();
|
||||
var original = $.extend(true, [], arr);
|
||||
var arr = jQuery.unique(arr).sort();
|
||||
$.each(original, function(index, value) {
|
||||
newCord.push(jQuery.inArray(value, arr));
|
||||
});
|
||||
return [newCord, arr, original];
|
||||
}
|
||||
|
||||
/**
|
||||
** Scrolls the view to the display section
|
||||
**/
|
||||
function scrollToChart() {
|
||||
var x = $('#dataDisplay').offset().top - 100; // 100 provides buffer in viewport
|
||||
$('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;
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer';
|
||||
var currentChart = null;
|
||||
var currentData = null;
|
||||
var xLabel = $('#tableid_0').val();
|
||||
var yLabel = $('#tableid_1').val();
|
||||
var xType = $('#types_0').val();
|
||||
var yType = $('#types_1').val();
|
||||
var dataLabel = $('#dataLabel').val();
|
||||
var zoomRatio = 1;
|
||||
|
||||
|
||||
// Get query result
|
||||
var data = jQuery.parseJSON($('#querydata').html());
|
||||
|
||||
/**
|
||||
** Input form submit on field change
|
||||
**/
|
||||
$('#tableid_0').change(function() {
|
||||
//AJAX request for field type, collation, operators, and value field
|
||||
$.post('tbl_zoom_select.php',{
|
||||
'ajax_request' : true,
|
||||
'change_tbl_info' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'field' : $('#tableid_0').val(),
|
||||
'it' : 0,
|
||||
'token' : window.parent.token
|
||||
},function(data) {
|
||||
$('#tableFieldsId tr:eq(1) td:eq(0)').html(data.field_type);
|
||||
$('#tableFieldsId tr:eq(1) td:eq(1)').html(data.field_collation);
|
||||
$('#tableFieldsId tr:eq(1) td:eq(2)').html(data.field_operators);
|
||||
$('#tableFieldsId tr:eq(1) td:eq(3)').html(data.field_value);
|
||||
xLabel = $('#tableid_0').val();
|
||||
$('#types_0').val(data.field_type);
|
||||
$('#collations_0').val(data.field_collations);
|
||||
});
|
||||
});
|
||||
|
||||
$('#tableid_1').change(function() {
|
||||
//AJAX request for field type, collation, operators, and value field
|
||||
$.post('tbl_zoom_select.php',{
|
||||
'ajax_request' : true,
|
||||
'change_tbl_info' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'field' : $('#tableid_1').val(),
|
||||
'it' : 1,
|
||||
'token' : window.parent.token
|
||||
},function(data) {
|
||||
$('#tableFieldsId tr:eq(3) td:eq(0)').html(data.field_type);
|
||||
$('#tableFieldsId tr:eq(3) td:eq(1)').html(data.field_collation);
|
||||
$('#tableFieldsId tr:eq(3) td:eq(2)').html(data.field_operators);
|
||||
$('#tableFieldsId tr:eq(3) td:eq(3)').html(data.field_value);
|
||||
yLabel = $('#tableid_1').val();
|
||||
$('#types_1').val(data.field_type);
|
||||
$('#collations_1').val(data.field_collations);
|
||||
});
|
||||
});
|
||||
|
||||
$('#tableid_2').change(function() {
|
||||
//AJAX request for field type, collation, operators, and value field
|
||||
$.post('tbl_zoom_select.php',{
|
||||
'ajax_request' : true,
|
||||
'change_tbl_info' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'field' : $('#tableid_2').val(),
|
||||
'it' : 2,
|
||||
'token' : window.parent.token
|
||||
},function(data) {
|
||||
$('#tableFieldsId tr:eq(6) td:eq(0)').html(data.field_type);
|
||||
$('#tableFieldsId tr:eq(6) td:eq(1)').html(data.field_collation);
|
||||
$('#tableFieldsId tr:eq(6) td:eq(2)').html(data.field_operators);
|
||||
$('#tableFieldsId tr:eq(6) td:eq(3)').html(data.field_value);
|
||||
$('#types_2').val(data.field_type);
|
||||
$('#collations_2').val(data.field_collations);
|
||||
});
|
||||
});
|
||||
|
||||
$('#tableid_3').change(function() {
|
||||
//AJAX request for field type, collation, operators, and value field
|
||||
$.post('tbl_zoom_select.php',{
|
||||
'ajax_request' : true,
|
||||
'change_tbl_info' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'field' : $('#tableid_3').val(),
|
||||
'it' : 3,
|
||||
'token' : window.parent.token
|
||||
},function(data) {
|
||||
$('#tableFieldsId tr:eq(8) td:eq(0)').html(data.field_type);
|
||||
$('#tableFieldsId tr:eq(8) td:eq(1)').html(data.field_collation);
|
||||
$('#tableFieldsId tr:eq(8) td:eq(2)').html(data.field_operators);
|
||||
$('#tableFieldsId tr:eq(8) td:eq(3)').html(data.field_value);
|
||||
$('#types_3').val(data.field_type);
|
||||
$('#collations_3').val(data.field_collations);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
PMA_ajaxShowMessage(PMA_messages['strSameInputs']);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
** Prepare a div containing a link, otherwise it's incorrectly displayed
|
||||
** after a couple of clicks
|
||||
**/
|
||||
$('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
|
||||
.insertAfter('#zoom_search_form')
|
||||
// don't show it until we have results on-screen
|
||||
.hide();
|
||||
|
||||
$('#togglesearchformlink')
|
||||
.html(PMA_messages['strShowSearchCriteria'])
|
||||
.bind('click', function() {
|
||||
var $link = $(this);
|
||||
$('#zoom_search_form').slideToggle();
|
||||
if ($link.text() == PMA_messages['strHideSearchCriteria']) {
|
||||
$link.text(PMA_messages['strShowSearchCriteria']);
|
||||
} else {
|
||||
$link.text(PMA_messages['strHideSearchCriteria']);
|
||||
}
|
||||
// avoid default click action
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
** Set dialog properties for the data display form
|
||||
**/
|
||||
var buttonOptions = {};
|
||||
/*
|
||||
* Handle saving of a row in the editor
|
||||
*/
|
||||
buttonOptions[PMA_messages['strSave']] = function () {
|
||||
//Find changed values by comparing form values with selectedRow Object
|
||||
var newValues = new Object();//Stores the values changed from original
|
||||
var sqlTypes = new Object();
|
||||
var it = 4;
|
||||
var xChange = false;
|
||||
var yChange = false;
|
||||
var key;
|
||||
|
||||
for (key in selectedRow) {
|
||||
var oldVal = selectedRow[key];
|
||||
var newVal = ($('#fields_null_id_' + it).prop('checked')) ? null : $('#fieldID_' + it).val();
|
||||
if (newVal instanceof Array) { // when the column is of type SET
|
||||
newVal = $('#fieldID_' + it).map(function(){
|
||||
return $(this).val();
|
||||
}).get().join(",");
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
var $input = $('#fieldID_' + it);
|
||||
if ($input.hasClass('bit')) {
|
||||
sqlTypes[key] = 'bit';
|
||||
}
|
||||
it++;
|
||||
} //End data update
|
||||
|
||||
//Update the chart series and replot
|
||||
if (xChange || yChange) {
|
||||
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);
|
||||
} 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();
|
||||
} //End plot update
|
||||
|
||||
//Generate SQL query for update
|
||||
if (!isEmpty(newValues)) {
|
||||
var sql_query = 'UPDATE `' + window.parent.table + '` SET ';
|
||||
for (key in newValues) {
|
||||
sql_query += '`' + key + '`=' ;
|
||||
var value = newValues[key];
|
||||
|
||||
// null
|
||||
if (value == null) {
|
||||
sql_query += 'NULL, ';
|
||||
|
||||
// empty
|
||||
} else if ($.trim(value) == '') {
|
||||
sql_query += "'', ";
|
||||
|
||||
// other
|
||||
} else {
|
||||
// type explicitly identified
|
||||
if (sqlTypes[key] != null) {
|
||||
if (sqlTypes[key] == 'bit') {
|
||||
sql_query += "b'" + value + "', ";
|
||||
}
|
||||
// type not explicitly identified
|
||||
} else {
|
||||
if (!isNumeric(value)) {
|
||||
sql_query += "'" + value + "', ";
|
||||
} else {
|
||||
sql_query += value + ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sql_query = sql_query.substring(0, sql_query.length - 2);
|
||||
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, false);
|
||||
}
|
||||
}); //End $.post
|
||||
}//End database update
|
||||
$("#dataDisplay").dialog('close');
|
||||
};
|
||||
buttonOptions[PMA_messages['strCancel']] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
$("#dataDisplay").dialog({
|
||||
autoOpen: false,
|
||||
title: PMA_messages['strDataPointContent'],
|
||||
modal: true,
|
||||
buttons: buttonOptions,
|
||||
width: $('#dataDisplay').width() + 80,
|
||||
open: function () {
|
||||
$(this).find('input[type=checkbox]').css('margin', '0.5em');
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Attach Ajax event handlers for input fields
|
||||
* in the dialog. Used to submit the Ajax
|
||||
* request when the ENTER key is pressed.
|
||||
*/
|
||||
$("#dataDisplay").find(':input').live('keydown', function (e) {
|
||||
if (e.which === 13) { // 13 is the ENTER key
|
||||
e.preventDefault();
|
||||
if (typeof buttonOptions[PMA_messages['strSave']] === 'function') {
|
||||
buttonOptions[PMA_messages['strSave']].call();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* Generate plot using Highcharts
|
||||
*/
|
||||
|
||||
if (data != null) {
|
||||
$('#zoom_search_form')
|
||||
.slideToggle()
|
||||
.hide();
|
||||
$('#togglesearchformlink')
|
||||
.text(PMA_messages['strShowSearchCriteria']);
|
||||
$('#togglesearchformdiv').show();
|
||||
var selectedRow;
|
||||
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
|
||||
},
|
||||
credits: {
|
||||
enabled: false
|
||||
},
|
||||
exporting: { enabled: false },
|
||||
label: { text: $('#dataLabel').val() },
|
||||
plotOptions: {
|
||||
series: {
|
||||
allowPointSelect: true,
|
||||
cursor: 'pointer',
|
||||
showInLegend: false,
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
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 = {
|
||||
'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
|
||||
};
|
||||
$.post('tbl_zoom_select.php', post_params, function(data) {
|
||||
// Row is contained in data.row_info, now fill the displayResultForm with row values
|
||||
for (var key in data.row_info) {
|
||||
$field = $('#fieldID_' + fid);
|
||||
$field_null = $('#fields_null_id_' + fid);
|
||||
if (data.row_info[key] == null) {
|
||||
$field_null.prop('checked', true);
|
||||
$field.val('');
|
||||
} else {
|
||||
$field_null.prop('checked', false);
|
||||
if ($field.prop('multiple')) { // when the column is of type SET
|
||||
$field.val(data.row_info[key].split(','));
|
||||
} else {
|
||||
$field.val(data.row_info[key]);
|
||||
}
|
||||
}
|
||||
fid++;
|
||||
}
|
||||
selectedRow = new Object();
|
||||
selectedRow = data.row_info;
|
||||
});
|
||||
|
||||
$("#dataDisplay").dialog("open");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
formatter: function() {
|
||||
return this.point.name;
|
||||
}
|
||||
},
|
||||
title: { text: PMA_messages['strQueryResults'] },
|
||||
xAxis: {
|
||||
title: { text: $('#tableid_0').val() },
|
||||
events: {
|
||||
setExtremes: function(e) {
|
||||
this.resetZoom.show();
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
yAxis: {
|
||||
min: null,
|
||||
title: { text: $('#tableid_1').val() },
|
||||
endOnTick: false,
|
||||
startOnTick: false,
|
||||
events: {
|
||||
setExtremes: function(e) {
|
||||
this.resetZoom.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// If data label is not set, do not show tooltips
|
||||
if (dataLabel == '') {
|
||||
currentSettings.tooltip.enabled = false;
|
||||
}
|
||||
|
||||
$('#resizer').resizable({
|
||||
resize: function() {
|
||||
currentChart.setSize(
|
||||
this.offsetWidth - 3,
|
||||
this.offsetHeight - 20,
|
||||
false
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// 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';
|
||||
|
||||
// Formulate series data for plot
|
||||
series[0] = new Object();
|
||||
series[0].data = new Array();
|
||||
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());
|
||||
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++;
|
||||
});
|
||||
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());
|
||||
}};
|
||||
}
|
||||
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());
|
||||
series[0].data.push({
|
||||
name: value[dataLabel],
|
||||
x: tempX[0][it],
|
||||
y: yVal,
|
||||
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];
|
||||
}
|
||||
}
|
||||
};
|
||||
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];
|
||||
|
||||
} 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++;
|
||||
});
|
||||
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];
|
||||
|
||||
} 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;
|
||||
currentChart = PMA_createChart(currentSettings);
|
||||
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();
|
||||
}
|
||||
});
|
||||
589
js/tbl_zoom_plot_jqplot.js
Normal file
589
js/tbl_zoom_plot_jqplot.js
Normal file
@@ -0,0 +1,589 @@
|
||||
// todo: change the axis
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
** @fileoverview JavaScript functions used on tbl_select.php
|
||||
**
|
||||
** @requires jQuery
|
||||
** @requires js/functions.js
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
** Display Help/Info
|
||||
**/
|
||||
function displayHelp() {
|
||||
PMA_ajaxShowMessage(PMA_messages['strDisplayHelp'], 10000);
|
||||
}
|
||||
|
||||
/**
|
||||
** Extend the array object for max function
|
||||
** @param array
|
||||
**/
|
||||
Array.max = function (array) {
|
||||
return Math.max.apply( Math, array );
|
||||
};
|
||||
|
||||
/**
|
||||
** Extend the array object for min function
|
||||
** @param array
|
||||
**/
|
||||
Array.min = function (array) {
|
||||
return Math.min.apply( Math, array );
|
||||
};
|
||||
|
||||
/**
|
||||
** Checks if a string contains only numeric value
|
||||
** @param n: String (to be checked)
|
||||
**/
|
||||
function isNumeric(n) {
|
||||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||
}
|
||||
|
||||
/**
|
||||
** Checks if an object is empty
|
||||
** @param n: Object (to be checked)
|
||||
**/
|
||||
function isEmpty(obj) {
|
||||
var name;
|
||||
for (name in obj) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
** Converts a date/time into timestamp
|
||||
** @param val String Date
|
||||
** @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');
|
||||
}
|
||||
else if (type.toString().search(/date/i) != -1) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
/**
|
||||
** Converts a categorical array into numeric array
|
||||
** @param array categorical values array
|
||||
**/
|
||||
function getCord(arr) {
|
||||
var newCord = new Array();
|
||||
var original = $.extend(true, [], arr);
|
||||
var arr = jQuery.unique(arr).sort();
|
||||
$.each(original, function(index, value) {
|
||||
newCord.push(jQuery.inArray(value, arr));
|
||||
});
|
||||
return [newCord, arr, original];
|
||||
}
|
||||
|
||||
/**
|
||||
** Scrolls the view to the display section
|
||||
**/
|
||||
function scrollToChart() {
|
||||
var x = $('#dataDisplay').offset().top - 100; // 100 provides buffer in viewport
|
||||
$('html,body').animate({scrollTop: x}, 500);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer';
|
||||
var currentChart = null;
|
||||
var searchedDataKey = null;
|
||||
var xLabel = $('#tableid_0').val();
|
||||
var yLabel = $('#tableid_1').val();
|
||||
// will be updated via Ajax
|
||||
var xType = $('#types_0').val();
|
||||
var yType = $('#types_1').val();
|
||||
var dataLabel = $('#dataLabel').val();
|
||||
var lastX;
|
||||
var lastY;
|
||||
var zoomRatio = 1;
|
||||
|
||||
|
||||
// Get query result
|
||||
var searchedData = jQuery.parseJSON($('#querydata').html());
|
||||
|
||||
/**
|
||||
** Input form submit on field change
|
||||
**/
|
||||
|
||||
// first column choice corresponds to the X axis
|
||||
$('#tableid_0').change(function() {
|
||||
//AJAX request for field type, collation, operators, and value field
|
||||
$.post('tbl_zoom_select.php',{
|
||||
'ajax_request' : true,
|
||||
'change_tbl_info' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'field' : $('#tableid_0').val(),
|
||||
'it' : 0,
|
||||
'token' : window.parent.token
|
||||
},function(data) {
|
||||
$('#tableFieldsId tr:eq(1) td:eq(0)').html(data.field_type);
|
||||
$('#tableFieldsId tr:eq(1) td:eq(1)').html(data.field_collation);
|
||||
$('#tableFieldsId tr:eq(1) td:eq(2)').html(data.field_operators);
|
||||
$('#tableFieldsId tr:eq(1) td:eq(3)').html(data.field_value);
|
||||
xLabel = $('#tableid_0').val();
|
||||
$('#types_0').val(data.field_type);
|
||||
xType = data.field_type;
|
||||
$('#collations_0').val(data.field_collations);
|
||||
addDateTimePicker();
|
||||
});
|
||||
});
|
||||
|
||||
// second column choice corresponds to the Y axis
|
||||
$('#tableid_1').change(function() {
|
||||
//AJAX request for field type, collation, operators, and value field
|
||||
$.post('tbl_zoom_select.php',{
|
||||
'ajax_request' : true,
|
||||
'change_tbl_info' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'field' : $('#tableid_1').val(),
|
||||
'it' : 1,
|
||||
'token' : window.parent.token
|
||||
},function(data) {
|
||||
$('#tableFieldsId tr:eq(3) td:eq(0)').html(data.field_type);
|
||||
$('#tableFieldsId tr:eq(3) td:eq(1)').html(data.field_collation);
|
||||
$('#tableFieldsId tr:eq(3) td:eq(2)').html(data.field_operators);
|
||||
$('#tableFieldsId tr:eq(3) td:eq(3)').html(data.field_value);
|
||||
yLabel = $('#tableid_1').val();
|
||||
$('#types_1').val(data.field_type);
|
||||
yType = data.field_type;
|
||||
$('#collations_1').val(data.field_collations);
|
||||
addDateTimePicker();
|
||||
});
|
||||
});
|
||||
|
||||
$('#tableid_2').change(function() {
|
||||
//AJAX request for field type, collation, operators, and value field
|
||||
$.post('tbl_zoom_select.php',{
|
||||
'ajax_request' : true,
|
||||
'change_tbl_info' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'field' : $('#tableid_2').val(),
|
||||
'it' : 2,
|
||||
'token' : window.parent.token
|
||||
},function(data) {
|
||||
$('#tableFieldsId tr:eq(6) td:eq(0)').html(data.field_type);
|
||||
$('#tableFieldsId tr:eq(6) td:eq(1)').html(data.field_collation);
|
||||
$('#tableFieldsId tr:eq(6) td:eq(2)').html(data.field_operators);
|
||||
$('#tableFieldsId tr:eq(6) td:eq(3)').html(data.field_value);
|
||||
$('#types_2').val(data.field_type);
|
||||
$('#collations_2').val(data.field_collations);
|
||||
addDateTimePicker();
|
||||
});
|
||||
});
|
||||
|
||||
$('#tableid_3').change(function() {
|
||||
//AJAX request for field type, collation, operators, and value field
|
||||
$.post('tbl_zoom_select.php',{
|
||||
'ajax_request' : true,
|
||||
'change_tbl_info' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'field' : $('#tableid_3').val(),
|
||||
'it' : 3,
|
||||
'token' : window.parent.token
|
||||
},function(data) {
|
||||
$('#tableFieldsId tr:eq(8) td:eq(0)').html(data.field_type);
|
||||
$('#tableFieldsId tr:eq(8) td:eq(1)').html(data.field_collation);
|
||||
$('#tableFieldsId tr:eq(8) td:eq(2)').html(data.field_operators);
|
||||
$('#tableFieldsId tr:eq(8) td:eq(3)').html(data.field_value);
|
||||
$('#types_3').val(data.field_type);
|
||||
$('#collations_3').val(data.field_collations);
|
||||
addDateTimePicker();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
PMA_ajaxShowMessage(PMA_messages['strSameInputs']);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
** Prepare a div containing a link, otherwise it's incorrectly displayed
|
||||
** after a couple of clicks
|
||||
**/
|
||||
$('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
|
||||
.insertAfter('#zoom_search_form')
|
||||
// don't show it until we have results on-screen
|
||||
.hide();
|
||||
|
||||
$('#togglesearchformlink')
|
||||
.html(PMA_messages['strShowSearchCriteria'])
|
||||
.bind('click', function() {
|
||||
var $link = $(this);
|
||||
$('#zoom_search_form').slideToggle();
|
||||
if ($link.text() == PMA_messages['strHideSearchCriteria']) {
|
||||
$link.text(PMA_messages['strShowSearchCriteria']);
|
||||
} else {
|
||||
$link.text(PMA_messages['strHideSearchCriteria']);
|
||||
}
|
||||
// avoid default click action
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
** Set dialog properties for the data display form
|
||||
**/
|
||||
var buttonOptions = {};
|
||||
/*
|
||||
* Handle saving of a row in the editor
|
||||
*/
|
||||
buttonOptions[PMA_messages['strSave']] = function () {
|
||||
//Find changed values by comparing form values with selectedRow Object
|
||||
var newValues = new Object();//Stores the values changed from original
|
||||
var sqlTypes = new Object();
|
||||
var it = 0;
|
||||
var xChange = false;
|
||||
var yChange = false;
|
||||
for (key in selectedRow) {
|
||||
var oldVal = selectedRow[key];
|
||||
var newVal = ($('#edit_fields_null_id_' + it).attr('checked')) ? null : $('#edit_fieldID_' + it).val();
|
||||
if (newVal instanceof Array) { // when the column is of type SET
|
||||
newVal = $('#edit_fieldID_' + it).map(function(){
|
||||
return $(this).val();
|
||||
}).get().join(",");
|
||||
}
|
||||
if (oldVal != newVal) {
|
||||
selectedRow[key] = newVal;
|
||||
newValues[key] = newVal;
|
||||
if (key == xLabel) {
|
||||
xChange = true;
|
||||
searchedData[searchedDataKey][xLabel] = newVal;
|
||||
} else if (key == yLabel) {
|
||||
yChange = true;
|
||||
searchedData[searchedDataKey][yLabel] = newVal;
|
||||
}
|
||||
}
|
||||
var $input = $('#edit_fieldID_' + it);
|
||||
if ($input.hasClass('bit')) {
|
||||
sqlTypes[key] = 'bit';
|
||||
}
|
||||
it++;
|
||||
} //End data update
|
||||
|
||||
//Update the chart series and replot
|
||||
if (xChange || yChange) {
|
||||
//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[searchedDataKey] = selectedRow[xLabel];
|
||||
// [searchedDataKey][0] contains the x value
|
||||
if (xType == 'numeric') {
|
||||
series[0][searchedDataKey][0] = selectedRow[xLabel];
|
||||
} else if (xType == 'time') {
|
||||
series[0][searchedDataKey][0] =
|
||||
getTimeStamp(selectedRow[xLabel], $('#types_0').val());
|
||||
} else {
|
||||
// todo: text values
|
||||
}
|
||||
currentChart.series[0].data = series[0];
|
||||
// todo: axis changing
|
||||
currentChart.replot();
|
||||
|
||||
}
|
||||
if (yChange) {
|
||||
yCord[searchedDataKey] = selectedRow[yLabel];
|
||||
// [searchedDataKey][1] contains the y value
|
||||
if (yType == 'numeric') {
|
||||
series[0][searchedDataKey][1] = selectedRow[yLabel];
|
||||
} else if (yType == 'time') {
|
||||
series[0][searchedDataKey][1] =
|
||||
getTimeStamp(selectedRow[yLabel], $('#types_1').val());
|
||||
} else {
|
||||
// todo: text values
|
||||
}
|
||||
currentChart.series[0].data = series[0];
|
||||
// todo: axis changing
|
||||
currentChart.replot();
|
||||
}
|
||||
} //End plot update
|
||||
|
||||
//Generate SQL query for update
|
||||
if (!isEmpty(newValues)) {
|
||||
var sql_query = 'UPDATE `' + window.parent.table + '` SET ';
|
||||
for (key in newValues) {
|
||||
sql_query += '`' + key + '`=' ;
|
||||
var value = newValues[key];
|
||||
|
||||
// null
|
||||
if (value == null) {
|
||||
sql_query += 'NULL, ';
|
||||
|
||||
// empty
|
||||
} else if ($.trim(value) == '') {
|
||||
sql_query += "'', ";
|
||||
|
||||
// other
|
||||
} else {
|
||||
// type explicitly identified
|
||||
if (sqlTypes[key] != null) {
|
||||
if (sqlTypes[key] == 'bit') {
|
||||
sql_query += "b'" + value + "', ";
|
||||
}
|
||||
// type not explicitly identified
|
||||
} else {
|
||||
if (!isNumeric(value)) {
|
||||
sql_query += "'" + value + "', ";
|
||||
} else {
|
||||
sql_query += value + ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sql_query = sql_query.substring(0, sql_query.length - 2);
|
||||
sql_query += ' WHERE ' + PMA_urldecode(searchedData[searchedDataKey]['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, false);
|
||||
}
|
||||
}); //End $.post
|
||||
}//End database update
|
||||
$("#dataDisplay").dialog('close');
|
||||
};
|
||||
buttonOptions[PMA_messages['strCancel']] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
$("#dataDisplay").dialog({
|
||||
autoOpen: false,
|
||||
title: PMA_messages['strDataPointContent'],
|
||||
modal: true,
|
||||
buttons: buttonOptions,
|
||||
width: $('#dataDisplay').width() + 80,
|
||||
open: function () {
|
||||
$(this).find('input[type=checkbox]').css('margin', '0.5em');
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Attach Ajax event handlers for input fields
|
||||
* in the dialog. Used to submit the Ajax
|
||||
* request when the ENTER key is pressed.
|
||||
*/
|
||||
$("#dataDisplay").find(':input').live('keydown', function (e) {
|
||||
if (e.which === 13) { // 13 is the ENTER key
|
||||
e.preventDefault();
|
||||
if (typeof buttonOptions[PMA_messages['strSave']] === 'function') {
|
||||
buttonOptions[PMA_messages['strSave']].call();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* Generate plot using jqplot
|
||||
*/
|
||||
|
||||
if (searchedData != null) {
|
||||
$('#zoom_search_form')
|
||||
.slideToggle()
|
||||
.hide();
|
||||
$('#togglesearchformlink')
|
||||
.text(PMA_messages['strShowSearchCriteria']);
|
||||
$('#togglesearchformdiv').show();
|
||||
var selectedRow;
|
||||
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
|
||||
|
||||
var options = {
|
||||
series: [
|
||||
// for a scatter plot
|
||||
{ showLine: false }
|
||||
],
|
||||
axes: {
|
||||
xaxis: {
|
||||
label: $('#tableid_0').val(),
|
||||
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
|
||||
},
|
||||
yaxis: {
|
||||
label: $('#tableid_1').val(),
|
||||
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
|
||||
}
|
||||
},
|
||||
highlighter: {
|
||||
show: true,
|
||||
tooltipAxes: 'y',
|
||||
yvalues: 2,
|
||||
// hide the first y value
|
||||
formatString: '<span class="hide">%s</span>%s'
|
||||
},
|
||||
cursor: {
|
||||
show: true,
|
||||
zoom: true,
|
||||
showTooltip: false
|
||||
}
|
||||
}
|
||||
|
||||
// If data label is not set, do not show tooltips
|
||||
if (dataLabel == '') {
|
||||
options.highlighter.show = false;
|
||||
}
|
||||
|
||||
// Classify types as either numeric,time,text
|
||||
xType = getType(xType);
|
||||
yType = getType(yType);
|
||||
|
||||
// could have multiple series but we'll have just one
|
||||
series[0] = new Array();
|
||||
|
||||
if (xType == 'time') {
|
||||
originalXType = $('#types_0').val();
|
||||
if (originalXType == 'date') {
|
||||
format = '%Y-%m-%d';
|
||||
}
|
||||
// todo: does not seem to work
|
||||
//else if (originalXType == 'time') {
|
||||
// format = '%H:%M';
|
||||
//} else {
|
||||
// format = '%Y-%m-%d %H:%M';
|
||||
//}
|
||||
$.extend(options.axes.xaxis, {
|
||||
renderer:$.jqplot.DateAxisRenderer,
|
||||
tickOptions: {
|
||||
formatString: format
|
||||
}
|
||||
});
|
||||
}
|
||||
if (yType == 'time') {
|
||||
originalYType = $('#types_1').val();
|
||||
if (originalYType == 'date') {
|
||||
format = '%Y-%m-%d';
|
||||
}
|
||||
$.extend(options.axes.yaxis, {
|
||||
renderer:$.jqplot.DateAxisRenderer,
|
||||
tickOptions: {
|
||||
formatString: format
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$.each(searchedData, function(key, value) {
|
||||
if (xType == 'numeric') {
|
||||
var xVal = parseFloat(value[xLabel]);
|
||||
}
|
||||
if (xType == 'time') {
|
||||
var xVal = getTimeStamp(value[xLabel], originalXType);
|
||||
}
|
||||
if (yType == 'numeric') {
|
||||
var yVal = parseFloat(value[yLabel]);
|
||||
}
|
||||
if (yType == 'time') {
|
||||
var yVal = getTimeStamp(value[yLabel], originalYType);
|
||||
}
|
||||
series[0].push([
|
||||
xVal,
|
||||
yVal,
|
||||
// extra Y values
|
||||
value[dataLabel], // for highlighter
|
||||
// (may set an undefined value)
|
||||
value['where_clause'], // for click on point
|
||||
key // key from searchedData
|
||||
]);
|
||||
});
|
||||
|
||||
// under IE 8, the initial display is mangled; after a manual
|
||||
// resizing, it's ok
|
||||
// under IE 9, everything is fine
|
||||
currentChart = $.jqplot('querychart', series, options);
|
||||
currentChart.resetZoom();
|
||||
|
||||
$('button.button-reset').click(function(event) {
|
||||
event.preventDefault();
|
||||
currentChart.resetZoom();
|
||||
});
|
||||
|
||||
$('div#resizer').resizable();
|
||||
$('div#resizer').bind('resizestop', function(event, ui) {
|
||||
// make room so that the handle will still appear
|
||||
$('div#querychart').height($('div#resizer').height() * 0.96);
|
||||
$('div#querychart').width($('div#resizer').width() * 0.96);
|
||||
currentChart.replot( {resetAxes: true})
|
||||
});
|
||||
|
||||
$('div#querychart').bind('jqplotDataClick',
|
||||
function(event, seriesIndex, pointIndex, data) {
|
||||
searchedDataKey = data[4]; // key from searchedData (global)
|
||||
var field_id = 0;
|
||||
var post_params = {
|
||||
'ajax_request' : true,
|
||||
'get_data_row' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'where_clause' : data[3],
|
||||
'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) {
|
||||
$field = $('#edit_fieldID_' + field_id);
|
||||
$field_null = $('#edit_fields_null_id_' + field_id);
|
||||
if (data.row_info[key] == null) {
|
||||
$field_null.attr('checked', true);
|
||||
$field.val('');
|
||||
} else {
|
||||
$field_null.attr('checked', false);
|
||||
if ($field.attr('multiple')) { // when the column is of type SET
|
||||
$field.val(data.row_info[key].split(','));
|
||||
} else {
|
||||
$field.val(data.row_info[key]);
|
||||
}
|
||||
}
|
||||
field_id++;
|
||||
}
|
||||
selectedRow = new Object();
|
||||
selectedRow = data.row_info;
|
||||
});
|
||||
|
||||
$("#dataDisplay").dialog("open");
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -560,7 +560,7 @@ class PMA_Config
|
||||
unset($cfg['Servers']);
|
||||
|
||||
$this->default = $cfg;
|
||||
$this->settings = PMA_array_merge_recursive($this->settings, $cfg);
|
||||
$this->settings = PMA_arrayMergeRecursive($this->settings, $cfg);
|
||||
|
||||
$this->error_config_default_file = false;
|
||||
|
||||
@@ -630,7 +630,7 @@ class PMA_Config
|
||||
);
|
||||
}
|
||||
|
||||
$this->settings = PMA_array_merge_recursive($this->settings, $cfg);
|
||||
$this->settings = PMA_arrayMergeRecursive($this->settings, $cfg);
|
||||
$this->checkPmaAbsoluteUri();
|
||||
$this->checkFontsize();
|
||||
|
||||
@@ -716,8 +716,8 @@ class PMA_Config
|
||||
// backup some settings
|
||||
$org_fontsize = $this->settings['fontsize'];
|
||||
// load config array
|
||||
$this->settings = PMA_array_merge_recursive($this->settings, $config_data);
|
||||
$GLOBALS['cfg'] = PMA_array_merge_recursive($GLOBALS['cfg'], $config_data);
|
||||
$this->settings = PMA_arrayMergeRecursive($this->settings, $config_data);
|
||||
$GLOBALS['cfg'] = PMA_arrayMergeRecursive($GLOBALS['cfg'], $config_data);
|
||||
if (defined('PMA_MINIMUM_COMMON')) {
|
||||
return;
|
||||
}
|
||||
@@ -829,19 +829,19 @@ class PMA_Config
|
||||
if ($prefs_type) {
|
||||
include_once './libraries/user_preferences.lib.php';
|
||||
if ($default_value === null) {
|
||||
$default_value = PMA_array_read($cfg_path, $this->default);
|
||||
$default_value = PMA_arrayRead($cfg_path, $this->default);
|
||||
}
|
||||
PMA_persist_option($cfg_path, $new_cfg_value, $default_value);
|
||||
}
|
||||
if ($prefs_type != 'db' && $cookie_name) {
|
||||
// fall back to cookies
|
||||
if ($default_value === null) {
|
||||
$default_value = PMA_array_read($cfg_path, $this->settings);
|
||||
$default_value = PMA_arrayRead($cfg_path, $this->settings);
|
||||
}
|
||||
$this->setCookie($cookie_name, $new_cfg_value, $default_value);
|
||||
}
|
||||
PMA_array_write($cfg_path, $GLOBALS['cfg'], $new_cfg_value);
|
||||
PMA_array_write($cfg_path, $this->settings, $new_cfg_value);
|
||||
PMA_arrayWrite($cfg_path, $GLOBALS['cfg'], $new_cfg_value);
|
||||
PMA_arrayWrite($cfg_path, $this->settings, $new_cfg_value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1268,10 +1268,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))
|
||||
min(PMA_getRealSize($filesize), PMA_getRealSize($postsize))
|
||||
);
|
||||
} else {
|
||||
$this->set('max_upload_size', PMA_get_real_size($filesize));
|
||||
$this->set('max_upload_size', PMA_getRealSize($filesize));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,9 @@ class PMA_Error extends PMA_Message
|
||||
$retval = '';
|
||||
|
||||
foreach ($this->getBacktrace() as $step) {
|
||||
$retval .= PMA_Error::relPath($step['file']) . '#' . $step['line'] . ': ';
|
||||
if (isset($step['file']) && isset($step['line'])) {
|
||||
$retval .= PMA_Error::relPath($step['file']) . '#' . $step['line'] . ': ';
|
||||
}
|
||||
if (isset($step['class'])) {
|
||||
$retval .= $step['class'] . $step['type'];
|
||||
}
|
||||
@@ -317,6 +319,7 @@ class PMA_Error extends PMA_Message
|
||||
*/
|
||||
public function getDisplay()
|
||||
{
|
||||
$this->isDisplayed(true);
|
||||
$retval = '<div class="' . $this->getLevel() . '">';
|
||||
if (! $this->isUserError()) {
|
||||
$retval .= '<strong>' . $this->getType() . '</strong>';
|
||||
|
||||
@@ -64,8 +64,8 @@ class PMA_Error_Handler
|
||||
if (count($_SESSION['errors']) >= 20) {
|
||||
$error = new PMA_Error(0, __('Too many error messages, some are not displayed.'), __FILE__, __LINE__);
|
||||
$_SESSION['errors'][$error->getHash()] = $error;
|
||||
}
|
||||
if (($error instanceof PMA_Error) && ! $error->isDisplayed()) {
|
||||
break;
|
||||
} else if (($error instanceof PMA_Error) && ! $error->isDisplayed()) {
|
||||
$_SESSION['errors'][$key] = $error;
|
||||
}
|
||||
}
|
||||
@@ -205,17 +205,29 @@ class PMA_Error_Handler
|
||||
}
|
||||
|
||||
/**
|
||||
* display user errors not displayed
|
||||
* Displays user errors not displayed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dispUserErrors()
|
||||
{
|
||||
echo $this->getDispUserErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders user errors not displayed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDispUserErrors()
|
||||
{
|
||||
$retval = '';
|
||||
foreach ($this->getErrors() as $error) {
|
||||
if ($error->isUserError() && ! $error->isDisplayed()) {
|
||||
$error->display();
|
||||
$retval .= $error->getDisplay();
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,6 +239,7 @@ class PMA_Error_Handler
|
||||
*/
|
||||
protected function dispPageStart($error = null)
|
||||
{
|
||||
PMA_Response::getInstance()->disable();
|
||||
echo '<html><head><title>';
|
||||
if ($error) {
|
||||
echo $error->getTitle();
|
||||
@@ -259,25 +272,39 @@ class PMA_Error_Handler
|
||||
}
|
||||
|
||||
/**
|
||||
* display errors not displayed
|
||||
* renders errors not displayed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getDispErrors()
|
||||
{
|
||||
$retval = '';
|
||||
if ($GLOBALS['cfg']['Error_Handler']['display']) {
|
||||
foreach ($this->getErrors() as $error) {
|
||||
if ($error instanceof PMA_Error) {
|
||||
if (! $error->isDisplayed()) {
|
||||
$retval .= $error->getDisplay();
|
||||
}
|
||||
} else {
|
||||
ob_start();
|
||||
var_dump($error);
|
||||
$retval .= ob_end_clean();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$retval .= $this->getDispUserErrors();
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* displays errors not displayed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dispErrors()
|
||||
{
|
||||
if ($GLOBALS['cfg']['Error_Handler']['display']) {
|
||||
foreach ($this->getErrors() as $error) {
|
||||
if ($error instanceof PMA_Error) {
|
||||
if (! $error->isDisplayed()) {
|
||||
$error->display();
|
||||
}
|
||||
} else {
|
||||
var_dump($error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->dispUserErrors();
|
||||
}
|
||||
echo $this->getDispErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +324,7 @@ class PMA_Error_Handler
|
||||
}
|
||||
//$this->errors = array_merge($_SESSION['errors'], $this->errors);
|
||||
|
||||
// delet stored errors
|
||||
// delete stored errors
|
||||
$_SESSION['errors'] = array();
|
||||
unset($_SESSION['errors']);
|
||||
}
|
||||
|
||||
334
libraries/Footer.class.php
Normal file
334
libraries/Footer.class.php
Normal file
@@ -0,0 +1,334 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Used to render the footer of PMA's pages
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'libraries/Scripts.class.php';
|
||||
|
||||
/**
|
||||
* Class used to output the footer
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class PMA_Footer
|
||||
{
|
||||
/**
|
||||
* PMA_Scripts instance
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_scripts;
|
||||
/**
|
||||
* Whether we are servicing an ajax request.
|
||||
* We can't simply use $GLOBALS['is_ajax_request']
|
||||
* here since it may have not been initialised yet.
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isAjax;
|
||||
/**
|
||||
* Whether to only close the BODY and HTML tags
|
||||
* or also include scripts, errors and links
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isMinimal;
|
||||
/**
|
||||
* Whether to display anything
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isEnabled;
|
||||
|
||||
/**
|
||||
* Creates a new class instance
|
||||
*
|
||||
* @return new PMA_Footer object
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_isEnabled = true;
|
||||
$this->_scripts = new PMA_Scripts();
|
||||
$this->_isMinimal = false;
|
||||
$this->_addDefaultScripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads common scripts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _addDefaultScripts()
|
||||
{
|
||||
if (empty($GLOBALS['error_message'])) {
|
||||
$this->_scripts->addCode("
|
||||
$(function() {
|
||||
// updates current settings
|
||||
if (window.parent.setAll) {
|
||||
window.parent.setAll(
|
||||
'" . PMA_escapeJsString($GLOBALS['lang']) . "',
|
||||
'" . PMA_escapeJsString($GLOBALS['collation_connection']) . "',
|
||||
'" . PMA_escapeJsString($GLOBALS['server']) . "',
|
||||
'" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) . "',
|
||||
'" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) . "',
|
||||
'" . PMA_escapeJsString($_SESSION[' PMA_token ']) . "'
|
||||
);
|
||||
}
|
||||
});
|
||||
");
|
||||
if (! empty($GLOBALS['reload'])) {
|
||||
$this->_scripts->addCode("
|
||||
// refresh navigation frame content
|
||||
if (window.parent.refreshNavigation) {
|
||||
window.parent.refreshNavigation();
|
||||
}
|
||||
");
|
||||
} else if (isset($_GET['reload_left_frame'])
|
||||
&& $_GET['reload_left_frame'] == '1'
|
||||
) {
|
||||
// reload left frame (used by user preferences)
|
||||
$this->_scripts->addCode("
|
||||
if (window.parent && window.parent.frame_navigation) {
|
||||
window.parent.frame_navigation.location.reload();
|
||||
}
|
||||
");
|
||||
}
|
||||
|
||||
// set current db, table and sql query in the querywindow
|
||||
$query = '';
|
||||
if (strlen($GLOBALS['sql_query']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
|
||||
$query = PMA_escapeJsString($GLOBALS['sql_query']);
|
||||
}
|
||||
$this->_scripts->addCode("
|
||||
if (window.parent.reload_querywindow) {
|
||||
window.parent.reload_querywindow(
|
||||
'" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) . "',
|
||||
'" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) . "',
|
||||
'" . $query . "'
|
||||
);
|
||||
}
|
||||
");
|
||||
|
||||
if (! empty($GLOBALS['focus_querywindow'])) {
|
||||
// set focus to the querywindow
|
||||
$this->_scripts->addCode("
|
||||
if (parent.querywindow && !parent.querywindow.closed
|
||||
&& parent.querywindow.location
|
||||
) {
|
||||
self.focus();
|
||||
}
|
||||
");
|
||||
}
|
||||
$this->_scripts->addCode("
|
||||
if (window.parent.frame_content) {
|
||||
// reset content frame name, as querywindow needs
|
||||
// to set a unique name before submitting form data,
|
||||
// and navigation frame needs the original name
|
||||
if (typeof(window.parent.frame_content.name) != 'undefined'
|
||||
&& window.parent.frame_content.name != 'frame_content') {
|
||||
window.parent.frame_content.name = 'frame_content';
|
||||
}
|
||||
if (typeof(window.parent.frame_content.id) != 'undefined'
|
||||
&& window.parent.frame_content.id != 'frame_content') {
|
||||
window.parent.frame_content.id = 'frame_content';
|
||||
}
|
||||
//window.parent.frame_content.setAttribute('name', 'frame_content');
|
||||
//window.parent.frame_content.setAttribute('id', 'frame_content');
|
||||
}
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the debug messages
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getDebugMessage()
|
||||
{
|
||||
$retval = '';
|
||||
if (! empty($_SESSION['debug'])) {
|
||||
$sum_time = 0;
|
||||
$sum_exec = 0;
|
||||
foreach ($_SESSION['debug']['queries'] as $query) {
|
||||
$sum_time += $query['count'] * $query['time'];
|
||||
$sum_exec += $query['count'];
|
||||
}
|
||||
|
||||
$retval .= '<div>';
|
||||
$retval .= count($_SESSION['debug']['queries']) . ' queries executed ';
|
||||
$retval .= $sum_exec . ' times in ' . $sum_time . ' seconds';
|
||||
$retval .= '<pre>';
|
||||
|
||||
ob_start();
|
||||
print_r($_SESSION['debug']);
|
||||
$retval .= ob_end_clean();
|
||||
|
||||
$retval .= '</pre>';
|
||||
$retval .= '</div>';
|
||||
$_SESSION['debug'] = array();
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the link to open a new page
|
||||
*
|
||||
* @param string $url_params URL paramater string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getSelfLink($url_params)
|
||||
{
|
||||
$retval = '';
|
||||
$retval .= '<div id="selflink" class="print_ignore">';
|
||||
$retval .= '<a href="index.php' . PMA_generate_common_url($url_params) . '"'
|
||||
. ' title="' . __('Open new phpMyAdmin window') . '" target="_blank">';
|
||||
if ($GLOBALS['cfg']['NavigationBarIconic']) {
|
||||
$retval .= PMA_getImage(
|
||||
'window-new.png',
|
||||
__('Open new phpMyAdmin window')
|
||||
);
|
||||
} else {
|
||||
$retval .= __('Open new phpMyAdmin window');
|
||||
}
|
||||
$retval .= '</a>';
|
||||
$retval .= '</div>';
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the link to open a new page
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getErrorMessages()
|
||||
{
|
||||
$retval = '';
|
||||
if ($GLOBALS['error_handler']->hasDisplayErrors()) {
|
||||
$retval .= '<div class="clearfloat">';
|
||||
$retval .= $GLOBALS['error_handler']->getDispErrors();
|
||||
$retval .= '</div>';
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves query in history
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _setHistory()
|
||||
{
|
||||
if (! PMA_isValid($_REQUEST['no_history'])
|
||||
&& empty($GLOBALS['error_message'])
|
||||
&& ! empty($GLOBALS['sql_query'])
|
||||
) {
|
||||
PMA_setHistory(
|
||||
PMA_ifSetOr($GLOBALS['db'], ''),
|
||||
PMA_ifSetOr($GLOBALS['table'], ''),
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['sql_query']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the rendering of the footer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disable()
|
||||
{
|
||||
$this->_isEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ajax flag to indicate whether
|
||||
* we are sevicing an ajax request
|
||||
*
|
||||
* @param bool $isAjax Whether we are sevicing an ajax request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAjax($isAjax)
|
||||
{
|
||||
$this->_isAjax = ($isAjax == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn on minimal display mode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMinimal()
|
||||
{
|
||||
$this->_isMinimal = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PMA_Scripts object
|
||||
*
|
||||
* @return PMA_Scripts object
|
||||
*/
|
||||
public function getScripts()
|
||||
{
|
||||
return $this->_scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the footer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplay()
|
||||
{
|
||||
$retval = '';
|
||||
$this->_setHistory();
|
||||
if ($this->_isEnabled) {
|
||||
if (! $this->_isAjax && ! $this->_isMinimal) {
|
||||
// Link to itself to replicate windows including frameset
|
||||
if (! isset($GLOBALS['checked_special'])) {
|
||||
$GLOBALS['checked_special'] = false;
|
||||
}
|
||||
if (PMA_getenv('SCRIPT_NAME')
|
||||
&& empty($_POST)
|
||||
&& ! $GLOBALS['checked_special']
|
||||
&& ! $this->_isAjax
|
||||
) {
|
||||
$url_params['target'] = basename(PMA_getenv('SCRIPT_NAME'));
|
||||
$url = PMA_generate_common_url($url_params, 'text', '');
|
||||
$this->_scripts->addCode("
|
||||
// Store current location in hash part
|
||||
// of URL to allow direct bookmarking
|
||||
setURLHash('$url');
|
||||
");
|
||||
$retval .= $this->_getSelfLink($url_params);
|
||||
}
|
||||
$retval .= $this->_getDebugMessage();
|
||||
$retval .= $this->_getErrorMessages();
|
||||
$retval .= $this->_scripts->getDisplay();
|
||||
// Include possible custom footers
|
||||
if (file_exists(CUSTOM_FOOTER_FILE)) {
|
||||
ob_start();
|
||||
include CUSTOM_FOOTER_FILE;
|
||||
$retval .= ob_end_clean();
|
||||
}
|
||||
} else if (! $this->_isAjax) {
|
||||
$retval .= "</body></html>";
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
528
libraries/Header.class.php
Normal file
528
libraries/Header.class.php
Normal file
@@ -0,0 +1,528 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Used to render the header of PMA's pages
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'libraries/Scripts.class.php';
|
||||
require_once 'libraries/RecentTable.class.php';
|
||||
require_once 'libraries/Menu.class.php';
|
||||
|
||||
/**
|
||||
* Class used to output the HTTP and HTML headers
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class PMA_Header
|
||||
{
|
||||
/**
|
||||
* PMA_Scripts instance
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_scripts;
|
||||
/**
|
||||
* PMA_Menu instance
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_menu;
|
||||
/**
|
||||
* Whether to offer the option of importing user settings
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_userprefsOfferImport;
|
||||
/**
|
||||
* The page title
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_title;
|
||||
/**
|
||||
* The value for the id attribute for the body tag
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_bodyId;
|
||||
/**
|
||||
* Whether to show the top menu
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_menuEnabled;
|
||||
/**
|
||||
* Whether to show the warnings
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_warningsEnabled;
|
||||
/**
|
||||
* Whether the page is in 'print view' mode
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isPrintView;
|
||||
/**
|
||||
* Whether we are servicing an ajax request.
|
||||
* We can't simply use $GLOBALS['is_ajax_request']
|
||||
* here since it may have not been initialised yet.
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isAjax;
|
||||
/**
|
||||
* Whether to display anything
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isEnabled;
|
||||
/**
|
||||
* Whether the HTTP headers (and possibly some HTML)
|
||||
* have already been sent to the browser
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_headerIsSent;
|
||||
|
||||
/**
|
||||
* Creates a new class instance
|
||||
*
|
||||
* @return new PMA_Header object
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_isEnabled = true;
|
||||
$this->_isAjax = false;
|
||||
$this->_bodyId = '';
|
||||
$this->_title = '';
|
||||
$this->_menu = new PMA_Menu(
|
||||
$GLOBALS['server'],
|
||||
$GLOBALS['db'],
|
||||
$GLOBALS['table']
|
||||
);
|
||||
$this->_menuEnabled = true;
|
||||
$this->_warningsEnabled = true;
|
||||
$this->_isPrintView = false;
|
||||
$this->_scripts = new PMA_Scripts();
|
||||
$this->_addDefaultScripts();
|
||||
$this->_headerIsSent = false;
|
||||
// if database storage for user preferences is transient,
|
||||
// offer to load exported settings from localStorage
|
||||
// (detection will be done in JavaScript)
|
||||
$this->_userprefsOfferImport = false;
|
||||
if ($GLOBALS['PMA_Config']->get('user_preferences') == 'session'
|
||||
&& ! isset($_SESSION['userprefs_autoload'])
|
||||
) {
|
||||
$this->_userprefsOfferImport = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads common scripts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _addDefaultScripts()
|
||||
{
|
||||
$this->_scripts->addFile('jquery/jquery-1.6.2.js');
|
||||
$this->_scripts->addFile('jquery/jquery-ui-1.8.16.custom.js');
|
||||
$this->_scripts->addFile('jquery/jquery.sprintf.js');
|
||||
$this->_scripts->addFile('update-location.js');
|
||||
|
||||
$this->_scripts->addFile('jquery/jquery.qtip-1.0.0-rc3.js');
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$this->_scripts->addFile('codemirror/lib/codemirror.js');
|
||||
$this->_scripts->addFile('codemirror/mode/mysql/mysql.js');
|
||||
}
|
||||
// Cross-framing protection
|
||||
if ($GLOBALS['cfg']['AllowThirdPartyFraming'] === false) {
|
||||
$this->_scripts->addFile('cross_framing_protection.js');
|
||||
}
|
||||
// Localised strings
|
||||
$params = array('lang' => $GLOBALS['lang']);
|
||||
if (isset($GLOBALS['db'])) {
|
||||
$params['db'] = $GLOBALS['db'];
|
||||
}
|
||||
$this->_scripts->addFile('messages.php' . PMA_generate_common_url($params));
|
||||
// Append the theme id to this url to invalidate
|
||||
// the cache on a theme change
|
||||
$this->_scripts->addFile(
|
||||
'get_image.js.php?theme='
|
||||
. urlencode($_SESSION['PMA_Theme']->getId())
|
||||
);
|
||||
$this->_scripts->addFile('functions.js');
|
||||
$this->_scripts->addCode(PMA_getReloadNavigationScript(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the rendering of the header
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disable()
|
||||
{
|
||||
$this->_isEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ajax flag to indicate whether
|
||||
* we are sevicing an ajax request
|
||||
*
|
||||
* @param bool $isAjax Whether we are sevicing an ajax request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAjax($isAjax)
|
||||
{
|
||||
$this->_isAjax = ($isAjax == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PMA_Scripts object
|
||||
*
|
||||
* @return PMA_Scripts object
|
||||
*/
|
||||
public function getScripts()
|
||||
{
|
||||
return $this->_scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the ID attribute in the BODY tag
|
||||
*
|
||||
* @param string $id Value for the ID attribute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setBodyId($id)
|
||||
{
|
||||
$this->_bodyId = htmlspecialchars($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the title of the page
|
||||
*
|
||||
* @param string $title New title
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->_title = htmlspecialchars($title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the display of the top menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disableMenu()
|
||||
{
|
||||
$this->_menuEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the display of the top menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disableWarnings()
|
||||
{
|
||||
$this->_warningsEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on 'print view' mode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enablePrintView()
|
||||
{
|
||||
$this->disableMenu();
|
||||
$this->setTitle(__('Print view') . ' - phpMyAdmin ' . PMA_VERSION);
|
||||
$this->_isPrintView = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the header
|
||||
*
|
||||
* @return string The header
|
||||
*/
|
||||
public function getDisplay()
|
||||
{
|
||||
$retval = '';
|
||||
if (! $this->_headerIsSent) {
|
||||
if (! $this->_isAjax && $this->_isEnabled) {
|
||||
$this->sendHttpHeaders();
|
||||
$retval .= $this->_getHtmlStart();
|
||||
$retval .= $this->_getMetaTags();
|
||||
$retval .= $this->_getLinkTags();
|
||||
$retval .= $this->_getTitleTag();
|
||||
$title = PMA_sanitize(
|
||||
PMA_escapeJsString($this->_getPageTitle()),
|
||||
false,
|
||||
true
|
||||
);
|
||||
$this->_scripts->addCode(
|
||||
"if (typeof(parent.document) != 'undefined'"
|
||||
. " && typeof(parent.document) != 'unknown'"
|
||||
. " && typeof(parent.document.title) == 'string')"
|
||||
. "{"
|
||||
. "parent.document.title = '$title'"
|
||||
. "}"
|
||||
);
|
||||
if ($this->_userprefsOfferImport) {
|
||||
$this->_scripts->addFile('config.js');
|
||||
}
|
||||
$retval .= $this->_scripts->getDisplay();
|
||||
$retval .= $this->_getBodyStart();
|
||||
// Include possible custom headers
|
||||
if (file_exists(CUSTOM_HEADER_FILE)) {
|
||||
ob_start();
|
||||
include CUSTOM_HEADER_FILE;
|
||||
$retval .= ob_end_clean();
|
||||
}
|
||||
// offer to load user preferences from localStorage
|
||||
if ($this->_userprefsOfferImport) {
|
||||
include_once './libraries/user_preferences.lib.php';
|
||||
$retval .= PMA_userprefsAutoloadGetHeader();
|
||||
}
|
||||
// pass configuration for hint tooltip display
|
||||
// (to be used by PMA_createqTip in js/functions.js)
|
||||
if (! $GLOBALS['cfg']['ShowHint']) {
|
||||
$retval .= '<span id="no_hint" class="hide"></span>';
|
||||
}
|
||||
$retval .= $this->_getWarnings();
|
||||
if ($this->_menuEnabled && $GLOBALS['server'] > 0) {
|
||||
$retval .= $this->_menu->getDisplay();
|
||||
}
|
||||
$retval .= $this->_addRecentTable(
|
||||
$GLOBALS['db'],
|
||||
$GLOBALS['table']
|
||||
);
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends out the HTTP headers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendHttpHeaders()
|
||||
{
|
||||
/**
|
||||
* Sends http headers
|
||||
*/
|
||||
$GLOBALS['now'] = gmdate('D, d M Y H:i:s') . ' GMT';
|
||||
/* Prevent against ClickJacking by allowing frames only from same origin */
|
||||
if (! $GLOBALS['cfg']['AllowThirdPartyFraming']) {
|
||||
header(
|
||||
'X-Frame-Options: SAMEORIGIN'
|
||||
);
|
||||
header(
|
||||
"X-Content-Security-Policy: allow 'self'; "
|
||||
. "options inline-script eval-script; "
|
||||
. "frame-ancestors 'self'; img-src 'self' data:; "
|
||||
. "script-src 'self' http://www.phpmyadmin.net"
|
||||
);
|
||||
header(
|
||||
"X-WebKit-CSP: allow 'self' http://www.phpmyadmin.net; "
|
||||
. "options inline-script eval-script"
|
||||
);
|
||||
}
|
||||
PMA_noCacheHeader();
|
||||
if (! defined('IS_TRANSFORMATION_WRAPPER')) {
|
||||
// Define the charset to be used
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
$this->_headerIsSent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DOCTYPE and the start HTML tag
|
||||
*
|
||||
* @return string DOCTYPE and HTML tags
|
||||
*/
|
||||
private function _getHtmlStart()
|
||||
{
|
||||
$lang = $GLOBALS['available_languages'][$GLOBALS['lang']][1];
|
||||
$dir = $GLOBALS['text_dir'];
|
||||
|
||||
$retval = "<!DOCTYPE HTML>";
|
||||
$retval .= "<html lang='$lang' dir='$dir'>";
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the META tags
|
||||
*
|
||||
* @return string the META tags
|
||||
*/
|
||||
private function _getMetaTags()
|
||||
{
|
||||
$retval = '<meta charset="utf-8" />';
|
||||
$retval .= '<meta name="robots" content="noindex,nofollow" />';
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the LINK tags for the favicon and the stylesheets
|
||||
*
|
||||
* @return string the LINK tags
|
||||
*/
|
||||
private function _getLinkTags()
|
||||
{
|
||||
$retval = '<link rel="icon" href="favicon.ico" '
|
||||
. 'type="image/x-icon" />'
|
||||
. '<link rel="shortcut icon" href="favicon.ico" '
|
||||
. 'type="image/x-icon" />';
|
||||
// stylesheets
|
||||
$basedir = defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : '';
|
||||
$common_url = PMA_generate_common_url(array('server' => $GLOBALS['server']));
|
||||
$theme_id = $GLOBALS['PMA_Config']->getThemeUniqueValue();
|
||||
$theme_path = $GLOBALS['pmaThemePath'];
|
||||
|
||||
if ($this->_isPrintView) {
|
||||
$retval .= '<link rel="stylesheet" type="text/css" href="'
|
||||
. $basedir . 'print.css" media="print" />';
|
||||
} else {
|
||||
$retval .= '<link rel="stylesheet" type="text/css" href="'
|
||||
. $basedir . 'phpmyadmin.css.php'
|
||||
. $common_url . '&nocache='
|
||||
. $theme_id . '" />';
|
||||
$retval .= '<link rel="stylesheet" type="text/css" href="'
|
||||
. $theme_path . '/jquery/jquery-ui-1.8.16.custom.css" />';
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TITLE tag
|
||||
*
|
||||
* @return string the TITLE tag
|
||||
*/
|
||||
private function _getTitleTag()
|
||||
{
|
||||
$retval = "<title>";
|
||||
$retval .= $this->_getPageTitle();
|
||||
$retval .= "</title>";
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the page is missing the title, this function
|
||||
* will set it to something reasonable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getPageTitle()
|
||||
{
|
||||
if (empty($this->_title)) {
|
||||
if ($GLOBALS['server'] > 0) {
|
||||
if (! empty($GLOBALS['table'])) {
|
||||
$temp_title = $GLOBALS['cfg']['TitleTable'];
|
||||
} else if (! empty($GLOBALS['db'])) {
|
||||
$temp_title = $GLOBALS['cfg']['TitleDatabase'];
|
||||
} elseif (! empty($GLOBALS['cfg']['Server']['host'])) {
|
||||
$temp_title = $GLOBALS['cfg']['TitleServer'];
|
||||
} else {
|
||||
$temp_title = $GLOBALS['cfg']['TitleDefault'];
|
||||
}
|
||||
$this->_title = htmlspecialchars(
|
||||
PMA_expandUserString($temp_title)
|
||||
);
|
||||
} else {
|
||||
$this->_title = 'phpMyAdmin';
|
||||
}
|
||||
}
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the close tag to the HEAD
|
||||
* and the start tag for the BODY
|
||||
*
|
||||
* @return string HEAD and BODY tags
|
||||
*/
|
||||
private function _getBodyStart()
|
||||
{
|
||||
$retval = "</head><body";
|
||||
if (! empty($this->_bodyId)) {
|
||||
$retval .= " id='" . $this->_bodyId . "'";
|
||||
}
|
||||
$retval .= ">";
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns some warnings to be displayed at the top of the page
|
||||
*
|
||||
* @return string The warnings
|
||||
*/
|
||||
private function _getWarnings()
|
||||
{
|
||||
$retval = '';
|
||||
if ($this->_warningsEnabled) {
|
||||
// message of "Cookies required" displayed for auth_type http or config
|
||||
// note: here, the decoration won't work because without cookies,
|
||||
// our standard CSS is not operational
|
||||
if (empty($_COOKIE)) {
|
||||
$retval .= PMA_Message::notice(
|
||||
__('Cookies must be enabled past this point.')
|
||||
)->getDisplay();
|
||||
}
|
||||
$retval .= "<noscript>";
|
||||
$retval .= PMA_message::error(
|
||||
__("Javascript must be enabled past this point")
|
||||
)->getDisplay();
|
||||
$retval .= "</noscript>";
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add recently used table and reload the navigation.
|
||||
*
|
||||
* @param string $db Database name where the table is located.
|
||||
* @param string $table The table name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _addRecentTable($db, $table)
|
||||
{
|
||||
$retval = '';
|
||||
if (strlen($table) && $GLOBALS['cfg']['LeftRecentTable'] > 0) {
|
||||
$tmp_result = PMA_RecentTable::getInstance()->add($db, $table);
|
||||
if ($tmp_result === true) {
|
||||
$retval = '<span class="hide" id="update_recent_tables"></span>';
|
||||
} else {
|
||||
$error = $tmp_result;
|
||||
$retval = $error->getDisplay();
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -114,6 +114,7 @@ abstract class PMA_List extends ArrayObject
|
||||
/**
|
||||
* builds up the list
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function build();
|
||||
}
|
||||
|
||||
@@ -34,31 +34,31 @@ class PMA_List_Database extends PMA_List
|
||||
* @var mixed database link resource|object to be used
|
||||
* @access protected
|
||||
*/
|
||||
protected $_db_link = null;
|
||||
protected $db_link = null;
|
||||
|
||||
/**
|
||||
* @var mixed user database link resource|object
|
||||
* @access protected
|
||||
*/
|
||||
protected $_db_link_user = null;
|
||||
protected $db_link_user = null;
|
||||
|
||||
/**
|
||||
* @var mixed controluser database link resource|object
|
||||
* @access protected
|
||||
*/
|
||||
protected $_db_link_control = null;
|
||||
protected $db_link_control = null;
|
||||
|
||||
/**
|
||||
* @var boolean whether SHOW DATABASES is disabled or not
|
||||
* @access protected
|
||||
*/
|
||||
protected $_show_databases_disabled = false;
|
||||
protected $show_databases_disabled = false;
|
||||
|
||||
/**
|
||||
* @var string command to retrieve databases from server
|
||||
* @access protected
|
||||
*/
|
||||
protected $_command = null;
|
||||
protected $command = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -70,9 +70,9 @@ class PMA_List_Database extends PMA_List
|
||||
*/
|
||||
public function __construct($db_link_user = null, $db_link_control = null)
|
||||
{
|
||||
$this->_db_link = $db_link_user;
|
||||
$this->_db_link_user = $db_link_user;
|
||||
$this->_db_link_control = $db_link_control;
|
||||
$this->db_link = $db_link_user;
|
||||
$this->db_link_user = $db_link_user;
|
||||
$this->db_link_control = $db_link_control;
|
||||
|
||||
parent::__construct();
|
||||
$this->build();
|
||||
@@ -83,7 +83,7 @@ class PMA_List_Database extends PMA_List
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _checkHideDatabase()
|
||||
protected function checkHideDatabase()
|
||||
{
|
||||
if (empty($GLOBALS['cfg']['Server']['hide_db'])) {
|
||||
return;
|
||||
@@ -104,33 +104,33 @@ class PMA_List_Database extends PMA_List
|
||||
* @return array
|
||||
* @todo we could also search mysql tables if all fail?
|
||||
*/
|
||||
protected function _retrieve($like_db_name = null)
|
||||
protected function retrieve($like_db_name = null)
|
||||
{
|
||||
if ($this->_show_databases_disabled) {
|
||||
if ($this->show_databases_disabled) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (null !== $like_db_name) {
|
||||
$command = "SHOW DATABASES LIKE '" . $like_db_name . "'";
|
||||
} elseif (null === $this->_command) {
|
||||
} elseif (null === $this->command) {
|
||||
$command = str_replace(
|
||||
'#user#', $GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['cfg']['Server']['ShowDatabasesCommand']
|
||||
);
|
||||
$this->_command = $command;
|
||||
$this->command = $command;
|
||||
} else {
|
||||
$command = $this->_command;
|
||||
$command = $this->command;
|
||||
}
|
||||
|
||||
$database_list = PMA_DBI_fetch_result($command, null, null, $this->_db_link);
|
||||
$database_list = PMA_DBI_fetch_result($command, null, null, $this->db_link);
|
||||
PMA_DBI_getError();
|
||||
|
||||
if ($GLOBALS['errno'] !== 0) {
|
||||
// failed to get database list, try the control user
|
||||
// (hopefully there is one and he has SHOW DATABASES right)
|
||||
$this->_db_link = $this->_db_link_control;
|
||||
$this->db_link = $this->db_link_control;
|
||||
$database_list = PMA_DBI_fetch_result(
|
||||
$command, null, null, $this->_db_link
|
||||
$command, null, null, $this->db_link
|
||||
);
|
||||
|
||||
PMA_DBI_getError();
|
||||
@@ -140,7 +140,7 @@ class PMA_List_Database extends PMA_List
|
||||
// retrieve database list, the admin has to setup a control user or
|
||||
// allow SHOW DATABASES
|
||||
$GLOBALS['error_showdatabases'] = true;
|
||||
$this->_show_databases_disabled = true;
|
||||
$this->show_databases_disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,12 +162,12 @@ class PMA_List_Database extends PMA_List
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if (! $this->_checkOnlyDatabase()) {
|
||||
$items = $this->_retrieve();
|
||||
if (! $this->checkOnlyDatabase()) {
|
||||
$items = $this->retrieve();
|
||||
$this->exchangeArray($items);
|
||||
}
|
||||
|
||||
$this->_checkHideDatabase();
|
||||
$this->checkHideDatabase();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ class PMA_List_Database extends PMA_List
|
||||
*
|
||||
* @return boolean false if there is no only_db, otherwise true
|
||||
*/
|
||||
protected function _checkOnlyDatabase()
|
||||
protected function checkOnlyDatabase()
|
||||
{
|
||||
if (is_string($GLOBALS['cfg']['Server']['only_db'])
|
||||
&& strlen($GLOBALS['cfg']['Server']['only_db'])
|
||||
@@ -192,10 +192,10 @@ class PMA_List_Database extends PMA_List
|
||||
$items = array();
|
||||
|
||||
foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
|
||||
if ($each_only_db === '*' && ! $this->_show_databases_disabled) {
|
||||
if ($each_only_db === '*' && ! $this->show_databases_disabled) {
|
||||
// append all not already listed dbs to the list
|
||||
$items = array_merge(
|
||||
$items, array_diff($this->_retrieve(), $items)
|
||||
$items, array_diff($this->retrieve(), $items)
|
||||
);
|
||||
// there can only be one '*', and this can only be last
|
||||
break;
|
||||
@@ -209,8 +209,8 @@ class PMA_List_Database extends PMA_List
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $this->_show_databases_disabled) {
|
||||
$items = array_merge($items, $this->_retrieve($each_only_db));
|
||||
if (! $this->show_databases_disabled) {
|
||||
$items = array_merge($items, $this->retrieve($each_only_db));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ class PMA_List_Database extends PMA_List
|
||||
* @deprecated
|
||||
* @return void
|
||||
*/
|
||||
protected function _checkAgainstPrivTables()
|
||||
protected function checkAgainstPrivTables()
|
||||
{
|
||||
// 1. get allowed dbs from the "mysql.db" table
|
||||
// User can be blank (anonymous user)
|
||||
|
||||
@@ -10,7 +10,7 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton class for generating the top menu
|
||||
* Class for generating the top menu
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
@@ -37,17 +37,9 @@ class PMA_Menu
|
||||
* @var string
|
||||
*/
|
||||
private $_table;
|
||||
/**
|
||||
* PMA_Menu instance
|
||||
*
|
||||
* @access private
|
||||
* @static
|
||||
* @var object
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* Private constructor disables direct object creation
|
||||
* Creates a new instance of PMA_Menu
|
||||
*
|
||||
* @param int $server Server id
|
||||
* @param string $db Database name
|
||||
@@ -55,28 +47,11 @@ class PMA_Menu
|
||||
*
|
||||
* @return New PMA_Table
|
||||
*/
|
||||
private function __construct($server, $db, $table)
|
||||
public function __construct($server, $db, $table)
|
||||
{
|
||||
$this->_server = $server;
|
||||
$this->_db = $db;
|
||||
$this->_table = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the menu and the breadcrumbs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (empty(self::$_instance)) {
|
||||
self::$_instance = new PMA_Menu(
|
||||
$GLOBALS['server'],
|
||||
$GLOBALS['db'],
|
||||
$GLOBALS['table']
|
||||
);
|
||||
}
|
||||
return self::$_instance;
|
||||
$this->_db = $db;
|
||||
$this->_table = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,12 +61,29 @@ class PMA_Menu
|
||||
*/
|
||||
public function display()
|
||||
{
|
||||
echo $this->_getBreadcrumbs();
|
||||
echo $this->_getMenu();
|
||||
echo $this->getDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the menu and the breadcrumbs as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplay()
|
||||
{
|
||||
$retval = $this->_getBreadcrumbs();
|
||||
$retval .= $this->_getMenu();
|
||||
if (! empty($GLOBALS['message'])) {
|
||||
echo PMA_getMessage($GLOBALS['message']);
|
||||
if (isset($GLOBALS['buffer_message'])) {
|
||||
$buffer_message = $GLOBALS['buffer_message'];
|
||||
}
|
||||
$retval .= PMA_getMessage($GLOBALS['message']);
|
||||
unset($GLOBALS['message']);
|
||||
if (isset($buffer_message)) {
|
||||
$GLOBALS['buffer_message'] = $buffer_message;
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,10 +206,6 @@ class PMA_Menu
|
||||
} // end if
|
||||
} else {
|
||||
// no table selected, display database comment if present
|
||||
/**
|
||||
* Settings for relations stuff
|
||||
*/
|
||||
include_once './libraries/relation.lib.php';
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
|
||||
// Get additional information about tables for tooltip is done
|
||||
@@ -353,7 +341,7 @@ class PMA_Menu
|
||||
* export, search and qbe links if there is at least one table
|
||||
*/
|
||||
if ($num_tables == 0) {
|
||||
$tabs['qbe']['warning'] = __('Database seems to be empty!');
|
||||
$tabs['qbe']['warning'] = __('Database seems to be empty!');
|
||||
$tabs['search']['warning'] = __('Database seems to be empty!');
|
||||
$tabs['export']['warning'] = __('Database seems to be empty!');
|
||||
}
|
||||
@@ -480,9 +468,9 @@ class PMA_Menu
|
||||
$tabs['import']['link'] = 'server_import.php';
|
||||
$tabs['import']['text'] = __('Import');
|
||||
|
||||
$tabs['settings']['icon'] = 'b_tblops.png';
|
||||
$tabs['settings']['link'] = 'prefs_manage.php';
|
||||
$tabs['settings']['text'] = __('Settings');
|
||||
$tabs['settings']['icon'] = 'b_tblops.png';
|
||||
$tabs['settings']['link'] = 'prefs_manage.php';
|
||||
$tabs['settings']['text'] = __('Settings');
|
||||
$tabs['settings']['active'] = in_array(
|
||||
basename($GLOBALS['PMA_PHP_SELF']),
|
||||
array('prefs_forms.php', 'prefs_manage.php')
|
||||
|
||||
@@ -27,15 +27,15 @@
|
||||
* $message = PMA_Message::success('strSomeLocaleMessage');
|
||||
*
|
||||
* // create another message, a hint, with a localized string which expects
|
||||
* // two parameters: $strSomeFootnote = 'Read the %smanual%s'
|
||||
* $hint = PMA_Message::notice('strSomeFootnote');
|
||||
* // two parameters: $strSomeTooltip = 'Read the %smanual%s'
|
||||
* $hint = PMA_Message::notice('strSomeTooltip');
|
||||
* // replace %d with the following params
|
||||
* $hint->addParam('[a@./Documentation.html#cfg_Example@_blank]');
|
||||
* $hint->addParam('[/a]');
|
||||
* // add this hint as a footnote
|
||||
* // add this hint as a tooltip
|
||||
* $hint = PMA_showHint($hint);
|
||||
*
|
||||
* // add the retrieved footnote reference to the original message
|
||||
* // add the retrieved tooltip reference to the original message
|
||||
* $message->addMessage($hint);
|
||||
*
|
||||
* // create another message ...
|
||||
@@ -700,6 +700,7 @@ class PMA_Message
|
||||
*/
|
||||
public function getDisplay()
|
||||
{
|
||||
$this->isDisplayed(true);
|
||||
return '<div class="' . $this->getLevel() . '">'
|
||||
. $this->getMessage() . '</div>';
|
||||
}
|
||||
|
||||
129
libraries/OutputBuffering.class.php
Normal file
129
libraries/OutputBuffering.class.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class PMA_OutputBuffering
|
||||
{
|
||||
private static $_instance;
|
||||
private $_mode;
|
||||
private $_content;
|
||||
private $_on;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$this->_mode = $this->_getMode();
|
||||
$this->_on = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function could be used eventually to support more modes.
|
||||
*
|
||||
* @return integer the output buffer mode
|
||||
*/
|
||||
private function _getMode()
|
||||
{
|
||||
$mode = 0;
|
||||
if ($GLOBALS['cfg']['OBGzip'] && function_exists('ob_start')) {
|
||||
if (ini_get('output_handler') == 'ob_gzhandler') {
|
||||
// If a user sets the output_handler in php.ini to ob_gzhandler, then
|
||||
// any right frame file in phpMyAdmin will not be handled properly by
|
||||
// the browser. My fix was to check the ini file within the
|
||||
// PMA_outBufferModeGet() function.
|
||||
$mode = 0;
|
||||
} elseif (function_exists('ob_get_level') && ob_get_level() > 0) {
|
||||
// If output buffering is enabled in php.ini it's not possible to
|
||||
// add the ob_gzhandler without a warning message from php 4.3.0.
|
||||
// Being better safe than sorry, check for any existing output handler
|
||||
// instead of just checking the 'output_buffering' setting.
|
||||
$mode = 0;
|
||||
} else {
|
||||
$mode = 1;
|
||||
}
|
||||
}
|
||||
// Zero (0) is no mode or in other words output buffering is OFF.
|
||||
// Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
|
||||
// Usefull if we ever decide to combine modes. Then a bitmask field of
|
||||
// the sum of all modes will be the natural choice.
|
||||
return $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton PMA_OutputBuffering object
|
||||
*
|
||||
* @return PMA_OutputBuffering object
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (empty(self::$_instance)) {
|
||||
self::$_instance = new PMA_OutputBuffering();
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will need to run at the top of all pages if output
|
||||
* output buffering is turned on. It also needs to be passed $mode from
|
||||
* the PMA_outBufferModeGet() function or it will be useless.
|
||||
*
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
if (! $this->_on) {
|
||||
if ($this->_mode) {
|
||||
ob_start('ob_gzhandler');
|
||||
}
|
||||
ob_start();
|
||||
header('X-ob_mode: ' . $this->_mode);
|
||||
register_shutdown_function('PMA_OutputBuffering::stop');
|
||||
$this->_on = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will need to run at the bottom of all pages if output
|
||||
* buffering is turned on. It also needs to be passed $mode from the
|
||||
* PMA_outBufferModeGet() function or it will be useless.
|
||||
*
|
||||
*/
|
||||
public static function stop()
|
||||
{
|
||||
$buffer = PMA_OutputBuffering::getInstance();
|
||||
if ($buffer->_on) {
|
||||
$buffer->_on = false;
|
||||
$buffer->_content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
PMA_Response::response();
|
||||
}
|
||||
|
||||
public function getContents()
|
||||
{
|
||||
return $this->_content;
|
||||
}
|
||||
|
||||
public function flush()
|
||||
{
|
||||
if (ob_get_status() && $this->_mode) {
|
||||
ob_flush();
|
||||
}
|
||||
/**
|
||||
* previously we had here an "else flush()" but some PHP versions
|
||||
* (at least PHP 5.2.11) have a bug (49816) that produces garbled
|
||||
* data
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -85,9 +85,8 @@ class PMA_PDF extends TCPDF
|
||||
*/
|
||||
function Error($error_message = '')
|
||||
{
|
||||
include './libraries/header.inc.php';
|
||||
PMA_Message::error(__('Error while creating PDF:') . ' ' . $error_message)->display();
|
||||
include './libraries/footer.inc.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +95,7 @@ class PMA_PDF extends TCPDF
|
||||
function Download($filename)
|
||||
{
|
||||
$pdfData = $this->getPDFData();
|
||||
PMA_download_header($filename, 'application/pdf', strlen($pdfData));
|
||||
PMA_downloadHeader($filename, 'application/pdf', strlen($pdfData));
|
||||
echo $pdfData;
|
||||
}
|
||||
}
|
||||
|
||||
315
libraries/Response.class.php
Normal file
315
libraries/Response.class.php
Normal file
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Manages the rendering of pages in PMA
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'libraries/OutputBuffering.class.php';
|
||||
require_once 'libraries/Header.class.php';
|
||||
require_once 'libraries/Footer.class.php';
|
||||
|
||||
/**
|
||||
* Singleton class used to manage the rendering of pages in PMA
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class PMA_Response
|
||||
{
|
||||
/**
|
||||
* PMA_Response instance
|
||||
*
|
||||
* @access private
|
||||
* @static
|
||||
* @var object
|
||||
*/
|
||||
private static $_instance;
|
||||
/**
|
||||
* PMA_Header instance
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_header;
|
||||
/**
|
||||
* HTML data to be used in the response
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_HTML;
|
||||
/**
|
||||
* An array of JSON key-value pairs
|
||||
* to be sent back for ajax requests
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private $_JSON;
|
||||
/**
|
||||
* PMA_Footer instance
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_footer;
|
||||
/**
|
||||
* Whether we are servicing an ajax request.
|
||||
* We can't simply use $GLOBALS['is_ajax_request']
|
||||
* here since it may have not been initialised yet.
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isAjax;
|
||||
/**
|
||||
* Whether there were any errors druing the processing of the request
|
||||
* Only used for ajax responses
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isSuccess;
|
||||
/**
|
||||
* Workaround for PHP bug
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_CWD;
|
||||
|
||||
/**
|
||||
* Creates a new class instance
|
||||
*
|
||||
* @return new PMA_Response object
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$buffer = PMA_OutputBuffering::getInstance();
|
||||
$buffer->start();
|
||||
$this->_header = new PMA_Header();
|
||||
$this->_HTML = '';
|
||||
$this->_JSON = array();
|
||||
$this->_footer = new PMA_Footer();
|
||||
|
||||
$this->_isSuccess = true;
|
||||
$this->_isAjax = false;
|
||||
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
$this->_isAjax = true;
|
||||
}
|
||||
$this->_header->setAjax($this->_isAjax);
|
||||
$this->_footer->setAjax($this->_isAjax);
|
||||
$this->_CWD = getcwd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton PMA_Response object
|
||||
*
|
||||
* @return PMA_Response object
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (empty(self::$_instance)) {
|
||||
self::$_instance = new PMA_Response();
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status of an ajax response,
|
||||
* whether it is a success or an error
|
||||
*
|
||||
* @param bool $state Whether the request was successfully processed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function isSuccess($state)
|
||||
{
|
||||
$this->_isSuccess = ($state == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true or false depending on whether
|
||||
* we are servicing an ajax request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function isAjax()
|
||||
{
|
||||
return $this->_isAjax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the current working directory
|
||||
* Necessary to work around a PHP bug where the CWD is
|
||||
* reset after the initial script exits
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCWD()
|
||||
{
|
||||
return $this->_CWD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the rendering of the header
|
||||
* and the footer in responses
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disable()
|
||||
{
|
||||
$this->_header->disable();
|
||||
$this->_footer->disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a PMA_Header object
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getHeader()
|
||||
{
|
||||
return $this->_header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a PMA_Footer object
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getFooter()
|
||||
{
|
||||
return $this->_footer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HTML code to the response
|
||||
*
|
||||
* @param string $content A string to be appended to
|
||||
* the current output buffer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addHTML($content)
|
||||
{
|
||||
if ($content instanceof PMA_Message) {
|
||||
$this->_HTML .= $content->getDisplay();
|
||||
} else {
|
||||
$this->_HTML .= $content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add JSON code to the response
|
||||
*
|
||||
* @param mixed $json Either a key (string) or an
|
||||
* array or key-value pairs
|
||||
* @param mixed $value Null, if passing an array in $json otherwise
|
||||
* it's a string value to the key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addJSON($json, $value = null)
|
||||
{
|
||||
if (is_array($json)) {
|
||||
foreach ($json as $key => $value) {
|
||||
$this->addJSON($key, $value);
|
||||
}
|
||||
} else {
|
||||
if ($value instanceof PMA_Message) {
|
||||
$this->_JSON[$json] = $value->getDisplay();
|
||||
} else {
|
||||
$this->_JSON[$json] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the HTML response text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getDisplay()
|
||||
{
|
||||
// The header may contain nothing at all,
|
||||
// if it's content was already rendered
|
||||
// and, in this case, the header will be
|
||||
// in the content part of the request
|
||||
$retval = $this->_header->getDisplay();
|
||||
$retval .= $this->_HTML;
|
||||
$retval .= $this->_footer->getDisplay();
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an HTML response to the browser
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _htmlResponse()
|
||||
{
|
||||
echo $this->_getDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a JSON response to the browser
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _ajaxResponse()
|
||||
{
|
||||
if (! isset($this->_JSON['message'])) {
|
||||
$this->_JSON['message'] = $this->_getDisplay();
|
||||
} else if ($this->_JSON['message'] instanceof PMA_Message) {
|
||||
$this->_JSON['message'] = $this->_JSON['message']->getDisplay();
|
||||
}
|
||||
|
||||
if ($this->_isSuccess) {
|
||||
$this->_JSON['success'] = true;
|
||||
} else {
|
||||
$this->_JSON['success'] = false;
|
||||
$this->_JSON['error'] = $this->_JSON['message'];
|
||||
unset($this->_JSON['message']);
|
||||
}
|
||||
|
||||
// Set the Content-Type header to JSON so that jQuery parses the
|
||||
// response correctly.
|
||||
if (! defined('TESTSUITE')) {
|
||||
header('Cache-Control: no-cache');
|
||||
header('Content-Type: application/json');
|
||||
}
|
||||
|
||||
echo json_encode($this->_JSON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an HTML response to the browser
|
||||
*
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
public static function response()
|
||||
{
|
||||
$response = PMA_Response::getInstance();
|
||||
chdir($response->getCWD());
|
||||
$buffer = PMA_OutputBuffering::getInstance();
|
||||
if (empty($response->_HTML)) {
|
||||
$response->_HTML = $buffer->getContents();
|
||||
}
|
||||
if ($response->isAjax()) {
|
||||
$response->_ajaxResponse();
|
||||
} else {
|
||||
$response->_htmlResponse();
|
||||
}
|
||||
$buffer->flush();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
174
libraries/Scripts.class.php
Normal file
174
libraries/Scripts.class.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* JavaScript management
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects information about which JavaScript
|
||||
* files and objects are necessary to render
|
||||
* the page and generates the relevant code.
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class PMA_Scripts
|
||||
{
|
||||
/**
|
||||
* An array of SCRIPT tags
|
||||
*
|
||||
* @access private
|
||||
* @var array of strings
|
||||
*/
|
||||
private $_files;
|
||||
/**
|
||||
* An array of discrete javascript code snippets
|
||||
*
|
||||
* @access private
|
||||
* @var array of strings
|
||||
*/
|
||||
private $_code;
|
||||
/**
|
||||
* An array of event names to bind and javascript code
|
||||
* snippets to fire for the corresponding events
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private $_events;
|
||||
|
||||
/**
|
||||
* Returns HTML code to include javascript file.
|
||||
*
|
||||
* @param string $url Location of javascript, relative to js/ folder.
|
||||
* @param int $timestamp The date when the file was last modified
|
||||
* @param string $ie_conditional true - wrap with IE conditional comment
|
||||
* 'lt 9' etc. - wrap for specific IE version
|
||||
*
|
||||
* @return string HTML code for javascript inclusion.
|
||||
*/
|
||||
private function _includeFile($url, $timestamp = null, $ie_conditional = false)
|
||||
{
|
||||
$include = '';
|
||||
if ($ie_conditional !== false) {
|
||||
if ($ie_conditional === true) {
|
||||
$include .= '<!--[if IE]>' . "\n ";
|
||||
} else {
|
||||
$include .= '<!--[if IE ' . $ie_conditional . ']>' . "\n ";
|
||||
}
|
||||
}
|
||||
$include .= '<script src="' . $url;
|
||||
if (! empty($timestamp)) {
|
||||
$include .= '?ts=' . filemtime($url);
|
||||
}
|
||||
$include .= '" type="text/javascript"></script>' . "\n";
|
||||
if ($ie_conditional !== false) {
|
||||
$include .= '<![endif]-->' . "\n";
|
||||
}
|
||||
return $include;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates new PMA_Scripts objects
|
||||
*
|
||||
* @return PMA_Scripts object
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_files = array();
|
||||
$this->_code = '';
|
||||
$this->_events = array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new file to the list of scripts
|
||||
*
|
||||
* @param string $filename The name of the file to include
|
||||
* @param bool $conditional_ie Whether to wrap the script tag in
|
||||
* conditional comments for IE
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addFile($filename, $conditional_ie = false)
|
||||
{
|
||||
$filename = 'js/' . $filename;
|
||||
$hash = md5($filename);
|
||||
if (empty($this->_files[$hash])) {
|
||||
$timestamp = null;
|
||||
if (strpos($filename, '?') === false) {
|
||||
$timestamp = filemtime($filename);
|
||||
}
|
||||
$this->_files[$hash] = array(
|
||||
'filename' => $filename,
|
||||
'timestamp' => $timestamp,
|
||||
'conditional_ie' => $conditional_ie
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new code snippet to the code to be executed
|
||||
*
|
||||
* @param string $code The JS code to be added
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addCode($code)
|
||||
{
|
||||
$this->_code .= "$code\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new event to the list of events
|
||||
*
|
||||
* @param string $event The name of the event to register
|
||||
* @param string $function The code to execute when the event fires
|
||||
* E.g: 'function () { doSomething(); }'
|
||||
* or 'doSomething'
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addEvent($event, $function)
|
||||
{
|
||||
$this->_events[] = array(
|
||||
'event' => $event,
|
||||
'function' => $function
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders all the JavaScript file inclusions, code and events
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplay()
|
||||
{
|
||||
$retval = '';
|
||||
|
||||
foreach ($this->_files as $file) {
|
||||
$retval .= $this->_includeFile(
|
||||
$file['filename'],
|
||||
$file['conditional_ie']
|
||||
);
|
||||
}
|
||||
$retval .= '<script type="text/javascript">';
|
||||
$retval .= "// <![CDATA[\n";
|
||||
$retval .= $this->_code;
|
||||
foreach ($this->_events as $js_event) {
|
||||
$retval .= sprintf(
|
||||
"$(window.parent).bind('%s', %s);\n",
|
||||
$js_event['event'],
|
||||
$js_event['function']
|
||||
);
|
||||
}
|
||||
$retval .= '// ]]>';
|
||||
$retval .= '</script>';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
@@ -252,7 +252,8 @@ class PMA_StorageEngine
|
||||
if (isset($variables[$row['Variable_name']])) {
|
||||
$mysql_vars[$row['Variable_name']] = $variables[$row['Variable_name']];
|
||||
} elseif (! $like
|
||||
&& strpos(strtolower($row['Variable_name']), strtolower($this->engine)) !== 0) {
|
||||
&& strpos(strtolower($row['Variable_name']), strtolower($this->engine)) !== 0
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$mysql_vars[$row['Variable_name']]['value'] = $row['Value'];
|
||||
|
||||
@@ -617,7 +617,8 @@ class PMA_Table
|
||||
* @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 $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
|
||||
@@ -727,7 +728,6 @@ class PMA_Table
|
||||
return true;
|
||||
} // end of 'PMA_Table::duplicateInfo()' function
|
||||
|
||||
|
||||
/**
|
||||
* Copies or renames table
|
||||
*
|
||||
@@ -749,10 +749,7 @@ 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);
|
||||
if ($result) {
|
||||
$GLOBALS['message'] = $tbl->getLastMessage();
|
||||
return true;
|
||||
@@ -978,91 +975,11 @@ class PMA_Table
|
||||
$sql_drop_query .= ' ' . $source;
|
||||
PMA_DBI_query($sql_drop_query);
|
||||
|
||||
// Move old entries from PMA-DBs to new table
|
||||
if ($GLOBALS['cfgRelation']['commwork']) {
|
||||
$remove_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info'])
|
||||
. ' SET table_name = \'' . PMA_sqlAddSlashes($target_table) . '\', '
|
||||
. ' db_name = \'' . PMA_sqlAddSlashes($target_db) . '\''
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($source_db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($source_table) . '\'';
|
||||
PMA_query_as_controluser($remove_query);
|
||||
unset($remove_query);
|
||||
}
|
||||
|
||||
// updating bookmarks is not possible since only a single table is
|
||||
// moved, and not the whole DB.
|
||||
|
||||
if ($GLOBALS['cfgRelation']['displaywork']) {
|
||||
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_info'])
|
||||
. ' SET db_name = \'' . PMA_sqlAddSlashes($target_db) . '\', '
|
||||
. ' table_name = \'' . PMA_sqlAddSlashes($target_table) . '\''
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($source_db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($source_table) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['cfgRelation']['relwork']) {
|
||||
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation'])
|
||||
. ' SET foreign_table = \'' . PMA_sqlAddSlashes($target_table) . '\','
|
||||
. ' foreign_db = \'' . PMA_sqlAddSlashes($target_db) . '\''
|
||||
. ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($source_db) . '\''
|
||||
. ' AND foreign_table = \'' . PMA_sqlAddSlashes($source_table) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
|
||||
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation'])
|
||||
. ' SET master_table = \'' . PMA_sqlAddSlashes($target_table) . '\','
|
||||
. ' master_db = \'' . PMA_sqlAddSlashes($target_db) . '\''
|
||||
. ' WHERE master_db = \'' . PMA_sqlAddSlashes($source_db) . '\''
|
||||
. ' AND master_table = \'' . PMA_sqlAddSlashes($source_table) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Can't get moving PDFs the right way. The page numbers
|
||||
* always get screwed up independently from duplication because the
|
||||
* numbers do not seem to be stored on a per-database basis. Would
|
||||
* the author of pdf support please have a look at it?
|
||||
*/
|
||||
|
||||
if ($GLOBALS['cfgRelation']['pdfwork']) {
|
||||
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_coords'])
|
||||
. ' SET table_name = \'' . PMA_sqlAddSlashes($target_table) . '\','
|
||||
. ' db_name = \'' . PMA_sqlAddSlashes($target_db) . '\''
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($source_db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($source_table) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
/*
|
||||
$pdf_query = 'SELECT pdf_page_number '
|
||||
. ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_coords'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($target_db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($target_table) . '\'';
|
||||
$pdf_rs = PMA_query_as_controluser($pdf_query);
|
||||
|
||||
while ($pdf_copy_row = PMA_DBI_fetch_assoc($pdf_rs)) {
|
||||
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['pdf_pages'])
|
||||
. ' SET db_name = \'' . PMA_sqlAddSlashes($target_db) . '\''
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($source_db) . '\''
|
||||
. ' AND page_nr = \'' . PMA_sqlAddSlashes($pdf_copy_row['pdf_page_number']) . '\'';
|
||||
$tb_rs = PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
unset($tb_rs);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if ($GLOBALS['cfgRelation']['designerwork']) {
|
||||
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords'])
|
||||
. ' SET table_name = \'' . PMA_sqlAddSlashes($target_table) . '\','
|
||||
. ' db_name = \'' . PMA_sqlAddSlashes($target_db) . '\''
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($source_db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($source_table) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
}
|
||||
// Renable table in configuration storage
|
||||
PMA_REL_renameTable(
|
||||
$source_db, $target_db,
|
||||
$source_table, $target_table
|
||||
);
|
||||
|
||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_drop_query . ';';
|
||||
// end if ($move)
|
||||
@@ -1265,13 +1182,10 @@ class PMA_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?
|
||||
*
|
||||
* @todo remove the $is_view parameter (also in callers)
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
function rename($new_name, $new_db = null, $is_view = false)
|
||||
function rename($new_name, $new_db = null)
|
||||
{
|
||||
if (null !== $new_db && $new_db !== $this->getDbName()) {
|
||||
// Ensure the target is valid
|
||||
@@ -1334,80 +1248,11 @@ class PMA_Table
|
||||
$this->setName($new_name);
|
||||
$this->setDbName($new_db);
|
||||
|
||||
/**
|
||||
* @todo move into extra function
|
||||
* PMA_Relation::renameTable($new_name, $old_name, $new_db, $old_db)
|
||||
*/
|
||||
// Move old entries from comments to new table
|
||||
$GLOBALS['cfgRelation'] = PMA_getRelationsParam();
|
||||
if ($GLOBALS['cfgRelation']['commwork']) {
|
||||
$remove_query = '
|
||||
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
|
||||
SET `db_name` = \'' . PMA_sqlAddSlashes($new_db) . '\',
|
||||
`table_name` = \'' . PMA_sqlAddSlashes($new_name) . '\'
|
||||
WHERE `db_name` = \'' . PMA_sqlAddSlashes($old_db) . '\'
|
||||
AND `table_name` = \'' . PMA_sqlAddSlashes($old_name) . '\'';
|
||||
PMA_query_as_controluser($remove_query);
|
||||
unset($remove_query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['cfgRelation']['displaywork']) {
|
||||
$table_query = '
|
||||
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['table_info']) . '
|
||||
SET `db_name` = \'' . PMA_sqlAddSlashes($new_db) . '\',
|
||||
`table_name` = \'' . PMA_sqlAddSlashes($new_name) . '\'
|
||||
WHERE `db_name` = \'' . PMA_sqlAddSlashes($old_db) . '\'
|
||||
AND `table_name` = \'' . PMA_sqlAddSlashes($old_name) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['cfgRelation']['relwork']) {
|
||||
$table_query = '
|
||||
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['relation']) . '
|
||||
SET `foreign_db` = \'' . PMA_sqlAddSlashes($new_db) . '\',
|
||||
`foreign_table` = \'' . PMA_sqlAddSlashes($new_name) . '\'
|
||||
WHERE `foreign_db` = \'' . PMA_sqlAddSlashes($old_db) . '\'
|
||||
AND `foreign_table` = \'' . PMA_sqlAddSlashes($old_name) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
|
||||
$table_query = '
|
||||
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['relation']) . '
|
||||
SET `master_db` = \'' . PMA_sqlAddSlashes($new_db) . '\',
|
||||
`master_table` = \'' . PMA_sqlAddSlashes($new_name) . '\'
|
||||
WHERE `master_db` = \'' . PMA_sqlAddSlashes($old_db) . '\'
|
||||
AND `master_table` = \'' . PMA_sqlAddSlashes($old_name) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['cfgRelation']['pdfwork']) {
|
||||
$table_query = '
|
||||
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['table_coords']) . '
|
||||
SET `db_name` = \'' . PMA_sqlAddSlashes($new_db) . '\',
|
||||
`table_name` = \'' . PMA_sqlAddSlashes($new_name) . '\'
|
||||
WHERE `db_name` = \'' . PMA_sqlAddSlashes($old_db) . '\'
|
||||
AND `table_name` = \'' . PMA_sqlAddSlashes($old_name) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['cfgRelation']['designerwork']) {
|
||||
$table_query = '
|
||||
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['designer_coords']) . '
|
||||
SET `db_name` = \'' . PMA_sqlAddSlashes($new_db) . '\',
|
||||
`table_name` = \'' . PMA_sqlAddSlashes($new_name) . '\'
|
||||
WHERE `db_name` = \'' . PMA_sqlAddSlashes($old_db) . '\'
|
||||
AND `table_name` = \'' . PMA_sqlAddSlashes($old_name) . '\'';
|
||||
PMA_query_as_controluser($table_query);
|
||||
unset($table_query);
|
||||
}
|
||||
// Renable table in configuration storage
|
||||
PMA_REL_renameTable(
|
||||
$old_db, $new_db,
|
||||
$old_name, $new_name
|
||||
);
|
||||
|
||||
$this->messages[] = sprintf(
|
||||
__('Table %1$s has been renamed to %2$s.'),
|
||||
|
||||
1197
libraries/TableSearch.class.php
Normal file
1197
libraries/TableSearch.class.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -74,7 +74,9 @@ class PMA_Theme
|
||||
'gis',
|
||||
'navigation',
|
||||
'pmd',
|
||||
'rte'
|
||||
'rte',
|
||||
'codemirror',
|
||||
'jqplot'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -146,22 +148,30 @@ class PMA_Theme
|
||||
*/
|
||||
public function checkImgPath()
|
||||
{
|
||||
// try current theme first
|
||||
if (is_dir($this->getPath() . '/img/')) {
|
||||
$this->setImgPath($this->getPath() . '/img/');
|
||||
return true;
|
||||
} elseif (is_dir($GLOBALS['cfg']['ThemePath'] . '/' . PMA_Theme_Manager::FALLBACK_THEME . '/img/')) {
|
||||
$this->setImgPath($GLOBALS['cfg']['ThemePath'] . '/' . PMA_Theme_Manager::FALLBACK_THEME . '/img/');
|
||||
return true;
|
||||
} else {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__('No valid image path for theme %s found!'),
|
||||
$this->getName()
|
||||
),
|
||||
E_USER_ERROR
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// try fallback theme
|
||||
$fallback = $GLOBALS['cfg']['ThemePath'] . '/'
|
||||
. PMA_Theme_Manager::FALLBACK_THEME
|
||||
. '/img/';
|
||||
if (is_dir($fallback)) {
|
||||
$this->setImgPath($fallback);
|
||||
return true;
|
||||
}
|
||||
|
||||
// we failed
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__('No valid image path for theme %s found!'),
|
||||
$this->getName()
|
||||
),
|
||||
E_USER_ERROR
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,16 +309,84 @@ class PMA_Theme
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to images for the theme
|
||||
* Returns the path to image for the theme.
|
||||
* If filename is given, it possibly fallbacks to fallback
|
||||
* theme for it if image does not exist.
|
||||
*
|
||||
* @param string $file file name for image
|
||||
*
|
||||
* @access public
|
||||
* @return string image path for this theme
|
||||
*/
|
||||
public function getImgPath()
|
||||
public function getImgPath($file = null)
|
||||
{
|
||||
return $this->img_path;
|
||||
if (is_null($file)) {
|
||||
return $this->img_path;
|
||||
} else {
|
||||
if (is_readable($this->img_path . $file)) {
|
||||
return $this->img_path . $file;
|
||||
} else {
|
||||
return $GLOBALS['cfg']['ThemePath'] . '/'
|
||||
. PMA_Theme_Manager::FALLBACK_THEME . '/img/' . $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a CSS rule used for html formatted SQL queries
|
||||
*
|
||||
* @param string $classname The class name
|
||||
* @param string $property The property name
|
||||
* @param string $value The property value
|
||||
*
|
||||
* @return string The CSS rule
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @see PMA_SQP_buildCssData()
|
||||
*/
|
||||
public function buildSQPCssRule($classname, $property, $value)
|
||||
{
|
||||
$str = '.' . $classname . ' {';
|
||||
if ($value != '') {
|
||||
$str .= $property . ': ' . $value . ';';
|
||||
}
|
||||
$str .= '}' . "\n";
|
||||
|
||||
return $str;
|
||||
} // end of the "PMA_SQP_buildCssRule()" function
|
||||
|
||||
|
||||
/**
|
||||
* Builds CSS rules used for html formatted SQL queries
|
||||
*
|
||||
* @return string The CSS rules set
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @global array The current PMA configuration
|
||||
*
|
||||
* @see PMA_SQP_buildCssRule()
|
||||
*/
|
||||
public function buildSQPCssData()
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
$css_string = '';
|
||||
foreach ($cfg['SQP']['fmtColor'] AS $key => $col) {
|
||||
$css_string .= $this->buildSQPCssRule('syntax_' . $key, 'color', $col);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$css_string .= $this->buildSQPCssRule(
|
||||
'syntax_indent' . $i, 'margin-left',
|
||||
($i * $cfg['SQP']['fmtInd']) . $cfg['SQP']['fmtIndUnit']
|
||||
);
|
||||
}
|
||||
|
||||
return $css_string;
|
||||
} // end of the "PMA_SQP_buildCssData()" function
|
||||
|
||||
/**
|
||||
* load css (send to stdout, normally the browser)
|
||||
*
|
||||
@@ -319,7 +397,7 @@ class PMA_Theme
|
||||
{
|
||||
$success = true;
|
||||
|
||||
echo PMA_SQP_buildCssData();
|
||||
echo $this->buildSQPCssData();
|
||||
|
||||
if ($GLOBALS['text_dir'] === 'ltr') {
|
||||
$right = 'right';
|
||||
@@ -331,7 +409,8 @@ class PMA_Theme
|
||||
|
||||
foreach ($this->_cssFiles as $file) {
|
||||
$path = $this->getPath() . "/css/$file.css.php";
|
||||
$fallback = "./themes/" . PMA_Theme_Manager::FALLBACK_THEME . "/css/$file.css.php";
|
||||
$fallback = "./themes/"
|
||||
. PMA_Theme_Manager::FALLBACK_THEME . "/css/$file.css.php";
|
||||
|
||||
if (is_readable($path)) {
|
||||
echo "\n/* FILE: $file.css.php */\n";
|
||||
@@ -350,35 +429,39 @@ class PMA_Theme
|
||||
}
|
||||
|
||||
/**
|
||||
* prints out the preview for this theme
|
||||
* Renders the preview for this theme
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public function printPreview()
|
||||
public function getPrintPreview()
|
||||
{
|
||||
echo '<div class="theme_preview">';
|
||||
echo '<h2>' . htmlspecialchars($this->getName())
|
||||
.' (' . htmlspecialchars($this->getVersion()) . ')</h2>';
|
||||
echo '<p>';
|
||||
echo '<a target="_top" class="take_theme" '
|
||||
.'name="' . htmlspecialchars($this->getId()) . '" '
|
||||
. 'href="index.php'. PMA_generate_common_url(
|
||||
array('set_theme' => $this->getId())
|
||||
) . '">';
|
||||
$url_params = array('set_theme' => $this->getId());
|
||||
$url = 'index.php'. PMA_generate_common_url($url_params);
|
||||
|
||||
$retval = '<div class="theme_preview">';
|
||||
$retval .= '<h2>';
|
||||
$retval .= htmlspecialchars($this->getName());
|
||||
$retval .= ' (' . htmlspecialchars($this->getVersion()) . ') ';
|
||||
$retval .= '</h2>';
|
||||
$retval .= '<p>';
|
||||
$retval .= '<a target="_top" class="take_theme" ';
|
||||
$retval .= 'name="' . htmlspecialchars($this->getId()) . '" ';
|
||||
$retval .= 'href="' . $url . '">';
|
||||
if (@file_exists($this->getPath() . '/screen.png')) {
|
||||
// if screen exists then output
|
||||
|
||||
echo '<img src="' . $this->getPath() . '/screen.png" border="1"'
|
||||
.' alt="' . htmlspecialchars($this->getName()) . '"'
|
||||
.' title="' . htmlspecialchars($this->getName()) . '" /><br />';
|
||||
$retval .= '<img src="' . $this->getPath() . '/screen.png" border="1"';
|
||||
$retval .= ' alt="' . htmlspecialchars($this->getName()) . '"';
|
||||
$retval .= ' title="' . htmlspecialchars($this->getName()) . '" />';
|
||||
$retval .= '<br />';
|
||||
} else {
|
||||
echo __('No preview available.');
|
||||
$retval .= __('No preview available.');
|
||||
}
|
||||
|
||||
echo '[ <strong>' . __('take it') . '</strong> ]</a>'
|
||||
.'</p>'
|
||||
.'</div>';
|
||||
$retval .= '[ <strong>' . __('take it') . '</strong> ]';
|
||||
$retval .= '</a>';
|
||||
$retval .= '</p>';
|
||||
$retval .= '</div>';
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,6 +478,23 @@ class PMA_Theme
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets currently configured font size.
|
||||
*
|
||||
* @return String with font size.
|
||||
*/
|
||||
function getFontSize()
|
||||
{
|
||||
$fs = $GLOBALS['PMA_Config']->get('fontsize');
|
||||
if (!is_null($fs)) {
|
||||
return $fs;
|
||||
}
|
||||
if (isset($_COOKIE['pma_fontsize'])) {
|
||||
return $_COOKIE['pma_fontsize'];
|
||||
}
|
||||
return '82%';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates code for CSS gradient using various browser extensions.
|
||||
*
|
||||
@@ -407,21 +507,33 @@ class PMA_Theme
|
||||
{
|
||||
$result = array();
|
||||
// Opera 9.5+, IE 9
|
||||
$result[] = 'background-image: url(./themes/svg_gradient.php?from=' . $start_color . '&to=' . $end_color . ');';
|
||||
$result[] = 'background-image: url(./themes/svg_gradient.php?from='
|
||||
. $start_color . '&to=' . $end_color . ');';
|
||||
$result[] = 'background-size: 100% 100%;';
|
||||
// Safari 4-5, Chrome 1-9
|
||||
$result[] = 'background: -webkit-gradient(linear, left top, left bottom, from(#' . $start_color . '), to(#' . $end_color . '));';
|
||||
$result[] = 'background: '
|
||||
. '-webkit-gradient(linear, left top, left bottom, from(#'
|
||||
. $start_color . '), to(#' . $end_color . '));';
|
||||
// Safari 5.1, Chrome 10+
|
||||
$result[] = 'background: -webkit-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
|
||||
$result[] = 'background: -webkit-linear-gradient(top, #'
|
||||
. $start_color . ', #' . $end_color . ');';
|
||||
// Firefox 3.6+
|
||||
$result[] = 'background: -moz-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
|
||||
$result[] = 'background: -moz-linear-gradient(top, #'
|
||||
. $start_color . ', #' . $end_color . ');';
|
||||
// IE 10
|
||||
$result[] = 'background: -ms-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
|
||||
$result[] = 'background: -ms-linear-gradient(top, #'
|
||||
. $start_color . ', #' . $end_color . ');';
|
||||
// Opera 11.10
|
||||
$result[] = 'background: -o-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
|
||||
$result[] = 'background: -o-linear-gradient(top, #'
|
||||
. $start_color . ', #' . $end_color . ');';
|
||||
// IE 6-8
|
||||
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 . '");';
|
||||
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);
|
||||
}
|
||||
@@ -429,141 +541,59 @@ class PMA_Theme
|
||||
/**
|
||||
* Returns CSS styles for CodeMirror editor based on query formatter colors.
|
||||
*
|
||||
* @param boolean $generic Whether to include generic CodeMirror CSS as well
|
||||
*
|
||||
* @return string CSS code.
|
||||
*/
|
||||
function getCssCodeMirror($generic = false)
|
||||
function getCssCodeMirror()
|
||||
{
|
||||
if (! $GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$result[] = 'span.cm-keyword, span.cm-statement-verb {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_reservedWord'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['alpha_reservedWord'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-variable {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-comment {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['comment'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['comment'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-mysql-string {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['quote'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['quote'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-operator {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-mysql-word {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-builtin {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_functionName'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['alpha_functionName'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-variable-2 {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnType'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnType'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-variable-3 {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnAttrib'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnAttrib'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-separator {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
|
||||
$result[] = '}';
|
||||
$result[] = 'span.cm-number {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['digit_integer'] . ';';
|
||||
$result[] = ' color: '
|
||||
. $GLOBALS['cfg']['SQP']['fmtColor']['digit_integer'] . ';';
|
||||
$result[] = '}';
|
||||
|
||||
if ($generic) {
|
||||
$height = ceil($GLOBALS['cfg']['TextareaRows'] * 1.2);
|
||||
$result[] = <<<EOT
|
||||
.CodeMirror {
|
||||
font-size: 140%;
|
||||
font-family: monospace;
|
||||
background: #fff;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
overflow: auto;
|
||||
height: ${height}em;
|
||||
/* This is needed to prevent an IE[67] bug where the scrolled content
|
||||
is visible outside of the scrolling box. */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.CodeMirror-gutter {
|
||||
position: absolute; left: 0; top: 0;
|
||||
z-index: 10;
|
||||
background-color: #f7f7f7;
|
||||
border-right: 1px solid #eee;
|
||||
min-width: 2em;
|
||||
height: 100%;
|
||||
}
|
||||
.CodeMirror-gutter-text {
|
||||
color: #aaa;
|
||||
text-align: right;
|
||||
padding: .4em .2em .4em .4em;
|
||||
white-space: pre !important;
|
||||
}
|
||||
.CodeMirror-lines {
|
||||
padding: .4em;
|
||||
}
|
||||
|
||||
.CodeMirror pre {
|
||||
-moz-border-radius: 0;
|
||||
-webkit-border-radius: 0;
|
||||
-o-border-radius: 0;
|
||||
border-radius: 0;
|
||||
border-width: 0; margin: 0; padding: 0; background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
padding: 0; margin: 0;
|
||||
white-space: pre;
|
||||
word-wrap: normal;
|
||||
}
|
||||
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.CodeMirror-wrap .CodeMirror-scroll {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror textarea {
|
||||
font-family: inherit !important;
|
||||
font-size: inherit !important;
|
||||
}
|
||||
|
||||
.CodeMirror-cursor {
|
||||
z-index: 10;
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
border-left: 1px solid black !important;
|
||||
}
|
||||
|
||||
.CodeMirror-focused .CodeMirror-cursor {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
span.CodeMirror-selected {
|
||||
background: #ccc !important;
|
||||
color: HighlightText !important;
|
||||
}
|
||||
|
||||
.CodeMirror-focused span.CodeMirror-selected {
|
||||
background: Highlight !important;
|
||||
}
|
||||
|
||||
.CodeMirror-matchingbracket {
|
||||
color: #0f0 !important;
|
||||
}
|
||||
|
||||
.CodeMirror-nonmatchingbracket {
|
||||
color: #f22 !important;
|
||||
}
|
||||
EOT;
|
||||
}
|
||||
return implode("\n", $result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,13 +293,18 @@ class PMA_Theme_Manager
|
||||
// check for themes directory
|
||||
while (false !== ($PMA_Theme = readdir($handleThemes))) {
|
||||
// Skip non dirs, . and ..
|
||||
if ($PMA_Theme == '.' || $PMA_Theme == '..' || ! is_dir($this->getThemesPath() . '/' . $PMA_Theme)) {
|
||||
if ($PMA_Theme == '.'
|
||||
|| $PMA_Theme == '..'
|
||||
|| ! is_dir($this->getThemesPath() . '/' . $PMA_Theme)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($PMA_Theme, $this->themes)) {
|
||||
continue;
|
||||
}
|
||||
$new_theme = PMA_Theme::load($this->getThemesPath() . '/' . $PMA_Theme);
|
||||
$new_theme = PMA_Theme::load(
|
||||
$this->getThemesPath() . '/' . $PMA_Theme
|
||||
);
|
||||
if ($new_theme) {
|
||||
$new_theme->setId($PMA_Theme);
|
||||
$this->themes[$PMA_Theme] = $new_theme;
|
||||
@@ -395,16 +400,18 @@ class PMA_Theme_Manager
|
||||
}
|
||||
|
||||
/**
|
||||
* prints out preview for every theme
|
||||
* Renders the previews for all themes
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public function printPreviews()
|
||||
public function getPrintPreviews()
|
||||
{
|
||||
$retval = '';
|
||||
foreach ($this->themes as $each_theme) {
|
||||
$each_theme->printPreview();
|
||||
$retval .= $each_theme->getPrintPreview();
|
||||
} // end 'open themes'
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -148,18 +148,24 @@ class PMA_Types
|
||||
/**
|
||||
* Returns operators for given type as html options
|
||||
*
|
||||
* @param string $type Type of field
|
||||
* @param boolean $null Whether field can be NULL
|
||||
* @param string $type Type of field
|
||||
* @param boolean $null Whether field can be NULL
|
||||
* @param string $selectedOperator Option to be selected
|
||||
*
|
||||
* @return array
|
||||
* @return string Generated Html
|
||||
*/
|
||||
public function getTypeOperatorsHtml($type, $null)
|
||||
public function getTypeOperatorsHtml($type, $null, $selectedOperator = null)
|
||||
{
|
||||
$html = '';
|
||||
|
||||
foreach ($this->getTypeOperators($type, $null) as $fc) {
|
||||
$escaped = htmlspecialchars($fc);
|
||||
$html .= '<option value="' . $escaped . '">' . $escaped . '</option>';
|
||||
if (isset($selectedOperator) && $selectedOperator == $fc) {
|
||||
$html .= '<option value="' . htmlspecialchars($fc) . '" selected="selected">'
|
||||
. htmlspecialchars($fc) . '</option>';
|
||||
} else {
|
||||
$html .= '<option value="' . htmlspecialchars($fc) . '">'
|
||||
. htmlspecialchars($fc) . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
|
||||
@@ -68,21 +68,18 @@ function PMA_auth_set_user()
|
||||
function PMA_auth_fails()
|
||||
{
|
||||
$conn_error = PMA_DBI_getError();
|
||||
if (!$conn_error) {
|
||||
if (! $conn_error) {
|
||||
$conn_error = __('Cannot connect: invalid settings.');
|
||||
}
|
||||
|
||||
// Defines the charset to be used
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
/* HTML header */
|
||||
$page_title = __('Access denied');
|
||||
include './libraries/header_meta_style.inc.php';
|
||||
include './libraries/header_scripts.inc.php';
|
||||
?>
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->getFooter()->setMinimal();
|
||||
$header = $response->getHeader();
|
||||
$header->setTitle(__('Access denied'));
|
||||
$header->disableMenu();
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
?>
|
||||
<br /><br />
|
||||
<center>
|
||||
<h1><?php echo sprintf(__('Welcome to %s'), ' phpMyAdmin '); ?></h1>
|
||||
@@ -91,9 +88,7 @@ function PMA_auth_fails()
|
||||
<table cellpadding="0" cellspacing="3" style="margin: 0 auto" width="80%">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<?php
|
||||
$GLOBALS['is_header_sent'] = true;
|
||||
|
||||
if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
|
||||
trigger_error(__('Access denied'), E_USER_NOTICE);
|
||||
@@ -131,7 +126,7 @@ function PMA_auth_fails()
|
||||
echo '</tr>' . "\n";
|
||||
}
|
||||
echo '</table>' . "\n";
|
||||
include './libraries/footer.inc.php';
|
||||
exit;
|
||||
return true;
|
||||
} // end of the 'PMA_auth_fails()' function
|
||||
|
||||
|
||||
@@ -130,6 +130,17 @@ function PMA_auth()
|
||||
{
|
||||
global $conn_error;
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
if ($response->isAjax()) {
|
||||
$response->isSuccess(false);
|
||||
if (! empty($conn_error)) {
|
||||
$response->addJSON('message', $conn_error);
|
||||
} else {
|
||||
$response->addJSON('message', PMA_Message::error(__('Your session has expired. Please login again.')));
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Perform logout to custom URL */
|
||||
if (! empty($_REQUEST['old_usr'])
|
||||
&& ! empty($GLOBALS['cfg']['Server']['LogoutURL'])
|
||||
@@ -154,20 +165,13 @@ function PMA_auth()
|
||||
|
||||
$cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right';
|
||||
|
||||
// Defines the charset to be used
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
$response->getFooter()->setMinimal();
|
||||
$header = $response->getHeader();
|
||||
$header->setBodyId('loginform');
|
||||
$header->setTitle('phpMyAdmin');
|
||||
$header->disableMenu();
|
||||
$header->disableWarnings();
|
||||
|
||||
/* HTML header; do not show here the PMA version to improve security */
|
||||
$page_title = 'phpMyAdmin ';
|
||||
include './libraries/header_meta_style.inc.php';
|
||||
// if $page_title is set, this script uses it as the title:
|
||||
include './libraries/header_scripts.inc.php';
|
||||
?>
|
||||
</head>
|
||||
|
||||
<body class="loginform">
|
||||
|
||||
<?php
|
||||
if (file_exists(CUSTOM_HEADER_FILE)) {
|
||||
include CUSTOM_HEADER_FILE;
|
||||
}
|
||||
@@ -189,7 +193,7 @@ function PMA_auth()
|
||||
<?php
|
||||
echo sprintf(
|
||||
__('Welcome to %s'),
|
||||
'<bdo dir="ltr" lang="en">' . $page_title . '</bdo>'
|
||||
'<bdo dir="ltr" lang="en">phpMyAdmin</bdo>'
|
||||
);
|
||||
?>
|
||||
</h1>
|
||||
@@ -306,13 +310,11 @@ function PMA_auth()
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
// show login form in top frame.
|
||||
if (top != self || document.body.className != 'loginform') {
|
||||
if (top != self || ! $('body#loginform').length) {
|
||||
window.top.location.href=location;
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
} // end of the 'PMA_auth()' function
|
||||
@@ -373,8 +375,6 @@ function PMA_auth_check()
|
||||
|
||||
// according to the PHP manual we should do this before the destroy:
|
||||
//$_SESSION = array();
|
||||
// but we still need some parts of the session information
|
||||
// in libraries/header_meta_style.inc.php
|
||||
|
||||
session_destroy();
|
||||
// -> delete password cookie(s)
|
||||
@@ -581,11 +581,13 @@ function PMA_auth_set_user()
|
||||
*/
|
||||
PMA_clearUserCache();
|
||||
|
||||
PMA_Response::getInstance()->disable();
|
||||
|
||||
PMA_sendHeaderLocation(
|
||||
$redirect_url . PMA_generate_common_url($url_params, '&'),
|
||||
true
|
||||
);
|
||||
exit();
|
||||
exit;
|
||||
} // end if
|
||||
|
||||
return true;
|
||||
|
||||
@@ -48,20 +48,14 @@ function PMA_auth()
|
||||
header('status: 401 Unauthorized');
|
||||
}
|
||||
|
||||
// Defines the charset to be used
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
/* HTML header */
|
||||
$page_title = __('Access denied');
|
||||
include './libraries/header_meta_style.inc.php';
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if (file_exists(CUSTOM_HEADER_FILE)) {
|
||||
include CUSTOM_HEADER_FILE;
|
||||
}
|
||||
?>
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->getFooter()->setMinimal();
|
||||
$header = $response->getHeader();
|
||||
$header->setTitle(__('Access denied'));
|
||||
$header->disableMenu();
|
||||
|
||||
?>
|
||||
<br /><br />
|
||||
<center>
|
||||
<h1><?php echo sprintf(__('Welcome to %s'), ' phpMyAdmin'); ?></h1>
|
||||
@@ -74,12 +68,8 @@ function PMA_auth()
|
||||
if (file_exists(CUSTOM_FOOTER_FILE)) {
|
||||
include CUSTOM_FOOTER_FILE;
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
exit;
|
||||
} // end of the 'PMA_auth()' function
|
||||
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ require './libraries/Table.class.php';
|
||||
*/
|
||||
require './libraries/Types.class.php';
|
||||
|
||||
if (!defined('PMA_MINIMUM_COMMON')) {
|
||||
if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
/**
|
||||
* common functions
|
||||
*/
|
||||
@@ -144,29 +144,16 @@ if (!defined('PMA_MINIMUM_COMMON')) {
|
||||
* Include URL/hidden inputs generating.
|
||||
*/
|
||||
include_once './libraries/url_generating.lib.php';
|
||||
|
||||
/**
|
||||
* Used to generate the page
|
||||
*/
|
||||
include_once 'libraries/Response.class.php';
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* start procedural code label_start_procedural */
|
||||
|
||||
/**
|
||||
* protect against possible exploits - there is no need to have so much variables
|
||||
*/
|
||||
if (count($_REQUEST) > 1000) {
|
||||
PMA_fatalError(__('possible exploit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for numeric keys
|
||||
* (if register_globals is on, numeric key can be found in $GLOBALS)
|
||||
*/
|
||||
foreach ($GLOBALS as $key => $dummy) {
|
||||
if (is_numeric($key)) {
|
||||
PMA_fatalError(__('numeric key detected'));
|
||||
}
|
||||
}
|
||||
unset($dummy);
|
||||
|
||||
/**
|
||||
* PATH_INFO could be compromised if set, so remove it from PHP_SELF
|
||||
* and provide a clean PHP_SELF here
|
||||
@@ -489,7 +476,9 @@ if (! PMA_isValid($_REQUEST['token'])
|
||||
/* Cookie preferences */
|
||||
'pma_lang', 'pma_collation_connection',
|
||||
/* Possible login form */
|
||||
'pma_servername', 'pma_username', 'pma_password'
|
||||
'pma_servername', 'pma_username', 'pma_password',
|
||||
/* Needed to send the correct reply */
|
||||
'ajax_request'
|
||||
);
|
||||
/**
|
||||
* Allow changing themes in test/theme.php
|
||||
@@ -558,40 +547,6 @@ if (PMA_isValid($_REQUEST['sql_query'])) {
|
||||
//$_REQUEST['server']; // checked later in this file
|
||||
//$_REQUEST['lang']; // checked by LABEL_loading_language_file
|
||||
|
||||
|
||||
/**
|
||||
* holds name of JavaScript files to be included in HTML header
|
||||
* @global array $js_include
|
||||
*/
|
||||
$GLOBALS['js_include'] = array();
|
||||
$GLOBALS['js_include'][] = 'jquery/jquery-1.6.2.js';
|
||||
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js';
|
||||
$GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js';
|
||||
$GLOBALS['js_include'][] = 'update-location.js';
|
||||
|
||||
/**
|
||||
* holds an array of javascript code snippets to be included in the HTML header
|
||||
* Can be used with PMA_AddJSCode() to pass on js variables to the browser.
|
||||
* @global array $js_script
|
||||
*/
|
||||
$GLOBALS['js_script'] = array();
|
||||
|
||||
/**
|
||||
* Add common jQuery functions script here if necessary.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JavaScript events that will be registered
|
||||
* @global array $js_events
|
||||
*/
|
||||
$GLOBALS['js_events'] = array();
|
||||
|
||||
/**
|
||||
* footnotes to be displayed ot the page bottom
|
||||
* @global array $footnotes
|
||||
*/
|
||||
$GLOBALS['footnotes'] = array();
|
||||
|
||||
/******************************************************************************/
|
||||
/* loading language file LABEL_loading_language_file */
|
||||
|
||||
@@ -600,6 +555,15 @@ $GLOBALS['footnotes'] = array();
|
||||
*/
|
||||
require './libraries/select_lang.lib.php';
|
||||
|
||||
// Defines the cell alignment values depending on text direction
|
||||
if ($GLOBALS['text_dir'] == 'ltr') {
|
||||
$GLOBALS['cell_align_left'] = 'left';
|
||||
$GLOBALS['cell_align_right'] = 'right';
|
||||
} else {
|
||||
$GLOBALS['cell_align_left'] = 'right';
|
||||
$GLOBALS['cell_align_right'] = 'left';
|
||||
}
|
||||
|
||||
/**
|
||||
* check for errors occurred while loading configuration
|
||||
* this check is done here after loading language files to present errors in locale
|
||||
@@ -766,6 +730,9 @@ if (@file_exists($_SESSION['PMA_Theme']->getLayoutFile())) {
|
||||
}
|
||||
|
||||
if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
// get a dummy object to ensure that the class is instanciated
|
||||
PMA_Response::getInstance();
|
||||
|
||||
/**
|
||||
* Character set conversion.
|
||||
*/
|
||||
@@ -881,7 +848,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
* the required auth type plugin
|
||||
*/
|
||||
include_once './libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php';
|
||||
if (!PMA_auth_check()) {
|
||||
if (! PMA_auth_check()) {
|
||||
/* Force generating of new session on login */
|
||||
PMA_secureSession();
|
||||
PMA_auth();
|
||||
@@ -932,7 +899,6 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
PMA_log_user($cfg['Server']['user'], 'allow-denied');
|
||||
PMA_auth_fails();
|
||||
}
|
||||
unset($allowDeny_forbidden); //Clean up after you!
|
||||
} // end if
|
||||
|
||||
// is root allowed?
|
||||
@@ -940,7 +906,6 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$allowDeny_forbidden = true;
|
||||
PMA_log_user($cfg['Server']['user'], 'root-denied');
|
||||
PMA_auth_fails();
|
||||
unset($allowDeny_forbidden); //Clean up after you!
|
||||
}
|
||||
|
||||
// is a login without password allowed?
|
||||
@@ -948,7 +913,6 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$login_without_password_is_forbidden = true;
|
||||
PMA_log_user($cfg['Server']['user'], 'empty-denied');
|
||||
PMA_auth_fails();
|
||||
unset($login_without_password_is_forbidden); //Clean up after you!
|
||||
}
|
||||
|
||||
// if using TCP socket is not needed
|
||||
@@ -1099,6 +1063,32 @@ if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) {
|
||||
$GLOBALS['grid_edit'] = false;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {
|
||||
PMA_fatalError(__("GLOBALS overwrite attempt"));
|
||||
}
|
||||
|
||||
/**
|
||||
* protect against possible exploits - there is no need to have so much variables
|
||||
*/
|
||||
if (count($_REQUEST) > 1000) {
|
||||
PMA_fatalError(__('possible exploit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for numeric keys
|
||||
* (if register_globals is on, numeric key can be found in $GLOBALS)
|
||||
*/
|
||||
foreach ($GLOBALS as $key => $dummy) {
|
||||
if (is_numeric($key)) {
|
||||
PMA_fatalError(__('numeric key detected'));
|
||||
}
|
||||
}
|
||||
unset($dummy);
|
||||
|
||||
// here, the function does not exist with this configuration:
|
||||
// $cfg['ServerDefault'] = 0;
|
||||
$GLOBALS['is_superuser'] = function_exists('PMA_isSuperuser') && PMA_isSuperuser();
|
||||
|
||||
if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
|
||||
/**
|
||||
* include subform target page
|
||||
@@ -1106,4 +1096,5 @@ if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
|
||||
include $__redirect;
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -361,7 +361,7 @@ function PMA_formatSql($parsed_sql, $unparsed_sql = '')
|
||||
return $formatted_sql;
|
||||
}
|
||||
|
||||
$formatted_sql = '';
|
||||
$formatted_sql = '';
|
||||
|
||||
switch ($cfg['SQP']['fmtType']) {
|
||||
case 'none':
|
||||
@@ -528,49 +528,23 @@ function PMA_showPHPDocu($target)
|
||||
} // end of the 'PMA_showPHPDocu()' function
|
||||
|
||||
/**
|
||||
* returns HTML for a footnote marker and add the messsage to the footnotes
|
||||
* Returns HTML code for a tooltip
|
||||
*
|
||||
* @param string $message the error message
|
||||
* @param bool $bbcode whether to interpret BB code
|
||||
* @param string $type message types
|
||||
* @param string $message the message for the tooltip
|
||||
*
|
||||
* @return string html code for a footnote marker
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PMA_showHint($message, $bbcode = false, $type = 'notice')
|
||||
function PMA_showHint($message)
|
||||
{
|
||||
if ($message instanceof PMA_Message) {
|
||||
$key = $message->getHash();
|
||||
$type = $message->getLevel();
|
||||
} else {
|
||||
$key = md5($message);
|
||||
}
|
||||
|
||||
if (! isset($GLOBALS['footnotes'][$key])) {
|
||||
if (empty($GLOBALS['footnotes']) || ! is_array($GLOBALS['footnotes'])) {
|
||||
$GLOBALS['footnotes'] = array();
|
||||
}
|
||||
$nr = count($GLOBALS['footnotes']) + 1;
|
||||
$GLOBALS['footnotes'][$key] = array(
|
||||
'note' => $message,
|
||||
'type' => $type,
|
||||
'nr' => $nr,
|
||||
);
|
||||
} else {
|
||||
$nr = $GLOBALS['footnotes'][$key]['nr'];
|
||||
}
|
||||
|
||||
if ($bbcode) {
|
||||
return '[sup]' . $nr . '[/sup]';
|
||||
}
|
||||
|
||||
// footnotemarker used in js/tooltip.js
|
||||
return '<sup class="footnotemarker">' . $nr . '</sup>'
|
||||
. PMA_getImage(
|
||||
'b_help.png', '',
|
||||
array('class' => 'footnotemarker footnote_' . $nr)
|
||||
);
|
||||
$retval = '<span class="pma_hint">';
|
||||
$retval .= PMA_getImage('b_help.png');
|
||||
$retval .= '<span class="hide">';
|
||||
$retval .= $message;
|
||||
$retval .= '</span>';
|
||||
$retval .= '</span>';
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -595,11 +569,6 @@ function PMA_mysqlDie(
|
||||
) {
|
||||
global $table, $db;
|
||||
|
||||
/**
|
||||
* start http output, display html headers
|
||||
*/
|
||||
include_once './libraries/header.inc.php';
|
||||
|
||||
$error_msg = '';
|
||||
|
||||
if (! $error_message) {
|
||||
@@ -683,10 +652,10 @@ function PMA_mysqlDie(
|
||||
// modified to show the help on error-returns
|
||||
// (now error-messages-server)
|
||||
$error_msg .= '<p>' . "\n"
|
||||
. ' <strong>' . __('MySQL said: ') . '</strong>'
|
||||
. PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server')
|
||||
. "\n"
|
||||
. '</p>' . "\n";
|
||||
. ' <strong>' . __('MySQL said: ') . '</strong>'
|
||||
. PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server')
|
||||
. "\n"
|
||||
. '</p>' . "\n";
|
||||
|
||||
// The error message will be displayed within a CODE segment.
|
||||
// To preserve original formatting, but allow wordwrapping,
|
||||
@@ -710,10 +679,13 @@ function PMA_mysqlDie(
|
||||
/**
|
||||
* If in an Ajax request
|
||||
* - avoid displaying a Back link
|
||||
* - use PMA_ajaxResponse() to transmit the message and exit
|
||||
* - use PMA_Response() to transmit the message and exit
|
||||
*/
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
PMA_ajaxResponse($error_msg, false);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess(false);
|
||||
$response->addJSON('message', $error_msg);
|
||||
exit;
|
||||
}
|
||||
if (! empty($back_url)) {
|
||||
if (strstr($back_url, '?')) {
|
||||
@@ -730,10 +702,7 @@ function PMA_mysqlDie(
|
||||
}
|
||||
|
||||
echo $error_msg;
|
||||
/**
|
||||
* display footer and exit
|
||||
*/
|
||||
include './libraries/footer.inc.php';
|
||||
exit;
|
||||
} else {
|
||||
echo $error_msg;
|
||||
}
|
||||
@@ -812,7 +781,8 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0,
|
||||
$group_name_full = '';
|
||||
$parts_cnt = count($parts) - 1;
|
||||
while ($i < $parts_cnt
|
||||
&& $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
|
||||
&& $i < $GLOBALS['cfg']['LeftFrameTableLevel']
|
||||
) {
|
||||
$group_name = $parts[$i] . $sep;
|
||||
$group_name_full .= $group_name;
|
||||
|
||||
@@ -938,8 +908,9 @@ function PMA_whichCrlf()
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PMA_reloadNavigation($jsonly = false)
|
||||
function PMA_getReloadNavigationScript($jsonly = false)
|
||||
{
|
||||
$retval = '';
|
||||
// Reloads the navigation frame via JavaScript if required
|
||||
if (isset($GLOBALS['reload']) && $GLOBALS['reload']) {
|
||||
// one of the reasons for a reload is when a table is dropped
|
||||
@@ -947,28 +918,29 @@ function PMA_reloadNavigation($jsonly = false)
|
||||
// we have a problem when dropping a table on the last page
|
||||
// and the offset becomes greater than the total number of tables
|
||||
unset($_SESSION['tmp_user_values']['table_limit_offset']);
|
||||
echo "\n";
|
||||
$reload_url = './navigation.php?' . PMA_generate_common_url(
|
||||
$GLOBALS['db'],
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
if (! $jsonly) {
|
||||
echo '<script type="text/javascript">' . PHP_EOL;
|
||||
$retval .= '<script type="text/javascript">' . PHP_EOL;
|
||||
}
|
||||
echo '//<![CDATA[' . PHP_EOL;
|
||||
echo 'if (typeof(window.parent) != "undefined"' . PHP_EOL;
|
||||
echo ' && typeof(window.parent.frame_navigation) != "undefined"' . PHP_EOL;
|
||||
echo ' && window.parent.goTo) {' . PHP_EOL;
|
||||
echo ' window.parent.goTo("' . $reload_url . '");' . PHP_EOL;
|
||||
echo '}' . PHP_EOL;
|
||||
echo '//]]>' . PHP_EOL;
|
||||
$retval .= '//<![CDATA[' . PHP_EOL;
|
||||
$retval .= 'if (typeof(window.parent) != "undefined"' . PHP_EOL;
|
||||
$retval .= ' && typeof(window.parent.frame_navigation) != "undefined"'
|
||||
. PHP_EOL;
|
||||
$retval .= ' && window.parent.goTo) {' . PHP_EOL;
|
||||
$retval .= ' window.parent.goTo("' . $reload_url . '");' . PHP_EOL;
|
||||
$retval .= '}' . PHP_EOL;
|
||||
$retval .= '//]]>' . PHP_EOL;
|
||||
if (! $jsonly) {
|
||||
echo '</script>' . PHP_EOL;
|
||||
$retval .= '</script>' . PHP_EOL;
|
||||
}
|
||||
|
||||
unset($GLOBALS['reload']);
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1076,7 +1048,8 @@ function PMA_getMessage(
|
||||
$query_too_big = true;
|
||||
$shortened_query_base = nl2br(
|
||||
htmlspecialchars(
|
||||
substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]'
|
||||
substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL'])
|
||||
. '[...]'
|
||||
)
|
||||
);
|
||||
} elseif (! empty($GLOBALS['parsed_sql'])
|
||||
@@ -1106,8 +1079,10 @@ function PMA_getMessage(
|
||||
// Need to reparse query
|
||||
$parsed_sql = PMA_SQP_parse($query_base);
|
||||
// update the $analyzed_display_query
|
||||
$analyzed_display_query[0]['section_before_limit'] .= $GLOBALS['sql_order_to_append'];
|
||||
$analyzed_display_query[0]['order_by_clause'] = $GLOBALS['sorted_col'];
|
||||
$analyzed_display_query[0]['section_before_limit']
|
||||
.= $GLOBALS['sql_order_to_append'];
|
||||
$analyzed_display_query[0]['order_by_clause']
|
||||
= $GLOBALS['sorted_col'];
|
||||
}
|
||||
|
||||
// Here we append the LIMIT added for navigation, to
|
||||
@@ -1139,7 +1114,9 @@ function PMA_getMessage(
|
||||
try {
|
||||
$query_base = PMA_validateSQL($query_base);
|
||||
} catch (Exception $e) {
|
||||
$retval .= PMA_Message::error(__('Failed to connect to SQL validator!'))->getDisplay();
|
||||
$retval .= PMA_Message::error(
|
||||
__('Failed to connect to SQL validator!')
|
||||
)->getDisplay();
|
||||
}
|
||||
} elseif (isset($parsed_sql)) {
|
||||
$query_base = PMA_formatSql($parsed_sql, $query_base);
|
||||
@@ -1182,13 +1159,17 @@ function PMA_getMessage(
|
||||
$explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
|
||||
$_message = __('Explain SQL');
|
||||
$is_select = true;
|
||||
} elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) {
|
||||
} elseif (
|
||||
preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)
|
||||
) {
|
||||
$explain_params['sql_query'] = substr($sql_query, 8);
|
||||
$_message = __('Skip Explain SQL');
|
||||
}
|
||||
if (isset($explain_params['sql_query'])) {
|
||||
$explain_link = 'import.php' . PMA_generate_common_url($explain_params);
|
||||
$explain_link = ' [' . PMA_linkOrButton($explain_link, $_message) . ']';
|
||||
$explain_link = 'import.php'
|
||||
. PMA_generate_common_url($explain_params);
|
||||
$explain_link = ' ['
|
||||
. PMA_linkOrButton($explain_link, $_message) . ']';
|
||||
}
|
||||
} //show explain
|
||||
|
||||
@@ -1232,7 +1213,8 @@ function PMA_getMessage(
|
||||
|
||||
if (isset($GLOBALS['show_as_php'])) {
|
||||
$runquery_link = 'import.php' . PMA_generate_common_url($url_params);
|
||||
$php_link .= ' [' . PMA_linkOrButton($runquery_link, __('Submit Query')) . ']';
|
||||
$php_link .= ' ['
|
||||
. PMA_linkOrButton($runquery_link, __('Submit Query')) . ']';
|
||||
}
|
||||
} else {
|
||||
$php_link = '';
|
||||
@@ -1244,7 +1226,8 @@ function PMA_getMessage(
|
||||
&& preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)
|
||||
) {
|
||||
$refresh_link = 'import.php' . PMA_generate_common_url($url_params);
|
||||
$refresh_link = ' [' . PMA_linkOrButton($refresh_link, __('Refresh')) . ']';
|
||||
$refresh_link = ' ['
|
||||
. PMA_linkOrButton($refresh_link, __('Refresh')) . ']';
|
||||
} else {
|
||||
$refresh_link = '';
|
||||
} //refresh
|
||||
@@ -1260,8 +1243,10 @@ function PMA_getMessage(
|
||||
$validate_message = __('Validate SQL');
|
||||
}
|
||||
|
||||
$validate_link = 'import.php' . PMA_generate_common_url($validate_params);
|
||||
$validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']';
|
||||
$validate_link = 'import.php'
|
||||
. PMA_generate_common_url($validate_params);
|
||||
$validate_link = ' ['
|
||||
. PMA_linkOrButton($validate_link, $validate_message) . ']';
|
||||
} else {
|
||||
$validate_link = '';
|
||||
} //validator
|
||||
@@ -1298,7 +1283,9 @@ function PMA_getMessage(
|
||||
// depend on the profiling support or on the refresh link
|
||||
if (empty($refresh_link) || ! PMA_profilingSupported()) {
|
||||
$retval .= '<form action="sql.php" method="post">';
|
||||
$retval .= PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']);
|
||||
$retval .= PMA_generate_common_hidden_inputs(
|
||||
$GLOBALS['db'], $GLOBALS['table']
|
||||
);
|
||||
$retval .= '<input type="hidden" name="sql_query" value="'
|
||||
. htmlspecialchars($sql_query) . '" />';
|
||||
$retval .= '</form>';
|
||||
@@ -1323,7 +1310,8 @@ function PMA_getMessage(
|
||||
"//]]>\n" .
|
||||
"</script>";
|
||||
}
|
||||
$retval .= $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
|
||||
$retval .= $edit_link . $explain_link . $php_link
|
||||
. $refresh_link . $validate_link;
|
||||
$retval .= '</div>';
|
||||
}
|
||||
$retval .= '</div>';
|
||||
@@ -1332,7 +1320,7 @@ function PMA_getMessage(
|
||||
}
|
||||
|
||||
return $retval;
|
||||
|
||||
|
||||
} // end of the 'PMA_getMessage()' function
|
||||
|
||||
/**
|
||||
@@ -1376,10 +1364,15 @@ function PMA_getProfilingForm($sql_query)
|
||||
if (PMA_profilingSupported()) {
|
||||
|
||||
$retval .= '<form action="sql.php" method="post">' . "\n";
|
||||
$retval .= PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']);
|
||||
$retval .= '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
|
||||
$retval .= PMA_generate_common_hidden_inputs(
|
||||
$GLOBALS['db'], $GLOBALS['table']
|
||||
);
|
||||
$retval .= '<input type="hidden" name="sql_query" value="'
|
||||
. htmlspecialchars($sql_query) . '" />' . "\n";
|
||||
$retval .= '<input type="hidden" name="profiling_form" value="1" />' . "\n";
|
||||
$retval .= PMA_getCheckbox('profiling', __('Profiling'), isset($_SESSION['profiling']), true);
|
||||
$retval .= PMA_getCheckbox(
|
||||
'profiling', __('Profiling'), isset($_SESSION['profiling']), true
|
||||
);
|
||||
$retval .= ' </form>' . "\n";
|
||||
|
||||
}
|
||||
@@ -1955,17 +1948,17 @@ function PMA_linkOrButton($url, $message, $tag_params = array(),
|
||||
function PMA_splitURLQuery($url)
|
||||
{
|
||||
// decode encoded url separators
|
||||
$separator = PMA_get_arg_separator();
|
||||
$separator = PMA_get_arg_separator();
|
||||
// on most places separator is still hard coded ...
|
||||
if ($separator !== '&') {
|
||||
// ... so always replace & with $separator
|
||||
$url = str_replace(htmlentities('&'), $separator, $url);
|
||||
$url = str_replace('&', $separator, $url);
|
||||
$url = str_replace(htmlentities('&'), $separator, $url);
|
||||
$url = str_replace('&', $separator, $url);
|
||||
}
|
||||
$url = str_replace(htmlentities($separator), $separator, $url);
|
||||
$url = str_replace(htmlentities($separator), $separator, $url);
|
||||
// end decode
|
||||
|
||||
$url_parts = parse_url($url);
|
||||
$url_parts = parse_url($url);
|
||||
return explode($separator, $url_parts['query']);
|
||||
}
|
||||
|
||||
@@ -2131,7 +2124,9 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row,
|
||||
if (isset($GLOBALS['analyzed_sql'][0]['select_expr'])
|
||||
&& is_array($GLOBALS['analyzed_sql'][0]['select_expr'])
|
||||
) {
|
||||
foreach ($GLOBALS['analyzed_sql'][0]['select_expr'] as $select_expr) {
|
||||
foreach (
|
||||
$GLOBALS['analyzed_sql'][0]['select_expr'] as $select_expr
|
||||
) {
|
||||
// need (string) === (string)
|
||||
// '' !== 0 but '' == 0
|
||||
if ((string) $select_expr['alias'] === (string) $meta->name) {
|
||||
@@ -2207,7 +2202,8 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row,
|
||||
$condition = '';
|
||||
}
|
||||
} elseif ($meta->type == 'bit') {
|
||||
$con_val = "= b'" . PMA_printableBitValue($row[$i], $meta->length) . "'";
|
||||
$con_val = "= b'"
|
||||
. PMA_printableBitValue($row[$i], $meta->length) . "'";
|
||||
} else {
|
||||
$con_val = '= \'' . PMA_sqlAddSlashes($row[$i], false, true) . '\'';
|
||||
}
|
||||
@@ -2460,7 +2456,8 @@ function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_cou
|
||||
$caption1 = '<<';
|
||||
$caption2 = ' < ';
|
||||
$title1 = ' title="' . _pgettext('First page', 'Begin') . '"';
|
||||
$title2 = ' title="' . _pgettext('Previous page', 'Previous') . '"';
|
||||
$title2 = ' title="'
|
||||
. _pgettext('Previous page', 'Previous') . '"';
|
||||
} else {
|
||||
$caption1 = _pgettext('First page', 'Begin') . ' <<';
|
||||
$caption2 = _pgettext('Previous page', 'Previous') . ' <';
|
||||
@@ -2477,7 +2474,8 @@ function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_cou
|
||||
. $frame . '">' . $caption2 . '</a>';
|
||||
}
|
||||
|
||||
echo "\n", '<form action="', basename($script), '" method="post" target="', $frame, '">', "\n";
|
||||
echo "\n", '<form action="', basename($script),
|
||||
'" method="post" target="', $frame, '">', "\n";
|
||||
echo PMA_generate_common_hidden_inputs($_url_params);
|
||||
echo PMA_pageselector(
|
||||
$max_count,
|
||||
@@ -2626,22 +2624,25 @@ function PMA_getCheckbox($html_field_name, $label, $checked, $onclick)
|
||||
function PMA_getRadioFields($html_field_name, $choices, $checked_choice = '',
|
||||
$line_break = true, $escape_label = true, $class=''
|
||||
) {
|
||||
|
||||
|
||||
$radio_html = '';
|
||||
|
||||
|
||||
foreach ($choices as $choice_value => $choice_label) {
|
||||
if (! empty($class)) {
|
||||
$radio_html .= '<div class="' . $class . '">';
|
||||
}
|
||||
$html_field_id = $html_field_name . '_' . $choice_value;
|
||||
$radio_html .= '<input type="radio" name="' . $html_field_name . '" id="'
|
||||
. $html_field_id . '" value="' . htmlspecialchars($choice_value) . '"';
|
||||
. $html_field_id . '" value="'
|
||||
. htmlspecialchars($choice_value) . '"';
|
||||
if ($choice_value == $checked_choice) {
|
||||
$radio_html .= ' checked="checked"';
|
||||
}
|
||||
$radio_html .= ' />' . "\n"
|
||||
. '<label for="' . $html_field_id . '">'
|
||||
. ($escape_label ? htmlspecialchars($choice_label) : $choice_label)
|
||||
. ($escape_label
|
||||
? htmlspecialchars($choice_label)
|
||||
: $choice_label)
|
||||
. '</label>';
|
||||
if ($line_break) {
|
||||
$radio_html .= '<br />';
|
||||
@@ -2651,9 +2652,9 @@ function PMA_getRadioFields($html_field_name, $choices, $checked_choice = '',
|
||||
}
|
||||
$radio_html .= "\n";
|
||||
}
|
||||
|
||||
|
||||
return $radio_html;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2693,9 +2694,9 @@ function PMA_getDropdown($select_name, $choices, $active_choice, $id)
|
||||
*
|
||||
* @param string $id the id of the <div> on which to apply the effect
|
||||
* @param string $message the message to show as a link
|
||||
*
|
||||
*
|
||||
* @return string html div element
|
||||
*
|
||||
*
|
||||
*/
|
||||
function PMA_getDivForSliderEffect($id, $message)
|
||||
{
|
||||
@@ -2710,7 +2711,7 @@ function PMA_getDivForSliderEffect($id, $message)
|
||||
* method maybe by using an additional param, the id of the div to
|
||||
* append to
|
||||
*/
|
||||
|
||||
|
||||
return '<div id="' . $id . '"'
|
||||
. (($GLOBALS['cfg']['InitialSlidersState'] == 'closed')
|
||||
? ' style="display: none; overflow:auto;"'
|
||||
@@ -2748,7 +2749,8 @@ function PMA_toggleButton($action, $select_name, $options, $callback)
|
||||
$retval = "<!-- TOGGLE START -->\n";
|
||||
$retval .= "<div class='wrapper toggleAjax hide'>\n";
|
||||
$retval .= " <div class='toggleButton'>\n";
|
||||
$retval .= " <div title='" . __('Click to toggle') . "' class='container $state'>\n";
|
||||
$retval .= " <div title='" . __('Click to toggle');
|
||||
$retval .= "' class='container $state'>\n";
|
||||
$retval .= " <img src='" . htmlspecialchars($GLOBALS['pmaThemeImage']);
|
||||
$retval .= "toggle-" . htmlspecialchars($GLOBALS['text_dir']) . ".png'\n";
|
||||
$retval .= " alt='' />\n";
|
||||
@@ -2758,15 +2760,15 @@ function PMA_toggleButton($action, $select_name, $options, $callback)
|
||||
$retval .= " <td class='toggleOn'>\n";
|
||||
$retval .= " <span class='hide'>$link_on</span>\n";
|
||||
$retval .= " <div>";
|
||||
$retval .= str_replace(' ', ' ', htmlspecialchars($options[1]['label'])) . "\n";
|
||||
$retval .= " </div>\n";
|
||||
$retval .= str_replace(' ', ' ', htmlspecialchars($options[1]['label']));
|
||||
$retval .= "\n" . " </div>\n";
|
||||
$retval .= " </td>\n";
|
||||
$retval .= " <td><div> </div></td>\n";
|
||||
$retval .= " <td class='toggleOff'>\n";
|
||||
$retval .= " <span class='hide'>$link_off</span>\n";
|
||||
$retval .= " <div>";
|
||||
$retval .= str_replace(' ', ' ', htmlspecialchars($options[0]['label'])) . "\n";
|
||||
$retval .= " </div>\n";
|
||||
$retval .= str_replace(' ', ' ', htmlspecialchars($options[0]['label']));
|
||||
$retval .= "\n" . " </div>\n";
|
||||
$retval .= " </tr>\n";
|
||||
$retval .= " </tbody>\n";
|
||||
$retval .= " </table>\n";
|
||||
@@ -2985,7 +2987,8 @@ function PMA_extractColumnSpec($columnspec)
|
||||
// Increment character index
|
||||
$index++;
|
||||
} // end while
|
||||
$printtype = $type . '(' . str_replace("','", "', '", $spec_in_brackets) . ')';
|
||||
$printtype = $type
|
||||
. '(' . str_replace("','", "', '", $spec_in_brackets) . ')';
|
||||
$binary = false;
|
||||
$unsigned = false;
|
||||
$zerofill = false;
|
||||
@@ -2999,7 +3002,9 @@ function PMA_extractColumnSpec($columnspec)
|
||||
// this would be a BINARY or VARBINARY column type;
|
||||
// by the way, a BLOB should not show the BINARY attribute
|
||||
// because this is not accepted in MySQL syntax.
|
||||
if (preg_match('@binary@', $printtype) && ! preg_match('@binary[\(]@', $printtype)) {
|
||||
if (preg_match('@binary@', $printtype)
|
||||
&& ! preg_match('@binary[\(]@', $printtype)
|
||||
) {
|
||||
$printtype = preg_replace('@binary@', '', $printtype);
|
||||
$binary = true;
|
||||
} else {
|
||||
@@ -3026,7 +3031,9 @@ function PMA_extractColumnSpec($columnspec)
|
||||
|
||||
$can_contain_collation = false;
|
||||
if (! $binary
|
||||
&& preg_match("@^(char|varchar|text|tinytext|mediumtext|longtext|set|enum)@", $type)
|
||||
&& preg_match(
|
||||
"@^(char|varchar|text|tinytext|mediumtext|longtext|set|enum)@", $type
|
||||
)
|
||||
) {
|
||||
$can_contain_collation = true;
|
||||
}
|
||||
@@ -3126,7 +3133,7 @@ function PMA_duplicateFirstNewline($string)
|
||||
{
|
||||
$first_occurence = strpos($string, "\r\n");
|
||||
if ($first_occurence === 0) {
|
||||
$string = "\n".$string;
|
||||
$string = "\n" . $string;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
@@ -3240,61 +3247,6 @@ function PMA_expandUserString($string, $escape = null, $updates = array())
|
||||
return strtr(strftime($string), $replace);
|
||||
}
|
||||
|
||||
/**
|
||||
* function that generates a json output for an ajax request and ends script
|
||||
* execution
|
||||
*
|
||||
* @param PMA_Message|string $message message string containing the
|
||||
* html of the message
|
||||
* @param bool $success success whether the ajax request
|
||||
* was successfull
|
||||
* @param array $extra_data extra data optional - any other data
|
||||
* as part of the json request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_ajaxResponse($message, $success = true, $extra_data = array())
|
||||
{
|
||||
$response = array();
|
||||
if ( $success == true ) {
|
||||
$response['success'] = true;
|
||||
if ($message instanceof PMA_Message) {
|
||||
$response['message'] = $message->getDisplay();
|
||||
} else {
|
||||
$response['message'] = $message;
|
||||
}
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
if ($message instanceof PMA_Message) {
|
||||
$response['error'] = $message->getDisplay();
|
||||
} else {
|
||||
$response['error'] = $message;
|
||||
}
|
||||
}
|
||||
|
||||
// If extra_data has been provided, append it to the response array
|
||||
if ( ! empty($extra_data) && count($extra_data) > 0 ) {
|
||||
$response = array_merge($response, $extra_data);
|
||||
}
|
||||
|
||||
// Set the Content-Type header to JSON so that jQuery parses the
|
||||
// response correctly.
|
||||
//
|
||||
// At this point, other headers might have been sent;
|
||||
// even if $GLOBALS['is_header_sent'] is true,
|
||||
// we have to send these additional headers.
|
||||
if (! defined('TESTSUITE')) {
|
||||
header('Cache-Control: no-cache');
|
||||
header("Content-Type: application/json");
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
if (! defined('TESTSUITE')) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form used to browse anywhere on the local server for a file to
|
||||
* import
|
||||
@@ -3346,7 +3298,8 @@ function PMA_selectUploadFile($import_list, $uploaddir)
|
||||
$matcher = '@\.(' . $extensions . ')(\.('
|
||||
. PMA_supportedDecompressions() . '))?$@';
|
||||
|
||||
$active = (isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed'] && isset($local_import_file))
|
||||
$active = (isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed']
|
||||
&& isset($local_import_file))
|
||||
? $local_import_file
|
||||
: '';
|
||||
$files = PMA_getFileSelectOptions(
|
||||
@@ -3360,7 +3313,8 @@ function PMA_selectUploadFile($import_list, $uploaddir)
|
||||
)->display();
|
||||
} elseif (! empty($files)) {
|
||||
echo "\n";
|
||||
echo ' <select style="margin: 5px" size="1" name="local_import_file" id="select_local_import_file">' . "\n";
|
||||
echo ' <select style="margin: 5px" size="1" name="local_import_file" '
|
||||
.'id="select_local_import_file">' . "\n";
|
||||
echo ' <option value=""> </option>' . "\n";
|
||||
echo $files;
|
||||
echo ' </select>' . "\n";
|
||||
@@ -3509,7 +3463,6 @@ function PMA_getGISDatatypes($upper_case = false)
|
||||
$gis_data_types[$i] = strtoupper($gis_data_types[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
return $gis_data_types;
|
||||
}
|
||||
|
||||
@@ -3522,7 +3475,7 @@ function PMA_getGISDatatypes($upper_case = false)
|
||||
*/
|
||||
function PMA_createGISData($gis_string)
|
||||
{
|
||||
$gis_string = trim($gis_string);
|
||||
$gis_string = trim($gis_string);
|
||||
$geom_types = '(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING|'
|
||||
. 'POLYGON|MULTIPOLYGON|GEOMETRYCOLLECTION)';
|
||||
if (preg_match("/^'" . $geom_types . "\(.*\)',[0-9]*$/i", $gis_string)) {
|
||||
@@ -3672,17 +3625,20 @@ function PMA_getDefaultFunctionForField($field, $insert_mode)
|
||||
$default_function = $cfg['DefaultFunctions']['FUNC_' . $current_class];
|
||||
}
|
||||
}
|
||||
|
||||
$analyzed_sql_field_array = $analyzed_sql[0]['create_table_fields']
|
||||
[$field['Field']];
|
||||
// what function defined as default?
|
||||
// for the first timestamp we don't set the default function
|
||||
// if there is a default value for the timestamp
|
||||
// (not including CURRENT_TIMESTAMP)
|
||||
// and the column does not have the
|
||||
// ON UPDATE DEFAULT TIMESTAMP attribute.
|
||||
if ($field['True_Type'] == 'timestamp'
|
||||
if (($field['True_Type'] == 'timestamp')
|
||||
&& empty($field['Default'])
|
||||
&& empty($data)
|
||||
&& ! isset($analyzed_sql[0]['create_table_fields'][$field['Field']]['on_update_current_timestamp'])
|
||||
&& $analyzed_sql[0]['create_table_fields'][$field['Field']]['default_value'] != 'NULL'
|
||||
&& ! isset($analyzed_sql_field_array['on_update_current_timestamp'])
|
||||
&& ($analyzed_sql_field_array['default_value'] != 'NULL')
|
||||
) {
|
||||
$default_function = $cfg['DefaultFunctions']['first_timestamp'];
|
||||
}
|
||||
@@ -3797,15 +3753,15 @@ function PMA_currentUserHasPrivilege($priv, $db = null, $tbl = null)
|
||||
$query = "SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.`%s` "
|
||||
. "WHERE GRANTEE='%s' AND PRIVILEGE_TYPE='%s'";
|
||||
// Check global privileges first.
|
||||
if (PMA_DBI_fetch_value(
|
||||
$user_privileges = PMA_DBI_fetch_value(
|
||||
sprintf(
|
||||
$query,
|
||||
'USER_PRIVILEGES',
|
||||
$username,
|
||||
$priv
|
||||
)
|
||||
)
|
||||
) {
|
||||
);
|
||||
if ($user_privileges) {
|
||||
return true;
|
||||
}
|
||||
// If a database name was provided and user does not have the
|
||||
@@ -3814,7 +3770,7 @@ function PMA_currentUserHasPrivilege($priv, $db = null, $tbl = null)
|
||||
// need to escape wildcards in db and table names, see bug #3518484
|
||||
$db = str_replace(array('%', '_'), array('\%', '\_'), $db);
|
||||
$query .= " AND TABLE_SCHEMA='%s'";
|
||||
if (PMA_DBI_fetch_value(
|
||||
$schema_privileges = PMA_DBI_fetch_value(
|
||||
sprintf(
|
||||
$query,
|
||||
'SCHEMA_PRIVILEGES',
|
||||
@@ -3822,8 +3778,8 @@ function PMA_currentUserHasPrivilege($priv, $db = null, $tbl = null)
|
||||
$priv,
|
||||
PMA_sqlAddSlashes($db)
|
||||
)
|
||||
)
|
||||
) {
|
||||
);
|
||||
if ($schema_privileges) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
@@ -3837,7 +3793,7 @@ function PMA_currentUserHasPrivilege($priv, $db = null, $tbl = null)
|
||||
// need to escape wildcards in db and table names, see bug #3518484
|
||||
$tbl = str_replace(array('%', '_'), array('\%', '\_'), $tbl);
|
||||
$query .= " AND TABLE_NAME='%s'";
|
||||
if (PMA_DBI_fetch_value(
|
||||
$table_privileges = PMA_DBI_fetch_value(
|
||||
sprintf(
|
||||
$query,
|
||||
'TABLE_PRIVILEGES',
|
||||
@@ -3846,8 +3802,8 @@ function PMA_currentUserHasPrivilege($priv, $db = null, $tbl = null)
|
||||
PMA_sqlAddSlashes($db),
|
||||
PMA_sqlAddSlashes($tbl)
|
||||
)
|
||||
)
|
||||
) {
|
||||
);
|
||||
if ($table_privileges) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3904,4 +3860,48 @@ function PMA_printButton()
|
||||
. __('Print') . '" />';
|
||||
echo '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses ENUM/SET values
|
||||
*
|
||||
* @param string $definition The definition of the column
|
||||
* for which to parse the values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_parseEnumSetValues($definition)
|
||||
{
|
||||
$values_string = htmlentities($definition);
|
||||
// There is a JS port of the below parser in functions.js
|
||||
// If you are fixing something here,
|
||||
// you need to also update the JS port.
|
||||
$values = array();
|
||||
$in_string = false;
|
||||
$buffer = '';
|
||||
for ($i=0; $i<strlen($values_string); $i++) {
|
||||
$curr = $values_string[$i];
|
||||
$next = $i == strlen($values_string)-1 ? '' : $values_string[$i+1];
|
||||
if (! $in_string && $curr == "'") {
|
||||
$in_string = true;
|
||||
} else if ($in_string && $curr == "\\" && $next == "\\") {
|
||||
$buffer .= "\";
|
||||
$i++;
|
||||
} else if ($in_string && $next == "'" && ($curr == "'" || $curr == "\\")) {
|
||||
$buffer .= "'";
|
||||
$i++;
|
||||
} else if ($in_string && $curr == "'") {
|
||||
$in_string = false;
|
||||
$values[] = $buffer;
|
||||
$buffer = '';
|
||||
} else if ($in_string) {
|
||||
$buffer .= $curr;
|
||||
}
|
||||
}
|
||||
if (strlen($buffer) > 0) {
|
||||
// The leftovers in the buffer are the last value (if any)
|
||||
$values[] = $buffer;
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -518,9 +518,9 @@ $cfg['Servers'][$i]['tracking_add_drop_table'] = true;
|
||||
$cfg['Servers'][$i]['tracking_add_drop_database'] = true;
|
||||
|
||||
/**
|
||||
* Enables caching of TABLE STATUS outputs for specific databases on this server
|
||||
* (in some cases TABLE STATUS can be very slow, so you may want to cache it).
|
||||
* APC is used (if the PHP extension is available, if not, this setting is ignored
|
||||
* Enables caching of TABLE STATUS outputs for specific databases on this server
|
||||
* (in some cases TABLE STATUS can be very slow, so you may want to cache it).
|
||||
* APC is used (if the PHP extension is available, if not, this setting is ignored
|
||||
* silently). You have to provide StatusCacheLifetime.
|
||||
* Takes effect only if DisableIS is true.
|
||||
*
|
||||
|
||||
@@ -91,7 +91,7 @@ class ConfigFile
|
||||
// apply default values overrides
|
||||
if (count($cfg_db['_overrides'])) {
|
||||
foreach ($cfg_db['_overrides'] as $path => $value) {
|
||||
PMA_array_write($path, $cfg, $value);
|
||||
PMA_arrayWrite($path, $cfg, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ class ConfigFile
|
||||
// we need original config values not overwritten by user
|
||||
// preferences to allow for overwriting options set in
|
||||
// config.inc.php with default values
|
||||
$instance_default_value = PMA_array_read(
|
||||
$instance_default_value = PMA_arrayRead(
|
||||
$canonical_path,
|
||||
$this->_orgCfgObject->settings
|
||||
);
|
||||
@@ -240,11 +240,11 @@ class ConfigFile
|
||||
|| (empty($value) && empty($default_value) && (defined('PMA_SETUP')
|
||||
|| empty($current_global)))
|
||||
) {
|
||||
PMA_array_remove($path, $_SESSION[$this->_id]);
|
||||
PMA_arrayRemove($path, $_SESSION[$this->_id]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
PMA_array_write($path, $_SESSION[$this->_id], $value);
|
||||
PMA_arrayWrite($path, $_SESSION[$this->_id], $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +320,7 @@ class ConfigFile
|
||||
*/
|
||||
public function get($path, $default = null)
|
||||
{
|
||||
return PMA_array_read($path, $_SESSION[$this->_id], $default);
|
||||
return PMA_arrayRead($path, $_SESSION[$this->_id], $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,7 +335,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getDefault($canonical_path, $default = null)
|
||||
{
|
||||
return PMA_array_read($canonical_path, $this->_cfg, $default);
|
||||
return PMA_arrayRead($canonical_path, $this->_cfg, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,7 +349,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getValue($path, $default = null)
|
||||
{
|
||||
$v = PMA_array_read($path, $_SESSION[$this->_id], null);
|
||||
$v = PMA_arrayRead($path, $_SESSION[$this->_id], null);
|
||||
if ($v !== null) {
|
||||
return $v;
|
||||
}
|
||||
@@ -379,7 +379,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getDbEntry($path, $default = null)
|
||||
{
|
||||
return PMA_array_read($path, $this->_cfgDb, $default);
|
||||
return PMA_arrayRead($path, $this->_cfgDb, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,8 +511,8 @@ class ConfigFile
|
||||
{
|
||||
$c = $_SESSION[$this->_id];
|
||||
foreach ($this->_cfgUpdateReadMapping as $map_to => $map_from) {
|
||||
PMA_array_write($map_to, $c, PMA_array_read($map_from, $c));
|
||||
PMA_array_remove($map_from, $c);
|
||||
PMA_arrayWrite($map_to, $c, PMA_arrayRead($map_from, $c));
|
||||
PMA_arrayRemove($map_from, $c);
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ function PMA_config_get_validators()
|
||||
}
|
||||
for ($i = 1; $i < count($uv); $i++) {
|
||||
if (substr($uv[$i], 0, 6) == 'value:') {
|
||||
$uv[$i] = PMA_array_read(
|
||||
$uv[$i] = PMA_arrayRead(
|
||||
substr($uv[$i], 6), $org_cfg->settings
|
||||
);
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ function PMA_getTableCount($db)
|
||||
*
|
||||
* @return integer $size
|
||||
*/
|
||||
function PMA_get_real_size($size = 0)
|
||||
function PMA_getRealSize($size = 0)
|
||||
{
|
||||
if (! $size) {
|
||||
return 0;
|
||||
@@ -347,13 +347,13 @@ function PMA_get_real_size($size = 0)
|
||||
}
|
||||
|
||||
return $size;
|
||||
} // end function PMA_get_real_size()
|
||||
} // end function PMA_getRealSize()
|
||||
|
||||
/**
|
||||
* merges array recursive like array_merge_recursive() but keyed-values are
|
||||
* always overwritten.
|
||||
*
|
||||
* array PMA_array_merge_recursive(array $array1[, array $array2[, array ...]])
|
||||
* array PMA_arrayMergeRecursive(array $array1[, array $array2[, array ...]])
|
||||
*
|
||||
* @param array array to merge
|
||||
* @param array array to merge
|
||||
@@ -364,7 +364,7 @@ function PMA_get_real_size($size = 0)
|
||||
* @see http://php.net/array_merge
|
||||
* @see http://php.net/array_merge_recursive
|
||||
*/
|
||||
function PMA_array_merge_recursive()
|
||||
function PMA_arrayMergeRecursive()
|
||||
{
|
||||
switch(func_num_args()) {
|
||||
case 0 :
|
||||
@@ -381,7 +381,7 @@ function PMA_array_merge_recursive()
|
||||
}
|
||||
foreach ($args[1] as $key2 => $value2) {
|
||||
if (isset($args[0][$key2]) && !is_int($key2)) {
|
||||
$args[0][$key2] = PMA_array_merge_recursive(
|
||||
$args[0][$key2] = PMA_arrayMergeRecursive(
|
||||
$args[0][$key2], $value2
|
||||
);
|
||||
} else {
|
||||
@@ -401,9 +401,9 @@ function PMA_array_merge_recursive()
|
||||
break;
|
||||
default :
|
||||
$args = func_get_args();
|
||||
$args[1] = PMA_array_merge_recursive($args[0], $args[1]);
|
||||
$args[1] = PMA_arrayMergeRecursive($args[0], $args[1]);
|
||||
array_shift($args);
|
||||
return call_user_func_array('PMA_array_merge_recursive', $args);
|
||||
return call_user_func_array('PMA_arrayMergeRecursive', $args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -515,6 +515,7 @@ function PMA_sendHeaderLocation($uri, $use_refresh = false)
|
||||
{
|
||||
if (PMA_IS_IIS && strlen($uri) > 600) {
|
||||
include_once './libraries/js_escape.lib.php';
|
||||
PMA_Response::getInstance()->disable();
|
||||
|
||||
echo '<html><head><title>- - -</title>' . "\n";
|
||||
echo '<meta http-equiv="expires" content="0">' . "\n";
|
||||
@@ -572,7 +573,7 @@ function PMA_sendHeaderLocation($uri, $use_refresh = false)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_no_cache_header()
|
||||
function PMA_noCacheHeader()
|
||||
{
|
||||
// rfc2616 - Section 14.21
|
||||
header('Expires: ' . date(DATE_RFC1123));
|
||||
@@ -612,10 +613,10 @@ function PMA_no_cache_header()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_download_header($filename, $mimetype, $length = 0, $no_cache = true)
|
||||
function PMA_downloadHeader($filename, $mimetype, $length = 0, $no_cache = true)
|
||||
{
|
||||
if ($no_cache) {
|
||||
PMA_no_cache_header();
|
||||
PMA_noCacheHeader();
|
||||
}
|
||||
/* Replace all possibly dangerous chars in filename */
|
||||
$filename = str_replace(array(';', '"', "\n", "\r"), '-', $filename);
|
||||
@@ -642,7 +643,7 @@ function PMA_download_header($filename, $mimetype, $length = 0, $no_cache = true
|
||||
*
|
||||
* @return mixed array element or $default
|
||||
*/
|
||||
function PMA_array_read($path, $array, $default = null)
|
||||
function PMA_arrayRead($path, $array, $default = null)
|
||||
{
|
||||
$keys = explode('/', $path);
|
||||
$value =& $array;
|
||||
@@ -664,7 +665,7 @@ function PMA_array_read($path, $array, $default = null)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_array_write($path, &$array, $value)
|
||||
function PMA_arrayWrite($path, &$array, $value)
|
||||
{
|
||||
$keys = explode('/', $path);
|
||||
$last_key = array_pop($keys);
|
||||
@@ -686,7 +687,7 @@ function PMA_array_write($path, &$array, $value)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_array_remove($path, &$array)
|
||||
function PMA_arrayRemove($path, &$array)
|
||||
{
|
||||
$keys = explode('/', $path);
|
||||
$keys_last = array_pop($keys);
|
||||
@@ -742,52 +743,24 @@ function PMA_linkURL($url)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML code to include javascript file.
|
||||
*
|
||||
* @param string $url Location of javascript, relative to js/ folder.
|
||||
* @param string $ie_conditional true - wrap with IE conditional comment
|
||||
* 'lt 9' etc. - wrap for specific IE version
|
||||
*
|
||||
* @return string HTML code for javascript inclusion.
|
||||
*/
|
||||
function PMA_includeJS($url, $ie_conditional = false)
|
||||
{
|
||||
$include = '';
|
||||
if ($ie_conditional !== false) {
|
||||
if ($ie_conditional === true) {
|
||||
$include .= '<!--[if IE]>' . "\n ";
|
||||
} else {
|
||||
$include .= '<!--[if IE ' . $ie_conditional . ']>' . "\n ";
|
||||
}
|
||||
}
|
||||
if (strpos($url, '?') === false) {
|
||||
$include .= '<script src="js/' . $url . '?ts=' . filemtime('js/' . $url)
|
||||
. '" type="text/javascript"></script>' . "\n";
|
||||
} else {
|
||||
$include .= '<script src="js/' . $url
|
||||
. '" type="text/javascript"></script>' . "\n";
|
||||
}
|
||||
if ($ie_conditional !== false) {
|
||||
$include .= '<![endif]-->' . "\n";
|
||||
}
|
||||
return $include;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 the PMA_Response class.
|
||||
* Adds a newline to each snippet.
|
||||
*
|
||||
* @param string $str Js code to be added (e.g. "token=1234;")
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_AddJSCode($str)
|
||||
function PMA_addJSCode($str)
|
||||
{
|
||||
$GLOBALS['js_script'][] = $str;
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addCode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds JS code snippet for variable assignment to be displayed by header.inc.php.
|
||||
* Adds JS code snippet for variable assignment
|
||||
* to be displayed by the PMA_Response class.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
@@ -796,9 +769,9 @@ function PMA_AddJSCode($str)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_AddJSVar($key, $value, $escape = true)
|
||||
function PMA_addJSVar($key, $value, $escape = true)
|
||||
{
|
||||
PMA_AddJsCode(PMA_getJsValue($key, $value, $escape));
|
||||
PMA_addJSCode(PMA_getJsValue($key, $value, $escape));
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -72,12 +72,13 @@ if (isset($submitcollation) && !empty($db_collation)) {
|
||||
* other pages, we might have to move this to a different location.
|
||||
*/
|
||||
if ( $GLOBALS['is_ajax_request'] == true) {
|
||||
PMA_ajaxResponse($message, $message->isSuccess());
|
||||
};
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess($message->isSuccess());
|
||||
$response->addJSON('message', $message);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
require_once './libraries/header.inc.php';
|
||||
|
||||
/**
|
||||
* Set parameters for links
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,7 @@ $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5 &&
|
||||
|
||||
// Displays the form
|
||||
?>
|
||||
<form method="post" id="change_password_form" action="<?php echo $GLOBALS['PMA_PHP_SELF']; ?>" name="chgPassword" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'class="ajax" ' : ''); ?> onsubmit="return checkPassword(this)">
|
||||
<form method="post" id="change_password_form" action="<?php echo $GLOBALS['PMA_PHP_SELF']; ?>" name="chgPassword" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'class="ajax" ' : ''); ?>>
|
||||
<?php echo PMA_generate_common_hidden_inputs();
|
||||
if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
|
||||
echo '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
|
||||
|
||||
@@ -38,7 +38,7 @@ $export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $exp
|
||||
/* Fail if we didn't find any plugin */
|
||||
if (empty($export_list)) {
|
||||
PMA_Message::error(__('Could not load export plugins, please check your installation!'))->display();
|
||||
include './libraries/footer.inc.php';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -232,18 +232,18 @@ if (isset($_GET['sql_query'])) {
|
||||
}
|
||||
}
|
||||
|
||||
$message = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
|
||||
$message->addParam(
|
||||
$msg = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
|
||||
$msg->addParam(
|
||||
'<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php'))
|
||||
. '" target="documentation" title="' . __('Documentation') . '">',
|
||||
false
|
||||
);
|
||||
$message->addParam('</a>', false);
|
||||
$message->addParam($trans);
|
||||
$message->addParam('<a href="Documentation.html#faq6_27" target="documentation">', false);
|
||||
$message->addParam('</a>', false);
|
||||
$msg->addParam('</a>', false);
|
||||
$msg->addParam($trans);
|
||||
$msg->addParam('<a href="Documentation.html#faq6_27" target="documentation">', false);
|
||||
$msg->addParam('</a>', false);
|
||||
|
||||
echo PMA_showHint($message);
|
||||
echo PMA_showHint($msg);
|
||||
?>
|
||||
</label>
|
||||
<input type="text" name="filename_template" id="filename_template"
|
||||
|
||||
@@ -17,7 +17,9 @@ if (! defined('PHPMYADMIN')) {
|
||||
function PMA_printGitRevision()
|
||||
{
|
||||
if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
|
||||
PMA_ajaxResponse('', false);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// load revision data from repo
|
||||
@@ -56,7 +58,6 @@ function PMA_printGitRevision()
|
||||
$branch = $commit_hash . ' (' . __('no branch') . ')';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
|
||||
$author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
|
||||
PMA_printListItem(
|
||||
@@ -79,7 +80,4 @@ function PMA_printGitRevision()
|
||||
: ''),
|
||||
'li_pma_version_git', null, null, null
|
||||
);
|
||||
$item = ob_get_contents();
|
||||
ob_end_clean();
|
||||
PMA_ajaxResponse($item, true);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ $import_list = PMA_getPlugins('./libraries/import/', $import_type);
|
||||
/* Fail if we didn't find any plugin */
|
||||
if (empty($import_list)) {
|
||||
PMA_Message::error(__('Could not load import plugins, please check your installation!'))->display();
|
||||
include './libraries/footer.inc.php';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -130,7 +130,7 @@ if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") {
|
||||
<?php
|
||||
// reload the left sidebar when the import is finished
|
||||
$GLOBALS['reload'] = true;
|
||||
PMA_reloadNavigation(true);
|
||||
echo PMA_getReloadNavigationScript(true);
|
||||
?>
|
||||
|
||||
} // if finished
|
||||
|
||||
@@ -393,7 +393,9 @@ function PMA_getTableNavigation($pos_next, $pos_prev, $sql_query,
|
||||
} // end show all
|
||||
|
||||
// Move to the next page or to the last one
|
||||
$endpos = $_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'];
|
||||
$endpos = $_SESSION['tmp_user_values']['pos']
|
||||
+ $_SESSION['tmp_user_values']['max_rows'];
|
||||
|
||||
if (($endpos < $unlim_num_rows)
|
||||
&& ($num_rows >= $_SESSION['tmp_user_values']['max_rows'])
|
||||
&& ($_SESSION['tmp_user_values']['max_rows'] != 'all')
|
||||
@@ -408,7 +410,8 @@ function PMA_getTableNavigation($pos_next, $pos_prev, $sql_query,
|
||||
|
||||
// show separator if pagination happen
|
||||
if ($nbTotalPage > 1) {
|
||||
$table_navigation_html .= '<td><div class="navigation_separator">|</div></td>';
|
||||
$table_navigation_html
|
||||
.= '<td><div class="navigation_separator">|</div></td>';
|
||||
}
|
||||
|
||||
$table_navigation_html .= '<td>'
|
||||
@@ -435,13 +438,15 @@ function PMA_getTableNavigation($pos_next, $pos_prev, $sql_query,
|
||||
. '(checkFormElementInRange('
|
||||
. 'this, '
|
||||
. '\'session_max_rows\', '
|
||||
. '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.')) . '\', '
|
||||
. '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.'))
|
||||
. '\', '
|
||||
. '1)'
|
||||
. ' && '
|
||||
. 'checkFormElementInRange('
|
||||
. 'this, '
|
||||
. '\'pos\', '
|
||||
. '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.')) . '\', '
|
||||
. '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.'))
|
||||
. '\', '
|
||||
. '0'
|
||||
. ($unlim_num_rows > 0 ? ', ' . ($unlim_num_rows - 1) : '') . ')'
|
||||
. ')'
|
||||
@@ -575,7 +580,8 @@ function PMA_getMoveForwardButtonsForTableNavigation(
|
||||
* Prepare feilds followed by Show button for table navigation
|
||||
* Start row, Number of rows, Headers every
|
||||
*
|
||||
* @param string $html_sql_query the sql encoded by html special characters
|
||||
* @param string $html_sql_query the sql encoded by html special
|
||||
* characters
|
||||
* @param string $goto the URL to go back in case of errors
|
||||
* @param integer $pos_next the offset for the "next" page
|
||||
* @param integer $unlim_num_rows the total number of rows returned by the
|
||||
@@ -626,12 +632,12 @@ function PMA_getAdditionalFieldsForTableNavigation(
|
||||
unset($choices);
|
||||
}
|
||||
|
||||
$additional_fields_html .= __('Headers every')
|
||||
. ' <input type="text" size="3" name="repeat_cells" value="'
|
||||
$additional_fields_html .= sprintf(
|
||||
__('Headers every %s rows'),
|
||||
'<input type="text" size="3" name="repeat_cells" value="'
|
||||
. $_SESSION['tmp_user_values']['repeat_cells']
|
||||
. '" class="textfield" /> '
|
||||
. __('rows')
|
||||
. "\n";
|
||||
);
|
||||
|
||||
return $additional_fields_html;
|
||||
|
||||
@@ -845,8 +851,8 @@ function PMA_getTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0,
|
||||
} elseif (($GLOBALS['cfg']['RowActionLinks'] == 'none')
|
||||
&& ($directionCondition)
|
||||
) {
|
||||
// ... elseif display an empty column if the actions links are disabled to
|
||||
// match the rest of the table
|
||||
// ... elseif display an empty column if the actions links are disabled to
|
||||
// match the rest of the table
|
||||
$table_headers_html .= '<th></th>';
|
||||
}
|
||||
|
||||
@@ -1055,7 +1061,6 @@ function PMA_getTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0,
|
||||
} elseif ((($GLOBALS['cfg']['RowActionLinks'] == 'left')
|
||||
|| ($GLOBALS['cfg']['RowActionLinks'] == 'both'))
|
||||
&& (($is_display['edit_lnk'] == 'nn') && ($is_display['del_lnk'] == 'nn'))
|
||||
&& (! isset($GLOBALS['is_header_sent']) || ! $GLOBALS['is_header_sent'])
|
||||
) {
|
||||
// ... elseif no button, displays empty columns if required
|
||||
// (unless coming from Browse mode print view)
|
||||
@@ -1161,8 +1166,8 @@ function PMA_getSortByKeyDropDown(
|
||||
. __('Descending') . ')</option>';
|
||||
}
|
||||
|
||||
$drop_down_html .= '<option value="' . htmlspecialchars($unsorted_sql_query) . '"'
|
||||
. ($used_index ? '' : ' selected="selected"') . '>' . __('None')
|
||||
$drop_down_html .= '<option value="' . htmlspecialchars($unsorted_sql_query)
|
||||
. '"' . ($used_index ? '' : ' selected="selected"') . '>' . __('None')
|
||||
. '</option>'
|
||||
. '</select>' . "\n"
|
||||
. '</form>' . "\n";
|
||||
@@ -1921,7 +1926,8 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
// delete/edit options correctly for tables without keys.
|
||||
|
||||
$odd_row = true;
|
||||
$directionCondition = ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal')
|
||||
$directionCondition
|
||||
= ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal')
|
||||
|| ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped');
|
||||
|
||||
while ($row = PMA_DBI_fetch_row($dt_result)) {
|
||||
@@ -1975,7 +1981,9 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
} // end if (1.2.1)
|
||||
|
||||
// 1.2.2 Delete/Kill link(s)
|
||||
if (($is_display['del_lnk'] == 'dr') || ($is_display['del_lnk'] == 'kp')) {
|
||||
if (($is_display['del_lnk'] == 'dr')
|
||||
|| ($is_display['del_lnk'] == 'kp')
|
||||
) {
|
||||
|
||||
list($del_query, $del_url, $del_str, $js_conf)
|
||||
= PMA_getDeleteAndKillLinks(
|
||||
@@ -2068,7 +2076,8 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
|
||||
if (file_exists($include_file)) {
|
||||
|
||||
$transformfunction_name = 'PMA_transformation_' . str_replace(
|
||||
$transformfunction_name = 'PMA_transformation_'
|
||||
. str_replace(
|
||||
'.inc.php', '',
|
||||
$GLOBALS['mime_map'][$meta->name]['transformation']
|
||||
);
|
||||
@@ -2080,8 +2089,11 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
$transform_function = $transformfunction_name;
|
||||
|
||||
$transform_options = PMA_transformation_getOptions(
|
||||
isset($GLOBALS['mime_map'][$meta->name]['transformation_options'])
|
||||
? $GLOBALS['mime_map'][$meta->name]['transformation_options']
|
||||
isset($GLOBALS['mime_map'][$meta->name]
|
||||
['transformation_options']
|
||||
)
|
||||
? $GLOBALS['mime_map'][$meta->name]
|
||||
['transformation_options']
|
||||
: ''
|
||||
);
|
||||
|
||||
@@ -2105,7 +2117,8 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
$_url_params['sql_query'] = $url_sql_query;
|
||||
}
|
||||
|
||||
$transform_options['wrapper_link'] = PMA_generate_common_url($_url_params);
|
||||
$transform_options['wrapper_link']
|
||||
= PMA_generate_common_url($_url_params);
|
||||
|
||||
if ($meta->numeric == 1) {
|
||||
// n u m e r i c
|
||||
@@ -2216,11 +2229,12 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
|
||||
if (!empty($del_url) && ($is_display['del_lnk'] != 'kp')) {
|
||||
|
||||
$vertical_display['row_delete'][$row_no] .= PMA_getCheckboxForMultiRowSubmissions(
|
||||
$del_url, $is_display, $row_no, $where_clause_html,
|
||||
$condition_array, $del_query, '[%_PMA_CHECKBOX_DIR_%]',
|
||||
$alternating_color_class . $vertical_class
|
||||
);
|
||||
$vertical_display['row_delete'][$row_no]
|
||||
.= PMA_getCheckboxForMultiRowSubmissions(
|
||||
$del_url, $is_display, $row_no, $where_clause_html,
|
||||
$condition_array, $del_query, '[%_PMA_CHECKBOX_DIR_%]',
|
||||
$alternating_color_class . $vertical_class
|
||||
);
|
||||
|
||||
} else {
|
||||
unset($vertical_display['row_delete'][$row_no]);
|
||||
@@ -2376,7 +2390,8 @@ function PMA_getVerticalDisplaySupportSegments(
|
||||
}
|
||||
|
||||
if ($vertical_display['emptyafter'] > 0) {
|
||||
$support_html .= ' <th colspan="' . $vertical_display['emptyafter'] . '">'
|
||||
$support_html .= ' <th colspan="' . $vertical_display['emptyafter']
|
||||
. '">'
|
||||
. "\n" . ' </th>' . "\n";
|
||||
}
|
||||
$support_html .= '</tr>' . "\n";
|
||||
@@ -3100,7 +3115,8 @@ function PMA_getVerticalTable()
|
||||
// assign appropriate key with current column order
|
||||
$key = $col_order ? $col_order[$j] : $j;
|
||||
|
||||
$vertical_table_html .= '<tr' . (($col_visib && !$col_visib[$j]) ? ' class="hide"' : '')
|
||||
$vertical_table_html .= '<tr'
|
||||
. (($col_visib && !$col_visib[$j]) ? ' class="hide"' : '')
|
||||
. '>' . "\n"
|
||||
. $val;
|
||||
|
||||
@@ -3285,7 +3301,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction']
|
||||
= $_REQUEST['disp_direction'];
|
||||
unset($_REQUEST['disp_direction']);
|
||||
} elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'])) {
|
||||
} elseif (
|
||||
empty($_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'])
|
||||
) {
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction']
|
||||
= $GLOBALS['cfg']['DefaultDisplay'];
|
||||
}
|
||||
@@ -3294,7 +3312,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells']
|
||||
= $_REQUEST['repeat_cells'];
|
||||
unset($_REQUEST['repeat_cells']);
|
||||
} elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'])) {
|
||||
} elseif (
|
||||
empty($_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'])
|
||||
) {
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells']
|
||||
= $GLOBALS['cfg']['RepeatCells'];
|
||||
}
|
||||
@@ -3324,7 +3344,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['display_text']
|
||||
= $_REQUEST['display_text'];
|
||||
unset($_REQUEST['display_text']);
|
||||
} elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'])) {
|
||||
} elseif (
|
||||
empty($_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'])
|
||||
) {
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'] = 'P';
|
||||
}
|
||||
|
||||
@@ -3332,7 +3354,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display']
|
||||
= $_REQUEST['relational_display'];
|
||||
unset($_REQUEST['relational_display']);
|
||||
} elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'])) {
|
||||
} elseif (
|
||||
empty($_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'])
|
||||
) {
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'] = 'K';
|
||||
}
|
||||
|
||||
@@ -3340,7 +3364,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display']
|
||||
= $_REQUEST['geometry_display'];
|
||||
unset($_REQUEST['geometry_display']);
|
||||
} elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'])) {
|
||||
} elseif (
|
||||
empty($_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'])
|
||||
) {
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'] = 'GEOM';
|
||||
}
|
||||
|
||||
@@ -3365,7 +3391,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
unset($_REQUEST['display_binary_as_hex']);
|
||||
} elseif (isset($_REQUEST['display_options_form'])) {
|
||||
// we know that the checkbox was unchecked
|
||||
unset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex']);
|
||||
unset(
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex']
|
||||
);
|
||||
} elseif (isset($_REQUEST['full_text_button'])) {
|
||||
// do nothing to keep the value that is there in the session
|
||||
} else {
|
||||
@@ -3392,7 +3420,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
unset($_REQUEST['hide_transformation']);
|
||||
} elseif (isset($_REQUEST['display_options_form'])) {
|
||||
// we know that the checkbox was unchecked
|
||||
unset($_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation']);
|
||||
unset(
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation']
|
||||
);
|
||||
}
|
||||
|
||||
// move current query to the last position, to be removed last
|
||||
@@ -3420,7 +3450,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
? true
|
||||
: false;
|
||||
$_SESSION['tmp_user_values']['display_binary_as_hex']
|
||||
= isset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex'])
|
||||
= isset(
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex']
|
||||
)
|
||||
? true
|
||||
: false;
|
||||
$_SESSION['tmp_user_values']['display_blob']
|
||||
@@ -3428,7 +3460,9 @@ function PMA_setConfigParamsForDisplayTable()
|
||||
? true
|
||||
: false;
|
||||
$_SESSION['tmp_user_values']['hide_transformation']
|
||||
= isset($_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation'])
|
||||
= isset(
|
||||
$_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation']
|
||||
)
|
||||
? true
|
||||
: false;
|
||||
$_SESSION['tmp_user_values']['pos']
|
||||
@@ -3607,7 +3641,8 @@ function PMA_getTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
|
||||
|
||||
foreach ($analyzed_sql[0]['table_ref']
|
||||
as $table_ref_position => $table_ref) {
|
||||
$target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
|
||||
$target[] = $analyzed_sql[0]['table_ref']
|
||||
[$table_ref_position]['table_true_name'];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3734,10 +3769,10 @@ function PMA_getOffsets()
|
||||
/**
|
||||
* Get sort parameters
|
||||
*
|
||||
* @param string $order_by_clause
|
||||
* @param string $order_by_clause the order by clause of the sql query
|
||||
*
|
||||
* @return array 3 element array: $sort_expression,
|
||||
* $sort_expression_nodirection, $sort_direction
|
||||
* @return array 3 element array: $sort_expression,
|
||||
* $sort_expression_nodirection, $sort_direction
|
||||
*
|
||||
* @see PMA_getTable()
|
||||
*/
|
||||
@@ -4431,7 +4466,8 @@ function PMA_getRowData($class, $condition_field, $analyzed_sql, $meta, $map,
|
||||
$alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
|
||||
|
||||
if (isset($alias) && strlen($alias)) {
|
||||
$true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
|
||||
$true_column = $analyzed_sql[0]['select_expr']
|
||||
[$select_expr_position]['column'];
|
||||
|
||||
if ($alias == $meta->name) {
|
||||
// this change in the parameter does not matter
|
||||
@@ -4718,7 +4754,8 @@ function PMA_getDeleteLink($del_url, $del_str, $js_conf, $class)
|
||||
*
|
||||
* @param string $position the position of the checkbox and links
|
||||
* @param string $del_url delete url
|
||||
* @param array $is_display array with explicit indexes for all the display elements
|
||||
* @param array $is_display array with explicit indexes for all the
|
||||
* display elements
|
||||
* @param string $row_no row number
|
||||
* @param string $where_clause where clause
|
||||
* @param string $where_clause_html url encoded where cluase
|
||||
|
||||
@@ -14,6 +14,8 @@ if (! defined('PHPMYADMIN')) {
|
||||
class PMA_StorageEngine_bdb extends PMA_StorageEngine
|
||||
{
|
||||
/**
|
||||
* Returns array with variable names related to this storage engine
|
||||
*
|
||||
* @return array variable names
|
||||
*/
|
||||
function getVariables()
|
||||
@@ -57,7 +59,10 @@ class PMA_StorageEngine_bdb extends PMA_StorageEngine
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string LIKE pattern
|
||||
* Returns the pattern to be used in the query for SQL variables
|
||||
* related to this storage engine
|
||||
*
|
||||
* @return string LIKE pattern
|
||||
*/
|
||||
function getVariablesLikePattern()
|
||||
{
|
||||
|
||||
@@ -13,7 +13,8 @@ if (! defined('PHPMYADMIN')) {
|
||||
require_once './libraries/engines/bdb.lib.php';
|
||||
|
||||
/**
|
||||
* This is same as BDB.
|
||||
* This is same as BDB
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
class PMA_StorageEngine_berkeleydb extends PMA_StorageEngine_bdb
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* The InnoDB storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -8,13 +10,16 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The InnoDB storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
class PMA_StorageEngine_innodb extends PMA_StorageEngine
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* Returns array with variable names related to InnoDB storage engine
|
||||
*
|
||||
* @return array variable names
|
||||
*/
|
||||
function getVariables()
|
||||
{
|
||||
@@ -114,6 +119,9 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pattern to be used in the query for SQL variables
|
||||
* related to InnoDb storage engine
|
||||
*
|
||||
* @return string SQL query LIKE pattern
|
||||
*/
|
||||
function getVariablesLikePattern()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* The MEMORY (HEAP) storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -8,13 +10,14 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* the MEMORY (HEAP) storage engine
|
||||
* The MEMORY (HEAP) storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
class PMA_StorageEngine_memory extends PMA_StorageEngine
|
||||
{
|
||||
/**
|
||||
* returns array with variable names dedicated to MyISAM storage engine
|
||||
* Returns array with variable names dedicated to MEMORY storage engine
|
||||
*
|
||||
* @return array variable names
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* The MERGE storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -8,6 +10,7 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The MERGE storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* The MyISAM storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -8,13 +10,14 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* the MyISAM storage engine
|
||||
* The MyISAM storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
class PMA_StorageEngine_myisam extends PMA_StorageEngine
|
||||
{
|
||||
/**
|
||||
* returns array with variable names dedicated to MyISAM storage engine
|
||||
* Returns array with variable names dedicated to MyISAM storage engine
|
||||
*
|
||||
* @return array variable names
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* The NDBCLUSTER storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -8,13 +10,16 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The NDBCLUSTER storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
class PMA_StorageEngine_ndbcluster extends PMA_StorageEngine
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* Returns array with variable names realted to NDBCLUSTER storage engine
|
||||
*
|
||||
* @return array variable names
|
||||
*/
|
||||
function getVariables()
|
||||
{
|
||||
@@ -25,6 +30,9 @@ class PMA_StorageEngine_ndbcluster extends PMA_StorageEngine
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pattern to be used in the query for SQL variables
|
||||
* related to NDBCLUSTER storage engine
|
||||
*
|
||||
* @return string SQL query LIKE pattern
|
||||
*/
|
||||
function getVariablesLikePattern()
|
||||
@@ -33,8 +41,8 @@ class PMA_StorageEngine_ndbcluster extends PMA_StorageEngine
|
||||
}
|
||||
|
||||
/**
|
||||
* returns string with filename for the MySQL helppage
|
||||
* about this storage engne
|
||||
* Returns string with filename for the MySQL help page
|
||||
* about this storage engine
|
||||
*
|
||||
* @return string mysql helppage filename
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* The PBXT storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -8,13 +10,14 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* the MyISAM storage engine
|
||||
* The PBXT storage engine
|
||||
*
|
||||
* @package PhpMyAdmin-Engines
|
||||
*/
|
||||
class PMA_StorageEngine_pbxt extends PMA_StorageEngine
|
||||
{
|
||||
/**
|
||||
* returns array with variable names dedicated to PBXT storage engine
|
||||
* Returns array with variable names dedicated to PBXT storage engine
|
||||
*
|
||||
* @return array variable names
|
||||
*/
|
||||
@@ -88,7 +91,7 @@ class PMA_StorageEngine_pbxt extends PMA_StorageEngine
|
||||
* returns the pbxt engine specific handling for
|
||||
* PMA_ENGINE_DETAILS_TYPE_SIZE variables.
|
||||
*
|
||||
* @param string $formatted_size the size expression (for example 8MB)
|
||||
* @param string $formatted_size the size expression (for example 8MB)
|
||||
*
|
||||
* @return string the formatted value and its unit
|
||||
*/
|
||||
|
||||
@@ -10,9 +10,12 @@ if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!defined('TESTSUITE')) {
|
||||
if (! defined('TESTSUITE')) {
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
|
||||
PMA_Response::getInstance()->disable();
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="<?php echo $lang; ?>" dir="<?php echo $dir; ?>">
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* finishes HTML output
|
||||
*
|
||||
* updates javascript variables in index.php for correct working with querywindow
|
||||
* and navigation frame refreshing
|
||||
*
|
||||
* send buffered data if buffered
|
||||
*
|
||||
* WARNING: This script has to be included at the very end of your code because
|
||||
* it will stop the script execution!
|
||||
*
|
||||
* always use $GLOBALS, as this script is also included by functions
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* for PMA_setHistory()
|
||||
*/
|
||||
if (! PMA_isValid($_REQUEST['no_history']) && empty($GLOBALS['error_message'])
|
||||
&& ! empty($GLOBALS['sql_query'])
|
||||
) {
|
||||
PMA_setHistory(
|
||||
PMA_ifSetOr($GLOBALS['db'], ''),
|
||||
PMA_ifSetOr($GLOBALS['table'], ''),
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['sql_query']
|
||||
);
|
||||
}
|
||||
|
||||
if ($GLOBALS['error_handler']->hasDisplayErrors()) {
|
||||
echo '<div class="clearfloat">';
|
||||
$GLOBALS['error_handler']->dispErrors();
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if (count($GLOBALS['footnotes'])) {
|
||||
echo '<div class="footnotes">';
|
||||
foreach ($GLOBALS['footnotes'] as $footnote) {
|
||||
echo '<span id="footnote_' . $footnote['nr'] . '"><sup>'
|
||||
. $footnote['nr'] . '</sup> ' . $footnote['note'] . '</span><br />';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if (! empty($_SESSION['debug'])) {
|
||||
$sum_time = 0;
|
||||
$sum_exec = 0;
|
||||
foreach ($_SESSION['debug']['queries'] as $query) {
|
||||
$sum_time += $query['count'] * $query['time'];
|
||||
$sum_exec += $query['count'];
|
||||
}
|
||||
|
||||
echo '<div>';
|
||||
echo count($_SESSION['debug']['queries']) . ' queries executed '
|
||||
. $sum_exec . ' times in ' . $sum_time . ' seconds';
|
||||
echo '<pre>';
|
||||
print_r($_SESSION['debug']);
|
||||
echo '</pre>';
|
||||
echo '</div>';
|
||||
$_SESSION['debug'] = array();
|
||||
}
|
||||
|
||||
if (!$GLOBALS['is_ajax_request']) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
<?php
|
||||
if (empty($GLOBALS['error_message'])) {
|
||||
?>
|
||||
$(function() {
|
||||
// updates current settings
|
||||
if (window.parent.setAll) {
|
||||
window.parent.setAll('<?php
|
||||
echo PMA_escapeJsString($GLOBALS['lang']) . "', '";
|
||||
echo PMA_escapeJsString($GLOBALS['collation_connection']) . "', '";
|
||||
echo PMA_escapeJsString($GLOBALS['server']) . "', '";
|
||||
echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) . "', '";
|
||||
echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) . "', '";
|
||||
echo PMA_escapeJsString($_SESSION[' PMA_token ']);?>');
|
||||
}
|
||||
<?php
|
||||
if (! empty($GLOBALS['reload'])) {
|
||||
?>
|
||||
// refresh navigation frame content
|
||||
if (window.parent.refreshNavigation) {
|
||||
window.parent.refreshNavigation();
|
||||
}
|
||||
<?php
|
||||
} else if (isset($_GET['reload_left_frame']) && $_GET['reload_left_frame'] == '1') {
|
||||
// reload left frame (used by user preferences)
|
||||
?>
|
||||
if (window.parent && window.parent.frame_navigation) {
|
||||
window.parent.frame_navigation.location.reload();
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
// set current db, table and sql query in the querywindow
|
||||
if (window.parent.reload_querywindow) {
|
||||
window.parent.reload_querywindow(
|
||||
'<?php echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) ?>',
|
||||
'<?php echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) ?>',
|
||||
'<?php echo strlen($GLOBALS['sql_query']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] ? PMA_escapeJsString($GLOBALS['sql_query']) : ''; ?>');
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
if (! empty($GLOBALS['focus_querywindow'])) {
|
||||
?>
|
||||
// set focus to the querywindow
|
||||
if (parent.querywindow && !parent.querywindow.closed && parent.querywindow.location) {
|
||||
self.focus();
|
||||
}
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
if (window.parent.frame_content) {
|
||||
// reset content frame name, as querywindow needs to set a unique name
|
||||
// before submitting form data, and navigation frame needs the original name
|
||||
if (typeof(window.parent.frame_content.name) != 'undefined'
|
||||
&& window.parent.frame_content.name != 'frame_content') {
|
||||
window.parent.frame_content.name = 'frame_content';
|
||||
}
|
||||
if (typeof(window.parent.frame_content.id) != 'undefined'
|
||||
&& window.parent.frame_content.id != 'frame_content') {
|
||||
window.parent.frame_content.id = 'frame_content';
|
||||
}
|
||||
//window.parent.frame_content.setAttribute('name', 'frame_content');
|
||||
//window.parent.frame_content.setAttribute('id', 'frame_content');
|
||||
}
|
||||
});
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Link to itself to replicate windows including frameset
|
||||
if (! isset($GLOBALS['checked_special'])) {
|
||||
$GLOBALS['checked_special'] = false;
|
||||
}
|
||||
|
||||
if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && !$GLOBALS['checked_special'] && ! $GLOBALS['is_ajax_request']) {
|
||||
echo '<div id="selflink" class="print_ignore">' . "\n";
|
||||
$url_params['target'] = basename(PMA_getenv('SCRIPT_NAME'));
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
||||
/* Store current location in hash part of URL to allow direct bookmarking */
|
||||
setURLHash("<?php echo PMA_generate_common_url($url_params, 'text', ''); ?>");
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
|
||||
echo '<a href="index.php' . PMA_generate_common_url($url_params) . '"'
|
||||
. ' title="' . __('Open new phpMyAdmin window') . '" target="_blank">';
|
||||
if ($GLOBALS['cfg']['NavigationBarIconic']) {
|
||||
echo PMA_getImage('window-new.png', __('Open new phpMyAdmin window'));
|
||||
}
|
||||
if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) {
|
||||
echo __('Open new phpMyAdmin window');
|
||||
}
|
||||
echo '</a>' . "\n";
|
||||
echo '</div>' . "\n";
|
||||
}
|
||||
|
||||
// Include possible custom footers
|
||||
if (! $GLOBALS['is_ajax_request'] && file_exists(CUSTOM_FOOTER_FILE)) {
|
||||
include CUSTOM_FOOTER_FILE;
|
||||
}
|
||||
|
||||
/**
|
||||
* If we are in an AJAX request, we do not need to generate the closing tags for
|
||||
* body and html.
|
||||
*/
|
||||
if (! $GLOBALS['is_ajax_request']) {
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* Stops the script execution
|
||||
*/
|
||||
exit;
|
||||
?>
|
||||
@@ -155,7 +155,7 @@ class PMA_GIS_Visualization
|
||||
|
||||
ob_clean();
|
||||
|
||||
PMA_download_header($file_name, $type);
|
||||
PMA_downloadHeader($file_name, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user