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