@@ -89,7 +89,6 @@ |
||
| 89 | 89 | * callback for FHEE__EE_Capabilities__init_caps_map__caps filter. |
| 90 | 90 | * Takes care of registering additional capabilities to the caps map. Note, that this also on the initial registration ensures that new capabilities are added to existing roles. |
| 91 | 91 | * |
| 92 | - * @param array $caps_and_cap_map The original caps map. |
|
| 93 | 92 | * |
| 94 | 93 | * @return array merged in new caps. |
| 95 | 94 | */ |
@@ -40,39 +40,39 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | - public static function register( $cap_reference = NULL, $setup_args = array() ) { |
|
| 43 | + public static function register($cap_reference = NULL, $setup_args = array()) { |
|
| 44 | 44 | //required fields MUST be present, so let's make sure they are. |
| 45 | - if ( ! isset( $cap_reference ) || ! is_array( $setup_args ) || empty( $setup_args['capabilities'] ) ) { |
|
| 45 | + if ( ! isset($cap_reference) || ! is_array($setup_args) || empty($setup_args['capabilities'])) { |
|
| 46 | 46 | throw new EE_Error( |
| 47 | - __( 'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso' ) |
|
| 47 | + __('In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso') |
|
| 48 | 48 | ); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | //make sure we don't register twice |
| 52 | - if( isset( self::$_registry[ $cap_reference ] ) ){ |
|
| 52 | + if (isset(self::$_registry[$cap_reference])) { |
|
| 53 | 53 | return; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | //make sure this is not registered too late or too early. |
| 57 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' ) ) { |
|
| 58 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference ), '4.5.0' ); |
|
| 57 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) { |
|
| 58 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference), '4.5.0'); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | //some preliminary sanitization and setting to the $_registry property |
| 62 | 62 | self::$_registry[$cap_reference] = array( |
| 63 | - 'caps' => isset( $setup_args['capabilities'] ) && is_array( $setup_args['capabilities'] ) ? $setup_args['capabilities'] : array(), |
|
| 64 | - 'cap_maps' => isset( $setup_args['capability_maps'] ) ? $setup_args['capability_maps'] : array() |
|
| 63 | + 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) ? $setup_args['capabilities'] : array(), |
|
| 64 | + 'cap_maps' => isset($setup_args['capability_maps']) ? $setup_args['capability_maps'] : array() |
|
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | //set initial caps (note that EE_Capabilities takes care of making sure that the caps get added donly once) |
| 69 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( 'EE_Register_Capabilities', 'register_capabilities' ), 10 ); |
|
| 69 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array('EE_Register_Capabilities', 'register_capabilities'), 10); |
|
| 70 | 70 | |
| 71 | 71 | //add filter for cap maps |
| 72 | - add_filter( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', array( 'EE_Register_Capabilities', 'register_cap_maps' ), 10 ); |
|
| 72 | + add_filter('FHEE__EE_Capabilities___set_meta_caps__meta_caps', array('EE_Register_Capabilities', 'register_cap_maps'), 10); |
|
| 73 | 73 | |
| 74 | 74 | //init_role_caps to register new capabilities |
| 75 | - if ( is_admin() ) { |
|
| 75 | + if (is_admin()) { |
|
| 76 | 76 | EE_Registry::instance()->load('Capabilities'); |
| 77 | 77 | EE_Capabilities::instance()->init_caps(); |
| 78 | 78 | } |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return array merged in new caps. |
| 90 | 90 | */ |
| 91 | - public static function register_capabilities( $incoming_caps ) { |
|
| 92 | - foreach ( self::$_registry as $ref => $caps_and_cap_map ) { |
|
| 93 | - $incoming_caps = array_merge_recursive( $incoming_caps, $caps_and_cap_map[ 'caps' ] ); |
|
| 91 | + public static function register_capabilities($incoming_caps) { |
|
| 92 | + foreach (self::$_registry as $ref => $caps_and_cap_map) { |
|
| 93 | + $incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']); |
|
| 94 | 94 | } |
| 95 | 95 | return $incoming_caps; |
| 96 | 96 | } |
@@ -106,22 +106,22 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return EE_Meta_Capability_Map[] |
| 108 | 108 | */ |
| 109 | - public static function register_cap_maps( $cap_maps ) { |
|
| 109 | + public static function register_cap_maps($cap_maps) { |
|
| 110 | 110 | //loop through and instantiate cap maps. |
| 111 | - foreach ( self::$_registry as $cap_reference => $setup ) { |
|
| 112 | - if ( ! isset( $setup['cap_maps'] ) ) { |
|
| 111 | + foreach (self::$_registry as $cap_reference => $setup) { |
|
| 112 | + if ( ! isset($setup['cap_maps'])) { |
|
| 113 | 113 | continue; |
| 114 | 114 | } |
| 115 | - foreach ( $setup['cap_maps'] as $cap_class => $args ) { |
|
| 116 | - if ( ! class_exists( $cap_class ) ) { |
|
| 117 | - throw new EE_Error( sprintf( __( 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', 'event_espresso' ), $cap_reference ) ); |
|
| 115 | + foreach ($setup['cap_maps'] as $cap_class => $args) { |
|
| 116 | + if ( ! class_exists($cap_class)) { |
|
| 117 | + throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', 'event_espresso'), $cap_reference)); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( count( $args ) !== 2 ) { |
|
| 121 | - throw new EE_Error( sprintf( __('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', 'event_espresso' ), $cap_reference ) ); |
|
| 120 | + if (count($args) !== 2) { |
|
| 121 | + throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', 'event_espresso'), $cap_reference)); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $cap_maps[] = new $cap_class( $args[0], $args[1] ); |
|
| 124 | + $cap_maps[] = new $cap_class($args[0], $args[1]); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | return $cap_maps; |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | |
| 133 | - public static function deregister( $cap_reference = NULL ) { |
|
| 134 | - if ( !empty( self::$_registry[$cap_reference] ) ) |
|
| 135 | - unset( self::$_registry[$cap_reference] ); |
|
| 133 | + public static function deregister($cap_reference = NULL) { |
|
| 134 | + if ( ! empty(self::$_registry[$cap_reference])) |
|
| 135 | + unset(self::$_registry[$cap_reference]); |
|
| 136 | 136 | } |
| 137 | 137 | } |
@@ -132,6 +132,6 @@ |
||
| 132 | 132 | |
| 133 | 133 | public static function deregister( $cap_reference = NULL ) { |
| 134 | 134 | if ( !empty( self::$_registry[$cap_reference] ) ) |
| 135 | - unset( self::$_registry[$cap_reference] ); |
|
| 135 | + unset( self::$_registry[$cap_reference] ); |
|
| 136 | 136 | } |
| 137 | 137 | } |
@@ -5,7 +5,9 @@ discard block |
||
| 5 | 5 | * @subpackage plugin api, capabilities |
| 6 | 6 | * @since 4.5.0 |
| 7 | 7 | */ |
| 8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 9 | + exit('No direct script access allowed'); |
|
| 10 | +} |
|
| 9 | 11 | |
| 10 | 12 | /** |
| 11 | 13 | * Use this to register new capabilities for the EE capabilities system. |
@@ -131,7 +133,8 @@ discard block |
||
| 131 | 133 | |
| 132 | 134 | |
| 133 | 135 | public static function deregister( $cap_reference = NULL ) { |
| 134 | - if ( !empty( self::$_registry[$cap_reference] ) ) |
|
| 135 | - unset( self::$_registry[$cap_reference] ); |
|
| 136 | + if ( !empty( self::$_registry[$cap_reference] ) ) { |
|
| 137 | + unset( self::$_registry[$cap_reference] ); |
|
| 138 | + } |
|
| 136 | 139 | } |
| 137 | 140 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | <ul class="wp-people-group" id="ee-people-group-owners"> |
| 4 | 4 | <li class="wp-person" id="ee-person-sshoultes"> |
| 5 | 5 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 6 | - <?php echo esp_gravatar_image( '[email protected]', 'Seth Shoultes' ); ?> |
|
| 6 | + <?php echo esp_gravatar_image('[email protected]', 'Seth Shoultes'); ?> |
|
| 7 | 7 | </a> |
| 8 | 8 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 9 | 9 | Seth Shoultes |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | </li> |
| 13 | 13 | <li class="wp-person" id="ee-person-gkoyle"> |
| 14 | 14 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 15 | - <?php echo esp_gravatar_image( '[email protected]', 'Garth Koyle' ); ?> |
|
| 15 | + <?php echo esp_gravatar_image('[email protected]', 'Garth Koyle'); ?> |
|
| 16 | 16 | </a> |
| 17 | 17 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 18 | 18 | Garth Koyle |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | <ul class="wp-people-group" id="ee-people-group-core-developers"> |
| 25 | 25 | <li class="wp-person" id="ee-person-bchristensen"> |
| 26 | 26 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 27 | - <?php echo esp_gravatar_image( '[email protected]', 'Brent Christensen' ); ?> |
|
| 27 | + <?php echo esp_gravatar_image('[email protected]', 'Brent Christensen'); ?> |
|
| 28 | 28 | </a> |
| 29 | 29 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 30 | 30 | Brent Christensen |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | </li> |
| 34 | 34 | <li class="wp-person" id="ee-person-dethier"> |
| 35 | 35 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 36 | - <?php echo esp_gravatar_image( '[email protected]', 'Darren Ethier' ); ?> |
|
| 36 | + <?php echo esp_gravatar_image('[email protected]', 'Darren Ethier'); ?> |
|
| 37 | 37 | </a> |
| 38 | 38 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 39 | 39 | Darren Ethier |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | </li> |
| 43 | 43 | <li class="wp-person" id="ee-person-mnelson"> |
| 44 | 44 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 45 | - <?php echo esp_gravatar_image( '[email protected]', 'Michael Nelson' ); ?> |
|
| 45 | + <?php echo esp_gravatar_image('[email protected]', 'Michael Nelson'); ?> |
|
| 46 | 46 | </a> |
| 47 | 47 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 48 | 48 | Michael Nelson |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | <ul class="wp-people-group" id="ee-people-group-support-staff"> |
| 55 | 55 | <li class="wp-person" id="ee-person-jfeck"> |
| 56 | 56 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 57 | - <?php echo esp_gravatar_image( '[email protected]', 'Josh Feck' ); ?> |
|
| 57 | + <?php echo esp_gravatar_image('[email protected]', 'Josh Feck'); ?> |
|
| 58 | 58 | </a> |
| 59 | 59 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 60 | 60 | Josh Feck |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | </li> |
| 63 | 63 | <li class="wp-person" id="ee-person-drobinson"> |
| 64 | 64 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 65 | - <?php echo esp_gravatar_image( '[email protected]', 'Dean Robinson' ); ?> |
|
| 65 | + <?php echo esp_gravatar_image('[email protected]', 'Dean Robinson'); ?> |
|
| 66 | 66 | </a> |
| 67 | 67 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 68 | 68 | Dean Robinson |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | </li> |
| 71 | 71 | <li class="wp-person" id="ee-person-jwilson"> |
| 72 | 72 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 73 | - <?php echo esp_gravatar_image( '[email protected]', 'Jonathan Wilson' ); ?> |
|
| 73 | + <?php echo esp_gravatar_image('[email protected]', 'Jonathan Wilson'); ?> |
|
| 74 | 74 | </a> |
| 75 | 75 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 76 | 76 | Jonathan Wilson |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | </li> |
| 79 | 79 | <li class="wp-person" id="ee-person-sharrel"> |
| 80 | 80 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 81 | - <?php echo esp_gravatar_image( '[email protected]', 'Sidney Harrell' ); ?> |
|
| 81 | + <?php echo esp_gravatar_image('[email protected]', 'Sidney Harrell'); ?> |
|
| 82 | 82 | </a> |
| 83 | 83 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 84 | 84 | Sidney Harrel |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | </li> |
| 87 | 87 | <li class="wp-person" id="ee-person-twarwick"> |
| 88 | 88 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 89 | - <?php echo esp_gravatar_image( '[email protected]', 'Tony Warwick' ); ?> |
|
| 89 | + <?php echo esp_gravatar_image('[email protected]', 'Tony Warwick'); ?> |
|
| 90 | 90 | </a> |
| 91 | 91 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 92 | 92 | Tony Warwick |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | </li> |
| 95 | 95 | <li class="wp-person" id="ee-person-lcaum"> |
| 96 | 96 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 97 | - <?php echo esp_gravatar_image( '[email protected]', 'Lorenzo Caum' ); ?> |
|
| 97 | + <?php echo esp_gravatar_image('[email protected]', 'Lorenzo Caum'); ?> |
|
| 98 | 98 | </a> |
| 99 | 99 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 100 | 100 | Lorenzo Caum |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | </ul> |
| 105 | 105 | <h4 class="wp-people-group"><?php _e('Contributor Recognition', 'event_espresso'); ?></h4> |
| 106 | 106 | <p class="description"> |
| 107 | - <?php printf( __('For every major release we want to recognize the people who contributed to the release via a Github pull request. Want to see your name listed here? %sApply for access to our github repo.%s When you submit a pull request that gets included in a major release, we\'ll add your name here linked to your Github profile.', 'event_espresso'), '<a href="http://eventespresso.com/developers/request-repo-access/">', '</a>' ); ?> |
|
| 107 | + <?php printf(__('For every major release we want to recognize the people who contributed to the release via a Github pull request. Want to see your name listed here? %sApply for access to our github repo.%s When you submit a pull request that gets included in a major release, we\'ll add your name here linked to your Github profile.', 'event_espresso'), '<a href="http://eventespresso.com/developers/request-repo-access/">', '</a>'); ?> |
|
| 108 | 108 | </p> |
| 109 | 109 | <p class="wp-credits-list"> |
| 110 | 110 | <ul> |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | </p> |
| 116 | 116 | <h4 class="wp-people-group"><?php _e('External Libraries', 'event_espresso'); ?></h4> |
| 117 | 117 | <p class="description"> |
| 118 | - <?php printf( __('Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', 'event_espresso'), '<a href="credits.php">', '</a>' ); ?> |
|
| 118 | + <?php printf(__('Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', 'event_espresso'), '<a href="credits.php">', '</a>'); ?> |
|
| 119 | 119 | </p> |
| 120 | 120 | <p class="wp-credits-list"> |
| 121 | 121 | <a href="http://josscrowcroft.github.io/accounting.js/"><?php _e('accounting.js', 'event_espresso'); ?></a>, |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | <?php |
| 133 | 133 | function esp_gravatar_profile($email) { |
| 134 | - echo 'http://www.gravatar.com/' . md5($email); |
|
| 134 | + echo 'http://www.gravatar.com/'.md5($email); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | function esp_gravatar_image($email, $name) { |
| 138 | - echo '<img src="http://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
| 138 | + echo '<img src="http://0.gravatar.com/avatar/'.md5($email).'?s=60" class="gravatar" alt="'.$name.'"/>'; |
|
| 139 | 139 | } |
| 140 | 140 | ?> |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | <h3><?php _e('Turn your blog into a complete event registration and management system', 'event_espresso'); ?></h3> |
| 63 | 63 | <p><?php _e('Create a beautiful event page with ticket selection, venue details, and an integrated single page checkout system. With WordPress, Event Espresso, and Espresso Arabica 2014 (based on the "Twenty Fourteen" theme by WordPress), your events will certainly sell out faster than ever!', 'event_espresso'); ?></p> |
| 64 | 64 | <p><?php _e('With a striking design that does not compromise the simplicity of WordPress and Event Espresso 4, Espresso Arabica 2014 will be the best event theme on the market.', 'event_espresso'); ?></p> |
| 65 | - <p><?php echo sprintf( __('%sLearn more >>%s', 'event_espresso'), '<a href="http://eventespresso.com/wiki/setup-event-espresso-arabica-theme/">', '</a>' ); ?></p> |
|
| 65 | + <p><?php echo sprintf(__('%sLearn more >>%s', 'event_espresso'), '<a href="http://eventespresso.com/wiki/setup-event-espresso-arabica-theme/">', '</a>'); ?></p> |
|
| 66 | 66 | </div> |
| 67 | 67 | </div> |
| 68 | 68 | <img src="<?php echo EE_GLOBAL_ASSETS_URL; ?>images/screenshots/single-event-page.jpg"> |
@@ -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 | |
@@ -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 ); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @access public |
| 195 | 195 | * @param EE_Ticket $ticket |
| 196 | 196 | * @param int $qty |
| 197 | - * @return TRUE on success, FALSE on fail |
|
| 197 | + * @return boolean on success, FALSE on fail |
|
| 198 | 198 | */ |
| 199 | 199 | public function add_ticket_to_cart( EE_Ticket $ticket, $qty = 1 ) { |
| 200 | 200 | EEH_Line_Item::add_ticket_purchase( $this->_grand_total, $ticket, $qty ); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | /** |
| 218 | 218 | * gets the total amount of tax paid for items in this cart |
| 219 | 219 | * @access public |
| 220 | - * @return float |
|
| 220 | + * @return boolean |
|
| 221 | 221 | */ |
| 222 | 222 | public function get_applied_taxes() { |
| 223 | 223 | return EEH_Line_Item::ensure_taxes_applied( $this->_grand_total ); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | /** |
| 229 | 229 | * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
| 230 | 230 | * @access public |
| 231 | - * @return float |
|
| 231 | + * @return boolean |
|
| 232 | 232 | */ |
| 233 | 233 | public function get_cart_grand_total() { |
| 234 | 234 | EEH_Line_Item::ensure_taxes_applied( $this->_grand_total ); |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | /** |
| 295 | 295 | * @save cart to session |
| 296 | 296 | * @access public |
| 297 | - * @return TRUE on success, FALSE on fail |
|
| 297 | + * @return boolean on success, FALSE on fail |
|
| 298 | 298 | */ |
| 299 | 299 | public function save_cart() { |
| 300 | 300 | EEH_Line_Item::ensure_taxes_applied( $this->_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 |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @access protected |
| 369 | 369 | * @param string $fieldname the property item the corresponding value is for. |
| 370 | 370 | * @param mixed $value The value we are caching. |
| 371 | - * @param null $cache_type |
|
| 371 | + * @param string $cache_type |
|
| 372 | 372 | * @return void |
| 373 | 373 | */ |
| 374 | 374 | protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
@@ -803,11 +803,11 @@ discard block |
||
| 803 | 803 | * |
| 804 | 804 | * @access protected |
| 805 | 805 | * @param string $field_name Field on the instantiated EE_Base_Class child object |
| 806 | - * @param null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
| 807 | - * @param null $tm_frmt Same as above except this is for time format |
|
| 806 | + * @param string|null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
| 807 | + * @param null|string $tm_frmt Same as above except this is for time format |
|
| 808 | 808 | * @param string $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time. |
| 809 | 809 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
| 810 | - * @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 |
|
| 810 | + * @return string|boolean | 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 |
|
| 811 | 811 | */ |
| 812 | 812 | protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
| 813 | 813 | |
@@ -1289,7 +1289,7 @@ discard block |
||
| 1289 | 1289 | |
| 1290 | 1290 | /** |
| 1291 | 1291 | * for getting a model while instantiated. |
| 1292 | - * @return \EEM_Base | \EEM_CPT_Base |
|
| 1292 | + * @return boolean | \EEM_CPT_Base |
|
| 1293 | 1293 | */ |
| 1294 | 1294 | public function get_model() { |
| 1295 | 1295 | $modelName = self::_get_model_classname( get_class($this) ); |
@@ -1320,7 +1320,7 @@ discard block |
||
| 1320 | 1320 | * If there is a key in the incoming array that matches the primary key for the model AND it is not null, then we check the db. If there's a an object we return it. If not we return false. |
| 1321 | 1321 | * @param array $props_n_values incoming array of properties and their values |
| 1322 | 1322 | * @param string $classname the classname of the child class |
| 1323 | - * @param null $timezone |
|
| 1323 | + * @param null|string $timezone |
|
| 1324 | 1324 | * @return mixed (EE_Base_Class|bool) |
| 1325 | 1325 | */ |
| 1326 | 1326 | protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL ) { |
@@ -1356,7 +1356,7 @@ discard block |
||
| 1356 | 1356 | * @param $classname |
| 1357 | 1357 | * @param null $timezone |
| 1358 | 1358 | * @throws EE_Error |
| 1359 | - * @return EEM_Base |
|
| 1359 | + * @return boolean |
|
| 1360 | 1360 | */ |
| 1361 | 1361 | protected static function _get_model( $classname, $timezone = NULL ){ |
| 1362 | 1362 | //find model for this class |
@@ -1372,8 +1372,8 @@ discard block |
||
| 1372 | 1372 | /** |
| 1373 | 1373 | * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee) |
| 1374 | 1374 | * @param string $model_classname |
| 1375 | - * @param null $timezone |
|
| 1376 | - * @return EEM_Base |
|
| 1375 | + * @param string|null $timezone |
|
| 1376 | + * @return boolean |
|
| 1377 | 1377 | */ |
| 1378 | 1378 | protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
| 1379 | 1379 | $model_classname = str_replace( 'EEM_', '', $model_classname ); |
@@ -1548,7 +1548,7 @@ discard block |
||
| 1548 | 1548 | /** |
| 1549 | 1549 | * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default, |
| 1550 | 1550 | * unless otherwise specified in the $query_params |
| 1551 | - * @param $relation_name model_name like 'Event', or 'Registration' |
|
| 1551 | + * @param string $relation_name model_name like 'Event', or 'Registration' |
|
| 1552 | 1552 | * @param array $query_params like EEM_Base::get_all's |
| 1553 | 1553 | * @param string $field_to_count name of field to count by. By default, uses primary key |
| 1554 | 1554 | * @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; |
@@ -1563,7 +1563,7 @@ discard block |
||
| 1563 | 1563 | /** |
| 1564 | 1564 | * Instead of getting the related model objects, simply sums up the values of the specified field. |
| 1565 | 1565 | * Note: ignores default_where_conditions by default, unless otherwise specified in the $query_params |
| 1566 | - * @param $relation_name model_name like 'Event', or 'Registration' |
|
| 1566 | + * @param string $relation_name model_name like 'Event', or 'Registration' |
|
| 1567 | 1567 | * @param array $query_params like EEM_Base::get_all's |
| 1568 | 1568 | * @param string $field_to_sum name of field to count by. |
| 1569 | 1569 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
@@ -1824,7 +1824,7 @@ discard block |
||
| 1824 | 1824 | * You can specify $default is case you haven't found the extra meta |
| 1825 | 1825 | * @param string $meta_key |
| 1826 | 1826 | * @param boolean $single |
| 1827 | - * @param mixed $default if we don't find anything, what should we return? |
|
| 1827 | + * @param string|false $default if we don't find anything, what should we return? |
|
| 1828 | 1828 | * @return mixed single value if $single; array if ! $single |
| 1829 | 1829 | */ |
| 1830 | 1830 | public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
@@ -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 | } |
@@ -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; |