1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Editor;
13
14 use ICanBoogie\I18n;
15
16 17 18
19 class TabbableNewPaneOperation extends \ICanBoogie\Operation
20 {
21 22 23 24 25
26 protected function validate(\ICanBoogie\Errors $errors)
27 {
28 if (!$this->request['control_name'])
29 {
30 $errors['control_name'] = I18n\t('The %identifier is required.', array('identifier' => 'control_name'));
31 }
32
33 return true;
34 }
35
36 37 38 39 40 41 42 43 44 45
46 protected function process()
47 {
48 global $core;
49
50 $request = $this->request;
51 $properties = array
52 (
53 'name' => $request['control_name'] . '[' . uniqid() . ']',
54 'title' => 'New tab',
55 'editor_id' => 'rte',
56 'serialized_content' => null
57 );
58
59 $tab = TabbableEditorElement::create_tab($properties);
60 $pane = TabbableEditorElement::create_pane($properties);
61
62 $tab->add_class('active');
63 $pane->add_class('active');
64
65 $tab = (string) $tab;
66 $pane = (string) $pane;
67
68 $this->response['tab'] = $tab;
69 $this->response['assets'] = $core->document->assets;
70
71 return $pane;
72 }
73 }