1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: 17: 18: 19:
20: class PifaFieldCollection extends ItemCollection {
21:
22: 23: 24: 25:
26: public function __construct($where = false) {
27: parent::__construct(cRegistry::getDbTableName('pifa_field'), 'idfield');
28: $this->_setItemClass('PifaField');
29: if (false !== $where) {
30: $this->select($where);
31: }
32: }
33:
34: 35: 36: 37: 38: 39:
40: public static function reorder($idform, $idfields) {
41: $sql = "-- PifaFieldCollection::reorder()
42: UPDATE
43: " . cRegistry::getDbTableName('pifa_field') . "
44: SET
45: field_rank = FIND_IN_SET(idfield, '$idfields')
46: WHERE
47: idform = $idform
48: ;";
49:
50: cRegistry::getDb()->query($sql);
51: }
52: }
53:
54: 55: 56: 57: 58:
59: class PifaField extends Item {
60:
61: 62: 63: 64: 65: 66: 67: 68: 69:
70: const VARCHAR_SIZE = 255;
71:
72: 73: 74: 75:
76: const INPUTTEXT = 1;
77:
78: 79: 80: 81:
82: const TEXTAREA = 2;
83:
84: 85: 86: 87:
88: const INPUTPASSWORD = 3;
89:
90: 91: 92: 93:
94: const INPUTRADIO = 4;
95:
96: 97: 98: 99:
100: const INPUTCHECKBOX = 5;
101:
102: 103: 104: 105:
106: const SELECT = 6;
107:
108: 109: 110: 111:
112: const SELECTMULTI = 7;
113:
114: 115: 116: 117:
118: const DATEPICKER = 8;
119:
120: 121: 122: 123:
124: const INPUTFILE = 9;
125:
126: 127: 128: 129:
130: const PROCESSBAR = 10;
131:
132: 133: 134: 135:
136: const SLIDER = 11;
137:
138:
139:
140:
141:
142:
143:
144: 145: 146: 147:
148: const BUTTONSUBMIT = 13;
149:
150: 151: 152: 153:
154: const BUTTONRESET = 14;
155:
156: 157: 158: 159:
160: const BUTTONBACK = 15;
161:
162: 163: 164: 165:
166: const MATRIX = 16;
167:
168: 169: 170: 171: 172: 173:
174: const PARA = 17;
175:
176: 177: 178: 179:
180: const INPUTHIDDEN = 18;
181:
182: 183: 184: 185:
186: const FIELDSET_BEGIN = 19;
187:
188: 189: 190: 191:
192: const FIELDSET_END = 20;
193:
194: 195: 196: 197:
198: private $_value = NULL;
199:
200: 201: 202: 203:
204: private $_file = NULL;
205:
206: 207: 208: 209:
210: public function __construct($id = false) {
211: parent::__construct(cRegistry::getDbTableName('pifa_field'), 'idfield');
212: $this->setFilters(array(), array());
213: if (false !== $id) {
214: $this->loadByPrimaryKey($id);
215: }
216: }
217:
218: 219: 220: 221: 222: 223:
224: function getField($field) {
225: $value = parent::getField($field);
226: if ('rule' === $field) {
227: $value = stripslashes($value);
228: }
229: return $value;
230: }
231:
232: 233: 234:
235: public function getLastError() {
236: return $this->lasterror;
237: }
238:
239: 240: 241: 242: 243:
244: public function getValue() {
245: return $this->_value;
246: }
247:
248: 249: 250: 251:
252: public function setValue($value) {
253: $this->_value = $value;
254: }
255:
256: 257: 258: 259: 260:
261: public function getFile() {
262: return $this->_file;
263: }
264:
265: 266: 267: 268:
269: public function setFile(array $_file) {
270: $this->_file = $_file;
271: }
272:
273: 274: 275: 276:
277: public function validate() {
278:
279:
280: $values = $this->getValue();
281: if (NULL === $values) {
282: $values = $this->get('default_value');
283: }
284:
285:
286:
287: if (!is_array($values)) {
288: $values = array(
289: $values
290: );
291: }
292:
293: foreach ($values as $value) {
294:
295:
296:
297:
298:
299:
300:
301:
302:
303: if (1 === cSecurity::toInteger($this->get('obligatory')) && 0 === strlen($value)) {
304:
305: $isValid = false;
306: } else if (0 < strlen($this->get('rule')) && in_array(preg_match($this->get('rule'), $value), array(
307: false,
308: 0
309: ))) {
310:
311: $isValid = false;
312: } else {
313: $isValid = true;
314: }
315:
316:
317: if (true !== $isValid) {
318: $error_message = $this->get('error_message');
319: if (NULL === $error_message) {
320:
321: $error_message = '';
322: }
323: throw new PifaValidationException(array(
324: $this->get('idfield') => $error_message
325: ));
326: }
327: }
328: }
329:
330: 331: 332: 333: 334: 335:
336: public function toHtml(array $errors = NULL) {
337: $out = '';
338: switch (cSecurity::toInteger($this->get('field_type'))) {
339:
340: case self::FIELDSET_BEGIN:
341:
342:
343: if (0 < strlen(trim($this->get('css_class')))) {
344: $class = ' class="' . implode(' ', explode(',', $this->get('css_class'))) . '"';
345: }
346: $out .= "\n\t<fieldset$class>";
347:
348: if (1 === cSecurity::toInteger($this->get('display_label'))) {
349: $label = $this->get('label');
350: $out .= "\n\t<legend>$label</legend>";
351: }
352:
353: return $out;
354: break;
355:
356: case self::FIELDSET_END:
357:
358: return "\n\t</fieldset>";
359: break;
360:
361: default:
362:
363:
364: $content = array();
365: try {
366: $content[] = $this->_getElemLabel();
367: $content[] = $this->_getElemField();
368: $content[] = $this->_getElemHelp();
369: $content[] = $this->_getElemScript();
370:
371: if (array_key_exists($this->get('idfield'), $errors)) {
372: $error = $errors[$this->get('idfield')];
373: $content[] = new cHTMLParagraph($error, 'pifa-error-message');
374: }
375: } catch (NotImplementedException $e) {
376: return NULL;
377: }
378:
379: $content = array_filter($content);
380: if (empty($content)) {
381: return NULL;
382: }
383:
384:
385: $class = 'pifa-field-' . $this->get('field_type');
386:
387: if (0 < strlen(trim($this->get('css_class')))) {
388: $class .= ' ' . implode(' ', explode(',', $this->get('css_class')));
389: }
390:
391: if (true === (bool) $this->get('obligatory')) {
392: $class .= ' pifa-obligatory';
393: }
394:
395: if (NULL !== $error) {
396: $class .= ' pifa-error';
397: }
398:
399:
400: $id = 'pifa-field-' . $this->get('idfield');
401:
402:
403: $div = new cHTMLDiv($content, $class, $id);
404:
405: return "\n\t" . $div->render();
406: break;
407: }
408: }
409:
410: 411: 412: 413: 414: 415: 416:
417: public function _getElemLabel() {
418: if (1 !== cSecurity::toInteger($this->get('display_label'))) {
419: return '';
420: }
421:
422:
423: $idfield = cSecurity::toInteger($this->get('idfield'));
424: $fieldType = cSecurity::toInteger($this->get('field_type'));
425: $label = $this->get('label');
426:
427: if (NULL === $label) {
428: return NULL;
429: }
430:
431:
432:
433: if (in_array($fieldType, array(
434: self::BUTTONSUBMIT,
435: self::BUTTONRESET,
436: self::BUTTONBACK
437: ))) {
438: return NULL;
439: }
440:
441:
442: if (true === (bool) $this->get('obligatory')) {
443: $label .= ' *';
444: }
445:
446:
447:
448:
449:
450:
451:
452: $elemLabel = new cHTMLLabel($label, 'pifa-field-elm-' . $idfield, 'pifa-field-lbl');
453:
454: $elemLabel->removeAttribute('id');
455:
456: return $elemLabel;
457: }
458:
459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472:
473: public function _getElemField() {
474:
475:
476: $idfield = cSecurity::toInteger($this->get('idfield'));
477:
478: $fieldType = cSecurity::toInteger($this->get('field_type'));
479:
480: $columnName = $this->get('column_name');
481:
482: $label = $this->get('label');
483:
484:
485:
486: $optionClass = $this->get('option_class');
487: if (0 === strlen(trim($optionClass))) {
488: $optionLabels = $this->get('option_labels');
489: if (NULL !== $optionLabels) {
490: $optionLabels = explode(',', $optionLabels);
491: }
492: $optionValues = $this->get('option_values');
493: if (NULL !== $optionValues) {
494: $optionValues = explode(',', $optionValues);
495: }
496: } else {
497: $filename = Pifa::fromCamelCase($optionClass);
498: $filename = "extensions/class.pifa.$filename.php";
499: if (false === file_exists(Pifa::getPath() . $filename)) {
500: $msg = Pifa::i18n('MISSING_EOD_FILE');
501: $msg = sprintf($msg, $filename);
502: throw new PifaException($msg);
503: }
504: plugin_include(Pifa::getName(), $filename);
505: if (false === class_exists($optionClass)) {
506: $msg = Pifa::i18n('MISSING_EOD_CLASS');
507: $msg = sprintf($msg, $optionClass);
508: throw new PifaException($msg);
509: }
510: $dataSource = new $optionClass();
511: $optionLabels = $dataSource->getOptionLabels();
512: $optionValues = $dataSource->getOptionValues();
513: }
514:
515:
516: $id = 'pifa-field-elm-' . $idfield;
517:
518:
519: $value = $this->getValue();
520:
521:
522: if (NULL === $value) {
523:
524: $value = $this->get('default_value');
525:
526: if (array_key_exists($columnName, $_GET)) {
527: $value = $_GET[$columnName];
528:
529: $value = htmlentities($value, ENT_COMPAT | ENT_HTML401, 'UTF-8');
530: }
531: }
532:
533: switch ($fieldType) {
534:
535: case self::INPUTTEXT:
536:
537: $elemField = new cHTMLTextbox($columnName);
538:
539: $elemField->removeAttribute('id')->setID($id);
540:
541: if (!is_null($this->get('default_value'))) {
542: $elemField->setAttribute('title', $this->get('default_value'));
543: }
544: if (!is_null($value)) {
545: $elemField->setValue($value);
546: }
547: break;
548:
549: case self::TEXTAREA:
550:
551: $elemField = new cHTMLTextarea($columnName);
552:
553: $elemField->removeAttribute('id')->setID($id);
554: if (!is_null($this->get('default_value'))) {
555: $elemField->setAttribute('title', $this->get('default_value'));
556: }
557: if (!is_null($value)) {
558: $elemField->setValue($value);
559: }
560: break;
561:
562: case self::INPUTPASSWORD:
563:
564: $elemField = new cHTMLPasswordbox($columnName);
565:
566: $elemField->removeAttribute('id')->setID($id);
567: if (!is_null($this->get('default_value'))) {
568: $elemField->setAttribute('title', $this->get('default_value'));
569: }
570: if (!is_null($value)) {
571: $elemField->setValue($value);
572: }
573: break;
574:
575: case self::INPUTRADIO:
576: case self::INPUTCHECKBOX:
577:
578: $count = min(array(
579: count($optionLabels),
580: count($optionValues)
581: ));
582: $tmpHtml = '';
583: for ($i = 0; $i < $count; $i++) {
584: if (self::INPUTRADIO === $fieldType) {
585: $elemField = new cHTMLRadiobutton($columnName, $optionValues[$i]);
586: } else if (self::INPUTCHECKBOX === $fieldType) {
587: $elemField = new cHTMLCheckbox($columnName . '[]', $optionValues[$i]);
588: }
589: if (!is_array($value)) {
590: $value = explode(',', $value);
591: }
592: $elemField->setChecked(in_array($optionValues[$i], $value));
593: $elemField->setLabelText($optionLabels[$i]);
594: $tmpHtml .= $elemField->render();
595: }
596: $elemField = new cHTMLSpan($tmpHtml);
597: break;
598:
599: case self::SELECT:
600: case self::SELECTMULTI:
601:
602: $elemField = new cHTMLSelectElement($columnName);
603:
604:
605: $elemField->removeAttribute('id')->setID($id);
606: $autofill = array();
607: $count = min(array(
608: count($optionLabels),
609: count($optionValues)
610: ));
611:
612: for ($i = 0; $i < $count; $i++) {
613: $autofill[$optionValues[$i]] = $optionLabels[$i];
614: }
615:
616: $elemField->autoFill($autofill);
617: $elemField->setDefault($value);
618:
619: break;
620:
621: case self::DATEPICKER:
622:
623:
624: $hiddenField = new cHTMLHiddenField($columnName);
625: $hiddenField->removeAttribute('id')->setID($id . '-hidden');
626: if (!is_null($value)) {
627: $hiddenField->setValue($value);
628: }
629:
630:
631: $textbox = new cHTMLTextbox($columnName . '_visible');
632:
633: $textbox->removeAttribute('id')->setID($id);
634:
635:
636: $elemField = new cHTMLDiv(array(
637: $hiddenField,
638: $textbox
639: ));
640:
641: break;
642:
643: case self::INPUTFILE:
644:
645: $elemField = new cHTMLUpload($columnName);
646:
647: $elemField->removeAttribute('id')->setID($id);
648: break;
649:
650: case self::PROCESSBAR:
651:
652: $elemField = NULL;
653:
654:
655: break;
656:
657: case self::SLIDER:
658:
659: $elemField = NULL;
660:
661:
662: break;
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684: case self::BUTTONSUBMIT:
685: case self::BUTTONRESET:
686: case self::BUTTONBACK:
687:
688: $modes = array(
689: self::BUTTONSUBMIT => 'submit',
690: self::BUTTONRESET => 'reset',
691: self::BUTTONBACK => 'button'
692: );
693: $elemField = new cHTMLButton($columnName);
694:
695: $elemField->removeAttribute('id')->setID($id);
696: if (NULL !== $label) {
697: $elemField->setTitle($label);
698: } else {
699: $elemField->setTitle($modes[$fieldType]);
700: }
701: $elemField->setMode($modes[$fieldType]);
702: break;
703:
704: case self::MATRIX:
705:
706: $elemField = NULL;
707:
708:
709: break;
710:
711: case self::PARA:
712: $elemField = NULL;
713:
714:
715: break;
716:
717: case self::INPUTHIDDEN:
718: $elemField = new cHTMLHiddenField($columnName);
719:
720: $elemField->removeAttribute('id')->setID($id);
721: if (NULL !== $value) {
722: $elemField->setValue($value);
723: }
724: break;
725:
726: default:
727: $msg = Pifa::i18n('NOT_IMPLEMENTED_FIELDTYPE');
728: $msg = sprintf($msg, $fieldType);
729: throw new NotImplementedException($msg);
730:
731: }
732:
733: return $elemField;
734: }
735:
736: 737: 738: 739: 740:
741: public function _getElemHelp() {
742: $helpText = $this->get('help_text');
743:
744: $p = NULL;
745: if (0 < strlen($helpText)) {
746: $p = new cHTMLParagraph($helpText, 'pifa-field-help');
747: }
748:
749: return $p;
750: }
751:
752: 753: 754: 755: 756:
757: public function _getElemScript() {
758:
759:
760: $idfield = cSecurity::toInteger($this->get('idfield'));
761: $fieldType = cSecurity::toInteger($this->get('field_type'));
762:
763: switch ($fieldType) {
764: case self::DATEPICKER:
765: $sel = '#pifa-field-elm-' . $idfield;
766:
767:
768: $script = "jQuery(function(){jQuery('$sel').datepicker({
769: altFormat: 'yy-mm-dd',
770: altField: '$sel-hidden'
771: });});";
772: break;
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787: default:
788: $script = '';
789: }
790:
791: $elemScript = NULL;
792: if (0 < strlen($script)) {
793: $elemScript = new cHTMLScript();
794: $elemScript->setContent($script);
795: }
796:
797: return $elemScript;
798: }
799:
800: 801: 802: 803: 804:
805: public static function getFieldTypeIcon($fieldType) {
806: switch ($fieldType) {
807: case self::INPUTTEXT:
808: case self::TEXTAREA:
809: case self::INPUTPASSWORD:
810: case self::INPUTRADIO:
811: case self::INPUTCHECKBOX:
812: case self::SELECT:
813: case self::SELECTMULTI:
814: case self::DATEPICKER:
815: case self::INPUTFILE:
816: case self::PROCESSBAR:
817: case self::SLIDER:
818:
819: case self::BUTTONSUBMIT:
820: case self::BUTTONRESET:
821: case self::BUTTONBACK:
822: case self::MATRIX:
823: case self::PARA:
824: case self::INPUTHIDDEN:
825: case self::FIELDSET_BEGIN:
826: case self::FIELDSET_END:
827: return 'icon.png';
828: }
829: }
830:
831: 832: 833: 834: 835:
836: public static function getFieldTypeIds() {
837: return array_keys(self::getFieldTypeNames());
838: }
839:
840: 841: 842: 843: 844:
845: public static function getFieldTypeNames() {
846: return array(
847: self::INPUTTEXT => Pifa::i18n('INPUTTEXT'),
848: self::TEXTAREA => Pifa::i18n('TEXTAREA'),
849: self::INPUTPASSWORD => Pifa::i18n('INPUTPASSWORD'),
850: self::INPUTRADIO => Pifa::i18n('INPUTRADIO'),
851: self::INPUTCHECKBOX => Pifa::i18n('INPUTCHECKBOX'),
852: self::SELECT => Pifa::i18n('SELECT'),
853: self::SELECTMULTI => Pifa::i18n('SELECTMULTI'),
854: self::DATEPICKER => Pifa::i18n('DATEPICKER'),
855: self::INPUTFILE => Pifa::i18n('INPUTFILE'),
856: self::PROCESSBAR => Pifa::i18n('PROCESSBAR'),
857: self::SLIDER => Pifa::i18n('SLIDER'),
858:
859: self::BUTTONSUBMIT => Pifa::i18n('BUTTONSUBMIT'),
860: self::BUTTONRESET => Pifa::i18n('BUTTONRESET'),
861: self::BUTTONBACK => Pifa::i18n('BUTTONBACK'),
862:
863: self::PARA => Pifa::i18n('PARAGRAPH'),
864: self::INPUTHIDDEN => Pifa::i18n('INPUTHIDDEN'),
865: self::FIELDSET_BEGIN => Pifa::i18n('FIELDSET_BEGIN'),
866: self::FIELDSET_END => Pifa::i18n('FIELDSET_END')
867: );
868: }
869:
870: 871: 872: 873: 874: 875:
876: public static function getFieldTypeName($fieldTypeId) {
877: $fieldTypeId = cSecurity::toInteger($fieldTypeId);
878: $fieldTypeNames = self::getFieldTypeNames();
879:
880: if (array_key_exists($fieldTypeId, $fieldTypeNames)) {
881: $fieldTypeName = $fieldTypeNames[$fieldTypeId];
882: } else {
883: $fieldTypeName = Pifa::i18n('UNKNOWN');
884: }
885:
886: return $fieldTypeName;
887: }
888:
889: 890: 891: 892: 893: 894:
895: public function getMyFieldTypeName() {
896: return self::getFieldTypeName($this->get('field_type'));
897: }
898:
899: 900: 901: 902: 903: 904: 905:
906: public function getDbDataType() {
907: if (!$this->isLoaded()) {
908: $msg = Pifa::i18n('FIELD_LOAD_ERROR');
909: throw new PifaException($msg);
910: }
911:
912: $fieldType = cSecurity::toInteger($this->get('field_type'));
913:
914: switch ($fieldType) {
915:
916:
917:
918:
919:
920: case self::INPUTTEXT:
921: case self::INPUTPASSWORD:
922: case self::INPUTHIDDEN:
923: case self::INPUTFILE:
924:
925: return 'VARCHAR(' . self::VARCHAR_SIZE . ')';
926:
927:
928:
929: case self::INPUTCHECKBOX:
930:
931: return 'VARCHAR(' . self::VARCHAR_SIZE . ')';
932:
933:
934:
935: case self::TEXTAREA:
936:
937: return 'TEXT';
938:
939:
940:
941:
942: case self::INPUTRADIO:
943: case self::SELECT:
944: case self::SELECTMULTI:
945:
946:
947:
948:
949:
950:
951:
952:
953:
954:
955:
956:
957: return 'VARCHAR(' . self::VARCHAR_SIZE . ')';
958:
959:
960:
961:
962:
963: case self::DATEPICKER:
964:
965: return 'DATETIME';
966:
967:
968: case self::BUTTONSUBMIT:
969: case self::BUTTONRESET:
970: case self::BUTTONBACK:
971:
972: return NULL;
973:
974:
975:
976: case self::PROCESSBAR:
977: case self::SLIDER:
978:
979: case self::MATRIX:
980: case self::PARA:
981: case self::FIELDSET_BEGIN:
982: case self::FIELDSET_END:
983:
984: return NULL;
985:
986: default:
987: $msg = Pifa::i18n('NOT_IMPLEMENTED_FIELDTYPE');
988: $msg = sprintf($msg, $fieldType);
989: throw new PifaException($msg);
990: }
991: }
992:
993: 994: 995: 996:
997: public function delete() {
998: $cfg = cRegistry::getConfig();
999: $db = cRegistry::getDb();
1000:
1001: if (!$this->isLoaded()) {
1002: $msg = Pifa::i18n('FIELD_LOAD_ERROR');
1003: throw new PifaException($msg);
1004: }
1005:
1006:
1007: $sql = "-- PifaField->delete()
1008: UPDATE
1009: " . cRegistry::getDbTableName('pifa_field') . "
1010: SET
1011: field_rank = field_rank - 1
1012: WHERE
1013: idform = " . cSecurity::toInteger($this->get('idform')) . "
1014: AND field_rank > " . cSecurity::toInteger($this->get('field_rank')) . "
1015: ;";
1016: if (false === $db->query($sql)) {
1017:
1018:
1019: }
1020:
1021:
1022: $sql = "-- PifaField->delete()
1023: DELETE FROM
1024: " . cRegistry::getDbTableName('pifa_field') . "
1025: WHERE
1026: idfield = " . cSecurity::toInteger($this->get('idfield')) . "
1027: ;";
1028: if (false === $db->query($sql)) {
1029: $msg = Pifa::i18n('FIELD_DELETE_ERROR');
1030: throw new PifaException($msg);
1031: }
1032:
1033:
1034: if (0 < strlen(trim($this->get('column_name')))) {
1035: $pifaForm = new PifaForm($this->get('idform'));
1036:
1037: if (0 < strlen(trim($pifaForm->get('data_table')))) {
1038: $sql = "-- PifaField->delete()
1039: ALTER TABLE
1040: `" . cSecurity::toString($pifaForm->get('data_table')) . "`
1041: DROP COLUMN
1042: `" . cSecurity::toString($this->get('column_name')) . "`
1043: ;";
1044: if (false === $db->query($sql)) {
1045: $msg = Pifa::i18n('COLUMN_DROP_ERROR');
1046: throw new PifaException($msg);
1047: }
1048: }
1049: }
1050: }
1051:
1052: 1053: 1054: 1055: 1056: 1057:
1058: public function showField($columnName) {
1059: $fieldType = $this->get('field_type');
1060: $fieldType = cSecurity::toInteger($fieldType);
1061:
1062: switch ($columnName) {
1063:
1064: case 'idfield':
1065: case 'idform':
1066: case 'field_rank':
1067: case 'field_type':
1068:
1069: return false;
1070:
1071: case 'column_name':
1072: return in_array($fieldType, array(
1073: self::INPUTTEXT,
1074: self::TEXTAREA,
1075: self::INPUTPASSWORD,
1076: self::INPUTRADIO,
1077: self::INPUTCHECKBOX,
1078: self::SELECT,
1079: self::SELECTMULTI,
1080: self::DATEPICKER,
1081: self::INPUTFILE,
1082: self::PROCESSBAR,
1083: self::SLIDER,
1084:
1085:
1086:
1087:
1088: self::MATRIX,
1089: self::INPUTHIDDEN
1090: 1091: 1092: 1093:
1094: ));
1095:
1096: case 'label':
1097: case 'display_label':
1098: return in_array($fieldType, array(
1099: self::INPUTTEXT,
1100: self::TEXTAREA,
1101: self::INPUTPASSWORD,
1102: self::INPUTRADIO,
1103: self::INPUTCHECKBOX,
1104: self::SELECT,
1105: self::SELECTMULTI,
1106: self::DATEPICKER,
1107: self::INPUTFILE,
1108: self::PROCESSBAR,
1109: self::SLIDER,
1110:
1111: self::BUTTONSUBMIT,
1112: self::BUTTONRESET,
1113: self::BUTTONBACK,
1114: self::MATRIX,
1115: self::PARA,
1116:
1117: self::FIELDSET_BEGIN
1118: 1119: 1120:
1121: ));
1122:
1123: case 'default_value':
1124: return in_array($fieldType, array(
1125: self::INPUTTEXT,
1126: self::TEXTAREA,
1127: self::INPUTPASSWORD,
1128: self::INPUTRADIO,
1129: self::INPUTCHECKBOX,
1130: self::SELECT,
1131: self::SELECTMULTI,
1132: self::DATEPICKER,
1133: self::INPUTFILE,
1134: self::PROCESSBAR,
1135: self::SLIDER,
1136:
1137: self::BUTTONSUBMIT,
1138: self::BUTTONRESET,
1139: self::BUTTONBACK,
1140: self::MATRIX,
1141: self::INPUTHIDDEN
1142: ));
1143:
1144: case 'option_labels':
1145: case 'option_values':
1146: case 'option_class':
1147: return in_array($fieldType, array(
1148: self::INPUTRADIO,
1149: self::INPUTCHECKBOX,
1150: self::SELECT,
1151: self::SELECTMULTI
1152: ));
1153:
1154: case 'help_text':
1155: return in_array($fieldType, array(
1156: self::INPUTTEXT,
1157: self::TEXTAREA,
1158: self::INPUTPASSWORD,
1159: self::INPUTRADIO,
1160: self::INPUTCHECKBOX,
1161: self::SELECT,
1162: self::SELECTMULTI,
1163: self::DATEPICKER,
1164: self::INPUTFILE,
1165: self::PROCESSBAR,
1166: self::SLIDER,
1167:
1168: self::BUTTONSUBMIT,
1169: self::BUTTONRESET,
1170: self::BUTTONBACK,
1171: self::MATRIX,
1172: self::PARA,
1173: self::FIELDSET_BEGIN
1174: ));
1175:
1176: case 'obligatory':
1177: return in_array($fieldType, array(
1178: self::INPUTTEXT,
1179: self::TEXTAREA,
1180: self::INPUTPASSWORD,
1181: self::INPUTRADIO,
1182: self::INPUTCHECKBOX,
1183: self::SELECT,
1184: self::SELECTMULTI,
1185: self::DATEPICKER,
1186: self::INPUTFILE,
1187: self::PROCESSBAR,
1188: self::SLIDER,
1189:
1190:
1191:
1192:
1193: self::MATRIX,
1194: self::INPUTHIDDEN
1195: ));
1196:
1197: case 'rule':
1198: return in_array($fieldType, array(
1199: self::INPUTTEXT,
1200: self::TEXTAREA,
1201: self::INPUTPASSWORD,
1202: self::INPUTRADIO,
1203: self::INPUTCHECKBOX,
1204: self::SELECT,
1205: self::SELECTMULTI,
1206: self::DATEPICKER,
1207: self::INPUTFILE,
1208: self::PROCESSBAR,
1209: self::SLIDER,
1210:
1211:
1212:
1213:
1214: self::MATRIX,
1215: self::INPUTHIDDEN
1216: ));
1217:
1218: case 'error_message':
1219: return in_array($fieldType, array(
1220: self::INPUTTEXT,
1221: self::TEXTAREA,
1222: self::INPUTPASSWORD,
1223: self::INPUTRADIO,
1224: self::INPUTCHECKBOX,
1225: self::SELECT,
1226: self::SELECTMULTI,
1227: self::DATEPICKER,
1228: self::INPUTFILE,
1229: self::PROCESSBAR,
1230: self::SLIDER,
1231:
1232:
1233:
1234:
1235: self::MATRIX,
1236: self::INPUTHIDDEN
1237: ));
1238:
1239: case 'css_class':
1240: return in_array($fieldType, array(
1241: self::INPUTTEXT,
1242: self::TEXTAREA,
1243: self::INPUTPASSWORD,
1244: self::INPUTRADIO,
1245: self::INPUTCHECKBOX,
1246: self::SELECT,
1247: self::SELECTMULTI,
1248: self::DATEPICKER,
1249: self::INPUTFILE,
1250: self::PROCESSBAR,
1251: self::SLIDER,
1252:
1253: self::BUTTONSUBMIT,
1254: self::BUTTONRESET,
1255: self::BUTTONBACK,
1256: self::MATRIX,
1257: self::PARA,
1258: self::FIELDSET_BEGIN
1259: 1260: 1261:
1262: ));
1263:
1264: default:
1265: $msg = Pifa::i18n('NOT_IMPLEMENTED_FIELDPROP');
1266: $msg = sprintf($msg, $columnName);
1267: throw new PifaException($msg);
1268: }
1269: }
1270:
1271: 1272: 1273: 1274:
1275: public function getOptions() {
1276: $option_labels = $this->get('option_labels');
1277: $option_values = $this->get('option_values');
1278:
1279: $out = array();
1280: if (0 < strlen($option_labels . $option_values)) {
1281: $option_labels = explode(',', $option_labels);
1282: $option_values = explode(',', $option_values);
1283:
1284:
1285:
1286:
1287:
1288:
1289: $func = create_function('$v', 'return str_replace(\',\', \',\', $v);');
1290: $option_labels = array_map($func, $option_labels);
1291: $option_values = array_map($func, $option_values);
1292:
1293: foreach (array_keys($option_labels) as $key) {
1294: $out[] = array(
1295: 'label' => $option_labels[$key],
1296: 'value' => $option_values[$key]
1297: );
1298: }
1299: }
1300:
1301: return $out;
1302: }
1303: }
1304:
1305: ?>