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' => __('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'),
30 * @param string Text of comment
32 * @return bool Whether it suceeded
34 function PMA_exportComment($text) {
39 * Outputs export footer
41 * @return bool Whether it suceeded
45 function PMA_exportFooter() {
50 * Outputs export header
52 * @return bool Whether it suceeded
56 function PMA_exportHeader() {
61 * Outputs database header
63 * @param string Database name
65 * @return bool Whether it suceeded
69 function PMA_exportDBHeader($db) {
74 * Outputs database footer
76 * @param string Database name
78 * @return bool Whether it suceeded
82 function PMA_exportDBFooter($db) {
87 * Outputs create database database
89 * @param string Database name
91 * @return bool Whether it suceeded
95 function PMA_exportDBCreate($db) {
100 * Outputs the content of a table in MediaWiki format
102 * @param string the database name
103 * @param string the table name
104 * @param string the end of line sequence
105 * @param string the url to go back in case of error
106 * @param string SQL query for obtaining data
108 * @return bool Whether it suceeded
112 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
113 global $mediawiki_export_struct;
114 global $mediawiki_export_data;
116 $result = PMA_DBI_fetch_result("SHOW COLUMNS FROM `" . $db . "`.`" . $table . "`");
117 $row_cnt = count($result);
119 $output = "{| cellpadding=\"10\" cellspacing=\"0\" border=\"1\" style=\"text-align:center;\"\n";
120 $output .= "|+'''" . $table . "'''\n";
121 $output .= "|- style=\"background:#ffdead;\"\n";
122 $output .= "! style=\"background:#ffffff\" | \n";
123 for ($i = 0; $i < $row_cnt; ++
$i) {
124 $output .= " | " . $result[$i]['Field'];
125 if (($i +
1) != $row_cnt) {
131 $output .= "|- style=\"background:#f9f9f9;\"\n";
132 $output .= "! style=\"background:#f2f2f2\" | Type\n";
133 for ($i = 0; $i < $row_cnt; ++
$i) {
134 $output .= " | " . $result[$i]['Type'];
135 if (($i +
1) != $row_cnt) {
141 $output .= "|- style=\"background:#f9f9f9;\"\n";
142 $output .= "! style=\"background:#f2f2f2\" | Null\n";
143 for ($i = 0; $i < $row_cnt; ++
$i) {
144 $output .= " | " . $result[$i]['Null'];
145 if (($i +
1) != $row_cnt) {
151 $output .= "|- style=\"background:#f9f9f9;\"\n";
152 $output .= "! style=\"background:#f2f2f2\" | Default\n";
153 for ($i = 0; $i < $row_cnt; ++
$i) {
154 $output .= " | " . $result[$i]['Default'];
155 if (($i +
1) != $row_cnt) {
161 $output .= "|- style=\"background:#f9f9f9;\"\n";
162 $output .= "! style=\"background:#f2f2f2\" | Extra\n";
163 for ($i = 0; $i < $row_cnt; ++
$i) {
164 $output .= " | " . $result[$i]['Extra'];
165 if (($i +
1) != $row_cnt) {
171 $output .= "|}\n\n\n\n";
172 return PMA_exportOutputHandler($output);