3.3.2-rc1
[phpmyadmin/madhuracj.git] / libraries / export / mediawiki.php
blobd1369cbe208cc08bedda274e20edb5208ac77548
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
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 $
8 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 if (isset($plugin_list)) {
14 $plugin_list['mediawiki'] = array(
15 'text' => 'strMediaWiki',
16 'extension' => 'txt',
17 'mime_type' => 'text/plain',
18 'options' => array(
19 array('type' => 'hidden', 'name' => 'data'),
21 'options_text' => 'strOptions',
23 } else {
25 /**
26 * Outputs comment
28 * @param string Text of comment
30 * @return bool Whether it suceeded
32 function PMA_exportComment($text) {
33 return TRUE;
36 /**
37 * Outputs export footer
39 * @return bool Whether it suceeded
41 * @access public
43 function PMA_exportFooter() {
44 return TRUE;
47 /**
48 * Outputs export header
50 * @return bool Whether it suceeded
52 * @access public
54 function PMA_exportHeader() {
55 return TRUE;
58 /**
59 * Outputs database header
61 * @param string Database name
63 * @return bool Whether it suceeded
65 * @access public
67 function PMA_exportDBHeader($db) {
68 return TRUE;
71 /**
72 * Outputs database footer
74 * @param string Database name
76 * @return bool Whether it suceeded
78 * @access public
80 function PMA_exportDBFooter($db) {
81 return TRUE;
84 /**
85 * Outputs create database database
87 * @param string Database name
89 * @return bool Whether it suceeded
91 * @access public
93 function PMA_exportDBCreate($db) {
94 return TRUE;
97 /**
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
108 * @access public
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) {
124 $output .= "\n";
127 $output .= "\n";
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) {
134 $output .= "\n";
137 $output .= "\n";
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) {
144 $output .= "\n";
147 $output .= "\n";
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) {
154 $output .= "\n";
157 $output .= "\n";
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) {
164 $output .= "\n";
167 $output .= "\n";
169 $output .= "|}\n\n\n\n";
170 return PMA_exportOutputHandler($output);