Housekeeping stuff:
[openemr.git] / phpmyadmin / libraries / export / yaml.php
blobf55e9153a8bd990fffdd23ee7d61d606ea94dca9
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Set of functions used to build YAML dumps of tables
6 * @version $Id$
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
15 if (isset($plugin_list)) {
16 $plugin_list['yaml'] = array(
17 'text' => 'YAML',
18 'extension' => 'yml',
19 'mime_type' => 'text/yaml',
20 'force_file' => true,
21 'options' => array(
22 array('type' => 'hidden', 'name' => 'data'),
24 'options_text' => 'strOptions',
26 } else {
28 /**
29 * Set of functions used to build exports of tables
32 /**
33 * Outputs comment
35 * @param string Text of comment
37 * @return bool Whether it suceeded
39 function PMA_exportComment($text)
41 return TRUE;
44 /**
45 * Outputs export footer
47 * @return bool Whether it suceeded
49 * @access public
51 function PMA_exportFooter()
53 return TRUE;
56 /**
57 * Outputs export header
59 * @return bool Whether it suceeded
61 * @access public
63 function PMA_exportHeader()
65 return TRUE;
68 /**
69 * Outputs database header
71 * @param string Database name
73 * @return bool Whether it suceeded
75 * @access public
77 function PMA_exportDBHeader($db)
79 return TRUE;
82 /**
83 * Outputs database footer
85 * @param string Database name
87 * @return bool Whether it suceeded
89 * @access public
91 function PMA_exportDBFooter($db)
93 return TRUE;
96 /**
97 * Outputs create database database
99 * @param string Database name
101 * @return bool Whether it suceeded
103 * @access public
105 function PMA_exportDBCreate($db)
107 return TRUE;
111 * Outputs the content of a table in YAML format
113 * @param string the database name
114 * @param string the table name
115 * @param string the end of line sequence
116 * @param string the url to go back in case of error
117 * @param string SQL query for obtaining data
119 * @return bool Whether it suceeded
121 * @access public
123 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
125 $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
127 $columns_cnt = PMA_DBI_num_fields($result);
128 for ($i = 0; $i < $columns_cnt; $i++) {
129 $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
131 unset($i);
133 $cnt = 0;
134 $buffer = '';
135 while ($record = PMA_DBI_fetch_row($result)) {
136 $cnt++;
137 $buffer = $cnt . ":$crlf";
138 for ($i = 0; $i < $columns_cnt; $i++) {
139 if (isset($record[$i]) && !is_null($record[$i])) {
140 $buffer .= ' ' . $columns[$i] . ': ' . htmlspecialchars($record[$i]) . $crlf;
144 if (!PMA_exportOutputHandler($buffer)) {
145 return FALSE;
148 PMA_DBI_free_result($result);
150 return TRUE;