Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pootle server 2011-08-02 16:40:26 +02:00
commit c36df906f0
19 changed files with 4046 additions and 4045 deletions

View File

@ -44,6 +44,7 @@ phpMyAdmin - ChangeLog
3.4.5.0 (not yet released)
- bug #3375325 [interface] Page list in navigation frame looks odd
- bug #3313235 [interface] Error div misplaced
- bug #3374802 [interface] Comment on a column breaks inline editing
3.4.4.0 (not yet released)
- bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes

View File

@ -1182,7 +1182,7 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
// in the tools div, only display the Inline link when not in ajax
// mode because 1) it currently does not work and 2) we would
// have two similar mechanisms on the page for the same goal
if ($is_select || $GLOBALS['is_ajax_request'] === false) {
if ($is_select || $GLOBALS['is_ajax_request'] === false && ! $query_too_big) {
// see in js/functions.js the jQuery code attached to id inline_edit
// document.write conflicts with jQuery, hence used $().append()
echo "<script type=\"text/javascript\">\n" .

View File

@ -42,188 +42,188 @@ if (isset($plugin_list)) {
);
} else {
/**
* Set of functions used to build exports of tables
*/
/**
* Set of functions used to build exports of tables
*/
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
return true;
}
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs the content of a table in NHibernate format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $CG_FORMATS, $CG_HANDLERS, $what;
$format = $GLOBALS[$what . '_format'];
if (isset($CG_FORMATS[$format])) {
return PMA_exportOutputHandler($CG_HANDLERS[$format]($db, $table, $crlf));
/**
* Outputs the content of a table in NHibernate format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $CG_FORMATS, $CG_HANDLERS, $what;
$format = $GLOBALS[$what . '_format'];
if (isset($CG_FORMATS[$format])) {
return PMA_exportOutputHandler($CG_HANDLERS[$format]($db, $table, $crlf));
}
return PMA_exportOutputHandler(sprintf("%s is not supported.", $format));
}
return PMA_exportOutputHandler(sprintf("%s is not supported.", $format));
}
/**
*
* @package phpMyAdmin-Export
* @subpackage Codegen
*/
class TableProperty
{
public $name;
public $type;
public $nullable;
public $key;
public $defaultValue;
public $ext;
function __construct($row)
/**
*
* @package phpMyAdmin-Export
* @subpackage Codegen
*/
class TableProperty
{
$this->name = trim($row[0]);
$this->type = trim($row[1]);
$this->nullable = trim($row[2]);
$this->key = trim($row[3]);
$this->defaultValue = trim($row[4]);
$this->ext = trim($row[5]);
public $name;
public $type;
public $nullable;
public $key;
public $defaultValue;
public $ext;
function __construct($row)
{
$this->name = trim($row[0]);
$this->type = trim($row[1]);
$this->nullable = trim($row[2]);
$this->key = trim($row[3]);
$this->defaultValue = trim($row[4]);
$this->ext = trim($row[5]);
}
function getPureType()
{
$pos=strpos($this->type, "(");
if ($pos > 0)
return substr($this->type, 0, $pos);
return $this->type;
}
function isNotNull()
{
return $this->nullable == "NO" ? "true" : "false";
}
function isUnique()
{
return $this->key == "PRI" || $this->key == "UNI" ? "true" : "false";
}
function getDotNetPrimitiveType()
{
if (strpos($this->type, "int") === 0) return "int";
if (strpos($this->type, "long") === 0) return "long";
if (strpos($this->type, "char") === 0) return "string";
if (strpos($this->type, "varchar") === 0) return "string";
if (strpos($this->type, "text") === 0) return "string";
if (strpos($this->type, "longtext") === 0) return "string";
if (strpos($this->type, "tinyint") === 0) return "bool";
if (strpos($this->type, "datetime") === 0) return "DateTime";
return "unknown";
}
function getDotNetObjectType()
{
if (strpos($this->type, "int") === 0) return "Int32";
if (strpos($this->type, "long") === 0) return "Long";
if (strpos($this->type, "char") === 0) return "String";
if (strpos($this->type, "varchar") === 0) return "String";
if (strpos($this->type, "text") === 0) return "String";
if (strpos($this->type, "longtext") === 0) return "String";
if (strpos($this->type, "tinyint") === 0) return "Boolean";
if (strpos($this->type, "datetime") === 0) return "DateTime";
return "Unknown";
}
function getIndexName()
{
if (strlen($this->key)>0)
return "index=\"" . htmlspecialchars($this->name, ENT_COMPAT, 'UTF-8') . "\"";
return "";
}
function isPK()
{
return $this->key=="PRI";
}
function formatCs($text)
{
$text=str_replace("#name#", cgMakeIdentifier($this->name, false), $text);
return $this->format($text);
}
function formatXml($text)
{
$text=str_replace("#name#", htmlspecialchars($this->name, ENT_COMPAT, 'UTF-8'), $text);
$text=str_replace("#indexName#", $this->getIndexName(), $text);
return $this->format($text);
}
function format($text)
{
$text=str_replace("#ucfirstName#", cgMakeIdentifier($this->name), $text);
$text=str_replace("#dotNetPrimitiveType#", $this->getDotNetPrimitiveType(), $text);
$text=str_replace("#dotNetObjectType#", $this->getDotNetObjectType(), $text);
$text=str_replace("#type#", $this->getPureType(), $text);
$text=str_replace("#notNull#", $this->isNotNull(), $text);
$text=str_replace("#unique#", $this->isUnique(), $text);
return $text;
}
}
function getPureType()
{
$pos=strpos($this->type, "(");
if ($pos > 0)
return substr($this->type, 0, $pos);
return $this->type;
}
function isNotNull()
{
return $this->nullable == "NO" ? "true" : "false";
}
function isUnique()
{
return $this->key == "PRI" || $this->key == "UNI" ? "true" : "false";
}
function getDotNetPrimitiveType()
{
if (strpos($this->type, "int") === 0) return "int";
if (strpos($this->type, "long") === 0) return "long";
if (strpos($this->type, "char") === 0) return "string";
if (strpos($this->type, "varchar") === 0) return "string";
if (strpos($this->type, "text") === 0) return "string";
if (strpos($this->type, "longtext") === 0) return "string";
if (strpos($this->type, "tinyint") === 0) return "bool";
if (strpos($this->type, "datetime") === 0) return "DateTime";
return "unknown";
}
function getDotNetObjectType()
{
if (strpos($this->type, "int") === 0) return "Int32";
if (strpos($this->type, "long") === 0) return "Long";
if (strpos($this->type, "char") === 0) return "String";
if (strpos($this->type, "varchar") === 0) return "String";
if (strpos($this->type, "text") === 0) return "String";
if (strpos($this->type, "longtext") === 0) return "String";
if (strpos($this->type, "tinyint") === 0) return "Boolean";
if (strpos($this->type, "datetime") === 0) return "DateTime";
return "Unknown";
}
function getIndexName()
{
if (strlen($this->key)>0)
return "index=\"" . htmlspecialchars($this->name, ENT_COMPAT, 'UTF-8') . "\"";
return "";
}
function isPK()
{
return $this->key=="PRI";
}
function formatCs($text)
{
$text=str_replace("#name#", cgMakeIdentifier($this->name, false), $text);
return $this->format($text);
}
function formatXml($text)
{
$text=str_replace("#name#", htmlspecialchars($this->name, ENT_COMPAT, 'UTF-8'), $text);
$text=str_replace("#indexName#", $this->getIndexName(), $text);
return $this->format($text);
}
function format($text)
{
$text=str_replace("#ucfirstName#", cgMakeIdentifier($this->name), $text);
$text=str_replace("#dotNetPrimitiveType#", $this->getDotNetPrimitiveType(), $text);
$text=str_replace("#dotNetObjectType#", $this->getDotNetObjectType(), $text);
$text=str_replace("#type#", $this->getPureType(), $text);
$text=str_replace("#notNull#", $this->isNotNull(), $text);
$text=str_replace("#unique#", $this->isUnique(), $text);
return $text;
}
}
function cgMakeIdentifier($str, $ucfirst = true)
{

View File

@ -35,189 +35,189 @@ if (isset($plugin_list)) {
);
} else {
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $what;
global $csv_terminated;
global $csv_separator;
global $csv_enclosed;
global $csv_escaped;
// Here we just prepare some values for export
if ($what == 'excel') {
$csv_terminated = "\015\012";
switch($GLOBALS['excel_edition']) {
case 'win':
// as tested on Windows with Excel 2002 and Excel 2007
$csv_separator = ';';
break;
case 'mac_excel2003':
$csv_separator = ';';
break;
case 'mac_excel2008':
$csv_separator = ',';
break;
}
$csv_enclosed = '"';
$csv_escaped = '"';
if (isset($GLOBALS['excel_columns'])) {
$GLOBALS['csv_columns'] = 'yes';
}
} else {
if (empty($csv_terminated) || strtolower($csv_terminated) == 'auto') {
$csv_terminated = $GLOBALS['crlf'];
} else {
$csv_terminated = str_replace('\\r', "\015", $csv_terminated);
$csv_terminated = str_replace('\\n', "\012", $csv_terminated);
$csv_terminated = str_replace('\\t', "\011", $csv_terminated);
} // end if
$csv_separator = str_replace('\\t', "\011", $csv_separator);
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return true;
}
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $what;
global $csv_terminated;
global $csv_separator;
global $csv_enclosed;
global $csv_escaped;
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in CSV format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
global $csv_terminated;
global $csv_separator;
global $csv_enclosed;
global $csv_escaped;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line
if (isset($GLOBALS['csv_columns'])) {
$schema_insert = '';
for ($i = 0; $i < $fields_cnt; $i++) {
if ($csv_enclosed == '') {
$schema_insert .= stripslashes(PMA_DBI_field_name($result, $i));
} else {
$schema_insert .= $csv_enclosed
. str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, stripslashes(PMA_DBI_field_name($result, $i)))
. $csv_enclosed;
// Here we just prepare some values for export
if ($what == 'excel') {
$csv_terminated = "\015\012";
switch($GLOBALS['excel_edition']) {
case 'win':
// as tested on Windows with Excel 2002 and Excel 2007
$csv_separator = ';';
break;
case 'mac_excel2003':
$csv_separator = ';';
break;
case 'mac_excel2008':
$csv_separator = ',';
break;
}
$schema_insert .= $csv_separator;
} // end for
$schema_insert =trim(substr($schema_insert, 0, -1));
if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
return false;
$csv_enclosed = '"';
$csv_escaped = '"';
if (isset($GLOBALS['excel_columns'])) {
$GLOBALS['csv_columns'] = 'yes';
}
} else {
if (empty($csv_terminated) || strtolower($csv_terminated) == 'auto') {
$csv_terminated = $GLOBALS['crlf'];
} else {
$csv_terminated = str_replace('\\r', "\015", $csv_terminated);
$csv_terminated = str_replace('\\n', "\012", $csv_terminated);
$csv_terminated = str_replace('\\t', "\011", $csv_terminated);
} // end if
$csv_separator = str_replace('\\t', "\011", $csv_separator);
}
} // end if
return true;
}
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$schema_insert .= $GLOBALS[$what . '_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
// always enclose fields
if ($what == 'excel') {
$row[$j] = preg_replace("/\015(\012)?/", "\012", $row[$j]);
}
// remove CRLF characters within field
if (isset($GLOBALS[$what . '_removeCRLF']) && $GLOBALS[$what . '_removeCRLF']) {
$row[$j] = str_replace("\n", "", str_replace("\r", "", $row[$j]));
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in CSV format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
global $csv_terminated;
global $csv_separator;
global $csv_enclosed;
global $csv_escaped;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line
if (isset($GLOBALS['csv_columns'])) {
$schema_insert = '';
for ($i = 0; $i < $fields_cnt; $i++) {
if ($csv_enclosed == '') {
$schema_insert .= $row[$j];
$schema_insert .= stripslashes(PMA_DBI_field_name($result, $i));
} else {
// also double the escape string if found in the data
if ('csv' == $what) {
$schema_insert .= $csv_enclosed
. str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, str_replace($csv_escaped, $csv_escaped . $csv_escaped, $row[$j]))
$schema_insert .= $csv_enclosed
. str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, stripslashes(PMA_DBI_field_name($result, $i)))
. $csv_enclosed;
} else {
// for excel, avoid a problem when a field contains
// double quotes
$schema_insert .= $csv_enclosed
. str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, $row[$j])
. $csv_enclosed;
}
}
} else {
$schema_insert .= '';
$schema_insert .= $csv_separator;
} // end for
$schema_insert =trim(substr($schema_insert, 0, -1));
if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
return false;
}
if ($j < $fields_cnt-1) {
$schema_insert .= $csv_separator;
} // end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$schema_insert .= $GLOBALS[$what . '_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
// always enclose fields
if ($what == 'excel') {
$row[$j] = preg_replace("/\015(\012)?/", "\012", $row[$j]);
}
// remove CRLF characters within field
if (isset($GLOBALS[$what . '_removeCRLF']) && $GLOBALS[$what . '_removeCRLF']) {
$row[$j] = str_replace("\n", "", str_replace("\r", "", $row[$j]));
}
if ($csv_enclosed == '') {
$schema_insert .= $row[$j];
} else {
// also double the escape string if found in the data
if ('csv' == $what) {
$schema_insert .= $csv_enclosed
. str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, str_replace($csv_escaped, $csv_escaped . $csv_escaped, $row[$j]))
. $csv_enclosed;
} else {
// for excel, avoid a problem when a field contains
// double quotes
$schema_insert .= $csv_enclosed
. str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, $row[$j])
. $csv_enclosed;
}
}
} else {
$schema_insert .= '';
}
if ($j < $fields_cnt-1) {
$schema_insert .= $csv_separator;
}
} // end for
if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
return false;
}
} // end for
} // end while
PMA_DBI_free_result($result);
if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
return false;
}
} // end while
PMA_DBI_free_result($result);
return true;
} // end of the 'PMA_getTableCsv()' function
return true;
} // end of the 'PMA_getTableCsv()' function
}
?>

View File

@ -34,321 +34,321 @@ if (isset($plugin_list)) {
);
} else {
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return PMA_exportOutputHandler('</body></html>');
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $charset_of_file;
return PMA_exportOutputHandler('<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=' . (isset($charset_of_file) ? $charset_of_file : 'utf-8') . '" />
</head>
<body>');
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return PMA_exportOutputHandler('<h1>' . __('Database') . ' ' . htmlspecialchars($db) . '</h1>');
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in HTML (Microsoft Word) format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
if (! PMA_exportOutputHandler('<h2>' . __('Dumping data for table') . ' ' . htmlspecialchars($table) . '</h2>')) {
return false;
}
if (! PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return false;
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return PMA_exportOutputHandler('</body></html>');
}
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $charset_of_file;
return PMA_exportOutputHandler('<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
// If required, get fields name at the first line
if (isset($GLOBALS['htmlword_columns'])) {
$schema_insert = '<tr class="print-category">';
for ($i = 0; $i < $fields_cnt; $i++) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
} // end for
$schema_insert .= '</tr>';
if (! PMA_exportOutputHandler($schema_insert)) {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=' . (isset($charset_of_file) ? $charset_of_file : 'utf-8') . '" />
</head>
<body>');
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return PMA_exportOutputHandler('<h1>' . __('Database') . ' ' . htmlspecialchars($db) . '</h1>');
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in HTML (Microsoft Word) format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
if (! PMA_exportOutputHandler('<h2>' . __('Dumping data for table') . ' ' . htmlspecialchars($table) . '</h2>')) {
return false;
}
if (! PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return false;
}
} // end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '<tr class="print-category">';
for ($j = 0; $j < $fields_cnt; $j++) {
if (! isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j];
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line
if (isset($GLOBALS['htmlword_columns'])) {
$schema_insert = '<tr class="print-category">';
for ($i = 0; $i < $fields_cnt; $i++) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
} // end for
$schema_insert .= '</tr>';
if (! PMA_exportOutputHandler($schema_insert)) {
return false;
}
} // end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '<tr class="print-category">';
for ($j = 0; $j < $fields_cnt; $j++) {
if (! isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j];
} else {
$value = '';
}
$schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>';
} // end for
$schema_insert .= '</tr>';
if (! PMA_exportOutputHandler($schema_insert)) {
return false;
}
} // end while
PMA_DBI_free_result($result);
if (! PMA_exportOutputHandler('</table>')) {
return false;
}
return true;
}
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
if (! PMA_exportOutputHandler('<h2>' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '</h2>')) {
return false;
}
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && ! empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$value = '';
$have_rel = false;
}
$schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>';
} // end for
$schema_insert .= '</tr>';
if (! PMA_exportOutputHandler($schema_insert)) {
} else {
$have_rel = false;
} // end if
/**
* Displays the table structure
*/
if (! PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return false;
}
} // end while
PMA_DBI_free_result($result);
if (! PMA_exportOutputHandler('</table>')) {
return false;
}
return true;
}
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
if (! PMA_exportOutputHandler('<h2>' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '</h2>')) {
return false;
}
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && ! empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
} // end if
/**
* Displays the table structure
*/
if (! PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return false;
}
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$columns_cnt++;
}
if ($do_comments && $cfgRelation['commwork']) {
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
}
$schema_insert = '<tr class="print-category">';
$schema_insert .= '<th class="print">' . htmlspecialchars(__('Column')) . '</th>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Type')) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Null')) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Default')) . '</b></td>';
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Links to')) . '</b></td>';
}
if ($do_comments) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Comments')) . '</b></td>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars('MIME') . '</b></td>';
$mime_map = PMA_getMIME($db, $table, true);
}
$schema_insert .= '</tr>';
if (! PMA_exportOutputHandler($schema_insert)) {
return false;
}
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$schema_insert = '<tr class="print-category">';
$type = $column['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$attribute = '&nbsp;';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
}
}
$fmt_pre = '';
$fmt_post = '';
if (in_array($column['Field'], $unique_keys)) {
$fmt_pre = '<b>' . $fmt_pre;
$fmt_post = $fmt_post . '</b>';
}
if ($column['Key'] == 'PRI') {
$fmt_pre = '<i>' . $fmt_pre;
$fmt_post = $fmt_post . '</i>';
}
$schema_insert .= '<td class="print">' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars($type) . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '') . '</td>';
$field_name = $column['Field'];
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print">' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '') . '</td>';
$columns_cnt++;
}
if ($do_comments && $cfgRelation['commwork']) {
$schema_insert .= '<td class="print">' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '') . '</td>';
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print">' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '') . '</td>';
$columns_cnt++;
}
$schema_insert = '<tr class="print-category">';
$schema_insert .= '<th class="print">' . htmlspecialchars(__('Column')) . '</th>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Type')) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Null')) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Default')) . '</b></td>';
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Links to')) . '</b></td>';
}
if ($do_comments) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Comments')) . '</b></td>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars('MIME') . '</b></td>';
$mime_map = PMA_getMIME($db, $table, true);
}
$schema_insert .= '</tr>';
if (! PMA_exportOutputHandler($schema_insert)) {
return false;
}
} // end while
return PMA_exportOutputHandler('</table>');
}
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$schema_insert = '<tr class="print-category">';
$type = $column['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$attribute = '&nbsp;';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
}
}
$fmt_pre = '';
$fmt_post = '';
if (in_array($column['Field'], $unique_keys)) {
$fmt_pre = '<b>' . $fmt_pre;
$fmt_post = $fmt_post . '</b>';
}
if ($column['Key'] == 'PRI') {
$fmt_pre = '<i>' . $fmt_pre;
$fmt_post = $fmt_post . '</i>';
}
$schema_insert .= '<td class="print">' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars($type) . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '') . '</td>';
$field_name = $column['Field'];
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print">' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '') . '</td>';
}
if ($do_comments && $cfgRelation['commwork']) {
$schema_insert .= '<td class="print">' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '') . '</td>';
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print">' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '') . '</td>';
}
$schema_insert .= '</tr>';
if (! PMA_exportOutputHandler($schema_insert)) {
return false;
}
} // end while
return PMA_exportOutputHandler('</table>');
}
}
?>

View File

@ -30,144 +30,144 @@ if (isset($plugin_list)) {
);
} else {
/**
* Set of functions used to build exports of tables
*/
/**
* Set of functions used to build exports of tables
*/
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
PMA_exportOutputHandler(
'/**' . $GLOBALS['crlf']
. ' Export to JSON plugin for PHPMyAdmin' . $GLOBALS['crlf']
. ' @version 0.1' . $GLOBALS['crlf']
. ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
);
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
PMA_exportOutputHandler('// Database \'' . $db . '\'' . $GLOBALS['crlf'] );
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs the content of a table in JSON format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
return true;
}
unset($i);
$buffer = '';
$record_cnt = 0;
while ($record = PMA_DBI_fetch_row($result)) {
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
PMA_exportOutputHandler(
'/**' . $GLOBALS['crlf']
. ' Export to JSON plugin for PHPMyAdmin' . $GLOBALS['crlf']
. ' @version 0.1' . $GLOBALS['crlf']
. ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
);
return true;
}
$record_cnt++;
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
PMA_exportOutputHandler('// Database \'' . $db . '\'' . $GLOBALS['crlf'] );
return true;
}
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
$buffer .= '// ' . $db . '.' . $table . $crlf . $crlf;
$buffer .= '[{';
} else {
$buffer .= ', {';
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs the content of a table in JSON format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
}
unset($i);
$isLastLine = ($i + 1 >= $columns_cnt);
$buffer = '';
$record_cnt = 0;
while ($record = PMA_DBI_fetch_row($result)) {
$column = $columns[$i];
$record_cnt++;
if (is_null($record[$i])) {
$buffer .= '"' . addslashes($column) . '": null' . (! $isLastLine ? ',' : '');
} elseif (is_numeric($record[$i])) {
$buffer .= '"' . addslashes($column) . '": ' . $record[$i] . (! $isLastLine ? ',' : '');
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
$buffer .= '// ' . $db . '.' . $table . $crlf . $crlf;
$buffer .= '[{';
} else {
$buffer .= '"' . addslashes($column) . '": "' . addslashes($record[$i]) . '"' . (! $isLastLine ? ',' : '');
$buffer .= ', {';
}
for ($i = 0; $i < $columns_cnt; $i++) {
$isLastLine = ($i + 1 >= $columns_cnt);
$column = $columns[$i];
if (is_null($record[$i])) {
$buffer .= '"' . addslashes($column) . '": null' . (! $isLastLine ? ',' : '');
} elseif (is_numeric($record[$i])) {
$buffer .= '"' . addslashes($column) . '": ' . $record[$i] . (! $isLastLine ? ',' : '');
} else {
$buffer .= '"' . addslashes($column) . '": "' . addslashes($record[$i]) . '"' . (! $isLastLine ? ',' : '');
}
}
$buffer .= '}';
}
$buffer .= '}';
}
if ($record_cnt) {
$buffer .= ']';
}
if (! PMA_exportOutputHandler($buffer)) {
return false;
}
if ($record_cnt) {
$buffer .= ']';
}
if (! PMA_exportOutputHandler($buffer)) {
return false;
}
PMA_DBI_free_result($result);
PMA_DBI_free_result($result);
return true;
}
return true;
}
}

View File

@ -82,389 +82,389 @@ if (isset($plugin_list)) {
array('type' => 'end_group');
} else {
/**
* Escapes some special characters for use in TeX/LaTeX
*
* @param string the string to convert
*
* @return string the converted string with escape codes
*
* @access private
*/
function PMA_texEscape($string) {
$escape = array('$', '%', '{', '}', '&', '#', '_', '^');
$cnt_escape = count($escape);
for ($k=0; $k < $cnt_escape; $k++) {
$string = str_replace($escape[$k], '\\' . $escape[$k], $string);
}
return $string;
}
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $crlf;
global $cfg;
$head = '% phpMyAdmin LaTeX Dump' . $crlf
. '% version ' . PMA_VERSION . $crlf
. '% http://www.phpmyadmin.net' . $crlf
. '%' . $crlf
. '% ' . __('Host') . ': ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. '% ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
. '% ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
. '% ' . __('PHP Version') . ': ' . phpversion() . $crlf;
return PMA_exportOutputHandler($head);
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
global $crlf;
$head = '% ' . $crlf
. '% ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. '% ' . $crlf;
return PMA_exportOutputHandler($head);
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in LaTeX table/sideways table environment
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = PMA_DBI_field_name($result, $i);
}
unset($i);
$buffer = $crlf . '%' . $crlf . '% ' . __('Data') . ': ' . $table . $crlf . '%' . $crlf
. ' \\begin{longtable}{|';
for ($index=0;$index<$columns_cnt;$index++) {
$buffer .= 'l|';
}
$buffer .= '} ' . $crlf ;
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf;
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . PMA_expandUserString($GLOBALS['latex_data_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db))
. '} \\label{' . PMA_expandUserString($GLOBALS['latex_data_label'], NULL, array('table' => $table, 'database' => $db)) . '} \\\\';
}
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
// show column names
if (isset($GLOBALS['latex_columns'])) {
$buffer = '\\hline ';
for ($i = 0; $i < $columns_cnt; $i++) {
$buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . PMA_texEscape(stripslashes($columns[$i])) . '}} & ';
}
$buffer = substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
return false;
/**
* Escapes some special characters for use in TeX/LaTeX
*
* @param string the string to convert
*
* @return string the converted string with escape codes
*
* @access private
*/
function PMA_texEscape($string) {
$escape = array('$', '%', '{', '}', '&', '#', '_', '^');
$cnt_escape = count($escape);
for ($k=0; $k < $cnt_escape; $k++) {
$string = str_replace($escape[$k], '\\' . $escape[$k], $string);
}
return $string;
}
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $crlf;
global $cfg;
$head = '% phpMyAdmin LaTeX Dump' . $crlf
. '% version ' . PMA_VERSION . $crlf
. '% http://www.phpmyadmin.net' . $crlf
. '%' . $crlf
. '% ' . __('Host') . ': ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. '% ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
. '% ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
. '% ' . __('PHP Version') . ': ' . phpversion() . $crlf;
return PMA_exportOutputHandler($head);
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
global $crlf;
$head = '% ' . $crlf
. '% ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. '% ' . $crlf;
return PMA_exportOutputHandler($head);
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in LaTeX table/sideways table environment
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = PMA_DBI_field_name($result, $i);
}
unset($i);
$buffer = $crlf . '%' . $crlf . '% ' . __('Data') . ': ' . $table . $crlf . '%' . $crlf
. ' \\begin{longtable}{|';
for ($index=0;$index<$columns_cnt;$index++) {
$buffer .= 'l|';
}
$buffer .= '} ' . $crlf ;
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf;
if (isset($GLOBALS['latex_caption'])) {
if (!PMA_exportOutputHandler('\\caption{' . PMA_expandUserString($GLOBALS['latex_data_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\\\ ')) return false;
$buffer .= ' \\caption{' . PMA_expandUserString($GLOBALS['latex_data_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db))
. '} \\label{' . PMA_expandUserString($GLOBALS['latex_data_label'], NULL, array('table' => $table, 'database' => $db)) . '} \\\\';
}
if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
return false;
}
} else {
if (!PMA_exportOutputHandler('\\\\ \hline')) {
return false;
}
}
// print the whole table
while ($record = PMA_DBI_fetch_assoc($result)) {
$buffer = '';
// print each row
for ($i = 0; $i < $columns_cnt; $i++) {
if (isset($record[$columns[$i]])
&& (! function_exists('is_null') || !is_null($record[$columns[$i]]))) {
$column_value = PMA_texEscape(stripslashes($record[$columns[$i]]));
} else {
$column_value = $GLOBALS['latex_null'];
}
// last column ... no need for & character
if ($i == ($columns_cnt - 1)) {
$buffer .= $column_value;
} else {
$buffer .= $column_value . " & ";
}
}
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
}
$buffer = ' \\end{longtable}' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
// show column names
if (isset($GLOBALS['latex_columns'])) {
$buffer = '\\hline ';
for ($i = 0; $i < $columns_cnt; $i++) {
$buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . PMA_texEscape(stripslashes($columns[$i])) . '}} & ';
}
PMA_DBI_free_result($result);
return true;
} // end getTableLaTeX
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
} // end if
/**
* Displays the table structure
*/
$buffer = $crlf . '%' . $crlf . '% ' . __('Structure') . ': ' . $table . $crlf . '%' . $crlf
. ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
$columns_cnt = 4;
$alignment = '|l|c|c|c|';
if ($do_relation && $have_rel) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_comments) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
$alignment .='l|';
}
$buffer = $alignment . '} ' . $crlf ;
$header = ' \\hline ';
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . __('Column') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Type') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Null') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Default') . '}}';
if ($do_relation && $have_rel) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Links to') . '}}';
}
if ($do_comments) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Comments') . '}}';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
$mime_map = PMA_getMIME($db, $table, true);
}
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'. PMA_expandUserString($GLOBALS['latex_structure_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db))
. '} \\label{' . PMA_expandUserString($GLOBALS['latex_structure_label'], NULL, array('table' => $table, 'database' => $db))
. '} \\\\' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'. PMA_expandUserString($GLOBALS['latex_structure_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db))
. '} \\\\ ' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
$fields = PMA_DBI_get_columns($db, $table);
foreach ($fields as $row) {
$type = $row['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
$buffer = substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
return false;
}
$binary = preg_match('/BINARY/i', $row['Type']);
$unsigned = preg_match('/UNSIGNED/i', $row['Type']);
$zerofill = preg_match('/ZEROFILL/i', $row['Type']);
}
if (!isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL';
if (isset($GLOBALS['latex_caption'])) {
if (!PMA_exportOutputHandler('\\caption{' . PMA_expandUserString($GLOBALS['latex_data_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\\\ ')) return false;
}
if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
return false;
}
} else {
if (!PMA_exportOutputHandler('\\\\ \hline')) {
return false;
}
}
$field_name = $row['Field'];
// print the whole table
while ($record = PMA_DBI_fetch_assoc($result)) {
$local_buffer = $field_name . "\000" . $type . "\000"
. (($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes'))
. "\000" . (isset($row['Default']) ? $row['Default'] : '');
$buffer = '';
// print each row
for ($i = 0; $i < $columns_cnt; $i++) {
if (isset($record[$columns[$i]])
&& (! function_exists('is_null') || !is_null($record[$columns[$i]]))) {
$column_value = PMA_texEscape(stripslashes($record[$columns[$i]]));
} else {
$column_value = $GLOBALS['latex_null'];
}
// last column ... no need for & character
if ($i == ($columns_cnt - 1)) {
$buffer .= $column_value;
} else {
$buffer .= $column_value . " & ";
}
}
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
}
$buffer = ' \\end{longtable}' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
PMA_DBI_free_result($result);
return true;
} // end getTableLaTeX
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
} // end if
/**
* Displays the table structure
*/
$buffer = $crlf . '%' . $crlf . '% ' . __('Structure') . ': ' . $table . $crlf . '%' . $crlf
. ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
$columns_cnt = 4;
$alignment = '|l|c|c|c|';
if ($do_relation && $have_rel) {
$local_buffer .= "\000";
if (isset($res_rel[$field_name])) {
$local_buffer .= $res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')';
}
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_comments && $cfgRelation['commwork']) {
$local_buffer .= "\000";
if (isset($comments[$field_name])) {
$local_buffer .= $comments[$field_name];
}
if ($do_comments) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_mime && $cfgRelation['mimework']) {
$local_buffer .= "\000";
if (isset($mime_map[$field_name])) {
$local_buffer .= str_replace('_', '/', $mime_map[$field_name]['mimetype']);
}
$columns_cnt++;
$alignment .='l|';
}
$local_buffer = PMA_texEscape($local_buffer);
if ($row['Key']=='PRI') {
$pos=strpos($local_buffer, "\000");
$local_buffer = '\\textit{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
$buffer = $alignment . '} ' . $crlf ;
$header = ' \\hline ';
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . __('Column') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Type') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Null') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Default') . '}}';
if ($do_relation && $have_rel) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Links to') . '}}';
}
if (in_array($field_name, $unique_keys)) {
$pos=strpos($local_buffer, "\000");
$local_buffer = '\\textbf{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
if ($do_comments) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Comments') . '}}';
$comments = PMA_getComments($db, $table);
}
$buffer = str_replace("\000", ' & ', $local_buffer);
$buffer .= ' \\\\ \\hline ' . $crlf;
if ($do_mime && $cfgRelation['mimework']) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
$mime_map = PMA_getMIME($db, $table, true);
}
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'. PMA_expandUserString($GLOBALS['latex_structure_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db))
. '} \\label{' . PMA_expandUserString($GLOBALS['latex_structure_label'], NULL, array('table' => $table, 'database' => $db))
. '} \\\\' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'. PMA_expandUserString($GLOBALS['latex_structure_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db))
. '} \\\\ ' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
} // end while
$buffer = ' \\end{longtable}' . $crlf;
return PMA_exportOutputHandler($buffer);
} // end of the 'PMA_exportStructure' function
$fields = PMA_DBI_get_columns($db, $table);
foreach ($fields as $row) {
$type = $row['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $row['Type']);
$unsigned = preg_match('/UNSIGNED/i', $row['Type']);
$zerofill = preg_match('/ZEROFILL/i', $row['Type']);
}
if (!isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL';
}
}
$field_name = $row['Field'];
$local_buffer = $field_name . "\000" . $type . "\000"
. (($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes'))
. "\000" . (isset($row['Default']) ? $row['Default'] : '');
if ($do_relation && $have_rel) {
$local_buffer .= "\000";
if (isset($res_rel[$field_name])) {
$local_buffer .= $res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')';
}
}
if ($do_comments && $cfgRelation['commwork']) {
$local_buffer .= "\000";
if (isset($comments[$field_name])) {
$local_buffer .= $comments[$field_name];
}
}
if ($do_mime && $cfgRelation['mimework']) {
$local_buffer .= "\000";
if (isset($mime_map[$field_name])) {
$local_buffer .= str_replace('_', '/', $mime_map[$field_name]['mimetype']);
}
}
$local_buffer = PMA_texEscape($local_buffer);
if ($row['Key']=='PRI') {
$pos=strpos($local_buffer, "\000");
$local_buffer = '\\textit{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
}
if (in_array($field_name, $unique_keys)) {
$pos=strpos($local_buffer, "\000");
$local_buffer = '\\textbf{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
}
$buffer = str_replace("\000", ' & ', $local_buffer);
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
} // end while
$buffer = ' \\end{longtable}' . $crlf;
return PMA_exportOutputHandler($buffer);
} // end of the 'PMA_exportStructure' function
} // end else
?>

View File

