PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/petergibbons/OpenCounterWP
PHP | 93 lines | 86 code | 5 blank | 2 comment | 6 complexity | b06f381de2b4412fce6e0ce857ff407e MD5 | raw file
  1. <?php if ( !defined( 'WP_TABLE_RELOADED_ABSPATH' ) ) exit; // no direct loading of this file ?>
  2. <div style="clear:both;"><p><?php _e( 'This is a list of all available tables.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php _e( 'You may add, edit, copy, delete or preview tables here.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?><br /><br/><?php printf( __( 'To insert the table into a page, post or text-widget, copy the shortcode <strong>[table id=%s /]</strong> and paste it into the corresponding place in the editor.', WP_TABLE_RELOADED_TEXTDOMAIN ), '&lt;ID&gt;' ); ?> <?php _e( 'Each table has a unique ID that needs to be adjusted in that shortcode.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php printf( __( 'You can also click the button &quot;%s&quot; in the editor toolbar to select and insert a table.', WP_TABLE_RELOADED_TEXTDOMAIN ), __( 'Table', WP_TABLE_RELOADED_TEXTDOMAIN ) ); ?></p></div>
  3. <?php
  4. if ( 0 < count( $this->tables ) ) {
  5. ?>
  6. <div style="clear:both;">
  7. <form method="post" action="<?php echo $this->get_action_url(); ?>">
  8. <?php wp_nonce_field( $this->get_nonce( 'bulk_edit' ) ); ?>
  9. <table class="widefat" id="wp-table-reloaded-list">
  10. <thead>
  11. <tr>
  12. <th class="check-column" scope="col"><input type="checkbox" /></th>
  13. <th scope="col"><?php _e( 'ID', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  14. <th scope="col" style="display:none;"></th>
  15. <th scope="col"><?php _e( 'Table Name', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  16. <th scope="col"><?php _e( 'Description', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  17. <th scope="col"><?php _e( 'Last Modified', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  18. </tr>
  19. </thead>
  20. <tfoot>
  21. <tr>
  22. <th class="check-column" scope="col"><input type="checkbox" /></th>
  23. <th scope="col"><?php _e( 'ID', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  24. <th scope="col" style="display:none;"></th>
  25. <th scope="col"><?php _e( 'Table Name', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  26. <th scope="col"><?php _e( 'Description', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  27. <th scope="col"><?php _e( 'Last Modified', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  28. </tr>
  29. </tfoot>
  30. <tbody>
  31. <?php
  32. $bg_style_index = 0;
  33. foreach ( $this->tables as $id => $tableoptionname ) {
  34. $bg_style_index++;
  35. $bg_style = ( 1 == ($bg_style_index % 2) ) ? ' class="alternate"' : '';
  36. // get name and description to show in list
  37. $table = $this->load_table( $id );
  38. $name = ( !empty( $table['name'] ) ) ? $this->helper->safe_output( $table['name'] ) : __( '(no name)', WP_TABLE_RELOADED_TEXTDOMAIN );
  39. $description = ( !empty( $table['description'] ) ) ? $this->helper->safe_output( $table['description'] ) : __( '(no description)', WP_TABLE_RELOADED_TEXTDOMAIN );
  40. $last_modified = $this->format_datetime( $table['last_modified'] );
  41. $last_editor = $this->get_last_editor( $table['last_editor_id'] );
  42. if ( !empty( $last_editor ) )
  43. $last_editor = __( 'by', WP_TABLE_RELOADED_TEXTDOMAIN ) . ' ' . $last_editor;
  44. unset( $table );
  45. $edit_url = $this->get_action_url( array( 'action' => 'edit', 'table_id' => $id ), false );
  46. $copy_url = $this->get_action_url( array( 'action' => 'copy', 'table_id' => $id ), true );
  47. $export_url = $this->get_action_url( array( 'action' => 'export', 'table_id' => $id ), false );
  48. $delete_url = $this->get_action_url( array( 'action' => 'delete', 'table_id' => $id, 'item' => 'table' ), true );
  49. $preview_url = $this->get_action_url( array( 'action' => 'ajax_preview', 'table_id' => $id ), true );
  50. echo "<tr id=\"wp-table-reloaded-table-{$id}\" {$bg_style}>\n";
  51. echo "\t<td class=\"check-column no-wrap\"><input type=\"checkbox\" name=\"tables[]\" value=\"{$id}\" /></td>\n";
  52. echo "\t<td class=\"no-wrap table-id\">{$id}</td>\n";
  53. echo "\t<td style=\"display:none;\">{$name}</td>\n";
  54. echo "\t<td>\n";
  55. echo "\t\t<a title=\"" . sprintf( __( 'Edit %s', WP_TABLE_RELOADED_TEXTDOMAIN ), "&quot;{$name}&quot;" ) . "\" class=\"row-title\" href=\"{$edit_url}\">{$name}</a>\n";
  56. echo "\t\t<div class=\"row-actions no-wrap\">";
  57. echo "<a href=\"{$edit_url}\">" . __( 'Edit', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>" . " | ";
  58. $shortcode = "[table id={$id} /]";
  59. echo "<a href=\"javascript:void(0);\" class=\"table_shortcode_link\" title=\"{$shortcode}\">" . __( 'Shortcode', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>" . " | ";
  60. echo "<a class=\"copy_table_link\" href=\"{$copy_url}\">" . __( 'Copy', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>" . " | ";
  61. echo "<a href=\"{$export_url}\">" . __( 'Export', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>" . " | ";
  62. echo "<span class=\"delete\"><a class=\"delete_table_link\" href=\"{$delete_url}\">" . __( 'Delete', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a></span>" . " | ";
  63. $preview_title = sprintf( __( 'Preview of Table %s', WP_TABLE_RELOADED_TEXTDOMAIN ), $id );
  64. echo "<a class=\"preview-link\" href=\"{$preview_url}\" title=\"{$preview_title}\">" . __( 'Preview', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  65. echo "</div>\n";
  66. echo "\t</td>\n";
  67. echo "\t<td>{$description}</td>\n";
  68. echo "\t<td class=\"no-wrap\">{$last_modified}<br/>{$last_editor}</td>\n";
  69. echo "</tr>\n";
  70. }
  71. ?>
  72. </tbody>
  73. </table>
  74. <input type="hidden" name="action" value="bulk_edit" />
  75. <p class="submit" style="clear:both;"><?php _e( 'Bulk actions:', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <input type="submit" name="submit[copy]" class="button-primary bulk_copy_tables" value="<?php _e( 'Copy Tables', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" /> <input type="submit" name="submit[delete]" class="button-primary bulk_delete_tables" value="<?php _e( 'Delete Tables', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  76. </p>
  77. </form>
  78. </div>
  79. <?php
  80. } else { // end if $tables
  81. $add_url = $this->get_action_url( array( 'action' => 'add' ), false );
  82. $import_url = $this->get_action_url( array( 'action' => 'import' ), false );
  83. echo "<div style=\"clear:both;\"><p>" . __( 'No tables were found.', WP_TABLE_RELOADED_TEXTDOMAIN ) . '<br/><br/><strong>' . 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 ) . "</strong></p></div>";
  84. }
  85. // add tablesorter script
  86. if ( 0 < count( $this->tables ) )
  87. add_action( 'admin_footer', array( &$this, 'output_tablesorter_js' ) );
  88. ?>