1: <?php
2:
3: /**
4: * This file contains the cHTMLLabel class.
5: *
6: * @package Core
7: * @subpackage GUI_HTML
8: *
9: * @author Simon Sprankel
10: * @copyright four for business AG <www.4fb.de>
11: * @license http://www.contenido.org/license/LIZENZ.txt
12: * @link http://www.4fb.de
13: * @link http://www.contenido.org
14: */
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: /**
19: * cHTMLLabel class represents a form label.
20: *
21: * @package Core
22: * @subpackage GUI_HTML
23: */
24: class cHTMLLabel extends cHTMLContentElement {
25:
26: /**
27: * The text to display on the label
28: *
29: * @var string
30: */
31: public $text;
32:
33: /**
34: * Constructor to create an instance of this class.
35: *
36: * Creates an HTML label which can be linked to any form element
37: * (specified by their ID).
38: *
39: * A label can be used to link to elements. This is very useful
40: * since if a user clicks a label, the linked form element receives
41: * the focus (if supported by the user agent).
42: *
43: * @param string $text
44: * Name of the element
45: * @param string $for
46: * ID of the form element to link to.
47: * @param string $class [optional]
48: * the class of this element
49: */
50: public function __construct($text, $for, $class = '') {
51: parent::__construct('', $class);
52: $this->_tag = 'label';
53: $this->updateAttribute('for', $for);
54: $this->text = $text;
55: }
56:
57: /**
58: * Renders the label
59: *
60: * @return string
61: * Rendered HTML
62: */
63: public function toHtml() {
64: $this->_setContent($this->text);
65:
66: return parent::toHtml();
67: }
68:
69: }
70: