~ubuntu-branches/ubuntu/lucid/phpmyadmin/lucid

« back to all changes in this revision

Viewing changes to libraries/export/mediawiki.php

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2010-03-08 15:25:00 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100308152500-6e8hmuqc5co39de5
Tags: 4:3.3.0-1
* New upstream version.
* Rediff debian/patches.
* Fix permissions on mediawiki export extension.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/* vim: set expandtab sw=4 ts=4 sts=4: */
 
3
/**
 
4
 * Set of functions used to build MediaWiki dumps of tables
 
5
 *
 
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;
 
11
}
 
12
 
 
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'),
 
20
            ),
 
21
        'options_text' => 'strOptions',
 
22
        );
 
23
} else {
 
24
 
 
25
/**
 
26
 * Outputs comment
 
27
 *
 
28
 * @param   string      Text of comment
 
29
 *
 
30
 * @return  bool        Whether it suceeded
 
31
 */
 
32
function PMA_exportComment($text) {
 
33
    return TRUE;
 
34
}
 
35
 
 
36
/**
 
37
 * Outputs export footer
 
38
 *
 
39
 * @return  bool        Whether it suceeded
 
40
 *
 
41
 * @access  public
 
42
 */
 
43
function PMA_exportFooter() {
 
44
    return TRUE;
 
45
}
 
46
 
 
47
/**
 
48
 * Outputs export header
 
49
 *
 
50
 * @return  bool        Whether it suceeded
 
51
 *
 
52
 * @access  public
 
53
 */
 
54
function PMA_exportHeader() {
 
55
    return TRUE;
 
56
}
 
57
 
 
58
/**
 
59
 * Outputs database header
 
60
 *
 
61
 * @param   string      Database name
 
62
 *
 
63
 * @return  bool        Whether it suceeded
 
64
 *
 
65
 * @access  public
 
66
 */
 
67
function PMA_exportDBHeader($db) {
 
68
    return TRUE;
 
69
}
 
70
 
 
71
/**
 
72
 * Outputs database footer
 
73
 *
 
74
 * @param   string      Database name
 
75
 *
 
76
 * @return  bool        Whether it suceeded
 
77
 *
 
78
 * @access  public
 
79
 */
 
80
function PMA_exportDBFooter($db) {
 
81
    return TRUE;
 
82
}
 
83
 
 
84
/**
 
85
 * Outputs create database database
 
86
 *
 
87
 * @param   string      Database name
 
88
 *
 
89
 * @return  bool        Whether it suceeded
 
90
 *
 
91
 * @access  public
 
92
 */
 
93
function PMA_exportDBCreate($db) {
 
94
    return TRUE;
 
95
}
 
96
 
 
97
/**
 
98
 * Outputs the content of a table in MediaWiki format
 
99
 *
 
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
 
105
 *
 
106
 * @return  bool        Whether it suceeded
 
107
 *
 
108
 * @access  public
 
109
 */
 
110
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
 
111
    global $mediawiki_export_struct;
 
112
    global $mediawiki_export_data;
 
113
    
 
114
    $result  = PMA_DBI_fetch_result("SHOW COLUMNS FROM `" . $db . "`.`" . $table . "`");
 
115
    $row_cnt = count($result);
 
116
 
 
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";
 
125
        }
 
126
    }
 
127
    $output .= "\n";
 
128
    
 
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";
 
135
        }
 
136
    }
 
137
    $output .= "\n";
 
138
    
 
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";
 
145
        }
 
146
    }
 
147
    $output .= "\n";
 
148
    
 
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";
 
155
        }
 
156
    }
 
157
    $output .= "\n";
 
158
    
 
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";
 
165
        }
 
166
    }
 
167
    $output .= "\n";
 
168
    
 
169
    $output .= "|}\n\n\n\n";
 
170
    return PMA_exportOutputHandler($output);
 
171
}
 
172
 
 
173
}
 
174
?>