PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.42
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.42
5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 5.5.43 All 159 releases
wp-data-access / WPDataProjects / Project / WPDP_Project_Table_Form.php

WPDP_Project_Table_Form.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.42, at WPDataProjects/Project/WPDP_Project_Table_Form.php

1,998 lines 70.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 *
6 * @package WPDataProjects\Project
7 */
8 namespace WPDataProjects\Project;
9
10 use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Exist;
11 use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists;
12 use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model;
13 use WPDataAccess\WPDA;
14 use WPDataProjects\Data_Dictionary\WPDP_List_Columns_Cache;
15 use WPDataAccess\Utilities\WPDA_Message_Box;
16 use WPDataAccess\Plugin_Table_Models\WPDP_Project_Design_Table_Model;
17 use WPDataAccess\Utilities\WPDA_Reverse_Engineering;
18 use WPDataProjects\WPDP;
19 use WPDataAccess\Dashboard\WPDA_Dashboard;
20 /**
21 * Class WPDP_Project_Table_Form
22 *
23 * @author Peter Schulz
24 * @since 2.0.0
25 */
26 class WPDP_Project_Table_Form {
27 /**
28 * Menu slug
29 *
30 * @var string
31 */
32 protected $page = null;
33
34 /**
35 * Database schema name
36 *
37 * @var string
38 */
39 protected $wpda_schema_name = '';
40
41 /**
42 * Database schema name (as saved in column wpda_schema_name)
43 *
44 * Used to allow older versions of the plugin to have an empty schema name stored in column wpda_schema_name.
45 *
46 * @var string
47 */
48 protected $wpda_schema_name_db = '';
49
50 /**
51 * Database table name
52 *
53 * @var string
54 */
55 protected $wpda_table_name = null;
56
57 /**
58 * Options set name
59 *
60 * @var string
61 */
62 protected $wpda_table_setname = null;
63
64 /**
65 * Database table structure
66 *
67 * @var array|null
68 */
69 protected $table_structure = null;
70
71 /**
72 * Handle to instance of class WPDA_Dictionary_Exist
73 *
74 * @var object|null
75 */
76 protected $wpda_data_dictionary = null;
77
78 /**
79 * Handle to instance of class WPDP_List_Columns
80 *
81 * @var object|null
82 */
83 protected $wpda_list_columns = null;
84
85 /**
86 * Requested action
87 *
88 * @var string
89 */
90 protected $action = null;
91
92 /**
93 * Requested action2
94 *
95 * @var string
96 */
97 protected $action2 = null;
98
99 /**
100 * Indicate whether the table has a primary key
101 *
102 * @var boolean|null
103 */
104 protected $has_primary_key = null;
105
106 /**
107 * Available tabs
108 *
109 * @var array
110 */
111 protected $tabs;
112
113 /**
114 * Current tab
115 *
116 * @var
117 */
118 protected $current_tab;
119
120 const WPNONCE_SEED = 'wpda-data-templates-';
121
122 protected $wpnonce;
123
124 protected $wpnonce_requested = null;
125
126 /**
127 * Table design (taken from WPDA_Design_Table_Model)
128 *
129 * @var array|null
130 */
131 protected $wpda_table_design = null;
132
133 /**
134 * WPDP_Project_Table_Form constructor
135 */
136 public function __construct() {
137 global $wpdb;
138 if ( isset( $_REQUEST['page'] ) ) {
139 $this->page = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) );
140 // input var okay.
141 } else {
142 wp_die( __( 'ERROR: Wrong arguments [missing page]', 'wp-data-access' ) );
143 }
144 if ( isset( $_REQUEST['action'] ) ) {
145 $this->action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );
146 }
147 if ( isset( $_REQUEST['action2'] ) ) {
148 $this->action2 = sanitize_text_field( wp_unslash( $_REQUEST['action2'] ) );
149 }
150 $this->tabs = array(
151 'tableinfo' => __( 'Table Settings', 'wp-data-access' ),
152 'relation' => __( 'Relationships', 'wp-data-access' ),
153 'listtable' => __( 'List Table', 'wp-data-access' ),
154 'tableform' => __( 'Data Entry', 'wp-data-access' ),
155 'reconcile' => __( 'Reconcile', 'wp-data-access' ),
156 );
157 $this->current_tab = 'tableinfo';
158 if ( isset( $_REQUEST['tab'] ) ) {
159 $tab = sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) );
160 // input var okay.
161 if ( isset( $this->tabs[$tab] ) ) {
162 $this->current_tab = $tab;
163 }
164 }
165 $this->wpnonce_requested = ( isset( $_POST['wpnonce'] ) ? sanitize_text_field( wp_unslash( $_POST['wpnonce'] ) ) : null );
166 // input var okay.
167 if ( isset( $_REQUEST['wpda_table_name'] ) && !is_array( $_REQUEST['wpda_table_name'] ) ) {
168 $wpda_project_design_table_model = new WPDP_Project_Design_Table_Model();
169 if ( 'reconcile' === $this->action ) {
170 $wpda_table_name_re = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_name'] ) );
171 // input var okay.
172 $this->is_authorized( $wpda_table_name_re );
173 $wpda_schema_name_re = ( isset( $_REQUEST['wpda_schema_name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_schema_name'] ) ) : '' );
174 // input var okay.
175 $wpda_reverse_engineering = new WPDA_Reverse_Engineering($wpda_table_name_re, $wpda_schema_name_re);
176 $table_structure = $wpda_reverse_engineering->get_designer_format( 'advanced' );
177 if ( isset( $_REQUEST['keep_options'] ) ) {
178 $param_keep_options = sanitize_text_field( wp_unslash( $_REQUEST['keep_options'] ) );
179 } else {
180 $param_keep_options = 'off';
181 }
182 $result_update = $wpda_project_design_table_model->reconcile( $table_structure, $param_keep_options );
183 if ( false === $result_update ) {
184 $msg = new WPDA_Message_Box(array(
185 'message_text' => __( 'Update failed', 'wp-data-access' ),
186 'message_type' => 'error',
187 'message_is_dismissible' => false,
188 ));
189 $msg->box();
190 }
191 if ( 0 === $result_update ) {
192 $msg = new WPDA_Message_Box(array(
193 'message_text' => __( 'Nothing to save', 'wp-data-access' ),
194 ));
195 $msg->box();
196 } else {
197 $msg = new WPDA_Message_Box(array(
198 'message_text' => __( 'Succesfully saved changes to database', 'wp-data-access' ),
199 ));
200 $msg->box();
201 }
202 } elseif ( 'reverse_engineering' === $this->action ) {
203 if ( isset( $_REQUEST['wpda_table_name'] ) ) {
204 $wpda_table_name_re = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_name'] ) );
205 // input var okay.
206 $this->is_authorized( WPDP_Project_Design_Table_Model::get_base_table_name() );
207 $wpda_schema_name_re = ( isset( $_REQUEST['wpda_schema_name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_schema_name'] ) ) : '' );
208 // input var okay.
209 $wpda_reverse_engineering = new WPDA_Reverse_Engineering($wpda_table_name_re, $wpda_schema_name_re);
210 $table_structure = $wpda_reverse_engineering->get_designer_format( 'advanced' );
211 if ( count( $table_structure ) > 0 ) {
212 //phpcs:ignore - 8.1 proof
213 $this->wpda_schema_name = $wpda_schema_name_re;
214 $this->wpda_table_name = $wpda_table_name_re;
215 $this->get_unique_setname();
216 $this->wpda_table_design = $table_structure;
217 } else {
218 wp_die( __( 'ERROR: Reverse engineering table failed [invalid structure]', 'wp-data-access' ) );
219 }
220 if ( !WPDP_Project_Design_Table_Model::insert_reverse_engineered(
221 $this->wpda_table_name,
222 $this->wpda_table_setname,
223 $this->wpda_table_design,
224 $this->wpda_schema_name
225 ) ) {
226 $db_error = ( '' === $wpdb->last_error ? '' : ' [' . $wpdb->last_error . ']' );
227 wp_die( __( 'ERROR: Reverse engineering table failed' . $db_error, 'wp-data-access' ) );
228 } else {
229 // Convert named array to object (needed to display structure).
230 $this->wpda_table_design = json_decode( json_encode( $table_structure ) );
231 $wpda_project_design_table_model->prepare_query( $this->wpda_table_setname );
232 }
233 $this->action2 = 'edit';
234 $msg = new WPDA_Message_Box(array(
235 'message_text' => __( 'Table added to respository', 'wp-data-access' ),
236 ));
237 $msg->box();
238 } else {
239 wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) );
240 }
241 } elseif ( null !== $this->action2 ) {
242 // Check authorization
243 $table_name = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_name'] ) );
244 // input var okay.
245 $this->is_authorized( $table_name );
246 $result_update = $wpda_project_design_table_model->update();
247 if ( false === $result_update ) {
248 $msg = new WPDA_Message_Box(array(
249 'message_text' => __( 'Update failed', 'wp-data-access' ),
250 'message_type' => 'error',
251 'message_is_dismissible' => false,
252 ));
253 $msg->box();
254 } else {
255 if ( 0 === $result_update ) {
256 $msg = new WPDA_Message_Box(array(
257 'message_text' => __( 'Nothing to save', 'wp-data-access' ),
258 ));
259 $msg->box();
260 } else {
261 $msg = new WPDA_Message_Box(array(
262 'message_text' => __( 'Successfully saved changes to database', 'wp-data-access' ),
263 ));
264 $msg->box();
265 }
266 }
267 }
268 $wpda_project_design_table_model->query();
269 $structure_messages = $wpda_project_design_table_model->validate();
270 foreach ( $structure_messages as $messages ) {
271 if ( 'ERR' === $messages[0] ) {
272 $msg = new WPDA_Message_Box(array(
273 'message_text' => $messages[1],
274 'message_type' => 'error',
275 'message_is_dismissible' => false,
276 ));
277 $msg->box();
278 } else {
279 $msg = new WPDA_Message_Box(array(
280 'message_text' => $messages[1],
281 ));
282 $msg->box();
283 }
284 }
285 $this->table_structure = $wpda_project_design_table_model->get_table_design();
286 $this->wpda_table_setname = $wpda_project_design_table_model->get_table_setname();
287 $this->wpda_schema_name = ( isset( $_REQUEST['wpda_schema_name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_schema_name'] ) ) : '' );
288 // input var okay.
289 $this->wpda_schema_name_db = $this->wpda_schema_name;
290 if ( '' === $this->wpda_schema_name ) {
291 $this->wpda_schema_name = $wpdb->dbname;
292 }
293 $this->wpda_table_name = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_name'] ) );
294 $this->wpda_data_dictionary = new WPDA_Dictionary_Exist($this->wpda_schema_name, $this->wpda_table_name);
295 if ( $this->wpda_data_dictionary->table_exists() ) {
296 $this->wpda_list_columns = WPDP_List_Columns_Cache::get_list_columns(
297 $this->wpda_schema_name,
298 $this->wpda_table_name,
299 'tableform',
300 $this->wpda_table_setname
301 );
302 if ( 0 === count( $this->wpda_list_columns->get_table_primary_key() ) ) {
303 //phpcs:ignore - 8.1 proof
304 $this->has_primary_key = false;
305 } else {
306 $this->has_primary_key = true;
307 }
308 } else {
309 wp_die( __( 'ERROR: Invalid table name or not authorized', 'wp-data-access' ) );
310 }
311 } else {
312 wp_die( __( 'ERROR: Argument wpda_table_name not found', 'wp-data-access' ) );
313 }
314 $this->wpnonce = wp_create_nonce( self::WPNONCE_SEED . $this->wpda_table_name );
315 }
316
317 public function prepare_form() {
318 }
319
320 protected function is_authorized( $table_name ) {
321 if ( !wp_verify_nonce( $this->wpnonce_requested, self::WPNONCE_SEED . $table_name ) ) {
322 wp_die( __( 'ERROR: Not authorized', 'wp-data-access' ) );
323 }
324 }
325
326 /**
327 * Create a unique setname for this table
328 */
329 public function get_unique_setname() {
330 $this->wpda_table_setname = 'default';
331 // Default for first options set
332 global $wpdb;
333 $query = "select 'x' from `%1s` where wpda_table_name = %s";
334 $wpdb->get_results( $wpdb->prepare(
335 $query,
336 // phpcs:ignore WordPress.DB.PreparedSQL
337 array(WPDA::remove_backticks( WPDP_Project_Design_Table_Model::get_base_table_name() ), $this->wpda_table_name)
338 ) );
339 if ( $wpdb->num_rows > 0 ) {
340 $query = "select 'x' from `%1s` where wpda_schema_name = %s and wpda_table_name = %s and wpda_table_setname = %s";
341 $i = $wpdb->num_rows + 1;
342 $this->wpda_table_setname = "options_set_{$i}";
343 $wpdb->get_results( $wpdb->prepare(
344 $query,
345 // phpcs:ignore WordPress.DB.PreparedSQL
346 array(
347 WPDA::remove_backticks( WPDP_Project_Design_Table_Model::get_base_table_name() ),
348 $this->wpda_schema_name,
349 $this->wpda_table_name,
350 $this->wpda_table_setname
351 )
352 ) );
353 while ( $wpdb->num_rows > 0 ) {
354 // Search until a free options set is found
355 $this->wpda_table_setname = "options_set_{$i}";
356 $wpdb->get_results( $wpdb->prepare(
357 $query,
358 // phpcs:ignore WordPress.DB.PreparedSQL
359 array(
360 WPDA::remove_backticks( WPDP_Project_Design_Table_Model::get_base_table_name() ),
361 $this->wpda_schema_name,
362 $this->wpda_table_name,
363 $this->wpda_table_setname
364 )
365 ) );
366 $i++;
367 }
368 }
369 }
370
371 /**
372 * Adds tabs to page
373 */
374 protected function add_tabs() {
375 ?>
376 <div style="display:none">
377 <?php
378 foreach ( $this->tabs as $tab => $name ) {
379 $form_id = esc_attr( $tab ) . '_form_id';
380 $page = esc_attr( WPDP::PAGE_TEMPLATES );
381 $schema_name = esc_attr( $this->wpda_schema_name_db );
382 $table_name = esc_attr( $this->wpda_table_name );
383 $set_name = esc_attr( $this->wpda_table_setname );
384 $tab_value = esc_attr( $tab );
385 $tab_form = "\n\t\t\t\t\t\t<form id='{$form_id}' method='post' action='?page={$page}&tab={$tab_value}'>\n\t\t\t\t\t\t\t<input type='hidden' name='wpda_schema_name' value='{$schema_name}'/>\n\t\t\t\t\t\t\t<input type='hidden' name='wpda_table_name' value='{$table_name}'/>\n\t\t\t\t\t\t\t<input type='hidden' name='wpda_table_setname' value='{$set_name}'/>\n\t\t\t\t\t\t\t<input type='hidden' name='wpda_table_setname_old' value='{$set_name}'/>\n\t\t\t\t\t\t\t<input type='hidden' name='action' value='edit'/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t";
386 echo $tab_form;
387 // phpcs:ignore WordPress.Security.EscapeOutput
388 }
389 ?>
390 </div>
391 <h2 class="nav-tab-wrapper">
392 <?php
393 foreach ( $this->tabs as $tab => $name ) {
394 $class = ( $tab === $this->current_tab ? ' nav-tab-active' : '' );
395 echo '<a class="nav-tab' . esc_attr( $class ) . '"' . ' href="javascript:void(0)"' . ' onclick="submit_form(\'' . esc_attr( $tab ) . '_form_id\')"' . '>' . esc_attr( $name ) . '</a>';
396 }
397 ?>
398 </h2>
399 <div class="wpdp-spacer"></div>
400 <?php
401 }
402
403 /**
404 * Show page
405 */
406 public function show() {
407 ?>
408 <div class="wrap">
409 <?php
410 $this->show_title();
411 $this->add_tabs();
412 switch ( $this->current_tab ) {
413 case 'tableinfo':
414 $this->show_table_info();
415 break;
416 case 'relation':
417 if ( true === $this->has_primary_key ) {
418 $this->show_relations();
419 } else {
420 $this->show_view();
421 }
422 break;
423 case 'listtable':
424 $this->show_list_table();
425 break;
426 case 'tableform':
427 if ( true === $this->has_primary_key ) {
428 $this->show_table_form();
429 } else {
430 $this->show_view();
431 }
432 break;
433 case 'reconcile':
434 $this->show_reconcile();
435 break;
436 }
437 ?>
438 </div>
439 <script type='text/javascript'>
440 function submit_form(form_id) {
441 if (wpda_columns_updated===true) {
442 if (confirm("Your changes will not be saved! Continue?")) {
443 jQuery('#' + form_id).submit();
444 }
445 } else {
446 jQuery('#' + form_id).submit();
447 }
448 }
449 jQuery(function () {
450 jQuery('#wpda_table_structure').sortable();
451 jQuery('#wpda_list_table_options').sortable();
452 jQuery('#wpda_form_options').sortable();
453 jQuery('.wpda_tooltip').tooltip();
454 });
455 </script>
456 <?php
457 if ( 'view' === $this->action ) {
458 // Set all forms to read only
459 ?>
460 <script type='text/javascript'>
461 jQuery(function () {
462 jQuery("input").attr("disabled", true);
463 jQuery("select").attr("disabled", true);
464 });
465 </script>
466 <?php
467 } else {
468 // Keep track of changes
469 ?>
470 <script type='text/javascript'>
471 var wpda_columns_updated = false;
472 jQuery(function () {
473 jQuery("input").on("change", function() { wpda_columns_updated = true; });
474 jQuery("select").on("change", function() { wpda_columns_updated = true; });
475 });
476 </script>
477 <?php
478 }
479 }
480
481 protected function show_title() {
482 $title = 'Project Templates';
483 ?>
484 <h1 class="wp-heading-inline">
485 <a
486 href="?page=<?php
487 echo esc_attr( $this->page );
488 ?>"
489 class="dashicons dashicons-arrow-left-alt2"
490 title="<?php
491 echo __( 'Template list', 'wp-data-access' );
492 ?>"
493 ></a>
494 <?php
495 echo esc_attr( $title );
496 ?>
497 </h1>
498 <?php
499 }
500
501 protected function show_view() {
502 ?>
503 <div class="wpdp-spacer"></div>
504 <div>
505 <fieldset class="wpda_fieldset wpdp_fieldset">
506 <strong>
507 Sorry, this feature is only available for tables containing a primary or unique key.
508 </strong>
509 </fieldset>
510 </div>
511 <?php
512 }
513
514 /**
515 * Show table info
516 */
517 protected function show_table_info() {
518 global $wpdb;
519 if ( '' === $this->wpda_schema_name || $wpdb->dbname === $this->wpda_schema_name ) {
520 $wpda_table_name = $this->wpda_table_name;
521 } else {
522 $wpda_table_name = $this->wpda_table_name . ' (' . $this->wpda_schema_name . ')';
523 }
524 $tab_label = ( isset( $this->table_structure->tableinfo->tab_label ) ? $this->table_structure->tableinfo->tab_label : '' );
525 $default_where = ( isset( $this->table_structure->tableinfo->default_where ) ? $this->table_structure->tableinfo->default_where : '' );
526 $default_orderby = ( isset( $this->table_structure->tableinfo->default_orderby ) ? $this->table_structure->tableinfo->default_orderby : '' );
527 $hyperlinks_parent = ( isset( $this->table_structure->tableinfo->hyperlinks_parent ) ? $this->table_structure->tableinfo->hyperlinks_parent : array() );
528 $hyperlinks_child = ( isset( $this->table_structure->tableinfo->hyperlinks_child ) ? $this->table_structure->tableinfo->hyperlinks_child : array() );
529 $html = '';
530 $html_child = '';
531 $settings_db = WPDA_Table_Settings_Model::query( $this->wpda_table_name, $this->wpda_schema_name );
532 if ( isset( $settings_db[0]['wpda_table_settings'] ) && '' !== $settings_db[0]['wpda_table_settings'] ) {
533 $settings = json_decode( $settings_db[0]['wpda_table_settings'] );
534 if ( isset( $settings->hyperlinks ) && is_array( $settings->hyperlinks ) ) {
535 foreach ( $settings->hyperlinks as $hyperlink ) {
536 if ( isset( $hyperlink->hyperlink_label ) ) {
537 $hyperlink_label = $hyperlink->hyperlink_label;
538 if ( isset( $hyperlinks_parent->{$hyperlink_label} ) ) {
539 $checked = ( $hyperlinks_parent->{$hyperlink_label} ? 'checked' : '' );
540 } else {
541 $checked = '';
542 }
543 $html .= "<label style='padding-right: 10px;'>\n\t\t\t\t\t\t\t\t\t<input type='checkbox' name='{$hyperlink_label}_hyperlink' style='width: 16px; height: 16px;' {$checked}/>\n\t\t\t\t\t\t\t\t\t{$hyperlink_label}\n\t\t\t\t\t\t\t\t</label>";
544 if ( isset( $hyperlinks_child->{$hyperlink_label} ) ) {
545 $checked = ( $hyperlinks_child->{$hyperlink_label} ? 'checked' : '' );
546 } else {
547 $checked = '';
548 }
549 $html_child .= "<label style='padding-right: 10px;'>\n\t\t\t\t\t\t\t\t\t<input type='checkbox' name='{$hyperlink_label}_hyperlink_child' style='width: 16px; height: 16px;' {$checked}/>\n\t\t\t\t\t\t\t\t\t{$hyperlink_label}\n\t\t\t\t\t\t\t\t</label>";
550 }
551 }
552 }
553 }
554 if ( '' === $html && '' === $html_child ) {
555 $hint = 'Hyperlinks';
556 } else {
557 $hint = __( 'Hyperlinks - uncheck to disable', 'wp-data-access' ) . ' <span class="dashicons dashicons-editor-help wpda_tooltip" title="Use table settings to define where hyperlinks are shown."></span>';
558 }
559 if ( '' === $html ) {
560 $html = '--';
561 }
562 if ( '' === $html_child ) {
563 $html_child = '--';
564 }
565 ?>
566 <form id="wpdp_form_table_info" method="post">
567
568 <fieldset class="wpda_fieldset wpdp_fieldset">
569 <legend>
570 <label style="font-weight: normal;">
571 <?php
572 echo __( 'Manage table settings for table ', 'wp-data-access' );
573 ?>
574 </label>
575 <label>
576 <?php
577 echo esc_attr( $wpda_table_name );
578 ?>
579 </label>
580 </legend>
581
582 <table class="wpda-table-structure wpdp-table-structure">
583 <tr>
584 <td style="text-align: right; padding-right: 5px; width: 140px;" class="wpdp-label-column">
585 <label>
586 <?php
587 echo __( 'Template set name', 'wp-data-access' );
588 ?>
589 </label>
590 </td>
591 <td>
592 <input type="text" name="wpda_table_setname" value="<?php
593 echo esc_attr( $this->wpda_table_setname );
594 ?>"/>
595 <input type="hidden" name="wpda_table_setname_old" value="<?php
596 echo esc_attr( $this->wpda_table_setname );
597 ?>"/>
598 </td>
599 <td style="width:5px;"></td>
600 <td style="width:1%;" class="icon">
601 <i title="A template set is used to connect a table to a Data Project." class="fas fa-circle-question pointer wpda_tooltip"></i>
602 </td>
603 </tr>
604 <tr>
605 <td style="text-align: right; padding-right: 5px;">
606 <label>
607 <?php
608 echo __( 'Tab label', 'wp-data-access' );
609 ?>
610 </label>
611 </td>
612 <td>
613 <input type="text" name="tab_label" value="<?php
614 echo esc_attr( $tab_label );
615 ?>"/>
616 </td>
617 <td style="width:5px;"></td>
618 <td style="width:1%;" class="icon">
619 <i title="Label shown on tab when table is shown as child table." class="fas fa-circle-question pointer wpda_tooltip"></i>
620 </td>
621 </tr>
622 </table>
623 </fieldset>
624
625 <div class="wpdp-spacer"></div>
626 <div class="wpdp-spacer"></div>
627
628 <fieldset class="wpda_fieldset wpdp_fieldset">
629 <legend>
630 <label style="font-weight: normal;">
631 <?php
632 echo esc_attr( $hint );
633 ?>
634 </label>
635 </legend>
636
637 <table class="wpda-table-structure wpdp-table-structure">
638 <tr>
639 <td style="text-align: right; padding-right: 5px; padding-top: 10px;" class="wpdp-label-column">
640 <label>
641 <?php
642 echo __( 'Hyperlinks parent', 'wp-data-access' );
643 ?>
644 </label>
645 </td>
646 <td style="padding-top: 10px;">
647 <?php
648 echo $html;
649 // phpcs:ignore WordPress.Security.EscapeOutput
650 ?>
651 </td>
652 </tr>
653 <tr>
654 <td style="text-align: right; padding-right: 5px;" class="wpdp-label-column">
655 <label>
656 <?php
657 echo __( 'Hyperlinks child', 'wp-data-access' );
658 ?>
659 </label>
660 </td>
661 <td>
662 <?php
663 echo $html_child;
664 // phpcs:ignore WordPress.Security.EscapeOutput
665 ?>
666 </td>
667 </tr>
668 </table>
669 </fieldset>
670
671 <?php
672 do_action( 'wpda_data_projects_add_table_option', $this->wpda_schema_name, $this->wpda_table_name );
673 ?>
674
675 <div class="wpdp-spacer"></div>
676 <div class="wpdp-spacer"></div>
677
678 <fieldset class="wpda_fieldset wpdp_fieldset">
679 <legend>
680 <label style="font-weight: normal;">
681 <?php
682 echo __( 'Child table setting only', 'wp-data-access' );
683 ?>
684 <span class="dashicons dashicons-editor-help wpda_tooltip" title="These settings only affect child tables! Parent table settings are available on Data Projects page."></span>
685 </label>
686 </legend>
687
688 <table class="wpda-table-structure wpdp-table-structure">
689 <tr>
690 <td style="text-align: right; padding-right: 5px;" class="wpdp-label-column">
691 <label>
692 <?php
693 echo __( 'Default WHERE', 'wp-data-access' );
694 ?>
695 </label>
696 </td>
697 <td>
698 <input type="text" name="default_where" value="<?php
699 echo esc_attr( $default_where );
700 ?>"/>
701 </td>
702 <td style="width:5px;"></td>
703 <td style="width:1%;" class="icon">
704 <i title="Enter a valid sql where clause, for example: name like 'Peter%'" class="fas fa-circle-question pointer wpda_tooltip"></i>
705 </td>
706 </tr>
707 <tr>
708 <td style="text-align: right; padding-right: 5px;" class="wpdp-label-column">
709 <label>
710 <?php
711 echo __( 'Default ORDER BY', 'wp-data-access' );
712 ?>
713 </label>
714 </td>
715 <td>
716 <input type="text" name="default_orderby" value="<?php
717 echo esc_attr( $default_orderby );
718 ?>"/>
719 </td>
720 <td style="width:5px;"></td>
721 <td style="width:1%;" class="icon">
722 <i title="Enter a valid sql order by clause, for example: course_date desc, student_name asc" class="fas fa-circle-question pointer wpda_tooltip"></i>
723 </td>
724 </tr>
725 </table>
726 </fieldset>
727
728 <div class="wpdp-button-panel">
729 <input type="hidden" name="wpda_schema_name"
730 value="<?php
731 echo esc_attr( $this->wpda_schema_name_db );
732 ?>"/>
733 <input type="hidden" name="wpda_table_name"
734 value="<?php
735 echo esc_attr( $this->wpda_table_name );
736 ?>"/>
737 <input type="hidden" name="action" value="edit"/>
738 <input type="hidden" name="action2" value="tableinfo"/>
739 <input type="hidden" name="wpnonce"
740 value="<?php
741 echo esc_attr( $this->wpnonce );
742 ?>"/>
743 <button type="submit" class="button button-primary">
744 <i class="fas fa-check wpda_icon_on_button"></i>
745 <?php
746 echo __( 'Save table info', 'wp-data-access' );
747 ?>
748 </button>
749 <a href="?page=<?php
750 echo esc_attr( $this->page );
751 ?>" class="button button-secondary">
752 <i class="fas fa-times-circle wpda_icon_on_button"></i>
753 <?php
754 echo __( 'Back to list', 'wp-data-access' );
755 ?>
756 </a>
757 </div>
758
759 </form>
760 <?php
761 }
762
763 /**
764 * Show relationships
765 */
766 protected function show_relations() {
767 $source_table_columns = $this->wpda_list_columns->get_table_columns();
768 $target_table_names = WPDA_Dictionary_Lists::get_tables( true, $this->wpda_schema_name );
769 $available_databases = WPDA_Dictionary_Lists::get_db_schemas();
770 $i = 0;
771 global $wpdb;
772 if ( '' === $this->wpda_schema_name || $wpdb->dbname === $this->wpda_schema_name ) {
773 $wpda_table_name = $this->wpda_table_name;
774 } else {
775 $wpda_table_name = $this->wpda_table_name . ' (' . $this->wpda_schema_name . ')';
776 }
777 ?>
778 <script type='text/javascript'>
779 var row_num = 0;
780 var col_num = [];
781
782 function wpdp_get_tables(schema_name, index, target_id, selected_value, target_column_name = false, source_column_name= false) {
783 var url = location.pathname + '?action=wpda_get_tables';
784 var data = {
785 wpdaschema_name: schema_name,
786 wpda_wpnonce: '<?php
787 echo esc_attr( wp_create_nonce( 'wpda-getdata-access-' . WPDA::get_current_user_login() ) );
788 ?>'
789 };
790 jQuery.post(
791 url,
792 data,
793 function (data) {
794 jQuery(target_id).find('option').remove();
795 var jsonData = JSON.parse(data);
796 for (i = 0; i < jsonData.length; i++) {
797 jQuery(target_id).append(
798 newitem = jQuery("<option></option>")
799 .attr("value", jsonData[i]['table_name'])
800 .text(jsonData[i]['table_name'])
801 );
802 if (jsonData[i]['table_name'] === selected_value) {
803 newitem.attr("selected", true);
804 }
805 }
806 if (!target_column_name) {
807 jQuery(target_id).trigger("change");
808 } else {
809 wpdp_get_columns(selected_value, index, '#target_column_name_' + index, target_column_name[0], schema_name);
810 for (i=1; i<target_column_name.length; i++) {
811 add_column(index, target_column_name[i]);
812 jQuery('#source_column_name_' + index + '_' + i).val(source_column_name[i]);
813 wpdp_get_columns(selected_value, index, '#target_column_name_' + index + '_' + i, target_column_name[i], schema_name);
814 }
815 }
816 }
817 );
818 }
819
820 function wpdp_get_columns(table_name, index, target_id, selected_value, schema_name = '') {
821 if (schema_name === '') {
822 schema_name = '<?php
823 echo esc_attr( $this->wpda_schema_name );
824 ?>';
825 }
826 var url = location.pathname + '?action=wpda_get_columns';
827 var data = {
828 wpdaschema_name: schema_name,
829 table_name: table_name,
830 wpda_wpnonce: '<?php
831 echo esc_attr( wp_create_nonce( 'wpda-getdata-access-' . WPDA::get_current_user_login() ) );
832 ?>'
833 };
834 jQuery.post(
835 url,
836 data,
837 function (data) {
838 jQuery(target_id).find('option').remove();
839 var jsonData = JSON.parse(data);
840 for (i = 0; i < jsonData.length; i++) {
841 jQuery(target_id).append(
842 newitem = jQuery("<option></option>")
843 .attr("value", jsonData[i]['column_name'])
844 .text(jsonData[i]['column_name'])
845 );
846 if (jsonData[i]['column_name'] === selected_value) {
847 newitem.attr("selected", true);
848 }
849 }
850 }
851 );
852 }
853
854 function add_row(relation_type, source_column_name, target_table_name, target_column_name, relation_table_name, target_schema_name = '') {
855 if (relation_type === undefined || relation_type === '') {
856 relation_type = '1n';
857 }
858 if (source_column_name === undefined || source_column_name === '') {
859 source_column_name = [''];
860 }
861 if (relation_table_name === undefined || relation_table_name === '') {
862 relation_table_name = '';
863 }
864 if (target_schema_name === '' || target_schema_name === '<?php
865 echo esc_attr( $this->wpda_schema_name );
866 ?>') {
867 target_schema_name = '<?php
868 echo esc_attr( $this->wpda_schema_name );
869 ?>';
870 populate_lookup = false;
871 } else {
872 populate_lookup = true;
873 }
874 var new_row = '<tr id="relation_' + row_num + '">' +
875 '<td class="wpda-table-structure-first-column-move wpda-table-structure-top">' +
876 ' <span class="dashicons dashicons-move grabbable" style="padding-top:5px;"></span>' +
877 ' <input type="hidden" name="row_num[]" value="' + row_num + '" />' +
878 '</td>' +
879 '<td class="wpda-table-structure-top">' +
880 ' <select id="relation_type_' + row_num + '" name="relation_type[]" onchange="change_relationship(event, ' + row_num + ')">' +
881 ' <option value="1n" ' + (relation_type === '1n' ? 'selected' : '') + '>1:n</option>' +
882 ' <option value="nm" ' + (relation_type === 'nm' ? 'selected' : '') + '>n:m</option>' +
883 ' <option value="lookup" ' + (relation_type === 'lookup' ? 'selected' : '') + '>lookup listbox</option>' +
884 ' <option value="autocomplete" ' + (relation_type === 'autocomplete' ? 'selected' : '') + '>lookup autocomplete</option>' +
885 ' </select>' +
886 '</td>' +
887 '<td class="wpda-table-structure-top">' +
888 ' <select name="source_column_name[]" id="source_column_name_' + row_num + '">' +
889 <?php
890 foreach ( $source_table_columns as $column ) {
891 ?>
892 '<option value="<?php
893 echo esc_attr( $column['column_name'] );
894 ?>" ' + (source_column_name[0] === "<?php
895 echo esc_attr( $column['column_name'] );
896 ?>" ? "selected" : "") + '><?php
897 echo esc_attr( $column['column_name'] );
898 ?></option>' +
899 <?php
900 }
901 ?>
902 ' </select>' +
903 ' <input type="hidden" name="num_source_column_name[]" id="num_source_column_name_' + row_num + '" value="0" />' +
904 '</td>' +
905 '<td class="wpda-table-structure-top">' +
906 ' <a href="javascript:void(0)" style="vertical-align:-webkit-baseline-middle;padding-top:7px;"' +
907 ' class="dashicons dashicons-plus wpda_tooltip" title="Add column"' +
908 ' onclick="add_column(' + row_num + ')" id="remove_column_names_' + row_num + '"' +
909 ' ></a>' +
910 '</td>' +
911 '<td class="wpda-table-structure-top">' +
912 ' <select id="target_schema_name_' + row_num + '" name="target_schema_name[]" onchange="wpdp_get_tables(jQuery(this).val(), ' + row_num + ', \'#target_table_name_' + row_num + '\', \'\')" class="wpda_tooltip" title="Create lookup to other database"' + (relation_type==="lookup"||relation_type==="autocomplete" ? "" : "style=\'display:none;\'") + '>' +
913 <?php
914 global $wpdb;
915 foreach ( $available_databases as $available_database ) {
916 if ( $wpdb->dbname === $available_database['schema_name'] ) {
917 $database_printed = "WordPress database ({$available_database['schema_name']})";
918 } else {
919 $database_printed = $available_database['schema_name'];
920 }
921 ?>
922 '<option value="<?php
923 echo esc_attr( $available_database['schema_name'] );
924 ?>" ' + (target_schema_name === "<?php
925 echo esc_attr( $available_database['schema_name'] );
926 ?>" ? "selected" : "") + '><?php
927 echo esc_attr( $database_printed );
928 ?></option>' +
929 <?php
930 }
931 ?>
932 ' </select>' +
933 ' <select id="target_table_name_' + row_num + '" name="target_table_name[]" onchange="wpdp_get_columns(jQuery(this).val(), ' + row_num + ', \'#target_column_name_' + row_num + '\', \'\', jQuery(\'#target_schema_name_' + row_num + '\').val())">' +
934 ' <option value=""></option>' +
935 <?php
936 foreach ( $target_table_names as $target_table_name ) {
937 ?>
938 '<option value="<?php
939 echo esc_attr( $target_table_name['table_name'] );
940 ?>" ' + (target_table_name === "<?php
941 echo esc_attr( $target_table_name['table_name'] );
942 ?>" ? "selected" : "") + '><?php
943 echo esc_attr( $target_table_name['table_name'] );
944 ?></option>' +
945 <?php
946 }
947 ?>
948 ' </select>' +
949 '</td>' +
950 '<td class="wpda-table-structure-top">' +
951 ' <select name="target_column_name[]" id="target_column_name_' + row_num + '"></select>' +
952 '</td>' +
953 '<td class="wpda-table-structure-top">' +
954 ' <select name="relation_table_name_' + row_num + '" id="relation_table_name_' + row_num + '"></select>' +
955 '</td>' +
956 '<td class="wpda-table-structure-last-column wpda-table-structure-top">' +
957 ' <a href="javascript:void(0)" class="dashicons dashicons-trash" onclick="rem_row(event)" style="float:right;padding-top:5px;"></a>' +
958 '</td>' +
959 '</tr>';
960 if (jQuery("#wpda_table_structure tr").length === 0) {
961 jQuery("#wpda_table_structure").append(new_row);
962 } else {
963 jQuery("#wpda_table_structure tr:last").after(new_row);
964 }
965 col_num[row_num] = 0;
966 if (jQuery('#target_table_name_' + row_num + ' option:selected').val() !== '') {
967 // console.log(target_column_name[0])
968 wpdp_get_columns(jQuery('#target_table_name_' + row_num).val(), row_num, '#target_column_name_' + row_num, target_column_name[0]);
969 for (i = 1; i < target_column_name.length; i++) {
970 add_column(row_num, target_column_name[i]);
971 jQuery('#source_column_name_' + row_num + '_' + i).val(source_column_name[i]);
972 }
973 }
974 jQuery('#relation_table_name_' + row_num).append("<option value=''></option>");
975 <?php
976 foreach ( $target_table_names as $target_table_name ) {
977 $option = "<option value='" . esc_attr( $target_table_name['table_name'] ) . "'>" . esc_attr( $target_table_name['table_name'] ) . '</option>';
978 ?>
979 jQuery('#relation_table_name_' + row_num).append("<?php
980 echo $option;
981 // phpcs:ignore WordPress.Security.EscapeOutput
982 ?>");
983 jQuery('#relation_table_name_' + row_num).val(relation_table_name);
984 <?php
985 }
986 ?>
987 if (relation_type === '1n' || relation_type === 'lookup' || relation_type === 'autocomplete') {
988 jQuery('#relation_table_name_' + row_num).hide();
989 }
990 if (populate_lookup) {
991 // If lookup table is stored in another schema, we need to populate the listboxes with ajax calls
992 wpdp_get_tables(jQuery('#target_schema_name_' + row_num).val(), row_num, '#target_table_name_' + row_num, target_table_name, target_column_name, source_column_name);
993 }
994 row_num++;
995 }
996
997 function change_relationship(e, index) {
998 if (jQuery(e.target).val() === 'nm') {
999 jQuery('#relation_table_name_' + index).show();
1000 } else {
1001 jQuery('#relation_table_name_' + index).hide();
1002 }
1003
1004 if (jQuery(e.target).val() === 'lookup' || jQuery(e.target).val() === 'autocomplete') {
1005 jQuery('#target_schema_name_' + index).show();
1006 } else {
1007 jQuery('#target_schema_name_' + index).hide();
1008 }
1009 }
1010
1011 function rem_row(e) {
1012 var curr_id = e.target.parentNode.parentNode.id;
1013 if (confirm("Delete relationship?")) {
1014 jQuery("#" + curr_id).remove();
1015 }
1016 }
1017
1018 function add_column(index, selected_value = '') {
1019 var source_column_name_list =
1020 '<select name="source_column_name_' + index + '_' + (col_num[index] + 1) + '" id="source_column_name_' + index + '_' + (col_num[index] + 1) + '">' +
1021 <?php
1022 foreach ( $source_table_columns as $column ) {
1023 ?>
1024 '<option value="<?php
1025 echo esc_attr( $column['column_name'] );
1026 ?>"><?php
1027 echo esc_attr( $column['column_name'] );
1028 ?></option>' +
1029 <?php
1030 }
1031 ?>
1032 '</select>';
1033 jQuery(source_column_name_list).insertAfter(jQuery('#source_column_name_' + index).parent().children().last());
1034
1035 var remove_column_names_list =
1036 '<div id="remove_column_names_' + index + '_' + (col_num[index] + 1) + '" style="padding-top:4px;">' +
1037 ' <a href="javascript:void(0)"' +
1038 ' style="vertical-align:-webkit-baseline-middle;padding-top:5px;"' +
1039 ' class="dashicons dashicons-minus wpda_tooltip"' +
1040 ' title="Remove column"' +
1041 ' onclick="rem_column(' + index + ',' + (col_num[index] + 1) + ')"' +
1042 ' ></a>' +
1043 '</div>';
1044 jQuery(remove_column_names_list).insertAfter(jQuery('#remove_column_names_' + index).parent().children().last());
1045
1046 var target_column_name_list =
1047 '<select name="target_column_name_' + index + '_' + (col_num[index] + 1) + '" id="target_column_name_' + index + '_' + (col_num[index] + 1) + '">' +
1048 '</select>';
1049 jQuery(target_column_name_list).insertAfter(jQuery('#target_column_name_' + index).parent().children().last());
1050 if (
1051 jQuery('#relation_type_' + index).val()==='lookup' ||
1052 jQuery('#relation_type_' + index).val()==='autocomplete'
1053 ) {
1054 // Is lookup accessing a remote database?
1055 wpdp_get_columns(
1056 jQuery('#target_table_name_' + index).val(),
1057 index,
1058 '#target_column_name_' + index + '_' + (col_num[index] + 1),
1059 selected_value,
1060 jQuery('#target_schema_name_' + index).val()
1061 );
1062 } else {
1063 wpdp_get_columns(
1064 jQuery('#target_table_name_' + index).val(),
1065 index,
1066 '#target_column_name_' + index + '_' + (col_num[index] + 1),
1067 selected_value
1068 );
1069 }
1070
1071 col_num[index] += 1;
1072 jQuery('#num_source_column_name_' + index).val(col_num[index]);
1073 }
1074
1075 function rem_column(index, seq) {
1076 jQuery('#source_column_name_' + index + '_' + seq).remove();
1077 jQuery('#remove_column_names_' + index + '_' + seq).remove();
1078 jQuery('#target_column_name_' + index + '_' + seq).remove();
1079 }
1080 </script>
1081 <form id="wpdp_form_relations" method="post">
1082 <fieldset class="wpda_fieldset wpdp_fieldset">
1083 <legend>
1084 <label style="font-weight: normal;">
1085 <?php
1086 echo __( 'Manage relationships for table', 'wp-data-access' );
1087 ?>
1088 </label>
1089 <label>
1090 <?php
1091 echo esc_attr( $wpda_table_name );
1092 ?>
1093 </label>
1094 </legend>
1095
1096 <table class="wpda-table-structure">
1097 <thead>
1098 <tr>
1099 <th class="wpda-table-structure-first-column-move"></th>
1100 <th>
1101 <?php
1102 echo __( 'Type', 'wp-data-access' );
1103 ?>
1104 </th>
1105 <th>
1106 <?php
1107 echo __( 'Source column name', 'wp-data-access' );
1108 ?>
1109 </th>
1110 <th style="width:20px;"></th>
1111 <th>
1112 <?php
1113 echo __( 'Target table name', 'wp-data-access' );
1114 ?>
1115 </th>
1116 <th>
1117 <?php
1118 echo __( 'Target column name', 'wp-data-access' );
1119 ?>
1120 </th>
1121 <th>
1122 <span style="vertical-align:inherit">
1123 <?php
1124 echo __( 'Relation table name (only n:m)', 'wp-data-access' );
1125 ?>
1126 </span>
1127 <span
1128 class="dashicons dashicons-info wpda_tooltip"
1129 title="<?php
1130 echo __( 'Table shown on the other end of the n:m relationship (instead of target table shown for 1:n relationships). Not available for 1:n relationships.', 'wp-data-access' );
1131 ?>"
1132 style="cursor:pointer;"
1133 ></span>
1134 </th>
1135 <th class="wpda-table-structure-last-column">
1136 <a href="javascript:void(0)"
1137 style="vertical-align:-webkit-baseline-middle;float:right;"
1138 class="dashicons dashicons-plus add-row"
1139 onclick="add_row()"
1140 ></a>
1141 </th>
1142 </tr>
1143 </thead>
1144 <tbody id="wpda_table_structure">
1145 </tbody>
1146 </table>
1147 </fieldset>
1148
1149 <div class="wpdp-button-panel">
1150 <input type="hidden" name="wpda_schema_name"
1151 value="<?php
1152 echo esc_attr( $this->wpda_schema_name_db );
1153 ?>"/>
1154 <input type="hidden" name="wpda_table_name"
1155 value="<?php
1156 echo esc_attr( $this->wpda_table_name );
1157 ?>"/>
1158 <input type="hidden" name="wpda_table_setname"
1159 value="<?php
1160 echo esc_attr( $this->wpda_table_setname );
1161 ?>"/>
1162 <input type="hidden" name="wpda_table_setname_old"
1163 value="<?php
1164 echo esc_attr( $this->wpda_table_setname );
1165 ?>"/>
1166 <input type="hidden" name="action" value="edit"/>
1167 <input type="hidden" name="action2" value="relation"/>
1168 <input type="hidden" name="wpnonce"
1169 value="<?php
1170 echo esc_attr( $this->wpnonce );
1171 ?>"/>
1172 <button type="submit" class="button button-primary">
1173 <i class="fas fa-check wpda_icon_on_button"></i>
1174 <?php
1175 echo __( 'Save relationships', 'wp-data-access' );
1176 ?>
1177 </button>
1178 <a href="?page=<?php
1179 echo esc_attr( $this->page );
1180 ?>" class="button button-secondary">
1181 <i class="fas fa-times-circle wpda_icon_on_button"></i>
1182 <?php
1183 echo __( 'Back to list', 'wp-data-access' );
1184 ?>
1185 </a>
1186 </div>
1187
1188 </form>
1189 <?php
1190 if ( isset( $this->table_structure->relationships ) ) {
1191 $relationships = $this->table_structure->relationships;
1192 if ( 0 < count( $relationships ) ) {
1193 //phpcs:ignore - 8.1 proof
1194 foreach ( $relationships as $relationship ) {
1195 ?>
1196 <script type='text/javascript'>
1197 <?php
1198 if ( !is_array( $relationship->source_column_name ) ) {
1199 $source_column_name_array = '[""]';
1200 } else {
1201 $source_column_name_array = wp_json_encode( $relationship->source_column_name );
1202 }
1203 echo 'var source_column_name_array = ' . $source_column_name_array . ";\n";
1204 // phpcs:ignore WordPress.Security.EscapeOutput
1205 if ( !is_array( $relationship->target_column_name ) ) {
1206 $target_column_name_array = '[""]';
1207 } else {
1208 $target_column_name_array = wp_json_encode( $relationship->target_column_name );
1209 }
1210 echo 'var target_column_name_array = ' . $target_column_name_array . ";\n";
1211 // phpcs:ignore WordPress.Security.EscapeOutput
1212 if ( isset( $relationship->relation_table_name ) ) {
1213 $relation_table_name = $relationship->relation_table_name;
1214 } else {
1215 $relation_table_name = '';
1216 }
1217 if ( isset( $relationship->target_schema_name ) ) {
1218 $target_schema_name = $relationship->target_schema_name;
1219 } else {
1220 $target_schema_name = '';
1221 }
1222 ?>
1223 add_row(
1224 '<?php
1225 echo esc_attr( $relationship->relation_type );
1226 ?>',
1227 source_column_name_array,
1228 '<?php
1229 echo esc_attr( $relationship->target_table_name );
1230 ?>',
1231 target_column_name_array,
1232 '<?php
1233 echo esc_attr( $relation_table_name );
1234 ?>',
1235 '<?php
1236 echo esc_attr( $target_schema_name );
1237 ?>'
1238 );
1239 </script>
1240 <?php
1241 }
1242 } else {
1243 ?>
1244 <script type='text/javascript'>
1245 add_row('', '', '', '');
1246 </script>
1247 <?php
1248 }
1249 } else {
1250 ?>
1251 <script type='text/javascript'>
1252 add_row('', '', '', '');
1253 </script>
1254 <?php
1255 }
1256 }
1257
1258 /**
1259 * Show list table settings
1260 */
1261 protected function show_list_table() {
1262 if ( null === $this->table_structure ) {
1263 return __( 'Invalid structure', 'wp-data-access' );
1264 }
1265 global $wpdb;
1266 if ( '' === $this->wpda_schema_name || $wpdb->dbname === $this->wpda_schema_name ) {
1267 $wpda_table_name = $this->wpda_table_name;
1268 } else {
1269 $wpda_table_name = $this->wpda_table_name . ' (' . $this->wpda_schema_name . ')';
1270 }
1271 ?>
1272 <form id="wpdp_form_labels" method="post">
1273 <fieldset class="wpda_fieldset wpdp_fieldset">
1274 <legend>
1275 <label style="font-weight: normal;">
1276 <?php
1277 echo __( 'Manage columns for list table of table', 'wp-data-access' );
1278 ?>
1279 </label>
1280 <label>
1281 <?php
1282 echo esc_attr( $wpda_table_name );
1283 ?>
1284 </label>
1285 </legend>
1286
1287 <table class="wpda-table-structure">
1288 <thead>
1289 <tr>
1290 <th class="wpda-table-structure-first-column-move"></th>
1291 <th>
1292 <?php
1293 echo __( 'Column name', 'wp-data-access' );
1294 ?>
1295 </th>
1296 <th>
1297 <?php
1298 echo __( 'Data type', 'wp-data-access' );
1299 ?>
1300 </th>
1301 <th>
1302 <?php
1303 echo __( 'Key', 'wp-data-access' );
1304 ?>
1305 </th>
1306 <th>
1307 <?php
1308 echo __( 'Mandatory', 'wp-data-access' );
1309 ?>
1310 </th>
1311 <th>
1312 <?php
1313 echo __( 'Visible', 'wp-data-access' );
1314 ?>
1315 </th>
1316 <th>
1317 <?php
1318 echo __( 'Label', 'wp-data-access' );
1319 ?>
1320 </th>
1321 <th></th>
1322 <th>
1323 <?php
1324 echo __( 'Lookup', 'wp-data-access' );
1325 ?>
1326 </th>
1327 </tr>
1328 </thead>
1329 <tbody id="wpda_list_table_options">
1330 <?php
1331 $table_structure = array();
1332 if ( isset( $this->table_structure->listtable_column_options ) ) {
1333 $structure = $this->table_structure->listtable_column_options;
1334 foreach ( $this->table_structure->table as $column ) {
1335 $table_structure[$column->column_name] = $column;
1336 }
1337 } else {
1338 $structure = $this->table_structure->table;
1339 }
1340 $i = 0;
1341 foreach ( $structure as $column ) {
1342 $column_name = $column->column_name;
1343 if ( isset( $this->table_structure->listtable_column_options ) && isset( $table_structure[$column_name] ) ) {
1344 $data_type = $table_structure[$column_name]->data_type;
1345 $type_attribute = $table_structure[$column_name]->type_attribute;
1346 $key = $table_structure[$column_name]->key;
1347 $mandatory = $table_structure[$column_name]->mandatory;
1348 $max_length = $table_structure[$column_name]->max_length;
1349 } else {
1350 $msg = new WPDA_Message_Box(array(
1351 'message_text' => __( "Column {$column_name} not found for list table", 'wp-data-access' ),
1352 'message_type' => 'error',
1353 'message_is_dismissible' => false,
1354 ));
1355 $msg->box();
1356 break;
1357 }
1358 if ( '' === $max_length ) {
1359 $data_type = $data_type . ' ' . $type_attribute;
1360 } else {
1361 $data_type = $data_type . ' (' . $max_length . ') ' . $type_attribute;
1362 }
1363 if ( isset( $this->table_structure->listtable_column_options ) ) {
1364 $show_in_list = ( 'on' === $column->show ? 'checked' : '' );
1365 $label_in_list = $column->label;
1366 $lookup_in_list = ( isset( $column->lookup ) ? $column->lookup : '' );
1367 } else {
1368 $show_in_list = 'checked';
1369 $label_in_list = ucfirst( str_replace( '_', ' ', $column_name ) );
1370 $lookup_in_list = '';
1371 }
1372 $i++;
1373 ?>
1374 <tr id="listtable_<?php
1375 echo esc_attr( $i );
1376 ?>">
1377 <td class="wpda-table-structure-first-column-move">
1378 <span class="dashicons dashicons-move grabbable" style="float:left;"></span>
1379 </td>
1380 <td>
1381 <?php
1382 echo esc_attr( $column_name );
1383 ?>
1384 <input type="hidden" name="list_item_name[]"
1385 value="<?php
1386 echo esc_attr( $column_name );
1387 ?>"/>
1388 </td>
1389 <td>
1390 <?php
1391 echo esc_attr( $data_type );
1392 ?>
1393 </td>
1394 <td>
1395 <?php
1396 echo esc_attr( $key );
1397 ?>
1398 </td>
1399 <td>
1400 <?php
1401 echo esc_attr( $mandatory );
1402 ?>
1403 </td>
1404 <td>
1405 <input type="checkbox"
1406 name="<?php
1407 echo esc_attr( $column_name );
1408 ?>_show"
1409 <?php
1410 echo esc_attr( $show_in_list );
1411 ?>
1412 style="vertical-align:middle;width:16px;height:16px;"
1413 />
1414 </td>
1415 <td>
1416 <input type="text"
1417 name="<?php
1418 echo esc_attr( $column_name );
1419 ?>"
1420 value="<?php
1421 echo esc_attr( $label_in_list );
1422 ?>"
1423 style="vertical-align:middle;"
1424 />
1425 </td>
1426 <td></td>
1427 <td class="wpda-table-structure-last-column">
1428 <?php
1429 $has_lookup = false;
1430 if ( isset( $this->table_structure->relationships ) ) {
1431 foreach ( $this->table_structure->relationships as $relationship ) {
1432 if ( $column_name === $relationship->source_column_name[0] && ('lookup' === $relationship->relation_type || 'autocomplete' === $relationship->relation_type) ) {
1433 if ( isset( $relationship->target_schema_name ) ) {
1434 $target_schema_name = $relationship->target_schema_name;
1435 } else {
1436 $target_schema_name = $this->wpda_schema_name;
1437 }
1438 $lookup_column_list = WPDA_Dictionary_Lists::get_table_columns( $relationship->target_table_name, $target_schema_name );
1439 ?>
1440 <select name="<?php
1441 echo esc_attr( $column_name );
1442 ?>_lookup">
1443 <?php
1444 foreach ( $lookup_column_list as $lookup_column ) {
1445 ?>
1446 <option value="<?php
1447 echo esc_attr( $lookup_column['column_name'] );
1448 ?>"
1449 <?php
1450 if ( $lookup_in_list === $lookup_column['column_name'] ) {
1451 echo 'selected';
1452 }
1453 ?>
1454 >
1455 <?php
1456 echo esc_attr( $lookup_column['column_name'] );
1457 ?>
1458 </option>
1459 <?php
1460 }
1461 ?>
1462 </select>
1463 <?php
1464 $has_lookup = true;
1465 }
1466 }
1467 }
1468 if ( !$has_lookup ) {
1469 echo '--';
1470 }
1471 ?>
1472 </td>
1473 </tr>
1474 <?php
1475 }
1476 ?>
1477 </tbody>
1478 </table>
1479 </fieldset>
1480
1481 <div class="wpdp-button-panel">
1482 <input type="hidden" name="wpda_schema_name"
1483 value="<?php
1484 echo esc_attr( $this->wpda_schema_name_db );
1485 ?>"/>
1486 <input type="hidden" name="wpda_table_name"
1487 value="<?php
1488 echo esc_attr( $this->wpda_table_name );
1489 ?>"/>
1490 <input type="hidden" name="wpda_table_setname"
1491 value="<?php
1492 echo esc_attr( $this->wpda_table_setname );
1493 ?>"/>
1494 <input type="hidden" name="wpda_table_setname_old"
1495 value="<?php
1496 echo esc_attr( $this->wpda_table_setname );
1497 ?>"/>
1498 <input type="hidden" name="action" value="edit"/>
1499 <input type="hidden" name="action2" value="listtable"/>
1500 <input type="hidden" name="wpnonce"
1501 value="<?php
1502 echo esc_attr( $this->wpnonce );
1503 ?>"/>
1504 <button type="submit" class="button button-primary">
1505 <i class="fas fa-check wpda_icon_on_button"></i>
1506 <?php
1507 echo __( 'Save list table columns', 'wp-data-access' );
1508 ?>
1509 </button>
1510 <a href="?page=<?php
1511 echo esc_attr( $this->page );
1512 ?>" class="button button-secondary">
1513 <i class="fas fa-times-circle wpda_icon_on_button"></i>
1514 <?php
1515 echo __( 'Back to list', 'wp-data-access' );
1516 ?>
1517 </a>
1518 </div>
1519
1520 </form>
1521 <?php
1522 }
1523
1524 /**
1525 * Show data entry form settings
1526 */
1527 protected function show_table_form() {
1528 if ( null === $this->table_structure ) {
1529 return __( 'Invalid structure', 'wp-data-access' );
1530 }
1531 global $wpdb;
1532 if ( '' === $this->wpda_schema_name || $wpdb->dbname === $this->wpda_schema_name ) {
1533 $wpda_table_name = $this->wpda_table_name;
1534 } else {
1535 $wpda_table_name = $this->wpda_table_name . ' (' . $this->wpda_schema_name . ')';
1536 }
1537 ?>
1538 <form id="wpdp_form_labels" method="post">
1539 <fieldset class="wpda_fieldset wpdp_fieldset">
1540 <legend>
1541 <label style="font-weight: normal;">
1542 <?php
1543 echo __( 'Manage columns for data entry form for table', 'wp-data-access' );
1544 ?>
1545 </label>
1546 <label>
1547 <?php
1548 echo esc_attr( $wpda_table_name );
1549 ?>
1550 </label>
1551 </legend>
1552
1553 <table class="wpda-table-structure">
1554 <thead>
1555 <tr>
1556 <th class="wpda-table-structure-first-column-move"></th>
1557 <th>
1558 <?php
1559 echo __( 'Column name', 'wp-data-access' );
1560 ?>
1561 </th>
1562 <th>
1563 <?php
1564 echo __( 'Data type', 'wp-data-access' );
1565 ?>
1566 </th>
1567 <th>
1568 <?php
1569 echo __( 'Key', 'wp-data-access' );
1570 ?>
1571 </th>
1572 <th>
1573 <?php
1574 echo __( 'Mandatory', 'wp-data-access' );
1575 ?>
1576 </th>
1577 <th>
1578 <?php
1579 echo __( 'Visible', 'wp-data-access' );
1580 ?>
1581 </th>
1582 <th>
1583 <?php
1584 echo __( 'Read only', 'wp-data-access' );
1585 ?>
1586 </th>
1587 <th>
1588 <?php
1589 echo __( 'Less', 'wp-data-access' );
1590 ?>
1591 </th>
1592 <th>
1593 <?php
1594 echo __( 'Label', 'wp-data-access' );
1595 ?>
1596 </th>
1597 <th></th>
1598 <th>
1599 <?php
1600 echo __( 'Default value', 'wp-data-access' );
1601 ?>
1602 </th>
1603 <th></th>
1604 <th>
1605 <?php
1606 echo __( 'Lookup', 'wp-data-access' );
1607 ?>
1608 </th>
1609 <th>
1610 <span style="vertical-align:inherit">
1611 <?php
1612 echo __( 'ID?', 'wp-data-access' );
1613 ?>
1614 </span>
1615 <span
1616 class="dashicons dashicons-info wpda_tooltip"
1617 title="<?php
1618 echo __( 'Enable to hide ID in lookup', 'wp-data-access' );
1619 ?>"
1620 style="cursor:pointer;"
1621 ></span>
1622
1623 </th>
1624 </tr>
1625 </thead>
1626 <tbody id="wpda_form_options">
1627 <?php
1628 $table_structure = array();
1629 if ( isset( $this->table_structure->tableform_column_options ) ) {
1630 $structure = $this->table_structure->tableform_column_options;
1631 foreach ( $this->table_structure->table as $column ) {
1632 $table_structure[$column->column_name] = $column;
1633 }
1634 } else {
1635 $structure = $this->table_structure->table;
1636 }
1637 $i = 0;
1638 foreach ( $structure as $column ) {
1639 $column_name = $column->column_name;
1640 if ( isset( $this->table_structure->tableform_column_options ) && isset( $table_structure[$column_name] ) ) {
1641 $data_type = $table_structure[$column_name]->data_type;
1642 $type_attribute = $table_structure[$column_name]->type_attribute;
1643 $key = $table_structure[$column_name]->key;
1644 $mandatory = $table_structure[$column_name]->mandatory;
1645 $max_length = $table_structure[$column_name]->max_length;
1646 } else {
1647 $msg = new WPDA_Message_Box(array(
1648 'message_text' => __( "Column {$column_name} not found for data entry form", 'wp-data-access' ),
1649 'message_type' => 'error',
1650 'message_is_dismissible' => false,
1651 ));
1652 $msg->box();
1653 break;
1654 }
1655 if ( '' === $max_length ) {
1656 $data_type = $data_type . ' ' . $type_attribute;
1657 } else {
1658 $data_type = $data_type . ' (' . $max_length . ') ' . $type_attribute;
1659 }
1660 if ( isset( $this->table_structure->tableform_column_options ) ) {
1661 $show_on_form = ( 'on' === $column->show ? 'checked' : '' );
1662 $label_on_form = $column->label;
1663 $lookup_in_list = ( isset( $column->lookup ) ? $column->lookup : '' );
1664 } else {
1665 $show_on_form = 'checked';
1666 $label_on_form = ucfirst( str_replace( '_', ' ', $column_name ) );
1667 $lookup_in_list = '';
1668 }
1669 if ( isset( $column->readonly ) ) {
1670 $readonly_on_form = ( 'on' === $column->readonly ? 'checked' : '' );
1671 } else {
1672 $readonly_on_form = '';
1673 }
1674 if ( isset( $column->less ) ) {
1675 $less_on_form = ( 'on' === $column->less ? 'checked' : '' );
1676 } else {
1677 $less_on_form = 'checked';
1678 }
1679 if ( isset( $column->default ) ) {
1680 $default_on_form = esc_html( $column->default );
1681 } else {
1682 $default_on_form = '';
1683 }
1684 if ( isset( $column->hide_lookup_key ) ) {
1685 $hide_id = ( 'on' === $column->hide_lookup_key ? 'checked' : '' );
1686 } else {
1687 $hide_id = 'checked';
1688 }
1689 $i++;
1690 ?>
1691 <tr id="tableform_<?php
1692 echo esc_attr( $i );
1693 ?>">
1694 <td class="wpda-table-structure-first-column-move">
1695 <span class="dashicons dashicons-move grabbable" style="float:left;"></span>
1696 </td>
1697 <td>
1698 <?php
1699 echo esc_attr( $column_name );
1700 ?>
1701 <input type="hidden" name="list_item_name[]"
1702 value="<?php
1703 echo esc_attr( $column_name );
1704 ?>"/>
1705 </td>
1706 <td>
1707 <?php
1708 echo esc_attr( $data_type );
1709 ?>
1710 <?php
1711 echo ( $this->wpda_list_columns->get_auto_increment_column_name() === $column_name ? ' (auto increment)' : '' );
1712 ?>
1713 </td>
1714 <td>
1715 <?php
1716 echo ( 'Yes' === $key ? 'Yes' : '' );
1717 ?>
1718 </td>
1719 <td>
1720 <?php
1721 echo ( 'Yes' === $mandatory ? 'Yes' : '' );
1722 ?>
1723 </td>
1724 <td>
1725 <?php
1726 if ( $this->wpda_list_columns->get_auto_increment_column_name() === $column_name ) {
1727 // Allow to hide auto_increment column
1728 $l_key = 'No';
1729 $l_mandatory = 'No';
1730 } else {
1731 $l_key = $key;
1732 $l_mandatory = $mandatory;
1733 }
1734 ?>
1735 <input type="checkbox"
1736 name="<?php
1737 echo esc_attr( $column_name );
1738 ?>_show"
1739 <?php
1740 echo esc_attr( $show_on_form );
1741 ?>
1742 <?php
1743 if ( 'Yes' === $l_key || 'Yes' === $l_mandatory ) {
1744 echo ' disabled="disabled"';
1745 }
1746 ?>
1747 style="vertical-align:middle;width:16px;height:16px;"
1748 />
1749 <?php
1750 if ( 'Yes' === $l_key || 'Yes' === $l_mandatory ) {
1751 ?>
1752 <input name="<?php
1753 echo esc_attr( $column_name );
1754 ?>_show"
1755 type="hidden"
1756 value="true"/>
1757 <?php
1758 }
1759 ?>
1760 </td>
1761 <td>
1762 <input type="checkbox" name="<?php
1763 echo esc_attr( $column_name );
1764 ?>_readonly"
1765 style="vertical-align:middle;width:16px;height:16px;"
1766 <?php
1767 echo esc_attr( $readonly_on_form );
1768 ?>
1769 />
1770 </td>
1771 <td>
1772 <input type="checkbox" name="<?php
1773 echo esc_attr( $column_name );
1774 ?>_less"
1775 style="vertical-align:middle;width:16px;height:16px;"
1776 <?php
1777 echo esc_attr( $less_on_form );
1778 ?>
1779 />
1780 </td>
1781 <td>
1782 <input type="text"
1783 name="<?php
1784 echo esc_attr( $column_name );
1785 ?>"
1786 value="<?php
1787 echo esc_attr( $label_on_form );
1788 ?>"
1789 style="vertical-align:middle;"
1790 />
1791 </td>
1792 <td></td>
1793 <td>
1794 <input type="text"
1795 name="<?php
1796 echo esc_attr( $column_name );
1797 ?>_default"
1798 value="<?php
1799 echo esc_attr( $default_on_form );
1800 ?>"
1801 style="vertical-align:middle;"
1802 />
1803 </td>
1804 <td></td>
1805 <td>
1806 <?php
1807 $has_lookup = false;
1808 if ( isset( $this->table_structure->relationships ) ) {
1809 foreach ( $this->table_structure->relationships as $relationship ) {
1810 if ( $column_name === $relationship->source_column_name[0] && ('lookup' === $relationship->relation_type || 'autocomplete' === $relationship->relation_type) ) {
1811 if ( isset( $relationship->target_schema_name ) ) {
1812 $target_schema_name = $relationship->target_schema_name;
1813 } else {
1814 $target_schema_name = $this->wpda_schema_name;
1815 }
1816 $lookup_column_list = WPDA_Dictionary_Lists::get_table_columns( $relationship->target_table_name, $target_schema_name );
1817 ?>
1818 <select name="<?php
1819 echo esc_attr( $column_name );
1820 ?>_lookup">
1821 <?php
1822 foreach ( $lookup_column_list as $lookup_column ) {
1823 ?>
1824 <option value="<?php
1825 echo esc_attr( $lookup_column['column_name'] );
1826 ?>"
1827 <?php
1828 if ( $lookup_in_list === $lookup_column['column_name'] ) {
1829 echo 'selected';
1830 }
1831 ?>
1832 >
1833 <?php
1834 echo esc_attr( $lookup_column['column_name'] );
1835 ?>
1836 </option>
1837 <?php
1838 }
1839 ?>
1840 </select>
1841 <?php
1842 $has_lookup = true;
1843 }
1844 }
1845 }
1846 if ( !$has_lookup ) {
1847 echo '--';
1848 }
1849 ?>
1850 </td>
1851 <td class="wpda-table-structure-last-column">
1852 <?php
1853 if ( $has_lookup ) {
1854 ?>
1855 <input type="checkbox"
1856 name="<?php
1857 echo esc_attr( $column_name );
1858 ?>_hide_lookup_key"
1859 <?php
1860 echo esc_attr( $hide_id );
1861 ?>
1862 style="vertical-align:middle;width:16px;height:16px;"
1863 />
1864 <?php
1865 }
1866 ?>
1867 </td>
1868 </tr>
1869 <?php
1870 }
1871 ?>
1872 </tbody>
1873 </table>
1874 </fieldset>
1875
1876 <div class="wpdp-button-panel">
1877 <input type="hidden" name="wpda_schema_name"
1878 value="<?php
1879 echo esc_attr( $this->wpda_schema_name_db );
1880 ?>"/>
1881 <input type="hidden" name="wpda_table_name"
1882 value="<?php
1883 echo esc_attr( $this->wpda_table_name );
1884 ?>"/>
1885 <input type="hidden" name="wpda_table_setname"
1886 value="<?php
1887 echo esc_attr( $this->wpda_table_setname );
1888 ?>"/>
1889 <input type="hidden" name="wpda_table_setname_old"
1890 value="<?php
1891 echo esc_attr( $this->wpda_table_setname );
1892 ?>"/>
1893 <input type="hidden" name="action" value="edit"/>
1894 <input type="hidden" name="action2" value="tableform"/>
1895 <input type="hidden" name="wpnonce"
1896 value="<?php
1897 echo esc_attr( $this->wpnonce );
1898 ?>"/>
1899 <button type="submit" class="button button-primary">
1900 <i class="fas fa-check wpda_icon_on_button"></i>
1901 <?php
1902 echo __( 'Save data entry form columns', 'wp-data-access' );
1903 ?>
1904 </button>
1905 <a href="?page=<?php
1906 echo esc_attr( $this->page );
1907 ?>" class="button button-secondary">
1908 <i class="fas fa-times-circle wpda_icon_on_button"></i>
1909 <?php
1910 echo __( 'Back to list', 'wp-data-access' );
1911 ?>
1912 </a>
1913 </div>
1914
1915 </form>
1916 <?php
1917 }
1918
1919 protected function show_reconcile() {
1920 ?>
1921 <div class="wrap" style="padding-left:8px;">
1922 <form method="post">
1923 <fieldset class="wpda_fieldset wpdp_fieldset">
1924 <legend>
1925 <label style="font-weight: normal;">
1926 <?php
1927 echo __( 'Reconcile columns for table', 'wp-data-access' );
1928 ?>
1929 </label>
1930 <label>
1931 <?php
1932 echo esc_attr( $this->wpda_table_name );
1933 ?>
1934 </label>
1935 </legend>
1936
1937 <div>
1938 <strong>Update table design from database table</strong>
1939 <ul class="wpdp-reconcile">
1940 <li>Add new columns</li>
1941 <li>Remove deleted columns</li>
1942 <li>Change column settings</li>
1943 <li>Update settings</li>
1944 </ul>
1945 <label style="line-height:30px;padding-bottom:8px">
1946 <input type="checkbox" name="keep_options" style="vertical-align:middle;">
1947 <strong>Keep options?</strong> (enable to keep settings of unchanged columns)
1948 </label>
1949 </div>
1950 </fieldset>
1951
1952 <div class="wpdp-spacer"></div>
1953 <div class="wpdp-spacer"></div>
1954
1955 <div class="wpdp-button-panel">
1956 <input type="hidden" name="action" value="reconcile"/>
1957 <input type="hidden" name="wpda_schema_name"
1958 value="<?php
1959 echo esc_attr( $this->wpda_schema_name_db );
1960 ?>">
1961 <input type="hidden" name="wpda_table_name"
1962 value="<?php
1963 echo esc_attr( $this->wpda_table_name );
1964 ?>">
1965 <input type="hidden" name="wpda_table_setname"
1966 value="<?php
1967 echo esc_attr( $this->wpda_table_setname );
1968 ?>"/>
1969 <input type="hidden" name="wpnonce"
1970 value="<?php
1971 echo esc_attr( $this->wpnonce );
1972 ?>"/>
1973 <button type="submit" class="button button-primary wpda_tooltip"
1974 onclick="return (confirm('<?php
1975 echo __( 'Reconcile table? Your current modifications will be lost!' );
1976 ?>'));"
1977 >
1978 <i class="fas fa-check wpda_icon_on_button"></i>
1979 <?php
1980 echo __( 'Reconcile Table', 'wp-data-access' );
1981 ?>
1982 </button>
1983 <a href="?page=<?php
1984 echo esc_attr( $this->page );
1985 ?>" class="button button-secondary">
1986 <i class="fas fa-times-circle wpda_icon_on_button"></i>
1987 <?php
1988 echo __( 'Back to list', 'wp-data-access' );
1989 ?>
1990 </a>
1991 </div>
1992 </form>
1993 </div>
1994 <?php
1995 }
1996
1997 }
1998