1 <?php
2
3 /*
4 * This file is part of the Icybee package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Icybee\Modules\Pages;
13
14 use ICanBoogie\Operation;
15
16 class TemplateEditorsOperation extends Operation
17 {
18 protected function get_controls()
19 {
20 return array
21 (
22 self::CONTROL_PERMISSION => Module::PERMISSION_CREATE
23 )
24
25 + parent::get_controls();
26 }
27
28 protected function validate(\ICanboogie\Errors $errors)
29 {
30 return true;
31 }
32
33 /**
34 * Returns a sectionned form with the editors to use to edit the contents of a template.
35 *
36 * The function alters the operation object by adding the `template` property, which holds an
37 * array with the following keys:
38 *
39 * - `name`: The name of the template.
40 * - `description`: The description for the template.
41 * - `inherited`: Whether or not the template is inherited.
42 *
43 * The function also alters the operation object by adding the `assets` property, which holds
44 * an array with the following keys:
45 *
46 * - `css`: An array of CSS files URL.
47 * - `js`: An array of Javascript files URL.
48 *
49 * @return string The HTML code for the form.
50 */
51 protected function process()
52 {
53 global $core;
54
55 $request = $this->request;
56 $template = $request['template'];
57 $pageid = $request['pageid'];
58
59 list($contents_tags, $template_info) = $this->module->get_contents_section($pageid, $template);
60
61 $this->response['template'] = $template_info;
62
63 $form = (string) new \Brickrouge\Form(array(\Brickrouge\Form::RENDERER => 'Simple') + $contents_tags);
64
65 $this->response['assets'] = $core->document->assets;
66
67 return $form;
68 }
69 }