PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.2
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.2
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.2, at WPDataProjects/Project/WPDP_Project_Project_List.php

137 lines 4.3 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 /**
24 * WPDP_Project_Project_List constructor
25 *
26 * @param array $args
27 */
28 public function __construct( array $args = array() )
29 {
30 $args['column_headers'] = self::column_headers_labels();
31 $args['allow_import'] = 'off';
32 $args['allow_insert'] = 'on';
33 parent::__construct( $args );
34 try {
35 // Instantiate WPDA_Import.
36 $this->wpda_import = new WPDA_Import_Multi( "?page={$this->page}", $this->schema_name, array( __( 'IMPORT DATA PROJECTS', 'wp-data-access' ), '' ) );
37 } catch ( \Exception $e ) {
38 // If import is turned off instantition will fail. Handle is set to null (check in future calls).
39 $this->wpda_import = null;
40 }
41 }
42
43 /**
44 * Overwrites method add_header_button to add arguments to insert button
45 *
46 * @param string $add_param
47 */
48 protected function add_header_button( $add_param = '' )
49 {
50 ?>
51 <form
52 method="post"
53 action="?page=<?php
54 echo esc_attr( $this->page ) ;
55 ?>"
56 style="display: inline-block; vertical-align: unset;"
57 >
58 <div>
59 <input type="hidden" name="action" value="new">
60 <input type="hidden" name="mode" value="edit">
61 <input type="hidden" name="table_name" value="<?php
62 echo esc_attr( $this->table_name ) ;
63 ?>">
64 <button type="submit" class="page-title-action wpda_tooltip"
65 title="Add new project to repository"
66 >
67 <span class="material-icons wpda_icon_on_button">add_circle</span>
68 <?php
69 echo __( 'Add New', 'wp-data-access' ) ;
70 ?>
71 </button>
72 </div>
73 </form>
74 <?php
75 if ( null !== $this->wpda_import ) {
76 $this->wpda_import->add_button( __( 'Import', 'wp-data-access' ) );
77 }
78 }
79
80 /**
81 * Overwrites method column_default_add_action to rewrite export action
82 *
83 * Default export supports single table export only. Project export support exporting child rows as well.
84 *
85 * @param array $item
86 * @param string $column_name
87 * @param array $actions
88 */
89 protected function column_default_add_action( $item, $column_name, &$actions )
90 {
91 parent::column_default_add_action( $item, $column_name, $actions );
92 $wp_nonce_action = 'wpdp-export-project-' . $item['project_id'];
93 $wp_nonce = wp_create_nonce( $wp_nonce_action );
94 $src = '?action=wpda_export_project&project_id=' . $item['project_id'] . '&wpnonce=' . $wp_nonce;
95 $actions['export'] = sprintf( '
96 <a href="%s" target="_blank" title="Export project" class="wpda_tooltip">
97 <span style="white-space:nowrap">
98 <span class="material-icons wpda_icon_on_button">cloud_download</span>
99 %s
100 </span>
101 </a>
102 ', $src, __( 'Export', 'wp-data-access' ) );
103 }
104
105 public static function column_headers_labels()
106 {
107 return array(
108 'project_id' => __( 'Project ID', 'wp-data-access' ),
109 'project_name' => __( 'Project Name', 'wp-data-access' ),
110 'project_description' => __( 'Project Description', 'wp-data-access' ),
111 'add_to_menu' => __( 'Add To Menu', 'wp-data-access' ),
112 'menu_name' => __( 'Menu Name', 'wp-data-access' ),
113 'project_sequence' => __( 'Seq#', 'wp-data-access' ),
114 );
115 }
116
117 // Overwrite method
118 public function show()
119 {
120 parent::show();
121 WPDA::shortcode_popup();
122 }
123
124 public function get_bulk_actions()
125 {
126 $actions = parent::get_bulk_actions();
127 unset(
128 $actions['bulk-export'],
129 $actions['bulk-export-xml'],
130 $actions['bulk-export-json'],
131 $actions['bulk-export-excel'],
132 $actions['bulk-export-csv']
133 );
134 return $actions;
135 }
136
137 }