Field.php
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
namespace ACA\Pods;
use AC;
use ACA\Pods\ConditionalFormatting\FormattableConfigFactory;
use ACP;
use ACP\ConditionalFormat\FormattableConfig;
class Field
implements ACP\Filtering\Filterable, ACP\Sorting\Sortable, ACP\Editing\Editable, ACP\Export\Exportable, ACP\Search\Searchable, ACP\ConditionalFormat\Formattable {
/**
* @var Column
*/
protected $column;
public function __construct( Column $column ) {
$this->column = $column;
}
public function filtering() {
return new Filtering\Disabled( $this->column );
}
public function editing() {
return false;
}
public function sorting() {
return new ACP\Sorting\Model\Disabled();
}
public function export() {
return new ACP\Export\Model\RawValue( $this->column );
}
public function search() {
return false;
}
public function conditional_format(): ?FormattableConfig {
return ( new FormattableConfigFactory() )->create( $this );
}
/**
* @return AC\Settings\Column[]
*/
public function get_dependent_settings() {
return [];
}
/**
* @return Column
*/
protected function column() {
return $this->column;
}
public function get_value( $id ) {
return $this->column->get_formatted_value( $this->get_raw_value( $id ) );
}
/**
* @return string
*/
public function get_pod() {
return $this->get( 'pod' );
}
/**
* @return string
*/
public function get_field_name() {
return $this->get_meta_key();
}
public function get_raw_value( $id ) {
return pods_field_raw( $this->get_pod(), $id, $this->get_field_name(), true );
}
public function get_meta_type() {
return $this->column->get_meta_type();
}
/**
* Get the raw DB value
*
* @param int $id
*
* @return array|false
*/
protected function get_db_value( $id ) {
return ( new Value\DbRaw( $this->get_meta_key(), $this->get_meta_type() ) )->get_value( $id );
}
public function get_separator() {
return null;
}
/**
* @param string $key
*
* @return mixed|false
*/
public function get( $key ) {
return $this->column->get_pod_field_option( $key );
}
/**
* @param string $key
*
* @return mixed|false
*/
public function get_option( $key ) {
$options = $this->get( 'options' );
return isset( $options[ $key ] ) ? $options[ $key ] : false;
}
protected function get_meta_key() {
return $this->column->get_meta_key();
}
}