This repository has been archived by the owner on Sep 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.php
executable file
·124 lines (116 loc) · 3.07 KB
/
Input.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/*
* ###########
* #__________#
* __________#
* ________#
* _____###_____²xiT development
* _________#
* ___________#
* #__________#
* _#________#
* __#______#
* ____####
*/
/**
* @package MyOOF
* @version 2.00
* @author Joris Berthelot <admin@eexit.net>
* @copyright Copyright (c) 2008, Joris Berthelot
* @license http://www.opensource.org/licenses/mit-license.php MIT Licence
*/
/**
* @package MyOOF
*/
class Input extends Element {
/**
* The final compiled opbject result will go in this var
* @var string
* @access protected
*/
protected $_output;
/**
* List of available attributes
* @var array
* @access protected
*/
protected $_pattern = array(
'accept' => null,
'accesskey' => null,
'alt' => null,
'checked' => null,
'class' => null,
'dir' => 'ltr',
'disabled' => null,
'id' => null,
'lang' => null,
'maxlength' => null,
'name' => null,
'readonly' => null,
'size' => null,
'src' => null,
'style' => null,
'tabindex' => null,
'title' => null,
'type' => 'text',
'usemap' => null,
'value' => '',
'xml:lang' => null,
'xmlns' => null
);
/**
* List of default attribute values
* @var array
* @access protected
*/
protected $_defaultValues = array(
'checked' => 'checked',
'dir' => array('ltr', 'rtl'),
'disabled' => 'disabled',
'readonly' => 'readonly',
'type' => array('button', 'checkbox', 'file', 'hidden', 'image',
'password', 'radio', 'reset', 'submit', 'text')
);
/**
* Instanciates the self class if allowed in
* {@link Element::$_availableChilds}
* @final
* @access public
* @param [array $config = null Associative array of attributes]
*/
final public function __construct(array $config = null) {
if (parent::__construct($this)) {
if (!empty($config)) {
$this->setAttributes($config);
}
}
}
/**
* Gets final source code. Also called by {@link Element::__toString()}
* @final
* @access public
* @return mixed string The generated object source code | bool false
*/
final public function getOutput() {
if ($this->_buildInput()) {
return $this->_output;
}
return false;
}
/**
* Generates final source code. Called by {@link Input::getOutput()}
* @access private
* @return bool true
*/
private function _buildInput() {
$this->_output = '<input ';
foreach ($this->_pattern as $attr => $value) {
if (!is_null($value)) {
$this->_output .= $attr . '="' . $value . '" ';
}
}
$this->_output .= '/>';
return true;
}
}
?>