Fix for the Open in New Window in Patient/Client->Patients search gui, take 2.
[openemr.git] / phpmyadmin / libraries / export / xml.php
blobbc99eb006302907c403a6e697de26fef5eb2bab8
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Set of functions used to build XML dumps of tables
6 * @version $Id$
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
15 if (strlen($GLOBALS['db'])) { /* Can't do server export */
17 if (isset($plugin_list)) {
18 $plugin_list['xml'] = array(
19 'text' => 'strXML',
20 'extension' => 'xml',
21 'mime_type' => 'text/xml',
22 'options' => array(
23 array('type' => 'hidden', 'name' => 'data'),
25 'options_text' => 'strOptions',
27 } else {
29 /**
30 * Outputs comment
32 * @param string Text of comment
34 * @return bool Whether it suceeded
36 function PMA_exportComment($text) {
37 return PMA_exportOutputHandler('<!-- ' . $text . ' -->' . $GLOBALS['crlf']);
40 /**
41 * Outputs export footer
43 * @return bool Whether it suceeded
45 * @access public
47 function PMA_exportFooter() {
48 return TRUE;
51 /**
52 * Outputs export header
54 * @return bool Whether it suceeded
56 * @access public
58 function PMA_exportHeader() {
59 global $crlf;
60 global $cfg;
62 if ($GLOBALS['output_charset_conversion']) {
63 $charset = $GLOBALS['charset_of_file'];
64 } else {
65 $charset = $GLOBALS['charset'];
68 $head = '<?xml version="1.0" encoding="' . $charset . '" ?>' . $crlf
69 . '<!--' . $crlf
70 . '-' . $crlf
71 . '- phpMyAdmin XML Dump' . $crlf
72 . '- version ' . PMA_VERSION . $crlf
73 . '- http://www.phpmyadmin.net' . $crlf
74 . '-' . $crlf
75 . '- ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
76 if (!empty($cfg['Server']['port'])) {
77 $head .= ':' . $cfg['Server']['port'];
79 $head .= $crlf
80 . '- ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf
81 . '- ' . $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
82 . '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf
83 . '-->' . $crlf . $crlf;
84 return PMA_exportOutputHandler($head);
87 /**
88 * Outputs database header
90 * @param string Database name
92 * @return bool Whether it suceeded
94 * @access public
96 function PMA_exportDBHeader($db) {
97 global $crlf;
98 $head = '<!--' . $crlf
99 . '- ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
100 . '-->' . $crlf
101 . '<' . $db . '>' . $crlf;
102 return PMA_exportOutputHandler($head);
106 * Outputs database footer
108 * @param string Database name
110 * @return bool Whether it suceeded
112 * @access public
114 function PMA_exportDBFooter($db) {
115 global $crlf;
116 return PMA_exportOutputHandler('</' . $db . '>' . $crlf);
120 * Outputs create database database
122 * @param string Database name
124 * @return bool Whether it suceeded
126 * @access public
128 function PMA_exportDBCreate($db) {
129 return TRUE;
134 * Outputs the content of a table
136 * @param string the database name
137 * @param string the table name
138 * @param string the end of line sequence
139 * @param string the url to go back in case of error
140 * @param string SQL query for obtaining data
142 * @return bool Whether it suceeded
144 * @access public
146 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
147 $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
149 $columns_cnt = PMA_DBI_num_fields($result);
150 for ($i = 0; $i < $columns_cnt; $i++) {
151 $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
153 unset($i);
155 $buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
156 if (!PMA_exportOutputHandler($buffer)) {
157 return FALSE;
160 while ($record = PMA_DBI_fetch_row($result)) {
161 $buffer = ' <' . $table . '>' . $crlf;
162 for ($i = 0; $i < $columns_cnt; $i++) {
163 if (isset($record[$i]) && !is_null($record[$i])) {
164 $buffer .= ' <' . $columns[$i] . '>' . htmlspecialchars($record[$i])
165 . '</' . $columns[$i] . '>' . $crlf;
168 $buffer .= ' </' . $table . '>' . $crlf;
170 if (!PMA_exportOutputHandler($buffer)) {
171 return FALSE;
174 PMA_DBI_free_result($result);
176 return TRUE;
177 } // end of the 'PMA_getTableXML()' function