PluginProbe
Contact Forms by Cimatti / 2.2.4
Contact Forms by Cimatti v2.2.4
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
contact-forms / classes / Element / Radio.php

Radio.php in Contact Forms by Cimatti 2.2.4, at classes/Element/Radio.php

69 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped, PluginCheck.CodeAnalysis.Heredoc -- PFBC framework extension, HTML output is controlled
3 class AccuaForm_Element_Radio extends AccuaForm_OptionElement {
4 protected $attributes = array("type" => "radio");
5 protected $inline;
6 protected $maxheight;
7
8 public function jQueryDocumentReady() {
9 if(!empty($this->inline))
10 echo 'jQuery("#', $this->attributes["id"], ' .pfbc-radio:last").css("margin-right", "0");';
11 else
12 echo 'jQuery("#', $this->attributes["id"], ' .pfbc-radio:last").css({ "padding-bottom": "0", "border-bottom": "none" });';
13
14 if(!empty($this->maxheight) && is_numeric($this->maxheight)) {
15 echo <<<JS
16 var radiobuttons = jQuery("#{$this->attributes["id"]} .pfbc-radio-buttons");
17 if(radiobuttons.outerHeight() > {$this->maxheight}) {
18 radiobuttons.css({
19 "height": "{$this->maxheight}px",
20 "overflow": "auto",
21 "overflow-x": "hidden"
22 });
23 }
24 JS;
25 }
26 }
27
28 public function render() {
29 // Apply ARIA attributes for accessibility (EAA compliance)
30 $this->applyAriaAttributes();
31
32 $count = 0;
33 $checked = false;
34 $wrapperCssId = $this->getWrapperCssId();
35 $wrapperCssClass = $this->getWrapperCssClass();
36 echo '<div id="', $this->attributes["id"], '"><div class="pfbc-radio-buttons">';
37 foreach($this->options as $value => $text) {
38 $value = $this->getOptionValue($value);
39 $optionNum = $count + 1;
40 $optionClass = 'pfbc-radio';
41 if(!empty($wrapperCssClass)) {
42 $optionClass .= ' ' . esc_attr($wrapperCssClass) . '-option-' . $optionNum;
43 }
44 echo '<div class="', $optionClass, '"';
45 if(!empty($wrapperCssId)) {
46 echo ' id="', esc_attr($wrapperCssId), '-option-', $optionNum, '"';
47 }
48 echo '><input id="', $this->attributes["id"], "-", $count, '"', $this->getAttributes(array("id", "value", "checked")), ' value="', $this->filter($value), '"';
49 if(isset($this->attributes["value"]) && $this->attributes["value"] == $value)
50 echo ' checked="checked"';
51 echo '/>&nbsp;<label for="', $this->attributes["id"], "-", $count, '">', $text, '</label></div>';
52 ++$count;
53 }
54 echo '</div>';
55
56 if(!empty($this->inline))
57 echo '<div style="clear: both;"></div>';
58
59 echo '</div>';
60 }
61
62 public function renderCSS() {
63 if(!empty($this->inline))
64 echo '#', $this->attributes["id"], ' .pfbc-radio { float: left; margin-right: 0.5em; }';
65 else
66 echo '#', $this->attributes["id"], ' .pfbc-radio { padding: 0.5em 0; border-bottom: 1px solid #f4f4f4; }';
67 }
68 }
69