@@ -19,7 +19,7 @@ |
||
19 | 19 | public function __construct($table_column, $nicename, $nullable, $default_value = null) |
20 | 20 | { |
21 | 21 | parent::__construct($table_column, $nicename, $nullable, $default_value); |
22 | - $this->setSchemaType(array('object','string')); |
|
22 | + $this->setSchemaType(array('object', 'string')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 |
@@ -8,73 +8,73 @@ |
||
8 | 8 | */ |
9 | 9 | class EE_Serialized_Text_Field extends EE_Text_Field_Base |
10 | 10 | { |
11 | - /** |
|
12 | - * @param string $table_column |
|
13 | - * @param string $nicename |
|
14 | - * @param bool $nullable |
|
15 | - * @param null $default_value |
|
16 | - */ |
|
17 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
18 | - { |
|
19 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
20 | - $this->setSchemaType(array('object','string')); |
|
21 | - } |
|
11 | + /** |
|
12 | + * @param string $table_column |
|
13 | + * @param string $nicename |
|
14 | + * @param bool $nullable |
|
15 | + * @param null $default_value |
|
16 | + */ |
|
17 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
18 | + { |
|
19 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
20 | + $this->setSchemaType(array('object','string')); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * Value SHOULD be an array, and we want to now convert it to a serialized string |
|
26 | - * |
|
27 | - * @param array $value_of_field_on_model_object |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
31 | - { |
|
32 | - return maybe_serialize($value_of_field_on_model_object); |
|
33 | - } |
|
24 | + /** |
|
25 | + * Value SHOULD be an array, and we want to now convert it to a serialized string |
|
26 | + * |
|
27 | + * @param array $value_of_field_on_model_object |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
31 | + { |
|
32 | + return maybe_serialize($value_of_field_on_model_object); |
|
33 | + } |
|
34 | 34 | |
35 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
36 | - { |
|
37 | - $value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object); |
|
38 | - if (is_string($value_inputted_for_field_on_model_object)) { |
|
39 | - return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
40 | - } |
|
41 | - if (is_array($value_inputted_for_field_on_model_object)) { |
|
42 | - return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object); |
|
43 | - } |
|
44 | - // so they passed NULL or an INT or something wack |
|
45 | - return $value_inputted_for_field_on_model_object; |
|
46 | - } |
|
35 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
36 | + { |
|
37 | + $value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object); |
|
38 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
39 | + return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
40 | + } |
|
41 | + if (is_array($value_inputted_for_field_on_model_object)) { |
|
42 | + return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object); |
|
43 | + } |
|
44 | + // so they passed NULL or an INT or something wack |
|
45 | + return $value_inputted_for_field_on_model_object; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Value provided should definetely be a serialized string. We should unserialize into an array |
|
50 | - * |
|
51 | - * @param string $value_found_in_db_for_model_object |
|
52 | - * @return array |
|
53 | - */ |
|
54 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
55 | - { |
|
56 | - return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object); |
|
57 | - } |
|
48 | + /** |
|
49 | + * Value provided should definetely be a serialized string. We should unserialize into an array |
|
50 | + * |
|
51 | + * @param string $value_found_in_db_for_model_object |
|
52 | + * @return array |
|
53 | + */ |
|
54 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
55 | + { |
|
56 | + return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Gets a string representation of the array |
|
61 | - * |
|
62 | - * @param mixed $value_on_field_to_be_outputted |
|
63 | - * @param string|null $schema , possible values are ',', others can be added |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null) |
|
67 | - { |
|
68 | - switch ($schema) { |
|
69 | - case 'print_r': |
|
70 | - $pretty_value = print_r($value_on_field_to_be_outputted, true); |
|
71 | - break; |
|
72 | - case 'as_table': |
|
73 | - $pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted); |
|
74 | - break; |
|
75 | - default: |
|
76 | - $pretty_value = implode(", ", $value_on_field_to_be_outputted); |
|
77 | - } |
|
78 | - return $pretty_value; |
|
79 | - } |
|
59 | + /** |
|
60 | + * Gets a string representation of the array |
|
61 | + * |
|
62 | + * @param mixed $value_on_field_to_be_outputted |
|
63 | + * @param string|null $schema , possible values are ',', others can be added |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null) |
|
67 | + { |
|
68 | + switch ($schema) { |
|
69 | + case 'print_r': |
|
70 | + $pretty_value = print_r($value_on_field_to_be_outputted, true); |
|
71 | + break; |
|
72 | + case 'as_table': |
|
73 | + $pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted); |
|
74 | + break; |
|
75 | + default: |
|
76 | + $pretty_value = implode(", ", $value_on_field_to_be_outputted); |
|
77 | + } |
|
78 | + return $pretty_value; |
|
79 | + } |
|
80 | 80 | } |
@@ -3,16 +3,16 @@ |
||
3 | 3 | |
4 | 4 | class EE_DB_Only_Float_Field extends EE_DB_Only_Field_Base |
5 | 5 | { |
6 | - /** |
|
7 | - * @param string $table_column |
|
8 | - * @param string $nicename |
|
9 | - * @param bool $nullable |
|
10 | - * @param null $default_value |
|
11 | - */ |
|
12 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
13 | - { |
|
14 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
15 | - $this->setSchemaType('number'); |
|
16 | - } |
|
6 | + /** |
|
7 | + * @param string $table_column |
|
8 | + * @param string $nicename |
|
9 | + * @param bool $nullable |
|
10 | + * @param null $default_value |
|
11 | + */ |
|
12 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
13 | + { |
|
14 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
15 | + $this->setSchemaType('number'); |
|
16 | + } |
|
17 | 17 | |
18 | 18 | } |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | <div id="espresso-event-details-dv" class="" > |
20 | 20 | <?php |
21 | 21 | // Start the Loop. |
22 | - while ( have_posts() ) : the_post(); |
|
22 | + while (have_posts()) : the_post(); |
|
23 | 23 | // Include the post TYPE-specific template for the content. |
24 | - espresso_get_template_part( 'content', 'espresso_events' ); |
|
24 | + espresso_get_template_part('content', 'espresso_events'); |
|
25 | 25 | // If comments are open or we have at least one comment, load up the comment template. |
26 | - if ( comments_open() || get_comments_number() ) { |
|
26 | + if (comments_open() || get_comments_number()) { |
|
27 | 27 | comments_template(); |
28 | 28 | } |
29 | 29 | endwhile; |
@@ -35,6 +35,6 @@ discard block |
||
35 | 35 | </div><!-- #primary --> |
36 | 36 | |
37 | 37 | <?php |
38 | -get_sidebar( 'content' ); |
|
38 | +get_sidebar('content'); |
|
39 | 39 | get_sidebar(); |
40 | 40 | get_footer(); |
41 | 41 | \ No newline at end of file |
@@ -57,7 +57,7 @@ |
||
57 | 57 | public function getCapCheck() |
58 | 58 | { |
59 | 59 | // need cap for non-AJAX admin requests |
60 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
60 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
61 | 61 | // there's no specific caps for editing/creating transactions, |
62 | 62 | // so that's why we are using ee_edit_registrations |
63 | 63 | return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
@@ -20,60 +20,60 @@ |
||
20 | 20 | */ |
21 | 21 | class CreateTransactionCommand extends Command implements CommandRequiresCapCheckInterface |
22 | 22 | { |
23 | - /** |
|
24 | - * @var EE_Checkout $checkout |
|
25 | - */ |
|
26 | - protected $checkout; |
|
23 | + /** |
|
24 | + * @var EE_Checkout $checkout |
|
25 | + */ |
|
26 | + protected $checkout; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var array $transaction_details |
|
30 | - */ |
|
31 | - protected $transaction_details; |
|
28 | + /** |
|
29 | + * @var array $transaction_details |
|
30 | + */ |
|
31 | + protected $transaction_details; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * CreateTransactionCommand constructor. |
|
36 | - * |
|
37 | - * @param EE_Checkout $checkout |
|
38 | - * @param array $transaction_details |
|
39 | - */ |
|
40 | - public function __construct(EE_Checkout $checkout = null, array $transaction_details = array()) |
|
41 | - { |
|
42 | - $this->checkout = $checkout; |
|
43 | - $this->transaction_details = $transaction_details; |
|
44 | - } |
|
34 | + /** |
|
35 | + * CreateTransactionCommand constructor. |
|
36 | + * |
|
37 | + * @param EE_Checkout $checkout |
|
38 | + * @param array $transaction_details |
|
39 | + */ |
|
40 | + public function __construct(EE_Checkout $checkout = null, array $transaction_details = array()) |
|
41 | + { |
|
42 | + $this->checkout = $checkout; |
|
43 | + $this->transaction_details = $transaction_details; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @return CapCheckInterface |
|
49 | - * @throws InvalidDataTypeException |
|
50 | - */ |
|
51 | - public function getCapCheck() |
|
52 | - { |
|
53 | - // need cap for non-AJAX admin requests |
|
54 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
55 | - // there's no specific caps for editing/creating transactions, |
|
56 | - // so that's why we are using ee_edit_registrations |
|
57 | - return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
|
58 | - } |
|
59 | - return new PublicCapabilities('', 'create_new_transaction'); |
|
60 | - } |
|
47 | + /** |
|
48 | + * @return CapCheckInterface |
|
49 | + * @throws InvalidDataTypeException |
|
50 | + */ |
|
51 | + public function getCapCheck() |
|
52 | + { |
|
53 | + // need cap for non-AJAX admin requests |
|
54 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
55 | + // there's no specific caps for editing/creating transactions, |
|
56 | + // so that's why we are using ee_edit_registrations |
|
57 | + return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
|
58 | + } |
|
59 | + return new PublicCapabilities('', 'create_new_transaction'); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return EE_Checkout |
|
65 | - */ |
|
66 | - public function checkout() |
|
67 | - { |
|
68 | - return $this->checkout; |
|
69 | - } |
|
63 | + /** |
|
64 | + * @return EE_Checkout |
|
65 | + */ |
|
66 | + public function checkout() |
|
67 | + { |
|
68 | + return $this->checkout; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function transactionDetails() |
|
76 | - { |
|
77 | - return $this->transaction_details; |
|
78 | - } |
|
72 | + /** |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function transactionDetails() |
|
76 | + { |
|
77 | + return $this->transaction_details; |
|
78 | + } |
|
79 | 79 | } |
@@ -81,7 +81,7 @@ |
||
81 | 81 | public function getCapCheck() |
82 | 82 | { |
83 | 83 | // need cap for non-AJAX admin requests |
84 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
84 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
85 | 85 | return new CapCheck('ee_edit_contacts', 'create_new_contact'); |
86 | 86 | } |
87 | 87 | return new PublicCapabilities('', 'create_new_contact'); |
@@ -19,62 +19,62 @@ |
||
19 | 19 | */ |
20 | 20 | class CreateAttendeeCommand extends Command implements CommandRequiresCapCheckInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * array of details where keys are names of EEM_Attendee model fields |
|
24 | - * |
|
25 | - * @var array $attendee_details |
|
26 | - */ |
|
27 | - protected $attendee_details; |
|
22 | + /** |
|
23 | + * array of details where keys are names of EEM_Attendee model fields |
|
24 | + * |
|
25 | + * @var array $attendee_details |
|
26 | + */ |
|
27 | + protected $attendee_details; |
|
28 | 28 | |
29 | - /** |
|
30 | - * an existing registration to associate this attendee with |
|
31 | - * |
|
32 | - * @var EE_Registration $registration |
|
33 | - */ |
|
34 | - protected $registration; |
|
29 | + /** |
|
30 | + * an existing registration to associate this attendee with |
|
31 | + * |
|
32 | + * @var EE_Registration $registration |
|
33 | + */ |
|
34 | + protected $registration; |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * CreateAttendeeCommand constructor. |
|
39 | - * |
|
40 | - * @param array $attendee_details |
|
41 | - * @param EE_Registration $registration |
|
42 | - */ |
|
43 | - public function __construct(array $attendee_details, EE_Registration $registration) |
|
44 | - { |
|
45 | - $this->attendee_details = $attendee_details; |
|
46 | - $this->registration = $registration; |
|
47 | - } |
|
37 | + /** |
|
38 | + * CreateAttendeeCommand constructor. |
|
39 | + * |
|
40 | + * @param array $attendee_details |
|
41 | + * @param EE_Registration $registration |
|
42 | + */ |
|
43 | + public function __construct(array $attendee_details, EE_Registration $registration) |
|
44 | + { |
|
45 | + $this->attendee_details = $attendee_details; |
|
46 | + $this->registration = $registration; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @return array |
|
52 | - */ |
|
53 | - public function attendeeDetails() |
|
54 | - { |
|
55 | - return $this->attendee_details; |
|
56 | - } |
|
50 | + /** |
|
51 | + * @return array |
|
52 | + */ |
|
53 | + public function attendeeDetails() |
|
54 | + { |
|
55 | + return $this->attendee_details; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return EE_Registration |
|
61 | - */ |
|
62 | - public function registration() |
|
63 | - { |
|
64 | - return $this->registration; |
|
65 | - } |
|
59 | + /** |
|
60 | + * @return EE_Registration |
|
61 | + */ |
|
62 | + public function registration() |
|
63 | + { |
|
64 | + return $this->registration; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return CapCheckInterface |
|
70 | - * @throws InvalidDataTypeException |
|
71 | - */ |
|
72 | - public function getCapCheck() |
|
73 | - { |
|
74 | - // need cap for non-AJAX admin requests |
|
75 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
76 | - return new CapCheck('ee_edit_contacts', 'create_new_contact'); |
|
77 | - } |
|
78 | - return new PublicCapabilities('', 'create_new_contact'); |
|
79 | - } |
|
68 | + /** |
|
69 | + * @return CapCheckInterface |
|
70 | + * @throws InvalidDataTypeException |
|
71 | + */ |
|
72 | + public function getCapCheck() |
|
73 | + { |
|
74 | + // need cap for non-AJAX admin requests |
|
75 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
76 | + return new CapCheck('ee_edit_contacts', 'create_new_contact'); |
|
77 | + } |
|
78 | + return new PublicCapabilities('', 'create_new_contact'); |
|
79 | + } |
|
80 | 80 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <p> |
2 | 2 | <?php esc_html_e( |
3 | - 'Use this to control what the default will be for maximum tickets on an order when creating a new event.', |
|
4 | - 'event_espresso' |
|
5 | - ); ?> |
|
3 | + 'Use this to control what the default will be for maximum tickets on an order when creating a new event.', |
|
4 | + 'event_espresso' |
|
5 | + ); ?> |
|
6 | 6 | </p> |
7 | 7 | \ No newline at end of file |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
44 | 44 | foreach ($notices->getError() as $notice) { |
45 | 45 | if ($this->getThrowExceptions()) { |
46 | - $error_string .= '<br />' . $notice->message(); |
|
46 | + $error_string .= '<br />'.$notice->message(); |
|
47 | 47 | } else { |
48 | 48 | EE_Error::add_error( |
49 | 49 | $notice->message(), |
@@ -13,54 +13,54 @@ |
||
13 | 13 | */ |
14 | 14 | class ConvertNoticesToEeErrors extends NoticeConverter |
15 | 15 | { |
16 | - /** |
|
17 | - * Converts Notice objects into EE_Error notifications |
|
18 | - * |
|
19 | - * @param NoticesContainerInterface $notices |
|
20 | - * @throws EE_Error |
|
21 | - */ |
|
22 | - public function process(NoticesContainerInterface $notices) |
|
23 | - { |
|
24 | - $this->setNotices($notices); |
|
25 | - $notices = $this->getNotices(); |
|
26 | - if ($notices->hasAttention()) { |
|
27 | - foreach ($notices->getAttention() as $notice) { |
|
28 | - EE_Error::add_attention( |
|
29 | - $notice->message(), |
|
30 | - $notice->file(), |
|
31 | - $notice->func(), |
|
32 | - $notice->line() |
|
33 | - ); |
|
34 | - } |
|
35 | - } |
|
36 | - if ($notices->hasError()) { |
|
37 | - $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
38 | - foreach ($notices->getError() as $notice) { |
|
39 | - if ($this->getThrowExceptions()) { |
|
40 | - $error_string .= '<br />' . $notice->message(); |
|
41 | - } else { |
|
42 | - EE_Error::add_error( |
|
43 | - $notice->message(), |
|
44 | - $notice->file(), |
|
45 | - $notice->func(), |
|
46 | - $notice->line() |
|
47 | - ); |
|
48 | - } |
|
49 | - } |
|
50 | - if ($this->getThrowExceptions()) { |
|
51 | - throw new EE_Error($error_string); |
|
52 | - } |
|
53 | - } |
|
54 | - if ($notices->hasSuccess()) { |
|
55 | - foreach ($notices->getSuccess() as $notice) { |
|
56 | - EE_Error::add_success( |
|
57 | - $notice->message(), |
|
58 | - $notice->file(), |
|
59 | - $notice->func(), |
|
60 | - $notice->line() |
|
61 | - ); |
|
62 | - } |
|
63 | - } |
|
64 | - $this->clearNotices(); |
|
65 | - } |
|
16 | + /** |
|
17 | + * Converts Notice objects into EE_Error notifications |
|
18 | + * |
|
19 | + * @param NoticesContainerInterface $notices |
|
20 | + * @throws EE_Error |
|
21 | + */ |
|
22 | + public function process(NoticesContainerInterface $notices) |
|
23 | + { |
|
24 | + $this->setNotices($notices); |
|
25 | + $notices = $this->getNotices(); |
|
26 | + if ($notices->hasAttention()) { |
|
27 | + foreach ($notices->getAttention() as $notice) { |
|
28 | + EE_Error::add_attention( |
|
29 | + $notice->message(), |
|
30 | + $notice->file(), |
|
31 | + $notice->func(), |
|
32 | + $notice->line() |
|
33 | + ); |
|
34 | + } |
|
35 | + } |
|
36 | + if ($notices->hasError()) { |
|
37 | + $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
38 | + foreach ($notices->getError() as $notice) { |
|
39 | + if ($this->getThrowExceptions()) { |
|
40 | + $error_string .= '<br />' . $notice->message(); |
|
41 | + } else { |
|
42 | + EE_Error::add_error( |
|
43 | + $notice->message(), |
|
44 | + $notice->file(), |
|
45 | + $notice->func(), |
|
46 | + $notice->line() |
|
47 | + ); |
|
48 | + } |
|
49 | + } |
|
50 | + if ($this->getThrowExceptions()) { |
|
51 | + throw new EE_Error($error_string); |
|
52 | + } |
|
53 | + } |
|
54 | + if ($notices->hasSuccess()) { |
|
55 | + foreach ($notices->getSuccess() as $notice) { |
|
56 | + EE_Error::add_success( |
|
57 | + $notice->message(), |
|
58 | + $notice->file(), |
|
59 | + $notice->func(), |
|
60 | + $notice->line() |
|
61 | + ); |
|
62 | + } |
|
63 | + } |
|
64 | + $this->clearNotices(); |
|
65 | + } |
|
66 | 66 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | // with these parameters |
141 | 141 | $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
142 | 142 | // then md5 the above to control it's length, add all of our prefixes, and truncate |
143 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
143 | + return substr($this->cachePrefix().$id_prefix.'-'.md5($cache_id), 0, 182); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | return ' |
171 | 171 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
172 | 172 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
173 | - <b>' . $type . '</b><span style="color:#999"> : </span> |
|
174 | - <span>' . $cache_id . '</span> |
|
175 | - <span style="margin-left:2em;">' . __FILE__ . '</span> |
|
173 | + <b>' . $type.'</b><span style="color:#999"> : </span> |
|
174 | + <span>' . $cache_id.'</span> |
|
175 | + <span style="margin-left:2em;">' . __FILE__.'</span> |
|
176 | 176 | </p> |
177 | 177 | </div>'; |
178 | 178 | } |
@@ -14,135 +14,135 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class BasicCacheManager implements CacheManagerInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @type string |
|
19 | - */ |
|
20 | - const CACHE_PREFIX = 'ee_cache_'; |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * @var CacheStorageInterface $cache_storage |
|
25 | - */ |
|
26 | - private $cache_storage; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * BasicCacheManager constructor. |
|
31 | - * |
|
32 | - * @param CacheStorageInterface $cache_storage [required] |
|
33 | - */ |
|
34 | - public function __construct(CacheStorageInterface $cache_storage) |
|
35 | - { |
|
36 | - $this->cache_storage = $cache_storage; |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * returns a string that will be prepended to all cache identifiers |
|
42 | - * |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function cachePrefix() |
|
46 | - { |
|
47 | - return BasicCacheManager::CACHE_PREFIX; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
53 | - * May also be helpful to include an additional specific identifier, |
|
54 | - * such as a post ID as part of the $id_prefix so that individual caches |
|
55 | - * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
56 | - * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
57 | - * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
58 | - * It is advisable to use some of the actual data |
|
59 | - * that is used to generate the content being cached, |
|
60 | - * in order to guarantee that the cache id is unique for that content. |
|
61 | - * The cache id will be md5'd before usage to make it more db friendly, |
|
62 | - * and the entire cache id string will be truncated to 190 characters. |
|
63 | - * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
64 | - * necessary, |
|
65 | - * we wrap our content creation in a Closure so that it is not executed until needed. |
|
66 | - * @param int $expiration |
|
67 | - * @return Closure|mixed |
|
68 | - */ |
|
69 | - public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
70 | - { |
|
71 | - $content = ''; |
|
72 | - $expiration = absint( |
|
73 | - apply_filters( |
|
74 | - 'FHEE__CacheManager__get__cache_expiration', |
|
75 | - $expiration, |
|
76 | - $id_prefix, |
|
77 | - $cache_id |
|
78 | - ) |
|
79 | - ); |
|
80 | - $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
81 | - // is caching enabled for this content ? |
|
82 | - if ($expiration) { |
|
83 | - $content = $this->cache_storage->get($cache_id); |
|
84 | - } |
|
85 | - // any existing content ? |
|
86 | - if (empty($content)) { |
|
87 | - // nope! let's generate some new stuff |
|
88 | - $content = $callback(); |
|
89 | - // save the new content if caching is enabled |
|
90 | - if ($expiration) { |
|
91 | - $this->cache_storage->add($cache_id, $content, $expiration); |
|
92 | - if (EE_DEBUG) { |
|
93 | - $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
94 | - } |
|
95 | - } |
|
96 | - } else { |
|
97 | - if (EE_DEBUG) { |
|
98 | - $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
99 | - } |
|
100 | - } |
|
101 | - return $content; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * Generates a unique identifier string for the cache |
|
107 | - * |
|
108 | - * @param string $id_prefix [required] see BasicCacheManager::get() |
|
109 | - * @param string $cache_id [required] see BasicCacheManager::get() |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - private function generateCacheIdentifier($id_prefix, $cache_id) |
|
113 | - { |
|
114 | - // let's make the cached content unique for this "page" |
|
115 | - $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
116 | - // with these parameters |
|
117 | - $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
118 | - // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
119 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
125 | - * or a specific ID targeting a single cache item |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - public function clear($cache_id) |
|
129 | - { |
|
130 | - // ensure incoming arg is in an array |
|
131 | - $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
132 | - // delete corresponding transients for the supplied id prefix |
|
133 | - $this->cache_storage->deleteMany($cache_id); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
139 | - * or a specific ID targeting a single cache item |
|
140 | - * @param string $type |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - private function displayCacheNotice($cache_id, $type) |
|
144 | - { |
|
145 | - return ' |
|
17 | + /** |
|
18 | + * @type string |
|
19 | + */ |
|
20 | + const CACHE_PREFIX = 'ee_cache_'; |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * @var CacheStorageInterface $cache_storage |
|
25 | + */ |
|
26 | + private $cache_storage; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * BasicCacheManager constructor. |
|
31 | + * |
|
32 | + * @param CacheStorageInterface $cache_storage [required] |
|
33 | + */ |
|
34 | + public function __construct(CacheStorageInterface $cache_storage) |
|
35 | + { |
|
36 | + $this->cache_storage = $cache_storage; |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * returns a string that will be prepended to all cache identifiers |
|
42 | + * |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function cachePrefix() |
|
46 | + { |
|
47 | + return BasicCacheManager::CACHE_PREFIX; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
53 | + * May also be helpful to include an additional specific identifier, |
|
54 | + * such as a post ID as part of the $id_prefix so that individual caches |
|
55 | + * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
56 | + * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
57 | + * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
58 | + * It is advisable to use some of the actual data |
|
59 | + * that is used to generate the content being cached, |
|
60 | + * in order to guarantee that the cache id is unique for that content. |
|
61 | + * The cache id will be md5'd before usage to make it more db friendly, |
|
62 | + * and the entire cache id string will be truncated to 190 characters. |
|
63 | + * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
64 | + * necessary, |
|
65 | + * we wrap our content creation in a Closure so that it is not executed until needed. |
|
66 | + * @param int $expiration |
|
67 | + * @return Closure|mixed |
|
68 | + */ |
|
69 | + public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
70 | + { |
|
71 | + $content = ''; |
|
72 | + $expiration = absint( |
|
73 | + apply_filters( |
|
74 | + 'FHEE__CacheManager__get__cache_expiration', |
|
75 | + $expiration, |
|
76 | + $id_prefix, |
|
77 | + $cache_id |
|
78 | + ) |
|
79 | + ); |
|
80 | + $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
81 | + // is caching enabled for this content ? |
|
82 | + if ($expiration) { |
|
83 | + $content = $this->cache_storage->get($cache_id); |
|
84 | + } |
|
85 | + // any existing content ? |
|
86 | + if (empty($content)) { |
|
87 | + // nope! let's generate some new stuff |
|
88 | + $content = $callback(); |
|
89 | + // save the new content if caching is enabled |
|
90 | + if ($expiration) { |
|
91 | + $this->cache_storage->add($cache_id, $content, $expiration); |
|
92 | + if (EE_DEBUG) { |
|
93 | + $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
94 | + } |
|
95 | + } |
|
96 | + } else { |
|
97 | + if (EE_DEBUG) { |
|
98 | + $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
99 | + } |
|
100 | + } |
|
101 | + return $content; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * Generates a unique identifier string for the cache |
|
107 | + * |
|
108 | + * @param string $id_prefix [required] see BasicCacheManager::get() |
|
109 | + * @param string $cache_id [required] see BasicCacheManager::get() |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + private function generateCacheIdentifier($id_prefix, $cache_id) |
|
113 | + { |
|
114 | + // let's make the cached content unique for this "page" |
|
115 | + $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
116 | + // with these parameters |
|
117 | + $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
118 | + // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
119 | + return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
125 | + * or a specific ID targeting a single cache item |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + public function clear($cache_id) |
|
129 | + { |
|
130 | + // ensure incoming arg is in an array |
|
131 | + $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
132 | + // delete corresponding transients for the supplied id prefix |
|
133 | + $this->cache_storage->deleteMany($cache_id); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
139 | + * or a specific ID targeting a single cache item |
|
140 | + * @param string $type |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + private function displayCacheNotice($cache_id, $type) |
|
144 | + { |
|
145 | + return ' |
|
146 | 146 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
147 | 147 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
148 | 148 | <b>' . $type . '</b><span style="color:#999"> : </span> |
@@ -150,5 +150,5 @@ discard block |
||
150 | 150 | <span style="margin-left:2em;">' . __FILE__ . '</span> |
151 | 151 | </p> |
152 | 152 | </div>'; |
153 | - } |
|
153 | + } |
|
154 | 154 | } |
@@ -98,7 +98,7 @@ |
||
98 | 98 | { |
99 | 99 | sort($EVT_ID); |
100 | 100 | $EVT_ID = implode(',', array_unique($EVT_ID)); |
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
101 | + return md5($messenger.$message_type.$EVT_ID); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -10,114 +10,114 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Message_Template_Group_Collection extends EE_Object_Collection |
12 | 12 | { |
13 | - /** |
|
14 | - * EE_Message_Template_Group_Collection constructor. |
|
15 | - */ |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - $this->interface = 'EE_Message_Template_Group'; |
|
19 | - } |
|
13 | + /** |
|
14 | + * EE_Message_Template_Group_Collection constructor. |
|
15 | + */ |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + $this->interface = 'EE_Message_Template_Group'; |
|
19 | + } |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * Adds the Message Template Group object to the repository. |
|
24 | - * |
|
25 | - * @param $message_template_group |
|
26 | - * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
27 | - * indexing the template by key. If this template is shared among multiple events then |
|
28 | - * include the events as an array. |
|
29 | - * @return bool |
|
30 | - */ |
|
31 | - public function add($message_template_group, $EVT_ID = array()): bool |
|
32 | - { |
|
33 | - $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
34 | - if ($message_template_group instanceof $this->interface) { |
|
35 | - $data['key'] = $this->getKey( |
|
36 | - $message_template_group->messenger(), |
|
37 | - $message_template_group->message_type(), |
|
38 | - $EVT_ID |
|
39 | - ); |
|
40 | - return parent::add($message_template_group, $data); |
|
41 | - } |
|
42 | - return false; |
|
43 | - } |
|
22 | + /** |
|
23 | + * Adds the Message Template Group object to the repository. |
|
24 | + * |
|
25 | + * @param $message_template_group |
|
26 | + * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
27 | + * indexing the template by key. If this template is shared among multiple events then |
|
28 | + * include the events as an array. |
|
29 | + * @return bool |
|
30 | + */ |
|
31 | + public function add($message_template_group, $EVT_ID = array()): bool |
|
32 | + { |
|
33 | + $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
34 | + if ($message_template_group instanceof $this->interface) { |
|
35 | + $data['key'] = $this->getKey( |
|
36 | + $message_template_group->messenger(), |
|
37 | + $message_template_group->message_type(), |
|
38 | + $EVT_ID |
|
39 | + ); |
|
40 | + return parent::add($message_template_group, $data); |
|
41 | + } |
|
42 | + return false; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
48 | - * |
|
49 | - * @param $GRP_ID |
|
50 | - * @return EE_Message_Template_Group | null |
|
51 | - */ |
|
52 | - public function get_by_ID($GRP_ID) |
|
53 | - { |
|
54 | - $this->rewind(); |
|
55 | - while ($this->valid()) { |
|
56 | - if ($this->current()->ID() === $GRP_ID) { |
|
57 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
58 | - $message_template_group = $this->current(); |
|
59 | - $this->rewind(); |
|
60 | - return $message_template_group; |
|
61 | - } |
|
62 | - $this->next(); |
|
63 | - } |
|
64 | - return null; |
|
65 | - } |
|
46 | + /** |
|
47 | + * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
48 | + * |
|
49 | + * @param $GRP_ID |
|
50 | + * @return EE_Message_Template_Group | null |
|
51 | + */ |
|
52 | + public function get_by_ID($GRP_ID) |
|
53 | + { |
|
54 | + $this->rewind(); |
|
55 | + while ($this->valid()) { |
|
56 | + if ($this->current()->ID() === $GRP_ID) { |
|
57 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
58 | + $message_template_group = $this->current(); |
|
59 | + $this->rewind(); |
|
60 | + return $message_template_group; |
|
61 | + } |
|
62 | + $this->next(); |
|
63 | + } |
|
64 | + return null; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * Generates a hash used to identify a given Message Template Group. |
|
70 | - * |
|
71 | - * @param string $messenger The EE_messenger->name |
|
72 | - * @param string $message_type The EE_message_type->name |
|
73 | - * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
74 | - * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
78 | - { |
|
79 | - $EVT_ID = (array) $EVT_ID; |
|
80 | - return $this->getKey($messenger, $message_type, $EVT_ID); |
|
81 | - } |
|
68 | + /** |
|
69 | + * Generates a hash used to identify a given Message Template Group. |
|
70 | + * |
|
71 | + * @param string $messenger The EE_messenger->name |
|
72 | + * @param string $message_type The EE_message_type->name |
|
73 | + * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
74 | + * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
78 | + { |
|
79 | + $EVT_ID = (array) $EVT_ID; |
|
80 | + return $this->getKey($messenger, $message_type, $EVT_ID); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * Generates a hash used to identify a given Message Template Group |
|
86 | - * @param string $messenger The EE_messenger->name |
|
87 | - * @param string $message_type The EE_message_type->name |
|
88 | - * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
89 | - * be included. |
|
90 | - * @since 4.9.40.rc.017 |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
94 | - { |
|
95 | - sort($EVT_ID); |
|
96 | - $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
97 | - return md5($messenger . $message_type . $EVT_ID); |
|
98 | - } |
|
84 | + /** |
|
85 | + * Generates a hash used to identify a given Message Template Group |
|
86 | + * @param string $messenger The EE_messenger->name |
|
87 | + * @param string $message_type The EE_message_type->name |
|
88 | + * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
89 | + * be included. |
|
90 | + * @since 4.9.40.rc.017 |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
94 | + { |
|
95 | + sort($EVT_ID); |
|
96 | + $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
97 | + return md5($messenger . $message_type . $EVT_ID); |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | - /** |
|
102 | - * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
103 | - * the given string. |
|
104 | - * |
|
105 | - * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
106 | - * @return null|EE_Message_Template_Group |
|
107 | - */ |
|
108 | - public function get_by_key($key) |
|
109 | - { |
|
110 | - $this->rewind(); |
|
111 | - while ($this->valid()) { |
|
112 | - $data = $this->getInfo(); |
|
113 | - if (isset($data['key']) && $data['key'] === $key) { |
|
114 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
115 | - $message_template_group = $this->current(); |
|
116 | - $this->rewind(); |
|
117 | - return $message_template_group; |
|
118 | - } |
|
119 | - $this->next(); |
|
120 | - } |
|
121 | - return null; |
|
122 | - } |
|
101 | + /** |
|
102 | + * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
103 | + * the given string. |
|
104 | + * |
|
105 | + * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
106 | + * @return null|EE_Message_Template_Group |
|
107 | + */ |
|
108 | + public function get_by_key($key) |
|
109 | + { |
|
110 | + $this->rewind(); |
|
111 | + while ($this->valid()) { |
|
112 | + $data = $this->getInfo(); |
|
113 | + if (isset($data['key']) && $data['key'] === $key) { |
|
114 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
115 | + $message_template_group = $this->current(); |
|
116 | + $this->rewind(); |
|
117 | + return $message_template_group; |
|
118 | + } |
|
119 | + $this->next(); |
|
120 | + } |
|
121 | + return null; |
|
122 | + } |
|
123 | 123 | } |