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