1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Editor;
13
14 use Brickrouge\Element;
15
16 17 18
19 class NodeEditorElement extends Element implements EditorElement
20 {
21 public function __construct(array $attributes=array())
22 {
23 parent::__construct('div', $attributes);
24 }
25
26 protected function render_inner_html()
27 {
28 $rc = parent::render_inner_html();
29
30 $value = $this['value'];
31 $name = $this['name'];
32
33 if ($value && !is_numeric($value))
34 {
35 $value = json_decode($value);
36 }
37
38 $class = 'Icybee\Modules\Nodes\PopNode';
39 $constructor = $this['data-constructor'] ?: 'nodes';
40
41 if ($constructor == 'images')
42 {
43 $class = 'Icybee\Modules\Images\PopImage';
44 }
45
46 $rc .= (string) new $class
47 (
48 array
49 (
50 \Icybee\Modules\Nodes\PopNode::T_CONSTRUCTOR => $constructor,
51
52 'name' => $name,
53 'value' => $value
54 )
55 );
56
57 return $rc;
58 }
59 }