feat: add a pod_name parameter

This commit is contained in:
Glen Whitney 2021-02-08 13:07:30 -08:00
parent 8ccabf59a1
commit 8043cc7739
2 changed files with 16 additions and 29 deletions

View File

@ -3,7 +3,7 @@
Plugin Name: TablePress Extension: Pods tables Plugin Name: TablePress Extension: Pods tables
Plugin URI: https://code.studioinfinity.org/glen/tablepress-pods Plugin URI: https://code.studioinfinity.org/glen/tablepress-pods
Description: Custom Extension for TablePress to incorporate Pods information in tables Description: Custom Extension for TablePress to incorporate Pods information in tables
Version: 0.2.8 Version: 0.2.9
Author: Glen Whitney Author: Glen Whitney
Author URI: http://studioinfinity.org/ Author URI: http://studioinfinity.org/
*/ */
@ -98,11 +98,13 @@ function playground_exportpods_data( $data, $act ) {
$data['export_ids'] = array(); $data['export_ids'] = array();
} }
$exporter = TablePress::load_class( 'TablePress_Export', 'class-export.php', 'classes' ); $exporter = TablePress::load_class( 'TablePress_Export', 'class-export.php', 'classes' );
$data['zip_support_available'] = $exporter->zip_support_available; $data['zip_support_available'] = false;
$data['export_formats'] = $exporter->export_formats; $data['export_formats'] = $exporter->export_formats;
$data['csv_delimiters'] = $exporter->csv_delimiters;
$data['export_format'] = ( ! empty( $_GET['export_format'] ) ) ? $_GET['export_format'] : false; $data['export_format'] = ( ! empty( $_GET['export_format'] ) ) ? $_GET['export_format'] : false;
$data['csv_delimiters'] = $exporter->csv_delimiters;
$data['csv_delimiter'] = ( ! empty( $_GET['csv_delimiter'] ) ) ? $_GET['csv_delimiter'] : _x( ',', 'Default CSV delimiter in the translated language (";", ",", or "tab")', 'tablepress' ); $data['csv_delimiter'] = ( ! empty( $_GET['csv_delimiter'] ) ) ? $_GET['csv_delimiter'] : _x( ',', 'Default CSV delimiter in the translated language (";", ",", or "tab")', 'tablepress' );
$data['pod_names'] = pods_api()->load_pods();
$data['pod_name'] = ( ! empty( $_GET['pod_name'] ) ) ? $_GET['pod_name'] : false;
return $data; return $data;
} }

View File

