88 * License: GNU/GPLv2
99 * @see LICENSE.txt
1010 *
11- * This file: Front-end handler (last modified: 2021.05.01 ).
11+ * This file: Front-end handler (last modified: 2021.06.06 ).
1212 */
1313
1414namespace phpMussel \FrontEnd ;
@@ -360,6 +360,7 @@ public function view(string $Page = ''): void
360360 $ this ->Loader ->L10N ->Data ['Text Direction ' ] = 'ltr ' ;
361361 $ FE ['FE_Align ' ] = 'left ' ;
362362 $ FE ['FE_Align_Reverse ' ] = 'right ' ;
363+ $ FE ['FE_Align_Mode ' ] = 'lr ' ;
363364 $ FE ['PIP_Input ' ] = $ Pips ['Right ' ];
364365 $ FE ['PIP_Input_64 ' ] = base64_encode ($ Pips ['Right ' ]);
365366 $ FE ['Gradient_Degree ' ] = 90 ;
@@ -368,6 +369,7 @@ public function view(string $Page = ''): void
368369 } else {
369370 $ FE ['FE_Align ' ] = 'right ' ;
370371 $ FE ['FE_Align_Reverse ' ] = 'left ' ;
372+ $ FE ['FE_Align_Mode ' ] = 'rl ' ;
371373 $ FE ['PIP_Input ' ] = $ Pips ['Left ' ];
372374 $ FE ['PIP_Input_64 ' ] = base64_encode ($ Pips ['Left ' ]);
373375 $ FE ['Gradient_Degree ' ] = 270 ;
@@ -1095,8 +1097,16 @@ public function view(string $Page = ''): void
10951097 ) {
10961098 $ DirValue ['Posts ' ] = [];
10971099 foreach ($ DirValue ['choices ' ] as $ DirValue ['ThisChoiceKey ' ] => $ DirValue ['ThisChoice ' ]) {
1098- if (!empty ($ _POST [$ ThisDir ['DirLangKey ' ] . '_ ' . $ DirValue ['ThisChoiceKey ' ]])) {
1099- $ DirValue ['Posts ' ][] = $ DirValue ['ThisChoiceKey ' ];
1100+ if (isset ($ DirValue ['labels ' ]) && is_array ($ DirValue ['labels ' ])) {
1101+ foreach ($ DirValue ['labels ' ] as $ DirValue ['ThisLabelKey ' ] => $ DirValue ['ThisLabel ' ]) {
1102+ if (!empty ($ _POST [$ ThisDir ['DirLangKey ' ] . '_ ' . $ DirValue ['ThisChoiceKey ' ] . '_ ' . $ DirValue ['ThisLabelKey ' ]])) {
1103+ $ DirValue ['Posts ' ][] = $ DirValue ['ThisChoiceKey ' ] . ': ' . $ DirValue ['ThisLabelKey ' ];
1104+ }
1105+ }
1106+ } else {
1107+ if (!empty ($ _POST [$ ThisDir ['DirLangKey ' ] . '_ ' . $ DirValue ['ThisChoiceKey ' ]])) {
1108+ $ DirValue ['Posts ' ][] = $ DirValue ['ThisChoiceKey ' ];
1109+ }
11001110 }
11011111 }
11021112 $ DirValue ['Posts ' ] = implode (', ' , $ DirValue ['Posts ' ]) ?: '' ;
@@ -1109,7 +1119,10 @@ public function view(string $Page = ''): void
11091119 }
11101120 }
11111121 if (isset ($ DirValue ['preview ' ])) {
1112- $ ThisDir ['Preview ' ] = ($ DirValue ['preview ' ] === 'allow_other ' ) ? '' : ' = <span id=" ' . $ ThisDir ['DirLangKey ' ] . '_preview"></span> ' ;
1122+ $ ThisDir ['Preview ' ] = ($ DirValue ['preview ' ] === 'allow_other ' ) ? '' : sprintf (
1123+ $ DirValue ['preview_default_fill ' ] ?? ' = <span id="%s_preview"></span> ' ,
1124+ $ ThisDir ['DirLangKey ' ]
1125+ );
11131126 $ ThisDir ['Trigger ' ] = ' onchange="javascript: ' . $ ThisDir ['DirLangKey ' ] . '_function();" onkeyup="javascript: ' . $ ThisDir ['DirLangKey ' ] . '_function();" ' ;
11141127 if ($ DirValue ['preview ' ] === 'kb ' ) {
11151128 $ ThisDir ['Preview ' ] .= sprintf (
@@ -1213,6 +1226,11 @@ public function view(string $Page = ''): void
12131226 'document.all ' ,
12141227 $ ThisDir ['DirLangKeyOther ' ]
12151228 );
1229+ } elseif (substr ($ DirValue ['preview ' ], 0 , 3 ) === 'js: ' ) {
1230+ $ ThisDir ['Preview ' ] .= '<script type="text/javascript"> ' . sprintf (
1231+ substr ($ DirValue ['preview ' ], 3 ),
1232+ $ ThisDir ['DirLangKey ' ]
1233+ ) . '</script> ' ;
12161234 }
12171235 }
12181236 if ($ DirValue ['type ' ] === 'timezone ' ) {
@@ -1222,7 +1240,36 @@ public function view(string $Page = ''): void
12221240 }
12231241 }
12241242 if (isset ($ DirValue ['choices ' ])) {
1225- if ($ DirValue ['type ' ] !== 'checkbox ' ) {
1243+ if ($ DirValue ['type ' ] === 'checkbox ' ) {
1244+ if (isset ($ DirValue ['labels ' ]) && is_array ($ DirValue ['labels ' ])) {
1245+ $ ThisDir ['FieldOut ' ] = sprintf (
1246+ '<div style="display:grid;grid-template-columns:%s;text-align:%s"> ' ,
1247+ str_repeat ('18px ' , count ($ DirValue ['labels ' ])) . 'auto ' ,
1248+ $ FE ['FE_Align ' ]
1249+ );
1250+ $ DirValue ['HasLabels ' ] = true ;
1251+ foreach ($ DirValue ['labels ' ] as $ DirValue ['ThisLabel ' ]) {
1252+ foreach (['response_ ' , 'label_ ' , 'field_ ' ] as $ LabelPrefix ) {
1253+ if (array_key_exists ($ LabelPrefix . $ DirValue ['ThisLabel ' ], $ this ->Loader ->L10N ->Data )) {
1254+ $ DirValue ['ThisLabel ' ] = $ this ->Loader ->L10N ->getString ($ LabelPrefix . $ DirValue ['ThisLabel ' ]);
1255+ break ;
1256+ }
1257+ }
1258+ $ ThisDir ['FieldOut ' ] .= sprintf (
1259+ '<div class="gridboxitem" style="text-align:right;writing-mode:vertical-%s;height:auto;line-height:18px"><span class="s">%s</span></div> ' ,
1260+ $ FE ['FE_Align_Mode ' ],
1261+ $ DirValue ['ThisLabel ' ]
1262+ );
1263+ }
1264+ $ ThisDir ['FieldOut ' ] .= '<div class="gridboxitem"></div> ' ;
1265+ } else {
1266+ $ ThisDir ['FieldOut ' ] = sprintf (
1267+ '<div style="display:grid;grid-template-columns:18px auto;text-align:%s"> ' ,
1268+ $ FE ['FE_Align ' ]
1269+ );
1270+ $ DirValue ['HasLabels ' ] = false ;
1271+ }
1272+ } else {
12261273 $ ThisDir ['FieldOut ' ] = sprintf (
12271274 '<select class="auto" style="text-transform:capitalize" name="%1$s" id="%1$s_field"%2$s> ' ,
12281275 $ ThisDir ['DirLangKey ' ],
@@ -1243,12 +1290,31 @@ public function view(string $Page = ''): void
12431290 $ ChoiceValue = $ this ->Loader ->parse ($ this ->Loader ->L10N ->Data , $ ChoiceValue );
12441291 }
12451292 if ($ DirValue ['type ' ] === 'checkbox ' ) {
1246- $ ThisDir ['FieldOut ' ] .= sprintf (
1247- '<input type="checkbox" class="auto" name="%1$s" id="%1$s"%2$s /><label for="%1$s" class="s">%3$s</label><br /> ' ,
1248- $ ThisDir ['DirLangKey ' ] . '_ ' . $ ChoiceKey ,
1249- $ this ->Loader ->Request ->inCsv ($ ChoiceKey , $ this ->Loader ->Configuration [$ CatKey ][$ DirKey ]) ? ' checked ' : '' ,
1250- $ ChoiceValue
1251- );
1293+ if ($ DirValue ['HasLabels ' ]) {
1294+ foreach ($ DirValue ['labels ' ] as $ DirValue ['ThisLabelKey ' ] => $ DirValue ['ThisLabel ' ]) {
1295+ $ ThisDir ['FieldOut ' ] .= sprintf (
1296+ '<div class="gridboxitem" style="text-align:center;vertical-align:middle"><input%3$s type="checkbox" class="auto" name="%1$s" id="%1$s"%2$s /></div> ' ,
1297+ $ ThisDir ['DirLangKey ' ] . '_ ' . $ ChoiceKey . '_ ' . $ DirValue ['ThisLabelKey ' ],
1298+ $ this ->Loader ->Request ->inCsv (
1299+ $ ChoiceKey . ': ' . $ DirValue ['ThisLabelKey ' ],
1300+ $ this ->Loader ->Configuration [$ CatKey ][$ DirKey ]
1301+ ) ? ' checked ' : '' ,
1302+ $ ThisDir ['Trigger ' ]
1303+ );
1304+ }
1305+ $ ThisDir ['FieldOut ' ] .= sprintf ('<div class="gridboxitem"><span class="s">%s</span></div> ' , $ ChoiceValue );
1306+ } else {
1307+ $ ThisDir ['FieldOut ' ] .= sprintf (
1308+ '<div class="gridboxitem" style="text-align:center;vertical-align:middle"><input%4$s type="checkbox" class="auto" name="%1$s" id="%1$s"%2$s /></div><div class="gridboxitem"><label for="%1$s" class="s" style="cursor:pointer">%3$s</label></div> ' ,
1309+ $ ThisDir ['DirLangKey ' ] . '_ ' . $ ChoiceKey ,
1310+ $ this ->Loader ->Request ->inCsv (
1311+ $ ChoiceKey ,
1312+ $ this ->Loader ->Configuration [$ CatKey ][$ DirKey ]
1313+ ) ? ' checked ' : '' ,
1314+ $ ChoiceValue ,
1315+ $ ThisDir ['Trigger ' ]
1316+ );
1317+ }
12521318 } else {
12531319 foreach (['response_ ' , 'label_ ' , 'field_ ' ] as $ ChoicePrefix ) {
12541320 if (array_key_exists ($ ChoicePrefix . $ ChoiceValue , $ this ->Loader ->L10N ->Data )) {
@@ -1264,7 +1330,9 @@ public function view(string $Page = ''): void
12641330 );
12651331 }
12661332 }
1267- if ($ DirValue ['type ' ] !== 'checkbox ' ) {
1333+ if ($ DirValue ['type ' ] === 'checkbox ' ) {
1334+ $ ThisDir ['FieldOut ' ] .= '</div> ' ;
1335+ } else {
12681336 $ ThisDir ['SelectOther ' ] = !isset ($ DirValue ['choices ' ][$ this ->Loader ->Configuration [$ CatKey ][$ DirKey ]]);
12691337 $ ThisDir ['FieldOut ' ] .= empty ($ DirValue ['allow_other ' ]) ? '</select> ' : sprintf (
12701338 '<option value="Other"%1$s>%2$s</option></select> <input type="text"%3$s class="auto" name="%4$s" id="%4$s_field" value="%5$s" /> ' ,
@@ -1277,7 +1345,7 @@ public function view(string $Page = ''): void
12771345 }
12781346 } elseif ($ DirValue ['type ' ] === 'bool ' ) {
12791347 $ ThisDir ['FieldOut ' ] = sprintf (
1280- '<select class="auto" name="%1$s" id="%1$s_field"%2$s> ' .
1348+ '<select class="auto" name="%1$s" id="%1$s_field"%2$s> ' .
12811349 '<option value="true"%5$s>%3$s</option><option value="false"%6$s>%4$s</option> ' .
12821350 '</select> ' ,
12831351 $ ThisDir ['DirLangKey ' ],
0 commit comments