Completed
Branch FET-10580-form-html-parser (f9e386)
by
unknown
104:12 queued 91:46
created
core/libraries/rest_api/controllers/config/Read.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -42,27 +42,27 @@  discard block
 block discarded – undo
42 42
 	
43 43
 	/**
44 44
 	 * Handles the request for public site info
45
-     * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the current user could be authenticated using basic auth data
46
-     * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if basic auth data was somehow received
45
+	 * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the current user could be authenticated using basic auth data
46
+	 * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if basic auth data was somehow received
47 47
 	 * @param \WP_REST_Request $request
48 48
 	 * @return \EE_Config|\WP_Error
49 49
 	 */
50 50
 	public static function handle_request_site_info( \WP_REST_Request $request) {
51
-	    global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data;
52
-        $insecure_usage_of_basic_auth = apply_filters(
53
-            'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth',
54
-            $wp_json_basic_auth_success && ! is_ssl(),
55
-            $request
56
-        );
57
-        if( $insecure_usage_of_basic_auth ) {
58
-            $warning = sprintf(
59
-                esc_html__( 'Your data is not secured with SSL. %1$sPlease see our recommendations.%2$s', 'event_espresso' ),
60
-                '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">',
61
-                '</a>'
62
-            );
63
-        } else {
64
-            $warning = '';
65
-        }
51
+		global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data;
52
+		$insecure_usage_of_basic_auth = apply_filters(
53
+			'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth',
54
+			$wp_json_basic_auth_success && ! is_ssl(),
55
+			$request
56
+		);
57
+		if( $insecure_usage_of_basic_auth ) {
58
+			$warning = sprintf(
59
+				esc_html__( 'Your data is not secured with SSL. %1$sPlease see our recommendations.%2$s', 'event_espresso' ),
60
+				'<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">',
61
+				'</a>'
62
+			);
63
+		} else {
64
+			$warning = '';
65
+		}
66 66
 		return array(
67 67
 			'default_timezone' => array(
68 68
 				'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(),
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 				'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(),
71 71
 			),
72 72
 			'default_currency' => \EE_Config::instance()->currency,
73
-            'authentication' => array(
74
-                'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data,
75
-                'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth,
76
-                'warning' => $warning
77
-            )
73
+			'authentication' => array(
74
+				'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data,
75
+				'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth,
76
+				'warning' => $warning
77
+			)
78 78
 		);
79 79
 	}
80 80
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\rest_api\controllers\config;
3
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	 * @param \WP_REST_Request $request
22 22
 	 * @return \EE_Config|\WP_Error
23 23
 	 */
24
-	public static function handle_request( \WP_REST_Request $request) {
24
+	public static function handle_request(\WP_REST_Request $request) {
25 25
 		$cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap();
26
-		if( \EE_Capabilities::instance()->current_user_can( $cap, 'read_over_api' ) ){
26
+		if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) {
27 27
 			return \EE_Config::instance();
28
-		}else{
28
+		} else {
29 29
 			return new \WP_Error(
30 30
 				'cannot_read_config',
31 31
 				sprintf(
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 					),
36 36
 					$cap
37 37
 				),
38
-				array( 'status' => 403 )
38
+				array('status' => 403)
39 39
 			);
40 40
 		}
41 41
 	}
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
 	 * @param \WP_REST_Request $request
48 48
 	 * @return \EE_Config|\WP_Error
49 49
 	 */
