This repository has been archived by the owner on Nov 19, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fe_adminLib.php
3769 lines (3425 loc) · 174 KB
/
fe_adminLib.php
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
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2005 Kasper Skaarhoj ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project 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 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* FE admin lib
*
* $Id: fe_adminLib.inc,v 1.19 2005/04/01 14:37:14 typo3 Exp $
* Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
*
* @author Kasper Skaarhoj <[email protected]>
* @modified by Christophe BALISKY <[email protected]>
*/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*
*
*
* 138: class user_feAdmin extends tslib_pibase
* 189: function init($content,$conf)
*
* SECTION: Data processing
* 450: function parseValues()
* 549: function processFiles($cmdParts,$theField)
* 682: function overrideValues()
* 698: function defaultValues()
* 717: function evalValues()
* 842: function userProcess($mConfKey,$passVar)
* 860: function userProcess_alt($confVal,$confArr,$passVar)
* 879: function MetaDBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0, &$mmTable)
* 925: function DBmayFEUserEditSelectMM($table,$fe_user,$allowedGroups,$fe_userEditSelf, &$mmTable)
* 944: function DBmayFEUserEditSelect($table,$fe_user,$allowedGroups,$fe_userEditSelf, &$mmTable)
* 964: function DBmayFEUserEdit($table,$origArr,$fe_user,$allowedGroups,$fe_userEditSelf)
*
* SECTION: Database manipulation functions
* 986: function save()
* 1055: function deleteRecord()
* 1085: function deleteFilesFromRecord($uid)
*
* SECTION: Command "display" functions
* 1142: function displayDeleteScreen()
* 1170: function displayCreateScreen()
* 1194: function displayListScreen($TABLES,$DBSELECT)
* 1194: function displayGridScreen($TABLES,$DBSELECT)
* 1194: function displayCalendarScreen($TABLES,$DBSELECT)
* 1282: function displayEditScreen()
* 1377: function procesSetFixed()
*
* SECTION: Template processing functions
* 1466: function removeRequired($templateCode,$failure)
* 1484: function getPlainTemplate($key,$r='')
* 1501: function modifyDataArrForFormUpdate($inputArr)
* 1569: function setCObjects($templateCode,$currentArr=array(),$markerArray='',$specialPrefix='')
*
* SECTION: Emailing
* 1631: function sendInfoMail()
* 1679: function compileMail($key, $DBrows, $recipient, $setFixedConfig=array())
* 1725: function sendMail($recipient, $admin, $content='', $adminContent='')
* 1770: function isHTMLContent($c)
* 1791: function sendHTMLMail($content,$recipient,$dummy,$fromEmail,$fromName,$replyTo='')
*
* SECTION: Various helper functions
* 1875: function aCAuth($r)
* 1889: function authCode($r,$extra='')
* 1915: function setfixed($markerArray, $setfixed, $r)
* 1954: function setfixedHash($recCopy,$fields='')
* 1980: function isPreview()
* 1989: function createFileFuncObj()
* 2000: function clearCacheIfSet()
* 2015: function getFailure($theField, $theCmd, $label)
*
* TOTAL FUNCTIONS: 38
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php'); // For use with images.
require_once(PATH_tslib.'class.tslib_pibase.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_srfeuserregister_pi1_urlvalidator.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_lib.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_grid.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_ajax.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_calendar.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_export.php');
if (t3lib_extMgm::isLoaded('fpdf')) require_once(t3lib_extMgm::extPath('fpdf').'class.tx_fpdf.php');
/**
* This library provides a HTML-template file based framework for Front End creating/editing/deleting records authenticated by email or fe_user login.
* It is used in the extensions "direct_mail_subscription" and "feuser_admin" (and the depreciated(!) static template "plugin.feadmin.dmailsubscription" and "plugin.feadmin.fe_users" which are the old versions of these two extensions)
* Further the extensions "t3consultancies" and "t3references" also uses this library but contrary to the "direct_mail_subscription" and "feuser_admin" extensions which relies on external HTML templates which must be adapted these two extensions delivers the HTML template code from inside.
* Generally the fe_adminLib appears to be hard to use. Personally I feel turned off by all the template-file work involved and since it is very feature rich (and for that sake pretty stable!) there are lots of things that can go wrong - you feel. Therefore I like the concept used by "t3consultancies"/"t3references" since those extensions uses the library by supplying the HTML-template code automatically.
* Suggestions for improvement and streamlining is welcome so this powerful class could be used more and effectively.
*
* @author Kasper Skaarhoj <[email protected]>
* @package TYPO3
* @subpackage tslib
* @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=396&cHash=d267c36546
*/
class tx_metafeedit_user_feAdmin extends tslib_pibase {
// External, static:
var $recInMarkersHSC = TRUE; // If true, values from the record put into markers going out into HTML will be passed through htmlspecialchars()!
var $prefixId = "tx_metafeedit"; // Same as class name
var $dataArr = array();
var $extKey='tx_metafeedit';
var $failureMsg = array();
var $theTable = '';
var $thePid = 0;
var $markerArray = array();
var $templateCode='';
var $cObj;
var $cmd;
var $preview;
var $backURL;
var $recUid;
var $feData=array();
var $metafeeditlib;
var $metafeeditgrid;
/**
*
* @var tx_metafeedit_export
*/
var $metafeeditexport;
var $print='';
var $exporttype=0;
var $value =10; // ??? kesako
//var $performanceaudit; // performance audit flag
var $perfArray= array();
var $originUid;
var $originTable;
var $originUidsField;
var $failure=0; // is set if data did not have the required fields set.
var $error='';
var $saved=0; // is set if data is saved
var $requiredArr;
var $currentArr = array();
var $LOCAL_LANG;
var $previewLabel='';
var $nc = ''; // '&no_cache=1' if you want that parameter sent.
var $additionalUpdateFields='';
var $emailMarkPrefix = 'EMAIL_TEMPLATE_';
var $codeLength;
var $cmdKey;
var $blogFieldList;
var $fileFunc=''; // Set to a basic_filefunc object
var $filesStoredInUploadFolders=array(); // This array will hold the names of files transferred to the uploads/* folder if any. If the records are NOT saved, these files should be deleted!! Currently this is not working!
// Internal vars, dynamic:
var $unlinkTempFiles = array(); // Is loaded with all temporary filenames used for upload which should be deleted before exit...
/**
*
* @var Tx_ArdMcm_Core_LanguageHandler
*/
var $langHandler=null;
/**
* Main function. Called from TypoScript.
* This
* - initializes internal variables,
* - fills in the markerArray with default substitution string
* - saves/emails if such commands are sent
* - calls functions for display of the screen for editing/creation/deletion etc.
*
* @param string Empty string, ignore.
* @param array TypoScript properties following the USER_INT object which uses this library
* @return string HTML content
* @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=396&cHash=d267c36546
*/
//function user_init($content,&$conf) {
function user_init($content,$conf) {
//error_log(__METHOD__."start ================".$GLOBALS['TSFE']->lang);
$DEBUG='';
//error_log(__METHOD__.":>>>".print_r($conf['LOCAL_LANG'],true));
if ( $conf['ajax.']['ajaxOn'] || $conf['list.']['advancedSearchAjaxSelector'] || is_array($conf['list.']['advancedSearchAjaxSelector.'])) {
$ajax = t3lib_div::makeInstance('tx_metafeedit_ajax');
$ajax->init($this,$conf);
}
$this->cObj=$GLOBALS['TSFE']->cObj;
$this->conf = &$conf;
if (is_object($conf['caller'])) {
$this->metafeeditlib=$conf['caller']->metafeeditlib;
} else {
// We are called by USER_INT function ...
$this->metafeeditlib=t3lib_div::makeInstance('tx_metafeedit_lib');
}
//error_log(__METHOD__."start ================".$this->metafeeditlib->getMemoryUsage());
$this->metafeeditlib->feadminlib=&$this;
$this->metafeedit=t3lib_div::makeInstance('tx_metafeedit'); //CBY WHY ????
//new export class (do we need to load this here ?)...Only in export mode ...
$this->metafeeditexport=t3lib_div::makeInstance('tx_metafeedit_export');
$this->metafeeditexport->init($this);
if (t3lib_extmgm::isLoaded('ard_mcm')) {
$this->langHandler = t3lib_div::makeInstance('Tx_ArdMcm_Core_LanguageHandler', null, 'ard_mcm');
}
// We should handle here all GET//POST//PIVARS ... should be in pi1
$this->pi_setPiVarDefaults();
$this->conf['piVars']=$this->piVars;
if ($this->conf['general.']['listMode']==2) {
$this->metafeeditgrid=t3lib_div::makeInstance('tx_metafeedit_grid');
$this->metafeeditgrid->init($this->metafeeditlib,$this);
}
if ($conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Init ']=strlen(serialize($conf))." Bytes";
if ($conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Conf before init size ']=$this->metafeeditlib->displaytime()." Seconds";
// template file is fetched.
$this->templateCode = $this->conf['templateContent']; //? $this->conf['templateContent']: $this->cObj->fileResource($this->conf['templateFile']);
// Checking template file
if (!$this->templateCode) {
$content = 'No template file found : '.$this->conf['templateFile'];
return $content;
}
// get table
$this->theTable = $this->conf['table'];
// Getting the cmd var
$this->cmd = (string)$this->conf['inputvar.']['cmd'];
// Getting the preview var
$this->preview = $this->conf['inputvar.']['preview'];
//error_log(__METHOD__.":Preview");
// Preview mode is forced also if edit mode is disabled but edit preview mode active
if (!$this->preview) $this->preview=$this->conf['disableEdit']&&$this->conf[$this->conf['inputvar.']['cmd'].'.']['preview'] && ($this->conf['inputvar.']['cmd']=='edit'|| $this->conf['inputvar.']['cmd']=='create');
//error_log(__METHOD__.":$this->preview, ".$this->conf['inputvar.']['cmd'].",". $this->conf[$this->conf['inputvar.']['cmd'].'.']['preview']);
// backURL is a given URL to return to when login is performed
// this should be a seperate function ...
$this->backURL = $this->conf['inputvar.']['backURL'][$conf['pageType']];
// Uid to edit:
if ($this->conf['inputvar.']['rU'] && $conf['inputvar.']['cmd']!='list') $this->recUid = $this->conf['inputvar.']['rU'];
// Fe User Fields
$this->fUField = $this->conf['fUField']?$this->conf['fUField']:t3lib_div::_GP('fUField['.$this->conf['pluginId'].']');
$this->fUKeyField = $this->conf['fUKeyField']?$this->conf['fUKeyField']:t3lib_div::_GP('fUKeyField['.$this->conf['pluginId'].']');
$this->fU = $this->conf['fU']?$this->conf['fU']:t3lib_div::_GP('fU['.$this->conf['pluginId'].']');
$this->conf['recUid']=$this->recUid;
$this->conf['originUid'] = $this->conf['originUid']?$this->conf['originUid']:t3lib_div::_GP('oU');
$this->conf['originTable'] = $this->conf['originTable']?$this->conf['originTable']:t3lib_div::_GP('oUTable');
$this->conf['originUidsField'] = $this->conf['originUidsField']?$this->conf['originUidsField']:t3lib_div::_GP('oUField');
$this->conf['originKeyField'] = $this->conf['originKeyField']?$this->conf['originKeyField']:t3lib_div::_GP('oUKeyField');
// *****************
// order by handling , is this usefull ?
// *******************
if ($this->conf['inputvar.']['orderDir']==1 && !$this->preview && !$conf['inputvar.']['doNotSave']) { // Delete record if delete command is sent + the preview flag is NOT set.
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc order start:']=$this->metafeeditlib->displaytime()." Seconds";
$this->orderRecord();
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc order end:']=$this->metafeeditlib->displaytime()." Seconds";
}
// Authentication code:
$this->authCode = t3lib_div::_GP('aC');
$this->nc = $this->conf['cacheMode']==0 ? '&no_cache=1' : $this->nc;
// pid
$this->thePid = intval($this->conf['pid']) ? intval($this->conf['pid']) : $GLOBALS['TSFE']->id;
if ($conf['debug']) echo Tx_MetaFeedit_Lib_ViewArray::viewArray(array('thePid '=>$this->thePid ));
//
$this->codeLength = intval($this->conf['authcodeFields.']['codeLength']) ? intval($this->conf['authcodeFields.']['codeLength']) : 8;
$this->LOCAL_LANG=$conf['LOCAL_LANG'];
// Setting the hardcoded lists of fields allowed for editing and creation.
$this->metafeeditlib->getFieldList($this->conf);
if (!$this->theTable || !$this->conf['fieldList']) {
$content = 'Wrong table: '.$this->theTable.', Fields : '.$this->conf['fieldList'];
return $content; // Not listed or editable table!
}
$fArr=t3lib_div::trimexplode(',',$this->conf['fieldList']);
foreach($fArr as $fN) {
if (in_array(substr($fN,0,11),array('--div--;Tab','--fsb--;FSB','--fse--;FSE'))) continue;
$this->markerArray['###EVAL_ERROR_FIELD_'.$fN.'###']='';
$this->markerArray['###CSS_ERROR_FIELD_'.$fN.'###']='';
$this->markerArray['###FIELD_EVAL_'.$fN.'###']='';
$this->markerArray['###EVAL_ERROR_FIELD_'.str_replace('.','_',$fN).'###']='';
$this->markerArray['###CSS_ERROR_FIELD_'.str_replace('.','_',$fN).'###']='';
$this->markerArray['###FIELD_EVAL_'.str_replace('.','_',$fN).'###']='';
if ( $GLOBALS['TCA'][$this->theTable]['columns'][$fN]['config']['type']=='group') {
if ($GLOBALS['TCA'][$this->theTable]['columns'][$fN]['config']['internal_type']=='file') {
$this->markerArray['###EVAL_ERROR_FIELD_'.$fN.'_file###']='';
$this->markerArray['###CSS_ERROR_FIELD_'.$fN.'_file###']='';
}
$this->markerArray['###FIELD_EVAL_'.$fN.'###']='';
}
}
//Si blog
$fbArr=t3lib_div::trimexplode(',',$this->conf['blogFieldList']);
foreach($fbArr as $fN) {
if (in_array(substr($fN,0,11),array('--div--;Tab','--fsb--;FSB','--fse--;FSE'))) continue;
$this->markerArray['###EVAL_ERROR_FIELD_'.$fN.'###']='';
$this->markerArray['###CSS_ERROR_FIELD_'.$fN.'###']='';
//$this->markerArray['###FIELD_EVAL_'.$fN.'###']='';
if ( $GLOBALS['TCA'][$this->theTable]['columns'][$fN]['config']['type']=='group') {
if ($GLOBALS['TCA'][$this->theTable]['columns'][$fN]['config']['internal_type']=='file') {
$this->markerArray['###EVAL_ERROR_FIELD_'.$fN.'_file###']='';
$this->markerArray['###CSS_ERROR_FIELD_'.$fN.'_file###']='';
}
$this->markerArray['###FIELD_EVAL_'.$fN.'###']='';
}
}
// globally substituted markers, fonts and colors.
$splitMark = md5(microtime());
list($this->markerArray['###GW1B###'],$this->markerArray['###GW1E###']) = explode($splitMark,$this->cObj->stdWrap($splitMark,$this->conf['wrap1.']));
list($this->markerArray['###GW2B###'],$this->markerArray['###GW2E###']) = explode($splitMark,$this->cObj->stdWrap($splitMark,$this->conf['wrap2.']));
$this->markerArray['###GC1###'] = $this->cObj->stdWrap($this->conf['color1'],$this->conf['color1.']);
$this->markerArray['###GC2###'] = $this->cObj->stdWrap($this->conf['color2'],$this->conf['color2.']);
$this->markerArray['###GC3###'] = $this->cObj->stdWrap($this->conf['color3'],$this->conf['color3.']);
// Initialize markerArray, setting FORM_URL and HIDDENFIELDS
$formid=$GLOBALS['TSFE']->id;
$formType=$GLOBALS['TSFE']->type;
if ($this->conf['createPid']) { $formid=$this->conf['createPid']; }
if ($this->conf['editPid'] && $this->conf['inputvar.']['cmd']=='edit') { $formid=$this->conf['editPid']; }
// we handle Global parameters for links from other page
$this->markerArray['###GLOBALPARAMS###']='';
$this->markerArray['###GLOBALPARAMS###'].=t3lib_div::_GP('eID')?'&eID='.t3lib_div::_GP('eID'):'';
$this->markerArray['###GLOBALPARAMS###'].=t3lib_div::_GP('config')?'&config='.t3lib_div::_GP('config'):'';
$this->markerArray['###GLOBALPARAMS###'].=t3lib_div::_GP('module')?'&module='.t3lib_div::_GP('module'):'';
$this->markerArray['###GLOBALPARAMS###'].=$this->piVars['title']?'&tx_metafeedit[title]='.$this->piVars['title']:'';
$this->markerArray['###GLOBALPARAMS###'].=$this->piVars['referer'][$this->conf['pluginId']]?'&tx_metafeedit[referer]['.$this->conf['pluginId'].']='.rawurlencode($this->piVars['referer'][$this->conf['pluginId']]):'';
$this->conf['GLOBALPARAMS']=$this->markerArray['###GLOBALPARAMS###'];
$prma=array();
if ($this->nc) $prma['no_cache']=1;
//We handle page type here
if ($formType != 0) $formid .=','.$formType;
$pl=$this->pi_getPageLink($formid,'',$prma);//,,$this->nc.$this->conf['addParams']);
if (!strpos($pl,'?')) $pl.='?';
//$pl=$this->metafeeditlib->hsc($this->conf,$pl);
$this->markerArray['###FORM_URL###'] = $this->metafeeditlib->hsc($this->conf,$pl.$this->markerArray['###GLOBALPARAMS###']);
$this->markerArray['###FORM_URL_NO_PRM###']=$this->metafeeditlib->hsc($this->conf,$pl.$this->markerArray['###GLOBALPARAMS###']);
$this->markerArray['###FORM_URL_ENC###'] = rawurlencode($this->markerArray['###FORM_URL###']);
$this->markerArray['###FORM_URL_HSC###'] = htmlspecialchars($pl.$this->markerArray['###GLOBALPARAMS###']);
$this->markerArray['###NEW_URL###']=$this->metafeeditlib->hsc($this->conf,$this->pi_getPageLink($formid,'',array( 'no_cache'=>1, 'cmd['.$this->conf['pluginId'].']'=>'create', 'rU['.$this->conf['pluginId'].']' => '', 'backURL['.$this->conf['pluginId'].']'=> $pl)));
$this->markerArray['###BACK_URL###'] = $this->metafeeditlib->hsc($this->conf,$this->backURL.$this->markerArray['###GLOBALPARAMS###']);
$this->markerArray['###BACK_URL_ENC###'] = rawurlencode($this->markerArray['###BACK_URL###']);
$this->markerArray['###BACK_URL_HSC###'] = htmlspecialchars($this->backURL.$this->markerArray['###GLOBALPARAMS###']);
$this->markerArray['###EVAL_ERROR###'] = '';
$this->markerArray['###THE_PID###'] = $this->thePid;
$this->markerArray['###AUTH_CODE###'] = $this->authCode;
$this->markerArray['###THIS_ID###'] = $GLOBALS['TSFE']->id;
$this->markerArray['###THIS_URL###'] = htmlspecialchars(t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR'));
$this->markerArray['###HTTP_HOST###'] = $_SERVER["HTTP_HOST"];
$FEUSER=$GLOBALS['TSFE']->fe_user->user;
if (!is_array($FEUSER)) $FEUSER=array();
$this->markerArray = $this->cObj->fillInMarkerArray($this->markerArray, $FEUSER, '', TRUE, 'FEUSER_FIELD_', $this->conf['general.']['xhtml']);
// Setting cmdKey which is either 'edit' or 'create'
switch($this->conf['inputvar.']['cmd']) {
case 'list':
$this->conf['cmdKey']='list';
$this->conf['cmdmode']='list';
break;
case 'edit':
$this->conf['cmdKey']='edit';
$this->conf['cmdmode']='edit';
break;
default:
$this->conf['cmdKey']='create';
$this->conf['cmdmode']='edit';
break;
}
$pluginId=$conf['pluginId'];
$this->markerArray['###HIDDENFIELDS###'] =
($this->authCode?'<input type="hidden" name="aC['.$pluginId.']" value="'.htmlspecialchars($this->authCode).'" />':'').
($conf['blogData']?'<input type="hidden" name="cameFromBlog['.$pluginId.']" value="1" />':'');
// Setting requiredArr to the fields in 'required' intersected field the total field list in order to remove invalid fields.
$this->requiredArr = array_intersect(
t3lib_div::trimExplode(',',$this->conf[$this->conf['cmdKey'].'.']['required'],1),
t3lib_div::trimExplode(',',$this->conf[$this->conf['cmdKey'].'.']['fields'],1)
);
// Setting incoming data. Non-stripped
$this->feData=$fe=$conf['inputvar.']['fedata'];
//if ($conf['inputvar.']['cmd']!='list' || $conf['general.']['listMode']==2) $this->dataArr=$fe[$this->theTable]; // Incoming data.
//We take incoming data if we are not in list mode or submit is save...TODO must be improved
if ($conf['inputvar.']['cmd']!='list' || $conf['general.']['listMode']==2 || ($conf['inputvar.']['submit']=='save' && $this->conf['editUnique'])) $this->dataArr=$fe[$this->theTable]; // Incoming data.
$this->conf['dataArr']=&$this->dataArr;
// Setting blog incoming data. Non-stripped
$this->markerArray['###EVAL_BLOG_ERROR###'] = '';
if ($this->conf['blogData'] && is_array($fe['tx_metafeedit_comments']) && $conf['inputvar.']['cmd']!='list') {
$this->dataArr = $fe['tx_metafeedit_comments'];
$this->dataArr['linked_row'] =$this->theTable.'_'.$this->recUid;
// checking CAPTCHA
if ($this->conf['blog.']['captcha'] && is_object($this->metafeeditlib->freeCap) && !$this->metafeeditlib->freeCap->checkWord($this->piVars['captcha_response'])) {
$this->markerArray['###EVAL_BLOG_ERROR###'] = $this->metafeeditlib->getLL('blog_captcha_error',$this->conf);
$this->failure=1;
$this->failureMsg['blog_captcha']=$this->markerArray['###EVAL_BLOG_ERROR###'];
}
}
// Incoming data.
if (!$this->recUid) $this->recUid=$this->dataArr[$this->conf['uidField']]?$this->dataArr[$this->conf['uidField']]:NULL;
$this->conf['recUid']=$this->recUid;
$this->markerArray['###REC_UID###'] = $this->recUid;
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Init done:']=$this->metafeeditlib->displaytime()." Seconds";
// *****************
// If data is submitted, we take care of it here.
// *******************
if ($this->conf['inputvar.']['cmd']=='delete' && !$this->preview && !$conf['inputvar.']['doNotSave']) { // Delete record if delete command is sent + the preview flag is NOT set.
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc delete start:']=$this->metafeeditlib->displaytime()." Seconds";
$this->deleteRecord();
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc delete end:']=$this->metafeeditlib->displaytime()." Seconds";
$this->conf['inputvar.']['cmd']='list';
$this->conf['cmdKey']='list';
$this->conf['cmdmode']='list';
$this->dataArr=array();
$this->recUid=NULL;
}
// If incoming data is seen...
if (is_array($this->dataArr) && count($this->dataArr)>0) {
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc incoming data start:']=$this->metafeeditlib->displaytime()." Seconds";
// We have data to save
// Evaluation of data for grid mode:
if (is_array($this->dataArr['grid'])) {
// We are in datagrid mode ...
// A VALIDER CBY
$this->conf['cmdmode']='grid';
$saveData=$this->dataArr;
$saveCurrentData=$this->currentArr;
$rowData=$this->dataArr['grid'];
$nbcols=$this->dataArr['nbcols'];
$sqlModeArr=$this->dataArr['grid-sqlmode'];
foreach($rowData as $row=>$colData) {
foreach($colData as $col=>$dataArr) {
$this->failure=0;
if ( (!$this->preview || $this->conf['blogData']) && !$conf['inputvar.']['doNotSave']) { // doNotSave is a global var (eg a 'Cancel' submit button) that prevents the data from being processed
if ($nbcols>1 && is_array($dataArr) && !array_key_exists('uid', $dataArr)) { // secondaryFields
foreach($dataArr as $col2=>$dataArr2) {
switch ($sqlModeArr[$row][$col][$col2]) {
case 'insert':
$this->conf['cmdKey']='create';
break;
case 'update':
$this->conf['cmdKey']='edit';
break;
}
$this->dataArr=$dataArr2;
$this->parseValues();
$this->overrideValues();
$this->evalValues();
if ($this->conf['evalFunc']) {
$this->dataArr = $this->userProcess('evalFunc',$this->dataArr);
}
$this->saveGrid($this->conf,$row,$col,$this->dataArr,$sqlModeArr[$row][$col][$col2],array($col2));
}
} else {
switch ($sqlModeArr[$row][$col]) {
case 'insert':
$this->conf['cmdKey']='create';
break;
case 'update':
$this->conf['cmdKey']='edit';
break;
}
$this->dataArr=$dataArr;
$this->parseValues();
$this->overrideValues();
$this->evalValues();
if ($this->conf['evalFunc']) {
$this->dataArr = $this->userProcess('evalFunc',$this->dataArr);
}
$this->saveGrid($this->conf,$row,$col,$this->dataArr,$sqlModeArr[$row][$col]);
}
if ($this->conf['evalFunc']) {
$this->currentArr = $this->userProcess('evalFunc',$this->currentArr);
}
} else {
if ($this->conf['debug']) debug($this->failure);
}
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Incoming data end:']=$this->metafeeditlib->displaytime()." Seconds";
}
}
$this->dataArr=$saveData;
$this->currentArr=$saveCurrentData;
} else {
// We are in normal List or edit mode
$this->parseValues();
$this->overrideValues();
$this->evalValues();
if ($this->conf['evalFunc']) {
$this->dataArr = $this->userProcess('evalFunc',$this->dataArr);
}
// if not preview and no failures, then set data...
if (!$this->failure && $this->conf['inputvar.']['BACK']!=1 && (!$this->preview || $this->conf['blogData']) && !$conf['inputvar.']['doNotSave']) {
// doNotSave is a global var (eg a 'Cancel' submit button) that prevents the data from being processed
$this->save($this->conf);
if ($this->conf['evalFunc']) {
$this->currentArr = $this->userProcess('evalFunc',$this->currentArr);
}
} else {
if ($this->conf['debug']) debug($this->failure);
}
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Incoming data end:']=$this->metafeeditlib->displaytime()." Seconds";
}
} else {
// We have no incoming data
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc No incoming data start:']=$this->metafeeditlib->displaytime()." Seconds";
$dataArr=array();
//moved before creating default value, else it will be unseted
$this->dataArr=$dataArr;
$this->defaultValues($this->conf); // If no incoming data, this will set the default values.
// here we load overrideValues !
// override value arr to transmit to fe_adminLib
$fNA=$this->metafeeditlib->getOverrideFields($this->conf['inputvar.']['cmd'],$this->conf);
$this->cObj->start($this->dataArr,$this->theTable);
foreach($fNA as $fN) {
$val=$this->metafeeditlib->getOverrideValue($fN,$this->conf['inputvar.']['cmd'],$this->conf,$this->cObj);
$dataArr[$fN]=$val;
$this->dataArr[$fN]=$val;
}
$nbf=count($this->dataArr);
$this->currentArr=$dataArr;
// ugly hack to handle checkboxes properly
$this->dataArr['tx_metafeedit_dont_ctrl_checkboxes']=1;
if (is_array($this->dataArr) && count($this->dataArr)>1) {
$this->parseValues(1);
//$this->evalValues(); Is this good ?
}
if ($this->conf['evalFunc']) {
$this->dataArr = $this->userProcess('evalFunc',$this->dataArr);
}
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc No incoming data end:']=$this->metafeeditlib->displaytime()." Seconds";
}
if ($this->failure && !$this->conf['blogData']) {$this->preview=0;} // No preview flag if a evaluation failure has occured
$this->previewLabel = ($this->preview || $this->conf['blogData'])? '_PREVIEW' : ''; // Setting preview label prefix.
//error_log(__METHOD__."DISPLAY======".$this->metafeeditlib->getMemoryUsage());
// *********************
// DISPLAY FORMS:
// ***********************
if ($this->saved) {
//@todo why do we do this we lose override values here !!
//$savedData=$this->dataArr;
$this->dataArr=array_merge($this->dataArr,$this->currentArr);
// Clear page cache
$this->clearCacheIfSet();
// Displaying the page here that says, the record has been saved. You're able to include the saved values by markers.
switch($this->conf['inputvar.']['cmd']) {
case 'delete':
$key='DELETE';
break;
case 'create':
/** create mode is valid :
* - in list mode (new element button)
* - in create only screen (for aexample a subscription screen).
*/
switch ($this->conf['defaultCmd']) {
case 'create' :
$key='CREATE';
// We force status screen if default command is create.
// and no preview is set ...
if (!$this->preview) $this->conf[$this->conf['inputvar.']['cmd'].'.']['statusScreen']=1;
break;
default:
$key='EDIT';
break;
};
break;
case 'list':
case 'edit':
$key='EDIT';
break;
break;
default:
$key='CREATE';
break;
}
// We handle status screen
if (($this->conf[$this->conf['inputvar.']['cmd'].'.']['statusScreen'] && ($this->conf['inputvar.']['cmd']=='edit' || $this->conf['inputvar.']['cmd']=='create')) || (!($this->conf['inputvar.']['cmd']=='list' && $this->conf['general.']['listMode']==2) && ($this->conf['inputvar.']['cmd']!='edit' && $this->conf['inputvar.']['cmd']!='create'))) {
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Status screen start:']=$this->metafeeditlib->displaytime()." Seconds";
$this->conf['cmdmode']='status';
// Output message
// this should be message in Edit Screen;
$templateCode = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_'.$key.'_SAVED###');
$this->metafeeditlib->setCObjects($this->conf,$this->markerArray,$templateCode,$this->currentArr);
// ???
$markerArray = $this->cObj->fillInMarkerArray($this->markerArray, $this->currentArr, '', TRUE, 'FIELD_', $this->conf['general.']['xhtml']);
$content = $this->cObj->substituteMarkerArray($templateCode, $markerArray);
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Status screen end:']=$this->metafeeditlib->displaytime()." Seconds";
} else {
// no status screen we want too stay on the edit form if in create mode we must switch to edit template, if in list or grid we stay in same mode ...
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc No status screen start:']=$this->metafeeditlib->displaytime()." Seconds";
if ($this->conf['inputvar.']['cmd']!='list') {
$this->conf['inputvar.']['cmd']='edit';
$this->metafeeditlib->getFieldList($this->conf);
}
if (!$this->preview) $this->preview=$this->conf['disableEdit']&&$this->conf[$this->conf['inputvar.']['cmd'].'.']['preview'] && ($this->conf['inputvar.']['cmd']=='edit'|| $this->conf['inputvar.']['cmd']=='create');
$this->previewLabel = ($this->preview || $this->conf['blogData'])? '_PREVIEW' : '';
// thanks to Karl-Ernst Kiel [[email protected]]
$this->markerArray['###EVAL_ERROR###'] = $this->metafeeditlib->makeErrorMarker($this->conf,$this->metafeeditlib->getLL('edit_saved_message',$this->conf));
$content = $this->displayEditScreen();
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc No status screen end:']=$this->metafeeditlib->displaytime()." Seconds";
}
// Notification Mails
// mail admin
// mail feuser
// mail datamail
// SetFixed Mails (moderation)...
// mail admin
// mail feuser
// mail datamail ?
// we reset email array if data is empty.
foreach($this->conf['email.'] as $key_mode=>$val) {
if ($this->conf['email.'][$key_mode]===0 || $this->conf['email.'][$key_mode]=='0') unset($this->conf['email.'][$key_mode]);
}
if ($this->conf['email.']['sendAdminMail'] || $this->conf['email.']['sendFEUserMail'] || $this->conf['email.']['sendDataMail'] || $this->conf['email.']['sendDataInfoMail'] || $this->conf['email.']['sendFEUserInfoMail'] || $this->conf['email.']['sendAdminInfoMail']) {
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Notification mail start:']=$this->metafeeditlib->displaytime()." Seconds";
$this->compileMail(
$key.'_SAVED',
array($this->currentArr),
$this->getFeuserMail($this->currentArr,$this->conf),
$this->conf['setfixed.']
);
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Notification mail end:']=$this->metafeeditlib->displaytime()." Seconds";
}
switch($this->conf['inputvar.']['cmd']) {
case 'setfixed':
$this->conf['inputvar.']['cmd']=$this->conf['defaultCmd'];
case 'delete':
case 'create':
switch ($this->conf['defaultCmd']) {
case 'create' :
$this->conf['inputvar.']['cmd']='create';
break;
default:
$this->conf['inputvar.']['cmd']='edit';
break;
};
break;
default:
$this->conf['inputvar.']['cmd']='list';
}
} elseif ($this->error) {
// If there was an error, we return the template-subpart with the error message
$this->markerArray['###EVAL_ERROR###'] = $this->metafeeditlib->makeErrorMarker($this->conf,$this->metafeeditlib->getLL('error_occured',$this->conf));
$templateCode = $this->cObj->getSubpart($this->templateCode, $this->error);
$this->metafeeditlib->setCObjects($this->conf,$this->markerArray,$templateCode);
$content = $this->cObj->substituteMarkerArray($templateCode, $this->markerArray);
} else {
// Finally, if there has been no attempt to save. That is either preview or just displaying and empty or not correctly filled form:
if (!$this->conf['inputvar.']['cmd']) {
$this->conf['inputvar.']['cmd']=$this->conf['defaultCmd'];
}
if ($this->conf['debug']) debug('Display form: '.$this->conf['inputvar.']['cmd'],1);
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc process start:']=$this->metafeeditlib->displaytime()." Seconds";
switch($this->conf['inputvar.']['cmd']) {
case 'setfixed':
$content = $this->procesSetFixed();
$this->conf['cmdmode']=$this->conf['defaultCmd'];
$this->conf['inputvar.']['cmd']=$this->conf['defaultCmd'];
break;
case 'infomail':
$this->conf['cmdmode']='infomail';
$content = $this->sendInfoMail();
$this->conf['cmdmode']=$this->conf['defaultCmd'];
$this->conf['inputvar.']['cmd']=$this->conf['defaultCmd'];
break;
case 'delete':
$this->conf['cmdmode']='delete';
$content = $this->displayDeleteScreen();
break;
case 'list': //TODO to be improved move displayListScreen here.
case 'edit':
if ($this->conf['debug']) echo Tx_MetaFeedit_Lib_ViewArray::viewArray(array('displayEditScreen'=>'on'));
$this->conf['cmdmode']='edit';
$content = $this->displayEditScreen();
break;
case 'create':
$this->conf['cmdmode']='create';
$content = $this->displayCreateScreen($this->conf);
break;
}
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc process end:']=$this->metafeeditlib->displaytime()." Seconds";
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc Conf process end size']=strlen(serialize($this->conf))." Bytes";
if ($this->conf['performanceaudit']) $this->perfArray['Conf TCAN size ']=strlen(serialize($this->conf['TCAN']))." Bytes";
if ($this->conf['performanceaudit']) $this->perfArray['Conf LOCALLANG size ']=strlen(serialize($this->conf['LOCAL_LANG']))." Bytes";
if ($this->conf['performanceaudit']) $this->perfArray['Conf Template size ']=strlen(serialize($this->conf['templateContent']))." Bytes";
if ($this->conf['debug.']['krumo'] && t3lib_extmgm::isLoaded('krumo')) {
krumo($this->conf);
krumo($this->conf['TCAN']);
krumo($this->conf['LOCAL_LANG']);
}
}
// Delete temp files:
foreach($this->unlinkTempFiles as $tempFileName) {
t3lib_div::unlink_tempfile($tempFileName);
}
if ($this->conf['performanceaudit']) $this->perfArray['fe_adminLib.inc process end:']=$this->metafeeditlib->displaytime()." Seconds";
if ($conf['debug.']['vars']) {
$this->metafeeditlib->debug('Post Vars :',$_POST,$DEBUG);
$this->metafeeditlib->debug('GET Vars :',$_GET,$DEBUG);
$this->metafeeditlib->debug('PI Vars :',$this->piVars,$DEBUG);
$this->metafeeditlib->debug('METAFEEDIT Vars :',$this->conf['inputvar.'],$DEBUG);
}
if ($conf['debug.']['markerArray']) $this->metafeeditlib->debug('Marker Array :',$this->markerArray,$DEBUG);
if ($conf['debug.']['langArray']) {
$this->metafeeditlib->debug('Local Lang Array :'.$this->conf['LLKEY'],$this->conf['LLKEY'],$DEBUG);
$this->metafeeditlib->debug('LOCAL_LANG',$this->conf['LOCAL_LANG'],$DEBUG);
$this->metafeeditlib->debug('_LOCAL_LANG',$this->conf['_LOCAL_LANG.'],$DEBUG);
}
if ($conf['debug.']['conf']) $this->metafeeditlib->debug('Conf :',$this->conf,$DEBUG);
if ($conf['debug.']['template']) $this->metafeeditlib->debug('Templates :',$this->conf['templateContent'],$DEBUG);
if ($conf['debug.']['tsfe']) $this->metafeeditlib->debug('TSFE :',$GLOBALS['TSFE'],$DEBUG);
// We update Session vars in case of change of cmd mode
$this->metafeeditlib->updateSessionVars($this->conf);
return ($conf['performanceaudit']?Tx_MetaFeedit_Lib_ViewArray::viewArray($this->perfArray):'').$content.$conf['debug.']['debugString'].$DEBUG;
}
/**
* Gets connected users email
* @param array $Arr incoming dataArray
* @param array $conf configuration array
* @return string email (should never be empty !!)
*/
function getFeuserMail($Arr,&$conf) {
$recipient='';
// handle user mail !!!!
if ($conf['fe_cruser_id']) {
$feuserid=$Arr[$conf['fe_cruser_id']];
$DBrows = $GLOBALS['TSFE']->sys_page->getRecordsByField('fe_users','uid',$feuserid,'','','1');
$recipient=$DBrows[0]['email'];
} elseif ($GLOBALS['TSFE']->fe_user->user[email]) {
// Are we conencted, if so we take conencted user's email ???
$recipient=$GLOBALS['TSFE']->fe_user->user[email];
} else {
if (!$conf['email.']['field']) echo 'Record Email field is not defined';
$emailfields=t3lib_div::trimexplode(',',$conf['email.']['field']);
foreach($emailfields as $ef) {
$recipient.=$recipient?$Arr[$conf['email.']['field']].';'.$recipient:$Arr[$conf['email.']['field']];
}
}
return $recipient;
}
/*****************************************
*
* Data processing
*
*****************************************/
/**
* Performs processing on the values found in the input data array, $this->dataArr.
* The processing is done according to configuration found in TypoScript
* Examples of this could be to force a value to an integer, remove all non-alphanumeric characters, trimming a value, upper/lowercase it, or process it due to special types like files submitted etc.
* Called from init() if the $this->dataArr is found to be an array
*
* @return void
* @see init()
*/
function parseValues($workOnlyOnDataArr=0) {
//Blog Hack
$evalValues=$this->conf['blogData']?$this->metafeeditlib->getBlogEvalValues($this->conf):$this->conf[$this->conf['cmdKey'].'.']['evalValues.'];
//$parseValues=array_merge(is_array($this->conf['parseValues.'])?$this->conf['parseValues.']:array(),is_array($evalValues)?$evalValues:array());
if(is_array($this->conf['parseValues.'])) {
$parseValues=$this->conf['parseValues.'];
if (is_array($evalValues)) {
$arr=$parseValues;
foreach ($evalValues as $key=>$val) {
if ($arr[$key]) {
$arr[$key]=implode(',',array_merge(t3lib_div::trimexplode(',',$parseValues[$key]),t3lib_div::trimexplode(',',$evalValues[$key])));
} else {
$arr[$key]=$val;
}
}
$parseValues=$arr;
}
}
else $parseValues = $evalValues;
if ($workOnlyOnDataArr) {
$theParseValues=array();
foreach ($this->dataArr as $field=>$val) {
if ($theParseValues[$field]) $parseValues[]=$parseValues[$field];
}
unset ($parseValues);
$parseValues=&$theParseValues;
}
if (is_array($parseValues)) {
reset($parseValues);
while(list($theField,$theValue)=each($parseValues)) {
$this->markerArray['###EVAL_ERROR_FIELD_'.$theField.'###']='';
$this->markerArray['###CSS_ERROR_FIELD_'.$theField.'###']='';
$this->markerArray['###EVAL_ERROR_FIELD_'.str_replace('.','_',$theField).'###']='';
$this->markerArray['###CSS_ERROR_FIELD_'.str_replace('.','_',$theField).'###']='';
$listOfCommands = t3lib_div::trimExplode(',',$theValue,1);
while(list(,$cmd)=each($listOfCommands)) {
$cmdParts = preg_split('/\[|\]/',$cmd); // Point is to enable parameters after each command enclosed in brackets [..]. These will be in position 1 in the array.
$theCmd=trim($cmdParts[0]);
switch($theCmd) {
case 'int':
$this->dataArr[$theField]=intval($this->dataArr[$theField]);
break;
case 'lower':
case 'upper':
$this->dataArr[$theField] = $this->cObj->caseshift($this->dataArr[$theField],$theCmd);
break;
case 'upperfirst':
$val = $this->cObj->caseshift($this->dataArr[$theField],'lower');
$this->dataArr[$theField]=strtoupper(substr($val,0,1)).substr($val,1);
break;
case 'nospace':
$this->dataArr[$theField] = str_replace(' ', '', $this->dataArr[$theField]);
break;
case 'alpha':
$this->dataArr[$theField] = preg_replace('/[^a-zA-Z]/','',$this->dataArr[$theField]);
break;
case 'num':
$this->dataArr[$theField] = preg_replace('/[^0-9]/','',$this->dataArr[$theField]);
break;
case 'alphanum':
$this->dataArr[$theField] = preg_replace('/[^a-zA-Z0-9]/','',$this->dataArr[$theField]);
break;
case 'alphanum_x':
$this->dataArr[$theField] = preg_replace('/[^a-zA-Z0-9_-]/','',$this->dataArr[$theField]);
break;
case 'trim':
$this->dataArr[$theField] = trim($this->dataArr[$theField]);
break;
case 'strip_tags':
$this->dataArr[$theField] = strip_tags($this->dataArr[$theField]);
break;
case 'noaccents':
$this->dataArr[$theField] = removeaccents($this->dataArr[$theField]);
break;
case 'invert':
$this->dataArr[$theField]=$this->dataArr[$theField]?0:1;
break;
case 'random':
$this->dataArr[$theField] = substr(md5(uniqid(microtime(),1)),0,intval($cmdParts[1]));
break;
case 'files':
$this->processFiles($cmdParts,$theField);
break;
case 'setEmptyIfAbsent':
if (!isset($this->dataArr[$theField])) {
$this->dataArr[$theField]='';
}
break;
case 'multiple':
if (is_array($this->dataArr[$theField])) {
$this->dataArr[$theField] = implode(',',$this->dataArr[$theField]);
}
break;
case 'checkArray':
if (is_array($this->dataArr[$theField])) {
reset($this->dataArr[$theField]);
$val = 0;
while(list($kk,$vv)=each($this->dataArr[$theField])) {
$kk = t3lib_div::intInRange($kk,0);
if ($kk<=30) {
if ($vv) {
$val|=pow(2,$kk);
}
}
}
$this->dataArr[$theField] = $val;
} else {$this->dataArr[$theField]=0;}
break;
case 'uniqueHashInt':
$otherFields = t3lib_div::trimExplode(';',$cmdParts[1],1);
$hashArray=array();
while(list(,$fN)=each($otherFields)) {
$vv = $this->dataArr[$fN];
$vv = preg_replace('/[[:space:]]/','',$vv);
$vv = preg_replace('/[^[:alnum:]]/','',$vv);
$vv = strtolower($vv);
$hashArray[]=$vv;
}
$this->dataArr[$theField]=hexdec(substr(md5(serialize($hashArray)),0,8));
break;
}
}
}
}
// Call to user parse function
$this->conf['parentObj']=&$this;
if ($this->conf['userFunc_afterParse']) {
t3lib_div::callUserFunction($this->conf['userFunc_afterParse'],$this->conf,$this);
}
}
/**
* Remove latin accents ...
*
* @param string string from which to remove accents
* @return string
* @access private
*/
Function removeaccents($string)
{
$string= strtr($string,
"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
"aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
return $string;
}
/**
* Processing of files.
* NOTICE: for now files can be handled only on creation of records. But a more advanced feature is that PREVIEW of files is handled.
*
* @param array Array with cmd-parts (from parseValues()). This will for example contain information about allowed file extensions and max size of uploaded files.
* @param string The fieldname with the files.
* @return void
* @access private
* @see parseValues()
*/
function processFiles($cmdParts,$theField) {
// First, make an array with the filename and file reference, whether the file is just uploaded or a preview
$filesArr = array();
if (is_string($this->dataArr[$theField])) { // files from preview.
$tmpArr = explode(',',$this->dataArr[$theField]);
reset($tmpArr);
while(list(,$val)=each($tmpArr)) {
$valParts = explode('|',$val);
$filesArr[] = array (
'name'=>$valParts[1],
'tmp_name'=>PATH_site.'typo3temp/'.$valParts[0]
);
}
} elseif (is_array($_FILES['FE'][$this->theTable][$theField]['name'])) { // Files from upload
reset($_FILES['FE'][$this->theTable][$theField]['name']);
while(list($kk,$vv)=each($_FILES['FE'][$this->theTable][$theField]['name'])) {