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