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 1
/
tca.php
executable file
·751 lines (586 loc) · 15.9 KB
/
tca.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
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');
$GLOBALS['tx_cabag_import-availableOptions'] = '
# storage which writes the rows
storage = tce
storage {
dontUpdateFields = password
dontUsePidForKeyField = 0
# needed for ordering records in TYPO3
// moveAfterField = myFunnyFieldWithUIDofpreviousRecord
}
# Here, no mm fieldproc is possible!
storage = sql
storage {
dontUpdateFields = password
tablekeys = uid_local, uid_foreign
# if isset to 1, tstamp will be inserted, needed for deleteObsolete!
setTstamp = 0
# sets the pid if enabled (sql storage does not set any default fields)
setPid = 0
# you can use a different database as storage (just mysql support for the moment)
# Host of the mssql database
//host = hostname,port
# login user for the connection
//user =
# login password for the connection
//password =
# database to connect to
//database =
}
# Here, no mm fieldproc and no update is possible!
storage = csv
storage {
fields {
# additional information needed for the fields
# maps a field with a title that has spaces
writeTitleRow = 1
fields {
doctorid.title = Doctor ID
userid.title = User ID
}
# fills the field with the timestamp of the handler
tstamp.isTstamp = 1
}
file {
# path must exist and be relative to the TYPO3 directory
path = fileadmin/user_uploads/tx_cabagimport/some_file.csv
# if set to overwrite, the file (if it exists) will be cleared and overwritten
mode = overwrite
# if set to append, the file will have the rows appended
mode = append
# if neither overwrite nor append is set and the file exists, a new file will be created like \'some_file_1.csv\'
}
# csv delimiter between each field
delimiter = ,
// delimiter.chr = 9
# enclosure for a field
enclosure = "
// enclosure.chr = 32
}
source = file
source {
# in KB
maxFileSize = 10000
archivePath = uploads/tx_cabagimport/
# path to the file (overwrithen by mod1 input)
// filePath = fileadmin/user_upload/import/alwaysthesamename.csv
# set to 1 to prevent file source from doing this in php: PATH_site.filePath
// absoluteFilePath = 0
# search for file within path (overwrithen by filePath)
searchPath = fileadmin/user_upload/import
searchPath {
preg_match = .*importname.*
}
# interpreter which parses the data
interpret = csv
interpret {
# csv options
delimiter = ,
# for ascii codes like tab
// delimiter.chr = 9
enclosure = "
# don\'t use the native fgetcsv (stores the whole file in the RAM -> DON\'T USE IF THAT IS AN ISSUE)
dontUsePHPFunction = 0
# uses trim() on the values of the first row -> only usable in conjunction with dontUsePHPFunction
trimFirstRow = 0
}
# executes sed for the importing file before importing it, this example fixes mac line endings
preImportSedExpression = s/\r/\n/g
interpret = xml
interpret {
recordPath = channel,0,ch,item
}
}
# select data from a mysql server
source = mysql
source {
# if not access data is set the TYPO3 database connection is used (NO DBAL SUPPORT!)
# Host of the mysql database
host =
# login user for the connection
user =
# login password for the connection
password =
# database to connect to
database =
# query for the import
query =
}
# select records from a tree in the current typo3 system
source = recordsintree
source {
# name of the record table
table = tt_content
# starting parent page uid
pid = 44
# additional where
addWhere = AND hidden = 1
}
source = mssql
source {
# Host of the mssql database
host = hostname,port
# login user for the connection
user =
# login password for the connection
password =
# database to connect to
database =
# do not select a database (database must be preselected by mssql server)
noDatabase = 1
# query for the import
query =
# The number of records to batch in the buffer.
batchSize =
}
# converts xls to csv
source = xls
source {
# in KB
maxFileSize = 10000
archivePath = uploads/tx_cabagimport/
# force charset if you have problems with umlaute
forceCharset = en_US.UTF-8
# interpreter which parses the data
interpret = csv
interpret {
# csv options
delimiter = ,
enclosure = "
}
}
source = ldap
source {
# IP Address of username
server =
# most commonly 389
port = 389
# username. This has to be the complete path to the user in the AD tree
rdn =
# password
password =
# path where to search in
base_dn = OU=Switzerland,OU=Feintool,DC=ft,DC=feintool,DC=local
# filter rules. See php ldap docu for further filters
filter = (&(objectClass=user)(objectCategory=person))
}
handler {
# table to import to
table = tx_xy
# row to start the import from
// rangeFrom = 0
# row to end the import
// rangeTo = 1000
# fields to identify records and rows
keyFields = field_xy
# delete records which are not within the import
deleteObsolete = 0
deleteObsolete.addWhere = sys_language_uid = 0 AND type = 0
# does the first row contain the labels or data
firstRowAreKeys = 1
# pid where to place the records
# if not set the pid selected in the backend module will be used!
defaultPid = 2
# continue with the next row if a row is invalid
continueAfterInvalidRow = 0
# import source charset
in_charset = CP1252
# database charset
out_charset = UTF-8
# if set {$currentRowNumber} contains the current number of the row starting from 1
addCurrentRowNumber = 0
}
mapping {
pid {
# define dynamic pid here or use instead of defaultPid
}
if_preg_match_example {
stack {
1 = TEXT
1.value = {$textfield}
2 = if_preg_match
2 {
pattern = /(cabag)/i
# optional returns specific match
returnMatchPosition = 0
}
}
}
preg_match_keys_example {
required = 1
stack {
2 = preg_match_keys
2 {
searchfor = /tx_cabag(.*)/
# implode string must be between two #\'s
implodeString = #, #
}
}
}
tx_templavoila_flex {
stack {
1 = maptranslations
1 {
flex = {$tx_templavoila_flex}
}
}
}
userhome_mkdir_example {
stack {
# creates directory from value or currentFieldValue and returns path as next currentFieldValue
1 = mkdir
1 {
# creates all folders in the path if not existing
deep = 1
# path relative to PATH_site
value = fileadmin/user_upload/users/{$username}
}
}
}
select_example {
# if set the value has to be != 0 and not empty otherwise the import will be stoped
required = 1
stack {
# sql statement -> first field of the first row will be taken
1 = select
1.sql = SELECT field_x FROM table WHERE field_y = \'{$ImportFieldX}\'
}
}
cachedtransformselect_example {
# if set the value has to be != 0 and not empty otherwise the import will be stoped
required = 1
stack {
# selects the table at the first run and reuses the result for transformation!
1 = cachedtransformselect
1.sql = SELECT field_from, field_to FROM table WHERE deleted=0
# the result will be the field_to which is in the same row as the field_from that matches your {$yourfunnyfield}
1.transform = {$yourfunnyfield}
# you can define a cache id so you can use the same cache for several fieldprocs
1.cacheid = funnyid
}
}
direct_selection = ImportFileX
date_example {
required = 1
stack {
1 = TEXT
1.value = {$Startdatum}
# perl regular expression replacement
2 = preg_replace
2 {
from = (\d\d)\.(\d\d)\.(\d\d\d\d)
to = $3-$2-$1
}
# strtotime for the current value
3 = strtotime
3.default = 0
}
}
passwordgen_example {
# unsets the field if it is empty (workaround for certain TCE defaults
unsetIfEmpty = 1
stack {
1 = passwordgen
1 {
# how many chars do you want
length = 8
# if set alphanumeric password is generated, default is numeric
alphanum = 1
}
2 = sendmail
2 {
# the recipient adress (can be static)
recipient = {$email}
# from
from = [email protected]
# subject of the mail
subject = This is a mail of the import system.
# text for the mail
bodytext (
Hello {$name}
This is your new password: {$currentFieldValue}
Best regards
Your cabag_import
)
# if this sql select returns a empty result the mail will be sent
sendIfNoResultSQLSelect = SELECT uid FROM fe_users WHERE keyfield = {$keyfield}
}
}
}
transform_example {
stack {
1 = transform
1 {
# use value like TEXT fieldproc or do a own stack part for TEXT fieldproc before
value = {$Kategorie}
transform {
sourcevalue1 = destvalue1
sourcevalue2 = destvalue2
}
# a default value is always needed
default = defaultvaluexyz
}
}
}
files_example {
required = 1
stack {
1 = TEXT
1.value = {$Bildname}
2 = files
2 {
# find the right file in the sourceFolder
preg_match = /.*{$currentFieldValue}[^\/]*.jpg/
sourceFolder = fileadmin/user_upload/shop_images/
# Search recursive from the sourceFolder
recursive = 1
# move the founded file to the destination folder
destinationFolder = uploads/tx_cabagshop/
# rename the founded file in the destination folder
rename = {$currentFieldValue}-{$fieldProcFilesNumber}.jpg
# Clear the currentFieldValue if no image was found
clearCurrentFieldValueIfNothingFound = 0
# uses exec with find/grep instead of php functions
useFindGrep = pattern...
# custom shell cmd
useCustomCmd = shell cmd
# returns imploded filelist
onlyReturnFoundFiles = 0
# implode char
onlyReturnFoundFilesImplodeChr = ,
}
}
}
copy_file_example {
required = 1
stack {
1 = copyfile
1 {
sourcebasepath = http://www.domain.ch/
# if source path is empty nothing will done
sourcepath = {$pdfpath}
dontCopyIfExists = 1
createFilename = {$filenametouse}.jpg
# filename will be trimmed
trimFilename = 1
# continue if filename is empty
skipEmptyFilename = 1
# if set then only this filetypes are allowed
allowedFiletypes = jpg,jpeg,gif,png
destinationpath = /fileadmin/user_upload/events/
# return just the filename if you have ie. a TCA file field
returnJustFilename = 0
# slow but supports curl/proxy
//useGetURL = 1
# enables splitting
// split = ,
# overwrithe if exists
overwrithe = 1
}
2 = TEXT
2 {
value = <LINK $currentFieldValue>{$pdftitle}</LINK>
}
}
}
dam_copy_file_example {
required = 1
stack {
1 = copyfile
1 {
sourcebasepath = http://www.domain.ch/
# if source path is empty nothing will done
sourcepath = {$pdfpath}
dontCopyIfExists = 1
createFilename = {$filenametouse}.jpg
# filename will be trimmed
trimFilename = 1
# continue if filename is empty
skipEmptyFilename = 1
# if set then only this filetypes are allowed
allowedFiletypes = jpg,jpeg,gif,png±
destinationpath = /fileadmin/user_upload/events/
# return just the filename if you have ie. a TCA file field
returnJustFilename = 0
# slow but supports curl/proxy
//useGetURL = 1
# enables splitting
// split = ,
# overwrithe if exists
overwrithe = 1
}
# creates a dam realtion and index file
# attention this has to be done in a secon import as you have the uid of the record in the storage
2 = dam
2 {
# semicolon separated list of files
singleFile = {$currentFieldValue}
# field name to relate to
fieldNameToRelateTo = picture
selectUidToRelateTo = SELECT uid FROM tx_xxx WHERE somereferencefield = {$referencefromimportsomefieldXXX} AND deleted=0
# table name to relate to
tableNameToRelateTo = tx_xxx
# data to put into DAM table
damPresetData {
copyright = {$img1_credit}
}
}
}
}
1n_relation_example {
required = 1
stack {
1 = TEXT
1.value = {$Ort}
# 1 to n relation
2 = relation
2 {
# table of the related records
relationtable = tx_xyz
# field to search for and where the value is saved
# if the searched one is missing
relationfield = fieldxyz
# additional condition for searching the relation record
relationaddwhere = AND sys_language_uid=0
# pid of the related records
# (if not set global import pid will be taken)
relationpid = 208
# add record if not found
addIfMissing = 1
}
}
}
mm_relation_example {
required = 1
stack {
1 = TEXT
1.value = {$1}
# m to m relation
2 = mm
2 {
# split value for relation
split = ,
# split alternative for newline
split.newline = 1
# possibility to restrict the relation to a position within
# the value
splitUseOnlyPosition = 1
# table to relate to
table = tx_cabagshop_category
# field to relate to and add value if record is missing
tablekeyfield = catalogkey
# set to 1 so search in the tablekeyfield with LIKE %value%
tablekeyfieldlike = 0
# pid for the relation records
# (if not set global import pid will be taken)
tablepid = 109
# add record if not found
addIfMissing = 1
# table for the mm relation records
mmtable = tx_cabagshop_article_category_mm
# field in the mm table which relates to the related table
mmtablefield = uid_foreign
}
}
}
save_to_raw_row_example {
stack {
1 = TEXT
1.value = $someField
2 = save_to_raw_row
2.field = random_field_name
3 = preg_replace
3.from = /{$random_field_name}/
3.to = {$someOtherField}
}
}
copypage_example {
stack {
1 = select
1.sql = SELECT uid FROM pages WHERE pid = 1212 AND deleted = 0 AND hidden = 0
2 = copypage
2 {
# destinationpid, otherwise its {$currentFieldValue}
# destinationpid = 1287
sourcepid = 345
# Sets the number of branches on a page tree to copy.
copyTree = 0
# clear page cache afterwards
clearPageCache = 0
}
3 = copypage
3 {
# destinationpid, otherwise its {$currentFieldValue}
# destinationpid = 1287
sourcepid = 51
# Sets the number of branches on a page tree to copy.
copyTree = 0
# clear page cache afterwards
clearPageCache = 0
}
}
}
}
';
if(!function_exists('tx_cabagimport_showavailableOptions')) {
function tx_cabagimport_showavailableOptions() {
return '
<div style="height:500px; width:600px; overflow:scroll;">
<pre>'.htmlspecialchars($GLOBALS['tx_cabag_import-availableOptions']).'</pre>
</div>';
}
}
$TCA["tx_cabagimport_config"] = array (
"ctrl" => $TCA["tx_cabagimport_config"]["ctrl"],
"interface" => array (
"showRecordFieldList" => "hidden,title,configuration"
),
"feInterface" => $TCA["tx_cabagimport_config"]["feInterface"],
"columns" => array (
'hidden' => array (
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
'config' => array (
'type' => 'check',
'default' => '0'
)
),
"title" => Array (
"exclude" => 0,
"label" => "LLL:EXT:cabag_import/locallang_db.xml:tx_cabagimport_config.title",
"config" => Array (
"type" => "input",
"size" => "30",
"eval" => "required",
)
),
"configuration" => Array (
"exclude" => 0,
"label" => "LLL:EXT:cabag_import/locallang_db.xml:tx_cabagimport_config.configuration",
"config" => Array (
"type" => "text",
"cols" => "300",
"rows" => "500",
"default" => $GLOBALS['tx_cabag_import-availableOptions'],
),
"defaultExtras" => "fixed-font : enable-tab",
),
"availableOptions" => array(
"exclude" => 0,
"label" => "LLL:EXT:cabag_import/locallang_db.xml:tx_cabagimport_config.availableOptions",
"config" => Array (
"type" => "user",
"userFunc" => 'tx_cabagimport_showavailableOptions',
"noTableWrapping" => 0,
),
)
),
"types" => array (
"0" => array("showitem" => "hidden;;1;;1-1-1, title;;;;2-2-2, configuration, availableOptions")
),
"palettes" => array (
"1" => array("showitem" => "")
)
);
?>