2.11.1.2 release
[phpmyadmin/arisferyanto.git] / libraries / display_export.lib.php
blob60fe0dd4ceacb7490370e83dca955ecc14f692fb
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
11 require_once './libraries/Table.class.php';
13 // Get relations & co. status
14 require_once './libraries/relation.lib.php';
15 $cfgRelation = PMA_getRelationsParam();
18 require_once './libraries/file_listing.php';
19 require_once './libraries/plugin_interface.lib.php';
21 function PMA_exportCheckboxCheck($str) {
22 if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
23 echo ' checked="checked"';
27 function PMA_exportIsActive($what, $val) {
28 if (isset($GLOBALS['cfg']['Export'][$what]) && $GLOBALS['cfg']['Export'][$what] == $val) {
29 echo ' checked="checked"';
33 /* Scan for plugins */
34 $export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $export_type, 'single_table' => isset($single_table)));
36 /* Fail if we didn't find any plugin */
37 if (empty($export_list)) {
38 $GLOBALS['show_error_header'] = TRUE;
39 PMA_showMessage($strCanNotLoadExportPlugins);
40 unset($GLOBALS['show_error_header']);
41 require './libraries/footer.inc.php';
45 <form method="post" action="export.php" name="dump">
47 <?php
48 if ($export_type == 'server') {
49 echo PMA_generate_common_hidden_inputs('', '', 1);
50 } elseif ($export_type == 'database') {
51 echo PMA_generate_common_hidden_inputs($db, '', 1);
52 } else {
53 echo PMA_generate_common_hidden_inputs($db, $table, 1);
56 // just to keep this value for possible next display of this form after saving on server
57 if (isset($single_table)) {
58 echo '<input type="hidden" name="single_table" value="TRUE" />' . "\n";
61 echo '<input type="hidden" name="export_type" value="' . $export_type . '" />' . "\n";
63 if (! empty($sql_query)) {
64 echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
66 echo PMA_pluginGetJavascript($export_list);
68 <fieldset id="fieldsetexport">
69 <legend><?php echo $export_page_title; ?></legend>
71 <?php
73 * this table is needed to fix rendering in Opera <= 9 and Safari <= 2
74 * normaly just the two fieldset would have float: left
77 <table><tr><td>
79 <div id="div_container_exportoptions">
80 <fieldset id="exportoptions">
81 <legend><?php echo $strExport; ?></legend>
83 <?php if (! empty($multi_values)) { ?>
84 <div class="formelementrow">
85 <?php echo $multi_values; ?>
86 </div>
87 <?php } ?>
88 <?php echo PMA_pluginGetChoice('Export', 'what', $export_list, 'format'); ?>
89 </fieldset>
90 </div>
92 </td><td>
94 <div id="div_container_sub_exportoptions">
95 <?php echo PMA_pluginGetOptions('Export', $export_list); ?>
96 </div>
97 </td></tr></table>
99 <script type="text/javascript">
100 //<![CDATA[
101 init_options();
102 //]]>
103 </script>
105 <?php if (strlen($table) && ! isset($num_tables)) { ?>
106 <div class="formelementrow">
107 <?php
108 echo sprintf($strDumpXRows,
109 '<input type="text" name="limit_to" size="5" value="'
110 . (isset($unlim_num_rows) ? $unlim_num_rows : PMA_Table::countRecords($db, $table, TRUE))
111 . '" onfocus="this.select()" />',
112 '<input type="text" name="limit_from" value="0" size="5"'
113 .' onfocus="this.select()" /> ');
115 </div>
116 <?php } ?>
117 </fieldset>
119 <fieldset>
120 <legend>
121 <input type="checkbox" name="asfile" value="sendit"
122 id="checkbox_dump_asfile" <?php PMA_exportCheckboxCheck('asfile'); ?> />
123 <label for="checkbox_dump_asfile"><?php echo $strSend; ?></label>
124 </legend>
126 <?php if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) { ?>
127 <input type="checkbox" name="onserver" value="saveit"
128 id="checkbox_dump_onserver"
129 onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
130 <?php PMA_exportCheckboxCheck('onserver'); ?> />
131 <label for="checkbox_dump_onserver">
132 <?php echo sprintf($strSaveOnServer, htmlspecialchars(PMA_userDir($cfg['SaveDir']))); ?>
133 </label>,<br />
134 <input type="checkbox" name="onserverover" value="saveitover"
135 id="checkbox_dump_onserverover"
136 onclick="document.getElementById('checkbox_dump_onserver').checked = true;
137 document.getElementById('checkbox_dump_asfile').checked = true;"
138 <?php PMA_exportCheckboxCheck('onserver_overwrite'); ?> />
139 <label for="checkbox_dump_onserverover">
140 <?php echo $strOverwriteExisting; ?></label>
141 <br />
142 <?php } ?>
144 <label for="filename_template">
145 <?php echo $strFileNameTemplate; ?>
146 <sup>(1)</sup></label>:
147 <input type="text" name="filename_template" id="filename_template"
148 <?php
149 echo ' value="';
150 if ($export_type == 'database') {
151 if (isset($_COOKIE) && !empty($_COOKIE['pma_db_filename_template'])) {
152 echo $_COOKIE['pma_db_filename_template'];
153 } else {
154 echo $GLOBALS['cfg']['Export']['file_template_database'];
156 } elseif ($export_type == 'table') {
157 if (isset($_COOKIE) && !empty($_COOKIE['pma_table_filename_template'])) {
158 echo $_COOKIE['pma_table_filename_template'];
159 } else {
160 echo $GLOBALS['cfg']['Export']['file_template_table'];
162 } else {
163 if (isset($_COOKIE) && !empty($_COOKIE['pma_server_filename_template'])) {
164 echo $_COOKIE['pma_server_filename_template'];
165 } else {
166 echo $GLOBALS['cfg']['Export']['file_template_server'];
169 echo '" />';
173 <input type="checkbox" name="remember_template"
174 id="checkbox_remember_template"
175 <?php PMA_exportCheckboxCheck('remember_file_template'); ?> />
176 <label for="checkbox_remember_template">
177 <?php echo $strFileNameTemplateRemember; ?></label>
180 <div class="formelementrow">
181 <?php
182 // charset of file
183 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
184 echo ' <label for="select_charset_of_file">'
185 . $strCharsetOfFile . '</label>' . "\n";
187 $temp_charset = reset($cfg['AvailableCharsets']);
188 echo ' <select id="select_charset_of_file" name="charset_of_file" size="1">' . "\n";
189 foreach ($cfg['AvailableCharsets'] as $key => $temp_charset) {
190 echo ' <option value="' . $temp_charset . '"';
191 if ((empty($cfg['Export']['charset']) && $temp_charset == $charset)
192 || $temp_charset == $cfg['Export']['charset']) {
193 echo ' selected="selected"';
195 echo '>' . $temp_charset . '</option>' . "\n";
196 } // end foreach
197 echo ' </select>';
198 } // end if
200 </div>
202 <?php
203 // zip, gzip and bzip2 encode features
204 $is_zip = ($cfg['ZipDump'] && @function_exists('gzcompress'));
205 $is_gzip = ($cfg['GZipDump'] && @function_exists('gzencode'));
206 $is_bzip = ($cfg['BZipDump'] && @function_exists('bzcompress'));
208 if ($is_zip || $is_gzip || $is_bzip) { ?>
209 <div class="formelementrow">
210 <?php echo $strCompression; ?>:
211 <input type="radio" name="compression" value="none"
212 id="radio_compression_none"
213 onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
214 <?php PMA_exportIsActive('compression', 'none'); ?> />
215 <label for="radio_compression_none"><?php echo $strNone; ?></label>
216 <?php
217 if ($is_zip) { ?>
218 <input type="radio" name="compression" value="zip"
219 id="radio_compression_zip"
220 onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
221 <?php PMA_exportIsActive('compression', 'zip'); ?> />
222 <label for="radio_compression_zip"><?php echo $strZip; ?></label>
223 <?php } if ($is_gzip) { ?>
224 <input type="radio" name="compression" value="gzip"
225 id="radio_compression_gzip"
226 onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
227 <?php PMA_exportIsActive('compression', 'gzip'); ?> />
228 <label for="radio_compression_gzip"><?php echo $strGzip; ?></label>
229 <?php } if ($is_bzip) { ?>
230 <input type="radio" name="compression" value="bzip"
231 id="radio_compression_bzip"
232 onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
233 <?php PMA_exportIsActive('compression', 'bzip2'); ?> />
234 <label for="radio_compression_bzip"><?php echo $strBzip; ?></label>
235 <?php } ?>
236 </div>
237 <?php } else { ?>
238 <input type="hidden" name="compression" value="none" />
239 <?php } ?>
240 </fieldset>
242 <?php if (function_exists('PMA_set_enc_form')) { ?>
243 <!-- Encoding setting form appended by Y.Kawada -->
244 <!-- Japanese encoding setting -->
245 <fieldset>
246 <?php echo PMA_set_enc_form(' '); ?>
247 </fieldset>
248 <?php } ?>
250 <fieldset class="tblFooters">
251 <?php PMA_externalBug($GLOBALS['strSQLCompatibility'], 'mysql', '50027', '14515'); ?>
252 <input type="submit" value="<?php echo $strGo; ?>" id="buttonGo" />
253 </fieldset>
254 </form>
256 <div class="notice">
257 <sup id="FileNameTemplateHelp">(1)</sup>
258 <?php
259 $trans = '__SERVER__/' . $strFileNameTemplateDescriptionServer;
260 if ($export_type == 'database' || $export_type == 'table') {
261 $trans .= ', __DB__/' . $strFileNameTemplateDescriptionDatabase;
263 if ($export_type == 'table') {
264 $trans .= ', __TABLE__/' . $strFileNameTemplateDescriptionTable;
266 echo sprintf($strFileNameTemplateDescription,
267 '<a href="http://www.php.net/strftime" target="documentation" title="'
268 . $strDocu . '">', '</a>', $trans); ?>
269 </div>