class_ListCondition.inc.php
22.9 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
<?php
/**
* @file ListCondition.inc.php
* @category freeSN
* @mailto code [at] netz.coop
* @version 0.4.200901
* @link http://netz.coop
*
* @copyright Copyright by netz.coop e.G. 2015
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Diese Klasse erstellt und verarbeitet den Teil der Url, welcher die Bedingungen für das laden der Listenelemente enthält. Gleichzeitig repräsentiert sie die Schnitstelle zu selbst implementierten ListCondition-Funktionen.
*
*/
class ListCondition{
/**
* vorläufiger BlackList String
*/
private static $forbidden = '/[ ;"]/';
/**
* Klassen Array
*/
private static $LinkClassArray = array();
/**
* vorläufiger chr-string für methode chr
*/
private static $LinkChrString = 'abcdefghijklmnopqrstuvwxyz';
/**
* @param Array $param_configArray - Array welcher die parameter des zu erstellen ListLinks enthält (normalerweise aus der config des jeweiligen BCs unter Menu => ListCondition)
* @param Array $param_urlArray - Array, welcher die zusätzlichen informationen aus der aktuellen Url hält
*
* @return Array - hat die Form array( array(ListClass-FncName) => array ( (Columnn => array()), Special => array(), Value => array())
*/
public static function getConditionUrl($param_partOfID, $param_BasisClipboardname, $param_configArray, $param_urlArray=null, $param_direction = false, $param_profileID = false){
$i=0;
foreach($param_configArray as $value){
foreach($value as $key => $value){
$var_linkClass=$key;
/* um says:
überprüfung bei url erstellung gar nicht notwendig, da die daten direkt aus der config kommen!!!
oder sehe ich das falsch?
//erlaube als Klassenparameter nur Buchstaben und Zahlen
if (!preg_match('#^[a-z0-9]+$#i', $var_linkClass)){
return null;
}*/
$returnArray[$i] =array();
foreach($value as $key => $value){
$fnc_name=key($value).'ConditionUrl';
//überprüfe ob klasse existiert
if(!array_key_exists($var_linkClass, self::$LinkClassArray)){
//falls nein, füge Klasse dem $LinkClassArray hinzu
self::$LinkClassArray [$var_linkClass] = new $var_linkClass();
}
//rufe Methode der jeweiligen Klasse auf
$returnArray[$i]=array_merge( $returnArray[$i],self::$LinkClassArray[$var_linkClass] -> $fnc_name($value[key($value)], $param_urlArray));
}
$i++;
}
}
$tmp_c3 = '0';
if($param_direction){
$tmp_c3 .= $param_direction;
}
else{
$tmp_c3 .= '-asc';
}
if($param_profileID){
$tmp_c3 .= $param_profileID;
}
$var_cStart = '&c['.($param_partOfID).']['.$param_BasisClipboardname.']['.$tmp_c3.']';
foreach($returnArray as $key => $value){
$tmp_clink=null;
foreach($value as $key => $value){
$tmp_urlFnc = $var_cStart."[".$key."]";
foreach($value as $key => $value){
$tmp_url = $tmp_urlFnc;
foreach($value as $key => $value){
if ($key != 'Value'){
$tmp_url .= '[';
}
else{
$tmp_url .= '=';
}
foreach($value as $value){
$tmp_url .= $value."-";
}
$tmp_url=substr($tmp_url, 0, -1);
if ($key != 'Value'){
$tmp_url .=']';
}
}
$tmp_clink[] = $tmp_url;
}
}
$var_cLinks[]=$tmp_clink;
}
return $var_cLinks;
}
/**
* the function returns a ConditionArray
*
*
* @param $param_conditions the parameters-conditions from the url for the BC
* @param $param_BasisClipboardname the name of the BasisClipboard
* @return array returns ConditionArray
*/
public static function getConditionArray($param_conditions, $param_BasisClipboardname){
$array_counter=0;
foreach($param_conditions as $key1 => $value1){
if($value1 != null){
foreach($value1 as $key => $value){
$key = explode('-', $key);
$var_linkClass=$key[0];
if(!array_key_exists($var_linkClass, self::$LinkClassArray)){
self::$LinkClassArray [$var_linkClass] = new $var_linkClass();
}
$fnc_name=$key[1].'ConditionArray';
foreach($value as $key2 => $value2){
if($key2[0] == 1){
$param_ConditionArray=self::$LinkClassArray[$var_linkClass] -> $fnc_name(array(ltrim($key2,'1-') => $value2));
}
else{
$param_ConditionArray['secConditionArrays'][$array_counter]=self::$LinkClassArray[$var_linkClass] -> $fnc_name(array($key2 => $value2));
$array_counter++;
}
}
}
}
$key1 = explode('-', $key1);
$param_ConditionArray['limitOf'] = $key1[0];
if(array_key_exists(1,$key1)){
$param_ConditionArray['direction'] = $key1[1];
}
else if($var_direction=CONFIG::get_Condition($param_BasisClipboardname,'direction')){
$param_ConditionArray['direction'] = $var_direction;
}
if(array_key_exists(2,$key1)){
$param_ConditionArray['limit']=$key1[2];
}
else if(CONFIG::getDisplayLimits($param_BasisClipboardname)){
$param_ConditionArray['limit']=CONFIG::getDisplayLimits($param_BasisClipboardname);
}
else{
$param_ConditionArray['limit']=CONFIG::getDisplayLimits('Display');
}
//Condition aus ConfigHolen
if(array_key_exists(2,$key1)){
$param_ConditionArray['partOfID'] = $key1[2];
}
else if($var_partOfID=CONFIG::get_Condition($param_BasisClipboardname,'partOfID')){
$param_ConditionArray['partOfID'] = $var_partOfID;
}
}
return $param_ConditionArray;
}
/**
* BlackList Methode
*
* @param $param_values - Array, der zu prüfenden Strings
*
* @return boolean
*/
private static function isAllowed($param_values){
foreach($param_values as $value){
if (preg_match(self::$forbidden, $value)){
return false;
}
}
return true;
}
/**
* function returns ConditionArray for condition equal (=)
*
* @param Array - ListConditions
* @return Array - ConditonArray
*/
private function equalConditionArray($param_condition){
$temp_ConditionArray['operator']='=';
foreach($param_condition as $key => $value){
$key = explode('-', $key);
//besser config vergleich
//hier spalte
if(self::isAllowed($key)){
$temp_ConditionArray['column']=$key;
}
else{
return null;
}
$tmp_value = explode('-', $value[key($value)]);
//besser whitelist -> problem der vergleichswert
if(self::isAllowed($tmp_value)){
$temp_ConditionArray['from']=$tmp_value;
}
else{
return null;
}
$tmp_special = explode('-', key($value));
if(count($tmp_special)>1){
$temp_ConditionArray['from'][0]=self::calculateSpecialValue($tmp_special, $temp_ConditionArray['from'][0],false);
}
}
$temp_ConditionArray['nexus'] = 'AND';
return $temp_ConditionArray;
}
/**
* function returns ConditionArray for condition not (!=)
*
* @param Array $param_condition
* @return Array - ConditionArray
*/
private function notConditionArray($param_condition){
$temp_ConditionArray=self::equalConditionArray($param_condition);
$temp_ConditionArray['operator']='!=';
return $temp_ConditionArray;
}
/**
* function returns ConditionArray for condition less (<=)
*
* @param Array $param_condition
* @return Array - ConditionArray
*/
private function lessConditionArray($param_condition){
$temp_ConditionArray=self::equalConditionArray($param_condition);
$temp_ConditionArray['operator']='<=';
return $temp_ConditionArray;
}
/**
* function returns ConditionArray for condition larger (>=)
*
* @param Array $param_condition
* @return Array - ConditionArray
*/
private function largerConditionArray($param_condition){
$temp_ConditionArray=self::equalConditionArray($param_condition);
$temp_ConditionArray['operator']='>=';
return $temp_ConditionArray;
}
/**
* function returns ConditionArray for condition is in
*
* @param Array $param_condition
* @return Array - ConditionArray
*/
private function inConditionArray($param_condition){
$temp_ConditionArray=self::equalConditionArray($param_condition);
$temp_ConditionArray['operator']='LIKE';
foreach($temp_ConditionArray['from'] as $key => $value){
$temp_ConditionArray['from'][$key] = '%'.$value.'%';
}
return $temp_ConditionArray;
}
/**
* function returns ConditionArray for condition starts with
*
* @param Array $param_condition
* @return Array - ConditionArray
*/
private function startConditionArray($param_condition){
$temp_ConditionArray=self::equalConditionArray($param_condition);
$temp_ConditionArray['operator']='LIKE';
foreach($temp_ConditionArray['from'] as $key => $value){
$temp_ConditionArray['from'][$key] = $value.'%';
}
return $temp_ConditionArray;
}
/**
* function returns ConditionArray for condition ends with
*
* @param Array $param_condition
* @return Array - ConditionArray
*/
private function endConditionArray($param_condition){
$temp_ConditionArray=self::equalConditionArray($param_condition);
$temp_ConditionArray['operator']='LIKE';
foreach($temp_ConditionArray['from'] as $key => $value){
$temp_ConditionArray['from'][$key] = '%'.$value;
}
return $temp_ConditionArray;
}
/**
* function returns ConditionArray for condition between
*
* @param Array $param_condition
* @return Array - ConditionArray
*/
private function betweenConditionArray($param_condition){
$temp_ConditionArray['operator']='BETWEEN';
foreach($param_condition as $key => $value){
$key = explode('-', $key);
//spalte
if(self::isAllowed($key)){
$temp_ConditionArray['column']=$key;
}
else{
return null;
}
$tmp_value = explode('-', $value[key($value)]);
if(self::isAllowed($tmp_value)){
$temp_ConditionArray['from']=$tmp_value;
}
else{
return null;
}
$tmp_special = explode('-', key($value));
if(count($tmp_special)>1){
$temp_ConditionArray['from'][1]=self::calculateSpecialValue($tmp_special, $temp_ConditionArray['from'][0],false);
if($temp_ConditionArray['from'][1]<$temp_ConditionArray['from'][0]){
$tmp_help=$temp_ConditionArray['from'][1];
$temp_ConditionArray['from'][1]=$temp_ConditionArray['from'][0];
$temp_ConditionArray['from'][0]=$tmp_help;
}
}
}
return $temp_ConditionArray;
}
/**
* function returns ConditionArray for condition term
*
* @param Array $param_condition
* @return Array - ConditionArray
*/
private function termConditionArray($param_condition){
$temp_ConditionArray=self::betweenConditionArray($param_condition);
$temp_ConditionArray['operator']='TERM';
return $temp_ConditionArray;
}
/**
* Methode gibt die Url für einen ConditionArray wieder
* !!!Achtung unvollständig!!!
* bisher implementiert:
* - limitOf
* - operator <,>,=
* - column
* - from
*
* @param array param_array
*
* @return String
*/
public static function tranformConditionToUrl($param_partOfID, $param_BasisClipboardname, $param_array){
$returnString = '';
if(array_key_exists('limitOf',$param_array) && ($param_array['limitOf'] > 0 || (array_key_exists('column',$param_array) && array_key_exists('operator',$param_array)))){
$returnString .= '&c['.($param_partOfID).']['.$param_BasisClipboardname.']['.$param_array['limitOf'].']';
if(array_key_exists('operator',$param_array)){
$returnString .= '[ListCondition-';
switch($param_array['operator']){
case '=' : {
$returnString .= 'equal]';
break;
}
case '!=' : {
$returnString .= 'not]';
break;
}
case '>' : {
$returnString .= 'larger]';
break;
}
case '<' : {
$returnString .= 'less]';
break;
}
case 'TERM' : {
$returnString .= 'TERM]';
break;
}
default : {break;}
}
}
if(array_key_exists('column',$param_array)){
$returnString .= '[1-';
foreach($param_array['column'] as $key => $value){
$returnString .= $value.'-';
}
// $returnString = substr($returnString, 0, -1).'][1]';
$returnString = substr($returnString, 0, -1).'][1]';
}
if(array_key_exists('from',$param_array)){
$returnString .= '=';
foreach($param_array['from'] as $key => $value){
$returnString .= $value.'-';
}
$returnString = substr($returnString, 0, -1);
}
}
return $returnString;
}
/**
* Hilfsmethode, welche den UrlteilArray ins richtige format für die Methode getConditionsUrl parst
*/
public static function tranformToListArray($param_array){
foreach($param_array as $keyFnc => $value){
foreach($value as $keyCol => $value){
$keyCol = explode('-', $keyCol);
foreach($value as $keySpecial => $value){
$keySpecial = explode('-', $keySpecial);
$value = explode('-', $value);
$var_cNew[$keyFnc][] = array('Column' => $keyCol, 'Special' => $keySpecial, 'Value' => $value);
}
}
}
return $var_cNew;
}
/**
* @param_fncName - String
* @param $param_configConditions - Array
* @param $param_urlConditions - Array
*
* @return boolean
*/
private static function checkColumnMatch($param_fncName, $param_configConditions, $param_urlConditions){
foreach($param_urlConditions[$param_fncName] as $key => $value){
if(array_key_exists('Column', $value)){
//prüfung ob gleich Columns
if(serialize($value['Column'])===serialize($param_configConditions['Column'])){
if(array_key_exists('Special',$param_configConditions) && count($param_configConditions['Special'])>1 ){
//calculate special
if(array_key_exists('Value', $value)){
$param_urlConditions[$param_fncName][$key]['Value']=self::calculateSpecialValue($param_configConditions['Special'], $value['Value'][0]);
return true;
}
else{
$param_urlConditions[$param_fncName][$key]['Value']=self::calculateSpecialValue($param_configConditions['Special']);
return true;
}
}
else if(array_key_exists('Value', $value)){
//adde auf jeden url value config value
if(array_key_exists('Special', $param_configConditions) && $param_configConditions['Special'][0] !=1 ){
foreach($param_configConditions['Value'] as $valueKey => $value){
$param_urlConditions[$param_fncName][$key]['Value'][$valueKey] += (-1 + $param_configConditions['Special'][0])*$value;
return true;
}
}
//only change value
else{
$param_urlConditions[$param_fncName][$key]['Value'] = $param_configConditions['Value'];
return true;
}
}
}
}
}
}
/**
* @param $param_column - String
* @param $param_urlConditions - Array
*/
private static function killSameColumns($param_column, &$param_urlConditions){
foreach($param_urlConditions as $key1 => $value){
foreach($value as $key2 => $value){
if(serialize($value['Column'])===serialize($param_column)){
unset($param_urlConditions[$key1][$key2]);
}
}
}
$param_urlConditions = array_filter($param_urlConditions);
}
private static function easyOperator($param_fncName, $param_configConditions, $param_urlConditions){
//D::show($param_configConditions, 'configC');
//D::show($param_urlConditions, 'urlC');
if(!array_key_exists('Special', $param_configConditions)){
$param_configConditions['Special'] = array (0 => 1);
ksort($param_configConditions);
}
//hilfs var
$var_sameColumn=false;
if(is_array($param_urlConditions) && array_key_exists($param_fncName, $param_urlConditions)){
$tmp_urlConditions[$param_fncName]=$param_urlConditions[$param_fncName];
foreach($param_urlConditions[$param_fncName] as $key => $value){
if(array_key_exists('Column', $value)){
//prüfung ob gleich Columns und nicht constant
if(serialize($value['Column'])===serialize($param_configConditions['Column'])){
$var_sameColumn=true;
if( $value['Special'][0] != 1
&& $param_configConditions['Special'][0] != 1
&& count($param_configConditions['Special'])>1
){
//calculate special
if(array_key_exists('Value', $value)){
$tmp_urlConditions[$param_fncName][$key]['Value']=self::calculateSpecialValue($param_configConditions['Special'], $value['Value'][0]);
}
else{
$tmp_urlConditions[$param_fncName][$key]['Value']=self::calculateSpecialValue($param_configConditions['Special']);
}
$tmp_urlConditions[$param_fncName][$key]['Special']=$param_configConditions['Special'];
}
else if(array_key_exists('Value', $value)){
//adde auf jeden url value config value
if(array_key_exists('Special', $param_configConditions) && $param_configConditions['Special'][0] !=1 ){
foreach($param_configConditions['Value'] as $valueKey => $value){
$tmp_urlConditions[$param_fncName][$key]['Value'][$valueKey] += ($param_configConditions['Special'][0]-1)*$value;
}
}
//only change value
else{
$tmp_urlConditions[$param_fncName][$key]['Value'] = $param_configConditions['Value'];
}
}
}
}
}
$param_urlConditions=$tmp_urlConditions;
/*if(!self::checkColumnMatch($param_fncName, $param_configConditions, &$param_urlConditions)){
if(array_key_exists('Special',$param_configConditions) && count($param_configConditions['Special'])>1 ){
//calculate special value
$param_urlConditions[$param_fncName][]=array('Column' => $param_configConditions['Column'], 'Special' => $param_configConditions['Special'], 'Value' => self::calculateSpecialValue($param_configConditions['Special']));
}
else{
$param_urlConditions[$param_fncName][]=$param_configConditions;
}
}
D::show($param_urlConditions, 'purlc');*/
}
if(!$var_sameColumn){
if(is_array($param_urlConditions)){
//wenn killSameColumns unstatt unset, links werden kombiniert
//self::killSameColumns($param_configConditions['Column'], &$param_urlConditions);
//new @non 23.02.
unset($param_urlConditions);
}
if(array_key_exists('Special',$param_configConditions) && count($param_configConditions['Special'])>1 ){
$param_configConditions['Value']=self::calculateSpecialValue($param_configConditions['Special']);
}
$param_urlConditions[$param_fncName][]=$param_configConditions;
}
return $param_urlConditions;
}
private function equalConditionUrl($param_configConditions, $param_urlConditions){
return self::easyOperator('ListCondition-equal',$param_configConditions, $param_urlConditions);
}
private function lessConditionUrl($param_configConditions, $param_urlConditions){
return self::easyOperator('ListCondition-less',$param_configConditions, $param_urlConditions);
}
private function largerConditionUrl($param_configConditions, $param_urlConditions){
return self::easyOperator('ListCondition-larger',$param_configConditions, $param_urlConditions);
}
private function betweenConditionUrl($param_configConditions, $param_urlConditions){
return self::easyOperator('ListCondition-between',$param_configConditions, $param_urlConditions);
}
private function termConditionUrl($param_configConditions, $param_urlConditions){
return self::easyOperator('ListCondition-term',$param_configConditions, $param_urlConditions);
}
private function inConditionUrl($param_configConditions, $param_urlConditions){
return self::easyOperator('ListCondition-in',$param_configConditions, $param_urlConditions);
}
private function startConditionUrl($param_configConditions, $param_urlConditions){
return self::easyOperator('ListCondition-start',$param_configConditions, $param_urlConditions);
}
private function endConditionUrl($param_configConditions, $param_urlConditions){
return self::easyOperator('ListCondition-end',$param_configConditions, $param_urlConditions);
}
//aus ermangelung von zeit noch nicht getetstet, wird schnellst möglich nachgeholt (um)
public static function calculateSpecialValue($param_special, $param_oldValue=null, $param_first=true){
switch($param_special[1]){
case 'chr' : {
if($param_oldValue == null){
return array('Value' =>substr(self::$LinkChrString,0,1));
}
else{
$pos = stripos(self::$LinkChrString, $param_oldValue);
$pos = $pos+(($param_special[0]-1)*$param_special[2]);
if($pos > strlen(self::$LinkChrString)-1){
return array('Value' =>substr($LinkChrString,strlen(self::$LinkChrString)-1,1));
}
else if($pos<0){
return array('Value' =>substr($LinkChrString,0,1));
}
else{
return array('Value' =>substr($LinkChrString,$pos,1));
}
}
}
case 'int' : {
if($param_oldValue == null){
if($param_first){
return array('Value' => (0));
}
else{
return array('Value' =>($param_special[0]-1)*$param_special[2]);
}
}
else{
return array('Value' => $param_oldValue+(($param_special[0]-1)*$param_special[2]));
}
}
case 'month42':{
if($param_oldValue == null){
$var_oldValue=time();
}
else{
$var_oldValue=$param_oldValue;
}
//jahr
$var_year = date('Y', $var_oldValue);
//monat
$var_month = date('n', $var_oldValue);
if($param_oldValue != null){
if($param_first){
$var_month +=1;
}
}
if($param_first){
$var_month += (($param_special[0]-1) * ($param_special[2]));
}
else if($param_special[0]!=1){
$var_month += ($param_special[2]);
}
$startWDay = date('N', mktime(0, 0, 0, $var_month , 0, $var_year)); //wochentagNummer des ersten tages im Monat
$var_minus=$startWDay-1;
// berechnung der zusätzlichen tagen
if($startWDay==0){
if(date('d')<15){
$var_minus=6;
}
}
$var_day = -$var_minus;
if(!$param_first){
$var_day += 42;
}
if($param_first){
return array('Value' => mktime(0, 0, 0, $var_month, $var_day, $var_year));
}
else{
return mktime(0, 0, -1, $var_month, $var_day, $var_year);
}
}
case ($param_special[1] == 'month' || $param_special[1] == 'week' || $param_special[1] == 'day'):{
if($param_oldValue == null){
$param_oldValue=time();
}
//jahr
$var_year = date('Y', $param_oldValue);
//monat
$var_month = date('n', $param_oldValue);
//tag
$var_day = date('j', $param_oldValue);
switch($param_special[1]){
case 'month': {
$var_month += (($param_special[0]-1) * $param_special[2]);
$var_day = 1;
break;
}
case 'week' : {
$var_day += (($param_special[0]-1) * $param_special[2] * 7);
break;
}
case 'day' : {
if(array_key_exists(2, $param_special)) {
$var_day += (($param_special[0]-1) * $param_special[2]);
}
break;
}
}
if($param_first){
return array('Value' => mktime(0, 0, 0, $var_month, $var_day, $var_year));
}
else{
return mktime(0, 0, -1, $var_month, $var_day, $var_year);
}
}
default : {
D::li($param_special[1], 'wird nicht abgefangen');
}
}
}
}
?>