1
|
|
|
<?php |
2
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit('No direct access allowed.'); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Template Layout strategy class for the EE Forms System that applies no layout. |
6
|
|
|
* |
7
|
|
|
* @package Event Espresso |
8
|
|
|
* @subpackage core |
9
|
|
|
* @author Mike Nelson |
10
|
|
|
* @since 4.6.0 |
11
|
|
|
*/ |
12
|
|
|
class EE_No_Layout extends EE_Div_Per_Section_Layout |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* This is a flag indicating whether to use '<br>' tags after each input in the layout |
18
|
|
|
* strategy. |
19
|
|
|
* |
20
|
|
|
* @var bool |
21
|
|
|
*/ |
22
|
|
|
protected $_use_break_tags = true; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* EE_No_Layout constructor. |
27
|
|
|
* |
28
|
|
|
* @param array $options Currently if this has a 'use_break_tags' key that is used to set the _use_break_tags |
29
|
|
|
* property on the class. |
30
|
|
|
*/ |
31
|
|
|
public function __construct($options = array()) |
32
|
|
|
{ |
33
|
|
|
$this->_use_break_tags = is_array($options) && isset($options['use_break_tags']) |
34
|
|
|
? filter_var($options['use_break_tags'], FILTER_VALIDATE_BOOLEAN) |
35
|
|
|
: $this->_use_break_tags; |
36
|
|
|
parent::__construct(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Add line break at beginning of form |
41
|
|
|
* |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function layout_form_begin() |
45
|
|
|
{ |
46
|
|
|
return EEH_HTML::nl(1); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Lays out the row for the input, including label and errors |
52
|
|
|
* |
53
|
|
|
* @param EE_Form_Input_Base $input |
54
|
|
|
* @return string |
55
|
|
|
* @throws \EE_Error |
56
|
|
|
*/ |
57
|
|
|
public function layout_input($input) |
58
|
|
|
{ |
59
|
|
|
$html = ''; |
60
|
|
|
if ($input instanceof EE_Hidden_Input) { |
61
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_input(); |
62
|
|
|
} else if ($input instanceof EE_Submit_Input) { |
63
|
|
|
$html .= $this->br(); |
64
|
|
|
$html .= $input->get_html_for_input(); |
65
|
|
|
} else if ($input instanceof EE_Select_Input) { |
66
|
|
|
$html .= $this->br(); |
67
|
|
|
$html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
68
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
69
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_input(); |
70
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_help(); |
71
|
|
|
$html .= $this->br(); |
72
|
|
|
} else if ($input instanceof EE_Form_Input_With_Options_Base) { |
73
|
|
|
$html .= $this->br(); |
74
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
75
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_input(); |
76
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_help(); |
77
|
|
|
} else { |
78
|
|
|
$html .= $this->br(); |
79
|
|
|
$html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
80
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
81
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_input(); |
82
|
|
|
$html .= EEH_HTML::nl() . $input->get_html_for_help(); |
83
|
|
|
} |
84
|
|
|
$html .= EEH_HTML::nl(-1); |
85
|
|
|
return $html; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Lays out a row for the subsection |
91
|
|
|
* |
92
|
|
|
* @param EE_Form_Section_Proper $form_section |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function layout_subsection($form_section) |
96
|
|
|
{ |
97
|
|
|
// d( $form_section ); |
98
|
|
|
return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Add line break at end of form. |
104
|
|
|
* |
105
|
|
|
* @return string |
106
|
|
|
*/ |
107
|
|
|
public function layout_form_end() |
108
|
|
|
{ |
109
|
|
|
return EEH_HTML::nl(-1); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* This returns a break tag or an empty string depending on the value of the `_use_break_tags` property. |
115
|
|
|
* |
116
|
|
|
* @return string |
117
|
|
|
*/ |
118
|
|
|
protected function br() |
119
|
|
|
{ |
120
|
|
|
return $this->_use_break_tags ? EEH_HTML::br() : ''; |
121
|
|
|
} |
122
|
|
|
} |