1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Contents;
13
14 class ManageBlock extends \Icybee\Modules\Nodes\ManageBlock
15 {
16 static protected function add_assets(\Brickrouge\Document $document)
17 {
18 parent::add_assets($document);
19
20 $document->css->add(DIR . 'public/admin.css');
21 $document->js->add(DIR . 'public/admin.js');
22 }
23
24 public function __construct(Module $module, array $attributes=[])
25 {
26 parent::__construct
27 (
28 $module, $attributes + [
29
30 self::T_COLUMNS_ORDER => [
31
32 'title', 'url', 'is_home_excluded', 'is_online', 'uid', 'date', 'updated_at'
33 ],
34
35 self::T_ORDER_BY => [ 'date', 'desc' ]
36 ]
37 );
38 }
39
40 41 42 43 44 45 46 47
48 protected function get_available_columns()
49 {
50 return array_merge(parent::get_available_columns(), [
51
52 'date' => 'Icybee\ManageBlock\DateColumn',
53 'is_home_excluded' => __CLASS__ . '\IsHomeExcludedColumn'
54 ]);
55 }
56 }
57
58 namespace Icybee\Modules\Contents\ManageBlock;
59
60 use Brickrouge\Element;
61
62 63 64
65 class IsHomeExcludedColumn extends \Icybee\ManageBlock\BooleanColumn
66 {
67 public function __construct(\Icybee\ManageBlock $manager, $id, array $options=[])
68 {
69 parent::__construct
70 (
71 $manager, $id, $options + [
72
73 'filters' => [
74
75 'options' => [
76
77 '=1' => "Excluded from home",
78 '=0' => "Included in home"
79 ]
80 ],
81
82 'cell_renderer' => __NAMESPACE__ . '\IsHomeExcludedCellRenderer'
83 ]
84 );
85 }
86 }
87
88 89 90
91 class IsHomeExcludedCellRenderer extends \Icybee\ManageBlock\BooleanCellRenderer
92 {
93 94 95 96 97
98 public function __invoke($record, $property)
99 {
100 return new Element('i', [
101
102 'class' => 'icon-home trigger ' . ($record->$property ? 'on' : ''),
103 'data-nid' => $record->nid,
104 'title' => "Include or exclude the record from the view 'home'"
105 ]);
106 }
107 }