PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.31
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.31
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / FormBuilder / Components / Rating.php

Rating.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 3.6.31, at app/Services/FormBuilder/Components/Rating.php

60 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 namespace FluentForm\App\Services\FormBuilder\Components;
4
5 use FluentForm\App\Helpers\Helper;
6 use FluentForm\Framework\Helpers\ArrayHelper;
7
8 class Rating extends BaseComponent
9 {
10 /**
11 * Compile and echo the html element
12 * @param array $data [element data]
13 * @param stdClass $form [Form Object]
14 * @return viod
15 */
16 public function compile($data, $form)
17 {
18 $elementName = $data['element'];
19 $data = apply_filters('fluenform_rendering_field_data_'.$elementName, $data, $form);
20
21 $data['attributes']['type'] = 'radio';
22
23 $defaultValues = (array) $this->extractValueFromAttributes($data);
24
25 $elMarkup = "<div class='ff-el-ratings jss-ff-el-ratings'>";
26 $ratingText = "";
27
28 foreach ( $data['options'] as $value => $label ) {
29 $starred = '';
30 if(in_array($value, $defaultValues)) {
31 $data['attributes']['checked'] = true;
32 $starred = 'active';
33 } else {
34 $data['attributes']['checked'] = false;
35 }
36
37 if($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) {
38 $data['attributes']['tabindex'] = $tabIndex;
39 }
40
41 $atts = $this->buildAttributes($data['attributes']);
42 $id = $this->getUniqueid(str_replace(['[', ']'], ['', ''], $data['attributes']['name']));
43
44 $elMarkup .= "<label class='{$starred}'><input {$atts} id={$id} value='{$value}'>";
45 $elMarkup .= '<?xml version="1.0" encoding="iso-8859-1"?><svg class="jss-ff-svg ff-svg" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 53.867 53.867" style="enable-background:new 0 0 53.867 53.867;" xml:space="preserve"><polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g></svg>';
46 $elMarkup .= '</label>';
47
48 if (ArrayHelper::get($data, 'settings.show_text') == 'yes') {
49 $displayDefaultText = in_array($value, $defaultValues) ? 'display: inline-block' : 'display: none';
50 $ratingText .= "<span style='{$displayDefaultText}' class='ff-el-rating-text' data-id='{$id}'>{$label}</span>";
51 }
52 };
53
54 $elMarkup .= "</div>".$ratingText;
55
56 $html = $this->buildElementMarkup($elMarkup, $data, $form);
57 echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form);
58 }
59 }
60