/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/DialogWidget.inc
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/widgets/DialogWidget.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu May 6 16:57:34 2004 UTC (20 years, 2 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
 updated all to v2.4.1 - Apr 01, 2004

1 <?php
2 /**
3 * This contains the TextNav widget
4 *
5 * $Id: DialogWidget.inc,v 1.4 2003/11/04 19:43:44 hemna Exp $
6 *
7 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
8 * @package phpHtmlLib
9 *
10 */
11
12
13 require_once($phphtmllib."/widgets/InfoTable.inc");
14 require_once($phphtmllib."/widgets/ButtonPanel.inc");
15
16
17 /**
18 * This is a base class for building generic
19 * Dialogs with messages and buttons.
20 *
21 */
22 class DialogWidget extends BaseWidget {
23
24 /**
25 * Holds the list of buttons
26 * for this widget dialog
27 *
28 */
29 var $_buttons = array();
30
31 /**
32 * Show or not to show the cancel button?
33 *
34 */
35 var $_show_cancel_button = FALSE;
36
37 /**
38 * Holds the cancel action
39 *
40 */
41 var $_cancel_url = NULL;
42
43
44 /**
45 * The constructor
46 *
47 * @param string the title
48 * @param string the width
49 * @return none
50 */
51 function DialogWidget($title = NULL, $width="100%", $align=NULL) {
52 $this->set_title($title);
53 $this->set_width($width);
54 $this->set_align($align);
55 }
56
57 /**
58 * Creates a container with title,
59 * data and the buttons
60 *
61 */
62 function render($indent_level, $output_debug=0) {
63
64 $table = html_table($this->get_width(), 0, 0, 0, $this->get_align());
65
66 $box =& $this->_build_message_container();
67 $table->add_row( $box );
68
69 // add the buttons
70 $buttons =& $this->_build_buttons() ;
71 if ($buttons != null) {
72 $table->add_row( _HTML_SPACE );
73 $table->add_row($buttons);
74 }
75
76 return $table->render( $indent_level, $output_debug );
77 }
78
79 /**
80 * Pushes a content into the data object
81 *
82 * @param mixed - either string, or tag object.
83 * @access public
84 */
85 function add() {
86 $args = func_get_args();
87
88 foreach($args as $content) {
89 $this->_data[] = $content;
90 }
91 }
92
93
94 /**
95 * Adds a single button to the dialog
96 * that will be display at the bottom
97 * of the widget
98 *
99 * @param string - button title
100 * @param string - button action, if NULL, then submit button is created
101 * @access public
102 */
103 function add_button($button) {
104 $this->_buttons[] = $button;
105 }
106
107
108 /**
109 * Sets the flag to show or not to show
110 * the cancel button
111 *
112 * @param bool - flag
113 */
114 function show_cancel_button($flag) {
115 $this->_show_cancel_button = $flag;
116 }
117
118 /**
119 * Sets the cancel action
120 *
121 * @param string - action
122 */
123 function set_cancel_url($url) {
124 $this->_cancel_url = $url;
125 }
126
127
128 /**
129 * Create a DIV that holds the buttons
130 *
131 * @return a DIVtag
132 * @access private
133 */
134 function _build_buttons() {
135
136 if (empty($this->_buttons) && !$this->_show_cancel_button) {
137 return null;
138 }
139
140 $buttons = new ButtonPanel($this->get_width(), "center");
141
142 foreach ($this->_buttons as $button) {
143 $buttons->add($button);
144 }
145
146 if ($this->_show_cancel_button) {
147 // build cancel buttons
148 $this->_build_cancel_url();
149
150 $buttons->add(form_button("cancel","Cancel",
151 array("type"=>"button",
152 "style"=>"width:90px;",
153 "onclick"=>"javascript:window.location='" . $this->_cancel_url . "'")));
154 }
155
156 return $buttons;
157 }
158
159
160 /**
161 * Build the cancel url
162 *
163 * @return string
164 */
165 function _build_cancel_url() {
166 if ($this->_cancel_url == NULL) {
167 $this->set_cancel_url("index.php");
168 }
169 }
170
171
172
173 /**
174 * This method is used to add the message blocks
175 * to the appropriate container
176 *
177 * @return object - the container object with the messages.
178 */
179 function &_build_message_container() {
180 $box = new InfoTable($this->get_title());
181
182 //don't show the cell borders
183 $box->set_show_cellborders(false);
184
185 // add each block
186 foreach ($this->_data as $message) {
187
188 // we have a block with the title
189 $box->add_row($message);
190 }
191
192 return $box;
193 }
194 }
195 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed