1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23:
24: class cHTMLForm extends cHTMLContentElement {
25:
26: protected $_name;
27:
28: protected $_action;
29:
30: protected $_method;
31:
32: 33: 34: 35: 36: 37: 38: 39: 40:
41: public function __construct($name = '', $action = 'main.php', $method = 'post', $class = '') {
42: parent::__construct('', $class);
43: $this->_tag = 'form';
44: $this->_name = $name;
45: $this->_action = $action;
46: $this->_method = $method;
47: }
48:
49: 50: 51: 52: 53: 54: 55:
56: public function setVar($var, $value) {
57: $this->_vars[$var] = $value;
58:
59: return $this;
60: }
61:
62: 63: 64: 65: 66:
67: public function toHTML() {
68: $out = '';
69: if (is_array($this->_vars)) {
70: foreach ($this->_vars as $var => $value) {
71: $f = new cHTMLHiddenField($var, $value);
72: $out .= $f->render();
73: }
74: }
75: if ($this->getAttribute('name') == '') {
76: $this->setAttribute('name', $this->_name);
77: }
78: if ($this->getAttribute('method') == '') {
79: $this->setAttribute('method', $this->_method);
80: }
81: if ($this->getAttribute('action') == '') {
82: $this->setAttribute('action', $this->_action);
83: }
84:
85: $attributes = $this->getAttributes(true);
86:
87: return $this->fillSkeleton($attributes) . $out . $this->_content . $this->fillCloseSkeleton();
88: }
89:
90: }
91: