@@ -75,7 +75,7 @@ class modTemplateVar extends modElement
75
75
*
76
76
* {@inheritdoc}
77
77
*/
78
- function __construct (& $ xpdo )
78
+ public function __construct (&$ xpdo )
79
79
{
80
80
parent :: __construct ($ xpdo );
81
81
$ this ->setToken ('* ' );
@@ -161,7 +161,7 @@ public function process($properties = null, $content = null)
161
161
/* copy the content source to the output buffer */
162
162
$ this ->_output = $ this ->_content ;
163
163
164
- if (is_string ($ this ->_output ) && !empty ($ this ->_output )) {
164
+ if (is_string ($ this ->_output ) && !empty ($ this ->_output )) {
165
165
/* turn the processed properties into placeholders */
166
166
$ scope = $ this ->xpdo ->toPlaceholders ($ this ->_properties , '' , '. ' , true );
167
167
@@ -217,10 +217,10 @@ public function getValue($resourceId = 0)
217
217
$ value = null ;
218
218
$ resourceId = intval ($ resourceId );
219
219
if ($ resourceId ) {
220
- if (is_object ($ this ->xpdo ->resource ) && $ resourceId === (integer )$ this ->xpdo ->resourceIdentifier && is_array ($ this ->xpdo ->resource ->get ($ this ->get ('name ' )))) {
220
+ if (is_object ($ this ->xpdo ->resource ) && $ resourceId === (int )$ this ->xpdo ->resourceIdentifier && is_array ($ this ->xpdo ->resource ->get ($ this ->get ('name ' )))) {
221
221
$ valueArray = $ this ->xpdo ->resource ->get ($ this ->get ('name ' ));
222
222
$ value = $ valueArray [1 ];
223
- } elseif ($ resourceId === (integer )$ this ->get ('resourceId ' ) && array_key_exists ('value ' , $ this ->_fields )) {
223
+ } elseif ($ resourceId === (int )$ this ->get ('resourceId ' ) && array_key_exists ('value ' , $ this ->_fields )) {
224
224
$ value = $ this ->get ('value ' );
225
225
} else {
226
226
$ resource = $ this ->xpdo ->getObject (modTemplateVarResource::class, [
@@ -269,8 +269,7 @@ public function setValue($resourceId = 0, $value = null)
269
269
$ templateVarResource ->set ('value ' , $ value );
270
270
}
271
271
$ this ->addMany ($ templateVarResource );
272
- } elseif (!$ templateVarResource ->isNew ()
273
- && ($ value === null || $ value === $ this ->get ('default_text ' ))) {
272
+ } elseif (!$ templateVarResource ->isNew () && ($ value === null || $ value === $ this ->get ('default_text ' ))) {
274
273
$ templateVarResource ->remove ();
275
274
}
276
275
}
@@ -325,8 +324,10 @@ public function prepareOutput($value, $resourceId = 0)
325
324
$ mTypes = $ this ->xpdo ->getOption ('manipulatable_url_tv_output_types ' , null , 'image,file ' );
326
325
$ mTypes = explode (', ' , $ mTypes );
327
326
if (!empty ($ value ) && in_array ($ this ->get ('type ' ), $ mTypes )) {
328
- $ context = !empty ($ resourceId ) ? $ this ->xpdo ->getObject (modResource::class,
329
- $ resourceId )->get ('context_key ' ) : $ this ->xpdo ->context ->get ('key ' );
327
+ $ context = !empty ($ resourceId )
328
+ ? $ this ->xpdo ->getObject (modResource::class, $ resourceId )->get ('context_key ' )
329
+ : $ this ->xpdo ->context ->get ('key ' )
330
+ ;
330
331
$ sourceCache = $ this ->getSourceCache ($ context );
331
332
$ classKey = $ sourceCache ['class_key ' ];
332
333
if (!empty ($ sourceCache ) && !empty ($ classKey )) {
@@ -336,8 +337,7 @@ public function prepareOutput($value, $resourceId = 0)
336
337
if ($ source ) {
337
338
$ source ->fromArray ($ sourceCache , '' , true , true );
338
339
$ source ->initialize ();
339
- $ isAbsolute = strpos ($ value , 'http:// ' ) === 0 || strpos ($ value ,
340
- 'https:// ' ) === 0 || strpos ($ value , 'ftp:// ' ) === 0 ;
340
+ $ isAbsolute = strpos ($ value , 'http:// ' ) === 0 || strpos ($ value , 'https:// ' ) === 0 || strpos ($ value , 'ftp:// ' ) === 0 ;
341
341
if (!$ isAbsolute ) {
342
342
$ value = $ source ->prepareOutputUrl ($ value );
343
343
}
@@ -380,8 +380,11 @@ public function renderInput($resource = null, $options = [])
380
380
}
381
381
if (!isset ($ this ->xpdo ->smarty )) {
382
382
$ this ->xpdo ->getService ('smarty ' , modSmarty::class, '' , [
383
- 'template_dir ' => $ this ->xpdo ->getOption ('manager_path ' ) . 'templates/ ' . $ this ->xpdo ->getOption ('manager_theme ' ,
384
- null , 'default ' ) . '/ ' ,
383
+ 'template_dir ' => $ this ->xpdo ->getOption ('manager_path ' ) . 'templates/ ' . $ this ->xpdo ->getOption (
384
+ 'manager_theme ' ,
385
+ null ,
386
+ 'default '
387
+ ) . '/ '
385
388
]);
386
389
}
387
390
$ this ->xpdo ->smarty ->assign ('style ' , $ style );
@@ -402,8 +405,12 @@ public function renderInput($resource = null, $options = [])
402
405
$ this ->set ('processedValue ' , $ value );
403
406
$ this ->set ('default_text ' , $ this ->processBindings ($ this ->get ('default_text ' ), $ resourceId ));
404
407
405
- /* strip tags from description */
406
- // $this->set('description', strip_tags($this->get('description')));
408
+ /* remove disallowed tags and attributes from description */
409
+ $ this ->set ('description ' , $ this ->modx ->stripHtml (
410
+ $ this ->get ('description ' ),
411
+ $ this ->modx ->getOption ('elements_description_allowedtags ' ),
412
+ $ this ->modx ->getOption ('elements_description_allowedattr ' )
413
+ ));
407
414
408
415
$ params = [];
409
416
if ($ paramstring = $ this ->get ('display_params ' )) {
@@ -627,8 +634,7 @@ public function checkForFormCustomizationRules($value, &$resource)
627
634
$ c = $ this ->xpdo ->newQuery (modActionDom::class);
628
635
$ c ->innerJoin (modFormCustomizationSet::class, 'FCSet ' );
629
636
$ c ->innerJoin (modFormCustomizationProfile::class, 'Profile ' , 'FCSet.profile = Profile.id ' );
630
- $ c ->leftJoin (modFormCustomizationProfileUserGroup::class, 'ProfileUserGroup ' ,
631
- 'Profile.id = ProfileUserGroup.profile ' );
637
+ $ c ->leftJoin (modFormCustomizationProfileUserGroup::class, 'ProfileUserGroup ' , 'Profile.id = ProfileUserGroup.profile ' );
632
638
$ c ->leftJoin (modFormCustomizationProfile::class, 'UGProfile ' , 'UGProfile.id = ProfileUserGroup.profile ' );
633
639
$ ruleFieldName = $ this ->xpdo ->escape ('rule ' );
634
640
$ c ->where ([
@@ -654,8 +660,7 @@ public function checkForFormCustomizationRules($value, &$resource)
654
660
], xPDOQuery::SQL_AND , null , 2 );
655
661
}
656
662
if (!empty ($ this ->xpdo ->request ) && !empty ($ this ->xpdo ->request ->action )) {
657
- $ wildAction = substr ($ this ->xpdo ->request ->action , 0 ,
658
- strrpos ($ this ->xpdo ->request ->action , '/ ' )) . '/* ' ;
663
+ $ wildAction = substr ($ this ->xpdo ->request ->action , 0 , strrpos ($ this ->xpdo ->request ->action , '/ ' )) . '/* ' ;
659
664
$ c ->where ([
660
665
'modActionDom.action:IN ' => [$ this ->xpdo ->request ->action , $ wildAction ],
661
666
]);
@@ -898,7 +903,7 @@ public function processBindings($value = '', $resourceId = 0, $preProcess = true
898
903
case 'DOCUMENT ' : /* retrieve a document and process it's content */
899
904
if ($ preProcess ) {
900
905
$ query = $ this ->xpdo ->newQuery (modResource::class, [
901
- 'id ' => (integer )$ param ,
906
+ 'id ' => (int )$ param ,
902
907
'deleted ' => false ,
903
908
]);
904
909
$ query ->select ('content ' );
@@ -919,8 +924,10 @@ public function processBindings($value = '', $resourceId = 0, $preProcess = true
919
924
$ dbtags ['DBASE ' ] = $ this ->xpdo ->getOption ('dbname ' );
920
925
$ dbtags ['PREFIX ' ] = $ this ->xpdo ->getOption ('table_prefix ' );
921
926
foreach ($ dbtags as $ key => $ pValue ) {
922
- if (!is_scalar ($ pValue )) continue ;
923
- $ param = str_replace ('[[+ ' .$ key .']] ' , (string )$ pValue , $ param );
927
+ if (!is_scalar ($ pValue )) {
928
+ continue ;
929
+ }
930
+ $ param = str_replace ('[[+ ' . $ key . ']] ' , (string )$ pValue , $ param );
924
931
}
925
932
$ stmt = $ this ->xpdo ->query ('SELECT ' . $ param );
926
933
if ($ stmt && $ stmt instanceof PDOStatement) {
@@ -975,7 +982,6 @@ public function processBindings($value = '', $resourceId = 0, $preProcess = true
975
982
default :
976
983
$ output = $ value ;
977
984
break ;
978
-
979
985
}
980
986
981
987
/* support for nested bindings */
@@ -1005,11 +1011,11 @@ public function parseBinding($binding_string)
1005
1011
$ regexp2 = '/(\S+)\s+(.+)/is ' ; /* Split binding on second whitespace to get properties */
1006
1012
1007
1013
$ properties = [];
1008
- if (preg_match ($ regexp2 , $ match [2 ] , $ match2 )) {
1014
+ if (preg_match ($ regexp2 , $ match [2 ], $ match2 )) {
1009
1015
if (isset ($ match2 [2 ])) {
1010
- $ props = json_decode ($ match2 [2 ],true );
1016
+ $ props = json_decode ($ match2 [2 ], true );
1011
1017
$ valid = json_last_error () === JSON_ERROR_NONE ;
1012
- if ($ valid && is_array ($ props )){
1018
+ if ($ valid && is_array ($ props )) {
1013
1019
$ properties = $ props ;
1014
1020
$ match [2 ] = $ match2 [1 ];
1015
1021
} else {
@@ -1041,8 +1047,10 @@ public function processInheritBinding($default = '', $resourceId = null)
1041
1047
$ output = $ default ; /* Default to param value if no content from parents */
1042
1048
$ resource = null ;
1043
1049
$ resourceColumns = $ this ->xpdo ->getSelectColumns (modResource::class, '' , '' , ['id ' , 'parent ' ]);
1044
- $ resourceQuery = new xPDOCriteria ($ this ->xpdo ,
1045
- "SELECT {$ resourceColumns } FROM {$ this ->xpdo ->getTableName (modResource::class)} WHERE id = ? " );
1050
+ $ resourceQuery = new xPDOCriteria (
1051
+ $ this ->xpdo ,
1052
+ "SELECT {$ resourceColumns } FROM {$ this ->xpdo ->getTableName (modResource::class)} WHERE id = ? "
1053
+ );
1046
1054
if (!empty ($ resourceId ) && (!($ this ->xpdo ->resource instanceof modResource) || $ this ->xpdo ->resource ->get ('id ' ) != $ resourceId )) {
1047
1055
if ($ resourceQuery ->stmt && $ resourceQuery ->stmt ->execute ([$ resourceId ])) {
1048
1056
$ result = $ resourceQuery ->stmt ->fetchAll (PDO ::FETCH_ASSOC );
@@ -1115,11 +1123,11 @@ public function findPolicy($context = '')
1115
1123
$ policy = [];
1116
1124
$ context = !empty ($ context ) ? $ context : $ this ->xpdo ->context ->get ('key ' );
1117
1125
if ($ context === $ this ->xpdo ->context ->get ('key ' )) {
1118
- $ catEnabled = (boolean )$ this ->xpdo ->getOption ('access_category_enabled ' , null , true );
1119
- $ rgEnabled = (boolean )$ this ->xpdo ->getOption ('access_resource_group_enabled ' , null , true );
1126
+ $ catEnabled = (bool )$ this ->xpdo ->getOption ('access_category_enabled ' , null , true );
1127
+ $ rgEnabled = (bool )$ this ->xpdo ->getOption ('access_resource_group_enabled ' , null , true );
1120
1128
} elseif ($ this ->xpdo ->getContext ($ context )) {
1121
- $ catEnabled = (boolean )$ this ->xpdo ->contexts [$ context ]->getOption ('access_category_enabled ' , true );
1122
- $ rgEnabled = (boolean )$ this ->xpdo ->contexts [$ context ]->getOption ('access_resource_group_enabled ' , true );
1129
+ $ catEnabled = (bool )$ this ->xpdo ->contexts [$ context ]->getOption ('access_category_enabled ' , true );
1130
+ $ rgEnabled = (bool )$ this ->xpdo ->contexts [$ context ]->getOption ('access_resource_group_enabled ' , true );
1123
1131
}
1124
1132
$ enabled = ($ catEnabled || $ rgEnabled );
1125
1133
if ($ enabled ) {
0 commit comments