@ -24,136 +24,136 @@ if (isset($plugin_list)) {
);
} else {
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in MediaWiki format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$columns = PMA_DBI_get_columns($db, $table);
$columns = array_values($columns);
$row_cnt = count($columns);
$output = "{| cellpadding=\"10\" cellspacing=\"0\" border=\"1\" style=\"text-align:center;\"\n";
$output .= "|+'''" . $table . "'''\n";
$output .= "|- style=\"background:#ffdead;\"\n";
$output .= "! style=\"background:#ffffff\" | \n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Field'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return true;
}
$output .= "\n";
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Type\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Type'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
return true;
}
$output .= "\n";
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Null\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Null'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
$output .= "\n";
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Default\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Default'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
$output .= "\n";
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Extra\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Extra'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
$output .= "\n";
$output .= "|}\n\n\n\n";
return PMA_exportOutputHandler($output);
}
/**
* Outputs the content of a table in MediaWiki format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$columns = PMA_DBI_get_columns($db, $table);
$columns = array_values($columns);
$row_cnt = count($columns);
$output = "{| cellpadding=\"10\" cellspacing=\"0\" border=\"1\" style=\"text-align:center;\"\n";
$output .= "|+'''" . $table . "'''\n";
$output .= "|- style=\"background:#ffdead;\"\n";
$output .= "! style=\"background:#ffffff\" | \n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Field'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
}
$output .= "\n";
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Type\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Type'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
}
$output .= "\n";
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Null\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Null'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
}
$output .= "\n";
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Default\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Default'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
}
$output .= "\n";
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Extra\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $columns[$i]['Extra'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
}
$output .= "\n";
$output .= "|}\n\n\n\n";
return PMA_exportOutputHandler($output);
}
}
?>

View File

@ -30,192 +30,192 @@ if (isset($plugin_list)) {
);
} else {
$GLOBALS['ods_buffer'] = '';
require_once './libraries/opendocument.lib.php';
$GLOBALS['ods_buffer'] = '';
require_once './libraries/opendocument.lib.php';
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
$GLOBALS['ods_buffer'] .= '</office:spreadsheet>'
. '</office:body>'
. '</office:document-content>';
if (!PMA_exportOutputHandler(PMA_createOpenDocument('application/vnd.oasis.opendocument.spreadsheet', $GLOBALS['ods_buffer']))) {
return false;
}
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
$GLOBALS['ods_buffer'] .= '<?xml version="1.0" encoding="utf-8"?' . '>'
. '<office:document-content '. $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">'
. '<office:automatic-styles>'
. '<number:date-style style:name="N37" number:automatic-order="true">'
. '<number:month number:style="long"/>'
. '<number:text>/</number:text>'
. '<number:day number:style="long"/>'
. '<number:text>/</number:text>'
. '<number:year/>'
. '</number:date-style>'
. '<number:time-style style:name="N43">'
. '<number:hours number:style="long"/>'
. '<number:text>:</number:text>'
. '<number:minutes number:style="long"/>'
. '<number:text>:</number:text>'
. '<number:seconds number:style="long"/>'
. '<number:text> </number:text>'
. '<number:am-pm/>'
. '</number:time-style>'
. '<number:date-style style:name="N50" number:automatic-order="true" number:format-source="language">'
. '<number:month/>'
. '<number:text>/</number:text>'
. '<number:day/>'
. '<number:text>/</number:text>'
. '<number:year/>'
. '<number:text> </number:text>'
. '<number:hours number:style="long"/>'
. '<number:text>:</number:text>'
. '<number:minutes number:style="long"/>'
. '<number:text> </number:text>'
. '<number:am-pm/>'
. '</number:date-style>'
. '<style:style style:name="DateCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N37"/>'
. '<style:style style:name="TimeCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N43"/>'
. '<style:style style:name="DateTimeCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N50"/>'
. '</office:automatic-styles>'
. '<office:body>'
. '<office:spreadsheet>';
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in ODS format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
$fields_meta = PMA_DBI_get_fields_meta($result);
$field_flags = array();
for ($j = 0; $j < $fields_cnt; $j++) {
$field_flags[$j] = PMA_DBI_field_flags($result, $j);
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
$GLOBALS['ods_buffer'] .= '</office:spreadsheet>'
. '</office:body>'
. '</office:document-content>';
if (!PMA_exportOutputHandler(PMA_createOpenDocument('application/vnd.oasis.opendocument.spreadsheet', $GLOBALS['ods_buffer']))) {
return false;
}
return true;
}
$GLOBALS['ods_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '">';
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
$GLOBALS['ods_buffer'] .= '<?xml version="1.0" encoding="utf-8"?' . '>'
. '<office:document-content '. $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">'
. '<office:automatic-styles>'
. '<number:date-style style:name="N37" number:automatic-order="true">'
. '<number:month number:style="long"/>'
. '<number:text>/</number:text>'
. '<number:day number:style="long"/>'
. '<number:text>/</number:text>'
. '<number:year/>'
. '</number:date-style>'
. '<number:time-style style:name="N43">'
. '<number:hours number:style="long"/>'
. '<number:text>:</number:text>'
. '<number:minutes number:style="long"/>'
. '<number:text>:</number:text>'
. '<number:seconds number:style="long"/>'
. '<number:text> </number:text>'
. '<number:am-pm/>'
. '</number:time-style>'
. '<number:date-style style:name="N50" number:automatic-order="true" number:format-source="language">'
. '<number:month/>'
. '<number:text>/</number:text>'
. '<number:day/>'
. '<number:text>/</number:text>'
. '<number:year/>'
. '<number:text> </number:text>'
. '<number:hours number:style="long"/>'
. '<number:text>:</number:text>'
. '<number:minutes number:style="long"/>'
. '<number:text> </number:text>'
. '<number:am-pm/>'
. '</number:date-style>'
. '<style:style style:name="DateCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N37"/>'
. '<style:style style:name="TimeCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N43"/>'
. '<style:style style:name="DateTimeCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N50"/>'
. '</office:automatic-styles>'
. '<office:body>'
. '<office:spreadsheet>';
return true;
}
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$GLOBALS['ods_buffer'] .= '<table:table-row>';
for ($i = 0; $i < $fields_cnt; $i++) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>'
. '</table:table-cell>';
} // end for
$GLOBALS['ods_buffer'] .= '</table:table-row>';
} // end if
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$GLOBALS['ods_buffer'] .= '<table:table-row>';
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in ODS format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
$fields_meta = PMA_DBI_get_fields_meta($result);
$field_flags = array();
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>'
. '</table:table-cell>';
// ignore BLOB
} elseif (stristr($field_flags[$j], 'BINARY')
&& $fields_meta[$j]->blob) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p></text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "date") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d", strtotime($row[$j])) . '" table:style-name="DateCell">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "time") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="time" office:time-value="' . date("\P\TH\Hi\Ms\S", strtotime($row[$j])) . '" table:style-name="TimeCell">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "datetime") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d\TH:i:s", strtotime($row[$j])) . '" table:style-name="DateTimeCell">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && ! $fields_meta[$j]->blob) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} else {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
}
} // end for
$GLOBALS['ods_buffer'] .= '</table:table-row>';
} // end while
PMA_DBI_free_result($result);
$field_flags[$j] = PMA_DBI_field_flags($result, $j);
}
$GLOBALS['ods_buffer'] .= '</table:table>';
$GLOBALS['ods_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '">';
return true;
}
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$GLOBALS['ods_buffer'] .= '<table:table-row>';
for ($i = 0; $i < $fields_cnt; $i++) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>'
. '</table:table-cell>';
} // end for
$GLOBALS['ods_buffer'] .= '</table:table-row>';
} // end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$GLOBALS['ods_buffer'] .= '<table:table-row>';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>'
. '</table:table-cell>';
// ignore BLOB
} elseif (stristr($field_flags[$j], 'BINARY')
&& $fields_meta[$j]->blob) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p></text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "date") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d", strtotime($row[$j])) . '" table:style-name="DateCell">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "time") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="time" office:time-value="' . date("\P\TH\Hi\Ms\S", strtotime($row[$j])) . '" table:style-name="TimeCell">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "datetime") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d\TH:i:s", strtotime($row[$j])) . '" table:style-name="DateTimeCell">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && ! $fields_meta[$j]->blob) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} else {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
}
} // end for
$GLOBALS['ods_buffer'] .= '</table:table-row>';
} // end while
PMA_DBI_free_result($result);
$GLOBALS['ods_buffer'] .= '</table:table>';
return true;
}
}
?>

View File

@ -62,345 +62,345 @@ if (isset($plugin_list)) {
array('type' => 'end_group');
} else {
$GLOBALS['odt_buffer'] = '';
require_once './libraries/opendocument.lib.php';
$GLOBALS['odt_buffer'] = '';
require_once './libraries/opendocument.lib.php';
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
$GLOBALS['odt_buffer'] .= '</office:text>'
. '</office:body>'
. '</office:document-content>';
if (!PMA_exportOutputHandler(PMA_createOpenDocument('application/vnd.oasis.opendocument.text', $GLOBALS['odt_buffer']))) {
return false;
}
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
$GLOBALS['odt_buffer'] .= '<?xml version="1.0" encoding="utf-8"?' . '>'
. '<office:document-content '. $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">'
. '<office:body>'
. '<office:text>';
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="1" text:style-name="Heading_1" text:is-list-header="true">' . htmlspecialchars(__('Database') . ' ' . $db) . '</text:h>';
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in ODT format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
$fields_meta = PMA_DBI_get_fields_meta($result);
$field_flags = array();
for ($j = 0; $j < $fields_cnt; $j++) {
$field_flags[$j] = PMA_DBI_field_flags($result, $j);
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
$GLOBALS['odt_buffer'] .= '</office:text>'
. '</office:body>'
. '</office:document-content>';
if (!PMA_exportOutputHandler(PMA_createOpenDocument('application/vnd.oasis.opendocument.text', $GLOBALS['odt_buffer']))) {
return false;
}
return true;
}
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Dumping data for table') . ' ' . $table) . '</text:h>';
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_structure">';
$GLOBALS['odt_buffer'] .= '<table:table-column table:number-columns-repeated="' . $fields_cnt . '"/>';
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
$GLOBALS['odt_buffer'] .= '<?xml version="1.0" encoding="utf-8"?' . '>'
. '<office:document-content '. $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">'
. '<office:body>'
. '<office:text>';
return true;
}
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$GLOBALS['odt_buffer'] .= '<table:table-row>';
for ($i = 0; $i < $fields_cnt; $i++) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>'
. '</table:table-cell>';
} // end for
$GLOBALS['odt_buffer'] .= '</table:table-row>';
} // end if
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="1" text:style-name="Heading_1" text:is-list-header="true">' . htmlspecialchars(__('Database') . ' ' . $db) . '</text:h>';
return true;
}
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$GLOBALS['odt_buffer'] .= '<table:table-row>';
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in ODT format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
$fields_meta = PMA_DBI_get_fields_meta($result);
$field_flags = array();
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$field_flags[$j] = PMA_DBI_field_flags($result, $j);
}
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Dumping data for table') . ' ' . $table) . '</text:h>';
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_structure">';
$GLOBALS['odt_buffer'] .= '<table:table-column table:number-columns-repeated="' . $fields_cnt . '"/>';
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$GLOBALS['odt_buffer'] .= '<table:table-row>';
for ($i = 0; $i < $fields_cnt; $i++) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>'
. '</table:table-cell>';
// ignore BLOB
} elseif (stristr($field_flags[$j], 'BINARY')
&& $fields_meta[$j]->blob) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p></text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && ! $fields_meta[$j]->blob) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>'
. '</table:table-cell>';
} // end for
$GLOBALS['odt_buffer'] .= '</table:table-row>';
} // end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$GLOBALS['odt_buffer'] .= '<table:table-row>';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>'
. '</table:table-cell>';
// ignore BLOB
} elseif (stristr($field_flags[$j], 'BINARY')
&& $fields_meta[$j]->blob) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p></text:p>'
. '</table:table-cell>';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && ! $fields_meta[$j]->blob) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
}
} // end for
$GLOBALS['odt_buffer'] .= '</table:table-row>';
} // end while
PMA_DBI_free_result($result);
$GLOBALS['odt_buffer'] .= '</table:table>';
return true;
}
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
/* Heading */
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Table structure for table') . ' ' . $table) . '</text:h>';
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
. '</table:table-cell>';
}
} // end for
$GLOBALS['odt_buffer'] .= '</table:table-row>';
} // end while
PMA_DBI_free_result($result);
$GLOBALS['odt_buffer'] .= '</table:table>';
return true;
}
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
/* Heading */
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Table structure for table') . ' ' . $table) . '</text:h>';
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
} // end if
/**
* Displays the table structure
*/
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_data">';
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$columns_cnt++;
}
if ($do_comments) {
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
}
$GLOBALS['odt_buffer'] .= '<table:table-column table:number-columns-repeated="' . $columns_cnt . '"/>';
/* Header */
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Column')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Type')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Null')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Default')) . '</text:p>'
. '</table:table-cell>';
if ($do_relation && $have_rel) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Links to')) . '</text:p>'
. '</table:table-cell>';
}
if ($do_comments) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Comments')) . '</text:p>'
. '</table:table-cell>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('MIME type')) . '</text:p>'
. '</table:table-cell>';
$mime_map = PMA_getMIME($db, $table, true);
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$field_name = $column['Field'];
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($field_name) . '</text:p>'
. '</table:table-cell>';
// reformat mysql query output
// set or enum types: slashes single quotes inside options
$type = $column['Type'];
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($type) . '</text:p>'
. '</table:table-cell>';
if (!isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
} else {
$column['Default'] = '';
$have_rel = false;
}
} else {
$column['Default'] = $column['Default'];
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($column['Default']) . '</text:p>'
. '</table:table-cell>';
$have_rel = false;
} // end if
/**
* Displays the table structure
*/
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_data">';
$columns_cnt = 4;
if ($do_relation && $have_rel) {
if (isset($res_rel[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') . '</text:p>'
. '</table:table-cell>';
}
$columns_cnt++;
}
if ($do_comments) {
if (isset($comments[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($comments[$field_name]) . '</text:p>'
. '</table:table-cell>';
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p></text:p>'
. '</table:table-cell>';
}
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
if (isset($mime_map[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) . '</text:p>'
. '</table:table-cell>';
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p></text:p>'
. '</table:table-cell>';
}
$columns_cnt++;
}
$GLOBALS['odt_buffer'] .= '<table:table-column table:number-columns-repeated="' . $columns_cnt . '"/>';
/* Header */
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Column')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Type')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Null')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Default')) . '</text:p>'
. '</table:table-cell>';
if ($do_relation && $have_rel) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Links to')) . '</text:p>'
. '</table:table-cell>';
}
if ($do_comments) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Comments')) . '</text:p>'
. '</table:table-cell>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('MIME type')) . '</text:p>'
. '</table:table-cell>';
$mime_map = PMA_getMIME($db, $table, true);
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';
} // end while
$GLOBALS['odt_buffer'] .= '</table:table>';
return true;
} // end of the 'PMA_exportStructure' function
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$field_name = $column['Field'];
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($field_name) . '</text:p>'
. '</table:table-cell>';
// reformat mysql query output
// set or enum types: slashes single quotes inside options
$type = $column['Type'];
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($type) . '</text:p>'
. '</table:table-cell>';
if (!isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
} else {
$column['Default'] = '';
}
} else {
$column['Default'] = $column['Default'];
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($column['Default']) . '</text:p>'
. '</table:table-cell>';
if ($do_relation && $have_rel) {
if (isset($res_rel[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') . '</text:p>'
. '</table:table-cell>';
}
}
if ($do_comments) {
if (isset($comments[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($comments[$field_name]) . '</text:p>'
. '</table:table-cell>';
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p></text:p>'
. '</table:table-cell>';
}
}
if ($do_mime && $cfgRelation['mimework']) {
if (isset($mime_map[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) . '</text:p>'
. '</table:table-cell>';
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p></text:p>'
. '</table:table-cell>';
}
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';
} // end while
$GLOBALS['odt_buffer'] .= '</table:table>';
return true;
} // end of the 'PMA_exportStructure' function
} // end else
?>

View File

@ -30,441 +30,441 @@ if (isset($plugin_list)) {
);
} else {
/**
* Font used in PDF.
*
* @todo Make this configuratble (at least Sans/Serif).
*/
define('PMA_PDF_FONT', 'DejaVuSans');
require_once './libraries/tcpdf/tcpdf.php';
/**
* Font used in PDF.
*
* @todo Make this configuratble (at least Sans/Serif).
*/
define('PMA_PDF_FONT', 'DejaVuSans');
require_once './libraries/tcpdf/tcpdf.php';
/**
* Adapted from a LGPL script by Philip Clarke
* @package phpMyAdmin-Export
* @subpackage PDF
*/
class PMA_PDF extends TCPDF
{
var $tablewidths;
var $headerset;
var $footerset;
/**
* Adapted from a LGPL script by Philip Clarke
* @package phpMyAdmin-Export
* @subpackage PDF
*/
class PMA_PDF extends TCPDF
{
var $tablewidths;
var $headerset;
var $footerset;
function checkPageBreak($h=0, $y='', $addpage=true) {
if ($this->empty_string($y)) {
$y = $this->y;
}
$current_page = $this->page;
if ((($y + $h) > $this->PageBreakTrigger) AND (!$this->InFooter) AND ($this->AcceptPageBreak())) {
if ($addpage) {
//Automatic page break
$x = $this->x;
$this->AddPage($this->CurOrientation);
$this->y = $this->dataY;
$oldpage = $this->page - 1;
if ($this->rtl) {
if ($this->pagedim[$this->page]['orm'] != $this->pagedim[$oldpage]['orm']) {
$this->x = $x - ($this->pagedim[$this->page]['orm'] - $this->pagedim[$oldpage]['orm']);
function checkPageBreak($h=0, $y='', $addpage=true) {
if ($this->empty_string($y)) {
$y = $this->y;
}
$current_page = $this->page;
if ((($y + $h) > $this->PageBreakTrigger) AND (!$this->InFooter) AND ($this->AcceptPageBreak())) {
if ($addpage) {
//Automatic page break
$x = $this->x;
$this->AddPage($this->CurOrientation);
$this->y = $this->dataY;
$oldpage = $this->page - 1;
if ($this->rtl) {
if ($this->pagedim[$this->page]['orm'] != $this->pagedim[$oldpage]['orm']) {
$this->x = $x - ($this->pagedim[$this->page]['orm'] - $this->pagedim[$oldpage]['orm']);
} else {
$this->x = $x;
}
} else {
$this->x = $x;
}
} else {
if ($this->pagedim[$this->page]['olm'] != $this->pagedim[$oldpage]['olm']) {
$this->x = $x + ($this->pagedim[$this->page]['olm'] - $this->pagedim[$oldpage]['olm']);
} else {
$this->x = $x;
if ($this->pagedim[$this->page]['olm'] != $this->pagedim[$oldpage]['olm']) {
$this->x = $x + ($this->pagedim[$this->page]['olm'] - $this->pagedim[$oldpage]['olm']);
} else {
$this->x = $x;
}
}
}
return true;
}
return true;
if ($current_page != $this->page) {
// account for columns mode
return true;
}
return false;
}
if ($current_page != $this->page) {
// account for columns mode
return true;
}
return false;
}
function Header()
{
global $maxY;
// Check if header for this page already exists
if (!isset($this->headerset[$this->page])) {
function Header()
{
global $maxY;
// Check if header for this page already exists
if (!isset($this->headerset[$this->page])) {
$fullwidth = 0;
foreach ($this->tablewidths as $width) {
$fullwidth += $width;
}
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*3);
$this->cellFontSize = $this->FontSizePt ;
$this->SetFont(PMA_PDF_FONT, '', ($this->titleFontSize ? $this->titleFontSize : $this->FontSizePt));
$this->Cell(0, $this->FontSizePt, $this->titleText, 0, 1, 'C');
$this->SetFont(PMA_PDF_FONT, '', $this->cellFontSize);
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*1.5);
$this->Cell(0, $this->FontSizePt, __('Database') .': ' .$this->currentDb .', ' .__('Table') .': ' .$this->currentTable, 0, 1, 'L');
$l = ($this->lMargin);
foreach ($this->colTitles as $col => $txt) {
$this->SetXY($l, ($this->tMargin));
$this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt);
$l += $this->tablewidths[$col] ;
$maxY = ($maxY < $this->getY()) ? $this->getY() : $maxY ;
}
$this->SetXY($this->lMargin, $this->tMargin);
$this->setFillColor(200, 200, 200);
$l = ($this->lMargin);
foreach ($this->colTitles as $col => $txt) {
$this->SetXY($l, $this->tMargin);
$this->cell($this->tablewidths[$col], $maxY-($this->tMargin), '', 1, 0, 'L', 1);
$this->SetXY($l, $this->tMargin);
$this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt, 0, 'C');
$l += $this->tablewidths[$col];
}
$this->setFillColor(255, 255, 255);
// set headerset
$this->headerset[$this->page] = 1;
}
$this->dataY = $maxY;
}
function Footer()
{
// Check if footer for this page already exists
if (!isset($this->footerset[$this->page])) {
$this->SetY(-15);
//Page number
$this->setFooterFont(PMA_PDF_FONT, '', 14);
$this->Cell(0, 6, __('Page number:') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
// set footerset
$this->footerset[$this->page] = 1;
}
}
function morepagestable($lineheight=8)
{
// some things to set and 'remember'
$l = $this->lMargin;
$startheight = $h = $this->dataY;
$startpage = $currpage = $this->page;
// calculate the whole width
$fullwidth = 0;
foreach ($this->tablewidths as $width) {
$fullwidth += $width;
}
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*3);
$this->cellFontSize = $this->FontSizePt ;
$this->SetFont(PMA_PDF_FONT, '', ($this->titleFontSize ? $this->titleFontSize : $this->FontSizePt));
$this->Cell(0, $this->FontSizePt, $this->titleText, 0, 1, 'C');
$this->SetFont(PMA_PDF_FONT, '', $this->cellFontSize);
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*1.5);
$this->Cell(0, $this->FontSizePt, __('Database') .': ' .$this->currentDb .', ' .__('Table') .': ' .$this->currentTable, 0, 1, 'L');
$l = ($this->lMargin);
foreach ($this->colTitles as $col => $txt) {
$this->SetXY($l, ($this->tMargin));
$this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt);
$l += $this->tablewidths[$col] ;
$maxY = ($maxY < $this->getY()) ? $this->getY() : $maxY ;
}
$this->SetXY($this->lMargin, $this->tMargin);
$this->setFillColor(200, 200, 200);
$l = ($this->lMargin);
foreach ($this->colTitles as $col => $txt) {
$this->SetXY($l, $this->tMargin);
$this->cell($this->tablewidths[$col], $maxY-($this->tMargin), '', 1, 0, 'L', 1);
$this->SetXY($l, $this->tMargin);
$this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt, 0, 'C');
$l += $this->tablewidths[$col];
}
$this->setFillColor(255, 255, 255);
// set headerset
$this->headerset[$this->page] = 1;
}
$this->dataY = $maxY;
}
// Now let's start to write the table
$row = 0;
$tmpheight = array();
$maxpage = $this->page;
function Footer()
{
// Check if footer for this page already exists
if (!isset($this->footerset[$this->page])) {
$this->SetY(-15);
//Page number
$this->setFooterFont(PMA_PDF_FONT, '', 14);
$this->Cell(0, 6, __('Page number:') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
// set footerset
$this->footerset[$this->page] = 1;
}
}
function morepagestable($lineheight=8)
{
// some things to set and 'remember'
$l = $this->lMargin;
$startheight = $h = $this->dataY;
$startpage = $currpage = $this->page;
// calculate the whole width
$fullwidth = 0;
foreach ($this->tablewidths as $width) {
$fullwidth += $width;
}
// Now let's start to write the table
$row = 0;
$tmpheight = array();
$maxpage = $this->page;
while ($data = PMA_DBI_fetch_row($this->results)) {
$this->page = $currpage;
// write the horizontal borders
$this->Line($l, $h, $fullwidth+$l, $h);
// write the content and remember the height of the highest col
foreach ($data as $col => $txt) {
while ($data = PMA_DBI_fetch_row($this->results)) {
$this->page = $currpage;
$this->SetXY($l, $h);
if ($this->tablewidths[$col] > 0) {
$this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, $this->colAlign[$col]);
$l += $this->tablewidths[$col];
// write the horizontal borders
$this->Line($l, $h, $fullwidth+$l, $h);
// write the content and remember the height of the highest col
foreach ($data as $col => $txt) {
$this->page = $currpage;
$this->SetXY($l, $h);
if ($this->tablewidths[$col] > 0) {
$this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, $this->colAlign[$col]);
$l += $this->tablewidths[$col];
}
if (!isset($tmpheight[$row.'-'.$this->page])) {
$tmpheight[$row.'-'.$this->page] = 0;
}
if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
$tmpheight[$row.'-'.$this->page] = $this->GetY();
}
if ($this->page > $maxpage) {
$maxpage = $this->page;
}
unset($data[$col]);
}
if (!isset($tmpheight[$row.'-'.$this->page])) {
$tmpheight[$row.'-'.$this->page] = 0;
}
if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
$tmpheight[$row.'-'.$this->page] = $this->GetY();
}
if ($this->page > $maxpage) {
$maxpage = $this->page;
}
unset($data[$col]);
// get the height we were in the last used page
$h = $tmpheight[$row.'-'.$maxpage];
// set the "pointer" to the left margin
$l = $this->lMargin;
// set the $currpage to the last page
$currpage = $maxpage;
unset($data[$row]);
$row++;
}
// get the height we were in the last used page
$h = $tmpheight[$row.'-'.$maxpage];
// set the "pointer" to the left margin
$l = $this->lMargin;
// set the $currpage to the last page
$currpage = $maxpage;
unset($data[$row]);
$row++;
}
// draw the borders
// we start adding a horizontal line on the last page
$this->page = $maxpage;
$this->Line($l, $h, $fullwidth+$l, $h);
// now we start at the top of the document and walk down
for ($i = $startpage; $i <= $maxpage; $i++) {
$this->page = $i;
$l = $this->lMargin;
$t = ($i == $startpage) ? $startheight : $this->tMargin;
$lh = ($i == $maxpage) ? $h : $this->h-$this->bMargin;
$this->Line($l, $t, $l, $lh);
foreach ($this->tablewidths as $width) {
$l += $width;
// draw the borders
// we start adding a horizontal line on the last page
$this->page = $maxpage;
$this->Line($l, $h, $fullwidth+$l, $h);
// now we start at the top of the document and walk down
for ($i = $startpage; $i <= $maxpage; $i++) {
$this->page = $i;
$l = $this->lMargin;
$t = ($i == $startpage) ? $startheight : $this->tMargin;
$lh = ($i == $maxpage) ? $h : $this->h-$this->bMargin;
$this->Line($l, $t, $l, $lh);
}
}
// set it to the last page, if not it'll cause some problems
$this->page = $maxpage;
}
function setAttributes($attr = array())
{
foreach ($attr as $key => $val) {
$this->$key = $val ;
}
}
function setTopMargin($topMargin)
{
$this->tMargin = $topMargin;
}
function mysql_report($query)
{
unset($this->tablewidths);
unset($this->colTitles);
unset($this->titleWidth);
unset($this->colFits);
unset($this->display_column);
unset($this->colAlign);
/**
* Pass 1 for column widths
*/
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
$this->numFields = PMA_DBI_num_fields($this->results);
$this->fields = PMA_DBI_get_fields_meta($this->results);
// sColWidth = starting col width (an average size width)
$availableWidth = $this->w - $this->lMargin - $this->rMargin;
$this->sColWidth = $availableWidth / $this->numFields;
$totalTitleWidth = 0;
// loop through results header and set initial col widths/ titles/ alignment
// if a col title is less than the starting col width, reduce that column size
for ($i = 0; $i < $this->numFields; $i++) {
$stringWidth = $this->getstringwidth($this->fields[$i]->name) + 6 ;
// save the real title's width
$titleWidth[$i] = $stringWidth;
$totalTitleWidth += $stringWidth;
// set any column titles less than the start width to the column title width
if ($stringWidth < $this->sColWidth) {
$colFits[$i] = $stringWidth ;
}
$this->colTitles[$i] = $this->fields[$i]->name;
$this->display_column[$i] = true;
switch ($this->fields[$i]->type) {
case 'int':
$this->colAlign[$i] = 'R';
break;
case 'blob':
case 'tinyblob':
case 'mediumblob':
case 'longblob':
/**
* @todo do not deactivate completely the display
* but show the field's name and [BLOB]
*/
if (stristr($this->fields[$i]->flags, 'BINARY')) {
$this->display_column[$i] = false;
unset($this->colTitles[$i]);
foreach ($this->tablewidths as $width) {
$l += $width;
$this->Line($l, $t, $l, $lh);
}
$this->colAlign[$i] = 'L';
break;
default:
$this->colAlign[$i] = 'L';
}
// set it to the last page, if not it'll cause some problems
$this->page = $maxpage;
}
function setAttributes($attr = array())
{
foreach ($attr as $key => $val) {
$this->$key = $val ;
}
}
// title width verification
if ($totalTitleWidth > $availableWidth) {
$adjustingMode = true;
} else {
$adjustingMode = false;
// we have enough space for all the titles at their
// original width so use the true title's width
foreach ($titleWidth as $key => $val) {
$colFits[$key] = $val;
}
function setTopMargin($topMargin)
{
$this->tMargin = $topMargin;
}
// loop through the data; any column whose contents
// is greater than the column size is resized
/**
* @todo force here a LIMIT to avoid reading all rows
*/
while ($row = PMA_DBI_fetch_row($this->results)) {
foreach ($colFits as $key => $val) {
$stringWidth = $this->getstringwidth($row[$key]) + 6 ;
if ($adjustingMode && ($stringWidth > $this->sColWidth)) {
// any column whose data's width is bigger than the start width is now discarded
unset($colFits[$key]);
} else {
// if data's width is bigger than the current column width,
// enlarge the column (but avoid enlarging it if the
// data's width is very big)
if ($stringWidth > $val && $stringWidth < ($this->sColWidth * 3)) {
$colFits[$key] = $stringWidth ;
function mysql_report($query)
{
unset($this->tablewidths);
unset($this->colTitles);
unset($this->titleWidth);
unset($this->colFits);
unset($this->display_column);
unset($this->colAlign);
/**
* Pass 1 for column widths
*/
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
$this->numFields = PMA_DBI_num_fields($this->results);
$this->fields = PMA_DBI_get_fields_meta($this->results);
// sColWidth = starting col width (an average size width)
$availableWidth = $this->w - $this->lMargin - $this->rMargin;
$this->sColWidth = $availableWidth / $this->numFields;
$totalTitleWidth = 0;
// loop through results header and set initial col widths/ titles/ alignment
// if a col title is less than the starting col width, reduce that column size
for ($i = 0; $i < $this->numFields; $i++) {
$stringWidth = $this->getstringwidth($this->fields[$i]->name) + 6 ;
// save the real title's width
$titleWidth[$i] = $stringWidth;
$totalTitleWidth += $stringWidth;
// set any column titles less than the start width to the column title width
if ($stringWidth < $this->sColWidth) {
$colFits[$i] = $stringWidth ;
}
$this->colTitles[$i] = $this->fields[$i]->name;
$this->display_column[$i] = true;
switch ($this->fields[$i]->type) {
case 'int':
$this->colAlign[$i] = 'R';
break;
case 'blob':
case 'tinyblob':
case 'mediumblob':
case 'longblob':
/**
* @todo do not deactivate completely the display
* but show the field's name and [BLOB]
*/
if (stristr($this->fields[$i]->flags, 'BINARY')) {
$this->display_column[$i] = false;
unset($this->colTitles[$i]);
}
$this->colAlign[$i] = 'L';
break;
default:
$this->colAlign[$i] = 'L';
}
}
// title width verification
if ($totalTitleWidth > $availableWidth) {
$adjustingMode = true;
} else {
$adjustingMode = false;
// we have enough space for all the titles at their
// original width so use the true title's width
foreach ($titleWidth as $key => $val) {
$colFits[$key] = $val;
}
}
// loop through the data; any column whose contents
// is greater than the column size is resized
/**
* @todo force here a LIMIT to avoid reading all rows
*/
while ($row = PMA_DBI_fetch_row($this->results)) {
foreach ($colFits as $key => $val) {
$stringWidth = $this->getstringwidth($row[$key]) + 6 ;
if ($adjustingMode && ($stringWidth > $this->sColWidth)) {
// any column whose data's width is bigger than the start width is now discarded
unset($colFits[$key]);
} else {
// if data's width is bigger than the current column width,
// enlarge the column (but avoid enlarging it if the
// data's width is very big)
if ($stringWidth > $val && $stringWidth < ($this->sColWidth * 3)) {
$colFits[$key] = $stringWidth ;
}
}
}
}
}
$totAlreadyFitted = 0;
foreach ($colFits as $key => $val) {
// set fitted columns to smallest size
$this->tablewidths[$key] = $val;
// to work out how much (if any) space has been freed up
$totAlreadyFitted += $val;
}
if ($adjustingMode) {
$surplus = (sizeof($colFits) * $this->sColWidth) - $totAlreadyFitted;
$surplusToAdd = $surplus / ($this->numFields - sizeof($colFits));
} else {
$surplusToAdd = 0;
}
for ($i=0; $i < $this->numFields; $i++) {
if (!in_array($i, array_keys($colFits))) {
$this->tablewidths[$i] = $this->sColWidth + $surplusToAdd;
$totAlreadyFitted = 0;
foreach ($colFits as $key => $val) {
// set fitted columns to smallest size
$this->tablewidths[$key] = $val;
// to work out how much (if any) space has been freed up
$totAlreadyFitted += $val;
}
if ($this->display_column[$i] == false) {
$this->tablewidths[$i] = 0;
if ($adjustingMode) {
$surplus = (sizeof($colFits) * $this->sColWidth) - $totAlreadyFitted;
$surplusToAdd = $surplus / ($this->numFields - sizeof($colFits));
} else {
$surplusToAdd = 0;
}
for ($i=0; $i < $this->numFields; $i++) {
if (!in_array($i, array_keys($colFits))) {
$this->tablewidths[$i] = $this->sColWidth + $surplusToAdd;
}
if ($this->display_column[$i] == false) {
$this->tablewidths[$i] = 0;
}
}
ksort($this->tablewidths);
PMA_DBI_free_result($this->results);
// Pass 2
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
$this->setY($this->tMargin);
$this->AddPage();
$this->morepagestable($this->FontSizePt);
PMA_DBI_free_result($this->results);
} // end of mysql_report function
} // end of PMA_PDF class
$pdf = new PMA_PDF('L', 'pt', 'A3');
/**
* Finalize the pdf.
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
global $pdf;
// instead of $pdf->Output():
if (!PMA_exportOutputHandler($pdf->getPDFData())) {
return false;
}
ksort($this->tablewidths);
PMA_DBI_free_result($this->results);
// Pass 2
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
$this->setY($this->tMargin);
$this->AddPage();
$this->morepagestable($this->FontSizePt);
PMA_DBI_free_result($this->results);
} // end of mysql_report function
} // end of PMA_PDF class
$pdf = new PMA_PDF('L', 'pt', 'A3');
/**
* Finalize the pdf.
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
global $pdf;
// instead of $pdf->Output():
if (!PMA_exportOutputHandler($pdf->getPDFData())) {
return false;
return true;
}
return true;
}
/**
* Initialize the pdf to export data.
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
global $pdf_report_title;
global $pdf;
/**
* Initialize the pdf to export data.
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
global $pdf_report_title;
global $pdf;
$pdf->AddFont('DejaVuSans', '', 'dejavusans.php');
$pdf->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
$pdf->AddFont('DejaVuSerif', '', 'dejavuserif.php');
$pdf->AddFont('DejaVuSerif', 'B', 'dejavuserifb.php');
$pdf->SetFont(PMA_PDF_FONT, '', 11.5);
$pdf->setFooterFont(array(PMA_PDF_FONT, '', 11.5));
$pdf->AliasNbPages();
$pdf->Open();
$pdf->AddFont('DejaVuSans', '', 'dejavusans.php');
$pdf->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
$pdf->AddFont('DejaVuSerif', '', 'dejavuserif.php');
$pdf->AddFont('DejaVuSerif', 'B', 'dejavuserifb.php');
$pdf->SetFont(PMA_PDF_FONT, '', 11.5);
$pdf->setFooterFont(array(PMA_PDF_FONT, '', 11.5));
$pdf->AliasNbPages();
$pdf->Open();
$attr=array('titleFontSize' => 18, 'titleText' => $pdf_report_title);
$pdf->setAttributes($attr);
$pdf->setTopMargin(45);
$attr=array('titleFontSize' => 18, 'titleText' => $pdf_report_title);
$pdf->setAttributes($attr);
$pdf->setTopMargin(45);
return true;
}
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs the content of a table in PDF format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $pdf;
/**
* Outputs the content of a table in PDF format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $pdf;
$attr=array('currentDb' => $db, 'currentTable' => $table);
$pdf->setAttributes($attr);
$pdf->mysql_report($sql_query);
$attr=array('currentDb' => $db, 'currentTable' => $table);
$pdf->setAttributes($attr);
$pdf->mysql_report($sql_query);
return true;
} // end of the 'PMA_exportData()' function
return true;
} // end of the 'PMA_exportData()' function
}
?>

View File

@ -30,134 +30,134 @@ if (isset($plugin_list)) {
);
} else {
/**
* Set of functions used to build exports of tables
*/
/**
* Set of functions used to build exports of tables
*/
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
PMA_exportOutputHandler(
'<?php' . $GLOBALS['crlf']
. '/**' . $GLOBALS['crlf']
. ' * Export to PHP Array plugin for PHPMyAdmin' . $GLOBALS['crlf']
. ' * @version 0.2b' . $GLOBALS['crlf']
. ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
);
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
PMA_exportOutputHandler('//' . $GLOBALS['crlf'] . '// Database "' . $db . '"' . $GLOBALS['crlf'] . '//' . $GLOBALS['crlf']);
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs the content of a table as a fragment of PHP code
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
return true;
}
unset($i);
$buffer = '';
$record_cnt = 0;
while ($record = PMA_DBI_fetch_row($result)) {
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
PMA_exportOutputHandler(
'<?php' . $GLOBALS['crlf']
. '/**' . $GLOBALS['crlf']
. ' * Export to PHP Array plugin for PHPMyAdmin' . $GLOBALS['crlf']
. ' * @version 0.2b' . $GLOBALS['crlf']
. ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
);
return true;
}
$record_cnt++;
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
PMA_exportOutputHandler('//' . $GLOBALS['crlf'] . '// Database "' . $db . '"' . $GLOBALS['crlf'] . '//' . $GLOBALS['crlf']);
return true;
}
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
$buffer .= $crlf . '// ' . $db . '.' . $table . $crlf;
$buffer .= '$' . $table . ' = array(' . $crlf;
$buffer .= ' array(';
} else {
$buffer .= ',' . $crlf . ' array(';
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs the content of a table as a fragment of PHP code
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$buffer .= "'" . $columns[$i]. "'=>" . var_export($record[$i], true) . (($i + 1 >= $columns_cnt) ? '' : ',');
$columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
}
unset($i);
$buffer = '';
$record_cnt = 0;
while ($record = PMA_DBI_fetch_row($result)) {
$record_cnt++;
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
$buffer .= $crlf . '// ' . $db . '.' . $table . $crlf;
$buffer .= '$' . $table . ' = array(' . $crlf;
$buffer .= ' array(';
} else {
$buffer .= ',' . $crlf . ' array(';
}
for ($i = 0; $i < $columns_cnt; $i++) {
$buffer .= "'" . $columns[$i]. "'=>" . var_export($record[$i], true) . (($i + 1 >= $columns_cnt) ? '' : ',');
}
$buffer .= ')';
}
$buffer .= ')';
$buffer .= $crlf . ');' . $crlf;
if (! PMA_exportOutputHandler($buffer)) {
return false;
}
PMA_DBI_free_result($result);
return true;
}
$buffer .= $crlf . ');' . $crlf;
if (! PMA_exportOutputHandler($buffer)) {
return false;
}
PMA_DBI_free_result($result);
return true;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -32,302 +32,302 @@ if (isset($plugin_list)) {
);
} else {
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return PMA_exportOutputHandler('===' . __('Database') . ' ' . $db . "\n\n");
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in Texy format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
if (! PMA_exportOutputHandler('== ' . __('Dumping data for table') . ' ' . $table . "\n\n")) {
return false;
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return true;
}
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
return true;
}
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$text_output = "|------\n";
for ($i = 0; $i < $fields_cnt; $i++) {
$text_output .= '|' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i)));
} // end for
$text_output .= "\n|------\n";
if (! PMA_exportOutputHandler($text_output)) {
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return PMA_exportOutputHandler('===' . __('Database') . ' ' . $db . "\n\n");
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in Texy format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
if (! PMA_exportOutputHandler('== ' . __('Dumping data for table') . ' ' . $table . "\n\n")) {
return false;
}
} // end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$text_output = '';
for ($j = 0; $j < $fields_cnt; $j++) {
if (! isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j];
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$text_output = "|------\n";
for ($i = 0; $i < $fields_cnt; $i++) {
$text_output .= '|' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i)));
} // end for
$text_output .= "\n|------\n";
if (! PMA_exportOutputHandler($text_output)) {
return false;
}
} // end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$text_output = '';
for ($j = 0; $j < $fields_cnt; $j++) {
if (! isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j];
} else {
$value = ' ';
}
$text_output .= '|' . htmlspecialchars($value);
} // end for
$text_output .= "\n";
if (! PMA_exportOutputHandler($text_output)) {
return false;
}
} // end while
PMA_DBI_free_result($result);
return true;
}
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
if (! PMA_exportOutputHandler('== ' . __('Table structure for table') . ' ' .$table . "\n\n")) {
return false;
}
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && ! empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$value = ' ';
$have_rel = false;
}
$text_output .= '|' . htmlspecialchars($value);
} // end for
$text_output .= "\n";
if (! PMA_exportOutputHandler($text_output)) {
return false;
}
} // end while
PMA_DBI_free_result($result);
return true;
}
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
if (! PMA_exportOutputHandler('== ' . __('Table structure for table') . ' ' .$table . "\n\n")) {
return false;
}
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && ! empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
} // end if
$have_rel = false;
} // end if
/**
* Displays the table structure
*/
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$columns_cnt++;
}
if ($do_comments && $cfgRelation['commwork']) {
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
}
$text_output = "|------\n";
$text_output .= '|' . htmlspecialchars(__('Column'));
$text_output .= '|' . htmlspecialchars(__('Type'));
$text_output .= '|' . htmlspecialchars(__('Null'));
$text_output .= '|' . htmlspecialchars(__('Default'));
if ($do_relation && $have_rel) {
$text_output .= '|' . htmlspecialchars(__('Links to'));
}
if ($do_comments) {
$text_output .= '|' . htmlspecialchars(__('Comments'));
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$text_output .= '|' . htmlspecialchars('MIME');
$mime_map = PMA_getMIME($db, $table, true);
}
$text_output .= "\n|------\n";
if (! PMA_exportOutputHandler($text_output)) {
return false;
}
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$text_output = '';
$type = $column['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$attribute = '&nbsp;';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
}
}
$fmt_pre = '';
$fmt_post = '';
if (in_array($column['Field'], $unique_keys)) {
$fmt_pre = '**' . $fmt_pre;
$fmt_post = $fmt_post . '**';
}
if ($column['Key']=='PRI') {
$fmt_pre = '//' . $fmt_pre;
$fmt_post = $fmt_post . '//';
}
$text_output .= '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
$text_output .= '|' . htmlspecialchars($type);
$text_output .= '|' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
$text_output .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
$field_name = $column['Field'];
/**
* Displays the table structure
*/
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$text_output .= '|' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '');
$columns_cnt++;
}
if ($do_comments && $cfgRelation['commwork']) {
$text_output .= '|' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '');
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$text_output .= '|' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '');
$columns_cnt++;
}
$text_output .= "\n";
$text_output = "|------\n";
$text_output .= '|' . htmlspecialchars(__('Column'));
$text_output .= '|' . htmlspecialchars(__('Type'));
$text_output .= '|' . htmlspecialchars(__('Null'));
$text_output .= '|' . htmlspecialchars(__('Default'));
if ($do_relation && $have_rel) {
$text_output .= '|' . htmlspecialchars(__('Links to'));
}
if ($do_comments) {
$text_output .= '|' . htmlspecialchars(__('Comments'));
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$text_output .= '|' . htmlspecialchars('MIME');
$mime_map = PMA_getMIME($db, $table, true);
}
$text_output .= "\n|------\n";
if (! PMA_exportOutputHandler($text_output)) {
return false;
}
} // end while
return true;
}
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$text_output = '';
$type = $column['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$attribute = '&nbsp;';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
}
}
$fmt_pre = '';
$fmt_post = '';
if (in_array($column['Field'], $unique_keys)) {
$fmt_pre = '**' . $fmt_pre;
$fmt_post = $fmt_post . '**';
}
if ($column['Key']=='PRI') {
$fmt_pre = '//' . $fmt_pre;
$fmt_post = $fmt_post . '//';
}
$text_output .= '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
$text_output .= '|' . htmlspecialchars($type);
$text_output .= '|' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
$text_output .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
$field_name = $column['Field'];
if ($do_relation && $have_rel) {
$text_output .= '|' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '');
}
if ($do_comments && $cfgRelation['commwork']) {
$text_output .= '|' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '');
}
if ($do_mime && $cfgRelation['mimework']) {
$text_output .= '|' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '');
}
$text_output .= "\n";
if (! PMA_exportOutputHandler($text_output)) {
return false;
}
} // end while
return true;
}
}
?>

View File

@ -30,164 +30,164 @@ if (isset($plugin_list)) {
);
} else {
/* Append the PHPExcel directory to the include path variable */
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/PHPExcel/');
/* Append the PHPExcel directory to the include path variable */
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/PHPExcel/');
require_once './libraries/PHPExcel/PHPExcel.php';
require_once './libraries/PHPExcel/PHPExcel/Writer/Excel5.php';
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
global $workbook;
global $tmp_filename;
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_');
$workbookWriter = new PHPExcel_Writer_Excel5($workbook);
$workbookWriter->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
$workbookWriter->save($tmp_filename);
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
return false;
}
unlink($tmp_filename);
unset($GLOBALS['workbook']);
unset($GLOBALS['sheet_index']);
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $db;
/* Initialize the workbook */
$GLOBALS['workbook'] = new PHPExcel();
$GLOBALS['sheet_index'] = 0;
global $workbook;
$workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
$workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
$workbook->getProperties()->setTitle($db);
$workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLS Dump');
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in XLS format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $workbook;
global $sheet_index;
require_once './libraries/PHPExcel/PHPExcel.php';
require_once './libraries/PHPExcel/PHPExcel/Writer/Excel5.php';
/**
* Get the data from the database using the original query
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
$result = PMA_DBI_fetch_result($sql_query);
$row_cnt = count($result);
function PMA_exportFooter() {
global $workbook;
global $tmp_filename;
if ($row_cnt > 0) {
$col_names = array_keys($result[0]);
$fields_cnt = count($result[0]);
$row_offset = 1;
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_');
/* Only one sheet is created on workbook initialization */
if ($sheet_index > 0) {
$workbook->createSheet();
$workbookWriter = new PHPExcel_Writer_Excel5($workbook);
$workbookWriter->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
$workbookWriter->save($tmp_filename);
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
return false;
}
$workbook->setActiveSheetIndex($sheet_index);
$workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
unlink($tmp_filename);
if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns']) {
for ($i = 0; $i < $fields_cnt; ++$i) {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
}
$row_offset++;
}
unset($GLOBALS['workbook']);
unset($GLOBALS['sheet_index']);
for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
for ($c = 0; $c < $fields_cnt; ++$c) {
if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $GLOBALS['xls_null']);
} elseif ($result[$r][$col_names[$c]] == '0' || $result[$r][$col_names[$c]] != '') {
/**
* @todo we should somehow handle character set here!
*/
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $result[$r][$col_names[$c]]);
} else {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), '');
}
}
}
$sheet_index++;
return true;
}
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $db;
/* Initialize the workbook */
$GLOBALS['workbook'] = new PHPExcel();
$GLOBALS['sheet_index'] = 0;
global $workbook;
$workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
$workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
$workbook->getProperties()->setTitle($db);
$workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLS Dump');
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in XLS format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $workbook;
global $sheet_index;
/**
* Get the data from the database using the original query
*/
$result = PMA_DBI_fetch_result($sql_query);
$row_cnt = count($result);
if ($row_cnt > 0) {
$col_names = array_keys($result[0]);
$fields_cnt = count($result[0]);
$row_offset = 1;
/* Only one sheet is created on workbook initialization */
if ($sheet_index > 0) {
$workbook->createSheet();
}
$workbook->setActiveSheetIndex($sheet_index);
$workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns']) {
for ($i = 0; $i < $fields_cnt; ++$i) {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
}
$row_offset++;
}
for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
for ($c = 0; $c < $fields_cnt; ++$c) {
if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $GLOBALS['xls_null']);
} elseif ($result[$r][$col_names[$c]] == '0' || $result[$r][$col_names[$c]] != '') {
/**
* @todo we should somehow handle character set here!
*/
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $result[$r][$col_names[$c]]);
} else {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), '');
}
}
}
$sheet_index++;
}
return true;
}
}
?>

