1: <?php
2: /**
3: * This file contains the cHTMLLabel class.
4: *
5: * @package Core
6: * @subpackage GUI_HTML
7: * @version SVN Revision $Rev:$
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.
35: * Creates an HTML label which can be linked
36: * to any form element (specified by their ID).
37: *
38: * A label can be used to link to elements. This is very useful
39: * since if a user clicks a label, the linked form element receives
40: * the focus (if supported by the user agent).
41: *
42: * @param string $text Name of the element
43: * @param string $for ID of the form element to link to.
44: * @param string $class the class of this element
45: * @return void
46: */
47: public function __construct($text, $for, $class = '') {
48: parent::__construct('', $class);
49: $this->_tag = 'label';
50: $this->updateAttribute('for', $for);
51: $this->text = $text;
52: }
53:
54: /**
55: * Renders the label
56: *
57: * @return string Rendered HTML
58: */
59: public function toHtml() {
60: $this->_setContent($this->text);
61:
62: return parent::toHTML();
63: }
64:
65: }
66: