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
/
class.tx_metafeedit.php
4377 lines (3987 loc) · 215 KB
/
class.tx_metafeedit.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) 2006 Christophe Balisky <christophe@balisky.org>
* 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.
*
* 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!
***************************************************************/
/**
* This is a API for crating and editing records in the frontend.
* The API is build on top of fe_adminLib.
*
* @author Christophe Balisky <christophe@balisky.org>
*/
// Necessary includes
require_once(PATH_tslib.'class.tslib_pibase.php');
require_once(PATH_site.TYPO3_mainDir.'sysext/lang/lang.php');
require_once(PATH_t3lib.'class.t3lib_parsehtml_proc.php');
require_once(PATH_t3lib.'class.t3lib_befunc.php');
require_once(PATH_t3lib.'class.t3lib_tcemain.php');
define(PATH_typo3,PATH_site.TYPO3_mainDir); // used in template.php
require_once(PATH_site.TYPO3_mainDir.'template.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_treecopy.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_ajax.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_lib.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'class.tx_metafeedit_widgets.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'Classes/Lib/ViewArray.php');
//require_once(t3lib_extMgm::extPath('div').'class.tx_div.php');
if(t3lib_extmgm::isLoaded('rtehtmlarea')) require_once(t3lib_extMgm::extPath('rtehtmlarea').'pi2/class.tx_rtehtmlarea_pi2.php');
if(t3lib_extmgm::isLoaded('rlmp_dateselectlib')) require_once(t3lib_extMgm::extPath('rlmp_dateselectlib').'class.tx_rlmpdateselectlib.php');
// replace with meta_ldap later on
if(t3lib_extmgm::isLoaded('eu_ldap')) require_once(t3lib_extMgm::extPath('eu_ldap').'mod1/class.tx_euldap_div.php');
if (t3lib_extMgm::isLoaded('kb_md5fepw')) require_once(t3lib_extMgm::extPath('kb_md5fepw').'class.tx_kbmd5fepw_funcs.php');
require_once(t3lib_extMgm::extPath('meta_feedit').'fe_adminLib.php');
// FE editing class
class tx_metafeedit extends tslib_pibase {
// Private fields
var $prefixId = 'tx_metafeedit'; // Same as class name
var $scriptRelPath = 'class.tx_metafeedit.php'; // Path to this script relative to the extension dir.
var $extKey = 'meta_feedit'; // The extension key.
var $conf;
var $cObj; // contains an initialized cObj, so we can use the cObj functions whenever we want to.
var $templateObj; // contains an initialized templateObj, so we can use the template functions whenever we want to.(ex with dynamic tabs)
var $caller; // the caller
var $table; // the table
var $TCA; // contains the complete TCA of the $table
var $cmd; // this is 'hopefully' the same value as fe_adminLib's cmd.
var $id_field = ''; // the field from a record witch will identify the record.
var $additionalJS_end = array(); // JS to be added after the end of the content.
// Fields for the RTE API
var $strEntryField;
var $RTEObj;
var $docLarge = 0;
var $RTEcounter = 0;
var $FCounter=0;
var $formName;
var $additionalJS_initial = '';// Initial JavaScript to be printed before the form (should be in head, but cannot due to IE6 timing bug)
var $additionalJS_pre = array();// Additional JavaScript to be printed before the form (works in Mozilla/Firefox when included in head, but not in IE6)
var $additionalJS_post = array();// Additional JavaScript to be printed after the form
var $additionalJS_submit = array();// Additional JavaScript to be executed on submit
var $PA = array(
'itemFormElName' => '',
'itemFormElValue' => '',
);
var $specConf = array();
/**
*
* @var tx_metafeedit_lib
*/
var $metafeeditlib;
var $thisConfig = array();
var $RTEtypeVal = 'text';
var $thePidValue;
var $TCATables=array();
//var $langOverrides=array();
var $performanceaudit; // performance audit flag
//var $_LOCAL_LANG = array(); // Language override
private function initReportCache($conf) {
if ($conf['general.']['tplCache']) {
$finalCacheDirectory = PATH_site . 'typo3temp/Cache/Reports/' . $conf['pluginId'] . '/';
if (!is_dir($finalCacheDirectory)) {
//error_log(__METHOD__.":$finalCacheDirectory");
$this->createFinalCacheDirectory($finalCacheDirectory);
}
$this->cacheDirectory = $finalCacheDirectory;
}
}
private function initBarcodeCache($conf) {
$finalCacheDirectory = PATH_site . 'typo3temp/Cache/Barcodes/';
if (!is_dir($finalCacheDirectory)) {
//error_log(__METHOD__.":$finalCacheDirectory");
$this->createFinalCacheDirectory($finalCacheDirectory);
}
}
/**
*
* @param string $templateName
*/
private function getTemplate($templateName,&$conf) {
$tpl='';
//error_log(__METHOD__);
if ($conf['general.']['tplCache']) {
$file=$this->cacheDirectory.$templateName.".".$conf['LLKey'].".tpl";
if (file_exists($file) ) {
return file_get_contents($file);
}
}
return $tpl;
}
/**
*
* @param string $templateName
* @param string $template
*/
private function saveTemplate($templateName,$template,&$conf) {
//error_log(__METHOD__);
if ($conf['general.']['tplCache']) {
$file=$this->cacheDirectory.$templateName.".".$conf['LLKey'].".tpl";
//error_log(__METHOD__.'we save template :'.$file);
return file_put_contents($file,$template);
}
}
/**
* Create the final cache directory if it does not exist. This method
* exists in TYPO3 v4 only.
*
* @param string $finalCacheDirectory Absolute path to final cache directory
* @return void
* @throws \t3lib_cache_Exception If directory is not writable after creation
*/
protected function createFinalCacheDirectory($finalCacheDirectory) {
try {
t3lib_div::mkdir_deep($finalCacheDirectory);
} catch (\RuntimeException $e) {
throw new \t3lib_cache_Exception(
'The directory "' . $finalCacheDirectory . '" can not be created.',
1303669848,
$e
);
}
if (!is_writable($finalCacheDirectory)) {
throw new \t3lib_cache_Exception(
'The directory "' . $finalCacheDirectory . '" is not writable.',
1203965200
);
}
}
/**
* init : Main method ...
*
* @param [object] $caller: calaing object (instance of PI1).
* @param [array] $conf: configuration array
* @return [string] content to display.
*/
function init(&$caller,&$conf) {
//error_log(__METHOD__." start ================".$GLOBALS['TSFE']->lang);
$this->initReportCache($conf);
$this->initBarcodeCache($conf);
$this->initialize($caller,$conf);
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Init done :']=$this->metafeeditlib->displaytime()." Seconds";
// command specific initialisation
$this->initCmd($conf);
$this->conf=&$conf; // to be removed !!! Can it be removed ? CBY
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Init feAconf done :']=$this->metafeeditlib->displaytime()." Seconds";
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Conf after Init feAConf size ']=strlen(serialize($conf))." Bytes";
// we call fe_adminLib.php here ...
$conf['caller_additionalJS_post']=$this->additionalJS_post;
$conf['caller_additionalJS_end']=$this->additionalJS_end;
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Conf before USER_INT call size ']=strlen(serialize($conf))." Bytes";
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit before USER_INT call :']=$this->metafeeditlib->displaytime()." Seconds";
// In No Cache or Mixt Cache We call USER_INT object
if ($conf['cacheMode']<2) {
$content = $this->cObj->cObjGetSingle('USER_INT',$conf);
} else {
// In Full cache mode we use user object and count on cHASH to renew cache ..
$feAdm=t3lib_div::makeInstance('tx_metafeedit_user_feAdmin');
$content='';
$content=$feAdm->user_init("",$conf);
}
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit USER_INT call done :']=$this->metafeeditlib->displaytime()." Seconds";
//error_log(__METHOD__." end ================".$GLOBALS['TSFE']->lang);
/**** ADDS THE REQUIRED JAVASCRIPTS ****/
$content = $this->getJSBefore($conf).$content;
// XAJAX form handler. Must not be generated if we are in an ajax call.
$onSubmit = ' onsubmit="return false;" ';
$form=t3lib_div::_GP('ajx')?'':'<form style="display:inline;height:10px;padding:0px;margin:0px;" '.$onSubmit.' action="#" method="post" enctype="multipart/form-data" id="xfm" name="xfm">'.
'<input type="hidden" id="mfdt_cmd" name="'.$this->prefixId.'[cmd]" value="" />'.
'<input type="hidden" id="mfdt_code" name="'.$this->prefixId.'[code]" value="" />'.
'<input type="hidden" id="mfdt_prefix" name="'.$this->prefixId.'[prefix]" value="" />'.
'<input type="hidden" id="mfdt_mode" name="'.$this->prefixId.'[mode]" value="" />'.
'<input type="hidden" id="mfdt_data" name="'.$this->prefixId.'[data]" value="" />'.
'<input type="hidden" id="mfdt_tdata" name="'.$this->prefixId.'[tdata]" value="" />'.
'<input type="hidden" id="mfdt_page" name="'.$this->prefixId.'[page]" value="" />'.
'<input type="hidden" id="mfdt_pagesize" name="'.$this->prefixId.'[pagesize]" value="" />'.
'<input type="hidden" id="mfdt_callbacks" name="'.$this->prefixId.'[callbacks]" value="" />'.
'<input type="hidden" id="mfdt_eventdata" name="'.$this->prefixId.'[eventdata]" value="" />'.
'<input type="hidden" id="mfdt_table" name="'.$this->prefixId.'[table]" value="" />'.
'<input type="hidden" id="mfdt_labelField" name="'.$this->prefixId.'[labelField]" value="" />'.
'<input type="hidden" id="mfdt_numField" name="'.$this->prefixId.'[numField]" value="" />'.
'<input type="hidden" id="mfdt_fields" name="'.$this->prefixId.'[fields]" value="" />'.
'<input type="hidden" id="mfdt_whereField" name="'.$this->prefixId.'[whereField]" value="" />'.
'<input type="hidden" id="mfdt_labels" name="'.$this->prefixId.'[labels]" value="" />'.
'<input type="hidden" id="mfdt_orderBy" name="'.$this->prefixId.'[orderBy]" value="" />'.
'</form>';
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Conf size ']=strlen(serialize($conf))." Bytes";
/**** ADDS THE REQUIRED JAVASCRIPTS ****/
$content .= $this->getJSAfter($conf);
return ($conf['performanceaudit']?Tx_MetaFeedit_Lib_ViewArray::viewArray($this->caller->perfArray):'').$form.$content;
}
// for template wizards
function initTpl(&$caller,&$conf) {
//$this->initialize($caller,$conf);
//if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Init done :']=$this->metafeeditlib->displaytime()." Seconds";
// command specific initialisation
//$this->initCmd($conf);
$this->metafeeditlib=t3lib_div::makeInstance('tx_metafeedit_lib');
}
/**
* initialize : initializes object...
*
* @param [type] $caller: ...
* @param [type] $conf: ...
* @return [type] ...
*/
function initialize(&$caller,&$conf) {
//error_log(__METHOD__." start ================".$GLOBALS['TSFE']->lang);
$this->caller = $caller;
$conf['caller']=&$caller; // 100 K
$this->metafeeditlib=$caller->metafeeditlib;
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit cache Mode : '.$conf['cacheMode']]=$this->metafeeditlib->displaytime()." Seconds";
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Conf Enter size ']=strlen(serialize($conf))." Bytes";
$conf['prefixId']= 'tx_metafeedit';
$conf['additionalJS_post'] = array();
$conf['additionalJS_end'] = array();
//$conf['performanceaudit']=$caller->performanceaudit;
// Cache ??
if ($conf['cacheMode']==0) $GLOBALS['TSFE']->set_no_cache();
$this->cObj=$GLOBALS['TSFE']->cObj;
$this->templateObj = t3lib_div::makeInstance('mediumDoc');
$this->table = $conf['table'];
// we check here editUnique Creation Mode
if ($conf['editUnique']) {
//@todo check why I have to do this ?
$conf['inputvar.']['cmd']='edit';
$mmTable='';
$DBSELECT=$this->metafeeditlib->DBmayFEUserEditSelectMM($this->table,$GLOBALS['TSFE']->fe_user->user, $conf['allowedGroups'],$conf['fe_userEditSelf'],$mmTable,$conf).$GLOBALS['TSFE']->sys_page->deleteClause($this->table);
$thePid = intval($conf['pid']) ? intval($conf['pid']) : $GLOBALS['TSFE']->id;
$lockPid = $conf['edit.']['menuLockPid'] ? ' AND pid='.intval($thePid) : '';
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->table.($mmTable?','.$mmTable:'') , '1 '.$lockPid.$DBSELECT);
$resu=$GLOBALS['TYPO3_DB']->sql_num_rows($res);
if ($resu===0 && $this->cmd!='setfixed') $conf['inputvar.']['cmd']='create';
}
if (!$conf['inputvar.']['cmd']) die ("META_FEEDIT ERROR: NO COMMAND SPECIFIED FOR THE SCRIPT");
//$conf['inputvar.']['cmd']='edit';
//$conf['cmd']=$this->cmd;
// debug("WARNING:: NO COMMAND SPECIFIED FOR THE SCRIPT","NO COMMAND");
$this->id_field = $conf['label.'][$FT]?$conf['label.'][$FT]:($conf['idField']?$conf['idField']:$GLOBALS['TCA'][$this->table]['ctrl']['label']);
if (!$this->id_field) $this->id_field='uid';
$conf["table_label"]=$this->id_field;
// TODO : move next lines to pi1 ...
if ($conf['list.']['advancedSearch']) {
$conf['keep_piVars']= $conf['keep_piVars']? $conf['keep_piVars'].',advancedSearch':'advancedSearch';
}
$this->LoadTCAs($conf);
$this->LoadLanguageConf($conf);
/**** Init Robert Lemkes dateselectlib if it is loaded ****/
if(t3lib_extmgm::isLoaded('rlmp_dateselectlib')) tx_rlmpdateselectlib::includeLib();
$this->conf=&$conf; // TODO : to be removed !!! CBY
//error_log(__METHOD__." end ================".$GLOBALS['TSFE']->lang);
}
/**
* Check if the given extension key is within the loaded extensions
*
* The key can be given in the regular format or with underscores stripped.
*
* @param string extension key to check
* @return boolean is the key valid?
*/
function getValidKey($rawKey) {
$uKeys = array_keys($this->getGlobal('TYPO3_LOADED_EXT'));
foreach((array)$uKeys as $uKey) {
if( str_replace('_', '', $uKey) == str_replace('_', '', $rawKey) ){
$result = $uKey;
}
}
return $result ? $result : FALSE;
}
/**
* Guess the key from the given information
*
* Guessing has the following order:
*
* 1. A KEY itself is tried.
* <pre>
* Example: my_extension
* </pre>
* 2. A classname of the pattern tx_KEY_something_else is tried.
* <pre>
* Example: tx_myextension_view
* </pre>
* 3. A full classname of the pattern ' * tx_KEY_something_else.php' is tried.
* <pre>
* Example: class.tx_myextension_view.php
* Example: brokenPath/class.tx_myextension_view.php
* </pre>
* 4. A path that starts with the KEY is tried.
* <pre>
* Example: my_extension/class.view.php
* </pre>
*
* @param string the minimal necessary information (see 1-4)
* @return string the guessed key, FALSE if no result
*/
function guessKey($minimalInformation) {
$info=trim($minimalInformation);
$key = FALSE;
if($info){
// Can it be the key itself?
if(!$key && preg_match('/^([A-Za-z_]*)$/', $info, $matches ) ) {
$key = $matches[1];
$key = $this->getValidKey($key);
}
// Is it a classname that contains the key?
if(!$key && (preg_match('/^tx_([^_]*)(.*)$/', $info, $matches ) || preg_match('/^user_([^_]*)(.*)$/', $info, $matches )) ) {
$key = $matches[1];
$key = $this->getValidKey($key);
}
// Is there a full filename that contains the key in it?
if(!$key && (preg_match('/^.*?tx_([^_]*)(.*)\.php$/', $info, $matches ) || preg_match('/^.*?user_([^_]*)(.*)\.php$/', $info, $matches )) ) {
$key = $matches[1];
$key = $this->getValidKey($key);
}
// Is it a path that starts with the key?
if(!$key && $last = strstr('/',$info)) {
$key = substr($info, 0, $last);
$key = $this->getValidKey($key);
}
}
return $key ? $key : FALSE;
}
/**
* Get a global variable
*
* @param string The key of the global variable
* @return mixed The global variable.
*/
function getGlobal($key) {
return $GLOBALS[$key];
}
/**
* LoadTCAs : Loads Tabel TCA with user overrides...
*
* @param [array] $conf: configuration array
*/
function LoadTCAs(&$conf) {
# $GLOBALS['TSFE']->includeTCA(); // Uncomment cause extensions using this API should be able to modify TCA array before used here.
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Conf before LoadTCA size ']=strlen(serialize($conf))." Bytes";
t3lib_div::loadTCA($this->table);
//t3lib_div::loadTCA('tx_metafeedit_comments');
$conf['uidField']=$GLOBALS['TCA'][$this->table]['ctrl']['uidField']?$GLOBALS['TCA'][$this->table]['ctrl']['uidField']:'uid';
if ($conf['debug']) echo Tx_MetaFeedit_Lib_ViewArray::viewArray(array('UIDFIELD'=>$conf['uidField']));
/**** CONFIGURE TCA ****/
// here we should calculate fieldList from showFields, evalFields, and override fields..
$GLOBALS['TCA'][$this->table]["feInterface"]["fe_admin_fieldList"] = $conf['create.']['fields'] ? $conf['create.']['fields'].($conf['edit.']['fields']?','.$conf['edit.']['fields']:'') : $conf['edit.']['fields'];
if($conf['fe_cruser_id'])
$GLOBALS['TCA'][$this->table]['ctrl']['fe_cruser_id'] = $conf['fe_cruser_id'];
if($conf['fe_crgroup_id'] && $conf['allowedGroups']) {
$GLOBALS['TCA'][$this->table]['ctrl']['fe_crgroup_id'] = $conf['fe_crgroup_id'];
}
$this->metafeeditlib->makeTypo3TCAForTable($GLOBALS['TCA'],$this->table);
// We handle Foreign Table TCA definitions here ...
$FTRels=explode(',',$conf['foreignTables']);
$FTs=array();
$FTs[$this->table]=$this->table;
foreach ($FTRels as $FTRel) {
if ($FTRel && $GLOBALS['TCA'][$this->table]['columns'][$FTRel]['config']['foreign_table']) $FTs[$GLOBALS['TCA'][$this->table]['columns'][$FTRel]['config']['foreign_table']]=$GLOBALS['TCA'][$this->table]['columns'][$FTRel]['config']['foreign_table'];
}
// We handle foreign tables of fields
$lfields=t3lib_div::trimexplode(',',$conf['list.']['show_fields']);
foreach ($lfields as $lf) {
if ($lf && $GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table']) $FTs[$GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table']]=$GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table'];
}
// We handle foreign tables of joinFields
$lfields=t3lib_div::trimexplode(',',$conf['list.']['joinFields']);
foreach ($lfields as $lf) {
if ($lf && $conf['joinTable']) $FTs[$GLOBALS['TCA'][$conf['joinTable']]['columns'][$lf]['config']['foreign_table']]=$GLOBALS['TCA'][$conf['joinTable']]['columns'][$lf]['config']['foreign_table'];
}
// We handle foreign tables of extra fields
$lfields=t3lib_div::trimexplode(',',$conf['list.']['extraFields']);
foreach ($lfields as $lf) {
if ($lf && $GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table']) $FTs[$GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table']]=$GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table'];
}
// We handle foreign tables of fields
$lfields=t3lib_div::trimexplode(',',$conf['list.']['advancedSearchFields']);
foreach ($lfields as $lf) {
if ($lf && $GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table']) $FTs[$GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table']]=$GLOBALS['TCA'][$this->table]['columns'][$lf]['config']['foreign_table'];
}
// We add fe_user table just in case we need feuser join.
if (!in_array('fe_users',$FTs)) $FTs['fe_users']='fe_users';
if (!in_array('tx_metafeedit_comments',$FTs)) $FTs['tx_metafeedit_comments']='tx_metafeedit_comments';
$conf['TCATables']=$FTs;
//We handle here tables from other software than T3 !!
//TODO : We should do this for every foreign table
//cmd load item proc func
foreach ($GLOBALS['TCA'][$this->table]['columns'] as $keyField => $fieldValues) {
if ($GLOBALS['TCA'][$this->table]['columns'][$keyField]["config"]["itemsProcFunc"]) {
$procExt = t3lib_extMgm::extPath($this->guessKey($GLOBALS['TCA'][$this->table]['columns'][$keyField]["config"]["itemsProcFunc"]));
$procExtKey = explode('->', $GLOBALS['TCA'][$this->table]['columns'][$keyField]["config"]["itemsProcFunc"]);
if (is_array($procExtKey) && file_exists($procExt.'class.'.strtolower ($procExtKey[0]).'.php')) include_once($procExt.'class.'.strtolower ($procExtKey[0]).'.php');
}
}
if ($conf["extTables"]) {
$extKeys=t3lib_div::trimExplode(chr(10),$conf["extTables"]);
$this->mergeExtendingTCAs($extKeys);
}
//TODO : allow general TCA override here.
//This will allow to handle tables from other software than T3 !!
//array_merge($GLOBALS['TCA'][$this->table],$conf...);
//TODO Cache TCA array here, include timestamp of plugin id... if timestamp is update renew cache...basically saving plugin once will renw cache.
$conf['TCAN'][$this->table]=$GLOBALS['TCA'][$this->table];
foreach($FTs as $FTable) {
$this->metafeeditlib->makeTypo3TCAForTable($conf['TCAN'],$FTable);
}
//We get related foreign tables if necessary
foreach ($lfields as $lf) {
if ($lf) $r=$this->metafeeditlib->getForeignTableFromField2($lf,$conf['table'],$conf['TCAN']);
}
// Set private TCA var
if (is_array($conf['general.']['tsOverride.'])) {
$settings=$this->metafeeditlib->postProcessSettings($conf['general.']['tsOverride.']);
$conf['TCAN'] = t3lib_div::array_merge_recursive_overrule($conf['TCAN'], $settings);
}
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Conf after TCA size 0 ']=strlen(serialize($conf))." Bytes";
//$conf['TCAN']=&$GLOBALS['TCA']; // 400 K ...
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Conf after LoadTCA size ']=strlen(serialize($conf))." Bytes";
}
/**
* LoadLanguageConf : Loads Language Configuration array for translations ...
*
* @param [array] $conf: configuration array
*/
function LoadLanguageConf(&$conf) {
if ($conf['performanceaudit']) $this->caller->perfArray['class.tx_metafeedit Conf before Language size ']=strlen(serialize($conf))." Bytes";
if (t3lib_extmgm::isLoaded('ard_mcm') ){
$this->langHandler=t3lib_div::makeInstance('Tx_ArdMcm_Core_LanguageHandler');
//$langHandler->update();
$this->langHandler->loadLangFile(t3lib_extMgm::extPath($this->extKey).'locallang.xml',$this->extKey);
//error_log(__METHOD__.":loaded file ".t3lib_extMgm::extPath($this->extKey).'locallang.xml');
$conf['LLKey']=$this->LLkey=$GLOBALS['LANG']->lang;
$this->processTSLanguageOverrides($conf);
// We handle ARD FRAMEWORK LANGUAGE OVERRIDES
if (t3lib_extMgm::isLoaded('ard_desktop')) $this->processLanguageOverrides();
} else {
// loads default locallang
$this->LOCAL_LANG = $GLOBALS['TSFE']->readLLfile(t3lib_extMgm::extPath($this->extKey).'locallang.xml');
// loads callers locallang
$this->LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($this->LOCAL_LANG,$this->caller->LOCAL_LANG);
// if we use static info table we must get language file.
// TOCHECK : Do we still need this ?
if(t3lib_extmgm::isLoaded('sr_static_info')) {
$filepath=t3lib_extMgm::extPath('sr_static_info').'pi1/locallang.php';
if (file_exists($filepath)) {
$stat_lang=$GLOBALS['TSFE']->readLLfile($filepath);
$this->LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($this->LOCAL_LANG,$stat_lang);
}
}
$this->processTSLanguageOverrides($conf);
/**
*
*/
$conf['LLkey']=$this->LLkey;
$conf['LOCAL_LANG']['default']=&$this->LOCAL_LANG['default'];
$conf['LOCAL_LANG'][$conf['LLkey']]=&$this->LOCAL_LANG[$conf['LLkey']];
$conf['LOCAL_LANG']['langoverride']=&$this->LOCAL_LANG['langoverride'];
unset($conf['_LOCAL_LANG.']);
/**** Init language object (used for translation of labels) ****/
//$GLOBALS['TSFE']->initLLvars();
}
}
function processTSLanguageOverrides($conf) {
// get override language data coming from typoscript. Should handle multiple languages ...
//@todo : We should only load default and local language translations ...
if (is_array($conf['_LOCAL_LANG.'])){
foreach($conf['_LOCAL_LANG.'] as $key=>$valarr) {
$nkey=substr($key,0,strpos($key,'.'));
foreach($valarr as $skey=>$sval) {
if (is_array($sval)) {
$svala=$sval;
foreach($svala as $skey2=>$sval) {
$skey2=$skey.$skey2;
while (is_array($sval)) { // if fieldname has several '.' in it we regenerate whole name here...
$svalb=$sval;
foreach($svalb as $skey3=>$sval) {
$skey2.=$skey3;
}
}
if (t3lib_extmgm::isLoaded('ard_mcm') ) {
$this->langHandler->override($nkey,$skey2,$sval);
} else {
$this->LOCAL_LANG['langoverride'][$nkey][$skey2]=$sval;
}
}
} else {
if (t3lib_extmgm::isLoaded('ard_mcm') ) {
$this->langHandler->override($nkey,$skey,$sval);
} else {
$this->LOCAL_LANG['langoverride'][$nkey][$skey]=$sval;
}
}
}
}
}
}
function processLanguageOverrides() {
$configHandler=t3lib_div::makeInstance('Tx_ArdMcm_Core_ConfigurationHandler');//singleton
$lo=$configHandler->getConfVal('ard_desktop','langoverride');
$loa=t3lib_div::trimExplode('\\n',$lo);
foreach($loa as $lod) {
$loda=t3lib_div::trimExplode('|',$lod);
//error_log(__METHOD__.":$lod");
if (t3lib_extmgm::isLoaded('ard_mcm') ) {
$this->langHandler->override($loda[0],$loda[2],$loda[3]);
} else {
$this->LOCAL_LANG['langoverride'][$loda[0]][$loda[2]]=$loda[3];
//$this->langOverrides[$loda[0]][$loda[1]][$loda[2]]=$loda[3];
}
}
}
/**
* initFieldsCmd
*
* @param [type] $$conf: ...
* @param [type] $cmd: ...
* @return [type] ...
*/
function initFieldsCmd(&$conf,$cmd) {
$table=$conf['table'];
/**** DO ADDITIONAL REQUIRED STUFF FOR THE FIELDS ****/
if (!$conf[$cmd.'.']['show_fields']) $conf[$cmd.'.']['show_fields']=$conf['TCAN'][$table]["interface"]["showRecordFieldList"];
$fieldArray = explode(',',$conf[$cmd.'.']['show_fields']);
$farr=array();
$fieldstoberemoved=array();
foreach((array)$fieldArray as $fN) { //runs through the different fields
$fN=trim($fN);
// make sure --div-- is in allowed fields list
$parts = explode(";",$fN);
if(!($conf['TCAN'][$table]['columns'][$fN]['config']['type']=='group' && $conf['TCAN'][$table]['columns'][$fN]['config']['internal_type']=='db' && count(t3lib_div::trimexplode(',',$conf['TCAN'][$table]['columns'][$fN]['config']['allowed']))>1)) {
if($parts[0]=='--div--') {
if (trim($parts[1])) {
$conf[$cmd.'.']['fields'] = $conf[$cmd.'.']['fields'] ? $conf[$cmd.'.']['fields'].','.$parts[1] : $parts[1];
// CBY $farr[]=$parts[1]; fixes bug on tabs not being shown ...
$farr[]=$parts[0].';'.$parts[1];
}
} else {
if ($fN) {
$conf[$cmd.'.']['fields'] = $conf[$cmd.'.']['fields'] ? $conf[$cmd.'.']['fields'].','.$fN : $fN;
$farr[]=$fN;
}
}
}
// CBY :: here we handle the new evalValues mecanism if empty we take the default config.eval value
// here whe should merge the eval arrays ....
if(!$conf[$cmd.'.']['evalValues.'][$fN] && $conf['TCAN'][$table]['columns'][$fN]['config']['eval']) $conf[$cmd.'.']['evalValues.'][$fN]= $conf['TCAN'][$table]['columns'][$fN]['config']['eval'];
// do stuff according to type from TCA
switch((string)$conf['TCAN'][$table]['columns'][$fN]['config']['type']) {
case 'group':
if($conf['TCAN'][$table]['columns'][$fN]['config']['internal_type']=='file') {
// CBY I removed _file handling here...
//We could add folder specialisation here ...
// modif by CMD - permet d'eviter les message d'errreur suite � la gestion des champs suppl�mentaire sql ou php calcul�
$conf['TCAN'][$table]['columns'][$fN.'_file'] = $conf['TCAN'][$table]['columns'][$fN]; // the new upload field should have the same upload folder as the original field
$conf['TCAN'][$table]['columns'][$fN.'_file']['imagealiasfield']=$fN;
//$conf['TCAN'][$table]['columns'][$fN.'_file']['config']['uploadfolder'] = $conf['TCAN'][$table]['columns'][$fN]['config']['uploadfolder']; // the new upload field should have the same upload folder as the original field
$conf['parseValues.'][$fN.'_file'] = 'files['.preg_replace('/,/',';',$conf['TCAN'][$table]['columns'][$fN]['config']['allowed']).']['.$conf['TCAN'][$table]['columns'][$fN]['config']['max_size'].']'; // adds the parse options for the new field, so it will be parsed as a file.
}
}
}
$conf[$cmd.'.']['show_fields']=implode(',',array_unique($farr));
$conf[$cmd.'.']['fields']=implode(',',array_unique(t3lib_div::trimExplode(',',$conf[$cmd.'.']['fields']))); // TODO : Why must we clean up here ?
}
/**
* initCmd
*
* @param [type] $$conf: ...
* @return [type] ...
*/
function initCmd(&$conf) {
$cmd=$conf['inputvar.']['cmd'];
$this->initFieldsCmd($conf,'create');
$this->initFieldsCmd($conf,'edit');
$this->initFieldsCmd($conf,'list');
$this->metafeeditlib->getFieldList($conf);
/**** CHECK IF LOGIN IS REQUIRED ****/
//CBY: if($conf['requireLogin'] && !$GLOBALS['TSFE']->loginUser) return $this->metafeeditlib->getLL("login_required_message",$conf);
/**** FE ADMIN LIB ****/
//$conf['parentObj']=&$this;
$conf["templateContent"]= $this->getDefaultTemplate($conf); // gets the default template
// generate default template in browser if required to.
if ($conf['generateTemplate']){
echo $conf["templateContent"];
die();
}
if ($conf['fetemplate']&& $conf['useTemplate']) {
$conf["templateContent"]=$conf['fetemplate'];
}
// CBY>
$conf["templateContentOptions"]=$conf['templateContent']; // can this be removed ?
$conf['parentObj']=&$this;
$conf["templateContent"]=$this->metafeeditlib->replaceOptions($conf["templateContent"],$conf,$cmd,$this->table,'');
return $conf;
}
/* mergeExtendingTCAs($ext_keys)
*
* In case you wrote an extension, that extends the table "$table", then
* the TCA information for the additional fields will be merged with the "$table" TCA.
*
* @param array Extension TCA's that should be merged.
* @return [type] ...
*/
function mergeExtendingTCAs($ext_keys){
global $_EXTKEY, $TCA;
//Merge all ext_keys
if (is_array($ext_keys)) {
for($i = 0; $i < sizeof($ext_keys); $i++){
//Include the ext_table
$_EXTKEY = $ext_keys[$i]; // added by F.Rakow
if ($_EXTKEY) include(t3lib_extMgm::extPath($ext_keys[$i]).'ext_tables.php');
}
}
}
/**********************************************************************************************
* TEMPLATE FUNCTIONS
**********************************************************************************************/
/**
* Gets a default template made from the TCA.
* The template there is returned depends on what $this->cmd is.
*
* @param [type] $$conf: ...
* @return [type] ...
*/
function getDefaultTemplate(&$conf) {
//error_log(__METHOD__.':'.$conf['piVars']['exporttype']);
$nbCols = $this->piVars['nbCols'];
if ($conf['generateTemplate']||$conf['general.']['tplCache']){ // We generate all templates
//error_log(__METHOD__.':cache'.$conf['piVars']['exporttype']);
if ($conf['general.']['tplCache']) {
$tpl=$this->getTemplate('full',$conf);
if ($tpl) {
//error_log(__METHOD__.'Used Cached Template');
return $tpl;
}
}
$template = $this->getRequiredTemplate($conf);
$template .= $this->getEmailTemplate($conf);
$template .= $this->getEditTemplate($conf);
$template .= $this->getListTemplate($conf);
//error_log(__METHOD__.':l '.print_r($conf['list.'],true));
if ($conf['list.']['csv']) $template .= $this->getCSVTemplate($conf);
if ($conf['list.']['xls']) $template .=$this->getExcelTemplate($conf);
if ($conf['list.']['pdf']) $template .= $this->getPDFTemplate($conf);
if ($conf['list.']['pdf'] || $conf['edit.']['pdf']) $template .= $this->getPDFDETTemplate($conf);
if ($conf['list.']['pdf']) $template .= $this->getPDFTABTemplate($conf);
if ($conf['grid.']['pdf']) $template .= $this->getGridPDFTemplate($conf);
if ($conf['grid.']['csv']) $template .= $this->getGridCSVTemplate($conf);
if ($conf['grid.']['xls']) $template .= $this->getGridExcelTemplate($conf);
$template .= $this->getCreateTemplate($conf);
$template .= $this->getDeleteTemplate($conf);
$template .= $this->getSetfixedTemplate($conf);
$this->saveTemplate('full',$template,$conf);
} else {
$template = $this->getRequiredTemplate($conf);
$template .= $this->getEmailTemplate($conf);
//error_log(__METHOD__.':nocache'.$conf['inputvar.']['cmd']);
switch((string) $conf['inputvar.']['cmd']) {
case 'edit':
$template .= $this->getEditTemplate($conf);
if ($conf['list.']['pdf'] || $conf['edit.']['pdf']) {
$template .= $this->getPDFDETTemplate($conf);
//$template .= array_search('getGridPDFTemplate',$callerMethods) || array_search('getGridPDFTemplate',$callerMethods)? $this->caller->getGridPDFTemplate($conf) : $this->getGridPDFTemplate($conf);
}
//$template .= array_search('getListTemplate',$callerMethods) || array_search('getListTemplate',$callerMethods)? $this->caller->getListTemplate($conf) : $this->getListTemplate($conf);
$template .=$this->getMediaPlayerTemplate($conf);
case 'list':
// We load edit templates in list mode if editUnique is set.
if ($conf['editUnique']) {
$template .= $this->getEditTemplate($conf);
}
$template .= $this->getListTemplate($conf);
if ($conf['piVars']['exporttype']) {
//error_log(__METHOD__.':'.$conf['piVars']['exporttype']);
if ($conf['list.']['csv']) $template .= $this->getCSVTemplate($conf);
if ($conf['list.']['xls']) $template .= $this->getExcelTemplate($conf);
if ($conf['list.']['pdf']) $template .= $this->getPDFTemplate($conf);
if ($conf['list.']['pdf']) $template .= $this->getPDFTABTemplate($conf);
//if ($conf['grid.']['csv']) $template .= array_search('getGridCSVTemplate',$callerMethods) || array_search('getGridCSVTemplate',$callerMethods)? $this->caller->getGridCSVTemplate($conf) : $this->getGridCSVTemplate($conf);
//if ($conf['grid.']['xls']) $template .= array_search('getGridExcelTemplate',$callerMethods) || array_search('getGridExcelTemplate',$callerMethods)? $this->caller->getGridExcelTemplate($conf) : $this->getGridExcelTemplate($conf);
}
break;
case 'create':
$template .= $this->getCreateTemplate($conf);
$template .= $this->getEditTemplate($conf);
/*if ($conf['list.']['pdf'] || $conf['edit.']['pdf']) {
$template .= array_search('getPDFDETTemplate',$callerMethods) || array_search('getPDFDETTemplate',$callerMethods)? $this->caller->getPDFDETTemplate($conf) : $this->getPDFDETTemplate($conf);
}
$template .= array_search('getmediaplayertemplate',$callerMethods) || array_search('getMediaPlayerTemplate',$callerMethods)? $this->caller->getMediaPlayerTemplate($conf): $this->getMediaPlayerTemplate($conf);
*/
break;
case 'delete':
$template .= $this->getDeleteTemplate($conf);
$template .= $this->getListTemplate($conf);
break;
case 'setfixed':
$template .= $this->getSetfixedTemplate($conf);
break;
default:
debug('meta_feedit->getDefaultTemplate():: No template found for cmd='.$conf['inputvar.']['cmd'],'No Template');
$template = '';
}
}
return $template;
}
/**
* Makes the form content from the TCA according to the configuration for the $cmd
*
* @param string The cmd. Should be 'edit' or 'create'.
* @param [type] $conf: ...
* @return [type] ...
*/
function makeHTMLForm($cmd,&$conf) {
//$fields = array_intersect( array_unique(t3lib_div::trimExplode(",",$conf[$cmd.'.']['show_fields'],1)) , array_unique(t3lib_div::trimExplode(",",$conf[$cmd.'.']['fields'],1)));
//$reqFields = array_intersect( array_unique(t3lib_div::trimExplode(",",$conf[$cmd.'.']["required"],1)) , array_unique(t3lib_div::trimExplode(",",$conf[$cmd.'.']['show_fields'],1)));
$fields = t3lib_div::trimExplode(",",$conf[$cmd.'.']['show_fields'],1);
$reqFields = t3lib_div::trimExplode(",",$conf[$cmd.'.']["required"],1);
$out_array = array();
$out_sheet = 0;
$fsc=0;
$fsi=0;
$tabLabels=explode(chr(10),$conf["tabLabels"]);
// avoid JS conflict errors !!!
$this->RTEcounter=0;
while(list(,$fN)=each($fields)) {
$parts = explode(';',$fN);
$fN = $parts[0];
if($fN=='--div--') {
if($conf["divide2tabs"]) {
$out_sheet++;
$out_array[$out_sheet] = array();
$out_array[$out_sheet]['title'] = $this->metafeeditlib->getLL($parts[1]?$parts[1]:'Tab '.$out_sheet,$conf);
//$out_array[$out_sheet]['title'] = $tabLabels[$out_sheet]?$tabLabels[$out_sheet]:'Tab '.$out_sheet;
}
} else {
if($fN=='--fse--' && $fsc) {
$out_array[$out_sheet][]='</fieldset></div>';
$fsc--;
}
if($fN=='--fsb--') {
if ($fsc) {
$out_array[$out_sheet][]='</fieldset></div>';
$fsc--;
}
$fsc++;
$fsclib='';
if ($conf['list.']['fieldSetNames.'][$fsi]) $fsclib='<legend>'.$conf['list.']['fieldSetNames.'][$fsi].'</legend>';
$out_array[$out_sheet][]='<div class="'.$this->caller->pi_getClassName('form-row').'"><fieldset>'.$fsclib;
$fsi++;
}
if ($fN=='--fse--' || $fN=='--fsb--') {
continue;
}
$fieldCode = $this->getFormFieldCode($cmd,$conf,$fN,0,$cmd);
if ($fieldCode) {
// NOTE: There are two ways to make a field required. The new way is to include 'required' in evalValues for a field. The old one is to have the the field in the required list.
// The new way take precedence over the old way. So if the new field has some evalValues, it makes no different if the field is in the required list or not.
$feData=$conf['inputvar.']['fedata'];
$msg = '';
$reqMarker = '';
if($conf[$cmd.'.']['evalValues.'][$fN]) { // evalValues defined
$reqMarker = in_array('required',t3lib_div::trimExplode(',',$conf[$cmd.'.']['evalValues.'][$fN])) ? $conf['required_marker'] : '';
}
if (in_array($fN,$reqFields)) { // No evalValues, but field listed in required list.
$msg .= '<!--###SUB_REQUIRED_FIELD_'.$fN.'###--><div class="'.$this->caller->pi_getClassName('form-error-field').' '.$this->caller->pi_getClassName('form-required-message').'">'.($conf['evalErrors.'][$fN.'.']['required']?$conf['evalErrors.'][$fN.'.']['required']:$this->metafeeditlib->getLL("required_message",$conf)).'</div><!--###SUB_REQUIRED_FIELD_'.$fN.'###-->';
//$msg .= '<!--###SUB_REQUIRED_FIELD_'.$fN.'###--><div'.$this->caller->pi_classParam('form-required-message').'>'.($conf['evalErrors.'][$fN.'.']['required']?$conf['evalErrors.'][$fN.'.']['required']:$this->metafeeditlib->getLL("required_message",$conf)).'</div><!--###SUB_REQUIRED_FIELD_'.$fN.'###-->';
$reqMarker = $conf['required_marker'];
}
$helpIcon = ($conf['show_help_icons'] ? '<div'.$this->caller->pi_classParam('form-help-icon').'>'.$this->helpIcon($fN).'</div>' : '');
$tab=array();
$res=$this->metafeeditlib->getForeignTableFromField($fN,$conf,'',$tab,__METHOD__);
$table=$res['relTable'];
$fNiD=$res['fNiD'];
$masterTable=$cmd=='blog'?'tx_metafeedit_comments':$conf['table'];
$evclasses='';
$evals=t3lib_div::trimexplode(',',$conf['TCAN'][$masterTable]['columns'][$fN]['config']['eval']);
foreach($evals as $ev) {
$evclasses.=' '.$this->caller->pi_getClassName('form-data-'.$ev);
}
$label = $this->metafeeditlib->getLLFromLabel($conf['TCAN'][$table]['columns'][$fNiD]['label'],$conf);
$out_array[$out_sheet][]='<div class="'.$this->caller->pi_getClassName($fsc?'fsc':'form-row').' '.$this->caller->pi_getClassName(($fsc?'fsc-':'form-row-').$fN).'">
<div class="'.$this->caller->pi_getClassName($fsc?'fsl':'form-label').' '.$this->caller->pi_getClassName(($fsc?'fsl-':'form-label-').$fN).'">
<div'.$this->caller->pi_classParam($fsc?'fsrm':'form-required-marker').'>'.$reqMarker.'</div>
'.$label. '
'.$helpIcon.'
</div>
<div class="###CSS_ERROR_FIELD_'.$fN.'###'.$this->caller->pi_getClassName($fsc?'fsf':'form-field').$evclasses.'">'.$fieldCode.'</div>'.$msg.'</div>';
}
}
}
if ($out_sheet>0) { // There were --div-- dividers around. Create parts array for the tab menu:
$parts = array();
foreach($out_array as $idx => $sheetContent) {
unset($sheetContent['title']);
$parts[] = array(
'label' => $out_array[$idx]['title'],
'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td>'.
implode(chr(10),$sheetContent).
'</td></tr></table>'
);
}
$content = $this->addCallersPiVars($this->templateObj->getDynTabMenu($parts, 'TCEforms:'.$table.':'.$row[$conf['uidField']]),$conf);
} else { // Only one, so just implode:
$content = is_array($out_array[$out_sheet]) ? $this->addCallersPiVars(implode(chr(10),$out_array[$out_sheet]),$conf) : 'makeHTMLForm() :: No form generated! (Probably no fields defined in typoscript option show_fields)';
}
return $content;
}
/**
* Returns a help icon for the field
*
* @param string The field to get the help icon for
* @param boolean The help icon with link to javascript popup, with help in.
* @return [type] ...
*/
function helpIcon($field) {
if(!is_array($GLOBALS['TCA_DESCR'][$this->table]['refs'])) return '';
foreach($GLOBALS['TCA_DESCR'][$this->table]['refs'] as $ref) {
$fieldDescription = $GLOBALS['TSFE']->sL('LLL:'.$ref.':'.$field.'.description') .' ';
}
if(empty($fieldDescription)) return '';
else {
// $aOnClick = 'confirm(\''.$fieldDescription.'\');return false;';
$fieldDescription = '<html><head><title>'.$field.'</title><style type="text/css">'.preg_replace("(\r)"," ",preg_replace("(\n)"," ",$conf['help_window_style'])).'</style></head><body'.$this->caller->pi_classParam('help-body').'><div'.$this->caller->pi_classParam('help-text').'>'.$fieldDescription.'</div></body></html>';
$aOnClick = 'top.vHWin=window.open(\'\',\'viewFieldHelpFE\',\'height=20,width=300,status=0,menubar=0,scrollbars=1\');top.vHWin.document.writeln(\''.$fieldDescription.'\');top.vHWin.document.close();top.vHWin.focus();return false;';
$script ='';
require_once(PATH_t3lib . 'class.t3lib_iconworks.php');
return
'<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
'<img'.t3lib_iconWorks::skinImg('typo3/','gfx/helpbubble.gif','width="14" height="14"').' hspace="2" border="0" class="absmiddle"'.($GLOBALS['CLIENT']['FORMSTYLE']?' style="cursor:help;"':'').' alt="" />'.
'</a>';
}
}
/**
* Makes a preview of the form content according to the configuration for the $cmd
*
* @param string The cmd. Should be 'edit' or 'create' or 'all'.
* @param boolean Should the output be wrapped in html or not.
* @param [type] $withHTML: ...
* @return [type] ...
*/
function makeHTMLPreview($cmd,&$conf, $withHTML = true) {
$fields = (string)$cmd=='all' ? array_unique(t3lib_div::trimExplode(",",($conf['create.']['show_fields'] ? $conf['create.']['show_fields'].($conf['edit.']['show_fields']?','.$conf['edit.']['show_fields']:'') : $conf['edit.']['show_fields']))) : array_unique(t3lib_div::trimExplode(",",$conf[$cmd.'.']['show_fields']));
$result = array();
$out_array = array();
$out_sheet = 0;
$hiddenFields = array();
foreach((array)$fields as $fN) {
$parts = explode(';',$fN);
$fN = $parts[0];
if ($fN=='--fse--' || $fN=='--fsb--') {
continue;
}
if($fN=='--div--') {
if($conf["divide2tabs"]&&$cmd!='all') {
$out_sheet++;
$out_array[$out_sheet] = array();
//DOESN'T WORK !!
// $out_array[$out_sheet]['title'] = $this->metafeeditlib->getLL($parts[1],$parts[1]?$parts[1]:'Tab '.$out_sheet,$conf); //OUCH
$out_array[$out_sheet]['title'] = $parts[1]?$parts[1]:'Tab '.$out_sheet; //OUCH
}
} else {
$sql=array();
$res=$this->metafeeditlib->getForeignTableFromField($fN,$conf,'',$sql,__METHOD__);
$table=$res['relTable'];
$fNiD=$res['fNiD'];
$label = $this->metafeeditlib->getLLFromLabel($conf['TCAN'][$table]['columns'][$fNiD]['label'],$conf);
$fieldCode = $this->getPreviewFieldCode($cmd,$conf, $fN, $withHTML);
$reptagbegin='<!-- ###editITEM-'.$fN.'### start -->';
$reptagend='<!-- ###editITEM-'.$fN.'### end -->';