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