Framework  3.9
auto_form_layout.inc
Go to the documentation of this file.
1 <?php
15 abstract class AutoFormLayout
16 {
17  var $form;
18 
19  var $externalErrorBox = false;
20 
21  function __construct($form)
22  {
23  $this->form = $form;
24  }
25 
26  function getGroupClass($name, $collapsible, $collapsed, $additionalClass = "")
27  {
28  $class = $this->form->getGroupCSSClass($name);
29  if ($additionalClass) $class = trim("{$additionalClass} $class");
30 
31  if ($collapsible)
32  {
33  $class = ($class) ? "{$class} collapsible" : "collapsible";
34  $class .= $collapsed ? " collapsed" : " expanded";
35  }
36 
37  if ($class)
38  {
39  $class = " class='$class'";
40  }
41 
42  return $class;
43  }
44 
45  abstract function startGroup($name, $collapsible = false, $collapsed = false);
46  abstract function endGroup();
47 
48  abstract function startField($field, $renderer, $colspan = 1, $styles = "");
49  abstract function endField($field, $renderer);
50 
51  abstract function printLabel($field, $renderer, $styles = "", $annotation = "");
52 
53  function getLabel($field, $renderer, $addSuffix = true)
54  {
55  $label = isset($renderer->label) ? $renderer->label : $this->form->prettifyFieldName($field);
56 
57  if ($renderer->parent->markRequiredFields &&
58  $renderer->parent->isRequired($field))
59  {
60  $label .= "*";
61  }
62 
63  $label .= $renderer->labelSuffix;
64 
65  if ($renderer->parent->onFormatLabel)
66  {
67  $fn = $renderer->parent->onFormatLabel;
68  $label = $fn($renderer->parent, $field, $label);
69  }
70 
71  return $label;
72  }
73 
74  function getLabelID($field)
75  {
76  return "{$this->form->id}_{$field}_label";
77  }
78 
79  abstract function startUngrouped();
80  abstract function endUngrouped();
81 
82  abstract function startButtonLine();
83  abstract function endButtonLine();
84 
85  abstract function errorBox();
86  abstract function requiredFields($text);
87 
88  static function create($type, $form)
89  {
90  switch($type)
91  {
92  case "mobile":
93  return new MobileFormLayout($form);
94 
95  case "table_header":
96  return new TableHeaderFormLayout($form);
97 
98  case "table_row":
99  return new TableRowFormLayout($form);
100 
101  case "selectable_table_header":
103 
104  case "selectable_table_row":
106 
107 
108  case "spreadsheet":
109  return new SpreadsheetFormLayout($form);
110 
111  case "simple":
112  return new SimpleFormLayout($form);
113 
114  case "table":
115 
116  default:
117  return new TableBasedFormLayout($form);
118  }
119  }
120 
121  function finalizeLayout()
122  {
123  }
124 }
125 
130 {
131  function __construct($form)
132  {
133  parent::__construct($form);
134  }
135 
136  function startGroup($name, $collapsible = false, $collapsed = false)
137  {
138  $class = $this->getGroupClass($name, $collapsible, $collapsed);
139 
140  $id = $this->form->id . "_" . codify($name) . "_group";
141 
142  echo "<fieldset id='$id'$class><legend>$name</legend>";
143 
144  $desc = $this->form->getGroupDescription($name, "start");
145  if ($desc)
146  {
147  echo "<div id='{$id}_description' class='{$this->form->groupDescriptionCSS}'>{$desc}</div>";
148  }
149  $this->groupName = $name;
150  $this->startUngrouped();
151  }
152 
153  function endGroup()
154  {
155  $this->endUngrouped();
156 
157  $name = $this->groupName;
158 
159  $desc = $this->form->getGroupDescription($name, "end");
160  if ($desc)
161  {
162  $id = $this->form->id . "_" . codify($name) . "_group";
163  echo "<div id='{$id}_description' class='{$this->form->groupDescriptionCSS}'>{$desc}</div>";
164  }
165 
166  unset($this->groupName);
167 
168  echo "</fieldset>";
169  }
170 
171  function startField($field, $renderer, $colspan = 1, $styles = "")
172  {
173  if ($renderer->colspan > 1) $styles = "text-align: left;$styles";
174 
175  echo "<tr class='{$renderer->parent->id}_{$field}_field'>\n";
176 
177  $this->printLabel($field, $renderer, $styles, ($renderer->annotateBefore && $renderer->colspan > 1) ? "<br/>".$renderer->parent->annotations[$field] : "");
178 
179  if ($renderer->colspan > 1)
180  {
181  echo "</tr>\n";
182  echo "<tr class='{$renderer->parent->id}_{$field}_field'>\n";
183  }
184  echo "<td colspan='{$renderer->colspan}'";
185  if ($renderer->parent->valueCSS) echo " class='{$renderer->parent->valueCSS}'";
186  echo ">";
187 
188  if ($renderer->parent->showAnnotations && $renderer->annotateBefore && $renderer->parent->annotations[$field] && $renderer->colspan == 1)
189  {
190  echo $renderer->parent->annotations[$field]."<br/>";
191  }
192  }
193 
194  function endField($field, $renderer)
195  {
196  if ($renderer->parent->showAnnotations && !$renderer->annotateBefore && $renderer->parent->annotations[$field])
197  {
198  if ($renderer->annotateNextLine)
199  {
200  echo "<br/>";
201  }
202  else
203  {
204  echo "&nbsp;&nbsp;";
205  }
206  echo $renderer->parent->annotations[$field];
207  }
208 
209  echo "</td>\n</tr>\n";
210  }
211 
220  function printLabel($field, $renderer, $styles = "", $annotation = "")
221  {
222  $colspan = $renderer->colspan;
223  if ($renderer->hideLabel && $colspan > 1 && !$annotation) return;
224 
225  $label = $this->getLabel($field, $renderer);
226 
227  echo "<td colspan='$colspan'";
228  if ($renderer->parent->labelCSS) echo " class='{$renderer->parent->labelCSS}'";
229  if ($styles) echo " style='$styles'";
230  echo ">";
231 
232  if (!$renderer->hideLabel) echo "<label id='".$this->getLabelID($field)."' for='$field'>$label</label> ";
233 
234  echo "$annotation</td>\n";
235  }
236 
237  function startUngrouped()
238  {
239  echo "<table";
240  if ($this->form->formCSS) echo " class='{$this->form->formCSS}'";
241  if ($this->form->style) echo " style='{$this->form->style}'";
242  echo ">\n";
243  }
244 
245  function endUngrouped()
246  {
247  echo "</table>";
248  }
249 
250  function startButtonLine()
251  {
252  echo "<tr>\n";
253  echo " <td colspan='2' class='{$this->form->buttonLineCSS}' style='text-align: {$this->form->buttonAlignment}'><br/>";
254  }
255 
256  function endButtonLine()
257  {
258  echo "</td></tr>";
259  }
260 
261  function errorBox()
262  {
263  echo "<tr>\n <td colspan='2' id='{$this->form->id}__error' class='error' style='display: ".($this->form->msg ? 'table-cell' : 'none')."'>{$this->form->msg}</td></tr>\n";
264  }
265 
266  function requiredFields($text)
267  {
268  echo "<tr>\n <td colspan='2'><span class='required_text'>{$text}</span></td></tr>\n";
269  }
270 }
271 
277 {
278  function __construct($form)
279  {
280  parent::__construct($form);
281  }
282 
283  function startGroup($name, $collapsible = false, $collapsed = false)
284  {
285  $this->startUngrouped();
286  }
287 
288  function endGroup()
289  {
290  $this->endUngrouped();
291  }
292 }
293 
298 {
299  function __construct($form)
300  {
301  parent::__construct($form);
302  }
303 
304  function startGroup($name, $collapsible = false, $collapsed = false)
305  {
306  //$this->startUngrouped();
307  }
308 
309  function endGroup()
310  {
311  //$this->endUngrouped();
312  }
313 }
319 {
320  function __construct($form)
321  {
322  parent::__construct($form);
323  }
324 
325  function startGroup($name, $collapsible = false, $collapsed = false)
326  {
327  $this->startUngrouped();
328  }
329 
330  function endGroup()
331  {
332  $this->endUngrouped();
333  }
334 
335 
336  function startField($field, $renderer, $colspan = 1, $styles = "")
337  {
338  echo "<td ";
339  if ($renderer->parent->valueCSS) echo " class='{$renderer->parent->valueCSS}'";
340  echo ">";
341 
342  if ($renderer->annotateBefore && $renderer->parent->annotations[$field] && $renderer->colspan == 1)
343  {
344  echo $renderer->parent->annotations[$field]."<br/>";
345  }
346  }
347 
348  function endField($field, $renderer)
349  {
350  echo "</td>\n";
351  }
352 
353  function requiredFields($text)
354  {
355  // empty - want displayed once at top not for every form in the spreadsheet
356  }
357 
366  function printLabel($field, $renderer, $styles = "", $annotation = "")
367  {
368  //if ($renderer->hideLabel && $renderer->colspan > 1 && !$annotation) return;
369 
370  $label = $this->getLabel($field, $renderer);
371 
372  echo "<th ";
373  if ($renderer->parent->labelCSS) echo " class='{$renderer->parent->labelCSS}'";
374  if ($styles) echo " style='$styles'";
375  echo ">";
376 
377  echo "<label id='".$this->getLabelID($field)."' for='$field'>$label</label> ";
378 
379  echo "$annotation</th>\n";
380  }
381 
382  function getLabel($field, $renderer, $addSuffix = true)
383  {
384  $obj = $renderer->parent->getData();
385  $label = isset($renderer->label) ? $renderer->label : $renderer->parent->prettifyFieldName($field);
386 
387  if ($renderer->parent->markRequiredFields &&
388  $renderer->parent->isRequired($field))
389  {
390  $label .= "*";
391  }
392 
393  $label .= $renderer->labelSuffix;
394 
395  if ($renderer->parent->onFormatLabel)
396  {
397  $fn = $renderer->parent->onFormatLabel;
398  $label = $fn($renderer->parent, $field, $label);
399  }
400 
401  return $label;
402  }
403 
404  function startUngrouped()
405  {
406  echo "<tr id='{$this->form->id}_container' class='{$this->form->containerClass}'>\n";
407  }
408 
409  function endUngrouped()
410  {
411  echo "</tr>\n";
412  }
413 
414  function startButtonLine()
415  {
416  // nothing to do
417  }
418 
419  function endButtonLine()
420  {
421  // nothing to do
422  }
423 
424  function errorBox()
425  {
426  echo "<tr>\n <td colspan='{$this->form->parent->colCount}' id='{$this->form->id}__error' class='error' style='display: ".($this->form->msg ? 'table-cell' : 'none')."'>{$this->form->msg}</td></tr>\n";
427  }
428 }
429 
430 
437 {
438  function __construct($form)
439  {
440  parent::__construct($form);
441  }
442 
443  function startUngrouped()
444  {
445  echo "<tr id='{$this->form->id}_container' class='{$this->form->containerClass}'><th style='text-align: center'>&nbsp;</th>\n";
446  }
447 
448 }
449 
450 
451 
457 {
458  var $externalErrorBox = true;
459 
460  function __construct($form)
461  {
462  parent::__construct($form);
463  }
464 
465  function startGroup($name, $collapsible = false, $collapsed = false)
466  {
467  $this->startUngrouped();
468  }
469 
470  function endGroup()
471  {
472  $this->endUngrouped();
473  }
474 
475 
476  function startField($field, $renderer, $colspan = 1, $styles = "")
477  {
478  echo "<td ";
479  if ($renderer->parent->valueCSS) echo " class='{$renderer->parent->valueCSS}'";
480  echo ">";
481 
482  if ($renderer->annotateBefore && $renderer->parent->annotations[$field] && $renderer->colspan == 1)
483  {
484  echo $renderer->parent->annotations[$field]."<br/>";
485  }
486  }
487 
488  function endField($field, $renderer)
489  {
490  echo "</td>\n";
491  }
492 
493  function requiredFields($text)
494  {
495  // empty - want displayed once at top not for every form in the spreadsheet
496  }
497 
506  function printLabel($field, $renderer, $styles = "", $annotation = "")
507  {
508  // Nothing to do
509  }
510 
511  function getLabel($field, $renderer, $addSuffix = true)
512  {
513  return "";
514  }
515 
516  function startUngrouped()
517  {
518  echo "<tr id='{$this->form->id}_container' class='{$this->form->containerClass}'>\n";
519  }
520 
521  function endUngrouped()
522  {
523  echo "</tr>\n";
524  }
525 
526  function startButtonLine()
527  {
528  // nothing to do
529  }
530 
531  function endButtonLine()
532  {
533  // nothing to do
534  }
535 
536  function errorBox()
537  {
538  echo "<tr>\n <td colspan='{$this->form->parent->colCount}' id='{$this->form->id}__error' class='error' style='display: ".($this->form->msg ? 'table-cell' : 'none')."'>{$this->form->msg}</td></tr>\n";
539  }
540 }
541 
548 {
549  function __construct($form)
550  {
551  parent::__construct($form);
552  }
553 
554  function startUngrouped()
555  {
556  $selected = $this->form->isSelected ? " checked='checked'" : "";
557 
558  echo "<tr id='{$this->form->id}_container' class='{$this->form->containerClass}'><td style='text-align: center'><input type='checkbox' class='checkbox selector'$selected id='{$this->form->id}__selected' name='#selected' value='1'/></td>\n";
559  }
560 
561 }
562 
568 {
569  function __construct($form)
570  {
571  parent::__construct($form);
572  }
573 
574  function startGroup($name, $collapsible = false, $collapsed = false)
575  {
576  $this->startUngrouped();
577  }
578 
579  function endGroup()
580  {
581  $this->endUngrouped();
582  }
583 
584  function startField($field, $renderer, $colspan = 1, $styles = "")
585  {
586  // nothing do to
587  }
588 
589  function endField($field, $renderer)
590  {
591  // nothing do to
592  }
593 
594  function requiredFields($text)
595  {
596  echo "<p><span class='required_text'>$text</span></p>";
597  }
598 
599  function printLabel($field, $renderer, $styles = "", $annotation = "")
600  {
601  // nothing to do
602  }
603 
604  function getLabel($field, $renderer, $addSuffix = true)
605  {
606  return ""; // nothing to do
607  }
608 
609  function startUngrouped()
610  {
611  echo "<table ";
612  if ($this->form->formCSS) echo " class='{$this->form->formCSS}'";
613  if ($this->form->style) echo " style='{$this->form->style}'";
614  echo ">\n";
615  }
616 
617  function endUngrouped()
618  {
619  echo "</table>";
620  }
621 
622  function startButtonLine()
623  {
624  echo "<tr>\n";
625  echo " <td colspan='{$this->form->colCount}' class='{$this->form->buttonLineCSS}' style='text-align: {$this->form->buttonAlignment}'><br/>";
626  }
627 
628  function endButtonLine()
629  {
630  echo "</td></tr>";
631  }
632 
633  function errorBox()
634  {
635  echo "<div id='{$this->form->id}__error' class='error' style='display: ".($this->form->msg ? 'table-cell' : 'none')."'>{$this->form->msg}</div>\n";
636  }
637 }
638 
643 {
644  function __construct($form)
645  {
646  parent::__construct($form);
647  }
648 
649  function startGroup($name, $collapsible = false, $collapsed = false)
650  {
651  $class = $this->getGroupClass($name, $collapsible, $collapsed);
652 
653  $id = $this->form->id . "_" . codify($name) . "_group";
654 
655  echo "<fieldset id='$id'$class><legend>$name</legend>";
656 
657  $desc = $this->form->getGroupDescription($name, "start");
658  if ($desc)
659  {
660  echo "<div id='{$id}_description' class='{$this->form->groupDescriptionCSS}'>{$desc}</div>";
661  }
662  $this->groupName = $name;
663 
664  $this->startUngrouped();
665  }
666 
667  function endGroup()
668  {
669  $this->endUngrouped();
670  $name = $this->groupName;
671 
672  $desc = $this->form->getGroupDescription($name, "end");
673  if ($desc)
674  {
675  $id = $this->form->id . "_" . codify($name) . "_group";
676  echo "<div id='{$id}_description' class='{$this->form->groupDescriptionCSS}'>{$desc}</div>";
677  }
678 
679  unset($this->groupName);
680  echo "</fieldset>";
681  }
682 
683  function startField($field, $renderer, $colspan = 1, $styles = "")
684  {
685  echo "<div class='field {$renderer->parent->id}_{$field}_field'>\n";
686 
687  $this->printLabel($field, $renderer, $styles, $this->parent->annotations[$field]);
688 
689  if (!$renderer->hideLabel) echo "<br/>\n";
690 
691  if ($renderer->parent->showAnnotations && $renderer->annotateBefore && $renderer->parent->annotations[$field])
692  {
693  echo $renderer->parent->annotations[$field]."<br/>";
694  }
695  }
696 
697  function endField($field, $renderer)
698  {
699  if ($renderer->parent->showAnnotations && !$renderer->annotateBefore && $renderer->parent->annotations[$field])
700  {
701  if ($renderer->annotateNextLine)
702  {
703  echo "<br/>";
704  }
705  else
706  {
707  echo "&nbsp;&nbsp;";
708  }
709  echo $renderer->parent->annotations[$field];
710  }
711 
712  echo "</div>\n";
713  }
714 
723  function printLabel($field, $renderer, $styles = "", $annotation = "")
724  {
725  $colspan = $renderer->colspan;
726  if ($renderer->hideLabel && !$annotation) return;
727 
728  $label = $this->getLabel($field, $renderer);
729 
730  if (!$renderer->hideLabel)
731  {
732  echo "<label id='".$this->getLabelID($field)."' for='$field'";
733  if ($renderer->parent->labelCSS) echo " class='{$renderer->parent->labelCSS}'";
734  if ($styles) echo " style='$styles'";
735 
736  echo ">$label</label> ";
737  }
738 
739  echo "$annotation\n";
740  }
741 
742  function startUngrouped()
743  {
744  echo "<div";
745  if ($this->form->formCSS) echo " class='{$this->form->formCSS}'";
746  if ($this->form->style) echo " style='{$this->form->style}'";
747  echo ">\n";
748  }
749 
750  function endUngrouped()
751  {
752  echo "</div>";
753  }
754 
755  function startButtonLine()
756  {
757  echo " <div class='{$this->form->buttonLineCSS}' style='text-align: {$this->form->buttonAlignment}'><br/>";
758  }
759 
760  function endButtonLine()
761  {
762  echo "</div><br/>";
763  }
764 
765  function errorBox()
766  {
767  echo "<div id='{$this->form->id}__error' class='error' style='display: ".($this->form->msg ? 'table-cell' : 'none')."'>{$this->form->msg}</div>\n";
768  }
769 
770  function requiredFields($text)
771  {
772  echo "<p class='required_text'>{$text}</p>\n";
773  }
774 }
775 
776 
777 
778 
783 {
784  function __construct($form)
785  {
786  parent::__construct($form);
787  }
788 
789  function startGroup($name, $collapsible = false, $collapsed = false)
790  {
791  $class = $this->getGroupClass($name, $collapsible, $collapsed);
792 
793  $id = $this->form->id . "_" . codify($name) . "_group";
794 
795  echo "<fieldset id='$id'$class><legend>$name</legend>";
796 
797  $desc = $this->form->getGroupDescription($name, "start");
798  if ($desc)
799  {
800  echo "<div id='{$id}_description' class='{$this->form->groupDescriptionCSS}'>{$desc}</div>";
801  }
802  $this->groupName = $name;
803 
804  $this->startUngrouped();
805  }
806 
807  function endGroup()
808  {
809  $this->endUngrouped();
810  $name = $this->groupName;
811 
812  $desc = $this->form->getGroupDescription($name, "end");
813  if ($desc)
814  {
815  $id = $this->form->id . "_" . codify($name) . "_group";
816  echo "<div id='{$id}_description' class='{$this->form->groupDescriptionCSS}'>{$desc}</div>";
817  }
818 
819  unset($this->groupName);
820  echo "</fieldset>";
821  }
822 
823  function startField($field, $renderer, $colspan = 1, $styles = "")
824  {
825  echo "<br/>\n";
826 
827  $this->printLabel($field, $renderer, $styles, $this->parent->annotations[$field]);
828 
829  if ($renderer->parent->showAnnotations && $renderer->annotateBefore && $renderer->parent->annotations[$field])
830  {
831  echo $renderer->parent->annotations[$field]." ";
832  }
833 
834  if ($colspan == 2) echo "<br/>\n";
835  }
836 
837  function endField($field, $renderer)
838  {
839  if ($renderer->parent->showAnnotations && !$renderer->annotateBefore && $renderer->parent->annotations[$field])
840  {
841  if ($renderer->annotateNextLine)
842  {
843  echo "<br/>";
844  }
845  else
846  {
847  echo "&nbsp;&nbsp;";
848  }
849  echo $renderer->parent->annotations[$field];
850  }
851 
852  echo "<br/>\n";
853  }
854 
863  function printLabel($field, $renderer, $styles = "", $annotation = "")
864  {
865  $colspan = $renderer->colspan;
866  if ($renderer->hideLabel && !$annotation) return;
867 
868  $label = $this->getLabel($field, $renderer);
869 
870  if (!$renderer->hideLabel)
871  {
872  echo "<label id='".$this->getLabelID($field)."' for='$field'";
873  if ($renderer->parent->labelCSS) echo " class='{$renderer->parent->labelCSS}'";
874  if ($styles) echo " style='$styles'";
875 
876  echo ">$label</label> ";
877  }
878 
879  echo "$annotation\n";
880  }
881 
882  function startUngrouped()
883  {
884  echo "<div";
885  if ($this->form->formCSS) echo " class='{$this->form->formCSS}'";
886  if ($this->form->style) echo " style='{$this->form->style}'";
887  echo ">\n";
888  }
889 
890  function endUngrouped()
891  {
892  echo "</div>";
893  }
894 
895  function startButtonLine()
896  {
897  echo "<br/>\n";
898  echo " <div class='{$this->form->buttonLineCSS}' style='text-align: {$this->form->buttonAlignment}'><br/>";
899  }
900 
901  function endButtonLine()
902  {
903  echo "</div><br/>";
904  }
905 
906  function errorBox()
907  {
908  echo "<div id='{$this->form->id}__error' class='error' style='display: ".($this->form->msg ? 'table-cell' : 'none')."'>{$this->form->msg}</div>\n";
909  }
910 
911  function requiredFields($text)
912  {
913  echo "<p class='required_text'>{$text}</p>\n";
914  }
915 }
916 
925 {
926  function __construct($form)
927  {
928  parent::__construct($form);
929  }
930 
931  function startGroup($name, $collapsible = false, $collapsed = false)
932  {
933  $class = $this->getGroupClass($name, $collapsible, $collapsed);
934 
935  $id = $this->form->id . "_" . codify($name) . "_group";
936 
937  $this->startUngrouped();
938  }
939 
940  function endGroup()
941  {
942  $this->endUngrouped();
943  }
944 
945  function startField($field, $renderer, $colspan = 1, $styles = "")
946  {
947  echo "<div class='{$renderer->cssClass}'>\n";
948  $this->printLabel($field, $renderer, $styles, "");
949  }
950 
951  function endField($field, $renderer)
952  {
953  echo "</div>\n";
954  }
955 
964  function printLabel($field, $renderer, $styles = "", $annotation = "")
965  {
966  if ($renderer->hideLabel) return;
967 
968  $label = $this->getLabel($field, $renderer);
969 
970  if (!$renderer->hideLabel) echo "<label id='".$this->getLabelID($field)."' for='$field'>$label</label> ";
971  }
972 
973  function startUngrouped()
974  {
975  // nothing to do
976  }
977 
978  function endUngrouped()
979  {
980  // nothing to do
981  }
982 
983  function startButtonLine()
984  {
985  // nothing to do
986  }
987 
988  function endButtonLine()
989  {
990  // nothing to do
991  }
992 
993  function errorBox()
994  {
995  // nothing to do
996  }
997 
998  function requiredFields($text)
999  {
1000  // nothing to do
1001  }
1002 }
1003 
1009 {
1011  var $output;
1012  var $showButtons = true;
1013 
1015  {
1016  trace("Using form template {$template}", 3);
1017  $this->template = file_get_contents($template);
1018  $this->showButtons = $showButtons;
1019  parent::__construct($form);
1020  }
1021 
1022  function startGroup($name, $collapsible = false, $collapsed = false)
1023  {
1024  // Groups are ignored when dealing with template form layouts
1025  $this->startUngrouped();
1026  }
1027 
1028  function endGroup()
1029  {
1030  $this->endUngrouped();
1031  }
1032 
1033  function startField($field, $renderer, $colspan = 1, $styles = "")
1034  {
1035  $annotations = ($renderer->parent->showAnnotations && $renderer->annotateBefore) ? $renderer->parent->annotations[$field] : "";
1036  $this->printLabel($field, $renderer, $styles, $annotations);
1037 
1038  ob_start();
1039  }
1040 
1041  function endField($field, $renderer)
1042  {
1043  $fieldContent = ob_get_contents();
1044 
1045  ob_end_clean();
1046 
1047  if ($renderer->parent->showAnnotations && !$renderer->annotateBefore && $renderer->parent->annotations[$field])
1048  {
1049  if ($renderer->annotateNextLine)
1050  {
1051  $fieldContent .= "<br/>";
1052  }
1053  else
1054  {
1055  $fieldContent .= "&nbsp;&nbsp;";
1056  }
1057 
1058  $fieldContent .= $renderer->parent->annotations[$field];
1059  }
1060 
1061  $this->template = str_replace("{".$field."}", $fieldContent, $this->template);
1062  }
1063 
1072  function printLabel($field, $renderer, $styles = "", $annotation = "")
1073  {
1074  if ($renderer->hideLabel && !$annotation) return;
1075 
1076  $label = $this->getLabel($field, $renderer);
1077 
1078  $labelHTML = "";
1079 
1080  if (!$renderer->hideLabel)
1081  {
1082  $labelHTML .= "<label id='".$this->getLabelID($field)."' for='$field'";
1083  if ($renderer->parent->labelCSS) $labelHTML .= " class='{$renderer->parent->labelCSS}'";
1084  if ($styles) $labelHTML .= " style='$styles'";
1085 
1086  $labelHTML .= ">$label</label> ";
1087  }
1088 
1089  $labelHTML .= "$annotation\n";
1090 
1091  $this->template = str_replace("{label:".$field."}", $labelHTML, $this->template);
1092  }
1093 
1094  function startUngrouped()
1095  {
1096  if (!$this->renderingForm)
1097  {
1098  $this->output .= "{FORM}";
1099  $this->renderingForm = true;
1100  }
1101  }
1102 
1103  function endUngrouped()
1104  {
1105  }
1106 
1107  function startButtonLine()
1108  {
1109  $this->output .= "<br/>\n";
1110  $this->output .= " <div class='{$this->form->buttonLineCSS}' style='text-align: {$this->form->buttonAlignment}'><br/>";
1111 
1112  ob_start();
1113 
1114  }
1115 
1116  function endButtonLine()
1117  {
1118  if ($this->showButtons)
1119  {
1120  $this->output .= ob_get_contents();
1121  }
1122  ob_end_clean();
1123 
1124  $this->output .= "</div><br/>";
1125  }
1126 
1127  function errorBox()
1128  {
1129  $this->output .= "<div id='{$this->form->id}__error' class='error' style='display: ".($this->form->msg ? 'table-cell' : 'none')."'>{$this->form->msg}</div>\n";
1130  }
1131 
1132  function requiredFields($text)
1133  {
1134  $this->output .= "<p class='required_text'>{$text}</p>\n";
1135  }
1136 
1137  function finalizeLayout()
1138  {
1139  // Clear any unmapped fields
1140  foreach($this->form->data->getFields() as $field => $type)
1141  {
1142  $this->template = str_replace(array("{{$field}}", "{label:{$field}}"), array("", ""), $this->template);
1143  }
1144 
1145  $this->output = str_replace("{FORM}", $this->template, $this->output);
1146  echo $this->output;
1147  }
1148 }
1149 
AutoFormLayout provides the abstract base class for form layout engine classes.
startGroup($name, $collapsible=false, $collapsed=false)
startField($field, $renderer, $colspan=1, $styles="")
printLabel($field, $renderer, $styles="", $annotation="")
getLabel($field, $renderer, $addSuffix=true)
getGroupClass($name, $collapsible, $collapsed, $additionalClass="")
$externalErrorBox
Flag indicating whether the error box should be rendered inside the form grouping.
requiredFields($text)
static create($type, $form)
endField($field, $renderer)
Layout for list filtering using filter_form.inc.
endField($field, $renderer)
startField($field, $renderer, $colspan=1, $styles="")
startGroup($name, $collapsible=false, $collapsed=false)
printLabel($field, $renderer, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
MobileFormLayout provides a linear form layout suitable for mobile devices.
endField($field, $renderer)
startField($field, $renderer, $colspan=1, $styles="")
startGroup($name, $collapsible=false, $collapsed=false)
printLabel($field, $renderer, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
Mobile version of UngroupedFormLayout.
startGroup($name, $collapsible=false, $collapsed=false)
Overrides the default table-row form layout to provide a selection checkbox for SpreadsheetForms with...
Overrides the default table-row form layout to provide a selection checkbox for SpreadsheetForms with...
SimpleFormLayout provides a form with minimal HTML, and does not employ table-based layout.
startGroup($name, $collapsible=false, $collapsed=false)
printLabel($field, $renderer, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
startField($field, $renderer, $colspan=1, $styles="")
endField($field, $renderer)
Used for the overall layout handling of SpreadsheetAutoForm instance.
startGroup($name, $collapsible=false, $collapsed=false)
getLabel($field, $renderer, $addSuffix=true)
printLabel($field, $renderer, $styles="", $annotation="")
startField($field, $renderer, $colspan=1, $styles="")
endField($field, $renderer)
Lays out the AutoForm using table-based layout.
printLabel($field, $renderer, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
endField($field, $renderer)
startField($field, $renderer, $colspan=1, $styles="")
startGroup($name, $collapsible=false, $collapsed=false)
Used for the header row in SpreadSheetAutoForm.
getLabel($field, $renderer, $addSuffix=true)
startField($field, $renderer, $colspan=1, $styles="")
endField($field, $renderer)
printLabel($field, $renderer, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
startGroup($name, $collapsible=false, $collapsed=false)
Used for each subordinate form row in SpreadSheetAutoForm.
endField($field, $renderer)
startField($field, $renderer, $colspan=1, $styles="")
getLabel($field, $renderer, $addSuffix=true)
printLabel($field, $renderer, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
startGroup($name, $collapsible=false, $collapsed=false)
TemplateFormLayout provides support for custom form layouts.
startField($field, $renderer, $colspan=1, $styles="")
endField($field, $renderer)
startGroup($name, $collapsible=false, $collapsed=false)
__construct($form, $template, $showButtons=true)
printLabel($field, $renderer, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
Used when you want layout to provide field ordering but don't want groups or borders around the group...
startGroup($name, $collapsible=false, $collapsed=false)
codify($name)
Takes a text string and converts it into a code-compliant format, suitable for use as a variable name...
Definition: functions.inc:1399
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010