CMS  Version 3.9
panel_view.inc
Go to the documentation of this file.
1 <?php
8 interface PanelControl
9 {
10  function writeScript();
11  function drawControl();
12 }
13 
14 
15 class PanelButton implements PanelControl
16 {
17  var $icon;
18  var $text;
19  var $tooltip;
20  var $action;
21 
23  {
24  $this->icon = $icon;
25  $this->text = $text;
26  $this->tooltip = $tooltip;
27  $this->action = $action;
28  }
29 
30  function writeScript()
31  {
32  }
33 
34  function drawControl()
35  {
36 ?>
37  <img src="<?echo $this->icon?>" alt="<?echo $this->text?>" title="<?echo $this->tooltip?>" style="border: none; display:inline-block;vertical-align: middle" onclick="<?echo $this->action?>; return false"/>
38 <?
39  }
40 }
41 
42 
43 class PanelSeparator implements PanelControl
44 {
45  var $width;
46 
48  {
49  $this->width = $width;
50  }
51 
52  function writeScript()
53  {
54  }
55 
56  function drawControl()
57  {
58  echo "<div style='display: inline-block;width: {$this->width}px'>&nbsp;</div>";
59  }
60 }
61 
63 {
64  var $controls;
65 
66  function PanelToolbar()
67  {
68  $this->controls = array();
69  }
70 
71  function button($icon, $text, $tooltip, $action)
72  {
73  $this->controls[] = new PanelButton($icon, $text, $tooltip, $action);
74  return $this;
75  }
76 
77  function separator($width = 8)
78  {
79  $this->controls[] = new PanelSeparator($width);
80  return $this;
81  }
82 
83  function control($control)
84  {
85  $this->controls[] = $control;
86  return $this;
87  }
88 
89  function writeScript()
90  {
91  foreach($this->controls as $control)
92  {
93  $control->writeScript();
94  }
95  }
96 
97  function drawToolbar()
98  {
99 ?>
100 <div class="panel_toolbar">
101 <?
102  foreach($this->controls as $control)
103  {
104  $control->drawControl();
105  }
106 ?>
107 </div>
108 <?
109  }
110 }
111 
113 {
114  var $id;
115  var $title;
116 
117  var $content;
118  var $dialogs;
119  var $menu;
120  var $script;
121  var $buttons;
124 
125  function PanelView($id, $title)
126  {
127  $this->id = $id;
128  $this->title = $title;
129 
130  $this->buttons = array();
131  $this->controls = array();
132  }
133 
134  function button($icon, $text, $tooltip, $action)
135  {
136  $this->buttons[] = new PanelButton($icon, $text, $tooltip, $action);
137  return $this;
138  }
139 
140  function control($control)
141  {
142  $this->controls[] = $control;
143  return $this;
144  }
145 
146  function toolbar($toolbar)
147  {
148  $this->toolbars[] = $toolbar;
149  return $this;
150  }
151 
152  function writeScript()
153  {
154  if ($this->menu)
155  {
156  $this->script .= $this->menu->writeScript();
157  }
158 
159  $this->script .= <<<ENDSCRIPT
160 <script type="text/javascript">
161 var {$this->id}_body = document.id('{$this->id}_body');
162 if ({$this->id}_body.panel)
163 {
164  var panel = {$this->id}_body.panel;
165 
166  panel.body = {$this->id}_body;
167  panel.header = document.id('{$this->id}_header');
168 }
169 </script>
170 ENDSCRIPT;
171 
172  if (count($this->controls) > 0)
173  {
174  foreach($this->controls as $control)
175  {
176  $this->script .= $control->writeScript();
177  }
178  }
179 
180  if (count($this->toolbars) > 0)
181  {
182  foreach($this->toolbars as $toolbar)
183  {
184  $this->script .= $toolbar->writeScript();
185  }
186  }
187 
188  if (is_object($this->title)) $script .= $this->title->writeScript();
189 
190  return $this->script;
191  }
192 
193  function commandMenu()
194  {
195  $this->menu = new ContextMenu($this->id . "_menu", "#{$this->id}_menu_button");
196  $this->menu->trigger = "click";
197 
198  return $this->menu;
199  }
200 
201  function drawView()
202  {
203  if ($this->menu) $this->dialogs .= $this->menu->writeMenu();
204 
205  $title = is_object($this->title) ? $this->title->getText() : $title;
206  ob_start();
207 ?>
208  <?echo $this->writeScript()?>
209  <?echo $this->dialogs?>
210 
211  <span class="tearoff_title" style="display:none"><?echo $title?></span>
212  <div id="<?echo $this->id?>_header" class="panel_header">
213 <?
214  if ($this->menu)
215  {
216 ?>
217  <img id="<?echo $this->id?>_menu_button" src="/fakoli/images/data_view_menu.png" alt="Panel Menu" style="border: none; display:inline-block;vertical-align: middle"/>
218 <?
219  }
220 
221  if (is_object($this->title))
222  {
223  $this->title->drawControl();
224  }
225  else
226  {
227  echo $this->title;
228  }
229 
230  if (count($this->buttons) > 0)
231  {
232 ?>
233  <div id="<?echo $this->id?>_buttons" class="panel_buttons">
234 <?
235  foreach($this->buttons as $button)
236  {
237  $button->drawControl();
238  }
239 ?>
240  </div>
241 <?
242  }
243 
244  if (count($this->controls) > 0)
245  {
246  foreach($this->controls as $control)
247  {
248  $control->drawControl();
249  }
250  }
251 
252 ?>
253  <div style="height: 0; clear: both"></div>
254 <?
255  if (count($this->toolbars) > 0)
256  {
257  foreach($this->toolbars as $toolbar)
258  {
259  $toolbar->drawToolbar();
260  }
261  }
262 ?>
263  </div>
264  <div id="<?echo $this->id?>_body" class="panel_body">
265  <?echo $this->content?>
266  </div>
267 <?
268  $out = ob_get_contents();
269  ob_end_clean();
270  return $out;
271  }
272 }
273 
274 ?>
$out
Definition: page.inc:66
$helpTree style
Definition: tree.inc:46
$helpTree width
Definition: tree.inc:45
$form action
Definition: edit.inc:67
$icon
Definition: upload.inc:92
$bookmark title
PanelButton($icon, $text, $tooltip, $action)
Definition: panel_view.inc:22
PanelSeparator($width)
Definition: panel_view.inc:47
button($icon, $text, $tooltip, $action)
Definition: panel_view.inc:71
separator($width=8)
Definition: panel_view.inc:77
control($control)
Definition: panel_view.inc:83
control($control)
Definition: panel_view.inc:140
button($icon, $text, $tooltip, $action)
Definition: panel_view.inc:134
PanelView($id, $title)
Definition: panel_view.inc:125
toolbar($toolbar)
Definition: panel_view.inc:146
$width
Definition: cover.inc:37
$action
Definition: run.php:41
$button
Definition: show.inc:6