| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDataAccess\Settings { |
| 4 |
|
| 5 |
use WPDataAccess\API\WPDA_API_Core; |
| 6 |
use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists; |
| 7 |
use WPDataAccess\Utilities\WPDA_Table_Actions; |
| 8 |
|
| 9 |
class WPDA_Settings_Legacy_TableSettings extends WPDA_Settings_Legacy_Page { |
| 10 |
|
| 11 |
/** |
| 12 |
* Legacy table settings |
| 13 |
* |
| 14 |
* @since 2.7.0 |
| 15 |
*/ |
| 16 |
public function show() { |
| 17 |
global $wpdb; |
| 18 |
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- already verified |
| 19 |
$dbs = isset( $_REQUEST['dbs'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['dbs'] ) ) : $wpdb->dbname; // input var okay. |
| 20 |
$tbl = isset( $_REQUEST['tbl'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tbl'] ) ) : ''; // input var okay. |
| 21 |
// phpcs:enable WordPress.Security.NonceVerification.Recommended |
| 22 |
?> |
| 23 |
<div> |
| 24 |
<form method="post" id="form_settings"> |
| 25 |
<fieldset style="border: 1px solid #c3c4c7; padding: 30px; border-radius: 4px; margin-bottom: 20px;"> |
| 26 |
<legend> |
| 27 |
Legacy Table Settings |
| 28 |
</legend> |
| 29 |
|
| 30 |
<div style="display: grid; gap: 10px;"> |
| 31 |
<div style="font-size: 85%;"> |
| 32 |
<div> |
| 33 |
Use this page to access table and view settings from the old Data Explorer. |
| 34 |
Select a database and a table or view, then press the <strong>SETTINGS</strong> button to access legacy table settings. |
| 35 |
</div> |
| 36 |
<div> |
| 37 |
✔ Dashboard menu settings are no longer available here. Use the App Builder to replace old dashboard menus. |
| 38 |
</div> |
| 39 |
<div> |
| 40 |
✔ The REST API menu is also no longer available here. Use the new Data Explorer to manage REST API settings. |
| 41 |
</div> |
| 42 |
</div> |
| 43 |
|
| 44 |
<div> |
| 45 |
<div> |
| 46 |
<label><strong>Select Database</strong></label> |
| 47 |
</div> |
| 48 |
<div> |
| 49 |
<select name="dbs" onchange="on_dbs_change()"> |
| 50 |
<?php |
| 51 |
$schemas = WPDA_Dictionary_Lists::get_db_schemas(); |
| 52 |
foreach ( $schemas as $schema ) { |
| 53 |
$selected = $dbs === $schema['schema_name'] ? ' selected' : ''; |
| 54 |
echo "<option value='{$schema['schema_name']}'$selected>{$schema['schema_name']}</option>"; // phpcs:ignore WordPress.Security.EscapeOutput |
| 55 |
} |
| 56 |
?> |
| 57 |
</select> |
| 58 |
</div> |
| 59 |
</div> |
| 60 |
|
| 61 |
<div> |
| 62 |
<div> |
| 63 |
<label><strong>Select Table</strong></label> |
| 64 |
</div> |
| 65 |
<div> |
| 66 |
<select name="tbl" id="tbl"> |
| 67 |
<?php |
| 68 |
$tables = WPDA_Dictionary_Lists::get_tables(true, $dbs); |
| 69 |
foreach ( $tables as $table ) { |
| 70 |
$selected = $tbl === $table['table_name'] ? ' selected' : ''; |
| 71 |
echo "<option value='{$table['table_name']}'$selected>{$table['table_name']}</option>"; // phpcs:ignore WordPress.Security.EscapeOutput |
| 72 |
} |
| 73 |
?> |
| 74 |
</select> |
| 75 |
</div> |
| 76 |
</div> |
| 77 |
|
| 78 |
<div style="margin-top: 10px;"> |
| 79 |
<button type="submit" class="button button-primary">SETTINGS</button> |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
</fieldset> |
| 83 |
</form> |
| 84 |
|
| 85 |
<div> |
| 86 |
<?php |
| 87 |
if ($tbl !== '') { |
| 88 |
$plugin_table_actions = new WPDA_Table_Actions(); |
| 89 |
$plugin_table_actions->show( WPDA_API_Core::sanitize_db_identifier( $dbs ), WPDA_API_Core::sanitize_db_identifier( $tbl ) ); |
| 90 |
} |
| 91 |
?> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
|
| 95 |
<script> |
| 96 |
function on_dbs_change() { |
| 97 |
if ("<?php echo esc_attr( $tbl); ?>" !== "") { |
| 98 |
jQuery("#tbl").val(""); |
| 99 |
jQuery("#form_settings").submit(); |
| 100 |
} |
| 101 |
} |
| 102 |
</script> |
| 103 |
<?php |
| 104 |
|
| 105 |
} |
| 106 |
|
| 107 |
} |
| 108 |
|
| 109 |
} |
| 110 |
|