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: */
46: public function __construct($text, $for, $class = '') {
47: parent::__construct('', $class);
48: $this->_tag = 'label';
49: $this->updateAttribute('for', $for);
50: $this->text = $text;
51: }
52:
53: /**
54: * Renders the label
55: *
56: * @return string Rendered HTML
57: */
58: public function toHtml() {
59: $this->_setContent($this->text);
60:
61: return parent::toHTML();
62: }
63:
64: }
65: