@@ -314,12 +314,11 @@ function create($model = null, $options = array()) {
314
314
}
315
315
316
316
if (!empty ($ append )) {
317
- $ append = sprintf ( $ this ->Html ->tags [ 'block ' ] , ' style="display:none;" ' , $ append );
317
+ $ append = $ this ->Html ->useTag ( 'block ' , ' style="display:none;" ' , $ append );
318
318
}
319
319
320
320
$ this ->setEntity ($ model . '. ' , true );
321
- $ attributes = $ this ->_parseAttributes ($ htmlAttributes , null , '' );
322
- return sprintf ($ this ->Html ->tags ['form ' ], $ attributes ) . $ append ;
321
+ return $ this ->Html ->useTag ('form ' , $ htmlAttributes ) . $ append ;
323
322
}
324
323
325
324
/**
@@ -372,7 +371,7 @@ public function end($options = null) {
372
371
$ this ->fields = array ();
373
372
}
374
373
$ this ->setEntity (null );
375
- $ out .= $ this ->Html ->tags [ 'formend ' ] ;
374
+ $ out .= $ this ->Html ->useTag ( 'formend ' ) ;
376
375
377
376
$ this ->_View ->modelScope = false ;
378
377
return $ out ;
@@ -407,8 +406,7 @@ public function secure($fields = array()) {
407
406
'value ' => urlencode ($ fields . ': ' . $ locked ),
408
407
'id ' => 'TokenFields ' . mt_rand ()
409
408
));
410
- $ out = sprintf ($ this ->Html ->tags ['block ' ], ' style="display:none;" ' , $ out );
411
- return $ out ;
409
+ return $ this ->Html ->useTag ('block ' , ' style="display:none;" ' , $ out );
412
410
}
413
411
414
412
/**
@@ -562,11 +560,7 @@ function label($fieldName = null, $text = null, $options = array()) {
562
560
$ labelFor = $ this ->domId ($ fieldName );
563
561
}
564
562
565
- return sprintf (
566
- $ this ->Html ->tags ['label ' ],
567
- $ labelFor ,
568
- $ this ->_parseAttributes ($ options ), $ text
569
- );
563
+ return $ this ->Html ->useTag ('label ' , $ labelFor , $ options , $ text );
570
564
}
571
565
572
566
/**
@@ -657,13 +651,9 @@ public function inputs($fields = null, $blacklist = null) {
657
651
}
658
652
659
653
if ($ fieldset && $ legend ) {
660
- return sprintf (
661
- $ this ->Html ->tags ['fieldset ' ],
662
- $ fieldsetClass ,
663
- sprintf ($ this ->Html ->tags ['legend ' ], $ legend ) . $ out
664
- );
654
+ return $ this ->Html ->useTag ('fieldset ' , $ fieldsetClass , $ this ->Html ->useTag ('legend ' , $ legend ) . $ out );
665
655
} elseif ($ fieldset ) {
666
- return sprintf ( $ this ->Html ->tags [ 'fieldset ' ] , $ fieldsetClass , $ out );
656
+ return $ this ->Html ->useTag ( 'fieldset ' , $ fieldsetClass , $ out );
667
657
} else {
668
658
return $ out ;
669
659
}
@@ -1019,11 +1009,7 @@ public function checkbox($fieldName, $options = array()) {
1019
1009
}
1020
1010
unset($ options ['hiddenField ' ]);
1021
1011
1022
- return $ output . sprintf (
1023
- $ this ->Html ->tags ['checkbox ' ],
1024
- $ options ['name ' ],
1025
- $ this ->_parseAttributes ($ options , array ('name ' ), null , ' ' )
1026
- );
1012
+ return $ output . $ this ->Html ->useTag ('checkbox ' , $ options ['name ' ], array_diff_key ($ options , array ('name ' => '' )));
1027
1013
}
1028
1014
1029
1015
/**
@@ -1085,20 +1071,17 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
1085
1071
if (isset ($ value ) && $ optValue == $ value ) {
1086
1072
$ optionsHere ['checked ' ] = 'checked ' ;
1087
1073
}
1088
- $ parsedOptions = $ this ->_parseAttributes (
1089
- array_merge ($ attributes , $ optionsHere ),
1090
- array ('name ' , 'type ' , 'id ' ), '' , ' '
1091
- );
1092
1074
$ tagName = Inflector::camelize (
1093
1075
$ attributes ['id ' ] . '_ ' . Inflector::slug ($ optValue )
1094
1076
);
1095
1077
1096
1078
if ($ label ) {
1097
- $ optTitle = sprintf ( $ this ->Html ->tags [ 'label ' ] , $ tagName , null , $ optTitle );
1079
+ $ optTitle = $ this ->Html ->useTag ( 'label ' , $ tagName , '' , $ optTitle );
1098
1080
}
1099
- $ out [] = sprintf (
1100
- $ this ->Html ->tags ['radio ' ], $ attributes ['name ' ],
1101
- $ tagName , $ parsedOptions , $ optTitle
1081
+ $ allOptions = array_merge ($ attributes , $ optionsHere );
1082
+ $ out [] = $ this ->Html ->useTag ('radio ' , $ attributes ['name ' ], $ tagName ,
1083
+ array_diff_key ($ allOptions , array ('name ' => '' , 'type ' => '' , 'id ' => '' )),
1084
+ $ optTitle
1102
1085
);
1103
1086
}
1104
1087
$ hidden = null ;
@@ -1113,10 +1096,7 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
1113
1096
$ out = $ hidden . implode ($ inbetween , $ out );
1114
1097
1115
1098
if ($ legend ) {
1116
- $ out = sprintf (
1117
- $ this ->Html ->tags ['fieldset ' ], '' ,
1118
- sprintf ($ this ->Html ->tags ['legend ' ], $ legend ) . $ out
1119
- );
1099
+ $ out = $ this ->Html ->useTag ('fieldset ' , '' , $ this ->Html ->useTag ('legend ' , $ legend ) . $ out );
1120
1100
}
1121
1101
return $ out ;
1122
1102
}
@@ -1154,11 +1134,7 @@ public function __call($method, $params) {
1154
1134
$ options ['type ' ] = $ method ;
1155
1135
}
1156
1136
$ options = $ this ->_initInputField ($ params [0 ], $ options );
1157
- return sprintf (
1158
- $ this ->Html ->tags ['input ' ],
1159
- $ options ['name ' ],
1160
- $ this ->_parseAttributes ($ options , array ('name ' ), null , ' ' )
1161
- );
1137
+ return $ this ->Html ->useTag ('input ' , $ options ['name ' ], array_diff_key ($ options , array ('name ' => '' )));
1162
1138
}
1163
1139
1164
1140
/**
@@ -1185,12 +1161,7 @@ public function textarea($fieldName, $options = array()) {
1185
1161
}
1186
1162
unset($ options ['value ' ]);
1187
1163
}
1188
- return sprintf (
1189
- $ this ->Html ->tags ['textarea ' ],
1190
- $ options ['name ' ],
1191
- $ this ->_parseAttributes ($ options , array ('type ' , 'name ' ), null , ' ' ),
1192
- $ value
1193
- );
1164
+ return $ this ->Html ->useTag ('textarea ' , $ options ['name ' ], array_diff_key ($ options , array ('type ' => '' , 'name ' => '' )), $ value );
1194
1165
}
1195
1166
1196
1167
/**
@@ -1218,11 +1189,7 @@ public function hidden($fieldName, $options = array()) {
1218
1189
$ this ->__secure (null , '' . $ options ['value ' ]);
1219
1190
}
1220
1191
1221
- return sprintf (
1222
- $ this ->Html ->tags ['hidden ' ],
1223
- $ options ['name ' ],
1224
- $ this ->_parseAttributes ($ options , array ('name ' , 'class ' ), '' , ' ' )
1225
- );
1192
+ return $ this ->Html ->useTag ('hidden ' , $ options ['name ' ], array_diff_key ($ options , array ('name ' => '' , 'class ' => '' )));
1226
1193
}
1227
1194
1228
1195
/**
@@ -1243,8 +1210,7 @@ public function file($fieldName, $options = array()) {
1243
1210
$ this ->__secure (array_merge ($ field , array ($ suffix )));
1244
1211
}
1245
1212
1246
- $ attributes = $ this ->_parseAttributes ($ options , array ('name ' ), '' , ' ' );
1247
- return sprintf ($ this ->Html ->tags ['file ' ], $ options ['name ' ], $ attributes );
1213
+ return $ this ->Html ->useTag ('file ' , $ options ['name ' ], array_diff_key ($ options , array ('name ' => '' )));
1248
1214
}
1249
1215
1250
1216
/**
@@ -1266,12 +1232,7 @@ public function button($title, $options = array()) {
1266
1232
if ($ options ['escape ' ]) {
1267
1233
$ title = h ($ title );
1268
1234
}
1269
- return sprintf (
1270
- $ this ->Html ->tags ['button ' ],
1271
- $ options ['type ' ],
1272
- $ this ->_parseAttributes ($ options , array ('type ' ), ' ' , '' ),
1273
- $ title
1274
- );
1235
+ return $ this ->Html ->useTag ('button ' , $ options ['type ' ], array_diff_key ($ options , array ('type ' => '' )), $ title );
1275
1236
}
1276
1237
1277
1238
/**
@@ -1408,11 +1369,7 @@ public function submit($caption = null, $options = array()) {
1408
1369
1409
1370
if (strpos ($ caption , ':// ' ) !== false ) {
1410
1371
unset($ options ['type ' ]);
1411
- $ out .= $ before . sprintf (
1412
- $ this ->Html ->tags ['submitimage ' ],
1413
- $ caption ,
1414
- $ this ->_parseAttributes ($ options , null , '' , ' ' )
1415
- ) . $ after ;
1372
+ $ out .= $ before . $ this ->Html ->useTag ('submitimage ' , $ caption , $ options ) . $ after ;
1416
1373
} elseif (preg_match ('/\.(jpg|jpe|jpeg|gif|png|ico)$/ ' , $ caption )) {
1417
1374
unset($ options ['type ' ]);
1418
1375
if ($ caption {0 } !== '/ ' ) {
@@ -1421,17 +1378,10 @@ public function submit($caption = null, $options = array()) {
1421
1378
$ caption = trim ($ caption , '/ ' );
1422
1379
$ url = $ this ->webroot ($ caption );
1423
1380
}
1424
- $ out .= $ before . sprintf (
1425
- $ this ->Html ->tags ['submitimage ' ],
1426
- $ url ,
1427
- $ this ->_parseAttributes ($ options , null , '' , ' ' )
1428
- ) . $ after ;
1381
+ $ out .= $ before . $ this ->Html ->useTag ('submitimage ' , $ url , $ options ) . $ after ;
1429
1382
} else {
1430
1383
$ options ['value ' ] = $ caption ;
1431
- $ out .= $ before . sprintf (
1432
- $ this ->Html ->tags ['submit ' ],
1433
- $ this ->_parseAttributes ($ options , null , '' , ' ' )
1434
- ). $ after ;
1384
+ $ out .= $ before . $ this ->Html ->useTag ('submit ' , $ options ) . $ after ;
1435
1385
}
1436
1386
1437
1387
if (isset ($ divOptions )) {
@@ -1524,7 +1474,7 @@ public function select($fieldName, $options = array(), $attributes = array()) {
1524
1474
if (isset ($ attributes ) && array_key_exists ('multiple ' , $ attributes )) {
1525
1475
$ style = ($ attributes ['multiple ' ] === 'checkbox ' ) ? 'checkbox ' : null ;
1526
1476
$ template = ($ style ) ? 'checkboxmultiplestart ' : 'selectmultiplestart ' ;
1527
- $ tag = $ this -> Html -> tags [ $ template] ;
1477
+ $ tag = $ template ;
1528
1478
$ hiddenAttributes = array (
1529
1479
'value ' => '' ,
1530
1480
'id ' => $ attributes ['id ' ] . ($ style ? '' : '_ ' ),
@@ -1533,16 +1483,14 @@ public function select($fieldName, $options = array(), $attributes = array()) {
1533
1483
);
1534
1484
$ select [] = $ this ->hidden (null , $ hiddenAttributes );
1535
1485
} else {
1536
- $ tag = $ this -> Html -> tags [ 'selectstart ' ] ;
1486
+ $ tag = 'selectstart ' ;
1537
1487
}
1538
1488
1539
1489
if (!empty ($ tag ) || isset ($ template )) {
1540
1490
if (!isset ($ secure ) || $ secure == true ) {
1541
1491
$ this ->__secure ();
1542
1492
}
1543
- $ select [] = sprintf ($ tag , $ attributes ['name ' ], $ this ->_parseAttributes (
1544
- $ attributes , array ('name ' , 'value ' ))
1545
- );
1493
+ $ select [] = $ this ->Html ->useTag ($ tag , $ attributes ['name ' ], array_diff_key ($ attributes , array ('name ' => '' , 'value ' => '' )));
1546
1494
}
1547
1495
$ emptyMulti = (
1548
1496
$ showEmpty !== null && $ showEmpty !== false && !(
@@ -1566,7 +1514,7 @@ public function select($fieldName, $options = array(), $attributes = array()) {
1566
1514
));
1567
1515
1568
1516
$ template = ($ style == 'checkbox ' ) ? 'checkboxmultipleend ' : 'selectend ' ;
1569
- $ select [] = $ this ->Html ->tags [ $ template] ;
1517
+ $ select [] = $ this ->Html ->useTag ( $ template) ;
1570
1518
return implode ("\n" , $ select );
1571
1519
}
1572
1520
@@ -2057,9 +2005,9 @@ function __selectOptions($elements = array(), $parents = array(), $showParents =
2057
2005
if (is_array ($ title ) && (!isset ($ title ['name ' ]) || !isset ($ title ['value ' ]))) {
2058
2006
if (!empty ($ name )) {
2059
2007
if ($ attributes ['style ' ] === 'checkbox ' ) {
2060
- $ select [] = $ this ->Html ->tags [ 'fieldsetend ' ] ;
2008
+ $ select [] = $ this ->Html ->useTag ( 'fieldsetend ' ) ;
2061
2009
} else {
2062
- $ select [] = $ this ->Html ->tags [ 'optiongroupend ' ] ;
2010
+ $ select [] = $ this ->Html ->useTag ( 'optiongroupend ' ) ;
2063
2011
}
2064
2012
$ parents [] = $ name ;
2065
2013
}
@@ -2070,9 +2018,9 @@ function __selectOptions($elements = array(), $parents = array(), $showParents =
2070
2018
if (!empty ($ name )) {
2071
2019
$ name = $ attributes ['escape ' ] ? h ($ name ) : $ name ;
2072
2020
if ($ attributes ['style ' ] === 'checkbox ' ) {
2073
- $ select [] = sprintf ( $ this ->Html ->tags [ 'fieldsetstart ' ] , $ name );
2021
+ $ select [] = $ this ->Html ->useTag ( 'fieldsetstart ' , $ name );
2074
2022
} else {
2075
- $ select [] = sprintf ( $ this ->Html ->tags [ 'optiongroup ' ] , $ name , '' );
2023
+ $ select [] = $ this ->Html ->useTag ( 'optiongroup ' , $ name , '' );
2076
2024
}
2077
2025
}
2078
2026
$ name = null ;
@@ -2117,16 +2065,10 @@ function __selectOptions($elements = array(), $parents = array(), $showParents =
2117
2065
$ attributes ['class ' ] = 'checkbox ' ;
2118
2066
}
2119
2067
$ label = $ this ->label (null , $ title , $ label );
2120
- $ item = sprintf (
2121
- $ this ->Html ->tags ['checkboxmultiple ' ], $ name ,
2122
- $ this ->_parseAttributes ($ htmlOptions )
2123
- );
2068
+ $ item = $ this ->Html ->useTag ('checkboxmultiple ' , $ name , $ htmlOptions );
2124
2069
$ select [] = $ this ->Html ->div ($ attributes ['class ' ], $ item . $ label );
2125
2070
} else {
2126
- $ select [] = sprintf (
2127
- $ this ->Html ->tags ['selectoption ' ],
2128
- $ name , $ this ->_parseAttributes ($ htmlOptions ), $ title
2129
- );
2071
+ $ select [] = $ this ->Html ->useTag ('selectoption ' , $ name , $ htmlOptions , $ title );
2130
2072
}
2131
2073
}
2132
2074
}
0 commit comments