Completed
Branch feature/checkins-to-csv (6396a5)
by
unknown
07:19 queued 04:57
created
core/data_migration_scripts/EE_DMS_Core_4_2_0.dms.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 $stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*');
16 16
 $class_to_filepath = array();
17 17
 if (! empty($stages)) {
18
-    foreach ($stages as $filepath) {
19
-        $matches = array();
20
-        preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-        $class_to_filepath[ $matches[1] ] = $filepath;
22
-    }
18
+	foreach ($stages as $filepath) {
19
+		$matches = array();
20
+		preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
+		$class_to_filepath[ $matches[1] ] = $filepath;
22
+	}
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages', $class_to_filepath);
@@ -32,57 +32,57 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * EE_DMS_Core_4_2_0 constructor.
37
-     *
38
-     * @param TableManager  $table_manager
39
-     * @param TableAnalysis $table_analysis
40
-     */
41
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
42
-    {
43
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso");
44
-        $this->_priority = 10;
45
-        $this->_migration_stages = array(
46
-            new EE_DMS_4_2_0_question_group_questions(),
47
-            new EE_DMS_4_2_0_datetime_fields(),
48
-        );
49
-        parent::__construct($table_manager, $table_analysis);
50
-    }
35
+	/**
36
+	 * EE_DMS_Core_4_2_0 constructor.
37
+	 *
38
+	 * @param TableManager  $table_manager
39
+	 * @param TableAnalysis $table_analysis
40
+	 */
41
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
42
+	{
43
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso");
44
+		$this->_priority = 10;
45
+		$this->_migration_stages = array(
46
+			new EE_DMS_4_2_0_question_group_questions(),
47
+			new EE_DMS_4_2_0_datetime_fields(),
48
+		);
49
+		parent::__construct($table_manager, $table_analysis);
50
+	}
51 51
 
52 52
 
53 53
 
54
-    public function can_migrate_from_version($version_array)
55
-    {
56
-        $version_string = $version_array['Core'];
57
-        if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
54
+	public function can_migrate_from_version($version_array)
55
+	{
56
+		$version_string = $version_array['Core'];
57
+		if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
58 58
 //          echo "$version_string can be migrated fro";
59
-            return true;
60
-        } elseif (! $version_string) {
59
+			return true;
60
+		} elseif (! $version_string) {
61 61
 //          echo "no version string provided: $version_string";
62
-            // no version string provided... this must be pre 4.1
63
-            // because since 4.1 we're
64
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
-        } else {
62
+			// no version string provided... this must be pre 4.1
63
+			// because since 4.1 we're
64
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
+		} else {
66 66
 //          echo "$version_string doesnt apply";
67
-            return false;
68
-        }
69
-    }
67
+			return false;
68
+		}
69
+	}
70 70
 
71 71
 
72 72
 
73
-    public function schema_changes_before_migration()
74
-    {
75
-        // relies on 4.1's EEH_Activation::create_table
76
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
-        $table_name = 'esp_answer';
78
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
73
+	public function schema_changes_before_migration()
74
+	{
75
+		// relies on 4.1's EEH_Activation::create_table
76
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
+		$table_name = 'esp_answer';
78
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79 79
 					REG_ID int(10) unsigned NOT NULL,
80 80
 					QST_ID int(10) unsigned NOT NULL,
81 81
 					ANS_value text NOT NULL,
82 82
 					PRIMARY KEY  (ANS_ID)";
83
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
84
-        $table_name = 'esp_attendee_meta';
85
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
83
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
84
+		$table_name = 'esp_attendee_meta';
85
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
86 86
 						ATT_ID bigint(20) unsigned NOT NULL,
87 87
 						ATT_fname varchar(45) NOT NULL,
88 88
 						ATT_lname varchar(45) NOT	NULL,
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 								KEY ATT_fname (ATT_fname),
99 99
 								KEY ATT_lname (ATT_lname),
100 100
 								KEY ATT_email (ATT_email(191))";
101
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
102
-        $table_name = 'esp_country';
103
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
101
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
102
+		$table_name = 'esp_country';
103
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
104 104
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
105 105
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
106 106
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 					  CNT_is_EU tinyint(1) DEFAULT '0',
117 117
 					  CNT_active tinyint(1) DEFAULT '0',
118 118
 					  PRIMARY KEY  (CNT_ISO)";
119
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
120
-        $table_name = 'esp_datetime';
121
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
119
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
120
+		$table_name = 'esp_datetime';
121
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
122 122
 				  EVT_ID bigint(20) unsigned NOT NULL,
123 123
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
124 124
 				  DTT_description text NOT NULL,
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 						PRIMARY KEY  (DTT_ID),
134 134
 						KEY EVT_ID (EVT_ID),
135 135
 						KEY DTT_is_primary (DTT_is_primary)";
136
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
137
-        $table_name = 'esp_event_meta';
138
-        $sql = "
136
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
137
+		$table_name = 'esp_event_meta';
138
+		$sql = "
139 139
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
140 140
 			EVT_ID bigint(20) unsigned NOT NULL,
141 141
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -150,31 +150,31 @@  discard block
 block discarded – undo
150 150
 			EVT_external_URL varchar(200) NULL,
151 151
 			EVT_donations tinyint(1) NULL,
152 152
 			PRIMARY KEY  (EVTM_ID)";
153
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
154
-        $table_name = 'esp_event_question_group';
155
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
153
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
154
+		$table_name = 'esp_event_question_group';
155
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
156 156
 					EVT_ID bigint(20) unsigned NOT NULL,
157 157
 					QSG_ID int(10) unsigned NOT NULL,
158 158
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
159 159
 					PRIMARY KEY  (EQG_ID)";
160
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
161
-        $table_name = 'esp_event_venue';
162
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
160
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
161
+		$table_name = 'esp_event_venue';
162
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
163 163
 				EVT_ID bigint(20) unsigned NOT NULL,
164 164
 				VNU_ID bigint(20) unsigned NOT NULL,
165 165
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
166 166
 				PRIMARY KEY  (EVV_ID)";
167
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
168
-        $table_name = 'esp_extra_meta';
169
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
167
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
168
+		$table_name = 'esp_extra_meta';
169
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
170 170
 				OBJ_ID int(11) DEFAULT NULL,
171 171
 				EXM_type varchar(45) DEFAULT NULL,
172 172
 				EXM_key varchar(45) DEFAULT NULL,
173 173
 				EXM_value text,
174 174
 				PRIMARY KEY  (EXM_ID)";
175
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176
-        $table_name = 'esp_line_item';
177
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
175
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176
+		$table_name = 'esp_line_item';
177
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
178 178
 				LIN_code varchar(245) NOT NULL DEFAULT '',
179 179
 				TXN_ID int(11) DEFAULT NULL,
180 180
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
 				OBJ_ID int(11) DEFAULT NULL,
191 191
 				OBJ_type varchar(45)DEFAULT NULL,
192 192
 				PRIMARY KEY  (LIN_ID)";
193
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
194
-        $table_name = 'esp_message_template';
195
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
193
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
194
+		$table_name = 'esp_message_template';
195
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
196 196
 					GRP_ID int(10) unsigned NOT NULL,
197 197
 					MTP_context varchar(50) NOT NULL,
198 198
 					MTP_template_field varchar(30) NOT NULL,
199 199
 					MTP_content text NOT NULL,
200 200
 					PRIMARY KEY  (MTP_ID),
201 201
 					KEY GRP_ID (GRP_ID)";
202
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
203
-        $table_name = 'esp_message_template_group';
204
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
202
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
203
+		$table_name = 'esp_message_template_group';
204
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
205 205
 					EVT_ID bigint(20) unsigned DEFAULT NULL,
206 206
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
207 207
 					MTP_messenger varchar(30) NOT NULL,
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 					PRIMARY KEY  (GRP_ID),
214 214
 					KEY EVT_ID (EVT_ID),
215 215
 					KEY MTP_user_id (MTP_user_id)";
216
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
217
-        $table_name = 'esp_payment';
218
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
216
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
217
+		$table_name = 'esp_payment';
218
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
219 219
 					TXN_ID int(10) unsigned DEFAULT NULL,
220 220
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
221 221
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 					PRIMARY KEY  (PAY_ID),
232 232
 					KEY TXN_ID (TXN_ID),
233 233
 					KEY PAY_timestamp (PAY_timestamp)";
234
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
235
-        $table_name = "esp_ticket";
236
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
234
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
235
+		$table_name = "esp_ticket";
236
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
237 237
 					  TTM_ID int(10) unsigned NOT NULL,
238 238
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
239 239
 					  TKT_description text NOT NULL,
@@ -252,28 +252,28 @@  discard block
 block discarded – undo
252 252
 					  TKT_parent int(10) unsigned DEFAULT '0',
253 253
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
254 254
 					  PRIMARY KEY  (TKT_ID)";
255
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
256
-        $table_name = "esp_ticket_price";
257
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
255
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
256
+		$table_name = "esp_ticket_price";
257
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
258 258
 					  TKT_ID int(10) unsigned NOT NULL,
259 259
 					  PRC_ID int(10) unsigned NOT NULL,
260 260
 					  PRIMARY KEY  (TKP_ID)";
261
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
262
-        $table_name = "esp_datetime_ticket";
263
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
261
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
262
+		$table_name = "esp_datetime_ticket";
263
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
264 264
 					  DTT_ID int(10) unsigned NOT NULL,
265 265
 					  TKT_ID int(10) unsigned NOT NULL,
266 266
 					  PRIMARY KEY  (DTK_ID)";
267
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
268
-        $table_name = "esp_ticket_template";
269
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
267
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
268
+		$table_name = "esp_ticket_template";
269
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
270 270
 					  TTM_name varchar(45) NOT NULL,
271 271
 					  TTM_description text,
272 272
 					  TTM_file varchar(45),
273 273
 					  PRIMARY KEY  (TTM_ID)";
274
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
275
-        $table_name = "esp_price";
276
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
274
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
275
+		$table_name = "esp_price";
276
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
277 277
 					  PRT_ID tinyint(3) unsigned NOT NULL,
278 278
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
279 279
 					  PRC_name varchar(245) NOT NULL,
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
285 285
 					  PRC_parent int(10) unsigned DEFAULT 0,
286 286
 					  PRIMARY KEY  (PRC_ID)";
287
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
288
-        $table_name = "esp_price_type";
289
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
287
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
288
+		$table_name = "esp_price_type";
289
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
290 290
 				  PRT_name varchar(45) NOT NULL,
291 291
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
292 292
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
295 295
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
296 296
 				  PRIMARY KEY  (PRT_ID)";
297
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
298
-        $table_name = 'esp_question';
299
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
297
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
298
+		$table_name = 'esp_question';
299
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
300 300
 					QST_display_text text NOT NULL,
301 301
 					QST_admin_label varchar(255) NOT NULL,
302 302
 					QST_system varchar(25) DEFAULT NULL,
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 					QST_wp_user bigint(20) unsigned NULL,
309 309
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
310 310
 					PRIMARY KEY  (QST_ID)';
311
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
312
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
313
-        $table_name = 'esp_question_group';
314
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
311
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
312
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
313
+		$table_name = 'esp_question_group';
314
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
315 315
 					QSG_name varchar(255) NOT NULL,
316 316
 					QSG_identifier varchar(100) NOT NULL,
317 317
 					QSG_desc text NULL,
@@ -322,24 +322,24 @@  discard block
 block discarded – undo
322 322
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
323 323
 					PRIMARY KEY  (QSG_ID),
324 324
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
325
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
326
-        $table_name = 'esp_question_group_question';
327
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
325
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
326
+		$table_name = 'esp_question_group_question';
327
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
328 328
 					QSG_ID int(10) unsigned NOT NULL,
329 329
 					QST_ID int(10) unsigned NOT NULL,
330 330
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
331 331
 					PRIMARY KEY  (QGQ_ID) ";
332
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
333
-        $table_name = 'esp_question_option';
334
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
332
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
333
+		$table_name = 'esp_question_option';
334
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
335 335
 					QSO_value varchar(255) NOT NULL,
336 336
 					QSO_desc text NOT NULL,
337 337
 					QST_ID int(10) unsigned NOT NULL,
338 338
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
339 339
 					PRIMARY KEY  (QSO_ID)";
340
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
-        $table_name = 'esp_registration';
342
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
340
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
+		$table_name = 'esp_registration';
342
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343 343
 					  EVT_ID bigint(20) unsigned NOT NULL,
344 344
 					  ATT_ID bigint(20) unsigned NOT NULL,
345 345
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -362,25 +362,25 @@  discard block
 block discarded – undo
362 362
 					  KEY STS_ID (STS_ID),
363 363
 					  KEY REG_url_link (REG_url_link),
364 364
 					  KEY REG_code (REG_code)";
365
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
366
-        $table_name = 'esp_checkin';
367
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
365
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
366
+		$table_name = 'esp_checkin';
367
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
368 368
 					REG_ID int(10) unsigned NOT NULL,
369 369
 					DTT_ID int(10) unsigned NOT NULL,
370 370
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
371 371
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
372 372
 					PRIMARY KEY  (CHK_ID)";
373
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
374
-        $table_name = 'esp_state';
375
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
373
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
374
+		$table_name = 'esp_state';
375
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
376 376
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
377 377
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
378 378
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
379 379
 					  STA_active tinyint(1) DEFAULT '1',
380 380
 					  PRIMARY KEY  (STA_ID)";
381
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
382
-        $table_name = 'esp_status';
383
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
381
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
382
+		$table_name = 'esp_status';
383
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
384 384
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
385 385
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
386 386
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
389 389
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
390 390
 					  KEY STS_type (STS_type)";
391
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = 'esp_transaction';
393
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
391
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = 'esp_transaction';
393
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
394 394
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
395 395
 					  TXN_total decimal(10,3) DEFAULT '0.00',
396 396
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 					  PRIMARY KEY  (TXN_ID),
401 401
 					  KEY TXN_timestamp (TXN_timestamp),
402 402
 					  KEY STS_ID (STS_ID)";
403
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
404
-        $table_name = 'esp_venue_meta';
405
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
403
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
404
+		$table_name = 'esp_venue_meta';
405
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
406 406
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
407 407
 			VNU_address varchar(255) DEFAULT NULL,
408 408
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -420,36 +420,36 @@  discard block
 block discarded – undo
420 420
 			PRIMARY KEY  (VNUM_ID),
421 421
 			KEY STA_ID (STA_ID),
422 422
 			KEY CNT_ISO (CNT_ISO)";
423
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
424
-        $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
425
-        // setting up the DEFAULT stats and countries is also essential for the data migrations to run
426
-        // (because many need to convert old string states to foreign keys into the states table)
427
-        $script_with_defaults->insert_default_states();
428
-        $script_with_defaults->insert_default_countries();
429
-        // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
430
-        $script_with_defaults->insert_default_price_types();
431
-        $script_with_defaults->insert_default_prices();
432
-        $script_with_defaults->insert_default_tickets();
433
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
434
-        EE_Config::instance()->update_espresso_config(false, true);
435
-        return true;
436
-    }
423
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
424
+		$script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
425
+		// setting up the DEFAULT stats and countries is also essential for the data migrations to run
426
+		// (because many need to convert old string states to foreign keys into the states table)
427
+		$script_with_defaults->insert_default_states();
428
+		$script_with_defaults->insert_default_countries();
429
+		// setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
430
+		$script_with_defaults->insert_default_price_types();
431
+		$script_with_defaults->insert_default_prices();
432
+		$script_with_defaults->insert_default_tickets();
433
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
434
+		EE_Config::instance()->update_espresso_config(false, true);
435
+		return true;
436
+	}
437 437
 
438 438
 
439 439
 
440
-    /**
441
-     * We COULD clean up the esp_question.QST_order field here. We'll leave it for now
442
-     *
443
-     * @return boolean
444
-     */
445
-    public function schema_changes_after_migration()
446
-    {
447
-        return true;
448
-    }
440
+	/**
441
+	 * We COULD clean up the esp_question.QST_order field here. We'll leave it for now
442
+	 *
443
+	 * @return boolean
444
+	 */
445
+	public function schema_changes_after_migration()
446
+	{
447
+		return true;
448
+	}
449 449
 
450 450
 
451 451
 
452
-    public function migration_page_hooks()
453
-    {
454
-    }
452
+	public function migration_page_hooks()
453
+	{
454
+	}
455 455
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 // unfortunately, this needs to be done upon INCLUSION of this file,
13 13
 // instead of construction, because it only gets constructed on first page load
14 14
 // (all other times it gets resurrected from a wordpress option)
15
-$stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*');
15
+$stages = glob(EE_CORE.'data_migration_scripts/4_2_0_stages/*');
16 16
 $class_to_filepath = array();
17
-if (! empty($stages)) {
17
+if ( ! empty($stages)) {
18 18
     foreach ($stages as $filepath) {
19 19
         $matches = array();
20 20
         preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-        $class_to_filepath[ $matches[1] ] = $filepath;
21
+        $class_to_filepath[$matches[1]] = $filepath;
22 22
     }
23 23
 }
24 24
 // give addons a chance to autoload their stages too
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
         if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
58 58
 //          echo "$version_string can be migrated fro";
59 59
             return true;
60
-        } elseif (! $version_string) {
60
+        } elseif ( ! $version_string) {
61 61
 //          echo "no version string provided: $version_string";
62 62
             // no version string provided... this must be pre 4.1
63 63
             // because since 4.1 we're
64
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
64
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
65 65
         } else {
66 66
 //          echo "$version_string doesnt apply";
67 67
             return false;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function schema_changes_before_migration()
74 74
     {
75 75
         // relies on 4.1's EEH_Activation::create_table
76
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
76
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
77 77
         $table_name = 'esp_answer';
78 78
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79 79
 					REG_ID int(10) unsigned NOT NULL,
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Recipient_List_Shortcodes.lib.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         // first get registrations just for this attendee.
81 81
         $att = $data->att_obj;
82
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
82
+        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array();
83 83
         $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
84 84
             ? array($data->reg_obj) : $registrations_on_attendee;
85 85
         $tkts = array();
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
             // tickets will be tickets for all registrations on this attendee.
102 102
             foreach ($registrations_on_attendee as $reg) {
103 103
                 if ($reg instanceof EE_Registration) {
104
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
105
-                        $data->registrations[ $reg->ID() ]
106
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
107
-                    ) ]['tkt_obj'] : null;
104
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
105
+                        $data->registrations[$reg->ID()]
106
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
107
+                    )]['tkt_obj'] : null;
108 108
                     if ($ticket instanceof EE_Ticket) {
109
-                        $tkts[ $ticket->ID() ] = $ticket;
109
+                        $tkts[$ticket->ID()] = $ticket;
110 110
                     }
111 111
                 }
112 112
             }
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
             // data will be tickets for this event for this recipient.
124 124
             foreach ($registrations_on_attendee as $reg) {
125 125
                 if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
126
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
127
-                        $data->registrations[ $reg->ID() ]
128
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
129
-                    ) ]['tkt_obj'] : null;
126
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
127
+                        $data->registrations[$reg->ID()]
128
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
129
+                    )]['tkt_obj'] : null;
130 130
                     if ($ticket instanceof EE_Ticket) {
131
-                        $tkts[ $ticket->ID() ] = $ticket;
131
+                        $tkts[$ticket->ID()] = $ticket;
132 132
                     }
133 133
                 }
134 134
             }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     {
171 171
         // first get registrations just for this attendee.
172 172
         $att = $data->att_obj;
173
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
173
+        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array();
174 174
         $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
175 175
             ? array($data->reg_obj)
176 176
             : $registrations_on_attendee;
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
             // dtts will be datetimes for all registrations on this attendee
186 186
             foreach ($registrations_on_attendee as $reg) {
187 187
                 if ($reg instanceof EE_Registration) {
188
-                    $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
189
-                        $data->registrations[ $reg->ID() ]
190
-                    ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
191
-                    ) ]['dtt_objs'] : array();
188
+                    $dtt_objs = isset($data->registrations[$reg->ID()]) && is_array(
189
+                        $data->registrations[$reg->ID()]
190
+                    ) && isset($data->registrations[$reg->ID()]['dtt_objs']) ? $data->registrations[$reg->ID(
191
+                    )]['dtt_objs'] : array();
192 192
                     $dtt_objs = (array) $dtt_objs;
193 193
                     foreach ($dtt_objs as $dtt_obj) {
194 194
                         if ($dtt_obj instanceof EE_Datetime) {
195
-                            $dtts[ $dtt_obj->ID() ] = $dtt_obj;
195
+                            $dtts[$dtt_obj->ID()] = $dtt_obj;
196 196
                         }
197 197
                     }
198 198
                 }
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
             // data will be datetimes for this event for this recipient
209 209
             foreach ($registrations_on_attendee as $reg) {
210 210
                 if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
211
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
212
-                        $data->registrations[ $reg->ID() ]
213
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
214
-                    ) ]['tkt_obj'] : null;
211
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
212
+                        $data->registrations[$reg->ID()]
213
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
214
+                    )]['tkt_obj'] : null;
215 215
                     if ($ticket instanceof EE_Ticket) {
216
-                        $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
217
-                            $data->tickets[ $ticket->ID() ]
218
-                        ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
219
-                        ) ]['dtt_objs'] : array();
216
+                        $dtt_objs = isset($data->tickets[$ticket->ID()]) && is_array(
217
+                            $data->tickets[$ticket->ID()]
218
+                        ) && isset($data->tickets[$ticket->ID()]['dtt_objs']) ? $data->tickets[$ticket->ID(
219
+                        )]['dtt_objs'] : array();
220 220
                         $dtt_objs = (array) $dtt_objs;
221 221
                         foreach ($dtt_objs as $dtt_obj) {
222 222
                             if ($dtt_obj instanceof EE_Datetime) {
223
-                                $dtts[ $dtt_obj->ID() ] = $dtt_obj;
223
+                                $dtts[$dtt_obj->ID()] = $dtt_obj;
224 224
                             }
225 225
                         }
226 226
                     }
Please login to merge, or discard this patch.
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -19,225 +19,225 @@
 block discarded – undo
19 19
 class EE_Recipient_List_Shortcodes extends EE_Shortcodes
