1: <?php
2: /**
3: * A class to render helpful information next to a form element
4: *
5: * @package Core
6: * @subpackage GUI
7: * @version SVN Revision $Rev:$
8: *
9: * @author Mischa Holz
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: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: /**
18: * Class cGuilBackendHelpbox.
19: * Renders a little helpbox to display information next to a form element
20: *
21: * @package Core
22: * @subpackage GUI
23: */
24: class cGuiBackendHelpbox {
25:
26: /**
27: * the text that will appear in the tooltip
28: *
29: * @var string
30: */
31: protected $helpText;
32:
33: /**
34: * Basic constructor.
35: * Assigns a help text
36: *
37: * @param string $helpText the text that will appear in the tooltip
38: */
39: function __construct($helpText) {
40: $this->setHelpText($helpText);
41: }
42:
43: /**
44: * Set the help text to a new value
45: *
46: * @param string $helpText the text that will appear in the tooltip
47: */
48: function setHelpText($helpText) {
49: $this->helpText = $helpText;
50: }
51:
52: /**
53: * Render the helpbox.
54: * Please make sure that the general.js, the atooltip.jquery.js and the
55: * atooltip.css are embedded on the site
56: *
57: * @param string $returnAsString if true the rendered button will be
58: * returned. Otherwise it will be echoed
59: * @return string|NULL rendered button or nothing if it's been printed
60: */
61: function render($returnAsString = true) {
62: $id = md5(rand()) . "-Info";
63:
64: $ret = "<a href='javascript://' id='" . $id . "-link' title='" . i18n("More information") . "' class='i-link infoButton'></a>";
65: $ret .= "<div id='" . $id . "' style='display: none;'>" . $this->helpText . "</div>";
66:
67: if ($returnAsString) {
68: return $ret;
69: } else {
70: echo ($ret);
71: return NULL;
72: }
73: }
74: }
75:
76: ?>