sorry, wrong version checked in
[phpmyadmin/arisferyanto.git] / libraries / export / xml.php
blob14488d9708a138c7eb4623b14551f7c3fc9e7435
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 /**
6 * Set of functions used to build XML dumps of tables
7 */
9 /**
10 * Outputs comment
12 * @param string Text of comment
14 * @return bool Whether it suceeded
16 function PMA_exportComment($text) {
17 return PMA_exportOutputHandler('<!-- ' . $text . ' -->' . $GLOBALS['crlf']);
20 /**
21 * Outputs export footer
23 * @return bool Whether it suceeded
25 * @access public
27 function PMA_exportFooter() {
28 return TRUE;
31 /**
32 * Outputs export header
34 * @return bool Whether it suceeded
36 * @access public
38 function PMA_exportHeader() {
39 global $crlf;
40 global $cfg;
42 if ($GLOBALS['output_charset_conversion']) {
43 $charset = $GLOBALS['charset_of_file'];
44 } else {
45 $charset = $GLOBALS['charset'];
48 $head = '<?xml version="1.0" encoding="' . $charset . '" ?>' . $crlf
49 . '<!--' . $crlf
50 . '-' . $crlf
51 . '- phpMyAdmin XML Dump' . $crlf
52 . '- version ' . PMA_VERSION . $crlf
53 . '- http://www.phpmyadmin.net' . $crlf
54 . '-' . $crlf
55 . '- ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
56 if (!empty($cfg['Server']['port'])) {
57 $head .= ':' . $cfg['Server']['port'];
59 $head .= $crlf
60 . '- ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf
61 . '- ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf
62 . '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf
63 . '-->' . $crlf . $crlf;
64 return PMA_exportOutputHandler($head);
67 /**
68 * Outputs database header
70 * @param string Database name
72 * @return bool Whether it suceeded
74 * @access public
76 function PMA_exportDBHeader($db) {
77 global $crlf;
78 $head = '<!--' . $crlf
79 . '- ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
80 . '-->' . $crlf
81 . '<' . $db . '>' . $crlf;
82 return PMA_exportOutputHandler($head);
85 /**
86 * Outputs database footer
88 * @param string Database name
90 * @return bool Whether it suceeded
92 * @access public
94 function PMA_exportDBFooter($db) {
95 global $crlf;
96 return PMA_exportOutputHandler('</' . $db . '>' . $crlf);
99 /**
100 * Outputs create database database
102 * @param string Database name
104 * @return bool Whether it suceeded
106 * @access public
108 function PMA_exportDBCreate($db) {
109 return TRUE;
114 * Outputs the content of a table
116 * @param string the database name
117 * @param string the table name
118 * @param string the end of line sequence
119 * @param string the url to go back in case of error
120 * @param string SQL query for obtaining data
122 * @return bool Whether it suceeded
124 * @access public
126 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
127 $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED);
129 $columns_cnt = PMA_DBI_num_fields($result);
130 for ($i = 0; $i < $columns_cnt; $i++) {
131 $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
133 unset($i);
135 $buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
136 if (!PMA_exportOutputHandler($buffer)) return FALSE;
138 while ($record = PMA_DBI_fetch_row($result)) {
139 $buffer = ' <' . $table . '>' . $crlf;
140 for ($i = 0; $i < $columns_cnt; $i++) {
141 if ( isset($record[$i]) && !is_null($record[$i])) {
142 $buffer .= ' <' . $columns[$i] . '>' . htmlspecialchars($record[$i])
143 . '</' . $columns[$i] . '>' . $crlf;
146 $buffer .= ' </' . $table . '>' . $crlf;
148 if (!PMA_exportOutputHandler($buffer)) return FALSE;
150 PMA_DBI_free_result($result);
152 return TRUE;
153 } // end of the 'PMA_getTableXML()' function