formguide_form.class.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class formguide_form {
  3. var $formid;
  4. var $fields;
  5. var $id;
  6. var $formValidator;
  7. function __construct($formid, $no_allowed = 0) {
  8. $this->formid = $formid;
  9. $this->no_allowed = $no_allowed ? 'disabled=""' : '';
  10. $this->fields = getcache('formguide_field_'.$formid, 'model');
  11. $this->siteid = get_siteid();
  12. }
  13. function get($data = array()) {
  14. $_groupid = param::get_cookie('_groupid');
  15. $this->data = $data;
  16. if(isset($data['id'])) $this->id = $data['id'];
  17. $info = array();
  18. $info = array();
  19. if (is_array($this->fields)) {
  20. foreach($this->fields as $field=>$v) {
  21. $func = $v['formtype'];
  22. $value = isset($data[$field]) ? new_html_special_chars($data[$field]) : '';
  23. if($func=='pages' && isset($data['maxcharperpage'])) {
  24. $value = $data['paginationtype'].'|'.$data['maxcharperpage'];
  25. }
  26. if(!method_exists($this, $func)) continue;
  27. $form = $this->$func($field, $value, $v);
  28. if($form !== false) {
  29. $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
  30. $info[$field] = array('name'=>$v['name'], 'tips'=>$v['tips'], 'form'=>$form, 'star'=>$star,'isomnipotent'=>$v['isomnipotent'],'formtype'=>$v['formtype']);
  31. }
  32. }
  33. }
  34. return $info;
  35. }
  36. }?>