@ -35,7 +35,6 @@ class TablePress_ExportPods_View extends TablePress_View {
'error_export' => __( 'Error: The export failed.', 'tablepress' ), 'error_export' => __( 'Error: The export failed.', 'tablepress' ),
'error_load_table' => __( 'Error: This table could not be loaded!', 'tablepress' ), 'error_load_table' => __( 'Error: This table could not be loaded!', 'tablepress' ),
'error_table_corrupted' => __( 'Error: The internal data of this table is corrupted!', 'tablepress' ), 'error_table_corrupted' => __( 'Error: The internal data of this table is corrupted!', 'tablepress' ),
'error_create_zip_file' => __( 'Error: The ZIP file could not be created.', 'tablepress' ),
) ); ) );
$this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' ); $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
@ -64,8 +63,7 @@ class TablePress_ExportPods_View extends TablePress_View {
<?php _e( 'Regularly exporting tables is also recommended as a backup of your data.', 'tablepress' ); ?> <?php _e( 'Regularly exporting tables is also recommended as a backup of your data.', 'tablepress' ); ?>
</p> </p>
<p> <p>
<?php _e( 'To export, select the tables, the PODS parameters, and the desired export format.', 'tablepress' ); ?> <?php _e( 'To export, select the table, the PODS parameters, and the desired export format.', 'tablepress' ); ?>
<?php _e( 'If you choose more than one table, the exported files will automatically be stored in a ZIP archive file.', 'tablepress' ); ?>
<br /> <br />
<?php _e( 'Be aware that for the CSV and HTML formats only the table data, but no table options are exported!', 'tablepress' ); ?> <?php _e( 'Be aware that for the CSV and HTML formats only the table data, but no table options are exported!', 'tablepress' ); ?>
<?php _e( 'For the JSON format, the table data and the table options are exported.', 'tablepress' ); ?> <?php _e( 'For the JSON format, the table data and the table options are exported.', 'tablepress' ); ?>
@ -104,12 +102,7 @@ class TablePress_ExportPods_View extends TablePress_View {
<tbody> <tbody>
<tr> <tr>
<th class="column-1 top-align" scope="row"> <th class="column-1 top-align" scope="row">
<label for="tables-export"><?php _e( 'Tables to Export', 'tablepress' ); ?>:</label> <label for="tables-export"><?php _e( 'Table to Export', 'tablepress' ); ?>:</label>
<?php
if ( $data['zip_support_available'] ) {
echo '<br /><br /><label for="tables-export-select-all"><input type="checkbox" id="tables-export-select-all"> ' . __( 'Select all', 'tablepress' ) . '</label>';
}
?>
</th> </th>
<td class="column-2"> <td class="column-2">
<input type="hidden" name="export[tables_list]" id="tables-export-list" value="" /> <input type="hidden" name="export[tables_list]" id="tables-export-list" value="" />
@ -117,7 +110,6 @@ class TablePress_ExportPods_View extends TablePress_View {
$select_size = $data['tables_count'] + 1; // to show at least one empty row in the select $select_size = $data['tables_count'] + 1; // to show at least one empty row in the select
$select_size = max( $select_size, 3 ); $select_size = max( $select_size, 3 );
$select_size = min( $select_size, 12 ); $select_size = min( $select_size, 12 );
$size_multiple = ( $data['zip_support_available'] ) ? " size=\"{$select_size}\" multiple=\"multiple\"" : '';
?> ?>
<select id="tables-export" name="export[tables][]"<?php echo $size_multiple; ?>> <select id="tables-export" name="export[tables][]"<?php echo $size_multiple; ?>>
<?php <?php
@ -136,11 +128,6 @@ class TablePress_ExportPods_View extends TablePress_View {
} }
?> ?>
</select> </select>
<?php
if ( $data['zip_support_available'] ) {
echo '<br /><span class="description">' . __( 'You can select multiple tables by holding down the &#8220;Ctrl&#8221; key (Windows) or the &#8220;Command&#8221; key (Mac).', 'tablepress' ) . '</span>';
}
?>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -170,18 +157,16 @@ class TablePress_ExportPods_View extends TablePress_View {
</td> </td>
</tr> </tr>
<tr> <tr>
<th class="column-1" scope="row"><?php _e( 'ZIP file', 'tablepress' ); ?>:</th> <th class="column-1" scope="row"><label for="tables-export-pod-name"><?php _e( 'Pod name', 'tablepress'); ?>:</label></th>
<td class="column-2"> <td class="column-2">
<?php <select id="tables-export-pod-name" name="export[pod_name]">
if ( $data['zip_support_available'] ) { <?php
?> foreach ( $data['pod_names'] as $pod) {
<input type="checkbox" id="tables-export-zip-file" name="export[zip_file]" value="true" /> $selected = selected( $pod, $data['pod_name'], false );
<label for="tables-export-zip-file"><?php _e( 'Create a ZIP archive.', 'tablepress' ); ?> <span id="tables-export-zip-file-description" class="description hide-if-js"><?php _e( '(Mandatory if more than one table is selected.)', 'tablepress' ); ?></span></label> echo "<option{$selected} value=\"{$pod}\"?{$pod}</option>";
<?php }
} else { ?>
_e( 'Note: Support for ZIP file creation seems not to be available on this server.', 'tablepress' ); </select>
}
?>
</td> </td>
</tr> </tr>
</tbody> </tbody>