Merge branch 'master' of git://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin
This commit is contained in:
commit
681df0a9f9
@ -44,6 +44,9 @@ phpMyAdmin - ChangeLog
|
||||
- bug #3380946 [export] no uid Query result export (Suhosin limit)
|
||||
+ Grid editing in browse mode (replaces row inline edit)
|
||||
+ Zoom-search in table Search
|
||||
+ [interface] Editor for GIS data
|
||||
+ [import] Import GIS data from ESRI Shapefiles
|
||||
+ [interface] 'Function based search' for GIS data
|
||||
|
||||
3.4.5.0 (not yet released)
|
||||
- bug #3375325 [interface] Page list in navigation frame looks odd
|
||||
@ -54,6 +57,7 @@ phpMyAdmin - ChangeLog
|
||||
- [core] Remove library PHPExcel, due to license issues
|
||||
- [export] Remove native Excel export modules (xls and xlsx formats)
|
||||
- [import] Remove native Excel import modules (xls and xlsx formats)
|
||||
- bug #3392920 [edit] BLOB emptied after editing another column
|
||||
|
||||
3.4.4.0 (not yet released)
|
||||
- bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes
|
||||
|
||||
@ -2088,9 +2088,10 @@ $cfg['TrustedProxies'] =
|
||||
The name of the directory where temporary files can be stored.
|
||||
<br /><br />
|
||||
|
||||
This is needed to work around limitations of <tt>open_basedir</tt>
|
||||
for uploaded files, see
|
||||
<a href="#faq1_11"><abbr title="Frequently Asked Questions">FAQ</abbr>
|
||||
This is needed for importing ESRI Shapefiles, see
|
||||
<a href="#faq6_30"><abbr title="Frequently Asked Questions">FAQ</abbr>
|
||||
6.30</a> and to work around limitations of <tt>open_basedir</tt> for uploaded
|
||||
files, see <a href="#faq1_11"><abbr title="Frequently Asked Questions">FAQ</abbr>
|
||||
1.11</a>.
|
||||
<br /><br />
|
||||
|
||||
@ -4373,6 +4374,49 @@ INSERT INTO REL_towns VALUES ('M', 'Montréal');
|
||||
|
||||
<p> Not every table can be put to the chart. Only tables with one, two or three columns can be visualised as a chart. Moreover the table must be in a special format for chart script to understand it. Currently supported formats can be found in the <a href="http://wiki.phpmyadmin.net/pma/Charts#Data_formats_for_query_results_chart">wiki</a>.</p>
|
||||
|
||||
<h4 id="faq6_30">
|
||||
<a href="#faq6_30">6.30 Import: How can I import ESRI Shapefiles</a></h4>
|
||||
|
||||
<p>
|
||||
An ESRI Shapefile is actually a set of several files, where .shp file contains
|
||||
geometry data and .dbf file contains data related to those geometry data.
|
||||
To read data from .dbf file you need to have PHP compiled with the dBase extension
|
||||
(--enable-dbase). Otherwise only geometry data will be imported.
|
||||
</p>
|
||||
|
||||
<p>To upload these set of files you can use either of the following methods:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
Configure upload directory with
|
||||
<a href="#cfg_UploadDir" class="configrule">$cfg['UploadDir']</a>, upload both
|
||||
.shp and .dbf files with the same filename and chose the .shp file from the import page.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Create a Zip archive with .shp and .dbf files and import it. For this to work,
|
||||
you need to set <a href="#cfg_TempDir" class="configrule">$cfg['TempDir']</a> to a
|
||||
place where the web server user can write (for example <tt>'./tmp'</tt>).
|
||||
</p>
|
||||
|
||||
<p> To create the temporary directory on a UNIX-based system, you can do:</p>
|
||||
<pre>
|
||||
cd phpMyAdmin
|
||||
mkdir tmp
|
||||
chmod o+rwx tmp
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 id="faq6_31">
|
||||
<a href="#faq6_31">6.30 How do I create a relation in designer?</a></h4>
|
||||
|
||||
<p>To select relation, click :</p>
|
||||
|
||||
<img src="pmd/images/help_relation.png"></p>
|
||||
<p>The display column is shown in pink. To set/unset a column as the display column, click the "Choose column to display" icon, then click on the appropriate column name.</p>
|
||||
|
||||
<h3 id="faqproject">phpMyAdmin project</h3>
|
||||
|
||||
<h4 id="faq7_1">
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
<arg line="${source_comma_sep}
|
||||
xml
|
||||
codesize,design,naming,unusedcode
|
||||
--exclude test,build,tcpdf,php-gettext
|
||||
--exclude test,build,tcpdf,php-gettext,bfShapeFiles
|
||||
--reportfile ${basedir}/build/logs/pmd.xml" />
|
||||
</exec>
|
||||
</target>
|
||||
@ -50,6 +50,7 @@
|
||||
--exclude build
|
||||
--exclude libraries/tcpdf
|
||||
--exclude libraries/php-gettext
|
||||
--exclude libraries/bfShapeFiles
|
||||
${source}" />
|
||||
</exec>
|
||||
</target>
|
||||
@ -61,6 +62,7 @@
|
||||
--exclude build
|
||||
--exclude libraries/tcpdf
|
||||
--exclude libraries/php-gettext
|
||||
--exclude libraries/bfShapeFiles
|
||||
${source}" />
|
||||
</exec>
|
||||
</target>
|
||||
@ -68,7 +70,7 @@
|
||||
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer excluding test, tcpdf directories">
|
||||
<exec executable="phpcs">
|
||||
<arg line="
|
||||
--ignore=*/php-gettext/*,*/tcpdf/*,*/canvg/*,*/codemirror/*,*/highcharts/*,*/openlayers/*,*/jquery/*,*/build/*
|
||||
--ignore=*/php-gettext/*,*/tcpdf/*,*/canvg/*,*/codemirror/*,*/highcharts/*,*/openlayers/*,*/jquery/*,*/build/*,*/bfShapeFiles/*
|
||||
--report=checkstyle
|
||||
--report-file=${basedir}/build/logs/checkstyle.xml
|
||||
--standard=PEAR
|
||||
|
||||
@ -11,7 +11,8 @@
|
||||
require_once './libraries/common.inc.php';
|
||||
|
||||
if (! isset($selected_tbl)) {
|
||||
require_once './libraries/header.inc.php';
|
||||
require './libraries/db_common.inc.php';
|
||||
require './libraries/db_info.inc.php';
|
||||
}
|
||||
|
||||
|
||||
@ -55,16 +56,15 @@ if ($cfgRelation['commwork']) {
|
||||
* Selects the database and gets tables names
|
||||
*/
|
||||
PMA_DBI_select_db($db);
|
||||
$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
|
||||
$tables = PMA_DBI_get_tables($db);
|
||||
|
||||
$count = 0;
|
||||
while ($row = PMA_DBI_fetch_row($rowset)) {
|
||||
$table = $row[0];
|
||||
foreach($tables as $table) {
|
||||
$comments = PMA_getComments($db, $table);
|
||||
|
||||
echo '<div>' . "\n";
|
||||
|
||||
echo '<h2>' . $table . '</h2>' . "\n";
|
||||
echo '<h2>' . htmlspecialchars($table) . '</h2>' . "\n";
|
||||
|
||||
/**
|
||||
* Gets table informations
|
||||
@ -204,7 +204,7 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
|
||||
} else {
|
||||
$row['Default'] = htmlspecialchars($row['Default']);
|
||||
}
|
||||
$field_name = htmlspecialchars($row['Field']);
|
||||
$field_name = $row['Field'];
|
||||
|
||||
if (PMA_MYSQL_INT_VERSION < 50025
|
||||
&& ! empty($analyzed_sql[0]['create_table_fields'][$field_name]['type'])
|
||||
@ -226,9 +226,9 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
|
||||
<td nowrap="nowrap">
|
||||
<?php
|
||||
if (isset($pk_array[$row['Field']])) {
|
||||
echo '<u>' . $field_name . '</u>';
|
||||
echo '<u>' . htmlspecialchars($field_name) . '</u>';
|
||||
} else {
|
||||
echo $field_name;
|
||||
echo htmlspecialchars($field_name);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
@ -128,8 +128,7 @@ if (isset($_REQUEST['submit_search'])) {
|
||||
$sqlstr_delete = 'DELETE';
|
||||
|
||||
// Fields to select
|
||||
$tblfields = PMA_DBI_fetch_result('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']),
|
||||
null, 'Field');
|
||||
$tblfields = PMA_DBI_get_columns($GLOBALS['db'], $table);
|
||||
|
||||
// Table to use
|
||||
$sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
|
||||
@ -148,8 +147,8 @@ if (isset($_REQUEST['submit_search'])) {
|
||||
|
||||
$thefieldlikevalue = array();
|
||||
foreach ($tblfields as $tblfield) {
|
||||
if (! isset($field) || strlen($field) == 0 || $tblfield == $field) {
|
||||
$thefieldlikevalue[] = 'CONVERT(' . PMA_backquote($tblfield) . ' USING utf8)'
|
||||
if (! isset($field) || strlen($field) == 0 || $tblfield['Field'] == $field) {
|
||||
$thefieldlikevalue[] = 'CONVERT(' . PMA_backquote($tblfield['Field']) . ' USING utf8)'
|
||||
. ' ' . $like_or_regex . ' '
|
||||
. "'" . $automatic_wildcard
|
||||
. $search_word
|
||||
|
||||
@ -67,9 +67,9 @@ require_once './libraries/db_links.inc.php';
|
||||
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
|
||||
PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
|
||||
PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
|
||||
' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddSlashes($_REQUEST['db']) . '\' ' .
|
||||
' GROUP BY '. PMA_backquote('table_name') .
|
||||
' ORDER BY '. PMA_backquote('table_name') .' ASC';
|
||||
' WHERE db_name = \'' . PMA_sqlAddSlashes($_REQUEST['db']) . '\' ' .
|
||||
' GROUP BY table_name' .
|
||||
' ORDER BY table_name ASC';
|
||||
|
||||
$all_tables_result = PMA_query_as_controluser($all_tables_query);
|
||||
|
||||
|
||||
335
gis_data_editor.php
Normal file
335
gis_data_editor.php
Normal file
@ -0,0 +1,335 @@
|
||||
<?php
|
||||
require_once './libraries/common.inc.php';
|
||||
if (! isset($_REQUEST['get_gis_editor']) && ! isset($_REQUEST['generate'])) {
|
||||
require_once './libraries/header_http.inc.php';
|
||||
require_once './libraries/header_meta_style.inc.php';
|
||||
}
|
||||
require_once './libraries/gis/pma_gis_factory.php';
|
||||
require_once './libraries/gis_visualization.lib.php';
|
||||
|
||||
// Get data if any posted
|
||||
$gis_data = array();
|
||||
if (PMA_isValid($_REQUEST['gis_data'], 'array')) {
|
||||
$gis_data = $_REQUEST['gis_data'];
|
||||
}
|
||||
|
||||
$gis_types = array(
|
||||
'POINT',
|
||||
'MULTIPOINT',
|
||||
'LINESTRING',
|
||||
'MULTILINESTRING',
|
||||
'POLYGON',
|
||||
'MULTIPOLYGON',
|
||||
'GEOMETRYCOLLECTION'
|
||||
);
|
||||
|
||||
// Extract type from the initial call and make sure that it's a valid one.
|
||||
// Extract from field's values if availbale, if not use the column type passed.
|
||||
if (! isset($gis_data['gis_type'])) {
|
||||
if (isset($_REQUEST['type']) && $_REQUEST['type'] != '') {
|
||||
$gis_data['gis_type'] = strtoupper($_REQUEST['type']);
|
||||
}
|
||||
if (isset($_REQUEST['value']) && trim($_REQUEST['value']) != '') {
|
||||
$start = (substr($_REQUEST['value'], 0, 1) == "'") ? 1 : 0;
|
||||
$gis_data['gis_type'] = substr($_REQUEST['value'], $start, strpos($_REQUEST['value'], "(") - $start);
|
||||
}
|
||||
if ((! isset($gis_data['gis_type'])) || (! in_array($gis_data['gis_type'], $gis_types))) {
|
||||
$gis_data['gis_type'] = $gis_types[0];
|
||||
}
|
||||
}
|
||||
$geom_type = $gis_data['gis_type'];
|
||||
|
||||
// Generate parameters from value passed.
|
||||
$gis_obj = PMA_GIS_Factory::factory($geom_type);
|
||||
if (isset($_REQUEST['value'])) {
|
||||
$gis_data = array_merge($gis_data, $gis_obj->generateParams($_REQUEST['value']));
|
||||
}
|
||||
|
||||
// Generate Well Known Text
|
||||
$srid = (isset($gis_data['srid']) && $gis_data['srid'] != '') ? htmlspecialchars($gis_data['srid']) : 0;
|
||||
$wkt = $gis_obj->generateWkt($gis_data, 0);
|
||||
$wkt_with_zero = $gis_obj->generateWkt($gis_data, 0, '0');
|
||||
$result = "'" . $wkt . "'," . $srid;
|
||||
|
||||
// Gererate PNG or SVG based visualization
|
||||
$format = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER <= 8) ? 'png' : 'svg';
|
||||
$visualizationSettings = array('width' => 450, 'height' => 300, 'spatialColumn' => 'wkt');
|
||||
$data = array(array('wkt' => $wkt_with_zero, 'srid' => $srid));
|
||||
$visualization = PMA_GIS_visualizationResults($data, $visualizationSettings, $format);
|
||||
$open_layers = PMA_GIS_visualizationResults($data, $visualizationSettings, 'ol');
|
||||
|
||||
// If the call is to update the WKT and visualization make an AJAX response
|
||||
if (isset($_REQUEST['generate']) && $_REQUEST['generate'] == true) {
|
||||
$extra_data = array(
|
||||
'result' => $result,
|
||||
'visualization' => $visualization,
|
||||
'openLayers' => $open_layers,
|
||||
);
|
||||
PMA_ajaxResponse(null, true, $extra_data);
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
?>
|
||||
<form id="gis_data_editor_form" action="gis_data_editor.php" method="post">
|
||||
<input type="hidden" id="pmaThemeImage" value="<?php echo($GLOBALS['pmaThemeImage']); ?>" />
|
||||
<div id="gis_data_editor">
|
||||
<h3><?php printf(__('Value for the column "%s"'), htmlspecialchars($_REQUEST['field'])); ?></h3>
|
||||
|
||||
<?php echo('<input type="hidden" name="field" value="' . htmlspecialchars($_REQUEST['field']) . '" />');
|
||||
// The input field to which the final result should be added and corresponding null checkbox
|
||||
if (isset($_REQUEST['input_name'])) {
|
||||
echo('<input type="hidden" name="input_name" value="' . htmlspecialchars($_REQUEST['input_name']) . '" />');
|
||||
}
|
||||
echo PMA_generate_common_hidden_inputs();
|
||||
?>
|
||||
<!-- Visualization section -->
|
||||
<div id="placeholder" style="width:450px;height:300px;
|
||||
<?php if ($srid != 0) {
|
||||
echo('display:none;');
|
||||
}
|
||||
?> ">
|
||||
<?php echo ($visualization);
|
||||
?> </div>
|
||||
<div id="openlayersmap" style="width:450px;height:300px;
|
||||
<?php if ($srid == 0) {
|
||||
echo('display:none;');
|
||||
}
|
||||
?> ">
|
||||
</div>
|
||||
<div class="choice" style="float:right;clear:right;">
|
||||
<input type="checkbox" id="choice" value="useBaseLayer"
|
||||
<?php if ($srid != 0) {
|
||||
echo(' checked="checked"');
|
||||
}
|
||||
?> />
|
||||
<label for="choice"><?php echo __("Use OpenStreetMaps as Base Layer"); ?></label>
|
||||
</div>
|
||||
<script language="javascript" type="text/javascript">
|
||||
<?php echo($open_layers); ?>
|
||||
</script>
|
||||
<!-- End of visualization section -->
|
||||
|
||||
<!-- Header section - Inclueds GIS type selector and input field for SRID -->
|
||||
<div id="gis_data_header">
|
||||
<select name="gis_data[gis_type]" class="gis_type">
|
||||
<?php
|
||||
foreach ($gis_types as $gis_type) {
|
||||
echo('<option value="' . $gis_type . '"');
|
||||
if ($geom_type == $gis_type) {
|
||||
echo(' selected="selected"');
|
||||
}
|
||||
echo('>' . $gis_type . '</option>');
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="submit" name="gis_data[go]" class="go" value="<?php echo __("Go")?>" />
|
||||
<label for="srid"><?php echo __("SRID"); ?>: </label>
|
||||
<input name="gis_data[srid]" type="text" value="<?php echo($srid); ?>" />
|
||||
</div>
|
||||
<!-- End of header section -->
|
||||
|
||||
<!-- Data section -->
|
||||
<div id="gis_data">
|
||||
<?php $geom_count = 1;
|
||||
if ($geom_type == 'GEOMETRYCOLLECTION') {
|
||||
$geom_count = (isset($gis_data[$geom_type]['geom_count'])) ? $gis_data[$geom_type]['geom_count'] : 1;
|
||||
if (isset($gis_data[$geom_type]['add_geom'])) {
|
||||
$geom_count++;
|
||||
}
|
||||
echo('<input type="hidden" name="gis_data[GEOMETRYCOLLECTION][geom_count]" value="' . $geom_count . '">');
|
||||
}
|
||||
for ($a = 0; $a < $geom_count; $a++) {
|
||||
if ($geom_type == 'GEOMETRYCOLLECTION') {
|
||||
echo('<br/><br/>'); echo __("Geometry"); echo($a + 1 . ':<br/>');
|
||||
if (isset($gis_data[$a]['gis_type'])) {
|
||||
$type = $gis_data[$a]['gis_type'];
|
||||
} else {
|
||||
$type = $gis_types[0];
|
||||
}
|
||||
echo('<select name="gis_data[' . $a . '][gis_type]" class="gis_type">');
|
||||
foreach (array_slice($gis_types, 0, 6) as $gis_type) {
|
||||
echo('<option value="' . $gis_type . '"');
|
||||
if ($type == $gis_type) {
|
||||
echo(' selected="selected"');
|
||||
}
|
||||
echo('>' . $gis_type . '</option>');
|
||||
}
|
||||
echo('</select>');
|
||||
echo('<input type="submit" name="gis_data[' . $a . '][go]" class="go" value="'); echo __("Go"); echo('">');
|
||||
} else {
|
||||
$type = $geom_type;
|
||||
}
|
||||
|
||||
if ($type == 'POINT') {
|
||||
echo('<br/>'); echo __("Point"); echo(' :');
|
||||
?> <label for="x"><?php echo __("X"); ?></label>
|
||||
<input name="gis_data[<?php echo($a); ?>][POINT][x]" type="text" value="<?php echo(isset($gis_data[$a]['POINT']['x']) ? htmlspecialchars($gis_data[$a]['POINT']['x']) : ''); ?>" />
|
||||
<label for="y"><?php echo __("Y"); ?></label>
|
||||
<input name="gis_data[<?php echo($a); ?>][POINT][y]" type="text" value="<?php echo(isset($gis_data[$a]['POINT']['y']) ? htmlspecialchars($gis_data[$a]['POINT']['y']) : ''); ?>" />
|
||||
<?php
|
||||
} elseif ($type == 'MULTIPOINT' || $type == 'LINESTRING') {
|
||||
|
||||
$no_of_points = isset($gis_data[$a][$type]['no_of_points']) ? $gis_data[$a][$type]['no_of_points'] : 1;
|
||||
if ($type == 'LINESTRING' && $no_of_points < 2) {
|
||||
$no_of_points = 2;
|
||||
}
|
||||
if ($type == 'MULTIPOINT' && $no_of_points < 1) {
|
||||
$no_of_points = 1;
|
||||
}
|
||||
|
||||
if (isset($gis_data[$a][$type]['add_point'])) {
|
||||
$no_of_points++;
|
||||
}
|
||||
echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][no_of_points]" value="' . $no_of_points . '">');
|
||||
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
echo('<br/>'); echo __("Point"); echo($i + 1 . ':');
|
||||
?> <label for="x"><?php echo __("X"); ?></label>
|
||||
<input type="text" name="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][x]" value="<?php echo(isset($gis_data[$a][$type][$i]['x']) ? htmlspecialchars($gis_data[$a][$type][$i]['x']) : ''); ?>" />
|
||||
<label for="y"><?php echo __("Y"); ?></label>
|
||||
<input type="text" name="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][y]" value="<?php echo(isset($gis_data[$a][$type][$i]['y']) ? htmlspecialchars($gis_data[$a][$type][$i]['y']) : ''); ?>" />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<input type="submit" name="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][add_point]" class="add addPoint" value="<?php echo __("Add a point"); ?>">
|
||||
<?php
|
||||
} elseif ($type == 'MULTILINESTRING' || $type == 'POLYGON') {
|
||||
|
||||
$no_of_lines = isset($gis_data[$a][$type]['no_of_lines']) ? $gis_data[$a][$type]['no_of_lines'] : 1;
|
||||
if ($no_of_lines < 1) {
|
||||
$no_of_lines = 1;
|
||||
}
|
||||
if (isset($gis_data[$a][$type]['add_line'])) {
|
||||
$no_of_lines++;
|
||||
}
|
||||
echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][no_of_lines]" value="' . $no_of_lines . '">');
|
||||
|
||||
for ($i = 0; $i < $no_of_lines; $i++) {
|
||||
echo('<br/>');
|
||||
if ($type == 'MULTILINESTRING') {
|
||||
echo __("Linestring"); echo($i + 1 . ':');
|
||||
} else {
|
||||
if ($i == 0) {
|
||||
echo __("Outer Ring:");
|
||||
} else {
|
||||
echo __("Inner Ring"); echo($i . ':');
|
||||
}
|
||||
}
|
||||
|
||||
$no_of_points = isset($gis_data[$a][$type][$i]['no_of_points']) ? $gis_data[$a][$type][$i]['no_of_points'] : 2;
|
||||
if ($type == 'MULTILINESTRING' && $no_of_points < 2) {
|
||||
$no_of_points = 2;
|
||||
}
|
||||
if ($type == 'POLYGON' && $no_of_points < 4) {
|
||||
$no_of_points = 4;
|
||||
}
|
||||
if (isset($gis_data[$a][$type][$i]['add_point'])) {
|
||||
$no_of_points++;
|
||||
}
|
||||
echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][' . $i . '][no_of_points]" value="' . $no_of_points . '">');
|
||||
|
||||
for ($j = 0; $j < $no_of_points; $j++) {
|
||||
echo('<br/>'); echo __("Point"); echo($j + 1 . ':');
|
||||
?> <label for="x"><?php echo __("X"); ?></label>
|
||||
<input type="text" name="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][<?php echo($j); ?>][x]" value="<?php echo(isset($gis_data[$a][$type][$i][$j]['x']) ? htmlspecialchars($gis_data[$a][$type][$i][$j]['x']) : ''); ?>" />
|
||||
<label for="y"><?php echo __("Y"); ?></label>
|
||||
<input type="text" name="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][<?php echo($j); ?>][y]" value="<?php echo(isset($gis_data[$a][$type][$i][$j]['x']) ? htmlspecialchars($gis_data[$a][$type][$i][$j]['y']) : ''); ?>" />
|
||||
<?php }
|
||||
?> <input type="submit" name="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][add_point]" class="add addPoint" value="<?php echo __("Add a point"); ?>">
|
||||
<?php }
|
||||
$caption = ($type == 'MULTILINESTRING') ? __('Add a linestring') : __('Add an inner ring');
|
||||
?> <br/><input type="submit" name="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][add_line]" class="add addLine" value="<?php echo($caption); ?>">
|
||||
<?php
|
||||
} elseif ($type == 'MULTIPOLYGON') {
|
||||
$no_of_polygons = isset($gis_data[$a][$type]['no_of_polygons']) ? $gis_data[$a][$type]['no_of_polygons'] : 1;
|
||||
if ($no_of_polygons < 1) {
|
||||
$no_of_polygons = 1;
|
||||
}
|
||||
if (isset($gis_data[$a][$type]['add_polygon'])) {
|
||||
$no_of_polygons++;
|
||||
}
|
||||
echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][no_of_polygons]" value="' . $no_of_polygons . '">');
|
||||
|
||||
for ($k = 0; $k < $no_of_polygons; $k++) {
|
||||
echo('<br/>'); echo __("Polygon"); echo($k + 1 . ':');
|
||||
$no_of_lines = isset($gis_data[$a][$type][$k]['no_of_lines']) ? $gis_data[$a][$type][$k]['no_of_lines'] : 1;
|
||||
if ($no_of_lines < 1) {
|
||||
$no_of_lines = 1;
|
||||
}
|
||||
if (isset($gis_data[$a][$type][$k]['add_line'])) {
|
||||
$no_of_lines++;
|
||||
}
|
||||
echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][' . $k . '][no_of_lines]" value="' . $no_of_lines . '">');
|
||||
|
||||
for ($i = 0; $i < $no_of_lines; $i++) {
|
||||
echo('<br/><br/>');
|
||||
if ($i == 0) {
|
||||
echo __("Outer Ring:");
|
||||
} else {
|
||||
echo __("Inner Ring"); echo($i . ':');
|
||||
}
|
||||
|
||||
$no_of_points = isset($gis_data[$a][$type][$k][$i]['no_of_points']) ? $gis_data[$a][$type][$k][$i]['no_of_points'] : 4;
|
||||
if ($no_of_points < 4) {
|
||||
$no_of_points = 4;
|
||||
}
|
||||
if (isset($gis_data[$a][$type][$k][$i]['add_point'])) {
|
||||
$no_of_points++;
|
||||
}
|
||||
echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][' . $k . '][' . $i . '][no_of_points]" value="' . $no_of_points . '">');
|
||||
|
||||
for ($j = 0; $j < $no_of_points; $j++) {
|
||||
echo('<br/>'); echo __("Point"); echo($j + 1 . ':');
|
||||
?> <label for="x"><?php echo __("X"); ?></label>
|
||||
<input type="text" name="<?php echo("gis_data[" . $a . "][" . $type . "][" . $k . "][" . $i . "][" . $j . "][x]"); ?>" value="<?php echo(isset($gis_data[$a][$type][$k][$i][$j]['x']) ? htmlspecialchars($gis_data[$a][$type][$k][$i][$j]['x']) : ''); ?>" />
|
||||
<label for="y"><?php echo __("Y"); ?></label>
|
||||
<input type="text" name="<?php echo("gis_data[" . $a . "][" . $type . "][" . $k . "][" . $i . "][" . $j . "][y]"); ?>" value="<?php echo(isset($gis_data[$a][$type][$k][$i][$j]['y']) ? htmlspecialchars($gis_data[$a][$type][$k][$i][$j]['y']) : ''); ?>" />
|
||||
<?php }
|
||||
?> <input type="submit" name="<?php echo("gis_data[" . $a . "][" . $type . "][" . $k . "][" . $i . "][add_point]"); ?>" class="add addPoint" value="<?php echo __("Add a point"); ?>">
|
||||
<?php }
|
||||
?> <br/><input type="submit" name="<?php echo("gis_data[" . $a . "][" . $type . "][" . $k . "][add_line]"); ?>" class="add addLine" value="<?php echo __('Add an inner ring') ?>"><br/>
|
||||
<?php }
|
||||
?> <br/><input type="submit" name="<?php echo("gis_data[" . $a . "][" . $type . "][add_polygon]"); ?>" class="add addPolygon" value="<?php echo __('Add a polygon') ?>">
|
||||
<?php }
|
||||
}
|
||||
if ($geom_type == 'GEOMETRYCOLLECTION') {
|
||||
?> <br/><br/><input type="submit" name="gis_data[GEOMETRYCOLLECTION][add_geom]" class="add addGeom" value="<?php echo __("Add geometry"); ?>" />
|
||||
<?php }
|
||||
?> </div>
|
||||
<!-- End of data section -->
|
||||
|
||||
<br/><input type="submit" name="gis_data[save]" value="<?php echo __('Go') ?>">
|
||||
<div id="gis_data_output">
|
||||
<h3><?php echo __('Output'); ?></h3>
|
||||
<p><?php echo __('Chose "GeomFromText" from the "Function" column and paste the below string into the "Value" field'); ?></p>
|
||||
<textarea id="gis_data_textarea" cols="95" rows="5">
|
||||
<?php echo($result);
|
||||
?> </textarea>
|
||||
</div>
|
||||
</div>
|
||||
</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';
|
||||
|
||||
?>
|
||||
125
js/OpenStreetMap.js
Normal file
125
js/OpenStreetMap.js
Normal file
@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Namespace: Util.OSM
|
||||
*/
|
||||
OpenLayers.Util.OSM = {};
|
||||
|
||||
/**
|
||||
* Constant: MISSING_TILE_URL
|
||||
* {String} URL of image to display for missing tiles
|
||||
*/
|
||||
OpenLayers.Util.OSM.MISSING_TILE_URL = "http://www.openstreetmap.org/openlayers/img/404.png";
|
||||
|
||||
/**
|
||||
* Property: originalOnImageLoadError
|
||||
* {Function} Original onImageLoadError function.
|
||||
*/
|
||||
OpenLayers.Util.OSM.originalOnImageLoadError = OpenLayers.Util.onImageLoadError;
|
||||
|
||||
/**
|
||||
* Function: onImageLoadError
|
||||
*/
|
||||
OpenLayers.Util.onImageLoadError = function() {
|
||||
if (this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)) {
|
||||
this.src = OpenLayers.Util.OSM.MISSING_TILE_URL;
|
||||
} else if (this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)) {
|
||||
// do nothing - this layer is transparent
|
||||
} else {
|
||||
OpenLayers.Util.OSM.originalOnImageLoadError;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Layer.OSM.Mapnik
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Layer.OSM>
|
||||
*/
|
||||
OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
||||
/**
|
||||
* Constructor: OpenLayers.Layer.OSM.Mapnik
|
||||
*
|
||||
* Parameters:
|
||||
* name - {String}
|
||||
* options - {Object} Hashtable of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, options) {
|
||||
var url = [
|
||||
"http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
|
||||
"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
|
||||
"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
|
||||
];
|
||||
options = OpenLayers.Util.extend({
|
||||
numZoomLevels: 19,
|
||||
buffer: 0,
|
||||
transitionEffect: "resize"
|
||||
}, options);
|
||||
var newArguments = [name, url, options];
|
||||
OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik"
|
||||
});
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Layer.OSM.Osmarender
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Layer.OSM>
|
||||
*/
|
||||
OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
||||
/**
|
||||
* Constructor: OpenLayers.Layer.OSM.Osmarender
|
||||
*
|
||||
* Parameters:
|
||||
* name - {String}
|
||||
* options - {Object} Hashtable of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, options) {
|
||||
var url = [
|
||||
"http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
|
||||
"http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
|
||||
"http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
|
||||
];
|
||||
options = OpenLayers.Util.extend({
|
||||
numZoomLevels: 18,
|
||||
buffer: 0,
|
||||
transitionEffect: "resize"
|
||||
}, options);
|
||||
var newArguments = [name, url, options];
|
||||
OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender"
|
||||
});
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Layer.OSM.CycleMap
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Layer.OSM>
|
||||
*/
|
||||
OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
||||
/**
|
||||
* Constructor: OpenLayers.Layer.OSM.CycleMap
|
||||
*
|
||||
* Parameters:
|
||||
* name - {String}
|
||||
* options - {Object} Hashtable of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, options) {
|
||||
var url = [
|
||||
"http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
|
||||
"http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
|
||||
"http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"
|
||||
];
|
||||
options = OpenLayers.Util.extend({
|
||||
numZoomLevels: 19,
|
||||
buffer: 0,
|
||||
transitionEffect: "resize"
|
||||
}, options);
|
||||
var newArguments = [name, url, options];
|
||||
OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap"
|
||||
});
|
||||
@ -1,288 +0,0 @@
|
||||
/**
|
||||
* A class to parse color values
|
||||
* @author Stoyan Stefanov <sstoo@gmail.com>
|
||||
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
|
||||
* @license Use it if you like it
|
||||
*/
|
||||
function RGBColor(color_string)
|
||||
{
|
||||
this.ok = false;
|
||||
|
||||
// strip any leading #
|
||||
if (color_string.charAt(0) == '#') { // remove # if any
|
||||
color_string = color_string.substr(1,6);
|
||||
}
|
||||
|
||||
color_string = color_string.replace(/ /g,'');
|
||||
color_string = color_string.toLowerCase();
|
||||
|
||||
// before getting into regexps, try simple matches
|
||||
// and overwrite the input
|
||||
var simple_colors = {
|
||||
aliceblue: 'f0f8ff',
|
||||
antiquewhite: 'faebd7',
|
||||
aqua: '00ffff',
|
||||
aquamarine: '7fffd4',
|
||||
azure: 'f0ffff',
|
||||
beige: 'f5f5dc',
|
||||
bisque: 'ffe4c4',
|
||||
black: '000000',
|
||||
blanchedalmond: 'ffebcd',
|
||||
blue: '0000ff',
|
||||
blueviolet: '8a2be2',
|
||||
brown: 'a52a2a',
|
||||
burlywood: 'deb887',
|
||||
cadetblue: '5f9ea0',
|
||||
chartreuse: '7fff00',
|
||||
chocolate: 'd2691e',
|
||||
coral: 'ff7f50',
|
||||
cornflowerblue: '6495ed',
|
||||
cornsilk: 'fff8dc',
|
||||
crimson: 'dc143c',
|
||||
cyan: '00ffff',
|
||||
darkblue: '00008b',
|
||||
darkcyan: '008b8b',
|
||||
darkgoldenrod: 'b8860b',
|
||||
darkgray: 'a9a9a9',
|
||||
darkgreen: '006400',
|
||||
darkkhaki: 'bdb76b',
|
||||
darkmagenta: '8b008b',
|
||||
darkolivegreen: '556b2f',
|
||||
darkorange: 'ff8c00',
|
||||
darkorchid: '9932cc',
|
||||
darkred: '8b0000',
|
||||
darksalmon: 'e9967a',
|
||||
darkseagreen: '8fbc8f',
|
||||
darkslateblue: '483d8b',
|
||||
darkslategray: '2f4f4f',
|
||||
darkturquoise: '00ced1',
|
||||
darkviolet: '9400d3',
|
||||
deeppink: 'ff1493',
|
||||
deepskyblue: '00bfff',
|
||||
dimgray: '696969',
|
||||
dodgerblue: '1e90ff',
|
||||
feldspar: 'd19275',
|
||||
firebrick: 'b22222',
|
||||
floralwhite: 'fffaf0',
|
||||
forestgreen: '228b22',
|
||||
fuchsia: 'ff00ff',
|
||||
gainsboro: 'dcdcdc',
|
||||
ghostwhite: 'f8f8ff',
|
||||
gold: 'ffd700',
|
||||
goldenrod: 'daa520',
|
||||
gray: '808080',
|
||||
green: '008000',
|
||||
greenyellow: 'adff2f',
|
||||
honeydew: 'f0fff0',
|
||||
hotpink: 'ff69b4',
|
||||
indianred : 'cd5c5c',
|
||||
indigo : '4b0082',
|
||||
ivory: 'fffff0',
|
||||
khaki: 'f0e68c',
|
||||
lavender: 'e6e6fa',
|
||||
lavenderblush: 'fff0f5',
|
||||
lawngreen: '7cfc00',
|
||||
lemonchiffon: 'fffacd',
|
||||
lightblue: 'add8e6',
|
||||
lightcoral: 'f08080',
|
||||
lightcyan: 'e0ffff',
|
||||
lightgoldenrodyellow: 'fafad2',
|
||||
lightgrey: 'd3d3d3',
|
||||
lightgreen: '90ee90',
|
||||
lightpink: 'ffb6c1',
|
||||
lightsalmon: 'ffa07a',
|
||||
lightseagreen: '20b2aa',
|
||||
lightskyblue: '87cefa',
|
||||
lightslateblue: '8470ff',
|
||||
lightslategray: '778899',
|
||||
lightsteelblue: 'b0c4de',
|
||||
lightyellow: 'ffffe0',
|
||||
lime: '00ff00',
|
||||
limegreen: '32cd32',
|
||||
linen: 'faf0e6',
|
||||
magenta: 'ff00ff',
|
||||
maroon: '800000',
|
||||
mediumaquamarine: '66cdaa',
|
||||
mediumblue: '0000cd',
|
||||
mediumorchid: 'ba55d3',
|
||||
mediumpurple: '9370d8',
|
||||
mediumseagreen: '3cb371',
|
||||
mediumslateblue: '7b68ee',
|
||||
mediumspringgreen: '00fa9a',
|
||||
mediumturquoise: '48d1cc',
|
||||
mediumvioletred: 'c71585',
|
||||
midnightblue: '191970',
|
||||
mintcream: 'f5fffa',
|
||||
mistyrose: 'ffe4e1',
|
||||
moccasin: 'ffe4b5',
|
||||
navajowhite: 'ffdead',
|
||||
navy: '000080',
|
||||
oldlace: 'fdf5e6',
|
||||
olive: '808000',
|
||||
olivedrab: '6b8e23',
|
||||
orange: 'ffa500',
|
||||
orangered: 'ff4500',
|
||||
orchid: 'da70d6',
|
||||
palegoldenrod: 'eee8aa',
|
||||
palegreen: '98fb98',
|
||||
paleturquoise: 'afeeee',
|
||||
palevioletred: 'd87093',
|
||||
papayawhip: 'ffefd5',
|
||||
peachpuff: 'ffdab9',
|
||||
peru: 'cd853f',
|
||||
pink: 'ffc0cb',
|
||||
plum: 'dda0dd',
|
||||
powderblue: 'b0e0e6',
|
||||
purple: '800080',
|
||||
red: 'ff0000',
|
||||
rosybrown: 'bc8f8f',
|
||||
royalblue: '4169e1',
|
||||
saddlebrown: '8b4513',
|
||||
salmon: 'fa8072',
|
||||
sandybrown: 'f4a460',
|
||||
seagreen: '2e8b57',
|
||||
seashell: 'fff5ee',
|
||||
sienna: 'a0522d',
|
||||
silver: 'c0c0c0',
|
||||
skyblue: '87ceeb',
|
||||
slateblue: '6a5acd',
|
||||
slategray: '708090',
|
||||
snow: 'fffafa',
|
||||
springgreen: '00ff7f',
|
||||
steelblue: '4682b4',
|
||||
tan: 'd2b48c',
|
||||
teal: '008080',
|
||||
thistle: 'd8bfd8',
|
||||
tomato: 'ff6347',
|
||||
turquoise: '40e0d0',
|
||||
violet: 'ee82ee',
|
||||
violetred: 'd02090',
|
||||
wheat: 'f5deb3',
|
||||
white: 'ffffff',
|
||||
whitesmoke: 'f5f5f5',
|
||||
yellow: 'ffff00',
|
||||
yellowgreen: '9acd32'
|
||||
};
|
||||
for (var key in simple_colors) {
|
||||
if (color_string == key) {
|
||||
color_string = simple_colors[key];
|
||||
}
|
||||
}
|
||||
// emd of simple type-in colors
|
||||
|
||||
// array of color definition objects
|
||||
var color_defs = [
|
||||
{
|
||||
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
|
||||
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
|
||||
process: function (bits){
|
||||
return [
|
||||
parseInt(bits[1]),
|
||||
parseInt(bits[2]),
|
||||
parseInt(bits[3])
|
||||
];
|
||||
}
|
||||
},
|
||||
{
|
||||
re: /^(\w{2})(\w{2})(\w{2})$/,
|
||||
example: ['#00ff00', '336699'],
|
||||
process: function (bits){
|
||||
return [
|
||||
parseInt(bits[1], 16),
|
||||
parseInt(bits[2], 16),
|
||||
parseInt(bits[3], 16)
|
||||
];
|
||||
}
|
||||
},
|
||||
{
|
||||
re: /^(\w{1})(\w{1})(\w{1})$/,
|
||||
example: ['#fb0', 'f0f'],
|
||||
process: function (bits){
|
||||
return [
|
||||
parseInt(bits[1] + bits[1], 16),
|
||||
parseInt(bits[2] + bits[2], 16),
|
||||
parseInt(bits[3] + bits[3], 16)
|
||||
];
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// search through the definitions to find a match
|
||||
for (var i = 0; i < color_defs.length; i++) {
|
||||
var re = color_defs[i].re;
|
||||
var processor = color_defs[i].process;
|
||||
var bits = re.exec(color_string);
|
||||
if (bits) {
|
||||
channels = processor(bits);
|
||||
this.r = channels[0];
|
||||
this.g = channels[1];
|
||||
this.b = channels[2];
|
||||
this.ok = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// validate/cleanup values
|
||||
this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
|
||||
this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
|
||||
this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
|
||||
|
||||
// some getters
|
||||
this.toRGB = function () {
|
||||
return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
|
||||
}
|
||||
this.toHex = function () {
|
||||
var r = this.r.toString(16);
|
||||
var g = this.g.toString(16);
|
||||
var b = this.b.toString(16);
|
||||
if (r.length == 1) r = '0' + r;
|
||||
if (g.length == 1) g = '0' + g;
|
||||
if (b.length == 1) b = '0' + b;
|
||||
return '#' + r + g + b;
|
||||
}
|
||||
|
||||
// help
|
||||
this.getHelpXML = function () {
|
||||
|
||||
var examples = new Array();
|
||||
// add regexps
|
||||
for (var i = 0; i < color_defs.length; i++) {
|
||||
var example = color_defs[i].example;
|
||||
for (var j = 0; j < example.length; j++) {
|
||||
examples[examples.length] = example[j];
|
||||
}
|
||||
}
|
||||
// add type-in colors
|
||||
for (var sc in simple_colors) {
|
||||
examples[examples.length] = sc;
|
||||
}
|
||||
|
||||
var xml = document.createElement('ul');
|
||||
xml.setAttribute('id', 'rgbcolor-examples');
|
||||
for (var i = 0; i < examples.length; i++) {
|
||||
try {
|
||||
var list_item = document.createElement('li');
|
||||
var list_color = new RGBColor(examples[i]);
|
||||
var example_div = document.createElement('div');
|
||||
example_div.style.cssText =
|
||||
'margin: 3px; '
|
||||
+ 'border: 1px solid black; '
|
||||
+ 'background:' + list_color.toHex() + '; '
|
||||
+ 'color:' + list_color.toHex()
|
||||
;
|
||||
example_div.appendChild(document.createTextNode('test'));
|
||||
var list_item_value = document.createTextNode(
|
||||
' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()
|
||||
);
|
||||
list_item.appendChild(example_div);
|
||||
list_item.appendChild(list_item_value);
|
||||
xml.appendChild(list_item);
|
||||
|
||||
} catch(e){}
|
||||
}
|
||||
return xml;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
49
js/codemirror/mode/mysql/mysql.js
vendored
49
js/codemirror/mode/mysql/mysql.js
vendored
@ -1,11 +1,14 @@
|
||||
CodeMirror.defineMode("mysql", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit,
|
||||
keywords = parserConfig.keywords,
|
||||
verbs = parserConfig.verbs,
|
||||
functions = parserConfig.functions,
|
||||
types = parserConfig.types,
|
||||
attributes = parserConfig.attributes,
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
attributes = parserConfig.attributes,
|
||||
multiLineStrings = parserConfig.multiLineStrings,
|
||||
multiPartKeywords= parserConfig.multiPartKeywords;
|
||||
var isOperatorChar = /[+\-*&%=<>!?:\/|]/;
|
||||
|
||||
function chain(stream, state, f) {
|
||||
state.tokenize = f;
|
||||
return f(stream, state);
|
||||
@ -64,14 +67,35 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
|
||||
else {
|
||||
// get the whole word
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var word = stream.current().toLowerCase();
|
||||
var oldPos = stream.pos;
|
||||
// is it one of the listed verbs?
|
||||
if (verbs && verbs.propertyIsEnumerable(word)) return ret("keyword", "statement-verb");
|
||||
// is it one of the listed keywords?
|
||||
if (keywords && keywords.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "keyword");
|
||||
if (keywords && keywords.propertyIsEnumerable(word)) return ret("keyword", "keyword");
|
||||
// is it one of the listed functions?
|
||||
if (functions && functions.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "builtin");
|
||||
if (functions && functions.propertyIsEnumerable(word)) {
|
||||
// All functions begin with '('
|
||||
stream.eatSpace();
|
||||
if(stream.peek() == '(')
|
||||
return ret("keyword", "builtin");
|
||||
// Not func => restore old pos
|
||||
stream.pos = oldPos;
|
||||
}
|
||||
// is it one of the listed types?
|
||||
if (types && types.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-2");
|
||||
if (types && types.propertyIsEnumerable(word)) return ret("keyword", "variable-2");
|
||||
// is it one of the listed attributes?
|
||||
if (attributes && attributes.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-3");
|
||||
if (attributes && attributes.propertyIsEnumerable(word)) return ret("keyword", "variable-3");
|
||||
// is it a multipart keyword? (currently only checks 2 word parts)
|
||||
|
||||
stream.eatSpace();
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var doubleWord = stream.current().toLowerCase();
|
||||
if (multiPartKeywords && multiPartKeywords.propertyIsEnumerable(doubleWord)) return ret("keyword", "keyword");
|
||||
|
||||
// restore old pos
|
||||
stream.pos = oldPos;
|
||||
|
||||
// default: just a "word"
|
||||
return ret("word", "mysql-word");
|
||||
}
|
||||
@ -122,11 +146,14 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
|
||||
|
||||
(function() {
|
||||
function keywords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
var obj = {}, words = str;
|
||||
if(typeof str == 'string') words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var cKeywords = "accessible add all alter analyze and as asc asensitive before between bigint binary blob both by call cascade case change char character check collate column condition constraint continue convert create cross current_date current_time current_timestamp current_user cursor database databases day_hour day_microsecond day_minute day_second dec decimal declare default delayed delete desc describe deterministic distinct distinctrow div double drop dual each else elseif enclosed escaped exists exit explain false fetch float float4 float8 for force foreign from fulltext grant group having high_priority hour_microsecond hour_minute hour_second if ignore in index infile inner inout insensitive insert int int1 int2 int3 int4 int8 integer interval into is iterate join key keys kill leading leave left like limit linear lines load localtime localtimestamp lock long longblob longtext loop low_priority master_ssl_verify_server_cert match maxvalue mediumblob mediumint mediumtext middleint minute_microsecond minute_second mod modifies natural not no_write_to_binlog null numeric on optimize option optionally or order out outer outfile precision primary procedure purge range read reads read_write real references regexp release rename repeat replace require resignal restrict return revoke right rlike schema schemas second_microsecond select sensitive separator set show signal smallint spatial specific sql sqlexception sqlstate sqlwarning sql_big_result sql_calc_found_rows sql_small_result ssl starting straight_join table terminated then tinyblob tinyint tinytext to trailing trigger true undo union unique unlock unsigned update usage use using utc_date utc_time utc_timestamp values varbinary varchar varcharacter varying when where while with write xor year_month zerofill";
|
||||
var cKeywords = "accessible add all and as asc asensitive before between bigint binary blob both cascade case char character collate column condition constraint continue convert cross current_date current_time current_timestamp current_user cursor database databases day_hour day_microsecond day_minute day_second dec decimal declare default delayed desc deterministic distinct distinctrow div double dual each else elseif enclosed escaped exists exit explain false fetch float float4 float8 for force foreign fulltext from having high_priority hour_microsecond hour_minute hour_second if ignore in index infile inner inout insensitive int int1 int2 int3 int4 int8 integer interval is iterate join key keys leading leave left like limit linear lines localtime localtimestamp long longblob longtext loop low_priority master_ssl_verify_server_cert match maxvalue mediumblob mediumint mediumtext middleint minute_microsecond minute_second mod modifies natural not no_write_to_binlog null numeric on option optionally or out outer outfile precision primary procedure range read reads read_write real references regexp repeat require restrict return right rlike schema schemas second_microsecond sensitive separator smallint spatial specific sql sqlexception sqlstate sqlwarning sql_big_result sql_calc_found_rows sql_small_result ssl starting straight_join table terminated then tinyblob tinyint tinytext to trailing trigger true undo union unique unsigned usage using utc_date utc_time utc_timestamp values varbinary varchar varcharacter varying when where while with write xor year_month zerofill";
|
||||
|
||||
var cVerbs = "alter analyze begin binlog call change check checksum commit create deallocate describe do drop execute flush grant handler install kill load lock optimize cache partition prepare purge release rename repair replace reset resignal revoke rollback savepoint select set signal show start truncate uninstall unlock update use xa";
|
||||
|
||||
var cFunctions = "abs acos adddate addtime aes_decrypt aes_encrypt area asbinary ascii asin astext atan atan2 avg bdmpolyfromtext bdmpolyfromwkb bdpolyfromtext bdpolyfromwkb benchmark bin bit_and bit_count bit_length bit_or bit_xor boundary buffer cast ceil ceiling centroid char character_length charset char_length coalesce coercibility collation compress concat concat_ws connection_id contains conv convert convert_tz convexhull cos cot count crc32 crosses curdate current_date current_time current_timestamp current_user curtime database date datediff date_add date_diff date_format date_sub day dayname dayofmonth dayofweek dayofyear decode default degrees des_decrypt des_encrypt difference dimension disjoint distance elt encode encrypt endpoint envelope equals exp export_set exteriorring extract extractvalue field find_in_set floor format found_rows from_days from_unixtime geomcollfromtext geomcollfromwkb geometrycollection geometrycollectionfromtext geometrycollectionfromwkb geometryfromtext geometryfromwkb geometryn geometrytype geomfromtext geomfromwkb get_format get_lock glength greatest group_concat group_unique_users hex hour if ifnull inet_aton inet_ntoa insert instr interiorringn intersection intersects interval isclosed isempty isnull isring issimple is_free_lock is_used_lock last_day last_insert_id lcase least left length linefromtext linefromwkb linestring linestringfromtext linestringfromwkb ln load_file localtime localtimestamp locate log log10 log2 lower lpad ltrim makedate maketime make_set master_pos_wait max mbrcontains mbrdisjoint mbrequal mbrintersects mbroverlaps mbrtouches mbrwithin md5 microsecond mid min minute mlinefromtext mlinefromwkb mod month monthname mpointfromtext mpointfromwkb mpolyfromtext mpolyfromwkb multilinestring multilinestringfromtext multilinestringfromwkb multipoint multipointfromtext multipointfromwkb multipolygon multipolygonfromtext multipolygonfromwkb name_const now nullif numgeometries numinteriorrings numpoints oct octet_length old_password ord overlaps password period_add period_diff pi point pointfromtext pointfromwkb pointn pointonsurface polyfromtext polyfromwkb polygon polygonfromtext polygonfromwkb position pow power quarter quote radians rand related release_lock repeat replace reverse right round row_count rpad rtrim schema second sec_to_time session_user sha sha1 sign sin sleep soundex space sqrt srid startpoint std stddev stddev_pop stddev_samp strcmp str_to_date subdate substr substring substring_index subtime sum symdifference sysdate system_user tan time timediff timestamp timestampadd timestampdiff time_format time_to_sec touches to_days trim truncate ucase uncompress uncompressed_length unhex unique_users unix_timestamp updatexml upper user utc_date utc_time utc_timestamp uuid variance var_pop var_samp version week weekday weekofyear within x y year yearweek";
|
||||
|
||||
@ -134,11 +161,15 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
|
||||
|
||||
var cAttributes = "archive ascii auto_increment bdb berkeleydb binary blackhole csv default example federated heap innobase innodb isam maria memory merge mrg_isam mrg_myisam myisam national ndb ndbcluster precision undefined unicode unsigned varying zerofill";
|
||||
|
||||
var cmultiPartKeywords = ['insert into', 'group by', 'order by', 'delete from'];
|
||||
|
||||
CodeMirror.defineMIME("text/x-mysql", {
|
||||
name: "mysql",
|
||||
keywords: keywords(cKeywords),
|
||||
multiPartKeywords: keywords(cmultiPartKeywords),
|
||||
verbs: keywords(cVerbs),
|
||||
functions: keywords(cFunctions),
|
||||
types: keywords(cTypes),
|
||||
attributes: keywords(cAttributes)
|
||||
});
|
||||
}());
|
||||
}());
|
||||
215
js/functions.js
215
js/functions.js
@ -150,13 +150,15 @@ function PMA_addDatepicker($this_element, options)
|
||||
showOn: 'button',
|
||||
buttonImage: themeCalendarImage, // defined in js/messages.php
|
||||
buttonImageOnly: true,
|
||||
duration: '',
|
||||
time24h: true,
|
||||
stepMinutes: 1,
|
||||
stepHours: 1,
|
||||
showTime: showTimeOption,
|
||||
showSecond: true,
|
||||
showTimepicker: showTimeOption,
|
||||
showButtonPanel: false,
|
||||
dateFormat: 'yy-mm-dd', // yy means year with four digits
|
||||
altTimeField: '',
|
||||
timeFormat: 'hh:mm:ss',
|
||||
altFieldTimeOnly: false,
|
||||
showAnim: '',
|
||||
beforeShow: function(input, inst) {
|
||||
// Remember that we came from the datepicker; this is used
|
||||
// in tbl_change.js by verificationsAfterFieldChange()
|
||||
@ -166,11 +168,10 @@ function PMA_addDatepicker($this_element, options)
|
||||
setTimeout(function() {
|
||||
$('#ui-timepicker-div').css('z-index',$('#ui-datepicker-div').css('z-index'))
|
||||
},0);
|
||||
},
|
||||
constrainInput: false
|
||||
}
|
||||
};
|
||||
|
||||
$this_element.datepicker($.extend(defaultOptions, options));
|
||||
$this_element.datetimepicker($.extend(defaultOptions, options));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -611,7 +612,7 @@ $(document).ready(function() {
|
||||
var $tr = $(this);
|
||||
|
||||
// make the table unselectable (to prevent default highlighting when shift+click)
|
||||
$tr.parents('table').noSelect();
|
||||
//$tr.parents('table').noSelect();
|
||||
|
||||
if (!e.shiftKey || last_clicked_row == -1) {
|
||||
// usual click
|
||||
@ -642,6 +643,7 @@ $(document).ready(function() {
|
||||
last_shift_clicked_row = -1;
|
||||
} else {
|
||||
// handle the shift click
|
||||
PMA_clearSelection();
|
||||
var start, end;
|
||||
|
||||
// clear last shift click result
|
||||
@ -683,10 +685,12 @@ $(document).ready(function() {
|
||||
/**
|
||||
* Add a date/time picker to each element that needs it
|
||||
*/
|
||||
$('.datefield, .datetimefield').each(function() {
|
||||
PMA_addDatepicker($(this));
|
||||
});
|
||||
})
|
||||
if ($.datetimepicker != undefined) {
|
||||
$('.datefield, .datetimefield').each(function() {
|
||||
PMA_addDatepicker($(this));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* True if last click is to check a row.
|
||||
@ -902,26 +906,6 @@ function goToUrl(selObj, goToLocation)
|
||||
eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* getElement
|
||||
*/
|
||||
function getElement(e,f)
|
||||
{
|
||||
if(document.layers){
|
||||
f=(f)?f:self;
|
||||
if(f.document.layers[e]) {
|
||||
return f.document.layers[e];
|
||||
}
|
||||
for(W=0;W<f.document.layers.length;W++) {
|
||||
return(getElement(e,f.document.layers[W]));
|
||||
}
|
||||
}
|
||||
if(document.all) {
|
||||
return document.all[e];
|
||||
}
|
||||
return document.getElementById(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the WYSIWYG scratchboard after changes have been made
|
||||
*/
|
||||
@ -1633,7 +1617,13 @@ function PMA_createProfilingChart(data, options)
|
||||
},options));
|
||||
}
|
||||
|
||||
// Formats a profiling duration nicely. Used in PMA_createProfilingChart() and server_status.js
|
||||
/**
|
||||
* Formats a profiling duration nicely (in us and ms time). Used in PMA_createProfilingChart() and server_status.js
|
||||
*
|
||||
* @param integer Number to be formatted, should be in the range of microsecond to second
|
||||
* @param integer Acuracy, how many numbers right to the comma should be
|
||||
* @return string The formatted number
|
||||
*/
|
||||
function PMA_prettyProfilingNum(num, acc)
|
||||
{
|
||||
if (!acc) {
|
||||
@ -1651,6 +1641,150 @@ function PMA_prettyProfilingNum(num, acc)
|
||||
return num + 's';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats a SQL Query nicely with newlines and indentation. Depends on Codemirror and MySQL Mode!
|
||||
*
|
||||
* @param string Query to be formatted
|
||||
* @return string The formatted query
|
||||
*/
|
||||
function PMA_SQLPrettyPrint(string)
|
||||
{
|
||||
var mode = CodeMirror.getMode({},"text/x-mysql");
|
||||
var stream = new CodeMirror.StringStream(string);
|
||||
var state = mode.startState();
|
||||
var token, tokens = [];
|
||||
var output = '';
|
||||
var tabs = function(cnt) {
|
||||
var ret = '';
|
||||
for (var i=0; i<4*cnt; i++)
|
||||
ret += " ";
|
||||
return ret;
|
||||
};
|
||||
|
||||
// "root-level" statements
|
||||
var statements = {
|
||||
'select': ['select', 'from','on','where','having','limit','order by','group by'],
|
||||
'update': ['update', 'set','where'],
|
||||
'insert into': ['insert into', 'values']
|
||||
};
|
||||
// don't put spaces before these tokens
|
||||
var spaceExceptionsBefore = { ';':true, ',': true, '.': true, '(': true };
|
||||
// don't put spaces after these tokens
|
||||
var spaceExceptionsAfter = { '.': true };
|
||||
|
||||
// Populate tokens array
|
||||
var str='';
|
||||
while (! stream.eol()) {
|
||||
stream.start = stream.pos;
|
||||
token = mode.token(stream, state);
|
||||
if(token != null) {
|
||||
tokens.push([token, stream.current().toLowerCase()]);
|
||||
}
|
||||
}
|
||||
|
||||
var currentStatement = tokens[0][1];
|
||||
|
||||
if(! statements[currentStatement]) {
|
||||
return string;
|
||||
}
|
||||
// Holds all currently opened code blocks (statement, function or generic)
|
||||
var blockStack = [];
|
||||
// Holds the type of block from last iteration (the current is in blockStack[0])
|
||||
var previousBlock;
|
||||
// If a new code block is found, newBlock contains its type for one iteration and vice versa for endBlock
|
||||
var newBlock, endBlock;
|
||||
// How much to indent in the current line
|
||||
var indentLevel = 0;
|
||||
// Holds the "root-level" statements
|
||||
var statementPart, lastStatementPart = statements[currentStatement][0];
|
||||
|
||||
blockStack.unshift('statement');
|
||||
|
||||
// Iterate through every token and format accordingly
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
previousBlock = blockStack[0];
|
||||
|
||||
// New block => push to stack
|
||||
if (tokens[i][1] == '(') {
|
||||
if (i < tokens.length - 1 && tokens[i+1][0] == 'statement-verb') {
|
||||
blockStack.unshift(newBlock = 'statement');
|
||||
} else if (i > 0 && tokens[i-1][0] == 'builtin') {
|
||||
blockStack.unshift(newBlock = 'function');
|
||||
} else {
|
||||
blockStack.unshift(newBlock = 'generic');
|
||||
}
|
||||
} else {
|
||||
newBlock = null;
|
||||
}
|
||||
|
||||
// Block end => pop from stack
|
||||
if (tokens[i][1] == ')') {
|
||||
endBlock = blockStack[0];
|
||||
blockStack.shift();
|
||||
} else {
|
||||
endBlock = null;
|
||||
}
|
||||
|
||||
// A subquery is starting
|
||||
if (i > 0 && newBlock == 'statement') {
|
||||
indentLevel++;
|
||||
output += "\n" + tabs(indentLevel) + tokens[i][1] + ' ' + tokens[i+1][1].toUpperCase() + "\n" + tabs(indentLevel + 1);
|
||||
currentStatement = tokens[i+1][1];
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// A subquery is ending
|
||||
if (endBlock == 'statement' && indentLevel > 0) {
|
||||
output += "\n" + tabs(indentLevel);
|
||||
indentLevel--;
|
||||
}
|
||||
|
||||
// One less indentation for statement parts (from, where, order by, etc.) and a newline
|
||||
statementPart = statements[currentStatement].indexOf(tokens[i][1]);
|
||||
if (statementPart != -1) {
|
||||
if (i > 0) output += "\n";
|
||||
output += tabs(indentLevel) + tokens[i][1].toUpperCase();
|
||||
output += "\n" + tabs(indentLevel + 1);
|
||||
lastStatementPart = tokens[i][1];
|
||||
}
|
||||
// Normal indentatin and spaces for everything else
|
||||
else {
|
||||
if (! spaceExceptionsBefore[tokens[i][1]]
|
||||
&& ! (i > 0 && spaceExceptionsAfter[tokens[i-1][1]])
|
||||
&& output.charAt(output.length -1) != ' ' ) {
|
||||
output += " ";
|
||||
}
|
||||
if (tokens[i][0] == 'keyword') {
|
||||
output += tokens[i][1].toUpperCase();
|
||||
} else {
|
||||
output += tokens[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
// split columns in select and 'update set' clauses, but only inside statements blocks
|
||||
if (( lastStatementPart == 'select' || lastStatementPart == 'where' || lastStatementPart == 'set')
|
||||
&& tokens[i][1]==',' && blockStack[0] == 'statement') {
|
||||
|
||||
output += "\n" + tabs(indentLevel + 1);
|
||||
}
|
||||
|
||||
// split conditions in where clauses, but only inside statements blocks
|
||||
if (lastStatementPart == 'where'
|
||||
&& (tokens[i][1]=='and' || tokens[i][1]=='or' || tokens[i][1]=='xor')) {
|
||||
|
||||
if (blockStack[0] == 'statement') {
|
||||
output += "\n" + tabs(indentLevel + 1);
|
||||
}
|
||||
// Todo: Also split and or blocks in newlines & identation++
|
||||
//if(blockStack[0] == 'generic')
|
||||
// output += ...
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* jQuery function that uses jQueryUI's dialogs to confirm with user. Does not
|
||||
* return a jQuery object yet and hence cannot be chained
|
||||
@ -3173,8 +3307,6 @@ function PMA_getCellValue(td) {
|
||||
return '';
|
||||
} else if (! $(td).is('.to_be_saved') && $(td).data('original_data')) {
|
||||
return $(td).data('original_data');
|
||||
} else if ($(td).is(':not(.transformed, .relation, .enum, .set, .null)')) {
|
||||
return unescape($(td).find('span').html()).replace(/<br>/g, "\n");
|
||||
} else {
|
||||
return $(td).text();
|
||||
}
|
||||
@ -3225,3 +3357,16 @@ $(document).ready(function() {
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Clear text selection
|
||||
*/
|
||||
function PMA_clearSelection() {
|
||||
if(document.selection && document.selection.empty) {
|
||||
document.selection.empty();
|
||||
} else if(window.getSelection) {
|
||||
var sel = window.getSelection();
|
||||
if(sel.empty) sel.empty();
|
||||
if(sel.removeAllRanges) sel.removeAllRanges();
|
||||
}
|
||||
}
|
||||
|
||||
309
js/gis_data_editor.js
Normal file
309
js/gis_data_editor.js
Normal file
@ -0,0 +1,309 @@
|
||||
/**
|
||||
* @fileoverview functions used in GIS data editor
|
||||
*
|
||||
* @requires jQuery
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Closes the GIS data editor and perform necessary clean up work.
|
||||
*/
|
||||
function closeGISEditor(){
|
||||
$("#popup_background").fadeOut("fast");
|
||||
$("#gis_editor").fadeOut("fast");
|
||||
$("#gis_editor").html('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the HTML recieved via AJAX.
|
||||
*/
|
||||
function prepareJSVersion() {
|
||||
// Hide 'Go' buttons associated with the dropdowns
|
||||
$('.go').hide();
|
||||
|
||||
// Change the text on the submit button
|
||||
$("input[name='gis_data[save]']")
|
||||
.attr('value', PMA_messages['strCopy'])
|
||||
.insertAfter($('#gis_data_textarea'))
|
||||
.before('<br><br>');
|
||||
|
||||
// Add close and cancel links
|
||||
$('#gis_data_editor').prepend('<a class="close_gis_editor">' + PMA_messages['strClose'] + '</a>');
|
||||
$('<a class="cancel_gis_editor"> ' + PMA_messages['strCancel'] + '</a>')
|
||||
.insertAfter($("input[name='gis_data[save]']"));
|
||||
|
||||
// Remove the unnecessary text
|
||||
$('div#gis_data_output p').remove();
|
||||
|
||||
// Remove 'add' buttons and add links
|
||||
$('.add').each(function(e) {
|
||||
var $button = $(this);
|
||||
$button.addClass('addJs').removeClass('add');
|
||||
var classes = $button.attr('class');
|
||||
$button
|
||||
.after('<a class="' + classes + '" name="' + $button.attr('name')
|
||||
+ '">+ ' + $button.attr('value') + '</a>')
|
||||
.remove();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML for a data point.
|
||||
*
|
||||
* @param pointNumber point number
|
||||
* @param prefix prefix of the name
|
||||
* @returns the HTML for a data point
|
||||
*/
|
||||
function addDataPoint(pointNumber, prefix) {
|
||||
return '<br>' + PMA_messages['strPoint'] + (pointNumber + 1) + ':'
|
||||
+ '<label for="x"> ' + PMA_messages['strX'] + ' </label>'
|
||||
+ '<input type="text" name="' + prefix + '[' + pointNumber + '][x]" value="">'
|
||||
+ '<label for="y"> ' + PMA_messages['strY'] + ' </label>'
|
||||
+ '<input type="text" name="' + prefix + '[' + pointNumber + '][y]" value="">';
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the visualization in the GIS data editor.
|
||||
*/
|
||||
function initGISEditorVisualization() {
|
||||
// Loads either SVG or OSM visualization based on the choice
|
||||
selectVisualization();
|
||||
// Adds necessary styles to the div that coontains the openStreetMap
|
||||
styleOSM();
|
||||
// Loads the SVG element and make a reference to it
|
||||
loadSVG();
|
||||
// Adds controllers for zooming and panning
|
||||
addZoomPanControllers();
|
||||
zoomAndPan();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens up the GIS data editor.
|
||||
*
|
||||
* @param value current value of the geometry field
|
||||
* @param field field name
|
||||
* @param type geometry type
|
||||
* @param input_name name of the input field
|
||||
* @param token token
|
||||
*/
|
||||
function openGISEditor(value, field, type, input_name, token) {
|
||||
// Center the popup
|
||||
var windowWidth = document.documentElement.clientWidth;
|
||||
var windowHeight = document.documentElement.clientHeight;
|
||||
var popupWidth = windowWidth * 0.9;
|
||||
var popupHeight = windowHeight * 0.9;
|
||||
var popupOffsetTop = windowHeight / 2 - popupHeight / 2;
|
||||
var popupOffsetLeft = windowWidth / 2 - popupWidth / 2;
|
||||
var $gis_editor = $("#gis_editor");
|
||||
$gis_editor.css({"top": popupOffsetTop, "left": popupOffsetLeft, "width": popupWidth, "height": popupHeight});
|
||||
|
||||
$.post('gis_data_editor.php', {
|
||||
'field' : field,
|
||||
'value' : value,
|
||||
'type' : type,
|
||||
'input_name' : input_name,
|
||||
'get_gis_editor' : true,
|
||||
'token' : token
|
||||
}, function(data) {
|
||||
if(data.success == true) {
|
||||
$gis_editor.html(data.gis_editor);
|
||||
initGISEditorVisualization();
|
||||
prepareJSVersion();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
}
|
||||
}, 'json');
|
||||
|
||||
// Make it appear
|
||||
$("#popup_background").css({"opacity":"0.7"});
|
||||
$("#popup_background").fadeIn("fast");
|
||||
$gis_editor.fadeIn("fast");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and insert the GIS data in Well Known Text format
|
||||
* to the input field.
|
||||
*/
|
||||
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) {
|
||||
if(data.success == true) {
|
||||
$("input[name='" + input_name + "']").val(data.result);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
}
|
||||
}, 'json');
|
||||
closeGISEditor();
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// Remove the class that is added due to the URL being too long.
|
||||
$('.open_gis_editor a').removeClass('formLinkSubmit');
|
||||
|
||||
/**
|
||||
* Prepares and insert the GIS data to the input field on clicking 'copy'.
|
||||
*/
|
||||
$("input[name='gis_data[save]']").live('click', function(event) {
|
||||
event.preventDefault();
|
||||
insertDataAndClose();
|
||||
});
|
||||
|
||||
/**
|
||||
* Prepares and insert the GIS data to the input field on pressing 'enter'.
|
||||
*/
|
||||
$('#gis_editor').live('submit', function(event) {
|
||||
event.preventDefault();
|
||||
insertDataAndClose();
|
||||
});
|
||||
|
||||
/**
|
||||
* Trigger asynchronous calls on data change and update the output.
|
||||
*/
|
||||
$('#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) {
|
||||
if(data.success == true) {
|
||||
$('#gis_data_textarea').val(data.result);
|
||||
$('#placeholder').empty().removeClass('hasSVG').html(data.visualization);
|
||||
$('#openlayersmap').empty();
|
||||
eval(data.openLayers);
|
||||
initGISEditorVisualization();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
|
||||
/**
|
||||
* Update the form on change of the GIS type.
|
||||
*/
|
||||
$(".gis_type").live('change', function(event) {
|
||||
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) {
|
||||
if(data.success == true) {
|
||||
$gis_editor.html(data.gis_editor);
|
||||
initGISEditorVisualization();
|
||||
prepareJSVersion();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles closing of the GIS data editor.
|
||||
*/
|
||||
$('.close_gis_editor, .cancel_gis_editor').live('click', function() {
|
||||
closeGISEditor();
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles adding data points
|
||||
*/
|
||||
$('.addJs.addPoint').live('click', function() {
|
||||
var $a = $(this);
|
||||
var name = $a.attr('name');
|
||||
// Eg. name = gis_data[0][MULTIPOINT][add_point] => prefix = gis_data[0][MULTIPOINT]
|
||||
var prefix = name.substr(0, name.length - 11);
|
||||
// Find the number of points
|
||||
var $noOfPointsInput = $("input[name='" + prefix + "[no_of_points]" + "']");
|
||||
var noOfPoints = parseInt($noOfPointsInput.attr('value'));
|
||||
// Add the new data point
|
||||
var html = addDataPoint(noOfPoints, prefix);
|
||||
$a.before(html);
|
||||
$noOfPointsInput.attr('value', noOfPoints + 1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles adding linestrings and inner rings
|
||||
*/
|
||||
$('.addLine.addJs').live('click', function() {
|
||||
var $a = $(this);
|
||||
var name = $a.attr('name');
|
||||
|
||||
// Eg. name = gis_data[0][MULTILINESTRING][add_line] => prefix = gis_data[0][MULTILINESTRING]
|
||||
var prefix = name.substr(0, name.length - 10);
|
||||
var type = prefix.slice(prefix.lastIndexOf('[') + 1, prefix.lastIndexOf(']'));
|
||||
|
||||
// Find the number of lines
|
||||
var $noOfLinesInput = $("input[name='" + prefix + "[no_of_lines]" + "']");
|
||||
var noOfLines = parseInt($noOfLinesInput.attr('value'));
|
||||
|
||||
// Add the new linesting of inner ring based on the type
|
||||
var html = '<br>';
|
||||
if (type == 'MULTILINESTRING') {
|
||||
html += PMA_messages['strLineString'] + (noOfLines + 1) + ':';
|
||||
var noOfPoints = 2;
|
||||
} else {
|
||||
html += PMA_messages['strInnerRing'] + noOfLines + ':';
|
||||
var noOfPoints = 4;
|
||||
}
|
||||
html += '<input type="hidden" name="' + prefix + '[' + noOfLines + '][no_of_points]" value="' + noOfPoints + '">';
|
||||
for (i = 0; i < noOfPoints; i++) {
|
||||
html += addDataPoint(i, (prefix + '[' + noOfLines + ']'));
|
||||
}
|
||||
html += '<a class="addPoint addJs" name="' + prefix + '[' + noOfLines + '][add_point]">+ '
|
||||
+ PMA_messages['strAddPoint'] + '</a><br>';
|
||||
|
||||
$a.before(html);
|
||||
$noOfLinesInput.attr('value', noOfLines + 1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles adding polygons
|
||||
*/
|
||||
$('.addJs.addPolygon').live('click', function() {
|
||||
var $a = $(this);
|
||||
var name = $a.attr('name');
|
||||
// Eg. name = gis_data[0][MULTIPOLYGON][add_polygon] => prefix = gis_data[0][MULTIPOLYGON]
|
||||
var prefix = name.substr(0, name.length - 13);
|
||||
// Find the number of polygons
|
||||
var $noOfPolygonsInput = $("input[name='" + prefix + "[no_of_polygons]" + "']");
|
||||
var noOfPolygons = parseInt($noOfPolygonsInput.attr('value'));
|
||||
|
||||
// Add the new polygon
|
||||
var html = PMA_messages['strPolygon'] + (noOfPolygons + 1) + ':<br>';
|
||||
html += '<input type="hidden" name="' + prefix + '[' + noOfPolygons + '][no_of_lines]" value="1">';
|
||||
+ '<br>' + PMA_messages['strOuterRing'] + ':';
|
||||
+ '<input type="hidden" name="' + prefix + '[' + noOfPolygons + '][0][no_of_points]" value="4">';
|
||||
for (i = 0; i < 4; i++) {
|
||||
html += addDataPoint(i, (prefix + '[' + noOfPolygons + '][0]'));
|
||||
}
|
||||
html += '<a class="addPoint addJs" name="' + prefix + '[' + noOfPolygons + '][0][add_point]">+ '
|
||||
+ PMA_messages['strAddPoint'] + '</a><br>'
|
||||
+ '<a class="addLine addJs" name="' + prefix + '[' + noOfPolygons + '][add_line]">+ '
|
||||
+ PMA_messages['strAddInnerRing'] + '</a><br><br>';
|
||||
|
||||
$a.before(html);
|
||||
$noOfPolygonsInput.attr('value', noOfPolygons + 1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles adding geoms
|
||||
*/
|
||||
$('.addJs.addGeom').live('click', function() {
|
||||
var $a = $(this);
|
||||
var prefix = 'gis_data[GEOMETRYCOLLECTION]';
|
||||
// Find the number of geoms
|
||||
var $noOfGeomsInput = $("input[name='" + prefix + "[geom_count]" + "']");
|
||||
var noOfGeoms = parseInt($noOfGeomsInput.attr('value'));
|
||||
|
||||
var html1 = PMA_messages['strGeometry'] + (noOfGeoms + 1) + ':<br>';
|
||||
var $geomType = $("select[name='gis_data[" + (noOfGeoms - 1) + "][gis_type]']").clone();
|
||||
$geomType.attr('name', 'gis_data[' + noOfGeoms + '][gis_type]').val('POINT');
|
||||
var html2 = '<br>' + PMA_messages['strPoint'] + ' :'
|
||||
+ '<label for="x"> ' + PMA_messages['strX'] + ' </label>'
|
||||
+ '<input type="text" name="gis_data[' + noOfGeoms + '][POINT][x]" value="">'
|
||||
+ '<label for="y"> ' + PMA_messages['strY'] + ' </label>'
|
||||
+ '<input type="text" name="gis_data[' + noOfGeoms + '][POINT][y]" value="">'
|
||||
+ '<br><br>';
|
||||
|
||||
$a.before(html1); $geomType.insertBefore($a); $a.before(html2);
|
||||
$noOfGeomsInput.attr('value', noOfGeoms + 1);
|
||||
});
|
||||
});
|
||||
@ -826,9 +826,11 @@
|
||||
// if user has supplied a sort list to constructor.
|
||||
if (config.sortList.length > 0) {
|
||||
$this.trigger("sorton", [config.sortList]);
|
||||
} else {
|
||||
// appendToTable used in sorton event already calls applyWidget
|
||||
// apply widgets
|
||||
applyWidget(this);
|
||||
}
|
||||
// apply widgets
|
||||
applyWidget(this);
|
||||
});
|
||||
};
|
||||
this.addParser = function (parser) {
|
||||
|
||||
1540
js/jquery/timepicker.js
vendored
1540
js/jquery/timepicker.js
vendored
File diff suppressed because it is too large
Load Diff
519
js/makegrid.js
519
js/makegrid.js
File diff suppressed because it is too large
Load Diff
@ -90,7 +90,7 @@ $js_messages['strChartIssuedQueriesTitle'] = __('Questions (executed statements
|
||||
$js_messages['strChartQueryPie'] = __('Query statistics');
|
||||
|
||||
/* server status monitor */
|
||||
$js_messages['strIncompatibleMonitorConfig'] = __('Local monitor configuration icompatible');
|
||||
$js_messages['strIncompatibleMonitorConfig'] = __('Local monitor configuration incompatible');
|
||||
$js_messages['strIncompatibleMonitorConfigDescription'] = __('The chart arrangement configuration in your browsers local storage is not compatible anymore to the newer version of the monitor dialog. It is very likely that your current configuration will not work anymore. Please reset your configuration to default in the <i>Settings</i> menu.');
|
||||
|
||||
$js_messages['strQueryCacheEfficiency'] = __('Query cache efficiency');
|
||||
@ -170,7 +170,7 @@ $js_messages['strJumpToTable'] = __('Jump to Log table');
|
||||
$js_messages['strNoDataFound'] = __('Log analysed, but no data found in this time span.');
|
||||
|
||||
/* l10n: A collection of available filters */
|
||||
$js_messages['strFilters'] = __('Filters');
|
||||
$js_messages['strFiltersForLogTable'] = __('Log table filter options');
|
||||
/* l10n: Filter as in "Start Filtering" */
|
||||
$js_messages['strFilter'] = __('Filter');
|
||||
$js_messages['strFilterByWordRegexp'] = __('Filter queries by word/regexp:');
|
||||
@ -260,12 +260,38 @@ $js_messages['strShowSearchCriteria'] = __('Show search criteria');
|
||||
|
||||
/* For tbl_zoom_plot.js */
|
||||
$js_messages['strZoomSearch'] = __('Zoom Search');
|
||||
$js_messages['strDisplayHelp'] = __('* Each point represents a data row.<br>* Hovering over a point will show its label.<br>* Drag and select an area in the plot to zoom into it.<br>* Click reset zoom link to come back to original state.<br>* Click a data point to view and possibly edit the data row.<br>* The plot can be resized by dragging it along the bottom right corner.<br>* Strings are converted into integer for plotting');
|
||||
$js_messages['strInputNull'] = __('<b>Select two columns</b>');
|
||||
$js_messages['strSameInputs'] = __('<b>Select two different columns</b>');
|
||||
$js_messages['strDisplayHelp'] = '<ul><li>'
|
||||
. __('Each point represents a data row.')
|
||||
. '</li><li>'
|
||||
. __('Hovering over a point will show its label.')
|
||||
. '</li><li>'
|
||||
. __('Drag and select an area in the plot to zoom into it.')
|
||||
. '</li><li>'
|
||||
. __('Click reset zoom link 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>';
|
||||
|
||||
/* For tbl_change.js */
|
||||
$js_messages['strIgnore'] = __('Ignore');
|
||||
$js_messages['strCopy'] = __('Copy');
|
||||
$js_messages['strX'] = __('X');
|
||||
$js_messages['strY'] = __('Y');
|
||||
$js_messages['strPoint'] = __('Point');
|
||||
$js_messages['strLineString'] = __('Linestring');
|
||||
$js_messages['strPolygon'] = __('Polygon');
|
||||
$js_messages['strGeometry'] = __('Geometry');
|
||||
$js_messages['strInnerRing'] = __('Inner Ring');
|
||||
$js_messages['strOuterRing'] = __('Outer Ring');
|
||||
$js_messages['strAddPoint'] = __('Add a point');
|
||||
$js_messages['strAddInnerRing'] = __('Add an inner ring');
|
||||
$js_messages['strAddPolygon'] = __('Add a polygon');
|
||||
|
||||
/* For tbl_structure.js */
|
||||
$js_messages['strAddColumns'] = __('Add columns');
|
||||
|
||||
@ -113,7 +113,7 @@ function MouseDown(e)
|
||||
dx = offsetx - parseInt(cur_click.style.left);
|
||||
dy = offsety - parseInt(cur_click.style.top);
|
||||
//alert(" dx = " + dx + " dy = " +dy);
|
||||
document.getElementById("canvas").style.visibility = 'hidden';
|
||||
document.getElementById("canvas").style.display = 'none';
|
||||
/*
|
||||
var left = parseInt(cur_click.style.left);
|
||||
var top = parseInt(cur_click.style.top);
|
||||
@ -159,8 +159,8 @@ function MouseMove(e)
|
||||
}
|
||||
|
||||
if (ON_relation || ON_display_field) {
|
||||
document.getElementById('hint').style.left = (Glob_X + 20) + 'px';
|
||||
document.getElementById('hint').style.top = (Glob_Y + 20) + 'px';
|
||||
document.getElementById('pmd_hint').style.left = (Glob_X + 20) + 'px';
|
||||
document.getElementById('pmd_hint').style.top = (Glob_Y + 20) + 'px';
|
||||
}
|
||||
|
||||
if (layer_menu_cur_click) {
|
||||
@ -173,7 +173,7 @@ function MouseMove(e)
|
||||
function MouseUp(e)
|
||||
{
|
||||
if (cur_click != null) {
|
||||
document.getElementById("canvas").style.visibility = 'visible';
|
||||
document.getElementById("canvas").style.display = 'inline-block';
|
||||
Re_load();
|
||||
cur_click.style.zIndex = 1;
|
||||
cur_click = null;
|
||||
@ -225,7 +225,7 @@ function Main()
|
||||
Canvas_pos();
|
||||
Small_tab_refresh();
|
||||
Re_load();
|
||||
id_hint = document.getElementById('hint');
|
||||
id_hint = document.getElementById('pmd_hint');
|
||||
if (isIE) {
|
||||
General_scroll();
|
||||
}
|
||||
@ -535,12 +535,12 @@ function Start_relation()
|
||||
if (!ON_relation) {
|
||||
document.getElementById('foreign_relation').style.display = '';
|
||||
ON_relation = 1;
|
||||
document.getElementById('hint').innerHTML = PMA_messages['strSelectReferencedKey'];
|
||||
document.getElementById('hint').style.visibility = "visible";
|
||||
document.getElementById('pmd_hint').innerHTML = PMA_messages['strSelectReferencedKey'];
|
||||
document.getElementById('pmd_hint').style.display = 'block';
|
||||
document.getElementById('rel_button').className = 'M_butt_Selected_down';
|
||||
} else {
|
||||
document.getElementById('hint').innerHTML = "";
|
||||
document.getElementById('hint').style.visibility = "hidden";
|
||||
document.getElementById('pmd_hint').innerHTML = "";
|
||||
document.getElementById('pmd_hint').style.display = 'none';
|
||||
document.getElementById('rel_button').className = 'M_butt';
|
||||
click_field = 0;
|
||||
ON_relation = 0;
|
||||
@ -551,7 +551,7 @@ function Click_field(T, f, PK) // table field
|
||||
{
|
||||
if (ON_relation) {
|
||||
if (!click_field) {
|
||||
//.style.display=='none' .style.visibility = "hidden"
|
||||
//.style.display=='none' .style.display = 'none'
|
||||
if (!PK) {
|
||||
alert(PMA_messages['strPleaseSelectPrimaryOrUniqueKey']);
|
||||
return;// 0;
|
||||
@ -561,7 +561,7 @@ function Click_field(T, f, PK) // table field
|
||||
}
|
||||
click_field = 1;
|
||||
link_relation = "T1=" + T + "&F1=" + f;
|
||||
document.getElementById('hint').innerHTML = PMA_messages['strSelectForeignKey'];
|
||||
document.getElementById('pmd_hint').innerHTML = PMA_messages['strSelectForeignKey'];
|
||||
} else {
|
||||
Start_relation(); // hidden hint...
|
||||
if (j_tabs[db + '.' + T] != '1' || !PK) {
|
||||
@ -571,7 +571,7 @@ function Click_field(T, f, PK) // table field
|
||||
document.getElementById('layer_new_relation').style.left = left + 'px';
|
||||
var top = Glob_Y - document.getElementById('layer_new_relation').offsetHeight + 40;
|
||||
document.getElementById('layer_new_relation').style.top = top + 'px';
|
||||
document.getElementById('layer_new_relation').style.visibility = "visible";
|
||||
document.getElementById('layer_new_relation').style.display = 'block';
|
||||
link_relation += '&T2=' + T + '&F2=' + f;
|
||||
}
|
||||
}
|
||||
@ -596,8 +596,8 @@ function Click_field(T, f, PK) // table field
|
||||
display_field[T] = f;
|
||||
}
|
||||
ON_display_field = 0;
|
||||
document.getElementById('hint').innerHTML = "";
|
||||
document.getElementById('hint').style.visibility = "hidden";
|
||||
document.getElementById('pmd_hint').innerHTML = "";
|
||||
document.getElementById('pmd_hint').style.display = 'none';
|
||||
document.getElementById('display_field_button').className = 'M_butt';
|
||||
makeRequest('pmd_display_field.php', 'T=' + T + '&F=' + f + '&server=' + server + '&db=' + db + '&token=' + token);
|
||||
}
|
||||
@ -605,7 +605,7 @@ function Click_field(T, f, PK) // table field
|
||||
|
||||
function New_relation()
|
||||
{
|
||||
document.getElementById('layer_new_relation').style.visibility = 'hidden';
|
||||
document.getElementById('layer_new_relation').style.display = 'none';
|
||||
link_relation += '&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=0';
|
||||
link_relation += '&on_delete=' + document.getElementById('on_delete').value + '&on_update=' + document.getElementById('on_update').value;
|
||||
link_relation += Get_url_pos();
|
||||
@ -776,14 +776,14 @@ function Canvas_click(id)
|
||||
document.getElementById('layer_upd_relation').style.left = left + 'px';
|
||||
var top = Glob_Y - document.getElementById('layer_upd_relation').offsetHeight - 10;
|
||||
document.getElementById('layer_upd_relation').style.top = top + 'px';
|
||||
document.getElementById('layer_upd_relation').style.visibility = 'visible';
|
||||
document.getElementById('layer_upd_relation').style.display = 'block';
|
||||
link_relation = 'T1=' + Key0 + '&F1=' + Key1 + '&T2=' + Key2 + '&F2=' + Key3 + '&K=' + Key;
|
||||
}
|
||||
}
|
||||
|
||||
function Upd_relation()
|
||||
{
|
||||
document.getElementById('layer_upd_relation').style.visibility = 'hidden';
|
||||
document.getElementById('layer_upd_relation').style.display = 'none';
|
||||
link_relation += '&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=0';
|
||||
link_relation += Get_url_pos();
|
||||
makeRequest('pmd_relation_upd.php', link_relation);
|
||||
@ -792,9 +792,9 @@ function Upd_relation()
|
||||
function VisibleTab(id, t_n)
|
||||
{
|
||||
if (id.checked) {
|
||||
document.getElementById(t_n).style.visibility = 'visible';
|
||||
document.getElementById(t_n).style.display = 'block';
|
||||
} else {
|
||||
document.getElementById(t_n).style.visibility = 'hidden';
|
||||
document.getElementById(t_n).style.display = 'none';
|
||||
}
|
||||
Re_load();
|
||||
}
|
||||
@ -813,10 +813,10 @@ function Hide_tab_all(id_this) // max/min all tables
|
||||
if (E.elements[i].type == "checkbox" && E.elements[i].id.substring(0, 10) == 'check_vis_') {
|
||||
if (id_this.alt == 'v') {
|
||||
E.elements[i].checked = true;
|
||||
document.getElementById(E.elements[i].value).style.visibility = 'visible';
|
||||
document.getElementById(E.elements[i].value).style.display = 'block';
|
||||
} else {
|
||||
E.elements[i].checked = false;
|
||||
document.getElementById(E.elements[i].value).style.visibility = 'hidden';
|
||||
document.getElementById(E.elements[i].value).style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -859,20 +859,15 @@ function No_have_constr(id_this)
|
||||
if (!in_array_k(E.elements[i].value, a))
|
||||
if (id_this.alt == 'v') {
|
||||
E.elements[i].checked = true;
|
||||
document.getElementById(E.elements[i].value).style.visibility = 'visible';
|
||||
document.getElementById(E.elements[i].value).style.display = 'block';
|
||||
} else {
|
||||
E.elements[i].checked = false;
|
||||
document.getElementById(E.elements[i].value).style.visibility = 'hidden';
|
||||
document.getElementById(E.elements[i].value).style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Help()
|
||||
{
|
||||
var WinHelp = window.open("pmd_help.php", "wind1", "top=200,left=400,width=300,height=200,resizable=yes,scrollbars=yes,menubar=no");
|
||||
}
|
||||
|
||||
function PDF_save()
|
||||
{
|
||||
// var WinPDF =
|
||||
@ -884,7 +879,7 @@ function General_scroll()
|
||||
{
|
||||
/*
|
||||
if (!document.getElementById('show_relation_olways').checked) {
|
||||
document.getElementById("canvas").style.visibility = 'hidden';
|
||||
document.getElementById("canvas").style.display = 'none';
|
||||
clearTimeout(timeoutID);
|
||||
timeoutID = setTimeout(General_scroll_end, 500);
|
||||
}
|
||||
@ -913,15 +908,18 @@ function General_scroll_end()
|
||||
document.getElementById('layer_menu').style.left = document.body.scrollLeft;
|
||||
document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
|
||||
}
|
||||
document.getElementById("canvas").style.visibility = 'visible';
|
||||
document.getElementById("canvas").style.display = 'block';
|
||||
}
|
||||
*/
|
||||
|
||||
function Show_left_menu(id_this) // max/min all tables
|
||||
{
|
||||
if (id_this.alt == "v") {
|
||||
document.getElementById("layer_menu").style.top = document.getElementById('top_menu').offsetHeight + 'px';
|
||||
document.getElementById("layer_menu").style.visibility = 'visible';
|
||||
var pos = $("#top_menu").offset();
|
||||
var height = $("#top_menu").height();
|
||||
document.getElementById("layer_menu").style.top = (pos.top + height) + 'px';
|
||||
document.getElementById("layer_menu").style.left = pos.left + 'px';
|
||||
document.getElementById("layer_menu").style.display = 'block';
|
||||
id_this.alt = ">";
|
||||
id_this.src = "pmd/images/uparrow2_m.png";
|
||||
if (isIE) {
|
||||
@ -929,7 +927,7 @@ function Show_left_menu(id_this) // max/min all tables
|
||||
}
|
||||
} else {
|
||||
document.getElementById("layer_menu").style.top = -1000 + 'px'; //fast scroll
|
||||
document.getElementById("layer_menu").style.visibility = 'hidden';
|
||||
document.getElementById("layer_menu").style.display = 'none';
|
||||
id_this.alt = "v";
|
||||
id_this.src = "pmd/images/downarrow2_m.png";
|
||||
}
|
||||
@ -955,16 +953,16 @@ function Start_display_field()
|
||||
}
|
||||
if (!ON_display_field) {
|
||||
ON_display_field = 1;
|
||||
document.getElementById('hint').innerHTML = PMA_messages['strChangeDisplay'];
|
||||
document.getElementById('hint').style.visibility = "visible";
|
||||
document.getElementById('pmd_hint').innerHTML = PMA_messages['strChangeDisplay'];
|
||||
document.getElementById('pmd_hint').style.display = 'block';
|
||||
document.getElementById('display_field_button').className = 'M_butt_Selected_down';//'#FFEE99';gray #AAAAAA
|
||||
|
||||
if (isIE) { // correct for IE
|
||||
document.getElementById('display_field_button').className = 'M_butt_Selected_down_IE';
|
||||
}
|
||||
} else {
|
||||
document.getElementById('hint').innerHTML = "";
|
||||
document.getElementById('hint').style.visibility = "hidden";
|
||||
document.getElementById('pmd_hint').innerHTML = "";
|
||||
document.getElementById('pmd_hint').style.display = 'none';
|
||||
document.getElementById('display_field_button').className = 'M_butt';
|
||||
ON_display_field = 0;
|
||||
}
|
||||
@ -1021,7 +1019,7 @@ function Click_option(id_this,column_name,table_name)
|
||||
document.getElementById(id_this).style.left = left + 'px';
|
||||
// var top = Glob_Y - document.getElementById(id_this).offsetHeight - 10;
|
||||
document.getElementById(id_this).style.top = (screen.height / 4) + 'px';
|
||||
document.getElementById(id_this).style.visibility = "visible";
|
||||
document.getElementById(id_this).style.display = 'block';
|
||||
document.getElementById('option_col_name').innerHTML = '<strong>' + PMA_messages['strAddOption'] +'"' +column_name+ '"</strong>';
|
||||
col_name = column_name;
|
||||
tab_name = table_name;
|
||||
@ -1029,7 +1027,7 @@ function Click_option(id_this,column_name,table_name)
|
||||
|
||||
function Close_option()
|
||||
{
|
||||
document.getElementById('pmd_optionse').style.visibility = "hidden";
|
||||
document.getElementById('pmd_optionse').style.display = 'none';
|
||||
}
|
||||
|
||||
function Select_all(id_this,owner)
|
||||
@ -1136,8 +1134,8 @@ function add_object()
|
||||
var init = history_array.length;
|
||||
if (rel.value != '--') {
|
||||
if (document.getElementById('Query').value == "") {
|
||||
document.getElementById('hint').innerHTML = "value/subQuery is empty" ;
|
||||
document.getElementById('hint').style.visibility = "visible";
|
||||
document.getElementById('pmd_hint').innerHTML = "value/subQuery is empty" ;
|
||||
document.getElementById('pmd_hint').style.display = 'block';
|
||||
return;
|
||||
}
|
||||
var p = document.getElementById('Query');
|
||||
@ -1168,8 +1166,8 @@ function add_object()
|
||||
}
|
||||
if (document.getElementById('h_rel_opt').value != '--') {
|
||||
if (document.getElementById('having').value == "") {
|
||||
document.getElementById('hint').innerHTML = "value/subQuery is empty" ;
|
||||
document.getElementById('hint').style.visibility = "visible";
|
||||
document.getElementById('pmd_hint').innerHTML = "value/subQuery is empty" ;
|
||||
document.getElementById('pmd_hint').style.display = 'block';
|
||||
return;
|
||||
}
|
||||
var p = document.getElementById('having');
|
||||
@ -1186,8 +1184,8 @@ function add_object()
|
||||
document.getElementById('orderby').checked = false;
|
||||
//make orderby
|
||||
}
|
||||
document.getElementById('hint').innerHTML = sum + "object created" ;
|
||||
document.getElementById('hint').style.visibility = "visible";
|
||||
document.getElementById('pmd_hint').innerHTML = sum + "object created" ;
|
||||
document.getElementById('pmd_hint').style.display = 'block';
|
||||
//output sum new objects created
|
||||
var existingDiv = document.getElementById('ab');
|
||||
existingDiv.innerHTML = display(init,history_array.length);
|
||||
|
||||
@ -15,6 +15,9 @@
|
||||
|
||||
// Add a tablesorter parser to properly handle thousands seperated numbers and SI prefixes
|
||||
$(function() {
|
||||
// Show all javascript related parts of the page
|
||||
$('.jsfeature').show();
|
||||
|
||||
jQuery.tablesorter.addParser({
|
||||
id: "fancyNumber",
|
||||
is: function(s) {
|
||||
@ -41,6 +44,36 @@ $(function() {
|
||||
type: "numeric"
|
||||
});
|
||||
|
||||
jQuery.tablesorter.addParser({
|
||||
id: "withinSpanNumber",
|
||||
is: function(s) {
|
||||
return /<span class="original"/.test(s);
|
||||
},
|
||||
format: function(s, table, html) {
|
||||
var res = html.innerHTML.match(/<span(\s*style="display:none;"\s*)?\s*class="original">(.*)?<\/span>/);
|
||||
return (res && res.length >= 3) ? res[2] : 0;
|
||||
},
|
||||
type: "numeric"
|
||||
});
|
||||
|
||||
// faster zebra widget: no row visibility check, faster css class switching, no cssChildRow check
|
||||
jQuery.tablesorter.addWidget({
|
||||
id: "fast-zebra",
|
||||
format: function (table) {
|
||||
if (table.config.debug) {
|
||||
var time = new Date();
|
||||
}
|
||||
$("tr:even", table.tBodies[0])
|
||||
.removeClass(table.config.widgetZebra.css[0])
|
||||
.addClass(table.config.widgetZebra.css[1]);
|
||||
$("tr:odd", table.tBodies[0])
|
||||
.removeClass(table.config.widgetZebra.css[1])
|
||||
.addClass(table.config.widgetZebra.css[0]);
|
||||
if (table.config.debug) {
|
||||
$.tablesorter.benchmark("Applying Fast-Zebra widget", time);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Popup behaviour
|
||||
$('a[rel="popupLink"]').click( function() {
|
||||
@ -107,10 +140,16 @@ $(function() {
|
||||
cookie: { name: 'pma_serverStatusTabs', expires: 1 },
|
||||
show: function(event, ui) {
|
||||
// Fixes line break in the menu bar when the page overflows and scrollbar appears
|
||||
menuResize();
|
||||
menuResize();
|
||||
|
||||
// Initialize selected tab
|
||||
if (!$(ui.tab.hash).data('init-done')) {
|
||||
initTab($(ui.tab.hash), null);
|
||||
}
|
||||
|
||||
// Load Server status monitor
|
||||
if (ui.tab.hash == '#statustabs_charting' && ! monitorLoaded) {
|
||||
$('div#statustabs_charting').append(
|
||||
$('div#statustabs_charting').append( //PMA_messages['strLoadingMonitor'] + ' ' +
|
||||
'<img class="ajaxIcon" id="loadingMonitorIcon" src="' +
|
||||
pmaThemeImage + 'ajax_clock_small.gif" alt="">'
|
||||
);
|
||||
@ -140,13 +179,14 @@ $(function() {
|
||||
|
||||
// Initialize each tab
|
||||
$('div.ui-tabs-panel').each(function() {
|
||||
initTab($(this), null);
|
||||
tabStatus[$(this).attr('id')] = 'static';
|
||||
var $tab = $(this);
|
||||
tabStatus[$tab.attr('id')] = 'static';
|
||||
// Initialize tabs after browser catches up with previous changes and displays tabs
|
||||
setTimeout(function() {
|
||||
initTab($tab, null);
|
||||
}, 0.5);
|
||||
});
|
||||
|
||||
// Display button links
|
||||
$('div.buttonlinks').show();
|
||||
|
||||
// Handles refresh rate changing
|
||||
$('.buttonlinks select').change(function() {
|
||||
var chart = tabChart[$(this).parents('div.ui-tabs-panel').attr('id')];
|
||||
@ -362,12 +402,12 @@ $(function() {
|
||||
});
|
||||
|
||||
$('#filterText').keyup(function(e) {
|
||||
word = $(this).val().replace(/_/g, ' ');
|
||||
var word = $(this).val().replace(/_/g, ' ');
|
||||
|
||||
if (word.length == 0) {
|
||||
textFilter = null;
|
||||
}
|
||||
else textFilter = new RegExp("(^|_)" + word, 'i');
|
||||
else textFilter = new RegExp("(^| )" + word, 'i');
|
||||
|
||||
text = word;
|
||||
|
||||
@ -389,6 +429,10 @@ $(function() {
|
||||
|
||||
/* Adjust DOM / Add handlers to the tabs */
|
||||
function initTab(tab, data) {
|
||||
if ($(tab).data('init-done') && !data) {
|
||||
return;
|
||||
}
|
||||
$(tab).data('init-done', true);
|
||||
switch(tab.attr('id')) {
|
||||
case 'statustabs_traffic':
|
||||
if (data != null) {
|
||||
@ -442,6 +486,7 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
initTableSorter(tab.attr('id'));
|
||||
break;
|
||||
|
||||
case 'statustabs_allvars':
|
||||
@ -449,43 +494,40 @@ $(function() {
|
||||
tab.find('.tabInnerContent').html(data);
|
||||
filterVariables();
|
||||
}
|
||||
initTableSorter(tab.attr('id'));
|
||||
break;
|
||||
}
|
||||
|
||||
initTableSorter(tab.attr('id'));
|
||||
}
|
||||
|
||||
// TODO: tablesorter shouldn't sort already sorted columns
|
||||
function initTableSorter(tabid) {
|
||||
var $table, opts;
|
||||
switch(tabid) {
|
||||
case 'statustabs_queries':
|
||||
$('#serverstatusqueriesdetails').tablesorter({
|
||||
sortList: [[3, 1]],
|
||||
widgets: ['zebra'],
|
||||
headers: {
|
||||
1: { sorter: 'fancyNumber' },
|
||||
2: { sorter: 'fancyNumber' }
|
||||
}
|
||||
});
|
||||
|
||||
$('#serverstatusqueriesdetails tr:first th')
|
||||
.append('<img class="icon sortableIcon" src="themes/dot.gif" alt="">');
|
||||
|
||||
$table = $('#serverstatusqueriesdetails');
|
||||
opts = {
|
||||
sortList: [[3, 1]],
|
||||
widgets: ['fast-zebra'],
|
||||
headers: {
|
||||
1: { sorter: 'fancyNumber' },
|
||||
2: { sorter: 'fancyNumber' }
|
||||
}
|
||||
};
|
||||
break;
|
||||
|
||||
case 'statustabs_allvars':
|
||||
$('#serverstatusvariables').tablesorter({
|
||||
sortList: [[0, 0]],
|
||||
widgets: ['zebra'],
|
||||
headers: {
|
||||
1: { sorter: 'fancyNumber' }
|
||||
}
|
||||
});
|
||||
|
||||
$('#serverstatusvariables tr:first th')
|
||||
.append('<img class="icon sortableIcon" src="themes/dot.gif" alt="">');
|
||||
|
||||
$table = $('#serverstatusvariables');
|
||||
opts = {
|
||||
sortList: [[0, 0]],
|
||||
widgets: ['fast-zebra'],
|
||||
headers: {
|
||||
1: { sorter: 'withinSpanNumber' }
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
$table.tablesorter(opts);
|
||||
$table.find('tr:first th')
|
||||
.append('<img class="icon sortableIcon" src="themes/dot.gif" alt="">');
|
||||
}
|
||||
|
||||
/* Filters the status variables by name/category/alert in the variables tab */
|
||||
|
||||
@ -9,6 +9,10 @@ $(function() {
|
||||
codemirror_editor = CodeMirror.fromTextArea(elm[0], { lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql" });
|
||||
}
|
||||
}
|
||||
// Timepicker is loaded on demand so we need to initialize datetime fields from the 'load log' dialog
|
||||
$('div#logAnalyseDialog .datetimefield').each(function() {
|
||||
PMA_addDatepicker($(this));
|
||||
});
|
||||
|
||||
/**** Monitor charting implementation ****/
|
||||
/* Saves the previous ajax response for differential values */
|
||||
@ -1022,8 +1026,6 @@ $(function() {
|
||||
removeVariables: $('input#removeVariables').prop('checked'),
|
||||
limitTypes: $('input#limitTypes').prop('checked')
|
||||
});
|
||||
|
||||
$('#logAnalyseDialog').find('dateStart,dateEnd').datepicker('destroy');
|
||||
}
|
||||
|
||||
$('#logAnalyseDialog').dialog({
|
||||
@ -1388,7 +1390,7 @@ $(function() {
|
||||
if (logData.numRows > 12) {
|
||||
$('div#logTable').prepend(
|
||||
'<fieldset id="logDataFilter">' +
|
||||
' <legend>' + PMA_messages['strFilters'] + '</legend>' +
|
||||
' <legend>' + PMA_messages['strFiltersForLogTable'] + '</legend>' +
|
||||
' <div class="formelement">' +
|
||||
' <label for="filterQueryText">' + PMA_messages['strFilterByWordRegexp'] + '</label>' +
|
||||
' <input name="filterQueryText" type="text" id="filterQueryText" style="vertical-align: baseline;" />' +
|
||||
@ -1680,7 +1682,7 @@ $(function() {
|
||||
|
||||
$('div#logTable table').tablesorter({
|
||||
sortList: [[cols.length - 1, 1]],
|
||||
widgets: ['zebra']
|
||||
widgets: ['fast-zebra']
|
||||
});
|
||||
|
||||
$('div#logTable table thead th')
|
||||
@ -1688,33 +1690,18 @@ $(function() {
|
||||
|
||||
return cols;
|
||||
}
|
||||
|
||||
|
||||
/* Opens the query analyzer dialog */
|
||||
function openQueryAnalyzer() {
|
||||
var rowData = $(this).parent().data('query');
|
||||
var query = rowData.argument || rowData.sql_text;
|
||||
|
||||
/* A very basic SQL Formatter. Totally fails in the cases of
|
||||
- Any string appearance containing a MySQL Keyword, surrounded by whitespaces, e.g. WHERE bar = "This where the formatter fails"
|
||||
- Subqueries too probably
|
||||
*/
|
||||
|
||||
// Matches the columns to be selected
|
||||
// .* selector doesn't include whitespace and we have no PCRE_DOTALL modifier, (.|\s)+ crashes Chrome (reported and confirmed),
|
||||
// [^]+ results in JS error in IE8, thus we use [^\0]+ for matching each column since the zero-byte char (hopefully) doesn't appear in column names ;)
|
||||
var sLists = query.match(/SELECT\s+[^\0]+\s+FROM\s+/gi);
|
||||
if (sLists) {
|
||||
for (var i = 0; i < sLists.length; i++) {
|
||||
query = query.replace(sLists[i], sLists[i].replace(/\s*((`|'|"|).*?\1,)\s*/gi, '$1\n\t'));
|
||||
}
|
||||
query = query
|
||||
.replace(/(\s+|^)(SELECT|FROM|WHERE|GROUP BY|HAVING|ORDER BY|LIMIT)(\s+|$)/gi, '\n$2\n\t')
|
||||
.replace(/\s+UNION\s+/gi, '\n\nUNION\n\n')
|
||||
.replace(/\s+(AND)\s+/gi, ' $1\n\t')
|
||||
.trim();
|
||||
}
|
||||
|
||||
query = PMA_SQLPrettyPrint(query);
|
||||
codemirror_editor.setValue(query);
|
||||
// Codemirror is bugged, it doesn't refresh properly sometimes. Following lines seem to fix that
|
||||
setTimeout(function() {
|
||||
codemirror_editor.refresh()
|
||||
},50);
|
||||
|
||||
var profilingChart = null;
|
||||
var dlgBtns = {};
|
||||
@ -1869,4 +1856,9 @@ $(function() {
|
||||
|
||||
$('a[href="#clearMonitorConfig"]').show();
|
||||
}
|
||||
});
|
||||
|
||||
// Run the monitor once loaded
|
||||
$(function() {
|
||||
$('a[href="#pauseCharts"]').trigger('click');
|
||||
});
|
||||
@ -173,9 +173,20 @@ function editVariable(link)
|
||||
// hide original content
|
||||
$cell.html('<span class="oldContent" style="display:none;">' + $cell.html() + '</span>');
|
||||
// put edit field and save/cancel link
|
||||
$cell.prepend('<table class="serverVariableEditTable" border="0"><tr><td></td><td style="width:100%;"><input type="text" value="' + data + '"/></td></tr</table>');
|
||||
$cell.prepend('<table class="serverVariableEditTable" border="0"><tr><td></td><td style="width:100%;">' +
|
||||
'<input type="text" id="variableEditArea" value="' + data + '" /></td></tr</table>');
|
||||
$cell.find('table td:first').append(mySaveLink);
|
||||
$cell.find('table td:first').append(' ');
|
||||
$cell.find('table td:first').append(myCancelLink);
|
||||
|
||||
// Keyboard shortcuts to the rescue
|
||||
$('input#variableEditArea').focus();
|
||||
$('input#variableEditArea').keydown(function(event) {
|
||||
// Enter key
|
||||
if(event.keyCode == 13) mySaveLink.trigger('click');
|
||||
// Escape key
|
||||
if(event.keyCode == 27) myCancelLink.trigger('click');
|
||||
});
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
10
js/sql.js
10
js/sql.js
@ -334,10 +334,10 @@ $(document).ready(function() {
|
||||
*/
|
||||
var button_options = {};
|
||||
// in the following function we need to use $(this)
|
||||
button_options[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();}
|
||||
button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();}
|
||||
|
||||
var button_options_error = {};
|
||||
button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();}
|
||||
button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();}
|
||||
var $form = $("#resultsForm");
|
||||
var $msgbox = PMA_ajaxShowMessage();
|
||||
|
||||
@ -351,6 +351,9 @@ $(document).ready(function() {
|
||||
height: 230,
|
||||
width: 900,
|
||||
open: PMA_verifyTypeOfAllColumns,
|
||||
close: function(event, ui) {
|
||||
$('#change_row_dialog').remove();
|
||||
},
|
||||
buttons : button_options_error
|
||||
})// end dialog options
|
||||
} else {
|
||||
@ -361,6 +364,9 @@ $(document).ready(function() {
|
||||
height: 600,
|
||||
width: 900,
|
||||
open: PMA_verifyTypeOfAllColumns,
|
||||
close: function(event, ui) {
|
||||
$('#change_row_dialog').remove();
|
||||
},
|
||||
buttons : button_options
|
||||
})
|
||||
//Remove the top menu container from the dialog
|
||||
|
||||
@ -218,11 +218,38 @@ function verificationsAfterFieldChange(urlField, multi_edit, theType)
|
||||
* Ajax handlers for Change Table page
|
||||
*
|
||||
* Actions Ajaxified here:
|
||||
* Submit Data to be inserted into the table
|
||||
* Submit Data to be inserted into the table.
|
||||
* Restart insertion with 'N' rows.
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.open_gis_editor').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $span = $(this);
|
||||
// Current value
|
||||
var value = $span.parent('td').children("input[type='text']").val();
|
||||
// Field name
|
||||
var field = $span.parents('tr').children('td:first').find("input[type='hidden']").val();
|
||||
// Column type
|
||||
var type = $span.parents('tr').find('span.column_type').text();
|
||||
// Names of input field and null checkbox
|
||||
var input_name = $span.parent('td').children("input[type='text']").attr('name');
|
||||
//Token
|
||||
var token = $("input[name='token']").val();
|
||||
|
||||
openGISEditor(value, field, type, input_name, token);
|
||||
});
|
||||
|
||||
/**
|
||||
* Uncheck the null checkbox as geometry data is placed on the input field
|
||||
*/
|
||||
$("input[name='gis_data[save]']").live('click', function(event) {
|
||||
var input_name = $('form#gis_data_editor_form').find("input[name='input_name']").val();
|
||||
var $null_checkbox = $("input[name='" + input_name + "']").parents('tr').find('.checkbox_null');
|
||||
$null_checkbox.attr('checked', false);
|
||||
});
|
||||
|
||||
// these were hidden via the "hide" class
|
||||
$('.foreign_values_anchor').show();
|
||||
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
*/
|
||||
|
||||
var x = 0;
|
||||
var default_x = 0;
|
||||
var y = 0;
|
||||
var default_y = 0;
|
||||
var scale = 1;
|
||||
var svg;
|
||||
|
||||
@ -51,56 +53,52 @@ function zoomAndPan()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handlers for GIS visualization page
|
||||
*
|
||||
* Actions Ajaxified here:
|
||||
*
|
||||
* Zooming in and zooming out on mousewheel movement.
|
||||
* Panning the visualization on dragging.
|
||||
* Zooming in on double clicking.
|
||||
* Zooming out on clicking the zoom out button.
|
||||
* Panning on clicking the arrow buttons.
|
||||
* Displaying tooltips for GIS objects.
|
||||
* Initially loads either SVG or OSM visualization based on the choice.
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
var $placeholder = $('#placeholder');
|
||||
var $openlayersmap = $('#openlayersmap');
|
||||
|
||||
if ($('#choice').prop('checked') != true) {
|
||||
$openlayersmap.hide();
|
||||
function selectVisualization() {
|
||||
if ($('#choice').prop('checked') != true) {
|
||||
$('#openlayersmap').hide();
|
||||
} else {
|
||||
$placeholder.hide();
|
||||
$('#placeholder').hide();
|
||||
}
|
||||
$('.choice').show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds necessary styles to the div that coontains the openStreetMap.
|
||||
*/
|
||||
function styleOSM() {
|
||||
var $placeholder = $('#placeholder');
|
||||
var cssObj = {
|
||||
'border' : '1px solid #aaa',
|
||||
'width' : $placeholder.width(),
|
||||
'height' : $placeholder.height(),
|
||||
'float' : 'right'
|
||||
};
|
||||
$openlayersmap.css(cssObj);
|
||||
drawOpenLayers();
|
||||
$('#openlayersmap').css(cssObj);
|
||||
}
|
||||
|
||||
$('.choice').show();
|
||||
$('#choice').bind('click', function() {
|
||||
if ($(this).prop('checked') == false) {
|
||||
$placeholder.show();
|
||||
$openlayersmap.hide();
|
||||
} else {
|
||||
$placeholder.hide();
|
||||
$openlayersmap.show();
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Loads the SVG element and make a reference to it.
|
||||
*/
|
||||
function loadSVG() {
|
||||
var $placeholder = $('#placeholder');
|
||||
|
||||
$('#placeholder').svg({
|
||||
$placeholder.svg({
|
||||
onLoad: function(svg_ref) {
|
||||
svg = svg_ref;
|
||||
}
|
||||
});
|
||||
|
||||
// Removes the second SVG element unnecessarily added due to the above command.
|
||||
$('#placeholder').find('svg:nth-child(2)').remove();
|
||||
// Removes the second SVG element unnecessarily added due to the above command
|
||||
$placeholder.find('svg:nth-child(2)').remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds controllers for zooming and panning.
|
||||
*/
|
||||
function addZoomPanControllers() {
|
||||
var $placeholder = $('#placeholder');
|
||||
if ($("#placeholder svg").length > 0) {
|
||||
var pmaThemeImage = $('#pmaThemeImage').attr('value');
|
||||
// add panning arrows
|
||||
@ -113,7 +111,81 @@ $(document).ready(function() {
|
||||
$('<img class="button" id="zoom_world" src="' + pmaThemeImage + 'zoom-world-mini.png">').appendTo($placeholder);
|
||||
$('<img class="button" id="zoom_out" src="' + pmaThemeImage + 'zoom-minus-mini.png">').appendTo($placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the GIS visualization to fit into the space available.
|
||||
*/
|
||||
function resizeGISVisualization() {
|
||||
var $placeholder = $('#placeholder');
|
||||
|
||||
// Hide inputs for width and height
|
||||
$("input[name='visualizationSettings[width]']").parents('tr').remove();
|
||||
$("input[name='visualizationSettings[height]']").parents('tr').remove();
|
||||
|
||||
var old_width = $placeholder.width();
|
||||
var extraPadding = 100;
|
||||
var leftWidth = $('.gis_table').width();
|
||||
var windowWidth = document.documentElement.clientWidth;
|
||||
var visWidth = windowWidth - extraPadding - leftWidth;
|
||||
|
||||
// Assign new value for width
|
||||
$placeholder.width(visWidth);
|
||||
$('svg').attr('width', visWidth);
|
||||
|
||||
// Assign the offset created due to resizing to default_x and center the svg.
|
||||
default_x = (visWidth - old_width) / 2;
|
||||
x = default_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the GIS visualization.
|
||||
*/
|
||||
function initGISVisualization() {
|
||||
// Loads either SVG or OSM visualization based on the choice
|
||||
selectVisualization();
|
||||
// Resizes the GIS visualization to fit into the space available
|
||||
resizeGISVisualization();
|
||||
// Adds necessary styles to the div that coontains the openStreetMap
|
||||
styleOSM();
|
||||
// Draws openStreetMap with openLayers
|
||||
drawOpenLayers();
|
||||
// Loads the SVG element and make a reference to it
|
||||
loadSVG();
|
||||
// Adds controllers for zooming and panning
|
||||
addZoomPanControllers();
|
||||
zoomAndPan();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handlers for GIS visualization page
|
||||
*
|
||||
* Actions Ajaxified here:
|
||||
*
|
||||
* Zooming in and zooming out on mousewheel movement.
|
||||
* Panning the visualization on dragging.
|
||||
* Zooming in on double clicking.
|
||||
* Zooming out on clicking the zoom out button.
|
||||
* Panning on clicking the arrow buttons.
|
||||
* Displaying tooltips for GIS objects.
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
|
||||
// If we are in GIS visualization, initialize it
|
||||
if ($('.gis_table').length > 0) {
|
||||
initGISVisualization();
|
||||
}
|
||||
|
||||
$('#choice').live('click', function() {
|
||||
if ($(this).prop('checked') == false) {
|
||||
$('#placeholder').show();
|
||||
$('#openlayersmap').hide();
|
||||
} else {
|
||||
$('#placeholder').hide();
|
||||
$('#openlayersmap').show();
|
||||
}
|
||||
});
|
||||
|
||||
$('#placeholder').live('mousewheel', function(event, delta) {
|
||||
if (delta > 0) {
|
||||
//zoom in
|
||||
@ -135,13 +207,13 @@ $(document).ready(function() {
|
||||
|
||||
var dragX = 0; var dragY = 0;
|
||||
$('svg').live('dragstart', function(event, dd) {
|
||||
$placeholder.addClass('placeholderDrag');
|
||||
$('#placeholder').addClass('placeholderDrag');
|
||||
dragX = Math.round(dd.offsetX);
|
||||
dragY = Math.round(dd.offsetY);
|
||||
});
|
||||
|
||||
$('svg').live('mouseup', function(event) {
|
||||
$placeholder.removeClass('placeholderDrag');
|
||||
$('#placeholder').removeClass('placeholderDrag');
|
||||
});
|
||||
|
||||
$('svg').live('drag', function(event, dd) {
|
||||
@ -178,8 +250,8 @@ $(document).ready(function() {
|
||||
$('#zoom_world').live('click', function(e) {
|
||||
e.preventDefault();
|
||||
scale = 1;
|
||||
x = 0;
|
||||
y = 0;
|
||||
x = default_x;
|
||||
y = default_y;
|
||||
zoomAndPan();
|
||||
});
|
||||
|
||||
@ -225,7 +297,7 @@ $(document).ready(function() {
|
||||
*/
|
||||
$('.polygon, .multipolygon, .point, .multipoint, .linestring, .multilinestring, '
|
||||
+ '.geometrycollection').live('mousemove', function(event) {
|
||||
contents = $(this).attr('name');
|
||||
contents = $.trim($(this).attr('name'));
|
||||
$("#tooltip").remove();
|
||||
if (contents != '') {
|
||||
$('<div id="tooltip">' + contents + '</div>').css({
|
||||
|
||||
@ -68,7 +68,7 @@ $(document).ready(function() {
|
||||
$("#sqlqueryresults").html(response);
|
||||
$("#sqlqueryresults").trigger('appendAnchor');
|
||||
$('#tbl_search_form')
|
||||
// work around for bug #3168569 - Issue on toggling the "Hide search criteria" in chrome.
|
||||
// workaround for bug #3168569 - Issue on toggling the "Hide search criteria" in chrome.
|
||||
.slideToggle()
|
||||
.hide();
|
||||
$('#togglesearchformlink')
|
||||
@ -87,4 +87,91 @@ $(document).ready(function() {
|
||||
});
|
||||
}) // end $.post()
|
||||
})
|
||||
|
||||
// Following section is related to the 'function based search' for geometry data types.
|
||||
// Initialy hide all the open_gis_editor spans
|
||||
$('.open_search_gis_editor').hide();
|
||||
|
||||
$('.geom_func').bind('change', function() {
|
||||
var $geomFuncSelector = $(this);
|
||||
|
||||
var binaryFunctions = [
|
||||
'Contains',
|
||||
'Crosses',
|
||||
'Disjoint',
|
||||
'Equals',
|
||||
'Intersects',
|
||||
'Overlaps',
|
||||
'Touches',
|
||||
'Within',
|
||||
'MBRContains',
|
||||
'MBRDisjoint',
|
||||
'MBREquals',
|
||||
'MBRIntersects',
|
||||
'MBROverlaps',
|
||||
'MBRTouches',
|
||||
'MBRWithin',
|
||||
'ST_Contains',
|
||||
'ST_Crosses',
|
||||
'ST_Disjoint',
|
||||
'ST_Equals',
|
||||
'ST_Intersects',
|
||||
'ST_Overlaps',
|
||||
'ST_Touches',
|
||||
'ST_Within',
|
||||
];
|
||||
|
||||
var tempArray = [
|
||||
'Envelope',
|
||||
'EndPoint',
|
||||
'StartPoint',
|
||||
'ExteriorRing',
|
||||
'Centroid',
|
||||
'PointOnSurface'
|
||||
];
|
||||
var outputGeomFunctions = binaryFunctions.concat(tempArray);
|
||||
|
||||
// If the chosen function takes two geomerty objects as parameters
|
||||
var $operator = $geomFuncSelector.parents('tr').find('td:nth-child(5)').find('select');
|
||||
if ($.inArray($geomFuncSelector.val(), binaryFunctions) >= 0){
|
||||
$operator.attr('readonly', true);
|
||||
} else {
|
||||
$operator.attr('readonly', false);
|
||||
}
|
||||
|
||||
// if the chosen function's output is a geometry, enable GIS editor
|
||||
var $editorSpan = $geomFuncSelector.parents('tr').find('.open_search_gis_editor');
|
||||
if ($.inArray($geomFuncSelector.val(), outputGeomFunctions) >= 0){
|
||||
$editorSpan.show();
|
||||
} else {
|
||||
$editorSpan.hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('.open_search_gis_editor').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $span = $(this);
|
||||
// Current value
|
||||
var value = $span.parent('td').children("input[type='text']").val();
|
||||
// Field name
|
||||
var field = 'Parameter';
|
||||
// Column type
|
||||
var geom_func = $span.parents('tr').find('.geom_func').val();
|
||||
if (geom_func == 'Envelope') {
|
||||
var type = 'polygon';
|
||||
} else if (geom_func == 'ExteriorRing') {
|
||||
var type = 'linestring';
|
||||
} else {
|
||||
var type = 'point';
|
||||
}
|
||||
// Names of input field and null checkbox
|
||||
var input_name = $span.parent('td').children("input[type='text']").attr('name');
|
||||
//Token
|
||||
var token = $("input[name='token']").val();
|
||||
|
||||
openGISEditor(value, field, type, input_name, token);
|
||||
});
|
||||
|
||||
}, 'top.frame_content'); // end $(document).ready()
|
||||
|
||||
@ -35,7 +35,7 @@ Array.min = function (array) {
|
||||
|
||||
/**
|
||||
** Checks if a string contains only numeric value
|
||||
** @param n: String (to be checked)
|
||||
** @param n: String (to be checked)
|
||||
**/
|
||||
function isNumeric(n) {
|
||||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||
@ -43,7 +43,7 @@ function isNumeric(n) {
|
||||
|
||||
/**
|
||||
** Checks if an object is empty
|
||||
** @param n: Object (to be checked)
|
||||
** @param n: Object (to be checked)
|
||||
**/
|
||||
function isEmpty(obj) {
|
||||
var name;
|
||||
@ -59,15 +59,15 @@ function isEmpty(obj) {
|
||||
** @param type String Field type(datetime/timestamp/time/date)
|
||||
**/
|
||||
function getDate(val,type) {
|
||||
if(type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
|
||||
return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val)
|
||||
}
|
||||
else if(type.toString().search(/time/i) != -1) {
|
||||
if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
|
||||
return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val)
|
||||
}
|
||||
else if (type.toString().search(/time/i) != -1) {
|
||||
return Highcharts.dateFormat('%H:%M:%S', val + 19800000)
|
||||
}
|
||||
}
|
||||
else if (type.toString().search(/date/i) != -1) {
|
||||
return Highcharts.dateFormat('%Y-%m-%e', val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,30 +76,30 @@ function getDate(val,type) {
|
||||
** @param type Sring Field type(datetime/timestamp/time/date)
|
||||
**/
|
||||
function getTimeStamp(val,type) {
|
||||
if(type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
|
||||
return getDateFromFormat(val,'yyyy-MM-dd HH:mm:ss', val)
|
||||
}
|
||||
else if(type.toString().search(/time/i) != -1) {
|
||||
return getDateFromFormat('1970-01-01 ' + val,'yyyy-MM-dd HH:mm:ss')
|
||||
}
|
||||
if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
|
||||
return getDateFromFormat(val,'yyyy-MM-dd HH:mm:ss', val)
|
||||
}
|
||||
else if (type.toString().search(/time/i) != -1) {
|
||||
return getDateFromFormat('1970-01-01 ' + val,'yyyy-MM-dd HH:mm:ss')
|
||||
}
|
||||
else if (type.toString().search(/date/i) != -1) {
|
||||
return getDateFromFormat(val,'yyyy-MM-dd')
|
||||
}
|
||||
return getDateFromFormat(val,'yyyy-MM-dd')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Classifies the field type into numeric,timeseries or text
|
||||
** @param field: field type (as in database structure)
|
||||
**/
|
||||
**/
|
||||
function getType(field) {
|
||||
if(field.toString().search(/int/i) != -1 || field.toString().search(/decimal/i) != -1 || field.toString().search(/year/i) != -1)
|
||||
return 'numeric';
|
||||
else if(field.toString().search(/time/i) != -1 || field.toString().search(/date/i) != -1)
|
||||
return 'time';
|
||||
else
|
||||
return 'text';
|
||||
if (field.toString().search(/int/i) != -1 || field.toString().search(/decimal/i) != -1 || field.toString().search(/year/i) != -1)
|
||||
return 'numeric';
|
||||
else if (field.toString().search(/time/i) != -1 || field.toString().search(/date/i) != -1)
|
||||
return 'time';
|
||||
else
|
||||
return 'text';
|
||||
}
|
||||
/**
|
||||
/**
|
||||
** Converts a categorical array into numeric array
|
||||
** @param array categorical values array
|
||||
**/
|
||||
@ -131,7 +131,7 @@ $(document).ready(function() {
|
||||
cache: 'false'
|
||||
});
|
||||
|
||||
var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer';
|
||||
var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer';
|
||||
var currentChart = null;
|
||||
var currentData = null;
|
||||
var xLabel = $('#tableid_0').val();
|
||||
@ -140,7 +140,7 @@ $(document).ready(function() {
|
||||
var yType = $('#types_1').val();
|
||||
var dataLabel = $('#dataLabel').val();
|
||||
|
||||
// Get query result
|
||||
// Get query result
|
||||
var data = jQuery.parseJSON($('#querydata').html());
|
||||
|
||||
/**
|
||||
@ -164,16 +164,16 @@ $(document).ready(function() {
|
||||
|
||||
/**
|
||||
* Input form validation
|
||||
**/
|
||||
**/
|
||||
$('#inputFormSubmitId').click(function() {
|
||||
if ($('#tableid_0').get(0).selectedIndex == 0 || $('#tableid_1').get(0).selectedIndex == 0)
|
||||
PMA_ajaxShowMessage(PMA_messages['strInputNull']);
|
||||
else if (xLabel == yLabel)
|
||||
if ($('#tableid_0').get(0).selectedIndex == 0 || $('#tableid_1').get(0).selectedIndex == 0)
|
||||
PMA_ajaxShowMessage(PMA_messages['strInputNull']);
|
||||
else if (xLabel == yLabel)
|
||||
PMA_ajaxShowMessage(PMA_messages['strSameInputs']);
|
||||
});
|
||||
|
||||
/**
|
||||
** Prepare a div containing a link, otherwise it's incorrectly displayed
|
||||
** Prepare a div containing a link, otherwise it's incorrectly displayed
|
||||
** after a couple of clicks
|
||||
**/
|
||||
$('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
|
||||
@ -191,177 +191,177 @@ $(document).ready(function() {
|
||||
} else {
|
||||
$link.text(PMA_messages['strHideSearchCriteria']);
|
||||
}
|
||||
// avoid default click action
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
// avoid default click action
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
** Set dialog properties for the data display form
|
||||
**/
|
||||
$("#dataDisplay").dialog({
|
||||
autoOpen: false,
|
||||
title: 'Data point content',
|
||||
title: 'Data point content',
|
||||
modal: false, //false otherwise other dialogues like timepicker may not function properly
|
||||
height: $('#dataDisplay').height() + 80,
|
||||
width: $('#dataDisplay').width() + 80
|
||||
});
|
||||
|
||||
/*
|
||||
* Handle submit of zoom_display_form
|
||||
* Handle submit of zoom_display_form
|
||||
*/
|
||||
|
||||
|
||||
$("#submitForm").click(function(event) {
|
||||
|
||||
|
||||
//Prevent default submission of form
|
||||
event.preventDefault();
|
||||
|
||||
//Find changed values by comparing form values with selectedRow Object
|
||||
var newValues = new Array();//Stores the values changed from original
|
||||
|
||||
//Find changed values by comparing form values with selectedRow Object
|
||||
var newValues = new Array();//Stores the values changed from original
|
||||
var it = 4;
|
||||
var xChange = false;
|
||||
var yChange = false;
|
||||
for (key in selectedRow) {
|
||||
if (key != 'where_clause'){
|
||||
var oldVal = selectedRow[key];
|
||||
var newVal = ($('#fields_null_id_' + it).attr('checked')) ? null : $('#fieldID_' + it).val();
|
||||
if (oldVal != newVal){
|
||||
selectedRow[key] = newVal;
|
||||
newValues[key] = newVal;
|
||||
if(key == xLabel) {
|
||||
xChange = true;
|
||||
data[currentData][xLabel] = newVal;
|
||||
}
|
||||
else if(key == yLabel) {
|
||||
yChange = true;
|
||||
data[currentData][yLabel] = newVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
it++
|
||||
}//End data update
|
||||
|
||||
//Update the chart series and replot
|
||||
for (key in selectedRow) {
|
||||
if (key != 'where_clause'){
|
||||
var oldVal = selectedRow[key];
|
||||
var newVal = ($('#fields_null_id_' + it).attr('checked')) ? null : $('#fieldID_' + it).val();
|
||||
if (oldVal != newVal){
|
||||
selectedRow[key] = newVal;
|
||||
newValues[key] = newVal;
|
||||
if (key == xLabel) {
|
||||
xChange = true;
|
||||
data[currentData][xLabel] = newVal;
|
||||
}
|
||||
else if (key == yLabel) {
|
||||
yChange = true;
|
||||
data[currentData][yLabel] = newVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
it++
|
||||
}//End data update
|
||||
|
||||
//Update the chart series and replot
|
||||
if (xChange || yChange) {
|
||||
var newSeries = new Array();
|
||||
newSeries[0] = new Object();
|
||||
var newSeries = new Array();
|
||||
newSeries[0] = new Object();
|
||||
newSeries[0].marker = {
|
||||
symbol: 'circle'
|
||||
};
|
||||
//Logic similar to plot generation, replot only if xAxis changes or yAxis changes. Code includes a lot of checks so as to replot only when necessary
|
||||
if(xChange) {
|
||||
xCord[currentData] = selectedRow[xLabel];
|
||||
if(xType == 'numeric') {
|
||||
currentChart.series[0].data[currentData].update({ x : selectedRow[xLabel] });
|
||||
currentChart.xAxis[0].setExtremes(Array.min(xCord) - 6,Array.max(xCord) + 6);
|
||||
//Logic similar to plot generation, replot only if xAxis changes or yAxis changes. Code includes a lot of checks so as to replot only when necessary
|
||||
if (xChange) {
|
||||
xCord[currentData] = selectedRow[xLabel];
|
||||
if (xType == 'numeric') {
|
||||
currentChart.series[0].data[currentData].update({ x : selectedRow[xLabel] });
|
||||
currentChart.xAxis[0].setExtremes(Array.min(xCord) - 6,Array.max(xCord) + 6);
|
||||
}
|
||||
else if(xType == 'time') {
|
||||
currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel],$('#types_0').val())});
|
||||
}
|
||||
else {
|
||||
var tempX = getCord(xCord);
|
||||
var tempY = getCord(yCord);
|
||||
var i = 0;
|
||||
newSeries[0].data = new Array();
|
||||
xCord = tempX[2];
|
||||
yCord = tempY[2];
|
||||
else if (xType == 'time') {
|
||||
currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel],$('#types_0').val())});
|
||||
}
|
||||
else {
|
||||
var tempX = getCord(xCord);
|
||||
var tempY = getCord(yCord);
|
||||
var i = 0;
|
||||
newSeries[0].data = new Array();
|
||||
xCord = tempX[2];
|
||||
yCord = tempY[2];
|
||||
|
||||
$.each(data,function(key,value) {
|
||||
if(yType != 'text')
|
||||
newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: value[yLabel], marker: {fillColor: colorCodes[i % 8]} , id: i } );
|
||||
else
|
||||
$.each(data,function(key,value) {
|
||||
if (yType != 'text')
|
||||
newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: value[yLabel], marker: {fillColor: colorCodes[i % 8]} , id: i } );
|
||||
else
|
||||
newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } );
|
||||
i++;
|
||||
i++;
|
||||
});
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
if(tempX[1][this.value] && tempX[1][this.value].length > 10)
|
||||
return tempX[1][this.value].substring(0,10)
|
||||
else
|
||||
return tempX[1][this.value];
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
if (tempX[1][this.value] && tempX[1][this.value].length > 10)
|
||||
return tempX[1][this.value].substring(0,10)
|
||||
else
|
||||
return tempX[1][this.value];
|
||||
}
|
||||
}
|
||||
currentSettings.series = newSeries;
|
||||
currentSettings.series = newSeries;
|
||||
currentChart = PMA_createChart(currentSettings);
|
||||
}
|
||||
|
||||
}
|
||||
if(yChange) {
|
||||
|
||||
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' )
|
||||
}
|
||||
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
|
||||
else
|
||||
newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } );
|
||||
i++;
|
||||
i++;
|
||||
});
|
||||
currentSettings.yAxis.labels = { formatter : function() {
|
||||
if(tempY[1][this.value] && tempY[1][this.value].length > 10)
|
||||
return tempY[1][this.value].substring(0,10)
|
||||
else
|
||||
return tempY[1][this.value];
|
||||
currentSettings.yAxis.labels = { formatter : function() {
|
||||
if (tempY[1][this.value] && tempY[1][this.value].length > 10)
|
||||
return tempY[1][this.value].substring(0,10)
|
||||
else
|
||||
return tempY[1][this.value];
|
||||
}
|
||||
}
|
||||
currentSettings.series = newSeries;
|
||||
currentChart = PMA_createChart(currentSettings);
|
||||
}
|
||||
}
|
||||
currentChart.series[0].data[currentData].select();
|
||||
currentSettings.series = newSeries;
|
||||
currentChart = PMA_createChart(currentSettings);
|
||||
}
|
||||
}
|
||||
currentChart.series[0].data[currentData].select();
|
||||
}
|
||||
//End plot update
|
||||
//End plot update
|
||||
|
||||
//Generate SQL query for update
|
||||
if (!isEmpty(newValues)) {
|
||||
//Generate SQL query for update
|
||||
if (!isEmpty(newValues)) {
|
||||
var sql_query = 'UPDATE `' + window.parent.table + '` SET ';
|
||||
for (key in newValues) {
|
||||
if(key != 'where_clause') {
|
||||
sql_query += '`' + key + '`=' ;
|
||||
var value = newValues[key];
|
||||
if(!isNumeric(value) && value != null)
|
||||
sql_query += '\'' + value + '\' ,';
|
||||
else
|
||||
sql_query += value + ' ,';
|
||||
}
|
||||
}
|
||||
sql_query = sql_query.substring(0, sql_query.length - 1);
|
||||
sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']);
|
||||
|
||||
//Post SQL query to sql.php
|
||||
$.post('sql.php', {
|
||||
for (key in newValues) {
|
||||
if (key != 'where_clause') {
|
||||
sql_query += '`' + key + '`=' ;
|
||||
var value = newValues[key];
|
||||
if (!isNumeric(value) && value != null)
|
||||
sql_query += '\'' + value + '\' ,';
|
||||
else
|
||||
sql_query += value + ' ,';
|
||||
}
|
||||
}
|
||||
sql_query = sql_query.substring(0, sql_query.length - 1);
|
||||
sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']);
|
||||
|
||||
//Post SQL query to sql.php
|
||||
$.post('sql.php', {
|
||||
'token' : window.parent.token,
|
||||
'db' : window.parent.db,
|
||||
'ajax_request' : true,
|
||||
'sql_query' : sql_query,
|
||||
'inline_edit' : false
|
||||
}, function(data) {
|
||||
if(data.success == true) {
|
||||
$('#sqlqueryresults').html(data.sql_query);
|
||||
$("#sqlqueryresults").trigger('appendAnchor');
|
||||
}
|
||||
else
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
})//End $.post
|
||||
}//End database update
|
||||
$("#dataDisplay").dialog("close");
|
||||
});//End submit handler
|
||||
'inline_edit' : false
|
||||
}, function(data) {
|
||||
if (data.success == true) {
|
||||
$('#sqlqueryresults').html(data.sql_query);
|
||||
$("#sqlqueryresults").trigger('appendAnchor');
|
||||
}
|
||||
else
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
})//End $.post
|
||||
}//End database update
|
||||
$("#dataDisplay").dialog("close");
|
||||
});//End submit handler
|
||||
|
||||
/*
|
||||
* Generate plot using Highcharts
|
||||
*/
|
||||
*/
|
||||
|
||||
if (data != null) {
|
||||
$('#zoom_search_form')
|
||||
@ -369,87 +369,87 @@ $(document).ready(function() {
|
||||
.hide();
|
||||
$('#togglesearchformlink')
|
||||
.text(PMA_messages['strShowSearchCriteria'])
|
||||
$('#togglesearchformdiv').show();
|
||||
$('#togglesearchformdiv').show();
|
||||
var selectedRow;
|
||||
var columnNames = new Array();
|
||||
var colorCodes = ['#FF0000','#00FFFF','#0000FF','#0000A0','#FF0080','#800080','#FFFF00','#00FF00','#FF00FF'];
|
||||
var series = new Array();
|
||||
var xCord = new Array();
|
||||
var yCord = new Array();
|
||||
var xCat = new Array();
|
||||
var yCat = new Array();
|
||||
var tempX, tempY;
|
||||
var it = 0;
|
||||
var columnNames = new Array();
|
||||
var colorCodes = ['#FF0000','#00FFFF','#0000FF','#0000A0','#FF0080','#800080','#FFFF00','#00FF00','#FF00FF'];
|
||||
var series = new Array();
|
||||
var xCord = new Array();
|
||||
var yCord = new Array();
|
||||
var xCat = new Array();
|
||||
var yCat = new Array();
|
||||
var tempX, tempY;
|
||||
var it = 0;
|
||||
|
||||
// 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
|
||||
renderTo: 'querychart',
|
||||
type: 'scatter',
|
||||
zoomType: 'xy',
|
||||
width:$('#resizer').width() -3,
|
||||
height:$('#resizer').height()-20
|
||||
},
|
||||
exporting: { enabled: false },
|
||||
credits: {
|
||||
enabled: false
|
||||
},
|
||||
exporting: { enabled: false },
|
||||
label: { text: $('#dataLabel').val() },
|
||||
plotOptions: {
|
||||
series: {
|
||||
allowPointSelect: true,
|
||||
plotOptions: {
|
||||
series: {
|
||||
allowPointSelect: true,
|
||||
cursor: 'pointer',
|
||||
showInLegend: false,
|
||||
showInLegend: false,
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
enabled: false
|
||||
},
|
||||
point: {
|
||||
point: {
|
||||
events: {
|
||||
click: function() {
|
||||
var id = this.id;
|
||||
var fid = 4;
|
||||
currentData = id;
|
||||
// Make AJAX request to tbl_zoom_select.php for getting the complete row info
|
||||
var post_params = {
|
||||
var id = this.id;
|
||||
var fid = 4;
|
||||
currentData = id;
|
||||
// Make AJAX request to tbl_zoom_select.php for getting the complete row info
|
||||
var post_params = {
|
||||
'ajax_request' : true,
|
||||
'get_data_row' : true,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'where_clause' : data[id]['where_clause'],
|
||||
'token' : window.parent.token,
|
||||
'token' : window.parent.token
|
||||
}
|
||||
$.post('tbl_zoom_select.php', post_params, function(data) {
|
||||
// Row is contained in data.row_info, now fill the displayResultForm with row values
|
||||
for ( key in data.row_info) {
|
||||
if (data.row_info[key] == null)
|
||||
$('#fields_null_id_' + fid).attr('checked', true);
|
||||
else
|
||||
$('#fieldID_' + fid).val(data.row_info[key]);
|
||||
fid++;
|
||||
}
|
||||
selectedRow = new Object();
|
||||
selectedRow = data.row_info;
|
||||
// Row is contained in data.row_info, now fill the displayResultForm with row values
|
||||
for ( key in data.row_info) {
|
||||
if (data.row_info[key] == null)
|
||||
$('#fields_null_id_' + fid).attr('checked', true);
|
||||
else
|
||||
$('#fieldID_' + fid).val(data.row_info[key]);
|
||||
fid++;
|
||||
}
|
||||
selectedRow = new Object();
|
||||
selectedRow = data.row_info;
|
||||
});
|
||||
|
||||
$("#dataDisplay").dialog("open");
|
||||
},
|
||||
$("#dataDisplay").dialog("open");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
formatter: function() {
|
||||
return this.point.name;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
formatter: function() {
|
||||
return this.point.name;
|
||||
}
|
||||
},
|
||||
title: { text: 'Query Results' },
|
||||
xAxis: {
|
||||
title: { text: $('#tableid_0').val() },
|
||||
xAxis: {
|
||||
title: { text: $('#tableid_0').val() }
|
||||
},
|
||||
yAxis: {
|
||||
min: null,
|
||||
title: { text: $('#tableid_1').val() },
|
||||
},
|
||||
min: null,
|
||||
title: { text: $('#tableid_1').val() }
|
||||
}
|
||||
}
|
||||
|
||||
$('#resizer').resizable({
|
||||
@ -461,145 +461,145 @@ $(document).ready(function() {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// 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';
|
||||
// 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 = {
|
||||
series[0].marker = {
|
||||
symbol: 'circle'
|
||||
};
|
||||
if (xType != 'text' && yType != 'text') {
|
||||
$.each(data,function(key,value) {
|
||||
var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val());
|
||||
var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val());
|
||||
if (xType != 'text' && yType != 'text') {
|
||||
$.each(data,function(key,value) {
|
||||
var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val());
|
||||
var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val());
|
||||
series[0].data.push({ name: value[dataLabel], x: xVal, y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } );
|
||||
xCord.push(value[xLabel]);
|
||||
yCord.push(value[yLabel]);
|
||||
it++;
|
||||
xCord.push(value[xLabel]);
|
||||
yCord.push(value[yLabel]);
|
||||
it++;
|
||||
});
|
||||
if(xType == 'numeric') {
|
||||
currentSettings.xAxis.max = Array.max(xCord) + 6
|
||||
currentSettings.xAxis.min = Array.min(xCord) - 6
|
||||
}
|
||||
else {
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
return getDate(this.value, $('#types_0').val());
|
||||
}}
|
||||
if (xType == 'numeric') {
|
||||
currentSettings.xAxis.max = Array.max(xCord) + 6
|
||||
currentSettings.xAxis.min = Array.min(xCord) - 6
|
||||
}
|
||||
if(yType == 'numeric') {
|
||||
currentSettings.yAxis.max = Array.max(yCord) + 6
|
||||
currentSettings.yAxis.min = Array.min(yCord) - 6
|
||||
}
|
||||
else {
|
||||
currentSettings.yAxis.labels = { formatter : function() {
|
||||
return getDate(this.value, $('#types_1').val());
|
||||
}}
|
||||
else {
|
||||
currentSettings.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());
|
||||
|
||||
else if (xType =='text' && yType !='text') {
|
||||
$.each(data,function(key,value) {
|
||||
xCord.push(value[xLabel]);
|
||||
yCord.push(value[yLabel]);
|
||||
});
|
||||
|
||||
tempX = getCord(xCord);
|
||||
$.each(data,function(key,value) {
|
||||
var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val());
|
||||
series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } );
|
||||
it++;
|
||||
it++;
|
||||
});
|
||||
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
if(tempX[1][this.value] && tempX[1][this.value].length > 10)
|
||||
return tempX[1][this.value].substring(0,10)
|
||||
else
|
||||
return tempX[1][this.value];
|
||||
}
|
||||
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
if (tempX[1][this.value] && tempX[1][this.value].length > 10)
|
||||
return tempX[1][this.value].substring(0,10)
|
||||
else
|
||||
return tempX[1][this.value];
|
||||
}
|
||||
}
|
||||
if(yType == 'numeric') {
|
||||
currentSettings.yAxis.max = Array.max(yCord) + 6
|
||||
currentSettings.yAxis.min = Array.min(yCord) - 6
|
||||
}
|
||||
else {
|
||||
currentSettings.yAxis.labels = { formatter : function() {
|
||||
return getDate(this.value, $('#types_1').val());
|
||||
}}
|
||||
if (yType == 'numeric') {
|
||||
currentSettings.yAxis.max = Array.max(yCord) + 6
|
||||
currentSettings.yAxis.min = Array.min(yCord) - 6
|
||||
}
|
||||
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());
|
||||
else {
|
||||
currentSettings.yAxis.labels = { formatter : function() {
|
||||
return getDate(this.value, $('#types_1').val());
|
||||
}}
|
||||
}
|
||||
xCord = tempX[2];
|
||||
}
|
||||
|
||||
else if (xType !='text' && yType =='text') {
|
||||
$.each(data,function(key,value) {
|
||||
xCord.push(value[xLabel]);
|
||||
yCord.push(value[yLabel]);
|
||||
});
|
||||
tempY = getCord(yCord);
|
||||
$.each(data,function(key,value) {
|
||||
var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val());
|
||||
series[0].data.push({ name: value[dataLabel], y: tempY[0][it], x: xVal, marker: {fillColor: colorCodes[it % 8]} , id: it } );
|
||||
it++;
|
||||
it++;
|
||||
});
|
||||
if(xType == 'numeric') {
|
||||
currentSettings.xAxis.max = Array.max(xCord) + 6
|
||||
currentSettings.xAxis.min = Array.min(xCord) - 6
|
||||
}
|
||||
else {
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
return getDate(this.value, $('#types_0').val());
|
||||
}}
|
||||
if (xType == 'numeric') {
|
||||
currentSettings.xAxis.max = Array.max(xCord) + 6
|
||||
currentSettings.xAxis.min = Array.min(xCord) - 6
|
||||
}
|
||||
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];
|
||||
}
|
||||
else {
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
return getDate(this.value, $('#types_0').val());
|
||||
}}
|
||||
}
|
||||
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) {
|
||||
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++;
|
||||
it++;
|
||||
});
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
if(tempX[1][this.value] && tempX[1][this.value].length > 10)
|
||||
return tempX[1][this.value].substring(0,10)
|
||||
else
|
||||
return tempX[1][this.value];
|
||||
}
|
||||
}
|
||||
currentSettings.yAxis.labels = { formatter : function() {
|
||||
if(tempY[1][this.value] && tempY[1][this.value].length > 10)
|
||||
return tempY[1][this.value].substring(0,10)
|
||||
else
|
||||
return tempY[1][this.value];
|
||||
}
|
||||
}
|
||||
xCord = tempX[2];
|
||||
yCord = tempY[2];
|
||||
currentSettings.xAxis.labels = { formatter : function() {
|
||||
if (tempX[1][this.value] && tempX[1][this.value].length > 10) {
|
||||
return tempX[1][this.value].substring(0,10)
|
||||
} else {
|
||||
return tempX[1][this.value];
|
||||
}
|
||||
}};
|
||||
currentSettings.yAxis.labels = { formatter : function() {
|
||||
if (tempY[1][this.value] && tempY[1][this.value].length > 10) {
|
||||
return tempY[1][this.value].substring(0,10);
|
||||
} else {
|
||||
return tempY[1][this.value];
|
||||
}
|
||||
}};
|
||||
xCord = tempX[2];
|
||||
yCord = tempY[2];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
currentSettings.series = series;
|
||||
currentSettings.series = series;
|
||||
currentChart = PMA_createChart(currentSettings);
|
||||
scrollToChart();
|
||||
scrollToChart();
|
||||
}
|
||||
});
|
||||
|
||||
@ -69,9 +69,11 @@ class Advisor
|
||||
$this->variables['value'] = $value;
|
||||
|
||||
try {
|
||||
if($this->ruleExprEvaluate($rule['test']))
|
||||
if ($this->ruleExprEvaluate($rule['test'])) {
|
||||
$this->addRule('fired', $rule);
|
||||
else $this->addRule('notfired', $rule);
|
||||
} else {
|
||||
$this->addRule('notfired', $rule);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->runResult['errors'][] = 'Failed running test for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
|
||||
}
|
||||
@ -81,14 +83,47 @@ class Advisor
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes percent string to be used in format string.
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function escapePercent($str)
|
||||
{
|
||||
return preg_replace('/%( |,|\.|$)/','%%\1', $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function for translating.
|
||||
*
|
||||
* @param string $str
|
||||
* @param mixed $param
|
||||
* @return string
|
||||
*/
|
||||
function translate($str, $param = null)
|
||||
{
|
||||
if (is_null($param)) {
|
||||
return sprintf(_gettext(Advisor::escapePercent($str)));
|
||||
} else {
|
||||
$printf = 'sprintf("' . _gettext(Advisor::escapePercent($str)) . '",';
|
||||
return $this->ruleExprEvaluate(
|
||||
$printf . $param . ')',
|
||||
strlen($printf)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits justification to text and formula.
|
||||
*
|
||||
* @param string $rule
|
||||
* @return array
|
||||
*/
|
||||
function splitJustification($rule)
|
||||
{
|
||||
$jst = preg_split('/\s*\|\s*/', $rule['justification'], 2);
|
||||
if (count($jst) > 1) {
|
||||
$jst[0] = preg_replace('/%( |,|\.|$)/','%%\1',$jst[0]);
|
||||
return array($jst[0], $jst[1]);
|
||||
}
|
||||
return array($rule['justification']);
|
||||
@ -100,38 +135,61 @@ class Advisor
|
||||
switch($type) {
|
||||
case 'notfired':
|
||||
case 'fired':
|
||||
$jst = Advisor::splitJustification($rule);
|
||||
if (count($jst) > 1) {
|
||||
try {
|
||||
/* Translate */
|
||||
$jst[0] = _gettext($jst[0]);
|
||||
$str = $this->ruleExprEvaluate(
|
||||
'sprintf("'.$jst[0].'",'.$jst[1].')',
|
||||
strlen('sprintf("'.$jst[0].'"')
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->runResult['errors'][] = 'Failed formattingstring for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
$rule['justification'] = $str;
|
||||
} else {
|
||||
$rule['justification'] = _gettext($rule['justification']);
|
||||
$jst = Advisor::splitJustification($rule);
|
||||
if (count($jst) > 1) {
|
||||
try {
|
||||
/* Translate */
|
||||
$str = $this->translate($jst[0], $jst[1]);
|
||||
} catch (Exception $e) {
|
||||
$this->runResult['errors'][] = sprintf(
|
||||
__('Failed formatting string for rule \'%s\'. PHP threw following error: %s'),
|
||||
$rule['name'],
|
||||
$e->getMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
$rule['name'] = _gettext($rule['name']);
|
||||
$rule['issue'] = _gettext($rule['issue']);
|
||||
|
||||
$rule['recommendation'] = preg_replace(
|
||||
'/\{([a-z_0-9]+)\}/Ui',
|
||||
'<a href="server_variables.php' . PMA_generate_common_url() . '#filter=\1">\1</a>',
|
||||
_gettext($rule['recommendation']));
|
||||
$rule['justification'] = $str;
|
||||
} else {
|
||||
$rule['justification'] = $this->translate($rule['justification']);
|
||||
}
|
||||
$rule['name'] = $this->translate($rule['name']);
|
||||
$rule['issue'] = $this->translate($rule['issue']);
|
||||
|
||||
break;
|
||||
// Replaces {server_variable} with 'server_variable' linking to server_variables.php
|
||||
$rule['recommendation'] = preg_replace(
|
||||
'/\{([a-z_0-9]+)\}/Ui',
|
||||
'<a href="server_variables.php?' . PMA_generate_common_url() . '#filter=\1">\1</a>',
|
||||
$this->translate($rule['recommendation']));
|
||||
|
||||
// Replaces external Links with PMA_linkURL() generated links
|
||||
$rule['recommendation'] = preg_replace(
|
||||
'#href=("|\')(https?://[^\1]+)\1#ie',
|
||||
'\'href="\' . PMA_linkURL("\2") . \'"\'',
|
||||
$rule['recommendation']
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$this->runResult[$type][] = $rule;
|
||||
}
|
||||
|
||||
private function ruleExprEvaluate_var1($matches)
|
||||
{
|
||||
// '/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie'
|
||||
return '1'; //isset($this->runResult[\'fired\']
|
||||
}
|
||||
|
||||
private function ruleExprEvaluate_var2($matches)
|
||||
{
|
||||
// '/\b(\w+)\b/e'
|
||||
return isset($this->variables[$matches[1]])
|
||||
? (is_numeric($this->variables[$matches[1]])
|
||||
? $this->variables[$matches[1]]
|
||||
: '"'.$this->variables[$matches[1]].'"')
|
||||
: $matches[1];
|
||||
}
|
||||
|
||||
// Runs a code expression, replacing variable names with their respective values
|
||||
// ignoreUntil: if > 0, it doesn't replace any variables until that string position, but still evaluates the whole expr
|
||||
function ruleExprEvaluate($expr, $ignoreUntil = 0)
|
||||
@ -140,13 +198,14 @@ class Advisor
|
||||
$exprIgnore = substr($expr,0,$ignoreUntil);
|
||||
$expr = substr($expr,$ignoreUntil);
|
||||
}
|
||||
$expr = preg_replace('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie','1',$expr); //isset($this->runResult[\'fired\']
|
||||
$expr = preg_replace('/\b(\w+)\b/e','isset($this->variables[\'\1\']) ? (!is_numeric($this->variables[\'\1\']) ? \'"\'.$this->variables[\'\1\'].\'"\' : $this->variables[\'\1\']) : \'\1\'', $expr);
|
||||
$expr = preg_replace_callback('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Ui', array($this, 'ruleExprEvaluate_var1'), $expr);
|
||||
$expr = preg_replace_callback('/\b(\w+)\b/', array($this, 'ruleExprEvaluate_var2'), $expr);
|
||||
if ($ignoreUntil > 0) {
|
||||
$expr = $exprIgnore . $expr;
|
||||
}
|
||||
$value = 0;
|
||||
$err = 0;
|
||||
|
||||
ob_start();
|
||||
eval('$value = '.$expr.';');
|
||||
$err = ob_get_contents();
|
||||
@ -334,6 +334,7 @@ class PMA_Config
|
||||
* should be called on object creation
|
||||
*
|
||||
* @param string $source config file
|
||||
* @return bool
|
||||
*/
|
||||
function load($source = null)
|
||||
{
|
||||
@ -698,6 +699,8 @@ class PMA_Config
|
||||
* $cfg['PmaAbsoluteUri'] is a required directive else cookies won't be
|
||||
* set properly and, depending on browsers, inserting or updating a
|
||||
* record might fail
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function checkPmaAbsoluteUri()
|
||||
{
|
||||
@ -937,7 +940,7 @@ class PMA_Config
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return bool
|
||||
*/
|
||||
public function isHttps()
|
||||
{
|
||||
@ -964,6 +967,8 @@ class PMA_Config
|
||||
*
|
||||
* Please note that this just detects what we see, so
|
||||
* it completely ignores things like reverse proxies.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function detectHttps()
|
||||
{
|
||||
@ -1012,7 +1017,7 @@ class PMA_Config
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return string
|
||||
*/
|
||||
public function getCookiePath()
|
||||
{
|
||||
|
||||
@ -127,6 +127,7 @@ class PMA_Error_Handler
|
||||
*
|
||||
* @todo finish!
|
||||
* @param PMA_Error $error
|
||||
* @return bool
|
||||
*/
|
||||
protected function _logError($error)
|
||||
{
|
||||
|
||||
@ -189,6 +189,7 @@ class PMA_File
|
||||
|
||||
/**
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function isUploaded()
|
||||
{
|
||||
@ -591,7 +592,7 @@ class PMA_File
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function open()
|
||||
{
|
||||
@ -688,6 +689,8 @@ class PMA_File
|
||||
* http://bugs.php.net/bug.php?id=29532
|
||||
* bzip reads a maximum of 8192 bytes on windows systems
|
||||
* @todo this function is unused
|
||||
* @param int $max_size
|
||||
* @return bool|string
|
||||
*/
|
||||
function getNextChunk($max_size = null)
|
||||
{
|
||||
|
||||
@ -90,6 +90,7 @@ require_once './libraries/List.class.php';
|
||||
*
|
||||
* @todo we could also search mysql tables if all fail?
|
||||
* @param string $like_db_name usally a db_name containing wildcards
|
||||
* @return array
|
||||
*/
|
||||
protected function _retrieve($like_db_name = null)
|
||||
{
|
||||
|
||||
@ -44,6 +44,9 @@ class PMA
|
||||
* magic access to protected/inaccessible members/properties
|
||||
*
|
||||
* @see http://php.net/language.oop5.overloading
|
||||
*
|
||||
* @param string $param
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($param)
|
||||
{
|
||||
@ -66,6 +69,9 @@ class PMA
|
||||
* magic access to protected/inaccessible members/properties
|
||||
*
|
||||
* @see http://php.net/language.oop5.overloading
|
||||
*
|
||||
* @param string $param
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($param, $value)
|
||||
{
|
||||
|
||||
@ -63,8 +63,8 @@ class PMA_Table
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $table_name table name
|
||||
* @param string $db_name database name
|
||||
* @param string $table_name table name
|
||||
* @param string $db_name database name
|
||||
*/
|
||||
function __construct($table_name, $db_name)
|
||||
{
|
||||
@ -83,11 +83,21 @@ class PMA_Table
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* return the last error
|
||||
*
|
||||
* @return the last error
|
||||
*/
|
||||
function getLastError()
|
||||
{
|
||||
return end($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* return the last message
|
||||
*
|
||||
* @return the last message
|
||||
*/
|
||||
function getLastMessage()
|
||||
{
|
||||
return end($this->messages);
|
||||
@ -96,7 +106,9 @@ class PMA_Table
|
||||
/**
|
||||
* sets table name
|
||||
*
|
||||
* @param string $table_name new table name
|
||||
* @param string $table_name new table name
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function setName($table_name)
|
||||
{
|
||||
@ -107,6 +119,7 @@ class PMA_Table
|
||||
* returns table name
|
||||
*
|
||||
* @param boolean $backquoted whether to quote name with backticks ``
|
||||
*
|
||||
* @return string table name
|
||||
*/
|
||||
function getName($backquoted = false)
|
||||
@ -120,7 +133,9 @@ class PMA_Table
|
||||
/**
|
||||
* sets database name for this table
|
||||
*
|
||||
* @param string $db_name
|
||||
* @param string $db_name database name
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function setDbName($db_name)
|
||||
{
|
||||
@ -131,6 +146,7 @@ class PMA_Table
|
||||
* returns database name for this table
|
||||
*
|
||||
* @param boolean $backquoted whether to quote name with backticks ``
|
||||
*
|
||||
* @return string database name for this table
|
||||
*/
|
||||
function getDbName($backquoted = false)
|
||||
@ -145,6 +161,7 @@ class PMA_Table
|
||||
* returns full name for table, including database name
|
||||
*
|
||||
* @param boolean $backquoted whether to quote name with backticks ``
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getFullName($backquoted = false)
|
||||
@ -152,6 +169,14 @@ class PMA_Table
|
||||
return $this->getDbName($backquoted) . '.' . $this->getName($backquoted);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns whether the table is actually a view
|
||||
*
|
||||
* @param string $db database
|
||||
* @param string $table table
|
||||
*
|
||||
* @return whether the given is a view
|
||||
*/
|
||||
static public function isView($db = null, $table = null)
|
||||
{
|
||||
if (strlen($db) && strlen($table)) {
|
||||
@ -166,6 +191,8 @@ class PMA_Table
|
||||
*
|
||||
* @param string $param name
|
||||
* @param mixed $value value
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function set($param, $value)
|
||||
{
|
||||
@ -176,6 +203,7 @@ class PMA_Table
|
||||
* returns value for given setting/param
|
||||
*
|
||||
* @param string $param name for value to return
|
||||
*
|
||||
* @return mixed value for $param
|
||||
*/
|
||||
function get($param)
|
||||
@ -204,8 +232,10 @@ class PMA_Table
|
||||
$this->settings = $table_info;
|
||||
|
||||
if ($this->get('TABLE_ROWS') === null) {
|
||||
$this->set('TABLE_ROWS', PMA_Table::countRecords($this->getDbName(),
|
||||
$this->getName(), true));
|
||||
$this->set(
|
||||
'TABLE_ROWS',
|
||||
PMA_Table::countRecords($this->getDbName(), $this->getName(), true)
|
||||
);
|
||||
}
|
||||
|
||||
$create_options = explode(' ', $this->get('TABLE_ROWS'));
|
||||
@ -224,10 +254,12 @@ class PMA_Table
|
||||
/**
|
||||
* Checks if this "table" is a view
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $table the table name
|
||||
*
|
||||
* @deprecated
|
||||
* @todo see what we could do with the possible existence of $table_is_view
|
||||
* @param string $db the database name
|
||||
* @param string $table the table name
|
||||
*
|
||||
* @return boolean whether this is a view
|
||||
*/
|
||||
static protected function _isView($db, $table)
|
||||
@ -237,7 +269,8 @@ class PMA_Table
|
||||
return true;
|
||||
}
|
||||
|
||||
// Since phpMyAdmin 3.2 the field TABLE_TYPE is properly filled by PMA_DBI_get_tables_full()
|
||||
// Since phpMyAdmin 3.2 the field TABLE_TYPE is properly filled by
|
||||
// PMA_DBI_get_tables_full()
|
||||
$type = PMA_Table::sGetStatusInfo($db, $table, 'TABLE_TYPE');
|
||||
return $type == 'VIEW';
|
||||
}
|
||||
@ -245,10 +278,12 @@ class PMA_Table
|
||||
/**
|
||||
* Checks if this is a merge table
|
||||
*
|
||||
* If the ENGINE of the table is MERGE or MRG_MYISAM (alias), this is a merge table.
|
||||
* If the ENGINE of the table is MERGE or MRG_MYISAM (alias),
|
||||
* this is a merge table.
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $table the table name
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $table the table name
|
||||
* @return boolean true if it is a merge table
|
||||
*/
|
||||
static public function isMerge($db = null, $table = null)
|
||||
@ -270,15 +305,17 @@ class PMA_Table
|
||||
|
||||
/**
|
||||
* Returns full table status info, or specific if $info provided
|
||||
*
|
||||
* this info is collected from information_schema
|
||||
*
|
||||
* @todo PMA_DBI_get_tables_full needs to be merged somehow into this class or at least better documented
|
||||
* @param string $db
|
||||
* @param string $table
|
||||
* @param string $info
|
||||
* @param boolean $force_read
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $info
|
||||
* @param boolean $force_read read new rather than serving from cache
|
||||
* @param boolean $disable_error if true, disables error message
|
||||
*
|
||||
* @todo PMA_DBI_get_tables_full needs to be merged somehow into this class
|
||||
* or at least better documented
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
static public function sGetStatusInfo($db, $table, $info = null, $force_read = false, $disable_error = false)
|
||||
@ -311,21 +348,24 @@ class PMA_Table
|
||||
/**
|
||||
* generates column specification for ALTER or CREATE TABLE syntax
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
|
||||
* @param string $length length ('2', '5,2', '', ...)
|
||||
* @param string $attribute attribute
|
||||
* @param string $collation collation
|
||||
* @param bool|string $null with 'NULL' or 'NOT NULL'
|
||||
* @param string $default_type whether default is CURRENT_TIMESTAMP,
|
||||
* NULL, NONE, USER_DEFINED
|
||||
* @param string $default_value default value for USER_DEFINED default type
|
||||
* @param string $extra 'AUTO_INCREMENT'
|
||||
* @param string $comment field comment
|
||||
* @param array &$field_primary list of fields for PRIMARY KEY
|
||||
* @param string $index
|
||||
*
|
||||
* @todo move into class PMA_Column
|
||||
* @todo on the interface, some js to clear the default value when the default current_timestamp is checked
|
||||
* @param string $name name
|
||||
* @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
|
||||
* @param string $length length ('2', '5,2', '', ...)
|
||||
* @param string $attribute
|
||||
* @param string $collation
|
||||
* @param bool|string $null with 'NULL' or 'NOT NULL'
|
||||
* @param string $default_type whether default is CURRENT_TIMESTAMP,
|
||||
* NULL, NONE, USER_DEFINED
|
||||
* @param string $default_value default value for USER_DEFINED default type
|
||||
* @param string $extra 'AUTO_INCREMENT'
|
||||
* @param string $comment field comment
|
||||
* @param array &$field_primary list of fields for PRIMARY KEY
|
||||
* @param string $index
|
||||
* @todo on the interface, some js to clear the default value when the default
|
||||
* current_timestamp is checked
|
||||
*
|
||||
* @return string field specification
|
||||
*/
|
||||
static function generateFieldSpec($name, $type, $length = '', $attribute = '',
|
||||
@ -339,8 +379,9 @@ class PMA_Table
|
||||
$query = PMA_backquote($name) . ' ' . $type;
|
||||
|
||||
if ($length != ''
|
||||
&& !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT'
|
||||
. '|SERIAL|BOOLEAN)$@i', $type)) {
|
||||
&& ! preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|'
|
||||
. 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN)$@i', $type)
|
||||
) {
|
||||
$query .= '(' . $length . ')';
|
||||
}
|
||||
|
||||
@ -348,8 +389,9 @@ class PMA_Table
|
||||
$query .= ' ' . $attribute;
|
||||
}
|
||||
|
||||
if (!empty($collation) && $collation != 'NULL'
|
||||
&& preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)) {
|
||||
if (! empty($collation) && $collation != 'NULL'
|
||||
&& preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)
|
||||
) {
|
||||
$query .= PMA_generateCharsetQueryPart($collation);
|
||||
}
|
||||
|
||||
@ -362,24 +404,26 @@ class PMA_Table
|
||||
}
|
||||
|
||||
switch ($default_type) {
|
||||
case 'USER_DEFINED' :
|
||||
if ($is_timestamp && $default_value === '0') {
|
||||
// a TIMESTAMP does not accept DEFAULT '0'
|
||||
// but DEFAULT 0 works
|
||||
$query .= ' DEFAULT 0';
|
||||
} elseif ($type == 'BIT') {
|
||||
$query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default_value) . '\'';
|
||||
} else {
|
||||
$query .= ' DEFAULT \'' . PMA_sqlAddSlashes($default_value) . '\'';
|
||||
}
|
||||
break;
|
||||
case 'NULL' :
|
||||
case 'CURRENT_TIMESTAMP' :
|
||||
$query .= ' DEFAULT ' . $default_type;
|
||||
break;
|
||||
case 'NONE' :
|
||||
default :
|
||||
break;
|
||||
case 'USER_DEFINED' :
|
||||
if ($is_timestamp && $default_value === '0') {
|
||||
// a TIMESTAMP does not accept DEFAULT '0'
|
||||
// but DEFAULT 0 works
|
||||
$query .= ' DEFAULT 0';
|
||||
} elseif ($type == 'BIT') {
|
||||
$query .= ' DEFAULT b\''
|
||||
. preg_replace('/[^01]/', '0', $default_value)
|
||||
. '\'';
|
||||
} else {
|
||||
$query .= ' DEFAULT \'' . PMA_sqlAddSlashes($default_value) . '\'';
|
||||
}
|
||||
break;
|
||||
case 'NULL' :
|
||||
case 'CURRENT_TIMESTAMP' :
|
||||
$query .= ' DEFAULT ' . $default_type;
|
||||
break;
|
||||
case 'NONE' :
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($extra)) {
|
||||
@ -389,16 +433,18 @@ class PMA_Table
|
||||
if ($extra == 'AUTO_INCREMENT') {
|
||||
$primary_cnt = count($field_primary);
|
||||
if (1 == $primary_cnt) {
|
||||
for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) {
|
||||
//void
|
||||
for ($j = 0; $j < $primary_cnt; $j++) {
|
||||
if ($field_primary[$j] == $index) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($field_primary[$j]) && $field_primary[$j] == $index) {
|
||||
$query .= ' PRIMARY KEY';
|
||||
unset($field_primary[$j]);
|
||||
}
|
||||
// but the PK could contain other columns so do not append
|
||||
// a PRIMARY KEY clause, just add a member to $field_primary
|
||||
} else {
|
||||
// but the PK could contain other columns so do not append
|
||||
// a PRIMARY KEY clause, just add a member to $field_primary
|
||||
$found_in_pk = false;
|
||||
for ($j = 0; $j < $primary_cnt; $j++) {
|
||||
if ($field_primary[$j] == $index) {
|
||||
@ -424,13 +470,13 @@ class PMA_Table
|
||||
* Revision 13 July 2001: Patch for limiting dump size from
|
||||
* vinay@sanisoft.com & girish@sanisoft.com
|
||||
*
|
||||
* @param string $db the current database name
|
||||
* @param string $table the current table name
|
||||
* @param bool $force_exact whether to force an exact count
|
||||
* @param bool $is_view
|
||||
* @param string $db the current database name
|
||||
* @param string $table the current table name
|
||||
* @param bool $force_exact whether to force an exact count
|
||||
* @param bool $is_view whether the table is a view
|
||||
*
|
||||
* @return mixed the number of records if "retain" param is true,
|
||||
* otherwise true
|
||||
* @return mixed the number of records if "retain" param is true,
|
||||
* otherwise true
|
||||
*/
|
||||
static public function countRecords($db, $table, $force_exact = false, $is_view = null)
|
||||
{
|
||||
@ -462,7 +508,8 @@ class PMA_Table
|
||||
if (! $is_view) {
|
||||
$row_count = PMA_DBI_fetch_value(
|
||||
'SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.'
|
||||
. PMA_backquote($table));
|
||||
. PMA_backquote($table)
|
||||
);
|
||||
} else {
|
||||
// For complex views, even trying to get a partial record
|
||||
// count could bring down a server, so we offer an
|
||||
@ -478,9 +525,11 @@ class PMA_Table
|
||||
// based on a table that no longer exists)
|
||||
$result = PMA_DBI_try_query(
|
||||
'SELECT 1 FROM ' . PMA_backquote($db) . '.'
|
||||
. PMA_backquote($table) . ' LIMIT '
|
||||
. $GLOBALS['cfg']['MaxExactCountViews'],
|
||||
null, PMA_DBI_QUERY_STORE);
|
||||
. PMA_backquote($table) . ' LIMIT '
|
||||
. $GLOBALS['cfg']['MaxExactCountViews'],
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
);
|
||||
if (!PMA_DBI_getError()) {
|
||||
$row_count = PMA_DBI_num_rows($result);
|
||||
PMA_DBI_free_result($result);
|
||||
@ -497,22 +546,24 @@ class PMA_Table
|
||||
/**
|
||||
* Generates column specification for ALTER syntax
|
||||
*
|
||||
* @param string $oldcol old column name
|
||||
* @param string $newcol new column name
|
||||
* @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
|
||||
* @param string $length length ('2', '5,2', '', ...)
|
||||
* @param string $attribute attribute
|
||||
* @param string $collation collation
|
||||
* @param bool|string $null with 'NULL' or 'NOT NULL'
|
||||
* @param string $default_type whether default is CURRENT_TIMESTAMP,
|
||||
* NULL, NONE, USER_DEFINED
|
||||
* @param string $default_value default value for USER_DEFINED default type
|
||||
* @param string $extra 'AUTO_INCREMENT'
|
||||
* @param string $comment field comment
|
||||
* @param array &$field_primary list of fields for PRIMARY KEY
|
||||
* @param string $index
|
||||
* @param mixed $default_orig
|
||||
*
|
||||
* @see PMA_Table::generateFieldSpec()
|
||||
* @param string $oldcol old column name
|
||||
* @param string $newcol new column name
|
||||
* @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
|
||||
* @param string $length length ('2', '5,2', '', ...)
|
||||
* @param string $attribute
|
||||
* @param string $collation
|
||||
* @param bool|string $null with 'NULL' or 'NOT NULL'
|
||||
* @param string $default_type whether default is CURRENT_TIMESTAMP,
|
||||
* NULL, NONE, USER_DEFINED
|
||||
* @param string $default_value default value for USER_DEFINED default type
|
||||
* @param string $extra 'AUTO_INCREMENT'
|
||||
* @param string $comment field comment
|
||||
* @param array &$field_primary list of fields for PRIMARY KEY
|
||||
* @param string $index
|
||||
* @param mixed $default_orig
|
||||
*
|
||||
* @return string field specification
|
||||
*/
|
||||
static public function generateAlter($oldcol, $newcol, $type, $length,
|
||||
@ -520,26 +571,32 @@ class PMA_Table
|
||||
$extra, $comment = '', &$field_primary, $index, $default_orig)
|
||||
{
|
||||
return PMA_backquote($oldcol) . ' '
|
||||
. PMA_Table::generateFieldSpec($newcol, $type, $length, $attribute,
|
||||
. PMA_Table::generateFieldSpec(
|
||||
$newcol, $type, $length, $attribute,
|
||||
$collation, $null, $default_type, $default_value, $extra,
|
||||
$comment, $field_primary, $index, $default_orig);
|
||||
$comment, $field_primary, $index, $default_orig
|
||||
);
|
||||
} // end function
|
||||
|
||||
/**
|
||||
* Inserts existing entries in a PMA_* table by reading a value from an old entry
|
||||
*
|
||||
* @param string $work The array index, which Relation feature to check
|
||||
* ('relwork', 'commwork', ...)
|
||||
* @param string $pma_table The array index, which PMA-table to update
|
||||
* ('bookmark', 'relation', ...)
|
||||
* @param array $get_fields Which fields will be SELECT'ed from the old entry
|
||||
* @param array $where_fields Which fields will be used for the WHERE query
|
||||
* (array('FIELDNAME' => 'FIELDVALUE'))
|
||||
* @param array $new_fields Which fields will be used as new VALUES. These are
|
||||
* the important keys which differ from the old entry
|
||||
* (array('FIELDNAME' => 'NEW FIELDVALUE'))
|
||||
*
|
||||
* @global relation variable
|
||||
* @param string $work The array index, which Relation feature to check ('relwork', 'commwork', ...)
|
||||
* @param string $pma_table The array index, which PMA-table to update ('bookmark', 'relation', ...)
|
||||
* @param array $get_fields Which fields will be SELECT'ed from the old entry
|
||||
* @param array $where_fields Which fields will be used for the WHERE query (array('FIELDNAME' => 'FIELDVALUE'))
|
||||
* @param array $new_fields Which fields will be used as new VALUES. These are the important
|
||||
* keys which differ from the old entry.
|
||||
* (array('FIELDNAME' => 'NEW FIELDVALUE'))
|
||||
*
|
||||
* @return int|true
|
||||
*/
|
||||
static public function duplicateInfo($work, $pma_table, $get_fields, $where_fields,
|
||||
$new_fields)
|
||||
static public function duplicateInfo($work, $pma_table, $get_fields, $where_fields, $new_fields)
|
||||
{
|
||||
$last_id = -1;
|
||||
|
||||
@ -572,8 +629,9 @@ class PMA_Table
|
||||
|
||||
// must use PMA_DBI_QUERY_STORE here, since we execute another
|
||||
// query inside the loop
|
||||
$table_copy_rs = PMA_query_as_controluser($table_copy_query, true,
|
||||
PMA_DBI_QUERY_STORE);
|
||||
$table_copy_rs = PMA_query_as_controluser(
|
||||
$table_copy_query, true, PMA_DBI_QUERY_STORE
|
||||
);
|
||||
|
||||
while ($table_copy_row = @PMA_DBI_fetch_assoc($table_copy_rs)) {
|
||||
$value_parts = array();
|
||||
@ -583,9 +641,9 @@ class PMA_Table
|
||||
}
|
||||
}
|
||||
|
||||
$new_table_query = '
|
||||
INSERT IGNORE INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
|
||||
. '.' . PMA_backquote($GLOBALS['cfgRelation'][$pma_table]) . '
|
||||
$new_table_query = 'INSERT IGNORE INTO '
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['db'])
|
||||
. '.' . PMA_backquote($GLOBALS['cfgRelation'][$pma_table]) . '
|
||||
(' . implode(', ', $select_parts) . ',
|
||||
' . implode(', ', $new_parts) . ')
|
||||
VALUES
|
||||
@ -608,14 +666,15 @@ class PMA_Table
|
||||
/**
|
||||
* Copies or renames table
|
||||
*
|
||||
* @param $source_db
|
||||
* @param $source_table
|
||||
* @param $target_db
|
||||
* @param $target_table
|
||||
* @param $what
|
||||
* @param $move
|
||||
* @param $mode
|
||||
* @return bool
|
||||
* @param string $source_db source database
|
||||
* @param string $source_table source table
|
||||
* @param string $target_db target database
|
||||
* @param string $target_table target table
|
||||
* @param string $what what to be moved or copied (data, dataonly)
|
||||
* @param bool $move whether to move
|
||||
* @param string $mode mode
|
||||
*
|
||||
* @return bool true if success, false otherwise
|
||||
*/
|
||||
static public function moveCopy($source_db, $source_table, $target_db, $target_table, $what, $move, $mode)
|
||||
{
|
||||
@ -624,7 +683,10 @@ class PMA_Table
|
||||
/* Try moving table directly */
|
||||
if ($move && $what == 'data') {
|
||||
$tbl = new PMA_Table($source_table, $source_db);
|
||||
$result = $tbl->rename($target_table, $target_db, PMA_Table::isView($source_db, $source_table));
|
||||
$result = $tbl->rename(
|
||||
$target_table, $target_db,
|
||||
PMA_Table::isView($source_db, $source_table)
|
||||
);
|
||||
if ($result) {
|
||||
$GLOBALS['message'] = $tbl->getLastMessage();
|
||||
return true;
|
||||
@ -638,12 +700,14 @@ class PMA_Table
|
||||
// Ensure the target is valid
|
||||
if (! $GLOBALS['pma']->databases->exists($source_db, $target_db)) {
|
||||
if (! $GLOBALS['pma']->databases->exists($source_db)) {
|
||||
$GLOBALS['message'] = PMA_Message::rawError('source database `'
|
||||
. htmlspecialchars($source_db) . '` not found');
|
||||
$GLOBALS['message'] = PMA_Message::rawError(
|
||||
'source database `' . htmlspecialchars($source_db) . '` not found'
|
||||
);
|
||||
}
|
||||
if (! $GLOBALS['pma']->databases->exists($target_db)) {
|
||||
$GLOBALS['message'] = PMA_Message::rawError('target database `'
|
||||
. htmlspecialchars($target_db) . '` not found');
|
||||
$GLOBALS['message'] = PMA_Message::rawError(
|
||||
'target database `' . htmlspecialchars($target_db) . '` not found'
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -661,21 +725,25 @@ class PMA_Table
|
||||
|
||||
// do not create the table if dataonly
|
||||
if ($what != 'dataonly') {
|
||||
require_once './libraries/export/sql.php';
|
||||
include_once './libraries/export/sql.php';
|
||||
|
||||
$no_constraints_comments = true;
|
||||
$GLOBALS['sql_constraints_query'] = '';
|
||||
|
||||
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url, false, false);
|
||||
$sql_structure = PMA_getTableDef(
|
||||
$source_db, $source_table, "\n", $err_url, false, false
|
||||
);
|
||||
unset($no_constraints_comments);
|
||||
$parsed_sql = PMA_SQP_parse($sql_structure);
|
||||
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
|
||||
$i = 0;
|
||||
if (empty($analyzed_sql[0]['create_table_fields'])) {
|
||||
// this is not a CREATE TABLE, so find the first VIEW
|
||||
// this is not a CREATE TABLE, so find the first VIEW
|
||||
$target_for_view = PMA_backquote($target_db);
|
||||
while (true) {
|
||||
if ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'VIEW') {
|
||||
if ($parsed_sql[$i]['type'] == 'alpha_reservedWord'
|
||||
&& $parsed_sql[$i]['data'] == 'VIEW'
|
||||
) {
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
@ -709,8 +777,10 @@ class PMA_Table
|
||||
$last = $parsed_sql['len'] - 1;
|
||||
$backquoted_source_db = PMA_backquote($source_db);
|
||||
for (++$i; $i <= $last; $i++) {
|
||||
if ($parsed_sql[$i]['type'] == $table_delimiter && $parsed_sql[$i]['data'] == $backquoted_source_db) {
|
||||
$parsed_sql[$i]['data'] = $target_for_view;
|
||||
if ($parsed_sql[$i]['type'] == $table_delimiter
|
||||
&& $parsed_sql[$i]['data'] == $backquoted_source_db
|
||||
) {
|
||||
$parsed_sql[$i]['data'] = $target_for_view;
|
||||
}
|
||||
}
|
||||
unset($last,$backquoted_source_db);
|
||||
@ -723,8 +793,9 @@ class PMA_Table
|
||||
// If table exists, and 'add drop table' is selected: Drop it!
|
||||
$drop_query = '';
|
||||
if (isset($GLOBALS['drop_if_exists'])
|
||||
&& $GLOBALS['drop_if_exists'] == 'true') {
|
||||
if (PMA_Table::_isView($target_db,$target_table)) {
|
||||
&& $GLOBALS['drop_if_exists'] == 'true'
|
||||
) {
|
||||
if (PMA_Table::_isView($target_db, $target_table)) {
|
||||
$drop_query = 'DROP VIEW';
|
||||
} else {
|
||||
$drop_query = 'DROP TABLE';
|
||||
@ -745,7 +816,8 @@ class PMA_Table
|
||||
$GLOBALS['sql_query'] .= "\n" . $sql_structure . ';';
|
||||
|
||||
if (($move || isset($GLOBALS['add_constraints']))
|
||||
&& !empty($GLOBALS['sql_constraints_query'])) {
|
||||
&& !empty($GLOBALS['sql_constraints_query'])
|
||||
) {
|
||||
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints_query']);
|
||||
$i = 0;
|
||||
|
||||
@ -768,7 +840,8 @@ class PMA_Table
|
||||
|
||||
for ($j = $i; $j < $cnt; $j++) {
|
||||
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
|
||||
&& strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT') {
|
||||
&& strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT'
|
||||
) {
|
||||
if ($parsed_sql[$j+1]['type'] == $table_delimiter) {
|
||||
$parsed_sql[$j+1]['data'] = '';
|
||||
}
|
||||
@ -776,8 +849,9 @@ class PMA_Table
|
||||
}
|
||||
|
||||
// Generate query back
|
||||
$GLOBALS['sql_constraints_query'] = PMA_SQP_formatHtml($parsed_sql,
|
||||
'query_only');
|
||||
$GLOBALS['sql_constraints_query'] = PMA_SQP_formatHtml(
|
||||
$parsed_sql, 'query_only'
|
||||
);
|
||||
if ($mode == 'one_table') {
|
||||
PMA_DBI_query($GLOBALS['sql_constraints_query']);
|
||||
}
|
||||
@ -791,9 +865,10 @@ class PMA_Table
|
||||
}
|
||||
|
||||
// Copy the data unless this is a VIEW
|
||||
if (($what == 'data' || $what == 'dataonly') && ! PMA_Table::_isView($target_db,$target_table)) {
|
||||
$sql_insert_data =
|
||||
'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
|
||||
if (($what == 'data' || $what == 'dataonly')
|
||||
&& ! PMA_Table::_isView($target_db, $target_table)
|
||||
) {
|
||||
$sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
|
||||
PMA_DBI_query($sql_insert_data);
|
||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_insert_data . ';';
|
||||
}
|
||||
@ -807,7 +882,7 @@ class PMA_Table
|
||||
// moving table from replicated one to not replicated one
|
||||
PMA_DBI_select_db($source_db);
|
||||
|
||||
if (PMA_Table::_isView($source_db,$source_table)) {
|
||||
if (PMA_Table::_isView($source_db, $source_table)) {
|
||||
$sql_drop_query = 'DROP VIEW';
|
||||
} else {
|
||||
$sql_drop_query = 'DROP TABLE';
|
||||
@ -902,7 +977,7 @@ class PMA_Table
|
||||
}
|
||||
|
||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_drop_query . ';';
|
||||
// end if ($move)
|
||||
// end if ($move)
|
||||
} else {
|
||||
// we are copying
|
||||
// Create new entries as duplicates from old PMA DBs
|
||||
@ -910,7 +985,7 @@ class PMA_Table
|
||||
if ($GLOBALS['cfgRelation']['commwork']) {
|
||||
// Get all comments and MIME-Types for current table
|
||||
$comments_copy_query = 'SELECT
|
||||
column_name, ' . PMA_backquote('comment') . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
|
||||
column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
|
||||
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
|
||||
WHERE
|
||||
db_name = \'' . PMA_sqlAddSlashes($source_db) . '\' AND
|
||||
@ -920,7 +995,7 @@ class PMA_Table
|
||||
// Write every comment as new copied entry. [MIME]
|
||||
while ($comments_copy_row = PMA_DBI_fetch_assoc($comments_copy_rs)) {
|
||||
$new_comment_query = 'REPLACE INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info'])
|
||||
. ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') '
|
||||
. ' (db_name, table_name, column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') '
|
||||
. ' VALUES('
|
||||
. '\'' . PMA_sqlAddSlashes($target_db) . '\','
|
||||
. '\'' . PMA_sqlAddSlashes($target_table) . '\','
|
||||
@ -993,9 +1068,11 @@ class PMA_Table
|
||||
* checks if given name is a valid table name,
|
||||
* currently if not empty, trailing spaces, '.', '/' and '\'
|
||||
*
|
||||
* @todo add check for valid chars in filename on current system/os
|
||||
* @see http://dev.mysql.com/doc/refman/5.0/en/legal-names.html
|
||||
* @param string $table_name name to check
|
||||
* @param string $table_name name to check
|
||||
*
|
||||
* @todo add check for valid chars in filename on current system/os
|
||||
* @see http://dev.mysql.com/doc/refman/5.0/en/legal-names.html
|
||||
*
|
||||
* @return boolean whether the string is valid or not
|
||||
*/
|
||||
function isValidName($table_name)
|
||||
@ -1021,10 +1098,11 @@ class PMA_Table
|
||||
/**
|
||||
* renames table
|
||||
*
|
||||
* @param string $new_name new table name
|
||||
* @param string $new_db new database name
|
||||
* @param bool $is_view is this for a VIEW rename?
|
||||
* @return bool success
|
||||
* @param string $new_name new table name
|
||||
* @param string $new_db new database name
|
||||
* @param bool $is_view is this for a VIEW rename?
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
function rename($new_name, $new_db = null, $is_view = false)
|
||||
{
|
||||
@ -1060,7 +1138,11 @@ class PMA_Table
|
||||
}
|
||||
// I don't think a specific error message for views is necessary
|
||||
if (! PMA_DBI_query($GLOBALS['sql_query'])) {
|
||||
$this->errors[] = sprintf(__('Error renaming table %1$s to %2$s'), $this->getFullName(), $new_table->getFullName());
|
||||
$this->errors[] = sprintf(
|
||||
__('Error renaming table %1$s to %2$s'),
|
||||
$this->getFullName(),
|
||||
$new_table->getFullName()
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1143,8 +1225,11 @@ class PMA_Table
|
||||
unset($table_query);
|
||||
}
|
||||
|
||||
$this->messages[] = sprintf(__('Table %s has been renamed to %s'),
|
||||
htmlspecialchars($old_name), htmlspecialchars($new_name));
|
||||
$this->messages[] = sprintf(
|
||||
__('Table %s has been renamed to %s'),
|
||||
htmlspecialchars($old_name),
|
||||
htmlspecialchars($new_name)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1160,8 +1245,8 @@ class PMA_Table
|
||||
* - PRIMARY(fk_id1, fk_id2) // NONE
|
||||
* - UNIQUE(x,y) // NONE
|
||||
*
|
||||
* @param bool $backquoted whether to quote name with backticks ``
|
||||
*
|
||||
* @param bool $backquoted whether to quote name with backticks ``
|
||||
* @return array
|
||||
*/
|
||||
public function getUniqueColumns($backquoted = true)
|
||||
@ -1174,7 +1259,8 @@ class PMA_Table
|
||||
if (count($index) > 1) {
|
||||
continue;
|
||||
}
|
||||
$return[] = $this->getFullName($backquoted) . '.' . ($backquoted ? PMA_backquote($index[0]) : $index[0]);
|
||||
$return[] = $this->getFullName($backquoted) . '.'
|
||||
. ($backquoted ? PMA_backquote($index[0]) : $index[0]);
|
||||
}
|
||||
|
||||
return $return;
|
||||
@ -1185,10 +1271,11 @@ class PMA_Table
|
||||
*
|
||||
* returns an array with all columns make use of an index, in fact only
|
||||
* first columns in an index
|
||||
*
|
||||
*
|
||||
* e.g. index(col1, col2) would only return col1
|
||||
*
|
||||
* @param bool $backquoted whether to quote name with backticks ``
|
||||
* @param bool $backquoted whether to quote name with backticks ``
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getIndexedColumns($backquoted = true)
|
||||
@ -1198,7 +1285,8 @@ class PMA_Table
|
||||
|
||||
$return = array();
|
||||
foreach ($indexed as $column) {
|
||||
$return[] = $this->getFullName($backquoted) . '.' . ($backquoted ? PMA_backquote($column) : $column);
|
||||
$return[] = $this->getFullName($backquoted) . '.'
|
||||
. ($backquoted ? PMA_backquote($column) : $column);
|
||||
}
|
||||
|
||||
return $return;
|
||||
@ -1209,7 +1297,8 @@ class PMA_Table
|
||||
*
|
||||
* returns an array with all columns
|
||||
*
|
||||
* @param bool $backquoted whether to quote name with backticks ``
|
||||
* @param bool $backquoted whether to quote name with backticks ``
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getColumns($backquoted = true)
|
||||
@ -1219,7 +1308,8 @@ class PMA_Table
|
||||
|
||||
$return = array();
|
||||
foreach ($indexed as $column) {
|
||||
$return[] = $this->getFullName($backquoted) . '.' . ($backquoted ? PMA_backquote($column) : $column);
|
||||
$return[] = $this->getFullName($backquoted) . '.'
|
||||
. ($backquoted ? PMA_backquote($column) : $column);
|
||||
}
|
||||
|
||||
return $return;
|
||||
@ -1228,7 +1318,6 @@ class PMA_Table
|
||||
/**
|
||||
* Return UI preferences for this table from phpMyAdmin database.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getUiPrefsFromDb()
|
||||
@ -1237,11 +1326,10 @@ class PMA_Table
|
||||
PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
|
||||
|
||||
// Read from phpMyAdmin database
|
||||
$sql_query =
|
||||
" SELECT `prefs` FROM " . $pma_table .
|
||||
" WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'" .
|
||||
" AND `db_name` = '" . PMA_sqlAddSlashes($this->db_name) . "'" .
|
||||
" AND `table_name` = '" . PMA_sqlAddSlashes($this->name) . "'";
|
||||
$sql_query = " SELECT `prefs` FROM " . $pma_table
|
||||
. " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'"
|
||||
. " AND `db_name` = '" . PMA_sqlAddSlashes($this->db_name) . "'"
|
||||
. " AND `table_name` = '" . PMA_sqlAddSlashes($this->name) . "'";
|
||||
|
||||
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
|
||||
if (isset($row[0])) {
|
||||
@ -1258,22 +1346,23 @@ class PMA_Table
|
||||
*/
|
||||
protected function saveUiPrefsToDb()
|
||||
{
|
||||
$pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".".
|
||||
PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
|
||||
$pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "."
|
||||
. PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
|
||||
|
||||
$username = $GLOBALS['cfg']['Server']['user'];
|
||||
$sql_query =
|
||||
" REPLACE INTO " . $pma_table .
|
||||
" VALUES ('" . $username . "', '" . PMA_sqlAddSlashes($this->db_name) . "', '" .
|
||||
PMA_sqlAddSlashes($this->name) . "', '" .
|
||||
PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)";
|
||||
$sql_query = " REPLACE INTO " . $pma_table
|
||||
. " VALUES ('" . $username . "', '" . PMA_sqlAddSlashes($this->db_name)
|
||||
. "', '" . PMA_sqlAddSlashes($this->name) . "', '"
|
||||
. PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)";
|
||||
|
||||
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
|
||||
|
||||
if (!$success) {
|
||||
$message = PMA_Message::error(__('Could not save table UI preferences'));
|
||||
$message->addMessage('<br /><br />');
|
||||
$message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
|
||||
$message->addMessage(
|
||||
PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink']))
|
||||
);
|
||||
return $message;
|
||||
}
|
||||
|
||||
@ -1290,10 +1379,15 @@ class PMA_Table
|
||||
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
|
||||
|
||||
if (!$success) {
|
||||
$message = PMA_Message::error(__('Failed to cleanup table UI preferences (see cfg["Server"]["MaxTableUiprefs"] documentation)'));
|
||||
$message = PMA_Message::error(
|
||||
sprintf(
|
||||
__('Failed to cleanup table UI preferences (see $cfg[\'Servers\'][$i][\'MaxTableUiprefs\'] %s)'),
|
||||
PMA_showDocu('cfg_Servers_MaxTableUiprefs')
|
||||
)
|
||||
);
|
||||
$message->addMessage('<br /><br />');
|
||||
$message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
|
||||
print_r($message);
|
||||
print_r($message);
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
@ -1306,6 +1400,7 @@ class PMA_Table
|
||||
* If pmadb and table_uiprefs is set, it will load the UI preferences from
|
||||
* phpMyAdmin database.
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
protected function loadUiPrefs()
|
||||
{
|
||||
@ -1313,10 +1408,11 @@ class PMA_Table
|
||||
// set session variable if it's still undefined
|
||||
if (! isset($_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name])) {
|
||||
$_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name] =
|
||||
// check whether we can get from pmadb
|
||||
(strlen($GLOBALS['cfg']['Server']['pmadb'])
|
||||
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) ?
|
||||
$this->getUiPrefsFromDb() : array();
|
||||
// check whether we can get from pmadb
|
||||
(strlen($GLOBALS['cfg']['Server']['pmadb'])
|
||||
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs']))
|
||||
? $this->getUiPrefsFromDb()
|
||||
: array();
|
||||
}
|
||||
$this->uiprefs =& $_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name];
|
||||
}
|
||||
@ -1329,8 +1425,8 @@ class PMA_Table
|
||||
* - PROP_COLUMN_ORDER
|
||||
* - PROP_COLUMN_VISIB
|
||||
*
|
||||
* @param string $property property
|
||||
*
|
||||
* @param string $property
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUiProp($property)
|
||||
@ -1347,8 +1443,7 @@ class PMA_Table
|
||||
$avail_columns = $this->getColumns();
|
||||
foreach ($avail_columns as $each_col) {
|
||||
// check if $each_col ends with $colname
|
||||
if (substr_compare($each_col, $colname,
|
||||
strlen($each_col) - strlen($colname)) === 0) {
|
||||
if (substr_compare($each_col, $colname, strlen($each_col) - strlen($colname)) === 0) {
|
||||
return $this->uiprefs[$property];
|
||||
}
|
||||
}
|
||||
@ -1358,12 +1453,12 @@ class PMA_Table
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if ($property == self::PROP_COLUMN_ORDER ||
|
||||
$property == self::PROP_COLUMN_VISIB) {
|
||||
} elseif ($property == self::PROP_COLUMN_ORDER
|
||||
|| $property == self::PROP_COLUMN_VISIB
|
||||
) {
|
||||
if (! PMA_Table::isView($this->db_name, $this->name) && isset($this->uiprefs[$property])) {
|
||||
// check if the table has not been modified
|
||||
if (self::sGetStatusInfo($this->db_name, $this->name, 'Create_time') ==
|
||||
$this->uiprefs['CREATE_TIME']) {
|
||||
if (self::sGetStatusInfo($this->db_name, $this->name, 'Create_time') == $this->uiprefs['CREATE_TIME']) {
|
||||
return $this->uiprefs[$property];
|
||||
} else {
|
||||
// remove the property, since the table has been modified
|
||||
@ -1387,9 +1482,10 @@ class PMA_Table
|
||||
* - PROP_COLUMN_ORDER
|
||||
* - PROP_COLUMN_VISIB
|
||||
*
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
* @param string $property Property
|
||||
* @param mixed $value Value for the property
|
||||
* @param string $table_create_time Needed for PROP_COLUMN_ORDER and PROP_COLUMN_VISIB
|
||||
*
|
||||
* @return boolean|PMA_Message
|
||||
*/
|
||||
public function setUiProp($property, $value, $table_create_time = null)
|
||||
@ -1398,12 +1494,13 @@ class PMA_Table
|
||||
$this->loadUiPrefs();
|
||||
}
|
||||
// we want to save the create time if the property is PROP_COLUMN_ORDER
|
||||
if (! PMA_Table::isView($this->db_name, $this->name) && ($property == self::PROP_COLUMN_ORDER ||
|
||||
$property == self::PROP_COLUMN_VISIB)) {
|
||||
|
||||
if (! PMA_Table::isView($this->db_name, $this->name)
|
||||
&& ($property == self::PROP_COLUMN_ORDER || $property == self::PROP_COLUMN_VISIB)
|
||||
) {
|
||||
$curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME');
|
||||
if (isset($table_create_time) &&
|
||||
$table_create_time == $curr_create_time) {
|
||||
if (isset($table_create_time)
|
||||
&& $table_create_time == $curr_create_time
|
||||
) {
|
||||
$this->uiprefs['CREATE_TIME'] = $curr_create_time;
|
||||
} else {
|
||||
// there is no $table_create_time, or
|
||||
@ -1416,7 +1513,8 @@ class PMA_Table
|
||||
$this->uiprefs[$property] = $value;
|
||||
// check if pmadb is set
|
||||
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
|
||||
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) {
|
||||
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
|
||||
) {
|
||||
return $this->saveUiprefsToDb();
|
||||
}
|
||||
return true;
|
||||
@ -1425,7 +1523,8 @@ class PMA_Table
|
||||
/**
|
||||
* Remove a property from UI preferences.
|
||||
*
|
||||
* @param string $property
|
||||
* @param string $property the property
|
||||
*
|
||||
* @return true|PMA_Message
|
||||
*/
|
||||
public function removeUiProp($property)
|
||||
@ -1437,7 +1536,8 @@ class PMA_Table
|
||||
unset($this->uiprefs[$property]);
|
||||
// check if pmadb is set
|
||||
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
|
||||
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) {
|
||||
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
|
||||
) {
|
||||
return $this->saveUiprefsToDb();
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +130,7 @@ class PMA_Theme
|
||||
* checks image path for existance - if not found use img from original theme
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function checkImgPath()
|
||||
{
|
||||
@ -282,6 +283,7 @@ class PMA_Theme
|
||||
*
|
||||
* @access public
|
||||
* @param string $type left, right or print
|
||||
* @return bool
|
||||
*/
|
||||
function loadCss(&$type)
|
||||
{
|
||||
|
||||
@ -38,7 +38,7 @@ class PMA_Theme_Manager
|
||||
var $active_theme = '';
|
||||
|
||||
/**
|
||||
* @var object PMA_Theme active theme
|
||||
* @var PMA_Theme PMA_Theme active theme
|
||||
*/
|
||||
var $theme = null;
|
||||
|
||||
@ -193,6 +193,7 @@ class PMA_Theme_Manager
|
||||
/**
|
||||
* save theme in cookie
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
function setThemeCookie()
|
||||
{
|
||||
@ -224,6 +225,8 @@ class PMA_Theme_Manager
|
||||
|
||||
/**
|
||||
* read all themes
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
function loadThemes()
|
||||
{
|
||||
@ -232,9 +235,11 @@ class PMA_Theme_Manager
|
||||
if ($handleThemes = opendir($this->getThemesPath())) {
|
||||
// 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)) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($PMA_Theme, $this->themes)) {
|
||||
// this does nothing!
|
||||
//$this->themes[$PMA_Theme] = $this->themes[$PMA_Theme];
|
||||
continue;
|
||||
}
|
||||
$new_theme = PMA_Theme::load($this->getThemesPath() . '/' . $PMA_Theme);
|
||||
@ -259,6 +264,7 @@ class PMA_Theme_Manager
|
||||
* checks if given theme name is a known theme
|
||||
*
|
||||
* @param string $theme name fo theme to check for
|
||||
* @return bool
|
||||
*/
|
||||
function checkTheme($theme)
|
||||
{
|
||||
@ -273,6 +279,7 @@ class PMA_Theme_Manager
|
||||
* returns HTML selectbox, with or without form enclosed
|
||||
*
|
||||
* @param boolean $form whether enclosed by from tags or not
|
||||
* @return string
|
||||
*/
|
||||
function getHtmlSelectBox($form = true)
|
||||
{
|
||||
@ -318,8 +325,8 @@ class PMA_Theme_Manager
|
||||
/**
|
||||
* load layout file if exists
|
||||
*/
|
||||
if (@file_exists($GLOBALS['pmaThemePath'] . 'layout.inc.php')) {
|
||||
include $GLOBALS['pmaThemePath'] . 'layout.inc.php';
|
||||
if (file_exists($this->theme->getLayoutFile())) {
|
||||
include $this->theme->getLayoutFile();
|
||||
}
|
||||
|
||||
|
||||
@ -351,6 +358,9 @@ class PMA_Theme_Manager
|
||||
|
||||
/**
|
||||
* prints css data
|
||||
*
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
function printCss($type)
|
||||
{
|
||||
|
||||
@ -71,6 +71,7 @@ class PMA_Tracker
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
static public function init()
|
||||
{
|
||||
@ -86,15 +87,15 @@ class PMA_Tracker
|
||||
self::$default_tracking_set = $GLOBALS['cfg']['Server']['tracking_default_statements'];
|
||||
|
||||
self::$version_auto_create = $GLOBALS['cfg']['Server']['tracking_version_auto_create'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually enables tracking. This needs to be done after all
|
||||
* Actually enables tracking. This needs to be done after all
|
||||
* underlaying code is initialized.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
static public function enable()
|
||||
{
|
||||
@ -130,45 +131,12 @@ class PMA_Tracker
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a simple DROP TABLE statement.
|
||||
*
|
||||
* @param string $tablename
|
||||
* @return string
|
||||
*/
|
||||
static public function getStatementDropTable($tablename)
|
||||
{
|
||||
return 'DROP TABLE IF EXISTS ' . $tablename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a simple DROP VIEW statement.
|
||||
*
|
||||
* @param string $viewname
|
||||
* @return string
|
||||
*/
|
||||
static public function getStatementDropView($viewname)
|
||||
{
|
||||
return 'DROP VIEW IF EXISTS ' . $viewname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a simple DROP DATABASE statement.
|
||||
*
|
||||
* @param string $dbname
|
||||
* @return string
|
||||
*/
|
||||
static public function getStatementDropDatabase($dbname)
|
||||
{
|
||||
return 'DROP DATABASE IF EXISTS ' . $dbname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the name of a table from a SQL statement substring.
|
||||
*
|
||||
* @static
|
||||
* @param string $string part of SQL statement
|
||||
*
|
||||
* @param string $string part of SQL statement
|
||||
* @static
|
||||
*
|
||||
* @return string the name of table
|
||||
*/
|
||||
@ -177,8 +145,7 @@ class PMA_Tracker
|
||||
if (strstr($string, '.')) {
|
||||
$temp = explode('.', $string);
|
||||
$tablename = $temp[1];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$tablename = $string;
|
||||
}
|
||||
|
||||
@ -196,10 +163,10 @@ class PMA_Tracker
|
||||
/**
|
||||
* Gets the tracking status of a table, is it active or deactive ?
|
||||
*
|
||||
* @static
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @static
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
@ -217,10 +184,9 @@ class PMA_Tracker
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql_query =
|
||||
" SELECT tracking_active FROM " . self::$pma_table .
|
||||
" WHERE " . PMA_backquote('db_name') . " = '" . PMA_sqlAddSlashes($dbname) . "' " .
|
||||
" AND " . PMA_backquote('table_name') . " = '" . PMA_sqlAddSlashes($tablename) . "' " .
|
||||
$sql_query = " SELECT tracking_active FROM " . self::$pma_table .
|
||||
" WHERE db_name = '" . PMA_sqlAddSlashes($dbname) . "' " .
|
||||
" AND table_name = '" . PMA_sqlAddSlashes($tablename) . "' " .
|
||||
" ORDER BY version DESC";
|
||||
|
||||
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
|
||||
@ -248,13 +214,13 @@ class PMA_Tracker
|
||||
* Creates tracking version of a table / view
|
||||
* (in other words: create a job to track future changes on the table).
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
* @param string $tracking_set set of tracking statements
|
||||
* @param string $is_view if table is a view
|
||||
* @param bool $is_view if table is a view
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @return int result of version insertion
|
||||
*/
|
||||
@ -266,20 +232,20 @@ class PMA_Tracker
|
||||
$tracking_set = self::$default_tracking_set;
|
||||
}
|
||||
|
||||
require_once './libraries/export/sql.php';
|
||||
include_once './libraries/export/sql.php';
|
||||
|
||||
$sql_backquotes = true;
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
|
||||
// Get data definition snapshot of table
|
||||
$sql_query = '
|
||||
SHOW FULL COLUMNS FROM ' . PMA_backquote($dbname) . '.' . PMA_backquote($tablename);
|
||||
|
||||
$sql_result = PMA_DBI_query($sql_query);
|
||||
|
||||
while ($row = PMA_DBI_fetch_array($sql_result)) {
|
||||
$columns[] = $row;
|
||||
$columns = PMA_DBI_get_columns($dbname, $tablename, true);
|
||||
// int indices to reduce size
|
||||
$columns = array_values($columns);
|
||||
// remove Privileges to reduce size
|
||||
for ($i = 0; $i < count($columns); $i++) {
|
||||
unset($columns[$i]['Privileges']);
|
||||
}
|
||||
|
||||
$sql_query = '
|
||||
@ -289,7 +255,7 @@ class PMA_Tracker
|
||||
|
||||
$indexes = array();
|
||||
|
||||
while($row = PMA_DBI_fetch_array($sql_result)) {
|
||||
while ($row = PMA_DBI_fetch_assoc($sql_result)) {
|
||||
$indexes[] = $row;
|
||||
}
|
||||
|
||||
@ -303,13 +269,13 @@ class PMA_Tracker
|
||||
|
||||
if (self::$add_drop_table == true && $is_view == false) {
|
||||
$create_sql .= self::getLogComment() .
|
||||
self::getStatementDropTable(PMA_backquote($tablename)) . ";\n";
|
||||
'DROP TABLE IF EXISTS ' . PMA_backquote($tablename) . ";\n";
|
||||
|
||||
}
|
||||
|
||||
if (self::$add_drop_view == true && $is_view == true) {
|
||||
$create_sql .= self::getLogComment() .
|
||||
self::getStatementDropView(PMA_backquote($tablename)) . ";\n";
|
||||
'DROP VIEW IF EXISTS ' . PMA_backquote($tablename) . ";\n";
|
||||
}
|
||||
|
||||
$create_sql .= self::getLogComment() .
|
||||
@ -317,8 +283,7 @@ class PMA_Tracker
|
||||
|
||||
// Save version
|
||||
|
||||
$sql_query =
|
||||
"/*NOTRACK*/\n" .
|
||||
$sql_query = "/*NOTRACK*/\n" .
|
||||
"INSERT INTO" . self::$pma_table . " (" .
|
||||
"db_name, " .
|
||||
"table_name, " .
|
||||
@ -353,19 +318,18 @@ class PMA_Tracker
|
||||
|
||||
|
||||
/**
|
||||
* Removes all tracking data for a table
|
||||
* Removes all tracking data for a table
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
*
|
||||
* @return int result of version insertion
|
||||
*/
|
||||
static public function deleteTracking($dbname, $tablename)
|
||||
{
|
||||
$sql_query =
|
||||
"/*NOTRACK*/\n" .
|
||||
$sql_query = "/*NOTRACK*/\n" .
|
||||
"DELETE FROM " . self::$pma_table . " WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "'";
|
||||
$result = PMA_query_as_controluser($sql_query);
|
||||
|
||||
@ -376,39 +340,36 @@ class PMA_Tracker
|
||||
* Creates tracking version of a database
|
||||
* (in other words: create a job to track future changes on the database).
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $version version
|
||||
* @param string $query query
|
||||
* @param string $tracking_set set of tracking statements
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @return int result of version insertion
|
||||
*/
|
||||
static public function createDatabaseVersion($dbname, $version, $query, $tracking_set = 'CREATE DATABASE,ALTER DATABASE,DROP DATABASE')
|
||||
{
|
||||
global $sql_backquotes;
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
|
||||
if ($tracking_set == '') {
|
||||
$tracking_set = self::$default_tracking_set;
|
||||
}
|
||||
|
||||
require_once './libraries/export/sql.php';
|
||||
include_once './libraries/export/sql.php';
|
||||
|
||||
$create_sql = "";
|
||||
|
||||
if (self::$add_drop_database == true) {
|
||||
$create_sql .= self::getLogComment() .
|
||||
self::getStatementDropDatabase(PMA_backquote($dbname)) . ";\n";
|
||||
'DROP DATABASE IF EXISTS ' . PMA_backquote($dbname) . ";\n";
|
||||
}
|
||||
|
||||
$create_sql .= self::getLogComment() . $query;
|
||||
|
||||
// Save version
|
||||
$sql_query =
|
||||
"/*NOTRACK*/\n" .
|
||||
$sql_query = "/*NOTRACK*/\n" .
|
||||
"INSERT INTO" . self::$pma_table . " (" .
|
||||
"db_name, " .
|
||||
"table_name, " .
|
||||
@ -441,19 +402,18 @@ class PMA_Tracker
|
||||
/**
|
||||
* Changes tracking of a table.
|
||||
*
|
||||
* @static
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
* @param integer $new_state the new state of tracking
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
* @param integer $new_state the new state of tracking
|
||||
* @static
|
||||
*
|
||||
* @return int result of SQL query
|
||||
*/
|
||||
static private function changeTracking($dbname, $tablename, $version, $new_state)
|
||||
static private function _changeTracking($dbname, $tablename, $version, $new_state)
|
||||
{
|
||||
$sql_query =
|
||||
" UPDATE " . self::$pma_table .
|
||||
$sql_query = " UPDATE " . self::$pma_table .
|
||||
" SET `tracking_active` = '" . $new_state . "' " .
|
||||
" WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
|
||||
" AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' " .
|
||||
@ -467,38 +427,38 @@ class PMA_Tracker
|
||||
/**
|
||||
* Changes tracking data of a table.
|
||||
*
|
||||
* @static
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
* @param string $type type of data(DDL || DML)
|
||||
* @param string|array $new_data the new tracking data
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
* @param string $type type of data(DDL || DML)
|
||||
* @param string || array $new_data the new tracking data
|
||||
* @static
|
||||
*
|
||||
* @return bool result of change
|
||||
*/
|
||||
static public function changeTrackingData($dbname, $tablename, $version, $type, $new_data)
|
||||
{
|
||||
if ($type == 'DDL')
|
||||
if ($type == 'DDL') {
|
||||
$save_to = 'schema_sql';
|
||||
elseif ($type == 'DML')
|
||||
} elseif ($type == 'DML') {
|
||||
$save_to = 'data_sql';
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
|
||||
}
|
||||
$date = date('Y-m-d H:i:s');
|
||||
|
||||
$new_data_processed = '';
|
||||
if (is_array($new_data)) {
|
||||
foreach ($new_data as $data) {
|
||||
$new_data_processed .= '# log ' . $date . ' ' . $data['username'] . PMA_sqlAddSlashes($data['statement']) . "\n";
|
||||
$new_data_processed .= '# log ' . $date . ' ' . $data['username']
|
||||
. PMA_sqlAddSlashes($data['statement']) . "\n";
|
||||
}
|
||||
} else {
|
||||
$new_data_processed = $new_data;
|
||||
}
|
||||
|
||||
$sql_query =
|
||||
" UPDATE " . self::$pma_table .
|
||||
$sql_query = " UPDATE " . self::$pma_table .
|
||||
" SET `" . $save_to . "` = '" . $new_data_processed . "' " .
|
||||
" WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
|
||||
" AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' " .
|
||||
@ -512,34 +472,34 @@ class PMA_Tracker
|
||||
/**
|
||||
* Activates tracking of a table.
|
||||
*
|
||||
* @static
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
* @static
|
||||
*
|
||||
* @return int result of SQL query
|
||||
*/
|
||||
static public function activateTracking($dbname, $tablename, $version)
|
||||
{
|
||||
return self::changeTracking($dbname, $tablename, $version, 1);
|
||||
return self::_changeTracking($dbname, $tablename, $version, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deactivates tracking of a table.
|
||||
*
|
||||
* @static
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version
|
||||
* @static
|
||||
*
|
||||
* @return int result of SQL query
|
||||
*/
|
||||
static public function deactivateTracking($dbname, $tablename, $version)
|
||||
{
|
||||
return self::changeTracking($dbname, $tablename, $version, 0);
|
||||
return self::_changeTracking($dbname, $tablename, $version, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -547,18 +507,17 @@ class PMA_Tracker
|
||||
* Gets the newest version of a tracking job
|
||||
* (in other words: gets the HEAD version).
|
||||
*
|
||||
* @static
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $statement tracked statement
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $statement tracked statement
|
||||
* @static
|
||||
*
|
||||
* @return int (-1 if no version exists | > 0 if a version exists)
|
||||
*/
|
||||
static public function getVersion($dbname, $tablename, $statement = null)
|
||||
{
|
||||
$sql_query =
|
||||
" SELECT MAX(version) FROM " . self::$pma_table .
|
||||
$sql_query = " SELECT MAX(version) FROM " . self::$pma_table .
|
||||
" WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
|
||||
" AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' ";
|
||||
|
||||
@ -566,24 +525,20 @@ class PMA_Tracker
|
||||
$sql_query .= " AND FIND_IN_SET('" . $statement . "',tracking) > 0" ;
|
||||
}
|
||||
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
|
||||
if (isset($row[0])) {
|
||||
$version = $row[0];
|
||||
}
|
||||
if (! isset($version)) {
|
||||
$version = -1;
|
||||
}
|
||||
return $version;
|
||||
return isset($row[0])
|
||||
? $row[0]
|
||||
: -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the record of a tracking job.
|
||||
*
|
||||
* @static
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version number
|
||||
*
|
||||
* @param string $dbname name of database
|
||||
* @param string $tablename name of table
|
||||
* @param string $version version number
|
||||
* @static
|
||||
*
|
||||
* @return mixed record DDM log, DDL log, structure snapshot, tracked statements.
|
||||
*/
|
||||
@ -598,9 +553,9 @@ class PMA_Tracker
|
||||
$sql_query .= " AND `table_name` = '" . PMA_sqlAddSlashes($tablename) ."' ";
|
||||
}
|
||||
$sql_query .= " AND `version` = '" . PMA_sqlAddSlashes($version) ."' ".
|
||||
" ORDER BY `version` DESC ";
|
||||
" ORDER BY `version` DESC LIMIT 1";
|
||||
|
||||
$mixed = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
|
||||
$mixed = PMA_DBI_fetch_assoc(PMA_query_as_controluser($sql_query));
|
||||
|
||||
// Parse log
|
||||
$log_schema_entries = explode('# log ', $mixed['schema_sql']);
|
||||
@ -683,12 +638,12 @@ class PMA_Tracker
|
||||
* - type of statement, is it part of DDL or DML ?
|
||||
* - tablename
|
||||
*
|
||||
* @param string $query query
|
||||
*
|
||||
* @static
|
||||
* @todo: using PMA SQL Parser when possible
|
||||
* @todo: support multi-table/view drops
|
||||
*
|
||||
* @param string $query
|
||||
*
|
||||
* @return mixed Array containing identifier, type and tablename.
|
||||
*
|
||||
*/
|
||||
@ -723,9 +678,10 @@ class PMA_Tracker
|
||||
$result['type'] = 'DDL';
|
||||
|
||||
// Parse CREATE VIEW statement
|
||||
if (in_array('CREATE', $tokens) == true &&
|
||||
in_array('VIEW', $tokens) == true &&
|
||||
in_array('AS', $tokens) == true) {
|
||||
if (in_array('CREATE', $tokens) == true
|
||||
&& in_array('VIEW', $tokens) == true
|
||||
&& in_array('AS', $tokens) == true
|
||||
) {
|
||||
$result['identifier'] = 'CREATE VIEW';
|
||||
|
||||
$index = array_search('VIEW', $tokens);
|
||||
@ -734,10 +690,11 @@ class PMA_Tracker
|
||||
}
|
||||
|
||||
// Parse ALTER VIEW statement
|
||||
if (in_array('ALTER', $tokens) == true &&
|
||||
in_array('VIEW', $tokens) == true &&
|
||||
in_array('AS', $tokens) == true &&
|
||||
! isset($result['identifier'])) {
|
||||
if (in_array('ALTER', $tokens) == true
|
||||
&& in_array('VIEW', $tokens) == true
|
||||
&& in_array('AS', $tokens) == true
|
||||
&& ! isset($result['identifier'])
|
||||
) {
|
||||
$result['identifier'] = 'ALTER VIEW';
|
||||
|
||||
$index = array_search('VIEW', $tokens);
|
||||
@ -817,11 +774,10 @@ class PMA_Tracker
|
||||
}
|
||||
|
||||
// Parse CREATE INDEX statement
|
||||
if (! isset($result['identifier']) &&
|
||||
( substr($query, 0, 12) == 'CREATE INDEX' ||
|
||||
substr($query, 0, 19) == 'CREATE UNIQUE INDEX' ||
|
||||
substr($query, 0, 20) == 'CREATE SPATIAL INDEX'
|
||||
)
|
||||
if (! isset($result['identifier'])
|
||||
&& (substr($query, 0, 12) == 'CREATE INDEX'
|
||||
|| substr($query, 0, 19) == 'CREATE UNIQUE INDEX'
|
||||
|| substr($query, 0, 20) == 'CREATE SPATIAL INDEX')
|
||||
) {
|
||||
$result['identifier'] = 'CREATE INDEX';
|
||||
$prefix = explode('ON ', $query);
|
||||
@ -861,7 +817,7 @@ class PMA_Tracker
|
||||
}
|
||||
|
||||
// Parse INSERT INTO statement
|
||||
if (! isset($result['identifier']) && substr($query, 0, 11 ) == 'INSERT INTO') {
|
||||
if (! isset($result['identifier']) && substr($query, 0, 11) == 'INSERT INTO') {
|
||||
$result['identifier'] = 'INSERT';
|
||||
$prefix = explode('INSERT INTO', $query);
|
||||
$suffix = explode('(', $prefix[1]);
|
||||
@ -869,7 +825,7 @@ class PMA_Tracker
|
||||
}
|
||||
|
||||
// Parse DELETE statement
|
||||
if (! isset($result['identifier']) && substr($query, 0, 6 ) == 'DELETE') {
|
||||
if (! isset($result['identifier']) && substr($query, 0, 6) == 'DELETE') {
|
||||
$result['identifier'] = 'DELETE';
|
||||
$prefix = explode('FROM ', $query);
|
||||
$suffix = explode(' ', $prefix[1]);
|
||||
@ -877,7 +833,7 @@ class PMA_Tracker
|
||||
}
|
||||
|
||||
// Parse TRUNCATE statement
|
||||
if (! isset($result['identifier']) && substr($query, 0, 8 ) == 'TRUNCATE') {
|
||||
if (! isset($result['identifier']) && substr($query, 0, 8) == 'TRUNCATE') {
|
||||
$result['identifier'] = 'TRUNCATE';
|
||||
$prefix = explode('TRUNCATE', $query);
|
||||
$result['tablename'] = self::getTableName($prefix[1]);
|
||||
@ -890,15 +846,17 @@ class PMA_Tracker
|
||||
/**
|
||||
* Analyzes a given SQL statement and saves tracking data.
|
||||
*
|
||||
* @param string $query a SQL query
|
||||
*
|
||||
* @static
|
||||
* @param string $query a SQL query
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
static public function handleQuery($query)
|
||||
{
|
||||
// If query is marked as untouchable, leave
|
||||
if (strstr($query, "/*NOTRACK*/")) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (! (substr($query, -1) == ';')) {
|
||||
@ -912,7 +870,7 @@ class PMA_Tracker
|
||||
// $dbname can be empty, for example when coming from Synchronize
|
||||
// and this is a query for the remote server
|
||||
if (empty($dbname)) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// If we found a valid statement
|
||||
@ -921,8 +879,9 @@ class PMA_Tracker
|
||||
|
||||
// If version not exists and auto-creation is enabled
|
||||
if (self::$version_auto_create == true
|
||||
&& self::isTracked($dbname, $result['tablename']) == false
|
||||
&& $version == -1) {
|
||||
&& self::isTracked($dbname, $result['tablename']) == false
|
||||
&& $version == -1
|
||||
) {
|
||||
// Create the version
|
||||
|
||||
switch ($result['identifier']) {
|
||||
@ -956,11 +915,10 @@ class PMA_Tracker
|
||||
$query = self::getLogComment() . $query ;
|
||||
|
||||
// Mark it as untouchable
|
||||
$sql_query =
|
||||
" /*NOTRACK*/\n" .
|
||||
$sql_query = " /*NOTRACK*/\n" .
|
||||
" UPDATE " . self::$pma_table .
|
||||
" SET " . PMA_backquote($save_to) ." = CONCAT( " . PMA_backquote($save_to) . ",'\n" . PMA_sqlAddSlashes($query) . "') ," .
|
||||
" `date_updated` = '" . $date . "' ";
|
||||
" SET " . PMA_backquote($save_to) ." = CONCAT( " . PMA_backquote($save_to) . ",'\n"
|
||||
. PMA_sqlAddSlashes($query) . "') ," . " `date_updated` = '" . $date . "' ";
|
||||
|
||||
// If table was renamed we have to change the tablename attribute in pma_tracking too
|
||||
if ($result['identifier'] == 'RENAME TABLE') {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# phpMyAdmin Advisory rules file
|
||||
# Use only UNIX style newlines
|
||||
# This file is being parsed by advisor.class.php, which should handle syntax errors correctly.
|
||||
# This file is being parsed by Advisor.class.php, which should handle syntax errors correctly.
|
||||
# However, PHP Warnings and the like are being consumed by the phpMyAdmin error handler, so those won't show up
|
||||
# E.g.: Justification line is empty because you used an unescape percent sign, sprintf() returns an empty string and no warning/error is shown
|
||||
#
|
||||
@ -74,9 +74,9 @@ rule 'Slow query logging'
|
||||
|
||||
#
|
||||
# versions
|
||||
rule 'Release Series'
|
||||
rule 'Release Series' [!PMA_DRIZZLE]
|
||||
version
|
||||
!PMA_DRIZZLE && substr(value,0,1) <= 5 && substr(value,2,1) < 1
|
||||
substr(value,0,1) <= 5 && substr(value,2,1) < 1
|
||||
The MySQL server version less then 5.1.
|
||||
You should upgrade, as MySQL 5.1 has improved performance, and MySQL 5.5 even more so.
|
||||
Current version: %s | value
|
||||
@ -111,7 +111,7 @@ rule 'Distribution'
|
||||
|
||||
rule 'MySQL Architecture'
|
||||
system_memory
|
||||
value > 3072*1024 && !preg_match('/64/',version_compile_machine)
|
||||
value > 3072*1024 && !preg_match('/64/',version_compile_machine) && !preg_match('/64/',version_compile_os)
|
||||
MySQL is not compiled as a 64-bit package.
|
||||
Your memory capacity is above 3 GiB (assuming the Server is on localhost), so MySQL might not be able to access all of your memory. You might want to consider installing the 64-bit version of MySQL.
|
||||
Available memory on this host: %s | implode(' ',PMA_formatByteDown(value*1024, 2, 2))
|
||||
@ -131,7 +131,7 @@ rule 'Query cache usage' [!fired('Query cache disabled')]
|
||||
Questions / Uptime
|
||||
value > 100
|
||||
Suboptimal caching method.
|
||||
You are using the MySQL Query cache with a fairly high traffic database. It might be worth considering to use <a href="http://dev.mysql.com/doc/refman/5.1/en/ha-memcached.html">memcached</a> instead of the MySQL Query cache, especially if you have multiple slaves.
|
||||
You are using the MySQL Query cache with a fairly high traffic database. It might be worth considering to use <a href="http://dev.mysql.com/doc/refman/5.5/en/ha-memcached.html">memcached</a> instead of the MySQL Query cache, especially if you have multiple slaves.
|
||||
The query cache is enabled and the server receives %d queries per second. This rule fires if there is more than 100 queries per second. | round(value,1)
|
||||
|
||||
rule 'Query cache efficiency (%)' [Com_select + Qcache_hits > 0 && !fired('Query cache disabled')]
|
||||
@ -214,6 +214,7 @@ rule 'Rate of reading first index entry'
|
||||
This usually indicates frequent full index scans. Full index scans are faster than table scans but require lots of CPU cycles in big tables, if those tables that have or had high volumes of UPDATEs and DELETEs, running 'OPTIMIZE TABLE' might reduce the amount of and/or speed up full index scans. Other than that full index scans can only be reduced by rewriting queries.
|
||||
Index scans average: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
|
||||
|
||||
# This rule may be applicable to MyISAM-only workloads, but completely wrong for InnoDB - http://www.mysqlperformanceblog.com/2010/06/15/what-does-handler_read_rnd-mean/
|
||||
rule 'Rate of reading fixed position'
|
||||
Handler_read_rnd / Uptime
|
||||
value * 60 * 60 > 1
|
||||
@ -247,19 +248,19 @@ rule 'Temp disk rate'
|
||||
Created_tmp_disk_tables / Uptime
|
||||
value * 60 * 60 > 1
|
||||
Many temporary tables are being written to disk instead of being kept in memory.
|
||||
Increasing {max_heap_table_size} and {tmp_table_size} might help. However some temporary tables are always being written to disk, independent of the value of these variables. To eliminate these you will have to rewrite your queries to avoid those conditions (Within a temprorary table: Presence of a BLOB or TEXT column or presence of a column bigger than 512 bytes) as mentioned in in the <a href="http://dev.mysql.com/doc/refman/5.0/en/internal-temporary-tables.html">MySQL Documentation</a>
|
||||
Increasing {max_heap_table_size} and {tmp_table_size} might help. However some temporary tables are always being written to disk, independent of the value of these variables. To eliminate these you will have to rewrite your queries to avoid those conditions (Within a temprorary table: Presence of a BLOB or TEXT column or presence of a column bigger than 512 bytes) as mentioned in in the <a href="http://dev.mysql.com/doc/refman/5.5/en/internal-temporary-tables.html">MySQL Documentation</a>
|
||||
Rate of temporay tables being written to disk: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
|
||||
|
||||
# I couldn't find any source on the internet that suggests a direct relation between high counts of temporary tables and any of these variables.
|
||||
# Several independent Blog entries suggest (http://ronaldbradford.com/blog/more-on-understanding-sort_buffer_size-2010-05-10/ and http://www.xaprb.com/blog/2010/05/09/how-to-tune-mysqls-sort_buffer_size/)
|
||||
# that sort_buffer_size should be left as it is. And increasing read_buffer_size is only suggested when there are a lot of
|
||||
# table scans (http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_read_buffer_size and other sources) though
|
||||
# table scans (http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_read_buffer_size and other sources) though
|
||||
# setting it too high is bad too (http://www.mysqlperformanceblog.com/2007/09/17/mysql-what-read_buffer_size-value-is-optimal/).
|
||||
#rule 'Temp table rate'
|
||||
# Created_tmp_tables / Uptime
|
||||
# value * 60 * 60 > 1
|
||||
# Many intermediate temporary tables are being created.
|
||||
# This may be caused by queries under certain conditions as mentioned in the <a href="http://dev.mysql.com/doc/refman/5.0/en/internal-temporary-tables.html">MySQL Documentation</a>. Consider increasing {sort_buffer_size} (sorting), {read_rnd_buffer_size} (random read buffer, ie, post-sort), {read_buffer_size} (sequential scan).
|
||||
# This may be caused by queries under certain conditions as mentioned in the <a href="http://dev.mysql.com/doc/refman/5.5/en/internal-temporary-tables.html">MySQL Documentation</a>. Consider increasing {sort_buffer_size} (sorting), {read_rnd_buffer_size} (random read buffer, ie, post-sort), {read_buffer_size} (sequential scan).
|
||||
|
||||
#
|
||||
# MyISAM index cache
|
||||
@ -422,15 +423,15 @@ rule 'InnoDB buffer pool size' [system_memory > 0]
|
||||
value < 60
|
||||
Your InnoDB buffer pool is fairly small.
|
||||
The InnoDB buffer pool has a profound impact on performance for InnoDB tables. Assign all your remaining memory to this buffer. For database servers that use solely InnoDB as storage engine and have no other services (e.g. a web server) running, you may set this as high as 80% of your available memory. If that is not the case, you need to carefully assess the memory consumption of your other services and non-InnoDB-Tables and set this variable accordingly. If it is set too high, your system will start swapping, which decreases performance significantly. See also <a href="http://www.mysqlperformanceblog.com/2007/11/03/choosing-innodb_buffer_pool_size/">this article</a>
|
||||
You are currently using %s% of your memory for the InnoDB buffer pool. This rule fires if you are assigning less than 60%, however this might be perfectly adequate for your system if you don't have much InnoDB tables or other services running on the same machine.
|
||||
You are currently using %s% of your memory for the InnoDB buffer pool. This rule fires if you are assigning less than 60%, however this might be perfectly adequate for your system if you don't have much InnoDB tables or other services running on the same machine. | value
|
||||
|
||||
#
|
||||
# other
|
||||
rule 'MyISAM concurrent inserts'
|
||||
concurrent_insert
|
||||
value == 0
|
||||
value === 0 || value === 'NEVER'
|
||||
Enable concurrent_insert by setting it to 1
|
||||
Setting {concurrent_insert} to 1 reduces contention between readers and writers for a given table. See also <a href="http://dev.mysql.com/doc/refman/5.0/en/concurrent-inserts.html">MySQL Documentation</a>
|
||||
Setting {concurrent_insert} to 1 reduces contention between readers and writers for a given table. See also <a href="http://dev.mysql.com/doc/refman/5.5/en/concurrent-inserts.html">MySQL Documentation</a>
|
||||
concurrent_insert is set to 0
|
||||
|
||||
# INSERT DELAYED USAGE
|
||||
|
||||
@ -80,6 +80,7 @@ if (function_exists('mcrypt_encrypt')) {
|
||||
* Returns blowfish secret or generates one if needed.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function PMA_get_blowfish_secret()
|
||||
{
|
||||
|
||||
649
libraries/bfShapeFiles/ShapeFile.lib.php
Normal file
649
libraries/bfShapeFiles/ShapeFile.lib.php
Normal file
@ -0,0 +1,649 @@
|
||||
<?php
|
||||
function loadData($type, $data) {
|
||||
if (!$data) return $data;
|
||||
$tmp = unpack($type, $data);
|
||||
return current($tmp);
|
||||
}
|
||||
|
||||
function swap($binValue) {
|
||||
$result = $binValue{strlen($binValue) - 1};
|
||||
for($i = strlen($binValue) - 2; $i >= 0 ; $i--) {
|
||||
$result .= $binValue{$i};
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function packDouble($value, $mode = 'LE') {
|
||||
$value = (double)$value;
|
||||
$bin = pack("d", $value);
|
||||
|
||||
//We test if the conversion of an integer (1) is done as LE or BE by default
|
||||
switch (pack ('L', 1)) {
|
||||
case pack ('V', 1): //Little Endian
|
||||
$result = ($mode == 'LE') ? $bin : swap($bin);
|
||||
break;
|
||||
case pack ('N', 1): //Big Endian
|
||||
$result = ($mode == 'BE') ? $bin : swap($bin);
|
||||
break;
|
||||
default: //Some other thing, we just return false
|
||||
$result = FALSE;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
class ShapeFile {
|
||||
var $FileName;
|
||||
|
||||
var $SHPFile;
|
||||
var $SHXFile;
|
||||
var $DBFFile;
|
||||
|
||||
var $DBFHeader;
|
||||
|
||||
var $lastError = "";
|
||||
|
||||
var $boundingBox = array("xmin" => 0.0, "ymin" => 0.0, "xmax" => 0.0, "ymax" => 0.0);
|
||||
var $fileLength = 0;
|
||||
var $shapeType = 0;
|
||||
|
||||
var $records;
|
||||
|
||||
function ShapeFile($shapeType, $boundingBox = array("xmin" => 0.0, "ymin" => 0.0, "xmax" => 0.0, "ymax" => 0.0), $FileName = NULL) {
|
||||
$this->shapeType = $shapeType;
|
||||
$this->boundingBox = $boundingBox;
|
||||
$this->FileName = $FileName;
|
||||
$this->fileLength = 50;
|
||||
}
|
||||
|
||||
function loadFromFile($FileName) {
|
||||
$this->FileName = $FileName;
|
||||
|
||||
if (($this->_openSHPFile()) && ($this->_openDBFFile())) {
|
||||
$this->_loadHeaders();
|
||||
$this->_loadRecords();
|
||||
$this->_closeSHPFile();
|
||||
$this->_closeDBFFile();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function saveToFile($FileName = NULL) {
|
||||
if ($FileName != NULL) $this->FileName = $FileName;
|
||||
|
||||
if (($this->_openSHPFile(TRUE)) && ($this->_openSHXFile(TRUE)) && ($this->_openDBFFile(TRUE))) {
|
||||
$this->_saveHeaders();
|
||||
$this->_saveRecords();
|
||||
$this->_closeSHPFile();
|
||||
$this->_closeSHXFile();
|
||||
$this->_closeDBFFile();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function addRecord($record) {
|
||||
if ((isset($this->DBFHeader)) && (is_array($this->DBFHeader))) {
|
||||
$record->updateDBFInfo($this->DBFHeader);
|
||||
}
|
||||
|
||||
$this->fileLength += ($record->getContentLength() + 4);
|
||||
$this->records[] = $record;
|
||||
$this->records[count($this->records) - 1]->recordNumber = count($this->records);
|
||||
|
||||
return (count($this->records) - 1);
|
||||
}
|
||||
|
||||
function deleteRecord($index) {
|
||||
if (isset($this->records[$index])) {
|
||||
$this->fileLength -= ($this->records[$index]->getContentLength() + 4);
|
||||
for ($i = $index; $i < (count($this->records) - 1); $i++) {
|
||||
$this->records[$i] = $this->records[$i + 1];
|
||||
}
|
||||
unset($this->records[count($this->records) - 1]);
|
||||
$this->_deleteRecordFromDBF($index);
|
||||
}
|
||||
}
|
||||
|
||||
function getDBFHeader() {
|
||||
return $this->DBFHeader;
|
||||
}
|
||||
|
||||
function setDBFHeader($header) {
|
||||
$this->DBFHeader = $header;
|
||||
|
||||
for ($i = 0; $i < count($this->records); $i++) {
|
||||
$this->records[$i]->updateDBFInfo($header);
|
||||
}
|
||||
}
|
||||
|
||||
function getIndexFromDBFData($field, $value) {
|
||||
$result = -1;
|
||||
for ($i = 0; $i < (count($this->records) - 1); $i++) {
|
||||
if (isset($this->records[$i]->DBFData[$field]) && (strtoupper($this->records[$i]->DBFData[$field]) == strtoupper($value))) {
|
||||
$result = $i;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function _loadDBFHeader() {
|
||||
$DBFFile = fopen(str_replace('.*', '.dbf', $this->FileName), 'r');
|
||||
|
||||
$result = array();
|
||||
$buff32 = array();
|
||||
$i = 1;
|
||||
$inHeader = true;
|
||||
|
||||
while ($inHeader) {
|
||||
if (!feof($DBFFile)) {
|
||||
$buff32 = fread($DBFFile, 32);
|
||||
if ($i > 1) {
|
||||
if (substr($buff32, 0, 1) == chr(13)) {
|
||||
$inHeader = false;
|
||||
} else {
|
||||
$pos = strpos(substr($buff32, 0, 10), chr(0));
|
||||
$pos = ($pos == 0 ? 10 : $pos);
|
||||
|
||||
$fieldName = substr($buff32, 0, $pos);
|
||||
$fieldType = substr($buff32, 11, 1);
|
||||
$fieldLen = ord(substr($buff32, 16, 1));
|
||||
$fieldDec = ord(substr($buff32, 17, 1));
|
||||
|
||||
array_push($result, array($fieldName, $fieldType, $fieldLen, $fieldDec));
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
} else {
|
||||
$inHeader = false;
|
||||
}
|
||||
}
|
||||
|
||||
fclose($DBFFile);
|
||||
return($result);
|
||||
}
|
||||
|
||||
function _deleteRecordFromDBF($index) {
|
||||
if (@dbase_delete_record($this->DBFFile, $index)) {
|
||||
@dbase_pack($this->DBFFile);
|
||||
}
|
||||
}
|
||||
|
||||
function _loadHeaders() {
|
||||
fseek($this->SHPFile, 24, SEEK_SET);
|
||||
$this->fileLength = loadData("N", fread($this->SHPFile, 4));
|
||||
|
||||
fseek($this->SHPFile, 32, SEEK_SET);
|
||||
$this->shapeType = loadData("V", fread($this->SHPFile, 4));
|
||||
|
||||
$this->boundingBox = array();
|
||||
$this->boundingBox["xmin"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->boundingBox["ymin"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->boundingBox["xmax"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->boundingBox["ymax"] = loadData("d", fread($this->SHPFile, 8));
|
||||
|
||||
$this->DBFHeader = $this->_loadDBFHeader();
|
||||
}
|
||||
|
||||
function _saveHeaders() {
|
||||
fwrite($this->SHPFile, pack("NNNNNN", 9994, 0, 0, 0, 0, 0));
|
||||
fwrite($this->SHPFile, pack("N", $this->fileLength));
|
||||
fwrite($this->SHPFile, pack("V", 1000));
|
||||
fwrite($this->SHPFile, pack("V", $this->shapeType));
|
||||
fwrite($this->SHPFile, packDouble($this->boundingBox['xmin']));
|
||||
fwrite($this->SHPFile, packDouble($this->boundingBox['ymin']));
|
||||
fwrite($this->SHPFile, packDouble($this->boundingBox['xmax']));
|
||||
fwrite($this->SHPFile, packDouble($this->boundingBox['ymax']));
|
||||
fwrite($this->SHPFile, pack("dddd", 0, 0, 0, 0));
|
||||
|
||||
fwrite($this->SHXFile, pack("NNNNNN", 9994, 0, 0, 0, 0, 0));
|
||||
fwrite($this->SHXFile, pack("N", 50 + 4*count($this->records)));
|
||||
fwrite($this->SHXFile, pack("V", 1000));
|
||||
fwrite($this->SHXFile, pack("V", $this->shapeType));
|
||||
fwrite($this->SHXFile, packDouble($this->boundingBox['xmin']));
|
||||
fwrite($this->SHXFile, packDouble($this->boundingBox['ymin']));
|
||||
fwrite($this->SHXFile, packDouble($this->boundingBox['xmax']));
|
||||
fwrite($this->SHXFile, packDouble($this->boundingBox['ymax']));
|
||||
fwrite($this->SHXFile, pack("dddd", 0, 0, 0, 0));
|
||||
}
|
||||
|
||||
function _loadRecords() {
|
||||
fseek($this->SHPFile, 100);
|
||||
while (!feof($this->SHPFile)) {
|
||||
$bByte = ftell($this->SHPFile);
|
||||
$record = new ShapeRecord(-1);
|
||||
$record->loadFromFile($this->SHPFile, $this->DBFFile);
|
||||
$eByte = ftell($this->SHPFile);
|
||||
if (($eByte <= $bByte) || ($record->lastError != "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->records[] = $record;
|
||||
}
|
||||
}
|
||||
|
||||
function _saveRecords() {
|
||||
if (file_exists(str_replace('.*', '.dbf', $this->FileName))) {
|
||||
@unlink(str_replace('.*', '.dbf', $this->FileName));
|
||||
}
|
||||
if (!($this->DBFFile = @dbase_create(str_replace('.*', '.dbf', $this->FileName), $this->DBFHeader))) {
|
||||
return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName)));
|
||||
}
|
||||
|
||||
$offset = 50;
|
||||
if (is_array($this->records) && (count($this->records) > 0)) {
|
||||
reset($this->records);
|
||||
while (list($index, $record) = each($this->records)) {
|
||||
//Save the record to the .shp file
|
||||
$record->saveToFile($this->SHPFile, $this->DBFFile, $index + 1);
|
||||
|
||||
//Save the record to the .shx file
|
||||
fwrite($this->SHXFile, pack("N", $offset));
|
||||
fwrite($this->SHXFile, pack("N", $record->getContentLength()));
|
||||
$offset += (4 + $record->getContentLength());
|
||||
}
|
||||
}
|
||||
@dbase_pack($this->DBFFile);
|
||||
}
|
||||
|
||||
function _openSHPFile($toWrite = false) {
|
||||
$this->SHPFile = @fopen(str_replace('.*', '.shp', $this->FileName), ($toWrite ? "wb+" : "rb"));
|
||||
if (!$this->SHPFile) {
|
||||
return $this->setError(sprintf("It wasn't possible to open the Shape file '%s'", str_replace('.*', '.shp', $this->FileName)));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function _closeSHPFile() {
|
||||
if ($this->SHPFile) {
|
||||
fclose($this->SHPFile);
|
||||
$this->SHPFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
function _openSHXFile($toWrite = false) {
|
||||
$this->SHXFile = @fopen(str_replace('.*', '.shx', $this->FileName), ($toWrite ? "wb+" : "rb"));
|
||||
if (!$this->SHXFile) {
|
||||
return $this->setError(sprintf("It wasn't possible to open the Index file '%s'", str_replace('.*', '.shx', $this->FileName)));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function _closeSHXFile() {
|
||||
if ($this->SHXFile) {
|
||||
fclose($this->SHXFile);
|
||||
$this->SHXFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
function _openDBFFile($toWrite = false) {
|
||||
$checkFunction = $toWrite ? "is_writable" : "is_readable";
|
||||
if (($toWrite) && (!file_exists(str_replace('.*', '.dbf', $this->FileName)))) {
|
||||
if (!@dbase_create(str_replace('.*', '.dbf', $this->FileName), $this->DBFHeader)) {
|
||||
return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName)));
|
||||
}
|
||||
}
|
||||
if ($checkFunction(str_replace('.*', '.dbf', $this->FileName))) {
|
||||
$this->DBFFile = dbase_open(str_replace('.*', '.dbf', $this->FileName), ($toWrite ? 2 : 0));
|
||||
if (!$this->DBFFile) {
|
||||
return $this->setError(sprintf("It wasn't possible to open the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName)));
|
||||
}
|
||||
} else {
|
||||
return $this->setError(sprintf("It wasn't possible to find the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName)));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function _closeDBFFile() {
|
||||
if ($this->DBFFile) {
|
||||
dbase_close($this->DBFFile);
|
||||
$this->DBFFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
function setError($error) {
|
||||
$this->lastError = $error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class ShapeRecord {
|
||||
var $SHPFile = NULL;
|
||||
var $DBFFile = NULL;
|
||||
|
||||
var $recordNumber = NULL;
|
||||
var $shapeType = NULL;
|
||||
|
||||
var $lastError = "";
|
||||
|
||||
var $SHPData = array();
|
||||
var $DBFData = array();
|
||||
|
||||
function ShapeRecord($shapeType) {
|
||||
$this->shapeType = $shapeType;
|
||||
}
|
||||
|
||||
function loadFromFile(&$SHPFile, &$DBFFile) {
|
||||
$this->SHPFile = $SHPFile;
|
||||
$this->DBFFile = $DBFFile;
|
||||
$this->_loadHeaders();
|
||||
|
||||
switch ($this->shapeType) {
|
||||
case 0:
|
||||
$this->_loadNullRecord();
|
||||
break;
|
||||
case 1:
|
||||
$this->_loadPointRecord();
|
||||
break;
|
||||
case 3:
|
||||
$this->_loadPolyLineRecord();
|
||||
break;
|
||||
case 5:
|
||||
$this->_loadPolygonRecord();
|
||||
break;
|
||||
case 8:
|
||||
$this->_loadMultiPointRecord();
|
||||
break;
|
||||
default:
|
||||
$this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType));
|
||||
break;
|
||||
}
|
||||
$this->_loadDBFData();
|
||||
}
|
||||
|
||||
function saveToFile(&$SHPFile, &$DBFFile, $recordNumber) {
|
||||
$this->SHPFile = $SHPFile;
|
||||
$this->DBFFile = $DBFFile;
|
||||
$this->recordNumber = $recordNumber;
|
||||
$this->_saveHeaders();
|
||||
|
||||
switch ($this->shapeType) {
|
||||
case 0:
|
||||
$this->_saveNullRecord();
|
||||
break;
|
||||
case 1:
|
||||
$this->_savePointRecord();
|
||||
break;
|
||||
case 3:
|
||||
$this->_savePolyLineRecord();
|
||||
break;
|
||||
case 5:
|
||||
$this->_savePolygonRecord();
|
||||
break;
|
||||
case 8:
|
||||
$this->_saveMultiPointRecord();
|
||||
break;
|
||||
default:
|
||||
$this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType));
|
||||
break;
|
||||
}
|
||||
$this->_saveDBFData();
|
||||
}
|
||||
|
||||
function updateDBFInfo($header) {
|
||||
$tmp = $this->DBFData;
|
||||
unset($this->DBFData);
|
||||
$this->DBFData = array();
|
||||
reset($header);
|
||||
while (list($key, $value) = each($header)) {
|
||||
$this->DBFData[$value[0]] = (isset($tmp[$value[0]])) ? $tmp[$value[0]] : "";
|
||||
}
|
||||
}
|
||||
|
||||
function _loadHeaders() {
|
||||
$this->recordNumber = loadData("N", fread($this->SHPFile, 4));
|
||||
$tmp = loadData("N", fread($this->SHPFile, 4)); //We read the length of the record
|
||||
$this->shapeType = loadData("V", fread($this->SHPFile, 4));
|
||||
}
|
||||
|
||||
function _saveHeaders() {
|
||||
fwrite($this->SHPFile, pack("N", $this->recordNumber));
|
||||
fwrite($this->SHPFile, pack("N", $this->getContentLength()));
|
||||
fwrite($this->SHPFile, pack("V", $this->shapeType));
|
||||
}
|
||||
|
||||
function _loadPoint() {
|
||||
$data = array();
|
||||
|
||||
$data["x"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$data["y"] = loadData("d", fread($this->SHPFile, 8));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function _savePoint($data) {
|
||||
fwrite($this->SHPFile, packDouble($data["x"]));
|
||||
fwrite($this->SHPFile, packDouble($data["y"]));
|
||||
}
|
||||
|
||||
function _loadNullRecord() {
|
||||
$this->SHPData = array();
|
||||
}
|
||||
|
||||
function _saveNullRecord() {
|
||||
//Don't save anything
|
||||
}
|
||||
|
||||
function _loadPointRecord() {
|
||||
$this->SHPData = $this->_loadPoint();
|
||||
}
|
||||
|
||||
function _savePointRecord() {
|
||||
$this->_savePoint($this->SHPData);
|
||||
}
|
||||
|
||||
function _loadMultiPointRecord() {
|
||||
$this->SHPData = array();
|
||||
$this->SHPData["xmin"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->SHPData["ymin"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->SHPData["xmax"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->SHPData["ymax"] = loadData("d", fread($this->SHPFile, 8));
|
||||
|
||||
$this->SHPData["numpoints"] = loadData("V", fread($this->SHPFile, 4));
|
||||
|
||||
for ($i = 0; $i <= $this->SHPData["numpoints"]; $i++) {
|
||||
$this->SHPData["points"][] = $this->_loadPoint();
|
||||
}
|
||||
}
|
||||
|
||||
function _saveMultiPointRecord() {
|
||||
fwrite($this->SHPFile, pack("dddd", $this->SHPData["xmin"], $this->SHPData["ymin"], $this->SHPData["xmax"], $this->SHPData["ymax"]));
|
||||
|
||||
fwrite($this->SHPFile, pack("V", $this->SHPData["numpoints"]));
|
||||
|
||||
for ($i = 0; $i <= $this->SHPData["numpoints"]; $i++) {
|
||||
$this->_savePoint($this->SHPData["points"][$i]);
|
||||
}
|
||||
}
|
||||
|
||||
function _loadPolyLineRecord() {
|
||||
$this->SHPData = array();
|
||||
$this->SHPData["xmin"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->SHPData["ymin"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->SHPData["xmax"] = loadData("d", fread($this->SHPFile, 8));
|
||||
$this->SHPData["ymax"] = loadData("d", fread($this->SHPFile, 8));
|
||||
|
||||
$this->SHPData["numparts"] = loadData("V", fread($this->SHPFile, 4));
|
||||
$this->SHPData["numpoints"] = loadData("V", fread($this->SHPFile, 4));
|
||||
|
||||
for ($i = 0; $i < $this->SHPData["numparts"]; $i++) {
|
||||
$this->SHPData["parts"][$i] = loadData("V", fread($this->SHPFile, 4));
|
||||
}
|
||||
|
||||
$firstIndex = ftell($this->SHPFile);
|
||||
$readPoints = 0;
|
||||
reset($this->SHPData["parts"]);
|
||||
while (list($partIndex, $partData) = each($this->SHPData["parts"])) {
|
||||
if (!isset($this->SHPData["parts"][$partIndex]["points"]) || !is_array($this->SHPData["parts"][$partIndex]["points"])) {
|
||||
$this->SHPData["parts"][$partIndex] = array();
|
||||
$this->SHPData["parts"][$partIndex]["points"] = array();
|
||||
}
|
||||
while (!in_array($readPoints, $this->SHPData["parts"]) && ($readPoints < ($this->SHPData["numpoints"])) && !feof($this->SHPFile)) {
|
||||
$this->SHPData["parts"][$partIndex]["points"][] = $this->_loadPoint();
|
||||
$readPoints++;
|
||||
}
|
||||
}
|
||||
|
||||
fseek($this->SHPFile, $firstIndex + ($readPoints*16));
|
||||
}
|
||||
|
||||
function _savePolyLineRecord() {
|
||||
fwrite($this->SHPFile, pack("dddd", $this->SHPData["xmin"], $this->SHPData["ymin"], $this->SHPData["xmax"], $this->SHPData["ymax"]));
|
||||
|
||||
fwrite($this->SHPFile, pack("VV", $this->SHPData["numparts"], $this->SHPData["numpoints"]));
|
||||
|
||||
for ($i = 0; $i < $this->SHPData["numparts"]; $i++) {
|
||||
fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i])));
|
||||
}
|
||||
|
||||
reset($this->SHPData["parts"]);
|
||||
foreach ($this->SHPData["parts"] as $partData){
|
||||
reset($partData["points"]);
|
||||
while (list($pointIndex, $pointData) = each($partData["points"])) {
|
||||
$this->_savePoint($pointData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _loadPolygonRecord() {
|
||||
$this->_loadPolyLineRecord();
|
||||
}
|
||||
|
||||
function _savePolygonRecord() {
|
||||
$this->_savePolyLineRecord();
|
||||
}
|
||||
|
||||
function addPoint($point, $partIndex = 0) {
|
||||
switch ($this->shapeType) {
|
||||
case 0:
|
||||
//Don't add anything
|
||||
break;
|
||||
case 1:
|
||||
//Substitutes the value of the current point
|
||||
$this->SHPData = $point;
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
//Adds a new point to the selected part
|
||||
if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"];
|
||||
if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"];
|
||||
if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"];
|
||||
if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"];
|
||||
|
||||
$this->SHPData["parts"][$partIndex]["points"][] = $point;
|
||||
|
||||
$this->SHPData["numparts"] = count($this->SHPData["parts"]);
|
||||
$this->SHPData["numpoints"]++;
|
||||
break;
|
||||
case 8:
|
||||
//Adds a new point
|
||||
if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"];
|
||||
if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"];
|
||||
if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"];
|
||||
if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"];
|
||||
|
||||
$this->SHPData["points"][] = $point;
|
||||
$this->SHPData["numpoints"]++;
|
||||
break;
|
||||
default:
|
||||
$this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function deletePoint($pointIndex = 0, $partIndex = 0) {
|
||||
switch ($this->shapeType) {
|
||||
case 0:
|
||||
//Don't delete anything
|
||||
break;
|
||||
case 1:
|
||||
//Sets the value of the point to zero
|
||||
$this->SHPData["x"] = 0.0;
|
||||
$this->SHPData["y"] = 0.0;
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
//Deletes the point from the selected part, if exists
|
||||
if (isset($this->SHPData["parts"][$partIndex]) && isset($this->SHPData["parts"][$partIndex]["points"][$pointIndex])) {
|
||||
for ($i = $pointIndex; $i < (count($this->SHPData["parts"][$partIndex]["points"]) - 1); $i++) {
|
||||
$this->SHPData["parts"][$partIndex]["points"][$i] = $this->SHPData["parts"][$partIndex]["points"][$i + 1];
|
||||
}
|
||||
unset($this->SHPData["parts"][$partIndex]["points"][count($this->SHPData["parts"][$partIndex]["points"]) - 1]);
|
||||
|
||||
$this->SHPData["numparts"] = count($this->SHPData["parts"]);
|
||||
$this->SHPData["numpoints"]--;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
//Deletes the point, if exists
|
||||
if (isset($this->SHPData["points"][$pointIndex])) {
|
||||
for ($i = $pointIndex; $i < (count($this->SHPData["points"]) - 1); $i++) {
|
||||
$this->SHPData["points"][$i] = $this->SHPData["points"][$i + 1];
|
||||
}
|
||||
unset($this->SHPData["points"][count($this->SHPData["points"]) - 1]);
|
||||
|
||||
$this->SHPData["numpoints"]--;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function getContentLength() {
|
||||
switch ($this->shapeType) {
|
||||
case 0:
|
||||
$result = 0;
|
||||
break;
|
||||
case 1:
|
||||
$result = 10;
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
$result = 22 + 2*count($this->SHPData["parts"]);
|
||||
for ($i = 0; $i < count($this->SHPData["parts"]); $i++) {
|
||||
$result += 8*count($this->SHPData["parts"][$i]["points"]);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
$result = 20 + 8*count($this->SHPData["points"]);
|
||||
break;
|
||||
default:
|
||||
$result = false;
|
||||
$this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType));
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function _loadDBFData() {
|
||||
$this->DBFData = @dbase_get_record_with_names($this->DBFFile, $this->recordNumber);
|
||||
unset($this->DBFData["deleted"]);
|
||||
}
|
||||
|
||||
function _saveDBFData() {
|
||||
unset($this->DBFData["deleted"]);
|
||||
if ($this->recordNumber <= dbase_numrecords($this->DBFFile)) {
|
||||
if (!dbase_replace_record($this->DBFFile, array_values($this->DBFData), $this->recordNumber)) {
|
||||
$this->setError("I wasn't possible to update the information in the DBF file.");
|
||||
}
|
||||
} else {
|
||||
if (!dbase_add_record($this->DBFFile, array_values($this->DBFData))) {
|
||||
$this->setError("I wasn't possible to add the information to the DBF file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setError($error) {
|
||||
$this->lastError = $error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -4,6 +4,11 @@
|
||||
* @package BLOBStreaming
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes PBMS database
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function initPBMSDatabase()
|
||||
{
|
||||
$query = "create database IF NOT EXISTS pbms;"; // If no other choice then try this.
|
||||
@ -379,6 +384,11 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
|
||||
* BLOB streaming on a per table or database basis. So in anticipation of this
|
||||
* PMA_BS_IsTablePBMSEnabled() passes in the table and database name even though
|
||||
* they are not currently needed.
|
||||
*
|
||||
* @param string $db_name
|
||||
* @param string $tbl_name
|
||||
* @param string $tbl_type
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_BS_IsTablePBMSEnabled($db_name, $tbl_name, $tbl_type)
|
||||
{
|
||||
|
||||
@ -321,6 +321,7 @@ class Horde_Cipher_blowfish
|
||||
* Set the key to be used for en/decryption.
|
||||
*
|
||||
* @param string $key The key to use.
|
||||
* @return bool
|
||||
*/
|
||||
public function setKey($key)
|
||||
{
|
||||
|
||||
@ -94,7 +94,7 @@ function PMA_getIcon($icon, $alternate = '', $force_text = false, $noSprite = fa
|
||||
$button .= '<span class="nowrap">';
|
||||
|
||||
if ($include_icon) {
|
||||
if($noSprite) {
|
||||
if ($noSprite) {
|
||||
$button .= '<img src="' . $GLOBALS['pmaThemeImage'] . $icon . '"'
|
||||
. ' class="icon" width="16" height="16" />';
|
||||
} else {
|
||||
@ -713,8 +713,8 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
|
||||
// in $group we save the reference to the place in $table_groups
|
||||
// where to store the table info
|
||||
if ($GLOBALS['cfg']['LeftFrameDBTree']
|
||||
&& $sep && strstr($table_name, $sep))
|
||||
{
|
||||
&& $sep && strstr($table_name, $sep)
|
||||
) {
|
||||
$parts = explode($sep, $table_name);
|
||||
|
||||
$group =& $table_groups;
|
||||
@ -754,7 +754,8 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
|
||||
|
||||
|
||||
if ($GLOBALS['cfg']['ShowTooltipAliasTB']
|
||||
&& $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested') {
|
||||
&& $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested'
|
||||
) {
|
||||
// switch tooltip and name
|
||||
$table['Comment'] = $table['Name'];
|
||||
$table['disp_name'] = $table['Comment'];
|
||||
@ -935,7 +936,8 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
|
||||
// @todo what about $GLOBALS['display_query']???
|
||||
// @todo this is REALLY the wrong place to do this - very unexpected here
|
||||
if (strlen($GLOBALS['table'])
|
||||
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
|
||||
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])
|
||||
) {
|
||||
if (PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Index_length') > 1024) {
|
||||
PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
|
||||
}
|
||||
@ -1029,7 +1031,8 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
|
||||
*/
|
||||
|
||||
if (isset($analyzed_display_query[0]['queryflags']['select_from'])
|
||||
&& isset($GLOBALS['sql_limit_to_append'])) {
|
||||
&& isset($GLOBALS['sql_limit_to_append'])
|
||||
) {
|
||||
$query_base = $analyzed_display_query[0]['section_before_limit']
|
||||
. "\n" . $GLOBALS['sql_limit_to_append']
|
||||
. $analyzed_display_query[0]['section_after_limit'];
|
||||
@ -1142,7 +1145,8 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
|
||||
|
||||
// Refresh query
|
||||
if (! empty($cfg['SQLQuery']['Refresh'])
|
||||
&& preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) {
|
||||
&& 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')) . ']';
|
||||
} else {
|
||||
@ -1150,7 +1154,8 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
|
||||
} //show as php
|
||||
|
||||
if (! empty($cfg['SQLValidator']['use'])
|
||||
&& ! empty($cfg['SQLQuery']['Validate'])) {
|
||||
&& ! empty($cfg['SQLQuery']['Validate'])
|
||||
) {
|
||||
$validate_params = $url_params;
|
||||
if (!empty($GLOBALS['validatequery'])) {
|
||||
$validate_message = __('Skip Validate SQL') ;
|
||||
@ -1251,8 +1256,9 @@ function PMA_profilingSupported()
|
||||
// (avoid a trip to the server for MySQL before 5.0.37)
|
||||
// and do not set a constant as we might be switching servers
|
||||
if (defined('PMA_MYSQL_INT_VERSION')
|
||||
&& PMA_MYSQL_INT_VERSION >= 50037
|
||||
&& PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")) {
|
||||
&& PMA_MYSQL_INT_VERSION >= 50037
|
||||
&& PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")
|
||||
) {
|
||||
PMA_cacheSet('profiling_supported', true, true);
|
||||
} else {
|
||||
PMA_cacheSet('profiling_supported', false, true);
|
||||
@ -1734,7 +1740,10 @@ function PMA_linkOrButton($url, $message, $tag_params = array(),
|
||||
|
||||
$displayed_message = '';
|
||||
// Add text if not already added
|
||||
if (stristr($message, '<img') && (!$strip_img || $GLOBALS['cfg']['PropertiesIconic'] === true) && strip_tags($message)==$message) {
|
||||
if (stristr($message, '<img')
|
||||
&& (!$strip_img || $GLOBALS['cfg']['PropertiesIconic'] === true)
|
||||
&& strip_tags($message)==$message
|
||||
) {
|
||||
$displayed_message = '<span>' . htmlspecialchars(preg_replace('/^.*\salt="([^"]*)".*$/si', '\1', $message)) . '</span>';
|
||||
}
|
||||
|
||||
@ -1996,7 +2005,8 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force
|
||||
$meta->orgname = $meta->name;
|
||||
|
||||
if (isset($GLOBALS['analyzed_sql'][0]['select_expr'])
|
||||
&& is_array($GLOBALS['analyzed_sql'][0]['select_expr'])) {
|
||||
&& is_array($GLOBALS['analyzed_sql'][0]['select_expr'])
|
||||
) {
|
||||
foreach ($GLOBALS['analyzed_sql'][0]['select_expr'] as $select_expr) {
|
||||
// need (string) === (string)
|
||||
// '' !== 0 but '' == 0
|
||||
@ -2019,7 +2029,10 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force
|
||||
// a view because this view might be updatable.
|
||||
// (The isView() verification should not be costly in most cases
|
||||
// because there is some caching in the function).
|
||||
if (isset($meta->orgtable) && $meta->table != $meta->orgtable && ! PMA_Table::isView($GLOBALS['db'], $meta->table)) {
|
||||
if (isset($meta->orgtable)
|
||||
&& $meta->table != $meta->orgtable
|
||||
&& ! PMA_Table::isView($GLOBALS['db'], $meta->table)
|
||||
) {
|
||||
$meta->table = $meta->orgtable;
|
||||
}
|
||||
|
||||
@ -2042,7 +2055,10 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force
|
||||
} else {
|
||||
// timestamp is numeric on some MySQL 4.1
|
||||
// for real we use CONCAT above and it should compare to string
|
||||
if ($meta->numeric && $meta->type != 'timestamp' && $meta->type != 'real') {
|
||||
if ($meta->numeric
|
||||
&& $meta->type != 'timestamp'
|
||||
&& $meta->type != 'real'
|
||||
) {
|
||||
$con_val = '= ' . $row[$i];
|
||||
} elseif (($meta->type == 'blob' || $meta->type == 'string')
|
||||
// hexify only if this is a true not empty BLOB or a BINARY
|
||||
@ -2057,6 +2073,13 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force
|
||||
// this blob won't be part of the final condition
|
||||
$con_val = null;
|
||||
}
|
||||
} elseif (in_array($meta->type, PMA_getGISDatatypes()) && ! empty($row[$i])) {
|
||||
// do not build a too big condition
|
||||
if (strlen($row[$i]) < 5000) {
|
||||
$condition .= '=0x' . bin2hex($row[$i]) . ' AND';
|
||||
} else {
|
||||
$condition = '';
|
||||
}
|
||||
} elseif ($meta->type == 'bit') {
|
||||
$con_val = "= b'" . PMA_printable_bit_value($row[$i], $meta->length) . "'";
|
||||
} else {
|
||||
@ -2131,10 +2154,13 @@ function PMA_buttonOrImage($button_name, $button_class, $image_name, $text,
|
||||
. PMA_getIcon($image, $text)
|
||||
.'</button>' . "\n";
|
||||
} else {
|
||||
echo '<input type="image" name="' . $image_name . '" value="'
|
||||
. htmlspecialchars($value) . '" title="' . htmlspecialchars($text) . '" src="' . $GLOBALS['pmaThemeImage']
|
||||
. $image . '" />'
|
||||
. ($GLOBALS['cfg']['PropertiesIconic'] === 'both' ? ' ' . htmlspecialchars($text) : '') . "\n";
|
||||
echo '<input type="image" name="' . $image_name
|
||||
. '" value="' . htmlspecialchars($value)
|
||||
. '" title="' . htmlspecialchars($text)
|
||||
. '" src="' . $GLOBALS['pmaThemeImage']. $image . '" />'
|
||||
. ($GLOBALS['cfg']['PropertiesIconic'] === 'both'
|
||||
? ' ' . htmlspecialchars($text)
|
||||
: '') . "\n";
|
||||
}
|
||||
} // end function
|
||||
|
||||
@ -2228,7 +2254,8 @@ function PMA_pageselector($rows, $pageNow = 1, $nbTotalPage = 1,
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$gotopage .= ' <option ' . $selected . ' value="' . (($i - 1) * $rows) . '">' . $i . '</option>' . "\n";
|
||||
$gotopage .= ' <option ' . $selected
|
||||
. ' value="' . (($i - 1) * $rows) . '">' . $i . '</option>' . "\n";
|
||||
}
|
||||
|
||||
$gotopage .= ' </select><noscript><input type="submit" value="' . __('Go') . '" /></noscript>';
|
||||
@ -2363,8 +2390,8 @@ function PMA_getDbLink($database = null)
|
||||
}
|
||||
|
||||
return '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($database) . '"'
|
||||
.' title="' . sprintf(__('Jump to database "%s".'), htmlspecialchars($database)) . '">'
|
||||
.htmlspecialchars($database) . '</a>';
|
||||
. ' title="' . sprintf(__('Jump to database "%s".'), htmlspecialchars($database)) . '">'
|
||||
. htmlspecialchars($database) . '</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2834,6 +2861,31 @@ function PMA_replace_binary_contents($content)
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts GIS data to Well Known Text format
|
||||
*
|
||||
* @param $data GIS data
|
||||
* @param $includeSRID Add SRID to the WKT
|
||||
* @return GIS data in Well Know Text format
|
||||
*/
|
||||
function PMA_asWKT($data, $includeSRID = false) {
|
||||
// Convert to WKT format
|
||||
$hex = bin2hex($data);
|
||||
$wktsql = "SELECT ASTEXT(x'" . $hex . "')";
|
||||
if ($includeSRID) {
|
||||
$wktsql .= ", SRID(x'" . $hex . "')";
|
||||
}
|
||||
$wktresult = PMA_DBI_try_query($wktsql, null, PMA_DBI_QUERY_STORE);
|
||||
$wktarr = PMA_DBI_fetch_row($wktresult, 0);
|
||||
$wktval = $wktarr[0];
|
||||
if ($includeSRID) {
|
||||
$srid = $wktarr[1];
|
||||
$wktval = "'" . $wktval . "'," . $srid;
|
||||
}
|
||||
@PMA_DBI_free_result($wktresult);
|
||||
return $wktval;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the string starts with a \r\n pair (0x0d0a) add an extra \n
|
||||
*
|
||||
@ -2953,10 +3005,9 @@ function PMA_expandUserString($string, $escape = null, $updates = array())
|
||||
* function that generates a json output for an ajax request and ends script
|
||||
* execution
|
||||
*
|
||||
* @param bool $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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
function PMA_ajaxResponse($message, $success = true, $extra_data = array())
|
||||
{
|
||||
@ -3147,22 +3198,157 @@ function PMA_getSupportedDatatypes($html = false, $selected = '')
|
||||
* @return array list of datatypes
|
||||
*/
|
||||
|
||||
function PMA_unsupportedDatatypes()
|
||||
{
|
||||
// These GIS data types are not yet supported.
|
||||
$no_support_types = array('geometry',
|
||||
'point',
|
||||
'linestring',
|
||||
'polygon',
|
||||
'multipoint',
|
||||
'multilinestring',
|
||||
'multipolygon',
|
||||
'geometrycollection'
|
||||
);
|
||||
|
||||
function PMA_unsupportedDatatypes() {
|
||||
$no_support_types = array();
|
||||
return $no_support_types;
|
||||
}
|
||||
|
||||
function PMA_getGISDatatypes($upper_case = false) {
|
||||
$gis_data_types = array('geometry',
|
||||
'point',
|
||||
'linestring',
|
||||
'polygon',
|
||||
'multipoint',
|
||||
'multilinestring',
|
||||
'multipolygon',
|
||||
'geometrycollection'
|
||||
);
|
||||
if ($upper_case) {
|
||||
for ($i = 0; $i < count($gis_data_types); $i++) {
|
||||
$gis_data_types[$i] = strtoupper($gis_data_types[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
return $gis_data_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates GIS data based on the string passed.
|
||||
*
|
||||
* @param string $gis_string GIS string
|
||||
*/
|
||||
function PMA_createGISData($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)) {
|
||||
return 'GeomFromText(' . $gis_string . ')';
|
||||
} elseif (preg_match("/^" . $geom_types . "\(.*\)$/i", $gis_string)) {
|
||||
return "GeomFromText('" . $gis_string . "')";
|
||||
} else {
|
||||
return $gis_string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names and details of the functions
|
||||
* that can be applied on geometry data typess.
|
||||
*
|
||||
* @param string $geom_type if provided the output is limited to the functions
|
||||
* that are applicable to the provided geometry type.
|
||||
* @param bool $binary if set to false functions that take two geometries
|
||||
* as arguments will not be included.
|
||||
* @param bool $display if set to true seperators will be added to the
|
||||
* output array.
|
||||
*
|
||||
* @return array names and details of the functions that can be applied on
|
||||
* geometry data typess.
|
||||
*/
|
||||
function PMA_getGISFunctions($geom_type = null, $binary = true, $display = false) {
|
||||
|
||||
$funcs = array();
|
||||
if ($display) {
|
||||
$funcs[] = array('display' => ' ');
|
||||
}
|
||||
|
||||
// Unary functions common to all geomety types
|
||||
$funcs['Dimension'] = array('params' => 1, 'type' => 'int');
|
||||
$funcs['Envelope'] = array('params' => 1, 'type' => 'Polygon');
|
||||
$funcs['GeometryType'] = array('params' => 1, 'type' => 'text');
|
||||
$funcs['SRID'] = array('params' => 1, 'type' => 'int');
|
||||
$funcs['IsEmpty'] = array('params' => 1, 'type' => 'int');
|
||||
$funcs['IsSimple'] = array('params' => 1, 'type' => 'int');
|
||||
|
||||
$geom_type = trim(strtolower($geom_type));
|
||||
if ($display && $geom_type != 'geometry' && $geom_type != 'multipoint') {
|
||||
$funcs[] = array('display' => '--------');
|
||||
}
|
||||
|
||||
// Unary functions that are specific to each geomety type
|
||||
if ($geom_type == 'point') {
|
||||
$funcs['X'] = array('params' => 1, 'type' => 'float');
|
||||
$funcs['Y'] = array('params' => 1, 'type' => 'float');
|
||||
|
||||
} elseif ($geom_type == 'multipoint') {
|
||||
// no fucntions here
|
||||
} elseif ($geom_type == 'linestring') {
|
||||
$funcs['EndPoint'] = array('params' => 1, 'type' => 'point');
|
||||
$funcs['GLength'] = array('params' => 1, 'type' => 'float');
|
||||
$funcs['NumPoints'] = array('params' => 1, 'type' => 'int');
|
||||
$funcs['StartPoint'] = array('params' => 1, 'type' => 'point');
|
||||
$funcs['IsRing'] = array('params' => 1, 'type' => 'int');
|
||||
|
||||
} elseif ($geom_type == 'multilinestring') {
|
||||
$funcs['GLength'] = array('params' => 1, 'type' => 'float');
|
||||
$funcs['IsClosed'] = array('params' => 1, 'type' => 'int');
|
||||
|
||||
} elseif ($geom_type == 'polygon') {
|
||||
$funcs['Area'] = array('params' => 1, 'type' => 'float');
|
||||
$funcs['ExteriorRing'] = array('params' => 1, 'type' => 'linestring');
|
||||
$funcs['NumInteriorRings'] = array('params' => 1, 'type' => 'int');
|
||||
|
||||
} elseif ($geom_type == 'multipolygon') {
|
||||
$funcs['Area'] = array('params' => 1, 'type' => 'float');
|
||||
$funcs['Centroid'] = array('params' => 1, 'type' => 'point');
|
||||
// Not yet implemented in MySQL
|
||||
//$funcs['PointOnSurface'] = array('params' => 1, 'type' => 'point');
|
||||
|
||||
} elseif ($geom_type == 'geometrycollection') {
|
||||
$funcs['NumGeometries'] = array('params' => 1, 'type' => 'int');
|
||||
}
|
||||
|
||||
// If we are asked for binary functions as well
|
||||
if ($binary) {
|
||||
// section seperator
|
||||
if ($display) {
|
||||
$funcs[] = array('display' => '--------');
|
||||
}
|
||||
if (PMA_MYSQL_INT_VERSION < 50601) {
|
||||
$funcs['Crosses'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['Contains'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['Disjoint'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['Equals'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['Intersects'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['Overlaps'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['Touches'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['Within'] = array('params' => 2, 'type' => 'int');
|
||||
} else {
|
||||
// If MySQl version is greaeter than or equal 5.6.1, use the ST_ prefix.
|
||||
$funcs['ST_Crosses'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['ST_Contains'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['ST_Disjoint'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['ST_Equals'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['ST_Intersects'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['ST_Overlaps'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['ST_Touches'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['ST_Within'] = array('params' => 2, 'type' => 'int');
|
||||
|
||||
}
|
||||
|
||||
if ($display) {
|
||||
$funcs[] = array('display' => '--------');
|
||||
}
|
||||
// Minimum bounding rectangle functions
|
||||
$funcs['MBRContains'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['MBRDisjoint'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['MBREquals'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['MBRIntersects'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['MBROverlaps'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['MBRTouches'] = array('params' => 2, 'type' => 'int');
|
||||
$funcs['MBRWithin'] = array('params' => 2, 'type' => 'int');
|
||||
}
|
||||
return $funcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dropdown box with MySQL functions for a particular column.
|
||||
*
|
||||
@ -3186,7 +3372,8 @@ function PMA_getFunctionsForField($field, $insert_mode)
|
||||
// or something similar. Then directly look up the entry in the RestrictFunctions array,
|
||||
// which will then reveal the available dropdown options
|
||||
if (isset($cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])])
|
||||
&& isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]])) {
|
||||
&& isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]])
|
||||
) {
|
||||
$current_func_type = $cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])];
|
||||
$dropdown = $cfg['RestrictFunctions'][$current_func_type];
|
||||
$default_function = $cfg['DefaultFunctions'][$current_func_type];
|
||||
@ -3203,9 +3390,10 @@ function PMA_getFunctionsForField($field, $insert_mode)
|
||||
// and the column does not have the
|
||||
// ON UPDATE DEFAULT TIMESTAMP attribute.
|
||||
if ($field['True_Type'] == 'timestamp'
|
||||
&& empty($field['Default'])
|
||||
&& empty($data)
|
||||
&& ! isset($analyzed_sql[0]['create_table_fields'][$field['Field']]['on_update_current_timestamp'])) {
|
||||
&& empty($field['Default'])
|
||||
&& empty($data)
|
||||
&& ! isset($analyzed_sql[0]['create_table_fields'][$field['Field']]['on_update_current_timestamp'])
|
||||
) {
|
||||
$default_function = $cfg['DefaultFunctions']['first_timestamp'];
|
||||
}
|
||||
// For primary keys of type char(36) or varchar(36) UUID if the default function
|
||||
|
||||
@ -2753,325 +2753,49 @@ $cfg['DBG']['sql'] = false;
|
||||
* Column types;
|
||||
* VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity
|
||||
*
|
||||
* This variable is filled in data_*.inc.php
|
||||
*
|
||||
* @global array $cfg['ColumnTypes']
|
||||
*/
|
||||
$cfg['ColumnTypes'] = array(
|
||||
// most used
|
||||
'INT',
|
||||
'VARCHAR',
|
||||
'TEXT',
|
||||
'DATE',
|
||||
|
||||
// numeric
|
||||
'NUMERIC' => array(
|
||||
'TINYINT',
|
||||
'SMALLINT',
|
||||
'MEDIUMINT',
|
||||
'INT',
|
||||
'BIGINT',
|
||||
'-',
|
||||
'DECIMAL',
|
||||
'FLOAT',
|
||||
'DOUBLE',
|
||||
'REAL',
|
||||
'-',
|
||||
'BIT',
|
||||
'BOOLEAN',
|
||||
'SERIAL',
|
||||
),
|
||||
|
||||
|
||||
// Date/Time
|
||||
'DATE and TIME' => array(
|
||||
'DATE',
|
||||
'DATETIME',
|
||||
'TIMESTAMP',
|
||||
'TIME',
|
||||
'YEAR',
|
||||
),
|
||||
|
||||
// Text
|
||||
'STRING' => array(
|
||||
'CHAR',
|
||||
'VARCHAR',
|
||||
'-',
|
||||
'TINYTEXT',
|
||||
'TEXT',
|
||||
'MEDIUMTEXT',
|
||||
'LONGTEXT',
|
||||
'-',
|
||||
'BINARY',
|
||||
'VARBINARY',
|
||||
'-',
|
||||
'TINYBLOB',
|
||||
'MEDIUMBLOB',
|
||||
'BLOB',
|
||||
'LONGBLOB',
|
||||
'-',
|
||||
'ENUM',
|
||||
'SET',
|
||||
),
|
||||
|
||||
'SPATIAL' => array(
|
||||
'GEOMETRY',
|
||||
'POINT',
|
||||
'LINESTRING',
|
||||
'POLYGON',
|
||||
'MULTIPOINT',
|
||||
'MULTILINESTRING',
|
||||
'MULTIPOLYGON',
|
||||
'GEOMETRYCOLLECTION',
|
||||
),
|
||||
);
|
||||
$cfg['ColumnTypes'] = array();
|
||||
|
||||
/**
|
||||
* Attributes
|
||||
*
|
||||
* This variable is filled in data_*.inc.php
|
||||
*
|
||||
* @global array $cfg['AttributeTypes']
|
||||
*/
|
||||
$cfg['AttributeTypes'] = array(
|
||||
'',
|
||||
'BINARY',
|
||||
'UNSIGNED',
|
||||
'UNSIGNED ZEROFILL',
|
||||
'on update CURRENT_TIMESTAMP',
|
||||
);
|
||||
$cfg['AttributeTypes'] = array();
|
||||
|
||||
|
||||
if ($cfg['ShowFunctionFields']) {
|
||||
/**
|
||||
* Available functions
|
||||
*
|
||||
* This variable is filled in data_*.inc.php
|
||||
*
|
||||
* @global array $cfg['Functions']
|
||||
*/
|
||||
$cfg['Functions'] = array(
|
||||
'ABS',
|
||||
'ACOS',
|
||||
'ASCII',
|
||||
'ASIN',
|
||||
'ATAN',
|
||||
'BIN',
|
||||
'BIT_COUNT',
|
||||
'BIT_LENGTH',
|
||||
'CEILING',
|
||||
'CHAR',
|
||||
'CHAR_LENGTH',
|
||||
'COMPRESS',
|
||||
'COS',
|
||||
'COT',
|
||||
'CRC32',
|
||||
'CURDATE',
|
||||
'CURRENT_USER',
|
||||
'CURTIME',
|
||||
'DATE',
|
||||
'DAYNAME',
|
||||
'DEGREES',
|
||||
'DES_DECRYPT',
|
||||
'DES_ENCRYPT',
|
||||
'ENCRYPT',
|
||||
'EXP',
|
||||
'FLOOR',
|
||||
'FROM_DAYS',
|
||||
'FROM_UNIXTIME',
|
||||
'HEX',
|
||||
'INET_ATON',
|
||||
'INET_NTOA',
|
||||
'LENGTH',
|
||||
'LN',
|
||||
'LOG',
|
||||
'LOG10',
|
||||
'LOG2',
|
||||
'LOWER',
|
||||
'MD5',
|
||||
'NOW',
|
||||
'OCT',
|
||||
'OLD_PASSWORD',
|
||||
'ORD',
|
||||
'PASSWORD',
|
||||
'RADIANS',
|
||||
'RAND',
|
||||
'REVERSE',
|
||||
'ROUND',
|
||||
'SEC_TO_TIME',
|
||||
'SHA1',
|
||||
'SOUNDEX',
|
||||
'SPACE',
|
||||
'SQRT',
|
||||
'STDDEV_POP',
|
||||
'STDDEV_SAMP',
|
||||
'TAN',
|
||||
'TIMESTAMP',
|
||||
'TIME_TO_SEC',
|
||||
'UNCOMPRESS',
|
||||
'UNHEX',
|
||||
'UNIX_TIMESTAMP',
|
||||
'UPPER',
|
||||
'USER',
|
||||
'UTC_DATE',
|
||||
'UTC_TIME',
|
||||
'UTC_TIMESTAMP',
|
||||
'UUID',
|
||||
'VAR_POP',
|
||||
'VAR_SAMP',
|
||||
'YEAR',
|
||||
);
|
||||
$cfg['Functions'] = array();
|
||||
|
||||
/**
|
||||
* Which column types will be mapped to which Group?
|
||||
*
|
||||
* This variable is filled in data_*.inc.php
|
||||
*
|
||||
* @global array $cfg['RestrictColumnTypes']
|
||||
*/
|
||||
$cfg['RestrictColumnTypes'] = array(
|
||||
'TINYINT' => 'FUNC_NUMBER',
|
||||
'SMALLINT' => 'FUNC_NUMBER',
|
||||
'MEDIUMINT' => 'FUNC_NUMBER',
|
||||
'INT' => 'FUNC_NUMBER',
|
||||
'BIGINT' => 'FUNC_NUMBER',
|
||||
'DECIMAL' => 'FUNC_NUMBER',
|
||||
'FLOAT' => 'FUNC_NUMBER',
|
||||
'DOUBLE' => 'FUNC_NUMBER',
|
||||
'REAL' => 'FUNC_NUMBER',
|
||||
'BIT' => 'FUNC_NUMBER',
|
||||
'BOOLEAN' => 'FUNC_NUMBER',
|
||||
'SERIAL' => 'FUNC_NUMBER',
|
||||
|
||||
'DATE' => 'FUNC_DATE',
|
||||
'DATETIME' => 'FUNC_DATE',
|
||||
'TIMESTAMP' => 'FUNC_DATE',
|
||||
'TIME' => 'FUNC_DATE',
|
||||
'YEAR' => 'FUNC_DATE',
|
||||
|
||||
'CHAR' => 'FUNC_CHAR',
|
||||
'VARCHAR' => 'FUNC_CHAR',
|
||||
'TINYTEXT' => 'FUNC_CHAR',
|
||||
'TEXT' => 'FUNC_CHAR',
|
||||
'MEDIUMTEXT' => 'FUNC_CHAR',
|
||||
'LONGTEXT' => 'FUNC_CHAR',
|
||||
'BINARY' => 'FUNC_CHAR',
|
||||
'VARBINARY' => 'FUNC_CHAR',
|
||||
'TINYBLOB' => 'FUNC_CHAR',
|
||||
'MEDIUMBLOB' => 'FUNC_CHAR',
|
||||
'BLOB' => 'FUNC_CHAR',
|
||||
'LONGBLOB' => 'FUNC_CHAR',
|
||||
'ENUM' => '',
|
||||
'SET' => '',
|
||||
|
||||
'GEOMETRY' => 'FUNC_SPATIAL',
|
||||
'POINT' => 'FUNC_SPATIAL',
|
||||
'LINESTRING' => 'FUNC_SPATIAL',
|
||||
'POLYGON' => 'FUNC_SPATIAL',
|
||||
'MULTIPOINT' => 'FUNC_SPATIAL',
|
||||
'MULTILINESTRING' => 'FUNC_SPATIAL',
|
||||
'MULTIPOLYGON' => 'FUNC_SPATIAL',
|
||||
'GEOMETRYCOLLECTION' => 'FUNC_SPATIAL',
|
||||
|
||||
);
|
||||
$cfg['RestrictColumnTypes'] = array();
|
||||
|
||||
/**
|
||||
* Map above defined groups to any function
|
||||
*
|
||||
* This variable is filled in data_*.inc.php
|
||||
*
|
||||
* @global array $cfg['RestrictFunctions']
|
||||
*/
|
||||
$cfg['RestrictFunctions'] = array(
|
||||
'FUNC_CHAR' => array(
|
||||
'BIN',
|
||||
'CHAR',
|
||||
'CURRENT_USER',
|
||||
'COMPRESS',
|
||||
'DAYNAME',
|
||||
'DES_DECRYPT',
|
||||
'DES_ENCRYPT',
|
||||
'ENCRYPT',
|
||||
'HEX',
|
||||
'INET_NTOA',
|
||||
'LOWER',
|
||||
'MD5',
|
||||
'OLD_PASSWORD',
|
||||
'PASSWORD',
|
||||
'REVERSE',
|
||||
'SHA1',
|
||||
'SOUNDEX',
|
||||
'SPACE',
|
||||
'UNCOMPRESS',
|
||||
'UNHEX',
|
||||
'UPPER',
|
||||
'USER',
|
||||
'UUID',
|
||||
),
|
||||
|
||||
'FUNC_DATE' => array(
|
||||
'CURDATE',
|
||||
'CURTIME',
|
||||
'DATE',
|
||||
'FROM_DAYS',
|
||||
'FROM_UNIXTIME',
|
||||
'NOW',
|
||||
'SEC_TO_TIME',
|
||||
'TIMESTAMP',
|
||||
'UTC_DATE',
|
||||
'UTC_TIME',
|
||||
'UTC_TIMESTAMP',
|
||||
'YEAR',
|
||||
),
|
||||
|
||||
'FUNC_NUMBER' => array(
|
||||
'ABS',
|
||||
'ACOS',
|
||||
'ASCII',
|
||||
'ASIN',
|
||||
'ATAN',
|
||||
'BIT_LENGTH',
|
||||
'BIT_COUNT',
|
||||
'CEILING',
|
||||
'CHAR_LENGTH',
|
||||
'COS',
|
||||
'COT',
|
||||
'CRC32',
|
||||
'DEGREES',
|
||||
'EXP',
|
||||
'FLOOR',
|
||||
'INET_ATON',
|
||||
'LENGTH',
|
||||
'LN',
|
||||
'LOG',
|
||||
'LOG2',
|
||||
'LOG10',
|
||||
'OCT',
|
||||
'ORD',
|
||||
'RADIANS',
|
||||
'RAND',
|
||||
'ROUND',
|
||||
'SQRT',
|
||||
'STDDEV_POP',
|
||||
'STDDEV_SAMP',
|
||||
'TAN',
|
||||
'TIME_TO_SEC',
|
||||
'UNIX_TIMESTAMP',
|
||||
'VAR_POP',
|
||||
'VAR_SAMP',
|
||||
),
|
||||
|
||||
'FUNC_SPATIAL' => array(
|
||||
'GeomFromText',
|
||||
'GeomFromWKB',
|
||||
|
||||
'GeomCollFromText',
|
||||
'LineFromText',
|
||||
'MLineFromText',
|
||||
'PointFromText',
|
||||
'MPointFromText',
|
||||
'PolyFromText',
|
||||
'MPolyFromText',
|
||||
|
||||
'GeomCollFromWKB',
|
||||
'LineFromWKB',
|
||||
'MLineFromWKB',
|
||||
'PointFromWKB',
|
||||
'MPointFromWKB',
|
||||
'PolyFromWKB',
|
||||
'MPolyFromWKB',
|
||||
),
|
||||
);
|
||||
$cfg['RestrictFunctions'] = array();
|
||||
|
||||
/**
|
||||
* Default functions for above defined groups
|
||||
@ -3082,11 +2806,10 @@ if ($cfg['ShowFunctionFields']) {
|
||||
'FUNC_CHAR' => '',
|
||||
'FUNC_DATE' => '',
|
||||
'FUNC_NUMBER' => '',
|
||||
'FUNC_SPATIAL' => 'GeomFromText',
|
||||
'first_timestamp' => 'NOW',
|
||||
'pk_char36' => 'UUID',
|
||||
);
|
||||
|
||||
|
||||
} // end if
|
||||
|
||||
/**
|
||||
|
||||
@ -467,10 +467,10 @@ class FormDisplay
|
||||
}
|
||||
|
||||
$this->errors = array();
|
||||
foreach ($forms as $form) {
|
||||
foreach ($forms as $form_name) {
|
||||
/* @var $form Form */
|
||||
if (isset($this->forms[$form])) {
|
||||
$form = $this->forms[$form];
|
||||
if (isset($this->forms[$form_name])) {
|
||||
$form = $this->forms[$form_name];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -708,13 +708,27 @@ function PMA_includeJS($url)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds JS code snippets to be displayed by header.inc.php. Adds a newline to each snippet.
|
||||
* Adds JS code snippets to be displayed by header.inc.php. Adds a
|
||||
* newline to each snippet.
|
||||
*
|
||||
* @param string $str Js code to be added (e.g. "token=1234;")
|
||||
*
|
||||
*/
|
||||
function PMA_AddJSCode($str) {
|
||||
function PMA_AddJSCode($str)
|
||||
{
|
||||
$GLOBALS['js_script'][] = $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds JS code snippet for variable assignment to be displayed by header.inc.php.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
*
|
||||
*/
|
||||
function PMA_AddJSVar($key, $value)
|
||||
{
|
||||
PMA_AddJsCode(PMA_getJsValue($key, $value));
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -23,6 +23,7 @@ define('PMA_DBI_GETVAR_GLOBAL', 2);
|
||||
* Checks one of the mysql extensions
|
||||
*
|
||||
* @param string $extension mysql extension to check
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_DBI_checkMysqlExtension($extension = 'mysql')
|
||||
{
|
||||
|
||||
@ -65,10 +65,10 @@ function PMA_TableHeader($db_is_information_schema = false, $replication = false
|
||||
/**
|
||||
* Creates a clickable column header for table information
|
||||
*
|
||||
* @param string title to use for the link
|
||||
* @param string corresponds to sortable data name mapped in libraries/db_info.inc.php
|
||||
* @param string initial sort order
|
||||
* @returns string link to be displayed in the table header
|
||||
* @param string $title title to use for the link
|
||||
* @param string $sort corresponds to sortable data name mapped in libraries/db_info.inc.php
|
||||
* @param string $initial_sort_order
|
||||
* @return string link to be displayed in the table header
|
||||
*/
|
||||
function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
|
||||
{
|
||||
|
||||
@ -578,8 +578,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
|
||||
echo '<input id="col_visib" type="hidden" value="' . implode(',', $col_visib) . '" />';
|
||||
}
|
||||
// generate table create time
|
||||
echo '<input id="table_create_time" type="hidden" value="' .
|
||||
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
|
||||
if (! PMA_Table::isView($GLOBALS['table'], $GLOBALS['db'])) {
|
||||
echo '<input id="table_create_time" type="hidden" value="' .
|
||||
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1411,11 +1413,19 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
$hide_class = ($col_visib && !$col_visib[$j] &&
|
||||
// hide per <td> only if the display direction is not vertical
|
||||
$_SESSION['tmp_user_values']['disp_direction'] != 'vertical') ? 'hide' : '';
|
||||
// handle datetime-related class, for grid editing
|
||||
if (substr($meta->type, 0, 9) == 'timestamp' || $meta->type == 'datetime') {
|
||||
$field_type_class = 'datetimefield';
|
||||
} else if ($meta->type == 'date') {
|
||||
$field_type_class = 'datefield';
|
||||
} else {
|
||||
$field_type_class = '';
|
||||
}
|
||||
$pointer = $i;
|
||||
$is_field_truncated = false;
|
||||
//If the previous column had blob data, we need to reset the class
|
||||
// to $inline_edit_class
|
||||
$class = 'data ' . $grid_edit_class . ' ' . $not_null_class . ' ' . $relation_class . ' ' . $hide_class; //' ' . $alternating_color_class .
|
||||
$class = 'data ' . $grid_edit_class . ' ' . $not_null_class . ' ' . $relation_class . ' ' . $hide_class . ' ' . $field_type_class; //' ' . $alternating_color_class .
|
||||
|
||||
// See if this column should get highlight because it's used in the
|
||||
// where-query.
|
||||
@ -1547,65 +1557,67 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
// Remove 'grid_edit' from $class as we do not allow to inline-edit geometry data.
|
||||
$class = str_replace('grid_edit', '', $class);
|
||||
|
||||
// Display as [GEOMETRY - (size)]
|
||||
if ('GEOM' == $_SESSION['tmp_user_values']['geometry_display']) {
|
||||
$geometry_text = PMA_handle_non_printable_contents(
|
||||
'GEOMETRY', (isset($row[$i]) ? $row[$i] : ''), $transform_function,
|
||||
$transform_options, $default_function, $meta
|
||||
);
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay(
|
||||
$class, $condition_field, $geometry_text
|
||||
);
|
||||
if (! isset($row[$i]) || is_null($row[$i])) {
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field);
|
||||
} elseif ($row[$i] != '') {
|
||||
// Display as [GEOMETRY - (size)]
|
||||
if ('GEOM' == $_SESSION['tmp_user_values']['geometry_display']) {
|
||||
$geometry_text = PMA_handle_non_printable_contents(
|
||||
'GEOMETRY', (isset($row[$i]) ? $row[$i] : ''), $transform_function,
|
||||
$transform_options, $default_function, $meta
|
||||
);
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay(
|
||||
$class, $condition_field, $geometry_text
|
||||
);
|
||||
|
||||
// Display in Well Known Text(WKT) format.
|
||||
} elseif ('WKT' == $_SESSION['tmp_user_values']['geometry_display']) {
|
||||
// Convert to WKT format
|
||||
$wktsql = "SELECT ASTEXT (GeomFromWKB(x'" . PMA_substr(bin2hex($row[$i]), 8) . "'))";
|
||||
$wktresult = PMA_DBI_try_query($wktsql, null, PMA_DBI_QUERY_STORE);
|
||||
$wktarr = PMA_DBI_fetch_row($wktresult, 0);
|
||||
$wktval = $wktarr[0];
|
||||
@PMA_DBI_free_result($wktresult);
|
||||
// Display in Well Known Text(WKT) format.
|
||||
} elseif ('WKT' == $_SESSION['tmp_user_values']['geometry_display']) {
|
||||
// Convert to WKT format
|
||||
$wktval = PMA_asWKT($row[$i]);
|
||||
|
||||
if (PMA_strlen($wktval) > $GLOBALS['cfg']['LimitChars']
|
||||
&& $_SESSION['tmp_user_values']['display_text'] == 'P'
|
||||
) {
|
||||
$wktval = PMA_substr($wktval, 0, $GLOBALS['cfg']['LimitChars']) . '...';
|
||||
$is_field_truncated = true;
|
||||
}
|
||||
|
||||
$vertical_display['data'][$row_no][$i] = '<td ' . PMA_prepare_row_data(
|
||||
$class, $condition_field, $analyzed_sql, $meta, $map, $wktval, $transform_function,
|
||||
$default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated
|
||||
);
|
||||
|
||||
// Display in Well Known Binary(WKB) format.
|
||||
} else {
|
||||
if ($_SESSION['tmp_user_values']['display_binary']) {
|
||||
if ($_SESSION['tmp_user_values']['display_binary_as_hex']
|
||||
&& PMA_contains_nonprintable_ascii($row[$i])
|
||||
) {
|
||||
$wkbval = PMA_substr(bin2hex($row[$i]), 8);
|
||||
} else {
|
||||
$wkbval = htmlspecialchars(PMA_replace_binary_contents($row[$i]));
|
||||
}
|
||||
|
||||
if (PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']
|
||||
if (PMA_strlen($wktval) > $GLOBALS['cfg']['LimitChars']
|
||||
&& $_SESSION['tmp_user_values']['display_text'] == 'P'
|
||||
) {
|
||||
$wkbval = PMA_substr($wkbval, 0, $GLOBALS['cfg']['LimitChars']) . '...';
|
||||
$wktval = PMA_substr($wktval, 0, $GLOBALS['cfg']['LimitChars']) . '...';
|
||||
$is_field_truncated = true;
|
||||
}
|
||||
|
||||
$vertical_display['data'][$row_no][$i] = '<td ' . PMA_prepare_row_data(
|
||||
$class, $condition_field, $analyzed_sql, $meta, $map, $wkbval, $transform_function,
|
||||
$class, $condition_field, $analyzed_sql, $meta, $map, $wktval, $transform_function,
|
||||
$default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated
|
||||
);
|
||||
|
||||
// Display in Well Known Binary(WKB) format.
|
||||
} else {
|
||||
$wkbval = PMA_handle_non_printable_contents(
|
||||
'BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta, $_url_params
|
||||
);
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $wkbval);
|
||||
if ($_SESSION['tmp_user_values']['display_binary']) {
|
||||
if ($_SESSION['tmp_user_values']['display_binary_as_hex']
|
||||
&& PMA_contains_nonprintable_ascii($row[$i])
|
||||
) {
|
||||
$wkbval = PMA_substr(bin2hex($row[$i]), 8);
|
||||
} else {
|
||||
$wkbval = htmlspecialchars(PMA_replace_binary_contents($row[$i]));
|
||||
}
|
||||
|
||||
if (PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']
|
||||
&& $_SESSION['tmp_user_values']['display_text'] == 'P'
|
||||
) {
|
||||
$wkbval = PMA_substr($wkbval, 0, $GLOBALS['cfg']['LimitChars']) . '...';
|
||||
$is_field_truncated = true;
|
||||
}
|
||||
|
||||
$vertical_display['data'][$row_no][$i] = '<td ' . PMA_prepare_row_data(
|
||||
$class, $condition_field, $analyzed_sql, $meta, $map, $wkbval, $transform_function,
|
||||
$default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated
|
||||
);
|
||||
} else {
|
||||
$wkbval = PMA_handle_non_printable_contents(
|
||||
'BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta, $_url_params
|
||||
);
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $wkbval);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta);
|
||||
}
|
||||
|
||||
// n o t n u m e r i c a n d n o t B L O B
|
||||
|
||||
@ -297,8 +297,8 @@ if (isset($plugin_list)) {
|
||||
/**
|
||||
* Avoids undefined variables, use NULL so isset() returns false
|
||||
*/
|
||||
if (! isset($sql_backquotes)) {
|
||||
$sql_backquotes = null;
|
||||
if (! isset($GLOBALS['sql_backquotes'])) {
|
||||
$GLOBALS['sql_backquotes'] = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -10,9 +10,9 @@
|
||||
/**
|
||||
* Returns array of filtered file names
|
||||
*
|
||||
* @param string directory to list
|
||||
* @param string regular expression to match files
|
||||
* @returns array sorted file list on success, false on failure
|
||||
* @param string $dir directory to list
|
||||
* @param string $expression regular expression to match files
|
||||
* @return array sorted file list on success, false on failure
|
||||
*/
|
||||
function PMA_getDirContent($dir, $expression = '')
|
||||
{
|
||||
@ -39,10 +39,10 @@ function PMA_getDirContent($dir, $expression = '')
|
||||
/**
|
||||
* Returns options of filtered file names
|
||||
*
|
||||
* @param string directory to list
|
||||
* @param string regullar expression to match files
|
||||
* @param string currently active choice
|
||||
* @returns array sorted file list on success, false on failure
|
||||
* @param string $dir directory to list
|
||||
* @param string $extensions regullar expression to match files
|
||||
* @param string $active currently active choice
|
||||
* @return array sorted file list on success, false on failure
|
||||
*/
|
||||
function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
|
||||
{
|
||||
@ -64,7 +64,7 @@ function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
|
||||
/**
|
||||
* Get currently supported decompressions.
|
||||
*
|
||||
* @returns string | separated list of extensions usable in PMA_getDirContent
|
||||
* @return string | separated list of extensions usable in PMA_getDirContent
|
||||
*/
|
||||
function PMA_supportedDecompressions()
|
||||
{
|
||||
|
||||
@ -20,6 +20,9 @@ class PMA_GIS_Factory
|
||||
include_once './libraries/gis/pma_gis_geometry.php';
|
||||
|
||||
$type_lower = strtolower($type);
|
||||
if (! file_exists('./libraries/gis/pma_gis_' . $type_lower . '.php')) {
|
||||
return false;
|
||||
}
|
||||
if (include_once './libraries/gis/pma_gis_' . $type_lower . '.php') {
|
||||
switch($type) {
|
||||
case 'MULTIPOLYGON' :
|
||||
@ -37,10 +40,10 @@ class PMA_GIS_Factory
|
||||
case 'GEOMETRYCOLLECTION' :
|
||||
return PMA_GIS_Geometrycollection::singleton();
|
||||
default :
|
||||
throw new Exception('Unknown GIS data type');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('File not found');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,6 +67,17 @@ abstract class PMA_GIS_Geometry
|
||||
*/
|
||||
public abstract function scaleRow($spatial);
|
||||
|
||||
/**
|
||||
* Generate the WKT with the set of parameters passed by the GIS editor.
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Value for empty points
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
public abstract function generateWkt($gis_data, $index, $empty);
|
||||
|
||||
/**
|
||||
* Returns OpenLayers.Bounds object that correspond to the bounds of GIS data.
|
||||
*
|
||||
@ -121,6 +132,30 @@ abstract class PMA_GIS_Geometry
|
||||
return $min_max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate parameters for the GIS data editor from the value of the GIS column.
|
||||
* This method performs common work.
|
||||
* More specific work is performed by each of the geom classes.
|
||||
*
|
||||
* @param $gis_string $value of the GIS column
|
||||
*
|
||||
* @return array parameters for the GIS editor from the value of the GIS column
|
||||
*/
|
||||
protected function generateParams($value)
|
||||
{
|
||||
$geom_types = '(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING|POLYGON|MULTIPOLYGON|GEOMETRYCOLLECTION)';
|
||||
$srid = 0;
|
||||
$wkt = '';
|
||||
if (preg_match("/^'" . $geom_types . "\(.*\)',[0-9]*$/i", $value)) {
|
||||
$last_comma = strripos($value, ",");
|
||||
$srid = trim(substr($value, $last_comma + 1));
|
||||
$wkt = trim(substr($value, 1, $last_comma - 2));
|
||||
} elseif (preg_match("/^" . $geom_types . "\(.*\)$/i", $value)) {
|
||||
$wkt = $value;
|
||||
}
|
||||
return array('srid' => $srid, 'wkt' => $wkt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts points, scales and returns them as an array.
|
||||
*
|
||||
@ -141,14 +176,22 @@ abstract class PMA_GIS_Geometry
|
||||
// Extract cordinates of the point
|
||||
$cordinates = explode(" ", $point);
|
||||
|
||||
if ($scale_data != null) {
|
||||
$x = ($cordinates[0] - $scale_data['x']) * $scale_data['scale'];
|
||||
$y = $scale_data['height'] - ($cordinates[1] - $scale_data['y']) * $scale_data['scale'];
|
||||
if (isset($cordinates[0]) && trim($cordinates[0]) != ''
|
||||
&& isset($cordinates[1]) && trim($cordinates[1]) != ''
|
||||
) {
|
||||
if ($scale_data != null) {
|
||||
$x = ($cordinates[0] - $scale_data['x']) * $scale_data['scale'];
|
||||
$y = $scale_data['height'] - ($cordinates[1] - $scale_data['y']) * $scale_data['scale'];
|
||||
} else {
|
||||
$x = trim($cordinates[0]);
|
||||
$y = trim($cordinates[1]);
|
||||
}
|
||||
} else {
|
||||
$x = $cordinates[0];
|
||||
$y = $cordinates[1];
|
||||
$x = '';
|
||||
$y = '';
|
||||
}
|
||||
|
||||
|
||||
if (! $linear) {
|
||||
$points_arr[] = array($x, $y);
|
||||
} else {
|
||||
|
||||
@ -53,6 +53,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
|
||||
$type = substr($sub_part, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$scale_data = $gis_obj->scaleRow($sub_part);
|
||||
|
||||
// Upadate minimum/maximum values for x and y cordinates.
|
||||
@ -102,6 +105,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
|
||||
$type = substr($sub_part, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$image = $gis_obj->prepareRowAsPng($sub_part, $label, $color, $scale_data, $image);
|
||||
}
|
||||
return $image;
|
||||
@ -130,6 +136,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
|
||||
$type = substr($sub_part, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$pdf = $gis_obj->prepareRowAsPdf($sub_part, $label, $color, $scale_data, $pdf);
|
||||
}
|
||||
return $pdf;
|
||||
@ -159,6 +168,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
|
||||
$type = substr($sub_part, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$row .= $gis_obj->prepareRowAsSvg($sub_part, $label, $color, $scale_data);
|
||||
}
|
||||
return $row;
|
||||
@ -190,6 +202,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
|
||||
$type = substr($sub_part, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$row .= $gis_obj->prepareRowAsOl($sub_part, $srid, $label, $color, $scale_data);
|
||||
}
|
||||
return $row;
|
||||
@ -222,5 +237,71 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
|
||||
}
|
||||
return $sub_parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT with the set of parameters passed by the GIS editor.
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Value for empty points
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
public function generateWkt($gis_data, $index, $empty = '')
|
||||
{
|
||||
$geom_count = (isset($gis_data['GEOMETRYCOLLECTION']['geom_count']))
|
||||
? $gis_data['GEOMETRYCOLLECTION']['geom_count'] : 1;
|
||||
$wkt = 'GEOMETRYCOLLECTION(';
|
||||
for ($i = 0; $i < $geom_count; $i++) {
|
||||
if (isset($gis_data[$i]['gis_type'])) {
|
||||
$type = $gis_data[$i]['gis_type'];
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$wkt .= $gis_obj->generateWkt($gis_data, $i, $empty) . ',';
|
||||
}
|
||||
}
|
||||
if (isset($gis_data[0]['gis_type'])) {
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
}
|
||||
$wkt .= ')';
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/** Generate parameters for the GIS data editor from the value of the GIS column.
|
||||
*
|
||||
* @param string $value of the GIS column
|
||||
* @param index $index of the geometry
|
||||
*
|
||||
* @return parameters for the GIS data editor from the value of the GIS column
|
||||
*/
|
||||
public function generateParams($value)
|
||||
{
|
||||
$params = array();
|
||||
$data = PMA_GIS_Geometry::generateParams($value);
|
||||
$params['srid'] = $data['srid'];
|
||||
$wkt = $data['wkt'];
|
||||
|
||||
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
|
||||
$goem_col = substr($wkt, 19, (strlen($wkt) - 20));
|
||||
// Split the geometry collection object to get its constituents.
|
||||
$sub_parts = $this->_explodeGeomCol($goem_col);
|
||||
$params['GEOMETRYCOLLECTION']['geom_count'] = count($sub_parts);
|
||||
|
||||
$i = 0;
|
||||
foreach ($sub_parts as $sub_part) {
|
||||
$type_pos = stripos($sub_part, '(');
|
||||
$type = substr($sub_part, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$params = array_merge($params, $gis_obj->generateParams($sub_part, $i));
|
||||
$i++;
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -59,6 +59,7 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
|
||||
public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
|
||||
{
|
||||
// allocate colors
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$red = hexdec(substr($line_color, 1, 2));
|
||||
$green = hexdec(substr($line_color, 3, 2));
|
||||
$blue = hexdec(substr($line_color, 4, 2));
|
||||
@ -77,6 +78,10 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
|
||||
$temp_point = $point;
|
||||
}
|
||||
}
|
||||
// print label if applicable
|
||||
if (isset($label) && trim($label) != '') {
|
||||
imagestring($image, 1, $points_arr[1][0], $points_arr[1][1], trim($label), $black);
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
|
||||
@ -112,6 +117,12 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
|
||||
$temp_point = $point;
|
||||
}
|
||||
}
|
||||
// print label
|
||||
if (isset($label) && trim($label) != '') {
|
||||
$pdf->SetXY($points_arr[1][0], $points_arr[1][1]);
|
||||
$pdf->SetFontSize(5);
|
||||
$pdf->Cell(0, 0, trim($label));
|
||||
}
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
@ -196,5 +207,70 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
|
||||
. json_encode($style_options) . '));';
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT with the set of parameters passed by the GIS editor.
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Value for empty points
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
public function generateWkt($gis_data, $index, $empty = '')
|
||||
{
|
||||
$no_of_points = isset($gis_data[$index]['LINESTRING']['no_of_points'])
|
||||
? $gis_data[$index]['LINESTRING']['no_of_points'] : 2;
|
||||
if ($no_of_points < 2) {
|
||||
$no_of_points = 2;
|
||||
}
|
||||
$wkt = 'LINESTRING(';
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$wkt .= ((isset($gis_data[$index]['LINESTRING'][$i]['x'])
|
||||
&& trim($gis_data[$index]['LINESTRING'][$i]['x']) != '')
|
||||
? $gis_data[$index]['LINESTRING'][$i]['x'] : $empty)
|
||||
. ' ' . ((isset($gis_data[$index]['LINESTRING'][$i]['y'])
|
||||
&& trim($gis_data[$index]['LINESTRING'][$i]['y']) != '')
|
||||
? $gis_data[$index]['LINESTRING'][$i]['y'] : $empty) .',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')';
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate parameters for the GIS data editor from the value of the GIS column.
|
||||
*
|
||||
* @param string $value of the GIS column
|
||||
* @param index $index of the geometry
|
||||
*
|
||||
* @return parameters for the GIS data editor from the value of the GIS column
|
||||
*/
|
||||
public function generateParams($value, $index = -1)
|
||||
{
|
||||
if ($index == -1) {
|
||||
$index = 0;
|
||||
$params = array();
|
||||
$data = PMA_GIS_Geometry::generateParams($value);
|
||||
$params['srid'] = $data['srid'];
|
||||
$wkt = $data['wkt'];
|
||||
} else {
|
||||
$params[$index]['gis_type'] = 'LINESTRING';
|
||||
$wkt = $value;
|
||||
}
|
||||
|
||||
// Trim to remove leading 'LINESTRING(' and trailing ')'
|
||||
$linestring = substr($wkt, 11, (strlen($wkt) - 12));
|
||||
$points_arr = $this->extractPoints($linestring, null);
|
||||
|
||||
$no_of_points = count($points_arr);
|
||||
$params[$index]['LINESTRING']['no_of_points'] = $no_of_points;
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$params[$index]['LINESTRING'][$i]['x'] = $points_arr[$i][0];
|
||||
$params[$index]['LINESTRING'][$i]['y'] = $points_arr[$i][1];
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -68,6 +68,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
|
||||
public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
|
||||
{
|
||||
// allocate colors
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$red = hexdec(substr($line_color, 1, 2));
|
||||
$green = hexdec(substr($line_color, 3, 2));
|
||||
$blue = hexdec(substr($line_color, 4, 2));
|
||||
@ -78,6 +79,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
|
||||
// Seperate each linestring
|
||||
$linestirngs = explode("),(", $multilinestirng);
|
||||
|
||||
$first_line = true;
|
||||
foreach ($linestirngs as $linestring) {
|
||||
$points_arr = $this->extractPoints($linestring, $scale_data);
|
||||
foreach ($points_arr as $point) {
|
||||
@ -90,6 +92,11 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
|
||||
}
|
||||
}
|
||||
unset($temp_point);
|
||||
// print label if applicable
|
||||
if (isset($label) && trim($label) != '' && $first_line) {
|
||||
imagestring($image, 1, $points_arr[1][0], $points_arr[1][1], trim($label), $black);
|
||||
}
|
||||
$first_line = false;
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
@ -118,6 +125,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
|
||||
// Seperate each linestring
|
||||
$linestirngs = explode("),(", $multilinestirng);
|
||||
|
||||
$first_line = true;
|
||||
foreach ($linestirngs as $linestring) {
|
||||
$points_arr = $this->extractPoints($linestring, $scale_data);
|
||||
foreach ($points_arr as $point) {
|
||||
@ -130,6 +138,13 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
|
||||
}
|
||||
}
|
||||
unset($temp_point);
|
||||
// print label
|
||||
if (isset($label) && trim($label) != '' && $first_line) {
|
||||
$pdf->SetXY($points_arr[1][0], $points_arr[1][1]);
|
||||
$pdf->SetFontSize(5);
|
||||
$pdf->Cell(0, 0, trim($label));
|
||||
}
|
||||
$first_line = false;
|
||||
}
|
||||
return $pdf;
|
||||
}
|
||||
@ -225,5 +240,109 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
|
||||
$row .= ')), null, ' . json_encode($style_options) . '));';
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT with the set of parameters passed by the GIS editor.
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Value for empty points
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
public function generateWkt($gis_data, $index, $empty = '')
|
||||
{
|
||||
$no_of_lines = isset($gis_data[$index]['MULTILINESTRING']['no_of_lines'])
|
||||
? $gis_data[$index]['MULTILINESTRING']['no_of_lines'] : 1;
|
||||
if ($no_of_lines < 1) {
|
||||
$no_of_lines = 1;
|
||||
}
|
||||
$wkt = 'MULTILINESTRING(';
|
||||
for ($i = 0; $i < $no_of_lines; $i++) {
|
||||
$no_of_points = isset($gis_data[$index]['MULTILINESTRING'][$i]['no_of_points'])
|
||||
? $gis_data[$index]['MULTILINESTRING'][$i]['no_of_points'] : 2;
|
||||
if ($no_of_points < 2) {
|
||||
$no_of_points = 2;
|
||||
}
|
||||
$wkt .= '(';
|
||||
for ($j = 0; $j < $no_of_points; $j++) {
|
||||
$wkt .= ((isset($gis_data[$index]['MULTILINESTRING'][$i][$j]['x'])
|
||||
&& trim($gis_data[$index]['MULTILINESTRING'][$i][$j]['x']) != '')
|
||||
? $gis_data[$index]['MULTILINESTRING'][$i][$j]['x'] : $empty)
|
||||
. ' ' . ((isset($gis_data[$index]['MULTILINESTRING'][$i][$j]['y'])
|
||||
&& trim($gis_data[$index]['MULTILINESTRING'][$i][$j]['y']) != '')
|
||||
? $gis_data[$index]['MULTILINESTRING'][$i][$j]['y'] : $empty) . ',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= '),';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')';
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT for the data from ESRI shape files.
|
||||
*
|
||||
* @param array $row_data GIS data
|
||||
*
|
||||
* @return the WKT for the data from ESRI shape files
|
||||
*/
|
||||
public function getShape($row_data)
|
||||
{
|
||||
$wkt = 'MULTILINESTRING(';
|
||||
for ($i = 0; $i < $row_data['numparts']; $i++) {
|
||||
$wkt .= '(';
|
||||
foreach ($row_data['parts'][$i]['points'] as $point) {
|
||||
$wkt .= $point['x'] . ' ' . $point['y'] . ',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= '),';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')';
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate parameters for the GIS data editor from the value of the GIS column.
|
||||
*
|
||||
* @param string $value of the GIS column
|
||||
* @param index $index of the geometry
|
||||
*
|
||||
* @return parameters for the GIS data editor from the value of the GIS column
|
||||
*/
|
||||
public function generateParams($value, $index = -1)
|
||||
{
|
||||
if ($index == -1) {
|
||||
$index = 0;
|
||||
$params = array();
|
||||
$data = PMA_GIS_Geometry::generateParams($value);
|
||||
$params['srid'] = $data['srid'];
|
||||
$wkt = $data['wkt'];
|
||||
} else {
|
||||
$params[$index]['gis_type'] = 'MULTILINESTRING';
|
||||
$wkt = $value;
|
||||
}
|
||||
|
||||
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
|
||||
$multilinestirng = substr($wkt, 17, (strlen($wkt) - 19));
|
||||
// Seperate each linestring
|
||||
$linestirngs = explode("),(", $multilinestirng);
|
||||
$params[$index]['MULTILINESTRING']['no_of_lines'] = count($linestirngs);
|
||||
|
||||
$j = 0;
|
||||
foreach ($linestirngs as $linestring) {
|
||||
$points_arr = $this->extractPoints($linestring, null);
|
||||
$no_of_points = count($points_arr);
|
||||
$params[$index]['MULTILINESTRING'][$j]['no_of_points'] = $no_of_points;
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$params[$index]['MULTILINESTRING'][$j][$i]['x'] = $points_arr[$i][0];
|
||||
$params[$index]['MULTILINESTRING'][$j][$i]['y'] = $points_arr[$i][1];
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -59,6 +59,7 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image)
|
||||
{
|
||||
// allocate colors
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$red = hexdec(substr($point_color, 1, 2));
|
||||
$green = hexdec(substr($point_color, 3, 2));
|
||||
$blue = hexdec(substr($point_color, 4, 2));
|
||||
@ -70,7 +71,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
|
||||
foreach ($points_arr as $point) {
|
||||
// draw a small circle to mark the point
|
||||
imagearc($image, $point[0], $point[1], 7, 7, 0, 360, $color);
|
||||
if ($point[0] != '' && $point[1] != '') {
|
||||
imagearc($image, $point[0], $point[1], 7, 7, 0, 360, $color);
|
||||
}
|
||||
}
|
||||
// print label for each point
|
||||
if ((isset($label) && trim($label) != '')
|
||||
&& ($points_arr[0][0] != '' && $points_arr[0][1] != '')
|
||||
) {
|
||||
imagestring($image, 1, $points_arr[0][0], $points_arr[0][1], trim($label), $black);
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
@ -100,7 +109,17 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
|
||||
foreach ($points_arr as $point) {
|
||||
// draw a small circle to mark the point
|
||||
$pdf->Circle($point[0], $point[1], 2, 0, 360, 'D', $line);
|
||||
if ($point[0] != '' && $point[1] != '') {
|
||||
$pdf->Circle($point[0], $point[1], 2, 0, 360, 'D', $line);
|
||||
}
|
||||
}
|
||||
// print label for each point
|
||||
if ((isset($label) && trim($label) != '')
|
||||
&& ($points_arr[0][0] != '' && $points_arr[0][1] != '')
|
||||
) {
|
||||
$pdf->SetXY($points_arr[0][0], $points_arr[0][1]);
|
||||
$pdf->SetFontSize(5);
|
||||
$pdf->Cell(0, 0, trim($label));
|
||||
}
|
||||
return $pdf;
|
||||
}
|
||||
@ -131,12 +150,14 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
|
||||
$row = '';
|
||||
foreach ($points_arr as $point) {
|
||||
$row .= '<circle cx="' . $point[0] . '" cy="' . $point[1] . '" r="3"';
|
||||
$point_options['id'] = $label . rand();
|
||||
foreach ($point_options as $option => $val) {
|
||||
$row .= ' ' . $option . '="' . trim($val) . '"';
|
||||
if ($point[0] != '' && $point[1] != '') {
|
||||
$row .= '<circle cx="' . $point[0] . '" cy="' . $point[1] . '" r="3"';
|
||||
$point_options['id'] = $label . rand();
|
||||
foreach ($point_options as $option => $val) {
|
||||
$row .= ' ' . $option . '="' . trim($val) . '"';
|
||||
}
|
||||
$row .= '/>';
|
||||
}
|
||||
$row .= '/>';
|
||||
}
|
||||
|
||||
return $row;
|
||||
@ -176,11 +197,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
|
||||
$row = 'new Array(';
|
||||
foreach ($points_arr as $point) {
|
||||
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1]
|
||||
. ')).transform(new OpenLayers.Projection("EPSG:' . $srid
|
||||
. '"), map.getProjectionObject()), ';
|
||||
if ($point[0] != '' && $point[1] != '') {
|
||||
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1]
|
||||
. ')).transform(new OpenLayers.Projection("EPSG:' . $srid
|
||||
. '"), map.getProjectionObject()), ';
|
||||
}
|
||||
}
|
||||
if (substr($row, strlen($row) - 2) == ', ') {
|
||||
$row = substr($row, 0, strlen($row) - 2);
|
||||
}
|
||||
$row = substr($row, 0, strlen($row) - 2);
|
||||
$row .= ')';
|
||||
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
@ -188,5 +213,88 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
. json_encode($style_options) . '));';
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT with the set of parameters passed by the GIS editor.
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Multipoint does not adhere to this
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
public function generateWkt($gis_data, $index, $empty = '')
|
||||
{
|
||||
$no_of_points = isset($gis_data[$index]['MULTIPOINT']['no_of_points'])
|
||||
? $gis_data[$index]['MULTIPOINT']['no_of_points'] : 1;
|
||||
if ($no_of_points < 1) {
|
||||
$no_of_points = 1;
|
||||
}
|
||||
$wkt = 'MULTIPOINT(';
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$wkt .= ((isset($gis_data[$index]['MULTIPOINT'][$i]['x'])
|
||||
&& trim($gis_data[$index]['MULTIPOINT'][$i]['x']) != '')
|
||||
? $gis_data[$index]['MULTIPOINT'][$i]['x'] : '')
|
||||
. ' ' . ((isset($gis_data[$index]['MULTIPOINT'][$i]['y'])
|
||||
&& trim($gis_data[$index]['MULTIPOINT'][$i]['y']) != '')
|
||||
? $gis_data[$index]['MULTIPOINT'][$i]['y'] : '') . ',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')';
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT for the data from ESRI shape files.
|
||||
*
|
||||
* @param array $row_data GIS data
|
||||
*
|
||||
* @return the WKT for the data from ESRI shape files
|
||||
*/
|
||||
public function getShape($row_data)
|
||||
{
|
||||
$wkt = 'MULTIPOINT(';
|
||||
for ($i = 0; $i < $row_data['numpoints']; $i++) {
|
||||
$wkt .= $row_data['points'][$i]['x'] . ' ' . $row_data['points'][$i]['y'] . ',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')';
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate parameters for the GIS data editor from the value of the GIS column.
|
||||
*
|
||||
* @param string $value of the GIS column
|
||||
* @param index $index of the geometry
|
||||
*
|
||||
* @return parameters for the GIS data editor from the value of the GIS column
|
||||
*/
|
||||
public function generateParams($value, $index = -1)
|
||||
{
|
||||
if ($index == -1) {
|
||||
$index = 0;
|
||||
$params = array();
|
||||
$data = PMA_GIS_Geometry::generateParams($value);
|
||||
$params['srid'] = $data['srid'];
|
||||
$wkt = $data['wkt'];
|
||||
} else {
|
||||
$params[$index]['gis_type'] = 'MULTIPOINT';
|
||||
$wkt = $value;
|
||||
}
|
||||
|
||||
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
|
||||
$points = substr($wkt, 11, (strlen($wkt) - 12));
|
||||
$points_arr = $this->extractPoints($points, null);
|
||||
|
||||
$no_of_points = count($points_arr);
|
||||
$params[$index]['MULTIPOINT']['no_of_points'] = $no_of_points;
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$params[$index]['MULTIPOINT'][$i]['x'] = $points_arr[$i][0];
|
||||
$params[$index]['MULTIPOINT'][$i]['y'] = $points_arr[$i][1];
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -82,6 +82,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
|
||||
public function prepareRowAsPng($spatial, $label, $fill_color, $scale_data, $image)
|
||||
{
|
||||
// allocate colors
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$red = hexdec(substr($fill_color, 1, 2));
|
||||
$green = hexdec(substr($fill_color, 3, 2));
|
||||
$blue = hexdec(substr($fill_color, 4, 2));
|
||||
@ -92,6 +93,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
|
||||
// Seperate each polygon
|
||||
$polygons = explode(")),((", $multipolygon);
|
||||
|
||||
$first_poly = true;
|
||||
foreach ($polygons as $polygon) {
|
||||
// If the polygon doesnt have an inner polygon
|
||||
if (strpos($polygon, "),(") === false) {
|
||||
@ -112,6 +114,15 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
|
||||
}
|
||||
// draw polygon
|
||||
imagefilledpolygon($image, $points_arr, sizeof($points_arr) / 2, $color);
|
||||
// mark label point if applicable
|
||||
if (isset($label) && trim($label) != '' && $first_poly) {
|
||||
$label_point = array($points_arr[2], $points_arr[3]);
|
||||
}
|
||||
$first_poly = false;
|
||||
}
|
||||
// print label if applicable
|
||||
if (isset($label_point)) {
|
||||
imagestring($image, 1, $points_arr[2], $points_arr[3], trim($label), $black);
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
@ -140,6 +151,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
|
||||
// Seperate each polygon
|
||||
$polygons = explode(")),((", $multipolygon);
|
||||
|
||||
$first_poly = true;
|
||||
foreach ($polygons as $polygon) {
|
||||
// If the polygon doesnt have an inner polygon
|
||||
if (strpos($polygon, "),(") === false) {
|
||||
@ -161,6 +173,18 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
|
||||
}
|
||||
// draw polygon
|
||||
$pdf->Polygon($points_arr, 'F*', array(), $color, true);
|
||||
// mark label point if applicable
|
||||
if (isset($label) && trim($label) != '' && $first_poly) {
|
||||
$label_point = array($points_arr[2], $points_arr[3]);
|
||||
}
|
||||
$first_poly = false;
|
||||
}
|
||||
|
||||
// print label if applicable
|
||||
if (isset($label_point)) {
|
||||
$pdf->SetXY($label_point[0], $label_point[1]);
|
||||
$pdf->SetFontSize(5);
|
||||
$pdf->Cell(0, 0, trim($label));
|
||||
}
|
||||
return $pdf;
|
||||
}
|
||||
@ -287,5 +311,190 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT with the set of parameters passed by the GIS editor.
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Value for empty points
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
public function generateWkt($gis_data, $index, $empty = '')
|
||||
{
|
||||
$no_of_polygons = isset($gis_data[$index]['MULTIPOLYGON']['no_of_polygons'])
|
||||
? $gis_data[$index]['MULTIPOLYGON']['no_of_polygons'] : 1;
|
||||
if ($no_of_polygons < 1) {
|
||||
$no_of_polygons = 1;
|
||||
}
|
||||
$wkt = 'MULTIPOLYGON(';
|
||||
for ($k = 0; $k < $no_of_polygons; $k++) {
|
||||
$no_of_lines = isset($gis_data[$index]['MULTIPOLYGON'][$k]['no_of_lines'])
|
||||
? $gis_data[$index]['MULTIPOLYGON'][$k]['no_of_lines'] : 1;
|
||||
if ($no_of_lines < 1) {
|
||||
$no_of_lines = 1;
|
||||
}
|
||||
$wkt .= '(';
|
||||
for ($i = 0; $i < $no_of_lines; $i++) {
|
||||
$no_of_points = isset($gis_data[$index]['MULTIPOLYGON'][$k][$i]['no_of_points'])
|
||||
? $gis_data[$index]['MULTIPOLYGON'][$k][$i]['no_of_points'] : 4;
|
||||
if ($no_of_points < 4) {
|
||||
$no_of_points = 4;
|
||||
}
|
||||
$wkt .= '(';
|
||||
for ($j = 0; $j < $no_of_points; $j++) {
|
||||
$wkt .= ((isset($gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['x'])
|
||||
&& trim($gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['x']) != '')
|
||||
? $gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['x'] : $empty)
|
||||
. ' ' . ((isset($gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['y'])
|
||||
&& trim($gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['y']) != '')
|
||||
? $gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['y'] : $empty) .',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= '),';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= '),';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')';
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT for the data from ESRI shape files.
|
||||
*
|
||||
* @param array $row_data GIS data
|
||||
*
|
||||
* @return the WKT for the data from ESRI shape files
|
||||
*/
|
||||
public function getShape($row_data)
|
||||
{
|
||||
// Determines whether each line ring is an inner ring or an outer ring.
|
||||
// If it's an inner ring get a point on the surface which can be used to
|
||||
// correctly classify inner rings to their respective outer rings.
|
||||
require_once './libraries/gis/pma_gis_polygon.php';
|
||||
foreach ($row_data['parts'] as $i => $ring) {
|
||||
$row_data['parts'][$i]['isOuter'] = PMA_GIS_Polygon::isOuterRing($ring['points']);
|
||||
}
|
||||
|
||||
// Find points on surface for inner rings
|
||||
foreach ($row_data['parts'] as $i => $ring) {
|
||||
if (! $ring['isOuter']) {
|
||||
$row_data['parts'][$i]['pointOnSurface'] = PMA_GIS_Polygon::getPointOnSurface($ring['points']);
|
||||
}
|
||||
}
|
||||
|
||||
// Classify inner rings to their respective outer rings.
|
||||
foreach ($row_data['parts'] as $j => $ring1) {
|
||||
if (! $ring1['isOuter']) {
|
||||
foreach ($row_data['parts'] as $k => $ring2) {
|
||||
if ($ring2['isOuter']) {
|
||||
// If the pointOnSurface of the inner ring is also inside the outer ring
|
||||
if (PMA_GIS_Polygon::isPointInsidePolygon($ring1['pointOnSurface'], $ring2['points'])) {
|
||||
if (! isset($ring2['inner'])) {
|
||||
$row_data['parts'][$k]['inner'] = array();
|
||||
}
|
||||
$row_data['parts'][$k]['inner'][] = $j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$wkt = 'MULTIPOLYGON(';
|
||||
// for each polygon
|
||||
foreach ($row_data['parts'] as $ring) {
|
||||
if ($ring['isOuter']) {
|
||||
$wkt .= '('; // start of polygon
|
||||
|
||||
$wkt .= '('; // start of outer ring
|
||||
foreach($ring['points'] as $point) {
|
||||
$wkt .= $point['x'] . ' ' . $point['y'] . ',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')'; // end of outer ring
|
||||
|
||||
// inner rings if any
|
||||
if (isset($ring['inner'])) {
|
||||
foreach ($ring['inner'] as $j) {
|
||||
$wkt .= ',('; // start of inner ring
|
||||
foreach ($row_data['parts'][$j]['points'] as $innerPoint) {
|
||||
$wkt .= $innerPoint['x'] . ' ' . $innerPoint['y'] . ',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')'; // end of inner ring
|
||||
}
|
||||
}
|
||||
|
||||
$wkt .= '),'; // end of polygon
|
||||
}
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
|
||||
$wkt .= ')'; // end of multipolygon
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate parameters for the GIS data editor from the value of the GIS column.
|
||||
*
|
||||
* @param string $value of the GIS column
|
||||
* @param index $index of the geometry
|
||||
*
|
||||
* @return parameters for the GIS data editor from the value of the GIS column
|
||||
*/
|
||||
public function generateParams($value, $index = -1)
|
||||
{
|
||||
if ($index == -1) {
|
||||
$index = 0;
|
||||
$params = array();
|
||||
$data = PMA_GIS_Geometry::generateParams($value);
|
||||
$params['srid'] = $data['srid'];
|
||||
$wkt = $data['wkt'];
|
||||
} else {
|
||||
$params[$index]['gis_type'] = 'MULTIPOLYGON';
|
||||
$wkt = $value;
|
||||
}
|
||||
|
||||
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
|
||||
$multipolygon = substr($wkt, 15, (strlen($wkt) - 18));
|
||||
// Seperate each polygon
|
||||
$polygons = explode(")),((", $multipolygon);
|
||||
$params[$index]['MULTIPOLYGON']['no_of_polygons'] = count($polygons);
|
||||
|
||||
$k = 0;
|
||||
foreach ($polygons as $polygon) {
|
||||
// If the polygon doesnt have an inner polygon
|
||||
if (strpos($polygon, "),(") === false) {
|
||||
$params[$index]['MULTIPOLYGON'][$k]['no_of_lines'] = 1;
|
||||
$points_arr = $this->extractPoints($polygon, null);
|
||||
$no_of_points = count($points_arr);
|
||||
$params[$index]['MULTIPOLYGON'][$k][0]['no_of_points'] = $no_of_points;
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$params[$index]['MULTIPOLYGON'][$k][0][$i]['x'] = $points_arr[$i][0];
|
||||
$params[$index]['MULTIPOLYGON'][$k][0][$i]['y'] = $points_arr[$i][1];
|
||||
}
|
||||
} else {
|
||||
// Seperate outer and inner polygons
|
||||
$parts = explode("),(", $polygon);
|
||||
$params[$index]['MULTIPOLYGON'][$k]['no_of_lines'] = count($parts);
|
||||
$j = 0;
|
||||
foreach ($parts as $ring) {
|
||||
$points_arr = $this->extractPoints($ring, null);
|
||||
$no_of_points = count($points_arr);
|
||||
$params[$index]['MULTIPOLYGON'][$k][$j]['no_of_points'] = $no_of_points;
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$params[$index]['MULTIPOLYGON'][$k][$j][$i]['x'] = $points_arr[$i][0];
|
||||
$params[$index]['MULTIPOLYGON'][$k][$j][$i]['y'] = $points_arr[$i][1];
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
$k++;
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -59,6 +59,7 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image)
|
||||
{
|
||||
// allocate colors
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$red = hexdec(substr($point_color, 1, 2));
|
||||
$green = hexdec(substr($point_color, 3, 2));
|
||||
$blue = hexdec(substr($point_color, 4, 2));
|
||||
@ -69,7 +70,13 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
$points_arr = $this->extractPoints($point, $scale_data);
|
||||
|
||||
// draw a small circle to mark the point
|
||||
imagearc($image, $points_arr[0][0], $points_arr[0][1], 7, 7, 0, 360, $color);
|
||||
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
|
||||
imagearc($image, $points_arr[0][0], $points_arr[0][1], 7, 7, 0, 360, $color);
|
||||
// print label if applicable
|
||||
if (isset($label) && trim($label) != '') {
|
||||
imagestring($image, 1, $points_arr[0][0], $points_arr[0][1], trim($label), $black);
|
||||
}
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
|
||||
@ -97,7 +104,15 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
$points_arr = $this->extractPoints($point, $scale_data);
|
||||
|
||||
// draw a small circle to mark the point
|
||||
$pdf->Circle($points_arr[0][0], $points_arr[0][1], 2, 0, 360, 'D', $line);
|
||||
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
|
||||
$pdf->Circle($points_arr[0][0], $points_arr[0][1], 2, 0, 360, 'D', $line);
|
||||
// print label if applicable
|
||||
if (isset($label) && trim($label) != '') {
|
||||
$pdf->SetXY($points_arr[0][0], $points_arr[0][1]);
|
||||
$pdf->SetFontSize(5);
|
||||
$pdf->Cell(0, 0, trim($label));
|
||||
}
|
||||
}
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
@ -126,11 +141,14 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
$point = substr($spatial, 6, (strlen($spatial) - 7));
|
||||
$points_arr = $this->extractPoints($point, $scale_data);
|
||||
|
||||
$row = '<circle cx="' . $points_arr[0][0] . '" cy="' . $points_arr[0][1] . '" r="3"';
|
||||
foreach ($point_options as $option => $val) {
|
||||
$row .= ' ' . $option . '="' . trim($val) . '"';
|
||||
$row = '';
|
||||
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
|
||||
$row .= '<circle cx="' . $points_arr[0][0] . '" cy="' . $points_arr[0][1] . '" r="3"';
|
||||
foreach ($point_options as $option => $val) {
|
||||
$row .= ' ' . $option . '="' . trim($val) . '"';
|
||||
}
|
||||
$row .= '/>';
|
||||
}
|
||||
$row .= '/>';
|
||||
|
||||
return $row;
|
||||
}
|
||||
@ -167,12 +185,76 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
$point = substr($spatial, 6, (strlen($spatial) - 7));
|
||||
$points_arr = $this->extractPoints($point, null);
|
||||
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(('
|
||||
. 'new OpenLayers.Geometry.Point(' . $points_arr[0][0] . ', '
|
||||
. $points_arr[0][1] . ').transform(new OpenLayers.Projection("EPSG:'
|
||||
. $srid . '"), map.getProjectionObject())), null, '
|
||||
. json_encode($style_options) . '));';
|
||||
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(('
|
||||
. 'new OpenLayers.Geometry.Point(' . $points_arr[0][0] . ', '
|
||||
. $points_arr[0][1] . ').transform(new OpenLayers.Projection("EPSG:'
|
||||
. $srid . '"), map.getProjectionObject())), null, '
|
||||
. json_encode($style_options) . '));';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT with the set of parameters passed by the GIS editor.
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Point deos not adhere to this parameter
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
public function generateWkt($gis_data, $index, $empty = '')
|
||||
{
|
||||
return 'POINT('
|
||||
. ((isset($gis_data[$index]['POINT']['x']) && trim($gis_data[$index]['POINT']['x']) != '')
|
||||
? $gis_data[$index]['POINT']['x'] : '') . ' '
|
||||
. ((isset($gis_data[$index]['POINT']['y']) && trim($gis_data[$index]['POINT']['y']) != '')
|
||||
? $gis_data[$index]['POINT']['y'] : '') . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT for the data from ESRI shape files.
|
||||
*
|
||||
* @param array $row_data GIS data
|
||||
*
|
||||
* @return the WKT for the data from ESRI shape files
|
||||
*/
|
||||
public function getShape($row_data)
|
||||
{
|
||||
return 'POINT(' . (isset($row_data['x']) ? $row_data['x'] : '')
|
||||
. ' ' . (isset($row_data['y']) ? $row_data['y'] : '') . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate parameters for the GIS data editor from the value of the GIS column.
|
||||
*
|
||||
* @param string $value of the GIS column
|
||||
* @param index $index of the geometry
|
||||
*
|
||||
* @return parameters for the GIS data editor from the value of the GIS column
|
||||
*/
|
||||
public function generateParams($value, $index = -1)
|
||||
{
|
||||
if ($index == -1) {
|
||||
$index = 0;
|
||||
$params = array();
|
||||
$data = PMA_GIS_Geometry::generateParams($value);
|
||||
$params['srid'] = $data['srid'];
|
||||
$wkt = $data['wkt'];
|
||||
} else {
|
||||
$params[$index]['gis_type'] = 'POINT';
|
||||
$wkt = $value;
|
||||
}
|
||||
|
||||
// Trim to remove leading 'POINT(' and trailing ')'
|
||||
$point = substr($wkt, 6, (strlen($wkt) - 7));
|
||||
$points_arr = $this->extractPoints($point, null);
|
||||
|
||||
$params[$index]['POINT']['x'] = $points_arr[0][0];
|
||||
$params[$index]['POINT']['y'] = $points_arr[0][1];
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -77,6 +77,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
|
||||
public function prepareRowAsPng($spatial, $label, $fill_color, $scale_data, $image)
|
||||
{
|
||||
// allocate colors
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$red = hexdec(substr($fill_color, 1, 2));
|
||||
$green = hexdec(substr($fill_color, 3, 2));
|
||||
$blue = hexdec(substr($fill_color, 4, 2));
|
||||
@ -105,6 +106,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
|
||||
|
||||
// draw polygon
|
||||
imagefilledpolygon($image, $points_arr, sizeof($points_arr) / 2, $color);
|
||||
// print label if applicable
|
||||
if (isset($label) && trim($label) != '') {
|
||||
imagestring($image, 1, $points_arr[2], $points_arr[3], trim($label), $black);
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
|
||||
@ -150,6 +155,12 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
|
||||
|
||||
// draw polygon
|
||||
$pdf->Polygon($points_arr, 'F*', array(), $color, true);
|
||||
// print label if applicable
|
||||
if (isset($label) && trim($label) != '') {
|
||||
$pdf->SetXY($points_arr[2], $points_arr[3]);
|
||||
$pdf->SetFontSize(5);
|
||||
$pdf->Cell(0, 0, trim($label));
|
||||
}
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
@ -262,5 +273,248 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the WKT with the set of parameters passed by the GIS editor.
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Value for empty points
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
public function generateWkt($gis_data, $index, $empty = '')
|
||||
{
|
||||
$no_of_lines = isset($gis_data[$index]['POLYGON']['no_of_lines'])
|
||||
? $gis_data[$index]['POLYGON']['no_of_lines'] : 1;
|
||||
if ($no_of_lines < 1) {
|
||||
$no_of_lines = 1;
|
||||
}
|
||||
$wkt = 'POLYGON(';
|
||||
for ($i = 0; $i < $no_of_lines; $i++) {
|
||||
$no_of_points = isset($gis_data[$index]['POLYGON'][$i]['no_of_points'])
|
||||
? $gis_data[$index]['POLYGON'][$i]['no_of_points'] : 4;
|
||||
if ($no_of_points < 4) {
|
||||
$no_of_points = 4;
|
||||
}
|
||||
$wkt .= '(';
|
||||
for ($j = 0; $j < $no_of_points; $j++) {
|
||||
$wkt .= ((isset($gis_data[$index]['POLYGON'][$i][$j]['x'])
|
||||
&& trim($gis_data[$index]['POLYGON'][$i][$j]['x']) != '')
|
||||
? $gis_data[$index]['POLYGON'][$i][$j]['x'] : $empty)
|
||||
. ' ' . ((isset($gis_data[$index]['POLYGON'][$i][$j]['y'])
|
||||
&& trim($gis_data[$index]['POLYGON'][$i][$j]['y']) != '')
|
||||
? $gis_data[$index]['POLYGON'][$i][$j]['y'] : $empty) .',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= '),';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')';
|
||||
return $wkt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the area of a closed simple polygon.
|
||||
*
|
||||
* @param array $ring array of points forming the ring
|
||||
*
|
||||
* @return the area of a closed simple polygon.
|
||||
*/
|
||||
public static function area($ring)
|
||||
{
|
||||
|
||||
$no_of_points = count($ring);
|
||||
|
||||
// If the last point is same as the first point ignore it
|
||||
$last = count($ring) - 1;
|
||||
if (($ring[0]['x'] == $ring[$last]['x'])
|
||||
&& ($ring[0]['y'] == $ring[$last]['y'])
|
||||
) {
|
||||
$no_of_points--;
|
||||
}
|
||||
|
||||
// _n-1
|
||||
// A = _1_ \ (X(i) * Y(i+1)) - (Y(i) * X(i+1))
|
||||
// 2 /__
|
||||
// i=0
|
||||
$area = 0;
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$j = ($i + 1) % $no_of_points;
|
||||
$area += $ring[$i]['x'] * $ring[$j]['y'];
|
||||
$area -= $ring[$i]['y'] * $ring[$j]['x'];
|
||||
}
|
||||
$area /= 2.0;
|
||||
|
||||
return $area;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a set of points represents an outer ring.
|
||||
* If points are in clockwise orientation then, they form an outer ring.
|
||||
*
|
||||
* @param array $ring array of points forming the ring
|
||||
*
|
||||
* @return whether a set of points represents an outer ring.
|
||||
*/
|
||||
public static function isOuterRing($ring)
|
||||
{
|
||||
// If area is negative then it's in clockwise orientation,
|
||||
// i.e. it's an outer ring
|
||||
if (PMA_GIS_Polygon::area($ring) < 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a given point is inside a given polygon.
|
||||
*
|
||||
* @param array $point x, y coordinates of the point
|
||||
* @param array $polygon array of points forming the ring
|
||||
*
|
||||
* @return whether a given point is inside a given polygon
|
||||
*/
|
||||
public static function isPointInsidePolygon($point, $polygon)
|
||||
{
|
||||
// If first point is repeated at the end remove it
|
||||
$last = count($polygon) - 1;
|
||||
if (($polygon[0]['x'] == $polygon[$last]['x'])
|
||||
&& ($polygon[0]['y'] == $polygon[$last]['y'])
|
||||
) {
|
||||
$polygon = array_slice($polygon, 0, $last);
|
||||
}
|
||||
|
||||
$no_of_points = count($polygon);
|
||||
$counter = 0;
|
||||
|
||||
// Use ray casting algorithm
|
||||
$p1 = $polygon[0];
|
||||
for ($i = 1; $i <= $no_of_points; $i++) {
|
||||
$p2 = $polygon[$i % $no_of_points];
|
||||
if ($point['y'] > min(array($p1['y'], $p2['y']))) {
|
||||
if ($point['y'] <= max(array($p1['y'], $p2['y']))) {
|
||||
if ($point['x'] <= max(array($p1['x'], $p2['x']))) {
|
||||
if ($p1['y'] != $p2['y']) {
|
||||
$xinters = ($point['y'] - $p1['y'])
|
||||
* ($p2['x'] - $p1['x'])
|
||||
/ ($p2['y'] - $p1['y']) + $p1['x'];
|
||||
if ($p1['x'] == $p2['x'] || $point['x'] <= $xinters) {
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$p1 = $p2;
|
||||
}
|
||||
|
||||
if ($counter % 2 == 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a point that is guaranteed to be on the surface of the ring.
|
||||
* (for simple closed rings)
|
||||
*
|
||||
* @param array $ring array of points forming the ring
|
||||
*
|
||||
* @return a point on the surface of the ring
|
||||
*/
|
||||
public static function getPointOnSurface($ring)
|
||||
{
|
||||
// Find two consecutive distinct points.
|
||||
for ($i = 0; $i < count($ring) - 1; $i++) {
|
||||
if ($ring[$i]['y'] != $ring[$i + 1]['y']) {
|
||||
$x0 = $ring[$i]['x'];
|
||||
$x1 = $ring[$i + 1]['x'];
|
||||
$y0 = $ring[$i]['y'];
|
||||
$y1 = $ring[$i + 1]['y'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! isset($x0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find the mid point
|
||||
$x2 = ($x0 + $x1) / 2;
|
||||
$y2 = ($y0 + $y1) / 2;
|
||||
|
||||
// Always keep $epsilon < 1 to go with the reduction logic down here
|
||||
$epsilon = 0.1;
|
||||
$denominator = sqrt(pow(($y1 - $y0), 2) + pow(($x0 - $x1), 2));
|
||||
$pointA = array(); $pointB = array();
|
||||
|
||||
while (true) {
|
||||
// Get the points on either sides of the line
|
||||
// with a distance of epsilon to the mid point
|
||||
$pointA['x'] = $x2 + ($epsilon * ($y1 - $y0)) / $denominator;
|
||||
$pointA['y'] = $y2 + ($pointA['x'] - $x2) * ($x0 - $x1) / ($y1 - $y0);
|
||||
|
||||
$pointB['x'] = $x2 + ($epsilon * ($y1 - $y0)) / (0 - $denominator);
|
||||
$pointB['y'] = $y2 + ($pointB['x'] - $x2) * ($x0 - $x1) / ($y1 - $y0);
|
||||
|
||||
// One of the points should be inside the polygon,
|
||||
// unless epcilon chosen is too large
|
||||
if (PMA_GIS_Polygon::isPointInsidePolygon($pointA, $ring)) {
|
||||
return $pointA;
|
||||
} elseif (PMA_GIS_Polygon::isPointInsidePolygon($pointB, $ring)) {
|
||||
return $pointB;
|
||||
} else {
|
||||
//If both are outside the polygon reduce the epsilon and
|
||||
//recalculate the points(reduce exponentially for faster convergance)
|
||||
$epsilon = pow($epsilon, 2);
|
||||
if ($epsilon == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** Generate parameters for the GIS data editor from the value of the GIS column.
|
||||
*
|
||||
* @param string $value of the GIS column
|
||||
* @param index $index of the geometry
|
||||
*
|
||||
* @return parameters for the GIS data editor from the value of the GIS column
|
||||
*/
|
||||
public function generateParams($value, $index = -1)
|
||||
{
|
||||
if ($index == -1) {
|
||||
$index = 0;
|
||||
$params = array();
|
||||
$data = PMA_GIS_Geometry::generateParams($value);
|
||||
$params['srid'] = $data['srid'];
|
||||
$wkt = $data['wkt'];
|
||||
} else {
|
||||
$params[$index]['gis_type'] = 'POLYGON';
|
||||
$wkt = $value;
|
||||
}
|
||||
|
||||
// Trim to remove leading 'POLYGON((' and trailing '))'
|
||||
$polygon = substr($wkt, 9, (strlen($wkt) - 11));
|
||||
// Seperate each linestring
|
||||
$linerings = explode("),(", $polygon);
|
||||
$params[$index]['POLYGON']['no_of_lines'] = count($linerings);
|
||||
|
||||
$j = 0;
|
||||
foreach ($linerings as $linering) {
|
||||
$points_arr = $this->extractPoints($linering, null);
|
||||
$no_of_points = count($points_arr);
|
||||
$params[$index]['POLYGON'][$j]['no_of_points'] = $no_of_points;
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$params[$index]['POLYGON'][$j][$i]['x'] = $points_arr[$i][0];
|
||||
$params[$index]['POLYGON'][$j][$i]['y'] = $points_arr[$i][1];
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -18,15 +18,14 @@ class PMA_GIS_Visualization
|
||||
|
||||
// Array of colors to be used for GIS visualizations.
|
||||
'colors' => array(
|
||||
'#BCE02E',
|
||||
'#B02EE0',
|
||||
'#E0642E',
|
||||
'#E0D62E',
|
||||
'#2E97E0',
|
||||
'#B02EE0',
|
||||
'#BCE02E',
|
||||
'#E02E75',
|
||||
'#5CE02E',
|
||||
'#E0B02E',
|
||||
'#000000',
|
||||
'#0022E0',
|
||||
'#726CB1',
|
||||
'#481A36',
|
||||
@ -153,7 +152,7 @@ class PMA_GIS_Visualization
|
||||
$output .= '<g id="groupPanel">';
|
||||
|
||||
$scale_data = $this->_scaleDataSet($this->_data);
|
||||
$output .= $this->_prepareDataSet($this->_data, 0, $scale_data, 'svg', '');
|
||||
$output .= $this->_prepareDataSet($this->_data, $scale_data, 'svg', '');
|
||||
|
||||
$output .= '</g>';
|
||||
$output .= '</svg>';
|
||||
@ -206,7 +205,7 @@ class PMA_GIS_Visualization
|
||||
);
|
||||
|
||||
$scale_data = $this->_scaleDataSet($this->_data);
|
||||
$image = $this->_prepareDataSet($this->_data, 0, $scale_data, 'png', $image);
|
||||
$image = $this->_prepareDataSet($this->_data, $scale_data, 'png', $image);
|
||||
|
||||
return $image;
|
||||
}
|
||||
@ -256,7 +255,33 @@ class PMA_GIS_Visualization
|
||||
{
|
||||
$this->init();
|
||||
$scale_data = $this->_scaleDataSet($this->_data);
|
||||
$output = $this->_prepareDataSet($this->_data, 0, $scale_data, 'ol', '');
|
||||
$output =
|
||||
'var options = {'
|
||||
. 'projection: new OpenLayers.Projection("EPSG:900913"),'
|
||||
. 'displayProjection: new OpenLayers.Projection("EPSG:4326"),'
|
||||
. 'units: "m",'
|
||||
. 'numZoomLevels: 18,'
|
||||
. 'maxResolution: 156543.0339,'
|
||||
. 'maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508),'
|
||||
. 'restrictedExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508)'
|
||||
. '};'
|
||||
. 'var map = new OpenLayers.Map("openlayersmap", options);'
|
||||
. 'var layerNone = new OpenLayers.Layer.Boxes("None", {isBaseLayer: true});'
|
||||
. 'var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");'
|
||||
. 'var layerOsmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender");'
|
||||
. 'var layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap");'
|
||||
. 'map.addLayers([layerMapnik, layerOsmarender, layerCycleMap, layerNone]);'
|
||||
. 'var vectorLayer = new OpenLayers.Layer.Vector("Data");'
|
||||
. 'var bound;';
|
||||
$output .= $this->_prepareDataSet($this->_data, $scale_data, 'ol', '');
|
||||
$output .=
|
||||
'map.addLayer(vectorLayer);'
|
||||
. 'map.zoomToExtent(bound);'
|
||||
. 'if (map.getZoom() < 2) {'
|
||||
. 'map.zoomTo(2);'
|
||||
. '}'
|
||||
. 'map.addControl(new OpenLayers.Control.LayerSwitcher());'
|
||||
. 'map.addControl(new OpenLayers.Control.MousePosition());';
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -274,7 +299,7 @@ class PMA_GIS_Visualization
|
||||
include_once './libraries/tcpdf/tcpdf.php';
|
||||
|
||||
// create pdf
|
||||
$pdf = new TCPDF('', 'pt', 'A4', true, 'UTF-8', false);
|
||||
$pdf = new TCPDF('', 'pt', $GLOBALS['cfg']['PDFDefaultPageSize'], true, 'UTF-8', false);
|
||||
|
||||
// disable header and footer
|
||||
$pdf->setPrintHeader(false);
|
||||
@ -287,7 +312,7 @@ class PMA_GIS_Visualization
|
||||
$pdf->AddPage();
|
||||
|
||||
$scale_data = $this->_scaleDataSet($this->_data);
|
||||
$pdf = $this->_prepareDataSet($this->_data, 0, $scale_data, 'pdf', $pdf);
|
||||
$pdf = $this->_prepareDataSet($this->_data, $scale_data, 'pdf', $pdf);
|
||||
|
||||
// sanitize file name
|
||||
$file_name = $this->_sanitizeName($file_name, 'pdf');
|
||||
@ -319,6 +344,9 @@ class PMA_GIS_Visualization
|
||||
$type = substr($ref_data, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$scale_data = $gis_obj->scaleRow($row[$this->_settings['spatialColumn']]);
|
||||
|
||||
// Upadate minimum/maximum values for x and y cordinates.
|
||||
@ -377,19 +405,19 @@ class PMA_GIS_Visualization
|
||||
/**
|
||||
* Prepares and return the dataset as needed by the visualization.
|
||||
*
|
||||
* @param array $data Raw data
|
||||
* @param int $color_number Start index to the color array
|
||||
* @param array $scale_data Data related to scaling
|
||||
* @param string $format Format of the visulaization
|
||||
* @param image $results Image object in the case of png
|
||||
* @param array $data Raw data
|
||||
* @param array $scale_data Data related to scaling
|
||||
* @param string $format Format of the visulaization
|
||||
* @param image $results Image object in the case of png
|
||||
*
|
||||
* @return the formatted array of data.
|
||||
*/
|
||||
private function _prepareDataSet($data, $color_number, $scale_data, $format, $results)
|
||||
private function _prepareDataSet($data, $scale_data, $format, $results)
|
||||
{
|
||||
$color_number = 0;
|
||||
|
||||
// loop through the rows
|
||||
foreach ($data as $row) {
|
||||
|
||||
$index = $color_number % sizeof($this->_settings['colors']);
|
||||
|
||||
// Figure out the data type
|
||||
@ -398,6 +426,9 @@ class PMA_GIS_Visualization
|
||||
$type = substr($ref_data, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
if (! $gis_obj) {
|
||||
continue;
|
||||
}
|
||||
$label = '';
|
||||
if (isset($this->_settings['labelColumn'])
|
||||
&& isset($row[$this->_settings['labelColumn']])
|
||||
@ -432,4 +463,3 @@ class PMA_GIS_Visualization
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @return the modified sql query.
|
||||
*/
|
||||
function PMA_GIS_modify_query($sql_query, $visualizationSettings)
|
||||
function PMA_GIS_modifyQuery($sql_query, $visualizationSettings)
|
||||
{
|
||||
$modified_query = 'SELECT ';
|
||||
|
||||
@ -75,7 +75,9 @@ function PMA_GIS_modify_query($sql_query, $visualizationSettings)
|
||||
// If select cluase is *
|
||||
} else {
|
||||
// If label column is chosen add it to the query
|
||||
if ($visualizationSettings['labelColumn'] != '') {
|
||||
if (isset($visualizationSettings['labelColumn'])
|
||||
&& $visualizationSettings['labelColumn'] != ''
|
||||
) {
|
||||
$modified_query .= '`' . $visualizationSettings['labelColumn'] .'`, ';
|
||||
}
|
||||
|
||||
@ -84,7 +86,8 @@ function PMA_GIS_modify_query($sql_query, $visualizationSettings)
|
||||
. '`) AS `' . $visualizationSettings['spatialColumn'] . '`, ';
|
||||
|
||||
// Get the SRID
|
||||
$modified_query .= 'SRID(`' . $visualizationSettings['spatialColumn'] . '`) AS `srid` ';
|
||||
$modified_query .= 'SRID(`' . $visualizationSettings['spatialColumn']
|
||||
. '`) AS `srid` ';
|
||||
}
|
||||
|
||||
// Append the rest of the query
|
||||
@ -98,14 +101,16 @@ function PMA_GIS_modify_query($sql_query, $visualizationSettings)
|
||||
function sanitize($select)
|
||||
{
|
||||
$table_col = $select['table_name'] . "." . $select['column'];
|
||||
$db_table_col = $select['db'] . "." . $select['table_name'] . "." . $select['column'];
|
||||
$db_table_col = $select['db'] . "." . $select['table_name']
|
||||
. "." . $select['column'];
|
||||
|
||||
if ($select['expr'] == $select['column']) {
|
||||
return "`" . $select['column'] . "`";
|
||||
} elseif ($select['expr'] == $table_col) {
|
||||
return "`" . $select['table_name'] . "`.`" . $select['column'] . "`";
|
||||
} elseif ($select['expr'] == $db_table_col) {
|
||||
return "`" . $select['db'] . "`.`" . $select['table_name'] . "`.`" . $select['column'] . "`";
|
||||
return "`" . $select['db'] . "`.`" . $select['table_name']
|
||||
. "`.`" . $select['column'] . "`";
|
||||
}
|
||||
return $select['expr'];
|
||||
}
|
||||
@ -119,7 +124,7 @@ function sanitize($select)
|
||||
*
|
||||
* @return string HTML and JS code for the GIS visualization
|
||||
*/
|
||||
function PMA_GIS_visualization_results($data, &$visualizationSettings, $format)
|
||||
function PMA_GIS_visualizationResults($data, &$visualizationSettings, $format)
|
||||
{
|
||||
include_once './libraries/gis/pma_gis_visualization.php';
|
||||
include_once './libraries/gis/pma_gis_factory.php';
|
||||
@ -156,7 +161,7 @@ function PMA_GIS_visualization_results($data, &$visualizationSettings, $format)
|
||||
*
|
||||
* @return file File containing the visualization
|
||||
*/
|
||||
function PMA_GIS_save_to_file($data, $visualizationSettings, $format, $fileName)
|
||||
function PMA_GIS_saveToFile($data, $visualizationSettings, $format, $fileName)
|
||||
{
|
||||
include_once './libraries/gis/pma_gis_visualization.php';
|
||||
include_once './libraries/gis/pma_gis_factory.php';
|
||||
|
||||
@ -16,8 +16,9 @@ if (! defined('PHPMYADMIN')) {
|
||||
* copy values from one array to another, usually from a superglobal into $GLOBALS
|
||||
*
|
||||
* @param array $array values from
|
||||
* @param array $target values to
|
||||
* @param boolean $sanitize prevent importing key names in $_import_blacklist
|
||||
* @param array &$target values to
|
||||
* @param bool $sanitize prevent importing key names in $_import_blacklist
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_recursive_extract($array, &$target, $sanitize = true)
|
||||
{
|
||||
|
||||
@ -97,16 +97,21 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
$sql_query .= $import_run_buffer['full'];
|
||||
}
|
||||
if (!$cfg['AllowUserDropDatabase']
|
||||
&& !$is_superuser
|
||||
&& preg_match('@^[[:space:]]*DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE @i', $import_run_buffer['sql'])) {
|
||||
&& !$is_superuser
|
||||
&& preg_match('@^[[:space:]]*DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE @i', $import_run_buffer['sql'])
|
||||
) {
|
||||
$GLOBALS['message'] = PMA_Message::error(__('"DROP DATABASE" statements are disabled.'));
|
||||
$error = true;
|
||||
} else {
|
||||
$executed_queries++;
|
||||
if ($run_query && $GLOBALS['finished'] && empty($sql) && !$error && (
|
||||
(!empty($import_run_buffer['sql']) && preg_match('/^[\s]*(SELECT|SHOW|HANDLER)/i', $import_run_buffer['sql'])) ||
|
||||
($executed_queries == 1)
|
||||
)) {
|
||||
if ($run_query
|
||||
&& $GLOBALS['finished']
|
||||
&& empty($sql)
|
||||
&& !$error
|
||||
&& ((!empty($import_run_buffer['sql'])
|
||||
&& preg_match('/^[\s]*(SELECT|SHOW|HANDLER)/i', $import_run_buffer['sql']))
|
||||
|| ($executed_queries == 1))
|
||||
) {
|
||||
$go_sql = true;
|
||||
if (!$sql_query_disabled) {
|
||||
$complete_query = $sql_query;
|
||||
@ -161,13 +166,15 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload);
|
||||
}
|
||||
|
||||
if ($result != false && preg_match('@^[\s]*(DROP|CREATE)[\s]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im', $import_run_buffer['sql'])) {
|
||||
if ($result != false
|
||||
&& preg_match('@^[\s]*(DROP|CREATE)[\s]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im', $import_run_buffer['sql'])
|
||||
) {
|
||||
$reload = true;
|
||||
}
|
||||
} // end run query
|
||||
} // end if not DROP DATABASE
|
||||
} // end non empty query
|
||||
elseif (!empty($import_run_buffer['full'])) {
|
||||
// end non empty query
|
||||
} elseif (!empty($import_run_buffer['full'])) {
|
||||
if ($go_sql) {
|
||||
$complete_query .= $import_run_buffer['full'];
|
||||
$display_query .= $import_run_buffer['full'];
|
||||
@ -418,6 +425,7 @@ define("VARCHAR", 1);
|
||||
define("INT", 2);
|
||||
define("DECIMAL", 3);
|
||||
define("BIGINT", 4);
|
||||
define("GEOMETRY", 5);
|
||||
|
||||
/* Decimal size defs */
|
||||
define("M", 0);
|
||||
@ -430,8 +438,9 @@ define("COL_NAMES", 1);
|
||||
define("ROWS", 2);
|
||||
|
||||
/* Analysis array defs */
|
||||
define("TYPES", 0);
|
||||
define("SIZES", 1);
|
||||
define("TYPES", 0);
|
||||
define("SIZES", 1);
|
||||
define("FORMATTEDSQL", 2);
|
||||
|
||||
/**
|
||||
* Obtains the precision (total # of digits) from a size of type decimal
|
||||
@ -909,7 +918,7 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
}
|
||||
|
||||
if ($analyses != null) {
|
||||
$type_array = array(NONE => "NULL", VARCHAR => "varchar", INT => "int", DECIMAL => "decimal", BIGINT => "bigint");
|
||||
$type_array = array(NONE => "NULL", VARCHAR => "varchar", INT => "int", DECIMAL => "decimal", BIGINT => "bigint", GEOMETRY => 'geometry');
|
||||
|
||||
/* TODO: Do more checking here to make sure they really are matched */
|
||||
if (count($tables) != count($analyses)) {
|
||||
@ -928,7 +937,10 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
$size = 10;
|
||||
}
|
||||
|
||||
$tempSQLStr .= PMA_backquote($tables[$i][COL_NAMES][$j]) . " " . $type_array[$analyses[$i][TYPES][$j]] . "(" . $size . ")";
|
||||
$tempSQLStr .= PMA_backquote($tables[$i][COL_NAMES][$j]) . " " . $type_array[$analyses[$i][TYPES][$j]];
|
||||
if ($analyses[$i][TYPES][$j] != GEOMETRY) {
|
||||
$tempSQLStr .= "(" . $size . ")";
|
||||
}
|
||||
|
||||
if ($j != (count($tables[$i][COL_NAMES]) - 1)) {
|
||||
$tempSQLStr .= ", ";
|
||||
@ -973,20 +985,28 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
$tempSQLStr .= "(";
|
||||
|
||||
for ($k = 0; $k < $num_cols; ++$k) {
|
||||
if ($analyses != null) {
|
||||
$is_varchar = ($analyses[$i][TYPES][$col_count] === VARCHAR);
|
||||
// If fully formatted SQL, no need to enclose with aphostrophes, add shalshes etc.
|
||||
if ($analyses != null
|
||||
&& isset($analyses[$i][FORMATTEDSQL][$col_count])
|
||||
&& $analyses[$i][FORMATTEDSQL][$col_count] == true
|
||||
) {
|
||||
$tempSQLStr .= (string) $tables[$i][ROWS][$j][$k];
|
||||
} else {
|
||||
$is_varchar = !is_numeric($tables[$i][ROWS][$j][$k]);
|
||||
}
|
||||
if ($analyses != null) {
|
||||
$is_varchar = ($analyses[$i][TYPES][$col_count] === VARCHAR);
|
||||
} else {
|
||||
$is_varchar = !is_numeric($tables[$i][ROWS][$j][$k]);
|
||||
}
|
||||
|
||||
/* Don't put quotes around NULL fields */
|
||||
if (! strcmp($tables[$i][ROWS][$j][$k], 'NULL')) {
|
||||
$is_varchar = false;
|
||||
}
|
||||
/* Don't put quotes around NULL fields */
|
||||
if (! strcmp($tables[$i][ROWS][$j][$k], 'NULL')) {
|
||||
$is_varchar = false;
|
||||
}
|
||||
|
||||
$tempSQLStr .= (($is_varchar) ? "'" : "");
|
||||
$tempSQLStr .= PMA_sqlAddSlashes((string)$tables[$i][ROWS][$j][$k]);
|
||||
$tempSQLStr .= (($is_varchar) ? "'" : "");
|
||||
$tempSQLStr .= (($is_varchar) ? "'" : "");
|
||||
$tempSQLStr .= PMA_sqlAddSlashes((string)$tables[$i][ROWS][$j][$k]);
|
||||
$tempSQLStr .= (($is_varchar) ? "'" : "");
|
||||
}
|
||||
|
||||
if ($k != ($num_cols - 1)) {
|
||||
$tempSQLStr .= ", ";
|
||||
|
||||
@ -66,7 +66,7 @@ if ($data === true && !$error && !$timeout_passed) {
|
||||
$qry = '
|
||||
INSERT INTO
|
||||
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
|
||||
(db_name, table_name, column_name, ' . PMA_backquote('comment') . ')
|
||||
(db_name, table_name, column_name, comment)
|
||||
VALUES (
|
||||
\'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\',
|
||||
\'' . PMA_sqlAddSlashes(trim($tab)) . '\',
|
||||
|
||||
421
libraries/import/shp.php
Normal file
421
libraries/import/shp.php
Normal file
@ -0,0 +1,421 @@
|
||||
<?php
|
||||
/**
|
||||
* ESRI Shape file import plugin for phpMyAdmin
|
||||
*
|
||||
* @package phpMyAdmin-Import
|
||||
* @subpackage ESRI_Shape
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$plugin_list['shp'] = array(
|
||||
'text' => __('ESRI Shape File'),
|
||||
'extension' => 'shp',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options'),
|
||||
);
|
||||
} else {
|
||||
|
||||
if ((int) ini_get('memory_limit') < 512) {
|
||||
@ini_set('memory_limit', '512M');
|
||||
}
|
||||
@set_time_limit(300);
|
||||
|
||||
|
||||
// Append the bfShapeFiles directory to the include path variable
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/bfShapeFiles/');
|
||||
include_once './libraries/bfShapeFiles/ShapeFile.lib.php';
|
||||
|
||||
$GLOBALS['finished'] = false;
|
||||
$buffer = '';
|
||||
$eof = false;
|
||||
|
||||
// Returns specified number of bytes from the buffer.
|
||||
// Buffer automatically fetches next chunk of data when the buffer falls short.
|
||||
// Sets $eof when $GLOBALS['finished'] is set and the buffer falls short.
|
||||
function readFromBuffer($length){
|
||||
global $buffer, $eof;
|
||||
|
||||
if (strlen($buffer) < $length) {
|
||||
if ($GLOBALS['finished']) {
|
||||
$eof = true;
|
||||
} else {
|
||||
$buffer .= PMA_importGetNextChunk();
|
||||
}
|
||||
}
|
||||
$result = substr($buffer, 0, $length);
|
||||
$buffer = substr($buffer, $length);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class extends ShapeFile class to cater the following phpMyAdmin
|
||||
* specific requirements.
|
||||
* 1) To load data from .dbf file only when the dBase extension is available.
|
||||
* 2) To use PMA_importGetNextChunk() functionality to read data, rather than
|
||||
* reading directly from a file. Using readFromBuffer() in place of fread().
|
||||
* This makes it possible to use compressions.
|
||||
*/
|
||||
class PMA_ShapeFile extends ShapeFile {
|
||||
|
||||
function _isDbaseLoaded()
|
||||
{
|
||||
return extension_loaded('dbase');
|
||||
}
|
||||
|
||||
function loadFromFile($FileName)
|
||||
{
|
||||
$this->_loadHeaders();
|
||||
$this->_loadRecords();
|
||||
if ($this->_isDbaseLoaded()) {
|
||||
$this->_closeDBFFile();
|
||||
}
|
||||
}
|
||||
|
||||
function _loadHeaders()
|
||||
{
|
||||
readFromBuffer(24);
|
||||
$this->fileLength = loadData("N", readFromBuffer(4));
|
||||
|
||||
readFromBuffer(4);
|
||||
$this->shapeType = loadData("V", readFromBuffer(4));
|
||||
|
||||
$this->boundingBox = array();
|
||||
$this->boundingBox["xmin"] = loadData("d", readFromBuffer(8));
|
||||
$this->boundingBox["ymin"] = loadData("d", readFromBuffer(8));
|
||||
$this->boundingBox["xmax"] = loadData("d", readFromBuffer(8));
|
||||
$this->boundingBox["ymax"] = loadData("d", readFromBuffer(8));
|
||||
|
||||
if ($this->_isDbaseLoaded() && $this->_openDBFFile()) {
|
||||
$this->DBFHeader = $this->_loadDBFHeader();
|
||||
}
|
||||
}
|
||||
|
||||
function _loadRecords()
|
||||
{
|
||||
global $eof;
|
||||
readFromBuffer(32);
|
||||
while (true) {
|
||||
$record = new PMA_ShapeRecord(-1);
|
||||
$record->loadFromFile($this->SHPFile, $this->DBFFile);
|
||||
if ($record->lastError != "") {
|
||||
return false;
|
||||
}
|
||||
if ($eof) {
|
||||
break;
|
||||
}
|
||||
|
||||
$this->records[] = $record;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class extends ShapeRecord class to cater the following phpMyAdmin
|
||||
* specific requirements.
|
||||
* 1) To load data from .dbf file only when the dBase extension is available.
|
||||
* 2) To use PMA_importGetNextChunk() functionality to read data, rather than
|
||||
* reading directly from a file. Using readFromBuffer() in place of fread().
|
||||
* This makes it possible to use compressions.
|
||||
*/
|
||||
class PMA_ShapeRecord extends ShapeRecord
|
||||
{
|
||||
function loadFromFile(&$SHPFile, &$DBFFile)
|
||||
{
|
||||
$this->DBFFile = $DBFFile;
|
||||
$this->_loadHeaders();
|
||||
|
||||
switch ($this->shapeType) {
|
||||
case 0:
|
||||
$this->_loadNullRecord();
|
||||
break;
|
||||
case 1:
|
||||
$this->_loadPointRecord();
|
||||
break;
|
||||
case 3:
|
||||
$this->_loadPolyLineRecord();
|
||||
break;
|
||||
case 5:
|
||||
$this->_loadPolygonRecord();
|
||||
break;
|
||||
case 8:
|
||||
$this->_loadMultiPointRecord();
|
||||
break;
|
||||
default:
|
||||
$this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType));
|
||||
break;
|
||||
}
|
||||
if (extension_loaded('dbase') && isset($this->DBFFile)) {
|
||||
$this->_loadDBFData();
|
||||
}
|
||||
}
|
||||
|
||||
function _loadHeaders()
|
||||
{
|
||||
$this->recordNumber = loadData("N", readFromBuffer(4));
|
||||
//We read the length of the record
|
||||
$tmp = loadData("N", readFromBuffer(4));
|
||||
$this->shapeType = loadData("V", readFromBuffer(4));
|
||||
}
|
||||
|
||||
function _loadPoint()
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$data["x"] = loadData("d", readFromBuffer(8));
|
||||
$data["y"] = loadData("d", readFromBuffer(8));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function _loadMultiPointRecord()
|
||||
{
|
||||
$this->SHPData = array();
|
||||
$this->SHPData["xmin"] = loadData("d", readFromBuffer(8));
|
||||
$this->SHPData["ymin"] = loadData("d", readFromBuffer(8));
|
||||
$this->SHPData["xmax"] = loadData("d", readFromBuffer(8));
|
||||
$this->SHPData["ymax"] = loadData("d", readFromBuffer(8));
|
||||
|
||||
$this->SHPData["numpoints"] = loadData("V", readFromBuffer(4));
|
||||
|
||||
for ($i = 0; $i <= $this->SHPData["numpoints"]; $i++) {
|
||||
$this->SHPData["points"][] = $this->_loadPoint();
|
||||
}
|
||||
}
|
||||
|
||||
function _loadPolyLineRecord()
|
||||
{
|
||||
$this->SHPData = array();
|
||||
$this->SHPData["xmin"] = loadData("d", readFromBuffer(8));
|
||||
$this->SHPData["ymin"] = loadData("d", readFromBuffer(8));
|
||||
$this->SHPData["xmax"] = loadData("d", readFromBuffer(8));
|
||||
$this->SHPData["ymax"] = loadData("d", readFromBuffer(8));
|
||||
|
||||
$this->SHPData["numparts"] = loadData("V", readFromBuffer(4));
|
||||
$this->SHPData["numpoints"] = loadData("V", readFromBuffer(4));
|
||||
|
||||
for ($i = 0; $i < $this->SHPData["numparts"]; $i++) {
|
||||
$this->SHPData["parts"][$i] = loadData("V", readFromBuffer(4));
|
||||
}
|
||||
|
||||
$readPoints = 0;
|
||||
reset($this->SHPData["parts"]);
|
||||
while (list($partIndex, $partData) = each($this->SHPData["parts"])) {
|
||||
if (! isset($this->SHPData["parts"][$partIndex]["points"])
|
||||
|| !is_array($this->SHPData["parts"][$partIndex]["points"])
|
||||
) {
|
||||
$this->SHPData["parts"][$partIndex] = array();
|
||||
$this->SHPData["parts"][$partIndex]["points"] = array();
|
||||
}
|
||||
while (! in_array($readPoints, $this->SHPData["parts"])
|
||||
&& ($readPoints < ($this->SHPData["numpoints"]))
|
||||
) {
|
||||
$this->SHPData["parts"][$partIndex]["points"][] = $this->_loadPoint();
|
||||
$readPoints++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$shp = new PMA_ShapeFile(1);
|
||||
// If the zip archive has more than one file,
|
||||
// get the correct content to the buffer from .shp file.
|
||||
if ($compression == 'application/zip' && PMA_getNoOfFilesInZip($import_file) > 1) {
|
||||
$zip_content = PMA_getZipContents($import_file, '/^.*\.shp$/i');
|
||||
$GLOBALS['import_text'] = $zip_content['data'];
|
||||
}
|
||||
|
||||
$temp_dbf_file = false;
|
||||
// We need dbase extension to handle .dbf file
|
||||
if (extension_loaded('dbase')) {
|
||||
// If we can extract the zip archive to 'TempDir'
|
||||
// and use the files in it for import
|
||||
if ($compression == 'application/zip'
|
||||
&& ! empty($cfg['TempDir'])
|
||||
&& is_writable($cfg['TempDir'])
|
||||
) {
|
||||
$dbf_file_name = PMA_findFileFromZipArchive('/^.*\.dbf$/i', $import_file);
|
||||
// If the corresponding .dbf file is in the zip archive
|
||||
if ($dbf_file_name) {
|
||||
// Extract the .dbf file and point to it.
|
||||
$extracted = PMA_zipExtract(
|
||||
$import_file,
|
||||
realpath($cfg['TempDir']),
|
||||
array($dbf_file_name)
|
||||
);
|
||||
if ($extracted) {
|
||||
$dbf_file_path = realpath($cfg['TempDir'])
|
||||
. (PMA_IS_WINDOWS ? '\\' : '/') . $dbf_file_name;
|
||||
$temp_dbf_file = true;
|
||||
// Replace the .dbf with .*, as required by the bsShapeFiles library.
|
||||
$file_name = substr($dbf_file_path, 0, strlen($dbf_file_path) - 4) . '.*';
|
||||
$shp->FileName = $file_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If file is in UploadDir, use .dbf file in the same UploadDir
|
||||
// to load extra data.
|
||||
elseif (! empty($local_import_file)
|
||||
&& ! empty($cfg['UploadDir'])
|
||||
&& $compression == 'none'
|
||||
) {
|
||||
// Replace the .shp with .*,
|
||||
// so the bsShapeFiles library correctly locates .dbf file.
|
||||
$file_name = substr($import_file, 0, strlen($import_file) - 4) . '.*';
|
||||
$shp->FileName = $file_name;
|
||||
}
|
||||
}
|
||||
|
||||
// Load data
|
||||
$shp->loadFromFile('');
|
||||
if ($shp->lastError != "") {
|
||||
$error = true;
|
||||
$message = PMA_Message::error(__('There was an error importing the ESRI shape file: "%s".'));
|
||||
$message->addParam($shp->lastError);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete the .dbf file extracted to 'TempDir'
|
||||
if ($temp_dbf_file) {
|
||||
unlink($dbf_file_path);
|
||||
}
|
||||
|
||||
$esri_types = array(
|
||||
0 => 'Null Shape',
|
||||
1 => 'Point',
|
||||
3 => 'PolyLine',
|
||||
5 => 'Polygon',
|
||||
8 => 'MultiPoint',
|
||||
11 => 'PointZ',
|
||||
13 => 'PolyLineZ',
|
||||
15 => 'PolygonZ',
|
||||
18 => 'MultiPointZ',
|
||||
21 => 'PointM',
|
||||
23 => 'PolyLineM',
|
||||
25 => 'PolygonM',
|
||||
28 => 'MultiPointM',
|
||||
31 => 'MultiPatch',
|
||||
);
|
||||
|
||||
include_once './libraries/gis/pma_gis_geometry.php';
|
||||
switch ($shp->shapeType) {
|
||||
// ESRI Null Shape
|
||||
case 0:
|
||||
$gis_obj = null;
|
||||
break;
|
||||
// ESRI Point
|
||||
case 1:
|
||||
include_once './libraries/gis/pma_gis_point.php';
|
||||
$gis_obj = PMA_GIS_Point::singleton();
|
||||
break;
|
||||
// ESRI PolyLine
|
||||
case 3:
|
||||
include_once './libraries/gis/pma_gis_multilinestring.php';
|
||||
$gis_obj = PMA_GIS_Multilinestring::singleton();
|
||||
break;
|
||||
// ESRI Polygon
|
||||
case 5:
|
||||
include_once './libraries/gis/pma_gis_multipolygon.php';
|
||||
$gis_obj = PMA_GIS_Multipolygon::singleton();
|
||||
break;
|
||||
// ESRI MultiPoint
|
||||
case 8:
|
||||
include_once './libraries/gis/pma_gis_multipoint.php';
|
||||
$gis_obj = PMA_GIS_Multipoint::singleton();
|
||||
break;
|
||||
default:
|
||||
$error = true;
|
||||
if (! isset($esri_types[$shp->shapeType])) {
|
||||
$message = PMA_Message::error(__('You tried to import an invalid file or the imported file contains invalid data'));
|
||||
} else {
|
||||
$message = PMA_Message::error(__('MySQL Spatial Extension does not support ESRI type "%s".'));
|
||||
$message->addParam($param);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$num_rows = count($shp->records);
|
||||
// If .dbf file is loaded, the number of extra data columns
|
||||
$num_data_cols = isset($shp->DBFHeader) ? count($shp->DBFHeader) : 0;
|
||||
|
||||
$rows = array();
|
||||
$col_names = array();
|
||||
if ($num_rows != 0) {
|
||||
foreach ($shp->records as $record) {
|
||||
$tempRow = array();
|
||||
if ($gis_obj == null) {
|
||||
$tempRow[] = null;
|
||||
} else {
|
||||
$tempRow[] = "GeomFromText('" . $gis_obj->getShape($record->SHPData) . "')";
|
||||
}
|
||||
|
||||
if (isset($shp->DBFHeader)) {
|
||||
foreach ($shp->DBFHeader as $c) {
|
||||
$cell = trim($record->DBFData[$c[0]]);
|
||||
|
||||
if (! strcmp($cell, '')) {
|
||||
$cell = 'NULL';
|
||||
}
|
||||
|
||||
$tempRow[] = $cell;
|
||||
}
|
||||
}
|
||||
$rows[] = $tempRow;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$error = true;
|
||||
$message = PMA_Message::error(__('The imported file does not contain any data'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Column names for spatial column and the rest of the columns,
|
||||
// if they are available
|
||||
$col_names[] = 'SPATIAL';
|
||||
for ($n = 0; $n < $num_data_cols; $n++) {
|
||||
$col_names[] = $shp->DBFHeader[$n][0];
|
||||
}
|
||||
|
||||
// Set table name based on the number of tables
|
||||
if (strlen($db)) {
|
||||
$result = PMA_DBI_fetch_result('SHOW TABLES');
|
||||
$table_name = 'TABLE '.(count($result) + 1);
|
||||
} else {
|
||||
$table_name = 'TBL_NAME';
|
||||
}
|
||||
$tables = array(array($table_name, $col_names, $rows));
|
||||
|
||||
// Use data from shape file to chose best-fit MySQL types for each column
|
||||
$analyses = array();
|
||||
$analyses[] = PMA_analyzeTable($tables[0]);
|
||||
|
||||
$table_no = 0; $spatial_col = 0;
|
||||
$analyses[$table_no][TYPES][$spatial_col] = GEOMETRY;
|
||||
$analyses[$table_no][FORMATTEDSQL][$spatial_col] = true;
|
||||
|
||||
// Set database name to the currently selected one, if applicable
|
||||
if (strlen($db)) {
|
||||
$db_name = $db;
|
||||
$options = array('create_db' => false);
|
||||
} else {
|
||||
$db_name = 'SHP_DB';
|
||||
$options = null;
|
||||
}
|
||||
|
||||
// Created and execute necessary SQL statements from data
|
||||
$null_param = null;
|
||||
PMA_buildSQL($db_name, $tables, $analyses, $null_param, $options);
|
||||
|
||||
unset($tables);
|
||||
unset($analyses);
|
||||
|
||||
$finished = true;
|
||||
$error = false;
|
||||
|
||||
// Commit any possible data in buffers
|
||||
PMA_importRunQuery();
|
||||
}
|
||||
?>
|
||||
@ -15,6 +15,9 @@ $ID_KEY = 'APC_UPLOAD_PROGRESS';
|
||||
* Returns upload status.
|
||||
*
|
||||
* This is implementation for APC extension.
|
||||
*
|
||||
* @param string $id
|
||||
* @return array|null
|
||||
*/
|
||||
function PMA_getUploadStatus($id)
|
||||
{
|
||||
@ -22,7 +25,7 @@ function PMA_getUploadStatus($id)
|
||||
global $ID_KEY;
|
||||
|
||||
if (trim($id) == "") {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
|
||||
$_SESSION[$SESSION_KEY][$id] = array(
|
||||
|
||||
@ -15,6 +15,9 @@ $ID_KEY = 'noplugin';
|
||||
* Returns upload status.
|
||||
*
|
||||
* This is implementation when no webserver support exists, so it returns just zeroes.
|
||||
*
|
||||
* @param string $id
|
||||
* @return array|null
|
||||
*/
|
||||
function PMA_getUploadStatus($id)
|
||||
{
|
||||
@ -22,7 +25,7 @@ function PMA_getUploadStatus($id)
|
||||
global $ID_KEY;
|
||||
|
||||
if (trim($id) == "") {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
|
||||
$_SESSION[$SESSION_KEY][$id] = array(
|
||||
|
||||
@ -14,6 +14,9 @@ $ID_KEY = "UPLOAD_IDENTIFIER";
|
||||
* Returns upload status.
|
||||
*
|
||||
* This is implementation for uploadprogress extension.
|
||||
*
|
||||
* @param string $id
|
||||
* @return array|null
|
||||
*/
|
||||
function PMA_getUploadStatus($id)
|
||||
{
|
||||
@ -21,7 +24,7 @@ function PMA_getUploadStatus($id)
|
||||
global $ID_KEY;
|
||||
|
||||
if (trim($id) == "") {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
|
||||
|
||||
@ -56,25 +56,64 @@ function PMA_escapeJsString($string)
|
||||
"\r" => '\r')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a value for javascript code.
|
||||
*
|
||||
* @param string $value String to be formatted.
|
||||
*
|
||||
* @retrun string formatted value.
|
||||
*/
|
||||
function PMA_formatJsVal($value)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
if ($value) {
|
||||
return 'true';
|
||||
} else {
|
||||
return 'false';
|
||||
}
|
||||
} elseif (is_int($value)) {
|
||||
return (int)$value;
|
||||
} else {
|
||||
return '"' . PMA_escapeJsString($value) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an javascript assignment with proper escaping of a value
|
||||
* and support for assigning array of strings.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
*
|
||||
* @return string Javascript code.
|
||||
*/
|
||||
function PMA_getJsValue($key, $value)
|
||||
{
|
||||
$result = $key . ' = ';
|
||||
if (is_array($value)) {
|
||||
$result .= '[';
|
||||
foreach ($value as $id => $val) {
|
||||
$result .= PMA_formatJsVal($value) . ",";
|
||||
}
|
||||
$result .= "];\n";
|
||||
} else {
|
||||
$result .= PMA_formatJsVal($value) . ";\n";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an javascript assignment with proper escaping of a value
|
||||
* and support for assigning array of strings.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function PMA_printJsValue($key, $value)
|
||||
{
|
||||
echo $key . ' = ';
|
||||
if (is_array($value)) {
|
||||
echo '[';
|
||||
foreach ($value as $id => $val) {
|
||||
echo "'" . PMA_escapeJsString($val) . "',";
|
||||
}
|
||||
echo "];\n";
|
||||
} else {
|
||||
echo "'" . PMA_escapeJsString($value) . "';\n";
|
||||
}
|
||||
echo PMA_getJsValue($key, $value);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
|
||||
/**
|
||||
* Tries to detect MIME type of content.
|
||||
*
|
||||
* @param string &$test
|
||||
* @return string
|
||||
*/
|
||||
function PMA_detectMIME(&$test)
|
||||
{
|
||||
|
||||
@ -1068,10 +1068,9 @@ function PMA_REL_renameField($db, $table, $field, $new_name)
|
||||
* @param string $newpage
|
||||
* @param array $cfgRelation
|
||||
* @param string $db
|
||||
* @param string $query_default_option
|
||||
* @return string $pdf_page_number
|
||||
*/
|
||||
function PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option)
|
||||
function PMA_REL_create_page($newpage, $cfgRelation, $db)
|
||||
{
|
||||
if (! isset($newpage) || $newpage == '') {
|
||||
$newpage = __('no description');
|
||||
@ -1079,7 +1078,7 @@ function PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option)
|
||||
$ins_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
|
||||
. ' (db_name, page_descr)'
|
||||
. ' VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($newpage) . '\')';
|
||||
PMA_query_as_controluser($ins_query, false, $query_default_option);
|
||||
PMA_query_as_controluser($ins_query, false);
|
||||
return PMA_DBI_insert_id(isset($GLOBALS['controllink']) ? $GLOBALS['controllink'] : '');
|
||||
}
|
||||
?>
|
||||
|
||||
@ -298,21 +298,14 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
|
||||
{
|
||||
$src_db = $trg_db = $db;
|
||||
|
||||
$src_connection = PMA_DBI_select_db($src_db, $src_link);
|
||||
$trg_connection = PMA_DBI_select_db($trg_db, $trg_link);
|
||||
|
||||
$src_tables = PMA_DBI_get_tables($src_db, $src_link);
|
||||
$source_tables_num = sizeof($src_tables);
|
||||
|
||||
$trg_tables = PMA_DBI_get_tables($trg_db, $trg_link);
|
||||
$target_tables_num = sizeof($trg_tables);
|
||||
|
||||
/**
|
||||
* initializing arrays to save table names
|
||||
*/
|
||||
$unmatched_num_src = 0;
|
||||
$source_tables_uncommon = array();
|
||||
$unmatched_num_trg = 0;
|
||||
$target_tables_uncommon = array();
|
||||
$matching_tables = array();
|
||||
$matching_tables_num = 0;
|
||||
@ -367,6 +360,7 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
|
||||
$source_indexes = array();
|
||||
$target_indexes = array();
|
||||
$add_indexes_array = array();
|
||||
$alter_indexes_array = array();
|
||||
$remove_indexes_array = array();
|
||||
$criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment');
|
||||
|
||||
@ -378,17 +372,11 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
|
||||
$add_indexes_array, $alter_indexes_array,$remove_indexes_array, $counter);
|
||||
}
|
||||
|
||||
$matching_table_data_diff = array();
|
||||
$matching_table_structure_diff = array();
|
||||
$uncommon_table_structure_diff = array();
|
||||
$uncommon_table_data_diff = array();
|
||||
$uncommon_tables = $source_tables_uncommon;
|
||||
|
||||
/**
|
||||
* Generating Create Table query for all the non-matching tables present in Source but not in Target and populating tables.
|
||||
*/
|
||||
for ($q = 0; $q < sizeof($source_tables_uncommon); $q++) {
|
||||
if (isset($uncommon_tables[$q])) {
|
||||
if (isset($source_tables_uncommon[$q])) {
|
||||
PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $q, $uncommon_tables_fields, false);
|
||||
}
|
||||
if (isset($row_count[$q]) && $data) {
|
||||
|
||||
@ -70,16 +70,17 @@ function PMA_RTN_handleExport()
|
||||
{
|
||||
global $_GET, $db;
|
||||
|
||||
if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) {
|
||||
$item_name = $_GET['item_name'];
|
||||
$type = PMA_DBI_fetch_value(
|
||||
"SELECT ROUTINE_TYPE " .
|
||||
"FROM INFORMATION_SCHEMA.ROUTINES " .
|
||||
"WHERE ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' " .
|
||||
"AND SPECIFIC_NAME='" . PMA_sqlAddSlashes($item_name) . "';"
|
||||
);
|
||||
$export_data = PMA_DBI_get_definition($db, $type, $item_name);
|
||||
PMA_RTE_handleExport($item_name, $export_data);
|
||||
if ( ! empty($_GET['export_item'])
|
||||
&& ! empty($_GET['item_name'])
|
||||
&& ! empty($_GET['item_type'])
|
||||
) {
|
||||
if ($_GET['item_type'] == 'FUNCTION' || $_GET['item_type'] == 'PROCEDURE') {
|
||||
$export_data = PMA_DBI_get_definition(
|
||||
$db,
|
||||
$_GET['item_type'],
|
||||
$_GET['item_name']);
|
||||
PMA_RTE_handleExport($_GET['item_name'], $export_data);
|
||||
}
|
||||
}
|
||||
} // end PMA_RTN_handleExport()
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ function PMA_RTN_getRowForList($routine, $rowclass = '')
|
||||
$sql_drop = sprintf('DROP %s IF EXISTS %s',
|
||||
$routine['ROUTINE_TYPE'],
|
||||
PMA_backquote($routine['SPECIFIC_NAME']));
|
||||
|
||||
$type_link = "item_type={$routine['ROUTINE_TYPE']}";
|
||||
|
||||
$retval = " <tr class='noclick $rowclass'>\n";
|
||||
$retval .= " <td>\n";
|
||||
@ -136,6 +136,7 @@ function PMA_RTN_getRowForList($routine, $rowclass = '')
|
||||
. $url_query
|
||||
. '&edit_item=1'
|
||||
. '&item_name=' . urlencode($routine['SPECIFIC_NAME'])
|
||||
. '&' . $type_link
|
||||
. '">' . $titles['Edit'] . "</a>\n";
|
||||
} else {
|
||||
$retval .= " {$titles['NoEdit']}\n";
|
||||
@ -150,6 +151,7 @@ function PMA_RTN_getRowForList($routine, $rowclass = '')
|
||||
// otherwise we can execute it directly.
|
||||
$routine_details = PMA_RTN_getDataFromName(
|
||||
$routine['SPECIFIC_NAME'],
|
||||
$routine['ROUTINE_TYPE'],
|
||||
false
|
||||
);
|
||||
if ($routine !== false) {
|
||||
@ -168,6 +170,7 @@ function PMA_RTN_getRowForList($routine, $rowclass = '')
|
||||
. $url_query
|
||||
. '&' . $execute_action . '=1'
|
||||
. '&item_name=' . urlencode($routine['SPECIFIC_NAME'])
|
||||
. '&' . $type_link
|
||||
. '">' . $titles['Execute'] . "</a>\n";
|
||||
}
|
||||
} else {
|
||||
@ -180,15 +183,16 @@ function PMA_RTN_getRowForList($routine, $rowclass = '')
|
||||
. $url_query
|
||||
. '&export_item=1'
|
||||
. '&item_name=' . urlencode($routine['SPECIFIC_NAME'])
|
||||
. '&' . $type_link
|
||||
. '">' . $titles['Export'] . "</a>\n";
|
||||
$retval .= " </td>\n";
|
||||
$retval .= " <td>\n";
|
||||
if (PMA_currentUserHasPrivilege('EVENT', $db)) {
|
||||
if (PMA_currentUserHasPrivilege('ALTER ROUTINE', $db)) {
|
||||
$retval .= ' <a ' . $ajax_class['drop']
|
||||
. ' href="sql.php?'
|
||||
. $url_query
|
||||
. '&sql_query=' . urlencode($sql_drop)
|
||||
. '&goto=db_events.php' . urlencode("?db={$db}")
|
||||
. '&goto=db_routines.php' . urlencode("?db={$db}")
|
||||
. '" >' . $titles['Drop'] . "</a>\n";
|
||||
} else {
|
||||
$retval .= " {$titles['NoDrop']}\n";
|
||||
|
||||
@ -304,7 +304,9 @@ function PMA_RTN_handleEditor()
|
||||
$extra_data = array();
|
||||
if ($message->isSuccess()) {
|
||||
$columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, `DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
|
||||
$where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' AND ROUTINE_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'";
|
||||
$where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' "
|
||||
. "AND ROUTINE_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'"
|
||||
. "AND ROUTINE_TYPE='" . PMA_sqlAddSlashes($_REQUEST['item_type']) . "'";
|
||||
$routine = PMA_DBI_fetch_single_row("SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;");
|
||||
$extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['item_name']));
|
||||
$extra_data['new_row'] = PMA_RTN_getRowForList($routine);
|
||||
@ -343,7 +345,7 @@ function PMA_RTN_handleEditor()
|
||||
} else if (! empty($_REQUEST['edit_item'])) {
|
||||
$title = __("Edit routine");
|
||||
if (! $operation && ! empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit'])) {
|
||||
$routine = PMA_RTN_getDataFromName($_REQUEST['item_name']);
|
||||
$routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type']);
|
||||
if ($routine !== false) {
|
||||
$routine['item_original_name'] = $routine['item_name'];
|
||||
$routine['item_original_type'] = $routine['item_type'];
|
||||
@ -501,12 +503,13 @@ function PMA_RTN_getDataFromRequest()
|
||||
* the "Edit routine" form given the name of a routine.
|
||||
*
|
||||
* @param string $name The name of the routine.
|
||||
* @param string $type Type of routine (ROUTINE|PROCEDURE)
|
||||
* @param bool $all Whether to return all data or just
|
||||
* the info about parameters.
|
||||
*
|
||||
* @return array Data necessary to create the routine editor.
|
||||
*/
|
||||
function PMA_RTN_getDataFromName($name, $all = true)
|
||||
function PMA_RTN_getDataFromName($name, $type, $all = true)
|
||||
{
|
||||
global $param_directions, $param_sqldataaccess, $db;
|
||||
|
||||
@ -517,7 +520,8 @@ function PMA_RTN_getDataFromName($name, $all = true)
|
||||
. "ROUTINE_DEFINITION, IS_DETERMINISTIC, SQL_DATA_ACCESS, "
|
||||
. "ROUTINE_COMMENT, SECURITY_TYPE";
|
||||
$where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' "
|
||||
. "AND SPECIFIC_NAME='" . PMA_sqlAddSlashes($name) . "'";
|
||||
. "AND SPECIFIC_NAME='" . PMA_sqlAddSlashes($name) . "'"
|
||||
. "AND ROUTINE_TYPE='" . PMA_sqlAddSlashes($type) . "'";
|
||||
$query = "SELECT $fields FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;";
|
||||
|
||||
$routine = PMA_DBI_fetch_single_row($query);
|
||||
@ -1002,7 +1006,7 @@ function PMA_RTN_getQueryFromRequest()
|
||||
$warned_about_dir = false;
|
||||
$warned_about_name = false;
|
||||
$warned_about_length = false;
|
||||
if (! empty($_REQUEST['item_param_name'])
|
||||
if ( ! empty($_REQUEST['item_param_name'])
|
||||
&& ! empty($_REQUEST['item_param_type'])
|
||||
&& ! empty($_REQUEST['item_param_length'])
|
||||
&& is_array($_REQUEST['item_param_name'])
|
||||
@ -1124,7 +1128,7 @@ function PMA_RTN_handleExecute()
|
||||
*/
|
||||
if (! empty($_REQUEST['execute_routine']) && ! empty($_REQUEST['item_name'])) {
|
||||
// Build the queries
|
||||
$routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], false);
|
||||
$routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type'], false);
|
||||
if ($routine !== false) {
|
||||
$queries = array();
|
||||
$end_query = array();
|
||||
@ -1279,7 +1283,7 @@ function PMA_RTN_handleExecute()
|
||||
/**
|
||||
* Display the execute form for a routine.
|
||||
*/
|
||||
$routine = PMA_RTN_getDataFromName($_GET['item_name'], false);
|
||||
$routine = PMA_RTN_getDataFromName($_GET['item_name'], $_GET['item_type'], true);
|
||||
if ($routine !== false) {
|
||||
$form = PMA_RTN_getExecuteForm($routine);
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
@ -1336,6 +1340,8 @@ function PMA_RTN_getExecuteForm($routine)
|
||||
$retval .= "<form action='db_routines.php' method='post' class='rte_form'>\n";
|
||||
$retval .= "<input type='hidden' name='item_name'\n";
|
||||
$retval .= " value='{$routine['item_name']}' />\n";
|
||||
$retval .= "<input type='hidden' name='item_type'\n";
|
||||
$retval .= " value='{$routine['item_type']}' />\n";
|
||||
$retval .= PMA_generate_common_hidden_inputs($db) . "\n";
|
||||
$retval .= "<fieldset>\n";
|
||||
if ($GLOBALS['is_ajax_request'] != true) {
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* @package phpMyAdmin
|
||||
*/
|
||||
|
||||
include_once("Export_Relation_Schema.class.php");
|
||||
include_once "Export_Relation_Schema.class.php";
|
||||
|
||||
/**
|
||||
* This Class inherits the XMLwriter class and
|
||||
@ -14,7 +14,6 @@ include_once("Export_Relation_Schema.class.php");
|
||||
* @access public
|
||||
* @see http://php.net/manual/en/book.xmlwriter.php
|
||||
*/
|
||||
|
||||
class PMA_DIA extends XMLWriter
|
||||
{
|
||||
public $title;
|
||||
@ -44,7 +43,7 @@ class PMA_DIA extends XMLWriter
|
||||
* Create the XML document
|
||||
*/
|
||||
|
||||
$this->startDocument('1.0','UTF-8');
|
||||
$this->startDocument('1.0', 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,27 +54,29 @@ class PMA_DIA extends XMLWriter
|
||||
* to define the document, then finally a Layer starts which
|
||||
* holds all the objects.
|
||||
*
|
||||
* @param string paper The size of the paper/document
|
||||
* @param float topMargin top margin of the paper/document in cm
|
||||
* @param float bottomMargin bottom margin of the paper/document in cm
|
||||
* @param float leftMargin left margin of the paper/document in cm
|
||||
* @param float rightMargin right margin of the paper/document in cm
|
||||
* @param string portrait document will be portrait or landscape
|
||||
* @param string $paper the size of the paper/document
|
||||
* @param float $topMargin top margin of the paper/document in cm
|
||||
* @param float $bottomMargin bottom margin of the paper/document in cm
|
||||
* @param float $leftMargin left margin of the paper/document in cm
|
||||
* @param float $rightMargin right margin of the paper/document in cm
|
||||
* @param string $portrait document will be portrait or landscape
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @see XMLWriter::startElement(),XMLWriter::writeAttribute(),XMLWriter::writeRaw()
|
||||
*/
|
||||
function startDiaDoc($paper,$topMargin,$bottomMargin,$leftMargin,$rightMargin,$portrait)
|
||||
{
|
||||
if($portrait == 'P'){
|
||||
if ($portrait == 'P') {
|
||||
$isPortrait='true';
|
||||
}else{
|
||||
} else {
|
||||
$isPortrait='false';
|
||||
}
|
||||
$this->startElement('dia:diagram');
|
||||
$this->writeAttribute('xmlns:dia', 'http://www.lysator.liu.se/~alla/dia/');
|
||||
$this->startElement('dia:diagramdata');
|
||||
$this->writeRaw (
|
||||
$this->writeRaw(
|
||||
'<dia:attribute name="background">
|
||||
<dia:color val="#ffffff"/>
|
||||
</dia:attribute>
|
||||
@ -85,22 +86,22 @@ class PMA_DIA extends XMLWriter
|
||||
<dia:attribute name="paper">
|
||||
<dia:composite type="paper">
|
||||
<dia:attribute name="name">
|
||||
<dia:string>#'.$paper.'#</dia:string>
|
||||
<dia:string>#' . $paper . '#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="tmargin">
|
||||
<dia:real val="'.$topMargin.'"/>
|
||||
<dia:real val="' . $topMargin . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="bmargin">
|
||||
<dia:real val="'.$bottomMargin.'"/>
|
||||
<dia:real val="' . $bottomMargin . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="lmargin">
|
||||
<dia:real val="'.$leftMargin.'"/>
|
||||
<dia:real val="' . $leftMargin . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="rmargin">
|
||||
<dia:real val="'.$rightMargin.'"/>
|
||||
<dia:real val="' . $rightMargin . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="is_portrait">
|
||||
<dia:boolean val="'.$isPortrait.'"/>
|
||||
<dia:boolean val="' . $isPortrait . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="scaling">
|
||||
<dia:real val="1"/>
|
||||
@ -160,18 +161,21 @@ class PMA_DIA extends XMLWriter
|
||||
/**
|
||||
* Output Dia Document for download
|
||||
*
|
||||
* @param string fileName name of the dia document
|
||||
* @param string $fileName name of the dia document
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
* @see XMLWriter::flush()
|
||||
*/
|
||||
function showOutput($fileName)
|
||||
{
|
||||
if(ob_get_clean()){
|
||||
if (ob_get_clean()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
$output = $this->flush();
|
||||
PMA_download_header($fileName . '.dia', 'application/x-dia-diagram', strlen($output));
|
||||
PMA_download_header(
|
||||
$fileName . '.dia', 'application/x-dia-diagram', strlen($output)
|
||||
);
|
||||
print $output;
|
||||
}
|
||||
}
|
||||
@ -200,14 +204,17 @@ class Table_Stats
|
||||
/**
|
||||
* The "Table_Stats" constructor
|
||||
*
|
||||
* @param string table_name The table name
|
||||
* @param integer pageNumber The current page number (from the
|
||||
* $cfg['Servers'][$i]['table_coords'] table)
|
||||
* @param boolean showKeys Whether to display ONLY keys or not
|
||||
* @param string $tableName The table name
|
||||
* @param integer $pageNumber The current page number (from the
|
||||
* $cfg['Servers'][$i]['table_coords'] table)
|
||||
* @param boolean $showKeys Whether to display ONLY keys or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @global object The current dia document
|
||||
* @global array The relations settings
|
||||
* @global string The current db name
|
||||
*
|
||||
* @see PMA_DIA
|
||||
*/
|
||||
function __construct($tableName, $pageNumber, $showKeys = false)
|
||||
@ -218,7 +225,10 @@ class Table_Stats
|
||||
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
|
||||
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (!$result || !PMA_DBI_num_rows($result)) {
|
||||
$dia->dieSchema($pageNumber,"DIA",sprintf(__('The %s table doesn\'t exist!'), $tableName));
|
||||
$dia->dieSchema(
|
||||
$pageNumber, "DIA",
|
||||
sprintf(__('The %s table doesn\'t exist!'), $tableName)
|
||||
);
|
||||
}
|
||||
/*
|
||||
* load fields
|
||||
@ -228,7 +238,10 @@ class Table_Stats
|
||||
$indexes = PMA_Index::getFromTable($this->tableName, $db);
|
||||
$all_columns = array();
|
||||
foreach ($indexes as $index) {
|
||||
$all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
|
||||
$all_columns = array_merge(
|
||||
$all_columns,
|
||||
array_flip(array_keys($index->getColumns()))
|
||||
);
|
||||
}
|
||||
$this->fields = array_keys($all_columns);
|
||||
} else {
|
||||
@ -238,13 +251,21 @@ class Table_Stats
|
||||
}
|
||||
|
||||
$sql = 'SELECT x, y FROM '
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
|
||||
if (!$result || !PMA_DBI_num_rows($result)) {
|
||||
$dia->dieSchema($pageNumber,"DIA",sprintf(__('Please configure the coordinates for table %s'), $tableName));
|
||||
if (! $result || ! PMA_DBI_num_rows($result)) {
|
||||
$dia->dieSchema(
|
||||
$pageNumber,
|
||||
"DIA",
|
||||
sprintf(
|
||||
__('Please configure the coordinates for table %s'),
|
||||
$tableName
|
||||
)
|
||||
);
|
||||
}
|
||||
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
|
||||
$this->x = (double) $this->x;
|
||||
@ -256,7 +277,11 @@ class Table_Stats
|
||||
/*
|
||||
* index
|
||||
*/
|
||||
$result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
|
||||
$result = PMA_DBI_query(
|
||||
'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
);
|
||||
if (PMA_DBI_num_rows($result) > 0) {
|
||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
@ -280,13 +305,15 @@ class Table_Stats
|
||||
* is used to generate the XML of Dia Document. Database Table
|
||||
* Object and their attributes are involved in the combination
|
||||
* of displaing Database - Table on Dia Document.
|
||||
|
||||
* @param boolean changeColor Whether to show color for tables text or not
|
||||
if changeColor is true then an array of $listOfColors
|
||||
will be used to choose the random colors for tables text
|
||||
we can change/add more colors to this array
|
||||
@return void
|
||||
* @global object The current Dia document
|
||||
*
|
||||
* @param boolean $changeColor Whether to show color for tables text or not
|
||||
* if changeColor is true then an array of $listOfColors will be used to choose
|
||||
* the random colors for tables text we can change/add more colors to this array
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @global object The current Dia document
|
||||
*
|
||||
* @access public
|
||||
* @see PMA_DIA
|
||||
*/
|
||||
@ -301,7 +328,7 @@ class Table_Stats
|
||||
'00FF00'
|
||||
);
|
||||
shuffle($listOfColors);
|
||||
$this->tableColor = '#'.$listOfColors[0].'';
|
||||
$this->tableColor = '#' . $listOfColors[0] . '';
|
||||
} else {
|
||||
$this->tableColor = '#000000';
|
||||
}
|
||||
@ -311,19 +338,22 @@ class Table_Stats
|
||||
$dia->startElement('dia:object');
|
||||
$dia->writeAttribute('type', 'Database - Table');
|
||||
$dia->writeAttribute('version', '0');
|
||||
$dia->writeAttribute('id', ''.$this->tableId.'');
|
||||
$dia->writeAttribute('id', '' . $this->tableId . '');
|
||||
$dia->writeRaw(
|
||||
'<dia:attribute name="obj_pos">
|
||||
<dia:point val="'.($this->x * $factor).','.($this->y * $factor).'"/>
|
||||
<dia:point val="'
|
||||
. ($this->x * $factor) . ',' . ($this->y * $factor) . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="'.($this->x * $factor).','.($this->y * $factor).';9.97,9.2"/>
|
||||
<dia:rectangle val="'
|
||||
.($this->x * $factor) . ',' . ($this->y * $factor) . ';9.97,9.2"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="meta">
|
||||
<dia:composite type="dict"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="'.($this->x * $factor).','.($this->y * $factor).'"/>
|
||||
<dia:point val="'
|
||||
. ($this->x * $factor) . ',' . ($this->y * $factor) . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5.9199999999999999"/>
|
||||
@ -332,7 +362,7 @@ class Table_Stats
|
||||
<dia:real val="3.5"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="text_colour">
|
||||
<dia:color val="'.$this->tableColor.'"/>
|
||||
<dia:color val="' . $this->tableColor . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="line_colour">
|
||||
<dia:color val="#000000"/>
|
||||
@ -344,7 +374,7 @@ class Table_Stats
|
||||
<dia:real val="0.10000000000000001"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="name">
|
||||
<dia:string>#'.$this->tableName.'#</dia:string>
|
||||
<dia:string>#' . $this->tableName . '#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="comment">
|
||||
<dia:string>##</dia:string>
|
||||
@ -379,44 +409,44 @@ class Table_Stats
|
||||
<dia:attribute name="comment_font_height">
|
||||
<dia:real val="0.69999999999999996"/>
|
||||
</dia:attribute>'
|
||||
);
|
||||
);
|
||||
|
||||
$dia->startElement('dia:attribute');
|
||||
$dia->writeAttribute('name', 'attributes');
|
||||
|
||||
foreach ($this->fields as $field) {
|
||||
$dia->writeRaw(
|
||||
'<dia:composite type="table_attribute">
|
||||
<dia:attribute name="name">
|
||||
<dia:string>#'.$field.'#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="type">
|
||||
<dia:string>##</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="comment">
|
||||
$dia->writeRaw(
|
||||
'<dia:composite type="table_attribute">
|
||||
<dia:attribute name="name">
|
||||
<dia:string>#' . $field . '#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="type">
|
||||
<dia:string>##</dia:string>
|
||||
</dia:attribute>'
|
||||
);
|
||||
unset($pm);
|
||||
$pm = 'false';
|
||||
if (in_array($field, $this->primary)) {
|
||||
$pm = 'true';
|
||||
}
|
||||
if ($field == $this->displayfield) {
|
||||
$pm = 'false';
|
||||
}
|
||||
$dia->writeRaw(
|
||||
'<dia:attribute name="primary_key">
|
||||
<dia:boolean val="'.$pm.'"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="nullable">
|
||||
<dia:boolean val="false"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="unique">
|
||||
<dia:boolean val="'.$pm.'"/>
|
||||
</dia:attribute>
|
||||
</dia:composite>'
|
||||
);
|
||||
</dia:attribute>
|
||||
<dia:attribute name="comment">
|
||||
<dia:string>##</dia:string>
|
||||
</dia:attribute>'
|
||||
);
|
||||
unset($pm);
|
||||
$pm = 'false';
|
||||
if (in_array($field, $this->primary)) {
|
||||
$pm = 'true';
|
||||
}
|
||||
if ($field == $this->displayfield) {
|
||||
$pm = 'false';
|
||||
}
|
||||
$dia->writeRaw(
|
||||
'<dia:attribute name="primary_key">
|
||||
<dia:boolean val="' . $pm . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="nullable">
|
||||
<dia:boolean val="false"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="unique">
|
||||
<dia:boolean val="' . $pm . '"/>
|
||||
</dia:attribute>
|
||||
</dia:composite>'
|
||||
);
|
||||
}
|
||||
$dia->endElement();
|
||||
$dia->endElement();
|
||||
@ -452,11 +482,13 @@ class Relation_Stats
|
||||
/**
|
||||
* The "Relation_Stats" constructor
|
||||
*
|
||||
* @param string master_table The master table name
|
||||
* @param string master_field The relation field in the master table
|
||||
* @param string foreign_table The foreign table name
|
||||
* @param string foreigh_field The relation field in the foreign table
|
||||
* @param string $master_table The master table name
|
||||
* @param string $master_field The relation field in the master table
|
||||
* @param string $foreign_table The foreign table name
|
||||
* @param string $foreign_field The relation field in the foreign table
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @see Relation_Stats::_getXy
|
||||
*/
|
||||
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
|
||||
@ -480,9 +512,11 @@ class Relation_Stats
|
||||
* then determines its left and right connection
|
||||
* points.
|
||||
*
|
||||
* @param string table The current table name
|
||||
* @param string column The relation column name
|
||||
* @param string $table The current table name
|
||||
* @param string $column The relation column name
|
||||
*
|
||||
* @return array Table right,left connection points and key position
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function _getXy($table, $column)
|
||||
@ -490,8 +524,7 @@ class Relation_Stats
|
||||
$pos = array_search($column, $table->fields);
|
||||
// left, right, position
|
||||
$value = 12;
|
||||
if($pos != 0)
|
||||
{
|
||||
if ($pos != 0) {
|
||||
return array($pos + $value + $pos, $pos + $value + $pos + 1, $pos);
|
||||
}
|
||||
return array($pos + $value , $pos + $value + 1, $pos);
|
||||
@ -506,12 +539,14 @@ class Relation_Stats
|
||||
* Database reference Object and their attributes are involved
|
||||
* in the combination of displaing Database - reference on Dia Document.
|
||||
*
|
||||
* @param boolean changeColor Whether to use one color per relation or not
|
||||
if changeColor is true then an array of $listOfColors
|
||||
will be used to choose the random colors for references
|
||||
lines. we can change/add more colors to this array
|
||||
* @param boolean $changeColor Whether to use one color per relation or not
|
||||
* if changeColor is true then an array of $listOfColors will be used to choose
|
||||
* the random colors for references lines. we can change/add more colors to this
|
||||
*
|
||||
* @return void
|
||||
* @global object The current Dia document
|
||||
*
|
||||
* @global object The current Dia document
|
||||
*
|
||||
* @access public
|
||||
* @see PMA_PDF
|
||||
*/
|
||||
@ -525,8 +560,8 @@ class Relation_Stats
|
||||
* points are same then return it false and don't draw that
|
||||
* relation
|
||||
*/
|
||||
if ( $this->srcConnPointsRight == $this->destConnPointsRight ){
|
||||
if ( $this->srcConnPointsLeft == $this->destConnPointsLeft ){
|
||||
if ( $this->srcConnPointsRight == $this->destConnPointsRight) {
|
||||
if ( $this->srcConnPointsLeft == $this->destConnPointsLeft) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -538,13 +573,14 @@ class Relation_Stats
|
||||
'00FF00'
|
||||
);
|
||||
shuffle($listOfColors);
|
||||
$this->referenceColor = '#'.$listOfColors[0].'';
|
||||
$this->referenceColor = '#' . $listOfColors[0] . '';
|
||||
} else {
|
||||
$this->referenceColor = '#000000';
|
||||
}
|
||||
|
||||
$dia->writeRaw(
|
||||
'<dia:object type="Database - Reference" version="0" id="'.PMA_Dia_Relation_Schema::$objectId.'">
|
||||
'<dia:object type="Database - Reference" version="0" id="'
|
||||
. PMA_Dia_Relation_Schema::$objectId . '">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="3.27,18.9198"/>
|
||||
</dia:attribute>
|
||||
@ -576,7 +612,7 @@ class Relation_Stats
|
||||
<dia:color val="#000000"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="line_colour">
|
||||
<dia:color val="'.$this->referenceColor.'"/>
|
||||
<dia:color val="' . $this->referenceColor . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="line_width">
|
||||
<dia:real val="0.10000000000000001"/>
|
||||
@ -610,11 +646,15 @@ class Relation_Stats
|
||||
<dia:real val="0.59999999999999998"/>
|
||||
</dia:attribute>
|
||||
<dia:connections>
|
||||
<dia:connection handle="0" to="'.$this->masterTableId.'" connection="'.$this->srcConnPointsRight.'"/>
|
||||
<dia:connection handle="1" to="'.$this->foreignTableId.'" connection="'.$this->destConnPointsRight.'"/>
|
||||
<dia:connection handle="0" to="'
|
||||
. $this->masterTableId . '" connection="'
|
||||
. $this->srcConnPointsRight . '"/>
|
||||
<dia:connection handle="1" to="'
|
||||
. $this->foreignTableId . '" connection="'
|
||||
. $this->destConnPointsRight . '"/>
|
||||
</dia:connections>
|
||||
</dia:object>'
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -667,11 +707,16 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->setExportType($_POST['export_type']);
|
||||
|
||||
$dia = new PMA_DIA();
|
||||
$dia->startDiaDoc($this->paper,$this->_topMargin,$this->_bottomMargin,$this->_leftMargin,$this->_rightMargin,$this->orientation);
|
||||
$alltables = $this->getAllTables($db,$this->pageNumber);
|
||||
$dia->startDiaDoc(
|
||||
$this->paper, $this->_topMargin, $this->_bottomMargin,
|
||||
$this->_leftMargin, $this->_rightMargin, $this->orientation
|
||||
);
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
foreach ($alltables as $table) {
|
||||
if (! isset($this->tables[$table])) {
|
||||
$this->tables[$table] = new Table_Stats($table, $this->pageNumber, $this->showKeys);
|
||||
$this->tables[$table] = new Table_Stats(
|
||||
$table, $this->pageNumber, $this->showKeys
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,12 +727,15 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$seen_a_relation = true;
|
||||
foreach ($exist_rel as $master_field => $rel) {
|
||||
/* put the foreign table on the schema only if selected
|
||||
* by the user
|
||||
* (do not use array_search() because we would have to
|
||||
* to do a === false and this is not PHP3 compatible)
|
||||
*/
|
||||
* by the user
|
||||
* (do not use array_search() because we would have to
|
||||
* to do a === false and this is not PHP3 compatible)
|
||||
*/
|
||||
if (in_array($rel['foreign_table'], $alltables)) {
|
||||
$this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field'],$this->showKeys);
|
||||
$this->_addRelation(
|
||||
$one_table, $master_field, $rel['foreign_table'],
|
||||
$rel['foreign_field'], $this->showKeys
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -698,30 +746,40 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->_drawRelations($this->showColor);
|
||||
}
|
||||
$dia->endDiaDoc();
|
||||
$dia->showOutput($db.'-'.$this->pageNumber);
|
||||
$dia->showOutput($db . '-' . $this->pageNumber);
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines relation objects
|
||||
*
|
||||
* @param string masterTable The master table name
|
||||
* @param string masterField The relation field in the master table
|
||||
* @param string foreignTable The foreign table name
|
||||
* @param string foreignField The relation field in the foreign table
|
||||
* @param string $masterTable The master table name
|
||||
* @param string $masterField The relation field in the master table
|
||||
* @param string $foreignTable The foreign table name
|
||||
* @param string $foreignField The relation field in the foreign table
|
||||
* @param bool $showKeys Whether to display ONLY keys or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see Table_Stats::__construct(),Relation_Stats::__construct()
|
||||
*/
|
||||
private function _addRelation($masterTable, $masterField, $foreignTable, $foreignField, $showKeys)
|
||||
{
|
||||
if (! isset($this->tables[$masterTable])) {
|
||||
$this->tables[$masterTable] = new Table_Stats($masterTable, $this->pageNumber, $showKeys);
|
||||
$this->tables[$masterTable] = new Table_Stats(
|
||||
$masterTable, $this->pageNumber, $showKeys
|
||||
);
|
||||
}
|
||||
if (! isset($this->tables[$foreignTable])) {
|
||||
$this->tables[$foreignTable] = new Table_Stats($foreignTable, $this->pageNumber, $showKeys);
|
||||
$this->tables[$foreignTable] = new Table_Stats(
|
||||
$foreignTable, $this->pageNumber, $showKeys
|
||||
);
|
||||
}
|
||||
$this->_relations[] = new Relation_Stats($this->tables[$masterTable], $masterField, $this->tables[$foreignTable], $foreignField);
|
||||
$this->_relations[] = new Relation_Stats(
|
||||
$this->tables[$masterTable], $masterField,
|
||||
$this->tables[$foreignTable], $foreignField
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -731,8 +789,10 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
* foreign table's forein field using Dia object
|
||||
* type Database - Reference
|
||||
*
|
||||
* @param boolean changeColor Whether to use one color per relation or not
|
||||
* @param boolean $changeColor Whether to use one color per relation or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see Relation_Stats::relationDraw()
|
||||
*/
|
||||
@ -749,8 +809,10 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
* Tables are generated using Dia object type Database - Table
|
||||
* primary fields are underlined and bold in tables
|
||||
*
|
||||
* @param boolean changeColor Whether to show color for tables text or not
|
||||
* @param boolean $changeColor Whether to show color for tables text or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see Table_Stats::tableDraw()
|
||||
*/
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* @package phpMyAdmin
|
||||
*/
|
||||
|
||||
include_once("Export_Relation_Schema.class.php");
|
||||
include_once "Export_Relation_Schema.class.php";
|
||||
|
||||
/**
|
||||
* This Class is EPS Library and
|
||||
@ -42,8 +42,10 @@ class PMA_EPS
|
||||
/**
|
||||
* Set document title
|
||||
*
|
||||
* @param string value sets the title text
|
||||
* @param string $value sets the title text
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function setTitle($value)
|
||||
@ -54,8 +56,10 @@ class PMA_EPS
|
||||
/**
|
||||
* Set document author
|
||||
*
|
||||
* @param string value sets the author
|
||||
* @param string $value sets the author
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function setAuthor($value)
|
||||
@ -66,8 +70,10 @@ class PMA_EPS
|
||||
/**
|
||||
* Set document creation date
|
||||
*
|
||||
* @param string value sets the date
|
||||
* @param string $value sets the date
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function setDate($value)
|
||||
@ -78,17 +84,19 @@ class PMA_EPS
|
||||
/**
|
||||
* Set document orientation
|
||||
*
|
||||
* @param string value sets the author
|
||||
* @param string $value sets the author
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function setOrientation($value)
|
||||
{
|
||||
$this->stringCommands .= "%%PageOrder: Ascend \n";
|
||||
if($value == "L"){
|
||||
if ($value == "L") {
|
||||
$value = "Landscape";
|
||||
$this->stringCommands .= '%%Orientation: ' . $value . "\n";
|
||||
}else{
|
||||
} else {
|
||||
$value = "Portrait";
|
||||
$this->stringCommands .= '%%Orientation: ' . $value . "\n";
|
||||
}
|
||||
@ -102,17 +110,19 @@ class PMA_EPS
|
||||
*
|
||||
* font can be set whenever needed in EPS
|
||||
*
|
||||
* @param string value sets the font name e.g Arial
|
||||
* @param integer value sets the size of the font e.g 10
|
||||
* @param string $value sets the font name e.g Arial
|
||||
* @param integer $value sets the size of the font e.g 10
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function setFont($value,$size)
|
||||
{
|
||||
$this->font = $value;
|
||||
$this->fontSize = $size;
|
||||
$this->stringCommands .= "/".$value." findfont % Get the basic font\n";
|
||||
$this->stringCommands .= "".$size." scalefont % Scale the font to $size points\n";
|
||||
$this->stringCommands .= "/" . $value . " findfont % Get the basic font\n";
|
||||
$this->stringCommands .= "" . $size . " scalefont % Scale the font to $size points\n";
|
||||
$this->stringCommands .= "setfont % Make it the current font\n";
|
||||
}
|
||||
|
||||
@ -144,19 +154,21 @@ class PMA_EPS
|
||||
* drawing the lines from x,y source to x,y destination and set the
|
||||
* width of the line. lines helps in showing relationships of tables
|
||||
*
|
||||
* @param integer x_from The x_from attribute defines the start
|
||||
left position of the element
|
||||
* @param integer y_from The y_from attribute defines the start
|
||||
right position of the element
|
||||
* @param integer x_to The x_to attribute defines the end
|
||||
left position of the element
|
||||
* @param integer y_to The y_to attribute defines the end
|
||||
right position of the element
|
||||
* @param integer lineWidth sets the width of the line e.g 2
|
||||
* @param integer $x_from The x_from attribute defines the start
|
||||
* left position of the element
|
||||
* @param integer $y_from The y_from attribute defines the start
|
||||
* right position of the element
|
||||
* @param integer $x_to The x_to attribute defines the end
|
||||
* left position of the element
|
||||
* @param integer $y_to The y_to attribute defines the end
|
||||
* right position of the element
|
||||
* @param integer $lineWidth Sets the width of the line e.g 2
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function line($x_from=0, $y_from=0, $x_to=0, $y_to=0, $lineWidth=0)
|
||||
function line($x_from = 0, $y_from = 0, $x_to = 0, $y_to = 0, $lineWidth = 0)
|
||||
{
|
||||
$this->stringCommands .= $lineWidth . " setlinewidth \n";
|
||||
$this->stringCommands .= $x_from . ' ' . $y_from . " moveto \n";
|
||||
@ -170,28 +182,30 @@ class PMA_EPS
|
||||
* drawing the rectangle from x,y source to x,y destination and set the
|
||||
* width of the line. rectangles drawn around the text shown of fields
|
||||
*
|
||||
* @param integer x_from The x_from attribute defines the start
|
||||
left position of the element
|
||||
* @param integer y_from The y_from attribute defines the start
|
||||
right position of the element
|
||||
* @param integer x_to The x_to attribute defines the end
|
||||
left position of the element
|
||||
* @param integer y_to The y_to attribute defines the end
|
||||
right position of the element
|
||||
* @param integer lineWidth sets the width of the line e.g 2
|
||||
* @param integer $x_from The x_from attribute defines the start
|
||||
left position of the element
|
||||
* @param integer $y_from The y_from attribute defines the start
|
||||
right position of the element
|
||||
* @param integer $x_to The x_to attribute defines the end
|
||||
left position of the element
|
||||
* @param integer $y_to The y_to attribute defines the end
|
||||
right position of the element
|
||||
* @param integer $lineWidth Sets the width of the line e.g 2
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function rect($x_from, $y_from, $x_to, $y_to, $lineWidth)
|
||||
{
|
||||
$this->stringCommands .= $lineWidth . " setlinewidth \n";
|
||||
$this->stringCommands .= "newpath \n";
|
||||
$this->stringCommands .= $x_from . " " . $y_from . " moveto \n";
|
||||
$this->stringCommands .= "0 " . $y_to . " rlineto \n";
|
||||
$this->stringCommands .= $x_to . " 0 rlineto \n";
|
||||
$this->stringCommands .= "0 -" . $y_to . " rlineto \n";
|
||||
$this->stringCommands .= "closepath \n";
|
||||
$this->stringCommands .= "stroke \n";
|
||||
$this->stringCommands .= $lineWidth . " setlinewidth \n";
|
||||
$this->stringCommands .= "newpath \n";
|
||||
$this->stringCommands .= $x_from . " " . $y_from . " moveto \n";
|
||||
$this->stringCommands .= "0 " . $y_to . " rlineto \n";
|
||||
$this->stringCommands .= $x_to . " 0 rlineto \n";
|
||||
$this->stringCommands .= "0 -" . $y_to . " rlineto \n";
|
||||
$this->stringCommands .= "closepath \n";
|
||||
$this->stringCommands .= "stroke \n";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,11 +215,11 @@ class PMA_EPS
|
||||
* them as x and y coordinates to which to move. The coordinates
|
||||
* specified become the current point.
|
||||
*
|
||||
* @param integer x The x attribute defines the
|
||||
left position of the element
|
||||
* @param integer y The y attribute defines the
|
||||
right position of the element
|
||||
* @param integer $x The x attribute defines the left position of the element
|
||||
* @param integer $y The y attribute defines the right position of the element
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function moveTo($x, $y)
|
||||
@ -216,31 +230,33 @@ class PMA_EPS
|
||||
/**
|
||||
* Output/Display the text
|
||||
*
|
||||
* @param string text The string to be displayed
|
||||
* @param string $text The string to be displayed
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function show($text)
|
||||
{
|
||||
$this->stringCommands .= '(' . $text . ") show \n";
|
||||
}
|
||||
function show($text)
|
||||
{
|
||||
$this->stringCommands .= '(' . $text . ") show \n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the text at specified co-ordinates
|
||||
*
|
||||
* @param string text The string to be displayed
|
||||
* @param integer x The x attribute defines the
|
||||
left position of the element
|
||||
* @param integer y The y attribute defines the
|
||||
right position of the element
|
||||
* @param string $text String to be displayed
|
||||
* @param integer $x X attribute defines the left position of the element
|
||||
* @param integer $y Y attribute defines the right position of the element
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function showXY($text, $x, $y)
|
||||
{
|
||||
$this->moveTo($x, $y);
|
||||
$this->show($text);
|
||||
}
|
||||
function showXY($text, $x, $y)
|
||||
{
|
||||
$this->moveTo($x, $y);
|
||||
$this->show($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* get width of string/text
|
||||
@ -252,10 +268,12 @@ class PMA_EPS
|
||||
* This is a bit hardcore method. I didn't found any other better than this.
|
||||
* if someone found better than this. would love to hear that method
|
||||
*
|
||||
* @param string text string that width will be calculated
|
||||
* @param integer font name of the font like Arial,sans-serif etc
|
||||
* @param integer fontSize size of font
|
||||
* @param string $text string that width will be calculated
|
||||
* @param integer $font name of the font like Arial,sans-serif etc
|
||||
* @param integer $fontSize size of font
|
||||
*
|
||||
* @return integer width of the text
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function getStringWidth($text,$font,$fontSize)
|
||||
@ -264,22 +282,22 @@ class PMA_EPS
|
||||
* Start by counting the width, giving each character a modifying value
|
||||
*/
|
||||
$count = 0;
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("i","j","l"),"",$text)))*0.23);//ijl
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("f"),"",$text)))*0.27);//f
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("t","I"),"",$text)))*0.28);//tI
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("r"),"",$text)))*0.34);//r
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("1"),"",$text)))*0.49);//1
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("c","k","s","v","x","y","z","J"),"",$text)))*0.5);//cksvxyzJ
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("a","b","d","e","g","h","n","o","p","q","u","L","0","2","3","4","5","6","7","8","9"),"",$text)))*0.56);//abdeghnopquL023456789
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("F","T","Z"),"",$text)))*0.61);//FTZ
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("A","B","E","K","P","S","V","X","Y"),"",$text)))*0.67);//ABEKPSVXY
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("w","C","D","H","N","R","U"),"",$text)))*0.73);//wCDHNRU
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("G","O","Q"),"",$text)))*0.78);//GOQ
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("m","M"),"",$text)))*0.84);//mM
|
||||
$count = $count + ((strlen($text) - strlen(str_replace("W","",$text)))*.95);//W
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(" ","",$text)))*.28);//" "
|
||||
$text = str_replace(" ","",$text);//remove the " "'s
|
||||
$count = $count + (strlen(preg_replace("/[a-z0-9]/i","",$text))*0.3); //all other chrs
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("i", "j", "l"), "", $text))) * 0.23);//ijl
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("f"), "", $text))) * 0.27);//f
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("t", "I"), "", $text))) * 0.28);//tI
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("r"), "", $text))) * 0.34);//r
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("1"), "", $text))) * 0.49);//1
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("c", "k", "s", "v", "x", "y", "z", "J"), "", $text))) * 0.5);//cksvxyzJ
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("a", "b", "d", "e", "g", "h", "n", "o", "p", "q", "u", "L", "0", "2", "3", "4", "5", "6", "7", "8", "9"), "", $text))) * 0.56);//abdeghnopquL023456789
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("F", "T", "Z"), "", $text))) * 0.61);//FTZ
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("A", "B", "E", "K", "P", "S", "V", "X", "Y"), "", $text))) * 0.67);//ABEKPSVXY
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("w", "C", "D", "H", "N", "R", "U"), "", $text))) * 0.73);//wCDHNRU
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("G", "O", "Q"), "", $text))) * 0.78);//GOQ
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(array("m", "M"), "", $text))) * 0.84);//mM
|
||||
$count = $count + ((strlen($text) - strlen(str_replace("W", "", $text))) * .95);//W
|
||||
$count = $count + ((strlen($text) - strlen(str_replace(" ", "", $text))) * .28);//" "
|
||||
$text = str_replace(" ", "", $text);//remove the " "'s
|
||||
$count = $count + (strlen(preg_replace("/[a-z0-9]/i", "", $text)) * 0.3); //all other chrs
|
||||
|
||||
$modifier = 1;
|
||||
$font = strtolower($font);
|
||||
@ -289,7 +307,7 @@ class PMA_EPS
|
||||
*/
|
||||
case 'arial':
|
||||
case 'sans-serif':
|
||||
break;
|
||||
break;
|
||||
/*
|
||||
* .92 modifer for time, serif, brushscriptstd, and californian fb
|
||||
*/
|
||||
@ -298,13 +316,13 @@ class PMA_EPS
|
||||
case 'brushscriptstd':
|
||||
case 'californian fb':
|
||||
$modifier = .92;
|
||||
break;
|
||||
break;
|
||||
/*
|
||||
* 1.23 modifier for broadway
|
||||
*/
|
||||
case 'broadway':
|
||||
$modifier = 1.23;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
$textWidth = $count*$fontSize;
|
||||
return ceil($textWidth*$modifier);
|
||||
@ -324,8 +342,10 @@ class PMA_EPS
|
||||
/**
|
||||
* Output EPS Document for download
|
||||
*
|
||||
* @param string fileName name of the eps document
|
||||
* @param string $fileName name of the eps document
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function showOutput($fileName)
|
||||
@ -368,30 +388,37 @@ class Table_Stats
|
||||
/**
|
||||
* The "Table_Stats" constructor
|
||||
*
|
||||
* @param string tableName The table name
|
||||
* @param string font The font name
|
||||
* @param integer fontSize The font size
|
||||
* @param integer same_wide_width The max width among tables
|
||||
* @param boolean showKeys Whether to display keys or not
|
||||
* @param boolean showInfo Whether to display table position or not
|
||||
* @param string $tableName The table name
|
||||
* @param string $font The font name
|
||||
* @param integer $fontSize The font size
|
||||
* @param integer $pageNumber Page number
|
||||
* @param integer &$same_wide_width The max width among tables
|
||||
* @param boolean $showKeys Whether to display keys or not
|
||||
* @param boolean $showInfo Whether to display table position or not
|
||||
*
|
||||
* @global object The current eps document
|
||||
* @global integer The current page number (from the
|
||||
* $cfg['Servers'][$i]['table_coords'] table)
|
||||
* @global array The relations settings
|
||||
* @global string The current db name
|
||||
*
|
||||
* @access private
|
||||
* @see PMA_EPS, Table_Stats::Table_Stats_setWidth,
|
||||
Table_Stats::Table_Stats_setHeight
|
||||
* Table_Stats::Table_Stats_setHeight
|
||||
*/
|
||||
function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false)
|
||||
function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
|
||||
$showKeys = false, $showInfo = false)
|
||||
{
|
||||
global $eps, $cfgRelation, $db;
|
||||
|
||||
$this->_tableName = $tableName;
|
||||
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
|
||||
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (!$result || !PMA_DBI_num_rows($result)) {
|
||||
$eps->dieSchema($pageNumber,"EPS",sprintf(__('The %s table doesn\'t exist!'), $tableName));
|
||||
if (! $result || ! PMA_DBI_num_rows($result)) {
|
||||
$eps->dieSchema(
|
||||
$pageNumber, "EPS",
|
||||
sprintf(__('The %s table doesn\'t exist!'), $tableName)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -402,7 +429,10 @@ class Table_Stats
|
||||
$indexes = PMA_Index::getFromTable($this->_tableName, $db);
|
||||
$all_columns = array();
|
||||
foreach ($indexes as $index) {
|
||||
$all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
|
||||
$all_columns = array_merge(
|
||||
$all_columns,
|
||||
array_flip(array_keys($index->getColumns()))
|
||||
);
|
||||
}
|
||||
$this->fields = array_keys($all_columns);
|
||||
} else {
|
||||
@ -418,21 +448,28 @@ class Table_Stats
|
||||
|
||||
// setWidth must me after setHeight, because title
|
||||
// can include table height which changes table width
|
||||
$this->_setWidthTable($font,$fontSize);
|
||||
$this->_setWidthTable($font, $fontSize);
|
||||
if ($same_wide_width < $this->width) {
|
||||
$same_wide_width = $this->width;
|
||||
}
|
||||
|
||||
// x and y
|
||||
$sql = 'SELECT x, y FROM '
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
|
||||
|
||||
if (!$result || !PMA_DBI_num_rows($result)) {
|
||||
$eps->dieSchema($pageNumber,"EPS",sprintf(__('Please configure the coordinates for table %s'), $tableName));
|
||||
if (! $result || ! PMA_DBI_num_rows($result)) {
|
||||
$eps->dieSchema(
|
||||
$pageNumber, "EPS",
|
||||
sprintf(
|
||||
__('Please configure the coordinates for table %s'),
|
||||
$tableName
|
||||
)
|
||||
);
|
||||
}
|
||||
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
|
||||
$this->x = (double) $this->x;
|
||||
@ -440,7 +477,10 @@ class Table_Stats
|
||||
// displayfield
|
||||
$this->displayfield = PMA_getDisplayField($db, $tableName);
|
||||
// index
|
||||
$result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
|
||||
$result = PMA_DBI_query(
|
||||
'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
|
||||
null, PMA_DBI_QUERY_STORE
|
||||
);
|
||||
if (PMA_DBI_num_rows($result) > 0) {
|
||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
@ -459,16 +499,21 @@ class Table_Stats
|
||||
*/
|
||||
private function _getTitle()
|
||||
{
|
||||
return ($this->_showInfo ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) : '') . ' ' . $this->_tableName;
|
||||
return ($this->_showInfo
|
||||
? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell)
|
||||
: '') . ' ' . $this->_tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the width of the table
|
||||
*
|
||||
* @param string font The font name
|
||||
* @param integer fontSize The font size
|
||||
* @param string $font The font name
|
||||
* @param integer $fontSize The font size
|
||||
*
|
||||
* @global object The current eps document
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see PMA_EPS
|
||||
*/
|
||||
@ -477,14 +522,17 @@ class Table_Stats
|
||||
global $eps;
|
||||
|
||||
foreach ($this->fields as $field) {
|
||||
$this->width = max($this->width, $eps->getStringWidth($field,$font,$fontSize));
|
||||
$this->width = max(
|
||||
$this->width,
|
||||
$eps->getStringWidth($field, $font, $fontSize)
|
||||
);
|
||||
}
|
||||
$this->width += $eps->getStringWidth(' ',$font,$fontSize);
|
||||
$this->width += $eps->getStringWidth(' ', $font, $fontSize);
|
||||
/*
|
||||
* it is unknown what value must be added, because
|
||||
* table title is affected by the tabe width value
|
||||
*/
|
||||
while ($this->width < $eps->getStringWidth($this->_getTitle(),$font,$fontSize)) {
|
||||
while ($this->width < $eps->getStringWidth($this->_getTitle(), $font, $fontSize)) {
|
||||
$this->width += 7;
|
||||
}
|
||||
}
|
||||
@ -492,7 +540,8 @@ class Table_Stats
|
||||
/**
|
||||
* Sets the height of the table
|
||||
*
|
||||
* @param integer fontSize The font size
|
||||
* @param integer $fontSize The font size
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
@ -505,9 +554,12 @@ class Table_Stats
|
||||
/**
|
||||
* Draw the table
|
||||
*
|
||||
* @param boolean showColor Whether to display color
|
||||
* @param boolean $showColor Whether to display color
|
||||
*
|
||||
* @global object The current eps document
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @see PMA_EPS,PMA_EPS::line,PMA_EPS::rect
|
||||
*/
|
||||
@ -515,25 +567,24 @@ class Table_Stats
|
||||
{
|
||||
global $eps;
|
||||
//echo $this->_tableName.'<br />';
|
||||
$eps->rect($this->x,$this->y + 12,
|
||||
$this->width,$this->heightCell,
|
||||
1
|
||||
);
|
||||
$eps->showXY($this->_getTitle(),$this->x + 5,$this->y + 14);
|
||||
$eps->rect($this->x, $this->y + 12, $this->width, $this->heightCell, 1);
|
||||
$eps->showXY($this->_getTitle(), $this->x + 5, $this->y + 14);
|
||||
foreach ($this->fields as $field) {
|
||||
$this->currentCell += $this->heightCell;
|
||||
$showColor = 'none';
|
||||
if ($showColor) {
|
||||
if (in_array($field, $this->primary)) {
|
||||
$showColor = '#0c0';
|
||||
}
|
||||
if ($field == $this->displayfield) {
|
||||
$showColor = 'none';
|
||||
}
|
||||
$this->currentCell += $this->heightCell;
|
||||
$showColor = 'none';
|
||||
if ($showColor) {
|
||||
if (in_array($field, $this->primary)) {
|
||||
$showColor = '#0c0';
|
||||
}
|
||||
$eps->rect($this->x,$this->y + 12 + $this->currentCell,
|
||||
$this->width, $this->heightCell,1);
|
||||
$eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
|
||||
if ($field == $this->displayfield) {
|
||||
$showColor = 'none';
|
||||
}
|
||||
}
|
||||
$eps->rect(
|
||||
$this->x, $this->y + 12 + $this->currentCell,
|
||||
$this->width, $this->heightCell, 1
|
||||
);
|
||||
$eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -563,10 +614,11 @@ class Relation_Stats
|
||||
/**
|
||||
* The "Relation_Stats" constructor
|
||||
*
|
||||
* @param string master_table The master table name
|
||||
* @param string master_field The relation field in the master table
|
||||
* @param string foreign_table The foreign table name
|
||||
* @param string foreigh_field The relation field in the foreign table
|
||||
* @param string $master_table The master table name
|
||||
* @param string $master_field The relation field in the master table
|
||||
* @param string $foreign_table The foreign table name
|
||||
* @param string $foreign_field The relation field in the foreign table
|
||||
*
|
||||
* @see Relation_Stats::_getXy
|
||||
*/
|
||||
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
|
||||
@ -617,26 +669,36 @@ class Relation_Stats
|
||||
/**
|
||||
* Gets arrows coordinates
|
||||
*
|
||||
* @param string table The current table name
|
||||
* @param string column The relation column name
|
||||
* @param string $table The current table name
|
||||
* @param string $column The relation column name
|
||||
*
|
||||
* @return array Arrows coordinates
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function _getXy($table, $column)
|
||||
{
|
||||
$pos = array_search($column, $table->fields);
|
||||
// x_left, x_right, y
|
||||
return array($table->x, $table->x + $table->width, $table->y + ($pos + 1.5) * $table->heightCell);
|
||||
return array(
|
||||
$table->x,
|
||||
$table->x + $table->width,
|
||||
$table->y + ($pos + 1.5) * $table->heightCell
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* draws relation links and arrows
|
||||
* shows foreign key relations
|
||||
*
|
||||
* @param boolean changeColor Whether to use one color per relation or not
|
||||
* @global object The current EPS document
|
||||
* @param boolean $changeColor Whether to use one color per relation or not
|
||||
*
|
||||
* @global object The current EPS document
|
||||
*
|
||||
* @access public
|
||||
* @see PMA_EPS
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function relationDraw($changeColor)
|
||||
{
|
||||
@ -658,40 +720,58 @@ class Relation_Stats
|
||||
$color = 'black';
|
||||
}
|
||||
// draw a line like -- to foreign field
|
||||
$eps->line($this->xSrc,$this->ySrc,
|
||||
$this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
|
||||
$eps->line(
|
||||
$this->xSrc,
|
||||
$this->ySrc,
|
||||
$this->xSrc + $this->srcDir * $this->wTick,
|
||||
$this->ySrc,
|
||||
1
|
||||
);
|
||||
);
|
||||
// draw a line like -- to master field
|
||||
$eps->line($this->xDest + $this->destDir * $this->wTick, $this->yDest,
|
||||
$this->xDest, $this->yDest,
|
||||
$eps->line(
|
||||
$this->xDest + $this->destDir * $this->wTick,
|
||||
$this->yDest,
|
||||
$this->xDest,
|
||||
$this->yDest,
|
||||
1
|
||||
);
|
||||
);
|
||||
// draw a line that connects to master field line and foreign field line
|
||||
$eps->line($this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
|
||||
$this->xDest + $this->destDir * $this->wTick, $this->yDest,
|
||||
$eps->line(
|
||||
$this->xSrc + $this->srcDir * $this->wTick,
|
||||
$this->ySrc,
|
||||
$this->xDest + $this->destDir * $this->wTick,
|
||||
$this->yDest,
|
||||
1
|
||||
);
|
||||
);
|
||||
$root2 = 2 * sqrt(2);
|
||||
$eps->line($this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
|
||||
$this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick ,
|
||||
$this->ySrc + $this->wTick / $root2 ,
|
||||
$eps->line(
|
||||
$this->xSrc + $this->srcDir * $this->wTick * 0.75,
|
||||
$this->ySrc,
|
||||
$this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
|
||||
$this->ySrc + $this->wTick / $root2,
|
||||
1
|
||||
);
|
||||
$eps->line($this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
|
||||
$this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick ,
|
||||
$this->ySrc - $this->wTick / $root2 ,
|
||||
);
|
||||
$eps->line(
|
||||
$this->xSrc + $this->srcDir * $this->wTick * 0.75,
|
||||
$this->ySrc,
|
||||
$this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
|
||||
$this->ySrc - $this->wTick / $root2,
|
||||
1
|
||||
);
|
||||
$eps->line($this->xDest + $this->destDir * $this->wTick / 2 , $this->yDest ,
|
||||
);
|
||||
$eps->line(
|
||||
$this->xDest + $this->destDir * $this->wTick / 2,
|
||||
$this->yDest,
|
||||
$this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
|
||||
$this->yDest + $this->wTick / $root2 ,
|
||||
1);
|
||||
$eps->line($this->xDest + $this->destDir * $this->wTick / 2 ,
|
||||
$this->yDest , $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick ,
|
||||
$this->yDest - $this->wTick / $root2 ,
|
||||
$this->yDest + $this->wTick / $root2,
|
||||
1
|
||||
);
|
||||
);
|
||||
$eps->line(
|
||||
$this->xDest + $this->destDir * $this->wTick / 2,
|
||||
$this->yDest,
|
||||
$this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
|
||||
$this->yDest - $this->wTick / $root2,
|
||||
1
|
||||
);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -738,19 +818,26 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->setExportType($_POST['export_type']);
|
||||
|
||||
$eps = new PMA_EPS();
|
||||
$eps->setTitle(sprintf(__('Schema of the %s database - Page %s'), $db, $this->pageNumber));
|
||||
$eps->setTitle(
|
||||
sprintf(
|
||||
__('Schema of the %s database - Page %s'),
|
||||
$db,
|
||||
$this->pageNumber
|
||||
)
|
||||
);
|
||||
$eps->setAuthor('phpMyAdmin ' . PMA_VERSION);
|
||||
$eps->setDate(date("j F Y, g:i a"));
|
||||
$eps->setOrientation($this->orientation);
|
||||
$eps->setFont('Verdana','10');
|
||||
$eps->setFont('Verdana', '10');
|
||||
|
||||
|
||||
|
||||
$alltables = $this->getAllTables($db,$this->pageNumber);
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
|
||||
foreach ($alltables AS $table) {
|
||||
if (! isset($this->tables[$table])) {
|
||||
$this->tables[$table] = new Table_Stats($table,$eps->getFont(),$eps->getFontSize(), $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension);
|
||||
$this->tables[$table] = new Table_Stats(
|
||||
$table, $eps->getFont(), $eps->getFontSize(), $this->pageNumber,
|
||||
$this->_tablewidth, $this->showKeys, $this->tableDimension
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->sameWide) {
|
||||
@ -770,7 +857,11 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
* to do a === false and this is not PHP3 compatible)
|
||||
*/
|
||||
if (in_array($rel['foreign_table'], $alltables)) {
|
||||
$this->_addRelation($one_table,$eps->getFont(),$eps->getFontSize(), $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->tableDimension);
|
||||
$this->_addRelation(
|
||||
$one_table, $eps->getFont(), $eps->getFontSize(),
|
||||
$master_field, $rel['foreign_table'],
|
||||
$rel['foreign_field'], $this->tableDimension
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -788,33 +879,48 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
/**
|
||||
* Defines relation objects
|
||||
*
|
||||
* @param string masterTable The master table name
|
||||
* @param string masterField The relation field in the master table
|
||||
* @param string foreignTable The foreign table name
|
||||
* @param string foreignField The relation field in the foreign table
|
||||
* @param boolean showInfo Whether to display table position or not
|
||||
* @param string $masterTable The master table name
|
||||
* @param string $font The font
|
||||
* @param int $fontSize The font size
|
||||
* @param string $masterField The relation field in the master table
|
||||
* @param string $foreignTable The foreign table name
|
||||
* @param string $foreignField The relation field in the foreign table
|
||||
* @param boolean $showInfo Whether to display table position or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see _setMinMax,Table_Stats::__construct(),Relation_Stats::__construct()
|
||||
*/
|
||||
private function _addRelation($masterTable,$font,$fontSize, $masterField, $foreignTable, $foreignField, $showInfo)
|
||||
private function _addRelation($masterTable, $font, $fontSize, $masterField,
|
||||
$foreignTable, $foreignField, $showInfo)
|
||||
{
|
||||
if (! isset($this->tables[$masterTable])) {
|
||||
$this->tables[$masterTable] = new Table_Stats($masterTable, $font, $fontSize, $this->pageNumber, $this->_tablewidth, false, $showInfo);
|
||||
$this->tables[$masterTable] = new Table_Stats(
|
||||
$masterTable, $font, $fontSize, $this->pageNumber,
|
||||
$this->_tablewidth, false, $showInfo
|
||||
);
|
||||
}
|
||||
if (! isset($this->tables[$foreignTable])) {
|
||||
$this->tables[$foreignTable] = new Table_Stats($foreignTable,$font,$fontSize,$this->pageNumber, $this->_tablewidth, false, $showInfo);
|
||||
$this->tables[$foreignTable] = new Table_Stats(
|
||||
$foreignTable, $font, $fontSize, $this->pageNumber,
|
||||
$this->_tablewidth, false, $showInfo
|
||||
);
|
||||
}
|
||||
$this->_relations[] = new Relation_Stats($this->tables[$masterTable], $masterField, $this->tables[$foreignTable], $foreignField);
|
||||
$this->_relations[] = new Relation_Stats(
|
||||
$this->tables[$masterTable], $masterField,
|
||||
$this->tables[$foreignTable], $foreignField
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws relation arrows and lines
|
||||
* connects master table's master field to
|
||||
* Draws relation arrows and lines connects master table's master field to
|
||||
* foreign table's forein field
|
||||
*
|
||||
* @param boolean changeColor Whether to use one color per relation or not
|
||||
* @param boolean $changeColor Whether to use one color per relation or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see Relation_Stats::relationDraw()
|
||||
*/
|
||||
@ -828,8 +934,10 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
/**
|
||||
* Draws tables
|
||||
*
|
||||
* @param boolean changeColor Whether to show color for primary fields or not
|
||||
* @param boolean $changeColor Whether to show color for primary fields or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see Table_Stats::Table_Stats_tableDraw()
|
||||
*/
|
||||
|
||||
@ -144,7 +144,7 @@ class PMA_Schema_PDF extends PMA_PDF
|
||||
/**
|
||||
* Sets the scaled line width
|
||||
*
|
||||
* @param float width The line width
|
||||
* @param float $width The line width
|
||||
* @access public
|
||||
* @see TCPDF::SetLineWidth()
|
||||
*/
|
||||
@ -224,6 +224,10 @@ class PMA_Schema_PDF extends PMA_PDF
|
||||
|
||||
/**
|
||||
* Compute number of lines used by a multicell of width w
|
||||
*
|
||||
* @param int $w
|
||||
* @param string $txt
|
||||
* @return int
|
||||
*/
|
||||
function NbLines($w, $txt)
|
||||
{
|
||||
@ -386,7 +390,7 @@ class Table_Stats
|
||||
* Returns title of the current table,
|
||||
* title can have the dimensions of the table
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
private function _getTitle()
|
||||
{
|
||||
@ -401,7 +405,7 @@ class Table_Stats
|
||||
* @access private
|
||||
* @see PMA_Schema_PDF
|
||||
*/
|
||||
function _setWidth($fontSize)
|
||||
private function _setWidth($fontSize)
|
||||
{
|
||||
global $pdf;
|
||||
|
||||
@ -919,8 +923,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$pdf->SetX(10);
|
||||
$pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links['doc'][$table]['-']);
|
||||
// $pdf->Ln(1);
|
||||
$result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
|
||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||
$fields = PMA_DBI_get_columns($GLOBALS['db'], $table);
|
||||
foreach($fields as $row) {
|
||||
$pdf->SetX(20);
|
||||
$field_name = $row['Field'];
|
||||
$pdf->PMA_links['doc'][$table][$field_name] = $pdf->AddLink();
|
||||
|
||||
@ -440,7 +440,7 @@ class Table_Stats
|
||||
* @access private
|
||||
* @see PMA_SVG
|
||||
*/
|
||||
function _setWidthTable($font,$fontSize)
|
||||
private function _setWidthTable($font,$fontSize)
|
||||
{
|
||||
global $svg;
|
||||
|
||||
|
||||
@ -38,31 +38,52 @@ class PMA_User_Schema
|
||||
|
||||
public function processUserChoice()
|
||||
{
|
||||
global $action_choose,$db,$cfgRelation,$cfg,$query_default_option;
|
||||
global $action_choose, $db, $cfgRelation;
|
||||
|
||||
if (isset($this->action)) {
|
||||
switch ($this->action) {
|
||||
case 'selectpage':
|
||||
$this->chosenPage = $_REQUEST['chpage'];
|
||||
if ($action_choose=="1") {
|
||||
$this->deleteCoordinates($db, $cfgRelation, $this->chosenPage, $query_default_option);
|
||||
$this->deletePages($db, $cfgRelation, $this->chosenPage, $query_default_option);
|
||||
$this->deleteCoordinates(
|
||||
$db,
|
||||
$cfgRelation,
|
||||
$this->chosenPage
|
||||
);
|
||||
$this->deletePages(
|
||||
$db,
|
||||
$cfgRelation,
|
||||
$this->chosenPage
|
||||
);
|
||||
$this->chosenPage = 0;
|
||||
}
|
||||
break;
|
||||
case 'createpage':
|
||||
$this->pageNumber = PMA_REL_create_page($_POST['newpage'], $cfgRelation, $db, $query_default_option);
|
||||
$this->pageNumber = PMA_REL_create_page(
|
||||
$_POST['newpage'],
|
||||
$cfgRelation,
|
||||
$db
|
||||
);
|
||||
$this->autoLayoutForeign = isset($_POST['auto_layout_foreign']) ? "1":NULL;
|
||||
$this->autoLayoutInternal = isset($_POST['auto_layout_internal']) ? "1":NULL;
|
||||
$this->processRelations($db, $this->pageNumber,$cfgRelation,$query_default_option);
|
||||
$this->processRelations(
|
||||
$db,
|
||||
$this->pageNumber,
|
||||
$cfgRelation
|
||||
);
|
||||
break;
|
||||
case 'edcoord':
|
||||
$this->chosenPage = $_POST['chpage'];
|
||||
$this->c_table_rows = $_POST['c_table_rows'];
|
||||
$this->_editCoordinates($db, $cfgRelation,$query_default_option);
|
||||
$this->_editCoordinates($db, $cfgRelation);
|
||||
break;
|
||||
case 'delete_old_references':
|
||||
$this->_deleteTableRows($delrow,$cfgRelation,$db,$this->chosenPage);
|
||||
$this->_deleteTableRows(
|
||||
$delrow,
|
||||
$cfgRelation,
|
||||
$db,
|
||||
$this->chosenPage
|
||||
);
|
||||
break;
|
||||
case 'process_export':
|
||||
$this->_processExportSchema();
|
||||
@ -132,10 +153,10 @@ class PMA_User_Schema
|
||||
*/
|
||||
public function selectPage()
|
||||
{
|
||||
global $db,$table,$query_default_option,$cfgRelation;
|
||||
global $db,$table,$cfgRelation;
|
||||
$page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
|
||||
$page_rs = PMA_query_as_controluser($page_query, false, $query_default_option);
|
||||
$page_rs = PMA_query_as_controluser($page_query, false, PMA_DBI_QUERY_STORE);
|
||||
if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) {
|
||||
?>
|
||||
<form method="get" action="schema_edit.php" name="frm_select_page">
|
||||
@ -186,7 +207,7 @@ class PMA_User_Schema
|
||||
*/
|
||||
public function showTableDashBoard()
|
||||
{
|
||||
global $db,$cfgRelation,$table,$cfg,$with_field_names,$query_default_option;
|
||||
global $db, $cfgRelation, $table, $with_field_names;
|
||||
/*
|
||||
* We will need an array of all tables in this db
|
||||
*/
|
||||
@ -209,7 +230,7 @@ class PMA_User_Schema
|
||||
$page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
|
||||
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
|
||||
$page_rs = PMA_query_as_controluser($page_query, false, $query_default_option);
|
||||
$page_rs = PMA_query_as_controluser($page_query, false);
|
||||
$array_sh_page = array();
|
||||
while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
|
||||
$array_sh_page[] = $temp_sh_page;
|
||||
@ -420,6 +441,7 @@ class PMA_User_Schema
|
||||
*/
|
||||
private function _deleteTables($db, $chpage, $tabExist)
|
||||
{
|
||||
global $table;
|
||||
$_strtrans = '';
|
||||
$_strname = '';
|
||||
$shoot = false;
|
||||
@ -457,7 +479,7 @@ class PMA_User_Schema
|
||||
*/
|
||||
private function _displayScratchboardTables($array_sh_page)
|
||||
{
|
||||
global $with_field_names,$cfg,$db;
|
||||
global $with_field_names, $db;
|
||||
?>
|
||||
<script type="text/javascript" src="./js/dom-drag.js"></script>
|
||||
<form method="post" action="schema_edit.php" name="dragdrop">
|
||||
@ -474,31 +496,23 @@ class PMA_User_Schema
|
||||
$drag_x = $temp_sh_page['x'];
|
||||
$drag_y = $temp_sh_page['y'];
|
||||
|
||||
$draginit2 .= ' Drag.init(getElement("table_' . $i . '"), null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
|
||||
$draginit2 .= ' getElement("table_' . $i . '").onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n";
|
||||
$draginit .= ' getElement("table_' . $i . '").style.left = "' . $drag_x . 'px";' . "\n";
|
||||
$draginit .= ' getElement("table_' . $i . '").style.top = "' . $drag_y . 'px";' . "\n";
|
||||
$reset_draginit .= ' getElement("table_' . $i . '").style.left = "2px";' . "\n";
|
||||
$reset_draginit .= ' getElement("table_' . $i . '").style.top = "' . (15 * $i) . 'px";' . "\n";
|
||||
$draginit2 .= ' Drag.init($("#table_' . $i . '")[0], null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
|
||||
$draginit2 .= ' $("#table_' . $i . '")[0].onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n";
|
||||
$draginit .= ' $("#table_' . $i . '")[0].style.left = "' . $drag_x . 'px";' . "\n";
|
||||
$draginit .= ' $("#table_' . $i . '")[0].style.top = "' . $drag_y . 'px";' . "\n";
|
||||
$reset_draginit .= ' $("#table_' . $i . '")[0].style.left = "2px";' . "\n";
|
||||
$reset_draginit .= ' $("#table_' . $i . '")[0].style.top = "' . (15 * $i) . 'px";' . "\n";
|
||||
$reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
|
||||
$reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . (15 * $i) . '"' . "\n";
|
||||
|
||||
$local_query = 'SHOW FIELDS FROM '
|
||||
. PMA_backquote($temp_sh_page['table_name'])
|
||||
. ' FROM ' . PMA_backquote($db);
|
||||
$fields_rs = PMA_DBI_query($local_query);
|
||||
unset($local_query);
|
||||
$fields_cnt = PMA_DBI_num_rows($fields_rs);
|
||||
|
||||
echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
|
||||
if (isset($with_field_names)) {
|
||||
while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
|
||||
echo '<br />' . htmlspecialchars($row['Field']) . "\n";
|
||||
$fields = PMA_DBI_get_columns($db, $temp_sh_page['table_name']);
|
||||
foreach ($fields as $row) {
|
||||
echo '<br />' . htmlspecialchars($row['Field']) . "\n";
|
||||
}
|
||||
}
|
||||
echo '</div>' . "\n";
|
||||
PMA_DBI_free_result($fields_rs);
|
||||
unset($fields_rs);
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
@ -507,13 +521,13 @@ class PMA_User_Schema
|
||||
//<![CDATA[
|
||||
function PDFinit() {
|
||||
refreshLayout();
|
||||
myid = getElement('pdflayout');
|
||||
myid = $('#pdflayout')[0];
|
||||
<?php echo $draginit; ?>
|
||||
TableDragInit();
|
||||
}
|
||||
|
||||
function TableDragInit() {
|
||||
myid = getElement('pdflayout');
|
||||
myid = $('#pdflayout')[0];
|
||||
<?php echo $draginit2; ?>
|
||||
}
|
||||
|
||||
@ -543,7 +557,7 @@ class PMA_User_Schema
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($current_row) . '\'' . "\n"
|
||||
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($chpage) . '\'';
|
||||
echo $del_query;
|
||||
PMA_query_as_controluser($del_query, false, $query_default_option);
|
||||
PMA_query_as_controluser($del_query, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -584,12 +598,12 @@ class PMA_User_Schema
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
public function deleteCoordinates($db, $cfgRelation, $choosePage, $query_default_option)
|
||||
public function deleteCoordinates($db, $cfgRelation, $choosePage)
|
||||
{
|
||||
$query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
|
||||
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
|
||||
PMA_query_as_controluser($query, false, $query_default_option);
|
||||
PMA_query_as_controluser($query, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -601,12 +615,12 @@ class PMA_User_Schema
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
public function deletePages($db, $cfgRelation, $choosePage, $query_default_option)
|
||||
public function deletePages($db, $cfgRelation, $choosePage)
|
||||
{
|
||||
$query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
|
||||
. ' AND page_nr = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
|
||||
PMA_query_as_controluser($query, false, $query_default_option);
|
||||
PMA_query_as_controluser($query, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -618,7 +632,7 @@ class PMA_User_Schema
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
public function processRelations($db, $pageNumber, $cfgRelation, $query_default_option)
|
||||
public function processRelations($db, $pageNumber, $cfgRelation)
|
||||
{
|
||||
/*
|
||||
* A u t o m a t i c l a y o u t
|
||||
@ -662,10 +676,10 @@ class PMA_User_Schema
|
||||
*/
|
||||
$master_tables = 'SELECT COUNT(master_table), master_table'
|
||||
. ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
|
||||
. ' WHERE master_db = \'' . $db . '\''
|
||||
. ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
|
||||
. ' GROUP BY master_table'
|
||||
. ' ORDER BY ' . PMA_backquote('COUNT(master_table)') . ' DESC ';
|
||||
$master_tables_rs = PMA_query_as_controluser($master_tables, false, $query_default_option);
|
||||
. ' ORDER BY COUNT(master_table) DESC';
|
||||
$master_tables_rs = PMA_query_as_controluser($master_tables, false, PMA_DBI_QUERY_STORE);
|
||||
if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) {
|
||||
/* first put all the master tables at beginning
|
||||
* of the list, so they are near the center of
|
||||
@ -703,7 +717,7 @@ class PMA_User_Schema
|
||||
}
|
||||
|
||||
if (isset($this->autoLayoutInternal) || isset($this->autoLayoutForeign)) {
|
||||
$this->addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation,$query_default_option);
|
||||
$this->addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation);
|
||||
}
|
||||
|
||||
$this->chosenPage = $pageNumber;
|
||||
@ -719,7 +733,7 @@ class PMA_User_Schema
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
public function addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation,$query_default_option)
|
||||
public function addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation)
|
||||
{
|
||||
/*
|
||||
* Now generate the coordinates for the schema
|
||||
@ -737,7 +751,7 @@ class PMA_User_Schema
|
||||
$insert_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
|
||||
. '(db_name, table_name, pdf_page_number, x, y) '
|
||||
. 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($current_table) . '\',' . $pageNumber . ',' . $pos_x . ',' . $pos_y . ')';
|
||||
PMA_query_as_controluser($insert_query, false, $query_default_option);
|
||||
PMA_query_as_controluser($insert_query, false);
|
||||
|
||||
/*
|
||||
* compute for the next table
|
||||
@ -775,7 +789,7 @@ class PMA_User_Schema
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
private function _editCoordinates($db, $cfgRelation,$query_default_option)
|
||||
private function _editCoordinates($db, $cfgRelation)
|
||||
{
|
||||
for ($i = 0; $i < $this->c_table_rows; $i++) {
|
||||
$arrvalue = 'c_table_' . $i;
|
||||
@ -792,7 +806,7 @@ class PMA_User_Schema
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
|
||||
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
|
||||
$test_rs = PMA_query_as_controluser($test_query, false, $query_default_option);
|
||||
$test_rs = PMA_query_as_controluser($test_query, false, PMA_DBI_QUERY_STORE);
|
||||
//echo $test_query;
|
||||
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
|
||||
if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
|
||||
@ -813,7 +827,7 @@ class PMA_User_Schema
|
||||
. 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\', \'' . PMA_sqlAddSlashes($this->chosenPage) . '\',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
|
||||
}
|
||||
//echo $ch_query;
|
||||
PMA_query_as_controluser($ch_query, false, $query_default_option);
|
||||
PMA_query_as_controluser($ch_query, false);
|
||||
} // end if
|
||||
} // end for
|
||||
}
|
||||
|
||||
@ -280,13 +280,12 @@ class Table_Stats
|
||||
/**
|
||||
* Sets the width of the table
|
||||
*
|
||||
* @param string font The font name
|
||||
* @param integer fontSize The font size
|
||||
* @param string $font font name
|
||||
* @param integer $fontSize font size
|
||||
* @global object The current Visio XML document
|
||||
* @access private
|
||||
* @see PMA_VISIO
|
||||
*/
|
||||
function _setWidthTable($font,$fontSize)
|
||||
private function _setWidthTable($font,$fontSize)
|
||||
{
|
||||
global $visio;
|
||||
|
||||
|
||||
@ -11,6 +11,9 @@ if (! defined('PHPMYADMIN')) {
|
||||
|
||||
/**
|
||||
* Returns language name
|
||||
*
|
||||
* @param string $tmplang
|
||||
* @return string
|
||||
*/
|
||||
function PMA_langName($tmplang)
|
||||
{
|
||||
@ -182,6 +185,8 @@ function PMA_langDetect($str, $envType)
|
||||
* traditional) must be detected before 'zh' (chinese simplified) for
|
||||
* example.
|
||||
*
|
||||
* @param string $lang
|
||||
* @return array
|
||||
*/
|
||||
function PMA_langDetails($lang)
|
||||
{
|
||||
|
||||
@ -213,9 +213,7 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
|
||||
// Get the list and number of fields
|
||||
// we do a try_query here, because we could be in the query window,
|
||||
// trying to synchonize and the table has not yet been created
|
||||
$fields_list = PMA_DBI_fetch_result(
|
||||
'SHOW FULL COLUMNS FROM ' . PMA_backquote($db)
|
||||
. '.' . PMA_backquote($GLOBALS['table']));
|
||||
$fields_list = PMA_DBI_get_columns($db, $GLOBALS['table'], true);
|
||||
|
||||
$tmp_db_link = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
|
||||
. '?' . PMA_generate_common_url($db) . '"';
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
* @package phpMyAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function getSysInfo()
|
||||
{
|
||||
$supported = array('Linux','WINNT');
|
||||
|
||||
@ -101,7 +101,7 @@ if (false !== $possibly_uploaded_val) {
|
||||
}
|
||||
|
||||
// The Null checkbox was unchecked for this field
|
||||
if (empty($val) && isset($me_fields_null_prev[$key]) && ! isset($me_fields_null[$key])) {
|
||||
if (empty($val) && ! empty($me_fields_null_prev[$key]) && ! isset($me_fields_null[$key])) {
|
||||
$val = "''";
|
||||
}
|
||||
} // end else (field value in the form)
|
||||
|
||||
@ -3,74 +3,72 @@
|
||||
/**
|
||||
* Functions for the table-search page and zoom-search page
|
||||
*
|
||||
* Funtion PMA_tbl_getFields : Returns the fields of a table
|
||||
* Funtion PMA_tbl_search_getWhereClause : Returns the where clause for query generation
|
||||
* Funtion PMA_tbl_getFields : Returns the fields of a table
|
||||
* Funtion PMA_tbl_search_getWhereClause : Returns the where clause for query generation
|
||||
*
|
||||
* @package phpMyAdmin
|
||||
*/
|
||||
|
||||
require_once 'url_generating.lib.php';
|
||||
|
||||
/**
|
||||
* PMA_tbl_setTitle() sets the title for foreign keys display link
|
||||
*
|
||||
* @param $propertiesIconic Type of icon property
|
||||
* @param $themeImage Icon Image
|
||||
* @return string $str Value of the Title
|
||||
/**
|
||||
* Sets the title for foreign keys display link.
|
||||
*
|
||||
* @param mixed $propertiesIconic Type of icon property
|
||||
* @param string $pmaThemeImage Icon Image
|
||||
*
|
||||
* @return string $str Value of the Title
|
||||
*/
|
||||
|
||||
function PMA_tbl_setTitle($propertiesIconic,$pmaThemeImage){
|
||||
function PMA_tbl_setTitle($propertiesIconic, $pmaThemeImage)
|
||||
{
|
||||
if ($propertiesIconic == true) {
|
||||
$str = '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
|
||||
.'b_browse.png" alt="' . __('Browse foreign values') . '" title="'
|
||||
. __('Browse foreign values') . '" />';
|
||||
.'b_browse.png" alt="' . __('Browse foreign values') . '" title="'
|
||||
. __('Browse foreign values') . '" />';
|
||||
|
||||
if ($propertiesIconic === 'both') {
|
||||
$str .= __('Browse foreign values');
|
||||
return $str;
|
||||
}
|
||||
} else {
|
||||
return __('Browse foreign values');
|
||||
}
|
||||
if ($propertiesIconic === 'both') {
|
||||
$str .= __('Browse foreign values');
|
||||
}
|
||||
|
||||
return $str;
|
||||
} else {
|
||||
return __('Browse foreign values');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PMA_tbl_getFields() gets all the fields of a table along with their types,collations and whether null or not.
|
||||
/**
|
||||
* Gets all the fields of a table along with their types, collations
|
||||
* and whether null or not.
|
||||
*
|
||||
* @uses PMA_DBI_query()
|
||||
* @uses PMA_backquote()
|
||||
* @uses PMA_DBI_num_rows()
|
||||
* @uses PMA_DBI_fetch_assoc()
|
||||
* @uses PMA_DBI_free_result()
|
||||
* @uses preg_replace()
|
||||
* @uses str_replace()
|
||||
* @uses strncasecmp()
|
||||
* @uses empty()
|
||||
*
|
||||
* @param $db Selected database
|
||||
* @param $table Selected table
|
||||
*
|
||||
* @return array($fields_list,$fields_type,$fields_collation,$fields_null) Array containing the field list, field types, collations and null constatint
|
||||
* @param string $table Selected table
|
||||
* @param string $db Selected database
|
||||
*
|
||||
* @return array Array containing the field list, field types, collations
|
||||
* and null constraint
|
||||
*/
|
||||
|
||||
function PMA_tbl_getFields($table,$db) {
|
||||
|
||||
function PMA_tbl_getFields($table,$db)
|
||||
{
|
||||
// Gets the list and number of fields
|
||||
|
||||
$result = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
|
||||
$fields_cnt = PMA_DBI_num_rows($result);
|
||||
$fields = PMA_DBI_get_columns($db, $table, true);
|
||||
$fields_list = $fields_null = $fields_type = $fields_collation = array();
|
||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||
$geom_column_present = false;
|
||||
$geom_types = PMA_getGISDatatypes();
|
||||
|
||||
foreach ($fields as $row) {
|
||||
$fields_list[] = $row['Field'];
|
||||
$type = $row['Type'];
|
||||
|
||||
// check whether table contains geometric columns
|
||||
if (in_array($type, $geom_types)) {
|
||||
$geom_column_present = true;
|
||||
}
|
||||
|
||||
// reformat mysql query output
|
||||
if (strncasecmp($type, 'set', 3) == 0
|
||||
|| strncasecmp($type, 'enum', 4) == 0) {
|
||||
|| strncasecmp($type, 'enum', 4) == 0
|
||||
) {
|
||||
$type = str_replace(',', ', ', $type);
|
||||
} else {
|
||||
|
||||
// strip the "BINARY" attribute, except if we find "BINARY(" because
|
||||
// this would be a BINARY or VARBINARY field type
|
||||
if (!preg_match('@BINARY[\(]@i', $type)) {
|
||||
@ -86,47 +84,49 @@ function PMA_tbl_getFields($table,$db) {
|
||||
}
|
||||
$fields_null[] = $row['Null'];
|
||||
$fields_type[] = $type;
|
||||
$fields_collation[] = !empty($row['Collation']) && $row['Collation'] != 'NULL'
|
||||
? $row['Collation']
|
||||
: '';
|
||||
$fields_collation[] = ! empty($row['Collation']) && $row['Collation'] != 'NULL'
|
||||
? $row['Collation']
|
||||
: '';
|
||||
} // end while
|
||||
PMA_DBI_free_result($result);
|
||||
unset($result, $type);
|
||||
|
||||
return array($fields_list,$fields_type,$fields_collation,$fields_null);
|
||||
|
||||
return array($fields_list, $fields_type, $fields_collation, $fields_null, $geom_column_present);
|
||||
}
|
||||
|
||||
/* PMA_tbl_setTableHeader() sets the table header for displaying a table in query-by-example format
|
||||
/**
|
||||
* Sets the table header for displaying a table in query-by-example format.
|
||||
*
|
||||
* @return HTML content, the tags and content for table header
|
||||
* @param bool $geom_column_present whether a geometry column is present
|
||||
*
|
||||
* @return HTML content, the tags and content for table header
|
||||
*/
|
||||
function PMA_tbl_setTableHeader($geom_column_present = false)
|
||||
{
|
||||
// Display the Function column only if there is alteast one geomety colum
|
||||
$func = '';
|
||||
if ($geom_column_present) {
|
||||
$func = '<th>' . __('Function') . '</th>';
|
||||
}
|
||||
|
||||
function PMA_tbl_setTableHeader(){
|
||||
|
||||
return '<thead>
|
||||
<tr><th>' . __('Column') . '</th>
|
||||
return '<thead>
|
||||
<tr>' . $func . '<th>' . __('Column') . '</th>
|
||||
<th>' . __('Type') . '</th>
|
||||
<th>' . __('Collation') . '</th>
|
||||
<th>' . __('Operator') . '</th>
|
||||
<th>' . __('Value') . '</th>
|
||||
</tr>
|
||||
</tr>
|
||||
</thead>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* PMA_tbl_getSubTabs() returns an array with necessary configrations to create sub-tabs(Table Search and Zoom Search) in the table_select page
|
||||
*
|
||||
* @return array $subtabs Array containing configuration (icon,text,link,id,args) of sub-tabs for Table Search and Zoom search
|
||||
/**
|
||||
* Returns an array with necessary configrations to create
|
||||
* sub-tabs(Table Search and Zoom Search) in the table_select page.
|
||||
*
|
||||
* @return array Array containing configuration (icon, text, link, id, args)
|
||||
* of sub-tabs for Table Search and Zoom search
|
||||
*/
|
||||
|
||||
function PMA_tbl_getSubTabs(){
|
||||
|
||||
function PMA_tbl_getSubTabs()
|
||||
{
|
||||
$subtabs = array();
|
||||
|
||||
$subtabs['search']['icon'] = 'b_search.png';
|
||||
$subtabs['search']['text'] = __('Table Search');
|
||||
$subtabs['search']['link'] = 'tbl_select.php';
|
||||
@ -137,147 +137,189 @@ function PMA_tbl_getSubTabs(){
|
||||
$subtabs['zoom']['link'] = 'tbl_zoom_select.php';
|
||||
$subtabs['zoom']['text'] = __('Zoom Search');
|
||||
$subtabs['zoom']['id'] = 'zoom_search_id';
|
||||
|
||||
return $subtabs;
|
||||
|
||||
return $subtabs;
|
||||
}
|
||||
|
||||
|
||||
/* PMA_tbl_getForeignFields_Values() creates the HTML content for: 1) Browsing foreign data for a field. 2) Creating elements for search criteria input on fields.
|
||||
/**
|
||||
* Creates the HTML content for:
|
||||
* 1) Browsing foreign data for a field.
|
||||
* 2) Creating elements for search criteria input on fields.
|
||||
*
|
||||
* @uses PMA_foreignDropdown
|
||||
* @uses PMA_generate_common_url
|
||||
* @uses isset()
|
||||
* @uses is_array()
|
||||
* @uses in_array()
|
||||
* @uses urlencode()
|
||||
* @uses str_replace()
|
||||
* @uses stbstr()
|
||||
*
|
||||
* @param $foreigners Array of foreign keys
|
||||
* @param $foreignData Foreign keys data
|
||||
* @param $field Column name
|
||||
* @param $tbl_fields_type Column type
|
||||
* @param $i Column index
|
||||
* @param $db Selected database
|
||||
* @param $table Selected table
|
||||
* @param $titles Selected title
|
||||
* @param $foreignMaxLimit Max limit of displaying foreign elements
|
||||
* @param $fields Array of search criteria inputs
|
||||
*
|
||||
* @return string $str HTML content for viewing foreing data and elements for search criteria input.
|
||||
* @param array $foreigners Array of foreign keys
|
||||
* @param array $foreignData Foreign keys data
|
||||
* @param string $field Column name
|
||||
* @param string $tbl_fields_type Column type
|
||||
* @param int $i Column index
|
||||
* @param string $db Selected database
|
||||
* @param string $table Selected table
|
||||
* @param array $titles Selected title
|
||||
* @param int $foreignMaxLimit Max limit of displaying foreign elements
|
||||
* @param array $fields Array of search criteria inputs
|
||||
* @param bool $in_fbs Whether we are in 'function based search'
|
||||
*
|
||||
* @return string HTML content for viewing foreing data and elements
|
||||
* for search criteria input.
|
||||
*/
|
||||
|
||||
function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table,$titles,$foreignMaxLimit, $fields){
|
||||
|
||||
function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false)
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) {
|
||||
// f o r e i g n k e y s
|
||||
$str .= ' <select name="fields[' . $i . ']" id="fieldID_' . $i .'">' . "\n";
|
||||
$str .= '<select name="fields[' . $i . ']" id="fieldID_' . $i .'">' . "\n";
|
||||
// go back to first row
|
||||
// here, the 4th parameter is empty because there is no current
|
||||
// value of data for the dropdown (the search page initial values
|
||||
// are displayed empty)
|
||||
$str .= PMA_foreignDropdown($foreignData['disp_row'],
|
||||
$foreignData['foreign_field'],
|
||||
$foreignData['foreign_display'],
|
||||
'', $foreignMaxLimit);
|
||||
$str .= ' </select>' . "\n";
|
||||
}
|
||||
elseif ($foreignData['foreign_link'] == true) {
|
||||
$str .= PMA_foreignDropdown(
|
||||
$foreignData['disp_row'], $foreignData['foreign_field'],
|
||||
$foreignData['foreign_display'], '', $foreignMaxLimit
|
||||
);
|
||||
$str .= '</select>' . "\n";
|
||||
|
||||
} elseif ($foreignData['foreign_link'] == true) {
|
||||
if(isset($fields[$i]) && is_string($fields[$i])){
|
||||
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] " value="' . $fields[$i] . '"';
|
||||
'id="field_' . md5($field) . '[' . $i .']"
|
||||
class="textfield"/>' ;
|
||||
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] " value="' . $fields[$i] . '"';
|
||||
'id="field_' . md5($field) . '[' . $i .']"
|
||||
class="textfield"/>' ;
|
||||
}
|
||||
else{
|
||||
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] "';
|
||||
'id="field_' . md5($field) . '[' . $i .']"
|
||||
class="textfield" />' ;
|
||||
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] "';
|
||||
'id="field_' . md5($field) . '[' . $i .']"
|
||||
class="textfield" />' ;
|
||||
}
|
||||
?>
|
||||
<?php $str .= '<script type="text/javascript">';
|
||||
<?php $str .= '<script type="text/javascript">';
|
||||
// <![CDATA[
|
||||
$str .= <<<EOT
|
||||
<a target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes'); return false" href="browse_foreigners.php?
|
||||
$str .= <<<EOT
|
||||
<a target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes'); return false" href="browse_foreigners.php?
|
||||
EOT;
|
||||
$str .= '' . PMA_generate_common_url($db, $table) . '&field=' . urlencode($field) . '&fieldkey=' . $i . '">' . str_replace("'", "\'", $titles['Browse']) . '</a>';
|
||||
// ]]
|
||||
$str .= '</script>';
|
||||
}
|
||||
elseif (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0) {
|
||||
|
||||
} elseif (in_array($tbl_fields_type[$i], PMA_getGISDatatypes())) {
|
||||
// g e o m e t r y
|
||||
$str .= '<input type="text" name="fields[' . $i . ']"'
|
||||
.' size="40" class="textfield" id="field_' . $i . '" />' . "\n";
|
||||
|
||||
if ($in_fbs) {
|
||||
$edit_url = 'gis_data_editor.php?' . PMA_generate_common_url();
|
||||
$edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'), true);
|
||||
$str .= '<span class="open_search_gis_editor">';
|
||||
$str .= PMA_linkOrButton($edit_url, $edit_str, array(), false, false, '_blank');
|
||||
$str .= '</span>';
|
||||
}
|
||||
|
||||
} elseif (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0) {
|
||||
// e n u m s
|
||||
$enum_value=explode(', ', str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)));
|
||||
$cnt_enum_value = count($enum_value);
|
||||
$str .= '<select name="fields[' . ($i) . '][]" id="fieldID_' . $i .'"'
|
||||
.' multiple="multiple" size="' . min(3, $cnt_enum_value) . '">' . "\n";
|
||||
for ($j = 0; $j < $cnt_enum_value; $j++) {
|
||||
if(isset($fields[$i]) && is_array($fields[$i]) && in_array($enum_value[$j],$fields[$i])){
|
||||
$str .= ' <option value="' . $enum_value[$j] . '" Selected>'
|
||||
. $enum_value[$j] . '</option>';
|
||||
}
|
||||
else{
|
||||
$str .= ' <option value="' . $enum_value[$j] . '">'
|
||||
. $enum_value[$j] . '</option>';
|
||||
}
|
||||
} // end for
|
||||
$str .= ' </select>' . "\n";
|
||||
}
|
||||
else {
|
||||
.' multiple="multiple" size="' . min(3, $cnt_enum_value) . '">' . "\n";
|
||||
|
||||
for ($j = 0; $j < $cnt_enum_value; $j++) {
|
||||
if (isset($fields[$i])
|
||||
&& is_array($fields[$i])
|
||||
&& in_array($enum_value[$j], $fields[$i])
|
||||
) {
|
||||
$str .= '<option value="' . $enum_value[$j] . '" Selected>'
|
||||
. $enum_value[$j] . '</option>';
|
||||
} else {
|
||||
$str .= '<option value="' . $enum_value[$j] . '">'
|
||||
. $enum_value[$j] . '</option>';
|
||||
}
|
||||
} // end for
|
||||
$str .= '</select>' . "\n";
|
||||
|
||||
} else {
|
||||
// o t h e r c a s e s
|
||||
$the_class = 'textfield';
|
||||
$type = $tbl_fields_type[$i];
|
||||
|
||||
if ($type == 'date') {
|
||||
$the_class .= ' datefield';
|
||||
} elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
|
||||
$the_class .= ' datetimefield';
|
||||
}
|
||||
if(isset($fields[$i]) && is_string($fields[$i])){
|
||||
$str .= ' <input type="text" name="fields[' . $i . ']" '
|
||||
.' size="40" class="' . $the_class . '" id="fieldID_' . $i .'" value = "' . $fields[$i] . '"/>' . "\n";
|
||||
}
|
||||
else{
|
||||
$str .= ' <input type="text" name="fields[' . $i . ']"'
|
||||
.' size="40" class="' . $the_class . '" id="fieldID_' . $i .'" />' . "\n";
|
||||
}
|
||||
};
|
||||
return $str;
|
||||
|
||||
if (isset($fields[$i]) && is_string($fields[$i])) {
|
||||
$str .= '<input type="text" name="fields[' . $i . ']"'
|
||||
.' size="40" class="' . $the_class . '" id="fieldID_'
|
||||
. $i .'" value = "' . $fields[$i] . '"/>' . "\n";
|
||||
} else {
|
||||
$str .= '<input type="text" name="fields[' . $i . ']"'
|
||||
.' size="40" class="' . $the_class . '" id="fieldID_'
|
||||
. $i .'" />' . "\n";
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
/* PMA_tbl_search_getWhereClause() Return the where clause for query generation based on the inputs provided.
|
||||
/**
|
||||
* Return the where clause for query generation based on the inputs provided.
|
||||
*
|
||||
* @uses PMA_backquote
|
||||
* @uses PMA_sqlAddslashes
|
||||
* @uses preg_match
|
||||
* @uses isset()
|
||||
* @uses in_array()
|
||||
* @uses str_replace()
|
||||
* @uses strpos()
|
||||
* @uses explode()
|
||||
* @uses trim()
|
||||
*
|
||||
* @param $fields Search criteria input
|
||||
* @param $names Name of the field(column) on which search criteria is submitted
|
||||
* @param $types Type of the field
|
||||
* @param $collations Field collation
|
||||
* @param $func_type Search fucntion/operator
|
||||
* @param $unaryFlag Whether operator unary or not
|
||||
*
|
||||
* @return string $str HTML content for viewing foreing data and elements for search criteria input.
|
||||
* @param mixed $fields Search criteria input
|
||||
* @param string $names Name of the column on which search is submitted
|
||||
* @param string $types Type of the field
|
||||
* @param string $collations Field collation
|
||||
* @param string $func_type Search fucntion/operator
|
||||
* @param bool $unaryFlag Whether operator unary or not
|
||||
* @param bool $geom_func Whether geometry functions should be applied
|
||||
*
|
||||
* @return string HTML content for viewing foreing data and elements
|
||||
* for search criteria input.
|
||||
*/
|
||||
function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type, $unaryFlag, $geom_func = null)
|
||||
{
|
||||
/**
|
||||
* @todo move this to a more apropriate place
|
||||
*/
|
||||
$geom_unary_functions = array(
|
||||
'IsEmpty' => 1,
|
||||
'IsSimple' => 1,
|
||||
'IsRing' => 1,
|
||||
'IsClosed' => 1,
|
||||
);
|
||||
|
||||
function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type, $unaryFlag){
|
||||
|
||||
$w = '';
|
||||
// If geometry function is set apply it to the field name
|
||||
if ($geom_func != null && trim($geom_func) != '') {
|
||||
// Get details about the geometry fucntions
|
||||
$geom_funcs = PMA_getGISFunctions($types, true, false);
|
||||
|
||||
$w = '';
|
||||
if($unaryFlag){
|
||||
// If the function takes a single parameter
|
||||
if ($geom_funcs[$geom_func]['params'] == 1) {
|
||||
$backquoted_name = $geom_func . '(' . PMA_backquote($names) . ')';
|
||||
} else {
|
||||
// If the function takes two parameters
|
||||
// create gis data from the string
|
||||
$gis_data = PMA_createGISData($fields);
|
||||
|
||||
$w = $geom_func . '(' . PMA_backquote($names) . ',' . $gis_data . ')';
|
||||
return $w;
|
||||
}
|
||||
|
||||
// New output type is the output type of the function being applied
|
||||
$types = $geom_funcs[$geom_func]['type'];
|
||||
|
||||
// If the where clause is something like 'IsEmpty(`spatial_col_name`)'
|
||||
if (isset($geom_unary_functions[$geom_func]) && trim($fields) == '') {
|
||||
$w = $backquoted_name;
|
||||
return $w;
|
||||
}
|
||||
} else {
|
||||
$backquoted_name = PMA_backquote($names);
|
||||
}
|
||||
|
||||
if ($unaryFlag) {
|
||||
$fields = '';
|
||||
$w = PMA_backquote($names) . ' ' . $func_type;
|
||||
$w = $backquoted_name . ' ' . $func_type;
|
||||
|
||||
} elseif (in_array($types, PMA_getGISDatatypes()) && ! empty($fields)) {
|
||||
// create gis data from the string
|
||||
$gis_data = PMA_createGISData($fields);
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . $gis_data;
|
||||
|
||||
} elseif (strncasecmp($types, 'enum', 4) == 0) {
|
||||
if (!empty($fields)) {
|
||||
@ -295,23 +337,25 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
$parens_open = '(';
|
||||
$parens_close = ')';
|
||||
|
||||
} else {
|
||||
$parens_open = '';
|
||||
$parens_close = '';
|
||||
}
|
||||
$enum_where = '\'' . PMA_sqlAddslashes($fields[0]) . '\'';
|
||||
for ($e = 1; $e < $enum_selected_count; $e++) {
|
||||
$enum_where .= ', \'' . PMA_sqlAddslashes($fields[$e]) . '\'';
|
||||
}
|
||||
} else {
|
||||
$parens_open = '';
|
||||
$parens_close = '';
|
||||
}
|
||||
$enum_where = '\'' . PMA_sqlAddslashes($fields[0]) . '\'';
|
||||
for ($e = 1; $e < $enum_selected_count; $e++) {
|
||||
$enum_where .= ', \'' . PMA_sqlAddslashes($fields[$e]) . '\'';
|
||||
}
|
||||
|
||||
$w = PMA_backquote($names) . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close;
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close;
|
||||
}
|
||||
|
||||
} elseif ($fields != '') {
|
||||
// For these types we quote the value. Even if it's another type (like INT),
|
||||
// for a LIKE we always quote the value. MySQL converts strings to numbers
|
||||
// and numbers to strings as necessary during the comparison
|
||||
if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types) || strpos(' ' . $func_type, 'LIKE')) {
|
||||
if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types)
|
||||
|| strpos(' ' . $func_type, 'LIKE')
|
||||
) {
|
||||
$quot = '\'';
|
||||
} else {
|
||||
$quot = '';
|
||||
@ -327,23 +371,28 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
$fields = '^' . $fields . '$';
|
||||
}
|
||||
|
||||
if ($func_type == 'IN (...)' || $func_type == 'NOT IN (...)' || $func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN') {
|
||||
if ($func_type == 'IN (...)'
|
||||
|| $func_type == 'NOT IN (...)'
|
||||
|| $func_type == 'BETWEEN'
|
||||
|| $func_type == 'NOT BETWEEN'
|
||||
) {
|
||||
$func_type = str_replace(' (...)', '', $func_type);
|
||||
|
||||
// quote values one by one
|
||||
$values = explode(',', $fields);
|
||||
foreach ($values as &$value)
|
||||
$value = $quot . PMA_sqlAddslashes(trim($value)) . $quot;
|
||||
// quote values one by one
|
||||
$values = explode(',', $fields);
|
||||
foreach ($values as &$value) {
|
||||
$value = $quot . PMA_sqlAddslashes(trim($value)) . $quot;
|
||||
}
|
||||
|
||||
if ($func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN')
|
||||
$w = PMA_backquote($names) . ' ' . $func_type . ' ' . (isset($values[0]) ? $values[0] : '') . ' AND ' . (isset($values[1]) ? $values[1] : '');
|
||||
else
|
||||
$w = PMA_backquote($names) . ' ' . $func_type . ' (' . implode(',', $values) . ')';
|
||||
if ($func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN') {
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . (isset($values[0]) ? $values[0] : '')
|
||||
. ' AND ' . (isset($values[1]) ? $values[1] : '');
|
||||
} else {
|
||||
$w = $backquoted_name . ' ' . $func_type . ' (' . implode(',', $values) . ')';
|
||||
}
|
||||
} else {
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . $quot . PMA_sqlAddslashes($fields) . $quot;;
|
||||
}
|
||||
else {
|
||||
$w = PMA_backquote($names) . ' ' . $func_type . ' ' . $quot . PMA_sqlAddslashes($fields) . $quot;;
|
||||
}
|
||||
|
||||
} // end if
|
||||
|
||||
return $w;
|
||||
@ -352,14 +401,14 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
/**
|
||||
* Formats a SVG plot for the query results.
|
||||
*
|
||||
* @param array $data Data for the status chart
|
||||
* @param array &$settings Settings used to generate the chart
|
||||
* @param array $data Data for the status chart
|
||||
* @param array &$settings Settings used to generate the chart
|
||||
*
|
||||
* @return string HTML and JS code for the SVG plot
|
||||
*/
|
||||
function PMA_SVG_scatter_plot($data, &$settings)
|
||||
{
|
||||
require_once './libraries/svg_plot/pma_scatter_plot.php';
|
||||
include_once './libraries/svg_plot/pma_scatter_plot.php';
|
||||
|
||||
if (empty($data)) {
|
||||
// empty data
|
||||
@ -376,15 +425,5 @@ function PMA_SVG_scatter_plot($data, &$settings)
|
||||
}
|
||||
return $scatter_plot->asSVG();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@ -19,23 +19,26 @@
|
||||
* // }
|
||||
* </code>
|
||||
*
|
||||
* @param string $option_string comma separated options
|
||||
* @return array options
|
||||
* @param string $option_string comma separated options
|
||||
*
|
||||
* @return array options
|
||||
*/
|
||||
function PMA_transformation_getOptions($option_string)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
if (! strlen($option_string)
|
||||
|| ! $transform_options = preg_split('/,/', $option_string)) {
|
||||
|| ! $transform_options = preg_split('/,/', $option_string)
|
||||
) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
while (($option = array_shift($transform_options)) !== null) {
|
||||
$trimmed = trim($option);
|
||||
if (strlen($trimmed) > 1
|
||||
&& $trimmed[0] == "'"
|
||||
&& $trimmed[strlen($trimmed) - 1] == "'") {
|
||||
&& $trimmed[0] == "'"
|
||||
&& $trimmed[strlen($trimmed) - 1] == "'"
|
||||
) {
|
||||
// '...'
|
||||
$option = substr($trimmed, 1, -1);
|
||||
} elseif (isset($trimmed[0]) && $trimmed[0] == "'") {
|
||||
@ -117,11 +120,13 @@ function PMA_getAvailableMIMEtypes()
|
||||
/**
|
||||
* Gets the mimetypes for all columns of a table
|
||||
*
|
||||
* @param string $db the name of the db to check for
|
||||
* @param string $table the name of the table to check for
|
||||
* @param string $strict whether to include only results having a mimetype set
|
||||
*
|
||||
* @access public
|
||||
* @param string $db the name of the db to check for
|
||||
* @param string $table the name of the table to check for
|
||||
* @param string $strict whether to include only results having a mimetype set
|
||||
* @return array [field_name][field_key] = field_value
|
||||
*
|
||||
* @return array [field_name][field_key] = field_value
|
||||
*/
|
||||
function PMA_getMIME($db, $table, $strict = false)
|
||||
{
|
||||
@ -136,7 +141,7 @@ function PMA_getMIME($db, $table, $strict = false)
|
||||
`mimetype`,
|
||||
`transformation`,
|
||||
`transformation_options`
|
||||
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
|
||||
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
|
||||
WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\'
|
||||
AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\'
|
||||
AND ( `mimetype` != \'\'' . (!$strict ? '
|
||||
@ -148,14 +153,17 @@ function PMA_getMIME($db, $table, $strict = false)
|
||||
/**
|
||||
* Set a single mimetype to a certain value.
|
||||
*
|
||||
* @param string $db the name of the db
|
||||
* @param string $table the name of the table
|
||||
* @param string $key the name of the column
|
||||
* @param string $mimetype the mimetype of the column
|
||||
* @param string $transformation the transformation of the column
|
||||
* @param string $transformation_options the transformation options of the column
|
||||
* @param string $forcedelete force delete, will erase any existing
|
||||
* comments for this column
|
||||
*
|
||||
* @access public
|
||||
* @param string $db the name of the db
|
||||
* @param string $table the name of the table
|
||||
* @param string $key the name of the column
|
||||
* @param string $mimetype the mimetype of the column
|
||||
* @param string $transformation the transformation of the column
|
||||
* @param string $transformation_options the transformation options of the column
|
||||
* @param string $forcedelete force delete, will erase any existing comments for this column
|
||||
*
|
||||
* @return boolean true, if comment-query was made.
|
||||
*/
|
||||
function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
|
||||
@ -181,8 +189,9 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
|
||||
PMA_DBI_free_result($test_rs);
|
||||
|
||||
if (! $forcedelete
|
||||
&& (strlen($mimetype) || strlen($transformation)
|
||||
|| strlen($transformation_options) || strlen($row['comment']))) {
|
||||
&& (strlen($mimetype) || strlen($transformation)
|
||||
|| strlen($transformation_options) || strlen($row['comment']))
|
||||
) {
|
||||
$upd_query = '
|
||||
UPDATE ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
|
||||
SET `mimetype` = \'' . PMA_sqlAddSlashes($mimetype) . '\',
|
||||
|
||||
@ -9,13 +9,14 @@
|
||||
/**
|
||||
* Generates text with hidden inputs.
|
||||
*
|
||||
* @see PMA_generate_common_url()
|
||||
* @param string optional database name
|
||||
* (can also be an array of parameters)
|
||||
* @param string optional table name
|
||||
* @param int indenting level
|
||||
* @param string do not generate a hidden field for this parameter
|
||||
* (can be an array of strings)
|
||||
* @param string $db optional database name
|
||||
* (can also be an array of parameters)
|
||||
* @param string $table optional table name
|
||||
* @param int $indent indenting level
|
||||
* @param string $skip do not generate a hidden field for this parameter
|
||||
* (can be an array of strings)
|
||||
*
|
||||
* @see PMA_generate_common_url()
|
||||
*
|
||||
* @return string string with input fields
|
||||
*
|
||||
@ -27,7 +28,6 @@
|
||||
* @global boolean whether recoding is allowed or not
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $skip = array())
|
||||
{
|
||||
@ -48,15 +48,16 @@ function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $
|
||||
}
|
||||
|
||||
if (! empty($GLOBALS['server'])
|
||||
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']) {
|
||||
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']
|
||||
) {
|
||||
$params['server'] = $GLOBALS['server'];
|
||||
}
|
||||
if (empty($_COOKIE['pma_lang'])
|
||||
&& ! empty($GLOBALS['lang'])) {
|
||||
if (empty($_COOKIE['pma_lang']) && ! empty($GLOBALS['lang'])) {
|
||||
$params['lang'] = $GLOBALS['lang'];
|
||||
}
|
||||
if (empty($_COOKIE['pma_collation_connection'])
|
||||
&& ! empty($GLOBALS['collation_connection'])) {
|
||||
&& ! empty($GLOBALS['collation_connection'])
|
||||
) {
|
||||
$params['collation_connection'] = $GLOBALS['collation_connection'];
|
||||
}
|
||||
|
||||
@ -102,8 +103,9 @@ function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $
|
||||
* <input type="hidden" name="ccc[b]" Value="ccc_b" />
|
||||
* </code>
|
||||
*
|
||||
* @param array $values
|
||||
* @param string $pre
|
||||
* @param array $values hidden values
|
||||
* @param string $pre prefix
|
||||
*
|
||||
* @return string form fields of type hidden
|
||||
*/
|
||||
function PMA_getHiddenFields($values, $pre = '')
|
||||
@ -160,19 +162,20 @@ function PMA_getHiddenFields($values, $pre = '')
|
||||
* // script.php?server=1&lang=en
|
||||
* </code>
|
||||
*
|
||||
* @param mixed assoc. array with url params or optional string with database name
|
||||
* if first param is an array there is also an ? prefixed to the url
|
||||
* @param mixed assoc. array with url params or optional string with database name
|
||||
* if first param is an array there is also an ? prefixed to the url
|
||||
*
|
||||
* @param string - if first param is array: 'html' to use htmlspecialchars()
|
||||
* on the resulting URL (for a normal URL displayed in HTML)
|
||||
* or something else to avoid using htmlspecialchars() (for
|
||||
* a URL sent via a header); if not set,'html' is assumed
|
||||
* - if first param is not array: optional table name
|
||||
* @param string - if first param is array: 'html' to use htmlspecialchars()
|
||||
* on the resulting URL (for a normal URL displayed in HTML)
|
||||
* or something else to avoid using htmlspecialchars() (for
|
||||
* a URL sent via a header); if not set,'html' is assumed
|
||||
* - if first param is not array: optional table name
|
||||
*
|
||||
* @param string - if first param is array: optional character to
|
||||
* use instead of '?'
|
||||
* - if first param is not array: optional character to use
|
||||
* instead of '&' for dividing URL parameters
|
||||
*
|
||||
* @param string - if first param is array: optional character to
|
||||
* use instead of '?'
|
||||
* - if first param is not array: optional character to use
|
||||
* instead of '&' for dividing URL parameters
|
||||
* @return string string with URL parameters
|
||||
* @access public
|
||||
*/
|
||||
@ -219,17 +222,18 @@ function PMA_generate_common_url()
|
||||
|
||||
if (isset($GLOBALS['server'])
|
||||
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']
|
||||
// avoid overwriting when creating navi panel links to servers
|
||||
&& ! isset($params['server'])) {
|
||||
// avoid overwriting when creating navi panel links to servers
|
||||
&& ! isset($params['server'])
|
||||
) {
|
||||
$params['server'] = $GLOBALS['server'];
|
||||
}
|
||||
|
||||
if (empty($_COOKIE['pma_lang'])
|
||||
&& ! empty($GLOBALS['lang'])) {
|
||||
if (empty($_COOKIE['pma_lang']) && ! empty($GLOBALS['lang'])) {
|
||||
$params['lang'] = $GLOBALS['lang'];
|
||||
}
|
||||
if (empty($_COOKIE['pma_collation_connection'])
|
||||
&& ! empty($GLOBALS['collation_connection'])) {
|
||||
&& ! empty($GLOBALS['collation_connection'])
|
||||
) {
|
||||
$params['collation_connection'] = $GLOBALS['collation_connection'];
|
||||
}
|
||||
|
||||
@ -256,7 +260,9 @@ function PMA_generate_common_url()
|
||||
* extracted from arg_separator.input as set in php.ini
|
||||
* we do not use arg_separator.output to avoid problems with & and &
|
||||
*
|
||||
* @param string whether to encode separator or not, currently 'none' or 'html'
|
||||
* @param string $encode whether to encode separator or not,
|
||||
* currently 'none' or 'html'
|
||||
*
|
||||
* @return string character used for separating url parts usally ; or &
|
||||
* @access public
|
||||
*/
|
||||
@ -278,13 +284,13 @@ function PMA_get_arg_separator($encode = 'none')
|
||||
}
|
||||
|
||||
switch ($encode) {
|
||||
case 'html':
|
||||
return htmlentities($separator);
|
||||
break;
|
||||
case 'text' :
|
||||
case 'none' :
|
||||
default :
|
||||
return $separator;
|
||||
case 'html':
|
||||
return htmlentities($separator);
|
||||
break;
|
||||
case 'text' :
|
||||
case 'none' :
|
||||
default :
|
||||
return $separator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,9 +27,12 @@ $tabs_icons = array(
|
||||
'Import' => 'ic_b_import',
|
||||
'Export' => 'ic_b_export');
|
||||
echo '<ul id="topmenu2">';
|
||||
echo PMA_generate_html_tab(array(
|
||||
'link' => 'prefs_manage.php',
|
||||
'text' => __('Manage your settings'))) . "\n";
|
||||
echo PMA_generate_html_tab(
|
||||
array(
|
||||
'link' => 'prefs_manage.php',
|
||||
'text' => __('Manage your settings')
|
||||
)
|
||||
) . "\n";
|
||||
echo '<li> </li>' . "\n";
|
||||
$script_name = basename($GLOBALS['PMA_PHP_SELF']);
|
||||
foreach (array_keys($forms) as $formset) {
|
||||
|
||||
@ -16,9 +16,12 @@ function PMA_userprefs_pageinit()
|
||||
$cf = ConfigFile::getInstance();
|
||||
$cf->resetConfigData(); // start with a clean instance
|
||||
$cf->setAllowedKeys($forms_all_keys);
|
||||
$cf->setCfgUpdateReadMapping(array(
|
||||
'Server/hide_db' => 'Servers/1/hide_db',
|
||||
'Server/only_db' => 'Servers/1/only_db'));
|
||||
$cf->setCfgUpdateReadMapping(
|
||||
array(
|
||||
'Server/hide_db' => 'Servers/1/hide_db',
|
||||
'Server/only_db' => 'Servers/1/only_db'
|
||||
)
|
||||
);
|
||||
$cf->updateWithGlobalConfig($GLOBALS['cfg']);
|
||||
}
|
||||
|
||||
@ -64,7 +67,8 @@ function PMA_load_userprefs()
|
||||
/**
|
||||
* Saves user preferences
|
||||
*
|
||||
* @param array $config_data
|
||||
* @param array $config_array configuration array
|
||||
*
|
||||
* @return true|PMA_Message
|
||||
*/
|
||||
function PMA_save_userprefs(array $config_array)
|
||||
@ -80,7 +84,7 @@ function PMA_save_userprefs(array $config_array)
|
||||
'db' => $config_array,
|
||||
'ts' => time());
|
||||
if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
|
||||
unset($_SESSION['cache'][$cache_key]['userprefs']);
|
||||
unset($_SESSION['cache'][$cache_key]['userprefs']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -122,6 +126,7 @@ function PMA_save_userprefs(array $config_array)
|
||||
* (blacklist) and keys from user preferences form (whitelist)
|
||||
*
|
||||
* @param array $config_data path => value pairs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_apply_userprefs(array $config_data)
|
||||
@ -155,6 +160,7 @@ function PMA_apply_userprefs(array $config_data)
|
||||
* Reads user preferences field names
|
||||
*
|
||||
* @param array|null $forms
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_read_userprefs_fieldnames(array $forms = null)
|
||||
@ -185,8 +191,10 @@ function PMA_read_userprefs_fieldnames(array $forms = null)
|
||||
*
|
||||
* No validation is done!
|
||||
*
|
||||
* @param string $cfg_name
|
||||
* @param mixed $value
|
||||
* @param string $path configuration
|
||||
* @param mixed $value value
|
||||
* @param mixed $default_value default value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_persist_option($path, $value, $default_value)
|
||||
@ -222,12 +230,16 @@ function PMA_userprefs_redirect(array $forms, array $old_settings, $file_name, $
|
||||
? $old_settings['config_data']
|
||||
: array();
|
||||
$new_settings = ConfigFile::getInstance()->getConfigArray();
|
||||
$diff_keys = array_keys(array_diff_assoc($old_settings, $new_settings)
|
||||
+ array_diff_assoc($new_settings, $old_settings));
|
||||
$diff_keys = array_keys(
|
||||
array_diff_assoc($old_settings, $new_settings)
|
||||
+ array_diff_assoc($new_settings, $old_settings)
|
||||
);
|
||||
$check_keys = array('NaturalOrder', 'MainPageIconic', 'DefaultTabDatabase',
|
||||
'Server/hide_db', 'Server/only_db');
|
||||
$check_keys = array_merge($check_keys, $forms['Left_frame']['Left_frame'],
|
||||
$forms['Left_frame']['Left_databases']);
|
||||
$check_keys = array_merge(
|
||||
$check_keys, $forms['Left_frame']['Left_frame'],
|
||||
$forms['Left_frame']['Left_databases']
|
||||
);
|
||||
$diff = array_intersect($check_keys, $diff_keys);
|
||||
$reload_left_frame = !empty($diff);
|
||||
}
|
||||
@ -242,8 +254,10 @@ function PMA_userprefs_redirect(array $forms, array $old_settings, $file_name, $
|
||||
if ($hash) {
|
||||
$hash = '#' . urlencode($hash);
|
||||
}
|
||||
PMA_sendHeaderLocation($GLOBALS['cfg']['PmaAbsoluteUri'] . $file_name
|
||||
. PMA_generate_common_url($url_params, '&') . $hash);
|
||||
PMA_sendHeaderLocation(
|
||||
$GLOBALS['cfg']['PmaAbsoluteUri'] . $file_name
|
||||
. PMA_generate_common_url($url_params, '&') . $hash
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -62,8 +62,11 @@ class zipfile
|
||||
* "echo $zipfile;" command
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function setDoWrite() {
|
||||
function setDoWrite()
|
||||
{
|
||||
$this -> doWrite = true;
|
||||
} // end of the 'setDoWrite()' method
|
||||
|
||||
@ -71,13 +74,14 @@ class zipfile
|
||||
* Converts an Unix timestamp to a four byte DOS date and time format (date
|
||||
* in high two bytes, time in low two bytes allowing magnitude comparison).
|
||||
*
|
||||
* @param integer the current Unix timestamp
|
||||
* @param integer $unixtime the current Unix timestamp
|
||||
*
|
||||
* @return integer the current date in a four byte DOS format
|
||||
* @return integer the current date in a four byte DOS format
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function unix2DosTime($unixtime = 0) {
|
||||
function unix2DosTime($unixtime = 0)
|
||||
{
|
||||
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
|
||||
|
||||
if ($timearray['year'] < 1980) {
|
||||
@ -97,17 +101,19 @@ class zipfile
|
||||
/**
|
||||
* Adds "file" to archive
|
||||
*
|
||||
* @param string file contents
|
||||
* @param string name of the file in the archive (may contains the path)
|
||||
* @param integer the current timestamp
|
||||
* @param string $data file contents
|
||||
* @param string $name name of the file in the archive (may contains the path)
|
||||
* @param integer $time the current timestamp
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function addFile($data, $name, $time = 0)
|
||||
{
|
||||
$name = str_replace('\\', '/', $name);
|
||||
|
||||
$dtime = substr( "00000000" . dechex($this->unix2DosTime($time)), -8);
|
||||
$dtime = substr("00000000" . dechex($this->unix2DosTime($time)), -8);
|
||||
$hexdtime = '\x' . $dtime[6] . $dtime[7]
|
||||
. '\x' . $dtime[4] . $dtime[5]
|
||||
. '\x' . $dtime[2] . $dtime[3]
|
||||
|
||||
@ -7,14 +7,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets zip file contents
|
||||
*
|
||||
* @param string $file
|
||||
* @return array ($error_message, $file_data); $error_message
|
||||
* is empty if no error
|
||||
*/
|
||||
|
||||
function PMA_getZipContents($file)
|
||||
* Gets zip file contents
|
||||
*
|
||||
* @param string $file zip file
|
||||
* @param string $specific_entry regular expression to match a file
|
||||
*
|
||||
* @return array ($error_message, $file_data); $error_message
|
||||
* is empty if no error
|
||||
*/
|
||||
function PMA_getZipContents($file, $specific_entry = null)
|
||||
{
|
||||
$error_message = '';
|
||||
$file_data = '';
|
||||
@ -28,11 +29,15 @@ function PMA_getZipContents($file)
|
||||
$read = zip_entry_read($first_zip_entry);
|
||||
$ods_mime = 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
if (!strcmp($ods_mime, $read)) {
|
||||
$specific_entry = '/^content\.xml$/';
|
||||
}
|
||||
|
||||
if (isset($specific_entry)) {
|
||||
/* Return the correct contents, not just the first entry */
|
||||
for ( ; ; ) {
|
||||
$entry = zip_read($zip_handle);
|
||||
if (is_resource($entry)) {
|
||||
if (!strcmp('content.xml', zip_entry_name($entry))) {
|
||||
if (preg_match($specific_entry, zip_entry_name($entry))) {
|
||||
zip_entry_open($zip_handle, $entry, 'r');
|
||||
$file_data = zip_entry_read($entry, zip_entry_filesize($entry));
|
||||
zip_entry_close($entry);
|
||||
@ -41,15 +46,15 @@ function PMA_getZipContents($file)
|
||||
} else {
|
||||
/**
|
||||
* Either we have reached the end of the zip and still
|
||||
* haven't found 'content.xml' or there was a parsing
|
||||
* haven't found $specific_entry or there was a parsing
|
||||
* error that we must display
|
||||
*/
|
||||
if ($entry === false) {
|
||||
$error_message = __('Error in ZIP archive:') . ' Could not find "content.xml"';
|
||||
$error_message = __('Error in ZIP archive:') . ' Could not find "' . $specific_entry . '"';
|
||||
} else {
|
||||
$error_message = __('Error in ZIP archive:') . ' ' . PMA_getZipError($zip_handle);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -68,33 +73,104 @@ function PMA_getZipContents($file)
|
||||
return (array('error' => $error_message, 'data' => $file_data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file name of the first file that matches the given $file_regexp.
|
||||
*
|
||||
* @param string $file_regexp regular expression for the file name to match
|
||||
* @param string $file zip archive
|
||||
*
|
||||
* @return string the file name of the first file that matches the given regexp
|
||||
*/
|
||||
function PMA_findFileFromZipArchive ($file_regexp, $file)
|
||||
{
|
||||
$zip_handle = zip_open($file);
|
||||
$found = false;
|
||||
if (is_resource($zip_handle)) {
|
||||
$entry = zip_read($zip_handle);
|
||||
while (is_resource($entry)) {
|
||||
if (preg_match($file_regexp, zip_entry_name($entry))) {
|
||||
$file_name = zip_entry_name($entry);
|
||||
zip_close($zip_handle);
|
||||
return $file_name;
|
||||
}
|
||||
$entry = zip_read($zip_handle);
|
||||
}
|
||||
}
|
||||
zip_close($zip_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of files in the zip archive.
|
||||
*
|
||||
* @param string $file zip archive
|
||||
*
|
||||
* @return int the number of files in the zip archive
|
||||
*/
|
||||
function PMA_getNoOfFilesInZip($file)
|
||||
{
|
||||
$count = 0;
|
||||
$zip_handle = zip_open($file);
|
||||
$found = false;
|
||||
if (is_resource($zip_handle)) {
|
||||
$entry = zip_read($zip_handle);
|
||||
while (is_resource($entry)) {
|
||||
$count++;
|
||||
$entry = zip_read($zip_handle);
|
||||
}
|
||||
}
|
||||
zip_close($zip_handle);
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts a set of files from the given zip archive to a given destinations.
|
||||
*
|
||||
* @param string $zip_path path to the zip archive
|
||||
* @param string $destination destination to extract files
|
||||
* @param array $entries files in archive that should be extracted
|
||||
*
|
||||
* @return bool true on sucess, false otherwise
|
||||
*/
|
||||
function PMA_zipExtract($zip_path, $destination, $entries)
|
||||
{
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($zip_path) === true) {
|
||||
$zip->extractTo($destination, $entries);
|
||||
$zip->close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets zip error message
|
||||
*
|
||||
* @param integer error code
|
||||
* @return string error message
|
||||
* @param integer $code error code
|
||||
*
|
||||
* @return string error message
|
||||
*/
|
||||
function PMA_getZipError($code)
|
||||
{
|
||||
// I don't think this needs translation
|
||||
switch ($code) {
|
||||
case ZIPARCHIVE::ER_MULTIDISK:
|
||||
$message = 'Multi-disk zip archives not supported';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_READ:
|
||||
$message = 'Read error';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_CRC:
|
||||
$message = 'CRC error';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_NOZIP:
|
||||
$message = 'Not a zip archive';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_INCONS:
|
||||
$message = 'Zip archive inconsistent';
|
||||
break;
|
||||
default:
|
||||
$message = $code;
|
||||
case ZIPARCHIVE::ER_MULTIDISK:
|
||||
$message = 'Multi-disk zip archives not supported';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_READ:
|
||||
$message = 'Read error';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_CRC:
|
||||
$message = 'CRC error';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_NOZIP:
|
||||
$message = 'Not a zip archive';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_INCONS:
|
||||
$message = 'Zip archive inconsistent';
|
||||
break;
|
||||
default:
|
||||
$message = $code;
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
|
||||
|
||||
$table = $T;
|
||||
|
||||
@ -7,7 +7,9 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
require_once "./pmd_common.php";
|
||||
require_once './libraries/pmd_common.php';
|
||||
require './libraries/db_common.inc.php';
|
||||
require './libraries/db_info.inc.php';
|
||||
|
||||
$tab_column = get_tab_info();
|
||||
$script_tabs = get_script_tabs();
|
||||
@ -15,19 +17,7 @@ $script_contr = get_script_contr();
|
||||
$tab_pos = get_tab_pos();
|
||||
$tables_pk_or_unique_keys = get_pk_or_unique_keys();
|
||||
$tables_all_keys = get_all_keys();
|
||||
$hidden = "hidden";
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][1]; ?>" lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][1]; ?>" dir="<?php echo $GLOBALS['text_dir']; ?>">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="icon" href="pmd/images/favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="pmd/images/favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="pmd/styles/<?php echo $GLOBALS['PMD']['STYLE'] ?>/style1.css" />
|
||||
<title>Designer</title>
|
||||
<?php
|
||||
$params = array('lang' => $GLOBALS['lang']);
|
||||
if (isset($GLOBALS['db'])) {
|
||||
$params['db'] = $GLOBALS['db'];
|
||||
@ -88,7 +78,7 @@ echo $script_tabs . $script_contr . $script_display_field;
|
||||
/></a><a href="javascript:location.reload();" onmousedown="return false;"
|
||||
class="M_butt" target="_self"
|
||||
><img title="<?php echo __('Reload'); ?>" src="pmd/images/reload.png" alt=""
|
||||
/></a><a href="javascript:Help();" onmousedown="return false;"
|
||||
/></a><a href="Documentation.html#faq6_31" target="documentation"
|
||||
class="M_butt" target="_self"
|
||||
><img title="<?php echo __('Help'); ?>" src="pmd/images/help.png" alt=""
|
||||
/></a><img class="M_bord" src="pmd/images/bord.png" alt=""
|
||||
@ -125,12 +115,11 @@ echo $script_tabs . $script_contr . $script_display_field;
|
||||
title="<?php echo __('Move Menu'); ?>" /></a>
|
||||
</div>
|
||||
|
||||
<div id="osn_tab">
|
||||
<CANVAS id="canvas" width="100" height="100" onclick="Canvas_click(this)"></CANVAS>
|
||||
</div>
|
||||
|
||||
<form action="" method="post" name="form1">
|
||||
<div id="layer_menu" style="visibility:<?php echo $hidden ?>;">
|
||||
<div id="osn_tab">
|
||||
<canvas class="pmd" id="canvas" width="100" height="100" onclick="Canvas_click(this)"></canvas>
|
||||
</div>
|
||||
<div id="layer_menu" style="display:none;">
|
||||
<div align="center" style="padding-top:5px;">
|
||||
<a href="javascript:Hide_tab_all(document.getElementById('key_HS_all'));"
|
||||
onmousedown="return false;" class="M_butt" target="_self">
|
||||
@ -166,8 +155,8 @@ for ($i = 0; $i < $name_cnt; $i++) {
|
||||
echo 'checked="checked"';
|
||||
}
|
||||
?> /></td>
|
||||
<td class="Tabs" onmouseover="this.className='Tabs2'"
|
||||
onmouseout="this.className='Tabs'"
|
||||
<td class="pmd_Tabs" onmouseover="this.className='pmd_Tabs2'"
|
||||
onmouseout="this.className='pmd_Tabs'"
|
||||
onclick="Select_tab('<?php echo $GLOBALS['PMD_URL']["TABLE_NAME"][$i]; ?>');">
|
||||
<?php echo $GLOBALS['PMD_OUT']["TABLE_NAME"][$i]; ?></td>
|
||||
</tr>
|
||||
@ -185,6 +174,8 @@ for ($i = 0; $i < $name_cnt; $i++) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
$t_n = $GLOBALS['PMD']["TABLE_NAME"][$i];
|
||||
@ -196,7 +187,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
<input name="t_v[<?php echo $t_n_url ?>]" type="hidden" id="t_v_<?php echo $t_n_url ?>_" />
|
||||
<input name="t_h[<?php echo $t_n_url ?>]" type="hidden" id="t_h_<?php echo $t_n_url ?>_" />
|
||||
|
||||
<table id="<?php echo $t_n_url ?>" cellpadding="0" cellspacing="0" class="tab"
|
||||
<table id="<?php echo $t_n_url ?>" cellpadding="0" cellspacing="0" class="pmd_tab"
|
||||
style="position: absolute;
|
||||
left: <?php if (isset($tab_pos[$t_n])) echo $tab_pos[$t_n]["X"]; else echo rand(180, 800); ?>px;
|
||||
top: <?php if (isset($tab_pos[$t_n])) echo $tab_pos[$t_n]["Y"]; else echo rand(30, 500); ?>px;
|
||||
@ -246,7 +237,10 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="id_tbody_<?php echo $t_n_url ?>"
|
||||
<?php if ( isset($tab_pos[$t_n])) echo 'style="display: none;"'; ?>>
|
||||
<?php
|
||||
if (isset($tab_pos[$t_n]) && empty($tab_pos[$t_n]["V"])) {
|
||||
echo 'style="display: none;"';
|
||||
}?>>
|
||||
<?php
|
||||
$display_field = PMA_getDisplayField($db, $GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]);
|
||||
for ($j = 0, $id_cnt = count($tab_column[$t_n]["COLUMN_ID"]); $j < $id_cnt; $j++) {
|
||||
@ -332,10 +326,10 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
<div id="hint"></div>
|
||||
<div id='layer_action' style="visibility:<?php echo $hidden ?>;">Load...</div>
|
||||
<div id="pmd_hint"></div>
|
||||
<div id='layer_action' style="display:none;">Load...</div>
|
||||
|
||||
<table id="layer_new_relation" style="visibility:<?php echo $hidden ?>;"
|
||||
<table id="layer_new_relation" style="display:none;"
|
||||
width="5%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -386,7 +380,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
value="<?php echo __('OK'); ?>" onclick="New_relation()" />
|
||||
<input type="button" class="butt" name="Button"
|
||||
value="<?php echo __('Cancel'); ?>"
|
||||
onclick="document.getElementById('layer_new_relation').style.visibility = 'hidden';" />
|
||||
onclick="document.getElementById('layer_new_relation').style.display = 'none';" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -402,7 +396,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table id="layer_upd_relation" style="visibility:<?PHP echo $hidden ?>;"
|
||||
<table id="layer_upd_relation" style="display:none;"
|
||||
width="5%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -423,7 +417,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
onclick="Upd_relation()" value="<?php echo __('Delete'); ?>" />
|
||||
<input type="button" class="butt" name="Button"
|
||||
value="<?php echo __('Cancel'); ?>"
|
||||
onclick="document.getElementById('layer_upd_relation').style.visibility = 'hidden'; Re_load();" />
|
||||
onclick="document.getElementById('layer_upd_relation').style.display = 'none'; Re_load();" />
|
||||
</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
@ -437,7 +431,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table id="pmd_optionse" style="visibility:<?php echo $hidden ?>;"
|
||||
<table id="pmd_optionse" style="display:none;"
|
||||
width="5%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -559,7 +553,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table id="query_rename_to" style="visibility:<?php echo $hidden ?>;"
|
||||
<table id="query_rename_to" style="display:none;"
|
||||
width="5%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -591,7 +585,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
value="<?php echo __('OK'); ?>" onclick="edit('Rename')" />
|
||||
<input type="button" class="butt" name="Button"
|
||||
value="<?php echo __('Cancel'); ?>"
|
||||
onclick="document.getElementById('query_rename_to').style.visibility = 'hidden';" />
|
||||
onclick="document.getElementById('query_rename_to').style.display = 'none';" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -607,7 +601,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table id="query_having" style="visibility:<?php echo $hidden ?>;"
|
||||
<table id="query_having" style="display:none;"
|
||||
width="5%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -667,7 +661,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
value="<?php echo __('OK'); ?>" onclick="edit('Having')" />
|
||||
<input type="button" class="butt" name="Button"
|
||||
value="<?php echo __('Cancel'); ?>"
|
||||
onclick="document.getElementById('query_having').style.visibility = 'hidden';" />
|
||||
onclick="document.getElementById('query_having').style.display = 'none';" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -683,7 +677,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table id="query_Aggregate" style="visibility:<?php echo $hidden ?>;"
|
||||
<table id="query_Aggregate" style="display:none;"
|
||||
width="5%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -721,7 +715,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
value="<?php echo __('OK'); ?>" onclick="edit('Aggregate')" />
|
||||
<input type="button" class="butt" name="Button"
|
||||
value="<?php echo __('Cancel'); ?>"
|
||||
onclick="document.getElementById('query_Aggregate').style.visibility = 'hidden';" />
|
||||
onclick="document.getElementById('query_Aggregate').style.display = 'none';" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -737,7 +731,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table id="query_where" style="visibility:<?php echo $hidden ?>;"
|
||||
<table id="query_where" style="display:none;"
|
||||
width="5%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -784,7 +778,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
value="<?php echo __('OK'); ?>" onclick="edit('Where')" />
|
||||
<input type="button" class="butt" name="Button"
|
||||
value="<?php echo __('Cancel'); ?>"
|
||||
onclick="document.getElementById('query_where').style.visibility = 'hidden';" />
|
||||
onclick="document.getElementById('query_where').style.display = 'none';" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
27
pmd_help.php
27
pmd_help.php
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
*
|
||||
* @package phpMyAdmin-Designer
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
require_once 'pmd_common.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="./libraries/pmd/styles/<?php echo $GLOBALS['PMD']['STYLE'] ?>/style1.css">
|
||||
<title>Designer</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
echo '<p>' . __('To select relation, click :') . '<br />';
|
||||
echo '<img src="pmd/images/help_relation.png" border="1"></p>';
|
||||
echo '<p>' . __('The display column is shown in pink. To set/unset a column as the display column, click the "Choose column to display" icon, then click on the appropriate column name.') . '</p>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
20
pmd_pdf.php
20
pmd_pdf.php
@ -5,10 +5,10 @@
|
||||
* @package phpMyAdmin-Designer
|
||||
*/
|
||||
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
|
||||
/**
|
||||
* If called directly from the designer, first save the positions
|
||||
* If called directly from the designer, first save the positions
|
||||
*/
|
||||
if (! isset($scale)) {
|
||||
$no_die_save_pos = 1;
|
||||
@ -25,11 +25,7 @@ if (isset($mode)) {
|
||||
$scale_q = PMA_sqlAddSlashes($scale);
|
||||
|
||||
if ('create_export' == $mode) {
|
||||
/*
|
||||
* @see pdf_pages.php
|
||||
*/
|
||||
$query_default_option = PMA_DBI_QUERY_STORE;
|
||||
$pdf_page_number = PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option);
|
||||
$pdf_page_number = PMA_REL_create_page($newpage, $cfgRelation, $db);
|
||||
if ($pdf_page_number > 0) {
|
||||
$message = PMA_Message::success(__('Page has been created'));
|
||||
$mode = 'export';
|
||||
@ -57,7 +53,7 @@ if (isset($mode)) {
|
||||
' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
|
||||
AND
|
||||
' . $pmd_table . '.`db_name`=\''. PMA_sqlAddSlashes($db) .'\'
|
||||
AND pdf_page_number = ' . $pdf_page_number_q . ';', true, PMA_DBI_QUERY_STORE);
|
||||
AND pdf_page_number = ' . $pdf_page_number_q . ';', true, PMA_DBI_QUERY_STORE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,20 +64,20 @@ require_once './libraries/header_meta_style.inc.php';
|
||||
<body>
|
||||
<br>
|
||||
<div>
|
||||
<?php
|
||||
if (!empty($message)) {
|
||||
<?php
|
||||
if (!empty($message)) {
|
||||
$message->display();
|
||||
}
|
||||
?>
|
||||
<form name="form1" method="post" action="pmd_pdf.php">
|
||||
<?php
|
||||
<?php
|
||||
echo PMA_generate_common_hidden_inputs($db);
|
||||
echo '<div>';
|
||||
echo '<fieldset><legend>' . __('Import/Export coordinates for PDF schema') . '</legend>';
|
||||
|
||||
$choices = array();
|
||||
|
||||
$table_info_result = PMA_query_as_controluser('SELECT * FROM '
|
||||
$table_info_result = PMA_query_as_controluser('SELECT * FROM '
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'');
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
$die_save_pos = 0;
|
||||
include_once 'pmd_save_pos.php';
|
||||
extract($_POST, EXTR_SKIP);
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
extract($_POST, EXTR_SKIP);
|
||||
extract($_GET, EXTR_SKIP);
|
||||
$die_save_pos = 0;
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user