@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -$values = EEH_Form_Fields::prep_answer_options( array( |
|
| 3 | - array( 'id' => 1, 'text' => __('Yes', 'event_espresso')), |
|
| 4 | - array( 'id' => 0, 'text' => __('No', 'event_espresso')) |
|
| 2 | +$values = EEH_Form_Fields::prep_answer_options(array( |
|
| 3 | + array('id' => 1, 'text' => __('Yes', 'event_espresso')), |
|
| 4 | + array('id' => 0, 'text' => __('No', 'event_espresso')) |
|
| 5 | 5 | )); |
| 6 | 6 | |
| 7 | -$description = EEH_Form_Fields::prep_answer_options( array( |
|
| 8 | - array( 'id' => 0, 'text' => __('none', 'event_espresso')), |
|
| 9 | - array( 'id' => 1, 'text' => __('excerpt (short desc)', 'event_espresso')), |
|
| 10 | - array( 'id' => 2, 'text' => __('full description', 'event_espresso')) |
|
| 7 | +$description = EEH_Form_Fields::prep_answer_options(array( |
|
| 8 | + array('id' => 0, 'text' => __('none', 'event_espresso')), |
|
| 9 | + array('id' => 1, 'text' => __('excerpt (short desc)', 'event_espresso')), |
|
| 10 | + array('id' => 2, 'text' => __('full description', 'event_espresso')) |
|
| 11 | 11 | )); |
| 12 | 12 | |
| 13 | -add_filter( 'FHEE__EEH_Form_Fields__label_html', '__return_empty_string' ); |
|
| 13 | +add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
| 14 | 14 | ?> |
| 15 | 15 | |
| 16 | 16 | |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | <tr> |
| 25 | 25 | <th> |
| 26 | 26 | <label for="event_listings_url"> |
| 27 | - <?php _e('Event Listings URL', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('event_listings_url_info');?> |
|
| 27 | + <?php _e('Event Listings URL', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('event_listings_url_info'); ?> |
|
| 28 | 28 | </label> |
| 29 | 29 | </th> |
| 30 | 30 | <td> |
| 31 | - <a id="event_listings_url" class="ee-admin-settings-hdr-lnk small-text" href="<?php echo home_url('/') . __('events', 'event_espresso'); ?>"><?php echo home_url('/') . __('events', 'event_espresso'); ?></a> |
|
| 31 | + <a id="event_listings_url" class="ee-admin-settings-hdr-lnk small-text" href="<?php echo home_url('/').__('events', 'event_espresso'); ?>"><?php echo home_url('/').__('events', 'event_espresso'); ?></a> |
|
| 32 | 32 | </td> |
| 33 | 33 | </tr> |
| 34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | </label> |
| 40 | 40 | </th> |
| 41 | 41 | <td> |
| 42 | - <?php echo EEH_Form_Fields::select( 'display_status_banner', $display_status_banner, $values, 'EED_Events_Archive_display_status_banner', 'EED_Events_Archive_display_status_banner' );?> |
|
| 42 | + <?php echo EEH_Form_Fields::select('display_status_banner', $display_status_banner, $values, 'EED_Events_Archive_display_status_banner', 'EED_Events_Archive_display_status_banner'); ?> |
|
| 43 | 43 | <p class="description"><?php _e('Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the events archive page.', 'event_espresso'); ?></p> |
| 44 | 44 | </td> |
| 45 | 45 | </tr> |
@@ -47,55 +47,55 @@ discard block |
||
| 47 | 47 | <tr> |
| 48 | 48 | <th> |
| 49 | 49 | <label for="EED_Events_Archive_display_description"> |
| 50 | - <?php _e('Display Description', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_description_info');?> |
|
| 50 | + <?php _e('Display Description', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_description_info'); ?> |
|
| 51 | 51 | </label> |
| 52 | 52 | </th> |
| 53 | 53 | <td> |
| 54 | - <?php echo EEH_Form_Fields::select( 'description', $display_description, $description, 'EED_Events_Archive_display_description', 'EED_Events_Archive_display_description' );?> |
|
| 54 | + <?php echo EEH_Form_Fields::select('description', $display_description, $description, 'EED_Events_Archive_display_description', 'EED_Events_Archive_display_description'); ?> |
|
| 55 | 55 | </td> |
| 56 | 56 | </tr> |
| 57 | 57 | |
| 58 | 58 | <tr> |
| 59 | 59 | <th> |
| 60 | 60 | <label for="EED_Events_Archive_display_ticket_selector"> |
| 61 | - <?php _e('Display Ticket Selector', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_ticket_selector_info');?> |
|
| 61 | + <?php _e('Display Ticket Selector', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_ticket_selector_info'); ?> |
|
| 62 | 62 | </label> |
| 63 | 63 | </th> |
| 64 | 64 | <td> |
| 65 | - <?php echo EEH_Form_Fields::select( 'ticket_selector', $display_ticket_selector, $values, 'EED_Events_Archive_display_ticket_selector', 'EED_Events_Archive_display_ticket_selector' );?> |
|
| 65 | + <?php echo EEH_Form_Fields::select('ticket_selector', $display_ticket_selector, $values, 'EED_Events_Archive_display_ticket_selector', 'EED_Events_Archive_display_ticket_selector'); ?> |
|
| 66 | 66 | </td> |
| 67 | 67 | </tr> |
| 68 | 68 | |
| 69 | 69 | <tr> |
| 70 | 70 | <th> |
| 71 | 71 | <label for="EED_Events_Archive_display_datetimes"> |
| 72 | - <?php _e('Display Datetimes', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_datetimes_info');?> |
|
| 72 | + <?php _e('Display Datetimes', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_datetimes_info'); ?> |
|
| 73 | 73 | </label> |
| 74 | 74 | </th> |
| 75 | 75 | <td> |
| 76 | - <?php echo EEH_Form_Fields::select( 'venue_details', $display_datetimes, $values, 'EED_Events_Archive_display_datetimes', 'EED_Events_Archive_display_datetimes' );?> |
|
| 76 | + <?php echo EEH_Form_Fields::select('venue_details', $display_datetimes, $values, 'EED_Events_Archive_display_datetimes', 'EED_Events_Archive_display_datetimes'); ?> |
|
| 77 | 77 | </td> |
| 78 | 78 | </tr> |
| 79 | 79 | |
| 80 | 80 | <tr> |
| 81 | 81 | <th> |
| 82 | 82 | <label for="EED_Events_Archive_display_venue"> |
| 83 | - <?php _e('Display Venue Details', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_venue_details_info');?> |
|
| 83 | + <?php _e('Display Venue Details', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_venue_details_info'); ?> |
|
| 84 | 84 | </label> |
| 85 | 85 | </th> |
| 86 | 86 | <td> |
| 87 | - <?php echo EEH_Form_Fields::select( 'display_venue', $display_venue, $values, 'EED_Events_Archive_display_venue', 'EED_Events_Archive_display_venue' );?> |
|
| 87 | + <?php echo EEH_Form_Fields::select('display_venue', $display_venue, $values, 'EED_Events_Archive_display_venue', 'EED_Events_Archive_display_venue'); ?> |
|
| 88 | 88 | </td> |
| 89 | 89 | </tr> |
| 90 | 90 | |
| 91 | 91 | <tr> |
| 92 | 92 | <th> |
| 93 | 93 | <label for="EED_Events_Archive_display_expired_events"> |
| 94 | - <?php _e('Display Expired Events', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_expired_events_info');?> |
|
| 94 | + <?php _e('Display Expired Events', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('display_expired_events_info'); ?> |
|
| 95 | 95 | </label> |
| 96 | 96 | </th> |
| 97 | 97 | <td> |
| 98 | - <?php echo EEH_Form_Fields::select( 'expired_events', $display_expired_events, $values, 'EED_Events_Archive_display_expired_events', 'EED_Events_Archive_display_expired_events' );?> |
|
| 98 | + <?php echo EEH_Form_Fields::select('expired_events', $display_expired_events, $values, 'EED_Events_Archive_display_expired_events', 'EED_Events_Archive_display_expired_events'); ?> |
|
| 99 | 99 | </td> |
| 100 | 100 | </tr> |
| 101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | </label> |
| 107 | 107 | </th> |
| 108 | 108 | <td> |
| 109 | - <?php echo EEH_Form_Fields::select( 'reset_event_list_settings', 0, $values, 'EED_Events_Archive_reset_event_list_settings', 'EED_Events_Archive_reset_event_list_settings' );?> |
|
| 109 | + <?php echo EEH_Form_Fields::select('reset_event_list_settings', 0, $values, 'EED_Events_Archive_reset_event_list_settings', 'EED_Events_Archive_reset_event_list_settings'); ?> |
|
| 110 | 110 | </td> |
| 111 | 111 | </tr> |
| 112 | 112 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * A ReCaptchaResponse is returned from checkAnswer(). |
| 35 | 35 | */ |
| 36 | -if ( ! class_exists( 'ReCaptchaResponse' )) { |
|
| 36 | +if ( ! class_exists('ReCaptchaResponse')) { |
|
| 37 | 37 | class ReCaptchaResponse |
| 38 | 38 | { |
| 39 | 39 | public $success; |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | if ($secret == null || $secret == "") { |
| 60 | 60 | die("To use reCAPTCHA you must get an API key from <a href='" |
| 61 | - . self::$_signupUrl . "'>" . self::$_signupUrl . "</a>"); |
|
| 61 | + . self::$_signupUrl."'>".self::$_signupUrl."</a>"); |
|
| 62 | 62 | } |
| 63 | - $this->_secret=$secret; |
|
| 63 | + $this->_secret = $secret; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $req = ""; |
| 76 | 76 | foreach ($data as $key => $value) { |
| 77 | - $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; |
|
| 77 | + $req .= $key.'='.urlencode(stripslashes($value)).'&'; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Cut the last '&' |
| 81 | - $req=substr($req, 0, strlen($req)-1); |
|
| 81 | + $req = substr($req, 0, strlen($req) - 1); |
|
| 82 | 82 | return $req; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | private function _submitHTTPGet($path, $data) |
| 94 | 94 | { |
| 95 | 95 | $req = $this->_encodeQS($data); |
| 96 | - $response = file_get_contents($path . $req); |
|
| 96 | + $response = file_get_contents($path.$req); |
|
| 97 | 97 | return $response; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $getResponse = $this->_submitHttpGet( |
| 120 | 120 | self::$_siteVerifyUrl, |
| 121 | - array ( |
|
| 121 | + array( |
|
| 122 | 122 | 'secret' => $this->_secret, |
| 123 | 123 | 'remoteip' => $remoteIp, |
| 124 | 124 | 'v' => self::$_version, |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * ------------------------------------------------------------------------ |
| 27 | 27 | */ |
| 28 | -class EE_PMT_Mijireh extends EE_PMT_Base{ |
|
| 28 | +class EE_PMT_Mijireh extends EE_PMT_Base { |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | require_once($this->file_folder().'EEG_Mijireh.gateway.php'); |
| 39 | 39 | $this->_gateway = new EEG_Mijireh(); |
| 40 | 40 | $this->_pretty_name = __("Mijireh", 'event_espresso'); |
| 41 | - $this->_default_description = __( 'After clicking "Finalize Registration", you will be able to enter your billing information and complete your payment.', 'event_espresso' ); |
|
| 41 | + $this->_default_description = __('After clicking "Finalize Registration", you will be able to enter your billing information and complete your payment.', 'event_espresso'); |
|
| 42 | 42 | parent::__construct($pm_instance); |
| 43 | - $this->_default_button_url = $this->file_url() . 'lib' . DS . 'mijireh-checkout-logo.png'; |
|
| 43 | + $this->_default_button_url = $this->file_url().'lib'.DS.'mijireh-checkout-logo.png'; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @see EE_PMT_Base::help_tabs_config() |
| 51 | 51 | * @return array |
| 52 | 52 | */ |
| 53 | - public function help_tabs_config(){ |
|
| 53 | + public function help_tabs_config() { |
|
| 54 | 54 | return array( |
| 55 | 55 | $this->get_help_tab_name() => array( |
| 56 | 56 | 'title' => __('Mijireh Settings', 'event_espresso'), |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | $form = new EE_Payment_Method_Form(array( |
| 70 | 70 | 'extra_meta_inputs'=>array( |
| 71 | 71 | 'access_key'=>new EE_Text_Input(array( |
| 72 | - 'html_label_text'=> sprintf(__("Mijireh Access Key %s", 'event_espresso'), $this->get_help_tab_link()), |
|
| 72 | + 'html_label_text'=> sprintf(__("Mijireh Access Key %s", 'event_espresso'), $this->get_help_tab_link()), |
|
| 73 | 73 | 'required' => true |
| 74 | 74 | )), |
| 75 | 75 | ), |
| 76 | 76 | 'exclude'=>array('PMD_debug_mode'), |
| 77 | 77 | )); |
| 78 | - $form->add_subsections( array( |
|
| 79 | - 'slurper_area' => new EE_Form_Section_HTML_From_Template( $this->file_folder().DS.'templates'.DS.'mijireh_settings_after_form.template.php' ) |
|
| 78 | + $form->add_subsections(array( |
|
| 79 | + 'slurper_area' => new EE_Form_Section_HTML_From_Template($this->file_folder().DS.'templates'.DS.'mijireh_settings_after_form.template.php') |
|
| 80 | 80 | )); |
| 81 | 81 | return $form; |
| 82 | 82 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param \EE_Transaction $transaction |
| 89 | 89 | * @return NULL |
| 90 | 90 | */ |
| 91 | - public function generate_new_billing_form( EE_Transaction $transaction = NULL ) { |
|
| 91 | + public function generate_new_billing_form(EE_Transaction $transaction = NULL) { |
|
| 92 | 92 | return NULL; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | /** |
| 7 | 8 | * Event Espresso |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | +} |
|
| 2 | 4 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );/** |
| 3 | 5 | * |
| 4 | 6 | * Event Espresso |
@@ -64,7 +66,7 @@ discard block |
||
| 64 | 66 | // check if class object is instantiated |
| 65 | 67 | if( ! empty( $grand_total ) ){ |
| 66 | 68 | self::$_instance = new self( $grand_total ); |
| 67 | - }elseif ( ! self::$_instance instanceof EE_Cart) { |
|
| 69 | + } elseif ( ! self::$_instance instanceof EE_Cart) { |
|
| 68 | 70 | //try getting the cart out of the session |
| 69 | 71 | $saved_cart = EE_Registry::instance()->SSN->cart(); |
| 70 | 72 | self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self( $grand_total ); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 2 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );/** |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 2 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); /** |
|
| 3 | 3 | * |
| 4 | 4 | * Event Espresso |
| 5 | 5 | * |
@@ -59,20 +59,20 @@ discard block |
||
| 59 | 59 | * @param EE_Line_Item $grand_total |
| 60 | 60 | * @return \EE_Cart |
| 61 | 61 | */ |
| 62 | - public static function instance( EE_Line_Item $grand_total = NULL ) { |
|
| 62 | + public static function instance(EE_Line_Item $grand_total = NULL) { |
|
| 63 | 63 | EE_Registry::instance()->load_helper('Line_Item'); |
| 64 | 64 | // check if class object is instantiated |
| 65 | - if( ! empty( $grand_total ) ){ |
|
| 66 | - self::$_instance = new self( $grand_total ); |
|
| 65 | + if ( ! empty($grand_total)) { |
|
| 66 | + self::$_instance = new self($grand_total); |
|
| 67 | 67 | }elseif ( ! self::$_instance instanceof EE_Cart) { |
| 68 | 68 | //try getting the cart out of the session |
| 69 | 69 | $saved_cart = EE_Registry::instance()->SSN->cart(); |
| 70 | - self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self( $grand_total ); |
|
| 71 | - unset( $saved_cart ); |
|
| 70 | + self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total); |
|
| 71 | + unset($saved_cart); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // once everything is all said and done, save the cart to the EE_Session |
| 75 | - add_action( 'shutdown', array( self::$_instance, 'save_cart' ), 90 ); |
|
| 75 | + add_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 76 | 76 | return self::$_instance; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | * @param EE_Line_Item $grand_total |
| 86 | 86 | * @return \EE_Cart |
| 87 | 87 | */ |
| 88 | - private function __construct( EE_Line_Item $grand_total = NULL ) { |
|
| 89 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 90 | - if ( ! defined( 'ESPRESSO_CART' )) { |
|
| 91 | - define( 'ESPRESSO_CART', TRUE ); |
|
| 88 | + private function __construct(EE_Line_Item $grand_total = NULL) { |
|
| 89 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 90 | + if ( ! defined('ESPRESSO_CART')) { |
|
| 91 | + define('ESPRESSO_CART', TRUE); |
|
| 92 | 92 | } |
| 93 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
| 94 | - $this->set_grand_total_line_item( $grand_total ); |
|
| 93 | + if ($grand_total instanceof EE_Line_Item) { |
|
| 94 | + $this->set_grand_total_line_item($grand_total); |
|
| 95 | 95 | } |
| 96 | 96 | $this->get_grand_total(); |
| 97 | 97 | } |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | * @param EE_Line_Item $grand_total |
| 104 | 104 | * @return EE_Cart |
| 105 | 105 | */ |
| 106 | - public static function reset( EE_Line_Item $grand_total = NULL ){ |
|
| 107 | - remove_action( 'shutdown', array( self::$_instance, 'save_cart'), 90 ); |
|
| 106 | + public static function reset(EE_Line_Item $grand_total = NULL) { |
|
| 107 | + remove_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 108 | 108 | EE_Registry::instance()->SSN->reset_cart(); |
| 109 | 109 | self::$_instance = NULL; |
| 110 | - return self::instance( $grand_total ); |
|
| 110 | + return self::instance($grand_total); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | * @param EE_Transaction $transaction |
| 119 | 119 | * @return \EE_Cart |
| 120 | 120 | */ |
| 121 | - public static function get_cart_from_txn( EE_Transaction $transaction ) { |
|
| 121 | + public static function get_cart_from_txn(EE_Transaction $transaction) { |
|
| 122 | 122 | $grand_total = $transaction->total_line_item(); |
| 123 | 123 | $grand_total->get_items(); |
| 124 | 124 | $grand_total->tax_descendants(); |
| 125 | - return EE_Cart::instance( $grand_total ); |
|
| 125 | + return EE_Cart::instance($grand_total); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items |
| 132 | 132 | * @return EE_Line_Item |
| 133 | 133 | */ |
| 134 | - private function _create_grand_total(){ |
|
| 134 | + private function _create_grand_total() { |
|
| 135 | 135 | $this->_grand_total = EEH_Line_Item::create_default_total_line_item(); |
| 136 | 136 | return $this->_grand_total; |
| 137 | 137 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @return \EE_Line_Item[] |
| 145 | 145 | */ |
| 146 | 146 | public function get_tickets() { |
| 147 | - return EEH_Line_Item::get_items_subtotal( $this->_grand_total )->children(); |
|
| 147 | + return EEH_Line_Item::get_items_subtotal($this->_grand_total)->children(); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function all_ticket_quantity_count() { |
| 159 | 159 | $tickets = $this->get_tickets(); |
| 160 | - if ( empty( $tickets )) { |
|
| 160 | + if (empty($tickets)) { |
|
| 161 | 161 | return 0; |
| 162 | 162 | } |
| 163 | 163 | $count = 0; |
| 164 | - foreach ( $tickets as $ticket ) { |
|
| 164 | + foreach ($tickets as $ticket) { |
|
| 165 | 165 | $count = $count + $ticket->get('LIN_quantity'); |
| 166 | 166 | } |
| 167 | 167 | return $count; |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * Gets all tha tax line items |
| 174 | 174 | * @return \EE_Line_Item[] |
| 175 | 175 | */ |
| 176 | - public function get_taxes(){ |
|
| 177 | - return EEH_Line_Item::get_taxes_subtotal( $this->_grand_total )->children(); |
|
| 176 | + public function get_taxes() { |
|
| 177 | + return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children(); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * Gets the total line item (which is a parent of all other line items) on this cart |
| 184 | 184 | * @return EE_Line_Item |
| 185 | 185 | */ |
| 186 | - public function get_grand_total(){ |
|
| 186 | + public function get_grand_total() { |
|
| 187 | 187 | return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total(); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | * @param int $qty |
| 197 | 197 | * @return TRUE on success, FALSE on fail |
| 198 | 198 | */ |
| 199 | - public function add_ticket_to_cart( EE_Ticket $ticket, $qty = 1 ) { |
|
| 200 | - EEH_Line_Item::add_ticket_purchase( $this->_grand_total, $ticket, $qty ); |
|
| 199 | + public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) { |
|
| 200 | + EEH_Line_Item::add_ticket_purchase($this->_grand_total, $ticket, $qty); |
|
| 201 | 201 | return $this->save_cart() ? TRUE : FALSE; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @return float |
| 221 | 221 | */ |
| 222 | 222 | public function get_applied_taxes() { |
| 223 | - return EEH_Line_Item::ensure_taxes_applied( $this->_grand_total ); |
|
| 223 | + return EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @return float |
| 232 | 232 | */ |
| 233 | 233 | public function get_cart_grand_total() { |
| 234 | - EEH_Line_Item::ensure_taxes_applied( $this->_grand_total ); |
|
| 234 | + EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 235 | 235 | return $this->get_grand_total()->total(); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | * @param mixed - string or array - line_item_ids |
| 244 | 244 | * @return int on success, FALSE on fail |
| 245 | 245 | */ |
| 246 | - public function delete_items( $line_item_codes = FALSE ) { |
|
| 246 | + public function delete_items($line_item_codes = FALSE) { |
|
| 247 | 247 | |
| 248 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 249 | - return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes ); |
|
| 248 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 249 | + return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes); |
|
| 250 | 250 | |
| 251 | 251 | } |
| 252 | 252 | |
@@ -258,9 +258,9 @@ discard block |
||
| 258 | 258 | * @return void |
| 259 | 259 | */ |
| 260 | 260 | public function empty_cart() { |
| 261 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 261 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 262 | 262 | $this->_grand_total = $this->_create_grand_total(); |
| 263 | - $this->save_cart( TRUE ); |
|
| 263 | + $this->save_cart(TRUE); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * know the grand total line item on it |
| 271 | 271 | * @param EE_Line_Item $line_item |
| 272 | 272 | */ |
| 273 | - public function set_grand_total_line_item( EE_Line_Item $line_item ) { |
|
| 273 | + public function set_grand_total_line_item(EE_Line_Item $line_item) { |
|
| 274 | 274 | $this->_grand_total = $line_item; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | * @return TRUE on success, FALSE on fail |
| 283 | 283 | */ |
| 284 | 284 | public function save_cart() { |
| 285 | - EEH_Line_Item::ensure_taxes_applied( $this->_grand_total ); |
|
| 286 | - return EE_Registry::instance()->SSN->set_cart( $this ); |
|
| 285 | + EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 286 | + return EE_Registry::instance()->SSN->set_cart($this); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | |
@@ -8,16 +8,16 @@ |
||
| 8 | 8 | <div class="ee-list-table-legend-container"> |
| 9 | 9 | <h4><?php _e('Legend', 'event_espresso'); ?></h4> |
| 10 | 10 | <dl class="alignleft ee-list-table-legend"> |
| 11 | - <?php foreach ( $items as $item => $details ) : ?> |
|
| 12 | - <?php if ( $per_col < $count ) : ?> |
|
| 11 | + <?php foreach ($items as $item => $details) : ?> |
|
| 12 | + <?php if ($per_col < $count) : ?> |
|
| 13 | 13 | </dl> |
| 14 | 14 | <dl class="alignleft ee-list-table-legend"> |
| 15 | 15 | <?php $count = 1; endif; ?> |
| 16 | 16 | <dt id="ee-legend-item-<?php echo $item; ?>"> |
| 17 | - <?php $class = !empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?> |
|
| 17 | + <?php $class = ! empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?> |
|
| 18 | 18 | <span class="<?php echo $class; ?>"> |
| 19 | - <?php if ( !empty($details['icon']) ) : ?> |
|
| 20 | - <img src="<?php echo $details['icon']; ?>" class="ee-legend-icon" alt="<?php echo esc_attr( $details['desc'] ); ?>" /> |
|
| 19 | + <?php if ( ! empty($details['icon'])) : ?> |
|
| 20 | + <img src="<?php echo $details['icon']; ?>" class="ee-legend-icon" alt="<?php echo esc_attr($details['desc']); ?>" /> |
|
| 21 | 21 | <?php endif; ?> |
| 22 | 22 | </span> |
| 23 | 23 | <span class="ee-legend-description"><?php echo $details['desc']; ?></span> |
@@ -47,25 +47,25 @@ |
||
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | - * date format |
|
| 51 | - * |
|
| 52 | - * pattern or format for displaying dates |
|
| 53 | - * |
|
| 54 | - * @access protected |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 50 | + * date format |
|
| 51 | + * |
|
| 52 | + * pattern or format for displaying dates |
|
| 53 | + * |
|
| 54 | + * @access protected |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | 57 | protected $_dt_frmt; |
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * time format |
|
| 63 | - * |
|
| 64 | - * pattern or format for displaying time |
|
| 65 | - * |
|
| 66 | - * @access protected |
|
| 67 | - * @var string |
|
| 68 | - */ |
|
| 61 | + /** |
|
| 62 | + * time format |
|
| 63 | + * |
|
| 64 | + * pattern or format for displaying time |
|
| 65 | + * |
|
| 66 | + * @access protected |
|
| 67 | + * @var string |
|
| 68 | + */ |
|
| 69 | 69 | protected $_tm_frmt; |
| 70 | 70 | |
| 71 | 71 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | +} |
|
| 2 | 4 | do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
| 3 | 5 | /** |
| 4 | 6 | * |
@@ -133,7 +135,7 @@ discard block |
||
| 133 | 135 | foreach($fieldValues as $field_name => $field_value_from_db){ |
| 134 | 136 | $this->set_from_db($field_name,$field_value_from_db); |
| 135 | 137 | } |
| 136 | - }else{ |
|
| 138 | + } else{ |
|
| 137 | 139 | //we're constructing a brand |
| 138 | 140 | //new instance of the model object. Generally, this means we'll need to do more field validation |
| 139 | 141 | foreach($model_fields as $fieldName => $field_obj){ |
@@ -153,7 +155,7 @@ discard block |
||
| 153 | 155 | foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
| 154 | 156 | if($relation_obj instanceof EE_Belongs_To_Relation){ |
| 155 | 157 | $this->_model_relations[$relation_name] = NULL; |
| 156 | - }else{ |
|
| 158 | + } else{ |
|
| 157 | 159 | $this->_model_relations[$relation_name] = array(); |
| 158 | 160 | } |
| 159 | 161 | } |
@@ -177,7 +179,7 @@ discard block |
||
| 177 | 179 | if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
| 178 | 180 | $field_settings = $this->get_Model()->field_settings_for( $field_name )){ |
| 179 | 181 | return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
| 180 | - }else{ |
|
| 182 | + } else{ |
|
| 181 | 183 | return NULL; |
| 182 | 184 | } |
| 183 | 185 | } |
@@ -209,7 +211,7 @@ discard block |
||
| 209 | 211 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
| 210 | 212 | if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
| 211 | 213 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
| 212 | - }else{ |
|
| 214 | + } else{ |
|
| 213 | 215 | $this->_fields[$field_name] = $holder_of_value; |
| 214 | 216 | } |
| 215 | 217 | |
@@ -237,7 +239,7 @@ discard block |
||
| 237 | 239 | } |
| 238 | 240 | //let's unset any cache for this field_name from the $_cached_properties property. |
| 239 | 241 | $this->_clear_cached_property( $field_name ); |
| 240 | - }else{ |
|
| 242 | + } else{ |
|
| 241 | 243 | echo "\r\n\r\nSAAAY WHAT?? $field_name doesnt have a field???"; |
| 242 | 244 | } |
| 243 | 245 | |
@@ -434,8 +436,9 @@ discard block |
||
| 434 | 436 | * @return void |
| 435 | 437 | */ |
| 436 | 438 | protected function _clear_cached_property( $property_name ) { |
| 437 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) |
|
| 438 | - unset( $this->_cached_properties[ $property_name ] ); |
|
| 439 | + if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
| 440 | + unset( $this->_cached_properties[ $property_name ] ); |
|
| 441 | + } |
|
| 439 | 442 | } |
| 440 | 443 | |
| 441 | 444 | |
@@ -475,10 +478,10 @@ discard block |
||
| 475 | 478 | if($clear_all){ |
| 476 | 479 | $obj_removed = true; |
| 477 | 480 | $this->_model_relations[$relationName] = null; |
| 478 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
| 481 | + } elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
| 479 | 482 | $obj_removed = $this->_model_relations[$relationName]; |
| 480 | 483 | $this->_model_relations[$relationName] = null; |
| 481 | - }else{ |
|
| 484 | + } else{ |
|
| 482 | 485 | if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
| 483 | 486 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
| 484 | 487 | if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
@@ -492,20 +495,20 @@ discard block |
||
| 492 | 495 | } |
| 493 | 496 | if($index_found_at){ |
| 494 | 497 | $index_in_cache = $index_found_at; |
| 495 | - }else{ |
|
| 498 | + } else{ |
|
| 496 | 499 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
| 497 | 500 | //if it wasn't in it to begin with. So we're done |
| 498 | 501 | return $object_to_remove_or_index_into_array; |
| 499 | 502 | } |
| 500 | 503 | } |
| 501 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
| 504 | + } elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
| 502 | 505 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
| 503 | 506 | foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
| 504 | 507 | if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
| 505 | 508 | $index_in_cache = $index; |
| 506 | 509 | } |
| 507 | 510 | } |
| 508 | - }else{ |
|
| 511 | + } else{ |
|
| 509 | 512 | $index_in_cache = $object_to_remove_or_index_into_array; |
| 510 | 513 | } |
| 511 | 514 | //supposedly we've found it. But it could just be that the client code |
@@ -514,7 +517,7 @@ discard block |
||
| 514 | 517 | isset( $this->_model_relations[$relationName][$index_in_cache])){ |
| 515 | 518 | $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
| 516 | 519 | unset($this->_model_relations[$relationName][$index_in_cache]); |
| 517 | - }else{ |
|
| 520 | + } else{ |
|
| 518 | 521 | //that thing was never cached anyways. |
| 519 | 522 | $obj_removed = NULL; |
| 520 | 523 | } |
@@ -570,7 +573,7 @@ discard block |
||
| 570 | 573 | $cached_array_or_object = $this->_model_relations[$relationName]; |
| 571 | 574 | if(is_array($cached_array_or_object)){ |
| 572 | 575 | return array_shift($cached_array_or_object); |
| 573 | - }else{ |
|
| 576 | + } else{ |
|
| 574 | 577 | return $cached_array_or_object; |
| 575 | 578 | } |
| 576 | 579 | } |
@@ -589,10 +592,10 @@ discard block |
||
| 589 | 592 | $cached_array_or_object = $this->_model_relations[$relationName]; |
| 590 | 593 | if(is_array($cached_array_or_object)){ |
| 591 | 594 | $objects = $cached_array_or_object; |
| 592 | - }elseif($cached_array_or_object){ |
|
| 595 | + } elseif($cached_array_or_object){ |
|
| 593 | 596 | //if the result is not an array, but exists, make it an array |
| 594 | 597 | $objects = array($cached_array_or_object); |
| 595 | - }else{ |
|
| 598 | + } else{ |
|
| 596 | 599 | //if nothing was found, return an empty array |
| 597 | 600 | $objects = array(); |
| 598 | 601 | } |
@@ -607,7 +610,7 @@ discard block |
||
| 607 | 610 | if( $model_object->ID() ){ |
| 608 | 611 | $model->add_to_entity_map( $model_object ); |
| 609 | 612 | } |
| 610 | - }else{ |
|
| 613 | + } else{ |
|
| 611 | 614 | throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object ))); |
| 612 | 615 | } |
| 613 | 616 | } |
@@ -730,7 +733,7 @@ discard block |
||
| 730 | 733 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
| 731 | 734 | if($field_value_from_db === NULL && ! $field_obj->is_nullable()){ |
| 732 | 735 | $field_value = $field_obj->get_default_value(); |
| 733 | - }else{ |
|
| 736 | + } else{ |
|
| 734 | 737 | $field_value = $field_value_from_db; |
| 735 | 738 | } |
| 736 | 739 | $this->_fields[$field_name] = $field_obj->prepare_for_set_from_db($field_value); |
@@ -821,18 +824,20 @@ discard block |
||
| 821 | 824 | if ( $dt_frmt !== NULL ) { |
| 822 | 825 | $this->_clear_cached_property( $field_name, $date_or_time ); |
| 823 | 826 | } |
| 824 | - if ( $echo ) |
|
| 825 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
| 826 | - else |
|
| 827 | - $field->set_date_format( $in_dt_frmt ); |
|
| 827 | + if ( $echo ) { |
|
| 828 | + $field->set_pretty_date_format( $in_dt_frmt ); |
|
| 829 | + } else { |
|
| 830 | + $field->set_date_format( $in_dt_frmt ); |
|
| 831 | + } |
|
| 828 | 832 | |
| 829 | 833 | if ( $tm_frmt !== NULL ) { |
| 830 | 834 | $this->_clear_cached_property( $field_name, $date_or_time ); |
| 831 | 835 | } |
| 832 | - if ( $echo ) |
|
| 833 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
| 834 | - else |
|
| 835 | - $field->set_time_format( $in_tm_frmt ); |
|
| 836 | + if ( $echo ) { |
|
| 837 | + $field->set_pretty_time_format( $in_tm_frmt ); |
|
| 838 | + } else { |
|
| 839 | + $field->set_time_format( $in_tm_frmt ); |
|
| 840 | + } |
|
| 836 | 841 | |
| 837 | 842 | //set timezone in field object |
| 838 | 843 | $field->set_timezone( $this->_timezone ); |
@@ -1050,8 +1055,9 @@ discard block |
||
| 1050 | 1055 | EE_Registry::instance()->load_helper('DTT_Helper'); |
| 1051 | 1056 | $timezone = EEH_DTT_Helper::get_timezone(); |
| 1052 | 1057 | |
| 1053 | - if ( $timezone == $this->_timezone ) |
|
| 1054 | - return ''; |
|
| 1058 | + if ( $timezone == $this->_timezone ) { |
|
| 1059 | + return ''; |
|
| 1060 | + } |
|
| 1055 | 1061 | |
| 1056 | 1062 | $original_timezone = $this->_timezone; |
| 1057 | 1063 | $this->set_timezone( $timezone ); |
@@ -1059,8 +1065,9 @@ discard block |
||
| 1059 | 1065 | $fn = (array) $field_name; |
| 1060 | 1066 | $args = array_merge( $fn, (array) $args ); |
| 1061 | 1067 | |
| 1062 | - if ( !method_exists( $this, $callback ) ) |
|
| 1063 | - throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
| 1068 | + if ( !method_exists( $this, $callback ) ) { |
|
| 1069 | + throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
| 1070 | + } |
|
| 1064 | 1071 | $args = (array) $args; |
| 1065 | 1072 | $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
| 1066 | 1073 | |
@@ -1102,7 +1109,7 @@ discard block |
||
| 1102 | 1109 | $model=$this->get_model(); |
| 1103 | 1110 | if($model instanceof EEM_Soft_Delete_Base){ |
| 1104 | 1111 | $result=$model->delete_permanently_by_ID($this->ID()); |
| 1105 | - }else{ |
|
| 1112 | + } else{ |
|
| 1106 | 1113 | $result = $this->delete(); |
| 1107 | 1114 | } |
| 1108 | 1115 | return $result ? true : false; |
@@ -1168,7 +1175,7 @@ discard block |
||
| 1168 | 1175 | $this->_update_cached_related_model_objs_fks(); |
| 1169 | 1176 | } |
| 1170 | 1177 | } |
| 1171 | - }else{//PK is NOT auto-increment |
|
| 1178 | + } else{//PK is NOT auto-increment |
|
| 1172 | 1179 | //so check if one like it already exists in the db |
| 1173 | 1180 | if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
| 1174 | 1181 | if( ! $this->in_entity_map() && WP_DEBUG ){ |
@@ -1183,12 +1190,12 @@ discard block |
||
| 1183 | 1190 | ); |
| 1184 | 1191 | } |
| 1185 | 1192 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
| 1186 | - }else{ |
|
| 1193 | + } else{ |
|
| 1187 | 1194 | $results = $this->get_model()->insert($save_cols_n_values); |
| 1188 | 1195 | $this->_update_cached_related_model_objs_fks(); |
| 1189 | 1196 | } |
| 1190 | 1197 | } |
| 1191 | - }else{//there is NO primary key |
|
| 1198 | + } else{//there is NO primary key |
|
| 1192 | 1199 | $already_in_db = false; |
| 1193 | 1200 | foreach($this->get_model()->unique_indexes() as $index){ |
| 1194 | 1201 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
@@ -1199,7 +1206,7 @@ discard block |
||
| 1199 | 1206 | if( $already_in_db ){ |
| 1200 | 1207 | $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
| 1201 | 1208 | $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
| 1202 | - }else{ |
|
| 1209 | + } else{ |
|
| 1203 | 1210 | $results = $this->get_model()->insert( $save_cols_n_values ); |
| 1204 | 1211 | } |
| 1205 | 1212 | } |
@@ -1251,7 +1258,7 @@ discard block |
||
| 1251 | 1258 | //make sure this has been saved |
| 1252 | 1259 | if( ! $this->ID()){ |
| 1253 | 1260 | $id = $this->save(); |
| 1254 | - }else{ |
|
| 1261 | + } else{ |
|
| 1255 | 1262 | $id = $this->ID(); |
| 1256 | 1263 | } |
| 1257 | 1264 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
@@ -1270,7 +1277,7 @@ discard block |
||
| 1270 | 1277 | $this->_add_relation_to($related_model_obj, $relationName); |
| 1271 | 1278 | $related_model_obj->save_new_cached_related_model_objs(); |
| 1272 | 1279 | // } |
| 1273 | - }else{ |
|
| 1280 | + } else{ |
|
| 1274 | 1281 | foreach($this->_model_relations[$relationName] as $related_model_obj){ |
| 1275 | 1282 | //add a relation to that relation type (which saves the appropriate thing in the process) |
| 1276 | 1283 | //but ONLY if it DOES NOT exist in the DB |
@@ -1329,13 +1336,13 @@ discard block |
||
| 1329 | 1336 | |
| 1330 | 1337 | if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
| 1331 | 1338 | $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] ); |
| 1332 | - }else{ |
|
| 1339 | + } else{ |
|
| 1333 | 1340 | $existing = null; |
| 1334 | 1341 | } |
| 1335 | - }elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
| 1342 | + } elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
| 1336 | 1343 | //no primary key on this model, but there's still a matching item in the DB |
| 1337 | 1344 | $existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) ); |
| 1338 | - }else{ |
|
| 1345 | + } else{ |
|
| 1339 | 1346 | $existing = null; |
| 1340 | 1347 | } |
| 1341 | 1348 | if ( $existing ) { |
@@ -1393,7 +1400,7 @@ discard block |
||
| 1393 | 1400 | private static function _get_model_classname( $model_name = null){ |
| 1394 | 1401 | if(strpos($model_name,"EE_")===0){ |
| 1395 | 1402 | $model_classname=str_replace("EE_","EEM_",$model_name); |
| 1396 | - }else{ |
|
| 1403 | + } else{ |
|
| 1397 | 1404 | $model_classname = "EEM_".$model_name; |
| 1398 | 1405 | } |
| 1399 | 1406 | return $model_classname; |
@@ -1427,7 +1434,7 @@ discard block |
||
| 1427 | 1434 | //now that we know the name of the variable, use a variable variable to get its value and return its |
| 1428 | 1435 | if( $this->get_model()->has_primary_key_field() ) { |
| 1429 | 1436 | return $this->_fields[self::_get_primary_key_name( get_class($this) )]; |
| 1430 | - }else{ |
|
| 1437 | + } else{ |
|
| 1431 | 1438 | return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
| 1432 | 1439 | } |
| 1433 | 1440 | } |
@@ -1485,7 +1492,7 @@ discard block |
||
| 1485 | 1492 | if($this->ID()){//if this exists in the DB, save the relation change to the DB too |
| 1486 | 1493 | $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
| 1487 | 1494 | $this->clear_cache($relationName, $otherObject); |
| 1488 | - }else{//this doesn't exist in the DB, just remove it from the cache |
|
| 1495 | + } else{//this doesn't exist in the DB, just remove it from the cache |
|
| 1489 | 1496 | $otherObject = $this->clear_cache($relationName,$otherObjectModelObjectOrID); |
| 1490 | 1497 | } |
| 1491 | 1498 | return $otherObject; |
@@ -1501,7 +1508,7 @@ discard block |
||
| 1501 | 1508 | if($this->ID()){//if this exists in the DB, save the relation change to the DB too |
| 1502 | 1509 | $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params ); |
| 1503 | 1510 | $this->clear_cache($relationName,null,true); |
| 1504 | - }else{//this doesn't exist in the DB, just remove it from the cache |
|
| 1511 | + } else{//this doesn't exist in the DB, just remove it from the cache |
|
| 1505 | 1512 | $otherObjects = $this->clear_cache($relationName,null,true); |
| 1506 | 1513 | } |
| 1507 | 1514 | return $otherObjects; |
@@ -1523,7 +1530,7 @@ discard block |
||
| 1523 | 1530 | //if there are query parameters, forget about caching the related model objects. |
| 1524 | 1531 | if( $query_params ){ |
| 1525 | 1532 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
| 1526 | - }else{ |
|
| 1533 | + } else{ |
|
| 1527 | 1534 | //did we already cache the result of this query? |
| 1528 | 1535 | $cached_results = $this->get_all_from_cache($relationName); |
| 1529 | 1536 | if ( ! $cached_results ){ |
@@ -1533,11 +1540,11 @@ discard block |
||
| 1533 | 1540 | foreach($related_model_objects as $related_model_object){ |
| 1534 | 1541 | $this->cache($relationName, $related_model_object); |
| 1535 | 1542 | } |
| 1536 | - }else{ |
|
| 1543 | + } else{ |
|
| 1537 | 1544 | $related_model_objects = $cached_results; |
| 1538 | 1545 | } |
| 1539 | 1546 | } |
| 1540 | - }else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
| 1547 | + } else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
| 1541 | 1548 | $related_model_objects = $this->get_all_from_cache($relationName); |
| 1542 | 1549 | } |
| 1543 | 1550 | return $related_model_objects; |
@@ -1589,22 +1596,22 @@ discard block |
||
| 1589 | 1596 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
| 1590 | 1597 | if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
| 1591 | 1598 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
| 1592 | - }else{ |
|
| 1599 | + } else{ |
|
| 1593 | 1600 | //first, check if we've already cached the result of this query |
| 1594 | 1601 | $cached_result = $this->get_one_from_cache($relationName); |
| 1595 | 1602 | if ( ! $cached_result ){ |
| 1596 | 1603 | |
| 1597 | 1604 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
| 1598 | 1605 | $this->cache($relationName,$related_model_object); |
| 1599 | - }else{ |
|
| 1606 | + } else{ |
|
| 1600 | 1607 | $related_model_object = $cached_result; |
| 1601 | 1608 | } |
| 1602 | 1609 | } |
| 1603 | - }else{ |
|
| 1610 | + } else{ |
|
| 1604 | 1611 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
| 1605 | 1612 | if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
| 1606 | 1613 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
| 1607 | - }else{ |
|
| 1614 | + } else{ |
|
| 1608 | 1615 | $related_model_object = null; |
| 1609 | 1616 | } |
| 1610 | 1617 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
@@ -1630,7 +1637,7 @@ discard block |
||
| 1630 | 1637 | public function delete_related($relationName,$query_params = array()){ |
| 1631 | 1638 | if($this->ID()){ |
| 1632 | 1639 | $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
| 1633 | - }else{ |
|
| 1640 | + } else{ |
|
| 1634 | 1641 | $count = count($this->get_all_from_cache($relationName)); |
| 1635 | 1642 | $this->clear_cache($relationName,NULL,TRUE); |
| 1636 | 1643 | } |
@@ -1650,7 +1657,7 @@ discard block |
||
| 1650 | 1657 | public function delete_related_permanently($relationName,$query_params = array()){ |
| 1651 | 1658 | if($this->ID()){ |
| 1652 | 1659 | $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
| 1653 | - }else{ |
|
| 1660 | + } else{ |
|
| 1654 | 1661 | $count = count($this->get_all_from_cache($relationName)); |
| 1655 | 1662 | } |
| 1656 | 1663 | $this->clear_cache($relationName,NULL,TRUE); |
@@ -1685,8 +1692,9 @@ discard block |
||
| 1685 | 1692 | |
| 1686 | 1693 | foreach ( (array) $properties as $property_name ) { |
| 1687 | 1694 | //first make sure this property exists |
| 1688 | - if ( ! $this->_fields[ $property_name ] ) |
|
| 1689 | - throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
| 1695 | + if ( ! $this->_fields[ $property_name ] ) { |
|
| 1696 | + throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
| 1697 | + } |
|
| 1690 | 1698 | } |
| 1691 | 1699 | |
| 1692 | 1700 | return TRUE; |
@@ -1766,7 +1774,7 @@ discard block |
||
| 1766 | 1774 | $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
| 1767 | 1775 | if( ! $existing_rows_like_that){ |
| 1768 | 1776 | return $this->add_extra_meta($meta_key, $meta_value); |
| 1769 | - }else{ |
|
| 1777 | + } else{ |
|
| 1770 | 1778 | foreach( $existing_rows_like_that as $existing_row){ |
| 1771 | 1779 | $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
| 1772 | 1780 | } |
@@ -1832,10 +1840,10 @@ discard block |
||
| 1832 | 1840 | $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
| 1833 | 1841 | if ( $result instanceof EE_Extra_Meta ){ |
| 1834 | 1842 | return $result->value(); |
| 1835 | - }else{ |
|
| 1843 | + } else{ |
|
| 1836 | 1844 | return $default; |
| 1837 | 1845 | } |
| 1838 | - }else{ |
|
| 1846 | + } else{ |
|
| 1839 | 1847 | $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
| 1840 | 1848 | if($results){ |
| 1841 | 1849 | $values = array(); |
@@ -1845,7 +1853,7 @@ discard block |
||
| 1845 | 1853 | } |
| 1846 | 1854 | } |
| 1847 | 1855 | return $values; |
| 1848 | - }else{ |
|
| 1856 | + } else{ |
|
| 1849 | 1857 | return $default; |
| 1850 | 1858 | } |
| 1851 | 1859 | } |
@@ -1869,7 +1877,7 @@ discard block |
||
| 1869 | 1877 | foreach($extra_meta_objs as $extra_meta_obj){ |
| 1870 | 1878 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
| 1871 | 1879 | } |
| 1872 | - }else{ |
|
| 1880 | + } else{ |
|
| 1873 | 1881 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
| 1874 | 1882 | foreach($extra_meta_objs as $extra_meta_obj){ |
| 1875 | 1883 | if( ! isset($return_array[$extra_meta_obj->key()])){ |
@@ -1889,7 +1897,7 @@ discard block |
||
| 1889 | 1897 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
| 1890 | 1898 | if($field_we_can_use){ |
| 1891 | 1899 | return $this->get($field_we_can_use->get_name()); |
| 1892 | - }else{ |
|
| 1900 | + } else{ |
|
| 1893 | 1901 | $first_few_properties = $this->model_field_array(); |
| 1894 | 1902 | $first_few_properties = array_slice($first_few_properties,0,3); |
| 1895 | 1903 | $name_parts = array(); |
@@ -1909,7 +1917,7 @@ discard block |
||
| 1909 | 1917 | if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
| 1910 | 1918 | //well, if we looked, did we find it in the entity map? |
| 1911 | 1919 | return TRUE; |
| 1912 | - }else{ |
|
| 1920 | + } else{ |
|
| 1913 | 1921 | return FALSE; |
| 1914 | 1922 | } |
| 1915 | 1923 | } |
@@ -1923,7 +1931,7 @@ discard block |
||
| 1923 | 1931 | public function refresh_from_db(){ |
| 1924 | 1932 | if( $this->ID() && $this->in_entity_map() ){ |
| 1925 | 1933 | $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
| 1926 | - }else{ |
|
| 1934 | + } else{ |
|
| 1927 | 1935 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
| 1928 | 1936 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
| 1929 | 1937 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 2 | -do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
| 3 | 3 | /** |
| 4 | 4 | * |
| 5 | 5 | * Event Espresso |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * ------------------------------------------------------------------------ |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -abstract class EE_Base_Class{ |
|
| 27 | +abstract class EE_Base_Class { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * This is an array of the original properties and values provided during construction |
@@ -105,39 +105,39 @@ discard block |
||
| 105 | 105 | * @throws EE_Error |
| 106 | 106 | * @return \EE_Base_Class |
| 107 | 107 | */ |
| 108 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '' ){ |
|
| 108 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '') { |
|
| 109 | 109 | |
| 110 | - $className=get_class($this); |
|
| 110 | + $className = get_class($this); |
|
| 111 | 111 | //set default formats for date and time |
| 112 | - $this->_dt_frmt = EE_Base_Class::fix_date_format_for_use_with_strtotime( get_option( 'date_format' )); |
|
| 113 | - $this->_tm_frmt = get_option( 'time_format' ); |
|
| 112 | + $this->_dt_frmt = EE_Base_Class::fix_date_format_for_use_with_strtotime(get_option('date_format')); |
|
| 113 | + $this->_tm_frmt = get_option('time_format'); |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
| 117 | - $model=$this->get_model(); |
|
| 118 | - $model_fields = $model->field_settings( FALSE ); |
|
| 116 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
| 117 | + $model = $this->get_model(); |
|
| 118 | + $model_fields = $model->field_settings(FALSE); |
|
| 119 | 119 | // ensure $fieldValues is an array |
| 120 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
| 120 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
| 121 | 121 | // EEH_Debug_Tools::printr( $fieldValues, '$fieldValues <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 122 | 122 | // verify client code has not passed any invalid field names |
| 123 | - foreach($fieldValues as $field_name=> $field_value){ |
|
| 124 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
| 125 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
| 123 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
| 124 | + if ( ! isset($model_fields[$field_name])) { |
|
| 125 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 129 | 129 | |
| 130 | 130 | //if db model is instantiating |
| 131 | - if( $bydb ){ |
|
| 131 | + if ($bydb) { |
|
| 132 | 132 | //client code has indicated these field values are from the database |
| 133 | - foreach($fieldValues as $field_name => $field_value_from_db){ |
|
| 134 | - $this->set_from_db($field_name,$field_value_from_db); |
|
| 133 | + foreach ($fieldValues as $field_name => $field_value_from_db) { |
|
| 134 | + $this->set_from_db($field_name, $field_value_from_db); |
|
| 135 | 135 | } |
| 136 | - }else{ |
|
| 136 | + } else { |
|
| 137 | 137 | //we're constructing a brand |
| 138 | 138 | //new instance of the model object. Generally, this means we'll need to do more field validation |
| 139 | - foreach($model_fields as $fieldName => $field_obj){ |
|
| 140 | - $this->set($fieldName,isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null ,true); |
|
| 139 | + foreach ($model_fields as $fieldName => $field_obj) { |
|
| 140 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
@@ -146,14 +146,14 @@ discard block |
||
| 146 | 146 | //remember what values were passed to this constructor |
| 147 | 147 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
| 148 | 148 | //remember in entity mapper |
| 149 | - if($model->has_primary_key_field() && $this->ID() && ! $bydb ){ |
|
| 149 | + if ($model->has_primary_key_field() && $this->ID() && ! $bydb) { |
|
| 150 | 150 | $model->add_to_entity_map($this); |
| 151 | 151 | } |
| 152 | 152 | //setup all the relations |
| 153 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
| 154 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
| 153 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
| 154 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
| 155 | 155 | $this->_model_relations[$relation_name] = NULL; |
| 156 | - }else{ |
|
| 156 | + } else { |
|
| 157 | 157 | $this->_model_relations[$relation_name] = array(); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * Action done at the end of each model object construction |
| 162 | 162 | * @param EE_Base_Class $this the model object just created |
| 163 | 163 | */ |
| 164 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
| 164 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | * @param string $field_name |
| 174 | 174 | * @return mixed|null |
| 175 | 175 | */ |
| 176 | - public function get_original( $field_name ){ |
|
| 177 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
| 178 | - $field_settings = $this->get_Model()->field_settings_for( $field_name )){ |
|
| 179 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
| 180 | - }else{ |
|
| 176 | + public function get_original($field_name) { |
|
| 177 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
| 178 | + $field_settings = $this->get_Model()->field_settings_for($field_name)) { |
|
| 179 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
| 180 | + } else { |
|
| 181 | 181 | return NULL; |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @param EE_Base_Class $obj |
| 188 | 188 | * @return string |
| 189 | 189 | */ |
| 190 | - public function get_class($obj){ |
|
| 190 | + public function get_class($obj) { |
|
| 191 | 191 | return get_class($obj); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -200,24 +200,24 @@ discard block |
||
| 200 | 200 | * @param mixed $field_value |
| 201 | 201 | * @param bool $use_default |
| 202 | 202 | */ |
| 203 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
| 204 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
| 205 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
| 206 | - if ( method_exists( $field_obj, 'set_timezone' )) { |
|
| 207 | - $field_obj->set_timezone( $this->_timezone ); |
|
| 203 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
| 204 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
| 205 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
| 206 | + if (method_exists($field_obj, 'set_timezone')) { |
|
| 207 | + $field_obj->set_timezone($this->_timezone); |
|
| 208 | 208 | } |
| 209 | 209 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
| 210 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
| 210 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
| 211 | 211 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
| 212 | - }else{ |
|
| 212 | + } else { |
|
| 213 | 213 | $this->_fields[$field_name] = $holder_of_value; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | //if we're not in the constructor... |
| 217 | 217 | //now check if what we set was a primary key |
| 218 | - if($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
|
| 218 | + if ($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
|
| 219 | 219 | $field_name == $this->_get_primary_key_name(get_class($this)) && |
| 220 | - $field_value){ |
|
| 220 | + $field_value) { |
|
| 221 | 221 | //if so, we want all this object's fields to be filled either with |
| 222 | 222 | //what we've explicitly set on this model |
| 223 | 223 | //or what we have in the db |
@@ -225,19 +225,19 @@ discard block |
||
| 225 | 225 | $fields_on_model = $this->_get_model(get_class($this))->field_settings(); |
| 226 | 226 | |
| 227 | 227 | $obj_in_db = $this->_get_model(get_class($this))->get_one_by_ID($field_value); |
| 228 | - foreach($fields_on_model as $field_obj){ |
|
| 229 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
| 230 | - && $field_obj->get_name() != $field_name ){ |
|
| 228 | + foreach ($fields_on_model as $field_obj) { |
|
| 229 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
| 230 | + && $field_obj->get_name() != $field_name) { |
|
| 231 | 231 | |
| 232 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
| 232 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | //oh this model object has an ID? well make sure its in the entity mapper |
| 236 | 236 | $this->get_model()->add_to_entity_map($this); |
| 237 | 237 | } |
| 238 | 238 | //let's unset any cache for this field_name from the $_cached_properties property. |
| 239 | - $this->_clear_cached_property( $field_name ); |
|
| 240 | - }else{ |
|
| 239 | + $this->_clear_cached_property($field_name); |
|
| 240 | + } else { |
|
| 241 | 241 | echo "\r\n\r\nSAAAY WHAT?? $field_name doesnt have a field???"; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -253,17 +253,17 @@ discard block |
||
| 253 | 253 | * @param string $timezone A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php |
| 254 | 254 | * @return void |
| 255 | 255 | */ |
| 256 | - public function set_timezone( $timezone = '' ) { |
|
| 257 | - $timezone = empty( $timezone ) ? get_option( 'timezone_string' ) : $timezone; |
|
| 256 | + public function set_timezone($timezone = '') { |
|
| 257 | + $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
| 258 | 258 | |
| 259 | 259 | //if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
| 260 | - if ( empty( $timezone ) ) { |
|
| 260 | + if (empty($timezone)) { |
|
| 261 | 261 | //let's get a the WordPress UTC offset |
| 262 | 262 | $offset = get_option('gmt_offset'); |
| 263 | - $timezone = EE_Datetime_Field::timezone_convert_to_string_from_offset( $offset ); |
|
| 263 | + $timezone = EE_Datetime_Field::timezone_convert_to_string_from_offset($offset); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - EE_Datetime_Field::validate_timezone( $timezone ); //just running validation on the timezone. |
|
| 266 | + EE_Datetime_Field::validate_timezone($timezone); //just running validation on the timezone. |
|
| 267 | 267 | $this->_timezone = $timezone; |
| 268 | 268 | //make sure we clear all cached properties because they won't be relevant now |
| 269 | 269 | $this->_clear_cached_properties(); |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | * @param string $dt_frmt |
| 295 | 295 | * @return string |
| 296 | 296 | */ |
| 297 | - public static function fix_date_format_for_use_with_strtotime( $dt_frmt ) { |
|
| 297 | + public static function fix_date_format_for_use_with_strtotime($dt_frmt) { |
|
| 298 | 298 | // if the date format is d/m/y |
| 299 | - if ( strpos( $dt_frmt, 'd/' )=== 0 ) { |
|
| 299 | + if (strpos($dt_frmt, 'd/') === 0) { |
|
| 300 | 300 | // change it to d-m-y, or else strtotime() will think it is m/d/y |
| 301 | - $dt_frmt = str_replace( '/', '-', $dt_frmt ); |
|
| 301 | + $dt_frmt = str_replace('/', '-', $dt_frmt); |
|
| 302 | 302 | } |
| 303 | 303 | return $dt_frmt; |
| 304 | 304 | } |
@@ -316,17 +316,17 @@ discard block |
||
| 316 | 316 | * @throws EE_Error |
| 317 | 317 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
| 318 | 318 | */ |
| 319 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
| 319 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
| 320 | 320 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
| 321 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
| 321 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
| 322 | 322 | return FALSE; |
| 323 | 323 | } |
| 324 | 324 | // also get "how" the object is related, or throw an error |
| 325 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
| 326 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
| 325 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
| 326 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
| 327 | 327 | } |
| 328 | 328 | // how many things are related ? |
| 329 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
| 329 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
| 330 | 330 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
| 331 | 331 | // so for these model objects just set it to be cached |
| 332 | 332 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -334,26 +334,26 @@ discard block |
||
| 334 | 334 | } else { |
| 335 | 335 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
| 336 | 336 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
| 337 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
| 337 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
| 338 | 338 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
| 339 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
| 339 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
| 340 | 340 | } |
| 341 | 341 | // first check for a cache_id which is normally empty |
| 342 | - if ( ! empty( $cache_id )) { |
|
| 342 | + if ( ! empty($cache_id)) { |
|
| 343 | 343 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
| 344 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
| 344 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
| 345 | 345 | $return = $cache_id; |
| 346 | - } elseif ( $object_to_cache->ID() ) { |
|
| 346 | + } elseif ($object_to_cache->ID()) { |
|
| 347 | 347 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
| 348 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
| 348 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
| 349 | 349 | $return = $object_to_cache->ID(); |
| 350 | 350 | } else { |
| 351 | 351 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
| 352 | 352 | $this->_model_relations[$relationName][] = $object_to_cache; |
| 353 | 353 | // move the internal pointer to the end of the array |
| 354 | - end( $this->_model_relations[$relationName] ); |
|
| 354 | + end($this->_model_relations[$relationName]); |
|
| 355 | 355 | // and grab the key so that we can return it |
| 356 | - $return = key( $this->_model_relations[$relationName] ); |
|
| 356 | + $return = key($this->_model_relations[$relationName]); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | } |
@@ -371,11 +371,11 @@ discard block |
||
| 371 | 371 | * @param null $cache_type |
| 372 | 372 | * @return void |
| 373 | 373 | */ |
| 374 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
| 374 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
| 375 | 375 | //first make sure this property exists |
| 376 | 376 | $this->get_model()->field_settings_for($fieldname); |
| 377 | 377 | |
| 378 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
| 378 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
| 379 | 379 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
| 380 | 380 | } |
| 381 | 381 | |
@@ -390,24 +390,24 @@ discard block |
||
| 390 | 390 | * It can also accept certain pre-defined "schema" strings to define how to output the property. see the field's prepare_for_pretty_echoing for what strings can be used |
| 391 | 391 | * @return mixed whatever the value for the property is we're retrieving |
| 392 | 392 | */ |
| 393 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
| 393 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
| 394 | 394 | //verify the field exists |
| 395 | 395 | $this->get_model()->field_settings_for($fieldname); |
| 396 | 396 | |
| 397 | 397 | $cache_type = $pretty ? 'pretty' : 'standard'; |
| 398 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
| 398 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
| 399 | 399 | |
| 400 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
| 400 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
| 401 | 401 | return $this->_cached_properties[$fieldname][$cache_type]; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
| 405 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
| 406 | - if( ! isset($this->_fields[$fieldname])){ |
|
| 405 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
| 406 | + if ( ! isset($this->_fields[$fieldname])) { |
|
| 407 | 407 | $this->_fields[$fieldname] = NULL; |
| 408 | 408 | } |
| 409 | - $value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
| 410 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
| 409 | + $value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
| 410 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
| 411 | 411 | return $value; |
| 412 | 412 | } |
| 413 | 413 | return FALSE; |
@@ -433,9 +433,9 @@ discard block |
||
| 433 | 433 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
| 434 | 434 | * @return void |
| 435 | 435 | */ |
| 436 | - protected function _clear_cached_property( $property_name ) { |
|
| 437 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) |
|
| 438 | - unset( $this->_cached_properties[ $property_name ] ); |
|
| 436 | + protected function _clear_cached_property($property_name) { |
|
| 437 | + if (isset($this->_cached_properties[$property_name])) |
|
| 438 | + unset($this->_cached_properties[$property_name]); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | * @param string $model_name name of the related thing, eg 'Attendee', |
| 447 | 447 | * @return EE_Base_Class |
| 448 | 448 | */ |
| 449 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
| 449 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
| 450 | 450 | $other_model_instance = self::_get_model_instance_with_name(self::_get_model_classname($model_name), $this->_timezone); |
| 451 | 451 | $model_obj = $other_model_instance->ensure_is_obj($object_or_id); |
| 452 | 452 | return $model_obj; |
@@ -466,55 +466,55 @@ discard block |
||
| 466 | 466 | * @throws EE_Error |
| 467 | 467 | * @return EE_Base_Class from which was cleared from the cache, or true if we requested to remove a relation from all |
| 468 | 468 | */ |
| 469 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
| 469 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
| 470 | 470 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
| 471 | 471 | $index_in_cache = ''; |
| 472 | - if( ! $relationship_to_model){ |
|
| 473 | - throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache",'event_espresso'),$relationName,get_class($this))); |
|
| 472 | + if ( ! $relationship_to_model) { |
|
| 473 | + throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), $relationName, get_class($this))); |
|
| 474 | 474 | } |
| 475 | - if($clear_all){ |
|
| 475 | + if ($clear_all) { |
|
| 476 | 476 | $obj_removed = true; |
| 477 | 477 | $this->_model_relations[$relationName] = null; |
| 478 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
| 478 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
| 479 | 479 | $obj_removed = $this->_model_relations[$relationName]; |
| 480 | 480 | $this->_model_relations[$relationName] = null; |
| 481 | - }else{ |
|
| 482 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
| 481 | + } else { |
|
| 482 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
| 483 | 483 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
| 484 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
| 484 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
| 485 | 485 | $index_found_at = NULL; |
| 486 | 486 | //find this object in the array even though it has a different key |
| 487 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
| 488 | - if( $obj instanceof EE_Base_Class && ( $obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID() )) { |
|
| 487 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
| 488 | + if ($obj instanceof EE_Base_Class && ($obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID())) { |
|
| 489 | 489 | $index_found_at = $index; |
| 490 | 490 | break; |
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | - if($index_found_at){ |
|
| 493 | + if ($index_found_at) { |
|
| 494 | 494 | $index_in_cache = $index_found_at; |
| 495 | - }else{ |
|
| 495 | + } else { |
|
| 496 | 496 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
| 497 | 497 | //if it wasn't in it to begin with. So we're done |
| 498 | 498 | return $object_to_remove_or_index_into_array; |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
| 501 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
| 502 | 502 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
| 503 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
| 504 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
| 503 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
| 504 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
| 505 | 505 | $index_in_cache = $index; |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | - }else{ |
|
| 508 | + } else { |
|
| 509 | 509 | $index_in_cache = $object_to_remove_or_index_into_array; |
| 510 | 510 | } |
| 511 | 511 | //supposedly we've found it. But it could just be that the client code |
| 512 | 512 | //provided a bad index/object |
| 513 | - if(isset( $this->_model_relations[$relationName]) && |
|
| 514 | - isset( $this->_model_relations[$relationName][$index_in_cache])){ |
|
| 513 | + if (isset($this->_model_relations[$relationName]) && |
|
| 514 | + isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
| 515 | 515 | $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
| 516 | 516 | unset($this->_model_relations[$relationName][$index_in_cache]); |
| 517 | - }else{ |
|
| 517 | + } else { |
|
| 518 | 518 | //that thing was never cached anyways. |
| 519 | 519 | $obj_removed = NULL; |
| 520 | 520 | } |
@@ -533,24 +533,24 @@ discard block |
||
| 533 | 533 | * @param string $current_cache_id - the ID that was used when originally caching the object |
| 534 | 534 | * @return boolean TRUE on success, FALSE on fail |
| 535 | 535 | */ |
| 536 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
| 536 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
| 537 | 537 | // verify that incoming object is of the correct type |
| 538 | - $obj_class = 'EE_' . $relationName; |
|
| 539 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
| 538 | + $obj_class = 'EE_'.$relationName; |
|
| 539 | + if ($newly_saved_object instanceof $obj_class) { |
|
| 540 | 540 | /* @type EE_Base_Class $newly_saved_object*/ |
| 541 | 541 | // now get the type of relation |
| 542 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
| 542 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
| 543 | 543 | // if this is a 1:1 relationship |
| 544 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
| 544 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
| 545 | 545 | // then just replace the cached object with the newly saved object |
| 546 | 546 | $this->_model_relations[$relationName] = $newly_saved_object; |
| 547 | 547 | return TRUE; |
| 548 | 548 | // or if it's some kind of sordid feral polyamorous relationship... |
| 549 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
| 549 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
| 550 | 550 | // then remove the current cached item |
| 551 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
| 551 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
| 552 | 552 | // and cache the newly saved object using it's new ID |
| 553 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
| 553 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
| 554 | 554 | return TRUE; |
| 555 | 555 | } |
| 556 | 556 | } |
@@ -566,11 +566,11 @@ discard block |
||
| 566 | 566 | * @param string $relationName |
| 567 | 567 | * @return EE_Base_Class |
| 568 | 568 | */ |
| 569 | - public function get_one_from_cache($relationName){ |
|
| 570 | - $cached_array_or_object = $this->_model_relations[$relationName]; |
|
| 571 | - if(is_array($cached_array_or_object)){ |
|
| 569 | + public function get_one_from_cache($relationName) { |
|
| 570 | + $cached_array_or_object = $this->_model_relations[$relationName]; |
|
| 571 | + if (is_array($cached_array_or_object)) { |
|
| 572 | 572 | return array_shift($cached_array_or_object); |
| 573 | - }else{ |
|
| 573 | + } else { |
|
| 574 | 574 | return $cached_array_or_object; |
| 575 | 575 | } |
| 576 | 576 | } |
@@ -585,14 +585,14 @@ discard block |
||
| 585 | 585 | * @throws \EE_Error |
| 586 | 586 | * @return EE_Base_Class[] |
| 587 | 587 | */ |
| 588 | - public function get_all_from_cache($relationName){ |
|
| 589 | - $cached_array_or_object = $this->_model_relations[$relationName]; |
|
| 590 | - if(is_array($cached_array_or_object)){ |
|
| 588 | + public function get_all_from_cache($relationName) { |
|
| 589 | + $cached_array_or_object = $this->_model_relations[$relationName]; |
|
| 590 | + if (is_array($cached_array_or_object)) { |
|
| 591 | 591 | $objects = $cached_array_or_object; |
| 592 | - }elseif($cached_array_or_object){ |
|
| 592 | + }elseif ($cached_array_or_object) { |
|
| 593 | 593 | //if the result is not an array, but exists, make it an array |
| 594 | 594 | $objects = array($cached_array_or_object); |
| 595 | - }else{ |
|
| 595 | + } else { |
|
| 596 | 596 | //if nothing was found, return an empty array |
| 597 | 597 | $objects = array(); |
| 598 | 598 | } |
@@ -600,15 +600,15 @@ discard block |
||
| 600 | 600 | //basically, if this model object was stored in the session, and these cached model objects |
| 601 | 601 | //already have IDs, let's make sure they're in their model's entity mapper |
| 602 | 602 | //otherwise we will have duplicates next time we call EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
| 603 | - foreach( $objects as $model_object ){ |
|
| 604 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
| 605 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
| 603 | + foreach ($objects as $model_object) { |
|
| 604 | + $model = EE_Registry::instance()->load_model($relationName); |
|
| 605 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
| 606 | 606 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
| 607 | - if( $model_object->ID() ){ |
|
| 608 | - $model->add_to_entity_map( $model_object ); |
|
| 607 | + if ($model_object->ID()) { |
|
| 608 | + $model->add_to_entity_map($model_object); |
|
| 609 | 609 | } |
| 610 | - }else{ |
|
| 611 | - throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object ))); |
|
| 610 | + } else { |
|
| 611 | + throw new EE_Error(sprintf(__('Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso'), $relationName, gettype($model_object))); |
|
| 612 | 612 | } |
| 613 | 613 | } |
| 614 | 614 | return $objects; |
@@ -622,20 +622,20 @@ discard block |
||
| 622 | 622 | * @param string $field_name |
| 623 | 623 | * @param mixed $field_value_from_db |
| 624 | 624 | */ |
| 625 | - public function set_from_db($field_name,$field_value_from_db){ |
|
| 625 | + public function set_from_db($field_name, $field_value_from_db) { |
|
| 626 | 626 | $field_obj = $this->get_model()->field_settings_for($field_name); |
| 627 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
| 627 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
| 628 | 628 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
| 629 | 629 | //eg, a CPT model object could have an entry in the posts table, but no |
| 630 | 630 | //entry in the meta table. Meaning that all its columns in the meta table |
| 631 | 631 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
| 632 | - if($field_value_from_db === NULL && ! $field_obj->is_nullable()){ |
|
| 632 | + if ($field_value_from_db === NULL && ! $field_obj->is_nullable()) { |
|
| 633 | 633 | $field_value = $field_obj->get_default_value(); |
| 634 | - }else{ |
|
| 634 | + } else { |
|
| 635 | 635 | $field_value = $field_value_from_db; |
| 636 | 636 | } |
| 637 | 637 | $this->_fields[$field_name] = $field_obj->prepare_for_set_from_db($field_value); |
| 638 | - $this->_clear_cached_property( $field_name ); |
|
| 638 | + $this->_clear_cached_property($field_name); |
|
| 639 | 639 | } |
| 640 | 640 | } |
| 641 | 641 | |
@@ -647,8 +647,8 @@ discard block |
||
| 647 | 647 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
| 648 | 648 | * @return boolean |
| 649 | 649 | */ |
| 650 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
| 651 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
| 650 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
| 651 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
| 674 | 674 | * @return void |
| 675 | 675 | */ |
| 676 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
| 676 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
| 677 | 677 | echo $this->get_pretty($field_name, $extra_cache_ref); |
| 678 | 678 | } |
| 679 | 679 | /** |
@@ -682,8 +682,8 @@ discard block |
||
| 682 | 682 | * @param string $field_name |
| 683 | 683 | * @return void |
| 684 | 684 | */ |
| 685 | - public function f($field_name){ |
|
| 686 | - $this->e($field_name,'form_input'); |
|
| 685 | + public function f($field_name) { |
|
| 686 | + $this->e($field_name, 'form_input'); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /** |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
| 693 | 693 | * @return mixed |
| 694 | 694 | */ |
| 695 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
| 696 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
| 695 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
| 696 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | |
@@ -710,36 +710,36 @@ discard block |
||
| 710 | 710 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
| 711 | 711 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
| 712 | 712 | */ |
| 713 | - protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
|
| 713 | + protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) { |
|
| 714 | 714 | |
| 715 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : EE_Base_Class::fix_date_format_for_use_with_strtotime( $dt_frmt ); |
|
| 715 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : EE_Base_Class::fix_date_format_for_use_with_strtotime($dt_frmt); |
|
| 716 | 716 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
| 717 | 717 | |
| 718 | 718 | |
| 719 | 719 | //validate field for datetime and returns field settings if valid. |
| 720 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
| 720 | + $field = $this->_get_dtt_field_settings($field_name); |
|
| 721 | 721 | |
| 722 | - if ( $dt_frmt !== NULL ) { |
|
| 723 | - $this->_clear_cached_property( $field_name, $date_or_time ); |
|
| 722 | + if ($dt_frmt !== NULL) { |
|
| 723 | + $this->_clear_cached_property($field_name, $date_or_time); |
|
| 724 | 724 | } |
| 725 | - if ( $echo ) |
|
| 726 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
| 725 | + if ($echo) |
|
| 726 | + $field->set_pretty_date_format($in_dt_frmt); |
|
| 727 | 727 | else |
| 728 | - $field->set_date_format( $in_dt_frmt ); |
|
| 728 | + $field->set_date_format($in_dt_frmt); |
|
| 729 | 729 | |
| 730 | - if ( $tm_frmt !== NULL ) { |
|
| 731 | - $this->_clear_cached_property( $field_name, $date_or_time ); |
|
| 730 | + if ($tm_frmt !== NULL) { |
|
| 731 | + $this->_clear_cached_property($field_name, $date_or_time); |
|
| 732 | 732 | } |
| 733 | - if ( $echo ) |
|
| 734 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
| 733 | + if ($echo) |
|
| 734 | + $field->set_pretty_time_format($in_tm_frmt); |
|
| 735 | 735 | else |
| 736 | - $field->set_time_format( $in_tm_frmt ); |
|
| 736 | + $field->set_time_format($in_tm_frmt); |
|
| 737 | 737 | |
| 738 | 738 | //set timezone in field object |
| 739 | - $field->set_timezone( $this->_timezone ); |
|
| 739 | + $field->set_timezone($this->_timezone); |
|
| 740 | 740 | |
| 741 | 741 | //set the output returned |
| 742 | - switch ( $date_or_time ) { |
|
| 742 | + switch ($date_or_time) { |
|
| 743 | 743 | |
| 744 | 744 | case 'D' : |
| 745 | 745 | $field->set_date_time_output('date'); |
@@ -754,11 +754,11 @@ discard block |
||
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | |
| 757 | - if ( $echo ) { |
|
| 758 | - $this->e( $field_name, $date_or_time ); |
|
| 757 | + if ($echo) { |
|
| 758 | + $this->e($field_name, $date_or_time); |
|
| 759 | 759 | return ''; |
| 760 | 760 | } |
| 761 | - return $this->get( $field_name, $date_or_time ); |
|
| 761 | + return $this->get($field_name, $date_or_time); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | |
@@ -768,8 +768,8 @@ discard block |
||
| 768 | 768 | * @param string $format format for the date returned (if NULL we use default in dt_frmt property) |
| 769 | 769 | * @return string datetime value formatted |
| 770 | 770 | */ |
| 771 | - public function get_date( $field_name, $format = NULL ) { |
|
| 772 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
| 771 | + public function get_date($field_name, $format = NULL) { |
|
| 772 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | |
@@ -778,8 +778,8 @@ discard block |
||
| 778 | 778 | * @param $field_name |
| 779 | 779 | * @param null $format |
| 780 | 780 | */ |
| 781 | - public function e_date( $field_name, $format = NULL ) { |
|
| 782 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
| 781 | + public function e_date($field_name, $format = NULL) { |
|
| 782 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | |
@@ -789,8 +789,8 @@ discard block |
||
| 789 | 789 | * @param string $format format for the time returned ( if NULL we use default in tm_frmt property) |
| 790 | 790 | * @return string datetime value formatted |
| 791 | 791 | */ |
| 792 | - public function get_time( $field_name, $format = NULL ) { |
|
| 793 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
| 792 | + public function get_time($field_name, $format = NULL) { |
|
| 793 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | |
@@ -799,8 +799,8 @@ discard block |
||
| 799 | 799 | * @param $field_name |
| 800 | 800 | * @param null $format |
| 801 | 801 | */ |
| 802 | - public function e_time( $field_name, $format = NULL ) { |
|
| 803 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
| 802 | + public function e_time($field_name, $format = NULL) { |
|
| 803 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | |
@@ -813,8 +813,8 @@ discard block |
||
| 813 | 813 | * @param string $tm_frmt format for the time returned (if NULL we use default in tm_frmt property) |
| 814 | 814 | * @return string datetime value formatted |
| 815 | 815 | */ |
| 816 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
| 817 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
| 816 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
| 817 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | |
@@ -824,8 +824,8 @@ discard block |
||
| 824 | 824 | * @param null $dt_frmt |
| 825 | 825 | * @param null $tm_frmt |
| 826 | 826 | */ |
| 827 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
| 828 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
| 827 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
| 828 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | |
@@ -839,9 +839,9 @@ discard block |
||
| 839 | 839 | * |
| 840 | 840 | * @return string Date and time string in set locale. |
| 841 | 841 | */ |
| 842 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
| 843 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
| 844 | - return date_i18n( $format, strtotime( $this->_get_datetime( $field_name, NULL, NULL, NULL, false ) ) ); |
|
| 842 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
| 843 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
| 844 | + return date_i18n($format, strtotime($this->_get_datetime($field_name, NULL, NULL, NULL, false))); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | |
@@ -852,14 +852,14 @@ discard block |
||
| 852 | 852 | * @throws EE_Error |
| 853 | 853 | * @return EE_Datetime_Field |
| 854 | 854 | */ |
| 855 | - protected function _get_dtt_field_settings( $field_name ) { |
|
| 855 | + protected function _get_dtt_field_settings($field_name) { |
|
| 856 | 856 | $field = $this->get_model()->field_settings_for($field_name); |
| 857 | 857 | |
| 858 | 858 | //check if field is dtt |
| 859 | - if ( $field instanceof EE_Datetime_Field ) { |
|
| 859 | + if ($field instanceof EE_Datetime_Field) { |
|
| 860 | 860 | return $field; |
| 861 | 861 | } else { |
| 862 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
| 862 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
| 863 | 863 | } |
| 864 | 864 | } |
| 865 | 865 | |
@@ -880,8 +880,8 @@ discard block |
||
| 880 | 880 | * @param string $time a valid time string for php datetime functions |
| 881 | 881 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
| 882 | 882 | */ |
| 883 | - protected function _set_time_for( $time, $fieldname ) { |
|
| 884 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
| 883 | + protected function _set_time_for($time, $fieldname) { |
|
| 884 | + $this->_set_date_time('T', $time, $fieldname); |
|
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | * @param string $date a valid date string for php datetime functions |
| 896 | 896 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
| 897 | 897 | */ |
| 898 | - protected function _set_date_for( $date, $fieldname ) { |
|
| 899 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
| 898 | + protected function _set_date_for($date, $fieldname) { |
|
| 899 | + $this->_set_date_time('D', $date, $fieldname); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | |
@@ -912,19 +912,19 @@ discard block |
||
| 912 | 912 | * @param string $datetime_value A valid Date or Time string |
| 913 | 913 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
| 914 | 914 | */ |
| 915 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
| 916 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
| 917 | - $field->set_timezone( $this->_timezone ); |
|
| 915 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
| 916 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
| 917 | + $field->set_timezone($this->_timezone); |
|
| 918 | 918 | |
| 919 | - switch ( $what ) { |
|
| 919 | + switch ($what) { |
|
| 920 | 920 | case 'T' : |
| 921 | - $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( $datetime_value, $this->_fields[$fieldname] ); |
|
| 921 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time($datetime_value, $this->_fields[$fieldname]); |
|
| 922 | 922 | break; |
| 923 | 923 | case 'D' : |
| 924 | - $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( $datetime_value, $this->_fields[$fieldname] ); |
|
| 924 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date($datetime_value, $this->_fields[$fieldname]); |
|
| 925 | 925 | break; |
| 926 | 926 | case 'B' : |
| 927 | - $this->_fields[$fieldname] = $field->prepare_for_set( $datetime_value ); |
|
| 927 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
| 928 | 928 | break; |
| 929 | 929 | } |
| 930 | 930 | |
@@ -947,25 +947,25 @@ discard block |
||
| 947 | 947 | * @throws EE_Error |
| 948 | 948 | * @return string timestamp |
| 949 | 949 | */ |
| 950 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
| 950 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
| 951 | 951 | EE_Registry::instance()->load_helper('DTT_Helper'); |
| 952 | 952 | $timezone = EEH_DTT_Helper::get_timezone(); |
| 953 | 953 | |
| 954 | - if ( $timezone == $this->_timezone ) |
|
| 954 | + if ($timezone == $this->_timezone) |
|
| 955 | 955 | return ''; |
| 956 | 956 | |
| 957 | 957 | $original_timezone = $this->_timezone; |
| 958 | - $this->set_timezone( $timezone ); |
|
| 958 | + $this->set_timezone($timezone); |
|
| 959 | 959 | |
| 960 | 960 | $fn = (array) $field_name; |
| 961 | - $args = array_merge( $fn, (array) $args ); |
|
| 961 | + $args = array_merge($fn, (array) $args); |
|
| 962 | 962 | |
| 963 | - if ( !method_exists( $this, $callback ) ) |
|
| 964 | - throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
| 963 | + if ( ! method_exists($this, $callback)) |
|
| 964 | + throw new EE_Error(sprintf(__('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback)); |
|
| 965 | 965 | $args = (array) $args; |
| 966 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
| 966 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
| 967 | 967 | |
| 968 | - $this->set_timezone( $original_timezone ); |
|
| 968 | + $this->set_timezone($original_timezone); |
|
| 969 | 969 | return $return; |
| 970 | 970 | } |
| 971 | 971 | |
@@ -976,20 +976,20 @@ discard block |
||
| 976 | 976 | * Deletes this model object. That may mean just 'soft deleting' it though. |
| 977 | 977 | * @return boolean | int |
| 978 | 978 | */ |
| 979 | - public function delete(){ |
|
| 979 | + public function delete() { |
|
| 980 | 980 | /** |
| 981 | 981 | * Called just before deleting a model object |
| 982 | 982 | * |
| 983 | 983 | * @param EE_Base_Class $model_object about to be 'deleted' |
| 984 | 984 | */ |
| 985 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
| 986 | - $result = $this->get_model()->delete_by_ID( $this->ID() ); |
|
| 985 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
| 986 | + $result = $this->get_model()->delete_by_ID($this->ID()); |
|
| 987 | 987 | /** |
| 988 | 988 | * Called just after deleting a model object |
| 989 | 989 | * @param EE_Base_Class $model_object that was just 'deleted' |
| 990 | 990 | * @param boolean $result |
| 991 | 991 | */ |
| 992 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
| 992 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
| 993 | 993 | return $result; |
| 994 | 994 | } |
| 995 | 995 | |
@@ -999,11 +999,11 @@ discard block |
||
| 999 | 999 | * Deletes this model object permanently from db (but keep in mind related models my block the delete and return an error) |
| 1000 | 1000 | * @return bool |
| 1001 | 1001 | */ |
| 1002 | - public function delete_permanently(){ |
|
| 1003 | - $model=$this->get_model(); |
|
| 1004 | - if($model instanceof EEM_Soft_Delete_Base){ |
|
| 1005 | - $result=$model->delete_permanently_by_ID($this->ID()); |
|
| 1006 | - }else{ |
|
| 1002 | + public function delete_permanently() { |
|
| 1003 | + $model = $this->get_model(); |
|
| 1004 | + if ($model instanceof EEM_Soft_Delete_Base) { |
|
| 1005 | + $result = $model->delete_permanently_by_ID($this->ID()); |
|
| 1006 | + } else { |
|
| 1007 | 1007 | $result = $this->delete(); |
| 1008 | 1008 | } |
| 1009 | 1009 | return $result ? true : false; |
@@ -1021,17 +1021,17 @@ discard block |
||
| 1021 | 1021 | * @throws \EE_Error |
| 1022 | 1022 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure |
| 1023 | 1023 | */ |
| 1024 | - public function save($set_cols_n_values=array()) { |
|
| 1024 | + public function save($set_cols_n_values = array()) { |
|
| 1025 | 1025 | /** |
| 1026 | 1026 | * Filters the fields we're about to save on the model object |
| 1027 | 1027 | * |
| 1028 | 1028 | * @param array $set_cols_n_values |
| 1029 | 1029 | * @param EE_Base_Class $model_object |
| 1030 | 1030 | */ |
| 1031 | - $set_cols_n_values = apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
| 1031 | + $set_cols_n_values = apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
| 1032 | 1032 | //set attributes as provided in $set_cols_n_values |
| 1033 | - foreach($set_cols_n_values as $column=>$value){ |
|
| 1034 | - $this->set($column,$value); |
|
| 1033 | + foreach ($set_cols_n_values as $column=>$value) { |
|
| 1034 | + $this->set($column, $value); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | /** |
| 1037 | 1037 | * Saving a model object. |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | * Before we perform a save, this action is fired. |
| 1040 | 1040 | * @param EE_Base_Class $model_object the model object about to be saved. |
| 1041 | 1041 | */ |
| 1042 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
| 1042 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
| 1043 | 1043 | //now get current attribute values |
| 1044 | 1044 | $save_cols_n_values = $this->_fields; |
| 1045 | 1045 | //if the object already has an ID, update it. Otherwise, insert it |
@@ -1047,61 +1047,61 @@ discard block |
||
| 1047 | 1047 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
| 1048 | 1048 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
| 1049 | 1049 | //does this model have an autoincrement PK? |
| 1050 | - if($this->get_model()->has_primary_key_field()){ |
|
| 1051 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
| 1050 | + if ($this->get_model()->has_primary_key_field()) { |
|
| 1051 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
| 1052 | 1052 | //ok check if it's set, if so: update; if not, insert |
| 1053 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
| 1054 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
| 1053 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
| 1054 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
| 1055 | 1055 | } else { |
| 1056 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
| 1057 | - $results = $this->get_model()->insert( $save_cols_n_values, true); |
|
| 1058 | - if($results){ |
|
| 1056 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
| 1057 | + $results = $this->get_model()->insert($save_cols_n_values, true); |
|
| 1058 | + if ($results) { |
|
| 1059 | 1059 | //if successful, set the primary key |
| 1060 | 1060 | //but don't use the normal SET method, because it will check if |
| 1061 | 1061 | //an item with the same ID exists in the mapper & db, then |
| 1062 | 1062 | //will find it in the db (because we just added it) and THAT object |
| 1063 | 1063 | //will get added to the mapper before we can add this one! |
| 1064 | 1064 | //but if we just avoid using the SET method, all that headache can be avoided |
| 1065 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
| 1065 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
| 1066 | 1066 | $this->_fields[$pk_field_name] = $results; |
| 1067 | 1067 | $this->_clear_cached_property($pk_field_name); |
| 1068 | - $this->get_model()->add_to_entity_map( $this ); |
|
| 1068 | + $this->get_model()->add_to_entity_map($this); |
|
| 1069 | 1069 | $this->_update_cached_related_model_objs_fks(); |
| 1070 | 1070 | } |
| 1071 | 1071 | } |
| 1072 | - }else{//PK is NOT auto-increment |
|
| 1072 | + } else {//PK is NOT auto-increment |
|
| 1073 | 1073 | //so check if one like it already exists in the db |
| 1074 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
| 1075 | - if( ! $this->in_entity_map() && WP_DEBUG ){ |
|
| 1074 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
| 1075 | + if ( ! $this->in_entity_map() && WP_DEBUG) { |
|
| 1076 | 1076 | throw new EE_Error( |
| 1077 | 1077 | sprintf( |
| 1078 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
| 1078 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
| 1079 | 1079 | get_class($this), |
| 1080 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
| 1081 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
| 1080 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
| 1081 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
| 1082 | 1082 | '<br />' |
| 1083 | 1083 | ) |
| 1084 | 1084 | ); |
| 1085 | 1085 | } |
| 1086 | 1086 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
| 1087 | - }else{ |
|
| 1087 | + } else { |
|
| 1088 | 1088 | $results = $this->get_model()->insert($save_cols_n_values); |
| 1089 | 1089 | $this->_update_cached_related_model_objs_fks(); |
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | - }else{//there is NO primary key |
|
| 1092 | + } else {//there is NO primary key |
|
| 1093 | 1093 | $already_in_db = false; |
| 1094 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
| 1094 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
| 1095 | 1095 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
| 1096 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
| 1096 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
| 1097 | 1097 | $already_in_db = true; |
| 1098 | 1098 | } |
| 1099 | 1099 | } |
| 1100 | - if( $already_in_db ){ |
|
| 1101 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
| 1102 | - $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
|
| 1103 | - }else{ |
|
| 1104 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
| 1100 | + if ($already_in_db) { |
|
| 1101 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
| 1102 | + $results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values); |
|
| 1103 | + } else { |
|
| 1104 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
| 1105 | 1105 | } |
| 1106 | 1106 | } |
| 1107 | 1107 | //restore the old assumption about values being prepared by the model object |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
| 1115 | 1115 | * the new ID (or 0 if an error occurred and it wasn't updated) |
| 1116 | 1116 | */ |
| 1117 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
| 1117 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
| 1118 | 1118 | return $results; |
| 1119 | 1119 | } |
| 1120 | 1120 | |
@@ -1126,13 +1126,13 @@ discard block |
||
| 1126 | 1126 | * and we want to let its cached relations with foreign keys to it know about that change. Eg: we've created a transaction but haven't saved it to the db. We also create a registration and don't save it to the DB, but we DO cache it on the transaction. Now, when we save the transaction, the registration's TXN_ID will be automatically updated, whether or not they exist in the DB (if they do, their DB records will be automatically updated) |
| 1127 | 1127 | * @return void |
| 1128 | 1128 | */ |
| 1129 | - protected function _update_cached_related_model_objs_fks(){ |
|
| 1130 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
| 1131 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
| 1132 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
| 1133 | - $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( $this->get_model()->get_this_model_name() ); |
|
| 1134 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
| 1135 | - if( $related_model_obj_in_cache->ID() ){ |
|
| 1129 | + protected function _update_cached_related_model_objs_fks() { |
|
| 1130 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
| 1131 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
| 1132 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
| 1133 | + $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to($this->get_model()->get_this_model_name()); |
|
| 1134 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
| 1135 | + if ($related_model_obj_in_cache->ID()) { |
|
| 1136 | 1136 | $related_model_obj_in_cache->save(); |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
@@ -1148,21 +1148,21 @@ discard block |
||
| 1148 | 1148 | * and this object and properly setup |
| 1149 | 1149 | * @return int ID of new model object on save; 0 on failure+ |
| 1150 | 1150 | */ |
| 1151 | - public function save_new_cached_related_model_objs(){ |
|
| 1151 | + public function save_new_cached_related_model_objs() { |
|
| 1152 | 1152 | //make sure this has been saved |
| 1153 | - if( ! $this->ID()){ |
|
| 1153 | + if ( ! $this->ID()) { |
|
| 1154 | 1154 | $id = $this->save(); |
| 1155 | - }else{ |
|
| 1155 | + } else { |
|
| 1156 | 1156 | $id = $this->ID(); |
| 1157 | 1157 | } |
| 1158 | 1158 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
| 1159 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
| 1159 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
| 1160 | 1160 | |
| 1161 | 1161 | |
| 1162 | - if($this->_model_relations[$relationName]){ |
|
| 1162 | + if ($this->_model_relations[$relationName]) { |
|
| 1163 | 1163 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
| 1164 | 1164 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
| 1165 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
| 1165 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
| 1166 | 1166 | //add a relation to that relation type (which saves the appropriate thing in the process) |
| 1167 | 1167 | //but ONLY if it DOES NOT exist in the DB |
| 1168 | 1168 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1171,8 +1171,8 @@ discard block |
||
| 1171 | 1171 | $this->_add_relation_to($related_model_obj, $relationName); |
| 1172 | 1172 | $related_model_obj->save_new_cached_related_model_objs(); |
| 1173 | 1173 | // } |
| 1174 | - }else{ |
|
| 1175 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
| 1174 | + } else { |
|
| 1175 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
| 1176 | 1176 | //add a relation to that relation type (which saves the appropriate thing in the process) |
| 1177 | 1177 | //but ONLY if it DOES NOT exist in the DB |
| 1178 | 1178 | // if( ! $related_model_obj->ID()){ |
@@ -1193,8 +1193,8 @@ discard block |
||
| 1193 | 1193 | * @return \EEM_Base | \EEM_CPT_Base |
| 1194 | 1194 | */ |
| 1195 | 1195 | public function get_model() { |
| 1196 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
| 1197 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
| 1196 | + $modelName = self::_get_model_classname(get_class($this)); |
|
| 1197 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | |
@@ -1204,10 +1204,10 @@ discard block |
||
| 1204 | 1204 | * @param $classname |
| 1205 | 1205 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
| 1206 | 1206 | */ |
| 1207 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
| 1207 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
| 1208 | 1208 | //TODO: will not work for Term_Relationships because they have no PK! |
| 1209 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
| 1210 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
| 1209 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
| 1210 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
| 1211 | 1211 | $id = $props_n_values[$primary_id_ref]; |
| 1212 | 1212 | return self::_get_model($classname)->get_from_entity_map($id); |
| 1213 | 1213 | } |
@@ -1224,24 +1224,24 @@ discard block |
||
| 1224 | 1224 | * @param null $timezone |
| 1225 | 1225 | * @return mixed (EE_Base_Class|bool) |
| 1226 | 1226 | */ |
| 1227 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL ) { |
|
| 1228 | - if( self::_get_model( $classname )->has_primary_key_field()){ |
|
| 1229 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
| 1227 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL) { |
|
| 1228 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
| 1229 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
| 1230 | 1230 | |
| 1231 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
| 1232 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] ); |
|
| 1233 | - }else{ |
|
| 1231 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
| 1232 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID($props_n_values[$primary_id_ref]); |
|
| 1233 | + } else { |
|
| 1234 | 1234 | $existing = null; |
| 1235 | 1235 | } |
| 1236 | - }elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
| 1236 | + }elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
| 1237 | 1237 | //no primary key on this model, but there's still a matching item in the DB |
| 1238 | - $existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) ); |
|
| 1239 | - }else{ |
|
| 1238 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID(self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values)); |
|
| 1239 | + } else { |
|
| 1240 | 1240 | $existing = null; |
| 1241 | 1241 | } |
| 1242 | - if ( $existing ) { |
|
| 1243 | - foreach ( $props_n_values as $property => $field_value ) { |
|
| 1244 | - $existing->set( $property, $field_value ); |
|
| 1242 | + if ($existing) { |
|
| 1243 | + foreach ($props_n_values as $property => $field_value) { |
|
| 1244 | + $existing->set($property, $field_value); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | return $existing; |
| 1247 | 1247 | } else { |
@@ -1259,13 +1259,13 @@ discard block |
||
| 1259 | 1259 | * @throws EE_Error |
| 1260 | 1260 | * @return EEM_Base |
| 1261 | 1261 | */ |
| 1262 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
| 1262 | + protected static function _get_model($classname, $timezone = NULL) { |
|
| 1263 | 1263 | //find model for this class |
| 1264 | - if( ! $classname ){ |
|
| 1265 | - throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"),$classname)); |
|
| 1264 | + if ( ! $classname) { |
|
| 1265 | + throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"), $classname)); |
|
| 1266 | 1266 | } |
| 1267 | - $modelName=self::_get_model_classname($classname); |
|
| 1268 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
| 1267 | + $modelName = self::_get_model_classname($classname); |
|
| 1268 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | 1271 | |
@@ -1276,10 +1276,10 @@ discard block |
||
| 1276 | 1276 | * @param null $timezone |
| 1277 | 1277 | * @return EEM_Base |
| 1278 | 1278 | */ |
| 1279 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
| 1280 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
| 1281 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
| 1282 | - $model->set_timezone( $timezone ); |
|
| 1279 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
| 1280 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
| 1281 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
| 1282 | + $model->set_timezone($timezone); |
|
| 1283 | 1283 | return $model; |
| 1284 | 1284 | } |
| 1285 | 1285 | |
@@ -1291,10 +1291,10 @@ discard block |
||
| 1291 | 1291 | * @param null $model_name |
| 1292 | 1292 | * @return string like EEM_Attendee |
| 1293 | 1293 | */ |
| 1294 | - private static function _get_model_classname( $model_name = null){ |
|
| 1295 | - if(strpos($model_name,"EE_")===0){ |
|
| 1296 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
| 1297 | - }else{ |
|
| 1294 | + private static function _get_model_classname($model_name = null) { |
|
| 1295 | + if (strpos($model_name, "EE_") === 0) { |
|
| 1296 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
| 1297 | + } else { |
|
| 1298 | 1298 | $model_classname = "EEM_".$model_name; |
| 1299 | 1299 | } |
| 1300 | 1300 | return $model_classname; |
@@ -1308,11 +1308,11 @@ discard block |
||
| 1308 | 1308 | * @throws EE_Error |
| 1309 | 1309 | * @return string |
| 1310 | 1310 | */ |
| 1311 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
| 1312 | - if( ! $classname){ |
|
| 1313 | - throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),$classname)); |
|
| 1311 | + protected static function _get_primary_key_name($classname = NULL) { |
|
| 1312 | + if ( ! $classname) { |
|
| 1313 | + throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), $classname)); |
|
| 1314 | 1314 | } |
| 1315 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
| 1315 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | 1318 | |
@@ -1324,12 +1324,12 @@ discard block |
||
| 1324 | 1324 | * Usually defaults for integer primary keys are 0; string primary keys are usually NULL). |
| 1325 | 1325 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
| 1326 | 1326 | */ |
| 1327 | - public function ID(){ |
|
| 1327 | + public function ID() { |
|
| 1328 | 1328 | //now that we know the name of the variable, use a variable variable to get its value and return its |
| 1329 | - if( $this->get_model()->has_primary_key_field() ) { |
|
| 1330 | - return $this->_fields[self::_get_primary_key_name( get_class($this) )]; |
|
| 1331 | - }else{ |
|
| 1332 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
| 1329 | + if ($this->get_model()->has_primary_key_field()) { |
|
| 1330 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
| 1331 | + } else { |
|
| 1332 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
| 1333 | 1333 | } |
| 1334 | 1334 | } |
| 1335 | 1335 | |
@@ -1347,24 +1347,24 @@ discard block |
||
| 1347 | 1347 | * @throws EE_Error |
| 1348 | 1348 | * @return EE_Base_Class the object the relation was added to |
| 1349 | 1349 | */ |
| 1350 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $where_query = array(), $cache_id = NULL ){ |
|
| 1350 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array(), $cache_id = NULL) { |
|
| 1351 | 1351 | //if this thing exists in the DB, save the relation to the DB |
| 1352 | - if( $this->ID() ){ |
|
| 1353 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
| 1352 | + if ($this->ID()) { |
|
| 1353 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
| 1354 | 1354 | //clear cache so future get_many_related and get_first_related() return new results. |
| 1355 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
| 1355 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
| 1356 | 1356 | } else { |
| 1357 | 1357 | //this thing doesn't exist in the DB, so just cache it |
| 1358 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
| 1359 | - throw new EE_Error( sprintf( |
|
| 1360 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
| 1358 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
| 1359 | + throw new EE_Error(sprintf( |
|
| 1360 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
| 1361 | 1361 | $otherObjectModelObjectOrID, |
| 1362 | - get_class( $this ) |
|
| 1362 | + get_class($this) |
|
| 1363 | 1363 | )); |
| 1364 | 1364 | } else { |
| 1365 | 1365 | $otherObject = $otherObjectModelObjectOrID; |
| 1366 | 1366 | } |
| 1367 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
| 1367 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | |
@@ -1382,12 +1382,12 @@ discard block |
||
| 1382 | 1382 | * @param array $where_query You can optionally include an array of key=>value pairs that allow you to further constrict the relation to being added. However, keep in mind that the columns (keys) given must match a column on the JOIN table and currently only the HABTM models accept these additional conditions. Also remember that if an exact match isn't found for these extra cols/val pairs, then a NEW row is created in the join table. |
| 1383 | 1383 | * @return EE_Base_Class the relation was removed from |
| 1384 | 1384 | */ |
| 1385 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
| 1386 | - if($this->ID()){//if this exists in the DB, save the relation change to the DB too |
|
| 1387 | - $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
| 1385 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
| 1386 | + if ($this->ID()) {//if this exists in the DB, save the relation change to the DB too |
|
| 1387 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
| 1388 | 1388 | $this->clear_cache($relationName, $otherObject); |
| 1389 | - }else{//this doesn't exist in the DB, just remove it from the cache |
|
| 1390 | - $otherObject = $this->clear_cache($relationName,$otherObjectModelObjectOrID); |
|
| 1389 | + } else {//this doesn't exist in the DB, just remove it from the cache |
|
| 1390 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
| 1391 | 1391 | } |
| 1392 | 1392 | return $otherObject; |
| 1393 | 1393 | } |
@@ -1398,12 +1398,12 @@ discard block |
||
| 1398 | 1398 | * @param array $where_query_params like EEM_Base::get_all's $query_params[0] (where conditions) |
| 1399 | 1399 | * @return EE_Base_Class |
| 1400 | 1400 | */ |
| 1401 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
| 1402 | - if($this->ID()){//if this exists in the DB, save the relation change to the DB too |
|
| 1403 | - $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params ); |
|
| 1404 | - $this->clear_cache($relationName,null,true); |
|
| 1405 | - }else{//this doesn't exist in the DB, just remove it from the cache |
|
| 1406 | - $otherObjects = $this->clear_cache($relationName,null,true); |
|
| 1401 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
| 1402 | + if ($this->ID()) {//if this exists in the DB, save the relation change to the DB too |
|
| 1403 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
| 1404 | + $this->clear_cache($relationName, null, true); |
|
| 1405 | + } else {//this doesn't exist in the DB, just remove it from the cache |
|
| 1406 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
| 1407 | 1407 | } |
| 1408 | 1408 | return $otherObjects; |
| 1409 | 1409 | } |
@@ -1419,26 +1419,26 @@ discard block |
||
| 1419 | 1419 | * @param array $query_params like EEM_Base::get_all |
| 1420 | 1420 | * @return EE_Base_Class[] |
| 1421 | 1421 | */ |
| 1422 | - public function get_many_related($relationName,$query_params = array()){ |
|
| 1423 | - if($this->ID()){//this exists in the DB, so get the related things from either the cache or the DB |
|
| 1422 | + public function get_many_related($relationName, $query_params = array()) { |
|
| 1423 | + if ($this->ID()) {//this exists in the DB, so get the related things from either the cache or the DB |
|
| 1424 | 1424 | //if there are query parameters, forget about caching the related model objects. |
| 1425 | - if( $query_params ){ |
|
| 1425 | + if ($query_params) { |
|
| 1426 | 1426 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
| 1427 | - }else{ |
|
| 1427 | + } else { |
|
| 1428 | 1428 | //did we already cache the result of this query? |
| 1429 | 1429 | $cached_results = $this->get_all_from_cache($relationName); |
| 1430 | - if ( ! $cached_results ){ |
|
| 1430 | + if ( ! $cached_results) { |
|
| 1431 | 1431 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
| 1432 | 1432 | //if no query parameters were passed, then we got all the related model objects |
| 1433 | 1433 | //for that relation. We can cache them then. |
| 1434 | - foreach($related_model_objects as $related_model_object){ |
|
| 1434 | + foreach ($related_model_objects as $related_model_object) { |
|
| 1435 | 1435 | $this->cache($relationName, $related_model_object); |
| 1436 | 1436 | } |
| 1437 | - }else{ |
|
| 1437 | + } else { |
|
| 1438 | 1438 | $related_model_objects = $cached_results; |
| 1439 | 1439 | } |
| 1440 | 1440 | } |
| 1441 | - }else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
| 1441 | + } else {//this doesn't exist itn eh DB, so just get the related things from the cache |
|
| 1442 | 1442 | $related_model_objects = $this->get_all_from_cache($relationName); |
| 1443 | 1443 | } |
| 1444 | 1444 | return $related_model_objects; |
@@ -1455,8 +1455,8 @@ discard block |
||
| 1455 | 1455 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
| 1456 | 1456 | * @return int |
| 1457 | 1457 | */ |
| 1458 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
| 1459 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
| 1458 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
| 1459 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | |
@@ -1470,7 +1470,7 @@ discard block |
||
| 1470 | 1470 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
| 1471 | 1471 | * @return int |
| 1472 | 1472 | */ |
| 1473 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
| 1473 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
| 1474 | 1474 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
| 1475 | 1475 | } |
| 1476 | 1476 | |
@@ -1482,34 +1482,34 @@ discard block |
||
| 1482 | 1482 | * @param array $query_params like EEM_Base::get_all |
| 1483 | 1483 | * @return EE_Base_Class (not an array, a single object) |
| 1484 | 1484 | */ |
| 1485 | - public function get_first_related($relationName,$query_params = array()){ |
|
| 1486 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
| 1485 | + public function get_first_related($relationName, $query_params = array()) { |
|
| 1486 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
| 1487 | 1487 | |
| 1488 | 1488 | //if they've provided some query parameters, don't bother trying to cache the result |
| 1489 | 1489 | //also make sure we're not caching the result of get_first_related |
| 1490 | 1490 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
| 1491 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
| 1492 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
| 1493 | - }else{ |
|
| 1491 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
| 1492 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
| 1493 | + } else { |
|
| 1494 | 1494 | //first, check if we've already cached the result of this query |
| 1495 | 1495 | $cached_result = $this->get_one_from_cache($relationName); |
| 1496 | - if ( ! $cached_result ){ |
|
| 1496 | + if ( ! $cached_result) { |
|
| 1497 | 1497 | |
| 1498 | 1498 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
| 1499 | - $this->cache($relationName,$related_model_object); |
|
| 1500 | - }else{ |
|
| 1499 | + $this->cache($relationName, $related_model_object); |
|
| 1500 | + } else { |
|
| 1501 | 1501 | $related_model_object = $cached_result; |
| 1502 | 1502 | } |
| 1503 | 1503 | } |
| 1504 | - }else{ |
|
| 1504 | + } else { |
|
| 1505 | 1505 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
| 1506 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
| 1507 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
| 1508 | - }else{ |
|
| 1506 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
| 1507 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
| 1508 | + } else { |
|
| 1509 | 1509 | $related_model_object = null; |
| 1510 | 1510 | } |
| 1511 | 1511 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
| 1512 | - if( ! $related_model_object){ |
|
| 1512 | + if ( ! $related_model_object) { |
|
| 1513 | 1513 | $related_model_object = $this->get_one_from_cache($relationName); |
| 1514 | 1514 | } |
| 1515 | 1515 | |
@@ -1528,12 +1528,12 @@ discard block |
||
| 1528 | 1528 | * @param array $query_params like EEM_Base::get_all's |
| 1529 | 1529 | * @return int how many deleted |
| 1530 | 1530 | */ |
| 1531 | - public function delete_related($relationName,$query_params = array()){ |
|
| 1532 | - if($this->ID()){ |
|
| 1533 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
| 1534 | - }else{ |
|
| 1531 | + public function delete_related($relationName, $query_params = array()) { |
|
| 1532 | + if ($this->ID()) { |
|
| 1533 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
| 1534 | + } else { |
|
| 1535 | 1535 | $count = count($this->get_all_from_cache($relationName)); |
| 1536 | - $this->clear_cache($relationName,NULL,TRUE); |
|
| 1536 | + $this->clear_cache($relationName, NULL, TRUE); |
|
| 1537 | 1537 | } |
| 1538 | 1538 | return $count; |
| 1539 | 1539 | } |
@@ -1548,13 +1548,13 @@ discard block |
||
| 1548 | 1548 | * @param array $query_params like EEM_Base::get_all's |
| 1549 | 1549 | * @return int how many deleted (including those soft deleted) |
| 1550 | 1550 | */ |
| 1551 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
| 1552 | - if($this->ID()){ |
|
| 1553 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
| 1554 | - }else{ |
|
| 1551 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
| 1552 | + if ($this->ID()) { |
|
| 1553 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
| 1554 | + } else { |
|
| 1555 | 1555 | $count = count($this->get_all_from_cache($relationName)); |
| 1556 | 1556 | } |
| 1557 | - $this->clear_cache($relationName,NULL,TRUE); |
|
| 1557 | + $this->clear_cache($relationName, NULL, TRUE); |
|
| 1558 | 1558 | return $count; |
| 1559 | 1559 | } |
| 1560 | 1560 | |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | * @param string $field_name property to check |
| 1571 | 1571 | * @return bool TRUE if existing,FALSE if not. |
| 1572 | 1572 | */ |
| 1573 | - public function is_set( $field_name ) { |
|
| 1573 | + public function is_set($field_name) { |
|
| 1574 | 1574 | return isset($this->_fields[$field_name]); |
| 1575 | 1575 | } |
| 1576 | 1576 | |
@@ -1582,12 +1582,12 @@ discard block |
||
| 1582 | 1582 | * @throws EE_Error |
| 1583 | 1583 | * @return bool TRUE if existing, throw EE_Error if not. |
| 1584 | 1584 | */ |
| 1585 | - protected function _property_exists( $properties ) { |
|
| 1585 | + protected function _property_exists($properties) { |
|
| 1586 | 1586 | |
| 1587 | - foreach ( (array) $properties as $property_name ) { |
|
| 1587 | + foreach ((array) $properties as $property_name) { |
|
| 1588 | 1588 | //first make sure this property exists |
| 1589 | - if ( ! $this->_fields[ $property_name ] ) |
|
| 1590 | - throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
| 1589 | + if ( ! $this->_fields[$property_name]) |
|
| 1590 | + throw new EE_Error(sprintf(__('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name)); |
|
| 1591 | 1591 | } |
| 1592 | 1592 | |
| 1593 | 1593 | return TRUE; |
@@ -1604,7 +1604,7 @@ discard block |
||
| 1604 | 1604 | $fields = $this->get_model()->field_settings(FALSE); |
| 1605 | 1605 | $properties = array(); |
| 1606 | 1606 | //remove prepended underscore |
| 1607 | - foreach ( $fields as $field_name => $settings ) { |
|
| 1607 | + foreach ($fields as $field_name => $settings) { |
|
| 1608 | 1608 | $properties[$field_name] = $this->get($field_name); |
| 1609 | 1609 | } |
| 1610 | 1610 | return $properties; |
@@ -1634,14 +1634,14 @@ discard block |
||
| 1634 | 1634 | * @throws EE_Error |
| 1635 | 1635 | * @return mixed whatever the plugin which calls add_filter decides |
| 1636 | 1636 | */ |
| 1637 | - public function __call($methodName,$args){ |
|
| 1638 | - $className=get_class($this); |
|
| 1639 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
| 1640 | - if(!has_filter($tagName)){ |
|
| 1641 | - throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}","event_espresso"), |
|
| 1642 | - $methodName,$className,$tagName)); |
|
| 1637 | + public function __call($methodName, $args) { |
|
| 1638 | + $className = get_class($this); |
|
| 1639 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
| 1640 | + if ( ! has_filter($tagName)) { |
|
| 1641 | + throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}", "event_espresso"), |
|
| 1642 | + $methodName, $className, $tagName)); |
|
| 1643 | 1643 | } |
| 1644 | - return apply_filters($tagName,null,$this,$args); |
|
| 1644 | + return apply_filters($tagName, null, $this, $args); |
|
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 1647 | 1647 | |
@@ -1656,22 +1656,22 @@ discard block |
||
| 1656 | 1656 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
| 1657 | 1657 | * NOTE: if the values haven't changed, returns 0 |
| 1658 | 1658 | */ |
| 1659 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
| 1660 | - $query_params = array(array( |
|
| 1659 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
| 1660 | + $query_params = array(array( |
|
| 1661 | 1661 | 'EXM_key'=>$meta_key, |
| 1662 | 1662 | 'OBJ_ID'=>$this->ID(), |
| 1663 | 1663 | 'EXM_type'=>$this->get_model()->get_this_model_name())); |
| 1664 | - if($previous_value !== NULL){ |
|
| 1664 | + if ($previous_value !== NULL) { |
|
| 1665 | 1665 | $query_params[0]['EXM_value'] = $meta_value; |
| 1666 | 1666 | } |
| 1667 | 1667 | $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
| 1668 | - if( ! $existing_rows_like_that){ |
|
| 1668 | + if ( ! $existing_rows_like_that) { |
|
| 1669 | 1669 | return $this->add_extra_meta($meta_key, $meta_value); |
| 1670 | - }else{ |
|
| 1671 | - foreach( $existing_rows_like_that as $existing_row){ |
|
| 1672 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
| 1670 | + } else { |
|
| 1671 | + foreach ($existing_rows_like_that as $existing_row) { |
|
| 1672 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
| 1673 | 1673 | } |
| 1674 | - return count( $existing_rows_like_that ); |
|
| 1674 | + return count($existing_rows_like_that); |
|
| 1675 | 1675 | } |
| 1676 | 1676 | } |
| 1677 | 1677 | |
@@ -1684,10 +1684,10 @@ discard block |
||
| 1684 | 1684 | * @param boolean $unique |
| 1685 | 1685 | * @return boolean |
| 1686 | 1686 | */ |
| 1687 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
| 1688 | - if($unique){ |
|
| 1689 | - $existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key,'OBJ_ID'=>$this->ID(),'EXM_type'=>$this->_get_model_classname(get_class($this))))); |
|
| 1690 | - if($existing_extra_meta){ |
|
| 1687 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
| 1688 | + if ($unique) { |
|
| 1689 | + $existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key, 'OBJ_ID'=>$this->ID(), 'EXM_type'=>$this->_get_model_classname(get_class($this))))); |
|
| 1690 | + if ($existing_extra_meta) { |
|
| 1691 | 1691 | return false; |
| 1692 | 1692 | } |
| 1693 | 1693 | } |
@@ -1707,12 +1707,12 @@ discard block |
||
| 1707 | 1707 | * @param string $meta_value |
| 1708 | 1708 | * @return int number of extra meta rows deleted |
| 1709 | 1709 | */ |
| 1710 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
| 1711 | - $query_params = array(array( |
|
| 1710 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
| 1711 | + $query_params = array(array( |
|
| 1712 | 1712 | 'EXM_key'=>$meta_key, |
| 1713 | 1713 | 'OBJ_ID'=>$this->ID(), |
| 1714 | 1714 | 'EXM_type'=>$this->get_model()->get_this_model_name())); |
| 1715 | - if($meta_value !== NULL){ |
|
| 1715 | + if ($meta_value !== NULL) { |
|
| 1716 | 1716 | $query_params[0]['EXM_value'] = $meta_value; |
| 1717 | 1717 | } |
| 1718 | 1718 | $count_deleted = EEM_Extra_Meta::instance()->delete($query_params); |
@@ -1728,25 +1728,25 @@ discard block |
||
| 1728 | 1728 | * @param mixed $default if we don't find anything, what should we return? |
| 1729 | 1729 | * @return mixed single value if $single; array if ! $single |
| 1730 | 1730 | */ |
| 1731 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
| 1732 | - if($single){ |
|
| 1733 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
| 1734 | - if ( $result instanceof EE_Extra_Meta ){ |
|
| 1731 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
| 1732 | + if ($single) { |
|
| 1733 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
| 1734 | + if ($result instanceof EE_Extra_Meta) { |
|
| 1735 | 1735 | return $result->value(); |
| 1736 | - }else{ |
|
| 1736 | + } else { |
|
| 1737 | 1737 | return $default; |
| 1738 | 1738 | } |
| 1739 | - }else{ |
|
| 1740 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
| 1741 | - if($results){ |
|
| 1739 | + } else { |
|
| 1740 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
| 1741 | + if ($results) { |
|
| 1742 | 1742 | $values = array(); |
| 1743 | - foreach($results as $result){ |
|
| 1744 | - if ( $result instanceof EE_Extra_Meta ){ |
|
| 1743 | + foreach ($results as $result) { |
|
| 1744 | + if ($result instanceof EE_Extra_Meta) { |
|
| 1745 | 1745 | $values[$result->ID()] = $result->value(); |
| 1746 | 1746 | } |
| 1747 | 1747 | } |
| 1748 | 1748 | return $values; |
| 1749 | - }else{ |
|
| 1749 | + } else { |
|
| 1750 | 1750 | return $default; |
| 1751 | 1751 | } |
| 1752 | 1752 | } |
@@ -1763,17 +1763,17 @@ discard block |
||
| 1763 | 1763 | * @param boolean $one_of_each_key |
| 1764 | 1764 | * @return array |
| 1765 | 1765 | */ |
| 1766 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
| 1766 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
| 1767 | 1767 | $return_array = array(); |
| 1768 | - if($one_of_each_key){ |
|
| 1768 | + if ($one_of_each_key) { |
|
| 1769 | 1769 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
| 1770 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
| 1770 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
| 1771 | 1771 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
| 1772 | 1772 | } |
| 1773 | - }else{ |
|
| 1773 | + } else { |
|
| 1774 | 1774 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
| 1775 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
| 1776 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
| 1775 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
| 1776 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
| 1777 | 1777 | $return_array[$extra_meta_obj->key()] = array(); |
| 1778 | 1778 | } |
| 1779 | 1779 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -1785,19 +1785,19 @@ discard block |
||
| 1785 | 1785 | * Gets a pretty nice displayable nice for this model object. Often overriden |
| 1786 | 1786 | * @return string |
| 1787 | 1787 | */ |
| 1788 | - public function name(){ |
|
| 1788 | + public function name() { |
|
| 1789 | 1789 | //find a field that's not a text field |
| 1790 | 1790 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
| 1791 | - if($field_we_can_use){ |
|
| 1791 | + if ($field_we_can_use) { |
|
| 1792 | 1792 | return $this->get($field_we_can_use->get_name()); |
| 1793 | - }else{ |
|
| 1793 | + } else { |
|
| 1794 | 1794 | $first_few_properties = $this->model_field_array(); |
| 1795 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
| 1795 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
| 1796 | 1796 | $name_parts = array(); |
| 1797 | - foreach( $first_few_properties as $name=> $value ){ |
|
| 1797 | + foreach ($first_few_properties as $name=> $value) { |
|
| 1798 | 1798 | $name_parts[] = "$name:$value"; |
| 1799 | 1799 | } |
| 1800 | - return implode(",",$name_parts); |
|
| 1800 | + return implode(",", $name_parts); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | } |
| 1803 | 1803 | |
@@ -1806,11 +1806,11 @@ discard block |
||
| 1806 | 1806 | * Checks if this model object has been proven to already be in the entity map |
| 1807 | 1807 | * @return boolean |
| 1808 | 1808 | */ |
| 1809 | - public function in_entity_map(){ |
|
| 1810 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
| 1809 | + public function in_entity_map() { |
|
| 1810 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
| 1811 | 1811 | //well, if we looked, did we find it in the entity map? |
| 1812 | 1812 | return TRUE; |
| 1813 | - }else{ |
|
| 1813 | + } else { |
|
| 1814 | 1814 | return FALSE; |
| 1815 | 1815 | } |
| 1816 | 1816 | } |
@@ -1821,21 +1821,21 @@ discard block |
||
| 1821 | 1821 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
| 1822 | 1822 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
| 1823 | 1823 | */ |
| 1824 | - public function refresh_from_db(){ |
|
| 1825 | - if( $this->ID() && $this->in_entity_map() ){ |
|
| 1826 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
| 1827 | - }else{ |
|
| 1824 | + public function refresh_from_db() { |
|
| 1825 | + if ($this->ID() && $this->in_entity_map()) { |
|
| 1826 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
| 1827 | + } else { |
|
| 1828 | 1828 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
| 1829 | 1829 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
| 1830 | 1830 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
| 1831 | 1831 | //absolutely nothing in it for this ID |
| 1832 | - if( WP_DEBUG ) { |
|
| 1832 | + if (WP_DEBUG) { |
|
| 1833 | 1833 | throw new EE_Error( |
| 1834 | 1834 | sprintf( |
| 1835 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
| 1835 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
| 1836 | 1836 | $this->ID(), |
| 1837 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
| 1838 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
| 1837 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
| 1838 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
| 1839 | 1839 | ) |
| 1840 | 1840 | ); |
| 1841 | 1841 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php'); |
|
| 4 | -class EE_HABTM_Relation extends EE_Model_Relation_Base{ |
|
| 3 | +require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php'); |
|
| 4 | +class EE_HABTM_Relation extends EE_Model_Relation_Base { |
|
| 5 | 5 | /** |
| 6 | 6 | * Model whicih defines the relation between two other models. Eg, the EE_Event_Question_Group model, |
| 7 | 7 | * which joins EE_Event and EE_Question_Group |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param boolean $block_deletes for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model |
| 19 | 19 | * @param type $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
| 20 | 20 | */ |
| 21 | - function __construct($joining_model_name,$block_deletes = true, $blocking_delete_error_message =''){ |
|
| 21 | + function __construct($joining_model_name, $block_deletes = true, $blocking_delete_error_message = '') { |
|
| 22 | 22 | $this->_joining_model_name = $joining_model_name; |
| 23 | 23 | parent::__construct($block_deletes, $blocking_delete_error_message); |
| 24 | 24 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * Gets the joining model's object |
| 27 | 27 | * @return EEM_Base |
| 28 | 28 | */ |
| 29 | - function get_join_model(){ |
|
| 29 | + function get_join_model() { |
|
| 30 | 30 | return $this->_get_model($this->_joining_model_name); |
| 31 | 31 | } |
| 32 | 32 | /** |
@@ -34,21 +34,21 @@ discard block |
||
| 34 | 34 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
| 35 | 35 | * @return string of SQL |
| 36 | 36 | */ |
| 37 | - function get_join_to_intermediate_model_statement($model_relation_chain){ |
|
| 37 | + function get_join_to_intermediate_model_statement($model_relation_chain) { |
|
| 38 | 38 | //create sql like |
| 39 | 39 | //LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this |
| 40 | 40 | //LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk |
| 41 | 41 | //remember the model relation chain to the JOIN model, because we'll |
| 42 | 42 | //need it for get_join_statement() |
| 43 | 43 | $this->_model_relation_chain_to_join_model = $model_relation_chain; |
| 44 | - $this_table_pk_field = $this->get_this_model()->get_primary_key_field();//get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
| 44 | + $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); //get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
| 45 | 45 | $join_table_fk_field_to_this_table = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
| 46 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
| 46 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
| 47 | 47 | |
| 48 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
| 48 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
| 49 | 49 | $join_table = $this->get_join_model()->get_table_for_alias($join_table_alias); |
| 50 | 50 | //phew! ok, we have all the info we need, now we can create the SQL join string |
| 51 | - $SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(), $this_table_alias, $this_table_pk_field->get_table_column()) . $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
|
| 51 | + $SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(), $this_table_alias, $this_table_pk_field->get_table_column()).$this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
|
| 52 | 52 | |
| 53 | 53 | return $SQL; |
| 54 | 54 | } |
@@ -60,18 +60,18 @@ discard block |
||
| 60 | 60 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
| 61 | 61 | * @return string of SQL |
| 62 | 62 | */ |
| 63 | - function get_join_statement($model_relation_chain){ |
|
| 64 | - if( $this->_model_relation_chain_to_join_model === NULL ){ |
|
| 65 | - throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' ))); |
|
| 63 | + function get_join_statement($model_relation_chain) { |
|
| 64 | + if ($this->_model_relation_chain_to_join_model === NULL) { |
|
| 65 | + throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso'))); |
|
| 66 | 66 | } |
| 67 | 67 | $join_table_fk_field_to_this_table = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
| 68 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
| 68 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
| 69 | 69 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
| 70 | 70 | $join_table_fk_field_to_other_table = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
| 71 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
| 71 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
| 72 | 72 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
| 73 | 73 | |
| 74 | - $SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $join_table_alias, $join_table_fk_field_to_other_table->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
| 74 | + $SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $join_table_alias, $join_table_fk_field_to_other_table->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
| 75 | 75 | return $SQL; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -84,36 +84,36 @@ discard block |
||
| 84 | 84 | * @param array $where_query col=>val pairs that are used as extra conditions for checking existing values and for setting new rows if no exact matches. |
| 85 | 85 | * @return EE_Base_Class |
| 86 | 86 | */ |
| 87 | - function add_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){ |
|
| 87 | + function add_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
| 88 | 88 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
| 89 | 89 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
| 90 | 90 | //check if such a relationship already exists |
| 91 | 91 | $join_model_fk_to_this_model = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
| 92 | 92 | $join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
| 93 | 93 | |
| 94 | - $cols_n_values = array( |
|
| 94 | + $cols_n_values = array( |
|
| 95 | 95 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
| 96 | 96 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID()); |
| 97 | 97 | |
| 98 | 98 | //if $where_query exists lets add them to the query_params. |
| 99 | - if ( !empty( $where_query ) ) { |
|
| 99 | + if ( ! empty($where_query)) { |
|
| 100 | 100 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
| 101 | 101 | //make sure we strip THIS models name from the query param |
| 102 | - foreach ( $where_query as $query_param => $val ) { |
|
| 103 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
| 102 | + foreach ($where_query as $query_param => $val) { |
|
| 103 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
| 104 | 104 | $parsed_query[$query_param] = $val; |
| 105 | 105 | } |
| 106 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
| 106 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $query_params = array( $cols_n_values ); |
|
| 109 | + $query_params = array($cols_n_values); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params); |
| 113 | 113 | //if there is already an entry in the join table, indicating a relationship, we're done |
| 114 | 114 | //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to |
| 115 | 115 | //the other tables, use the joining model directly! |
| 116 | - if( ! $existing_entry_in_join_table ){ |
|
| 116 | + if ( ! $existing_entry_in_join_table) { |
|
| 117 | 117 | $this->get_join_model()->insert($cols_n_values); |
| 118 | 118 | } |
| 119 | 119 | return $other_model_obj; |
@@ -125,29 +125,29 @@ discard block |
||
| 125 | 125 | * * @param array $where_query col=>val pairs that are used as extra conditions for checking existing values and for removing existing rows if exact matches exist. |
| 126 | 126 | * @return EE_Base_Class |
| 127 | 127 | */ |
| 128 | - function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){ |
|
| 128 | + function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
| 129 | 129 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
| 130 | 130 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
| 131 | 131 | //check if such a relationship already exists |
| 132 | 132 | $join_model_fk_to_this_model = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
| 133 | 133 | $join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
| 134 | 134 | |
| 135 | - $cols_n_values = array( |
|
| 135 | + $cols_n_values = array( |
|
| 136 | 136 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
| 137 | 137 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID()); |
| 138 | 138 | |
| 139 | 139 | //if $where_query exists lets add them to the query_params. |
| 140 | - if ( !empty( $where_query ) ) { |
|
| 140 | + if ( ! empty($where_query)) { |
|
| 141 | 141 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
| 142 | 142 | //make sure we strip THIS models name from the query param |
| 143 | - foreach ( $where_query as $query_param => $val ) { |
|
| 144 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
| 143 | + foreach ($where_query as $query_param => $val) { |
|
| 144 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
| 145 | 145 | $parsed_query[$query_param] = $val; |
| 146 | 146 | } |
| 147 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
| 147 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $existing_entry_in_join_table = $this->get_join_model()->delete( array($cols_n_values) ); |
|
| 150 | + $existing_entry_in_join_table = $this->get_join_model()->delete(array($cols_n_values)); |
|
| 151 | 151 | return $other_model_obj; |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -7,16 +7,16 @@ discard block |
||
| 7 | 7 | * ID 34 or Registration with ID 34? The EE_Any_Foreign_Model_name_Field specifies which of the two). |
| 8 | 8 | * |
| 9 | 9 | */ |
| 10 | -require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php'); |
|
| 11 | -class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation{ |
|
| 10 | +require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php'); |
|
| 11 | +class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation { |
|
| 12 | 12 | |
| 13 | - function get_join_statement($model_relation_chain){ |
|
| 13 | + function get_join_statement($model_relation_chain) { |
|
| 14 | 14 | //create the sql string like |
| 15 | 15 | // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
| 16 | 16 | $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
| 17 | 17 | $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
| 18 | - $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
| 19 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias(); |
|
| 18 | + $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
| 19 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_fk_field->get_table_alias(); |
|
| 20 | 20 | $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
| 21 | 21 | $field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name(); |
| 22 | 22 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param EE_Base_Class/int $other_obj_or_id |
| 35 | 35 | * @return EE_Base_Class |
| 36 | 36 | */ |
| 37 | - function add_relation_to($this_obj_or_id, $other_obj_or_id ){ |
|
| 37 | + function add_relation_to($this_obj_or_id, $other_obj_or_id) { |
|
| 38 | 38 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
| 39 | 39 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
| 40 | 40 | |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * @param EE_Base_Class/int $other_obj_or_id |
| 54 | 54 | * @return EE_Base_Class |
| 55 | 55 | */ |
| 56 | - function remove_relation_to($this_obj_or_id, $other_obj_or_id){ |
|
| 56 | + function remove_relation_to($this_obj_or_id, $other_obj_or_id) { |
|
| 57 | 57 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
| 58 | 58 | //find the field on th eother model which is a foreign key to this model |
| 59 | 59 | $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
| 60 | 60 | //set that field on the other model to this model's ID |
| 61 | - $other_model_obj->set($fk_field_on_other_model->get_name(),null, true); |
|
| 61 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
| 62 | 62 | $other_model_obj->set($this->get_other_model()->get_field_containing_related_model_name()->get_name(), null, true); |
| 63 | 63 | $other_model_obj->save(); |
| 64 | 64 | return $other_model_obj; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | if(isset($default_data[$subsection_name])){ |
| 210 | 210 | if($subsection instanceof EE_Form_Input_Base){ |
| 211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
| 212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
| 212 | + } elseif($subsection instanceof EE_Form_Section_Proper){ |
|
| 213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | foreach($this->subsections() as $subsection){ |
| 441 | 441 | if( $subsection instanceof EE_Form_Input_Base ){ |
| 442 | 442 | $inputs[ $subsection->html_name() ] = $subsection; |
| 443 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
| 443 | + } elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
| 444 | 444 | $inputs += $subsection->inputs_in_subsections(); |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | foreach($this->get_validatable_subsections() as $subsection){ |
| 549 | 549 | try{ |
| 550 | 550 | $subsection->_normalize($req_data); |
| 551 | - }catch( EE_Validation_Error $e ){ |
|
| 551 | + } catch( EE_Validation_Error $e ){ |
|
| 552 | 552 | $subsection->add_validation_error( $e ); |
| 553 | 553 | } |
| 554 | 554 | } |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | } |
| 768 | 768 | $subsections_after = array_diff_key($this->_subsections, $subsections_before); |
| 769 | 769 | $this->_subsections = array_merge($subsections_before,$subsections,$subsections_after); |
| 770 | - }else{ |
|
| 770 | + } else{ |
|
| 771 | 771 | //don't use array_merge because keys might be numeric and we want to preserve their keys |
| 772 | 772 | foreach( $subsections as $key => $subsection ){ |
| 773 | 773 | $this->_subsections[ $key ] = $subsection; |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | public function html_name_prefix(){ |
| 841 | 841 | if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
| 842 | 842 | return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
| 843 | - }else{ |
|
| 843 | + } else{ |
|
| 844 | 844 | return $this->name(); |
| 845 | 845 | } |
| 846 | 846 | } |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | if( $subsection->form_data_present_in( $req_data ) ) { |
| 893 | 893 | return TRUE; |
| 894 | 894 | } |
| 895 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 895 | + } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 896 | 896 | if( $subsection->form_data_present_in( $req_data ) ) { |
| 897 | 897 | return TRUE; |
| 898 | 898 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
| 8 | 8 | * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
| 9 | 9 | */ |
| 10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
| 10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Subsections |
@@ -68,37 +68,37 @@ discard block |
||
| 68 | 68 | * } @see EE_Form_Section_Validatable::__construct() |
| 69 | 69 | * |
| 70 | 70 | */ |
| 71 | - public function __construct( $options_array = array() ){ |
|
| 71 | + public function __construct($options_array = array()) { |
|
| 72 | 72 | EE_Registry::instance()->load_helper('Formatter'); |
| 73 | 73 | //call parent first, as it may be setting the name |
| 74 | 74 | parent::__construct($options_array); |
| 75 | 75 | //if they've included subsections in the constructor, add them now |
| 76 | - if( isset( $options_array['include'] )){ |
|
| 76 | + if (isset($options_array['include'])) { |
|
| 77 | 77 | //we are going to make sure we ONLY have those subsections to include |
| 78 | 78 | //AND we are going to make sure they're in that specified order |
| 79 | 79 | $reordered_subsections = array(); |
| 80 | - foreach($options_array['include'] as $input_name){ |
|
| 81 | - if(isset($this->_subsections[$input_name])){ |
|
| 80 | + foreach ($options_array['include'] as $input_name) { |
|
| 81 | + if (isset($this->_subsections[$input_name])) { |
|
| 82 | 82 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | $this->_subsections = $reordered_subsections; |
| 86 | 86 | } |
| 87 | - if(isset($options_array['exclude'])){ |
|
| 87 | + if (isset($options_array['exclude'])) { |
|
| 88 | 88 | $exclude = $options_array['exclude']; |
| 89 | 89 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
| 90 | 90 | } |
| 91 | - if(isset($options_array['layout_strategy'])){ |
|
| 91 | + if (isset($options_array['layout_strategy'])) { |
|
| 92 | 92 | $this->_layout_strategy = $options_array['layout_strategy']; |
| 93 | 93 | } |
| 94 | - if( ! $this->_layout_strategy){ |
|
| 94 | + if ( ! $this->_layout_strategy) { |
|
| 95 | 95 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
| 96 | 96 | } |
| 97 | 97 | $this->_layout_strategy->_construct_finalize($this); |
| 98 | 98 | |
| 99 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
| 100 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
| 101 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
| 99 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
| 100 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
| 101 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | } |
@@ -112,20 +112,20 @@ discard block |
||
| 112 | 112 | * @param string $name |
| 113 | 113 | * @throws \EE_Error |
| 114 | 114 | */ |
| 115 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
| 115 | + public function _construct_finalize($parent_form_section, $name) { |
|
| 116 | 116 | parent::_construct_finalize($parent_form_section, $name); |
| 117 | 117 | $this->_set_default_name_if_empty(); |
| 118 | 118 | $this->_set_default_html_id_if_empty(); |
| 119 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
| 120 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
| 121 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
| 119 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
| 120 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
| 121 | + $subsection->_construct_finalize($this, $subsection_name); |
|
| 122 | 122 | } else { |
| 123 | 123 | throw new EE_Error( |
| 124 | 124 | sprintf( |
| 125 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
| 125 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
| 126 | 126 | $subsection_name, |
| 127 | 127 | get_class($this), |
| 128 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
| 128 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
| 129 | 129 | ) |
| 130 | 130 | ); |
| 131 | 131 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * Gets the layout strategy for this form section |
| 139 | 139 | * @return EE_Form_Section_Layout_Base |
| 140 | 140 | */ |
| 141 | - public function get_layout_strategy(){ |
|
| 141 | + public function get_layout_strategy() { |
|
| 142 | 142 | return $this->_layout_strategy; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @param EE_Form_Input_Base $input |
| 151 | 151 | * @return string |
| 152 | 152 | */ |
| 153 | - public function get_html_for_input($input){ |
|
| 153 | + public function get_html_for_input($input) { |
|
| 154 | 154 | return $this->_layout_strategy->layout_input($input); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param null $form_data |
| 164 | 164 | * @return boolean |
| 165 | 165 | */ |
| 166 | - public function was_submitted($form_data = NULL){ |
|
| 166 | + public function was_submitted($form_data = NULL) { |
|
| 167 | 167 | return $this->form_data_present_in($form_data); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | * to skip this step. |
| 185 | 185 | * @return void |
| 186 | 186 | */ |
| 187 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
| 188 | - if( $req_data === NULL){ |
|
| 187 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
| 188 | + if ($req_data === NULL) { |
|
| 189 | 189 | $req_data = $_REQUEST; |
| 190 | 190 | } |
| 191 | 191 | $this->_normalize($req_data); |
| 192 | - if( $validate ){ |
|
| 192 | + if ($validate) { |
|
| 193 | 193 | $this->_validate(); |
| 194 | 194 | } |
| 195 | 195 | } |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | * the value being an array formatted in teh same way |
| 205 | 205 | * @param array $default_data |
| 206 | 206 | */ |
| 207 | - public function populate_defaults($default_data){ |
|
| 208 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
| 209 | - if(isset($default_data[$subsection_name])){ |
|
| 210 | - if($subsection instanceof EE_Form_Input_Base){ |
|
| 207 | + public function populate_defaults($default_data) { |
|
| 208 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
| 209 | + if (isset($default_data[$subsection_name])) { |
|
| 210 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
| 212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
| 212 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
| 228 | 228 | * @return EE_Form_Section_Base |
| 229 | 229 | */ |
| 230 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 231 | - if( $require_construction_to_be_finalized ){ |
|
| 230 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
| 231 | + if ($require_construction_to_be_finalized) { |
|
| 232 | 232 | $this->ensure_construct_finalized_called(); |
| 233 | 233 | } |
| 234 | 234 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | * Gets all the validatable subsections of this form section |
| 241 | 241 | * @return EE_Form_Section_Validatable[] |
| 242 | 242 | */ |
| 243 | - public function get_validatable_subsections(){ |
|
| 243 | + public function get_validatable_subsections() { |
|
| 244 | 244 | $validatable_subsections = array(); |
| 245 | - foreach($this->subsections() as $name=>$obj){ |
|
| 246 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
| 245 | + foreach ($this->subsections() as $name=>$obj) { |
|
| 246 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
| 247 | 247 | $validatable_subsections[$name] = $obj; |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | * @return EE_Form_Input_Base |
| 264 | 264 | * @throws EE_Error |
| 265 | 265 | */ |
| 266 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 266 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
| 267 | 267 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
| 268 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
| 269 | - throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
| 268 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
| 269 | + throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
| 270 | 270 | } |
| 271 | 271 | return $subsection; |
| 272 | 272 | } |
@@ -284,10 +284,10 @@ discard block |
||
| 284 | 284 | * @return EE_Form_Section_Proper |
| 285 | 285 | * @throws EE_Error |
| 286 | 286 | */ |
| 287 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 288 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
| 289 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
| 290 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
| 287 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
| 288 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
| 289 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
| 290 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
| 291 | 291 | } |
| 292 | 292 | return $subsection; |
| 293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @param string $name |
| 301 | 301 | * @return mixed depending on the input's type and its normalization strategy |
| 302 | 302 | */ |
| 303 | - public function get_input_value($name){ |
|
| 303 | + public function get_input_value($name) { |
|
| 304 | 304 | $input = $this->get_input($name); |
| 305 | 305 | return $input->normalized_value(); |
| 306 | 306 | } |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | * @return boolean |
| 314 | 314 | */ |
| 315 | 315 | public function is_valid() { |
| 316 | - if( ! $this->has_received_submission()){ |
|
| 316 | + if ( ! $this->has_received_submission()) { |
|
| 317 | 317 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
| 318 | 318 | } |
| 319 | - if( ! parent::is_valid()){ |
|
| 319 | + if ( ! parent::is_valid()) { |
|
| 320 | 320 | return false; |
| 321 | 321 | } |
| 322 | 322 | //ok so no errors general to this entire form section. so let's check the subsections |
| 323 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
| 324 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
| 325 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
| 323 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 324 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
| 325 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | * gets teh default name of this form section if none is specified |
| 336 | 336 | * @return string |
| 337 | 337 | */ |
| 338 | - protected function _set_default_name_if_empty(){ |
|
| 339 | - if( ! $this->_name ){ |
|
| 338 | + protected function _set_default_name_if_empty() { |
|
| 339 | + if ( ! $this->_name) { |
|
| 340 | 340 | $classname = get_class($this); |
| 341 | 341 | $default_name = str_replace("EE_", "", $classname); |
| 342 | - $this->_name = $default_name; |
|
| 342 | + $this->_name = $default_name; |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * Also returns the HTML for the form, except for the form opening and closing tags |
| 351 | 351 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
| 352 | 352 | */ |
| 353 | - public function get_html_and_js(){ |
|
| 353 | + public function get_html_and_js() { |
|
| 354 | 354 | $this->enqueue_js(); |
| 355 | 355 | return $this->get_html(); |
| 356 | 356 | } |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
| 362 | 362 | * @return string |
| 363 | 363 | */ |
| 364 | - public function get_html(){ |
|
| 364 | + public function get_html() { |
|
| 365 | 365 | $this->ensure_construct_finalized_called(); |
| 366 | 366 | return $this->_layout_strategy->layout_form(); |
| 367 | 367 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * enqueues JS for the form |
| 373 | 373 | * @return string |
| 374 | 374 | */ |
| 375 | - public function enqueue_js(){ |
|
| 375 | + public function enqueue_js() { |
|
| 376 | 376 | $this->_enqueue_and_localize_form_js(); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | * could change until it's actually outputted) |
| 388 | 388 | * @return void |
| 389 | 389 | */ |
| 390 | - public static function wp_enqueue_scripts(){ |
|
| 391 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
| 392 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 390 | + public static function wp_enqueue_scripts() { |
|
| 391 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
| 392 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -399,14 +399,14 @@ discard block |
||
| 399 | 399 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
| 400 | 400 | * but before the wordpress hook wp_loaded |
| 401 | 401 | */ |
| 402 | - public function _enqueue_and_localize_form_js(){ |
|
| 402 | + public function _enqueue_and_localize_form_js() { |
|
| 403 | 403 | $this->ensure_construct_finalized_called(); |
| 404 | 404 | //actually, we don't want to localize just yet. There may be other forms on the page. |
| 405 | 405 | //so we need to add our form section data to a static variable accessible by all form sections |
| 406 | 406 | //and localize it just before the footer |
| 407 | 407 | $this->localize_validation_rules(); |
| 408 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
| 409 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
| 408 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
| 409 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | |
@@ -415,11 +415,11 @@ discard block |
||
| 415 | 415 | * add our form section data to a static variable accessible by all form sections |
| 416 | 416 | * @return void |
| 417 | 417 | */ |
| 418 | - public function localize_validation_rules(){ |
|
| 418 | + public function localize_validation_rules() { |
|
| 419 | 419 | // we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog |
| 420 | - if ( ! $this->parent_section() ) { |
|
| 421 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
| 422 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
| 420 | + if ( ! $this->parent_section()) { |
|
| 421 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
| 422 | + 'form_section_id'=> $this->html_id(TRUE), |
|
| 423 | 423 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
| 424 | 424 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
| 425 | 425 | ); |
@@ -434,12 +434,12 @@ discard block |
||
| 434 | 434 | * Keys are their form names, and values are the inputs themselves |
| 435 | 435 | * @return EE_Form_Input_Base |
| 436 | 436 | */ |
| 437 | - public function inputs_in_subsections(){ |
|
| 437 | + public function inputs_in_subsections() { |
|
| 438 | 438 | $inputs = array(); |
| 439 | - foreach($this->subsections() as $subsection){ |
|
| 440 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
| 441 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
| 442 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
| 439 | + foreach ($this->subsections() as $subsection) { |
|
| 440 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 441 | + $inputs[$subsection->html_name()] = $subsection; |
|
| 442 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 443 | 443 | $inputs += $subsection->inputs_in_subsections(); |
| 444 | 444 | } |
| 445 | 445 | } |
@@ -452,12 +452,12 @@ discard block |
||
| 452 | 452 | * and values are a string of all their validation errors |
| 453 | 453 | * @return string[] |
| 454 | 454 | */ |
| 455 | - public function subsection_validation_errors_by_html_name(){ |
|
| 455 | + public function subsection_validation_errors_by_html_name() { |
|
| 456 | 456 | $inputs = $this->inputs(); |
| 457 | 457 | $errors = array(); |
| 458 | - foreach( $inputs as $form_input ){ |
|
| 459 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
| 460 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
| 458 | + foreach ($inputs as $form_input) { |
|
| 459 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
| 460 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | return $errors; |
@@ -469,12 +469,12 @@ discard block |
||
| 469 | 469 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
| 470 | 470 | * Should be setup by each form during the _enqueues_and_localize_form_js |
| 471 | 471 | */ |
| 472 | - public static function localize_script_for_all_forms(){ |
|
| 472 | + public static function localize_script_for_all_forms() { |
|
| 473 | 473 | //allow inputs and stuff to hook in their JS and stuff here |
| 474 | 474 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
| 475 | 475 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
| 476 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
| 477 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
| 476 | + wp_enqueue_script('ee_form_section_validation'); |
|
| 477 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | /** |
| 483 | 483 | * ensure_scripts_localized |
| 484 | 484 | */ |
| 485 | - public function ensure_scripts_localized(){ |
|
| 486 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
| 485 | + public function ensure_scripts_localized() { |
|
| 486 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
| 487 | 487 | $this->_enqueue_and_localize_form_js(); |
| 488 | 488 | } |
| 489 | 489 | } |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | * is that the key here should be the same as the custom validation rule put in the JS file |
| 496 | 496 | * @return array keys are custom validation rules, and values are internationalized strings |
| 497 | 497 | */ |
| 498 | - private static function _get_localized_error_messages(){ |
|
| 498 | + private static function _get_localized_error_messages() { |
|
| 499 | 499 | return array( |
| 500 | 500 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso") |
| 501 | 501 | ); |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
| 526 | 526 | * @return array |
| 527 | 527 | */ |
| 528 | - function get_jquery_validation_rules(){ |
|
| 528 | + function get_jquery_validation_rules() { |
|
| 529 | 529 | $jquery_validation_rules = array(); |
| 530 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
| 531 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
| 530 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 531 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
| 532 | 532 | } |
| 533 | 533 | return $jquery_validation_rules; |
| 534 | 534 | } |
@@ -543,11 +543,11 @@ discard block |
||
| 543 | 543 | protected function _normalize($req_data) { |
| 544 | 544 | $this->_received_submission = TRUE; |
| 545 | 545 | $this->_validation_errors = array(); |
| 546 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
| 547 | - try{ |
|
| 546 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 547 | + try { |
|
| 548 | 548 | $subsection->_normalize($req_data); |
| 549 | - }catch( EE_Validation_Error $e ){ |
|
| 550 | - $subsection->add_validation_error( $e ); |
|
| 549 | + } catch (EE_Validation_Error $e) { |
|
| 550 | + $subsection->add_validation_error($e); |
|
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | } |
@@ -561,9 +561,9 @@ discard block |
||
| 561 | 561 | * calling parent::_validate() first. |
| 562 | 562 | */ |
| 563 | 563 | protected function _validate() { |
| 564 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
| 565 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
| 566 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 564 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 565 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 566 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
| 567 | 567 | } |
| 568 | 568 | $subsection->_validate(); |
| 569 | 569 | } |
@@ -575,13 +575,13 @@ discard block |
||
| 575 | 575 | * Gets all the validated inputs for the form section |
| 576 | 576 | * @return array |
| 577 | 577 | */ |
| 578 | - public function valid_data(){ |
|
| 578 | + public function valid_data() { |
|
| 579 | 579 | $inputs = array(); |
| 580 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
| 581 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 582 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
| 583 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
| 584 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
| 580 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
| 581 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
| 582 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
| 583 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
| 584 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | 587 | return $inputs; |
@@ -593,11 +593,11 @@ discard block |
||
| 593 | 593 | * Gets all the inputs on this form section |
| 594 | 594 | * @return EE_Form_Input_Base[] |
| 595 | 595 | */ |
| 596 | - public function inputs(){ |
|
| 596 | + public function inputs() { |
|
| 597 | 597 | $inputs = array(); |
| 598 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
| 599 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
| 600 | - $inputs[ $subsection_name ] = $subsection; |
|
| 598 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
| 599 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 600 | + $inputs[$subsection_name] = $subsection; |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | return $inputs; |
@@ -609,10 +609,10 @@ discard block |
||
| 609 | 609 | * Gets all the subsections which are a proper form |
| 610 | 610 | * @return EE_Form_Section_Proper[] |
| 611 | 611 | */ |
| 612 | - public function subforms(){ |
|
| 612 | + public function subforms() { |
|
| 613 | 613 | $form_sections = array(); |
| 614 | - foreach($this->subsections() as $name=>$obj){ |
|
| 615 | - if($obj instanceof EE_Form_Section_Proper){ |
|
| 614 | + foreach ($this->subsections() as $name=>$obj) { |
|
| 615 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
| 616 | 616 | $form_sections[$name] = $obj; |
| 617 | 617 | } |
| 618 | 618 | } |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | * if you only want form inputs or proper form sections. |
| 628 | 628 | * @return EE_Form_Section_Proper[] |
| 629 | 629 | */ |
| 630 | - public function subsections(){ |
|
| 630 | + public function subsections() { |
|
| 631 | 631 | $this->ensure_construct_finalized_called(); |
| 632 | 632 | return $this->_subsections; |
| 633 | 633 | } |
@@ -639,9 +639,9 @@ discard block |
||
| 639 | 639 | * values. (Similar to calling get_input_value on inputs) |
| 640 | 640 | * @return array |
| 641 | 641 | */ |
| 642 | - public function input_values(){ |
|
| 642 | + public function input_values() { |
|
| 643 | 643 | $input_values = array(); |
| 644 | - foreach($this->inputs() as $name => $input_obj){ |
|
| 644 | + foreach ($this->inputs() as $name => $input_obj) { |
|
| 645 | 645 | $input_values[$name] = $input_obj->normalized_value(); |
| 646 | 646 | } |
| 647 | 647 | return $input_values; |
@@ -654,9 +654,9 @@ discard block |
||
| 654 | 654 | * where keys are the input names, and values are their display values |
| 655 | 655 | * @return array |
| 656 | 656 | */ |
| 657 | - public function input_pretty_values(){ |
|
| 657 | + public function input_pretty_values() { |
|
| 658 | 658 | $input_values = array(); |
| 659 | - foreach($this->inputs() as $name => $input_obj){ |
|
| 659 | + foreach ($this->inputs() as $name => $input_obj) { |
|
| 660 | 660 | $input_values[$name] = $input_obj->pretty_value(); |
| 661 | 661 | } |
| 662 | 662 | return $input_values; |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | * (ie, had receive_form_submission called on it yet) |
| 670 | 670 | * @return boolean |
| 671 | 671 | */ |
| 672 | - public function has_received_submission(){ |
|
| 672 | + public function has_received_submission() { |
|
| 673 | 673 | $this->ensure_construct_finalized_called(); |
| 674 | 674 | return $this->_received_submission; |
| 675 | 675 | } |
@@ -682,8 +682,8 @@ discard block |
||
| 682 | 682 | * @param array $inputs_to_exclude values are the input names |
| 683 | 683 | * @return void |
| 684 | 684 | */ |
| 685 | - public function exclude($inputs_to_exclude = array()){ |
|
| 686 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
| 685 | + public function exclude($inputs_to_exclude = array()) { |
|
| 686 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
| 687 | 687 | unset($this->_subsections[$input_to_exclude_name]); |
| 688 | 688 | } |
| 689 | 689 | } |
@@ -693,8 +693,8 @@ discard block |
||
| 693 | 693 | /** |
| 694 | 694 | * @param array $inputs_to_hide |
| 695 | 695 | */ |
| 696 | - public function hide($inputs_to_hide= array()){ |
|
| 697 | - foreach($inputs_to_hide as $input_to_hide){ |
|
| 696 | + public function hide($inputs_to_hide = array()) { |
|
| 697 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
| 698 | 698 | $input = $this->get_input($input_to_hide); |
| 699 | 699 | |
| 700 | 700 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -710,13 +710,13 @@ discard block |
||
| 710 | 710 | * @param string $subsection_name_to_add_before name of the section to add these subsections in front of, or null to add at the very end |
| 711 | 711 | * @return void |
| 712 | 712 | */ |
| 713 | - public function add_subsections($subsections,$subsection_name_to_add_before = NULL){ |
|
| 714 | - foreach($subsections as $subsection_name => $subsection){ |
|
| 715 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
| 713 | + public function add_subsections($subsections, $subsection_name_to_add_before = NULL) { |
|
| 714 | + foreach ($subsections as $subsection_name => $subsection) { |
|
| 715 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
| 716 | 716 | EE_Error::add_error( |
| 717 | 717 | sprintf( |
| 718 | 718 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
| 719 | - get_class( $subsection ), |
|
| 719 | + get_class($subsection), |
|
| 720 | 720 | $subsection_name, |
| 721 | 721 | $this->name() |
| 722 | 722 | ) |
@@ -725,23 +725,23 @@ discard block |
||
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | 727 | $subsections_before = array(); |
| 728 | - if( $subsection_name_to_add_before ){ |
|
| 729 | - foreach( $this->_subsections as $subsection_name => $subsection ) { |
|
| 730 | - if ( $subsection_name == $subsection_name_to_add_before ) { |
|
| 728 | + if ($subsection_name_to_add_before) { |
|
| 729 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
| 730 | + if ($subsection_name == $subsection_name_to_add_before) { |
|
| 731 | 731 | break; |
| 732 | 732 | } |
| 733 | 733 | $subsections_before[$subsection_name] = $subsection; |
| 734 | 734 | } |
| 735 | 735 | $subsections_after = array_diff_key($this->_subsections, $subsections_before); |
| 736 | - $this->_subsections = array_merge($subsections_before,$subsections,$subsections_after); |
|
| 737 | - }else{ |
|
| 736 | + $this->_subsections = array_merge($subsections_before, $subsections, $subsections_after); |
|
| 737 | + } else { |
|
| 738 | 738 | //don't use array_merge because keys might be numeric and we want to preserve their keys |
| 739 | - foreach( $subsections as $key => $subsection ){ |
|
| 740 | - $this->_subsections[ $key ] = $subsection; |
|
| 739 | + foreach ($subsections as $key => $subsection) { |
|
| 740 | + $this->_subsections[$key] = $subsection; |
|
| 741 | 741 | } |
| 742 | 742 | } |
| 743 | - if( $this->_construction_finalized ){ |
|
| 744 | - foreach($this->_subsections as $name => $subsection){ |
|
| 743 | + if ($this->_construction_finalized) { |
|
| 744 | + foreach ($this->_subsections as $name => $subsection) { |
|
| 745 | 745 | $subsection->_construct_finalize($this, $name); |
| 746 | 746 | } |
| 747 | 747 | } |
@@ -752,8 +752,8 @@ discard block |
||
| 752 | 752 | /** |
| 753 | 753 | * Just gets all validatable subsections to clean their sensitive data |
| 754 | 754 | */ |
| 755 | - public function clean_sensitive_data(){ |
|
| 756 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
| 755 | + public function clean_sensitive_data() { |
|
| 756 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 757 | 757 | $subsection->clean_sensitive_data(); |
| 758 | 758 | } |
| 759 | 759 | } |
@@ -763,8 +763,8 @@ discard block |
||
| 763 | 763 | /** |
| 764 | 764 | * @param string $form_submission_error_message |
| 765 | 765 | */ |
| 766 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
| 767 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
| 766 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
| 767 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | |
@@ -781,8 +781,8 @@ discard block |
||
| 781 | 781 | /** |
| 782 | 782 | * @param string $form_submission_success_message |
| 783 | 783 | */ |
| 784 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
| 785 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
| 784 | + public function set_submission_success_message($form_submission_success_message) { |
|
| 785 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | |
@@ -804,10 +804,10 @@ discard block |
||
| 804 | 804 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
| 805 | 805 | * @return string |
| 806 | 806 | */ |
| 807 | - public function html_name_prefix(){ |
|
| 808 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
| 809 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
| 810 | - }else{ |
|
| 807 | + public function html_name_prefix() { |
|
| 808 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
| 809 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
| 810 | + } else { |
|
| 811 | 811 | return $this->name(); |
| 812 | 812 | } |
| 813 | 813 | } |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | * was set, which is probably nothing, or the classname) |
| 819 | 819 | * @return string |
| 820 | 820 | */ |
| 821 | - public function name(){ |
|
| 821 | + public function name() { |
|
| 822 | 822 | $this->ensure_construct_finalized_called(); |
| 823 | 823 | return parent::name(); |
| 824 | 824 | } |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | * |
| 828 | 828 | * @return EE_Form_Section_Proper |
| 829 | 829 | */ |
| 830 | - public function parent_section(){ |
|
| 830 | + public function parent_section() { |
|
| 831 | 831 | $this->ensure_construct_finalized_called(); |
| 832 | 832 | return parent::parent_section(); |
| 833 | 833 | } |
@@ -836,9 +836,9 @@ discard block |
||
| 836 | 836 | * make sure construction finalized was called, otherwise children might not be ready |
| 837 | 837 | * @return void |
| 838 | 838 | */ |
| 839 | - public function ensure_construct_finalized_called(){ |
|
| 840 | - if( ! $this->_construction_finalized ){ |
|
| 841 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
| 839 | + public function ensure_construct_finalized_called() { |
|
| 840 | + if ( ! $this->_construction_finalized) { |
|
| 841 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | |
@@ -850,17 +850,17 @@ discard block |
||
| 850 | 850 | * @param array $req_data |
| 851 | 851 | * @return boolean |
| 852 | 852 | */ |
| 853 | - public function form_data_present_in( $req_data = NULL ) { |
|
| 854 | - if( $req_data === NULL){ |
|
| 853 | + public function form_data_present_in($req_data = NULL) { |
|
| 854 | + if ($req_data === NULL) { |
|
| 855 | 855 | $req_data = $_POST; |
| 856 | 856 | } |
| 857 | - foreach( $this->subsections() as $subsection ) { |
|
| 858 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
| 859 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
| 857 | + foreach ($this->subsections() as $subsection) { |
|
| 858 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 859 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 860 | 860 | return TRUE; |
| 861 | 861 | } |
| 862 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 863 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
| 862 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 863 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 864 | 864 | return TRUE; |
| 865 | 865 | } |
| 866 | 866 | } |
@@ -877,14 +877,14 @@ discard block |
||
| 877 | 877 | */ |
| 878 | 878 | public function get_validation_errors_accumulated() { |
| 879 | 879 | $validation_errors = $this->get_validation_errors(); |
| 880 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
| 881 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 880 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 881 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
| 882 | 882 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
| 883 | 883 | } else { |
| 884 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
| 884 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
| 885 | 885 | } |
| 886 | - if( $validation_errors_on_this_subsection ){ |
|
| 887 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
| 886 | + if ($validation_errors_on_this_subsection) { |
|
| 887 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | return $validation_errors; |