20 20
 {
21 21
 
22
-    public function __construct()
23
-    {
24
-        parent::__construct();
25
-    }
26
-
27
-
28
-    protected function _init_props()
29
-    {
30
-        $this->label = esc_html__('Recipient List Shortcodes', 'event_espresso');
31
-        $this->description = esc_html__('All shortcodes specific to registrant recipients list type data.', 'event_espresso');
32
-        $this->_shortcodes = array(
33
-            '[RECIPIENT_TICKET_LIST]' => esc_html__(
34
-                'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.',
35
-                'event_espresso'
36
-            ),
37
-            '[RECIPIENT_DATETIME_LIST]' => esc_html__(
38
-                'Will output a list of datetimes that the person receiving this message has been registered for.',
39
-                'event_espresso'
40
-            ),
41
-        );
42
-    }
43
-
44
-
45
-    protected function _parser($shortcode)
46
-    {
47
-        switch ($shortcode) {
48
-            case '[RECIPIENT_TICKET_LIST]':
49
-                return $this->_get_recipient_ticket_list();
50
-                break;
51
-
52
-            case '[RECIPIENT_DATETIME_LIST]':
53
-                return $this->_get_recipient_datetime_list();
54
-                break;
55
-        }
56
-        return '';
57
-    }
58
-
59
-
60
-    /**
61
-     * figure out what the incoming data is and then return the appropriate parsed value
62
-     *
63
-     * @return string
64
-     */
65
-    private function _get_recipient_ticket_list()
66
-    {
67
-        $this->_validate_list_requirements();
68
-
69
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
70
-            return $this->_get_recipient_ticket_list_parsed($this->_data['data']);
71
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
72
-            return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']);
73
-        } else {
74
-            return '';
75
-        }
76
-    }
77
-
78
-
79
-    private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data)
80
-    {
81
-        // first get registrations just for this attendee.
82
-        $att = $data->att_obj;
83
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
84
-        $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
85
-            ? array($data->reg_obj) : $registrations_on_attendee;
86
-        $tkts = array();
87
-
88
-        // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee.
89
-        // which means we want to get tickets for all events this addressee is a part of.
90
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
91
-            $valid_shortcodes = array(
92
-                'ticket',
93
-                'event_list',
94
-                'attendee_list',
95
-                'datetime_list',
96
-                'registration_details',
97
-                'attendee',
98
-                'recipient_details',
99
-            );
100
-            $template = $this->_data['template'];
101
-
102
-            // tickets will be tickets for all registrations on this attendee.
103
-            foreach ($registrations_on_attendee as $reg) {
104
-                if ($reg instanceof EE_Registration) {
105
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
106
-                        $data->registrations[ $reg->ID() ]
107
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
108
-                    ) ]['tkt_obj'] : null;
109
-                    if ($ticket instanceof EE_Ticket) {
110
-                        $tkts[ $ticket->ID() ] = $ticket;
111
-                    }
112
-                }
113
-            }
114
-        }
115
-
116
-        // if coming from the context of the event list parser, then let's return just the tickets for that event.
117
-        $event = $this->_data['data'];
118
-        if ($event instanceof EE_Event) {
119
-            $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details');
120
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
121
-                ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
122
-            // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
123
-            $template = str_replace('[EVENT_LIST]', '', $template);
124
-            // data will be tickets for this event for this recipient.
125
-            foreach ($registrations_on_attendee as $reg) {
126
-                if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
127
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
128
-                        $data->registrations[ $reg->ID() ]
129
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
130
-                    ) ]['tkt_obj'] : null;
131
-                    if ($ticket instanceof EE_Ticket) {
132
-                        $tkts[ $ticket->ID() ] = $ticket;
133
-                    }
134
-                }
135
-            }
136
-        }
137
-
138
-        $tkt_parsed = '';
139
-        foreach ($tkts as $ticket) {
140
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
141
-                $template,
142
-                $ticket,
143
-                $valid_shortcodes,
144
-                $this->_extra_data
145
-            );
146
-        }
147
-        return $tkt_parsed;
148
-    }
149
-
150
-
151
-    /**
152
-     * figure out what the incoming data is and then return the appropriate parsed value
153
-     *
154
-     * @return string
155
-     */
156
-    private function _get_recipient_datetime_list()
157
-    {
158
-        $this->_validate_list_requirements();
159
-
160
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
161
-            return $this->_get_recipient_datetime_list_parsed($this->_data['data']);
162
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
163
-            return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']);
164
-        } else {
165
-            return '';
166
-        }
167
-    }
168
-
169
-
170
-    private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data)
171
-    {
172
-        // first get registrations just for this attendee.
173
-        $att = $data->att_obj;
174
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
175
-        $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
176
-            ? array($data->reg_obj)
177
-            : $registrations_on_attendee;
178
-        $valid_shortcodes = array('datetime', 'attendee', 'recipient_details');
179
-        $template = '';
180
-        $dtts = array();
181
-
182
-        // setup valid shortcodes depending on what the status of the $this->_data property is
183
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
184
-            $template = $this->_data['template'];
185
-
186
-            // dtts will be datetimes for all registrations on this attendee
187
-            foreach ($registrations_on_attendee as $reg) {
188
-                if ($reg instanceof EE_Registration) {
189
-                    $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
190
-                        $data->registrations[ $reg->ID() ]
191
-                    ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
192
-                    ) ]['dtt_objs'] : array();
193
-                    $dtt_objs = (array) $dtt_objs;
194
-                    foreach ($dtt_objs as $dtt_obj) {
195
-                        if ($dtt_obj instanceof EE_Datetime) {
196
-                            $dtts[ $dtt_obj->ID() ] = $dtt_obj;
197
-                        }
198
-                    }
199
-                }
200
-            }
201
-        }
202
-
203
-        // if coming from the context of the event list parser, then let's just return the datetimes for the specific event.
204
-        $event = $this->_data['data'];
205
-        if ($event instanceof EE_Event) {
206
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
207
-                ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
208
-
209
-            // data will be datetimes for this event for this recipient
210
-            foreach ($registrations_on_attendee as $reg) {
211
-                if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
212
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
213
-                        $data->registrations[ $reg->ID() ]
214
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
215
-                    ) ]['tkt_obj'] : null;
216
-                    if ($ticket instanceof EE_Ticket) {
217
-                        $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
218
-                            $data->tickets[ $ticket->ID() ]
219
-                        ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
220
-                        ) ]['dtt_objs'] : array();
221
-                        $dtt_objs = (array) $dtt_objs;
222
-                        foreach ($dtt_objs as $dtt_obj) {
223
-                            if ($dtt_obj instanceof EE_Datetime) {
224
-                                $dtts[ $dtt_obj->ID() ] = $dtt_obj;
225
-                            }
226
-                        }
227
-                    }
228
-                }
229
-            }
230
-        }
231
-
232
-        $dtt_parsed = '';
233
-        foreach ($dtts as $datetime) {
234
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
235
-                $template,
236
-                $datetime,
237
-                $valid_shortcodes,
238
-                $this->_extra_data
239
-            );
240
-        }
241
-        return $dtt_parsed;
242
-    }
22
+	public function __construct()
23
+	{
24
+		parent::__construct();
25
+	}
26
+
27
+
28
+	protected function _init_props()
29
+	{
30
+		$this->label = esc_html__('Recipient List Shortcodes', 'event_espresso');
31
+		$this->description = esc_html__('All shortcodes specific to registrant recipients list type data.', 'event_espresso');
32
+		$this->_shortcodes = array(
33
+			'[RECIPIENT_TICKET_LIST]' => esc_html__(
34
+				'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.',
35
+				'event_espresso'
36
+			),
37
+			'[RECIPIENT_DATETIME_LIST]' => esc_html__(
38
+				'Will output a list of datetimes that the person receiving this message has been registered for.',
39
+				'event_espresso'
40
+			),
41
+		);
42
+	}
43
+
44
+
45
+	protected function _parser($shortcode)
46
+	{
47
+		switch ($shortcode) {
48
+			case '[RECIPIENT_TICKET_LIST]':
49
+				return $this->_get_recipient_ticket_list();
50
+				break;
51
+
52
+			case '[RECIPIENT_DATETIME_LIST]':
53
+				return $this->_get_recipient_datetime_list();
54
+				break;
55
+		}
56
+		return '';
57
+	}
58
+
59
+
60
+	/**
61
+	 * figure out what the incoming data is and then return the appropriate parsed value
62
+	 *
63
+	 * @return string
64
+	 */
65
+	private function _get_recipient_ticket_list()
66
+	{
67
+		$this->_validate_list_requirements();
68
+
69
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
70
+			return $this->_get_recipient_ticket_list_parsed($this->_data['data']);
71
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
72
+			return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']);
73
+		} else {
74
+			return '';
75
+		}
76
+	}
77
+
78
+
79
+	private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data)
80
+	{
81
+		// first get registrations just for this attendee.
82
+		$att = $data->att_obj;
83
+		$registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
84
+		$registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
85
+			? array($data->reg_obj) : $registrations_on_attendee;
86
+		$tkts = array();
87
+
88
+		// if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee.
89
+		// which means we want to get tickets for all events this addressee is a part of.
90
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
91
+			$valid_shortcodes = array(
92
+				'ticket',
93
+				'event_list',
94
+				'attendee_list',
95
+				'datetime_list',
96
+				'registration_details',
97
+				'attendee',
98
+				'recipient_details',
99
+			);
100
+			$template = $this->_data['template'];
101
+
102
+			// tickets will be tickets for all registrations on this attendee.
103
+			foreach ($registrations_on_attendee as $reg) {
104
+				if ($reg instanceof EE_Registration) {
105
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
106
+						$data->registrations[ $reg->ID() ]
107
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
108
+					) ]['tkt_obj'] : null;
109
+					if ($ticket instanceof EE_Ticket) {
110
+						$tkts[ $ticket->ID() ] = $ticket;
111
+					}
112
+				}
113
+			}
114
+		}
115
+
116
+		// if coming from the context of the event list parser, then let's return just the tickets for that event.
117
+		$event = $this->_data['data'];
118
+		if ($event instanceof EE_Event) {
119
+			$valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details');
120
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
121
+				? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
122
+			// let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
123
+			$template = str_replace('[EVENT_LIST]', '', $template);
124
+			// data will be tickets for this event for this recipient.
125
+			foreach ($registrations_on_attendee as $reg) {
126
+				if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
127
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
128
+						$data->registrations[ $reg->ID() ]
129
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
130
+					) ]['tkt_obj'] : null;
131
+					if ($ticket instanceof EE_Ticket) {
132
+						$tkts[ $ticket->ID() ] = $ticket;
133
+					}
134
+				}
135
+			}
136
+		}
137
+
138
+		$tkt_parsed = '';
139
+		foreach ($tkts as $ticket) {
140
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
141
+				$template,
142
+				$ticket,
143
+				$valid_shortcodes,
144
+				$this->_extra_data
145
+			);
146
+		}
147
+		return $tkt_parsed;
148
+	}
149
+
150
+
151
+	/**
152
+	 * figure out what the incoming data is and then return the appropriate parsed value
153
+	 *
154
+	 * @return string
155
+	 */
156
+	private function _get_recipient_datetime_list()
157
+	{
158
+		$this->_validate_list_requirements();
159
+
160
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
161
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data']);
162
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
163
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']);
164
+		} else {
165
+			return '';
166
+		}
167
+	}
168
+
169
+
170
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data)
171
+	{
172
+		// first get registrations just for this attendee.
173
+		$att = $data->att_obj;
174
+		$registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
175
+		$registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
176
+			? array($data->reg_obj)
177
+			: $registrations_on_attendee;
178
+		$valid_shortcodes = array('datetime', 'attendee', 'recipient_details');
179
+		$template = '';
180
+		$dtts = array();
181
+
182
+		// setup valid shortcodes depending on what the status of the $this->_data property is
183
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
184
+			$template = $this->_data['template'];
185
+
186
+			// dtts will be datetimes for all registrations on this attendee
187
+			foreach ($registrations_on_attendee as $reg) {
188
+				if ($reg instanceof EE_Registration) {
189
+					$dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
190
+						$data->registrations[ $reg->ID() ]
191
+					) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
192
+					) ]['dtt_objs'] : array();
193
+					$dtt_objs = (array) $dtt_objs;
194
+					foreach ($dtt_objs as $dtt_obj) {
195
+						if ($dtt_obj instanceof EE_Datetime) {
196
+							$dtts[ $dtt_obj->ID() ] = $dtt_obj;
197
+						}
198
+					}
199
+				}
200
+			}
201
+		}
202
+
203
+		// if coming from the context of the event list parser, then let's just return the datetimes for the specific event.
204
+		$event = $this->_data['data'];
205
+		if ($event instanceof EE_Event) {
206
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
207
+				? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
208
+
209
+			// data will be datetimes for this event for this recipient
210
+			foreach ($registrations_on_attendee as $reg) {
211
+				if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
212
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
213
+						$data->registrations[ $reg->ID() ]
214
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
215
+					) ]['tkt_obj'] : null;
216
+					if ($ticket instanceof EE_Ticket) {
217
+						$dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
218
+							$data->tickets[ $ticket->ID() ]
219
+						) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
220
+						) ]['dtt_objs'] : array();
221
+						$dtt_objs = (array) $dtt_objs;
222
+						foreach ($dtt_objs as $dtt_obj) {
223
+							if ($dtt_obj instanceof EE_Datetime) {
224
+								$dtts[ $dtt_obj->ID() ] = $dtt_obj;
225
+							}
226
+						}
227
+					}
228
+				}
229
+			}
230
+		}
231
+
232
+		$dtt_parsed = '';
233
+		foreach ($dtts as $datetime) {
234
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
235
+				$template,
236
+				$datetime,
237
+				$valid_shortcodes,
238
+				$this->_extra_data
239
+			);
240
+		}
241
+		return $dtt_parsed;
242
+	}
243 243
 }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/DateFilterHeader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
                 $text .= '<span class="drk-grey-text">';
71 71
                 $text .= '<span class="dashicons dashicons-calendar"></span>';
72 72
                 $text .= $datetime->name();
73
-                $text .= ' ( ' . $datetime->start_date() . ' )';
73
+                $text .= ' ( '.$datetime->start_date().' )';
74 74
                 $text .= '</span></h3>';
75 75
             }
76 76
         }
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -23,57 +23,57 @@
 block discarded – undo
23 23
 class DateFilterHeader extends AdminPageHeaderDecorator
24 24
 {
25 25
 
26
-    /**
27
-     * @var EEM_Datetime $datetime_model
28
-     */
29
-    private $datetime_model;
26
+	/**
27
+	 * @var EEM_Datetime $datetime_model
28
+	 */
29
+	private $datetime_model;
30 30
 
31 31
 
32
-    /**
33
-     * DateFilterHeader constructor.
34
-     *
35
-     * @param RequestInterface $request
36
-     * @param EEM_Datetime     $datetime_model
37
-     */
38
-    public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
39
-    {
40
-        parent::__construct($request);
41
-        $this->datetime_model = $datetime_model;
42
-    }
32
+	/**
33
+	 * DateFilterHeader constructor.
34
+	 *
35
+	 * @param RequestInterface $request
36
+	 * @param EEM_Datetime     $datetime_model
37
+	 */
38
+	public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
39
+	{
40
+		parent::__construct($request);
41
+		$this->datetime_model = $datetime_model;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @param string $text
47
-     * @return string
48
-     * @throws EE_Error
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     * @throws ReflectionException
53
-     * @since 4.10.2.p
54
-     */
55
-    public function getHeaderText($text = '')
56
-    {
57
-        $DTT_ID = $this->request->getRequestParam('DTT_ID');
58
-        $DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID, 'int');
59
-        if ($DTT_ID) {
60
-            $datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
61
-            if ($datetime instanceof EE_Datetime && $text !== '') {
62
-                // remove the closing h3 heading tag if it exists
63
-                $text = str_replace(
64
-                    '</h3>',
65
-                    '',
66
-                    $text
67
-                );
68
-                $text .= '&nbsp; &nbsp; ';
69
-                $text .= '<span class="drk-grey-text">';
70
-                $text .= '<span class="dashicons dashicons-calendar"></span>';
71
-                $text .= $datetime->name();
72
-                $text .= ' ( ' . $datetime->start_date() . ' )';
73
-                $text .= '</span></h3>';
74
-            }
75
-        }
45
+	/**
46
+	 * @param string $text
47
+	 * @return string
48
+	 * @throws EE_Error
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 * @throws ReflectionException
53
+	 * @since 4.10.2.p
54
+	 */
55
+	public function getHeaderText($text = '')
56
+	{
57
+		$DTT_ID = $this->request->getRequestParam('DTT_ID');
58
+		$DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID, 'int');
59
+		if ($DTT_ID) {
60
+			$datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
61
+			if ($datetime instanceof EE_Datetime && $text !== '') {
62
+				// remove the closing h3 heading tag if it exists
63
+				$text = str_replace(
64
+					'</h3>',
65
+					'',
66
+					$text
67
+				);
68
+				$text .= '&nbsp; &nbsp; ';
69
+				$text .= '<span class="drk-grey-text">';
70
+				$text .= '<span class="dashicons dashicons-calendar"></span>';
71
+				$text .= $datetime->name();
72
+				$text .= ' ( ' . $datetime->start_date() . ' )';
73
+				$text .= '</span></h3>';
74
+			}
75
+		}
76 76
 
77
-        return $text;
78
-    }
77
+		return $text;
78
+	}
79 79
 }
Please login to merge, or discard this patch.
admin/registrations/list_table/page_header/AttendeeFilterHeader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@
 block discarded – undo
59 59
                         'event_espresso'
60 60
                     ),
61 61
                     '<h3 style="line-height:1.5em;">',
62
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
62
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
63 63
                         array(
64 64
                             'action' => 'edit_attendee',
65 65
                             'post'   => $ATT_ID,
66 66
                         ),
67 67
                         REG_ADMIN_URL
68
-                    ) . '">' . $attendee->full_name() . '</a>',
68
+                    ).'">'.$attendee->full_name().'</a>',
69 69
                     '</h3>'
70 70
                 );
71 71
             }
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -20,55 +20,55 @@
 block discarded – undo
20 20
 class AttendeeFilterHeader extends AdminPageHeaderDecorator
