/[cvs]/nfo/php/libs/org.netfrag.patches/phphtmllib/widgets/FlexibleNegotiation.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.patches/phphtmllib/widgets/FlexibleNegotiation.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Sat May 10 18:02:13 2003 UTC (21 years, 2 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +28 -3 lines
+ implemented multi-selection (special for multi-delete)

1 <?
2 /**
3 * This file contains the FlexibleNegotiation child class.
4 * It inherits from another patch to phpHtmlLib: the EditDataItem class.
5 *
6 * @package org.netfrag.patches
7 * @name FlexibleNegotiation
8 *
9 */
10
11 /**
12 * Cvs-Log
13 *
14 * $Id: FlexibleNegotiation.php,v 1.3 2003/04/11 01:34:46 joko Exp $
15 *
16 * $Log: FlexibleNegotiation.php,v $
17 * Revision 1.3 2003/04/11 01:34:46 joko
18 * don't show any form content on this negotation (does delete only by now)
19 *
20 * Revision 1.2 2003/04/11 00:59:10 joko
21 * minor update regarding function rename
22 *
23 * Revision 1.1 2003/04/11 00:40:31 joko
24 * initial commit
25 *
26 *
27 */
28
29 /**
30 * FlexibleNegotiation
31 *
32 * Encapsulate arbitrary actions into flexible negotiations.
33 *
34 *
35 * @package org.netfrag.patches
36 * @subpackage phphtmllib/widgets
37 * @name FlexibleNegotiation
38 *
39 */
40 class FlexibleNegotiation extends EditDataItem {
41
42 var $_negotiation_options;
43
44 /**
45 * The constructor of the FlexibleNegotiation is used to advance
46 * the workflow to "Confirm" automagically.
47 *
48 * We just have to flag this behavior here, phpHtmlLib
49 * already handles almost everything smoothly.
50 *
51 */
52 function FlexibleNegotiation($title, $options = array(), $negotiation_options = array()) {
53
54 $this->_negotiation_options = $negotiation_options;
55
56 // change phpHtmlLib default behavior to change
57 // entrypoint of form- approve-/confirm-workflow
58 // TODO: integrate into negotiation options!?
59 $_POST[FORM_VISITED] = 1;
60 //$_POST[FORM_CONFIRM] = 1;
61
62 // on multi-selections we can't currently confirm relating on problems at var forwarding
63 if(is_array($options[data_locator_meta][ident])) {
64 $_POST[FORM_CONFIRM] = 1;
65 }
66
67 // call constructor of base class
68 $this->EditDataItem($title, $options);
69 //$this->StandardFormContent($title, $PHP_SELF, 600);
70
71 // disable any form content (we just need buttons)
72 $this->_datasource = null;
73
74 // debug
75 //print "options: " . Dumper($this->_options);
76 }
77
78
79 /**
80 * This function is used to build the standard
81 * buttons for a form.
82 * Overwritten from EditDataItem.
83 *
84 * @return ButtonPanel DIVtag object
85 */
86 function form_content_buttons() {
87 //print Dumper($this->_options);
88 $div = new DIVtag(
89 array(
90 "style" => "background-color: #eeeeee;" . "padding-top:5px;padding-bottom:5px",
91 "align"=>"center",
92 "nowrap"
93 ),
94 //form_submit('ecdfc', "Back")
95 link::plain( url::viewdatanode($this->_options[data_locator_meta][nodename]), 'Back' )
96 //'abc'
97 );
98 return $div;
99 }
100
101
102
103
104 /**
105 * This should display a generic confirmation page.
106 *
107 * @return mixed - either raw html, or some container HTMLTag object.
108 *
109 */
110 function form_confirm( ) {
111
112 //print "Duids: " . Dumper($this->_options[data_locator_meta][ident]);
113
114 $this->add_hidden_element('ecmod', 'delete');
115
116 // if ident is an array( multi-selection!) forward this
117 // TODO: make it work!! Problem is that '$this->add_hidden_element'
118 // adds an 'FEHidden' object which replaces '[]' at array vars with '_', what will not work at request handling
119 if(is_array($this->_options[data_locator_meta][ident])) {
120 $this->add_hidden_element('ecdid', $this->_options[data_locator_meta][nodename]);
121 $this->add_hidden_element('ecdfa', 'delete');
122 foreach($this->_options[data_locator_meta][ident] as $key => $ident) {
123 //$this->add_hidden_element("checkbox[".$key."]", $ident);
124 }
125 $this->add_hidden_element('checkbox', $this->_options[data_locator_meta][ident]);
126 } else {
127 $this->add_hidden_element('ecdid', $this->_options[data_locator_meta][ident]);
128 $this->add_hidden_element('ecdm', $this->_options[data_locator_meta][nodename]);
129 }
130
131 $title = "Form Confirmation / " . $this->_options['caption'];
132 $title .="( ".$this->_required_field_marker." ".$this->_required_field_text." )";
133 $table = new InfoTable($title, $this->_width);
134
135 $this->build_confirm_table( $table );
136
137 //now add the confirmation button
138 $td = new TDtag(array("colspan" => 2,
139 "class" => "contentnovertical",
140 "align" => "center"),
141 form_submit('ecdfd', "Confirm"),
142 _HTML_SPACE,
143 //$this->add_action("Edit")
144 form_submit('ecdfc', "Cancel")
145 );
146
147 if ($this->_cancel_action) {
148 $td->add(_HTML_SPACE, $this->add_cancel());
149 }
150
151 $table->add_row( $td );
152
153 return $table;
154 }
155
156
157 /**
158 * This should execute the confirmed action and indicate success or failure.
159 *
160 * @todo error status & message propagation (e.g. logging)
161 * @todo advanced exception handling
162 * @todo actions might be synchronous and/or asynchronous (mixed)!?
163 * @todo what about triggers? before-action, after-action, etc.
164 * would solve some stuff, but would make other stuff more complicated
165 *
166 * @return bool
167 *
168 */
169 function confirm_action() {
170
171 //print "Guid(s): " . Dumper($this->_options['data_locator_meta']['ident']);
172
173 // If user confirms action, issue delete request on current item.
174 $this->_options['data_locator_meta']['action'] = "delete";
175 $error = $this->data_prefetch();
176
177 // disable any form content (we just need buttons)
178 $this->_datasource = null;
179
180 $msg = "Action confirmed! Changes may take a while to propagate through all parts of the system.";
181 $this->set_action_message($msg);
182
183 /*
184 $this->_options['data_locator_meta']['action'] = "read";
185 $error = $this->data_prefetch();
186 */
187
188 // TODO: review - what about the status of the action if executed
189 // asynchronous? try to implement something to monitor state here!?
190 return TRUE;
191 }
192
193
194 }
195
196 ?>

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