2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Set of functions used to build MediaWiki dumps of tables
6 * @package phpMyAdmin-Export
7 * @subpackage MediaWiki
9 if (! defined('PHPMYADMIN')) {
13 if (isset($plugin_list)) {
14 $plugin_list['mediawiki'] = array(
15 'text' => __('MediaWiki Table'),
17 'mime_type' => 'text/plain',
19 array('type' => 'begin_group', 'name' => 'general_opts'),
20 array('type' => 'hidden', 'name' => 'structure_or_data'),
21 array('type' => 'end_group')
23 'options_text' => __('Options'),
28 * Outputs export footer
30 * @return bool Whether it suceeded
34 function PMA_exportFooter() {
39 * Outputs export header
41 * @return bool Whether it suceeded
45 function PMA_exportHeader() {
50 * Outputs database header
52 * @param string $db Database name
53 * @return bool Whether it suceeded
57 function PMA_exportDBHeader($db) {
62 * Outputs database footer
64 * @param string $db Database name
65 * @return bool Whether it suceeded
69 function PMA_exportDBFooter($db) {
74 * Outputs CREATE DATABASE statement
76 * @param string $db Database name
77 * @return bool Whether it suceeded
81 function PMA_exportDBCreate($db) {
86 * Outputs the content of a table in MediaWiki format
88 * @param string $db database name
89 * @param string $table table name
90 * @param string $crlf the end of line sequence
91 * @param string $error_url the url to go back in case of error
92 * @param string $sql_query SQL query for obtaining data
93 * @return bool Whether it suceeded
97 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
98 $columns = PMA_DBI_get_columns($db, $table);
99 $columns = array_values($columns);
100 $row_cnt = count($columns);
102 $output = "{| cellpadding=\"10\" cellspacing=\"0\" border=\"1\" style=\"text-align:center;\"\n";
103 $output .= "|+'''" . $table . "'''\n";
104 $output .= "|- style=\"background:#ffdead;\"\n";
105 $output .= "! style=\"background:#ffffff\" | \n";
106 for ($i = 0; $i < $row_cnt; ++
$i) {
107 $output .= " | " . $columns[$i]['Field'];
108 if (($i +
1) != $row_cnt) {
114 $output .= "|- style=\"background:#f9f9f9;\"\n";
115 $output .= "! style=\"background:#f2f2f2\" | Type\n";
116 for ($i = 0; $i < $row_cnt; ++
$i) {
117 $output .= " | " . $columns[$i]['Type'];
118 if (($i +
1) != $row_cnt) {
124 $output .= "|- style=\"background:#f9f9f9;\"\n";
125 $output .= "! style=\"background:#f2f2f2\" | Null\n";
126 for ($i = 0; $i < $row_cnt; ++
$i) {
127 $output .= " | " . $columns[$i]['Null'];
128 if (($i +
1) != $row_cnt) {
134 $output .= "|- style=\"background:#f9f9f9;\"\n";
135 $output .= "! style=\"background:#f2f2f2\" | Default\n";
136 for ($i = 0; $i < $row_cnt; ++
$i) {
137 $output .= " | " . $columns[$i]['Default'];
138 if (($i +
1) != $row_cnt) {
144 $output .= "|- style=\"background:#f9f9f9;\"\n";
145 $output .= "! style=\"background:#f2f2f2\" | Extra\n";
146 for ($i = 0; $i < $row_cnt; ++
$i) {
147 $output .= " | " . $columns[$i]['Extra'];
148 if (($i +
1) != $row_cnt) {
154 $output .= "|}\n\n\n\n";
155 return PMA_exportOutputHandler($output);