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

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

129 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 *
6 * @package WPDataProjects\Project
7 */
8 namespace WPDataProjects\Project;
9
10 use WPDataAccess\WPDA;
11 use WPDataProjects\Parent_Child\WPDP_Parent_List_Table;
12 use WPDataAccess\Utilities\WPDA_Import_Multi;
13 /**
14 * Class WPDP_Project_Project_List extends WPDP_Parent_List_Table
15 *
16 * @see WPDP_Parent_List_Table
17 *
18 * @author Peter Schulz
19 * @since 2.0.0
20 */
21 class WPDP_Project_Project_List extends WPDP_Parent_List_Table {
22 /**
23 * WPDP_Project_Project_List constructor
24 *
25 * @param array $args
26 */
27 public function __construct( array $args = array() ) {
28 $args['column_headers'] = self::column_headers_labels();
29 $args['allow_import'] = 'off';
30 $args['allow_insert'] = 'on';
31 parent::__construct( $args );
32 try {
33 // Instantiate WPDA_Import.
34 $this->wpda_import = new WPDA_Import_Multi("?page={$this->page}", $this->schema_name, array(__( 'IMPORT DATA PROJECTS', 'wp-data-access' ), ''));
35 } catch ( \Exception $e ) {
36 // If import is turned off instantition will fail. Handle is set to null (check in future calls).
37 $this->wpda_import = null;
38 }
39 }
40
41 /**
42 * Overwrites method add_header_button to add arguments to insert button
43 */
44 protected function add_header_button() {
45 ?>
46 <form
47 method="post"
48 action="?page=<?php
49 echo esc_attr( $this->page );
50 ?>"
51 style="display: inline-block; vertical-align: unset;"
52 >
53 <div>
54 <input type="hidden" name="action" value="new">
55 <input type="hidden" name="mode" value="edit">
56 <input type="hidden" name="table_name" value="<?php
57 echo esc_attr( $this->table_name );
58 ?>">
59 <button type="submit" class="page-title-action wpda_tooltip"
60 title="Add new project to repository"
61 >
62 <i class="fas fa-plus-circle wpda_icon_on_button"></i>
63 <?php
64 echo __( 'Add New', 'wp-data-access' );
65 ?>
66 </button>
67 </div>
68 </form>
69 <?php
70 if ( null !== $this->wpda_import ) {
71 $this->wpda_import->add_button( __( 'Import', 'wp-data-access' ) );
72 }
73 }
74
75 /**
76 * Overwrites method column_default_add_action to rewrite export action
77 *
78 * Default export supports single table export only. Project export support exporting child rows as well.
79 *
80 * @param array $item
81 * @param string $column_name
82 * @param array $actions
83 */
84 protected function column_default_add_action( $item, $column_name, &$actions ) {
85 parent::column_default_add_action( $item, $column_name, $actions );
86 $wp_nonce_action = 'wpdp-export-project-' . $item['project_id'];
87 $wp_nonce = wp_create_nonce( $wp_nonce_action );
88 $src = '?action=wpda_export_project&project_id=' . $item['project_id'] . '&wpnonce=' . $wp_nonce;
89 $actions['export'] = sprintf( '
90 <a href="%s" target="_blank" title="Export project" class="wpda_tooltip">
91 <span style="white-space:nowrap">
92 <i class="fas fa-cloud-download wpda_icon_on_button"></i>
93 %s
94 </span>
95 </a>
96 ', $src, __( 'Export', 'wp-data-access' ) );
97 }
98
99 public static function column_headers_labels() {
100 return array(
101 'project_id' => __( 'Project ID', 'wp-data-access' ),
102 'project_name' => __( 'Project Name', 'wp-data-access' ),
103 'project_description' => __( 'Project Description', 'wp-data-access' ),
104 'add_to_menu' => __( 'Add To Menu', 'wp-data-access' ),
105 'menu_name' => __( 'Menu Name', 'wp-data-access' ),
106 'project_sequence' => __( 'Seq#', 'wp-data-access' ),
107 );
108 }
109
110 // Overwrite method
111 public function show() {
112 parent::show();
113 WPDA::shortcode_popup();
114 }
115
116 public function get_bulk_actions() {
117 $actions = parent::get_bulk_actions();
118 unset(
119 $actions['bulk-export'],
120 $actions['bulk-export-xml'],
121 $actions['bulk-export-json'],
122 $actions['bulk-export-excel'],
123 $actions['bulk-export-csv']
124 );
125 return $actions;
126 }
127
128 }
129