View File

@ -30,163 +30,163 @@ if (isset($plugin_list)) {
);
} else {
/* Append the PHPExcel directory to the include path variable */
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/PHPExcel/');
/* Append the PHPExcel directory to the include path variable */
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/PHPExcel/');
require_once './libraries/PHPExcel/PHPExcel.php';
require_once './libraries/PHPExcel/PHPExcel/Writer/Excel2007.php';
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
global $workbook;
global $tmp_filename;
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xlsx_');
$workbookWriter = new PHPExcel_Writer_Excel2007($workbook);
$workbookWriter->save($tmp_filename);
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
return false;
}
unlink($tmp_filename);
unset($GLOBALS['workbook']);
unset($GLOBALS['sheet_index']);
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $db;
/* Initialize the workbook */
$GLOBALS['workbook'] = new PHPExcel();
$GLOBALS['sheet_index'] = 0;
global $workbook;
$workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
$workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
$workbook->getProperties()->setTitle($db);
$workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLSX Dump');
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in XLSX format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $workbook;
global $sheet_index;
require_once './libraries/PHPExcel/PHPExcel.php';
require_once './libraries/PHPExcel/PHPExcel/Writer/Excel2007.php';
/**
* Get the data from the database using the original query
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
$result = PMA_DBI_fetch_result($sql_query);
$row_cnt = count($result);
function PMA_exportFooter() {
global $workbook;
global $tmp_filename;
if ($row_cnt > 0) {
$col_names = array_keys($result[0]);
$fields_cnt = count($result[0]);
$row_offset = 1;
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xlsx_');
/* Only one sheet is created on workbook initialization */
if ($sheet_index > 0) {
$workbook->createSheet();
$workbookWriter = new PHPExcel_Writer_Excel2007($workbook);
$workbookWriter->save($tmp_filename);
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
return false;
}
$workbook->setActiveSheetIndex($sheet_index);
$workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
unlink($tmp_filename);
if (isset($GLOBALS['xlsx_columns']) && $GLOBALS['xlsx_columns']) {
for ($i = 0; $i < $fields_cnt; ++$i) {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
}
$row_offset++;
}
unset($GLOBALS['workbook']);
unset($GLOBALS['sheet_index']);
for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
for ($c = 0; $c < $fields_cnt; ++$c) {
if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $GLOBALS['xlsx_null']);
} elseif ($result[$r][$col_names[$c]] == '0' || $result[$r][$col_names[$c]] != '') {
/**
* @todo we should somehow handle character set here!
*/
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $result[$r][$col_names[$c]]);
} else {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), '');
}
}
}
$sheet_index++;
return true;
}
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $db;
/* Initialize the workbook */
$GLOBALS['workbook'] = new PHPExcel();
$GLOBALS['sheet_index'] = 0;
global $workbook;
$workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
$workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
$workbook->getProperties()->setTitle($db);
$workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLSX Dump');
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
/**
* Outputs the content of a table in XLSX format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $workbook;
global $sheet_index;
/**
* Get the data from the database using the original query
*/
$result = PMA_DBI_fetch_result($sql_query);
$row_cnt = count($result);
if ($row_cnt > 0) {
$col_names = array_keys($result[0]);
$fields_cnt = count($result[0]);
$row_offset = 1;
/* Only one sheet is created on workbook initialization */
if ($sheet_index > 0) {
$workbook->createSheet();
}
$workbook->setActiveSheetIndex($sheet_index);
$workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
if (isset($GLOBALS['xlsx_columns']) && $GLOBALS['xlsx_columns']) {
for ($i = 0; $i < $fields_cnt; ++$i) {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
}
$row_offset++;
}
for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
for ($c = 0; $c < $fields_cnt; ++$c) {
if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $GLOBALS['xlsx_null']);
} elseif ($result[$r][$col_names[$c]] == '0' || $result[$r][$col_names[$c]] != '') {
/**
* @todo we should somehow handle character set here!
*/
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $result[$r][$col_names[$c]]);
} else {
$workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), '');
}
}
}
$sheet_index++;
}
return true;
}
}
?>

