1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Installer;
13
14 use Brickrouge\Element;
15
16 17 18
19 class DocumentDecorator
20 {
21 protected $component;
22
23 public function __construct($component)
24 {
25 $this->component = $component;
26 }
27
28 public function render()
29 {
30 global $core;
31
32 $component = (string) $this->component;
33
34 $document = $core->document;
35 $document->css->add(\Brickrouge\ASSETS . 'brickrouge.css', -100);
36 $document->css->add(\Icybee\ASSETS . 'admin.css', -100);
37 $document->css->add(\Icybee\ASSETS . 'admin-more.css', -100);
38 $document->css->add(ASSETS . 'page.css');
39
40 $document->js->add(\Icybee\ASSETS . 'mootools.js', -100);
41 $document->js->add(\ICanBoogie\ASSETS . 'icanboogie.js', -100);
42 $document->js->add(\Brickrouge\ASSETS . 'brickrouge.js', -100);
43 $document->js->add(ASSETS . 'page.js');
44
45 $title = t('document_title');
46
47 $hl = new Element
48 (
49 'select', array
50 (
51 Element::OPTIONS => array
52 (
53 'en' => 'English',
54 'fr' => 'Français'
55 ),
56
57 'class' => 'span2',
58 'value' => $core->language,
59 'id' => 'hl'
60 )
61 );
62
63 return <<<EOT
64 <!DOCTYPE html>
65 <html lang="{$core->language}">
66 <head>
67 <meta charset="utf-8">
68 <title>{$title}</title>
69 {$document->css}
70 </head>
71 <body id="installer">
72
73 <div id="quick">
74 <div class="pull-left">
75 <div class="btn-group">Icybee</div>
76 </div>
77 </div>
78
79 <div class="actionbar">
80 <div class="actionbar-title">
81 <h1>{$title}</h1>
82 </div>
83
84 <div class="pull-right">$hl</div>
85 </div>
86
87 <div class="container">
88 {$component}
89 </div>
90
91 {$document->js}
92 </body>
93 </html>
94 EOT;
95 }
96
97 public function __toString()
98 {
99 try
100 {
101 return (string) $this->render();
102 }
103 catch (\Exception $e)
104 {
105 return \Brickrouge\render_exception($e);
106 }
107 }
108 }