1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Forms;
13
14 class ManageBlock extends \Icybee\Modules\Nodes\ManageBlock
15 {
16 public function __construct(Module $module, array $attributes=array())
17 {
18 parent::__construct
19 (
20 $module, $attributes + array
21 (
22 self::T_COLUMNS_ORDER => array('title', 'is_online', 'modelid', 'uid', 'updated_at')
23 )
24 );
25 }
26
27 28 29 30 31
32 protected function get_available_columns()
33 {
34 return array_merge(parent::get_available_columns(), array
35 (
36 'modelid' => __CLASS__ . '\ModelIdColumn'
37 ));
38 }
39 }
40
41 42 43
44
45 namespace Icybee\Modules\Forms\ManageBlock;
46
47 use Icybee\ManageBlock\Column;
48 use Icybee\ManageBlock\FilterDecorator;
49 use Brickrouge\Alert;
50
51 52 53
54 class ModelIdColumn extends Column
55 {
56 static protected $modelid_models;
57
58 public function render_cell($record)
59 {
60 global $core;
61
62 if (empty(self::$modelid_models))
63 {
64 self::$modelid_models = $core->configs->synthesize('formmodels', 'merge');
65 }
66
67 $property = $this->id;
68 $modelid = $record->$property;
69 $label = $modelid;
70
71 if (isset(self::$modelid_models[$modelid]))
72 {
73 $label = $this->t(self::$modelid_models[$modelid]['title']);
74 }
75 else
76 {
77 return new Alert("Undefined model: $modelid", array(Alert::CONTEXT => Alert::CONTEXT_ERROR, Alert::UNDISSMISABLE => true));
78 }
79
80 return new FilterDecorator($record, $property, $this->is_filtering, $label);
81 }
82 }