Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
limbo_outputter.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/backend_outputter.inc';
18 
30 {
31 
32 
38  function Limbo_Outputter()
39  {
40  $this->Backend_Outputter();
41 
42  }//end constructor
43 
44 
57  function addFormActionGetVar($name, $value, $persistant=FALSE)
58  {
59  if ($persistant) {
60  return parent::addFormActionGetVar($name, $value, TRUE);
61  }
62  return $this->addHiddenField($name, $value);
63 
64  }//end addFormActionGetVar()
65 
66 
73  function paint()
74  {
75  if ($this->_raw_opened) $this->closeRaw();
76  // close all sections
77  while (!empty($this->_section_stack)) {
78  $this->closeSection();
79  }
80  $this->_paintBodyHeader();
81  ?><div id="sq_backend_sections"><?php
82  if (!$this->_redirect) $this->paintSections();
83  ?></div><?php
84 
85  $this->_paintBodyFooter();
86 
87  }//end paint()
88 
89 
97  function openRaw()
98  {
99  if ((!$this->_buffering) && SQ_IN_LIMBO) {
100  parent::openSection('&nbsp;');
101  } else {
102  parent::openRaw();
103  }
104 
105  }//end openRaw()
106 
107 
115  function closeRaw()
116  {
117  if ((!$this->_buffering) && SQ_IN_LIMBO) {
118  parent::closeSection();
119  } else {
120  parent::closeRaw();
121  }
122 
123  }//end closeRaw()
124 
125 
132  function paintSections()
133  {
134  for ($i = 0; $i < count($this->_contents); $i++) {
135  $this->_paintSection($this->_contents[$i]);
136  }
137 
138  }//end paintSections()
139 
140 
147  function _paintHeader()
148  {
149  // Charset header
150  if (!headers_sent()) {
151  if ($this->_charset) {
152  header("Content-type: text/html; charset=$this->_charset");
153  } else {
154  $default_charset = SQ_CONF_DEFAULT_CHARACTER_SET;
155  header("Content-type: text/html; charset=$default_charset");
156  }
157  }
158 
159  // CSS includes
160  // Let's get Layout Manager to see if we should output the edit.css file
161  $lm = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('layout_manager');
162  if ($lm->attr('edit_css')) {
163  $this->addCssInclude($this->filesPath('css/limbo.css'));
164  }
165 
166  foreach ($this->_css_includes as $file) {
167  $this->_paintCssInclude($file);
168  }
169 
170  // first add the js translation files
171  foreach ($GLOBALS['SQ_SYSTEM']->lm->getJavascriptIncludes() as $js_include) {
172  $this->addJsInclude($js_include);
173  }
174 
175  // JS includes, including some defaults
176  $this->addJsInclude(sq_web_path('lib').'/html_form/html_form.js');
177  $this->addJsInclude(sq_web_path('lib').'/js/general.js');
178  $this->addJsInclude(sq_web_path('lib').'/js/debug.js');
179  $this->addJsInclude(sq_web_path('lib').'/js/edit.js');
180  $this->addJsInclude(sq_web_path('lib').'/js/translation.js');
181  $this->addJsInclude(sq_web_path('lib').'/js/tooltip.js');
182 
183  list($lang, $country, $variant) = $GLOBALS['SQ_SYSTEM']->lm->getLocaleParts($GLOBALS['SQ_SYSTEM']->lm->getCurrentLocale());
184 
185  if (file_exists(SQ_DATA_PATH.'/public/system/core/js_strings.'.$lang.'.js')) {
186  $this->addJsInclude(sq_web_path('data').'/system/core/js_strings.'.$lang.'.js');
187  }
188 
189  if (!empty($country)) {
190  if (file_exists(SQ_DATA_PATH.'/public/system/core/js_strings.'.$lang.'_'.$country.'.js')) {
191  $this->addJsInclude(sq_web_path('data').'/system/core/js_strings.'.$lang.'_'.$country.'.js');
192  }
193 
194  if (!empty($variant)) {
195  if (file_exists(SQ_DATA_PATH.'/public/system/core/js_strings.'.$lang.'_'.$country.'@'.$variant.'.js')) {
196  $this->addJsInclude(sq_web_path('data').'/system/core/js_strings.'.$lang.'_'.$country.'@'.$variant.'.js');
197  }
198  }
199  }
200 
201  foreach ($this->_js_includes as $file) {
202  $this->_paintJsInclude($file);
203  }
204 
205  // Event handlers
206  $this->_paintEventHandlers();
207 
208  // Preloaded images
209  foreach ($this->_preload_imgs as $file) {
210  echo "\t\tpreload_image('".$file."');\n";
211  }
212 
213  }//end _paintHeader()
214 
215 
223  {
224  // CSS includes (if not empty), inline style
225  if (!empty($this->_css_includes)) {
226  ?>
227  <style type="text/css">
228  <?php
229  foreach ($this->_css_includes as $file) {
230  echo "\t\t@import url($file)\n";
231  }
232  ?>
233  </style>
234  <?php
235  } // End if
236 
237  // JS includes, including some defaults
238  $this->addJsInclude(sq_web_path('lib').'/html_form/html_form.js');
239  $this->addJsInclude(sq_web_path('lib').'/js/general.js');
240  $this->addJsInclude(sq_web_path('lib').'/js/debug.js');
241  $this->addJsInclude(sq_web_path('lib').'/js/edit.js');
242  $this->addJsInclude(sq_web_path('lib').'/js/translation.js');
243 
244  list($lang, $country, $variant) = $GLOBALS['SQ_SYSTEM']->lm->getLocaleParts($GLOBALS['SQ_SYSTEM']->lm->getCurrentLocale());
245 
246  if (file_exists(SQ_DATA_PATH.'/public/system/core/js_strings.'.$lang.'.js')) {
247  $this->addJsInclude(sq_web_path('data').'/system/core/js_strings.'.$lang.'.js');
248  }
249 
250  if (!empty($country)) {
251  if (file_exists(SQ_DATA_PATH.'/public/system/core/js_strings.'.$lang.'_'.$country.'.js')) {
252  $this->addJsInclude(sq_web_path('data').'/system/core/js_strings.'.$lang.'_'.$country.'.js');
253  }
254 
255  if (!empty($variant)) {
256  if (file_exists(SQ_DATA_PATH.'/public/system/core/js_strings.'.$lang.'_'.$country.'@'.$variant.'.js')) {
257  $this->addJsInclude(sq_web_path('data').'/system/core/js_strings.'.$lang.'_'.$country.'@'.$variant.'.js');
258  }
259  }
260  }
261 
262  foreach ($this->_js_includes as $file) {
263  $this->_paintJsInclude($file);
264  }
265 
266  // Event handlers
267  $this->_paintEventHandlers();
268 
269  // Hidden Fields
270  $this->_paintHiddenFields();
271 
272  // Preload images
273  foreach ($this->_preload_imgs as $file) {
274  echo "\t\tpreload_image('".$file."');\n";
275  }
276 
277  }//end _paintInlineHeader()
278 
279 
287  {
288  ?>
289  <script type="text/javascript"><!--
290  //<![CDATA[
291 
292  // slip our own onLoad function into the onLoad event of the window
293  var SQ_DOCUMENT_LOADED = false;
294 
295  function page_on_load()
296  {
297  <?php
298  foreach ($this->_on_load_calls as $call) {
299  echo "\t\t$call;\n";
300  }//end foreach
301  ?>
302 
303  // let everyone know the document is loaded
304  SQ_DOCUMENT_LOADED = true;
305 
306  }// end page_on_load()
307 
308  function print_tooltip()
309  {
310  if (window.self.name == 'sq_main') {
311  tooltip.print();
312  }
313  }
314 
315  var SQ_FORM_SUBMITTED = false;
316 
317  function form_on_submit()
318  {
319  if (SQ_FORM_SUBMITTED) {
320  alert(js_translate('form_already_submitted'));
321  return;
322  }
323 
324  <?php
325  foreach ($this->_on_submit_calls as $call) {
326  echo "\t\t$call;\n";
327  }
328  ?>
329 
330  // basically if they get this far then we can submit
331  SQ_FORM_SUBMITTED = true;
332  return true;
333 
334  }//end form_on_submit()
335 
336  //]]> -->
337  </script>
338  <?php
339 
340  }//end _paintEventHandlers()
341 
342 
354  function _nbOpenField($name, $format='', $note='', $hidden=FALSE)
355  {
356  if ($this->_is_open_field) $this->closeField();
357  $this->_is_open_field = TRUE;
358 
359  // store the format and note of the current field for future reference
360  $this->_current_field_type = $format;
361  $this->_current_field_note = $note;
362 
363  switch ($format) {
364  case 'new_line' :
365  ?>
366  <tr <?php if ($hidden) echo 'style="display: none"'; ?>>
367  <td class="sq-limbo-field" colspan="2">
368  <a name="field_<?php echo $this->_field_count; ?>"></a>
369  <?php echo $name;?>
370  </td>
371  </tr>
372  <tr <?php if ($hidden) echo 'style="display: none"'; ?>>
373  <td class="sq-backend-data sq-backend-data-newline" colspan="2">
374 
375  <?php
376  break;
377 
378  case 'commit' :
379  ?>
380  <tr>
381  <td class="sq-backend-data sq-backend-commit" colspan="2">
382  <?php
383  break;
384 
385  case 'blank' :
386  // a blank field to be used just for formatting
387  break;
388 
389  default :
390  ?>
391  <tr <?php if ($hidden) echo 'style="display: none"'; ?>>
392  <td class="sq-limbo-field">
393  <a name="field_<?php echo $this->_field_count; ?>"></a>
394  <?php echo $name;?>
395  </td>
396  <td class="sq-backend-data">
397  <?php
398  }//end switch
399 
400  }//end _nbOpenField()
401 
402 
411  function _nbOpenSection($section)
412  {
413  if ($this->_nb_section_count > 0) echo '<tr><td>';
414  $this->_nb_section_count++;
415 
416  ?>
417  <a name="section_<?php echo $this->_nb_section_count; ?>"></a>
418  <table class="sq-backend-section-table">
419  <?php
420  if ($section['heading']) {
421  if ($this->_is_open_section) {
422  // printing a nested section - needs to look a little different
423  ?>
424  <tr>
425  <td class="sq-limbo-section-subheading" colspan="2"><?php echo $section['heading'];?></td>
426  </tr>
427  <?php
428  } else {
429  $this->_is_open_section = TRUE;
430  // printing a top level section
431  ?>
432  <tr>
433  <td class="sq-limbo-section-heading" colspan="2"><?php echo $section['heading'];?></td>
434  </tr>
435  <?php
436  }
437  }//end if
438 
439  // print the section seperator
440  ?>
441  <tr>
442  <td>
443  <table class="sq-backend-section-table-inner">
444 
445  <?php
446 
447  }//end _nbOpenSection()
448 
449 
459  function _paintSection($section, $depth=0)
460  {
461  if ($section['type'] == 'raw') {
462  echo $section['contents'];
463  } else {
464  ?>
465  <a name="section_<?php echo $section['section_count']; ?>"></a>
466  <table class="sq-backend-section-table">
467  <?php
468  if ($section['heading']) {
469  if ($depth > 0) {
470  // printing a nested section - needs to look a little different
471  ?>
472  <tr>
473  <td class="sq-limbo-section-subheading"><?php echo $section['heading'];?></td>
474  </tr>
475  <?php
476  } else {
477  // printing a top level section
478  ?>
479  <tr>
480  <td class="sq-limbo-section-heading" style="border-bottom: 1px solid #000000"><?php echo $section['heading'];?></td>
481  </tr>
482  <?php
483  }
484  }//end if
485 
486  // print the section seperator
487  ?>
488  <tr>
489  <td>
490  <table class="sq-backend-section-table-inner">
491  <?php
492 
493  for ($j = 0; $j < count($section['areas']); $j++) {
494  switch ($section['areas'][$j]['area_type']) {
495  case 'section' :
496  ?>
497  <tr>
498  <td colspan="2">
499  <?php
500  $this->_paintSection($section['areas'][$j], $depth + 1);
501  ?>
502  </td>
503  </tr>
504  <?php
505 
506  break;
507 
508  case 'field' :
509  $field =& $section['areas'][$j];
510  switch ($field['format']) {
511  case 'new_line' :
512  ?>
513  <tr <?php if ($field['hidden']) echo 'style="display: none"'; ?>>
514  <td class="sq-limbo-field" colspan="2">
515  <a name="field_<?php echo $field['field_count']; ?>"></a>
516  <?php echo $field['name'];?>
517  </td>
518  </tr>
519  <tr <?php if ($field['hidden']) echo 'style="display: none"'; ?>>
520  <td class="sq-backend-data sq-backend-data-newline" colspan="2">
521  <?php
522  echo $field['contents'];
523  if ($field['note']) $this->note($field['note']);
524  ?>
525  </td>
526  </tr>
527  <?php
528  break;
529 
530  case 'commit' :
531  ?>
532  <tr <?php if ($field['hidden']) echo 'style="display: none"'; ?>>
533  <td class="sq-backend-data sq-limbo-data sq-backend-commit" colspan="2">
534  <?php
535  echo $field['contents'];
536  if ($field['note']) $this->note($field['note']);
537  ?>
538  </td>
539  </tr>
540  <?php
541  break;
542 
543  case 'blank' :
544  // a blank field to be used just for formatting
545  break;
546 
547  default :
548  ?>
549  <tr <?php if ($field['hidden']) echo 'style="display: none"'; ?>>
550  <td class="sq-limbo-field">
551  <a name="field_<?php echo $field['field_count']; ?>"></a>
552  <?php echo $field['name'];?>
553  </td>
554  <td class="sq-backend-data">
555  <?php
556  echo $field['contents'];
557  if ($field['note']) $this->note($field['note']);
558  ?>
559  </td>
560  </tr>
561  <?php
562  }//end switch
563 
564  break;
565 
566  default :
567  trigger_localised_error('SYS0257', E_USER_ERROR, $section['areas'][$j]['area_type']);
568 
569  }//end switch area type
570 
571  }//end for
572 
573  ?>
574  </table>
575  </td>
576  </tr>
577  </table>
578  <?php
579 
580  }//end else if section type == raw
581 
582  }//end _paintSection()
583 
584 
591  function _paintBodyHeader()
592  {
593  // if a redirect has been set - add an onLoad call so we redirect as normal
594  ?>
595  <script type="text/javascript"><!--
596  //<![CDATA[
597  <?php
598  if ($this->_redirect) {
599  echo $this->_redirect_target.'.location = "'.addslashes($this->_redirect).'";';
600  } else {
601  echo '
602  current_onload = (window.onload) ? window.onload : new Function;
603  window.onload = new Function ("page_on_load(); current_onload(); print_tooltip();")';
604  }
605  ?>
606 
607  //]]> -->
608  </script>
609 
610 
611  <form action="<?php echo $this->_action.$this->_anchor;?>" id="main_form" name="main_form" method="post" enctype="multipart/form-data" onsubmit="return form_on_submit();">
612 
613  <?php
614  hidden_field('process_form', '1');
615  // insert nonce token
616  hidden_field('token', get_unique_token());
617  $this->_paintHiddenFields();
618 
619  }//end _paintBodyHeader()
620 
621 
629  {
630  foreach ($this->_hidden_fields as $name => $value) {
631  hidden_field($name, $value);
632  }
633 
634  }//end _paintHiddenFields()
635 
636 
643  function _paintBodyFooter()
644  {
645  ?>
646  </form>
647  <?php
648 
649  }//end _paintBodyFooter()
650 
651 
652 }//end class
653 
654 ?>