| Total Complexity | 7 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class Field |
||
| 6 | { |
||
| 7 | public $name; |
||
| 8 | public $default; |
||
| 9 | public $value; |
||
| 10 | public $request; |
||
| 11 | public $hint; |
||
| 12 | |||
| 13 | function __construct($name, $default = null, $hint = '') |
||
| 14 | { |
||
| 15 | $this->name = $name; |
||
| 16 | $this->default = $default; |
||
| 17 | |||
| 18 | if ($hint == '') |
||
| 19 | $hint = $name; |
||
| 20 | |||
| 21 | $this->hint = $hint; |
||
| 22 | } |
||
| 23 | |||
| 24 | function init($request) |
||
|
|
|||
| 25 | { |
||
| 26 | $this->value = $request->get($this->name, $this->default); |
||
| 27 | } |
||
| 28 | |||
| 29 | function render() |
||
| 30 | { |
||
| 31 | $id = htmlentities($this->name); |
||
| 32 | echo '<label style="background-color: #c0c0c0; padding: 5px; margin: 2px;" for="imgparam_' . $id . '" title="' . htmlentities($this->hint) . '">'; |
||
| 33 | echo $this->name . ': '; |
||
| 34 | $this->renderBody($id, 'imgparam_' . $id); |
||
| 35 | echo '</label> '; |
||
| 36 | } |
||
| 37 | |||
| 38 | function renderBody($name, $id) |
||
| 39 | { |
||
| 40 | echo '<input id="' . $id . '" type="text" size="15" name="' . $name . '" value="' . $this->getRenderValue() . '" />'; |
||
| 41 | } |
||
| 42 | |||
| 43 | function getRenderValue() |
||
| 46 | } |
||
| 47 | |||
| 48 | function getUrlValue() |
||
| 49 | { |
||
| 50 | return urlencode($this->name) . '=' . urlencode($this->value); |
||
| 53 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.