-
Notifications
You must be signed in to change notification settings - Fork 1
/
modx.ddtools.class.php
3156 lines (2873 loc) · 79.6 KB
/
modx.ddtools.class.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
/**
* EvolutionCMS.libraries.ddTools
* @version 0.64.1 (2024-12-04)
*
* @see README.md
*
* @copyright 2012–2024 https://Ronef.me
*/
global $modx;
if (!class_exists('ddTools')){
class ddTools {
public static $modx;
// Contains names of document fields (`site_content`)
public static $documentFields = [
'id',
'type',
'contentType',
'pagetitle',
'longtitle',
'description',
'alias',
'alias_visible',
'link_attributes',
'published',
'pub_date',
'unpub_date',
'parent',
'isfolder',
'introtext',
'content',
'richtext',
'template',
'menuindex',
'searchable',
'cacheable',
'createdby',
'createdon',
'editedby',
'editedon',
'deleted',
'deletedon',
'deletedby',
'publishedon',
'publishedby',
'menutitle',
'donthit',
'haskeywords',
'hasmetatags',
'privateweb',
'privatemgr',
'content_dispo',
'hidemenu'
];
// Contains full names of db tables
public static $tables = [
// System
'categories' => '',
'event_log' => '',
'manager_log' => '',
'manager_users' => '',
'system_eventnames' => '',
'system_settings' => '',
// Documents
'site_content' => '',
'documentgroup_names' => '',
'document_groups' => '',
// Templates
'site_templates' => '',
// Chunks
'site_htmlsnippets' => '',
// TVs
'site_tmplvars' => '',
'site_tmplvar_access' => '',
'site_tmplvar_contentvalues' => '',
'site_tmplvar_templates' => '',
// Snippets
'site_snippets' => '',
// Plugins
'site_plugins' => '',
'site_plugin_events' => '',
// Modules
'site_modules' => '',
'site_module_access' => '',
'site_module_depobj' => '',
// Users
'membergroup_access' => '',
'membergroup_names' => '',
'member_groups' => '',
'active_users' => '',
'active_user_locks' => '',
'active_user_sessions' => '',
'user_attributes' => '',
'user_messages' => '',
'user_roles' => '',
'user_settings' => '',
'webgroup_access' => '',
'webgroup_names' => '',
'web_groups' => '',
'web_users' => '',
'web_user_attributes' => '',
'web_user_settings' => ''
];
private static $instance;
/**
* __construct
* @version 1.0.7 (2024-12-03)
*/
private function __construct(){
global $modx;
self::$modx = $modx;
// Init full table names
foreach (
self::$tables
as $tableAlias
=> $tableFullName
){
self::$tables[$tableAlias] = self::$modx->getFullTableName($tableAlias);
}
// We need to include required files if Composer is not used
if(!class_exists('\DDTools\Tools\Files')){
require_once(
__DIR__
. DIRECTORY_SEPARATOR
. 'require.php'
);
}
}
private function __clone(){}
/**
* getInstance
* @version 1.0.1 (2024-12-03)
*/
public static function getInstance(){
global $modx;
if(
isset($modx)
&& !self::$instance
){
self::$instance = new ddTools();
}
return self::$instance;
}
/**
* isEmpty
* @version 1.0 (2024-06-07)
*
* @see README.md
*
* @return {boolean}
*/
public static function isEmpty($value = null): bool {
return
is_object($value)
? empty((array) $value)
: empty($value)
;
}
/**
* orderedParamsToNamed
* @version 1.1.8 (2024-12-03)
*
* @desc Convert list of ordered parameters to named. Method is public, but be advised that this is beta-version!
*
* @param $params {stdClass|arrayAssociative} — The parameters object. @required
* @param $params->paramsList {array} — Parameters in ordered list (func_get_args). @required
* @param $params->paramsList[i] {mixed} — Parameter value. @required
* @param $params->compliance {array} — The order of parameters. @required
* @param $params->compliance[i] {string} — Parameter name. @required
*
* @return {arrayAssociative}
*/
public static function orderedParamsToNamed($params){
$params = (object) $params;
$result = [];
$logData = (object) [
'message' => [],
'backtraceArray' => []
];
// Перебираем массив соответствия
foreach (
$params->compliance
as $index
=> $name
){
// Если параметр задан
if (isset($params->paramsList[$index])){
// Сохраним его
$result[$name] = $params->paramsList[$index];
}
$logData->message[] = "'" . $name . "' => $" . $name;
}
$logData->backtraceArray = debug_backtrace();
// Remove this method
array_shift($logData->backtraceArray);
$caller = $logData->backtraceArray[0];
$caller =
(
isset($caller['class'])
? $caller['class'] . '->'
: ''
)
. $caller['function']
;
// General info with code example
$logData->message =
'<p>Deprecated ordered parameters.</p><p>Ordered list of parameters is no longer allowed, use the “<a href="https://en.wikipedia.org/wiki/Named_parameter" target="_blank">pass-by-name</a>” style.</p>'
. '<pre><code>//Old style'
. $caller
. '($'
. implode(
', $',
$params->compliance
)
. ');'
. '//Pass-by-name'
. $caller
. '(['
. implode(
',' . PHP_EOL . "\t",
$logData->message
)
. ']);'
. '</code></pre>'
;
self::logEvent($logData);
return $result;
}
/**
* explodeAssoc
* @version 1.1.8 (2024-12-03)
*
* @desc Splits string on two separators in the associative array.
*
* @param $inputString {stringSeparated} — String to explode. @required
* @param $itemDelimiter {string} — Separator between pairs of key-value. Default: '||'.
* @param $keyValDelimiter {string} — Separator between key and value. Default: '::'.
*
* @return {arrayAssociative}
*/
public static function explodeAssoc(
$inputString,
$itemDelimiter = '||',
$keyValDelimiter = '::'
){
$result = [];
// Если строка пустая, выкидываем сразу
if ($inputString == ''){
return $result;
}
// Разбиваем по парам
$inputString = explode(
$itemDelimiter,
$inputString
);
foreach (
$inputString
as $item
){
// Разбиваем на ключ-значение
$item = explode(
$keyValDelimiter,
$item
);
$result[$item[0]] =
isset($item[1])
? $item[1]
: ''
;
}
return $result;
}
/**
* sort2dArray
* @version 1.3.3 (2024-12-03)
*
* @desc Sorts 2-dimensional array by multiple columns (like in SQL) using Hoare's method, also referred to as quicksort. The sorting is stable.
*
* @param $array {array} — Array to sort. Associative arrays are also supported. @required
* @param $array[$i] {array|object} — Array to sort. Associative arrays are also supported. @required
* @param $sortBy {array} — Columns (second level keys) by which the array is sorted. @required
* @param $sortDir {1|-1} — Sort direction (1 == ASC; -1 == DESC). Default: 1.
* @param $i {integer} — Count, an internal variable used during recursive calls. Default: 0.
*
* @return {array} — Sorted array.
*/
public static function sort2dArray(
$array,
$sortBy,
$sortDir = 1,
$i = 0
){
// В качестве эталона получаем сортируемое значение (по первому условию сортировки) первого элемента
$currentItem_comparisonValue = \DDTools\Tools\Objects::getPropValue([
'object' => array_values($array)[0],
'propName' => $sortBy[$i]
]);
$isCurrentItemComparisonValueNumeric = is_numeric($currentItem_comparisonValue);
$isArrayAssociative =
count(array_filter(
array_keys($array),
'is_string'
)) >
0
;
$resultArrayLeft = [];
$resultArrayRight = [];
$resultArrayCenter = [];
// Перебираем массив
foreach (
$array
as $arrayItemKey
=> $arrayItem
){
$arrayItem_comparisonValue = \DDTools\Tools\Objects::getPropValue([
'object' => $arrayItem,
'propName' => $sortBy[$i]
]);
// Если эталон и текущее значение — числа
if (
$isCurrentItemComparisonValueNumeric
&& is_numeric($arrayItem_comparisonValue)
){
// Получаем нужную циферку
$cmpRes =
$arrayItem_comparisonValue == $currentItem_comparisonValue
? 0
: (
$arrayItem_comparisonValue > $currentItem_comparisonValue
? 1
: -1
)
;
// Если они строки
}else{
// Сравниваем текущее значение со значением эталонного
$cmpRes = strcmp(
$arrayItem_comparisonValue,
$currentItem_comparisonValue
);
}
// Если меньше эталона, отбрасываем в массив меньших
if ($cmpRes * $sortDir < 0){
$resultArray = &$resultArrayLeft;
// Если больше — в массив больших
}elseif ($cmpRes * $sortDir > 0){
$resultArray = &$resultArrayRight;
// Если равно — в центральный
}else{
$resultArray = &$resultArrayCenter;
}
if ($isArrayAssociative){
$resultArray[$arrayItemKey] = $arrayItem;
}else{
$resultArray[] = $arrayItem;
}
}
// Массивы меньших и массивы больших прогоняем по тому же алгоритму (если в них что-то есть)
$resultArrayLeft =
count($resultArrayLeft) > 1
? self::sort2dArray(
$resultArrayLeft,
$sortBy,
$sortDir,
$i
)
: $resultArrayLeft
;
$resultArrayRight =
count($resultArrayRight) > 1
? self::sort2dArray(
$resultArrayRight,
$sortBy,
$sortDir,
$i
)
: $resultArrayRight
;
// Массив одинаковых прогоняем по следующему условию сортировки (если есть условие и есть что сортировать)
$resultArrayCenter =
(
count($resultArrayCenter) > 1
&& $sortBy[$i + 1]
)
? self::sort2dArray(
$resultArrayCenter,
$sortBy,
$sortDir,
$i + 1
)
: $resultArrayCenter
;
// Склеиваем отсортированные меньшие, средние и большие
return array_merge(
$resultArrayLeft,
$resultArrayCenter,
$resultArrayRight
);
}
/**
* parseFileNameVersion
* @version 1.1.6 (2024-12-03)
*
* @desc Parses a file path and gets its name, version & extension.
*
* @param $file {string|array} — String of file path or result array of pathinfo() function. @required
*
* @return $result {arrayAssociative} — File data.
* @return $result['name'] {string} — File name.
* @return $result['version'] {string} — File version.
* @return $result['extension'] {string} — File extension.
*/
public static function parseFileNameVersion($file){
// Если сразу передали массив
if (is_array($file)){
// Просто запоминаем его
$fileinfo = $file;
// А также запоминаем строку
$file =
$fileinfo['dirname']
. '/'
. $fileinfo['basename']
;
// Если передали строку
}else{
// Получаем необходимые данные
$fileinfo = pathinfo($file);
}
// Fail by default
$result = [
'name' => strtolower($file),
'version' => '0',
'extension' =>
!$fileinfo['extension']
? ''
: $fileinfo['extension']
];
// Try to get file version [0 — full name, 1 — script name, 2 — version, 3 — all chars after version]
preg_match(
'/(\D*?)-?(\d(?:\.\d+)*(?:-?[A-Za-z])*)(.*)/',
$fileinfo['basename'],
$match
);
// If not fail
if (count($match) >= 4){
$result['name'] = strtolower($match[1]);
$result['version'] = strtolower($match[2]);
}
return $result;
}
/**
* convertUrlToAbsolute
* @version 1.0.3 (2024-12-03)
*
* @desc Converts relative URLs to absolute.
*
* @param $params {stdClass|arrayAssociative} — The parameters object. @required
* @param $params->url {string} — Source URL. Can be set as relative with(out) host or absolute with(out) protocol: example.com/some/url, some/url, /some/url, //example.com/some/url, https://example.com/some/url. @required
* @param $params->host {string} — Host for the result URL. Default: $_SERVER['HTTP_HOST'].
* @param $params->scheme {string} — Scheme for the result URL. Default: 'https' || 'http' depending on $_SERVER['HTTPS'].
*
* @return {string}
*/
public static function convertUrlToAbsolute($params){
// # Prepare params
$params = \DDTools\Tools\Objects::extend([
'objects' => [
// Defaults
(object) [
'url' => '',
'host' => $_SERVER['HTTP_HOST'],
'scheme' => null
],
$params
]
]);
if (is_null($params->scheme)){
$params->scheme =
(
isset($_SERVER['HTTPS'])
&& (
$_SERVER['HTTPS'] == 'on'
|| $_SERVER['HTTPS'] == 1
)
)
? 'https'
: 'http'
;
}
// # Run
$result = '';
// E. g. '//example.com/some/url'
if (
substr(
$params->url,
0,
2
) ==
'//'
){
$result =
$params->scheme
. ':'
. $params->url
;
// E. g. 'https://example.com/some/url'
}elseif (
!empty(parse_url(
$params->url,
PHP_URL_SCHEME
))
){
$result = $params->url;
// E. g. 'example.com/some/url'
}elseif (
strpos(
$params->url,
$params->host
) ===
0
){
$result =
$params->scheme
. '://'
. $params->url
;
// E. g. 'some/url', '/some/url'
}else{
$result =
$params->scheme
. '://'
. $params->host
. '/'
. ltrim(
$params->url,
'/'
)
;
}
return $result;
}
/**
* generateRandomString
* @version 1.0.3 (2018-06-17)
*
* @desc Generate random string with necessary length.
*
* @param $length {integer} — Length of output string. Default: 8.
* @param $chars {string} — Chars to generate. Default: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'.
*
* @return {string}
*/
public static function generateRandomString(
$length = 8,
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'
){
$numChars = strlen($chars);
$string = '';
for (
$i = 0;
$i < $length;
$i++
){
$string .= substr(
$chars,
rand(
1,
$numChars
) - 1,
1
);
}
return $string;
}
/**
* escapingForJS
* @version 1.1.3 (2024-08-04)
*
* @desc Escaping chars in string for JS.
*
* @param $str {string} — String to escaping. @required
*
* @return {string}
*/
public static function escapeForJS($str){
// Backslach escaping (see issue #1)
$str = str_replace(
'\\',
'\\\\',
$str
);
// Line breaks
$str = str_replace(
"\r\n",
' ',
$str
);
$str = str_replace(
"\n",
' ',
$str
);
$str = str_replace(
"\r",
' ',
$str
);
// Tabs
$str = str_replace(
chr(9),
' ',
$str
);
$str = str_replace(
' ',
' ',
$str
);
// MODX placeholders
$str = str_replace(
'[+',
'\[\+',
$str
);
$str = str_replace(
'+]',
'\+\]',
$str
);
// Quotes
$str = str_replace(
"'",
"\'",
$str
);
$str = str_replace(
'"',
'\"',
$str
);
return $str;
}
/**
* getPlaceholdersFromText
* @version 1.0.4 (2024-12-03)
*
* @desc Finds all placeholders' names and returns them as an array.
*
* @param $params {stdClass|arrayAssociative} — The parameters object. @required
* @param $params->text {string} — Source string. @required
* @param $params->placeholderPrefix {string} — Placeholders prefix. Default: '[+'.
* @param $params->placeholderSuffix {string} — Placeholders suffix. Default: '+]'.
*
* @return {array}
*/
public static function getPlaceholdersFromText($params = []){
// Defaults
$params = (object) array_merge(
[
'text' => '',
'placeholderPrefix' => '[+',
'placeholderSuffix' => '+]'
],
(array) $params
);
$params->placeholderPrefix = preg_quote($params->placeholderPrefix);
$params->placeholderSuffix = preg_quote($params->placeholderSuffix);
$result = [];
preg_match_all(
(
'/'
. $params->placeholderPrefix
. '(.*?)'
. $params->placeholderSuffix
. '/'
),
$params->text,
$result
);
$result = array_unique($result[1]);
return $result;
}
/**
* logEvent
* @version 1.0.5 (2024-12-03)
*
* @desc Add an alert message to the system event log with debug info (backtrace, snippet name, document id, etc).
*
* @param $params {stdClass|arrayAssociative} — The parameters object. @required
* @param $params->message {string} — Message to be logged. Default: ''.
* @param $params->source {string} — Source of the event (module, snippet name, etc). Default: $modx->currentSnippet || caller.
* @param $params->eventId {integer} — Event ID. Default: 1.
* @param $params->eventType {'information'|'warning'|'error'} — Event type. Default: 'warning'.
* @param $params->backtraceArray {array} — Backtrace (if default is not suitable). See http://php.net/manual/en/function.debug-backtrace.php. Default: debug_backtrace().
*
* @return {void}
*/
public static function logEvent($params){
// Defaults
$params = (object) array_merge(
[
'message' => '',
'source' => '',
// TODO: Why “1”, what does it mean?
'eventId' => 1,
'eventType' => 'warning',
// 'backtraceArray' => debug_backtrace(),
],
(array) $params
);
// Prepare backtrace and caller
if (!isset($params->backtraceArray)){
$params->backtraceArray = debug_backtrace();
// Remove this method
array_shift($params->backtraceArray);
}
$caller = $params->backtraceArray[0];
$caller =
(
isset($caller['class'])
? $caller['class'] . '->'
: ''
)
. $caller['function']
;
$debugInfo = [];
// Add current document Id to debug info
if (!empty(self::$modx->documentIdentifier)){
$debugInfo[] =
'<li>Document id: “'
. self::$modx->documentIdentifier
. '”;</li>'
;
}
// Is the code being run in the snippet?
if (!empty(self::$modx->currentSnippet)){
// Empty source
if ($params->source == ''){
// Set as source
$params->source = self::$modx->currentSnippet;
}else{
// Add to debug info
$debugInfo[] =
'<li>Snippet: “'
. self::$modx->currentSnippet
. '”;</li>'
;
}
}
if ($params->source == ''){
$params->source = $caller;
}
// Add debug info to the message
$params->message .= '<h3>Debug info</h3>';
if (!empty($debugInfo)){
$params->message .=
'<ul>'
. implode(
'',
$debugInfo
)
. '</ul>'
;
}
// Add backtrace to message
$params->message .= self::$modx->get_backtrace($params->backtraceArray);
// Prepare event type
switch (substr(
$params->eventType,
0,
1
)){
// Information
case 'i':
$params->eventType = 1;
break;
// Warning
case 'w':
$params->eventType = 2;
break;
// Error
case 'e':
$params->eventType = 3;
break;
}
self::$modx->logEvent(
$params->eventId,
$params->eventType,
$params->message,
$params->source
);
}
/**
* getTpl
* @version 1.0.1 (2024-08-04)
*
* @see README.md
*/
public static function getTpl($tpl = ''){
// Cast the parameter to a string
$tpl = $tpl . '';
$result = $tpl;
if (!empty($tpl)){
// $modx->getTpl('@CODE:') returns '@CODE:' O_o
if (
substr(
$tpl,
0,
6
) ==
'@CODE:'
){
$result = substr(
$tpl,
6
);
}else{
$result = self::$modx->getTpl($tpl);
}
}
return $result;
}
/**
* parseText
* @version 1.9.3 (2024-12-03)
*
* @see README.md
*/
public static function parseText($params = []){
$params = call_user_func_array(
[
static::class,
'parseText_parepareParams',
],
func_get_args()
);
$result = $params->text;
$params->data = static::parseText_prepareData([
'data' => $params->data
]);
foreach (
$params->data
as $key
=> $value
){
$result = static::parseText_parseItem([
'text' => $result,
'placeholder' => $params->placeholderPrefix . $key . $params->placeholderSuffix,
'value' => $value,
]);
}
if ($params->isCompletelyParsingEnabled){
$result = static::parseSource($result);
}
// It is needed only after static::parseSource because some snippets can create the new empty placeholders
if ($params->removeEmptyPlaceholders){
$result = preg_replace(
'/(\[\+\S+?\+\])/m',
'',
$result
);
}
return $result;
}
/**
* parseText_parepareParams
* @version 1.0.3 (2024-08-04)
*
* @param $params {stdClass|arrayAssociative} — The parameters object. See $this->parseText.
*
* @return {string}
*/
private static function parseText_parepareParams($params = []): \stdClass {
// For backward compatibility
if (func_num_args() > 1){
// Convert ordered list of params to named
$params = self::orderedParamsToNamed([
'paramsList' => func_get_args(),
'compliance' => [
'text',
'data',
'placeholderPrefix',
'placeholderSuffix',
'isCompletelyParsingEnabled'
]
]);
}
$params = \ddTools::verifyRenamedParams([
'params' => (object) $params,
'compliance' => [
'isCompletelyParsingEnabled' => 'mergeAll',
],
'returnCorrectedOnly' => false,
]);
$params = \DDTools\Tools\Objects::extend([
'objects' => [
// Defaults
(object) [
'text' => '',
'data' => null,
'placeholderPrefix' => '[+',
'placeholderSuffix' => '+]',
'removeEmptyPlaceholders' => false,
'isCompletelyParsingEnabled' => true
],
$params
]
]);
return $params;