DisplayDate.php
1.88 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
<?php
namespace ACA\EC\Column\Event;
use AC;
use ACA\EC\Editing;
use ACA\EC\Filtering;
use ACA\EC\Service\ColumnGroups;
use ACA\EC\Settings;
use ACP;
use ACP\ConditionalFormat\FormattableConfig;
use ACP\Search;
use ACP\Sorting\Type\DataType;
class DisplayDate extends AC\Column\Meta
implements ACP\Filtering\Filterable, ACP\Sorting\Sortable, ACP\Search\Searchable, ACP\Editing\Editable, ACP\ConditionalFormat\Formattable {
public function __construct() {
$this->set_type( 'column-ec-event_display_date' )
->set_label( __( 'Date', 'codepress-admin-columns' ) )
->set_group( ColumnGroups::EVENTS_CALENDAR );
}
public function get_meta_key() {
return $this->get_setting( 'event_date' )->get_value();
}
public function get_value( $id ) {
return $this->get_formatted_value( $this->get_raw_value( $id ) );
}
public function filtering() {
return new Filtering\Event\Date( $this );
}
public function register_settings() {
$this->add_setting( new Settings\EventDates( $this ) );
$this->add_setting( new AC\Settings\Column\Date( $this ) );
}
public function sorting() {
return new ACP\Sorting\Model\Post\Meta( $this->get_meta_key(), new DataType( DataType::DATETIME ) );
}
public function search() {
return new Search\Comparison\Meta\DateTime\ISO( $this->get_meta_key(), $this->get_meta_type() );
}
public function editing() {
switch ( $this->get_meta_key() ) {
case '_EventStartDate':
return new ACP\Editing\Service\Basic(
new ACP\Editing\View\DateTime(),
new Editing\Storage\Event\StartDate()
);
case '_EventEndDate':
return new ACP\Editing\Service\Basic(
new ACP\Editing\View\DateTime(),
new Editing\Storage\Event\EndDate()
);
default:
return false;
}
}
public function conditional_format(): ?FormattableConfig {
return new FormattableConfig( new ACP\ConditionalFormat\Formatter\DateFormatter\FormatFormatter() );
}
}