PluginProbe
Contact Forms by Cimatti / 2.3.5
Contact Forms by Cimatti v2.3.5
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 / Checkbox.php

Checkbox.php in Contact Forms by Cimatti 2.3.5, at classes/Element/Checkbox.php

78 lines 2.8 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_Checkbox extends AccuaForm_OptionElement {
4 protected $attributes = array("type" => "checkbox");
5 protected $inline;
6 protected $maxheight;
7
8 public function jQueryDocumentReady() {
9 if(!empty($this->inline))
10 echo 'jQuery("#', $this->attributes["id"], ' .pfbc-checkbox:last").css("margin-right", "0");';
11 else
12 echo 'jQuery("#', $this->attributes["id"], ' .pfbc-checkbox:last").css({ "padding-bottom": "0", "border-bottom": "none" });';
13
14 if(!empty($this->maxheight) && is_numeric($this->maxheight)) {
15 echo <<<JS
16 var checkboxes = jQuery("#{$this->attributes["id"]} .pfbc-checkboxes");
17 if(checkboxes.outerHeight() > {$this->maxheight}) {
18 checkboxes.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 if(isset($this->attributes["value"])) {
33 if(!is_array($this->attributes["value"]))
34 $this->attributes["value"] = array($this->attributes["value"]);
35 }
36 else
37 $this->attributes["value"] = array();
38
39 if(substr($this->attributes["name"], -2) != "[]")
40 $this->attributes["name"] .= "[]";
41
42 $count = 0;
43 $wrapperCssId = $this->getWrapperCssId();
44 $wrapperCssClass = $this->getWrapperCssClass();
45 echo '<div id="', $this->attributes["id"], '"><div class="pfbc-checkboxes">';
46 foreach($this->options as $value => $text) {
47 $value = $this->getOptionValue($value);
48 $optionNum = $count + 1;
49 $optionClass = 'pfbc-checkbox';
50 if(!empty($wrapperCssClass)) {
51 $optionClass .= ' ' . esc_attr($wrapperCssClass) . '-option-' . $optionNum;
52 }
53 echo '<div class="', $optionClass, '"';
54 if(!empty($wrapperCssId)) {
55 echo ' id="', esc_attr($wrapperCssId), '-option-', $optionNum, '"';
56 }
57 echo '><input id="', $this->attributes["id"], "-", $count, '"', $this->getAttributes(array("id", "value", "checked")), ' value="', $this->filter($value), '"';
58 if(in_array($value, $this->attributes["value"]))
59 echo ' checked="checked"';
60 echo '/>&nbsp;<label for="', $this->attributes["id"], "-", $count, '">', $text, '</label></div>';
61 ++$count;
62 }
63 echo '</div>';
64
65 if(!empty($this->inline))
66 echo '<div style="clear: both;"></div>';
67
68 echo '</div>';
69 }
70
71 public function renderCSS() {
72 if(!empty($this->inline))
73 echo '#', $this->attributes["id"], ' .pfbc-checkbox { float: left; margin-right: 0.5em; }';
74 else
75 echo '#', $this->attributes["id"], ' .pfbc-checkbox { padding: 0.5em 0; border-bottom: 1px solid #f4f4f4; }';
76 }
77 }
78