PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.13
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.13
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
bit-form / includes / Frontend / Form / View / Theme / Fields / TitleField.php

TitleField.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.21.13, at includes/Frontend/Form/View/Theme/Fields/TitleField.php

114 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Frontend\Form\View\Theme\Fields;
4
5 use BitCode\BitForm\Core\Util\FieldValueHandler;
6
7 class TitleField
8 {
9 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
10 {
11 return self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
12 }
13
14 private static function titleGenerator($tag, $text, $cls, $preIcn, $sufIcn, $fk, $field, $form_atomic_Cls_map)
15 {
16 $text = FieldValueHandler::replaceSmartTagWithValue($text);
17 $fieldHelpers = new ClassicFieldHelpers($field, $fk, $form_atomic_Cls_map);
18
19 return sprintf(
20 ' <%1$s class="%2$s %3$s">
21 %4$s
22 %5$s
23 %6$s
24 </%1$s>',
25 $tag,
26 $fieldHelpers->getAtomicCls($cls),
27 $fieldHelpers->getCustomClasses($cls),
28 $preIcn,
29 $fieldHelpers->kses_post($text),
30 $sufIcn
31 );
32 }
33
34 private static function iconImg($field, $object, $element, $fieldHelpers, $alt, $fk)
35 {
36 return sprintf(
37 '<img
38 %1$s
39 class="%2$s %3$s"
40 src="%4$s"
41 alt="%5$s"
42 />',
43 $fieldHelpers->getCustomAttributes($element),
44 $fieldHelpers->getAtomicCls($element),
45 $fieldHelpers->getCustomClasses($element),
46 $fieldHelpers->esc_url($field->$object),
47 $fieldHelpers->esc_attr($alt)
48 );
49 }
50
51 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
52 {
53 $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
54
55 $logo = $fieldHelpers->icon('logo', 'logo');
56 $titleHide = '';
57 $subtitleHide = '';
58
59 $titlePreIcn = '';
60 $titleSufIcn = '';
61 $subTitlPreIcn = '';
62 $subTitlSufIcn = '';
63
64 if (property_exists($field, 'titlePreIcn')) {
65 $titlePreIcn = self::iconImg($field, 'titlePreIcn', 'title-pre-i', $fieldHelpers, 'Title Prefix Icon', $rowID);
66 }
67
68 if (property_exists($field, 'titleSufIcn')) {
69 $titleSufIcn = self::iconImg($field, 'titleSufIcn', 'title-suf-i', $fieldHelpers, 'Title Suffix Icon', $rowID);
70 }
71
72 if (property_exists($field, 'subTitlPreIcn')) {
73 $subTitlPreIcn = self::iconImg($field, 'subTitlPreIcn', 'sub-titl-pre-i', $fieldHelpers, 'Subtitle Prefix Icon', $rowID);
74 }
75
76 if (property_exists($field, 'subTitlSufIcn')) {
77 $subTitlSufIcn = self::iconImg($field, 'subTitlSufIcn', 'sub-titl-suf-i', $fieldHelpers, 'Subtitle Suffix Icon', $rowID);
78 }
79
80 if (property_exists($field, 'titleHide') && !$field->titleHide) {
81 $titleHide = self::titleGenerator($field->titleTag, $field->title, 'title', $titlePreIcn, $titleSufIcn, $rowID, $field, $form_atomic_Cls_map);
82 }
83
84 if (property_exists($field, 'subtitleHide') && !$field->subtitleHide) {
85 $subtitleHide = self::titleGenerator($field->subTitleTag, $field->subtitle, 'sub-titl', $subTitlPreIcn, $subTitlSufIcn, $rowID, $field, $form_atomic_Cls_map);
86 }
87
88 return sprintf(
89 '<div
90 %1$s
91 class="%2$s %3$s"
92 >
93 %4$s
94 <div
95 %5$s
96 class="%6$s %7$s"
97 >
98 %8$s
99 %9$s
100 </div>
101 </div>',
102 $fieldHelpers->getCustomAttributes('fld-wrp'),
103 $fieldHelpers->getAtomicCls('fld-wrp'),
104 $fieldHelpers->getCustomClasses('fld-wrp'),
105 $logo,
106 $fieldHelpers->getCustomAttributes('titl-wrp'),
107 $fieldHelpers->getAtomicCls('titl-wrp'),
108 $fieldHelpers->getCustomClasses('titl-wrp'),
109 $titleHide,
110 $subtitleHide
111 );
112 }
113 }
114