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-MediaWiki
7 * @version $Id: mediawiki.php 12972 2009-09-14 06:21:04Z drummingds1 $
9 if (! defined('PHPMYADMIN')) {
13 if (isset($plugin_list)) {
14 $plugin_list['mediawiki'] = array(
15 'text' => 'strMediaWiki',
17 'mime_type' => 'text/plain',
19 array('type' => 'hidden', 'name' => 'data'),
21 'options_text' => 'strOptions',
28 * @param string Text of comment
30 * @return bool Whether it suceeded
32 function PMA_exportComment($text) {
37 * Outputs export footer
39 * @return bool Whether it suceeded
43 function PMA_exportFooter() {
48 * Outputs export header
50 * @return bool Whether it suceeded
54 function PMA_exportHeader() {
59 * Outputs database header
61 * @param string Database name
63 * @return bool Whether it suceeded
67 function PMA_exportDBHeader($db) {
72 * Outputs database footer
74 * @param string Database name
76 * @return bool Whether it suceeded
80 function PMA_exportDBFooter($db) {
85 * Outputs create database database
87 * @param string Database name
89 * @return bool Whether it suceeded
93 function PMA_exportDBCreate($db) {
98 * Outputs the content of a table in MediaWiki format
100 * @param string the database name
101 * @param string the table name
102 * @param string the end of line sequence
103 * @param string the url to go back in case of error
104 * @param string SQL query for obtaining data
106 * @return bool Whether it suceeded
110 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
111 global $mediawiki_export_struct;
112 global $mediawiki_export_data;
114 $result = PMA_DBI_fetch_result("SHOW COLUMNS FROM `" . $db . "`.`" . $table . "`");
115 $row_cnt = count($result);
117 $output = "{| cellpadding=\"10\" cellspacing=\"0\" border=\"1\" style=\"text-align:center;\"\n";
118 $output .= "|+'''" . $table . "'''\n";
119 $output .= "|- style=\"background:#ffdead;\"\n";
120 $output .= "! style=\"background:#ffffff\" | \n";
121 for ($i = 0; $i < $row_cnt; ++
$i) {
122 $output .= " | " . $result[$i]['Field'];
123 if (($i +
1) != $row_cnt) {
129 $output .= "|- style=\"background:#f9f9f9;\"\n";
130 $output .= "! style=\"background:#f2f2f2\" | Type\n";
131 for ($i = 0; $i < $row_cnt; ++
$i) {
132 $output .= " | " . $result[$i]['Type'];
133 if (($i +
1) != $row_cnt) {
139 $output .= "|- style=\"background:#f9f9f9;\"\n";
140 $output .= "! style=\"background:#f2f2f2\" | Null\n";
141 for ($i = 0; $i < $row_cnt; ++
$i) {
142 $output .= " | " . $result[$i]['Null'];
143 if (($i +
1) != $row_cnt) {
149 $output .= "|- style=\"background:#f9f9f9;\"\n";
150 $output .= "! style=\"background:#f2f2f2\" | Default\n";
151 for ($i = 0; $i < $row_cnt; ++
$i) {
152 $output .= " | " . $result[$i]['Default'];
153 if (($i +
1) != $row_cnt) {
159 $output .= "|- style=\"background:#f9f9f9;\"\n";
160 $output .= "! style=\"background:#f2f2f2\" | Extra\n";
161 for ($i = 0; $i < $row_cnt; ++
$i) {
162 $output .= " | " . $result[$i]['Extra'];
163 if (($i +
1) != $row_cnt) {
169 $output .= "|}\n\n\n\n";
170 return PMA_exportOutputHandler($output);