Skip to content

Commit c881529

Browse files
jools-rBloke
authored andcommitted
Self-closing tag ending acc. to doctype setting
Pleases the W3C validator. Self-closing tag ending acc. to doctype setting Pleases the W3C validator.
1 parent af3d982 commit c881529

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

com_connect.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ function com_connect($atts, $thing = '')
330330
'thanks_form' => ''
331331
), $atts));
332332

333+
$doctype = get_pref('doctype', 'xhtml');
334+
333335
if (!empty($lang)) {
334336
$strings = com_connect_load_lang($lang);
335337
$current = Txp::get('\Textpattern\L10n\Lang')->getStrings();
@@ -431,12 +433,13 @@ function com_connect($atts, $thing = '')
431433
$form = ($form) ? fetch_form($form) : $thing;
432434

433435
if (empty($form)) {
436+
$br = ($doctype === 'xhtml') ? '<br />' : '<br>';
434437
$form = '
435-
<txp:com_connect_text label="'.gTxt('com_connect_name').'" /><br />
436-
<txp:com_connect_email /><br />'.
437-
($send_article ? '<txp:com_connect_email send_article="1" label="'.gTxt('com_connect_recipient').'" /><br />' : '').
438-
'<txp:com_connect_textarea /><br />
439-
<txp:com_connect_submit />
438+
<txp:com_connect_text label="'.gTxt('com_connect_name').'" />'.$br.
439+
'<txp:com_connect_email />'.$br.
440+
($send_article ? '<txp:com_connect_email send_article="1" label="'.gTxt('com_connect_recipient').'" />'.$br : '').
441+
'<txp:com_connect_textarea />'.$br.
442+
'<txp:com_connect_submit />
440443
';
441444
}
442445

@@ -605,8 +608,8 @@ function com_connect($atts, $thing = '')
605608
($label ? n . '<fieldset>' : '') .
606609
($label ? n . '<legend>' . txpspecialchars($label) . '</legend>' : '') .
607610
$out .
608-
n . '<input type="hidden" name="com_connect_nonce" value="' . $com_connect_nonce . '" />' .
609-
n . '<input type="hidden" name="com_connect_form_id" value="' . $com_connect_form_id . '" />' .
611+
n . '<input type="hidden" name="com_connect_nonce" value="' . $com_connect_nonce . '"' . (($doctype === 'xhtml') ? ' />' : '>') .
612+
n . '<input type="hidden" name="com_connect_form_id" value="' . $com_connect_form_id . '"' . (($doctype === 'xhtml') ? ' />' : '>') .
610613
$form .
611614
callback_event('comconnect.form') .
612615
($label ? (n . '</fieldset>') : '') .
@@ -828,7 +831,7 @@ function com_connect_text($atts)
828831
$labelStr = ($label) ? '<label for="' . $name . '"' . $classStr . '>' . txpspecialchars($label) . '</label>' : '';
829832

830833
return ($labelStr && $label_position === 'before' ? $labelStr . $break : '') .
831-
'<input' . $classStr . ($attr ? ' ' . implode(' ', $attr) : '') . ' />' .
834+
'<input' . $classStr . ($attr ? ' ' . implode(' ', $attr) : '') . (($doctype === 'xhtml') ? ' />' : '>') .
832835
($labelStr && $label_position === 'after' ? $break . $labelStr : '');
833836
}
834837

@@ -1304,7 +1307,7 @@ function com_connect_checkbox($atts)
13041307

13051308
return ($labelStr && $label_position === 'before' ? $labelStr . $break : '') .
13061309
'<input type="checkbox"' . $classStr .
1307-
($theValue ? ' checked' . (($doctype === 'xhtml') ? '="checked"' : '') : '') . ($attr ? ' ' . implode(' ', $attr) : '') . ' />' .
1310+
($theValue ? ' checked' . (($doctype === 'xhtml') ? '="checked"' : '') : '') . ($attr ? ' ' . implode(' ', $attr) : '') . (($doctype === 'xhtml') ? ' />' : '>') .
13081311
($labelStr && $label_position === 'after' ? $break . $labelStr : '');
13091312
}
13101313

@@ -1426,7 +1429,7 @@ function com_connect_radio($atts)
14261429

14271430
return ($labelStr && $label_position === 'before' ? $labelStr . $break : '') .
14281431
'<input type="radio"'. $classStr . ($attr ? ' ' . implode(' ', $attr) : '') .
1429-
( $is_checked ? ' checked' . (($doctype === 'xhtml') ? '="checked"' : ''). ' />' : ' />') .
1432+
( $is_checked ? ' checked' . (($doctype === 'xhtml') ? '="checked"' : '') : '') . (($doctype === 'xhtml') ? ' />' : '>') .
14301433
($labelStr && $label_position === 'after' ? $break . $labelStr : '');
14311434
}
14321435

@@ -1528,7 +1531,7 @@ function com_connect_submit($atts, $thing = '')
15281531
if ($thing) {
15291532
return '<button type="submit"' . $classStr . ' name="com_connect_submit" value="' . $label . '"' . ($attr ? ' ' . implode(' ', $attr) : '') . '>' . ($thing ? trim(parse($thing)) : $label) . '</button>';
15301533
} else {
1531-
return '<input type="submit"' . $classStr . ' name="com_connect_submit" value="' . $label . '"' . ($attr ? ' ' . implode(' ', $attr) : '') . ' />';
1534+
return '<input type="submit"' . $classStr . ' name="com_connect_submit" value="' . $label . '"' . ($attr ? ' ' . implode(' ', $attr) : '') . (($doctype === 'xhtml') ? ' />' : '>');
15321535
}
15331536
}
15341537

@@ -1649,7 +1652,7 @@ function com_connect_lAtts($pairs, $atts)
16491652
}
16501653

16511654
if (isset($atts['break']) && $atts['break'] === 'br') {
1652-
$atts['break'] = '<br />';
1655+
$atts['break'] = ($doctype === 'xhtml') ? '<br />' : '<br>';
16531656
}
16541657

16551658
$com_connect_globals = array(

0 commit comments

Comments
 (0)