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

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

https://github.com/petergibbons/OpenCounterWP
PHP | 481 lines | 446 code | 30 blank | 5 comment | 41 complexity | 60ee291c63d50d6044db87e030f01849 MD5 | raw file
  1. <?php if ( !defined( 'WP_TABLE_RELOADED_ABSPATH' ) ) exit; // no direct loading of this file ?>
  2. <?php
  3. $rows = count( $table['data'] );
  4. $cols = (0 < $rows) ? count( $table['data'][0] ) : 0;
  5. ?>
  6. <div style="clear:both;"><p><?php _e( 'On this page, you can edit the content of the table.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php _e( 'It is also possible to change the table structure by inserting, deleting, moving, and swapping columns and rows.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?><br />
  7. <?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 ), $this->helper->safe_output( $table_id ) ); ?></p></div>
  8. <form id="wp_table_reloaded_edit_table" method="post" action="<?php echo $this->get_action_url( array( 'action' => 'edit', 'table_id' => $table_id ), false ); ?>">
  9. <?php wp_nonce_field( $this->get_nonce( 'edit' ) ); ?>
  10. <input type="hidden" name="table[id]" value="<?php echo $table['id']; ?>" />
  11. <div class="postbox<?php echo $this->helper->postbox_closed( 'table-information', false ); ?>">
  12. <h3 class="hndle"><span><?php _e( 'Table Information', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></span><span class="hide_link"><small><?php echo _x( 'Hide', 'expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span><span class="expand_link"><small><?php _e( 'Expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span></h3>
  13. <div class="inside">
  14. <table class="wp-table-reloaded-table-information">
  15. <tr>
  16. <th scope="row"><label for="table_id"><?php _e( 'Table ID', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</label></th>
  17. <td><input type="text" name="table_id" id="table_id" value="<?php echo $this->helper->safe_output( $table['id'] ); ?>" style="width:80px" /></td>
  18. </tr>
  19. <tr>
  20. <th scope="row"><label for="table_name"><?php _e( 'Table Name', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</label></th>
  21. <td><input type="text" name="table[name]" id="table_name" value="<?php echo $this->helper->safe_output( $table['name'] ); ?>" /></td>
  22. </tr>
  23. <tr>
  24. <th scope="row"><label for="table_description"><?php _e( 'Description', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</label></th>
  25. <td><textarea name="table[description]" id="table_description" rows="15" cols="40" style="height:84px;"><?php echo $this->helper->safe_output( $table['description'] ); ?></textarea></td>
  26. </tr>
  27. <?php if ( !empty( $table['last_editor_id'] ) ) { ?>
  28. <tr>
  29. <th scope="row"><?php _e( 'Last Modified', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  30. <td><?php echo $this->format_datetime( $table['last_modified'] ); ?> <?php _e( 'by', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php echo $this->get_last_editor( $table['last_editor_id'] ); ?></td>
  31. </tr>
  32. <?php } ?>
  33. </table>
  34. </div>
  35. </div>
  36. <p class="submit">
  37. <input type="submit" name="submit[update]" class="button-primary" value="<?php _e( 'Update Changes', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  38. <input type="submit" name="submit[save_back]" class="button-primary" value="<?php _e( 'Save and go back', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  39. <?php
  40. $list_url = $this->get_action_url( array( 'action' => 'list' ) );
  41. echo " <a class=\"button-primary\" href=\"{$list_url}\">" . __( 'Cancel', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  42. ?>
  43. </p>
  44. <?php if ( 0 < $cols && 0 < $rows ) { ?>
  45. <div class="postbox<?php echo $this->helper->postbox_closed( 'table-contents', false ); ?>">
  46. <h3 class="hndle"><span><?php _e( 'Table Contents', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></span><span class="hide_link"><small><?php echo _x( 'Hide', 'expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span><span class="expand_link"><small><?php _e( 'Expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span></h3>
  47. <div class="inside">
  48. <table class="widefat" style="width:auto;" id="table_contents">
  49. <tbody>
  50. <?php
  51. // first row
  52. echo "<tr class=\"table-head\">\n";
  53. echo "\t<td class=\"check-column\"><input type=\"checkbox\" style=\"display:none;\" /></td>\n";
  54. foreach ( $table['data'][0] as $col_idx => $cell_content ) {
  55. $letter = chr( ord( 'A' ) + $col_idx );
  56. $hidden = ( isset( $table['visibility']['columns'][$col_idx] ) && $table['visibility']['columns'][$col_idx] ) ? 'true': '' ;
  57. $col_hidden = ( isset( $table['visibility']['columns'][$col_idx] ) && $table['visibility']['columns'][$col_idx] ) ? ' column-hidden' : '';
  58. echo "\t<td class=\"edit_col_{$col_idx}{$col_hidden}\">{$letter}</td>\n";
  59. }
  60. echo "\t<td>&nbsp;</td>\n";
  61. echo "</tr>\n";
  62. // data rows, with checkboxes to select rows
  63. foreach ( $table['data'] as $row_idx => $table_row ) {
  64. $row_hidden = ( isset( $table['visibility']['rows'][$row_idx] ) && $table['visibility']['rows'][$row_idx] ) ? ' row-hidden' : '';
  65. echo "<tr class=\"edit_row_{$row_idx}{$row_hidden}\">\n";
  66. $output_idx = $row_idx + 1; // start counting at 1 on output
  67. $hidden = ( isset( $table['visibility']['rows'][$row_idx] ) && $table['visibility']['rows'][$row_idx] ) ? 'true': '' ;
  68. echo "\t<td class=\"check-column\"><label for=\"select_row_{$row_idx}\">{$output_idx} </label><input type=\"checkbox\" name=\"table_select[rows][{$row_idx}]\" id=\"select_row_{$row_idx}\" value=\"true\" /><input type=\"hidden\" name=\"table[visibility][rows][{$row_idx}]\" id=\"edit_row_{$row_idx}\" class=\"cell-hide\" value=\"{$hidden}\" /></td>\n";
  69. foreach ( $table_row as $col_idx => $cell_content ) {
  70. $cell_content = $this->helper->safe_output( $cell_content );
  71. $cell_name = "table[data][{$row_idx}][{$col_idx}]";
  72. $col_hidden = ( isset( $table['visibility']['columns'][$col_idx] ) && $table['visibility']['columns'][$col_idx] ) ? ' column-hidden' : '';
  73. echo "\t<td class=\"edit_col_{$col_idx}{$col_hidden}\"><textarea rows=\"1\" cols=\"20\" name=\"{$cell_name}\">{$cell_content}</textarea></td>\n";
  74. }
  75. echo "\t<th scope=\"row\">{$output_idx}</th>\n";
  76. echo "</tr>\n";
  77. }
  78. // last row (with checkboxes to select columns)
  79. echo "<tr class=\"table-foot\">\n";
  80. echo "\t<td>&nbsp;</td>\n";
  81. foreach ( $table['data'][0] as $col_idx => $cell_content ) {
  82. $letter = chr( ord( 'A' ) + $col_idx );
  83. $hidden = ( isset( $table['visibility']['columns'][$col_idx] ) && $table['visibility']['columns'][$col_idx] ) ? 'true': '' ;
  84. $col_hidden = ( isset( $table['visibility']['columns'][$col_idx] ) && $table['visibility']['columns'][$col_idx] ) ? ' column-hidden' : '';
  85. echo "\t<td class=\"check-column edit_col_{$col_idx}{$col_hidden}\"><label for=\"select_col_{$col_idx}\">{$letter} </label><input type=\"checkbox\" name=\"table_select[columns][{$col_idx}]\" id=\"select_col_{$col_idx}\" value=\"true\" /><input type=\"hidden\" name=\"table[visibility][columns][{$col_idx}]\" id=\"edit_col_{$col_idx}\" class=\"cell-hide\" value=\"{$hidden}\" /></td>\n";
  86. }
  87. echo "\t<td>&nbsp;</td>\n";
  88. echo "</tr>\n";
  89. ?>
  90. </tbody>
  91. </table>
  92. </div>
  93. </div>
  94. <?php } //endif 0 < $rows/$cols ?>
  95. <div class="postbox<?php echo $this->helper->postbox_closed( 'table-data-manipulation', false ); ?>">
  96. <h3 class="hndle"><span><?php _e( 'Data Manipulation', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></span><span class="hide_link"><small><?php echo _x( 'Hide', 'expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span><span class="expand_link"><small><?php _e( 'Expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span></h3>
  97. <div class="inside">
  98. <?php
  99. // don't show certain buttons
  100. $row_disabled = ( 1 < $rows ) ? '' : 'disabled="disabled" ';
  101. $col_disabled = ( 1 < $cols ) ? '' : 'disabled="disabled" ';
  102. ?>
  103. <table class="wp-table-reloaded-data-manipulation widefat">
  104. <tr><td>
  105. <a id="a-insert-link" class="button-primary" href="javascript:void(0);"><?php _e( 'Insert Link', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></a>
  106. <a id="a-insert-image" href="<?php echo admin_url( 'media-upload.php' ); ?>?post_id=0&amp;type=image&amp;tab=library&amp;TB_iframe=true" class="button-primary" onclick="javascript:return false;" title="<?php _e( 'Insert Image', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>"><?php _e( 'Insert Image', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></a>
  107. </td><td>
  108. <?php
  109. $col_select = '<select ' . $row_disabled . 'name="sort[col]">';
  110. foreach ( $table['data'][0] as $col_idx => $cell_content )
  111. $col_select .= "<option value=\"{$col_idx}\">" . ( chr( ord( 'A' ) + $col_idx ) ) . "</option>";
  112. $col_select .= '</select>';
  113. $sort_order_select = '<select ' . $row_disabled . 'name="sort[order]">';
  114. $sort_order_select .= "<option value=\"ASC\">" . __( 'ascending', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</option>";
  115. $sort_order_select .= "<option value=\"DESC\">" . __( 'descending', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</option>";
  116. $sort_order_select .= '</select>';
  117. printf( __( 'Sort table by column %s in %s order', WP_TABLE_RELOADED_TEXTDOMAIN ), $col_select, $sort_order_select );
  118. ?>
  119. <input type="submit" name="submit[sort]" class="button-primary" value="<?php _e( 'Sort', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" <?php echo $row_disabled; ?>/>
  120. </td></tr>
  121. <tr><td>
  122. <?php
  123. $a_rows_hide = '<a id="a-hide-rows" class="button-primary" href="javascript:void(0);">' . _x( 'Hide', 'item', WP_TABLE_RELOADED_TEXTDOMAIN ) . '</a>';
  124. $a_rows_unhide = '<a id="a-unhide-rows" class="button-primary" href="javascript:void(0);">' . _x( 'Unhide', 'item', WP_TABLE_RELOADED_TEXTDOMAIN ) . '</a>';
  125. printf( _x( 'Selected rows: %s %s', 'hide_unhide', WP_TABLE_RELOADED_TEXTDOMAIN ), $a_rows_hide, $a_rows_unhide );
  126. echo '<br />';
  127. $a_cols_hide = '<a id="a-hide-columns" class="button-primary" href="javascript:void(0);">' . _x( 'Hide', 'item', WP_TABLE_RELOADED_TEXTDOMAIN ) . '</a>';
  128. $a_cols_unhide = '<a id="a-unhide-columns" class="button-primary" href="javascript:void(0);">' . _x( 'Unhide', 'item', WP_TABLE_RELOADED_TEXTDOMAIN ) . '</a>';
  129. printf( _x( 'Selected columns: %s %s', 'hide_unhide', WP_TABLE_RELOADED_TEXTDOMAIN ), $a_cols_hide, $a_cols_unhide );
  130. ?>
  131. </td><td>
  132. <?php _e( 'Combine cells in a row:', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>
  133. <a<?php echo ( 1 < $cols ) ? ' id="a-add-colspan"' : '' ?> class="button-primary" href="javascript:void(0);" <?php echo $col_disabled; ?>><?php _e( 'Add colspan', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></a>
  134. <?php echo $this->helper->help_button( 'colspan' ); ?>
  135. <br/>
  136. <?php _e( 'Combine cells in a column:', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>
  137. <a<?php echo ( 1 < $rows ) ? ' id="a-add-rowspan"' : '' ?> class="button-primary" href="javascript:void(0);" <?php echo $row_disabled; ?>><?php _e( 'Add rowspan', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></a>
  138. <?php echo $this->helper->help_button( 'rowspan' ); ?>
  139. </td></tr>
  140. <tr><td>
  141. <?php
  142. $a_rows_insert = '<input id="button-insert-rows" type="submit" name="submit[insert_rows]" class="button-primary" value="' . __( 'Insert row', WP_TABLE_RELOADED_TEXTDOMAIN ) . '" />';
  143. $a_rows_delete = '<input id="button-delete-rows" type="submit" name="submit[delete_rows]" class="button-primary" value="' . __( 'Delete', WP_TABLE_RELOADED_TEXTDOMAIN ) . '" ' . $row_disabled . '/>';
  144. printf( _x( 'Selected rows: %s %s', 'insert_delete', WP_TABLE_RELOADED_TEXTDOMAIN ), $a_rows_insert, $a_rows_delete );
  145. echo '<br />';
  146. $a_cols_insert = '<input id="button-insert-columns" type="submit" name="submit[insert_cols]" class="button-primary" value="' . __( 'Insert column', WP_TABLE_RELOADED_TEXTDOMAIN ) . '" />';
  147. $a_cols_delete = '<input id="button-delete-columns" type="submit" name="submit[delete_cols]" class="button-primary" value="' . __( 'Delete', WP_TABLE_RELOADED_TEXTDOMAIN ) . '" ' . $col_disabled . '/>';
  148. printf( _x( 'Selected columns: %s %s', 'insert_delete', WP_TABLE_RELOADED_TEXTDOMAIN ), $a_cols_insert, $a_cols_delete );
  149. ?>
  150. </td><td>
  151. <?php
  152. // add rows/columns buttons
  153. echo "<input type=\"hidden\" name=\"insert[row][id]\" value=\"{$rows}\" /><input type=\"hidden\" name=\"insert[col][id]\" value=\"{$cols}\" />";
  154. $row_insert = '<input type="text" name="insert[row][number]" value="1" style="width:30px" />';
  155. $col_insert = '<input type="text" name="insert[col][number]" value="1" style="width:30px" />';
  156. ?>
  157. <?php printf( __( 'Add %s row(s)', WP_TABLE_RELOADED_TEXTDOMAIN ), $row_insert ); ?>
  158. <input type="submit" name="submit[append_rows]" class="button-primary" value="<?php _e( 'Add', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  159. <br/>
  160. <?php printf( __( 'Add %s column(s)', WP_TABLE_RELOADED_TEXTDOMAIN ), $col_insert ); ?>
  161. <input type="submit" name="submit[append_cols]" class="button-primary" value="<?php _e( 'Add', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  162. </td></tr>
  163. <tr><td>
  164. <?php
  165. $row1_select = '<select ' . $row_disabled . 'name="swap[row][1]">';
  166. $row2_select = '<select ' . $row_disabled . 'name="swap[row][2]">';
  167. foreach ( $table['data'] as $row_idx => $table_row ) {
  168. $row1_select .= "<option value=\"{$row_idx}\">" . ( $row_idx + 1 ) . "</option>";
  169. $row2_select .= "<option value=\"{$row_idx}\">" . ( $row_idx + 1 ) . "</option>";
  170. }
  171. $row1_select .= '</select>';
  172. $row2_select .= '</select>';
  173. printf( __( 'Swap rows %s and %s', WP_TABLE_RELOADED_TEXTDOMAIN ), $row1_select, $row2_select );
  174. ?>
  175. <input type="submit" name="submit[swap_rows]" class="button-primary" value="<?php _e( 'Swap', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" <?php echo $row_disabled; ?>/>
  176. <br/>
  177. <?php
  178. $col1_select = '<select ' . $col_disabled . 'name="swap[col][1]">';
  179. $col2_select = '<select ' . $col_disabled . 'name="swap[col][2]">';
  180. foreach ( $table['data'][0] as $col_idx => $cell_content ) {
  181. $col_letter = chr( ord( 'A' ) + $col_idx );
  182. $col1_select .= "<option value=\"{$col_idx}\">{$col_letter}</option>";
  183. $col2_select .= "<option value=\"{$col_idx}\">{$col_letter}</option>";
  184. }
  185. $col1_select .= '</select>';
  186. $col2_select .= '</select>';
  187. printf( __( 'Swap columns %s and %s', WP_TABLE_RELOADED_TEXTDOMAIN ), $col1_select, $col2_select );
  188. ?>
  189. <input type="submit" name="submit[swap_cols]" class="button-primary" value="<?php _e( 'Swap', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" <?php echo $col_disabled; ?>/>
  190. </td><td>
  191. <?php
  192. $row1_select = '<select ' . $row_disabled . 'name="move[row][1]">';
  193. $row2_select = '<select ' . $row_disabled . 'name="move[row][2]">';
  194. foreach ( $table['data'] as $row_idx => $table_row ) {
  195. $row1_select .= "<option value=\"{$row_idx}\">" . ( $row_idx + 1 ) . "</option>";
  196. $row2_select .= "<option value=\"{$row_idx}\">" . ( $row_idx + 1 ) . "</option>";
  197. }
  198. $row1_select .= '</select>';
  199. $row2_select .= '</select>';
  200. $move_where_select = '<select ' . $row_disabled . 'name="move[row][where]">';
  201. $move_where_select .= "<option value=\"before\">" . __( 'before', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</option>";
  202. $move_where_select .= "<option value=\"after\">" . __( 'after', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</option>";
  203. $move_where_select .= '</select>';
  204. printf( __( 'Move row %s %s row %s', WP_TABLE_RELOADED_TEXTDOMAIN ), $row1_select, $move_where_select, $row2_select );
  205. ?>
  206. <input type="submit" name="submit[move_row]" class="button-primary" value="<?php _e( 'Move', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" <?php echo $row_disabled; ?>/>
  207. <br/>
  208. <?php
  209. $col1_select = '<select ' . $col_disabled . 'name="move[col][1]">';
  210. $col2_select = '<select ' . $col_disabled . 'name="move[col][2]">';
  211. foreach ( $table['data'][0] as $col_idx => $cell_content ) {
  212. $col_letter = chr( ord( 'A' ) + $col_idx );
  213. $col1_select .= "<option value=\"{$col_idx}\">{$col_letter}</option>";
  214. $col2_select .= "<option value=\"{$col_idx}\">{$col_letter}</option>";
  215. }
  216. $col1_select .= '</select>';
  217. $col2_select .= '</select>';
  218. $move_where_select = '<select ' . $col_disabled . 'name="move[col][where]">';
  219. $move_where_select .= "<option value=\"before\">" . __( 'before', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</option>";
  220. $move_where_select .= "<option value=\"after\">" . __( 'after', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</option>";
  221. $move_where_select .= '</select>';
  222. printf( __( 'Move column %s %s column %s', WP_TABLE_RELOADED_TEXTDOMAIN ), $col1_select, $move_where_select, $col2_select );
  223. ?>
  224. <input type="submit" name="submit[move_col]" class="button-primary" value="<?php _e( 'Move', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" <?php echo $col_disabled; ?>/>
  225. </td></tr>
  226. </table>
  227. </div>
  228. </div>
  229. <p class="submit">
  230. <input type="submit" name="submit[update]" class="button-primary" value="<?php _e( 'Update Changes', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  231. <input type="submit" name="submit[save_back]" class="button-primary" value="<?php _e( 'Save and go back', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  232. <?php
  233. $list_url = $this->get_action_url( array( 'action' => 'list' ) );
  234. echo " <a class=\"button-primary\" href=\"{$list_url}\">" . __( 'Cancel', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  235. ?>
  236. </p>
  237. <div class="postbox<?php echo $this->helper->postbox_closed( 'table-styling-options', false ); ?>">
  238. <h3 class="hndle"><span><?php _e( 'Table Styling Options', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></span><span class="hide_link"><small><?php echo _x( 'Hide', 'expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span><span class="expand_link"><small><?php _e( 'Expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span></h3>
  239. <div class="inside">
  240. <p><?php _e( 'These settings will only be used for this table.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></p>
  241. <table class="wp-table-reloaded-options">
  242. <tr>
  243. <th scope="row"><?php _e( 'Alternating row colors', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  244. <td><input type="checkbox" name="table[options][alternating_row_colors]" id="table_options_alternating_row_colors"<?php checked( $table['options']['alternating_row_colors'] ); ?> value="true" /> <label for="table_options_alternating_row_colors"><?php _e( 'Every second row has an alternating background color.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  245. </tr>
  246. <tr>
  247. <th scope="row"><?php _e( 'Row Highlighting', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  248. <td><input type="checkbox" name="table[options][row_hover]" id="table_options_row_hover"<?php checked( $table['options']['row_hover'] ); ?> value="true" /> <label for="table_options_row_hover"><?php _e( 'Highlight a row by changing its background color while the mouse cursor hovers above it.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  249. </tr>
  250. <tr>
  251. <th scope="row"><?php _e( 'Table head', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  252. <td><input type="checkbox" name="table[options][first_row_th]" id="table_options_first_row_th"<?php checked( $table['options']['first_row_th'] ); ?> value="true" /> <label for="table_options_first_row_th"><?php _e( 'The first row of your table is the table head (HTML tags &lt;thead&gt; and &lt;th&gt;).', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  253. </tr>
  254. <tr>
  255. <th scope="row"><?php _e( 'Table footer', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  256. <td><input type="checkbox" name="table[options][table_footer]" id="table_options_table_footer"<?php checked( $table['options']['table_footer'] ); ?> value="true" /> <label for="table_options_table_footer"><?php _e( 'The last row of your table is the table footer (HTML tags &lt;tfoot&gt; and &lt;th&gt;).', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  257. </tr>
  258. <tr>
  259. <th scope="row"><?php _e( 'Table Name', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  260. <td><input type="checkbox" name="table[options][print_name]" id="table_options_print_name"<?php checked( $table['options']['print_name'] ); ?> value="true" /> <label for="table_options_print_name"></label>
  261. <?php
  262. $disabled = disabled( $table['options']['print_name'], false, false );
  263. $position_select = "<select{$disabled} id='table_options_print_name_position' name='table[options][print_name_position]'>";
  264. $selected = selected( $table['options']['print_name_position'], 'above', false );
  265. $position_select .= "<option{$selected} value='above'>" . __( 'above', WP_TABLE_RELOADED_TEXTDOMAIN ) . '</option>';
  266. $selected = selected( $table['options']['print_name_position'], 'below', false );
  267. $position_select .= "<option{$selected} value='below'>" . __( 'below', WP_TABLE_RELOADED_TEXTDOMAIN ) . '</option>';
  268. $position_select .= '</select>';
  269. echo '<span style="vertical-align: middle;">';
  270. printf( __( 'The Table Name shall be written %s the table (HTML tag &lt;h2&gt;).', WP_TABLE_RELOADED_TEXTDOMAIN ), $position_select );
  271. echo '</span>';
  272. ?>
  273. </td>
  274. </tr>
  275. <tr>
  276. <th scope="row"><?php _e( 'Table Description', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  277. <td><input type="checkbox" name="table[options][print_description]" id="table_options_print_description"<?php checked( $table['options']['print_description'] ); ?> value="true" /> <label for="table_options_print_description"></label>
  278. <?php
  279. $disabled = disabled( $table['options']['print_description'], false, false );
  280. $position_select = "<select{$disabled} id='table_options_print_description_position' name='table[options][print_description_position]'>";
  281. $selected = selected( $table['options']['print_description_position'], 'above', false );
  282. $position_select .= "<option{$selected} value='above'>" . __( 'above', WP_TABLE_RELOADED_TEXTDOMAIN ) . '</option>';
  283. $selected = selected( $table['options']['print_description_position'], 'below', false );
  284. $position_select .= "<option{$selected} value='below'>" . __( 'below', WP_TABLE_RELOADED_TEXTDOMAIN ) . '</option>';
  285. $position_select .= '</select>';
  286. echo '<span style="vertical-align: middle;">';
  287. printf( __( 'The Table Description shall be written %s the table.', WP_TABLE_RELOADED_TEXTDOMAIN ), $position_select );
  288. echo '</span>';
  289. ?>
  290. </td>
  291. </tr>
  292. <tr>
  293. <th scope="row"><?php _e( 'Cache Table Output', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  294. <td><input type="checkbox" name="table[options][cache_table_output]" id="table_options_cache_table_output"<?php checked( $table['options']['cache_table_output'] ); ?> value="true" /> <label for="table_options_cache_table_output"><?php _e( 'The resulting HTML output of the table shall be cached in the WordPress database cache for faster page generation.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  295. </tr>
  296. <tr>
  297. <th scope="row"><?php _e( 'Extra CSS Class', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  298. <td><input type="text" name="table[options][custom_css_class]" id="table_options_custom_css_class" value="<?php echo $this->helper->safe_output( $table['options']['custom_css_class'] ); ?>" style="width:100%" /> <label for="table_options_custom_css_class"><small><br/><?php _e( 'Enter a string that will be given to the table as an additional class for styling with CSS.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php _e( 'This is not the place to enter "Custom CSS" code!', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></label></td>
  299. </tr>
  300. <tr id="options_use_tablesorter">
  301. <th scope="row"><?php _e( 'Use JavaScript library', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  302. <td>
  303. <?php
  304. switch ( $this->options['tablesorter_script'] ) {
  305. case 'datatables':
  306. $js_library = 'DataTables';
  307. $js_library_text = __( 'You can change further settings for this library below.' , WP_TABLE_RELOADED_TEXTDOMAIN );
  308. break;
  309. case 'datatables-tabletools':
  310. $js_library = 'DataTables+TableTools';
  311. $js_library_text = __( 'You can change further settings for this library below.' , WP_TABLE_RELOADED_TEXTDOMAIN );
  312. break;
  313. case 'tablesorter':
  314. $js_library = 'Tablesorter';
  315. $js_library_text = __( 'The table will then be sortable by the visitor.' , WP_TABLE_RELOADED_TEXTDOMAIN );
  316. break;
  317. case 'tablesorter_extended':
  318. $js_library = 'Tablesorter Extended';
  319. $js_library_text = __( 'The table will then be sortable by the visitor.' , WP_TABLE_RELOADED_TEXTDOMAIN );
  320. break;
  321. default;
  322. $js_library = 'DataTables';
  323. $js_library_text = __( 'You can change further settings for this library below.' , WP_TABLE_RELOADED_TEXTDOMAIN );
  324. }
  325. ?>
  326. <input type="checkbox" name="table[options][use_tablesorter]" id="table_options_use_tablesorter"<?php checked( $table['options']['use_tablesorter'] ); ?><?php echo ( !$this->options['enable_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"': '' ; ?> value="true" /> <label for="table_options_use_tablesorter"><?php printf( __( 'Yes, use the &quot;%s&quot; JavaScript library with this table.', WP_TABLE_RELOADED_TEXTDOMAIN ), $js_library ); ?> <?php echo $js_library_text; ?><?php if ( !$this->options['enable_tablesorter'] ) { ?><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small><?php printf( __( 'You must enable the use of a JavaScript library on the &quot;%s&quot; screen first.', WP_TABLE_RELOADED_TEXTDOMAIN ), __( 'Plugin Options', WP_TABLE_RELOADED_TEXTDOMAIN ) ); ?></small><?php } ?></label></td>
  327. </tr>
  328. </table>
  329. </div>
  330. </div>
  331. <?php
  332. $datatables_enabled = $this->options['enable_tablesorter'] && ( 'datatables' == $this->options['tablesorter_script'] || 'datatables-tabletools' == $this->options['tablesorter_script'] );
  333. $tabletools_enabled = $this->options['enable_tablesorter'] && ( 'datatables-tabletools' == $this->options['tablesorter_script'] );
  334. ?>
  335. <div class="postbox<?php echo $this->helper->postbox_closed( 'datatables-features', false ); ?>">
  336. <h3 class="hndle"><span><?php _e( 'DataTables JavaScript Features', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></span><span class="hide_link"><small><?php echo _x( 'Hide', 'expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span><span class="expand_link"><small><?php _e( 'Expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span></h3>
  337. <div class="inside">
  338. <p><?php _e( 'You can enable certain features for the DataTables JavaScript library here.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php _e( 'More information on these features can be found on the <a href="http://www.datatables.net/">DataTables website</a>.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></p>
  339. <?php if ( !$datatables_enabled ) { ?>
  340. <p><strong><?php printf( __( 'You can currently not change these options, because you have not enabled the &quot;DataTables&quot; or the &quot;DataTables+TableTools&quot; JavaScript library on the &quot;%s&quot; screen.', WP_TABLE_RELOADED_TEXTDOMAIN ), __( 'Plugin Options', WP_TABLE_RELOADED_TEXTDOMAIN ) ); ?><br/><?php _e( 'It is not possible to use these features with the &quot;Tablesorter&quot; or &quot;Tablesorter Extended&quot; libraries.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></strong></p>
  341. <?php } ?>
  342. <table class="wp-table-reloaded-options wp-table-reloaded-datatables-options">
  343. <tr>
  344. <th scope="row"><?php _e( 'Sorting', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  345. <td><input type="checkbox" name="table[options][datatables_sort]" id="table_options_datatables_sort"<?php checked( $table['options']['datatables_sort'] ); ?><?php echo ( !$datatables_enabled || !$table['options']['use_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"': '' ; ?> value="true" /> <label for="table_options_datatables_sort"><?php _e( 'Yes, enable sorting of table data by the visitor.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  346. </tr>
  347. <tr>
  348. <th scope="row"><?php _e( 'Pagination', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  349. <td><input type="checkbox" name="table[options][datatables_paginate]" id="table_options_datatables_paginate"<?php checked( $table['options']['datatables_paginate'] ); ?><?php echo ( !$datatables_enabled || !$table['options']['use_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"': '' ; ?> value="true" /> <label for="table_options_datatables_paginate">
  350. <?php
  351. $disabled = ( !$table['options']['datatables_paginate'] || !$datatables_enabled || !$table['options']['use_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"' : '' ;
  352. $paginate_entries = '<input type="text"' . $disabled . ' id="table_options_datatables_paginate_entries" name="table[options][datatables_paginate_entries]" value="' . $this->helper->safe_output( $table['options']['datatables_paginate_entries'] ) . '" style="width:35px;" />';
  353. echo __( 'Yes, enable pagination (showing only a certain number of rows) of the table by the visitor.', WP_TABLE_RELOADED_TEXTDOMAIN );
  354. echo '</label> <span style="vertical-align: middle;">';
  355. printf( __( 'Show %1$s rows of the table per page.', WP_TABLE_RELOADED_TEXTDOMAIN ), $paginate_entries );
  356. echo '</span>';
  357. ?>
  358. </td>
  359. </tr>
  360. <tr>
  361. <th scope="row"><?php _e( 'Length Change', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  362. <td><input type="checkbox" name="table[options][datatables_lengthchange]" id="table_options_datatables_lengthchange"<?php checked( $table['options']['datatables_lengthchange'] ); ?><?php echo ( !$datatables_enabled || !$table['options']['use_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"': '' ; ?> value="true" /> <label for="table_options_datatables_lengthchange"><?php _e( 'Yes, allow the visitor to change the number of rows shown when using pagination.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  363. </tr>
  364. <tr>
  365. <th scope="row"><?php _e( 'Filtering/Search', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  366. <td><input type="checkbox" name="table[options][datatables_filter]" id="table_options_datatables_filter"<?php checked( $table['options']['datatables_filter'] ); ?><?php echo ( !$datatables_enabled || !$table['options']['use_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"': '' ; ?> value="true" /> <label for="table_options_datatables_filter"><?php _e( 'Yes, enable the visitor to filter or search the table. Only rows with the search word in them are shown.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  367. </tr>
  368. <tr>
  369. <th scope="row"><?php _e( 'Info Bar', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  370. <td><input type="checkbox" name="table[options][datatables_info]" id="table_options_datatables_info"<?php checked( $table['options']['datatables_info'] ); ?><?php echo ( !$datatables_enabled || !$table['options']['use_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"': '' ; ?> value="true" /> <label for="table_options_datatables_info"><?php _e( 'Yes, show the table information display. This shows information and statistics about the currently visible data, including filtering.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></label></td>
  371. </tr>
  372. <tr>
  373. <th scope="row"><?php _e( 'TableTools', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  374. <td><input type="checkbox" name="table[options][datatables_tabletools]" id="table_options_datatables_tabletools"<?php checked( $table['options']['datatables_tabletools'] ); ?><?php echo ( !$tabletools_enabled || !$table['options']['use_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"': '' ; ?> value="true" /> <label for="table_options_datatables_tabletools">
  375. <?php _e( 'Yes, activate the TableTools functions (Copy to Clipboard, Save to CSV, Save to XLS, Print Table) for this table.', WP_TABLE_RELOADED_TEXTDOMAIN );
  376. if ( !$tabletools_enabled ) { echo '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small>('; _e( 'This option can only be used with the &quot;DataTables+TableTools&quot; JavaScript library.', WP_TABLE_RELOADED_TEXTDOMAIN ); echo ')</small>';}
  377. ?></label></td>
  378. </tr>
  379. <tr>
  380. <th scope="row"><?php _e( 'Custom Commands', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>:</th>
  381. <td><input type="text" name="table[options][datatables_customcommands]" id="table_options_datatables_customcommands"<?php echo ( !$datatables_enabled || !$table['options']['use_tablesorter'] || !$table['options']['first_row_th'] ) ? ' disabled="disabled"': '' ; ?> value="<?php echo $this->helper->safe_output( $table['options']['datatables_customcommands'] ); ?>" style="width:100%" /> <label for="table_options_datatables_customcommands"><small><br/><?php _e( 'Enter additional DataTables JavaScript parameters that will be included with the script call here.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> (<?php _e( 'For advanced use only. Read the <a href="http://www.datatables.net/">DataTables documentation</a> before.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>)</small></label></td>
  382. </tr>
  383. </table>
  384. </div>
  385. </div>
  386. <p class="submit">
  387. <input type="submit" name="submit[update]" class="button-primary" value="<?php _e( 'Update Changes', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  388. <input type="submit" name="submit[save_back]" class="button-primary" value="<?php _e( 'Save and go back', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  389. <?php
  390. $list_url = $this->get_action_url( array( 'action' => 'list' ) );
  391. echo " <a class=\"button-primary\" href=\"{$list_url}\">" . __( 'Cancel', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  392. ?>
  393. </p>
  394. <div class="postbox<?php echo $this->helper->postbox_closed( 'custom-data-fields', true ); ?>">
  395. <h3 class="hndle"><span><?php _e( 'Custom Data Fields', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></span><span class="hide_link"><small><?php echo _x( 'Hide', 'expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span><span class="expand_link"><small><?php _e( 'Expand', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></small></span></h3>
  396. <div class="inside">
  397. <?php _e( 'Custom Data Fields can be used to add extra metadata to a table.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?> <?php _e( 'For example, this could be information about the source or the creator of the data.', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>
  398. <br/>
  399. <?php printf( __( 'You can show this data in the same way as tables by using the shortcode <strong>[table-info id=%s field="&lt;field-name&gt;" /]</strong>.', WP_TABLE_RELOADED_TEXTDOMAIN ), $this->helper->safe_output( $table_id ) ); ?>
  400. <br/><br/>
  401. <?php if ( isset( $table['custom_fields'] ) && !empty( $table['custom_fields'] ) ) { ?>
  402. <table class="widefat" style="width:100%" id="table_custom_fields">
  403. <thead>
  404. <tr>
  405. <th scope="col"><?php _e( 'Field Name', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  406. <th scope="col"><?php _e( 'Value', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  407. <th scope="col"><?php _e( 'Action', WP_TABLE_RELOADED_TEXTDOMAIN ); ?></th>
  408. </tr>
  409. </thead>
  410. <tbody>
  411. <?php
  412. foreach ( $table['custom_fields'] as $name => $value ) {
  413. $name = $this->helper->safe_output( $name );
  414. $value = $this->helper->safe_output( $value );
  415. echo "<tr>\n";
  416. echo "\t<td style=\"width:10%;\">{$name}</td>\n";
  417. echo "\t<td style=\"width:75%;\"><textarea rows=\"1\" cols=\"20\" name=\"table[custom_fields][{$name}]\" style=\"width:90%\">{$value}</textarea></td>\n";
  418. $delete_cf_url = $this->get_action_url( array( 'action' => 'delete', 'table_id' => $table['id'], 'item' => 'custom_field', 'element_id' => $name ), true );
  419. echo "\t<td style=\"width:15%;min-width:200px;\">";
  420. echo "<a href=\"{$delete_cf_url}\">" . __( 'Delete Field', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  421. $shortcode = "[table-info id=" . $this->helper->safe_output( $table_id ) . " field=&quot;{$name}&quot; /]";
  422. echo " | <a href=\"javascript:void(0);\" class=\"cf_shortcode_link\" title=\"{$shortcode}\">" . __( 'View shortcode', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  423. echo "</td>\n";
  424. echo "</tr>";
  425. }
  426. ?>
  427. </tbody>
  428. </table>
  429. <br/>
  430. <?php } // endif custom_fields ?>
  431. <?php _e( 'To add a new Custom Data Field, enter its name (only lowercase letters, numbers, _ and -).', WP_TABLE_RELOADED_TEXTDOMAIN ); ?><br/>
  432. <?php _e( 'Custom Data Field Name', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>: <input type="text" id="insert_custom_field_name" name="insert[custom_field]" value="" style="width:300px" /> <input type="submit" name="submit[insert_cf]" class="button-primary" value="<?php _e( 'Add', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  433. </div>
  434. </div>
  435. <p class="submit">
  436. <input type="submit" name="submit[update]" class="button-primary" value="<?php _e( 'Update Changes', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  437. <input type="submit" name="submit[save_back]" class="button-primary" value="<?php _e( 'Save and go back', WP_TABLE_RELOADED_TEXTDOMAIN ); ?>" />
  438. <?php
  439. $list_url = $this->get_action_url( array( 'action' => 'list' ) );
  440. echo " <a class=\"button-primary\" href=\"{$list_url}\">" . __( 'Cancel', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  441. ?>
  442. </p>
  443. <p>
  444. <?php echo __( 'Other actions', WP_TABLE_RELOADED_TEXTDOMAIN ) . ':';
  445. $delete_url = $this->get_action_url( array( 'action' => 'delete', 'table_id' => $table['id'], 'item' => 'table' ), true );
  446. $export_url = $this->get_action_url( array( 'action' => 'export', 'table_id' => $table['id'] ), false );
  447. echo " <a class=\"button-secondary delete_table_link\" href=\"{$delete_url}\">" . __( 'Delete Table', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  448. echo " <a class=\"button-secondary\" href=\"{$export_url}\">" . __( 'Export Table', WP_TABLE_RELOADED_TEXTDOMAIN ) . "</a>";
  449. ?>
  450. </p>
  451. </form>