50
-	public static function handle_request_site_info( \WP_REST_Request $request) {
50
+	public static function handle_request_site_info(\WP_REST_Request $request) {
51 51
 	    global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data;
52 52
         $insecure_usage_of_basic_auth = apply_filters(
53 53
             'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth',
54 54
             $wp_json_basic_auth_success && ! is_ssl(),
55 55
             $request
56 56
         );
57
-        if( $insecure_usage_of_basic_auth ) {
57
+        if ($insecure_usage_of_basic_auth) {
58 58
             $warning = sprintf(
59
-                esc_html__( 'Your data is not secured with SSL. %1$sPlease see our recommendations.%2$s', 'event_espresso' ),
59
+                esc_html__('Your data is not secured with SSL. %1$sPlease see our recommendations.%2$s', 'event_espresso'),
60 60
                 '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">',
61 61
                 '</a>'
62 62
             );
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 		return array(
67 67
 			'default_timezone' => array(
68 68
 				'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(),
69
-				'string' => get_option( 'timezone_string' ),
69
+				'string' => get_option('timezone_string'),
70 70
 				'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(),
71 71
 			),
72 72
 			'default_currency' => \EE_Config::instance()->currency,
73 73
             'authentication' => array(
74
-                'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data,
75
-                'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth,
74
+                'received_basic_auth_data' => (bool) $wp_json_basic_auth_received_data,
75
+                'insecure_usage_of_basic_auth' => (bool) $insecure_usage_of_basic_auth,
76 76
                 'warning' => $warning
77 77
             )
78 78
 		);
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.34.rc.004');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.34.rc.004');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorRowStandard.php 1 patch
Indentation   +392 added lines, -392 removed lines patch added patch discarded remove patch
@@ -19,398 +19,398 @@
 block discarded – undo
19 19
 class TicketSelectorRowStandard extends TicketSelectorRow
20 20
 {
21 21
 
22
-    /**
23
-     * @var TicketDetails $ticket_details
24
-     */
25
-    protected $ticket_details;
26
-
27
-    /**
28
-     * @var \EE_Ticket_Selector_Config $template_settings
29
-     */
30
-    protected $template_settings;
31
-
32
-    /**
33
-     * @var \EE_Tax_Config $tax_settings
34
-     */
35
-    protected $tax_settings;
36
-
37
-    /**
38
-     * @var boolean $prices_displayed_including_taxes
39
-     */
40
-    protected $prices_displayed_including_taxes;
41
-
42
-    /**
43
-     * @var int $row
44
-     */
45
-    protected $row;
46
-
47
-    /**
48
-     * @var int $cols
49
-     */
50
-    protected $cols;
51
-
52
-    /**
53
-     * @var boolean $hidden_input_qty
54
-     */
55
-    protected $hidden_input_qty;
56
-
57
-    /**
58
-     * @var string $ticket_datetime_classes
59
-     */
60
-    protected $ticket_datetime_classes;
61
-
62
-
63
-
64
-    /**
65
-     * TicketDetails constructor.
66
-     *
67
-     * @param TicketDetails  $ticket_details
68
-     * @param \EE_Tax_Config $tax_settings
69
-     * @param int            $total_tickets
70
-     * @param int            $max_atndz
71
-     * @param int            $row
72
-     * @param int            $cols
73
-     * @param boolean        $required_ticket_sold_out
74
-     * @param string         $event_status
75
-     * @param string         $ticket_datetime_classes
76
-     * @throws EE_Error
77
-     * @throws UnexpectedEntityException
78
-     */
79
-    public function __construct(
80
-        TicketDetails $ticket_details,
81
-        \EE_Tax_Config $tax_settings,
82
-        $total_tickets,
83
-        $max_atndz,
84
-        $row,
85
-        $cols,
86
-        $required_ticket_sold_out,
87
-        $event_status,
88
-        $ticket_datetime_classes
89
-    ) {
90
-        $this->ticket = $ticket_details->getTicket();
91
-        $this->ticket_details = $ticket_details;
92
-        $this->template_settings = $ticket_details->getTemplateSettings();
93
-        $this->tax_settings = $tax_settings;
94
-        $this->total_tickets = $total_tickets;
95
-        $this->max_atndz = $max_atndz;
96
-        $this->row = $row;
97
-        $this->cols = $cols;
98
-        $this->date_format = $ticket_details->getDateFormat();
99
-        $this->ticket_datetime_classes = $ticket_datetime_classes;
100
-        parent::__construct($this->ticket, $max_atndz, $this->date_format, $event_status, $required_ticket_sold_out);
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * other ticket rows will need to know if a required ticket is sold out,
107
-     * so that they are not offered for sale
108
-     *
109
-     * @return boolean
110
-     */
111
-    public function getRequiredTicketSoldOut()
112
-    {
113
-        return $this->required_ticket_sold_out;
114
-    }
115
-
116
-
117
-
118
-    /**
119
-     * @return int
120
-     */
121
-    public function getCols()
122
-    {
123
-        return $this->cols;
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     * getHtml
130
-     *
131
-     * @return string
132
-     * @throws EE_Error
133
-     */
134
-    public function getHtml()
135
-    {
136
-        $min = 0;
137
-        $max = $this->ticket->max();
138
-        $remaining = $this->ticket->remaining();
139
-        if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
140
-            list($min, $max) = $this->setTicketMinAndMax($remaining);
141
-        } else {
142
-            // set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
143
-            $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
144
-                ? $this->ticket->start_date()
145
-                : $this->required_ticket_sold_out;
146
-        }
147
-        list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
148
-        list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
149
-        /**
150
-         * Allow plugins to hook in and abort the generation and display of this row to do
151
-         * something else if they want.
152
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
153
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
154
-         * current row.
155
-         *
156
-         * @var string|bool
157
-         */
158
-        $ticket_selector_row_html = apply_filters(
159
-            'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
160
-            false,
161
-            $this->ticket,
162
-            $max,
163
-            $min,
164
-            $this->required_ticket_sold_out,
165
-            $ticket_price,
166
-            $ticket_bundle,
167
-            $ticket_status,
168
-            $status_class
169
-        );
170
-        if ($ticket_selector_row_html !== false) {
171
-            return $ticket_selector_row_html;
172
-        }
173
-        $ticket_selector_row_html = \EEH_HTML::tr(
174
-            '', '',
175
-            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
176
-        );
177
-        /**
178
-         * Allow plugins to hook in and abort the generation and display of the contents of this
179
-         * row to do something else if they want.
180
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
181
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
182
-         * current row.
183
-         *
184
-         * @var string|bool
185
-         */
186
-        $new_row_cells_content = apply_filters(
187
-            'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
188
-            false,
189
-            $this->ticket,
190
-            $max,
191
-            $min,
192
-            $this->required_ticket_sold_out,
193
-            $ticket_price,
194
-            $ticket_bundle,
195
-            $ticket_status,
196
-            $status_class
197
-        );
198
-        if ($new_row_cells_content !== false) {
199
-            return $ticket_selector_row_html
200
-                   . $new_row_cells_content
201
-                   . \EEH_HTML::trx();
202
-        }
203
-        $this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
204
-
205
-        $ticket_selector_row_html .= $this->ticketNameTableCell();
206
-        $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
207
-        $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
208
-        $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
209
-        if (empty($this->ticket_status_display)) {
210
-            if ($this->max_atndz === 1) {
211
-                // only ONE attendee is allowed to register at a time
212
-                $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
213
-            } else if ($max > 0) {
214
-                $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
215
-            }
216
-        }
217
-        $ticket_selector_row_html .= $this->ticket_status_display;
218
-        $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
219
-        $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
220
-        $ticket_selector_row_html .= \EEH_HTML::tdx();
221
-        $ticket_selector_row_html .= \EEH_HTML::trx();
222
-
223
-
224
-        $this->row++;
225
-        return $ticket_selector_row_html;
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     * setTicketMinAndMax
232
-     *
233
-     * @param int $remaining
234
-     * @return array
235
-     * @throws EE_Error
236
-     */
237
-    protected function setTicketMinAndMax($remaining)
238
-    {
239
-        // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
240
-        $max = min($remaining, $this->max_atndz);
241
-        // but... we also want to restrict the number of tickets by the ticket max setting,
242
-        // however, the max still can't be higher than what was just set above
243
-        $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
244
-        // and we also want to restrict the minimum number of tickets by the ticket min setting
245
-        $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
246
-        // and if the ticket is required, then make sure that min qty is at least 1
247
-        $min = $this->ticket->required() ? max($min, 1) : $min;
248
-        return array($min, $max);
249
-    }
250
-
251
-
252
-
253
-    /**
254
-     * getTicketPriceDetails
255
-     *
256
-     * @return array
257
-     * @throws EE_Error
258
-     */
259
-    protected function getTicketPriceDetails()
260
-    {
261
-        $ticket_price = $this->tax_settings->prices_displayed_including_taxes
262
-            ? $this->ticket->get_ticket_total_with_taxes()
263
-            : $this->ticket->get_ticket_subtotal();
264
-        $ticket_bundle = false;
265
-        $ticket_min = $this->ticket->min();
266
-        // for ticket bundles, set min and max qty the same
267
-        if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
268
-            $ticket_price *= $ticket_min;
269
-            $ticket_bundle = true;
270
-        }
271
-        $ticket_price = apply_filters(
272
-            'FHEE__ticket_selector_chart_template__ticket_price',
273
-            $ticket_price,
274
-            $this->ticket
275
-        );
276
-        return array($ticket_price, $ticket_bundle);
277
-    }
278
-
279
-
280
-
281
-
282
-    /**
283
-     * ticketNameTableCell
284
-     *
285
-     * @return string
286
-     * @throws EE_Error
287
-     */
288
-    protected function ticketNameTableCell()
289
-    {
290
-        $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
291
-        $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
292
-        $html .= $this->ticket_details->getShowHideLinks();
293
-        if ($this->ticket->required()) {
294
-            $html .= \EEH_HTML::p(
295
-                    apply_filters(
296
-                            'FHEE__ticket_selector_chart_template__ticket_required_message',
297
-                            esc_html__('This ticket is required and must be purchased.', 'event_espresso')
298
-                    ),
299
-                    '', 'ticket-required-pg'
300
-            );
301
-        }
302
-        $html .= \EEH_HTML::tdx();
303
-        return $html;
304
-    }
305
-
306
-
307
-
308
-    /**
309
-     * ticketPriceTableCell
310
-     *
311
-     * @param float $ticket_price
312
-     * @param bool  $ticket_bundle
313
-     * @return string
314
-     * @throws EE_Error
315
-     */
316
-    protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
317
-    {
318
-        $html = '';
319
-        if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
320
-            $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
321
-            $html .= \EEH_Template::format_currency($ticket_price);
322
-            $html .= $this->ticket->taxable()
323
-                ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
324
-                : '';
325
-            $html .= '&nbsp;';
326
-            $html .= \EEH_HTML::span(
327
-                $ticket_bundle
328
-                    ? apply_filters(
329
-                        'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
330
-                        __(' / bundle', 'event_espresso')
331
-                    )
332
-                    : apply_filters(
333
-                        'FHEE__ticket_selector_chart_template__per_ticket_text',
334
-                        __('', 'event_espresso')
335
-                    ),
336
-                '', 'smaller-text no-bold'
337
-            );
338
-            $html .= '&nbsp;';
339
-            $html .= \EEH_HTML::tdx();
340
-            $this->cols++;
341
-        }
342
-        return $html;
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * onlyOneAttendeeCanRegister
349
-     *
350
-     * @return string
351
-     */
352
-    protected function onlyOneAttendeeCanRegister()
353
-    {
354
-        // display submit button since we have tickets available
355
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
356
-        $this->hidden_input_qty = false;
357
-        $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
358
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
359
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
360
-        $html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
361
-        $html .= ' title=""/>';
362
-        return $html;
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     * ticketQuantitySelector
369
-     *
370
-     * @param int $min
371
-     * @param int $max
372
-     * @return string
373
-     * @throws EE_Error
374
-     */
375
-    protected function ticketQuantitySelector($min = 0, $max = 0)
376
-    {
377
-        // display submit button since we have tickets available
378
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
379
-        $this->hidden_input_qty = false;
380
-        $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
381
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
382
-        $html .= ' class="ticket-selector-tbl-qty-slct">';
383
-        // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
384
-        if ($min !== 0 && ! $this->ticket->required()) {
385
-            $html .= '<option value="0">&nbsp;0&nbsp;</option>';
386
-        }
387
-        // offer ticket quantities from the min to the max
388
-        for ($i = $min; $i <= $max; $i++) {
389
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
390
-        }
391
-        $html .= '</select>';
392
-        return $html;
393
-    }
394
-
395
-
396
-
397
-    /**
398
-     * getHiddenInputs
399
-     *
400
-     * @return string
401
-     * @throws EE_Error
402
-     */
403
-    protected function ticketQtyAndIdHiddenInputs()
404
-    {
405
-        $html = '';
406
-        // depending on group reg we need to change the format for qty
407
-        if ($this->hidden_input_qty) {
408
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
409
-        }
410
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
411
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
412
-        return $html;
413
-    }
22
+	/**
23
+	 * @var TicketDetails $ticket_details
24
+	 */
25
+	protected $ticket_details;
26
+
27
+	/**
28
+	 * @var \EE_Ticket_Selector_Config $template_settings
29
+	 */
30
+	protected $template_settings;
31
+
32
+	/**
33
+	 * @var \EE_Tax_Config $tax_settings
34
+	 */
35
+	protected $tax_settings;
36
+
37
+	/**
38
+	 * @var boolean $prices_displayed_including_taxes
39
+	 */
40
+	protected $prices_displayed_including_taxes;
41
+
42
+	/**
43
+	 * @var int $row
44
+	 */
45
+	protected $row;
46
+
47
+	/**
48
+	 * @var int $cols
49
+	 */
50
+	protected $cols;
51
+
52
+	/**
53
+	 * @var boolean $hidden_input_qty
54
+	 */
55
+	protected $hidden_input_qty;
56
+
57
+	/**
58
+	 * @var string $ticket_datetime_classes
59
+	 */
60
+	protected $ticket_datetime_classes;
61
+
62
+
63
+
64
+	/**
65
+	 * TicketDetails constructor.
66
+	 *
67
+	 * @param TicketDetails  $ticket_details
68
+	 * @param \EE_Tax_Config $tax_settings
69
+	 * @param int            $total_tickets
70
+	 * @param int            $max_atndz
71
+	 * @param int            $row
72
+	 * @param int            $cols
73
+	 * @param boolean        $required_ticket_sold_out
74
+	 * @param string         $event_status
75
+	 * @param string         $ticket_datetime_classes
76
+	 * @throws EE_Error
77
+	 * @throws UnexpectedEntityException
78
+	 */
79
+	public function __construct(
80
+		TicketDetails $ticket_details,
81
+		\EE_Tax_Config $tax_settings,
82
+		$total_tickets,
83
+		$max_atndz,
84
+		$row,
85
+		$cols,
86
+		$required_ticket_sold_out,
87
+		$event_status,
88
+		$ticket_datetime_classes
89
+	) {
90
+		$this->ticket = $ticket_details->getTicket();
91
+		$this->ticket_details = $ticket_details;
92
+		$this->template_settings = $ticket_details->getTemplateSettings();
93
+		$this->tax_settings = $tax_settings;
94
+		$this->total_tickets = $total_tickets;
95
+		$this->max_atndz = $max_atndz;
96
+		$this->row = $row;
97
+		$this->cols = $cols;
98
+		$this->date_format = $ticket_details->getDateFormat();
99
+		$this->ticket_datetime_classes = $ticket_datetime_classes;
100
+		parent::__construct($this->ticket, $max_atndz, $this->date_format, $event_status, $required_ticket_sold_out);
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * other ticket rows will need to know if a required ticket is sold out,
107
+	 * so that they are not offered for sale
108
+	 *
109
+	 * @return boolean
110
+	 */
111
+	public function getRequiredTicketSoldOut()
112
+	{
113
+		return $this->required_ticket_sold_out;
114
+	}
115
+
116
+
117
+
118
+	/**
119
+	 * @return int
120
+	 */
121
+	public function getCols()
122
+	{
123
+		return $this->cols;
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 * getHtml
130
+	 *
131
+	 * @return string
132
+	 * @throws EE_Error
133
+	 */
134
+	public function getHtml()
135
+	{
136
+		$min = 0;
137
+		$max = $this->ticket->max();
138
+		$remaining = $this->ticket->remaining();
139
+		if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
140
+			list($min, $max) = $this->setTicketMinAndMax($remaining);
141
+		} else {
142
+			// set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
143
+			$this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
144
+				? $this->ticket->start_date()
145
+				: $this->required_ticket_sold_out;
146
+		}
147
+		list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
148
+		list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
149
+		/**
150
+		 * Allow plugins to hook in and abort the generation and display of this row to do
151
+		 * something else if they want.
152
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
153
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
154
+		 * current row.
155
+		 *
156
+		 * @var string|bool
157
+		 */
158
+		$ticket_selector_row_html = apply_filters(
159
+			'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
160
+			false,
161
+			$this->ticket,
162
+			$max,
163
+			$min,
164
+			$this->required_ticket_sold_out,
165
+			$ticket_price,
166
+			$ticket_bundle,
167
+			$ticket_status,
168
+			$status_class
169
+		);
170
+		if ($ticket_selector_row_html !== false) {
171
+			return $ticket_selector_row_html;
172
+		}
173
+		$ticket_selector_row_html = \EEH_HTML::tr(
174
+			'', '',
175
+			"tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
176
+		);
177
+		/**
178
+		 * Allow plugins to hook in and abort the generation and display of the contents of this
179
+		 * row to do something else if they want.
180
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
181
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
182
+		 * current row.
183
+		 *
184
+		 * @var string|bool
185
+		 */
186
+		$new_row_cells_content = apply_filters(
187
+			'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
188
+			false,
189
+			$this->ticket,
190
+			$max,
191
+			$min,
192
+			$this->required_ticket_sold_out,
193
+			$ticket_price,
194
+			$ticket_bundle,
195
+			$ticket_status,
196
+			$status_class
197
+		);
198
+		if ($new_row_cells_content !== false) {
199
+			return $ticket_selector_row_html
200
+				   . $new_row_cells_content
201
+				   . \EEH_HTML::trx();
202
+		}
203
+		$this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
204
+
205
+		$ticket_selector_row_html .= $this->ticketNameTableCell();
206
+		$ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
207
+		$ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
208
+		$this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
209
+		if (empty($this->ticket_status_display)) {
210
+			if ($this->max_atndz === 1) {
211
+				// only ONE attendee is allowed to register at a time
212
+				$ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
213
+			} else if ($max > 0) {
214
+				$ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
215
+			}
216
+		}
217
+		$ticket_selector_row_html .= $this->ticket_status_display;
218
+		$ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
219
+		$ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
220
+		$ticket_selector_row_html .= \EEH_HTML::tdx();
221
+		$ticket_selector_row_html .= \EEH_HTML::trx();
222
+
223
+
224
+		$this->row++;
225
+		return $ticket_selector_row_html;
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 * setTicketMinAndMax
232
+	 *
233
+	 * @param int $remaining
234
+	 * @return array
235
+	 * @throws EE_Error
236
+	 */
237
+	protected function setTicketMinAndMax($remaining)
238
+	{
239
+		// offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
240
+		$max = min($remaining, $this->max_atndz);
241
+		// but... we also want to restrict the number of tickets by the ticket max setting,
242
+		// however, the max still can't be higher than what was just set above
243
+		$max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
244
+		// and we also want to restrict the minimum number of tickets by the ticket min setting
245
+		$min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
246
+		// and if the ticket is required, then make sure that min qty is at least 1
247
+		$min = $this->ticket->required() ? max($min, 1) : $min;
248
+		return array($min, $max);
249
+	}
250
+
251
+
252
+
253
+	/**
254
+	 * getTicketPriceDetails
255
+	 *
256
+	 * @return array
257
+	 * @throws EE_Error
258
+	 */
259
+	protected function getTicketPriceDetails()
260
+	{
261
+		$ticket_price = $this->tax_settings->prices_displayed_including_taxes
262
+			? $this->ticket->get_ticket_total_with_taxes()
263
+			: $this->ticket->get_ticket_subtotal();
264
+		$ticket_bundle = false;
265
+		$ticket_min = $this->ticket->min();
266
+		// for ticket bundles, set min and max qty the same
267
+		if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
268
+			$ticket_price *= $ticket_min;
269
+			$ticket_bundle = true;
270
+		}
271
+		$ticket_price = apply_filters(
272
+			'FHEE__ticket_selector_chart_template__ticket_price',
273
+			$ticket_price,
274
+			$this->ticket
275
+		);
276
+		return array($ticket_price, $ticket_bundle);
277
+	}
278
+
279
+
280
+
281
+
282
+	/**
283
+	 * ticketNameTableCell
284
+	 *
285
+	 * @return string
286
+	 * @throws EE_Error
287
+	 */
288
+	protected function ticketNameTableCell()
289
+	{
290
+		$html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
291
+		$html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
292
+		$html .= $this->ticket_details->getShowHideLinks();
293
+		if ($this->ticket->required()) {
294
+			$html .= \EEH_HTML::p(
295
+					apply_filters(
296
+							'FHEE__ticket_selector_chart_template__ticket_required_message',
297
+							esc_html__('This ticket is required and must be purchased.', 'event_espresso')
298
+					),
299
+					'', 'ticket-required-pg'
300
+			);
301
+		}
302
+		$html .= \EEH_HTML::tdx();
303
+		return $html;
304
+	}
305
+
306
+
307
+
308
+	/**
309
+	 * ticketPriceTableCell
310
+	 *
311
+	 * @param float $ticket_price
312
+	 * @param bool  $ticket_bundle
313
+	 * @return string
314
+	 * @throws EE_Error
315
+	 */
316
+	protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
317
+	{
318
+		$html = '';
319
+		if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
320
+			$html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
321
+			$html .= \EEH_Template::format_currency($ticket_price);
322
+			$html .= $this->ticket->taxable()
323
+				? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
324
+				: '';
325
+			$html .= '&nbsp;';
326
+			$html .= \EEH_HTML::span(
327
+				$ticket_bundle
328
+					? apply_filters(
329
+						'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
330
+						__(' / bundle', 'event_espresso')
331
+					)
332
+					: apply_filters(
333
+						'FHEE__ticket_selector_chart_template__per_ticket_text',
334
+						__('', 'event_espresso')
335
+					),
336
+				'', 'smaller-text no-bold'
337
+			);
338
+			$html .= '&nbsp;';
339
+			$html .= \EEH_HTML::tdx();
340
+			$this->cols++;
341
+		}
342
+		return $html;
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * onlyOneAttendeeCanRegister
349
+	 *
350
+	 * @return string
351
+	 */
352
+	protected function onlyOneAttendeeCanRegister()
353
+	{
354
+		// display submit button since we have tickets available
355
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
356
+		$this->hidden_input_qty = false;
357
+		$html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
358
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
359
+		$html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
360
+		$html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
361
+		$html .= ' title=""/>';
362
+		return $html;
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 * ticketQuantitySelector
369
+	 *
370
+	 * @param int $min
371
+	 * @param int $max
372
+	 * @return string
373
+	 * @throws EE_Error
374
+	 */
375
+	protected function ticketQuantitySelector($min = 0, $max = 0)
376
+	{
377
+		// display submit button since we have tickets available
378
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
379
+		$this->hidden_input_qty = false;
380
+		$html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
381
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
382
+		$html .= ' class="ticket-selector-tbl-qty-slct">';
383
+		// this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
384
+		if ($min !== 0 && ! $this->ticket->required()) {
385
+			$html .= '<option value="0">&nbsp;0&nbsp;</option>';
386
+		}
387
+		// offer ticket quantities from the min to the max
388
+		for ($i = $min; $i <= $max; $i++) {
389
+			$html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
390
+		}
391
+		$html .= '</select>';
392
+		return $html;
393
+	}
394
+
395
+
396
+
397
+	/**
398
+	 * getHiddenInputs
399
+	 *
400
+	 * @return string
401
+	 * @throws EE_Error
402
+	 */
403
+	protected function ticketQtyAndIdHiddenInputs()
404
+	{
405
+		$html = '';
406
+		// depending on group reg we need to change the format for qty
407
+		if ($this->hidden_input_qty) {
408
+			$html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
409
+		}
410
+		$html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
411
+		$html .= ' value="' . $this->ticket->ID() . '"/>';
412
+		return $html;
413
+	}
414 414
 
415 415
 }
416 416
 // End of file TicketSelectorRowStandard.php
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Base.form.php 2 patches
Indentation   +446 added lines, -446 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter;
3 3
 
4 4
 if (! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -19,462 +19,462 @@  discard block
 block discarded – undo
19 19
 abstract class EE_Form_Section_Base
20 20
 {
21 21
 
22
-    /**
23
-     * the URL the form is submitted to
24
-     *
25
-     * @var string
26
-     */
27
-    protected $_action;
28
-
29
-    /**
30
-     * POST (default) or GET
31
-     *
32
-     * @var string
33
-     */
34
-    protected $_method;
35
-
36
-    /**
37
-     * html_id and html_name are derived from this by default
38
-     *
39
-     * @var string
40
-     */
41
-    protected $_name;
42
-
43
-    /**
44
-     * $_html_id
45
-     * @var string
46
-     */
47
-    protected $_html_id;
48
-
49
-    /**
50
-     * $_html_class
51
-     * @var string
52
-     */
53
-    protected $_html_class;
54
-
55
-    /**
56
-     * $_html_style
57
-     * @var string
58
-     */
59
-    protected $_html_style;
60
-
61
-    /**
62
-     * $_other_html_attributes
63
-     * @var string
64
-     */
65
-    protected $_other_html_attributes;
66
-
67
-    /**
68
-     * The form section of which this form section is a part
69
-     *
70
-     * @var EE_Form_Section_Proper
71
-     */
72
-    protected $_parent_section;
73
-
74
-    /**
75
-     * flag indicating that _construct_finalize has been called.
76
-     * If it hasn't been called and we try to use functions which require it, we call it
77
-     * with no parameters. But normally, _construct_finalize should be called by the instantiating class
78
-     *
79
-     * @var boolean
80
-     */
81
-    protected $_construction_finalized;
82
-
83
-    /**
84
-     * Strategy for parsing the form HTML upon display
85
-     *
86
-     * @var FormHtmlFilter
87
-     */
88
-    protected $_form_html_filter;
89
-
90
-
91
-
92
-    /**
93
-     * @param array $options_array {
94
-     * @type        $name          string the name for this form section, if you want to explicitly define it
95
-     *                             }
96
-     */
97
-    public function __construct($options_array = array())
98
-    {
99
-        // used by display strategies
100
-        // assign incoming values to properties
101
-        foreach ($options_array as $key => $value) {
102
-            $key = '_' . $key;
103
-            if (property_exists($this, $key) && empty($this->{$key})) {
104
-                $this->{$key} = $value;
105
-            }
106
-        }
107
-        // set parser which allows the form section's rendered HTML to be filtered
108
-        if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
109
-            $this->_form_html_filter = $options_array['form_html_filter'];
110
-        }
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * @param $parent_form_section
117
-     * @param $name
118
-     * @throws \EE_Error
119
-     */
120
-    protected function _construct_finalize($parent_form_section, $name)
121
-    {
122
-        $this->_construction_finalized = true;
123
-        $this->_parent_section = $parent_form_section;
124
-        if ($name !== null) {
125
-            $this->_name = $name;
126
-        }
127
-    }
128
-
129
-
130
-
131
-    /**
132
-     * make sure construction finalized was called, otherwise children might not be ready
133
-     *
134
-     * @return void
135
-     * @throws \EE_Error
136
-     */
137
-    public function ensure_construct_finalized_called()
138
-    {
139
-        if (! $this->_construction_finalized) {
140
-            $this->_construct_finalize($this->_parent_section, $this->_name);
141
-        }
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     * @return string
148
-     */
149
-    public function action()
150
-    {
151
-        return $this->_action;
152
-    }
153
-
154
-
155
-
156
-    /**
157
-     * @param string $action
158
-     */
159
-    public function set_action($action)
160
-    {
161
-        $this->_action = $action;
162
-    }
163
-
164
-
165
-
166
-    /**
167
-     * @return string
168
-     */
169
-    public function method()
170
-    {
171
-        return ! empty($this->_method) ? $this->_method : 'POST';
172
-    }
173
-
174
-
175
-
176
-    /**
177
-     * @param string $method
178
-     */
179
-    public function set_method($method)
180
-    {
181
-        switch ($method) {
182
-            case 'get' :
183
-            case 'GET' :
184
-                $this->_method = 'GET';
185
-                break;
186
-            default :
187
-                $this->_method = 'POST';
188
-        }
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * Sets the html_id to its default value, if none was specified in the constructor.
195
-     * Calculation involves using the name and the parent's html id
196
-     * return void
197
-     *
198
-     * @throws \EE_Error
199
-     */
200
-    protected function _set_default_html_id_if_empty()
201
-    {
202
-        if (! $this->_html_id) {
203
-            if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
204
-                $this->_html_id = $this->_parent_section->html_id()
205
-                                  . '-'
206
-                                  . $this->_prep_name_for_html_id($this->name());
207
-            } else {
208
-                $this->_html_id = $this->_prep_name_for_html_id($this->name());
209
-            }
210
-        }
211
-    }
212
-
213
-
214
-
215
-    /**
216
-     * _prep_name_for_html_id
217
-     *
218
-     * @param $name
219
-     * @return string
220
-     */
221
-    private function _prep_name_for_html_id($name)
222
-    {
223
-        return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
224
-    }
22
+	/**
23
+	 * the URL the form is submitted to
24
+	 *
25
+	 * @var string
26
+	 */
27
+	protected $_action;
28
+
29
+	/**
30
+	 * POST (default) or GET
31
+	 *
32
+	 * @var string
33
+	 */
34
+	protected $_method;
35
+
36
+	/**
37
+	 * html_id and html_name are derived from this by default
38
+	 *
39
+	 * @var string
40
+	 */
41
+	protected $_name;
42
+
43
+	/**
44
+	 * $_html_id
45
+	 * @var string
46
+	 */
47
+	protected $_html_id;
48
+
49
+	/**
50
+	 * $_html_class
51
+	 * @var string
52
+	 */
53
+	protected $_html_class;
54
+
55
+	/**
56
+	 * $_html_style
57
+	 * @var string
58
+	 */
59
+	protected $_html_style;
60
+
61
+	/**
62
+	 * $_other_html_attributes
63
+	 * @var string
64
+	 */
65
+	protected $_other_html_attributes;
66
+
67
+	/**
68
+	 * The form section of which this form section is a part
69
+	 *
70
+	 * @var EE_Form_Section_Proper
71
+	 */
72
+	protected $_parent_section;
73
+
74
+	/**
75
+	 * flag indicating that _construct_finalize has been called.
76
+	 * If it hasn't been called and we try to use functions which require it, we call it
77
+	 * with no parameters. But normally, _construct_finalize should be called by the instantiating class
78
+	 *
79
+	 * @var boolean
80
+	 */
81
+	protected $_construction_finalized;
82
+
83
+	/**
84
+	 * Strategy for parsing the form HTML upon display
85
+	 *
86
+	 * @var FormHtmlFilter
87
+	 */
88
+	protected $_form_html_filter;
89
+
90
+
91
+
92
+	/**
93
+	 * @param array $options_array {
94
+	 * @type        $name          string the name for this form section, if you want to explicitly define it
95
+	 *                             }
96
+	 */
97
+	public function __construct($options_array = array())
98
+	{
99
+		// used by display strategies
100
+		// assign incoming values to properties
101
+		foreach ($options_array as $key => $value) {
102
+			$key = '_' . $key;
103
+			if (property_exists($this, $key) && empty($this->{$key})) {
104
+				$this->{$key} = $value;
105
+			}
106
+		}
107
+		// set parser which allows the form section's rendered HTML to be filtered
108
+		if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
109
+			$this->_form_html_filter = $options_array['form_html_filter'];
110
+		}
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * @param $parent_form_section
117
+	 * @param $name
118
+	 * @throws \EE_Error
119
+	 */
120
+	protected function _construct_finalize($parent_form_section, $name)
121
+	{
122
+		$this->_construction_finalized = true;
123
+		$this->_parent_section = $parent_form_section;
124
+		if ($name !== null) {
125
+			$this->_name = $name;
126
+		}
127
+	}
128
+
129
+
130
+
131
+	/**
132
+	 * make sure construction finalized was called, otherwise children might not be ready
133
+	 *
134
+	 * @return void
135
+	 * @throws \EE_Error
136
+	 */
137
+	public function ensure_construct_finalized_called()
138
+	{
139
+		if (! $this->_construction_finalized) {
140
+			$this->_construct_finalize($this->_parent_section, $this->_name);
141
+		}
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 * @return string
148
+	 */
149
+	public function action()
150
+	{
151
+		return $this->_action;
152
+	}
153
+
154
+
155
+
156
+	/**
157
+	 * @param string $action
158
+	 */
159
+	public function set_action($action)
160
+	{
161
+		$this->_action = $action;
162
+	}
163
+
164
+
165
+
166
+	/**
167
+	 * @return string
168
+	 */
169
+	public function method()
170
+	{
171
+		return ! empty($this->_method) ? $this->_method : 'POST';
172
+	}
173
+
174
+
175
+
176
+	/**
177
+	 * @param string $method
178
+	 */
179
+	public function set_method($method)
180
+	{
181
+		switch ($method) {
182
+			case 'get' :
183
+			case 'GET' :
184
+				$this->_method = 'GET';
185
+				break;
186
+			default :
187
+				$this->_method = 'POST';
188
+		}
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * Sets the html_id to its default value, if none was specified in the constructor.
195
+	 * Calculation involves using the name and the parent's html id
196
+	 * return void
197
+	 *
198
+	 * @throws \EE_Error
199
+	 */
200
+	protected function _set_default_html_id_if_empty()
201
+	{
202
+		if (! $this->_html_id) {
203
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
204
+				$this->_html_id = $this->_parent_section->html_id()
205
+								  . '-'
206
+								  . $this->_prep_name_for_html_id($this->name());
207
+			} else {
208
+				$this->_html_id = $this->_prep_name_for_html_id($this->name());
209
+			}
210
+		}
211
+	}
212
+
213
+
214
+
215
+	/**
216
+	 * _prep_name_for_html_id
217
+	 *
218
+	 * @param $name
219
+	 * @return string
220
+	 */
221
+	private function _prep_name_for_html_id($name)
222
+	{
223
+		return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
224
+	}
225 225
 
226 226
 
227 227
 
228
-    /**
229
-     * Returns the HTML, JS, and CSS necessary to display this form section on a page.
230
-     * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
231
-     * and call get_html when you want to output the html. Calling get_html_and_js after
232
-     * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
233
-     * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
234
-     * and so might stop working anytime.
235
-     *
236
-     * @return string
237
-     */
238
-    public function get_html_and_js()
239
-    {
240
-        return $this->get_html();
241
-    }
228
+	/**
229
+	 * Returns the HTML, JS, and CSS necessary to display this form section on a page.
230
+	 * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
231
+	 * and call get_html when you want to output the html. Calling get_html_and_js after
232
+	 * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
233
+	 * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
234
+	 * and so might stop working anytime.
235
+	 *
236
+	 * @return string
237
+	 */
238
+	public function get_html_and_js()
239
+	{
240
+		return $this->get_html();
241
+	}
242 242
 
243 243
 
244 244
 
245
-    /**
246
-     * Gets the HTML for displaying this form section
247
-     *
248
-     * @return string
249
-     */
250
-    public abstract function get_html();
245
+	/**
246
+	 * Gets the HTML for displaying this form section
247
+	 *
248
+	 * @return string
249
+	 */
250
+	public abstract function get_html();
251 251
 
252 252
 
253 253
 
254
-    /**
255
-     * @param bool $add_pound_sign
256
-     * @return string
257
-     */
258
-    public function html_id($add_pound_sign = false)
259
-    {
260
-        $this->_set_default_html_id_if_empty();
261
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
262
-    }
254
+	/**
255
+	 * @param bool $add_pound_sign
256
+	 * @return string
257
+	 */
258
+	public function html_id($add_pound_sign = false)
259
+	{
260
+		$this->_set_default_html_id_if_empty();
261
+		return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
262
+	}
263 263
 
264 264
 
265
-
266
-    /**
267
-     * @return string
268
-     */
269
-    public function html_class()
270
-    {
271
-        return $this->_html_class;
272
-    }
273
-
274
-
275
-
276
-    /**
277
-     * @return string
278
-     */
279
-    public function html_style()
280
-    {
281
-        return $this->_html_style;
282
-    }
283
-
284
-
285
-
286
-    /**
287
-     * @param mixed $html_class
288
-     */
289
-    public function set_html_class($html_class)
290
-    {
291
-        $this->_html_class = $html_class;
292
-    }
293
-
294
-
295
-
296
-    /**
297
-     * @param mixed $html_id
298
-     */
299
-    public function set_html_id($html_id)
300
-    {
301
-        $this->_html_id = $html_id;
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * @param mixed $html_style
308
-     */
309
-    public function set_html_style($html_style)
310
-    {
311
-        $this->_html_style = $html_style;
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * @param string $other_html_attributes
318
-     */
319
-    public function set_other_html_attributes($other_html_attributes)
320
-    {
321
-        $this->_other_html_attributes = $other_html_attributes;
322
-    }
323
-
324
-
325
-
326
-    /**
327
-     * @return string
328
-     */
329
-    public function other_html_attributes()
330
-    {
331
-        return $this->_other_html_attributes;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * Gets the name of the form section. This is not the same as the HTML name.
338
-     *
339
-     * @throws EE_Error
340
-     * @return string
341
-     */
342
-    public function name()
343
-    {
344
-        if (! $this->_construction_finalized) {
345
-            throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
346
-                'event_espresso'), get_class($this)));
347
-        }
348
-        return $this->_name;
349
-    }
350
-
351
-
352
-
353
-    /**
354
-     * Gets the parent section
355
-     *
356
-     * @return EE_Form_Section_Proper
357
-     */
358
-    public function parent_section()
359
-    {
360
-        return $this->_parent_section;
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * returns HTML for generating the opening form HTML tag (<form>)
367
-     *
368
-     * @param string $action           the URL the form is submitted to
369
-     * @param string $method           POST (default) or GET
370
-     * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
371
-     * @return string
372
-     */
373
-    public function form_open($action = '', $method = '', $other_attributes = '')
374
-    {
375
-        if (! empty($action)) {
376
-            $this->set_action($action);
377
-        }
378
-        if (! empty($method)) {
379
-            $this->set_method($method);
380
-        }
381
-        $html = EEH_HTML::nl(1, 'form') . '<form';
382
-        $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : '';
383
-        $html .= ' action="' . $this->action() . '"';
384
-        $html .= ' method="' . $this->method() . '"';
385
-        $html .= $other_attributes . '>';
386
-        return $html;
387
-    }
388
-
389
-
390
-
391
-    /**
392
-     * returns HTML for generating the closing form HTML tag (</form>)
393
-     *
394
-     * @return string
395
-     */
396
-    public function form_close()
397
-    {
398
-        return EEH_HTML::nl(-1, 'form')
399
-               . '</form>'
400
-               . EEH_HTML::nl()
401
-               . '<!-- end of ee-'
402
-               . $this->html_id()
403
-               . '-form -->'
404
-               . EEH_HTML::nl();
405
-    }
406
-
407
-
408
-
409
-    /**
410
-     * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
411
-     * wp_enqueue_style; the scripts could have optionally been registered earlier)
412
-     * Default does nothing, but child classes can override
413
-     *
414
-     * @return void
415
-     */
416
-    public function enqueue_js()
417
-    {
418
-        //defaults to enqueue NO js or css
419
-    }
420
-
421
-
422
-
423
-    /**
424
-     * Adds any extra data needed by js. Eventually we'll call wp_localize_script
425
-     * with it, and it will be on each form section's 'other_data' property.
426
-     * By default nothing is added, but child classes can extend this method to add something.
427
-     * Eg, if you have an input that will cause a modal dialog to appear,
428
-     * here you could add an entry like 'modal_dialog_inputs' to this array
429
-     * to map between the input's html ID and the modal dialogue's ID, so that
430
-     * your JS code will know where to find the modal dialog when the input is pressed.
431
-     * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
432
-     *
433
-     * @param array $form_other_js_data
434
-     * @return array
435
-     */
436
-    public function get_other_js_data($form_other_js_data = array())
437
-    {
438
-        return $form_other_js_data;
439
-    }
440
-
441
-
442
-
443
-    /**
444
-     * This isn't just the name of an input, it's a path pointing to an input. The
445
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
446
-     * dot-dot-slash (../) means to ascend into the parent section.
447
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
448
-     * which will be returned.
449
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
450
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
451
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
452
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
453
-     * Etc
454
-     *
455
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
456
-     * @return EE_Form_Section_Base
457
-     */
458
-    public function find_section_from_path($form_section_path)
459
-    {
460
-        if (strpos($form_section_path, '/') === 0) {
461
-            $form_section_path = substr($form_section_path, strlen('/'));
462
-        }
463
-        if (empty($form_section_path)) {
464
-            return $this;
465
-        }
466
-        if (strpos($form_section_path, '../') === 0) {
467
-            $parent = $this->parent_section();
468
-            $form_section_path = substr($form_section_path, strlen('../'));
469
-            if ($parent instanceof EE_Form_Section_Base) {
470
-                return $parent->find_section_from_path($form_section_path);
471
-            } elseif (empty($form_section_path)) {
472
-                return $this;
473
-            }
474
-        }
475
-        //couldn't find it using simple parent following
476
-        return null;
477
-    }
265
+
266
+	/**
267
+	 * @return string
268
+	 */
269
+	public function html_class()
270
+	{
271
+		return $this->_html_class;
272
+	}
273
+
274
+
275
+
276
+	/**
277
+	 * @return string
278
+	 */
279
+	public function html_style()
280
+	{
281
+		return $this->_html_style;
282
+	}
283
+
284
+
285
+
286
+	/**
287
+	 * @param mixed $html_class
288
+	 */
289
+	public function set_html_class($html_class)
290
+	{
291
+		$this->_html_class = $html_class;
292
+	}
293
+
294
+
295
+
296
+	/**
297
+	 * @param mixed $html_id
298
+	 */
299
+	public function set_html_id($html_id)
300
+	{
301
+		$this->_html_id = $html_id;
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * @param mixed $html_style
308
+	 */
309
+	public function set_html_style($html_style)
310
+	{
311
+		$this->_html_style = $html_style;
312
+	}
313
+
314
+
315
+
316
+	/**
317
+	 * @param string $other_html_attributes
318
+	 */
319
+	public function set_other_html_attributes($other_html_attributes)
320
+	{
321
+		$this->_other_html_attributes = $other_html_attributes;
322
+	}
323
+
324
+
325
+
326
+	/**
327
+	 * @return string
328
+	 */
329
+	public function other_html_attributes()
330
+	{
331
+		return $this->_other_html_attributes;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * Gets the name of the form section. This is not the same as the HTML name.
338
+	 *
339
+	 * @throws EE_Error
340
+	 * @return string
341
+	 */
342
+	public function name()
343
+	{
344
+		if (! $this->_construction_finalized) {
345
+			throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
346
+				'event_espresso'), get_class($this)));
347
+		}
348
+		return $this->_name;
349
+	}
350
+
351
+
352
+
353
+	/**
354
+	 * Gets the parent section
355
+	 *
356
+	 * @return EE_Form_Section_Proper
357
+	 */
358
+	public function parent_section()
359
+	{
360
+		return $this->_parent_section;
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * returns HTML for generating the opening form HTML tag (<form>)
367
+	 *
368
+	 * @param string $action           the URL the form is submitted to
369
+	 * @param string $method           POST (default) or GET
370
+	 * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
371
+	 * @return string
372
+	 */
373
+	public function form_open($action = '', $method = '', $other_attributes = '')
374
+	{
375
+		if (! empty($action)) {
376
+			$this->set_action($action);
377
+		}
378
+		if (! empty($method)) {
379
+			$this->set_method($method);
380
+		}
381
+		$html = EEH_HTML::nl(1, 'form') . '<form';
382
+		$html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : '';
383
+		$html .= ' action="' . $this->action() . '"';
384
+		$html .= ' method="' . $this->method() . '"';
385
+		$html .= $other_attributes . '>';
386
+		return $html;
387
+	}
388
+
389
+
390
+
391
+	/**
392
+	 * returns HTML for generating the closing form HTML tag (</form>)
393
+	 *
394
+	 * @return string
395
+	 */
396
+	public function form_close()
397
+	{
398
+		return EEH_HTML::nl(-1, 'form')
399
+			   . '</form>'
400
+			   . EEH_HTML::nl()
401
+			   . '<!-- end of ee-'
402
+			   . $this->html_id()
403
+			   . '-form -->'
404
+			   . EEH_HTML::nl();
405
+	}
406
+
407
+
408
+
409
+	/**
410
+	 * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
411
+	 * wp_enqueue_style; the scripts could have optionally been registered earlier)
412
+	 * Default does nothing, but child classes can override
413
+	 *
414
+	 * @return void
415
+	 */
416
+	public function enqueue_js()
417
+	{
418
+		//defaults to enqueue NO js or css
419
+	}
420
+
421
+
422
+
423
+	/**
424
+	 * Adds any extra data needed by js. Eventually we'll call wp_localize_script
425
+	 * with it, and it will be on each form section's 'other_data' property.
426
+	 * By default nothing is added, but child classes can extend this method to add something.
427
+	 * Eg, if you have an input that will cause a modal dialog to appear,
428
+	 * here you could add an entry like 'modal_dialog_inputs' to this array
429
+	 * to map between the input's html ID and the modal dialogue's ID, so that
430
+	 * your JS code will know where to find the modal dialog when the input is pressed.
431
+	 * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
432
+	 *
433
+	 * @param array $form_other_js_data
434
+	 * @return array
435
+	 */
436
+	public function get_other_js_data($form_other_js_data = array())
437
+	{
438
+		return $form_other_js_data;
439
+	}
440
+
441
+
442
+
443
+	/**
444
+	 * This isn't just the name of an input, it's a path pointing to an input. The
445
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
446
+	 * dot-dot-slash (../) means to ascend into the parent section.
447
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
448
+	 * which will be returned.
449
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
450
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
451
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
452
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
453
+	 * Etc
454
+	 *
455
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
456
+	 * @return EE_Form_Section_Base
457
+	 */
458
+	public function find_section_from_path($form_section_path)
459
+	{
460
+		if (strpos($form_section_path, '/') === 0) {
461
+			$form_section_path = substr($form_section_path, strlen('/'));
462
+		}
463
+		if (empty($form_section_path)) {
464
+			return $this;
465
+		}
466
+		if (strpos($form_section_path, '../') === 0) {
467
+			$parent = $this->parent_section();
468
+			$form_section_path = substr($form_section_path, strlen('../'));
469
+			if ($parent instanceof EE_Form_Section_Base) {
470
+				return $parent->find_section_from_path($form_section_path);
471
+			} elseif (empty($form_section_path)) {
472
+				return $this;
473
+			}
474
+		}
475
+		//couldn't find it using simple parent following
476
+		return null;
477
+	}
478 478
 
479 479
 
480 480
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter;
3 3
 
4
-if (! defined('EVENT_ESPRESSO_VERSION')) {
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5 5
     exit('No direct script access allowed');
6 6
 }
7 7
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         // used by display strategies
100 100
         // assign incoming values to properties
101 101
         foreach ($options_array as $key => $value) {
102
-            $key = '_' . $key;
102
+            $key = '_'.$key;
103 103
             if (property_exists($this, $key) && empty($this->{$key})) {
104 104
                 $this->{$key} = $value;
105 105
             }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function ensure_construct_finalized_called()
138 138
     {
139
-        if (! $this->_construction_finalized) {
139
+        if ( ! $this->_construction_finalized) {
140 140
             $this->_construct_finalize($this->_parent_section, $this->_name);
141 141
         }
142 142
     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      */
200 200
     protected function _set_default_html_id_if_empty()
201 201
     {
202
-        if (! $this->_html_id) {
202
+        if ( ! $this->_html_id) {
203 203
             if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
204 204
                 $this->_html_id = $this->_parent_section->html_id()
205 205
                                   . '-'
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     public function html_id($add_pound_sign = false)
259 259
     {
260 260
         $this->_set_default_html_id_if_empty();
261
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
261
+        return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id;
262 262
     }
263 263
 
264 264
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      */
342 342
     public function name()
343 343
     {
344
-        if (! $this->_construction_finalized) {
344
+        if ( ! $this->_construction_finalized) {
345 345
             throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
346 346
                 'event_espresso'), get_class($this)));
347 347
         }
@@ -372,17 +372,17 @@  discard block
 block discarded – undo
372 372
      */
373 373
     public function form_open($action = '', $method = '', $other_attributes = '')
374 374
     {
375
-        if (! empty($action)) {
375
+        if ( ! empty($action)) {
376 376
             $this->set_action($action);
377 377
         }
378
-        if (! empty($method)) {
378
+        if ( ! empty($method)) {
379 379
             $this->set_method($method);
380 380
         }
381
-        $html = EEH_HTML::nl(1, 'form') . '<form';
382
-        $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : '';
383
-        $html .= ' action="' . $this->action() . '"';
384
-        $html .= ' method="' . $this->method() . '"';
385
-        $html .= $other_attributes . '>';
381
+        $html = EEH_HTML::nl(1, 'form').'<form';
382
+        $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : '';
383
+        $html .= ' action="'.$this->action().'"';
384
+        $html .= ' method="'.$this->method().'"';
385
+        $html .= $other_attributes.'>';
386 386
         return $html;
387 387
     }
388 388
 
Please login to merge, or discard this patch.
core/libraries/form_sections/strategies/layout/EE_No_Layout.strategy.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -13,110 +13,110 @@
 block discarded – undo
13 13
 {
14 14
 
15 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;
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 23
 
24 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
-    }
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 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
-    }
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 48
 
49 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
-    }
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 87
 
88 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
-    {
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 97
 //		d( $form_section );
98
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
99
-    }
98
+		return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
99
+	}
100 100
 
101 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
-    }
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 111
 
112 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
-    }
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 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -58,28 +58,28 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $html = '';
60 60
         if ($input instanceof EE_Hidden_Input) {
61
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
61
+            $html .= EEH_HTML::nl().$input->get_html_for_input();
62 62
         } else if ($input instanceof EE_Submit_Input) {
63 63
             $html .= $this->br();
64 64
             $html .= $input->get_html_for_input();
65 65
         } else if ($input instanceof EE_Select_Input) {
66 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();
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 71
             $html .= $this->br();
72 72
         } else if ($input instanceof EE_Form_Input_With_Options_Base) {
73 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();
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 77
         } else {
78 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();
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 83
         }
84 84
         $html .= EEH_HTML::nl(-1);
85 85
         return $html;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     public function layout_subsection($form_section)
96 96
     {
97 97
 //		d( $form_section );
98
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
98
+        return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1);
99 99
     }
100 100
 
101 101
 
Please login to merge, or discard this patch.