| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDataAccess\Data_Apps; |
| 4 |
|
| 5 |
use WPDataAccess\API\WPDA_API_Core; |
| 6 |
use WPDataAccess\WPDA; |
| 7 |
class WPDA_Table_Container extends WPDA_Container { |
| 8 |
private $dbs = null; |
| 9 |
|
| 10 |
private $tbl = null; |
| 11 |
|
| 12 |
private $s; |
| 13 |
|
| 14 |
// Search string |
| 15 |
private $c; |
| 16 |
|
| 17 |
// Case sensitive ("true"|"false") |
| 18 |
public function __construct( $args = array() ) { |
| 19 |
parent::__construct( $args ); |
| 20 |
if ( !WPDA::current_user_is_admin() ) { |
| 21 |
if ( !is_admin() && !$this->send_feedback() ) { |
| 22 |
return; |
| 23 |
} |
| 24 |
$this->show_feedback( __( 'Not authorized', 'wp-data-access' ) ); |
| 25 |
return; |
| 26 |
} |
| 27 |
if ( isset( $args['dbs'], $args['tbl'] ) ) { |
| 28 |
$this->dbs = WPDA_API_Core::sanitize_db_identifier( $args['dbs'] ); |
| 29 |
$this->tbl = WPDA_API_Core::sanitize_db_identifier( $args['tbl'] ); |
| 30 |
} else { |
| 31 |
if ( isset( $args['feedback'] ) && false === $args['feedback'] ) { |
| 32 |
return; |
| 33 |
} |
| 34 |
throw new \Exception(esc_attr__( 'ERROR: Invalid usage', 'wp-data-access' )); |
| 35 |
} |
| 36 |
$this->s = ( isset( $args['s'] ) ? sanitize_text_field( $args['s'] ) : '' ); |
| 37 |
// Not required |
| 38 |
$this->c = ( isset( $args['c'] ) ? sanitize_text_field( $args['c'] ) : '' ); |
| 39 |
// Not required |
| 40 |
} |
| 41 |
|
| 42 |
public function show() { |
| 43 |
if ( !WPDA::current_user_is_admin() ) { |
| 44 |
if ( !is_admin() && !$this->send_feedback() ) { |
| 45 |
return; |
| 46 |
} |
| 47 |
$this->show_feedback( __( 'Not authorized', 'wp-data-access' ) ); |
| 48 |
return; |
| 49 |
} |
| 50 |
?> |
| 51 |
<div class="wrap wpda-explorer-backend"> |
| 52 |
|
| 53 |
<h1 class="wp-heading-inline" style="margin-bottom: 18px"> |
| 54 |
<?php |
| 55 |
?> |
| 56 |
Data Explorer |
| 57 |
</h1> |
| 58 |
|
| 59 |
<div class="wpda-pp-container"> |
| 60 |
<div |
| 61 |
class="pp-container-explorer pp-container-admin" |
| 62 |
data-source="{ 'dbs': '<?php |
| 63 |
echo esc_attr( $this->dbs ); |
| 64 |
?>', 'tbl': '<?php |
| 65 |
echo esc_attr( $this->tbl ); |
| 66 |
?>', 's': '<?php |
| 67 |
echo esc_attr( $this->s ); |
| 68 |
?>', 'c': '<?php |
| 69 |
echo esc_attr( $this->c ); |
| 70 |
?>' }" |
| 71 |
></div> |
| 72 |
</div> |
| 73 |
|
| 74 |
</div> |
| 75 |
<?php |
| 76 |
$this->add_client( 'de' ); |
| 77 |
} |
| 78 |
|
| 79 |
} |
| 80 |
|