PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / trunk
JetFormBuilder — Dynamic Blocks Form Builder vtrunk
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / admin / table-views / column-base.php
jetformbuilder / includes / admin / table-views Last commit date
actions 2 years ago columns 2 years ago column-advanced-base.php 2 years ago column-base.php 2 years ago column-heading-interface.php 2 years ago column-heading-trait.php 2 years ago view-advanced-base.php 2 years ago view-base.php 2 years ago view-simple-base.php 2 years ago
column-base.php
123 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Admin\Table_Views;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 // phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found
12
13 abstract class Column_Base {
14
15 const CHOOSE = 'choose';
16 const ACTIONS = 'actions';
17 const CLASSES = 'classes';
18 const STATUS = 'icon_status';
19 const PRE = 'pre';
20 const LINK = 'link';
21 const STATUS_SUCCESS = 'success';
22 const STATUS_INFO = 'info';
23 const STATUS_WARNING = 'warning';
24 const STATUS_FAILED = 'failed';
25 const STATUS_PENDING = 'pending';
26
27 protected $column = '';
28 protected $type = 'string';
29
30 public function __construct( $column = '' ) {
31 $this->set_column( $column );
32 }
33
34 final public function set_column( $column ): Column_Base {
35 if ( empty( $this->column ) && $column ) {
36 $this->column = $column;
37 }
38
39 return $this;
40 }
41
42 public function get_value( array $record = array() ) {
43 return $record[ $this->column ] ?? false;
44 }
45
46 public function get_type( array $record = array() ): string {
47 return $this->type;
48 }
49
50 public function is_editable( array $record = array() ): bool {
51 return false;
52 }
53
54 public function get_control( array $record = array() ): string {
55 return 'input';
56 }
57
58 public function get_control_options( array $record = array() ): array {
59 return array(
60 'type' => 'text',
61 );
62 }
63
64 public function get_options( array $record = array() ): array {
65 return array();
66 }
67
68 public function get_css_classes( array $record = array() ): array {
69 return array();
70 }
71
72 final public function get_column( array $record ): array {
73 $type = $this->get_type( $record );
74 $value = $this->prepare_value( $this->get_value( $record ), $type );
75 $editable = $this->is_editable( $record );
76 $options = $this->get_options( $record );
77 $classes = $this->get_css_classes( $record );
78 $control = 'input';
79 $control_options = array();
80
81 if ( $editable ) {
82 $control = $this->get_control( $record );
83 $control_options = $this->get_control_options( $record );
84 }
85
86 return array(
87 'type' => $type,
88 'value' => $value,
89 'editable' => $editable,
90 'control' => $control,
91 'control_options' => $control_options,
92 'classes' => $classes,
93 ) + $options;
94 }
95
96 protected function prepare_value( $value, $type ) {
97 switch ( $type ) {
98 case 'integer':
99 return (int) $value;
100 case 'price':
101 return number_format( $value, 2 );
102 case 'array':
103 return (array) $value;
104 case 'string':
105 if ( is_array( $value ) && array_key_exists( 'text', $value ) ) {
106 return (string) $value['text'];
107 }
108
109 return (string) $value;
110 case 'rawArray':
111 default:
112 return $value;
113 }
114 }
115
116 public function set_type( string $type ): Column_Base {
117 $this->type = $type;
118
119 return $this;
120 }
121
122 }
123