21 21
 {
22 22
 
23
-    /**
24
-     * @var EEM_Attendee $attendee_model
25
-     */
26
-    private $attendee_model;
23
+	/**
24
+	 * @var EEM_Attendee $attendee_model
25
+	 */
26
+	private $attendee_model;
27 27
 
28 28
 
29
-    /**
30
-     * AttendeeFilterHeader constructor.
31
-     *
32
-     * @param RequestInterface $request
33
-     * @param EEM_Attendee     $attendee_model
34
-     */
35
-    public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
36
-    {
37
-        parent::__construct($request);
38
-        $this->attendee_model = $attendee_model;
39
-    }
29
+	/**
30
+	 * AttendeeFilterHeader constructor.
31
+	 *
32
+	 * @param RequestInterface $request
33
+	 * @param EEM_Attendee     $attendee_model
34
+	 */
35
+	public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
36
+	{
37
+		parent::__construct($request);
38
+		$this->attendee_model = $attendee_model;
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * @param string $text
44
-     * @return string
45
-     * @throws EE_Error
46
-     * @since 4.10.2.p
47
-     */
48
-    public function getHeaderText($text = '')
49
-    {
50
-        $ATT_ID = $this->request->getRequestParam('ATT_ID');
51
-        $ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID, 'int');
52
-        if ($ATT_ID) {
53
-            $attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
54
-            if ($attendee instanceof EE_Attendee) {
55
-                $text .= sprintf(
56
-                    esc_html__(
57
-                        '%1$s Viewing registrations for %2$s%3$s',
58
-                        'event_espresso'
59
-                    ),
60
-                    '<h3 style="line-height:1.5em;">',
61
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
62
-                        array(
63
-                            'action' => 'edit_attendee',
64
-                            'post'   => $ATT_ID,
65
-                        ),
66
-                        REG_ADMIN_URL
67
-                    ) . '">' . $attendee->full_name() . '</a>',
68
-                    '</h3>'
69
-                );
70
-            }
71
-        }
72
-        return $text;
73
-    }
42
+	/**
43
+	 * @param string $text
44
+	 * @return string
45
+	 * @throws EE_Error
46
+	 * @since 4.10.2.p
47
+	 */
48
+	public function getHeaderText($text = '')
49
+	{
50
+		$ATT_ID = $this->request->getRequestParam('ATT_ID');
51
+		$ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID, 'int');
52
+		if ($ATT_ID) {
53
+			$attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
54
+			if ($attendee instanceof EE_Attendee) {
55
+				$text .= sprintf(
56
+					esc_html__(
57
+						'%1$s Viewing registrations for %2$s%3$s',
58
+						'event_espresso'
59
+					),
60
+					'<h3 style="line-height:1.5em;">',
61
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
62
+						array(
63
+							'action' => 'edit_attendee',
64
+							'post'   => $ATT_ID,
65
+						),
66
+						REG_ADMIN_URL
67
+					) . '">' . $attendee->full_name() . '</a>',
68
+					'</h3>'
69
+				);
70
+			}
71
+		}
72
+		return $text;
73
+	}
74 74
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Div_Per_Section_Layout.strategy.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -46,40 +46,40 @@  discard block
 block discarded – undo
46 46
             ? (string) $input->html_id()
47 47
             : spl_object_hash($input);
48 48
         // and add a generic input type class
49
-        $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
49
+        $html_class = sanitize_key(str_replace('_', '-', get_class($input))).'-dv';
50 50
         if ($input instanceof EE_Hidden_Input) {
51
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
51
+            $html .= EEH_HTML::nl().$input->get_html_for_input();
52 52
         } elseif ($input instanceof EE_Submit_Input) {
53 53
             $html .= EEH_HTML::div(
54 54
                 $input->get_html_for_input(),
55
-                $html_id . '-submit-dv',
55
+                $html_id.'-submit-dv',
56 56
                 "{$input->html_class()}-submit-dv {$html_class}"
57 57
             );
58 58
         } elseif ($input instanceof EE_Select_Input) {
59 59
             $html .= EEH_HTML::div(
60
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
61
-                EEH_HTML::nl() . $input->get_html_for_errors() .
62
-                EEH_HTML::nl() . $input->get_html_for_input() .
63
-                EEH_HTML::nl() . $input->get_html_for_help(),
64
-                $html_id . '-input-dv',
60
+                EEH_HTML::nl(1).$input->get_html_for_label().
61
+                EEH_HTML::nl().$input->get_html_for_errors().
62
+                EEH_HTML::nl().$input->get_html_for_input().
63
+                EEH_HTML::nl().$input->get_html_for_help(),
64
+                $html_id.'-input-dv',
65 65
                 "{$input->html_class()}-input-dv {$html_class}"
66 66
             );
67 67
         } elseif ($input instanceof EE_Form_Input_With_Options_Base) {
68 68
             $html .= EEH_HTML::div(
69
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
-                EEH_HTML::nl() . $input->get_html_for_errors() .
71
-                EEH_HTML::nl() . $input->get_html_for_input() .
72
-                EEH_HTML::nl() . $input->get_html_for_help(),
73
-                $html_id . '-input-dv',
69
+                EEH_HTML::nl().$this->_display_label_for_option_type_question($input).
70
+                EEH_HTML::nl().$input->get_html_for_errors().
71
+                EEH_HTML::nl().$input->get_html_for_input().
72
+                EEH_HTML::nl().$input->get_html_for_help(),
73
+                $html_id.'-input-dv',
74 74
                 "{$input->html_class()}-input-dv {$html_class}"
75 75
             );
76 76
         } else {
77 77
             $html .= EEH_HTML::div(
78
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
79
-                EEH_HTML::nl() . $input->get_html_for_errors() .
80
-                EEH_HTML::nl() . $input->get_html_for_input() .
81
-                EEH_HTML::nl() . $input->get_html_for_help(),
82
-                $html_id . '-input-dv',
78
+                EEH_HTML::nl(1).$input->get_html_for_label().
79
+                EEH_HTML::nl().$input->get_html_for_errors().
80
+                EEH_HTML::nl().$input->get_html_for_input().
81
+                EEH_HTML::nl().$input->get_html_for_help(),
82
+                $html_id.'-input-dv',
83 83
                 "{$input->html_class()}-input-dv {$html_class}"
84 84
             );
85 85
         }
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
             $html_label_text = $input->html_label_text();
104 104
             $label_html = EEH_HTML::div(
105 105
                 $input->required()
106
-                    ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
106
+                    ? $html_label_text.EEH_HTML::span('*', '', 'ee-asterisk')
107 107
                     : $html_label_text,
108 108
                 $input->html_label_id(),
109 109
                 $input->required()
110
-                    ? 'ee-required-label ' . $input->html_label_class()
110
+                    ? 'ee-required-label '.$input->html_label_class()
111 111
                     : $input->html_label_class(),
112 112
                 $input->html_label_style(),
113 113
                 $input->other_html_attributes()
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function layout_subsection($form_section)
134 134
     {
135
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
135
+        return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1);
136 136
     }
137 137
 
138 138
 
Please login to merge, or discard this patch.
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -12,136 +12,136 @@
 block discarded – undo
12 12
 class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base
13 13
 {
14 14
 
15
-    /**
16
-     * opening div tag for a form
17
-     *
18
-     * @return string
19
-     */
20
-    public function layout_form_begin()
21
-    {
22
-        return EEH_HTML::div(
23
-            '',
24
-            $this->_form_section->html_id(),
25
-            $this->_form_section->html_class(),
26
-            $this->_form_section->html_style()
27
-        );
28
-    }
15
+	/**
16
+	 * opening div tag for a form
17
+	 *
18
+	 * @return string
19
+	 */
20
+	public function layout_form_begin()
21
+	{
22
+		return EEH_HTML::div(
23
+			'',
24
+			$this->_form_section->html_id(),
25
+			$this->_form_section->html_class(),
26
+			$this->_form_section->html_style()
27
+		);
28
+	}
29 29
 
30 30
 
31 31
 
32
-    /**
33
-     * Lays out the row for the input, including label and errors
34
-     *
35
-     * @param EE_Form_Input_Base $input
36
-     * @return string
37
-     * @throws \EE_Error
38
-     */
39
-    public function layout_input($input)
40
-    {
41
-        $html = '';
42
-        // set something unique for the id
43
-        $html_id = (string) $input->html_id() !== ''
44
-            ? (string) $input->html_id()
45
-            : spl_object_hash($input);
46
-        // and add a generic input type class
47
-        $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
48
-        if ($input instanceof EE_Hidden_Input) {
49
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
50
-        } elseif ($input instanceof EE_Submit_Input) {
51
-            $html .= EEH_HTML::div(
52
-                $input->get_html_for_input(),
53
-                $html_id . '-submit-dv',
54
-                "{$input->html_class()}-submit-dv {$html_class}"
55
-            );
56
-        } elseif ($input instanceof EE_Select_Input) {
57
-            $html .= EEH_HTML::div(
58
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
59
-                EEH_HTML::nl() . $input->get_html_for_errors() .
60
-                EEH_HTML::nl() . $input->get_html_for_input() .
61
-                EEH_HTML::nl() . $input->get_html_for_help(),
62
-                $html_id . '-input-dv',
63
-                "{$input->html_class()}-input-dv {$html_class}"
64
-            );
65
-        } elseif ($input instanceof EE_Form_Input_With_Options_Base) {
66
-            $html .= EEH_HTML::div(
67
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
68
-                EEH_HTML::nl() . $input->get_html_for_errors() .
69
-                EEH_HTML::nl() . $input->get_html_for_input() .
70
-                EEH_HTML::nl() . $input->get_html_for_help(),
71
-                $html_id . '-input-dv',
72
-                "{$input->html_class()}-input-dv {$html_class}"
73
-            );
74
-        } else {
75
-            $html .= EEH_HTML::div(
76
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
77
-                EEH_HTML::nl() . $input->get_html_for_errors() .
78
-                EEH_HTML::nl() . $input->get_html_for_input() .
79
-                EEH_HTML::nl() . $input->get_html_for_help(),
80
-                $html_id . '-input-dv',
81
-                "{$input->html_class()}-input-dv {$html_class}"
82
-            );
83
-        }
84
-        return $html;
85
-    }
32
+	/**
33
+	 * Lays out the row for the input, including label and errors
34
+	 *
35
+	 * @param EE_Form_Input_Base $input
36
+	 * @return string
37
+	 * @throws \EE_Error
38
+	 */
39
+	public function layout_input($input)
40
+	{
41
+		$html = '';
42
+		// set something unique for the id
43
+		$html_id = (string) $input->html_id() !== ''
44
+			? (string) $input->html_id()
45
+			: spl_object_hash($input);
46
+		// and add a generic input type class
47
+		$html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
48
+		if ($input instanceof EE_Hidden_Input) {
49
+			$html .= EEH_HTML::nl() . $input->get_html_for_input();
50
+		} elseif ($input instanceof EE_Submit_Input) {
51
+			$html .= EEH_HTML::div(
52
+				$input->get_html_for_input(),
53
+				$html_id . '-submit-dv',
54
+				"{$input->html_class()}-submit-dv {$html_class}"
55
+			);
56
+		} elseif ($input instanceof EE_Select_Input) {
57
+			$html .= EEH_HTML::div(
58
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
59
+				EEH_HTML::nl() . $input->get_html_for_errors() .
60
+				EEH_HTML::nl() . $input->get_html_for_input() .
61
+				EEH_HTML::nl() . $input->get_html_for_help(),
62
+				$html_id . '-input-dv',
63
+				"{$input->html_class()}-input-dv {$html_class}"
64
+			);
65
+		} elseif ($input instanceof EE_Form_Input_With_Options_Base) {
66
+			$html .= EEH_HTML::div(
67
+				EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
68
+				EEH_HTML::nl() . $input->get_html_for_errors() .
69
+				EEH_HTML::nl() . $input->get_html_for_input() .
70
+				EEH_HTML::nl() . $input->get_html_for_help(),
71
+				$html_id . '-input-dv',
72
+				"{$input->html_class()}-input-dv {$html_class}"
73
+			);
74
+		} else {
75
+			$html .= EEH_HTML::div(
76
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
77
+				EEH_HTML::nl() . $input->get_html_for_errors() .
78
+				EEH_HTML::nl() . $input->get_html_for_input() .
79
+				EEH_HTML::nl() . $input->get_html_for_help(),
80
+				$html_id . '-input-dv',
81
+				"{$input->html_class()}-input-dv {$html_class}"
82
+			);
83
+		}
84
+		return $html;
85
+	}
86 86
 
87 87
 
88 88
 
89
-    /**
90
-     *
91
-     * _display_label_for_option_type_question
92
-     * Gets the HTML for the 'label', which is just text for this (because labels
93
-     * should be for each input)
94
-     *
95
-     * @param EE_Form_Input_With_Options_Base $input
96
-     * @return string
97
-     */
98
-    protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
99
-    {
100
-        if ($input->display_html_label_text()) {
101
-            $html_label_text = $input->html_label_text();
102
-            $label_html = EEH_HTML::div(
103
-                $input->required()
104
-                    ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
105
-                    : $html_label_text,
106
-                $input->html_label_id(),
107
-                $input->required()
108
-                    ? 'ee-required-label ' . $input->html_label_class()
109
-                    : $input->html_label_class(),
110
-                $input->html_label_style(),
111
-                $input->other_html_attributes()
112
-            );
113
-            // if no content was provided to EEH_HTML::div() above (ie: an empty label),
114
-            // then we need to close the div manually
115
-            if (empty($html_label_text)) {
116
-                $label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
117
-            }
118
-            return $label_html;
119
-        }
120
-        return '';
121
-    }
89
+	/**
90
+	 *
91
+	 * _display_label_for_option_type_question
92
+	 * Gets the HTML for the 'label', which is just text for this (because labels
93
+	 * should be for each input)
94
+	 *
95
+	 * @param EE_Form_Input_With_Options_Base $input
96
+	 * @return string
97
+	 */
98
+	protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
99
+	{
100
+		if ($input->display_html_label_text()) {
101
+			$html_label_text = $input->html_label_text();
102
+			$label_html = EEH_HTML::div(
103
+				$input->required()
104
+					? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
105
+					: $html_label_text,
106
+				$input->html_label_id(),
107
+				$input->required()
108
+					? 'ee-required-label ' . $input->html_label_class()
109
+					: $input->html_label_class(),
110
+				$input->html_label_style(),
111
+				$input->other_html_attributes()
112
+			);
113
+			// if no content was provided to EEH_HTML::div() above (ie: an empty label),
114
+			// then we need to close the div manually
115
+			if (empty($html_label_text)) {
116
+				$label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
117
+			}
118
+			return $label_html;
119
+		}
120
+		return '';
121
+	}
122 122
 
123 123
 
124 124
 
125
-    /**
126
-     * Lays out a row for the subsection
127
-     *
128
-     * @param EE_Form_Section_Proper $form_section
129
-     * @return string
130
-     */
131
-    public function layout_subsection($form_section)
132
-    {
133
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
134
-    }
125
+	/**
126
+	 * Lays out a row for the subsection
127
+	 *
128
+	 * @param EE_Form_Section_Proper $form_section
129
+	 * @return string
130
+	 */
131
+	public function layout_subsection($form_section)
132
+	{
133
+		return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
134
+	}
135 135
 
136 136
 
137 137
 
138
-    /**
139
-     * closing div tag for a form
140
-     *
141
-     * @return string
142
-     */
143
-    public function layout_form_end()
144
-    {
145
-        return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
146
-    }
138
+	/**
139
+	 * closing div tag for a form
140
+	 *
141
+	 * @return string
142
+	 */
143
+	public function layout_form_end()
144
+	{
145
+		return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
146
+	}
147 147
 }
