class_mcPUIX.inc.php
10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<?php
interface imcPUIX {
public function getDOMElement_edit(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, DOMElement &$param_DOMElement, $param_KindOf=null, array $param_DOMElemente=null);
public function getDOMElement_show(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, DOMElement &$param_DOMElement, $param_KindOf=null, array $param_DOMElemente=null);
public function manipulatePost_Data(Account &$param_HostAccount, iStorable &$param_iStorable, array &$param_Data);
public function getDOMElement_editSpecial(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, DOMElement &$param_DOMElement, $param_KindOf=null, array $param_DOMElemente=null);
public function setRootTable();
}
abstract class mcPUIX extends mcClass implements imcPUIX {
const DBUIConfig = 'DBUIConfig';
const PUIX_SUB_REFERENCELIST = 'PUIX_SUB_REFERENCELIST';
const PDOValues = 'PDOValues';
const PDOToSaveValues = 'PDOToSaveValues';
const PDO_OR = 'OR';
const PDO_AND = 'AND';
const PDO_XOR = 'XOR';
const PDO_NEW = 'PDO_NEW';
const PDO_NEWID = 'PDO_NEWID';
const PDO_Operator = 'PDO_Operator';
const PDO_Special = 'PDO_Special';
const PDO_Operand = 'PDO_Operand';
const PDO_bindValueArray = 'PDO_bindValueArray';
const PDOLoadDepth = 'PDOLoadDepth';
const PDOLoadDepth_OnlyNew = 'PDOLoadDepth_OnlyNew';
const ERRORMESSAGE ='ERRORMESSAGE';
const DOMmcPUIX = 'mcPUIX';
const DOMmcPUIX_edit = 'DOMmcPUIX_edit';
const DOMmcPUIX_edit_special = 'DOMmcPUIX_edit_special';
const DOMmcPUIX_show = 'DOMmcPUIX_show';
const DOMRow = 'DBUIRow';
const DOMList = 'DBUIList';
const DOMElement = 'DBUIElement';
const DOMValues = 'DOMValues';
##
// PUIXArray evt überprüfen
const PUIXArray = 'PUIXArray';
// const FORMValues = 'DBUIFormValues'; mcPUIX::FORM_DO_ROW
const FORM_POST_VALUES = 'FORM_POST_VALUES';
const FORM_REQUIRED = 'FORM_REQUIRED'; // mcPUIX::FORM_REQUIRED
const FORM_NEW_ROW = 'FORM_NEW_ROW'; // mcPUIX::FORM_NEW_ROW
const FORM_DO_VAR = 'FORM_DO_VAR'; // mcPUIX::FORM_DO_VAR
const FORM_DO_ROW = 'FORM_DO_ROW'; // mcPUIX::FORM_DO_ROW
const FORM_DO_SAVE = 'FORM_DO_SAVE'; // mcPUIX::FORM_DO_SAVE
const FORM_DO_DELETE = 'FORM_DO_DELETE'; // mcPUIX::FORM_DO_DELETE
const FORM_DO_NEW = 'FORM_DO_NEW'; // mcPUIX::FORM_DO_NEW
const FORM_DO_SELECT = 'FORM_DO_SELECT'; // mcPUIX::FORM_DO_SELECT
const FORM_TYPE_SEOLINK = 'FORM_TYPE_SEOLINK';
const FORM_TYPE_BASISELEMENT_SHORT = 'FORM_TYPE_BASISELEMENT_SHORT';
const STATE_LOADED = 'loaded';
const STATE_CHANGED = 'changed';
const STATE_SAVED = 'saved';
private $DBTab_State = array();
protected $RootTable;
/**
*
* @var array('tablename' => array(mcPUIX::PUIXArray => array()))
*/
private $DBTab = array();
/**
*
* @var aBasisElementAddon
*/
protected $PUIXHostObject = null;
public $ThisClassName;
public function __construct( $PUIXHostObject) {
$this->mcID = mcObjectStatistic::getCount__construct($this);
$this->PUIXHostObject = $PUIXHostObject;
$this->ThisClassName = get_class($this);
$this->setRootTable();
}
protected $SearchAttributes = null;
public function setSearchAttributes(array $param_SearchAttributes) {
$this->SearchAttributes = $param_SearchAttributes;
}
private function setTableValues($param_tablename, $param_tablevalues) {
$this->DBTab[$param_tablename] = $param_tablevalues;
}
public function getTableValues($param_tablename) {
return $this->DBTab[$param_tablename];
}
public function loadPDOTable(Account &$param_HostAccount, iStorable &$param_iStorable, $param_SQLWhere='', $param_depth=null) {
$DBTable = mcPUIX_PDO::getTableAsDBUIArray($param_HostAccount, $param_iStorable, $this->RootTable, $this->SearchAttributes, $param_SQLWhere, $param_depth);
if(is_array($DBTable)) {
// D::show($DBTable, '$DBTable');
$this->setTableValues($this->RootTable, $DBTable);
$this->DBTab_State[$this->RootTable] = mcPUIX::STATE_LOADED;
}
}
public function __toString() {
$var_string = parent::__toString();
$var_string .= '-['.$this->PUIXHostObject.']';
return $var_string;
}
/**
*
* @param Account $param_HostAccount
* @param iStorable $param_iStorable
* @param array $param_values -- array(
* get_class($this->PUIXHostObject) => array( // not necessary if $this->PUIXHostObject not exists
* get_class($this) => array(
* mcPUIX::PUIXArray => array(
* mcPUIX::FORM_POST_VALUES => array()
* )
* )
* )
* )
* @return boolean
*/
public function setData(Account &$param_HostAccount, iStorable &$param_iStorable, array $param_values) {
$param_tablename = $this->RootTable;
if(is_object($this->PUIXHostObject)) {
if(mcArray::checkKeyHasFullArray($param_values, get_class($this->PUIXHostObject))) {
$values = $param_values[get_class($this->PUIXHostObject)];
} else {
return false;
}
} else {
$values = $param_values;
}
if(mcArray::checkKeyHasFullArray($values, $this->ThisClassName, mcPUIX::PUIXArray, mcPUIX::FORM_POST_VALUES)) {
$this->manipulatePost_Data($param_HostAccount, $param_iStorable, $values[$this->ThisClassName][mcPUIX::PUIXArray][mcPUIX::FORM_POST_VALUES]);
}
$this->setTableValues($param_tablename, $values[$this->ThisClassName]);
$this->DBTab_State[$param_tablename] = mcPUIX::STATE_CHANGED;
}
public function savePDOTable(Account &$param_HostAccount, iStorable &$param_iStorable) {
D::cf(get_class($this).' '.$this->RootTable);
$param_tablename = $this->RootTable;
$DBUIArray_Values = $this->getTableValues($param_tablename);
// D::show($this->DBTab , '$this->DBTab');
$ManipulateTableConfig = null;
$DBUIConfig = mcPUIX_CONFIG::getTableConfig($param_tablename, $ManipulateTableConfig);
// D::show($DBUIConfig, '$DBUIConfig');
if(mcArray::checkKeyHasFullArray($DBUIConfig, mcPUIX::PUIXArray, mcPUIX::DBUIConfig, $param_tablename, 'TABLE', mcPUIX::PUIX_SUB_REFERENCELIST, 'TABLENAME')) {
$Tablename_LIST = mcPUIX_CONFIG::getReferenceTableName($param_tablename);
$ManipulateTableConfig = null;
$DBUIConfig_LIST = mcPUIX_CONFIG::getTableConfig($Tablename_LIST, $ManipulateTableConfig);
$DBUIConfig[mcPUIX::PUIXArray][mcPUIX::DBUIConfig][$Tablename_LIST] = $DBUIConfig_LIST[mcPUIX::PUIXArray][mcPUIX::DBUIConfig][$Tablename_LIST];
}
// D::show($DBUIArray_Values, $param_tablename);
$PreparedArray = mcPUIX_PDO::prepareArrayForDBOperation($param_tablename, $DBUIConfig, $DBUIArray_Values);
// D::show($PreparedArray, '$PreparedArray = mcPUIX_PDO::prepareArrayForDBOperation');
$DBUIArrayNew = mcPUIX_PDO::updateDatabaseTable($param_HostAccount, $param_iStorable, $DBUIConfig, $PreparedArray);
$this->setTableValues($param_tablename, $DBUIArrayNew);
$this->DBTab_State[$param_tablename] = mcPUIX::STATE_SAVED;
if(is_array($this->SearchAttributes)) {
$this->loadPDOTable($param_HostAccount, $param_iStorable);
}
}
protected function getFormPathToThis() {
$formpath = '';
if(is_object($this->PUIXHostObject)) {
$formpath .= '['.get_class($this->PUIXHostObject).']';
}
$formpath .= '['.$this->ThisClassName.']['.mcPUIX::PUIXArray.']['.mcPUIX::FORM_POST_VALUES.']';
return $formpath;
}
public function getObjDOMElement(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, $param_KindOf=null, array $param_DOMElemente=null) {
$DOMElement = $param_DOMDocument->createElement(mcPUIX::DOMmcPUIX);
$DOMElement->setAttribute('class', get_class($this));
$DOMElement->setAttribute('label', Language::getWord(get_class($this)));
if($param_KindOf==='form') {
$DOMElement_edit = $param_DOMDocument->createElement(mcPUIX::DOMmcPUIX_edit);
$DOMElement_edit->setAttribute('edit', true);
$DOMElement_edit->setAttribute('formpath', $this->getFormPathToThis());
$DOMElement->appendChild($DOMElement_edit);
$this->getDOMElement_edit($param_HostAccount, $param_iStorable, $param_DOMDocument, $DOMElement_edit, $param_KindOf, $param_DOMElemente);
$DOMElement_edit_special = $param_DOMDocument->createElement(mcPUIX::DOMmcPUIX_edit_special);
$this->getDOMElement_editSpecial($param_HostAccount, $param_iStorable, $param_DOMDocument, $DOMElement_edit_special, $param_KindOf, $param_DOMElemente);
$DOMElement_edit->appendChild($DOMElement_edit_special);
}
$DOMElement_show = $param_DOMDocument->createElement(mcPUIX::DOMmcPUIX_show);
$DOMElement->appendChild($DOMElement_show);
$this->getDOMElement_show($param_HostAccount, $param_iStorable, $param_DOMDocument, $DOMElement_show, $param_KindOf, $param_DOMElemente);
return $DOMElement;
}
protected static $unsetCONFIG = true;
public static function setmcPUIX_CONFIG(array $param_Configs) {
if(mcPUIX::$unsetCONFIG) {
foreach($param_Configs as $tablename => $values) {
// D::show($values, $tablename);
mcPUIX_CONFIG::setTableConfig($tablename, $values);
}
mcPUIX::$unsetCONFIG = false;
}
}
protected static $Tables = array ();
public function walk_ListElements(Account &$param_HostAccount, iStorable &$param_iStorable, $param_tablename, array $param_callbackfncForList=null, array $param_callbackfncForListElements=null) {
if(mcArray::checkKeyHasFullArray($this->DBTab, $param_tablename, mcPUIX::PUIXArray, mcPUIX::PDOValues) ) {
//D::show($this->DBTab[$param_tablename][mcPUIX::PUIXArray][mcPUIX::PDOValues], $this);
$callbackfncForList = false;
if(is_array($param_callbackfncForList) && !empty ($param_callbackfncForList)) {
$callbackfncForList = true;
}
$callbackfncForListElements = false;
if(is_array($param_callbackfncForListElements) && !empty ($param_callbackfncForListElements)) {
$callbackfncForListElements = true;
}
foreach($this->DBTab[$param_tablename][mcPUIX::PUIXArray][mcPUIX::PDOValues] as &$ListData) {
if($callbackfncForList) {
foreach($param_callbackfncForList as $fncForList) {
$this->$fncForList($param_HostAccount, $param_iStorable, $ListData);
}
}
foreach($ListData as &$ListElement) {
if($callbackfncForListElements && mcArray::checkKeyHasFullArray($ListElement, mcPUIX::PDOValues)) {
foreach($ListElement[mcPUIX::PDOValues] as $ListElementData) {
foreach($param_callbackfncForListElements as $fncForElements) {
$this->$fncForElements($param_HostAccount, $param_iStorable, $ListData, $ListElementData);
}
}
}
}
}
}
}
}
?>