diff --git a/db_export.php b/db_export.php
index 452e45c9b9..ba2aeae458 100644
--- a/db_export.php
+++ b/db_export.php
@@ -147,7 +147,7 @@ if (! isset($unlim_num_rows)) {
if (! isset($multi_values)) {
$multi_values = '';
}
-$response = PMA_Response::getInstance();
+$response = Response::getInstance();
$response->addHTML(
PMA_getExportDisplay(
'database', $db, $table, $sql_query, $num_tables,
diff --git a/libraries/plugins/import/AbstractImportCsv.class.php b/libraries/plugins/import/AbstractImportCsv.php
similarity index 94%
rename from libraries/plugins/import/AbstractImportCsv.class.php
rename to libraries/plugins/import/AbstractImportCsv.php
index 4653173bcf..96d17b312f 100644
--- a/libraries/plugins/import/AbstractImportCsv.class.php
+++ b/libraries/plugins/import/AbstractImportCsv.php
@@ -6,7 +6,14 @@
* @package PhpMyAdmin-Import
* @subpackage CSV
*/
+namespace PMA\libraries\plugins\import;
+
+use BoolPropertyItem;
+use ImportPluginProperties;
+use OptionsPropertyMainGroup;
+use OptionsPropertyRootGroup;
use PMA\libraries\plugins\ImportPlugin;
+use TextPropertyItem;
/**
* Super class of the import plugins for the CSV format
diff --git a/libraries/plugins/import/ImportCsv.class.php b/libraries/plugins/import/ImportCsv.php
similarity index 84%
rename from libraries/plugins/import/ImportCsv.class.php
rename to libraries/plugins/import/ImportCsv.php
index 80572e32fc..8c81df41ea 100644
--- a/libraries/plugins/import/ImportCsv.class.php
+++ b/libraries/plugins/import/ImportCsv.php
@@ -7,13 +7,16 @@
* @package PhpMyAdmin-Import
* @subpackage CSV
*/
-if (! defined('PHPMYADMIN')) {
+namespace PMA\libraries\plugins\import;
+
+use BoolPropertyItem;
+use PMA;
+use TextPropertyItem;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
-/* Get the import interface */
-require_once 'libraries/plugins/import/AbstractImportCsv.class.php';
-
/**
* Handles the import for the CSV format
*
@@ -88,7 +91,6 @@ class ImportCsv extends AbstractImportCsv
$leaf->setName("ignore");
$leaf->setText(__('Do not abort on INSERT error'));
$generalOptions->addProperty($leaf);
-
}
/**
@@ -99,23 +101,25 @@ class ImportCsv extends AbstractImportCsv
public function doImport()
{
global $db, $table, $csv_terminated, $csv_enclosed, $csv_escaped,
- $csv_new_line, $csv_columns, $err_url;
+ $csv_new_line, $csv_columns, $err_url;
// $csv_replace and $csv_ignore should have been here,
// but we use directly from $_POST
global $error, $timeout_passed, $finished, $message;
$replacements = array(
- '\\n' => "\n",
- '\\t' => "\t",
- '\\r' => "\r",
+ '\\n' => "\n",
+ '\\t' => "\t",
+ '\\r' => "\r",
);
$csv_terminated = strtr($csv_terminated, $replacements);
- $csv_enclosed = strtr($csv_enclosed, $replacements);
+ $csv_enclosed = strtr($csv_enclosed, $replacements);
$csv_escaped = strtr($csv_escaped, $replacements);
$csv_new_line = strtr($csv_new_line, $replacements);
$param_error = false;
- if (/*overload*/mb_strlen($csv_terminated) < 1) {
+ if (/*overload*/
+ mb_strlen($csv_terminated) < 1
+ ) {
$message = PMA\libraries\Message::error(
__('Invalid parameter for CSV import: %s')
);
@@ -130,7 +134,9 @@ class ImportCsv extends AbstractImportCsv
// confuses this script.
// But the parser won't work correctly with strings so we allow just
// one character.
- } elseif (/*overload*/mb_strlen($csv_enclosed) > 1) {
+ } elseif (/*overload*/
+ mb_strlen($csv_enclosed) > 1
+ ) {
$message = PMA\libraries\Message::error(
__('Invalid parameter for CSV import: %s')
);
@@ -141,14 +147,17 @@ class ImportCsv extends AbstractImportCsv
// confuses this script.
// But the parser won't work correctly with strings so we allow just
// one character.
- } elseif (/*overload*/mb_strlen($csv_escaped) > 1) {
+ } elseif (/*overload*/
+ mb_strlen($csv_escaped) > 1
+ ) {
$message = PMA\libraries\Message::error(
__('Invalid parameter for CSV import: %s')
);
$message->addParam(__('Columns escaped with'), false);
$error = true;
$param_error = true;
- } elseif (/*overload*/mb_strlen($csv_new_line) != 1
+ } elseif (/*overload*/
+ mb_strlen($csv_new_line) != 1
&& $csv_new_line != 'auto'
) {
$message = PMA\libraries\Message::error(
@@ -162,13 +171,18 @@ class ImportCsv extends AbstractImportCsv
// If there is an error in the parameters entered,
// indicate that immediately.
if ($param_error) {
- PMA\libraries\Util::mysqlDie($message->getMessage(), '', false, $err_url);
+ PMA\libraries\Util::mysqlDie(
+ $message->getMessage(),
+ '',
+ false,
+ $err_url
+ );
}
$buffer = '';
$required_fields = 0;
- if (! $this->_getAnalyze()) {
+ if (!$this->_getAnalyze()) {
$sql_template = 'INSERT';
if (isset($_POST['csv_ignore'])) {
$sql_template .= ' IGNORE';
@@ -182,7 +196,7 @@ class ImportCsv extends AbstractImportCsv
} else {
$sql_template .= ' (';
$fields = array();
- $tmp = preg_split('/,( ?)/', $csv_columns);
+ $tmp = preg_split('/,( ?)/', $csv_columns);
foreach ($tmp as $key => $val) {
if (count($fields) > 0) {
$sql_template .= ', ';
@@ -196,7 +210,7 @@ class ImportCsv extends AbstractImportCsv
break;
}
}
- if (! $found) {
+ if (!$found) {
$message = PMA\libraries\Message::error(
__(
'Invalid column (%s) specified! Ensure that columns'
@@ -235,8 +249,10 @@ class ImportCsv extends AbstractImportCsv
$col_count = 0;
$max_cols = 0;
- $csv_terminated_len = /*overload*/mb_strlen($csv_terminated);
- while (! ($finished && $i >= $len) && ! $error && ! $timeout_passed) {
+ $csv_terminated_len
+ = /*overload*/
+ mb_strlen($csv_terminated);
+ while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
if ($data === false) {
// subtract data we didn't handle yet and stop processing
@@ -251,7 +267,9 @@ class ImportCsv extends AbstractImportCsv
// Force a trailing new line at EOF to prevent parsing problems
if ($finished && $buffer) {
- $finalch = /*overload*/mb_substr($buffer, -1);
+ $finalch
+ = /*overload*/
+ mb_substr($buffer, -1);
if ($csv_new_line == 'auto'
&& $finalch != "\r"
&& $finalch != "\n"
@@ -267,26 +285,33 @@ class ImportCsv extends AbstractImportCsv
// Do not parse string when we're not at the end
// and don't have new line inside
if (($csv_new_line == 'auto'
- && /*overload*/mb_strpos($buffer, "\r") === false
- && /*overload*/mb_strpos($buffer, "\n") === false)
+ && /*overload*/
+ mb_strpos($buffer, "\r") === false
+ && /*overload*/
+ mb_strpos($buffer, "\n") === false)
|| ($csv_new_line != 'auto'
- && /*overload*/mb_strpos($buffer, $csv_new_line) === false)
+ && /*overload*/
+ mb_strpos($buffer, $csv_new_line) === false)
) {
continue;
}
}
// Current length of our buffer
- $len = /*overload*/mb_strlen($buffer);
+ $len
+ = /*overload*/
+ mb_strlen($buffer);
// Currently parsed char
$ch = mb_substr($buffer, $i, 1);
if ($csv_terminated_len > 1 && $ch == $csv_terminated[0]) {
$ch = $this->readCsvTerminatedString(
- $buffer, $ch, $i, $csv_terminated_len
+ $buffer,
+ $ch,
+ $i,
+ $csv_terminated_len
);
$i += $csv_terminated_len - 1;
-
}
while ($i < $len) {
// Deadlock protection
@@ -302,7 +327,7 @@ class ImportCsv extends AbstractImportCsv
$lastlen = $len;
// This can happen with auto EOL and \r at the end of buffer
- if (! $csv_finish) {
+ if (!$csv_finish) {
// Grab empty field
if ($ch == $csv_terminated) {
if ($i == $len - 1) {
@@ -313,7 +338,10 @@ class ImportCsv extends AbstractImportCsv
$ch = mb_substr($buffer, $i, 1);
if ($csv_terminated_len > 1 && $ch == $csv_terminated[0]) {
$ch = $this->readCsvTerminatedString(
- $buffer, $ch, $i, $csv_terminated_len
+ $buffer,
+ $ch,
+ $i,
+ $csv_terminated_len
);
$i += $csv_terminated_len - 1;
}
@@ -331,7 +359,10 @@ class ImportCsv extends AbstractImportCsv
$ch = mb_substr($buffer, $i, 1);
if ($csv_terminated_len > 1 && $ch == $csv_terminated[0]) {
$ch = $this->readCsvTerminatedString(
- $buffer, $ch, $i, $csv_terminated_len
+ $buffer,
+ $ch,
+ $i,
+ $csv_terminated_len
);
$i += $csv_terminated_len - 1;
}
@@ -341,12 +372,13 @@ class ImportCsv extends AbstractImportCsv
$fail = false;
$value = '';
while (($need_end
- && ( $ch != $csv_enclosed || $csv_enclosed == $csv_escaped ))
- || ( ! $need_end
- && ! ( $ch == $csv_terminated
- || $ch == $csv_new_line
- || ( $csv_new_line == 'auto'
- && ( $ch == "\r" || $ch == "\n" ) ) ) )
+ && ($ch != $csv_enclosed
+ || $csv_enclosed == $csv_escaped))
+ || (!$need_end
+ && !($ch == $csv_terminated
+ || $ch == $csv_new_line
+ || ($csv_new_line == 'auto'
+ && ($ch == "\r" || $ch == "\n"))))
) {
if ($ch == $csv_escaped) {
if ($i == $len - 1) {
@@ -359,22 +391,25 @@ class ImportCsv extends AbstractImportCsv
&& $ch == $csv_terminated[0]
) {
$ch = $this->readCsvTerminatedString(
- $buffer, $ch, $i, $csv_terminated_len
+ $buffer,
+ $ch,
+ $i,
+ $csv_terminated_len
);
$i += $csv_terminated_len - 1;
}
if ($csv_enclosed == $csv_escaped
&& ($ch == $csv_terminated
- || $ch == $csv_new_line
- || ($csv_new_line == 'auto'
- && ($ch == "\r" || $ch == "\n")))
+ || $ch == $csv_new_line
+ || ($csv_new_line == 'auto'
+ && ($ch == "\r" || $ch == "\n")))
) {
break;
}
}
$value .= $ch;
if ($i == $len - 1) {
- if (! $finished) {
+ if (!$finished) {
$fail = true;
}
break;
@@ -383,7 +418,10 @@ class ImportCsv extends AbstractImportCsv
$ch = mb_substr($buffer, $i, 1);
if ($csv_terminated_len > 1 && $ch == $csv_terminated[0]) {
$ch = $this->readCsvTerminatedString(
- $buffer, $ch, $i, $csv_terminated_len
+ $buffer,
+ $ch,
+ $i,
+ $csv_terminated_len
);
$i += $csv_terminated_len - 1;
}
@@ -422,7 +460,10 @@ class ImportCsv extends AbstractImportCsv
&& $ch == $csv_terminated[0]
) {
$ch = $this->readCsvTerminatedString(
- $buffer, $ch, $i, $csv_terminated_len
+ $buffer,
+ $ch,
+ $i,
+ $csv_terminated_len
);
$i += $csv_terminated_len - 1;
}
@@ -453,7 +494,10 @@ class ImportCsv extends AbstractImportCsv
&& $ch == $csv_terminated[0]
) {
$ch = $this->readCsvTerminatedString(
- $buffer, $ch, $i, $csv_terminated_len
+ $buffer,
+ $ch,
+ $i,
+ $csv_terminated_len
);
$i += $csv_terminated_len - 1;
}
@@ -468,16 +512,16 @@ class ImportCsv extends AbstractImportCsv
|| ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n"))
) {
if ($csv_new_line == 'auto' && $ch == "\r") { // Handle "\r\n"
- if ($i >= ($len - 2) && ! $finished) {
+ if ($i >= ($len - 2) && !$finished) {
break; // We need more data to decide new line
}
- if (mb_substr($buffer, $i+1, 1) == "\n") {
+ if (mb_substr($buffer, $i + 1, 1) == "\n") {
$i++;
}
}
// We didn't parse value till the end of line, so there was
// empty one
- if (! $csv_finish) {
+ if (!$csv_finish) {
$values[] = '';
}
@@ -517,7 +561,7 @@ class ImportCsv extends AbstractImportCsv
$first = true;
$sql = $sql_template;
foreach ($values as $key => $val) {
- if (! $first) {
+ if (!$first) {
$sql .= ', ';
}
if ($val === null) {
@@ -534,7 +578,9 @@ class ImportCsv extends AbstractImportCsv
if (isset($_POST['csv_replace'])) {
$sql .= " ON DUPLICATE KEY UPDATE ";
foreach ($fields as $field) {
- $fieldName = PMA\libraries\Util::backquote($field['Field']);
+ $fieldName = PMA\libraries\Util::backquote(
+ $field['Field']
+ );
$sql .= $fieldName . " = VALUES(" . $fieldName
. "), ";
}
@@ -551,11 +597,17 @@ class ImportCsv extends AbstractImportCsv
$line++;
$csv_finish = false;
$values = array();
- $buffer = /*overload*/mb_substr($buffer, $i + 1);
- $len = /*overload*/mb_strlen($buffer);
+ $buffer
+ = /*overload*/
+ mb_substr($buffer, $i + 1);
+ $len
+ = /*overload*/
+ mb_strlen($buffer);
$i = 0;
$lasti = -1;
- $ch = /*overload*/mb_substr($buffer, 0, 1);
+ $ch
+ = /*overload*/
+ mb_substr($buffer, 0, 1);
}
} // End of parser loop
} // End of import loop
@@ -579,7 +631,7 @@ class ImportCsv extends AbstractImportCsv
}
if ((isset($col_names) && count($col_names) != $max_cols)
- || ! isset($col_names)
+ || !isset($col_names)
) {
// Fill out column names
for ($i = 0; $i < $max_cols; ++$i) {
@@ -587,7 +639,9 @@ class ImportCsv extends AbstractImportCsv
}
}
- if (/*overload*/mb_strlen($db)) {
+ if (/*overload*/
+ mb_strlen($db)
+ ) {
$result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
$tbl_name = 'TABLE ' . (count($result) + 1);
} else {
@@ -630,7 +684,7 @@ class ImportCsv extends AbstractImportCsv
// Commit any possible data in buffers
PMA_importRunQuery();
- if (count($values) != 0 && ! $error) {
+ if (count($values) != 0 && !$error) {
$message = PMA\libraries\Message::error(
__('Invalid format of CSV input on line %d.')
);
@@ -644,12 +698,12 @@ class ImportCsv extends AbstractImportCsv
* $csv_terminated_len from the $buffer
* into variable $ch and return the read string $ch
*
- * @param string $buffer The original string buffer read from
+ * @param string $buffer The original string buffer read from
* csv file
- * @param string $ch Partially read "column Separated with"
+ * @param string $ch Partially read "column Separated with"
* string, also used to return after
* reading length equal $csv_terminated_len
- * @param int $i Current read counter of buffer string
+ * @param int $i Current read counter of buffer string
* @param int $csv_terminated_len The length of "column separated with"
* String
*
@@ -661,11 +715,11 @@ class ImportCsv extends AbstractImportCsv
$i++;
$ch .= mb_substr($buffer, $i, 1);
}
+
return $ch;
}
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
-
/**
* Returns true if the table should be analyzed, false otherwise
*
@@ -687,5 +741,4 @@ class ImportCsv extends AbstractImportCsv
{
$this->_analyze = $analyze;
}
-
}
diff --git a/libraries/plugins/import/ImportLdi.class.php b/libraries/plugins/import/ImportLdi.php
similarity index 91%
rename from libraries/plugins/import/ImportLdi.class.php
rename to libraries/plugins/import/ImportLdi.php
index 454eeb8639..2efa49000f 100644
--- a/libraries/plugins/import/ImportLdi.class.php
+++ b/libraries/plugins/import/ImportLdi.php
@@ -6,16 +6,21 @@
* @package PhpMyAdmin-Import
* @subpackage LDI
*/
-if (! defined('PHPMYADMIN')) {
+namespace PMA\libraries\plugins\import;
+
+use BoolPropertyItem;
+use PMA;
+use PMA\libraries\plugins\import\AbstractImportCsv;
+use TextPropertyItem;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
-/* Get the import interface */
-require_once 'libraries/plugins/import/AbstractImportCsv.class.php';
-
// We need relations enabled and we work only on database
if ($GLOBALS['plugin_param'] !== 'table') {
$GLOBALS['skip_import'] = true;
+
return;
}
@@ -88,7 +93,7 @@ class ImportLdi extends AbstractImportCsv
{
global $finished, $import_file, $compression, $charset_conversion, $table;
global $ldi_local_option, $ldi_replace, $ldi_ignore, $ldi_terminated,
- $ldi_enclosed, $ldi_escaped, $ldi_new_line, $skip_queries, $ldi_columns;
+ $ldi_enclosed, $ldi_escaped, $ldi_new_line, $skip_queries, $ldi_columns;
if ($import_file == 'none'
|| $compression != 'none'
@@ -99,6 +104,7 @@ class ImportLdi extends AbstractImportCsv
__('This plugin does not support compressed imports!')
);
$GLOBALS['error'] = true;
+
return;
}
@@ -106,7 +112,8 @@ class ImportLdi extends AbstractImportCsv
if (isset($ldi_local_option)) {
$sql .= ' LOCAL';
}
- $sql .= ' INFILE \'' . PMA\libraries\Util::sqlAddSlashes($import_file) . '\'';
+ $sql .= ' INFILE \'' . PMA\libraries\Util::sqlAddSlashes($import_file)
+ . '\'';
if (isset($ldi_replace)) {
$sql .= ' REPLACE';
} elseif (isset($ldi_ignore)) {
@@ -129,8 +136,8 @@ class ImportLdi extends AbstractImportCsv
if ($ldi_new_line == 'auto') {
$ldi_new_line
= (PMA\libraries\Util::whichCrlf() == "\n")
- ? '\n'
- : '\r\n';
+ ? '\n'
+ : '\r\n';
}
$sql .= ' LINES TERMINATED BY \'' . $ldi_new_line . '\'';
}
@@ -140,7 +147,7 @@ class ImportLdi extends AbstractImportCsv
}
if (strlen($ldi_columns) > 0) {
$sql .= ' (';
- $tmp = preg_split('/,( ?)/', $ldi_columns);
+ $tmp = preg_split('/,( ?)/', $ldi_columns);
$cnt_tmp = count($tmp);
for ($i = 0; $i < $cnt_tmp; $i++) {
if ($i > 0) {
diff --git a/libraries/plugins/import/ImportMediawiki.class.php b/libraries/plugins/import/ImportMediawiki.php
similarity index 85%
rename from libraries/plugins/import/ImportMediawiki.class.php
rename to libraries/plugins/import/ImportMediawiki.php
index 33851ae540..f6d4522fd5 100644
--- a/libraries/plugins/import/ImportMediawiki.class.php
+++ b/libraries/plugins/import/ImportMediawiki.php
@@ -6,9 +6,13 @@
* @package PhpMyAdmin-Import
* @subpackage MediaWiki
*/
+namespace PMA\libraries\plugins\import;
+
+use ImportPluginProperties;
+use PMA;
use PMA\libraries\plugins\ImportPlugin;
-if (! defined('PHPMYADMIN')) {
+if (!defined('PHPMYADMIN')) {
exit;
}
@@ -92,12 +96,14 @@ class ImportMediawiki extends ImportPlugin
// Initialize the name of the current table
$cur_table_name = "";
- while (! $finished && ! $error && ! $timeout_passed ) {
+ while (!$finished && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
if ($data === false) {
// Subtract data we didn't handle yet and stop processing
- $GLOBALS['offset'] -= /*overload*/mb_strlen($buffer);
+ $GLOBALS['offset']
+ -= /*overload*/
+ mb_strlen($buffer);
break;
} elseif ($data === true) {
// Handle rest of buffer
@@ -107,7 +113,9 @@ class ImportMediawiki extends ImportPlugin
unset($data);
// Don't parse string if we're not at the end
// and don't have a new line inside
- if (/*overload*/mb_strpos($buffer, $mediawiki_new_line) === false ) {
+ if (/*overload*/
+ mb_strpos($buffer, $mediawiki_new_line) === false
+ ) {
continue;
}
}
@@ -124,16 +132,16 @@ class ImportMediawiki extends ImportPlugin
$full_buffer_lines_count = count($buffer_lines);
// If the reading is not finalised, the final line of the current chunk
// will not be complete
- if (! $finished) {
+ if (!$finished) {
$full_buffer_lines_count -= 1;
$last_chunk_line = $buffer_lines[$full_buffer_lines_count];
}
- for ($line_nr = 0; $line_nr < $full_buffer_lines_count; ++ $line_nr) {
+ for ($line_nr = 0; $line_nr < $full_buffer_lines_count; ++$line_nr) {
$cur_buffer_line = trim($buffer_lines[$line_nr]);
// If the line is empty, go to the next one
- if ($cur_buffer_line === '' ) {
+ if ($cur_buffer_line === '') {
continue;
}
@@ -141,13 +149,19 @@ class ImportMediawiki extends ImportPlugin
$matches = array();
// Check beginning of comment
- if (! strcmp(/*overload*/mb_substr($cur_buffer_line, 0, 4), "")
+ if (!strcmp(/*overload*/
+ mb_substr($cur_buffer_line, 0, 4),
+ "-->"
+ )
) {
// Only data comments are closed. The structure comments
// will be closed when a data comment begins (in order to
@@ -157,7 +171,7 @@ class ImportMediawiki extends ImportPlugin
}
// End comments that are not related to table structure
- if (! $inside_structure_comment) {
+ if (!$inside_structure_comment) {
$inside_comment = false;
}
} else {
@@ -174,8 +188,8 @@ class ImportMediawiki extends ImportPlugin
$inside_structure_comment
= $this->_mngInsideStructComm(
- $inside_structure_comment
- );
+ $inside_structure_comment
+ );
} elseif (preg_match(
"/^Table structure for `(.*)`$/",
$cur_buffer_line,
@@ -204,18 +218,21 @@ class ImportMediawiki extends ImportPlugin
$in_table_header = false;
// End processing because the current line does not
// contain any column information
- } elseif (/*overload*/mb_substr($cur_buffer_line, 0, 2) === '|-'
- || /*overload*/mb_substr($cur_buffer_line, 0, 2) === '|+'
- || /*overload*/mb_substr($cur_buffer_line, 0, 2) === '|}'
+ } elseif (/*overload*/
+ mb_substr($cur_buffer_line, 0, 2) === '|-'
+ || /*overload*/
+ mb_substr($cur_buffer_line, 0, 2) === '|+'
+ || /*overload*/
+ mb_substr($cur_buffer_line, 0, 2) === '|}'
) {
// Check begin row or end table
// Add current line to the values storage
- if (! empty($cur_temp_line)) {
+ if (!empty($cur_temp_line)) {
// If the current line contains header cells
// ( marked with '!' ),
// it will be marked as table header
- if ($in_table_header ) {
+ if ($in_table_header) {
// Set the header columns
$cur_temp_table_headers = $cur_temp_line;
} else {
@@ -228,11 +245,13 @@ class ImportMediawiki extends ImportPlugin
$cur_temp_line = array();
// No more processing required at the end of the table
- if (/*overload*/mb_substr($cur_buffer_line, 0, 2) === '|}') {
+ if (/*overload*/
+ mb_substr($cur_buffer_line, 0, 2) === '|}'
+ ) {
$current_table = array(
$cur_table_name,
$cur_temp_table_headers,
- $cur_temp_table
+ $cur_temp_table,
);
// Import the current table data into the database
@@ -263,7 +282,7 @@ class ImportMediawiki extends ImportPlugin
// Delete the beginning of the column, if there is one
$cell = trim($cell);
- $col_start_chars = array( "|", "!");
+ $col_start_chars = array("|", "!");
foreach ($col_start_chars as $col_start_char) {
$cell = $this->_getCellContent($cell, $col_start_char);
}
@@ -287,14 +306,14 @@ class ImportMediawiki extends ImportPlugin
/**
* Imports data from a single table
*
- * @param array $table containing all table info:
- *
- * $table[0] - string containing table name
- * $table[1] - array[] of table headers
- * $table[2] - array[][] of table content rows
- *
+ * @param array $table containing all table info:
+ *
+ * $table[0] - string containing table name
+ * $table[1] - array[] of table headers
+ * $table[2] - array[][] of table content rows
+ *
*
- * @global bool $analyze whether to scan for column types
+ * @global bool $analyze whether to scan for column types
*
* @return void
*/
@@ -354,7 +373,7 @@ class ImportMediawiki extends ImportPlugin
// The first table row should contain the number of columns
// If they are not set, generic names will be given (COL 1, COL 2, etc)
$num_cols = count($table_row);
- for ($i = 0; $i < $num_cols; ++ $i) {
+ for ($i = 0; $i < $num_cols; ++$i) {
$table_headers [$i] = 'COL ' . ($i + 1);
}
}
@@ -364,16 +383,17 @@ class ImportMediawiki extends ImportPlugin
* Sets the database name and additional options and calls PMA_buildSQL()
* Used in PMA_importDataAllTables() and $this->_importDataOneTable()
*
- * @param array &$tables structure:
- * array(
- * array(table_name, array() column_names, array()() rows)
- * )
- * @param array &$analyses structure:
- * $analyses = array(
- * array(array() column_types, array() column_sizes)
- * )
+ * @param array &$tables structure:
+ * array(
+ * array(table_name, array() column_names, array()()
+ * rows)
+ * )
+ * @param array &$analyses structure:
+ * $analyses = array(
+ * array(array() column_types, array() column_sizes)
+ * )
*
- * @global string $db name of the database to import in
+ * @global string $db name of the database to import in
*
* @return void
*/
@@ -397,7 +417,6 @@ class ImportMediawiki extends ImportPlugin
unset($analyses);
}
-
/**
* Replaces all instances of the '||' separator between delimiters
* in a given string
@@ -422,13 +441,13 @@ class ImportMediawiki extends ImportPlugin
$partial_separator = false;
// Parse text char by char
- for ($i = 0; $i < strlen($subject); $i ++) {
+ for ($i = 0; $i < strlen($subject); $i++) {
$cur_char = $subject[$i];
// Check for separators
if ($cur_char == '|') {
// If we're not inside a tag, then this is part of a real separator,
// so we append it to the current segment
- if (! $inside_attribute) {
+ if (!$inside_attribute) {
$cleaned .= $cur_char;
if ($partial_separator) {
$inside_tag = false;
@@ -442,7 +461,7 @@ class ImportMediawiki extends ImportPlugin
// If the previous character was also '|', then this ends a
// full separator. If not, this may be the beginning of one
- $partial_separator = ! $partial_separator;
+ $partial_separator = !$partial_separator;
} else {
// If we're inside a tag attribute and the current character is
// not '|', but the previous one was, it means that the single '|'
@@ -456,15 +475,15 @@ class ImportMediawiki extends ImportPlugin
// any other character should be appended to the current segment
$cleaned .= $cur_char;
- if ($cur_char == '<' && ! $inside_attribute) {
+ if ($cur_char == '<' && !$inside_attribute) {
// start of a tag
$inside_tag = true;
- } elseif ($cur_char == '>' && ! $inside_attribute) {
+ } elseif ($cur_char == '>' && !$inside_attribute) {
// end of a tag
$inside_tag = false;
} elseif (($cur_char == '"' || $cur_char == "'") && $inside_tag) {
// start or end of an attribute
- if (! $inside_attribute) {
+ if (!$inside_attribute) {
$inside_attribute = true;
// remember the attribute`s declaration character (" or ')
$start_attribute_character = $cur_char;
@@ -515,7 +534,6 @@ class ImportMediawiki extends ImportPlugin
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
-
/**
* Returns true if the table should be analyzed, false otherwise
*
@@ -552,7 +570,9 @@ class ImportMediawiki extends ImportPlugin
// A '|' inside an invalid link should not
// be mistaken as delimiting cell parameters
- if (/*overload*/mb_strpos($cell_data[0], '[[') === false) {
+ if (/*overload*/
+ mb_strpos($cell_data[0], '[[') === false
+ ) {
return $cell;
}
@@ -576,6 +596,7 @@ class ImportMediawiki extends ImportPlugin
if ($inside_structure_comment) {
$inside_structure_comment = false;
}
+
return $inside_structure_comment;
}
@@ -589,9 +610,14 @@ class ImportMediawiki extends ImportPlugin
*/
private function _getCellContent($cell, $col_start_char)
{
- if (/*overload*/mb_strpos($cell, $col_start_char) === 0) {
- $cell = trim(/*overload*/mb_substr($cell, 1));
+ if (/*overload*/
+ mb_strpos($cell, $col_start_char) === 0
+ ) {
+ $cell = trim(/*overload*/
+ mb_substr($cell, 1)
+ );
}
+
return $cell;
}
}
diff --git a/libraries/plugins/import/ImportOds.class.php b/libraries/plugins/import/ImportOds.php
similarity index 94%
rename from libraries/plugins/import/ImportOds.class.php
rename to libraries/plugins/import/ImportOds.php
index 756d42a997..93430b127c 100644
--- a/libraries/plugins/import/ImportOds.class.php
+++ b/libraries/plugins/import/ImportOds.php
@@ -3,22 +3,31 @@
/**
* OpenDocument Spreadsheet import plugin for phpMyAdmin
*
- * @todo Pretty much everything
- * @todo Importing of accented characters seems to fail
+ * @todo Pretty much everything
+ * @todo Importing of accented characters seems to fail
* @package PhpMyAdmin-Import
* @subpackage ODS
*/
-use PMA\libraries\plugins\ImportPlugin;
+namespace PMA\libraries\plugins\import;
-if (! defined('PHPMYADMIN')) {
+use BoolPropertyItem;
+use ImportPluginProperties;
+use OptionsPropertyMainGroup;
+use OptionsPropertyRootGroup;
+use PMA;
+use PMA\libraries\plugins\ImportPlugin;
+use SimpleXMLElement;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
/**
* We need way to disable external XML entities processing.
*/
-if (! function_exists('libxml_disable_entity_loader')) {
+if (!function_exists('libxml_disable_entity_loader')) {
$GLOBALS['skip_import'] = true;
+
return;
}
@@ -119,7 +128,7 @@ class ImportOds extends ImportPlugin
* Read in the file via PMA_importGetNextChunk so that
* it can process compressed files
*/
- while (! ($finished && $i >= $len) && ! $error && ! $timeout_passed) {
+ while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
if ($data === false) {
/* subtract data we didn't handle yet and stop processing */
@@ -209,12 +218,12 @@ class ImportOds extends ImportPlugin
if (count($text) != 0) {
$attr = $cell->attributes('table', true);
- $num_repeat = (int) $attr['number-columns-repeated'];
+ $num_repeat = (int)$attr['number-columns-repeated'];
$num_iterations = $num_repeat ? $num_repeat : 1;
for ($k = 0; $k < $num_iterations; $k++) {
$value = $this->getValue($cell_attrs, $text);
- if (! $col_names_in_first_row) {
+ if (!$col_names_in_first_row) {
$tempRow[] = $value;
} else {
// MySQL column names can't end with a space
@@ -236,7 +245,7 @@ class ImportOds extends ImportPlugin
$num_null = (int)$attr['number-columns-repeated'];
if ($num_null) {
- if (! $col_names_in_first_row) {
+ if (!$col_names_in_first_row) {
for ($i = 0; $i < $num_null; ++$i) {
$tempRow[] = 'NULL';
++$col_count;
@@ -250,7 +259,7 @@ class ImportOds extends ImportPlugin
}
}
} else {
- if (! $col_names_in_first_row) {
+ if (!$col_names_in_first_row) {
$tempRow[] = 'NULL';
} else {
$col_names[] = PMA_getColumnAlphaName(
@@ -268,7 +277,7 @@ class ImportOds extends ImportPlugin
}
/* Don't include a row that is full of NULL values */
- if (! $col_names_in_first_row) {
+ if (!$col_names_in_first_row) {
if ($_REQUEST['ods_empty_rows']) {
foreach ($tempRow as $cell) {
if (strcmp('NULL', $cell)) {
@@ -341,7 +350,7 @@ class ImportOds extends ImportPlugin
continue;
}
- if (! isset($tables[$i][COL_NAMES])) {
+ if (!isset($tables[$i][COL_NAMES])) {
$tables[$i][] = $rows[$j][COL_NAMES];
}
@@ -407,11 +416,13 @@ class ImportOds extends ImportPlugin
)
) {
$value = (double)$cell_attrs['value'];
+
return $value;
} elseif ($_REQUEST['ods_recognize_currency']
&& !strcmp('currency', $cell_attrs['value-type'])
) {
$value = (double)$cell_attrs['value'];
+
return $value;
} else {
/* We need to concatenate all paragraphs */
@@ -420,6 +431,7 @@ class ImportOds extends ImportPlugin
$values[] = (string)$paragraph;
}
$value = implode("\n", $values);
+
return $value;
}
}
diff --git a/libraries/plugins/import/ImportShp.class.php b/libraries/plugins/import/ImportShp.php
similarity index 81%
rename from libraries/plugins/import/ImportShp.class.php
rename to libraries/plugins/import/ImportShp.php
index 4880ac8398..4f9ecdc8a5 100644
--- a/libraries/plugins/import/ImportShp.class.php
+++ b/libraries/plugins/import/ImportShp.php
@@ -6,16 +6,24 @@
* @package PhpMyAdmin-Import
* @subpackage ESRI_Shape
*/
-use PMA\libraries\plugins\ImportPlugin;
+namespace PMA\libraries\plugins\import;
-if (! defined('PHPMYADMIN')) {
+use ImportPluginProperties;
+use PMA;
+use PMA\libraries\plugins\ImportPlugin;
+use PMA_GIS_Factory;
+use PMA_GIS_Multilinestring;
+use PMA_GIS_Multipoint;
+use PMA_GIS_Point;
+use PMA_GIS_Polygon;
+use PMA\libraries\plugins\import\ShapeFile;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
/* Get the ShapeFile class */
require_once 'libraries/bfShapeFiles/ShapeFile.lib.php';
-require_once 'libraries/plugins/import/ShapeFile.class.php';
-require_once 'libraries/plugins/import/ShapeRecord.class.php';
/**
* Handles the import for ESRI Shape files
@@ -61,17 +69,17 @@ class ImportShp extends ImportPlugin
public function doImport()
{
global $db, $error, $finished, $compression,
- $import_file, $local_import_file, $message;
+ $import_file, $local_import_file, $message;
$GLOBALS['finished'] = false;
- $shp = new PMA_ShapeFile(1);
+ $shp = new 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');
+ $zip_content = PMA_getZipContents($import_file, '/^.*\.shp$/i');
$GLOBALS['import_text'] = $zip_content['data'];
}
@@ -81,16 +89,17 @@ class ImportShp extends ImportPlugin
// If we can extract the zip archive to 'TempDir'
// and use the files in it for import
if ($compression == 'application/zip'
- && ! empty($GLOBALS['cfg']['TempDir'])
+ && !empty($GLOBALS['cfg']['TempDir'])
&& is_writable($GLOBALS['cfg']['TempDir'])
) {
$dbf_file_name = PMA_findFileFromZipArchive(
- '/^.*\.dbf$/i', $import_file
+ '/^.*\.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(
+ $extracted = PMA_zipExtract(
$import_file,
realpath($GLOBALS['cfg']['TempDir']),
array($dbf_file_name)
@@ -101,27 +110,33 @@ class ImportShp extends ImportPlugin
$temp_dbf_file = true;
// Replace the .dbf with .*, as required
// by the bsShapeFiles library.
- $file_name = /*overload*/mb_substr(
- $dbf_file_path,
- 0,
- /*overload*/mb_strlen($dbf_file_path) - 4
- ) . '.*';
+ $file_name
+ = /*overload*/
+ mb_substr(
+ $dbf_file_path,
+ 0,
+ /*overload*/
+ mb_strlen($dbf_file_path) - 4
+ ) . '.*';
$shp->FileName = $file_name;
}
}
- } elseif (! empty($local_import_file)
- && ! empty($GLOBALS['cfg']['UploadDir'])
+ } elseif (!empty($local_import_file)
+ && !empty($GLOBALS['cfg']['UploadDir'])
&& $compression == 'none'
) {
// If file is in UploadDir, use .dbf file in the same UploadDir
// to load extra data.
// Replace the .shp with .*,
// so the bsShapeFiles library correctly locates .dbf file.
- $file_name = /*overload*/mb_substr(
- $import_file,
- 0,
- /*overload*/mb_strlen($import_file) - 4
- ) . '.*';
+ $file_name
+ = /*overload*/
+ mb_substr(
+ $import_file,
+ 0,
+ /*overload*/
+ mb_strlen($import_file) - 4
+ ) . '.*';
$shp->FileName = $file_name;
}
}
@@ -134,6 +149,7 @@ class ImportShp extends ImportPlugin
__('There was an error importing the ESRI shape file: "%s".')
);
$message->addParam($shp->lastError);
+
return;
}
@@ -146,11 +162,11 @@ class ImportShp extends ImportPlugin
}
$esri_types = array(
- 0 => 'Null Shape',
- 1 => 'Point',
- 3 => 'PolyLine',
- 5 => 'Polygon',
- 8 => 'MultiPoint',
+ 0 => 'Null Shape',
+ 1 => 'Point',
+ 3 => 'PolyLine',
+ 5 => 'Polygon',
+ 8 => 'MultiPoint',
11 => 'PointZ',
13 => 'PolyLineZ',
15 => 'PolygonZ',
@@ -163,28 +179,28 @@ class ImportShp extends ImportPlugin
);
switch ($shp->shapeType) {
- // ESRI Null Shape
+ // ESRI Null Shape
case 0:
break;
- // ESRI Point
+ // ESRI Point
case 1:
$gis_type = 'point';
break;
- // ESRI PolyLine
+ // ESRI PolyLine
case 3:
$gis_type = 'multilinestring';
break;
- // ESRI Polygon
+ // ESRI Polygon
case 5:
$gis_type = 'multipolygon';
break;
- // ESRI MultiPoint
+ // ESRI MultiPoint
case 8:
$gis_type = 'multipoint';
break;
default:
$error = true;
- if (! isset($esri_types[$shp->shapeType])) {
+ if (!isset($esri_types[$shp->shapeType])) {
$message = PMA\libraries\Message::error(
__(
'You tried to import an invalid file or the imported file'
@@ -197,13 +213,14 @@ class ImportShp extends ImportPlugin
);
$message->addParam($esri_types[$shp->shapeType]);
}
+
return;
}
if (isset($gis_type)) {
include_once './libraries/gis/GIS_Factory.class.php';
/** @var PMA_GIS_Multilinestring|PMA_GIS_Multipoint|PMA_GIS_Point|PMA_GIS_Polygon $gis_obj */
- $gis_obj = PMA_GIS_Factory::factory($gis_type);
+ $gis_obj = PMA_GIS_Factory::factory($gis_type);
} else {
$gis_obj = null;
}
@@ -228,7 +245,7 @@ class ImportShp extends ImportPlugin
foreach ($shp->DBFHeader as $c) {
$cell = trim($record->DBFData[$c[0]]);
- if (! strcmp($cell, '')) {
+ if (!strcmp($cell, '')) {
$cell = 'NULL';
}
@@ -244,6 +261,7 @@ class ImportShp extends ImportPlugin
$message = PMA\libraries\Message::error(
__('The imported file does not contain any data!')
);
+
return;
}
@@ -255,7 +273,9 @@ class ImportShp extends ImportPlugin
}
// Set table name based on the number of tables
- if (/*overload*/mb_strlen($db)) {
+ if (/*overload*/
+ mb_strlen($db)
+ ) {
$result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
$table_name = 'TABLE ' . (count($result) + 1);
} else {
@@ -267,12 +287,15 @@ class ImportShp extends ImportPlugin
$analyses = array();
$analyses[] = PMA_analyzeTable($tables[0]);
- $table_no = 0; $spatial_col = 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 (/*overload*/mb_strlen($db)) {
+ if (/*overload*/
+ mb_strlen($db)
+ ) {
$db_name = $db;
$options = array('create_db' => false);
} else {
@@ -317,6 +340,7 @@ class ImportShp extends ImportPlugin
}
$result = substr($buffer, 0, $length);
$buffer = substr($buffer, $length);
+
return $result;
}
}
diff --git a/libraries/plugins/import/ImportSql.class.php b/libraries/plugins/import/ImportSql.php
similarity index 93%
rename from libraries/plugins/import/ImportSql.class.php
rename to libraries/plugins/import/ImportSql.php
index 9b47f484ca..6d877bb6ff 100644
--- a/libraries/plugins/import/ImportSql.class.php
+++ b/libraries/plugins/import/ImportSql.php
@@ -6,9 +6,18 @@
* @package PhpMyAdmin-Import
* @subpackage SQL
*/
-use PMA\libraries\plugins\ImportPlugin;
+namespace PMA\libraries\plugins\import;
-if (! defined('PHPMYADMIN')) {
+use BoolPropertyItem;
+use ImportPluginProperties;
+use OptionsPropertyMainGroup;
+use OptionsPropertyRootGroup;
+use PMA;
+use PMA\libraries\plugins\ImportPlugin;
+use SelectPropertyItem;
+use SqlParser;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
@@ -20,7 +29,6 @@ if (! defined('PHPMYADMIN')) {
*/
class ImportSql extends ImportPlugin
{
-
/**
* Constructor
*/
@@ -86,7 +94,7 @@ class ImportSql extends ImportPlugin
array(
'manual_MySQL_Database_Administration',
'Server_SQL_mode',
- 'sqlmode_no_auto_value_on_zero'
+ 'sqlmode_no_auto_value_on_zero',
)
);
$generalOptions->addProperty($leaf);
@@ -121,7 +129,8 @@ class ImportSql extends ImportPlugin
/**
* Will be set in PMA_importGetNextChunk().
- * @global bool $GLOBALS['finished']
+ *
+ * @global bool $GLOBALS ['finished']
*/
$GLOBALS['finished'] = false;
@@ -176,7 +185,7 @@ class ImportSql extends ImportPlugin
* Handle compatibility options
*
* @param PMA\libraries\DatabaseInterface $dbi Database interface
- * @param array $request Request array
+ * @param array $request Request array
*
* @return void
*/
diff --git a/libraries/plugins/import/ImportXml.class.php b/libraries/plugins/import/ImportXml.php
similarity index 91%
rename from libraries/plugins/import/ImportXml.class.php
rename to libraries/plugins/import/ImportXml.php
index 05d02e1875..71829c42a6 100644
--- a/libraries/plugins/import/ImportXml.class.php
+++ b/libraries/plugins/import/ImportXml.php
@@ -8,17 +8,23 @@
* @subpackage XML
*/
-use PMA\libraries\plugins\ImportPlugin;
+namespace PMA\libraries\plugins\import;
-if (! defined('PHPMYADMIN')) {
+use ImportPluginProperties;
+use PMA;
+use PMA\libraries\plugins\ImportPlugin;
+use SimpleXMLElement;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
/**
* We need way to disable external XML entities processing.
*/
-if (! function_exists('libxml_disable_entity_loader')) {
+if (!function_exists('libxml_disable_entity_loader')) {
$GLOBALS['skip_import'] = true;
+
return;
}
@@ -76,7 +82,7 @@ class ImportXml extends ImportPlugin
* Read in the file via PMA_importGetNextChunk so that
* it can process compressed files
*/
- while (! ($finished && $i >= $len) && ! $error && ! $timeout_passed) {
+ while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
if ($data === false) {
/* subtract data we didn't handle yet and stop processing */
@@ -118,9 +124,11 @@ class ImportXml extends ImportPlugin
'The XML file specified was either malformed or incomplete.'
. ' Please correct the issue and try again.'
)
- )->display();
+ )
+ ->display();
unset($xml);
$GLOBALS['finished'] = false;
+
return;
}
@@ -165,7 +173,8 @@ class ImportXml extends ImportPlugin
* If the structure section is not present
* get the database name from the data section
*/
- $db_attr = $xml->children()->attributes();
+ $db_attr = $xml->children()
+ ->attributes();
$db_name = (string)$db_attr['name'];
$collation = null;
$charset = null;
@@ -180,9 +189,11 @@ class ImportXml extends ImportPlugin
'The XML file specified was either malformed or incomplete.'
. ' Please correct the issue and try again.'
)
- )->display();
+ )
+ ->display();
unset($xml);
$GLOBALS['finished'] = false;
+
return;
}
@@ -192,6 +203,7 @@ class ImportXml extends ImportPlugin
if (isset($namespaces['pma'])) {
/**
* Get structures for all tables
+ *
* @var SimpleXMLElement $struct
*/
$struct = $xml->children($namespaces['pma']);
@@ -230,7 +242,8 @@ class ImportXml extends ImportPlugin
/**
* Move down the XML tree to the actual data
*/
- $xml = $xml->children()->children();
+ $xml = $xml->children()
+ ->children();
$data_present = false;
@@ -249,7 +262,7 @@ class ImportXml extends ImportPlugin
$isInTables = false;
$num_tables = count($tables);
for ($i = 0; $i < $num_tables; ++$i) {
- if (! strcmp($tables[$i][TBL_NAME], (string)$tbl_attr['name'])) {
+ if (!strcmp($tables[$i][TBL_NAME], (string)$tbl_attr['name'])) {
$isInTables = true;
break;
}
@@ -261,7 +274,7 @@ class ImportXml extends ImportPlugin
foreach ($v1 as $v2) {
$row_attr = $v2->attributes();
- if (! array_search((string)$row_attr['name'], $tempRow)) {
+ if (!array_search((string)$row_attr['name'], $tempRow)) {
$tempRow[] = (string)$row_attr['name'];
}
$tempCells[] = (string)$v2;
@@ -284,8 +297,8 @@ class ImportXml extends ImportPlugin
for ($i = 0; $i < $num_tables; ++$i) {
$num_rows = count($rows);
for ($j = 0; $j < $num_rows; ++$j) {
- if (! strcmp($tables[$i][TBL_NAME], $rows[$j][TBL_NAME])) {
- if (! isset($tables[$i][COL_NAMES])) {
+ if (!strcmp($tables[$i][TBL_NAME], $rows[$j][TBL_NAME])) {
+ if (!isset($tables[$i][COL_NAMES])) {
$tables[$i][] = $rows[$j][COL_NAMES];
}
@@ -296,7 +309,7 @@ class ImportXml extends ImportPlugin
unset($rows);
- if (! $struct_present) {
+ if (!$struct_present) {
$analyses = array();
$len = count($tables);
@@ -318,9 +331,9 @@ class ImportXml extends ImportPlugin
* Set values to NULL if they were not present
* to maintain PMA_buildSQL() call integrity
*/
- if (! isset($analyses)) {
+ if (!isset($analyses)) {
$analyses = null;
- if (! $struct_present) {
+ if (!$struct_present) {
$create = null;
}
}
diff --git a/libraries/plugins/import/ShapeFile.class.php b/libraries/plugins/import/ShapeFile.php
similarity index 88%
rename from libraries/plugins/import/ShapeFile.class.php
rename to libraries/plugins/import/ShapeFile.php
index c3550f9305..b63c4462e2 100644
--- a/libraries/plugins/import/ShapeFile.class.php
+++ b/libraries/plugins/import/ShapeFile.php
@@ -7,20 +7,23 @@
* @package PhpMyAdmin-Import
* @subpackage ESRI_Shape
*/
-if (! defined('PHPMYADMIN')) {
+namespace PMA\libraries\plugins\import;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
/**
* 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 ImportShp::readFromBuffer() in place
- * of fread(). This makes it possible to use compressions.
+ * reading directly from a file. Using
+ * PMA\libraries\plugins\import\ImportShp::readFromBuffer() in place of fread().
+ * This makes it possible to use compressions.
*
* @package PhpMyAdmin-Import
* @subpackage ESRI_Shape
*/
-class PMA_ShapeFile extends ShapeFile
+class ShapeFile extends \ShapeFile
{
/**
* Returns whether the 'dbase' extension is loaded
@@ -86,7 +89,7 @@ class PMA_ShapeFile extends ShapeFile
global $eof;
ImportShp::readFromBuffer(32);
while (true) {
- $record = new PMA_ShapeRecord(-1);
+ $record = new ShapeRecord(-1);
$record->loadFromFile($this->SHPFile, $this->DBFFile);
if ($record->lastError != "") {
return false;
diff --git a/libraries/plugins/import/ShapeRecord.class.php b/libraries/plugins/import/ShapeRecord.php
similarity index 87%
rename from libraries/plugins/import/ShapeRecord.class.php
rename to libraries/plugins/import/ShapeRecord.php
index c6d9313b7e..b2e8df17a6 100644
--- a/libraries/plugins/import/ShapeRecord.class.php
+++ b/libraries/plugins/import/ShapeRecord.php
@@ -7,20 +7,23 @@
* @package PhpMyAdmin-Import
* @subpackage ESRI_Shape
*/
-if (! defined('PHPMYADMIN')) {
+namespace PMA\libraries\plugins\import;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
/**
* 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 ImportShp::readFromBuffer() in place
- * of fread(). This makes it possible to use compressions.
+ * reading directly from a file. Using
+ * PMA\libraries\plugins\import\ImportShp::readFromBuffer() in place of fread().
+ * This makes it possible to use compressions.
*
* @package PhpMyAdmin-Import
* @subpackage ESRI_Shape
*/
-class PMA_ShapeRecord extends ShapeRecord
+class ShapeRecord extends \ShapeRecord
{
/**
* Loads a geometry data record from the file
@@ -130,26 +133,27 @@ class PMA_ShapeRecord extends ShapeRecord
$this->SHPData["xmax"] = loadData("d", ImportShp::readFromBuffer(8));
$this->SHPData["ymax"] = loadData("d", ImportShp::readFromBuffer(8));
- $this->SHPData["numparts"] = loadData("V", ImportShp::readFromBuffer(4));
+ $this->SHPData["numparts"] = loadData("V", ImportShp::readFromBuffer(4));
$this->SHPData["numpoints"] = loadData("V", ImportShp::readFromBuffer(4));
for ($i = 0; $i < $this->SHPData["numparts"]; $i++) {
$this->SHPData["parts"][$i] = loadData(
- "V", ImportShp::readFromBuffer(4)
+ "V",
+ ImportShp::readFromBuffer(4)
);
}
$readPoints = 0;
reset($this->SHPData["parts"]);
while (list($partIndex,) = each($this->SHPData["parts"])) {
- if (! isset($this->SHPData["parts"][$partIndex]["points"])
+ 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"]))
+ while (!in_array($readPoints, $this->SHPData["parts"])
+ && ($readPoints < ($this->SHPData["numpoints"]))
) {
$this->SHPData["parts"][$partIndex]["points"][]
= $this->_loadPoint();
diff --git a/libraries/plugins/schema/Export_Relation_Schema.class.php b/libraries/plugins/schema/ExportRelationSchema.php
similarity index 94%
rename from libraries/plugins/schema/Export_Relation_Schema.class.php
rename to libraries/plugins/schema/ExportRelationSchema.php
index 12c27826fe..aaf6a2398f 100644
--- a/libraries/plugins/schema/Export_Relation_Schema.class.php
+++ b/libraries/plugins/schema/ExportRelationSchema.php
@@ -1,12 +1,16 @@
db . $extension;
// Get the name of this page to use as filename
- if ($this->pageNumber != -1 && ! $this->offline) {
+ if ($this->pageNumber != -1 && !$this->offline) {
$_name_sql = 'SELECT page_descr FROM '
. PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['pdf_pages'])
@@ -286,7 +289,7 @@ class PMA_Export_Relation_Schema
*/
public static function dieSchema($pageNumber, $type = '', $error_message = '')
{
- echo "
" . __("SCHEMA ERROR: ") . $type . "
" . "\n";
+ echo "" . __("SCHEMA ERROR: ") . $type . "
" . "\n";
if (!empty($error_message)) {
$error_message = htmlspecialchars($error_message);
}
diff --git a/libraries/plugins/schema/RelationStats.class.php b/libraries/plugins/schema/RelationStats.php
similarity index 69%
rename from libraries/plugins/schema/RelationStats.class.php
rename to libraries/plugins/schema/RelationStats.php
index 6e4c2f6715..f5d269b0de 100644
--- a/libraries/plugins/schema/RelationStats.class.php
+++ b/libraries/plugins/schema/RelationStats.php
@@ -5,7 +5,9 @@
*
* @package PhpMyAdmin
*/
-if (! defined('PHPMYADMIN')) {
+namespace PMA\libraries\plugins\schema;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
@@ -26,7 +28,7 @@ abstract class RelationStats
* Defines properties
*/
public $xSrc, $ySrc;
- public $srcDir ;
+ public $srcDir;
public $destDir;
public $xDest, $yDest;
public $wTick;
@@ -41,50 +43,54 @@ abstract class RelationStats
* @param string $foreign_field The relation field in the foreign table
*/
public function __construct(
- $diagram, $master_table, $master_field, $foreign_table, $foreign_field
+ $diagram,
+ $master_table,
+ $master_field,
+ $foreign_table,
+ $foreign_field
) {
$this->diagram = $diagram;
- $src_pos = $this->_getXy($master_table, $master_field);
+ $src_pos = $this->_getXy($master_table, $master_field);
$dest_pos = $this->_getXy($foreign_table, $foreign_field);
/*
* [0] is x-left
* [1] is x-right
* [2] is y
*/
- $src_left = $src_pos[0] - $this->wTick;
- $src_right = $src_pos[1] + $this->wTick;
- $dest_left = $dest_pos[0] - $this->wTick;
+ $src_left = $src_pos[0] - $this->wTick;
+ $src_right = $src_pos[1] + $this->wTick;
+ $dest_left = $dest_pos[0] - $this->wTick;
$dest_right = $dest_pos[1] + $this->wTick;
$d1 = abs($src_left - $dest_left);
$d2 = abs($src_right - $dest_left);
$d3 = abs($src_left - $dest_right);
$d4 = abs($src_right - $dest_right);
- $d = min($d1, $d2, $d3, $d4);
+ $d = min($d1, $d2, $d3, $d4);
if ($d == $d1) {
- $this->xSrc = $src_pos[0];
- $this->srcDir = -1;
- $this->xDest = $dest_pos[0];
+ $this->xSrc = $src_pos[0];
+ $this->srcDir = -1;
+ $this->xDest = $dest_pos[0];
$this->destDir = -1;
} elseif ($d == $d2) {
- $this->xSrc = $src_pos[1];
- $this->srcDir = 1;
- $this->xDest = $dest_pos[0];
+ $this->xSrc = $src_pos[1];
+ $this->srcDir = 1;
+ $this->xDest = $dest_pos[0];
$this->destDir = -1;
} elseif ($d == $d3) {
- $this->xSrc = $src_pos[0];
- $this->srcDir = -1;
- $this->xDest = $dest_pos[1];
+ $this->xSrc = $src_pos[0];
+ $this->srcDir = -1;
+ $this->xDest = $dest_pos[1];
$this->destDir = 1;
} else {
- $this->xSrc = $src_pos[1];
- $this->srcDir = 1;
- $this->xDest = $dest_pos[1];
+ $this->xSrc = $src_pos[1];
+ $this->srcDir = 1;
+ $this->xDest = $dest_pos[1];
$this->destDir = 1;
}
- $this->ySrc = $src_pos[2];
+ $this->ySrc = $src_pos[2];
$this->yDest = $dest_pos[2];
}
@@ -101,11 +107,12 @@ abstract class RelationStats
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
+ $table->y + ($pos + 1.5) * $table->heightCell,
);
}
}
diff --git a/libraries/plugins/schema/SchemaDia.class.php b/libraries/plugins/schema/SchemaDia.php
similarity index 91%
rename from libraries/plugins/schema/SchemaDia.class.php
rename to libraries/plugins/schema/SchemaDia.php
index 267cb7bd77..9e8e5f262f 100644
--- a/libraries/plugins/schema/SchemaDia.class.php
+++ b/libraries/plugins/schema/SchemaDia.php
@@ -6,15 +6,19 @@
* @package PhpMyAdmin-Schema
* @subpackage Dia
*/
-use PMA\libraries\plugins\SchemaPlugin;
+namespace PMA\libraries\plugins\schema;
-if (! defined('PHPMYADMIN')) {
+use OptionsPropertyMainGroup;
+use OptionsPropertyRootGroup;
+use PMA\libraries\plugins\SchemaPlugin;
+use PMA\libraries\plugins\schema\dia\DiaRelationSchema;
+use SchemaPluginProperties;
+use SelectPropertyItem;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
-/* Get the schema export interface */
-require_once 'libraries/plugins/schema/dia/Dia_Relation_Schema.class.php';
-
/**
* Handles the schema export for the Dia format
*
@@ -98,10 +102,10 @@ class SchemaDia extends SchemaPlugin
foreach ($GLOBALS['cfg']['PDFPageSizes'] as $val) {
$ret[$val] = $val;
}
+
return $ret;
}
-
/**
* Exports the schema into DIA format.
*
@@ -111,7 +115,7 @@ class SchemaDia extends SchemaPlugin
*/
public function exportSchema($db)
{
- $export = new PMA_Dia_Relation_Schema($db);
+ $export = new DiaRelationSchema($db);
$export->showOutput();
}
}
diff --git a/libraries/plugins/schema/SchemaEps.class.php b/libraries/plugins/schema/SchemaEps.php
similarity index 90%
rename from libraries/plugins/schema/SchemaEps.class.php
rename to libraries/plugins/schema/SchemaEps.php
index e9210eca11..92553cfb52 100644
--- a/libraries/plugins/schema/SchemaEps.class.php
+++ b/libraries/plugins/schema/SchemaEps.php
@@ -6,15 +6,20 @@
* @package PhpMyAdmin-Schema
* @subpackage EPS
*/
-use PMA\libraries\plugins\SchemaPlugin;
+namespace PMA\libraries\plugins\schema;
-if (! defined('PHPMYADMIN')) {
+use BoolPropertyItem;
+use OptionsPropertyMainGroup;
+use OptionsPropertyRootGroup;
+use PMA\libraries\plugins\schema\eps\EpsRelationSchema;
+use PMA\libraries\plugins\SchemaPlugin;
+use SchemaPluginProperties;
+use SelectPropertyItem;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
-/* Get the schema export interface */
-require_once 'libraries/plugins/schema/eps/Eps_Relation_Schema.class.php';
-
/**
* Handles the schema export for the EPS format
*
@@ -96,7 +101,7 @@ class SchemaEps extends SchemaPlugin
*/
public function exportSchema($db)
{
- $export = new PMA_Eps_Relation_Schema($db);
+ $export = new EpsRelationSchema($db);
$export->showOutput();
}
}
diff --git a/libraries/plugins/schema/SchemaPdf.class.php b/libraries/plugins/schema/SchemaPdf.php
similarity index 90%
rename from libraries/plugins/schema/SchemaPdf.class.php
rename to libraries/plugins/schema/SchemaPdf.php
index ab42b375be..98d3392aa7 100644
--- a/libraries/plugins/schema/SchemaPdf.class.php
+++ b/libraries/plugins/schema/SchemaPdf.php
@@ -6,15 +6,20 @@
* @package PhpMyAdmin-Schema
* @subpackage PDF
*/
-use PMA\libraries\plugins\SchemaPlugin;
+namespace PMA\libraries\plugins\schema;
-if (! defined('PHPMYADMIN')) {
+use BoolPropertyItem;
+use OptionsPropertyMainGroup;
+use OptionsPropertyRootGroup;
+use PMA\libraries\plugins\schema\pdf\PdfRelationSchema;
+use PMA\libraries\plugins\SchemaPlugin;
+use SchemaPluginProperties;
+use SelectPropertyItem;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
-/* Get the schema export interface */
-require_once 'libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php';
-
/**
* Handles the schema export for the PDF format
*
@@ -100,8 +105,8 @@ class SchemaPdf extends SchemaPlugin
$leaf->setText(__('Order of the tables'));
$leaf->setValues(
array(
- '' => __('None'),
- 'name_asc' => __('Name (Ascending)'),
+ '' => __('None'),
+ 'name_asc' => __('Name (Ascending)'),
'name_desc' => __('Name (Descending)'),
)
);
@@ -126,6 +131,7 @@ class SchemaPdf extends SchemaPlugin
foreach ($GLOBALS['cfg']['PDFPageSizes'] as $val) {
$ret[$val] = $val;
}
+
return $ret;
}
@@ -138,7 +144,7 @@ class SchemaPdf extends SchemaPlugin
*/
public function exportSchema($db)
{
- $export = new PMA_Pdf_Relation_Schema($db);
+ $export = new PdfRelationSchema($db);
$export->showOutput();
}
}
diff --git a/libraries/plugins/schema/SchemaSvg.class.php b/libraries/plugins/schema/SchemaSvg.php
similarity index 89%
rename from libraries/plugins/schema/SchemaSvg.class.php
rename to libraries/plugins/schema/SchemaSvg.php
index 2eaee8fc41..4ab42a175b 100644
--- a/libraries/plugins/schema/SchemaSvg.class.php
+++ b/libraries/plugins/schema/SchemaSvg.php
@@ -6,15 +6,19 @@
* @package PhpMyAdmin-Schema
* @subpackage SVG
*/
-use PMA\libraries\plugins\SchemaPlugin;
+namespace PMA\libraries\plugins\schema;
-if (! defined('PHPMYADMIN')) {
+use BoolPropertyItem;
+use OptionsPropertyMainGroup;
+use OptionsPropertyRootGroup;
+use PMA\libraries\plugins\SchemaPlugin;
+use PMA\libraries\plugins\schema\svg\SvgRelationSchema;
+use SchemaPluginProperties;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
-/* Get the schema export interface */
-require_once 'libraries/plugins/schema/svg/Svg_Relation_Schema.class.php';
-
/**
* Handles the schema export for the SVG format
*
@@ -84,7 +88,7 @@ class SchemaSvg extends SchemaPlugin
*/
public function exportSchema($db)
{
- $export = new PMA_Svg_Relation_Schema($db);
+ $export = new SvgRelationSchema($db);
$export->showOutput();
}
}
diff --git a/libraries/plugins/schema/TableStats.class.php b/libraries/plugins/schema/TableStats.php
similarity index 98%
rename from libraries/plugins/schema/TableStats.class.php
rename to libraries/plugins/schema/TableStats.php
index 7e33c8c6e7..bd5520db94 100644
--- a/libraries/plugins/schema/TableStats.class.php
+++ b/libraries/plugins/schema/TableStats.php
@@ -5,7 +5,11 @@
*
* @package PhpMyAdmin
*/
-if (! defined('PHPMYADMIN')) {
+namespace PMA\libraries\plugins\schema;
+
+use PMA;
+
+if (!defined('PHPMYADMIN')) {
exit;
}
@@ -24,18 +28,14 @@ abstract class TableStats
protected $db;
protected $pageNumber;
protected $tableName;
-
protected $showKeys;
protected $tableDimension;
-
public $displayfield;
public $fields = array();
public $primary = array();
public $x, $y;
-
public $width = 0;
public $heightCell = 0;
-
protected $offline;
/**
diff --git a/libraries/plugins/schema/dia/Dia.php b/libraries/plugins/schema/dia/Dia.php
new file mode 100644
index 0000000000..1060da8594
--- /dev/null
+++ b/libraries/plugins/schema/dia/Dia.php
@@ -0,0 +1,189 @@
+openMemory();
+ /*
+ * Set indenting using three spaces,
+ * so output is formatted
+ */
+ $this->setIndent(true);
+ $this->setIndentString(' ');
+ /*
+ * Create the XML document
+ */
+ $this->startDocument('1.0', 'UTF-8');
+ }
+
+ /**
+ * Starts Dia Document
+ *
+ * dia document starts by first initializing dia:diagram tag
+ * then dia:diagramdata contains all the attributes that needed
+ * 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 $orientation orientation of the document, portrait or landscape
+ *
+ * @return void
+ *
+ * @access public
+ * @see XMLWriter::startElement(),XMLWriter::writeAttribute(),
+ * XMLWriter::writeRaw()
+ */
+ public function startDiaDoc(
+ $paper,
+ $topMargin,
+ $bottomMargin,
+ $leftMargin,
+ $rightMargin,
+ $orientation
+ ) {
+ if ($orientation == 'P') {
+ $isPortrait = 'true';
+ } else {
+ $isPortrait = 'false';
+ }
+ $this->startElement('dia:diagram');
+ $this->writeAttribute('xmlns:dia', 'http://www.lysator.liu.se/~alla/dia/');
+ $this->startElement('dia:diagramdata');
+ $this->writeRaw(
+ '
+
+
+
+
+
+
+
+
+ #' . $paper . '#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ '
+ );
+ $this->endElement();
+ $this->startElement('dia:layer');
+ $this->writeAttribute('name', 'Background');
+ $this->writeAttribute('visible', 'true');
+ $this->writeAttribute('active', 'true');
+ }
+
+ /**
+ * Ends Dia Document
+ *
+ * @return void
+ * @access public
+ * @see XMLWriter::endElement(),XMLWriter::endDocument()
+ */
+ public function endDiaDoc()
+ {
+ $this->endElement();
+ $this->endDocument();
+ }
+
+ /**
+ * Output Dia Document for download
+ *
+ * @param string $fileName name of the dia document
+ *
+ * @return void
+ * @access public
+ * @see XMLWriter::flush()
+ */
+ public function showOutput($fileName)
+ {
+ if (ob_get_clean()) {
+ ob_end_clean();
+ }
+ $output = $this->flush();
+ PMA\libraries\Response::getInstance()
+ ->disable();
+ PMA_downloadHeader(
+ $fileName,
+ 'application/x-dia-diagram',
+ /*overload*/
+ mb_strlen($output)
+ );
+ print $output;
+ }
+}
\ No newline at end of file
diff --git a/libraries/plugins/schema/dia/DiaRelationSchema.php b/libraries/plugins/schema/dia/DiaRelationSchema.php
new file mode 100644
index 0000000000..f200eaad98
--- /dev/null
+++ b/libraries/plugins/schema/dia/DiaRelationSchema.php
@@ -0,0 +1,231 @@
+setShowColor(isset($_REQUEST['dia_show_color']));
+ $this->setShowKeys(isset($_REQUEST['dia_show_keys']));
+ $this->setOrientation($_REQUEST['dia_orientation']);
+ $this->setPaper($_REQUEST['dia_paper']);
+
+ $this->diagram->startDiaDoc(
+ $this->paper,
+ $this->_topMargin,
+ $this->_bottomMargin,
+ $this->_leftMargin,
+ $this->_rightMargin,
+ $this->orientation
+ );
+
+ $alltables = $this->getTablesFromRequest();
+
+ foreach ($alltables as $table) {
+ if (!isset($this->tables[$table])) {
+ $this->_tables[$table] = new TableStatsDia(
+ $this->diagram, $this->db, $table, $this->pageNumber,
+ $this->showKeys, $this->offline
+ );
+ }
+ }
+
+ $seen_a_relation = false;
+ foreach ($alltables as $one_table) {
+ $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
+ if (!$exist_rel) {
+ continue;
+ }
+
+ $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)
+ */
+ if ($master_field != 'foreign_keys_data') {
+ if (in_array($rel['foreign_table'], $alltables)) {
+ $this->_addRelation(
+ $one_table,
+ $master_field,
+ $rel['foreign_table'],
+ $rel['foreign_field'],
+ $this->showKeys
+ );
+ }
+ continue;
+ }
+
+ foreach ($rel as $one_key) {
+ if (!in_array($one_key['ref_table_name'], $alltables)) {
+ continue;
+ }
+
+ foreach ($one_key['index_list'] as $index => $one_field) {
+ $this->_addRelation(
+ $one_table,
+ $one_field,
+ $one_key['ref_table_name'],
+ $one_key['ref_index_list'][$index],
+ $this->showKeys
+ );
+ }
+ }
+ }
+ }
+ $this->_drawTables();
+
+ if ($seen_a_relation) {
+ $this->_drawRelations();
+ }
+ $this->diagram->endDiaDoc();
+ }
+
+ /**
+ * Output Dia Document for download
+ *
+ * @return void
+ * @access public
+ */
+ public function showOutput()
+ {
+ $this->diagram->showOutput($this->getFileName('.dia'));
+ }
+
+ /**
+ * 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 bool $showKeys Whether to display ONLY keys or not
+ *
+ * @return void
+ *
+ * @access private
+ * @see TableStatsDia::__construct(),RelationStatsDia::__construct()
+ */
+ private function _addRelation(
+ $masterTable,
+ $masterField,
+ $foreignTable,
+ $foreignField,
+ $showKeys
+ ) {
+ if (!isset($this->_tables[$masterTable])) {
+ $this->_tables[$masterTable] = new TableStatsDia(
+ $this->diagram, $this->db, $masterTable, $this->pageNumber, $showKeys
+ );
+ }
+ if (!isset($this->_tables[$foreignTable])) {
+ $this->_tables[$foreignTable] = new TableStatsDia(
+ $this->diagram,
+ $this->db,
+ $foreignTable,
+ $this->pageNumber,
+ $showKeys
+ );
+ }
+ $this->_relations[] = new RelationStatsDia(
+ $this->diagram,
+ $this->_tables[$masterTable],
+ $masterField,
+ $this->_tables[$foreignTable],
+ $foreignField
+ );
+ }
+
+ /**
+ * Draws relation references
+ *
+ * connects master table's master field to
+ * foreign table's foreign field using Dia object
+ * type Database - Reference
+ *
+ * @return void
+ *
+ * @access private
+ * @see RelationStatsDia::relationDraw()
+ */
+ private function _drawRelations()
+ {
+ foreach ($this->_relations as $relation) {
+ $relation->relationDraw($this->showColor);
+ }
+ }
+
+ /**
+ * Draws tables
+ *
+ * Tables are generated using Dia object type Database - Table
+ * primary fields are underlined and bold in tables
+ *
+ * @return void
+ *
+ * @access private
+ * @see TableStatsDia::tableDraw()
+ */
+ private function _drawTables()
+ {
+ foreach ($this->_tables as $table) {
+ $table->tableDraw($this->showColor);
+ }
+ }
+}
diff --git a/libraries/plugins/schema/dia/Dia_Relation_Schema.class.php b/libraries/plugins/schema/dia/Dia_Relation_Schema.class.php
deleted file mode 100644
index 4394122059..0000000000
--- a/libraries/plugins/schema/dia/Dia_Relation_Schema.class.php
+++ /dev/null
@@ -1,383 +0,0 @@
-openMemory();
- /*
- * Set indenting using three spaces,
- * so output is formatted
- */
- $this->setIndent(true);
- $this->setIndentString(' ');
- /*
- * Create the XML document
- */
- $this->startDocument('1.0', 'UTF-8');
- }
-
- /**
- * Starts Dia Document
- *
- * dia document starts by first initializing dia:diagram tag
- * then dia:diagramdata contains all the attributes that needed
- * 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 $orientation orientation of the document, portrait or landscape
- *
- * @return void
- *
- * @access public
- * @see XMLWriter::startElement(),XMLWriter::writeAttribute(),
- * XMLWriter::writeRaw()
- */
- public function startDiaDoc($paper, $topMargin, $bottomMargin, $leftMargin,
- $rightMargin, $orientation
- ) {
- if ($orientation == 'P') {
- $isPortrait = 'true';
- } else {
- $isPortrait = 'false';
- }
- $this->startElement('dia:diagram');
- $this->writeAttribute('xmlns:dia', 'http://www.lysator.liu.se/~alla/dia/');
- $this->startElement('dia:diagramdata');
- $this->writeRaw(
- '
-
-
-
-
-
-
-
-
- #' . $paper . '#
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- '
- );
- $this->endElement();
- $this->startElement('dia:layer');
- $this->writeAttribute('name', 'Background');
- $this->writeAttribute('visible', 'true');
- $this->writeAttribute('active', 'true');
- }
-
- /**
- * Ends Dia Document
- *
- * @return void
- * @access public
- * @see XMLWriter::endElement(),XMLWriter::endDocument()
- */
- public function endDiaDoc()
- {
- $this->endElement();
- $this->endDocument();
- }
-
- /**
- * Output Dia Document for download
- *
- * @param string $fileName name of the dia document
- *
- * @return void
- * @access public
- * @see XMLWriter::flush()
- */
- public function showOutput($fileName)
- {
- if (ob_get_clean()) {
- ob_end_clean();
- }
- $output = $this->flush();
- PMA\libraries\Response::getInstance()->disable();
- PMA_downloadHeader(
- $fileName,
- 'application/x-dia-diagram',
- /*overload*/mb_strlen($output)
- );
- print $output;
- }
-}
-
-/**
- * Dia Relation Schema Class
- *
- * Purpose of this class is to generate the Dia XML Document
- * which is used for representing the database diagrams in Dia IDE
- * This class uses Database Table and Reference Objects of Dia and with
- * the combination of these objects actually helps in preparing Dia XML.
- *
- * Dia XML is generated by using XMLWriter php extension and this class
- * inherits Export_Relation_Schema class has common functionality added
- * to this class
- *
- * @package PhpMyAdmin
- * @name Dia_Relation_Schema
- */
-class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
-{
- /**
- * @var Table_Stats_Dia[]|Table_Stats_Eps[]|Table_Stats_Pdf[]|Table_Stats_Svg[]
- */
- private $_tables = array();
-
- /** @var Relation_Stats_Dia[] Relations */
- private $_relations = array();
- private $_topMargin = 2.8222000598907471;
- private $_bottomMargin = 2.8222000598907471;
- private $_leftMargin = 2.8222000598907471;
- private $_rightMargin = 2.8222000598907471;
- public static $objectId = 0;
-
- /**
- * The "PMA_Dia_Relation_Schema" constructor
- *
- * Upon instantiation This outputs the Dia XML document
- * that user can download
- *
- * @param string $db database name
- *
- * @see PMA_DIA,Table_Stats_Dia,Relation_Stats_Dia
- */
- public function __construct($db)
- {
- parent::__construct($db, new PMA_DIA());
-
- $this->setShowColor(isset($_REQUEST['dia_show_color']));
- $this->setShowKeys(isset($_REQUEST['dia_show_keys']));
- $this->setOrientation($_REQUEST['dia_orientation']);
- $this->setPaper($_REQUEST['dia_paper']);
-
- $this->diagram->startDiaDoc(
- $this->paper, $this->_topMargin, $this->_bottomMargin,
- $this->_leftMargin, $this->_rightMargin, $this->orientation
- );
-
- $alltables = $this->getTablesFromRequest();
-
- foreach ($alltables as $table) {
- if (! isset($this->tables[$table])) {
- $this->_tables[$table] = new Table_Stats_Dia(
- $this->diagram, $this->db, $table, $this->pageNumber,
- $this->showKeys, $this->offline
- );
- }
- }
-
- $seen_a_relation = false;
- foreach ($alltables as $one_table) {
- $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
- if (!$exist_rel) {
- continue;
- }
-
- $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)
- */
- if ($master_field != 'foreign_keys_data') {
- if (in_array($rel['foreign_table'], $alltables)) {
- $this->_addRelation(
- $one_table, $master_field, $rel['foreign_table'],
- $rel['foreign_field'], $this->showKeys
- );
- }
- continue;
- }
-
- foreach ($rel as $one_key) {
- if (!in_array($one_key['ref_table_name'], $alltables)) {
- continue;
- }
-
- foreach ($one_key['index_list'] as $index => $one_field) {
- $this->_addRelation(
- $one_table, $one_field, $one_key['ref_table_name'],
- $one_key['ref_index_list'][$index], $this->showKeys
- );
- }
- }
- }
- }
- $this->_drawTables();
-
- if ($seen_a_relation) {
- $this->_drawRelations();
- }
- $this->diagram->endDiaDoc();
- }
-
- /**
- * Output Dia Document for download
- *
- * @return void
- * @access public
- */
- public function showOutput()
- {
- $this->diagram->showOutput($this->getFileName('.dia'));
- }
-
- /**
- * 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 bool $showKeys Whether to display ONLY keys or not
- *
- * @return void
- *
- * @access private
- * @see Table_Stats_Dia::__construct(),Relation_Stats_Dia::__construct()
- */
- private function _addRelation($masterTable, $masterField, $foreignTable,
- $foreignField, $showKeys
- ) {
- if (! isset($this->_tables[$masterTable])) {
- $this->_tables[$masterTable] = new Table_Stats_Dia(
- $this->diagram, $this->db, $masterTable, $this->pageNumber, $showKeys
- );
- }
- if (! isset($this->_tables[$foreignTable])) {
- $this->_tables[$foreignTable] = new Table_Stats_Dia(
- $this->diagram, $this->db, $foreignTable, $this->pageNumber, $showKeys
- );
- }
- $this->_relations[] = new Relation_Stats_Dia(
- $this->diagram,
- $this->_tables[$masterTable],
- $masterField,
- $this->_tables[$foreignTable],
- $foreignField
- );
- }
-
- /**
- * Draws relation references
- *
- * connects master table's master field to
- * foreign table's foreign field using Dia object
- * type Database - Reference
- *
- * @return void
- *
- * @access private
- * @see Relation_Stats_Dia::relationDraw()
- */
- private function _drawRelations()
- {
- foreach ($this->_relations as $relation) {
- $relation->relationDraw($this->showColor);
- }
- }
-
- /**
- * Draws tables
- *
- * Tables are generated using Dia object type Database - Table
- * primary fields are underlined and bold in tables
- *
- * @return void
- *
- * @access private
- * @see Table_Stats_Dia::tableDraw()
- */
- private function _drawTables()
- {
- foreach ($this->_tables as $table) {
- $table->tableDraw($this->showColor);
- }
- }
-}
diff --git a/libraries/plugins/schema/dia/RelationStatsDia.class.php b/libraries/plugins/schema/dia/RelationStatsDia.php
similarity index 90%
rename from libraries/plugins/schema/dia/RelationStatsDia.class.php
rename to libraries/plugins/schema/dia/RelationStatsDia.php
index 6cd6365831..28b219acdb 100644
--- a/libraries/plugins/schema/dia/RelationStatsDia.class.php
+++ b/libraries/plugins/schema/dia/RelationStatsDia.php
@@ -1,11 +1,13 @@
referenceColor = '#' . $listOfColors[0] . '';
+ $this->referenceColor = '#' . $listOfColors[0] . '';
} else {
$this->referenceColor = '#000000';
}
$this->diagram->writeRaw(
'
+ . DiaRelationSchema::$objectId . '">
diff --git a/libraries/plugins/schema/dia/TableStatsDia.class.php b/libraries/plugins/schema/dia/TableStatsDia.php
similarity index 87%
rename from libraries/plugins/schema/dia/TableStatsDia.class.php
rename to libraries/plugins/schema/dia/TableStatsDia.php
index c3bb97d4b9..5f197cc6ee 100644
--- a/libraries/plugins/schema/dia/TableStatsDia.class.php
+++ b/libraries/plugins/schema/dia/TableStatsDia.php
@@ -1,16 +1,19 @@
tableId = PMA_Dia_Relation_Schema::$objectId;
+ */
+ DiaRelationSchema::$objectId += 1;
+ $this->tableId = DiaRelationSchema::$objectId;
}
/**
@@ -59,7 +73,7 @@ class Table_Stats_Dia extends TableStats
*/
protected function showMissingTableError()
{
- PMA_Export_Relation_Schema::dieSchema(
+ ExportRelationSchema::dieSchema(
$this->pageNumber,
"DIA",
sprintf(__('The %s table doesn\'t exist!'), $this->tableName)
@@ -76,13 +90,14 @@ class Table_Stats_Dia extends TableStats
* of displaying Database - Table on Dia Document.
*
* @param boolean $showColor Whether to show color for tables text or not
- * if showColor 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
+ * if showColor 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
*
* @access public
- * @see PMA_DIA
+ * @see Dia
*/
public function tableDraw($showColor)
{
diff --git a/libraries/plugins/schema/eps/Eps.php b/libraries/plugins/schema/eps/Eps.php
new file mode 100644
index 0000000000..622b837a67
--- /dev/null
+++ b/libraries/plugins/schema/eps/Eps.php
@@ -0,0 +1,278 @@
+stringCommands = "";
+ $this->stringCommands .= "%!PS-Adobe-3.0 EPSF-3.0 \n";
+ }
+
+ /**
+ * Set document title
+ *
+ * @param string $value sets the title text
+ *
+ * @return void
+ */
+ public function setTitle($value)
+ {
+ $this->stringCommands .= '%%Title: ' . $value . "\n";
+ }
+
+ /**
+ * Set document author
+ *
+ * @param string $value sets the author
+ *
+ * @return void
+ */
+ public function setAuthor($value)
+ {
+ $this->stringCommands .= '%%Creator: ' . $value . "\n";
+ }
+
+ /**
+ * Set document creation date
+ *
+ * @param string $value sets the date
+ *
+ * @return void
+ */
+ public function setDate($value)
+ {
+ $this->stringCommands .= '%%CreationDate: ' . $value . "\n";
+ }
+
+ /**
+ * Set document orientation
+ *
+ * @param string $orientation sets the orientation
+ *
+ * @return void
+ */
+ public function setOrientation($orientation)
+ {
+ $this->stringCommands .= "%%PageOrder: Ascend \n";
+ if ($orientation == "L") {
+ $orientation = "Landscape";
+ $this->stringCommands .= '%%Orientation: ' . $orientation . "\n";
+ } else {
+ $orientation = "Portrait";
+ $this->stringCommands .= '%%Orientation: ' . $orientation . "\n";
+ }
+ $this->stringCommands .= "%%EndComments \n";
+ $this->stringCommands .= "%%Pages 1 \n";
+ $this->stringCommands .= "%%BoundingBox: 72 150 144 170 \n";
+ }
+
+ /**
+ * Set the font and size
+ *
+ * font can be set whenever needed in EPS
+ *
+ * @param string $value sets the font name e.g Arial
+ * @param integer $size sets the size of the font e.g 10
+ *
+ * @return void
+ */
+ 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
+ .= "setfont % Make it the current font\n";
+ }
+
+ /**
+ * Get the font
+ *
+ * @return string return the font name e.g Arial
+ */
+ public function getFont()
+ {
+ return $this->font;
+ }
+
+ /**
+ * Get the font Size
+ *
+ * @return string return the size of the font e.g 10
+ */
+ public function getFontSize()
+ {
+ return $this->fontSize;
+ }
+
+ /**
+ * Draw the line
+ *
+ * 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
+ *
+ * @return void
+ */
+ public 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";
+ $this->stringCommands .= $x_to . ' ' . $y_to . " lineto \n";
+ $this->stringCommands .= "stroke \n";
+ }
+
+ /**
+ * Draw the rectangle
+ *
+ * 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
+ *
+ * @return void
+ */
+ 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";
+ }
+
+ /**
+ * Set the current point
+ *
+ * The moveto operator takes two numbers off the stack and treats
+ * 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
+ *
+ * @return void
+ */
+ public function moveTo($x, $y)
+ {
+ $this->stringCommands .= $x . ' ' . $y . " moveto \n";
+ }
+
+ /**
+ * Output/Display the text
+ *
+ * @param string $text The string to be displayed
+ *
+ * @return void
+ */
+ public function show($text)
+ {
+ $this->stringCommands .= '(' . $text . ") show \n";
+ }
+
+ /**
+ * Output the text at specified co-ordinates
+ *
+ * @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
+ */
+ public function showXY($text, $x, $y)
+ {
+ $this->moveTo($x, $y);
+ $this->show($text);
+ }
+
+ /**
+ * Ends EPS Document
+ *
+ * @return void
+ */
+ public function endEpsDoc()
+ {
+ $this->stringCommands .= "showpage \n";
+ }
+
+ /**
+ * Output EPS Document for download
+ *
+ * @param string $fileName name of the eps document
+ *
+ * @return void
+ */
+ public function showOutput($fileName)
+ {
+ // if(ob_get_clean()){
+ //ob_end_clean();
+ //}
+ $output = $this->stringCommands;
+ Response::getInstance()
+ ->disable();
+ PMA_downloadHeader(
+ $fileName,
+ 'image/x-eps',
+ /*overload*/
+ mb_strlen($output)
+ );
+ print $output;
+ }
+}
\ No newline at end of file
diff --git a/libraries/plugins/schema/eps/EpsRelationSchema.php b/libraries/plugins/schema/eps/EpsRelationSchema.php
new file mode 100644
index 0000000000..45699e4124
--- /dev/null
+++ b/libraries/plugins/schema/eps/EpsRelationSchema.php
@@ -0,0 +1,225 @@
+setShowColor(isset($_REQUEST['eps_show_color']));
+ $this->setShowKeys(isset($_REQUEST['eps_show_keys']));
+ $this->setTableDimension(isset($_REQUEST['eps_show_table_dimension']));
+ $this->setAllTablesSameWidth(isset($_REQUEST['eps_all_tables_same_width']));
+ $this->setOrientation($_REQUEST['eps_orientation']);
+
+ $this->diagram->setTitle(
+ sprintf(
+ __('Schema of the %s database - Page %s'),
+ $this->db,
+ $this->pageNumber
+ )
+ );
+ $this->diagram->setAuthor('phpMyAdmin ' . PMA_VERSION);
+ $this->diagram->setDate(date("j F Y, g:i a"));
+ $this->diagram->setOrientation($this->orientation);
+ $this->diagram->setFont('Verdana', '10');
+
+ $alltables = $this->getTablesFromRequest();
+
+ foreach ($alltables as $table) {
+ if (! isset($this->_tables[$table])) {
+ $this->_tables[$table] = new TableStatsEps(
+ $this->diagram, $this->db,
+ $table, $this->diagram->getFont(),
+ $this->diagram->getFontSize(), $this->pageNumber,
+ $this->_tablewidth, $this->showKeys,
+ $this->tableDimension, $this->offline
+ );
+ }
+
+ if ($this->sameWide) {
+ $this->_tables[$table]->width = $this->_tablewidth;
+ }
+ }
+
+ $seen_a_relation = false;
+ foreach ($alltables as $one_table) {
+ $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
+ if (!$exist_rel) {
+ continue;
+ }
+
+ $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)
+ */
+ if ($master_field != 'foreign_keys_data') {
+ if (in_array($rel['foreign_table'], $alltables)) {
+ $this->_addRelation(
+ $one_table, $this->diagram->getFont(), $this->diagram->getFontSize(),
+ $master_field, $rel['foreign_table'],
+ $rel['foreign_field'], $this->tableDimension
+ );
+ }
+ continue;
+ }
+
+ foreach ($rel as $one_key) {
+ if (!in_array($one_key['ref_table_name'], $alltables)) {
+ continue;
+ }
+
+ foreach ($one_key['index_list']
+ as $index => $one_field
+ ) {
+ $this->_addRelation(
+ $one_table, $this->diagram->getFont(),
+ $this->diagram->getFontSize(),
+ $one_field, $one_key['ref_table_name'],
+ $one_key['ref_index_list'][$index],
+ $this->tableDimension
+ );
+ }
+ }
+ }
+ }
+ if ($seen_a_relation) {
+ $this->_drawRelations();
+ }
+
+ $this->_drawTables();
+ $this->diagram->endEpsDoc();
+ }
+
+ /**
+ * Output Eps Document for download
+ *
+ * @return void
+ */
+ public function showOutput()
+ {
+ $this->diagram->showOutput($this->getFileName('.eps'));
+ }
+
+ /**
+ * Defines relation objects
+ *
+ * @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 $tableDimension Whether to display table position or not
+ *
+ * @return void
+ *
+ * @see _setMinMax,Table_Stats_Eps::__construct(),
+ * PMA\libraries\plugins\schema\eps\RelationStatsEps::__construct()
+ */
+ private function _addRelation(
+ $masterTable, $font, $fontSize, $masterField,
+ $foreignTable, $foreignField, $tableDimension
+ ) {
+ if (! isset($this->_tables[$masterTable])) {
+ $this->_tables[$masterTable] = new TableStatsEps(
+ $this->diagram, $this->db, $masterTable, $font, $fontSize,
+ $this->pageNumber, $this->_tablewidth, false, $tableDimension
+ );
+ }
+ if (! isset($this->_tables[$foreignTable])) {
+ $this->_tables[$foreignTable] = new TableStatsEps(
+ $this->diagram, $this->db, $foreignTable, $font, $fontSize,
+ $this->pageNumber, $this->_tablewidth, false, $tableDimension
+ );
+ }
+ $this->_relations[] = new RelationStatsEps(
+ $this->diagram,
+ $this->_tables[$masterTable],
+ $masterField,
+ $this->_tables[$foreignTable],
+ $foreignField
+ );
+ }
+
+ /**
+ * Draws relation arrows and lines connects master table's master field to
+ * foreign table's foreign field
+ *
+ * @return void
+ *
+ * @see Relation_Stats_Eps::relationDraw()
+ */
+ private function _drawRelations()
+ {
+ foreach ($this->_relations as $relation) {
+ $relation->relationDraw($this->showColor);
+ }
+ }
+
+ /**
+ * Draws tables
+ *
+ * @return void
+ *
+ * @see Table_Stats_Eps::Table_Stats_tableDraw()
+ */
+ private function _drawTables()
+ {
+ foreach ($this->_tables as $table) {
+ $table->tableDraw($this->showColor);
+ }
+ }
+}
diff --git a/libraries/plugins/schema/eps/Eps_Relation_Schema.class.php b/libraries/plugins/schema/eps/Eps_Relation_Schema.class.php
deleted file mode 100644
index d40a5772d5..0000000000
--- a/libraries/plugins/schema/eps/Eps_Relation_Schema.class.php
+++ /dev/null
@@ -1,486 +0,0 @@
-stringCommands = "";
- $this->stringCommands .= "%!PS-Adobe-3.0 EPSF-3.0 \n";
- }
-
- /**
- * Set document title
- *
- * @param string $value sets the title text
- *
- * @return void
- */
- public function setTitle($value)
- {
- $this->stringCommands .= '%%Title: ' . $value . "\n";
- }
-
- /**
- * Set document author
- *
- * @param string $value sets the author
- *
- * @return void
- */
- public function setAuthor($value)
- {
- $this->stringCommands .= '%%Creator: ' . $value . "\n";
- }
-
- /**
- * Set document creation date
- *
- * @param string $value sets the date
- *
- * @return void
- */
- public function setDate($value)
- {
- $this->stringCommands .= '%%CreationDate: ' . $value . "\n";
- }
-
- /**
- * Set document orientation
- *
- * @param string $orientation sets the orientation
- *
- * @return void
- */
- public function setOrientation($orientation)
- {
- $this->stringCommands .= "%%PageOrder: Ascend \n";
- if ($orientation == "L") {
- $orientation = "Landscape";
- $this->stringCommands .= '%%Orientation: ' . $orientation . "\n";
- } else {
- $orientation = "Portrait";
- $this->stringCommands .= '%%Orientation: ' . $orientation . "\n";
- }
- $this->stringCommands .= "%%EndComments \n";
- $this->stringCommands .= "%%Pages 1 \n";
- $this->stringCommands .= "%%BoundingBox: 72 150 144 170 \n";
- }
-
- /**
- * Set the font and size
- *
- * font can be set whenever needed in EPS
- *
- * @param string $value sets the font name e.g Arial
- * @param integer $size sets the size of the font e.g 10
- *
- * @return void
- */
- 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
- .= "setfont % Make it the current font\n";
- }
-
- /**
- * Get the font
- *
- * @return string return the font name e.g Arial
- */
- public function getFont()
- {
- return $this->font;
- }
-
- /**
- * Get the font Size
- *
- * @return string return the size of the font e.g 10
- */
- public function getFontSize()
- {
- return $this->fontSize;
- }
-
- /**
- * Draw the line
- *
- * 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
- *
- * @return void
- */
- public 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";
- $this->stringCommands .= $x_to . ' ' . $y_to . " lineto \n";
- $this->stringCommands .= "stroke \n";
- }
-
- /**
- * Draw the rectangle
- *
- * 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
- *
- * @return void
- */
- 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";
- }
-
- /**
- * Set the current point
- *
- * The moveto operator takes two numbers off the stack and treats
- * 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
- *
- * @return void
- */
- public function moveTo($x, $y)
- {
- $this->stringCommands .= $x . ' ' . $y . " moveto \n";
- }
-
- /**
- * Output/Display the text
- *
- * @param string $text The string to be displayed
- *
- * @return void
- */
- public function show($text)
- {
- $this->stringCommands .= '(' . $text . ") show \n";
- }
-
- /**
- * Output the text at specified co-ordinates
- *
- * @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
- */
- public function showXY($text, $x, $y)
- {
- $this->moveTo($x, $y);
- $this->show($text);
- }
-
- /**
- * Ends EPS Document
- *
- * @return void
- */
- public function endEpsDoc()
- {
- $this->stringCommands .= "showpage \n";
- }
-
- /**
- * Output EPS Document for download
- *
- * @param string $fileName name of the eps document
- *
- * @return void
- */
- public function showOutput($fileName)
- {
- // if(ob_get_clean()){
- //ob_end_clean();
- //}
- $output = $this->stringCommands;
- PMA\libraries\Response::getInstance()->disable();
- PMA_downloadHeader(
- $fileName,
- 'image/x-eps',
- /*overload*/mb_strlen($output)
- );
- print $output;
- }
-}
-
-/**
- * EPS Relation Schema Class
- *
- * Purpose of this class is to generate the EPS Document
- * which is used for representing the database diagrams.
- * This class uses post script commands and with
- * the combination of these commands actually helps in preparing EPS Document.
- *
- * This class inherits Export_Relation_Schema class has common functionality added
- * to this class
- *
- * @package PhpMyAdmin
- * @name Eps_Relation_Schema
- */
-class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
-{
- /**
- * @var Table_Stats_Dia[]|Table_Stats_Eps[]|Table_Stats_Pdf[]|Table_Stats_Svg[]
- */
- private $_tables = array();
-
- /** @var Relation_Stats_Dia[] Relations */
- private $_relations = array();
-
- /**
- * The "PMA_EPS_Relation_Schema" constructor
- *
- * Upon instantiation This starts writing the EPS document
- * user will be prompted for download as .eps extension
- *
- * @param string $db database name
- *
- * @see PMA_EPS
- */
- public function __construct($db)
- {
- parent::__construct($db, new PMA_EPS());
-
- $this->setShowColor(isset($_REQUEST['eps_show_color']));
- $this->setShowKeys(isset($_REQUEST['eps_show_keys']));
- $this->setTableDimension(isset($_REQUEST['eps_show_table_dimension']));
- $this->setAllTablesSameWidth(isset($_REQUEST['eps_all_tables_same_width']));
- $this->setOrientation($_REQUEST['eps_orientation']);
-
- $this->diagram->setTitle(
- sprintf(
- __('Schema of the %s database - Page %s'),
- $this->db,
- $this->pageNumber
- )
- );
- $this->diagram->setAuthor('phpMyAdmin ' . PMA_VERSION);
- $this->diagram->setDate(date("j F Y, g:i a"));
- $this->diagram->setOrientation($this->orientation);
- $this->diagram->setFont('Verdana', '10');
-
- $alltables = $this->getTablesFromRequest();
-
- foreach ($alltables as $table) {
- if (! isset($this->_tables[$table])) {
- $this->_tables[$table] = new Table_Stats_Eps(
- $this->diagram, $this->db,
- $table, $this->diagram->getFont(),
- $this->diagram->getFontSize(), $this->pageNumber,
- $this->_tablewidth, $this->showKeys,
- $this->tableDimension, $this->offline
- );
- }
-
- if ($this->sameWide) {
- $this->_tables[$table]->width = $this->_tablewidth;
- }
- }
-
- $seen_a_relation = false;
- foreach ($alltables as $one_table) {
- $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
- if (!$exist_rel) {
- continue;
- }
-
- $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)
- */
- if ($master_field != 'foreign_keys_data') {
- if (in_array($rel['foreign_table'], $alltables)) {
- $this->_addRelation(
- $one_table, $this->diagram->getFont(), $this->diagram->getFontSize(),
- $master_field, $rel['foreign_table'],
- $rel['foreign_field'], $this->tableDimension
- );
- }
- continue;
- }
-
- foreach ($rel as $one_key) {
- if (!in_array($one_key['ref_table_name'], $alltables)) {
- continue;
- }
-
- foreach ($one_key['index_list']
- as $index => $one_field
- ) {
- $this->_addRelation(
- $one_table, $this->diagram->getFont(),
- $this->diagram->getFontSize(),
- $one_field, $one_key['ref_table_name'],
- $one_key['ref_index_list'][$index],
- $this->tableDimension
- );
- }
- }
- }
- }
- if ($seen_a_relation) {
- $this->_drawRelations();
- }
-
- $this->_drawTables();
- $this->diagram->endEpsDoc();
- }
-
- /**
- * Output Eps Document for download
- *
- * @return void
- */
- public function showOutput()
- {
- $this->diagram->showOutput($this->getFileName('.eps'));
- }
-
- /**
- * Defines relation objects
- *
- * @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 $tableDimension Whether to display table position or not
- *
- * @return void
- *
- * @see _setMinMax,Table_Stats_Eps::__construct(),
- * Relation_Stats_Eps::__construct()
- */
- private function _addRelation(
- $masterTable, $font, $fontSize, $masterField,
- $foreignTable, $foreignField, $tableDimension
- ) {
- if (! isset($this->_tables[$masterTable])) {
- $this->_tables[$masterTable] = new Table_Stats_Eps(
- $this->diagram, $this->db, $masterTable, $font, $fontSize,
- $this->pageNumber, $this->_tablewidth, false, $tableDimension
- );
- }
- if (! isset($this->_tables[$foreignTable])) {
- $this->_tables[$foreignTable] = new Table_Stats_Eps(
- $this->diagram, $this->db, $foreignTable, $font, $fontSize,
- $this->pageNumber, $this->_tablewidth, false, $tableDimension
- );
- }
- $this->_relations[] = new Relation_Stats_Eps(
- $this->diagram,
- $this->_tables[$masterTable],
- $masterField,
- $this->_tables[$foreignTable],
- $foreignField
- );
- }
-
- /**
- * Draws relation arrows and lines connects master table's master field to
- * foreign table's foreign field
- *
- * @return void
- *
- * @see Relation_Stats_Eps::relationDraw()
- */
- private function _drawRelations()
- {
- foreach ($this->_relations as $relation) {
- $relation->relationDraw($this->showColor);
- }
- }
-
- /**
- * Draws tables
- *
- * @return void
- *
- * @see Table_Stats_Eps::Table_Stats_tableDraw()
- */
- private function _drawTables()
- {
- foreach ($this->_tables as $table) {
- $table->tableDraw($this->showColor);
- }
- }
-}
diff --git a/libraries/plugins/schema/eps/RelationStatsEps.class.php b/libraries/plugins/schema/eps/RelationStatsEps.php
similarity index 92%
rename from libraries/plugins/schema/eps/RelationStatsEps.class.php
rename to libraries/plugins/schema/eps/RelationStatsEps.php
index 44106faaec..bbc33c9e41 100644
--- a/libraries/plugins/schema/eps/RelationStatsEps.class.php
+++ b/libraries/plugins/schema/eps/RelationStatsEps.php
@@ -1,16 +1,18 @@
pageNumber,
"EPS",
sprintf(__('The %s table doesn\'t exist!'), $this->tableName)
@@ -90,7 +107,7 @@ class Table_Stats_Eps extends TableStats
*
* @see PMA_EPS
*/
- private function _setWidthTable($font,$fontSize)
+ private function _setWidthTable($font, $fontSize)
{
foreach ($this->fields as $field) {
$this->width = max(
@@ -98,13 +115,21 @@ class Table_Stats_Eps extends TableStats
PMA\libraries\Font::getStringWidth($field, $font, $fontSize)
);
}
- $this->width += PMA\libraries\Font::getStringWidth(' ', $font, $fontSize);
+ $this->width += PMA\libraries\Font::getStringWidth(
+ ' ',
+ $font,
+ $fontSize
+ );
/*
* it is unknown what value must be added, because
* table title is affected by the table width value
*/
while ($this->width
- < PMA\libraries\Font::getStringWidth($this->getTitle(), $font, $fontSize)) {
+ < PMA\libraries\Font::getStringWidth(
+ $this->getTitle(),
+ $font,
+ $fontSize
+ )) {
$this->width += 7;
}
}
@@ -134,15 +159,28 @@ class Table_Stats_Eps extends TableStats
public function tableDraw($showColor)
{
//echo $this->tableName.'
';
- $this->diagram->rect($this->x, $this->y + 12, $this->width, $this->heightCell, 1);
+ $this->diagram->rect(
+ $this->x,
+ $this->y + 12,
+ $this->width,
+ $this->heightCell,
+ 1
+ );
$this->diagram->showXY($this->getTitle(), $this->x + 5, $this->y + 14);
foreach ($this->fields as $field) {
$this->currentCell += $this->heightCell;
$this->diagram->rect(
- $this->x, $this->y + 12 + $this->currentCell,
- $this->width, $this->heightCell, 1
+ $this->x,
+ $this->y + 12 + $this->currentCell,
+ $this->width,
+ $this->heightCell,
+ 1
+ );
+ $this->diagram->showXY(
+ $field,
+ $this->x + 5,
+ $this->y + 14 + $this->currentCell
);
- $this->diagram->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
}
}
}
diff --git a/libraries/plugins/schema/pdf/Pdf.php b/libraries/plugins/schema/pdf/Pdf.php
new file mode 100644
index 0000000000..9e0858427e
--- /dev/null
+++ b/libraries/plugins/schema/pdf/Pdf.php
@@ -0,0 +1,400 @@
+_pageNumber = $pageNumber;
+ $this->_withDoc = $withDoc;
+ $this->_db = $db;
+ }
+
+ /**
+ * Sets the value for margins
+ *
+ * @param float $c_margin margin
+ *
+ * @return void
+ */
+ public function setCMargin($c_margin)
+ {
+ $this->cMargin = $c_margin;
+ }
+
+ /**
+ * Sets the scaling factor, defines minimum coordinates and margins
+ *
+ * @param float|int $scale The scaling factor
+ * @param float|int $xMin The minimum X coordinate
+ * @param float|int $yMin The minimum Y coordinate
+ * @param float|int $leftMargin The left margin
+ * @param float|int $topMargin The top margin
+ *
+ * @return void
+ */
+ public function setScale($scale = 1, $xMin = 0, $yMin = 0,
+ $leftMargin = -1, $topMargin = -1
+ ) {
+ $this->scale = $scale;
+ $this->_xMin = $xMin;
+ $this->_yMin = $yMin;
+ if ($this->leftMargin != -1) {
+ $this->leftMargin = $leftMargin;
+ }
+ if ($this->topMargin != -1) {
+ $this->topMargin = $topMargin;
+ }
+ }
+
+ /**
+ * Outputs a scaled cell
+ *
+ * @param float|int $w The cell width
+ * @param float|int $h The cell height
+ * @param string $txt The text to output
+ * @param mixed $border Whether to add borders or not
+ * @param integer $ln Where to put the cursor once the output is done
+ * @param string $align Align mode
+ * @param integer $fill Whether to fill the cell with a color or not
+ * @param string $link Link
+ *
+ * @return void
+ *
+ * @see TCPDF::Cell()
+ */
+ public function cellScale($w, $h = 0, $txt = '', $border = 0, $ln = 0,
+ $align = '', $fill = 0, $link = ''
+ ) {
+ $h = $h / $this->scale;
+ $w = $w / $this->scale;
+ $this->Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
+ }
+
+ /**
+ * Draws a scaled line
+ *
+ * @param float $x1 The horizontal position of the starting point
+ * @param float $y1 The vertical position of the starting point
+ * @param float $x2 The horizontal position of the ending point
+ * @param float $y2 The vertical position of the ending point
+ *
+ * @return void
+ *
+ * @see TCPDF::Line()
+ */
+ public function lineScale($x1, $y1, $x2, $y2)
+ {
+ $x1 = ($x1 - $this->_xMin) / $this->scale + $this->leftMargin;
+ $y1 = ($y1 - $this->_yMin) / $this->scale + $this->topMargin;
+ $x2 = ($x2 - $this->_xMin) / $this->scale + $this->leftMargin;
+ $y2 = ($y2 - $this->_yMin) / $this->scale + $this->topMargin;
+ $this->Line($x1, $y1, $x2, $y2);
+ }
+
+ /**
+ * Sets x and y scaled positions
+ *
+ * @param float $x The x position
+ * @param float $y The y position
+ *
+ * @return void
+ *
+ * @see TCPDF::SetXY()
+ */
+ public function setXyScale($x, $y)
+ {
+ $x = ($x - $this->_xMin) / $this->scale + $this->leftMargin;
+ $y = ($y - $this->_yMin) / $this->scale + $this->topMargin;
+ $this->SetXY($x, $y);
+ }
+
+ /**
+ * Sets the X scaled positions
+ *
+ * @param float $x The x position
+ *
+ * @return void
+ *
+ * @see TCPDF::SetX()
+ */
+ public function setXScale($x)
+ {
+ $x = ($x - $this->_xMin) / $this->scale + $this->leftMargin;
+ $this->SetX($x);
+ }
+
+ /**
+ * Sets the scaled font size
+ *
+ * @param float $size The font size (in points)
+ *
+ * @return void
+ *
+ * @see TCPDF::SetFontSize()
+ */
+ public function setFontSizeScale($size)
+ {
+ // Set font size in points
+ $size = $size / $this->scale;
+ $this->SetFontSize($size);
+ }
+
+ /**
+ * Sets the scaled line width
+ *
+ * @param float $width The line width
+ *
+ * @return void
+ *
+ * @see TCPDF::SetLineWidth()
+ */
+ public function setLineWidthScale($width)
+ {
+ $width = $width / $this->scale;
+ $this->SetLineWidth($width);
+ }
+
+ /**
+ * This method is used to render the page header.
+ *
+ * @return void
+ *
+ * @see TCPDF::Header()
+ */
+ public function Header()
+ {
+ // We only show this if we find something in the new pdf_pages table
+
+ // This function must be named "Header" to work with the TCPDF library
+ if ($this->_withDoc) {
+ if ($this->_offline || $this->_pageNumber == -1) {
+ $pg_name = __("PDF export page");
+ } else {
+ $test_query = 'SELECT * FROM '
+ . Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . Util::backquote($GLOBALS['cfgRelation']['pdf_pages'])
+ . ' WHERE db_name = \'' . Util::sqlAddSlashes($this->_db)
+ . '\' AND page_nr = \'' . $this->_pageNumber . '\'';
+ $test_rs = PMA_queryAsControlUser($test_query);
+ $pages = @$GLOBALS['dbi']->fetchAssoc($test_rs);
+ $pg_name = ucfirst($pages['page_descr']);
+ }
+
+ $this->SetFont($this->_ff, 'B', 14);
+ $this->Cell(0, 6, $pg_name, 'B', 1, 'C');
+ $this->SetFont($this->_ff, '');
+ $this->Ln();
+ }
+ }
+
+ /**
+ * This function must be named "Footer" to work with the TCPDF library
+ *
+ * @return void
+ *
+ * @see PDF::Footer()
+ */
+ public function Footer()
+ {
+ if ($this->_withDoc) {
+ parent::Footer();
+ }
+ }
+
+ /**
+ * Sets widths
+ *
+ * @param array $w array of widths
+ *
+ * @return void
+ */
+ public function SetWidths($w)
+ {
+ // column widths
+ $this->widths = $w;
+ }
+
+ /**
+ * Generates table row.
+ *
+ * @param array $data Data for table
+ * @param array $links Links for table cells
+ *
+ * @return void
+ */
+ public function Row($data, $links)
+ {
+ // line height
+ $nb = 0;
+ $data_cnt = count($data);
+ for ($i = 0;$i < $data_cnt;$i++) {
+ $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
+ }
+ $il = $this->FontSize;
+ $h = ($il + 1) * $nb;
+ // page break if necessary
+ $this->CheckPageBreak($h);
+ // draw the cells
+ $data_cnt = count($data);
+ for ($i = 0;$i < $data_cnt;$i++) {
+ $w = $this->widths[$i];
+ // save current position
+ $x = $this->GetX();
+ $y = $this->GetY();
+ // draw the border
+ $this->Rect($x, $y, $w, $h);
+ if (isset($links[$i])) {
+ $this->Link($x, $y, $w, $h, $links[$i]);
+ }
+ // print text
+ $this->MultiCell($w, $il + 1, $data[$i], 0, 'L');
+ // go to right side
+ $this->SetXY($x + $w, $y);
+ }
+ // go to line
+ $this->Ln($h);
+ }
+
+ /**
+ * Compute number of lines used by a multicell of width w
+ *
+ * @param int $w width
+ * @param string $txt text
+ *
+ * @return int
+ */
+ public function NbLines($w, $txt)
+ {
+ $cw = &$this->CurrentFont['cw'];
+ if ($w == 0) {
+ $w = $this->w - $this->rMargin - $this->x;
+ }
+ $wmax = ($w-2 * $this->cMargin) * 1000 / $this->FontSize;
+ $s = str_replace("\r", '', $txt);
+ $nb = /*overload*/mb_strlen($s);
+ if ($nb > 0 and $s[$nb-1] == "\n") {
+ $nb--;
+ }
+ $sep = -1;
+ $i = 0;
+ $j = 0;
+ $l = 0;
+ $nl = 1;
+ while ($i < $nb) {
+ $c = $s[$i];
+ if ($c == "\n") {
+ $i++;
+ $sep = -1;
+ $j = $i;
+ $l = 0;
+ $nl++;
+ continue;
+ }
+ if ($c == ' ') {
+ $sep = $i;
+ }
+ $l += isset($cw[/*overload*/mb_ord($c)])?$cw[/*overload*/mb_ord($c)]:0 ;
+ if ($l > $wmax) {
+ if ($sep == -1) {
+ if ($i == $j) {
+ $i++;
+ }
+ } else {
+ $i = $sep + 1;
+ }
+ $sep = -1;
+ $j = $i;
+ $l = 0;
+ $nl++;
+ } else {
+ $i++;
+ }
+ }
+ return $nl;
+ }
+
+ /**
+ * Set whether the document is generated from client side DB
+ *
+ * @param string $value whether offline
+ *
+ * @return void
+ *
+ * @access private
+ */
+ public function setOffline($value)
+ {
+ $this->_offline = $value;
+ }
+}
\ No newline at end of file
diff --git a/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php b/libraries/plugins/schema/pdf/PdfRelationSchema.php
similarity index 68%
rename from libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php
rename to libraries/plugins/schema/pdf/PdfRelationSchema.php
index 9b3403c5f1..99fe9c15a0 100644
--- a/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php
+++ b/libraries/plugins/schema/pdf/PdfRelationSchema.php
@@ -5,7 +5,10 @@
*
* @package PhpMyAdmin
*/
-use PMA\libraries\PDF;
+namespace PMA\libraries\plugins\schema\pdf;
+
+use PMA\libraries\plugins\schema\ExportRelationSchema;
+use PMA\libraries\Util;
if (! defined('PHPMYADMIN')) {
exit;
@@ -26,392 +29,21 @@ if (getcwd() == dirname(__FILE__)) {
die('Attack stopped');
}
-require_once 'libraries/plugins/schema/Export_Relation_Schema.class.php';
-require_once 'libraries/plugins/schema/pdf/RelationStatsPdf.class.php';
-require_once 'libraries/plugins/schema/pdf/TableStatsPdf.class.php';
require_once 'libraries/transformations.lib.php';
-/**
- * Extends the "TCPDF" class and helps
- * in developing the structure of PDF Schema Export
- *
- * @access public
- * @package PhpMyAdmin
- * @see TCPDF
- */
-class PMA_Schema_PDF extends PDF
-{
- /**
- * Defines properties
- */
- var $_xMin;
- var $_yMin;
- var $leftMargin = 10;
- var $topMargin = 10;
- var $scale;
- var $PMA_links;
- var $Outlines = array();
- var $def_outlines;
- var $widths;
- private $_ff = PMA_PDF_FONT;
- private $_offline;
- private $_pageNumber;
- private $_withDoc;
- private $_db;
-
- /**
- * Constructs PDF for schema export.
- *
- * @param string $orientation page orientation
- * @param string $unit unit
- * @param string $paper the format used for pages
- * @param int $pageNumber schema page number that is being exported
- * @param boolean $withDoc with document dictionary
- * @param string $db the database name
- *
- * @access public
- */
- public function __construct(
- $orientation, $unit, $paper, $pageNumber, $withDoc, $db
- ) {
- parent::__construct($orientation, $unit, $paper);
- $this->_pageNumber = $pageNumber;
- $this->_withDoc = $withDoc;
- $this->_db = $db;
- }
-
- /**
- * Sets the value for margins
- *
- * @param float $c_margin margin
- *
- * @return void
- */
- public function setCMargin($c_margin)
- {
- $this->cMargin = $c_margin;
- }
-
- /**
- * Sets the scaling factor, defines minimum coordinates and margins
- *
- * @param float|int $scale The scaling factor
- * @param float|int $xMin The minimum X coordinate
- * @param float|int $yMin The minimum Y coordinate
- * @param float|int $leftMargin The left margin
- * @param float|int $topMargin The top margin
- *
- * @return void
- */
- public function setScale($scale = 1, $xMin = 0, $yMin = 0,
- $leftMargin = -1, $topMargin = -1
- ) {
- $this->scale = $scale;
- $this->_xMin = $xMin;
- $this->_yMin = $yMin;
- if ($this->leftMargin != -1) {
- $this->leftMargin = $leftMargin;
- }
- if ($this->topMargin != -1) {
- $this->topMargin = $topMargin;
- }
- }
-
- /**
- * Outputs a scaled cell
- *
- * @param float|int $w The cell width
- * @param float|int $h The cell height
- * @param string $txt The text to output
- * @param mixed $border Whether to add borders or not
- * @param integer $ln Where to put the cursor once the output is done
- * @param string $align Align mode
- * @param integer $fill Whether to fill the cell with a color or not
- * @param string $link Link
- *
- * @return void
- *
- * @see TCPDF::Cell()
- */
- public function cellScale($w, $h = 0, $txt = '', $border = 0, $ln = 0,
- $align = '', $fill = 0, $link = ''
- ) {
- $h = $h / $this->scale;
- $w = $w / $this->scale;
- $this->Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
- }
-
- /**
- * Draws a scaled line
- *
- * @param float $x1 The horizontal position of the starting point
- * @param float $y1 The vertical position of the starting point
- * @param float $x2 The horizontal position of the ending point
- * @param float $y2 The vertical position of the ending point
- *
- * @return void
- *
- * @see TCPDF::Line()
- */
- public function lineScale($x1, $y1, $x2, $y2)
- {
- $x1 = ($x1 - $this->_xMin) / $this->scale + $this->leftMargin;
- $y1 = ($y1 - $this->_yMin) / $this->scale + $this->topMargin;
- $x2 = ($x2 - $this->_xMin) / $this->scale + $this->leftMargin;
- $y2 = ($y2 - $this->_yMin) / $this->scale + $this->topMargin;
- $this->Line($x1, $y1, $x2, $y2);
- }
-
- /**
- * Sets x and y scaled positions
- *
- * @param float $x The x position
- * @param float $y The y position
- *
- * @return void
- *
- * @see TCPDF::SetXY()
- */
- public function setXyScale($x, $y)
- {
- $x = ($x - $this->_xMin) / $this->scale + $this->leftMargin;
- $y = ($y - $this->_yMin) / $this->scale + $this->topMargin;
- $this->SetXY($x, $y);
- }
-
- /**
- * Sets the X scaled positions
- *
- * @param float $x The x position
- *
- * @return void
- *
- * @see TCPDF::SetX()
- */
- public function setXScale($x)
- {
- $x = ($x - $this->_xMin) / $this->scale + $this->leftMargin;
- $this->SetX($x);
- }
-
- /**
- * Sets the scaled font size
- *
- * @param float $size The font size (in points)
- *
- * @return void
- *
- * @see TCPDF::SetFontSize()
- */
- public function setFontSizeScale($size)
- {
- // Set font size in points
- $size = $size / $this->scale;
- $this->SetFontSize($size);
- }
-
- /**
- * Sets the scaled line width
- *
- * @param float $width The line width
- *
- * @return void
- *
- * @see TCPDF::SetLineWidth()
- */
- public function setLineWidthScale($width)
- {
- $width = $width / $this->scale;
- $this->SetLineWidth($width);
- }
-
- /**
- * This method is used to render the page header.
- *
- * @return void
- *
- * @see TCPDF::Header()
- */
- public function Header()
- {
- // We only show this if we find something in the new pdf_pages table
-
- // This function must be named "Header" to work with the TCPDF library
- if ($this->_withDoc) {
- if ($this->_offline || $this->_pageNumber == -1) {
- $pg_name = __("PDF export page");
- } else {
- $test_query = 'SELECT * FROM '
- . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['pdf_pages'])
- . ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($this->_db)
- . '\' AND page_nr = \'' . $this->_pageNumber . '\'';
- $test_rs = PMA_queryAsControlUser($test_query);
- $pages = @$GLOBALS['dbi']->fetchAssoc($test_rs);
- $pg_name = ucfirst($pages['page_descr']);
- }
-
- $this->SetFont($this->_ff, 'B', 14);
- $this->Cell(0, 6, $pg_name, 'B', 1, 'C');
- $this->SetFont($this->_ff, '');
- $this->Ln();
- }
- }
-
- /**
- * This function must be named "Footer" to work with the TCPDF library
- *
- * @return void
- *
- * @see PDF::Footer()
- */
- public function Footer()
- {
- if ($this->_withDoc) {
- parent::Footer();
- }
- }
-
- /**
- * Sets widths
- *
- * @param array $w array of widths
- *
- * @return void
- */
- public function SetWidths($w)
- {
- // column widths
- $this->widths = $w;
- }
-
- /**
- * Generates table row.
- *
- * @param array $data Data for table
- * @param array $links Links for table cells
- *
- * @return void
- */
- public function Row($data, $links)
- {
- // line height
- $nb = 0;
- $data_cnt = count($data);
- for ($i = 0;$i < $data_cnt;$i++) {
- $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
- }
- $il = $this->FontSize;
- $h = ($il + 1) * $nb;
- // page break if necessary
- $this->CheckPageBreak($h);
- // draw the cells
- $data_cnt = count($data);
- for ($i = 0;$i < $data_cnt;$i++) {
- $w = $this->widths[$i];
- // save current position
- $x = $this->GetX();
- $y = $this->GetY();
- // draw the border
- $this->Rect($x, $y, $w, $h);
- if (isset($links[$i])) {
- $this->Link($x, $y, $w, $h, $links[$i]);
- }
- // print text
- $this->MultiCell($w, $il + 1, $data[$i], 0, 'L');
- // go to right side
- $this->SetXY($x + $w, $y);
- }
- // go to line
- $this->Ln($h);
- }
-
- /**
- * Compute number of lines used by a multicell of width w
- *
- * @param int $w width
- * @param string $txt text
- *
- * @return int
- */
- public function NbLines($w, $txt)
- {
- $cw = &$this->CurrentFont['cw'];
- if ($w == 0) {
- $w = $this->w - $this->rMargin - $this->x;
- }
- $wmax = ($w-2 * $this->cMargin) * 1000 / $this->FontSize;
- $s = str_replace("\r", '', $txt);
- $nb = /*overload*/mb_strlen($s);
- if ($nb > 0 and $s[$nb-1] == "\n") {
- $nb--;
- }
- $sep = -1;
- $i = 0;
- $j = 0;
- $l = 0;
- $nl = 1;
- while ($i < $nb) {
- $c = $s[$i];
- if ($c == "\n") {
- $i++;
- $sep = -1;
- $j = $i;
- $l = 0;
- $nl++;
- continue;
- }
- if ($c == ' ') {
- $sep = $i;
- }
- $l += isset($cw[/*overload*/mb_ord($c)])?$cw[/*overload*/mb_ord($c)]:0 ;
- if ($l > $wmax) {
- if ($sep == -1) {
- if ($i == $j) {
- $i++;
- }
- } else {
- $i = $sep + 1;
- }
- $sep = -1;
- $j = $i;
- $l = 0;
- $nl++;
- } else {
- $i++;
- }
- }
- return $nl;
- }
-
- /**
- * Set whether the document is generated from client side DB
- *
- * @param string $value whether offline
- *
- * @return void
- *
- * @access private
- */
- public function setOffline($value)
- {
- $this->_offline = $value;
- }
-}
-
/**
* Pdf Relation Schema Class
*
* Purpose of this class is to generate the PDF Document. PDF is widely
* used format for documenting text,fonts,images and 3d vector graphics.
*
- * This class inherits Export_Relation_Schema class has common functionality added
+ * This class inherits ExportRelationSchema class has common functionality added
* to this class
*
* @name Pdf_Relation_Schema
* @package PhpMyAdmin
*/
-class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
+class PdfRelationSchema extends ExportRelationSchema
{
/**
* Defines properties
@@ -421,7 +53,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
private $_tableOrder;
/**
- * @var Table_Stats_Pdf[]
+ * @var TableStatsPdf[]
*/
private $_tables = array();
private $_ff = PMA_PDF_FONT;
@@ -437,12 +69,12 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
private $_tablewidth;
/**
- * @var Relation_Stats_Pdf[]
+ * @var RelationStatsPdf[]
*/
protected $relations = array();
/**
- * The "PMA_Pdf_Relation_Schema" constructor
+ * The "PdfRelationSchema" constructor
*
* @param string $db database name
*
@@ -463,7 +95,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
// Initializes a new document
parent::__construct(
$db,
- new PMA_Schema_PDF(
+ new Pdf(
$this->orientation, 'mm', $this->paper,
$this->pageNumber, $this->_withDoc, $db
)
@@ -507,7 +139,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/* snip */
foreach ($alltables as $table) {
if (! isset($this->_tables[$table])) {
- $this->_tables[$table] = new Table_Stats_Pdf(
+ $this->_tables[$table] = new TableStatsPdf(
$this->diagram,
$this->db,
$table,
@@ -684,7 +316,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Sets X and Y minimum and maximum for a table cell
*
- * @param Table_Stats_Pdf $table The table name of which sets XY co-ordinates
+ * @param TableStatsPdf $table The table name of which sets XY co-ordinates
*
* @return void
*/
@@ -712,7 +344,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$foreignField
) {
if (! isset($this->_tables[$masterTable])) {
- $this->_tables[$masterTable] = new Table_Stats_Pdf(
+ $this->_tables[$masterTable] = new TableStatsPdf(
$this->diagram,
$this->db,
$masterTable,
@@ -725,7 +357,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$this->_setMinMax($this->_tables[$masterTable]);
}
if (! isset($this->_tables[$foreignTable])) {
- $this->_tables[$foreignTable] = new Table_Stats_Pdf(
+ $this->_tables[$foreignTable] = new TableStatsPdf(
$this->diagram,
$this->db,
$foreignTable,
@@ -737,7 +369,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
);
$this->_setMinMax($this->_tables[$foreignTable]);
}
- $this->relations[] = new Relation_Stats_Pdf(
+ $this->relations[] = new RelationStatsPdf(
$this->diagram,
$this->_tables[$masterTable],
$masterField,
@@ -933,17 +565,17 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
? $showtable['Comment']
: '';
$create_time = isset($showtable['Create_time'])
- ? PMA\libraries\Util::localisedDate(
+ ? Util::localisedDate(
strtotime($showtable['Create_time'])
)
: '';
$update_time = isset($showtable['Update_time'])
- ? PMA\libraries\Util::localisedDate(
+ ? Util::localisedDate(
strtotime($showtable['Update_time'])
)
: '';
$check_time = isset($showtable['Check_time'])
- ? PMA\libraries\Util::localisedDate(
+ ? Util::localisedDate(
strtotime($showtable['Check_time'])
)
: '';
@@ -1037,7 +669,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
foreach ($columns as $row) {
$extracted_columnspec
- = PMA\libraries\Util::extractColumnSpec($row['Type']);
+ = Util::extractColumnSpec($row['Type']);
$type = $extracted_columnspec['print_type'];
$attribute = $extracted_columnspec['attribute'];
if (! isset($row['Default'])) {
diff --git a/libraries/plugins/schema/pdf/RelationStatsPdf.class.php b/libraries/plugins/schema/pdf/RelationStatsPdf.php
similarity index 91%
rename from libraries/plugins/schema/pdf/RelationStatsPdf.class.php
rename to libraries/plugins/schema/pdf/RelationStatsPdf.php
index 9328a5c4ed..c8f31283fa 100644
--- a/libraries/plugins/schema/pdf/RelationStatsPdf.class.php
+++ b/libraries/plugins/schema/pdf/RelationStatsPdf.php
@@ -1,16 +1,18 @@
heightCell = 6;
@@ -76,7 +91,7 @@ class Table_Stats_Pdf extends TableStats
*/
protected function showMissingTableError()
{
- PMA_Export_Relation_Schema::dieSchema(
+ ExportRelationSchema::dieSchema(
$this->pageNumber,
"PDF",
sprintf(__('The %s table doesn\'t exist!'), $this->tableName)
@@ -95,6 +110,7 @@ class Table_Stats_Pdf extends TableStats
if ($this->tableDimension) {
$ret = sprintf('%.0fx%0.f', $this->width, $this->height);
}
+
return $ret . ' ' . $this->tableName;
}
@@ -107,7 +123,7 @@ class Table_Stats_Pdf extends TableStats
*
* @return void
*
- * @see PMA_Schema_PDF
+ * @see PMA_Schema_PDF
*/
private function _setWidth($fontSize)
{
@@ -149,7 +165,7 @@ class Table_Stats_Pdf extends TableStats
*
* @return void
*
- * @see PMA_Schema_PDF
+ * @see PMA_Schema_PDF
*/
public function tableDraw($fontSize, $withDoc, $setColor = 0)
{
@@ -160,7 +176,10 @@ class Table_Stats_Pdf extends TableStats
$this->diagram->SetFillColor(0, 0, 128);
}
if ($withDoc) {
- $this->diagram->SetLink($this->diagram->PMA_links['RT'][$this->tableName]['-'], -1);
+ $this->diagram->SetLink(
+ $this->diagram->PMA_links['RT'][$this->tableName]['-'],
+ -1
+ );
} else {
$this->diagram->PMA_links['doc'][$this->tableName]['-'] = '';
}
@@ -190,7 +209,10 @@ class Table_Stats_Pdf extends TableStats
}
}
if ($withDoc) {
- $this->diagram->SetLink($this->diagram->PMA_links['RT'][$this->tableName][$field], -1);
+ $this->diagram->SetLink(
+ $this->diagram->PMA_links['RT'][$this->tableName][$field],
+ -1
+ );
} else {
$this->diagram->PMA_links['doc'][$this->tableName][$field] = '';
}
diff --git a/libraries/plugins/schema/svg/RelationStatsSvg.class.php b/libraries/plugins/schema/svg/RelationStatsSvg.php
similarity index 64%
rename from libraries/plugins/schema/svg/RelationStatsSvg.class.php
rename to libraries/plugins/schema/svg/RelationStatsSvg.php
index ed30c05ce8..d53ca96c20 100644
--- a/libraries/plugins/schema/svg/RelationStatsSvg.class.php
+++ b/libraries/plugins/schema/svg/RelationStatsSvg.php
@@ -1,16 +1,18 @@
wTick = 10;
parent::__construct(
- $diagram, $master_table, $master_field, $foreign_table, $foreign_field
+ $diagram,
+ $master_table,
+ $master_field,
+ $foreign_table,
+ $foreign_field
);
}
@@ -51,7 +61,7 @@ class Relation_Stats_Svg extends RelationStats
* @return void
* @access public
*
- * @see PMA_SVG
+ * @see PMA_SVG
*/
public function relationDraw($showColor)
{
@@ -63,50 +73,67 @@ class Relation_Stats_Svg extends RelationStats
'#cb0',
'#0b0',
'#0bf',
- '#b0b'
+ '#b0b',
);
shuffle($listOfColors);
- $color = $listOfColors[0];
+ $color = $listOfColors[0];
} else {
$color = '#333';
}
$this->diagram->printElementLine(
- 'line', $this->xSrc, $this->ySrc,
- $this->xSrc + $this->srcDir * $this->wTick, $this->ySrc,
+ 'line',
+ $this->xSrc,
+ $this->ySrc,
+ $this->xSrc + $this->srcDir * $this->wTick,
+ $this->ySrc,
'stroke:' . $color . ';stroke-width:1;'
);
$this->diagram->printElementLine(
- 'line', $this->xDest + $this->destDir * $this->wTick,
- $this->yDest, $this->xDest, $this->yDest,
+ 'line',
+ $this->xDest + $this->destDir * $this->wTick,
+ $this->yDest,
+ $this->xDest,
+ $this->yDest,
'stroke:' . $color . ';stroke-width:1;'
);
$this->diagram->printElementLine(
- 'line', $this->xSrc + $this->srcDir * $this->wTick, $this->ySrc,
- $this->xDest + $this->destDir * $this->wTick, $this->yDest,
+ 'line',
+ $this->xSrc + $this->srcDir * $this->wTick,
+ $this->ySrc,
+ $this->xDest + $this->destDir * $this->wTick,
+ $this->yDest,
'stroke:' . $color . ';stroke-width:1;'
);
$root2 = 2 * sqrt(2);
$this->diagram->printElementLine(
- 'line', $this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
+ '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,
'stroke:' . $color . ';stroke-width:2;'
);
$this->diagram->printElementLine(
- 'line', $this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
+ '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,
'stroke:' . $color . ';stroke-width:2;'
);
$this->diagram->printElementLine(
- 'line', $this->xDest + $this->destDir * $this->wTick / 2, $this->yDest,
+ '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,
'stroke:' . $color . ';stroke-width:2;'
);
$this->diagram->printElementLine(
- 'line', $this->xDest + $this->destDir * $this->wTick / 2, $this->yDest,
+ '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,
'stroke:' . $color . ';stroke-width:2;'
diff --git a/libraries/plugins/schema/svg/Svg.php b/libraries/plugins/schema/svg/Svg.php
new file mode 100644
index 0000000000..d5bcb62890
--- /dev/null
+++ b/libraries/plugins/schema/svg/Svg.php
@@ -0,0 +1,284 @@
+openMemory();
+ /*
+ * Set indenting using three spaces,
+ * so output is formatted
+ */
+
+ $this->setIndent(true);
+ $this->setIndentString(' ');
+ /*
+ * Create the XML document
+ */
+
+ $this->startDocument('1.0', 'UTF-8');
+ $this->startDtd(
+ 'svg',
+ '-//W3C//DTD SVG 1.1//EN',
+ 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'
+ );
+ $this->endDtd();
+ }
+
+ /**
+ * Set document title
+ *
+ * @param string $value sets the title text
+ *
+ * @return void
+ */
+ public function setTitle($value)
+ {
+ $this->title = $value;
+ }
+
+ /**
+ * Set document author
+ *
+ * @param string $value sets the author
+ *
+ * @return void
+ */
+ public function setAuthor($value)
+ {
+ $this->author = $value;
+ }
+
+ /**
+ * Set document font
+ *
+ * @param string $value sets the font e.g Arial, Sans-serif etc
+ *
+ * @return void
+ */
+ public function setFont($value)
+ {
+ $this->font = $value;
+ }
+
+ /**
+ * Get document font
+ *
+ * @return string returns the font name
+ */
+ public function getFont()
+ {
+ return $this->font;
+ }
+
+ /**
+ * Set document font size
+ *
+ * @param string $value sets the font size in pixels
+ *
+ * @return void
+ */
+ public function setFontSize($value)
+ {
+ $this->fontSize = $value;
+ }
+
+ /**
+ * Get document font size
+ *
+ * @return string returns the font size
+ */
+ public function getFontSize()
+ {
+ return $this->fontSize;
+ }
+
+ /**
+ * Starts RelationStatsSvg Document
+ *
+ * svg document starts by first initializing svg tag
+ * which contains all the attributes and namespace that needed
+ * to define the svg document
+ *
+ * @param integer $width total width of the RelationStatsSvg document
+ * @param integer $height total height of the RelationStatsSvg document
+ * @param integer $x min-x of the view box
+ * @param integer $y min-y of the view box
+ *
+ * @return void
+ *
+ * @see XMLWriter::startElement(),XMLWriter::writeAttribute()
+ */
+ public function startSvgDoc($width, $height, $x = 0, $y = 0)
+ {
+ $this->startElement('svg');
+
+ if (!is_int($width)) {
+ $width = intval($width);
+ }
+
+ if (!is_int($height)) {
+ $height = intval($height);
+ }
+
+ if ($x != 0 || $y != 0) {
+ $this->writeAttribute('viewBox', "$x $y $width $height");
+ }
+ $this->writeAttribute('width', ($width - $x) . 'px');
+ $this->writeAttribute('height', ($height - $y) . 'px');
+ $this->writeAttribute('xmlns', 'http://www.w3.org/2000/svg');
+ $this->writeAttribute('version', '1.1');
+ }
+
+ /**
+ * Ends RelationStatsSvg Document
+ *
+ * @return void
+ * @see XMLWriter::endElement(),XMLWriter::endDocument()
+ */
+ public function endSvgDoc()
+ {
+ $this->endElement();
+ $this->endDocument();
+ }
+
+ /**
+ * output RelationStatsSvg Document
+ *
+ * svg document prompted to the user for download
+ * RelationStatsSvg document saved in .svg extension and can be
+ * easily changeable by using any svg IDE
+ *
+ * @param string $fileName file name
+ *
+ * @return void
+ * @see XMLWriter::startElement(),XMLWriter::writeAttribute()
+ */
+ public function showOutput($fileName)
+ {
+ //ob_get_clean();
+ $output = $this->flush();
+ PMA\libraries\Response::getInstance()
+ ->disable();
+ PMA_downloadHeader(
+ $fileName,
+ 'image/svg+xml',
+ /*overload*/
+ mb_strlen($output)
+ );
+ print $output;
+ }
+
+ /**
+ * Draws RelationStatsSvg elements
+ *
+ * SVG has some predefined shape elements like rectangle & text
+ * and other elements who have x,y co-ordinates are drawn.
+ * specify their width and height and can give styles too.
+ *
+ * @param string $name RelationStatsSvg element name
+ * @param int $x The x attr defines the left position of the element
+ * (e.g. x="0" places the element 0 pixels from the
+ * left of the browser window)
+ * @param integer $y The y attribute defines the top position of the
+ * element (e.g. y="0" places the element 0 pixels
+ * from the top of the browser window)
+ * @param int|string $width The width attribute defines the width the element
+ * @param int|string $height The height attribute defines the height the element
+ * @param string $text The text attribute defines the text the element
+ * @param string $styles The style attribute defines the style the element
+ * styles can be defined like CSS styles
+ *
+ * @return void
+ *
+ * @see XMLWriter::startElement(), XMLWriter::writeAttribute(),
+ * XMLWriter::text(), XMLWriter::endElement()
+ */
+ public function printElement(
+ $name,
+ $x,
+ $y,
+ $width = '',
+ $height = '',
+ $text = '',
+ $styles = ''
+ ) {
+ $this->startElement($name);
+ $this->writeAttribute('width', $width);
+ $this->writeAttribute('height', $height);
+ $this->writeAttribute('x', $x);
+ $this->writeAttribute('y', $y);
+ $this->writeAttribute('style', $styles);
+ if (isset($text)) {
+ $this->writeAttribute('font-family', $this->font);
+ $this->writeAttribute('font-size', $this->fontSize);
+ $this->text($text);
+ }
+ $this->endElement();
+ }
+
+ /**
+ * Draws RelationStatsSvg Line element
+ *
+ * RelationStatsSvg line element is drawn for connecting the tables.
+ * arrows are also drawn by specify its start and ending
+ * co-ordinates
+ *
+ * @param string $name RelationStatsSvg element name i.e line
+ * @param integer $x1 Defines the start of the line on the x-axis
+ * @param integer $y1 Defines the start of the line on the y-axis
+ * @param integer $x2 Defines the end of the line on the x-axis
+ * @param integer $y2 Defines the end of the line on the y-axis
+ * @param string $styles The style attribute defines the style the element
+ * styles can be defined like CSS styles
+ *
+ * @return void
+ *
+ * @see XMLWriter::startElement(), XMLWriter::writeAttribute(),
+ * XMLWriter::endElement()
+ */
+ public function printElementLine($name, $x1, $y1, $x2, $y2, $styles)
+ {
+ $this->startElement($name);
+ $this->writeAttribute('x1', $x1);
+ $this->writeAttribute('y1', $y1);
+ $this->writeAttribute('x2', $x2);
+ $this->writeAttribute('y2', $y2);
+ $this->writeAttribute('style', $styles);
+ $this->endElement();
+ }
+}
diff --git a/libraries/plugins/schema/svg/SvgRelationSchema.php b/libraries/plugins/schema/svg/SvgRelationSchema.php
new file mode 100644
index 0000000000..2ba33514d0
--- /dev/null
+++ b/libraries/plugins/schema/svg/SvgRelationSchema.php
@@ -0,0 +1,267 @@
+setShowColor(isset($_REQUEST['svg_show_color']));
+ $this->setShowKeys(isset($_REQUEST['svg_show_keys']));
+ $this->setTableDimension(isset($_REQUEST['svg_show_table_dimension']));
+ $this->setAllTablesSameWidth(isset($_REQUEST['svg_all_tables_same_width']));
+
+ $this->diagram->setTitle(
+ sprintf(
+ __('Schema of the %s database - Page %s'),
+ $this->db,
+ $this->pageNumber
+ )
+ );
+ $this->diagram->SetAuthor('phpMyAdmin ' . PMA_VERSION);
+ $this->diagram->setFont('Arial');
+ $this->diagram->setFontSize('16px');
+
+ $alltables = $this->getTablesFromRequest();
+
+ foreach ($alltables as $table) {
+ if (!isset($this->_tables[$table])) {
+ $this->_tables[$table] = new TableStatsSvg(
+ $this->diagram, $this->db,
+ $table, $this->diagram->getFont(),
+ $this->diagram->getFontSize(), $this->pageNumber,
+ $this->_tablewidth, $this->showKeys, $this->tableDimension,
+ $this->offline
+ );
+ }
+
+ if ($this->sameWide) {
+ $this->_tables[$table]->width = &$this->_tablewidth;
+ }
+ $this->_setMinMax($this->_tables[$table]);
+ }
+
+ $border = 15;
+ $this->diagram->startSvgDoc(
+ $this->_xMax + $border,
+ $this->_yMax + $border,
+ $this->_xMin - $border,
+ $this->_yMin - $border
+ );
+
+ $seen_a_relation = false;
+ foreach ($alltables as $one_table) {
+ $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
+ if (!$exist_rel) {
+ continue;
+ }
+
+ $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)
+ */
+ if ($master_field != 'foreign_keys_data') {
+ if (in_array($rel['foreign_table'], $alltables)) {
+ $this->_addRelation(
+ $one_table,
+ $this->diagram->getFont(),
+ $this->diagram->getFontSize(),
+ $master_field,
+ $rel['foreign_table'],
+ $rel['foreign_field'],
+ $this->tableDimension
+ );
+ }
+ continue;
+ }
+
+ foreach ($rel as $one_key) {
+ if (!in_array($one_key['ref_table_name'], $alltables)) {
+ continue;
+ }
+
+ foreach (
+ $one_key['index_list']
+ as $index => $one_field
+ ) {
+ $this->_addRelation(
+ $one_table,
+ $this->diagram->getFont(),
+ $this->diagram->getFontSize(),
+ $one_field,
+ $one_key['ref_table_name'],
+ $one_key['ref_index_list'][$index],
+ $this->tableDimension
+ );
+ }
+ }
+ }
+ }
+ if ($seen_a_relation) {
+ $this->_drawRelations();
+ }
+
+ $this->_drawTables();
+ $this->diagram->endSvgDoc();
+ }
+
+ /**
+ * Output RelationStatsSvg Document for download
+ *
+ * @return void
+ */
+ public function showOutput()
+ {
+ $this->diagram->showOutput($this->getFileName('.svg'));
+ }
+
+ /**
+ * Sets X and Y minimum and maximum for a table cell
+ *
+ * @param string $table The table name
+ *
+ * @return void
+ */
+ private function _setMinMax($table)
+ {
+ $this->_xMax = max($this->_xMax, $table->x + $table->width);
+ $this->_yMax = max($this->_yMax, $table->y + $table->height);
+ $this->_xMin = min($this->_xMin, $table->x);
+ $this->_yMin = min($this->_yMin, $table->y);
+ }
+
+ /**
+ * Defines relation objects
+ *
+ * @param string $masterTable The master table name
+ * @param string $font The font face
+ * @param int $fontSize Font size
+ * @param string $masterField The relation field in the master table
+ * @param string $foreignTable The foreign table name
+ * @param string $foreignField The relation field in the foreign table
+ * @param boolean $tableDimension Whether to display table position or not
+ *
+ * @return void
+ *
+ * @see _setMinMax,Table_Stats_Svg::__construct(),
+ * PMA\libraries\plugins\schema\svg\RelationStatsSvg::__construct()
+ */
+ private function _addRelation(
+ $masterTable,
+ $font,
+ $fontSize,
+ $masterField,
+ $foreignTable,
+ $foreignField,
+ $tableDimension
+ ) {
+ if (!isset($this->_tables[$masterTable])) {
+ $this->_tables[$masterTable] = new TableStatsSvg(
+ $this->diagram, $this->db,
+ $masterTable, $font, $fontSize, $this->pageNumber,
+ $this->_tablewidth, false, $tableDimension
+ );
+ $this->_setMinMax($this->_tables[$masterTable]);
+ }
+ if (!isset($this->_tables[$foreignTable])) {
+ $this->_tables[$foreignTable] = new TableStatsSvg(
+ $this->diagram, $this->db,
+ $foreignTable, $font, $fontSize, $this->pageNumber,
+ $this->_tablewidth, false, $tableDimension
+ );
+ $this->_setMinMax($this->_tables[$foreignTable]);
+ }
+ $this->_relations[] = new RelationStatsSvg(
+ $this->diagram,
+ $this->_tables[$masterTable],
+ $masterField,
+ $this->_tables[$foreignTable],
+ $foreignField
+ );
+ }
+
+ /**
+ * Draws relation arrows and lines
+ * connects master table's master field to
+ * foreign table's foreign field
+ *
+ * @return void
+ *
+ * @see Relation_Stats_Svg::relationDraw()
+ */
+ private function _drawRelations()
+ {
+ foreach ($this->_relations as $relation) {
+ $relation->relationDraw($this->showColor);
+ }
+ }
+
+ /**
+ * Draws tables
+ *
+ * @return void
+ *
+ * @see Table_Stats_Svg::Table_Stats_tableDraw()
+ */
+ private function _drawTables()
+ {
+ foreach ($this->_tables as $table) {
+ $table->tableDraw($this->showColor);
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/plugins/schema/svg/Svg_Relation_Schema.class.php b/libraries/plugins/schema/svg/Svg_Relation_Schema.class.php
deleted file mode 100644
index ff00e4a522..0000000000
--- a/libraries/plugins/schema/svg/Svg_Relation_Schema.class.php
+++ /dev/null
@@ -1,520 +0,0 @@
-openMemory();
- /*
- * Set indenting using three spaces,
- * so output is formatted
- */
-
- $this->setIndent(true);
- $this->setIndentString(' ');
- /*
- * Create the XML document
- */
-
- $this->startDocument('1.0', 'UTF-8');
- $this->startDtd(
- 'svg', '-//W3C//DTD SVG 1.1//EN',
- 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'
- );
- $this->endDtd();
- }
-
- /**
- * Set document title
- *
- * @param string $value sets the title text
- *
- * @return void
- */
- public function setTitle($value)
- {
- $this->title = $value;
- }
-
- /**
- * Set document author
- *
- * @param string $value sets the author
- *
- * @return void
- */
- public function setAuthor($value)
- {
- $this->author = $value;
- }
-
- /**
- * Set document font
- *
- * @param string $value sets the font e.g Arial, Sans-serif etc
- *
- * @return void
- */
- public function setFont($value)
- {
- $this->font = $value;
- }
-
- /**
- * Get document font
- *
- * @return string returns the font name
- */
- public function getFont()
- {
- return $this->font;
- }
-
- /**
- * Set document font size
- *
- * @param string $value sets the font size in pixels
- *
- * @return void
- */
- public function setFontSize($value)
- {
- $this->fontSize = $value;
- }
-
- /**
- * Get document font size
- *
- * @return string returns the font size
- */
- public function getFontSize()
- {
- return $this->fontSize;
- }
-
- /**
- * Starts Svg Document
- *
- * svg document starts by first initializing svg tag
- * which contains all the attributes and namespace that needed
- * to define the svg document
- *
- * @param integer $width total width of the Svg document
- * @param integer $height total height of the Svg document
- * @param integer $x min-x of the view box
- * @param integer $y min-y of the view box
- *
- * @return void
- *
- * @see XMLWriter::startElement(),XMLWriter::writeAttribute()
- */
- public function startSvgDoc($width, $height, $x = 0, $y = 0)
- {
- $this->startElement('svg');
-
- if (!is_int($width)) {
- $width = intval($width);
- }
-
- if (!is_int($height)) {
- $height = intval($height);
- }
-
- if ($x != 0 || $y != 0) {
- $this->writeAttribute('viewBox', "$x $y $width $height");
- }
- $this->writeAttribute('width', ($width - $x) . 'px');
- $this->writeAttribute('height', ($height - $y) . 'px');
- $this->writeAttribute('xmlns', 'http://www.w3.org/2000/svg');
- $this->writeAttribute('version', '1.1');
- }
-
- /**
- * Ends Svg Document
- *
- * @return void
- * @see XMLWriter::endElement(),XMLWriter::endDocument()
- */
- public function endSvgDoc()
- {
- $this->endElement();
- $this->endDocument();
- }
-
- /**
- * output Svg Document
- *
- * svg document prompted to the user for download
- * Svg document saved in .svg extension and can be
- * easily changeable by using any svg IDE
- *
- * @param string $fileName file name
- *
- * @return void
- * @see XMLWriter::startElement(),XMLWriter::writeAttribute()
- */
- public function showOutput($fileName)
- {
- //ob_get_clean();
- $output = $this->flush();
- PMA\libraries\Response::getInstance()->disable();
- PMA_downloadHeader(
- $fileName,
- 'image/svg+xml',
- /*overload*/mb_strlen($output)
- );
- print $output;
- }
-
- /**
- * Draws Svg elements
- *
- * SVG has some predefined shape elements like rectangle & text
- * and other elements who have x,y co-ordinates are drawn.
- * specify their width and height and can give styles too.
- *
- * @param string $name Svg element name
- * @param int $x The x attr defines the left position of the element
- * (e.g. x="0" places the element 0 pixels from the left of the browser window)
- * @param integer $y The y attribute defines the top position of the
- * element (e.g. y="0" places the element 0 pixels from the top of the browser
- * window)
- * @param int|string $width The width attribute defines the width the element
- * @param int|string $height The height attribute defines the height the element
- * @param string $text The text attribute defines the text the element
- * @param string $styles The style attribute defines the style the element
- * styles can be defined like CSS styles
- *
- * @return void
- *
- * @see XMLWriter::startElement(), XMLWriter::writeAttribute(),
- * XMLWriter::text(), XMLWriter::endElement()
- */
- public function printElement($name, $x, $y, $width = '', $height = '',
- $text = '', $styles = ''
- ) {
- $this->startElement($name);
- $this->writeAttribute('width', $width);
- $this->writeAttribute('height', $height);
- $this->writeAttribute('x', $x);
- $this->writeAttribute('y', $y);
- $this->writeAttribute('style', $styles);
- if (isset($text)) {
- $this->writeAttribute('font-family', $this->font);
- $this->writeAttribute('font-size', $this->fontSize);
- $this->text($text);
- }
- $this->endElement();
- }
-
- /**
- * Draws Svg Line element
- *
- * Svg line element is drawn for connecting the tables.
- * arrows are also drawn by specify its start and ending
- * co-ordinates
- *
- * @param string $name Svg element name i.e line
- * @param integer $x1 Defines the start of the line on the x-axis
- * @param integer $y1 Defines the start of the line on the y-axis
- * @param integer $x2 Defines the end of the line on the x-axis
- * @param integer $y2 Defines the end of the line on the y-axis
- * @param string $styles The style attribute defines the style the element
- * styles can be defined like CSS styles
- *
- * @return void
- *
- * @see XMLWriter::startElement(), XMLWriter::writeAttribute(),
- * XMLWriter::endElement()
- */
- public function printElementLine($name,$x1,$y1,$x2,$y2,$styles)
- {
- $this->startElement($name);
- $this->writeAttribute('x1', $x1);
- $this->writeAttribute('y1', $y1);
- $this->writeAttribute('x2', $x2);
- $this->writeAttribute('y2', $y2);
- $this->writeAttribute('style', $styles);
- $this->endElement();
- }
-}
-
-/**
- * Svg Relation Schema Class
- *
- * Purpose of this class is to generate the SVG XML Document because
- * SVG defines the graphics in XML format which is used for representing
- * the database diagrams as vector image. This class actually helps
- * in preparing SVG XML format.
- *
- * SVG XML is generated by using XMLWriter php extension and this class
- * inherits Export_Relation_Schema class has common functionality added
- * to this class
- *
- * @package PhpMyAdmin
- * @name Svg_Relation_Schema
- */
-class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
-{
- /**
- * @var Table_Stats_Dia[]|Table_Stats_Eps[]|Table_Stats_Pdf[]|Table_Stats_Svg[]
- */
- private $_tables = array();
-
- /** @var Relation_Stats_Dia[] Relations */
- private $_relations = array();
- private $_xMax = 0;
- private $_yMax = 0;
- private $_xMin = 100000;
- private $_yMin = 100000;
- private $_tablewidth;
-
- /**
- * The "PMA_Svg_Relation_Schema" constructor
- *
- * Upon instantiation This starts writing the SVG XML document
- * user will be prompted for download as .svg extension
- *
- * @param string $db database name
- *
- * @see PMA_SVG
- */
- function __construct($db)
- {
- parent::__construct($db, new PMA_SVG());
-
- $this->setShowColor(isset($_REQUEST['svg_show_color']));
- $this->setShowKeys(isset($_REQUEST['svg_show_keys']));
- $this->setTableDimension(isset($_REQUEST['svg_show_table_dimension']));
- $this->setAllTablesSameWidth(isset($_REQUEST['svg_all_tables_same_width']));
-
- $this->diagram->setTitle(
- sprintf(
- __('Schema of the %s database - Page %s'),
- $this->db,
- $this->pageNumber
- )
- );
- $this->diagram->SetAuthor('phpMyAdmin ' . PMA_VERSION);
- $this->diagram->setFont('Arial');
- $this->diagram->setFontSize('16px');
-
- $alltables = $this->getTablesFromRequest();
-
- foreach ($alltables as $table) {
- if (! isset($this->_tables[$table])) {
- $this->_tables[$table] = new Table_Stats_Svg(
- $this->diagram, $this->db,
- $table, $this->diagram->getFont(),
- $this->diagram->getFontSize(), $this->pageNumber,
- $this->_tablewidth, $this->showKeys, $this->tableDimension,
- $this->offline
- );
- }
-
- if ($this->sameWide) {
- $this->_tables[$table]->width = &$this->_tablewidth;
- }
- $this->_setMinMax($this->_tables[$table]);
- }
-
- $border = 15;
- $this->diagram->startSvgDoc(
- $this->_xMax + $border,
- $this->_yMax + $border,
- $this->_xMin - $border,
- $this->_yMin - $border
- );
-
- $seen_a_relation = false;
- foreach ($alltables as $one_table) {
- $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
- if (!$exist_rel) {
- continue;
- }
-
- $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)
- */
- if ($master_field != 'foreign_keys_data') {
- if (in_array($rel['foreign_table'], $alltables)) {
- $this->_addRelation(
- $one_table,
- $this->diagram->getFont(),
- $this->diagram->getFontSize(),
- $master_field,
- $rel['foreign_table'],
- $rel['foreign_field'],
- $this->tableDimension
- );
- }
- continue;
- }
-
- foreach ($rel as $one_key) {
- if (!in_array($one_key['ref_table_name'], $alltables)) {
- continue;
- }
-
- foreach ($one_key['index_list']
- as $index => $one_field
- ) {
- $this->_addRelation(
- $one_table, $this->diagram->getFont(),
- $this->diagram->getFontSize(),
- $one_field, $one_key['ref_table_name'],
- $one_key['ref_index_list'][$index],
- $this->tableDimension
- );
- }
- }
- }
- }
- if ($seen_a_relation) {
- $this->_drawRelations();
- }
-
- $this->_drawTables();
- $this->diagram->endSvgDoc();
- }
-
- /**
- * Output Svg Document for download
- *
- * @return void
- */
- public function showOutput()
- {
- $this->diagram->showOutput($this->getFileName('.svg'));
- }
-
-
- /**
- * Sets X and Y minimum and maximum for a table cell
- *
- * @param string $table The table name
- *
- * @return void
- */
- private function _setMinMax($table)
- {
- $this->_xMax = max($this->_xMax, $table->x + $table->width);
- $this->_yMax = max($this->_yMax, $table->y + $table->height);
- $this->_xMin = min($this->_xMin, $table->x);
- $this->_yMin = min($this->_yMin, $table->y);
- }
-
- /**
- * Defines relation objects
- *
- * @param string $masterTable The master table name
- * @param string $font The font face
- * @param int $fontSize Font size
- * @param string $masterField The relation field in the master table
- * @param string $foreignTable The foreign table name
- * @param string $foreignField The relation field in the foreign table
- * @param boolean $tableDimension Whether to display table position or not
- *
- * @return void
- *
- * @see _setMinMax,Table_Stats_Svg::__construct(),
- * Relation_Stats_Svg::__construct()
- */
- private function _addRelation(
- $masterTable,$font,$fontSize, $masterField,
- $foreignTable, $foreignField, $tableDimension
- ) {
- if (! isset($this->_tables[$masterTable])) {
- $this->_tables[$masterTable] = new Table_Stats_Svg(
- $this->diagram, $this->db,
- $masterTable, $font, $fontSize, $this->pageNumber,
- $this->_tablewidth, false, $tableDimension
- );
- $this->_setMinMax($this->_tables[$masterTable]);
- }
- if (! isset($this->_tables[$foreignTable])) {
- $this->_tables[$foreignTable] = new Table_Stats_Svg(
- $this->diagram, $this->db,
- $foreignTable, $font, $fontSize, $this->pageNumber,
- $this->_tablewidth, false, $tableDimension
- );
- $this->_setMinMax($this->_tables[$foreignTable]);
- }
- $this->_relations[] = new Relation_Stats_Svg(
- $this->diagram,
- $this->_tables[$masterTable],
- $masterField,
- $this->_tables[$foreignTable],
- $foreignField
- );
- }
-
- /**
- * Draws relation arrows and lines
- * connects master table's master field to
- * foreign table's foreign field
- *
- * @return void
- *
- * @see Relation_Stats_Svg::relationDraw()
- */
- private function _drawRelations()
- {
- foreach ($this->_relations as $relation) {
- $relation->relationDraw($this->showColor);
- }
- }
-
- /**
- * Draws tables
- *
- * @return void
- *
- * @see Table_Stats_Svg::Table_Stats_tableDraw()
- */
- private function _drawTables()
- {
- foreach ($this->_tables as $table) {
- $table->tableDraw($this->showColor);
- }
- }
-}
diff --git a/libraries/plugins/schema/svg/TableStatsSvg.class.php b/libraries/plugins/schema/svg/TableStatsSvg.php
similarity index 67%
rename from libraries/plugins/schema/svg/TableStatsSvg.class.php
rename to libraries/plugins/schema/svg/TableStatsSvg.php
index 195ea66aaa..d1bce10a9f 100644
--- a/libraries/plugins/schema/svg/TableStatsSvg.class.php
+++ b/libraries/plugins/schema/svg/TableStatsSvg.php
@@ -1,16 +1,20 @@
pageNumber,
"SVG",
sprintf(__('The %s table doesn\'t exist!'), $this->tableName)
@@ -89,9 +106,9 @@ class Table_Stats_Svg extends TableStats
* @return void
* @access private
*
- * @see PMA_SVG
+ * @see PMA_SVG
*/
- private function _setWidthTable($font,$fontSize)
+ private function _setWidthTable($font, $fontSize)
{
foreach ($this->fields as $field) {
$this->width = max(
@@ -133,21 +150,31 @@ class Table_Stats_Svg extends TableStats
* @access public
* @return void
*
- * @see PMA_SVG,PMA_SVG::printElement
+ * @see PMA_SVG,PMA_SVG::printElement
*/
public function tableDraw($showColor)
{
$this->diagram->printElement(
- 'rect', $this->x, $this->y, $this->width,
- $this->heightCell, null, 'fill:#007;stroke:black;'
+ 'rect',
+ $this->x,
+ $this->y,
+ $this->width,
+ $this->heightCell,
+ null,
+ 'fill:#007;stroke:black;'
);
$this->diagram->printElement(
- 'text', $this->x + 5, $this->y+ 14, $this->width, $this->heightCell,
- $this->getTitle(), 'fill:#fff;'
+ 'text',
+ $this->x + 5,
+ $this->y + 14,
+ $this->width,
+ $this->heightCell,
+ $this->getTitle(),
+ 'fill:#fff;'
);
foreach ($this->fields as $field) {
$this->currentCell += $this->heightCell;
- $fillColor = 'none';
+ $fillColor = 'none';
if ($showColor) {
if (in_array($field, $this->primary)) {
$fillColor = '#aea';
@@ -157,12 +184,22 @@ class Table_Stats_Svg extends TableStats
}
}
$this->diagram->printElement(
- 'rect', $this->x, $this->y + $this->currentCell, $this->width,
- $this->heightCell, null, 'fill:' . $fillColor . ';stroke:black;'
+ 'rect',
+ $this->x,
+ $this->y + $this->currentCell,
+ $this->width,
+ $this->heightCell,
+ null,
+ 'fill:' . $fillColor . ';stroke:black;'
);
$this->diagram->printElement(
- 'text', $this->x + 5, $this->y + 14 + $this->currentCell,
- $this->width, $this->heightCell, $field, 'fill:black;'
+ 'text',
+ $this->x + 5,
+ $this->y + 14 + $this->currentCell,
+ $this->width,
+ $this->heightCell,
+ $field,
+ 'fill:black;'
);
}
}
diff --git a/server_export.php b/server_export.php
index 0949cdb4c5..508aa28a1d 100644
--- a/server_export.php
+++ b/server_export.php
@@ -43,7 +43,7 @@ if (! isset($num_tables)) {
if (! isset($unlim_num_rows)) {
$unlim_num_rows = 0;
}
-$response = PMA_Response::getInstance();
+$response = Response::getInstance();
$response->addHTML(
PMA_getExportDisplay(
'server', $db, $table, $sql_query, $num_tables,
diff --git a/tbl_export.php b/tbl_export.php
index cfa19fb42c..0531dbbbf6 100644
--- a/tbl_export.php
+++ b/tbl_export.php
@@ -6,6 +6,7 @@
* @package PhpMyAdmin
*/
use PMA\libraries\config\PageSettings;
+use PMA\libraries\Response;
/**
*
@@ -192,7 +193,7 @@ if (! isset($unlim_num_rows)) {
if (! isset($multi_values)) {
$multi_values = '';
}
-$response = PMA_Response::getInstance();
+$response = Response::getInstance();
$response->addHTML(
PMA_getExportDisplay(
'table', $db, $table, $sql_query, $num_tables,
diff --git a/test/classes/plugin/import/ImportCsv_test.php b/test/classes/plugin/import/ImportCsv_test.php
index 595217aab1..053745a2d0 100644
--- a/test/classes/plugin/import/ImportCsv_test.php
+++ b/test/classes/plugin/import/ImportCsv_test.php
@@ -1,6 +1,6 @@
getMock();
$GLOBALS['dbi'] = $dbi;
- include_once 'libraries/plugins/import/ImportShp.class.php';
$this->object = new ImportShp();
/**
diff --git a/test/classes/plugin/import/ImportSql_test.php b/test/classes/plugin/import/ImportSql_test.php
index 215f4523d3..f1d9cf81aa 100644
--- a/test/classes/plugin/import/ImportSql_test.php
+++ b/test/classes/plugin/import/ImportSql_test.php
@@ -1,6 +1,6 @@
object = new PMA_Dia_Relation_Schema('information_schema');
+ $this->object = new DiaRelationSchema('information_schema');
}
/**
diff --git a/test/classes/schema/Eps_Relation_Schema_test.php b/test/classes/schema/Eps_Relation_Schema_test.php
index 53e7133c12..8151c80ba3 100644
--- a/test/classes/schema/Eps_Relation_Schema_test.php
+++ b/test/classes/schema/Eps_Relation_Schema_test.php
@@ -1,6 +1,6 @@
object = new PMA_Eps_Relation_Schema('information_schema');
+ $this->object = new EpsRelationSchema('information_schema');
}
/**
diff --git a/test/classes/schema/Export_Relation_Schema_test.php b/test/classes/schema/Export_Relation_Schema_test.php
index 019f27e6f3..0de74b6406 100644
--- a/test/classes/schema/Export_Relation_Schema_test.php
+++ b/test/classes/schema/Export_Relation_Schema_test.php
@@ -1,6 +1,6 @@
object = new PMA_Export_Relation_Schema('information_schema', null);
+ $this->object = new ExportRelationSchema('information_schema', null);
}
/**
diff --git a/test/classes/schema/Pdf_Relation_Schema_test.php b/test/classes/schema/Pdf_Relation_Schema_test.php
index 5ec8e17171..e21c8773f3 100644
--- a/test/classes/schema/Pdf_Relation_Schema_test.php
+++ b/test/classes/schema/Pdf_Relation_Schema_test.php
@@ -1,6 +1,6 @@
object = new PMA_Pdf_Relation_Schema('information_schema');
+ $this->object = new PdfRelationSchema('information_schema');
}
/**
diff --git a/test/classes/schema/Svg_Relation_Schema_test.php b/test/classes/schema/Svg_Relation_Schema_test.php
index c816e1ddb1..74c16a279a 100644
--- a/test/classes/schema/Svg_Relation_Schema_test.php
+++ b/test/classes/schema/Svg_Relation_Schema_test.php
@@ -1,6 +1,6 @@
object = new PMA_Svg_Relation_Schema('information_schema');
+ $this->object = new SvgRelationSchema('information_schema');
}
/**