View File

@ -48,295 +48,295 @@ if (isset($plugin_list)) {
$plugin_list['xml']['options'][] = array('type' => 'end_group');
} else {
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
$foot = '</pma_xml_export>';
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
$foot = '</pma_xml_export>';
return PMA_exportOutputHandler($foot);
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $crlf;
global $cfg;
global $db;
global $table;
global $tables;
$export_struct = isset($GLOBALS['xml_export_functions']) || isset($GLOBALS['xml_export_procedures'])
|| isset($GLOBALS['xml_export_tables']) || isset($GLOBALS['xml_export_triggers'])
|| isset($GLOBALS['xml_export_views']);
$export_data = isset($GLOBALS['xml_export_contents']) ? true : false;
if ($GLOBALS['output_charset_conversion']) {
$charset = $GLOBALS['charset_of_file'];
} else {
$charset = 'utf-8';
return PMA_exportOutputHandler($foot);
}
$head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf
. '<!--' . $crlf
. '- phpMyAdmin XML Dump' . $crlf
. '- version ' . PMA_VERSION . $crlf
. '- http://www.phpmyadmin.net' . $crlf
. '-' . $crlf
. '- ' . __('Host') . ': ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. '- ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
. '- ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
. '- ' . __('PHP Version') . ': ' . phpversion() . $crlf
. '-->' . $crlf . $crlf;
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $crlf;
global $cfg;
global $db;
global $table;
global $tables;
$head .= '<pma_xml_export version="1.0"' . (($export_struct) ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf;
$export_struct = isset($GLOBALS['xml_export_functions']) || isset($GLOBALS['xml_export_procedures'])
|| isset($GLOBALS['xml_export_tables']) || isset($GLOBALS['xml_export_triggers'])
|| isset($GLOBALS['xml_export_views']);
$export_data = isset($GLOBALS['xml_export_contents']) ? true : false;
if ($export_struct) {
$result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \''.PMA_sqlAddSlashes($db).'\' LIMIT 1');
$db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
$db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
$head .= ' <!--' . $crlf;
$head .= ' - Structure schemas' . $crlf;
$head .= ' -->' . $crlf;
$head .= ' <pma:structure_schemas>' . $crlf;
$head .= ' <pma:database name="' . htmlspecialchars($db) . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf;
if (count($tables) == 0) {
$tables[] = $table;
if ($GLOBALS['output_charset_conversion']) {
$charset = $GLOBALS['charset_of_file'];
} else {
$charset = 'utf-8';
}
foreach ($tables as $table) {
// Export tables and views
$result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0);
$tbl = $result[$table][1];
$head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf
. '<!--' . $crlf
. '- phpMyAdmin XML Dump' . $crlf
. '- version ' . PMA_VERSION . $crlf
. '- http://www.phpmyadmin.net' . $crlf
. '-' . $crlf
. '- ' . __('Host') . ': ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. '- ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
. '- ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
. '- ' . __('PHP Version') . ': ' . phpversion() . $crlf
. '-->' . $crlf . $crlf;
$is_view = PMA_isView($db, $table);
$head .= '<pma_xml_export version="1.0"' . (($export_struct) ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf;
if ($is_view) {
$type = 'view';
} else {
$type = 'table';
}
if ($is_view && ! isset($GLOBALS['xml_export_views'])) {
continue;
}
if (! $is_view && ! isset($GLOBALS['xml_export_tables'])) {
continue;
if ($export_struct) {
$result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \''.PMA_sqlAddSlashes($db).'\' LIMIT 1');
$db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
$db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
$head .= ' <!--' . $crlf;
$head .= ' - Structure schemas' . $crlf;
$head .= ' -->' . $crlf;
$head .= ' <pma:structure_schemas>' . $crlf;
$head .= ' <pma:database name="' . htmlspecialchars($db) . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf;
if (count($tables) == 0) {
$tables[] = $table;
}
$head .= ' <pma:' . $type . ' name="' . $table . '">' . $crlf;
$tbl = " " . htmlspecialchars($tbl);
$tbl = str_replace("\n", "\n ", $tbl);
foreach ($tables as $table) {
// Export tables and views
$result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0);
$tbl = $result[$table][1];
$head .= $tbl . ';' . $crlf;
$head .= ' </pma:' . $type . '>' . $crlf;
if (isset($GLOBALS['xml_export_triggers']) && $GLOBALS['xml_export_triggers']) {
// Export triggers
$triggers = PMA_DBI_get_triggers($db, $table);
if ($triggers) {
foreach ($triggers as $trigger) {
$code = $trigger['create'];
$head .= ' <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
$is_view = PMA_isView($db, $table);
if ($is_view) {
$type = 'view';
} else {
$type = 'table';
}
if ($is_view && ! isset($GLOBALS['xml_export_views'])) {
continue;
}
if (! $is_view && ! isset($GLOBALS['xml_export_tables'])) {
continue;
}
$head .= ' <pma:' . $type . ' name="' . $table . '">' . $crlf;
$tbl = " " . htmlspecialchars($tbl);
$tbl = str_replace("\n", "\n ", $tbl);
$head .= $tbl . ';' . $crlf;
$head .= ' </pma:' . $type . '>' . $crlf;
if (isset($GLOBALS['xml_export_triggers']) && $GLOBALS['xml_export_triggers']) {
// Export triggers
$triggers = PMA_DBI_get_triggers($db, $table);
if ($triggers) {
foreach ($triggers as $trigger) {
$code = $trigger['create'];
$head .= ' <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
// Do some formatting
$code = substr(rtrim($code), 0, -3);
$code = " " . htmlspecialchars($code);
$code = str_replace("\n", "\n ", $code);
$head .= $code . $crlf;
$head .= ' </pma:trigger>' . $crlf;
}
unset($trigger);
unset($triggers);
}
}
}
if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
// Export functions
$functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($functions) {
foreach ($functions as $function) {
$head .= ' <pma:function name="' . $function . '">' . $crlf;
// Do some formatting
$code = substr(rtrim($code), 0, -3);
$code = " " . htmlspecialchars($code);
$code = str_replace("\n", "\n ", $code);
$sql = PMA_DBI_get_definition($db, 'FUNCTION', $function);
$sql = rtrim($sql);
$sql = " " . htmlspecialchars($sql);
$sql = str_replace("\n", "\n ", $sql);
$head .= $code . $crlf;
$head .= ' </pma:trigger>' . $crlf;
$head .= $sql . $crlf;
$head .= ' </pma:function>' . $crlf;
}
unset($trigger);
unset($triggers);
unset($create_func);
unset($function);
unset($functions);
}
}
}
if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
// Export functions
$functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($functions) {
foreach ($functions as $function) {
$head .= ' <pma:function name="' . $function . '">' . $crlf;
// Do some formatting
$sql = PMA_DBI_get_definition($db, 'FUNCTION', $function);
$sql = rtrim($sql);
$sql = " " . htmlspecialchars($sql);
$sql = str_replace("\n", "\n ", $sql);
if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
// Export procedures
$procedures = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
if ($procedures) {
foreach ($procedures as $procedure) {
$head .= ' <pma:procedure name="' . $procedure . '">' . $crlf;
$head .= $sql . $crlf;
$head .= ' </pma:function>' . $crlf;
// Do some formatting
$sql = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure);
$sql = rtrim($sql);
$sql = " " . htmlspecialchars($sql);
$sql = str_replace("\n", "\n ", $sql);
$head .= $sql . $crlf;
$head .= ' </pma:procedure>' . $crlf;
}
unset($create_proc);
unset($procedure);
unset($procedures);
}
unset($create_func);
unset($function);
unset($functions);
}
}
if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
// Export procedures
$procedures = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
if ($procedures) {
foreach ($procedures as $procedure) {
$head .= ' <pma:procedure name="' . $procedure . '">' . $crlf;
// Do some formatting
$sql = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure);
$sql = rtrim($sql);
$sql = " " . htmlspecialchars($sql);
$sql = str_replace("\n", "\n ", $sql);
unset($result);
$head .= $sql . $crlf;
$head .= ' </pma:procedure>' . $crlf;
}
$head .= ' </pma:database>' . $crlf;
$head .= ' </pma:structure_schemas>' . $crlf;
unset($create_proc);
unset($procedure);
unset($procedures);
if ($export_data) {
$head .= $crlf;
}
}
unset($result);
$head .= ' </pma:database>' . $crlf;
$head .= ' </pma:structure_schemas>' . $crlf;
if ($export_data) {
$head .= $crlf;
}
}
return PMA_exportOutputHandler($head);
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
global $crlf;
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$head = ' <!--' . $crlf
. ' - ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. ' -->' . $crlf
. ' <database name="' . htmlspecialchars($db) . '">' . $crlf;
return PMA_exportOutputHandler($head);
}
else
{
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
global $crlf;
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$head = ' <!--' . $crlf
. ' - ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. ' -->' . $crlf
. ' <database name="' . htmlspecialchars($db) . '">' . $crlf;
return PMA_exportOutputHandler($head);
}
else
{
return true;
}
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
global $crlf;
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
return PMA_exportOutputHandler(' </database>' . $crlf);
}
else
{
return true;
}
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
global $crlf;
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
return PMA_exportOutputHandler(' </database>' . $crlf);
}
else
{
return true;
}
}
/**
* Outputs the content of a table in XML format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return true;
}
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
/**
* Outputs the content of a table in XML format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
$columns = array();
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = stripslashes(str_replace(' ', '_', PMA_DBI_field_name($result, $i)));
}
unset($i);
$buffer = ' <!-- ' . __('Table') . ' ' . $table . ' -->' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
while ($record = PMA_DBI_fetch_row($result)) {
$buffer = ' <table name="' . htmlspecialchars($table) . '">' . $crlf;
$columns_cnt = PMA_DBI_num_fields($result);
$columns = array();
for ($i = 0; $i < $columns_cnt; $i++) {
// If a cell is NULL, still export it to preserve the XML structure
if (!isset($record[$i]) || is_null($record[$i])) {
$record[$i] = 'NULL';
}
$buffer .= ' <column name="' . htmlspecialchars($columns[$i]) . '">' . htmlspecialchars((string)$record[$i])
. '</column>' . $crlf;
$columns[$i] = stripslashes(str_replace(' ', '_', PMA_DBI_field_name($result, $i)));
}
$buffer .= ' </table>' . $crlf;
unset($i);
$buffer = ' <!-- ' . __('Table') . ' ' . $table . ' -->' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
}
PMA_DBI_free_result($result);
}
return true;
} // end of the 'PMA_getTableXML()' function
}
while ($record = PMA_DBI_fetch_row($result)) {
$buffer = ' <table name="' . htmlspecialchars($table) . '">' . $crlf;
for ($i = 0; $i < $columns_cnt; $i++) {
// If a cell is NULL, still export it to preserve the XML structure
if (!isset($record[$i]) || is_null($record[$i])) {
$record[$i] = 'NULL';
}
$buffer .= ' <column name="' . htmlspecialchars($columns[$i]) . '">' . htmlspecialchars((string)$record[$i])
. '</column>' . $crlf;
}
$buffer .= ' </table>' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
}
PMA_DBI_free_result($result);
}
return true;
} // end of the 'PMA_getTableXML()' function
}
}
?>

View File

@ -31,139 +31,139 @@ if (isset($plugin_list)) {
);
} else {
/**
* Set of functions used to build exports of tables
*/
/**
* Set of functions used to build exports of tables
*/
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
PMA_exportOutputHandler('...' . $GLOBALS['crlf']);
return true;
}
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
PMA_exportOutputHandler('%YAML 1.1' . $GLOBALS['crlf'] . '---' . $GLOBALS['crlf']);
return true;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs the content of a table in YAML format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
PMA_exportOutputHandler('...' . $GLOBALS['crlf']);
return true;
}
unset($i);
$buffer = '';
$record_cnt = 0;
while ($record = PMA_DBI_fetch_row($result)) {
$record_cnt++;
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
PMA_exportOutputHandler('%YAML 1.1' . $GLOBALS['crlf'] . '---' . $GLOBALS['crlf']);
return true;
}
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
$buffer = '# ' . $db . '.' . $table . $crlf;
$buffer .= '-' . $crlf;
} else {
$buffer = '-' . $crlf;
}
/**
* Outputs database header
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
return true;
}
/**
* Outputs database footer
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return true;
}
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return true;
}
/**
* Outputs the content of a table in YAML format
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param string $sql_query SQL query for obtaining data
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
if (! isset($record[$i])) {
continue;
}
$column = $columns[$i];
if (is_null($record[$i])) {
$buffer .= ' ' . $column . ': null' . $crlf;
continue;
}
if (is_numeric($record[$i])) {
$buffer .= ' ' . $column . ': ' . $record[$i] . $crlf;
continue;
}
$record[$i] = str_replace(array('\\', '"', "\n", "\r"), array('\\\\', '\"', '\n', '\r'), $record[$i]);
$buffer .= ' ' . $column . ': "' . $record[$i] . '"' . $crlf;
$columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
}
unset($i);
if (! PMA_exportOutputHandler($buffer)) {
return false;
$buffer = '';
$record_cnt = 0;
while ($record = PMA_DBI_fetch_row($result)) {
$record_cnt++;
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
$buffer = '# ' . $db . '.' . $table . $crlf;
$buffer .= '-' . $crlf;
} else {
$buffer = '-' . $crlf;
}
for ($i = 0; $i < $columns_cnt; $i++) {
if (! isset($record[$i])) {
continue;
}
$column = $columns[$i];
if (is_null($record[$i])) {
$buffer .= ' ' . $column . ': null' . $crlf;
continue;
}
if (is_numeric($record[$i])) {
$buffer .= ' ' . $column . ': ' . $record[$i] . $crlf;
continue;
}
$record[$i] = str_replace(array('\\', '"', "\n", "\r"), array('\\\\', '\"', '\n', '\r'), $record[$i]);
$buffer .= ' ' . $column . ': "' . $record[$i] . '"' . $crlf;
}
if (! PMA_exportOutputHandler($buffer)) {
return false;
}
}
PMA_DBI_free_result($result);
return true;
}
PMA_DBI_free_result($result);
return true;
}
}
?>

View File

@ -2629,12 +2629,12 @@ if (! defined('PMA_MINIMUM_COMMON')) {
break;
} // end switch ($typearr[2])
/*
/*
if ($typearr[3] != 'punct_qualifier') {
$after .= ' ';
}
$after .= "\n";
*/
*/
$str .= $before;
if ($mode=='color') {
$str .= PMA_SQP_formatHTML_colorize($arr[$i]);
@ -2650,7 +2650,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$indent--;
$str .= ($mode != 'query_only' ? '</div>' : ' ');
}
/* End possibly unclosed documentation link */
/* End possibly unclosed documentation link */
if ($close_docu_link) {
$str .= '</a>';
$close_docu_link = false;