PluginProbe
Contact Forms by Cimatti / 2.2.32
Contact Forms by Cimatti v2.2.32
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 / PFBC / Element / Checkbox.php

Checkbox.php in Contact Forms by Cimatti 2.2.32, at PFBC/Element/Checkbox.php

71 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PFBC (PHP Form Builder Class) - Third-party library
4 * @package PFBC
5 */
6
7 // phpcs:disable WordPress.Security.EscapeOutput, WordPress.NamingConventions.PrefixAllGlobals, PluginCheck.CodeAnalysis.Heredoc -- Third-party library
8
9 class Element_Checkbox extends OptionElement {
10 protected $attributes = array("type" => "checkbox");
11 protected $inline;
12 protected $maxheight;
13
14 public function jQueryDocumentReady() {
15 if(!empty($this->inline))
16 echo 'jQuery("#', $this->attributes["id"], ' .pfbc-checkbox:last").css("margin-right", "0");';
17 else
18 echo 'jQuery("#', $this->attributes["id"], ' .pfbc-checkbox:last").css({ "padding-bottom": "0", "border-bottom": "none" });';
19
20 if(!empty($this->maxheight) && is_numeric($this->maxheight)) {
21 echo <<<JS
22 var checkboxes = jQuery("#{$this->attributes["id"]} .pfbc-checkboxes");
23 if(checkboxes.outerHeight() > {$this->maxheight}) {
24 checkboxes.css({
25 "height": "{$this->maxheight}px",
26 "overflow": "auto",
27 "overflow-x": "hidden"
28 });
29 }
30 JS;
31 }
32 }
33
34 public function render() {
35 if(isset($this->attributes["value"])) {
36 if(!is_array($this->attributes["value"]))
37 $this->attributes["value"] = array($this->attributes["value"]);
38 }
39 else
40 $this->attributes["value"] = array();
41
42 if(substr($this->attributes["name"], -2) != "[]")
43 $this->attributes["name"] .= "[]";
44
45 $this->applyAriaAttributes();
46 $count = 0;
47 echo '<div id="', $this->attributes["id"], '"><div class="pfbc-checkboxes">';
48 foreach($this->options as $value => $text) {
49 $value = $this->getOptionValue($value);
50 echo '<div class="pfbc-checkbox"><table cellpadding="0" cellspacing="0"><tr><td valign="top"><input id="', $this->attributes["id"], "-", $count, '"', $this->getAttributes(array("id", "value", "checked")), ' value="', $this->filter($value), '"';
51 if(in_array($value, $this->attributes["value"]))
52 echo ' checked="checked"';
53 echo '/></td><td><label for="', $this->attributes["id"], "-", $count, '">', $text, '</label></td></tr></table></div>';
54 ++$count;
55 }
56 echo '</div>';
57
58 if(!empty($this->inline))
59 echo '<div style="clear: both;"></div>';
60
61 echo '</div>';
62 }
63
64 public function renderCSS() {
65 if(!empty($this->inline))
66 echo '#', $this->attributes["id"], ' .pfbc-checkbox { float: left; margin-right: 0.5em; }';
67 else
68 echo '#', $this->attributes["id"], ' .pfbc-checkbox { padding: 0.5em 0; border-bottom: 1px solid #f4f4f4; }';
69 }
70 }
71