Please login to merge, or discard this patch.
core/services/admin/AdminPageHeaderDecorator.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@
 block discarded – undo
16 16
 abstract class AdminPageHeaderDecorator implements AdminPageHeaderDecoratorInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var RequestInterface $request
21
-     */
22
-    protected $request;
19
+	/**
20
+	 * @var RequestInterface $request
21
+	 */
22
+	protected $request;
23 23
 
24 24
 
25
-    /**
26
-     * AdminPageHeader constructor.
27
-     *
28
-     * @param RequestInterface $request
29
-     */
30
-    public function __construct(RequestInterface $request)
31
-    {
32
-        $this->request = $request;
33
-    }
25
+	/**
26
+	 * AdminPageHeader constructor.
27
+	 *
28
+	 * @param RequestInterface $request
29
+	 */
30
+	public function __construct(RequestInterface $request)
31
+	{
32
+		$this->request = $request;
33
+	}
34 34
 }
Please login to merge, or discard this patch.
core/domain/services/admin/registrations/list_table/QueryBuilder.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'caps'                     => EEM_Registration::caps_read_admin,
83 83
             'default_where_conditions' => 'this_model_only',
84 84
         ];
85
-        if (! $count_query) {
85
+        if ( ! $count_query) {
86 86
             $query_params = array_merge(
87 87
                 $query_params,
88 88
                 $this->getOrderbyClause(),
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
                 [
229 229
                     $this->registration_model->convert_datetime_for_query(
230 230
                         'REG_date',
231
-                        $now . ' 00:00:00',
231
+                        $now.' 00:00:00',
232 232
                         'Y-m-d H:i:s'
233 233
                     ),
234 234
                     $this->registration_model->convert_datetime_for_query(
235 235
                         'REG_date',
236
-                        $now . ' 23:59:59',
236
+                        $now.' 23:59:59',
237 237
                         'Y-m-d H:i:s'
238 238
                     ),
239 239
                 ],
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
                 [
249 249
                     $this->registration_model->convert_datetime_for_query(
250 250
                         'REG_date',
251
-                        $current_year_and_month . '-01 00:00:00',
251
+                        $current_year_and_month.'-01 00:00:00',
252 252
                         'Y-m-d H:i:s'
253 253
                     ),
254 254
                     $this->registration_model->convert_datetime_for_query(
255 255
                         'REG_date',
256
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
256
+                        $current_year_and_month.'-'.$days_this_month.' 23:59:59',
257 257
                         'Y-m-d H:i:s'
258 258
                     ),
259 259
                 ],
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
                 : '';
273 273
             // if there is not a month or year then we can't go further
274 274
             if ($month_requested && $year_requested) {
275
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
275
+                $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01'));
276 276
                 $this->where_params['REG_date'] = [
277 277
                     'BETWEEN',
278 278
                     [
279 279
                         $this->registration_model->convert_datetime_for_query(
280 280
                             'REG_date',
281
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
281
+                            $year_requested.'-'.$month_requested.'-01 00:00:00',
282 282
                             'Y-m-d H:i:s'
283 283
                         ),
284 284
                         $this->registration_model->convert_datetime_for_query(
285 285
                             'REG_date',
286
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
286
+                            $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59',
287 287
                             'Y-m-d H:i:s'
288 288
                         ),
289 289
                     ],
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     {
301 301
         $search = $this->request->getRequestParam('s');
302 302
         if ($search) {
303
-            $search_string = '%' . sanitize_text_field($search) . '%';
303
+            $search_string = '%'.sanitize_text_field($search).'%';
304 304
             $this->where_params['OR*search_conditions'] = [
305 305
                 'Event.EVT_name'                          => ['LIKE', $search_string],
306 306
                 'Event.EVT_desc'                          => ['LIKE', $search_string],
Please login to merge, or discard this patch.
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -21,382 +21,382 @@
 block discarded – undo
21 21
 class QueryBuilder
22 22
 {
23 23
 
24
-    /**
25
-     * @var RequestInterface $request
26
-     */
27
-    protected $request;
28
-
29
-    /**
30
-     * @var EEM_Registration $registration_model
31
-     */
32
-    protected $registration_model;
33
-
34
-    /**
35
-     * @var string $view
36
-     */
37
-    protected $view;
38
-
39
-    /**
40
-     * @var array $where_params
41
-     */
42
-    protected $where_params;
43
-
44
-
45
-    /**
46
-     * QueryBuilder constructor.
47
-     *
48
-     * @param RequestInterface $request
49
-     * @param EEM_Registration $registration_model
50
-     * @param array            $extra_request_params
51
-     */
52
-    public function __construct(
53
-        RequestInterface $request,
54
-        EEM_Registration $registration_model,
55
-        array $extra_request_params = []
56
-    ) {
57
-        $this->request = $request;
58
-        $this->registration_model = $registration_model;
59
-        foreach ($extra_request_params as $key => $value) {
60
-            $this->request->setRequestParam($key, $value);
61
-        }
62
-        $this->view = $this->request->getRequestParam('status', '');
63
-        $this->where_params = [];
64
-    }
65
-
66
-
67
-    /**
68
-     * Sets up the where conditions for the registrations query.
69
-     *
70
-     * @param int  $per_page
71
-     * @param bool $count_query
72
-     * @return array
73
-     * @throws EE_Error
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     */
78
-    public function getQueryParams($per_page = 10, $count_query = false)
79
-    {
80
-        $query_params = [
81
-            0                          => $this->getWhereClause(),
82
-            'caps'                     => EEM_Registration::caps_read_admin,
83
-            'default_where_conditions' => 'this_model_only',
84
-        ];
85
-        if (! $count_query) {
86
-            $query_params = array_merge(
87
-                $query_params,
88
-                $this->getOrderbyClause(),
89
-                $this->getLimitClause($per_page)
90
-            );
91
-        }
92
-
93
-        return $query_params;
94
-    }
95
-
96
-
97
-    /**
98
-     * Sets up the where conditions for the registrations query.
99
-     *
100
-     * @return array
101
-     * @throws EE_Error
102
-     * @throws InvalidArgumentException
103
-     * @throws InvalidDataTypeException
104
-     * @throws InvalidInterfaceException
105
-     */
106
-    protected function getWhereClause()
107
-    {
108
-        $this->addAttendeeIdToWhereConditions();
109
-        $this->addEventIdToWhereConditions();
110
-        $this->addCategoryIdToWhereConditions();
111
-        $this->addDatetimeIdToWhereConditions();
112
-        $this->addTicketIdToWhereConditions();
113
-        $this->addRegistrationStatusToWhereConditions();
114
-        $this->addDateToWhereConditions();
115
-        $this->addSearchToWhereConditions();
116
-        return apply_filters(
117
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
118
-            $this->where_params,
119
-            $this->request->requestParams()
120
-        );
121
-    }
122
-
123
-
124
-    /**
125
-     * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
126
-     */
127
-    protected function addAttendeeIdToWhereConditions()
128
-    {
129
-        $ATT_ID = $this->request->getRequestParam('attendee_id');
130
-        $ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID, 'int');
131
-        if ($ATT_ID) {
132
-            $this->where_params['ATT_ID'] = $ATT_ID;
133
-        }
134
-    }
135
-
136
-
137
-    /**
138
-     * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
139
-     */
140
-    protected function addEventIdToWhereConditions()
141
-    {
142
-        $EVT_ID = $this->request->getRequestParam('event_id');
143
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID, 'int');
144
-        if ($EVT_ID) {
145
-            $this->where_params['EVT_ID'] = $EVT_ID;
146
-        }
147
-    }
148
-
149
-
150
-    /**
151
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
152
-     */
153
-    protected function addCategoryIdToWhereConditions()
154
-    {
155
-        $EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT', 0, 'int');
156
-        if ($EVT_CAT > 0) {
157
-            $this->where_params['Event.Term_Taxonomy.term_id'] = $EVT_CAT;
158
-        }
159
-    }
160
-
161
-
162
-    /**
163
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
164
-     */
165
-    protected function addDatetimeIdToWhereConditions()
166
-    {
167
-        // first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
168
-        $DTT_ID = $this->request->getRequestParam('datetime_id');
169
-        $DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID, 'int');
170
-        if ($DTT_ID) {
171
-            $this->where_params['Ticket.Datetime.DTT_ID'] = $DTT_ID;
172
-        }
173
-    }
174
-
175
-
176
-    /**
177
-     * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
178
-     */
179
-    protected function addTicketIdToWhereConditions()
180
-    {
181
-        // first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
182
-        $TKT_ID = $this->request->getRequestParam('ticket_id');
183
-        $TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID, 'int');
184
-        if ($TKT_ID) {
185
-            $this->where_params['TKT_ID'] = $TKT_ID;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * Adds the correct registration status to the where conditions for the registrations query.
192
-     * If filtering by registration status, then we show registrations matching that status.
193
-     * If not filtering by specified status, then we show all registrations excluding incomplete registrations
194
-     * UNLESS viewing trashed registrations.
195
-     */
196
-    protected function addRegistrationStatusToWhereConditions()
197
-    {
198
-        $registration_status = $this->request->getRequestParam('_reg_status');
199
-        if ($registration_status) {
200
-            $this->where_params['STS_ID'] = sanitize_text_field($registration_status);
201
-            return;
202
-        }
203
-        // make sure we exclude incomplete registrations, but only if not trashed.
204
-        if ($this->view === 'trash') {
205
-            $this->where_params['REG_deleted'] = true;
206
-            return;
207
-        }
208
-        $this->where_params['STS_ID'] = $this->view === 'incomplete'
209
-            ? EEM_Registration::status_id_incomplete
210
-            : ['!=', EEM_Registration::status_id_incomplete];
211
-    }
212
-
213
-
214
-    /**
215
-     * Adds any provided date restraints to the where conditions for the registrations query.
216
-     *
217
-     * @throws EE_Error
218
-     * @throws InvalidArgumentException
219
-     * @throws InvalidDataTypeException
220
-     * @throws InvalidInterfaceException
221
-     */
222
-    protected function addDateToWhereConditions()
223
-    {
224
-        if ($this->view === 'today') {
225
-            $now = date('Y-m-d', current_time('timestamp'));
226
-            $this->where_params['REG_date'] = [
227
-                'BETWEEN',
228
-                [
229
-                    $this->registration_model->convert_datetime_for_query(
230
-                        'REG_date',
231
-                        $now . ' 00:00:00',
232
-                        'Y-m-d H:i:s'
233
-                    ),
234
-                    $this->registration_model->convert_datetime_for_query(
235
-                        'REG_date',
236
-                        $now . ' 23:59:59',
237
-                        'Y-m-d H:i:s'
238
-                    ),
239
-                ],
240
-            ];
241
-            return;
242
-        }
243
-        if ($this->view === 'month') {
244
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
245
-            $days_this_month = date('t', current_time('timestamp'));
246
-            $this->where_params['REG_date'] = [
247
-                'BETWEEN',
248
-                [
249
-                    $this->registration_model->convert_datetime_for_query(
250
-                        'REG_date',
251
-                        $current_year_and_month . '-01 00:00:00',
252
-                        'Y-m-d H:i:s'
253
-                    ),
254
-                    $this->registration_model->convert_datetime_for_query(
255
-                        'REG_date',
256
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
257
-                        'Y-m-d H:i:s'
258
-                    ),
259
-                ],
260
-            ];
261
-            return;
262
-        }
263
-        $month_range = $this->request->getRequestParam('month_range');
264
-        if ($month_range) {
265
-            $month_range = sanitize_text_field($month_range);
266
-            $pieces = explode(' ', $month_range, 3);
267
-            $month_requested = ! empty($pieces[0])
268
-                ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
269
-                : '';
270
-            $year_requested = ! empty($pieces[1])
271
-                ? $pieces[1]
272
-                : '';
273
-            // if there is not a month or year then we can't go further
274
-            if ($month_requested && $year_requested) {
275
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
276
-                $this->where_params['REG_date'] = [
277
-                    'BETWEEN',
278
-                    [
279
-                        $this->registration_model->convert_datetime_for_query(
280
-                            'REG_date',
281
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
282
-                            'Y-m-d H:i:s'
283
-                        ),
284
-                        $this->registration_model->convert_datetime_for_query(
285
-                            'REG_date',
286
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
287
-                            'Y-m-d H:i:s'
288
-                        ),
289
-                    ],
290
-                ];
291
-            }
292
-        }
293
-    }
294
-
295
-
296
-    /**
297
-     * Adds any provided search restraints to the where conditions for the registrations query
298
-     */
299
-    protected function addSearchToWhereConditions()
300
-    {
301
-        $search = $this->request->getRequestParam('s');
302
-        if ($search) {
303
-            $search_string = '%' . sanitize_text_field($search) . '%';
304
-            $this->where_params['OR*search_conditions'] = [
305
-                'Event.EVT_name'                          => ['LIKE', $search_string],
306
-                'Event.EVT_desc'                          => ['LIKE', $search_string],
307
-                'Event.EVT_short_desc'                    => ['LIKE', $search_string],
308
-                'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
309
-                'Attendee.ATT_fname'                      => ['LIKE', $search_string],
310
-                'Attendee.ATT_lname'                      => ['LIKE', $search_string],
311
-                'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
312
-                'Attendee.ATT_email'                      => ['LIKE', $search_string],
313
-                'Attendee.ATT_address'                    => ['LIKE', $search_string],
314
-                'Attendee.ATT_address2'                   => ['LIKE', $search_string],
315
-                'Attendee.ATT_city'                       => ['LIKE', $search_string],
316
-                'REG_final_price'                         => ['LIKE', $search_string],
317
-                'REG_code'                                => ['LIKE', $search_string],
318
-                'REG_count'                               => ['LIKE', $search_string],
319
-                'REG_group_size'                          => ['LIKE', $search_string],
320
-                'Ticket.TKT_name'                         => ['LIKE', $search_string],
321
-                'Ticket.TKT_description'                  => ['LIKE', $search_string],
322
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
323
-            ];
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * Sets up the orderby for the registrations query.
330
-     *
331
-     * @return array
332
-     */
333
-    protected function getOrderbyClause()
334
-    {
335
-        $orderby_field = $this->request->getRequestParam('orderby');
336
-        $orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
337
-        switch ($orderby_field) {
338
-            case '_REG_ID':
339
-                $orderby = ['REG_ID'];
340
-                break;
341
-            case '_Reg_status':
342
-                $orderby = ['STS_ID'];
343
-                break;
344
-            case 'ATT_fname':
345
-                $orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
346
-                break;
347
-            case 'ATT_lname':
348
-                $orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
349
-                break;
350
-            case 'event_name':
351
-                $orderby = ['Event.EVT_name'];
352
-                break;
353
-            case 'DTT_EVT_start':
354
-                $orderby = ['Event.Datetime.DTT_EVT_start'];
355
-                break;
356
-            case '_REG_date':
357
-                $orderby = ['REG_date'];
358
-                break;
359
-            default:
360
-                $orderby = [$orderby_field];
361
-                break;
362
-        }
363
-        $order = $this->request->getRequestParam('order');
364
-        $order = $order ? sanitize_text_field($order) : 'DESC';
365
-
366
-        $orderby = array_combine(
367
-            $orderby,
368
-            array_fill(0, count($orderby), $order)
369
-        );
370
-        // because there are many registrations with the same date, define
371
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
372
-        if (empty($orderby['REG_ID'])) {
373
-            $orderby['REG_ID'] = $order;
374
-        }
375
-
376
-        $orderby = apply_filters(
377
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
378
-            $orderby,
379
-            $this->request->requestParams()
380
-        );
381
-        return ['order_by' => $orderby];
382
-    }
383
-
384
-
385
-    /**
386
-     * Sets up the limit for the registrations query.
387
-     *
388
-     * @param $per_page
389
-     * @return array
390
-     */
391
-    protected function getLimitClause($per_page)
392
-    {
393
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
394
-        $per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
395
-        // -1 means return all results so get out if that's set.
396
-        if ($per_page === -1) {
397
-            return [];
398
-        }
399
-        $offset = ($current_page - 1) * $per_page;
400
-        return ['limit' => [$offset, $per_page]];
401
-    }
24
+	/**
25
+	 * @var RequestInterface $request
26
+	 */
27
+	protected $request;
28
+
29
+	/**
30
+	 * @var EEM_Registration $registration_model
31
+	 */
32
+	protected $registration_model;
33
+
34
+	/**
35
+	 * @var string $view
36
+	 */
37
+	protected $view;
38
+
39
+	/**
40
+	 * @var array $where_params
41
+	 */
42
+	protected $where_params;
43
+
44
+
45
+	/**
46
+	 * QueryBuilder constructor.
47
+	 *
48
+	 * @param RequestInterface $request
49
+	 * @param EEM_Registration $registration_model
50
+	 * @param array            $extra_request_params
51
+	 */
52
+	public function __construct(
53
+		RequestInterface $request,
54
+		EEM_Registration $registration_model,
55
+		array $extra_request_params = []
56
+	) {
57
+		$this->request = $request;
58
+		$this->registration_model = $registration_model;
59
+		foreach ($extra_request_params as $key => $value) {
60
+			$this->request->setRequestParam($key, $value);
61
+		}
62
+		$this->view = $this->request->getRequestParam('status', '');
63
+		$this->where_params = [];
64
+	}
65
+
66
+
67
+	/**
68
+	 * Sets up the where conditions for the registrations query.
69
+	 *
70
+	 * @param int  $per_page
71
+	 * @param bool $count_query
72
+	 * @return array
73
+	 * @throws EE_Error
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 */
78
+	public function getQueryParams($per_page = 10, $count_query = false)
79
+	{
80
+		$query_params = [
81
+			0                          => $this->getWhereClause(),
82
+			'caps'                     => EEM_Registration::caps_read_admin,
83
+			'default_where_conditions' => 'this_model_only',
84
+		];
85
+		if (! $count_query) {
86
+			$query_params = array_merge(
87
+				$query_params,
88
+				$this->getOrderbyClause(),
89
+				$this->getLimitClause($per_page)
90
+			);
91
+		}
92
+
93
+		return $query_params;
94
+	}
95
+
96
+
97
+	/**
98
+	 * Sets up the where conditions for the registrations query.
99
+	 *
100
+	 * @return array
101
+	 * @throws EE_Error
102
+	 * @throws InvalidArgumentException
103
+	 * @throws InvalidDataTypeException
104
+	 * @throws InvalidInterfaceException
105
+	 */
106
+	protected function getWhereClause()
107
+	{
108
+		$this->addAttendeeIdToWhereConditions();
109
+		$this->addEventIdToWhereConditions();
110
+		$this->addCategoryIdToWhereConditions();
111
+		$this->addDatetimeIdToWhereConditions();
112
+		$this->addTicketIdToWhereConditions();
113
+		$this->addRegistrationStatusToWhereConditions();
114
+		$this->addDateToWhereConditions();
115
+		$this->addSearchToWhereConditions();
116
+		return apply_filters(
117
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
118
+			$this->where_params,
119
+			$this->request->requestParams()
120
+		);
121
+	}
122
+
123
+
124
+	/**
125
+	 * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
126
+	 */
127
+	protected function addAttendeeIdToWhereConditions()
128
+	{
129
+		$ATT_ID = $this->request->getRequestParam('attendee_id');
130
+		$ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID, 'int');
131
+		if ($ATT_ID) {
132
+			$this->where_params['ATT_ID'] = $ATT_ID;
133
+		}
134
+	}
135
+
136
+
137
+	/**
138
+	 * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
139
+	 */
140
+	protected function addEventIdToWhereConditions()
141
+	{
142
+		$EVT_ID = $this->request->getRequestParam('event_id');
143
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID, 'int');
144
+		if ($EVT_ID) {
145
+			$this->where_params['EVT_ID'] = $EVT_ID;
146
+		}
147
+	}
148
+
149
+
150
+	/**
151
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
152
+	 */
153
+	protected function addCategoryIdToWhereConditions()
154
+	{
155
+		$EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT', 0, 'int');
156
+		if ($EVT_CAT > 0) {
157
+			$this->where_params['Event.Term_Taxonomy.term_id'] = $EVT_CAT;
158
+		}
159
+	}
160
+
161
+
162
+	/**
163
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
164
+	 */
165
+	protected function addDatetimeIdToWhereConditions()
166
+	{
167
+		// first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
168
+		$DTT_ID = $this->request->getRequestParam('datetime_id');
169
+		$DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID, 'int');
170
+		if ($DTT_ID) {
171
+			$this->where_params['Ticket.Datetime.DTT_ID'] = $DTT_ID;
172
+		}
173
+	}
174
+
175
+
176
+	/**
177
+	 * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
178
+	 */
179
+	protected function addTicketIdToWhereConditions()
180
+	{
181
+		// first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
182
+		$TKT_ID = $this->request->getRequestParam('ticket_id');
183
+		$TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID, 'int');
184
+		if ($TKT_ID) {
185
+			$this->where_params['TKT_ID'] = $TKT_ID;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * Adds the correct registration status to the where conditions for the registrations query.
192
+	 * If filtering by registration status, then we show registrations matching that status.
193
+	 * If not filtering by specified status, then we show all registrations excluding incomplete registrations
194
+	 * UNLESS viewing trashed registrations.
195
+	 */
196
+	protected function addRegistrationStatusToWhereConditions()
197
+	{
198
+		$registration_status = $this->request->getRequestParam('_reg_status');
199
+		if ($registration_status) {
200
+			$this->where_params['STS_ID'] = sanitize_text_field($registration_status);
201
+			return;
202
+		}
203
+		// make sure we exclude incomplete registrations, but only if not trashed.
204
+		if ($this->view === 'trash') {
205
+			$this->where_params['REG_deleted'] = true;
206
+			return;
207
+		}
208
+		$this->where_params['STS_ID'] = $this->view === 'incomplete'
209
+			? EEM_Registration::status_id_incomplete
210
+			: ['!=', EEM_Registration::status_id_incomplete];
211
+	}
212
+
213
+
214
+	/**
215
+	 * Adds any provided date restraints to the where conditions for the registrations query.
216
+	 *
217
+	 * @throws EE_Error
218
+	 * @throws InvalidArgumentException
219
+	 * @throws InvalidDataTypeException
220
+	 * @throws InvalidInterfaceException
221
+	 */
222
+	protected function addDateToWhereConditions()
223
+	{
224
+		if ($this->view === 'today') {
225
+			$now = date('Y-m-d', current_time('timestamp'));
226
+			$this->where_params['REG_date'] = [
227
+				'BETWEEN',
228
+				[
229
+					$this->registration_model->convert_datetime_for_query(
230
+						'REG_date',
231
+						$now . ' 00:00:00',
232
+						'Y-m-d H:i:s'
233
+					),
234
+					$this->registration_model->convert_datetime_for_query(
235
+						'REG_date',
236
+						$now . ' 23:59:59',
237
+						'Y-m-d H:i:s'
238
+					),
239
+				],
240
+			];
241
+			return;
242
+		}
243
+		if ($this->view === 'month') {
244
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
245
+			$days_this_month = date('t', current_time('timestamp'));
246
+			$this->where_params['REG_date'] = [
247
+				'BETWEEN',
248
+				[
249
+					$this->registration_model->convert_datetime_for_query(
250
+						'REG_date',
251
+						$current_year_and_month . '-01 00:00:00',
252
+						'Y-m-d H:i:s'
253
+					),
254
+					$this->registration_model->convert_datetime_for_query(
255
+						'REG_date',
256
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
257
+						'Y-m-d H:i:s'
258
+					),
259
+				],
260
+			];
261
+			return;
262
+		}
263
+		$month_range = $this->request->getRequestParam('month_range');
264
+		if ($month_range) {
265
+			$month_range = sanitize_text_field($month_range);
266
+			$pieces = explode(' ', $month_range, 3);
267
+			$month_requested = ! empty($pieces[0])
268
+				? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
269
+				: '';
270
+			$year_requested = ! empty($pieces[1])
271
+				? $pieces[1]
272
+				: '';
273
+			// if there is not a month or year then we can't go further
274
+			if ($month_requested && $year_requested) {
275
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
276
+				$this->where_params['REG_date'] = [
277
+					'BETWEEN',
278
+					[
279
+						$this->registration_model->convert_datetime_for_query(
280
+							'REG_date',
281
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
282
+							'Y-m-d H:i:s'
283
+						),
284
+						$this->registration_model->convert_datetime_for_query(
285
+							'REG_date',
286
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
287
+							'Y-m-d H:i:s'
288
+						),
289
+					],
290
+				];
291
+			}
292
+		}
293
+	}
294
+
295
+
296
+	/**
297
+	 * Adds any provided search restraints to the where conditions for the registrations query
298
+	 */
299
+	protected function addSearchToWhereConditions()
300
+	{
301
+		$search = $this->request->getRequestParam('s');
302
+		if ($search) {
303
+			$search_string = '%' . sanitize_text_field($search) . '%';
304
+			$this->where_params['OR*search_conditions'] = [
305
+				'Event.EVT_name'                          => ['LIKE', $search_string],
306
+				'Event.EVT_desc'                          => ['LIKE', $search_string],
307
+				'Event.EVT_short_desc'                    => ['LIKE', $search_string],
308
+				'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
309
+				'Attendee.ATT_fname'                      => ['LIKE', $search_string],
310
+				'Attendee.ATT_lname'                      => ['LIKE', $search_string],
311
+				'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
312
+				'Attendee.ATT_email'                      => ['LIKE', $search_string],
313
+				'Attendee.ATT_address'                    => ['LIKE', $search_string],
314
+				'Attendee.ATT_address2'                   => ['LIKE', $search_string],
315
+				'Attendee.ATT_city'                       => ['LIKE', $search_string],
316
+				'REG_final_price'                         => ['LIKE', $search_string],
317
+				'REG_code'                                => ['LIKE', $search_string],
318
+				'REG_count'                               => ['LIKE', $search_string],
319
+				'REG_group_size'                          => ['LIKE', $search_string],
320
+				'Ticket.TKT_name'                         => ['LIKE', $search_string],
321
+				'Ticket.TKT_description'                  => ['LIKE', $search_string],
322
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
323
+			];
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * Sets up the orderby for the registrations query.
330
+	 *
331
+	 * @return array
332
+	 */
333
+	protected function getOrderbyClause()
334
+	{
335
+		$orderby_field = $this->request->getRequestParam('orderby');
336
+		$orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
337
+		switch ($orderby_field) {
338
+			case '_REG_ID':
339
+				$orderby = ['REG_ID'];
340
+				break;
341
+			case '_Reg_status':
342
+				$orderby = ['STS_ID'];
343
+				break;
344
+			case 'ATT_fname':
345
+				$orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
346
+				break;
347
+			case 'ATT_lname':
348
+				$orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
349
+				break;
350
+			case 'event_name':
351
+				$orderby = ['Event.EVT_name'];
352
+				break;
353
+			case 'DTT_EVT_start':
354
+				$orderby = ['Event.Datetime.DTT_EVT_start'];
355
+				break;
356
+			case '_REG_date':
357
+				$orderby = ['REG_date'];
358
+				break;
359
+			default:
360
+				$orderby = [$orderby_field];
361
+				break;
362
+		}
363
+		$order = $this->request->getRequestParam('order');
364
+		$order = $order ? sanitize_text_field($order) : 'DESC';
365
+
366
+		$orderby = array_combine(
367
+			$orderby,
368
+			array_fill(0, count($orderby), $order)
369
+		);
370
+		// because there are many registrations with the same date, define
371
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
372
+		if (empty($orderby['REG_ID'])) {
373
+			$orderby['REG_ID'] = $order;
374
+		}
375
+
376
+		$orderby = apply_filters(
377
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
378
+			$orderby,
379
+			$this->request->requestParams()
380
+		);
381
+		return ['order_by' => $orderby];
382
+	}
383
+
384
+
385
+	/**
386
+	 * Sets up the limit for the registrations query.
387
+	 *
388
+	 * @param $per_page
389
+	 * @return array
390
+	 */
391
+	protected function getLimitClause($per_page)
392
+	{
393
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
394
+		$per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
395
+		// -1 means return all results so get out if that's set.
396
+		if ($per_page === -1) {
397
+			return [];
398
+		}
399
+		$offset = ($current_page - 1) * $per_page;
400
+		return ['limit' => [$offset, $per_page]];
401
+	}
402 402
 }
Please login to merge, or discard this patch.
core/services/assets/AssetManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,7 @@
 block discarded – undo
176 176
         $version = ''
177 177
     ) {
178 178
         $dev_suffix = wp_scripts_get_suffix('dev');
179
-        $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
179
+        $vendor_path = $this->domain->pluginUrl().'assets/vendor/';
180 180
         return $this->addJavascript(
181 181
             $handle,
182 182
             "{$vendor_path}{$handle}{$dev_suffix}.js",
Please login to merge, or discard this patch.
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -23,284 +23,284 @@
 block discarded – undo
23 23
 abstract class AssetManager implements AssetManagerInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var AssetCollection $assets
28
-     */
29
-    protected $assets;
26
+	/**
27
+	 * @var AssetCollection $assets
28
+	 */
29
+	protected $assets;
30 30
 
31
-    /**
32
-     * @var DomainInterface
33
-     */
34
-    protected $domain;
31
+	/**
32
+	 * @var DomainInterface
33
+	 */
34
+	protected $domain;
35 35
 
36
-    /**
37
-     * @var Registry $registry
38
-     */
39
-    protected $registry;
36
+	/**
37
+	 * @var Registry $registry
38
+	 */
39
+	protected $registry;
40 40
 
41 41
 
42
-    /**
43
-     * AssetRegister constructor.
44
-     *
45
-     * @param DomainInterface $domain
46
-     * @param AssetCollection $assets
47
-     * @param Registry        $registry
48
-     */
49
-    public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)
50
-    {
51
-        $this->domain = $domain;
52
-        $this->assets = $assets;
53
-        $this->registry = $registry;
54
-        add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0);
55
-        add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0);
56
-        add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2);
57
-        add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2);
58
-    }
42
+	/**
43
+	 * AssetRegister constructor.
44
+	 *
45
+	 * @param DomainInterface $domain
46
+	 * @param AssetCollection $assets
47
+	 * @param Registry        $registry
48
+	 */
49
+	public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)
50
+	{
51
+		$this->domain = $domain;
52
+		$this->assets = $assets;
53
+		$this->registry = $registry;
54
+		add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0);
55
+		add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0);
56
+		add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2);
57
+		add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2);
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     * @since 4.9.71.p
63
-     * @return string
64
-     */
65
-    public function assetNamespace()
66
-    {
67
-        return $this->domain->assetNamespace();
68
-    }
61
+	/**
62
+	 * @since 4.9.71.p
63
+	 * @return string
64
+	 */
65
+	public function assetNamespace()
66
+	{
67
+		return $this->domain->assetNamespace();
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @return void
73
-     * @throws DuplicateCollectionIdentifierException
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidEntityException
76
-     * @since 4.9.62.p
77
-     */
78
-    public function addManifestFile()
79
-    {
80
-        // if a manifest file has already been added for this domain, then just return
81
-        if ($this->assets->has($this->domain->assetNamespace())) {
82
-            return;
83
-        }
84
-        $asset = new ManifestFile($this->domain);
85
-        $this->assets->add($asset, $this->domain->assetNamespace());
86
-    }
71
+	/**
72
+	 * @return void
73
+	 * @throws DuplicateCollectionIdentifierException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidEntityException
76
+	 * @since 4.9.62.p
77
+	 */
78
+	public function addManifestFile()
79
+	{
80
+		// if a manifest file has already been added for this domain, then just return
81
+		if ($this->assets->has($this->domain->assetNamespace())) {
82
+			return;
83
+		}
84
+		$asset = new ManifestFile($this->domain);
85
+		$this->assets->add($asset, $this->domain->assetNamespace());
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * @return ManifestFile[]
91
-     * @since 4.9.62.p
92
-     */
93
-    public function getManifestFile()
94
-    {
95
-        return $this->assets->getManifestFiles();
96
-    }
89
+	/**
90
+	 * @return ManifestFile[]
91
+	 * @since 4.9.62.p
92
+	 */
93
+	public function getManifestFile()
94
+	{
95
+		return $this->assets->getManifestFiles();
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * @param string $handle
101
-     * @param string $source
102
-     * @param array  $dependencies
103
-     * @param bool   $load_in_footer
104
-     * @param string $version
105
-     * @return JavascriptAsset
106
-     * @throws DuplicateCollectionIdentifierException
107
-     * @throws InvalidDataTypeException
108
-     * @throws InvalidEntityException
109
-     * @throws DomainException
110
-     * @since 4.9.62.p
111
-     */
112
-    public function addJavascript(
113
-        $handle,
114
-        $source,
115
-        array $dependencies = array(),
116
-        $load_in_footer = true,
117
-        $version = ''
118
-    ) {
119
-        $asset = new JavascriptAsset(
120
-            $handle,
121
-            $source,
122
-            array_unique($dependencies),
123
-            $load_in_footer,
124
-            $this->domain,
125
-            $version
126
-        );
127
-        $this->assets->add($asset, $handle);
128
-        return $asset;
129
-    }
99
+	/**
100
+	 * @param string $handle
101
+	 * @param string $source
102
+	 * @param array  $dependencies
103
+	 * @param bool   $load_in_footer
104
+	 * @param string $version
105
+	 * @return JavascriptAsset
106
+	 * @throws DuplicateCollectionIdentifierException
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws InvalidEntityException
109
+	 * @throws DomainException
110
+	 * @since 4.9.62.p
111
+	 */
112
+	public function addJavascript(
113
+		$handle,
114
+		$source,
115
+		array $dependencies = array(),
116
+		$load_in_footer = true,
117
+		$version = ''
118
+	) {
119
+		$asset = new JavascriptAsset(
120
+			$handle,
121
+			$source,
122
+			array_unique($dependencies),
123
+			$load_in_footer,
124
+			$this->domain,
125
+			$version
126
+		);
127
+		$this->assets->add($asset, $handle);
128
+		return $asset;
129
+	}
130 130
 
131 131
 
132
-    /**
133
-     * Used to register a javascript asset where everything is dynamically derived from the given handle.
134
-     *
135
-     * @param string       $handle
136
-     * @param string|array $extra_dependencies
137
-     * @return JavascriptAsset
138
-     * @throws DuplicateCollectionIdentifierException
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidEntityException
141
-     * @throws DomainException
142
-     */
143
-    public function addJs($handle, $extra_dependencies = [])
144
-    {
145
-        $details = $this->getAssetDetails(
146
-            Asset::TYPE_JS,
147
-            $handle,
148
-            $extra_dependencies
149
-        );
150
-        return $this->addJavascript(
151
-            $handle,
152
-            $this->registry->getJsUrl($this->domain->assetNamespace(), $handle),
153
-            $details['dependencies'],
154
-            true,
155
-            $details['version']
156
-        );
157
-    }
132
+	/**
133
+	 * Used to register a javascript asset where everything is dynamically derived from the given handle.
134
+	 *
135
+	 * @param string       $handle
136
+	 * @param string|array $extra_dependencies
137
+	 * @return JavascriptAsset
138
+	 * @throws DuplicateCollectionIdentifierException
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidEntityException
141
+	 * @throws DomainException
142
+	 */
143
+	public function addJs($handle, $extra_dependencies = [])
144
+	{
145
+		$details = $this->getAssetDetails(
146
+			Asset::TYPE_JS,
147
+			$handle,
148
+			$extra_dependencies
149
+		);
150
+		return $this->addJavascript(
151
+			$handle,
152
+			$this->registry->getJsUrl($this->domain->assetNamespace(), $handle),
153
+			$details['dependencies'],
154
+			true,
155
+			$details['version']
156
+		);
157
+	}
158 158
 
159 159
 
160
-    /**
161
-     * @param string $handle
162
-     * @param array  $dependencies
163
-     * @param bool   $load_in_footer
164
-     * @param string $version
165
-     * @return JavascriptAsset
166
-     * @throws DomainException
167
-     * @throws DuplicateCollectionIdentifierException
168
-     * @throws InvalidDataTypeException
169
-     * @throws InvalidEntityException
170
-     * @since 4.9.71.p
171
-     */
172
-    public function addVendorJavascript(
173
-        $handle,
174
-        array $dependencies = array(),
175
-        $load_in_footer = true,
176
-        $version = ''
177
-    ) {
178
-        $dev_suffix = wp_scripts_get_suffix('dev');
179
-        $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
180
-        return $this->addJavascript(
181
-            $handle,
182
-            "{$vendor_path}{$handle}{$dev_suffix}.js",
183
-            $dependencies,
184
-            $load_in_footer,
185
-            $version
186
-        );
187
-    }
160
+	/**
161
+	 * @param string $handle
162
+	 * @param array  $dependencies
163
+	 * @param bool   $load_in_footer
164
+	 * @param string $version
165
+	 * @return JavascriptAsset
166
+	 * @throws DomainException
167
+	 * @throws DuplicateCollectionIdentifierException
168
+	 * @throws InvalidDataTypeException
169
+	 * @throws InvalidEntityException
170
+	 * @since 4.9.71.p
171
+	 */
172
+	public function addVendorJavascript(
173
+		$handle,
174
+		array $dependencies = array(),
175
+		$load_in_footer = true,
176
+		$version = ''
177
+	) {
178
+		$dev_suffix = wp_scripts_get_suffix('dev');
179
+		$vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
180
+		return $this->addJavascript(
181
+			$handle,
182
+			"{$vendor_path}{$handle}{$dev_suffix}.js",
183
+			$dependencies,
184
+			$load_in_footer,
185
+			$version
186
+		);
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * @param string $handle
192
-     * @param string $source
193
-     * @param array  $dependencies
194
-     * @param string $media
195
-     * @param string $version
196
-     * @return StylesheetAsset
197
-     * @throws DomainException
198
-     * @throws DuplicateCollectionIdentifierException
199
-     * @throws InvalidDataTypeException
200
-     * @throws InvalidEntityException
201
-     * @since 4.9.62.p
202
-     */
203
-    public function addStylesheet(
204
-        $handle,
205
-        $source,
206
-        array $dependencies = array(),
207
-        $media = 'all',
208
-        $version = ''
209
-    ) {
210
-        $asset = new StylesheetAsset(
211
-            $handle,
212
-            $source,
213
-            array_unique($dependencies),
214
-            $this->domain,
215
-            $media,
216
-            $version
217
-        );
218
-        $this->assets->add($asset, $handle);
219
-        return $asset;
220
-    }
190
+	/**
191
+	 * @param string $handle
192
+	 * @param string $source
193
+	 * @param array  $dependencies
194
+	 * @param string $media
195
+	 * @param string $version
196
+	 * @return StylesheetAsset
197
+	 * @throws DomainException
198
+	 * @throws DuplicateCollectionIdentifierException
199
+	 * @throws InvalidDataTypeException
200
+	 * @throws InvalidEntityException
201
+	 * @since 4.9.62.p
202
+	 */
203
+	public function addStylesheet(
204
+		$handle,
205
+		$source,
206
+		array $dependencies = array(),
207
+		$media = 'all',
208
+		$version = ''
209
+	) {
210
+		$asset = new StylesheetAsset(
211
+			$handle,
212
+			$source,
213
+			array_unique($dependencies),
214
+			$this->domain,
215
+			$media,
216
+			$version
217
+		);
218
+		$this->assets->add($asset, $handle);
219
+		return $asset;
220
+	}
221 221
 
222 222
 
223
-    /**
224
-     * Used to register a css asset where everything is dynamically derived from the given handle.
225
-     *
226
-     * @param string       $handle
227
-     * @param string|array $extra_dependencies
228
-     * @return StylesheetAsset
229
-     * @throws DuplicateCollectionIdentifierException
230
-     * @throws InvalidDataTypeException
231
-     * @throws InvalidEntityException
232
-     * @throws DomainException
233
-     */
234
-    public function addCss($handle, $extra_dependencies = [])
235
-    {
236
-        $details = $this->getAssetDetails(
237
-            Asset::TYPE_CSS,
238
-            $handle,
239
-            $extra_dependencies
240
-        );
241
-        return $this->addStylesheet(
242
-            $handle,
243
-            $this->registry->getCssUrl($this->domain->assetNamespace(), $handle),
244
-            $details['dependencies'],
245
-            'all',
246
-            $details['version']
247
-        );
248
-    }
223
+	/**
224
+	 * Used to register a css asset where everything is dynamically derived from the given handle.
225
+	 *
226
+	 * @param string       $handle
227
+	 * @param string|array $extra_dependencies
228
+	 * @return StylesheetAsset
229
+	 * @throws DuplicateCollectionIdentifierException
230
+	 * @throws InvalidDataTypeException
231
+	 * @throws InvalidEntityException
232
+	 * @throws DomainException
233
+	 */
234
+	public function addCss($handle, $extra_dependencies = [])
235
+	{
236
+		$details = $this->getAssetDetails(
237
+			Asset::TYPE_CSS,
238
+			$handle,
239
+			$extra_dependencies
240
+		);
241
+		return $this->addStylesheet(
242
+			$handle,
243
+			$this->registry->getCssUrl($this->domain->assetNamespace(), $handle),
244
+			$details['dependencies'],
245
+			'all',
246
+			$details['version']
247
+		);
248
+	}
249 249
 
250 250
 
251
-    /**
252
-     * @param string $handle
253
-     * @return bool
254
-     * @since 4.9.62.p
255
-     */
256
-    public function enqueueAsset($handle)
257
-    {
258
-        if ($this->assets->has($handle)) {
259
-            $asset = $this->assets->get($handle);
260
-            if ($asset->isRegistered()) {
261
-                $asset->enqueueAsset();
262
-                return true;
263
-            }
264
-        }
265
-        return false;
266
-    }
251
+	/**
252
+	 * @param string $handle
253
+	 * @return bool
254
+	 * @since 4.9.62.p
255
+	 */
256
+	public function enqueueAsset($handle)
257
+	{
258
+		if ($this->assets->has($handle)) {
259
+			$asset = $this->assets->get($handle);
260
+			if ($asset->isRegistered()) {
261
+				$asset->enqueueAsset();
262
+				return true;
263
+			}
264
+		}
265
+		return false;
266
+	}
267 267
 
268 268
 
269
-    /**
270
-     * @param string $asset_type
271
-     * @param string $handle
272
-     * @param array  $extra_dependencies
273
-     * @return array
274
-     * @since 4.10.2.p
275
-     */
276
-    private function getAssetDetails($asset_type, $handle, $extra_dependencies = [])
277
-    {
278
-        $getAssetDetails = '';
279
-        switch ($asset_type) {
280
-            case Asset::TYPE_JS :
281
-                $getAssetDetails = 'getJsAssetDetails';
282
-                break;
283
-            case Asset::TYPE_CSS :
284
-                $getAssetDetails = 'getCssAssetDetails';
285
-                break;
286
-        }
287
-        if ($getAssetDetails === '') {
288
-            return ['dependencies' => [], 'version' => ''];
289
-        }
290
-        $details = $this->registry->$getAssetDetails(
291
-            $this->domain->assetNamespace(),
292
-            $handle
293
-        );
294
-        $details['dependencies'] = isset($details['dependencies'])
295
-            ? $details['dependencies']
296
-            : [];
297
-        $details['version'] = isset($details['version'])
298
-            ? $details['version']
299
-            : '';
300
-        $details['dependencies'] = ! empty($extra_dependencies)
301
-            ? array_merge($details['dependencies'], (array) $extra_dependencies)
302
-            : $details['dependencies'];
303
-        return $details;
269
+	/**
270
+	 * @param string $asset_type
271
+	 * @param string $handle
272
+	 * @param array  $extra_dependencies
273
+	 * @return array
274
+	 * @since 4.10.2.p
275
+	 */
276
+	private function getAssetDetails($asset_type, $handle, $extra_dependencies = [])
277
+	{
278
+		$getAssetDetails = '';
279
+		switch ($asset_type) {
280
+			case Asset::TYPE_JS :
281
+				$getAssetDetails = 'getJsAssetDetails';
282
+				break;
283
+			case Asset::TYPE_CSS :
284
+				$getAssetDetails = 'getCssAssetDetails';
285
+				break;
286
+		}
287
+		if ($getAssetDetails === '') {
288
+			return ['dependencies' => [], 'version' => ''];
289
+		}
290
+		$details = $this->registry->$getAssetDetails(
291
+			$this->domain->assetNamespace(),
292
+			$handle
293
+		);
294
+		$details['dependencies'] = isset($details['dependencies'])
295
+			? $details['dependencies']
296
+			: [];
297
+		$details['version'] = isset($details['version'])
298
+			? $details['version']
299
+			: '';
300
+		$details['dependencies'] = ! empty($extra_dependencies)
301
+			? array_merge($details['dependencies'], (array) $extra_dependencies)
302
+			: $details['dependencies'];
303
+		return $details;
304 304
 
305
-    }
305
+	}
306 306
 }
Please login to merge, or discard this patch.
core/domain/values/assets/BrowserAsset.php 2 patches
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -17,148 +17,148 @@
 block discarded – undo
17 17
 abstract class BrowserAsset extends Asset
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $source
22
-     */
23
-    private $source;
24
-
25
-    /**
26
-     * @var array $dependencies
27
-     */
28
-    private $dependencies;
29
-
30
-    /**
31
-     * @var string $version
32
-     */
33
-    private $version;
34
-
35
-
36
-    /**
37
-     * Asset constructor.
38
-     *
39
-     * @param string          $type
40
-     * @param string          $handle
41
-     * @param string          $source
42
-     * @param array           $dependencies
43
-     * @param DomainInterface $domain
44
-     * @param string          $version
45
-     * @throws DomainException
46
-     * @throws InvalidDataTypeException
47
-     */
48
-    public function __construct($type, $handle, $source, array $dependencies, DomainInterface $domain, $version = '')
49
-    {
50
-        parent::__construct($type, $handle, $domain);
51
-        $this->setSource($source);
52
-        $this->setDependencies($dependencies);
53
-        $this->setVersion($version, false);
54
-    }
55
-
56
-
57
-    /**
58
-     * @since 4.9.62.p
59
-     */
60
-    abstract public function enqueueAsset();
61
-
62
-
63
-    /**
64
-     * @return array
65
-     */
66
-    public function dependencies()
67
-    {
68
-        return $this->dependencies;
69
-    }
70
-
71
-
72
-    /**
73
-     * @param array $dependencies
74
-     */
75
-    private function setDependencies(array $dependencies)
76
-    {
77
-        $this->dependencies = $dependencies;
78
-    }
79
-
80
-
81
-    /**
82
-     * @since 4.9.62.p
83
-     * @return bool
84
-     */
85
-    public function hasDependencies()
86
-    {
87
-        return count($this->dependencies) > 0;
88
-    }
89
-
90
-
91
-    /**
92
-     * @return string
93
-     */
94
-    public function source()
95
-    {
96
-        return $this->source;
97
-    }
98
-
99
-
100
-    /**
101
-     * @param string $source
102
-     * @throws InvalidDataTypeException
103
-     */
104
-    private function setSource($source)
105
-    {
106
-        if (! is_string($source)) {
107
-            throw new InvalidDataTypeException(
108
-                '$source',
109
-                $source,
110
-                'string'
111
-            );
112
-        }
113
-        $this->source = $source;
114
-    }
115
-
116
-
117
-    /**
118
-     * @return string
119
-     * @throws InvalidDataTypeException
120
-     * @throws DomainException
121
-     */
122
-    public function version()
123
-    {
124
-        return $this->version;
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string $version
130
-     * @param bool   $fluent
131
-     * @return BrowserAsset|null
132
-     * @throws DomainException
133
-     * @throws InvalidDataTypeException
134
-     */
135
-    public function setVersion($version, $fluent = true)
136
-    {
137
-        // if version is NOT set and this asset was NOT built for distribution,
138
-        // then set the version equal to the EE core plugin version
139
-        if (empty($version) && ! $this->isBuiltDistributionSource()) {
140
-            $version = $this->domain->version();
141
-        }
142
-        if (! is_string($version)) {
143
-            throw new InvalidDataTypeException(
144
-                '$version',
145
-                $version,
146
-                'string'
147
-            );
148
-        }
149
-        $this->version = $version;
150
-        if ($fluent) {
151
-            return $this;
152
-        }
153
-        return null;
154
-    }
155
-
156
-
157
-    /**
158
-     * @return bool
159
-     */
160
-    public function isBuiltDistributionSource() {
161
-        return substr($this->source, -8) === Asset::FILE_EXTENSION_DISTRIBUTION_JS
162
-               || substr($this->source, -9) === Asset::FILE_EXTENSION_DISTRIBUTION_CSS;
163
-    }
20
+	/**
21
+	 * @var string $source
22
+	 */
23
+	private $source;
24
+
25
+	/**
26
+	 * @var array $dependencies
27
+	 */
28
+	private $dependencies;
29
+
30
+	/**
31
+	 * @var string $version
32
+	 */
33
+	private $version;
34
+
35
+
36
+	/**
37
+	 * Asset constructor.
38
+	 *
39
+	 * @param string          $type
40
+	 * @param string          $handle
41
+	 * @param string          $source
42
+	 * @param array           $dependencies
43
+	 * @param DomainInterface $domain
44
+	 * @param string          $version
45
+	 * @throws DomainException
46
+	 * @throws InvalidDataTypeException
47
+	 */
48
+	public function __construct($type, $handle, $source, array $dependencies, DomainInterface $domain, $version = '')
49
+	{
50
+		parent::__construct($type, $handle, $domain);
51
+		$this->setSource($source);
52
+		$this->setDependencies($dependencies);
53
+		$this->setVersion($version, false);
54
+	}
55
+
56
+
57
+	/**
58
+	 * @since 4.9.62.p
59
+	 */
60
+	abstract public function enqueueAsset();
61
+
62
+
63
+	/**
64
+	 * @return array
65
+	 */
66
+	public function dependencies()
67
+	{
68
+		return $this->dependencies;
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param array $dependencies
74
+	 */
75
+	private function setDependencies(array $dependencies)
76
+	{
77
+		$this->dependencies = $dependencies;
78
+	}
79
+
80
+
81
+	/**
82
+	 * @since 4.9.62.p
83
+	 * @return bool
84
+	 */
85
+	public function hasDependencies()
86
+	{
87
+		return count($this->dependencies) > 0;
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return string
93
+	 */
94
+	public function source()
95
+	{
96
+		return $this->source;
97
+	}
98
+
99
+
100
+	/**
101
+	 * @param string $source
102
+	 * @throws InvalidDataTypeException
103
+	 */
104
+	private function setSource($source)
105
+	{
106
+		if (! is_string($source)) {
107
+			throw new InvalidDataTypeException(
108
+				'$source',
109
+				$source,
110
+				'string'
111
+			);
112
+		}
113
+		$this->source = $source;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @return string
119
+	 * @throws InvalidDataTypeException
120
+	 * @throws DomainException
121
+	 */
122
+	public function version()
123
+	{
124
+		return $this->version;
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string $version
130
+	 * @param bool   $fluent
131
+	 * @return BrowserAsset|null
132
+	 * @throws DomainException
133
+	 * @throws InvalidDataTypeException
134
+	 */
135
+	public function setVersion($version, $fluent = true)
136
+	{
137
+		// if version is NOT set and this asset was NOT built for distribution,
138
+		// then set the version equal to the EE core plugin version
139
+		if (empty($version) && ! $this->isBuiltDistributionSource()) {
140
+			$version = $this->domain->version();
141
+		}
142
+		if (! is_string($version)) {
143
+			throw new InvalidDataTypeException(
144
+				'$version',
145
+				$version,
146
+				'string'
147
+			);
148
+		}
149
+		$this->version = $version;
150
+		if ($fluent) {
151
+			return $this;
152
+		}
153
+		return null;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @return bool
159
+	 */
160
+	public function isBuiltDistributionSource() {
161
+		return substr($this->source, -8) === Asset::FILE_EXTENSION_DISTRIBUTION_JS
162
+			   || substr($this->source, -9) === Asset::FILE_EXTENSION_DISTRIBUTION_CSS;
163
+	}
164 164
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     private function setSource($source)
105 105
     {
106
-        if (! is_string($source)) {
106
+        if ( ! is_string($source)) {
107 107
             throw new InvalidDataTypeException(
108 108
                 '$source',
109 109
                 $source,
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         if (empty($version) && ! $this->isBuiltDistributionSource()) {
140 140
             $version = $this->domain->version();
141 141
         }
142
-        if (! is_string($version)) {
142
+        if ( ! is_string($version)) {
143 143
             throw new InvalidDataTypeException(
144 144
                 '$version',
145 145
                 $version,
Please login to merge, or discard this patch.