1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Editor;
13
14 15 16
17 class TabbableEditor implements Editor
18 {
19 20 21 22 23
24 public function serialize($content)
25 {
26 global $core;
27
28 $panes = array();
29
30 if ($content && is_array($content))
31 {
32 foreach ($content as $properties)
33 {
34 $editor_id = $properties['editor_id'];
35
36 $panes[] = array
37 (
38 'title' => $properties['title'],
39 'editor_id' => $editor_id,
40 'serialized_content' => $core->editors[$editor_id]->serialize($properties['content'])
41 );
42 }
43 }
44
45 return json_encode($panes);
46 }
47
48 49 50 51 52 53 54
55 public function unserialize($serialized_content)
56 {
57 if (is_array($serialized_content))
58 {
59 return $serialized_content;
60 }
61
62 return json_decode($serialized_content, true);
63 }
64
65 66 67 68 69
70 public function from(array $attributes)
71 {
72 return new TabbableEditorElement($attributes);
73 }
74
75 protected $renderer;
76
77 78 79 80 81
82 public function render($content)
83 {
84 $renderer = $this->renderer;
85
86 if (!$renderer)
87 {
88 $this->renderer = $renderer = new TabbableEditorRenderer($this);
89 }
90
91 return $renderer($content);
92 }
93 }