PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/wp-table-reloaded/views/view-export.php

https://github.com/petergibbons/OpenCounterWP
PHP | 74 lines | 69 code | 2 blank | 3 comment | 10 complexity | 431612f54223651bb11dbee850a4a034 MD5 | raw file
  1. <?php if ( !defined( 'WP_TABLE_RELOADED_ABSPATH' ) ) exit; // no direct loading of this file ?>
  2. <?php
  3. // Begin Export Table Form
  4. $table = $this->load_table( $table_id );
  5. $rows = count( $table['data'] );
  6. $cols = (0 < $rows) ? count( $table['data'][0] ) : 0;
  7. ?>
  8. <div style="clear:both;">
  9. <p><?php _e( 'It is recommended to export and backup the data of important tables regularly.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php _e( 'Select the table, the desired export format and (for CSV only) a delimiter.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php _e( 'You may choose to download the export file. Otherwise it will be shown on this page.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?><br/><?php _e( 'Be aware that only the table data, but no options or settings are exported.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?><br/><?php printf( __( 'To backup all tables, including their settings, at once use the &quot;%s&quot; button in the &quot;%s&quot;.', WP_TABLE_RELOADED_TEXTDOMAIN ), __( 'Create and Download Dump File', WP_TABLE_RELOADED_TEXTDOMAIN ), __( 'Plugin Options', WP_TABLE_RELOADED_TEXTDOMAIN ) ); ?></p>
  10. </div>
  11. <?php if ( 0 < count( $this->tables ) ) { ?>
  12. <div style="clear:both;">
  13. <form method="post" action="<?php echo $this->get_action_url(); ?>">
  14. <?php wp_nonce_field( $this->get_nonce( 'export' ) ); ?>
  15. <table class="wp-table-reloaded-options">
  16. <tr>
  17. <th scope="row"><label for="table_id"><?php _e( 'Select Table to Export', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</label></th>
  18. <td><select id="table_id" name="table_id">
  19. <?php
  20. foreach ( $this->tables as $id => $tableoptionname ) {
  21. // get name and description to show in list
  22. $table = $this->load_table( $id );
  23. $name = $this->helper->safe_output( $table['name'] );
  24. //$description = $this->helper->safe_output( $table['description'] );
  25. unset( $table );
  26. $selected = selected( $table_id, $id, false );
  27. echo "<option{$selected} value='{$id}'>{$name} (ID {$id})</option>";
  28. }
  29. ?>
  30. </select></td>
  31. </tr>
  32. <tr>
  33. <th scope="row"><label for="export_format"><?php _e( 'Select Export Format', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</label></th>
  34. <td><select id="export_format" name="export_format">
  35. <?php
  36. $export_formats = $this->export_instance->export_formats;
  37. foreach ( $export_formats as $export_format => $longname )
  38. echo "<option" . ( ( isset( $_POST['export_format'] ) && $export_format == $_POST['export_format'] ) ? ' selected="selected"': '' ) . " value=\"{$export_format}\">{$longname}</option>";
  39. ?>
  40. </select></td>
  41. </tr>
  42. <tr class="tr-export-delimiter">
  43. <th scope="row"><label for="delimiter"><?php _e( 'Select Delimiter to use', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</label></th>
  44. <td><select id="delimiter" name="delimiter">
  45. <?php
  46. $delimiters = $this->export_instance->delimiters;
  47. foreach ( $delimiters as $delimiter => $longname )
  48. echo "<option" . ( ( isset( $_POST['delimiter'] ) && $delimiter == $_POST['delimiter'] ) ? ' selected="selected"': '' ) . " value=\"{$delimiter}\">{$longname}</option>";
  49. ?>
  50. </select> <small>(<?php _e( 'Only needed for CSV export.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>)</small></td>
  51. </tr>
  52. <tr>
  53. <th scope="row"><?php _e( 'Download file', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  54. <td><input type="checkbox" name="download_export_file" id="download_export_file" value="true"<?php echo ( isset( $_POST['submit'] ) && !isset( $_POST['download_export_file'] ) ) ? '' : ' checked="checked"'; ?> /> <label for="download_export_file"><?php _e( 'Yes, I want to download the export file.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  55. </tr>
  56. </table>
  57. <input type="hidden" name="action" value="export" />
  58. <p class="submit">
  59. <input type="submit" name="submit" class="button-primary" value="<?php _e( 'Export Table', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  60. </p>
  61. <?php if ( isset( $output ) && $output ) { ?>
  62. <textarea rows="15" cols="40" style="width:600px;height:300px;"><?php echo htmlspecialchars( $output ); ?></textarea>
  63. <?php } ?>
  64. </form>
  65. </div>
  66. <?php
  67. } else { // end if $tables
  68. $add_url = $this->get_action_url( array( 'action' => 'add' ), false );
  69. $import_url = $this->get_action_url( array( 'action' => 'import' ), false );
  70. echo "<div style=\"clear:both;\"><p>" . __( 'No tables were found.', WP_TABLE_RELOADED_TEXTDOMAIN ) . '<br/>' . sprintf( __( 'You should <a href="%s">add</a> or <a href="%s">import</a> a table to get started!', WP_TABLE_RELOADED_TEXTDOMAIN ), $add_url, $import_url ) . "</p></div>";
  71. }
  72. ?>