@@ -131,7 +131,7 @@ |
||
| 131 | 131 | /** |
| 132 | 132 | * this just returns the properly formatted tab content for our tab box. |
| 133 | 133 | * @param string $name name of tab (used for selector) |
| 134 | - * @param string $content content of tab |
|
| 134 | + * @param string $tab_content content of tab |
|
| 135 | 135 | * @return string html for content area |
| 136 | 136 | */ |
| 137 | 137 | private static function tab_content($name, $tab_content, $active = false) { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | 3 | exit('NO direct script access allowed'); |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -43,22 +43,22 @@ discard block |
||
| 43 | 43 | * @param array $tabs_content an array of the content for each tab [required] |
| 44 | 44 | * @return string the assembled html string containing the tabbed content for display. |
| 45 | 45 | */ |
| 46 | - public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) { |
|
| 46 | + public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) { |
|
| 47 | 47 | |
| 48 | 48 | //first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
| 49 | - if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) { |
|
| 50 | - throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') ); |
|
| 49 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
| 50 | + throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | //make sure we've got incoming data setup properly |
| 54 | - $tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents ); |
|
| 55 | - $tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents; |
|
| 54 | + $tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents); |
|
| 55 | + $tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents; |
|
| 56 | 56 | |
| 57 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
| 57 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
| 58 | 58 | $all_tabs_content = ''; |
| 59 | 59 | |
| 60 | 60 | $index = 0; |
| 61 | - foreach ( $tabs as $tab ) { |
|
| 61 | + foreach ($tabs as $tab) { |
|
| 62 | 62 | $active = $index === 0 ? true : false; |
| 63 | 63 | $all_tabs .= self::tab($tab, $active); |
| 64 | 64 | $all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs'; |
| 77 | 77 | |
| 78 | - return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>'; |
|
| 78 | + return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>'; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * @param array $nav_tabs tab array for nav tabs |
| 99 | 99 | */ |
| 100 | 100 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
| 101 | - if ( empty($nav_tabs) ) |
|
| 102 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
| 101 | + if (empty($nav_tabs)) |
|
| 102 | + throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')); |
|
| 103 | 103 | |
| 104 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
| 105 | - foreach ( $nav_tabs as $slug => $tab ) { |
|
| 104 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
| 105 | + foreach ($nav_tabs as $slug => $tab) { |
|
| 106 | 106 | $all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
| 107 | 107 | } |
| 108 | 108 | $all_tabs .= '</h2>'; |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | * @param bool|string $css If string given then the generated tab will include that as the class. |
| 119 | 119 | * @return string html for tab |
| 120 | 120 | */ |
| 121 | - private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) { |
|
| 121 | + private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) { |
|
| 122 | 122 | $name = str_replace(' ', '-', $name); |
| 123 | 123 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
| 124 | - $class = $css ? $class . ' ' . $css : $class; |
|
| 125 | - $nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) ); |
|
| 126 | - $url = $url ? $url : '#' . $name; |
|
| 127 | - $tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t"; |
|
| 124 | + $class = $css ? $class.' '.$css : $class; |
|
| 125 | + $nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name)); |
|
| 126 | + $url = $url ? $url : '#'.$name; |
|
| 127 | + $tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t"; |
|
| 128 | 128 | return $tab; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | private static function tab_content($name, $tab_content, $active = false) { |
| 138 | 138 | $class = $active ? 'nav-tab-content' : 'nav-tab-content hidden'; |
| 139 | - $name = str_replace( ' ', '-', $name); |
|
| 140 | - $content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n"; |
|
| 141 | - $content .= "\t" . $tab_content . "\n"; |
|
| 139 | + $name = str_replace(' ', '-', $name); |
|
| 140 | + $content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n"; |
|
| 141 | + $content .= "\t".$tab_content."\n"; |
|
| 142 | 142 | $content .= '<div style="clear:both"></div></div>'; |
| 143 | 143 | return $content; |
| 144 | 144 | } |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | * @param string $default You can include a string for the item that will receive the "item_display" class for the js. |
| 165 | 165 | * @return string a html snippet of of all the formatted link elements. |
| 166 | 166 | */ |
| 167 | - public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
|
| 168 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
| 167 | + public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') { |
|
| 168 | + if ( ! is_array($item_array) || empty($item_array)) |
|
| 169 | 169 | return false; //get out we don't have even the basic thing we need! |
| 170 | 170 | |
| 171 | 171 | |
@@ -176,15 +176,15 @@ discard block |
||
| 176 | 176 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
| 177 | 177 | 'slug' => 'item_slug' |
| 178 | 178 | ); |
| 179 | - $container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links'; |
|
| 180 | - $list = '<ul class="' . $container_class . '">'; |
|
| 179 | + $container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links'; |
|
| 180 | + $list = '<ul class="'.$container_class.'">'; |
|
| 181 | 181 | |
| 182 | 182 | $ci = 1; |
| 183 | - foreach ( $item_array as $item ) { |
|
| 184 | - $item = wp_parse_args( $item, $defaults ); |
|
| 185 | - $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
|
| 183 | + foreach ($item_array as $item) { |
|
| 184 | + $item = wp_parse_args($item, $defaults); |
|
| 185 | + $item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class']; |
|
| 186 | 186 | $list .= self::_text_link_item($item); |
| 187 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
| 187 | + if ( ! empty($sep) && $ci != count($item_array)) |
|
| 188 | 188 | $list .= self::_text_link_item($sep); |
| 189 | 189 | $ci++; |
| 190 | 190 | } |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | |
| 198 | - private static function _text_link_item( $item ) { |
|
| 198 | + private static function _text_link_item($item) { |
|
| 199 | 199 | //if this isn't an array then we're doing a separator |
| 200 | - if ( !is_array( $item ) ) { |
|
| 200 | + if ( ! is_array($item)) { |
|
| 201 | 201 | $label = $item; |
| 202 | 202 | $class = 'ee-text-link-sep'; |
| 203 | 203 | $href = ''; |
@@ -206,12 +206,12 @@ discard block |
||
| 206 | 206 | extract($item); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"'; |
|
| 209 | + $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"'; |
|
| 210 | 210 | |
| 211 | - $content = '<li ' . $class . '>'; |
|
| 212 | - $content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : ''; |
|
| 211 | + $content = '<li '.$class.'>'; |
|
| 212 | + $content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : ''; |
|
| 213 | 213 | $content .= $label; |
| 214 | - $content .= !empty($href) ? '</a>' : ''; |
|
| 214 | + $content .= ! empty($href) ? '</a>' : ''; |
|
| 215 | 215 | $content .= '</li>'; |
| 216 | 216 | return $content; |
| 217 | 217 | } |
@@ -1,6 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
| 3 | 3 | exit('NO direct script access allowed'); |
| 4 | +} |
|
| 4 | 5 | |
| 5 | 6 | /** |
| 6 | 7 | * Event Espresso |
@@ -98,8 +99,9 @@ discard block |
||
| 98 | 99 | * @param array $nav_tabs tab array for nav tabs |
| 99 | 100 | */ |
| 100 | 101 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
| 101 | - if ( empty($nav_tabs) ) |
|
| 102 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
| 102 | + if ( empty($nav_tabs) ) { |
|
| 103 | + throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
| 105 | 107 | foreach ( $nav_tabs as $slug => $tab ) { |
@@ -165,8 +167,10 @@ discard block |
||
| 165 | 167 | * @return string a html snippet of of all the formatted link elements. |
| 166 | 168 | */ |
| 167 | 169 | public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
| 168 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
| 169 | - return false; //get out we don't have even the basic thing we need! |
|
| 170 | + if ( !is_array($item_array) || empty( $item_array ) ) { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 173 | + //get out we don't have even the basic thing we need! |
|
| 170 | 174 | |
| 171 | 175 | |
| 172 | 176 | $defaults = array( |
@@ -184,8 +188,9 @@ discard block |
||
| 184 | 188 | $item = wp_parse_args( $item, $defaults ); |
| 185 | 189 | $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
| 186 | 190 | $list .= self::_text_link_item($item); |
| 187 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
| 188 | - $list .= self::_text_link_item($sep); |
|
| 191 | + if ( !empty($sep) && $ci != count($item_array) ) { |
|
| 192 | + $list .= self::_text_link_item($sep); |
|
| 193 | + } |
|
| 189 | 194 | $ci++; |
| 190 | 195 | } |
| 191 | 196 | |
@@ -248,7 +248,7 @@ |
||
| 248 | 248 | * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
| 249 | 249 | * @param array $template_args an array of arguments to be extracted for use in the template |
| 250 | 250 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
| 251 | - * @return mixed string |
|
| 251 | + * @return string string |
|
| 252 | 252 | */ |
| 253 | 253 | public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
| 254 | 254 | //require the template validator for verifying variables are set according to how the template requires |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | return array(); |
| 100 | 100 | } |
| 101 | 101 | if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
| 102 | - unset( $espresso_themes[ $key ] ); |
|
| 102 | + unset( $espresso_themes[ $key ] ); |
|
| 103 | 103 | } |
| 104 | 104 | EEH_Template::$_espresso_themes = array(); |
| 105 | 105 | foreach ( $espresso_themes as $espresso_theme ) { |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | foreach ( (array)$full_template_paths as $full_template_path ) { |
| 227 | 227 | if ( is_readable( $full_template_path )) { |
| 228 | 228 | $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
| 229 | - break; |
|
| 229 | + break; |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
| 18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * espresso_get_template_part |
| 21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | * @param string $name The name of the specialised template. |
| 26 | 26 | * @return string the html output for the formatted money value |
| 27 | 27 | */ |
| 28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
| 29 | - EEH_Template::get_template_part( $slug, $name ); |
|
| 28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
| 29 | + EEH_Template::get_template_part($slug, $name); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
| 35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
| 36 | 36 | /** |
| 37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
| 38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @param string $suffix added to the end of the generated class |
| 43 | 43 | * @return string |
| 44 | 44 | */ |
| 45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
| 46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
| 45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
| 46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @return boolean |
| 71 | 71 | */ |
| 72 | 72 | public static function is_espresso_theme() { |
| 73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
| 73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | * @return void |
| 80 | 80 | */ |
| 81 | 81 | public static function load_espresso_theme_functions() { |
| 82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
| 83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
| 84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
| 82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
| 83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
| 84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
| 93 | 93 | * @return array |
| 94 | 94 | */ |
| 95 | 95 | public static function get_espresso_themes() { |
| 96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
| 97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
| 98 | - if ( empty( $espresso_themes ) ) { |
|
| 96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
| 97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
| 98 | + if (empty($espresso_themes)) { |
|
| 99 | 99 | return array(); |
| 100 | 100 | } |
| 101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
| 102 | - unset( $espresso_themes[ $key ] ); |
|
| 101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
| 102 | + unset($espresso_themes[$key]); |
|
| 103 | 103 | } |
| 104 | 104 | EEH_Template::$_espresso_themes = array(); |
| 105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
| 106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
| 105 | + foreach ($espresso_themes as $espresso_theme) { |
|
| 106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
| 122 | 122 | * @param bool $return_string |
| 123 | 123 | * @return string the html output for the formatted money value |
| 124 | 124 | */ |
| 125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
| 126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
| 125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
| 126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
| 127 | 127 | $templates = array(); |
| 128 | 128 | $name = (string) $name; |
| 129 | - if ( $name != '' ) { |
|
| 129 | + if ($name != '') { |
|
| 130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
| 131 | 131 | } |
| 132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
| 133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
| 134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
| 133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
| 134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -156,26 +156,26 @@ discard block |
||
| 156 | 156 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
| 157 | 157 | * @return mixed |
| 158 | 158 | */ |
| 159 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
| 159 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
| 160 | 160 | // first use WP locate_template to check for template in the current theme folder |
| 161 | - $template_path = locate_template( $templates ); |
|
| 161 | + $template_path = locate_template($templates); |
|
| 162 | 162 | |
| 163 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
| 163 | + if ($check_if_custom && ! empty($template_path)) |
|
| 164 | 164 | return TRUE; |
| 165 | 165 | |
| 166 | 166 | // not in the theme |
| 167 | - if ( empty( $template_path )) { |
|
| 167 | + if (empty($template_path)) { |
|
| 168 | 168 | // not even a template to look for ? |
| 169 | - if ( empty( $templates )) { |
|
| 169 | + if (empty($templates)) { |
|
| 170 | 170 | // get post_type |
| 171 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
| 171 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
| 172 | 172 | // get array of EE Custom Post Types |
| 173 | 173 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
| 174 | 174 | // build template name based on request |
| 175 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
| 176 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
| 177 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
| 178 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
| 175 | + if (isset($EE_CPTs[$post_type])) { |
|
| 176 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
| 177 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
| 178 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | // currently active EE template theme |
@@ -184,61 +184,61 @@ discard block |
||
| 184 | 184 | // array of paths to folders that may contain templates |
| 185 | 185 | $template_folder_paths = array( |
| 186 | 186 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
| 187 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
| 187 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
| 188 | 188 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
| 189 | 189 | EVENT_ESPRESSO_TEMPLATE_DIR |
| 190 | 190 | ); |
| 191 | 191 | |
| 192 | 192 | //add core plugin folders for checking only if we're not $check_if_custom |
| 193 | - if ( ! $check_if_custom ) { |
|
| 193 | + if ( ! $check_if_custom) { |
|
| 194 | 194 | $core_paths = array( |
| 195 | 195 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
| 196 | - EE_PUBLIC . $current_theme, |
|
| 196 | + EE_PUBLIC.$current_theme, |
|
| 197 | 197 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
| 198 | - EE_TEMPLATES . $current_theme, |
|
| 198 | + EE_TEMPLATES.$current_theme, |
|
| 199 | 199 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
| 200 | 200 | EE_PLUGIN_DIR_PATH |
| 201 | 201 | ); |
| 202 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
| 202 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // now filter that array |
| 206 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
| 206 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
| 207 | 207 | |
| 208 | 208 | // array to hold all possible template paths |
| 209 | 209 | $full_template_paths = array(); |
| 210 | 210 | |
| 211 | 211 | // loop through $templates |
| 212 | - foreach ( (array)$templates as $template ) { |
|
| 212 | + foreach ((array) $templates as $template) { |
|
| 213 | 213 | // while looping through all template folder paths |
| 214 | - foreach ( (array)$template_folder_paths as $template_folder_path ) { |
|
| 214 | + foreach ((array) $template_folder_paths as $template_folder_path) { |
|
| 215 | 215 | // build up our template locations array by combining our template folder paths with our templates |
| 216 | - $full_template_paths[] = rtrim( $template_folder_path, DS ) . DS . $template; |
|
| 216 | + $full_template_paths[] = rtrim($template_folder_path, DS).DS.$template; |
|
| 217 | 217 | } |
| 218 | 218 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
| 219 | - array_unshift( $full_template_paths, $template ); |
|
| 219 | + array_unshift($full_template_paths, $template); |
|
| 220 | 220 | } |
| 221 | 221 | // filter final array of full template paths |
| 222 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths ); |
|
| 222 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths); |
|
| 223 | 223 | |
| 224 | 224 | |
| 225 | 225 | // now loop through our final array of template location paths and check each location |
| 226 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
| 227 | - if ( is_readable( $full_template_path )) { |
|
| 228 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
| 226 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
| 227 | + if (is_readable($full_template_path)) { |
|
| 228 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
| 229 | 229 | break; |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | // if we got it and you want to see it... |
| 234 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
| 235 | - if ( $return_string ) { |
|
| 236 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 234 | + if ($template_path && $load && ! $check_if_custom) { |
|
| 235 | + if ($return_string) { |
|
| 236 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 237 | 237 | } else { |
| 238 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
| 238 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
| 241 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
| 251 | 251 | * @return mixed string |
| 252 | 252 | */ |
| 253 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
| 253 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
| 254 | 254 | //require the template validator for verifying variables are set according to how the template requires |
| 255 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
| 255 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -263,26 +263,26 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @since 4.6.0 |
| 265 | 265 | */ |
| 266 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
| 267 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
| 266 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
| 267 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
| 268 | 268 | |
| 269 | 269 | // you gimme nuttin - YOU GET NUTTIN !! |
| 270 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
| 270 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
| 271 | 271 | return ''; |
| 272 | 272 | } |
| 273 | 273 | // if $template_args are not in an array, then make it so |
| 274 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
| 275 | - $template_args = array( $template_args ); |
|
| 274 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
| 275 | + $template_args = array($template_args); |
|
| 276 | 276 | } |
| 277 | - extract( (array) $template_args); |
|
| 277 | + extract((array) $template_args); |
|
| 278 | 278 | |
| 279 | - if ( $return_string ) { |
|
| 279 | + if ($return_string) { |
|
| 280 | 280 | // because we want to return a string, we are going to capture the output |
| 281 | 281 | ob_start(); |
| 282 | - include( $template_path ); |
|
| 282 | + include($template_path); |
|
| 283 | 283 | return ob_get_clean(); |
| 284 | 284 | } else { |
| 285 | - include( $template_path ); |
|
| 285 | + include($template_path); |
|
| 286 | 286 | } |
| 287 | 287 | return ''; |
| 288 | 288 | } |
@@ -300,27 +300,27 @@ discard block |
||
| 300 | 300 | * @param string $suffix added to the end of the generated class |
| 301 | 301 | * @return string |
| 302 | 302 | */ |
| 303 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
| 303 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
| 304 | 304 | // in the beginning... |
| 305 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
| 305 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
| 306 | 306 | // da muddle |
| 307 | 307 | $class = ''; |
| 308 | 308 | // the end |
| 309 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
| 309 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
| 310 | 310 | // is the passed object an EE object ? |
| 311 | - if ( $object instanceof EE_Base_Class ) { |
|
| 311 | + if ($object instanceof EE_Base_Class) { |
|
| 312 | 312 | // grab the exact type of object |
| 313 | - $obj_class = get_class( $object ); |
|
| 313 | + $obj_class = get_class($object); |
|
| 314 | 314 | // depending on the type of object... |
| 315 | - switch ( $obj_class ) { |
|
| 315 | + switch ($obj_class) { |
|
| 316 | 316 | // no specifics just yet... |
| 317 | 317 | default : |
| 318 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
| 319 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
| 318 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
| 319 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
| 320 | 320 | |
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | - return $prefix . $class . $suffix; |
|
| 323 | + return $prefix.$class.$suffix; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
@@ -336,50 +336,50 @@ discard block |
||
| 336 | 336 | * @param string $cur_code_span_class |
| 337 | 337 | * @return string the html output for the formatted money value |
| 338 | 338 | */ |
| 339 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
| 339 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
| 340 | 340 | // ensure amount was received |
| 341 | - if ( is_null( $amount ) ) { |
|
| 342 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
| 343 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 341 | + if (is_null($amount)) { |
|
| 342 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
| 343 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 344 | 344 | return ''; |
| 345 | 345 | } |
| 346 | 346 | //ensure amount is float |
| 347 | 347 | $amount = (float) $amount; |
| 348 | 348 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
| 349 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
| 349 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
| 350 | 350 | // still a number or was amount converted to a string like "free" ? |
| 351 | - if ( is_float( $amount_formatted )) { |
|
| 351 | + if (is_float($amount_formatted)) { |
|
| 352 | 352 | // was a country ISO code passed ? if so generate currency config object for that country |
| 353 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
| 353 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
| 354 | 354 | // verify results |
| 355 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
| 355 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
| 356 | 356 | // set default config country currency settings |
| 357 | 357 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
| 358 | 358 | } |
| 359 | 359 | // format float |
| 360 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
| 360 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
| 361 | 361 | // add formatting ? |
| 362 | - if ( ! $return_raw ) { |
|
| 362 | + if ( ! $return_raw) { |
|
| 363 | 363 | // add currency sign |
| 364 | - if( $mny->sign_b4 ){ |
|
| 365 | - if( $amount >= 0 ){ |
|
| 366 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
| 367 | - }else{ |
|
| 368 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
| 364 | + if ($mny->sign_b4) { |
|
| 365 | + if ($amount >= 0) { |
|
| 366 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
| 367 | + } else { |
|
| 368 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - }else{ |
|
| 372 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
| 371 | + } else { |
|
| 372 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | // add currency code ? |
| 376 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
| 376 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
| 377 | 377 | } |
| 378 | 378 | // filter results |
| 379 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
| 379 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
| 380 | 380 | } |
| 381 | 381 | // clean up vars |
| 382 | - unset( $mny ); |
|
| 382 | + unset($mny); |
|
| 383 | 383 | // return formatted currency amount |
| 384 | 384 | return $amount_formatted; |
| 385 | 385 | } |
@@ -394,11 +394,11 @@ discard block |
||
| 394 | 394 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
| 395 | 395 | * @return string The localized label for the status id. |
| 396 | 396 | */ |
| 397 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
| 397 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
| 398 | 398 | /** @type EEM_Status $EEM_Status */ |
| 399 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
| 400 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
| 401 | - return $status[ $status_id ]; |
|
| 399 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
| 400 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
| 401 | + return $status[$status_id]; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | |
@@ -411,9 +411,9 @@ discard block |
||
| 411 | 411 | * @param string $icon |
| 412 | 412 | * @return string the html output for the button |
| 413 | 413 | */ |
| 414 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
| 415 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
| 416 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
| 414 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
| 415 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
| 416 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
| 417 | 417 | return $button; |
| 418 | 418 | } |
| 419 | 419 | |
@@ -430,21 +430,21 @@ discard block |
||
| 430 | 430 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
| 431 | 431 | * @return string generated link |
| 432 | 432 | */ |
| 433 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
| 433 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
| 434 | 434 | |
| 435 | - if ( ! $page ) |
|
| 436 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
| 435 | + if ( ! $page) |
|
| 436 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
| 437 | 437 | |
| 438 | - if ( ! $action ) |
|
| 439 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
| 438 | + if ( ! $action) |
|
| 439 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
| 440 | 440 | |
| 441 | 441 | $action = empty($action) ? 'default' : $action; |
| 442 | 442 | |
| 443 | 443 | |
| 444 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
| 445 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 446 | - $help_text = !$help_text ? '' : $help_text; |
|
| 447 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
| 444 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
| 445 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 446 | + $help_text = ! $help_text ? '' : $help_text; |
|
| 447 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | |
@@ -456,31 +456,31 @@ discard block |
||
| 456 | 456 | * @param EE_Help_Tour |
| 457 | 457 | * @return string html |
| 458 | 458 | */ |
| 459 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
| 459 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
| 460 | 460 | $id = $tour->get_slug(); |
| 461 | 461 | $stops = $tour->get_stops(); |
| 462 | 462 | |
| 463 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
| 463 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
| 464 | 464 | |
| 465 | - foreach ( $stops as $stop ) { |
|
| 466 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
| 467 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
| 465 | + foreach ($stops as $stop) { |
|
| 466 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
| 467 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
| 468 | 468 | |
| 469 | 469 | //if container is set to modal then let's make sure we set the options accordingly |
| 470 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
| 470 | + if (empty($data_id) && empty($data_class)) { |
|
| 471 | 471 | $stop['options']['modal'] = true; |
| 472 | 472 | $stop['options']['expose'] = true; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
| 476 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
| 475 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
| 476 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
| 477 | 477 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
| 478 | 478 | |
| 479 | 479 | //options |
| 480 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
| 480 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
| 481 | 481 | $options = ' data-options="'; |
| 482 | - foreach ( $stop['options'] as $option => $value ) { |
|
| 483 | - $options .= $option . ':' . $value . ';'; |
|
| 482 | + foreach ($stop['options'] as $option => $value) { |
|
| 483 | + $options .= $option.':'.$value.';'; |
|
| 484 | 484 | } |
| 485 | 485 | $options .= '"'; |
| 486 | 486 | } else { |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | //let's put all together |
| 491 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
| 491 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | $content .= '</ol>'; |
@@ -509,31 +509,31 @@ discard block |
||
| 509 | 509 | * @throws EE_Error |
| 510 | 510 | * @return string html structure for status. |
| 511 | 511 | */ |
| 512 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
| 513 | - if ( !is_array( $status_array ) ) |
|
| 514 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
| 512 | + public static function status_legend($status_array, $active_status = '') { |
|
| 513 | + if ( ! is_array($status_array)) |
|
| 514 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
| 515 | 515 | |
| 516 | 516 | $setup_array = array(); |
| 517 | - foreach ( $status_array as $item => $status ) { |
|
| 517 | + foreach ($status_array as $item => $status) { |
|
| 518 | 518 | $setup_array[$item] = array( |
| 519 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
| 520 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
| 519 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
| 520 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
| 521 | 521 | 'status' => $status |
| 522 | 522 | ); |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
| 526 | - $content .= '<h4>' . __('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
| 527 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
| 528 | - foreach ( $setup_array as $item => $details ) { |
|
| 525 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
| 526 | + $content .= '<h4>'.__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
| 527 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
| 528 | + foreach ($setup_array as $item => $details) { |
|
| 529 | 529 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
| 530 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
| 531 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
| 532 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
| 533 | - $content .= '</dt>' . "\n"; |
|
| 530 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
| 531 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
| 532 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
| 533 | + $content .= '</dt>'."\n"; |
|
| 534 | 534 | } |
| 535 | - $content .= '</dl>' . "\n"; |
|
| 536 | - $content .= '</div>' . "\n"; |
|
| 535 | + $content .= '</dl>'."\n"; |
|
| 536 | + $content .= '</div>'."\n"; |
|
| 537 | 537 | return $content; |
| 538 | 538 | } |
| 539 | 539 | |
@@ -546,8 +546,8 @@ discard block |
||
| 546 | 546 | * @return string |
| 547 | 547 | */ |
| 548 | 548 | public static function layout_array_as_table($data) { |
| 549 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
| 550 | - $data = (array)$data; |
|
| 549 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
| 550 | + $data = (array) $data; |
|
| 551 | 551 | } |
| 552 | 552 | EE_Registry::instance()->load_helper('Array'); |
| 553 | 553 | ob_start(); |
@@ -561,10 +561,10 @@ discard block |
||
| 561 | 561 | ?> |
| 562 | 562 | <tr> |
| 563 | 563 | <td> |
| 564 | - <?php echo $data_key;?> |
|
| 564 | + <?php echo $data_key; ?> |
|
| 565 | 565 | </td> |
| 566 | 566 | <td> |
| 567 | - <?php echo self::layout_array_as_table($data_values);?> |
|
| 567 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
| 568 | 568 | </td> |
| 569 | 569 | </tr> |
| 570 | 570 | <?php |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | <ul> |
| 579 | 579 | <?php |
| 580 | 580 | foreach ($data as $datum) { |
| 581 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
| 581 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
| 582 | 582 | }?> |
| 583 | 583 | </ul> |
| 584 | 584 | <?php |
@@ -604,8 +604,8 @@ discard block |
||
| 604 | 604 | * @param $url |
| 605 | 605 | * @param bool $show_num_field |
| 606 | 606 | */ |
| 607 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE ) { |
|
| 608 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field ); |
|
| 607 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE) { |
|
| 608 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | |
@@ -623,69 +623,69 @@ discard block |
||
| 623 | 623 | * @param boolean $show_num_field Whether to show the input for changing page number. |
| 624 | 624 | * @return string |
| 625 | 625 | */ |
| 626 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE ) { |
|
| 626 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE) { |
|
| 627 | 627 | $page_links = array(); |
| 628 | 628 | $disable_first = $disable_last = ''; |
| 629 | 629 | $total_items = (int) $total_items; |
| 630 | 630 | $per_page = (int) $per_page; |
| 631 | 631 | $current = (int) $current; |
| 632 | 632 | |
| 633 | - $total_pages = round( ceil( $total_items ) / $per_page ); |
|
| 633 | + $total_pages = round(ceil($total_items) / $per_page); |
|
| 634 | 634 | |
| 635 | - if ( $total_pages <= 1) |
|
| 635 | + if ($total_pages <= 1) |
|
| 636 | 636 | return ''; |
| 637 | 637 | |
| 638 | - $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>'; |
|
| 638 | + $output = '<span class="displaying-num">'.sprintf(_n('1 item', '%s items', $total_items), number_format_i18n($total_items)).'</span>'; |
|
| 639 | 639 | |
| 640 | - if ( $current == 1 ) |
|
| 640 | + if ($current == 1) |
|
| 641 | 641 | $disable_first = ' disabled'; |
| 642 | - if ( $current == $total_pages ) |
|
| 642 | + if ($current == $total_pages) |
|
| 643 | 643 | $disable_last = ' disabled'; |
| 644 | 644 | |
| 645 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 646 | - 'first-page' . $disable_first, |
|
| 647 | - esc_attr__( 'Go to the first page' ), |
|
| 648 | - esc_url( remove_query_arg( 'paged', $url ) ), |
|
| 645 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 646 | + 'first-page'.$disable_first, |
|
| 647 | + esc_attr__('Go to the first page'), |
|
| 648 | + esc_url(remove_query_arg('paged', $url)), |
|
| 649 | 649 | '«' |
| 650 | 650 | ); |
| 651 | 651 | |
| 652 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 653 | - 'prev-page' . $disable_first, |
|
| 654 | - esc_attr__( 'Go to the previous page' ), |
|
| 655 | - esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $url ) ), |
|
| 652 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 653 | + 'prev-page'.$disable_first, |
|
| 654 | + esc_attr__('Go to the previous page'), |
|
| 655 | + esc_url(add_query_arg('paged', max(1, $current - 1), $url)), |
|
| 656 | 656 | '‹' |
| 657 | 657 | ); |
| 658 | 658 | |
| 659 | - if ( ! $show_num_field ) |
|
| 659 | + if ( ! $show_num_field) |
|
| 660 | 660 | $html_current_page = $current; |
| 661 | 661 | else |
| 662 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />", |
|
| 663 | - esc_attr__( 'Current page' ), |
|
| 662 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />", |
|
| 663 | + esc_attr__('Current page'), |
|
| 664 | 664 | $current, |
| 665 | - strlen( $total_pages ) |
|
| 665 | + strlen($total_pages) |
|
| 666 | 666 | ); |
| 667 | 667 | |
| 668 | - $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
|
| 669 | - $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>'; |
|
| 668 | + $html_total_pages = sprintf("<span class='total-pages'>%s</span>", number_format_i18n($total_pages)); |
|
| 669 | + $page_links[] = '<span class="paging-input">'.sprintf(_x('%1$s of %2$s', 'paging'), $html_current_page, $html_total_pages).'</span>'; |
|
| 670 | 670 | |
| 671 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 672 | - 'next-page' . $disable_last, |
|
| 673 | - esc_attr__( 'Go to the next page' ), |
|
| 674 | - esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $url ) ), |
|
| 671 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 672 | + 'next-page'.$disable_last, |
|
| 673 | + esc_attr__('Go to the next page'), |
|
| 674 | + esc_url(add_query_arg('paged', min($total_pages, $current + 1), $url)), |
|
| 675 | 675 | '›' |
| 676 | 676 | ); |
| 677 | 677 | |
| 678 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 679 | - 'last-page' . $disable_last, |
|
| 680 | - esc_attr__( 'Go to the last page' ), |
|
| 681 | - esc_url( add_query_arg( 'paged', $total_pages, $url ) ), |
|
| 678 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 679 | + 'last-page'.$disable_last, |
|
| 680 | + esc_attr__('Go to the last page'), |
|
| 681 | + esc_url(add_query_arg('paged', $total_pages, $url)), |
|
| 682 | 682 | '»' |
| 683 | 683 | ); |
| 684 | 684 | |
| 685 | 685 | $pagination_links_class = 'pagination-links'; |
| 686 | - $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>'; |
|
| 686 | + $output .= "\n<span class='$pagination_links_class'>".join("\n", $page_links).'</span>'; |
|
| 687 | 687 | |
| 688 | - if ( $total_pages ) |
|
| 688 | + if ($total_pages) |
|
| 689 | 689 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 690 | 690 | else |
| 691 | 691 | $page_class = ' no-pages'; |
@@ -160,8 +160,9 @@ discard block |
||
| 160 | 160 | // first use WP locate_template to check for template in the current theme folder |
| 161 | 161 | $template_path = locate_template( $templates ); |
| 162 | 162 | |
| 163 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
| 164 | - return TRUE; |
|
| 163 | + if ( $check_if_custom && !empty( $template_path ) ) { |
|
| 164 | + return TRUE; |
|
| 165 | + } |
|
| 165 | 166 | |
| 166 | 167 | // not in the theme |
| 167 | 168 | if ( empty( $template_path )) { |
@@ -364,11 +365,11 @@ discard block |
||
| 364 | 365 | if( $mny->sign_b4 ){ |
| 365 | 366 | if( $amount >= 0 ){ |
| 366 | 367 | $amount_formatted = $mny->sign . $amount_formatted; |
| 367 | - }else{ |
|
| 368 | + } else{ |
|
| 368 | 369 | $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
| 369 | 370 | } |
| 370 | 371 | |
| 371 | - }else{ |
|
| 372 | + } else{ |
|
| 372 | 373 | $amount_formatted = $amount_formatted . $mny->sign; |
| 373 | 374 | } |
| 374 | 375 | |
@@ -432,11 +433,13 @@ discard block |
||
| 432 | 433 | */ |
| 433 | 434 | public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
| 434 | 435 | |
| 435 | - if ( ! $page ) |
|
| 436 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
| 436 | + if ( ! $page ) { |
|
| 437 | + $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
| 438 | + } |
|
| 437 | 439 | |
| 438 | - if ( ! $action ) |
|
| 439 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
| 440 | + if ( ! $action ) { |
|
| 441 | + $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
| 442 | + } |
|
| 440 | 443 | |
| 441 | 444 | $action = empty($action) ? 'default' : $action; |
| 442 | 445 | |
@@ -510,8 +513,9 @@ discard block |
||
| 510 | 513 | * @return string html structure for status. |
| 511 | 514 | */ |
| 512 | 515 | public static function status_legend( $status_array, $active_status = '' ) { |
| 513 | - if ( !is_array( $status_array ) ) |
|
| 514 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
| 516 | + if ( !is_array( $status_array ) ) { |
|
| 517 | + throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
| 518 | + } |
|
| 515 | 519 | |
| 516 | 520 | $setup_array = array(); |
| 517 | 521 | foreach ( $status_array as $item => $status ) { |
@@ -572,8 +576,7 @@ discard block |
||
| 572 | 576 | </tbody> |
| 573 | 577 | </table> |
| 574 | 578 | <?php |
| 575 | - } |
|
| 576 | - else { |
|
| 579 | + } else { |
|
| 577 | 580 | ?> |
| 578 | 581 | <ul> |
| 579 | 582 | <?php |
@@ -583,8 +586,7 @@ discard block |
||
| 583 | 586 | </ul> |
| 584 | 587 | <?php |
| 585 | 588 | } |
| 586 | - } |
|
| 587 | - else { |
|
| 589 | + } else { |
|
| 588 | 590 | //simple value |
| 589 | 591 | echo $data; |
| 590 | 592 | } |
@@ -632,15 +634,18 @@ discard block |
||
| 632 | 634 | |
| 633 | 635 | $total_pages = round( ceil( $total_items ) / $per_page ); |
| 634 | 636 | |
| 635 | - if ( $total_pages <= 1) |
|
| 636 | - return ''; |
|
| 637 | + if ( $total_pages <= 1) { |
|
| 638 | + return ''; |
|
| 639 | + } |
|
| 637 | 640 | |
| 638 | 641 | $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>'; |
| 639 | 642 | |
| 640 | - if ( $current == 1 ) |
|
| 641 | - $disable_first = ' disabled'; |
|
| 642 | - if ( $current == $total_pages ) |
|
| 643 | - $disable_last = ' disabled'; |
|
| 643 | + if ( $current == 1 ) { |
|
| 644 | + $disable_first = ' disabled'; |
|
| 645 | + } |
|
| 646 | + if ( $current == $total_pages ) { |
|
| 647 | + $disable_last = ' disabled'; |
|
| 648 | + } |
|
| 644 | 649 | |
| 645 | 650 | $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
| 646 | 651 | 'first-page' . $disable_first, |
@@ -656,14 +661,15 @@ discard block |
||
| 656 | 661 | '‹' |
| 657 | 662 | ); |
| 658 | 663 | |
| 659 | - if ( ! $show_num_field ) |
|
| 660 | - $html_current_page = $current; |
|
| 661 | - else |
|
| 662 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />", |
|
| 664 | + if ( ! $show_num_field ) { |
|
| 665 | + $html_current_page = $current; |
|
| 666 | + } else { |
|
| 667 | + $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />", |
|
| 663 | 668 | esc_attr__( 'Current page' ), |
| 664 | 669 | $current, |
| 665 | 670 | strlen( $total_pages ) |
| 666 | 671 | ); |
| 672 | + } |
|
| 667 | 673 | |
| 668 | 674 | $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
| 669 | 675 | $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>'; |
@@ -685,10 +691,11 @@ discard block |
||
| 685 | 691 | $pagination_links_class = 'pagination-links'; |
| 686 | 692 | $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>'; |
| 687 | 693 | |
| 688 | - if ( $total_pages ) |
|
| 689 | - $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
| 690 | - else |
|
| 691 | - $page_class = ' no-pages'; |
|
| 694 | + if ( $total_pages ) { |
|
| 695 | + $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
| 696 | + } else { |
|
| 697 | + $page_class = ' no-pages'; |
|
| 698 | + } |
|
| 692 | 699 | |
| 693 | 700 | return "<div class='tablenav-pages{$page_class}'>$output</div>"; |
| 694 | 701 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | /** |
| 132 | 132 | * For verifying that a variable is indeed an array, else throw an EE_Error |
| 133 | 133 | * @param type $variable_to_test |
| 134 | - * @param type $variable_name |
|
| 134 | + * @param string $variable_name |
|
| 135 | 135 | * @param type $allow_empty one of 'allow_empty' or 'do_not_allow_empty' |
| 136 | 136 | * @return void |
| 137 | 137 | * @throws EE_Error |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * for verifying that a variable is one of the string optiosn supplied |
| 160 | 160 | * @param mixed $variable_to_test |
| 161 | 161 | * @param mixed $variable_name the name you've given the variable. Eg, '$foo'. THis helps in producing better error messages |
| 162 | - * @param array $string_options an array of acceptable values |
|
| 162 | + * @param string[] $string_options an array of acceptable values |
|
| 163 | 163 | * @return void |
| 164 | 164 | * @throws EE_Error |
| 165 | 165 | */ |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | * @throws EE_Error (indirectly) |
| 52 | 52 | */ |
| 53 | - static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){ |
|
| 54 | - if(!WP_DEBUG)return; |
|
| 55 | - self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
|
| 56 | - if('allow_null' == $allow_null && is_null($variable_to_test)){ |
|
| 53 | + static function verify_is_array_of($variable_to_test, $name_of_variable, $class_name, $allow_null = 'allow_null') { |
|
| 54 | + if ( ! WP_DEBUG)return; |
|
| 55 | + self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null')); |
|
| 56 | + if ('allow_null' == $allow_null && is_null($variable_to_test)) { |
|
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | self::verify_is_array($variable_to_test, $name_of_variable); |
| 60 | - foreach($variable_to_test as $key=>$array_element){ |
|
| 60 | + foreach ($variable_to_test as $key=>$array_element) { |
|
| 61 | 61 | self::verify_instanceof($array_element, $key, $class_name); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * @return void |
| 74 | 74 | * @throws EE_Error |
| 75 | 75 | */ |
| 76 | - static function verify_isnt_null($variable_to_test,$name_of_variable){ |
|
| 77 | - if(!WP_DEBUG)return; |
|
| 78 | - if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){ |
|
| 79 | - $error[]=__('Variable named %s is null.','event_espresso'); |
|
| 80 | - $error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso'); |
|
| 81 | - throw new EE_Error(sprintf(implode(",",$error),$name_of_variable,$name_of_variable)); |
|
| 76 | + static function verify_isnt_null($variable_to_test, $name_of_variable) { |
|
| 77 | + if ( ! WP_DEBUG)return; |
|
| 78 | + if ($variable_to_test == null && $variable_to_test != 0 && $variable_to_test != FALSE) { |
|
| 79 | + $error[] = __('Variable named %s is null.', 'event_espresso'); |
|
| 80 | + $error[] = __("Consider looking at the stack trace to see why it wasn't set.", 'event_espresso'); |
|
| 81 | + throw new EE_Error(sprintf(implode(",", $error), $name_of_variable, $name_of_variable)); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | * @return void |
| 91 | 91 | * @throws EE_Error |
| 92 | 92 | */ |
| 93 | - static function verify_is_true($expression_to_test,$expression_string_representation){ |
|
| 94 | - if(!WP_DEBUG)return; |
|
| 95 | - if(!$expression_to_test){ |
|
| 96 | - $error[]=__('Template error.','event_espresso'); |
|
| 97 | - $error[]=__("%s evaluated to false, but it must be true!",'event_espresso'); |
|
| 98 | - throw new EE_Error(sprintf(implode(",",$error),$expression_string_representation)); |
|
| 93 | + static function verify_is_true($expression_to_test, $expression_string_representation) { |
|
| 94 | + if ( ! WP_DEBUG)return; |
|
| 95 | + if ( ! $expression_to_test) { |
|
| 96 | + $error[] = __('Template error.', 'event_espresso'); |
|
| 97 | + $error[] = __("%s evaluated to false, but it must be true!", 'event_espresso'); |
|
| 98 | + throw new EE_Error(sprintf(implode(",", $error), $expression_string_representation)); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | * @return void |
| 112 | 112 | * @throws EE_Error |
| 113 | 113 | */ |
| 114 | - static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){ |
|
| 115 | - if(!WP_DEBUG)return; |
|
| 116 | - self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
|
| 117 | - if($allow_null == 'allow_null' && is_null($variable_to_test)){ |
|
| 114 | + static function verify_instanceof($variable_to_test, $name_of_variable, $class_name, $allow_null = 'do_not_allow_null') { |
|
| 115 | + if ( ! WP_DEBUG)return; |
|
| 116 | + self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null')); |
|
| 117 | + if ($allow_null == 'allow_null' && is_null($variable_to_test)) { |
|
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | - if( $variable_to_test == NULL || ! ( $variable_to_test instanceof $class_name )){ |
|
| 121 | - $msg[]=__('Variable %s is not of the correct type.','event_espresso'); |
|
| 122 | - $msg[]=__("It should be of type %s",'event_espresso'); |
|
| 123 | - throw new EE_Error(sprintf(implode(",",$msg),$name_of_variable,$name_of_variable,$class_name)); |
|
| 120 | + if ($variable_to_test == NULL || ! ($variable_to_test instanceof $class_name)) { |
|
| 121 | + $msg[] = __('Variable %s is not of the correct type.', 'event_espresso'); |
|
| 122 | + $msg[] = __("It should be of type %s", 'event_espresso'); |
|
| 123 | + throw new EE_Error(sprintf(implode(",", $msg), $name_of_variable, $name_of_variable, $class_name)); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -136,16 +136,16 @@ discard block |
||
| 136 | 136 | * @return void |
| 137 | 137 | * @throws EE_Error |
| 138 | 138 | */ |
| 139 | - static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){ |
|
| 140 | - if(!WP_DEBUG)return; |
|
| 141 | - self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty')); |
|
| 142 | - if(empty($variable_to_test) && 'allow_empty'==$allow_empty){ |
|
| 139 | + static function verify_is_array($variable_to_test, $variable_name, $allow_empty = 'allow_empty') { |
|
| 140 | + if ( ! WP_DEBUG)return; |
|
| 141 | + self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty', 'do_not_allow_empty')); |
|
| 142 | + if (empty($variable_to_test) && 'allow_empty' == $allow_empty) { |
|
| 143 | 143 | return; |
| 144 | 144 | } |
| 145 | - if(!is_array($variable_to_test)){ |
|
| 146 | - $error[]=__('Variable %s should be an array, but it is not.'); |
|
| 147 | - $error[]=__("Its value is, instead '%s'",'event_espresso'); |
|
| 148 | - throw new EE_Error(sprintf(implode(",",$error),$variable_name,$variable_name,$variable_to_test)); |
|
| 145 | + if ( ! is_array($variable_to_test)) { |
|
| 146 | + $error[] = __('Variable %s should be an array, but it is not.'); |
|
| 147 | + $error[] = __("Its value is, instead '%s'", 'event_espresso'); |
|
| 148 | + throw new EE_Error(sprintf(implode(",", $error), $variable_name, $variable_name, $variable_to_test)); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -163,12 +163,12 @@ discard block |
||
| 163 | 163 | * @return void |
| 164 | 164 | * @throws EE_Error |
| 165 | 165 | */ |
| 166 | - static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){ |
|
| 167 | - if(!WP_DEBUG)return; |
|
| 168 | - if(!in_array($variable_to_test,$string_options)){ |
|
| 169 | - $msg[0]=__('Malconfigured template.','event_espresso'); |
|
| 170 | - $msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso'); |
|
| 171 | - throw new EE_Error(sprintf(implode("||",$msg),$variable_name,$variable_to_test, implode("', '",$string_options))); |
|
| 166 | + static function verify_argument_is_one_of($variable_to_test, $variable_name, $string_options) { |
|
| 167 | + if ( ! WP_DEBUG)return; |
|
| 168 | + if ( ! in_array($variable_to_test, $string_options)) { |
|
| 169 | + $msg[0] = __('Malconfigured template.', 'event_espresso'); |
|
| 170 | + $msg[1] = __("Variable named '%s' was set to '%s'. It can only be one of '%s'", 'event_espresso'); |
|
| 171 | + throw new EE_Error(sprintf(implode("||", $msg), $variable_name, $variable_to_test, implode("', '", $string_options))); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -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 | |
| 3 | 5 | /** |
| 4 | 6 | * Event Espresso |
@@ -51,7 +53,9 @@ discard block |
||
| 51 | 53 | * @throws EE_Error (indirectly) |
| 52 | 54 | */ |
| 53 | 55 | static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){ |
| 54 | - if(!WP_DEBUG)return; |
|
| 56 | + if(!WP_DEBUG) { |
|
| 57 | + return; |
|
| 58 | + } |
|
| 55 | 59 | self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
| 56 | 60 | if('allow_null' == $allow_null && is_null($variable_to_test)){ |
| 57 | 61 | return; |
@@ -74,7 +78,9 @@ discard block |
||
| 74 | 78 | * @throws EE_Error |
| 75 | 79 | */ |
| 76 | 80 | static function verify_isnt_null($variable_to_test,$name_of_variable){ |
| 77 | - if(!WP_DEBUG)return; |
|
| 81 | + if(!WP_DEBUG) { |
|
| 82 | + return; |
|
| 83 | + } |
|
| 78 | 84 | if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){ |
| 79 | 85 | $error[]=__('Variable named %s is null.','event_espresso'); |
| 80 | 86 | $error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso'); |
@@ -91,7 +97,9 @@ discard block |
||
| 91 | 97 | * @throws EE_Error |
| 92 | 98 | */ |
| 93 | 99 | static function verify_is_true($expression_to_test,$expression_string_representation){ |
| 94 | - if(!WP_DEBUG)return; |
|
| 100 | + if(!WP_DEBUG) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 95 | 103 | if(!$expression_to_test){ |
| 96 | 104 | $error[]=__('Template error.','event_espresso'); |
| 97 | 105 | $error[]=__("%s evaluated to false, but it must be true!",'event_espresso'); |
@@ -112,7 +120,9 @@ discard block |
||
| 112 | 120 | * @throws EE_Error |
| 113 | 121 | */ |
| 114 | 122 | static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){ |
| 115 | - if(!WP_DEBUG)return; |
|
| 123 | + if(!WP_DEBUG) { |
|
| 124 | + return; |
|
| 125 | + } |
|
| 116 | 126 | self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
| 117 | 127 | if($allow_null == 'allow_null' && is_null($variable_to_test)){ |
| 118 | 128 | return; |
@@ -137,7 +147,9 @@ discard block |
||
| 137 | 147 | * @throws EE_Error |
| 138 | 148 | */ |
| 139 | 149 | static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){ |
| 140 | - if(!WP_DEBUG)return; |
|
| 150 | + if(!WP_DEBUG) { |
|
| 151 | + return; |
|
| 152 | + } |
|
| 141 | 153 | self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty')); |
| 142 | 154 | if(empty($variable_to_test) && 'allow_empty'==$allow_empty){ |
| 143 | 155 | return; |
@@ -164,7 +176,9 @@ discard block |
||
| 164 | 176 | * @throws EE_Error |
| 165 | 177 | */ |
| 166 | 178 | static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){ |
| 167 | - if(!WP_DEBUG)return; |
|
| 179 | + if(!WP_DEBUG) { |
|
| 180 | + return; |
|
| 181 | + } |
|
| 168 | 182 | if(!in_array($variable_to_test,$string_options)){ |
| 169 | 183 | $msg[0]=__('Malconfigured template.','event_espresso'); |
| 170 | 184 | $msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso'); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | /** |
| 187 | 187 | * _prep_name_for_html_id |
| 188 | - * @param $name |
|
| 188 | + * @param string $name |
|
| 189 | 189 | * @return string |
| 190 | 190 | */ |
| 191 | 191 | private function _prep_name_for_html_id( $name ) { |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | - * @param mixed $html_class |
|
| 234 | + * @param string $html_class |
|
| 235 | 235 | */ |
| 236 | 236 | public function set_html_class( $html_class ) { |
| 237 | 237 | $this->_html_class = $html_class; |
@@ -1,7 +1,8 @@ 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 | 7 | /** |
| 7 | 8 | * Event Espresso |
@@ -175,7 +176,7 @@ discard block |
||
| 175 | 176 | if( ! $this->_html_id ){ |
| 176 | 177 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
| 177 | 178 | $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
| 178 | - }else{ |
|
| 179 | + } else{ |
|
| 179 | 180 | $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
| 180 | 181 | } |
| 181 | 182 | } |
@@ -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 | /** |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | * @type $name string the name for this form section, if you want to explicitly define it |
| 96 | 96 | * } |
| 97 | 97 | */ |
| 98 | - function __construct( $options_array = array() ) { |
|
| 98 | + function __construct($options_array = array()) { |
|
| 99 | 99 | // used by display strategies |
| 100 | 100 | EE_Registry::instance()->load_helper('HTML'); |
| 101 | 101 | // assign incoming values to properties |
| 102 | - foreach( $options_array as $key => $value ) { |
|
| 103 | - $key = '_' . $key; |
|
| 104 | - if ( property_exists( $this, $key ) && empty( $this->$key )) { |
|
| 102 | + foreach ($options_array as $key => $value) { |
|
| 103 | + $key = '_'.$key; |
|
| 104 | + if (property_exists($this, $key) && empty($this->$key)) { |
|
| 105 | 105 | $this->$key = $value; |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param $parent_form_section |
| 114 | 114 | * @param $name |
| 115 | 115 | */ |
| 116 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
| 116 | + protected function _construct_finalize($parent_form_section, $name) { |
|
| 117 | 117 | $this->_construction_finalized = TRUE; |
| 118 | 118 | $this->_parent_section = $parent_form_section; |
| 119 | 119 | $this->_name = $name; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @param string $action |
| 136 | 136 | */ |
| 137 | - public function set_action( $action ) { |
|
| 137 | + public function set_action($action) { |
|
| 138 | 138 | $this->_action = $action; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @return string |
| 145 | 145 | */ |
| 146 | 146 | public function method() { |
| 147 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
| 147 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | /** |
| 153 | 153 | * @param string $method |
| 154 | 154 | */ |
| 155 | - public function set_method( $method ) { |
|
| 156 | - switch ( $method ) { |
|
| 155 | + public function set_method($method) { |
|
| 156 | + switch ($method) { |
|
| 157 | 157 | case 'get' : |
| 158 | 158 | case 'GET' : |
| 159 | 159 | $this->_method = 'GET'; |
@@ -171,12 +171,12 @@ discard block |
||
| 171 | 171 | * Calculation involves using the name and the parent's html id |
| 172 | 172 | * return void |
| 173 | 173 | */ |
| 174 | - protected function _set_default_html_id_if_empty(){ |
|
| 175 | - if( ! $this->_html_id ){ |
|
| 176 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
| 177 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
| 178 | - }else{ |
|
| 179 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
| 174 | + protected function _set_default_html_id_if_empty() { |
|
| 175 | + if ( ! $this->_html_id) { |
|
| 176 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
| 177 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
| 178 | + } else { |
|
| 179 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | * @param $name |
| 189 | 189 | * @return string |
| 190 | 190 | */ |
| 191 | - private function _prep_name_for_html_id( $name ) { |
|
| 192 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
| 191 | + private function _prep_name_for_html_id($name) { |
|
| 192 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | * @param bool $add_pound_sign |
| 207 | 207 | * @return string |
| 208 | 208 | */ |
| 209 | - public function html_id( $add_pound_sign = FALSE ){ |
|
| 210 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
| 209 | + public function html_id($add_pound_sign = FALSE) { |
|
| 210 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | /** |
| 216 | 216 | * @return string |
| 217 | 217 | */ |
| 218 | - public function html_class(){ |
|
| 218 | + public function html_class() { |
|
| 219 | 219 | return $this->_html_class; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | /** |
| 225 | 225 | * @return string |
| 226 | 226 | */ |
| 227 | - public function html_style(){ |
|
| 227 | + public function html_style() { |
|
| 228 | 228 | return $this->_html_style; |
| 229 | 229 | } |
| 230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | /** |
| 234 | 234 | * @param mixed $html_class |
| 235 | 235 | */ |
| 236 | - public function set_html_class( $html_class ) { |
|
| 236 | + public function set_html_class($html_class) { |
|
| 237 | 237 | $this->_html_class = $html_class; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | /** |
| 243 | 243 | * @param mixed $html_id |
| 244 | 244 | */ |
| 245 | - public function set_html_id( $html_id ) { |
|
| 245 | + public function set_html_id($html_id) { |
|
| 246 | 246 | $this->_html_id = $html_id; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | /** |
| 252 | 252 | * @param mixed $html_style |
| 253 | 253 | */ |
| 254 | - public function set_html_style( $html_style ) { |
|
| 254 | + public function set_html_style($html_style) { |
|
| 255 | 255 | $this->_html_style = $html_style; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | /** |
| 261 | 261 | * @param string $other_html_attributes |
| 262 | 262 | */ |
| 263 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
| 263 | + public function set_other_html_attributes($other_html_attributes) { |
|
| 264 | 264 | $this->_other_html_attributes = $other_html_attributes; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -280,9 +280,9 @@ discard block |
||
| 280 | 280 | * @throws EE_Error |
| 281 | 281 | * @return string |
| 282 | 282 | */ |
| 283 | - function name(){ |
|
| 284 | - if( ! $this->_construction_finalized ){ |
|
| 285 | - throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) ); |
|
| 283 | + function name() { |
|
| 284 | + if ( ! $this->_construction_finalized) { |
|
| 285 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this))); |
|
| 286 | 286 | } |
| 287 | 287 | return $this->_name; |
| 288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * Gets the parent section |
| 294 | 294 | * @return EE_Form_Section_Proper |
| 295 | 295 | */ |
| 296 | - function parent_section(){ |
|
| 296 | + function parent_section() { |
|
| 297 | 297 | return $this->_parent_section; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -306,14 +306,14 @@ discard block |
||
| 306 | 306 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
| 307 | 307 | * @return string |
| 308 | 308 | */ |
| 309 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
| 310 | - if ( ! empty( $action )) { |
|
| 311 | - $this->set_action( $action ); |
|
| 309 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
| 310 | + if ( ! empty($action)) { |
|
| 311 | + $this->set_action($action); |
|
| 312 | 312 | } |
| 313 | - if ( ! empty( $method )) { |
|
| 314 | - $this->set_method( $method ); |
|
| 313 | + if ( ! empty($method)) { |
|
| 314 | + $this->set_method($method); |
|
| 315 | 315 | } |
| 316 | - return EEH_HTML::nl( 1, 'form' ) . '<form id="' . $this->html_id() . '" action="' . $this->action() . '" method="' . $this->method() . '"' . $other_attributes . '>'; |
|
| 316 | + return EEH_HTML::nl(1, 'form').'<form id="'.$this->html_id().'" action="'.$this->action().'" method="'.$this->method().'"'.$other_attributes.'>'; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @return string |
| 324 | 324 | */ |
| 325 | 325 | public function form_close() { |
| 326 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
| 326 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * leave this as TRUE so that the inputs will be properly configured. However, |
| 226 | 226 | * some client code may be ok with construction finalize being called later |
| 227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
| 228 | - * @return EE_Form_Section_Base |
|
| 228 | + * @return EE_Form_Section_Validatable|null |
|
| 229 | 229 | */ |
| 230 | 230 | public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
| 231 | 231 | if( $require_construction_to_be_finalized ){ |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | /** |
| 713 | 713 | * Equivalent to passing 'exclude' in the constructor's options array. |
| 714 | 714 | * Removes the listed inputs from the form |
| 715 | - * @param array $inputs_to_exclude values are the input names |
|
| 715 | + * @param string[] $inputs_to_exclude values are the input names |
|
| 716 | 716 | * @return void |
| 717 | 717 | */ |
| 718 | 718 | public function exclude($inputs_to_exclude = array()){ |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | if(isset($default_data[$subsection_name])){ |
| 210 | 210 | if($subsection instanceof EE_Form_Input_Base){ |
| 211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
| 212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
| 212 | + } elseif($subsection instanceof EE_Form_Section_Proper){ |
|
| 213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | foreach($this->subsections() as $subsection){ |
| 441 | 441 | if( $subsection instanceof EE_Form_Input_Base ){ |
| 442 | 442 | $inputs[ $subsection->html_name() ] = $subsection; |
| 443 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
| 443 | + } elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
| 444 | 444 | $inputs += $subsection->inputs_in_subsections(); |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | foreach($this->get_validatable_subsections() as $subsection){ |
| 549 | 549 | try{ |
| 550 | 550 | $subsection->_normalize($req_data); |
| 551 | - }catch( EE_Validation_Error $e ){ |
|
| 551 | + } catch( EE_Validation_Error $e ){ |
|
| 552 | 552 | $subsection->add_validation_error( $e ); |
| 553 | 553 | } |
| 554 | 554 | } |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | } |
| 768 | 768 | $subsections_after = array_diff_key($this->_subsections, $subsections_before); |
| 769 | 769 | $this->_subsections = array_merge($subsections_before,$subsections,$subsections_after); |
| 770 | - }else{ |
|
| 770 | + } else{ |
|
| 771 | 771 | //don't use array_merge because keys might be numeric and we want to preserve their keys |
| 772 | 772 | foreach( $subsections as $key => $subsection ){ |
| 773 | 773 | $this->_subsections[ $key ] = $subsection; |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | public function html_name_prefix(){ |
| 841 | 841 | if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
| 842 | 842 | return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
| 843 | - }else{ |
|
| 843 | + } else{ |
|
| 844 | 844 | return $this->name(); |
| 845 | 845 | } |
| 846 | 846 | } |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | if( $subsection->form_data_present_in( $req_data ) ) { |
| 893 | 893 | return TRUE; |
| 894 | 894 | } |
| 895 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 895 | + } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 896 | 896 | if( $subsection->form_data_present_in( $req_data ) ) { |
| 897 | 897 | return TRUE; |
| 898 | 898 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
| 8 | 8 | * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
| 9 | 9 | */ |
| 10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
| 10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Subsections |
@@ -68,37 +68,37 @@ discard block |
||
| 68 | 68 | * } @see EE_Form_Section_Validatable::__construct() |
| 69 | 69 | * |
| 70 | 70 | */ |
| 71 | - public function __construct( $options_array = array() ){ |
|
| 71 | + public function __construct($options_array = array()) { |
|
| 72 | 72 | EE_Registry::instance()->load_helper('Formatter'); |
| 73 | 73 | //call parent first, as it may be setting the name |
| 74 | 74 | parent::__construct($options_array); |
| 75 | 75 | //if they've included subsections in the constructor, add them now |
| 76 | - if( isset( $options_array['include'] )){ |
|
| 76 | + if (isset($options_array['include'])) { |
|
| 77 | 77 | //we are going to make sure we ONLY have those subsections to include |
| 78 | 78 | //AND we are going to make sure they're in that specified order |
| 79 | 79 | $reordered_subsections = array(); |
| 80 | - foreach($options_array['include'] as $input_name){ |
|
| 81 | - if(isset($this->_subsections[$input_name])){ |
|
| 80 | + foreach ($options_array['include'] as $input_name) { |
|
| 81 | + if (isset($this->_subsections[$input_name])) { |
|
| 82 | 82 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | $this->_subsections = $reordered_subsections; |
| 86 | 86 | } |
| 87 | - if(isset($options_array['exclude'])){ |
|
| 87 | + if (isset($options_array['exclude'])) { |
|
| 88 | 88 | $exclude = $options_array['exclude']; |
| 89 | 89 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
| 90 | 90 | } |
| 91 | - if(isset($options_array['layout_strategy'])){ |
|
| 91 | + if (isset($options_array['layout_strategy'])) { |
|
| 92 | 92 | $this->_layout_strategy = $options_array['layout_strategy']; |
| 93 | 93 | } |
| 94 | - if( ! $this->_layout_strategy){ |
|
| 94 | + if ( ! $this->_layout_strategy) { |
|
| 95 | 95 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
| 96 | 96 | } |
| 97 | 97 | $this->_layout_strategy->_construct_finalize($this); |
| 98 | 98 | |
| 99 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
| 100 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
| 101 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
| 99 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
| 100 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
| 101 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | } |
@@ -112,20 +112,20 @@ discard block |
||
| 112 | 112 | * @param string $name |
| 113 | 113 | * @throws \EE_Error |
| 114 | 114 | */ |
| 115 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
| 115 | + public function _construct_finalize($parent_form_section, $name) { |
|
| 116 | 116 | parent::_construct_finalize($parent_form_section, $name); |
| 117 | 117 | $this->_set_default_name_if_empty(); |
| 118 | 118 | $this->_set_default_html_id_if_empty(); |
| 119 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
| 120 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
| 121 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
| 119 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
| 120 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
| 121 | + $subsection->_construct_finalize($this, $subsection_name); |
|
| 122 | 122 | } else { |
| 123 | 123 | throw new EE_Error( |
| 124 | 124 | sprintf( |
| 125 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
| 125 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
| 126 | 126 | $subsection_name, |
| 127 | 127 | get_class($this), |
| 128 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
| 128 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
| 129 | 129 | ) |
| 130 | 130 | ); |
| 131 | 131 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * Gets the layout strategy for this form section |
| 139 | 139 | * @return EE_Form_Section_Layout_Base |
| 140 | 140 | */ |
| 141 | - public function get_layout_strategy(){ |
|
| 141 | + public function get_layout_strategy() { |
|
| 142 | 142 | return $this->_layout_strategy; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @param EE_Form_Input_Base $input |
| 151 | 151 | * @return string |
| 152 | 152 | */ |
| 153 | - public function get_html_for_input($input){ |
|
| 153 | + public function get_html_for_input($input) { |
|
| 154 | 154 | return $this->_layout_strategy->layout_input($input); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param null $form_data |
| 164 | 164 | * @return boolean |
| 165 | 165 | */ |
| 166 | - public function was_submitted($form_data = NULL){ |
|
| 166 | + public function was_submitted($form_data = NULL) { |
|
| 167 | 167 | return $this->form_data_present_in($form_data); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | * to skip this step. |
| 185 | 185 | * @return void |
| 186 | 186 | */ |
| 187 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
| 188 | - if( $req_data === NULL){ |
|
| 187 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
| 188 | + if ($req_data === NULL) { |
|
| 189 | 189 | $req_data = $_REQUEST; |
| 190 | 190 | } |
| 191 | 191 | $this->_normalize($req_data); |
| 192 | - if( $validate ){ |
|
| 192 | + if ($validate) { |
|
| 193 | 193 | $this->_validate(); |
| 194 | 194 | } |
| 195 | 195 | } |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | * the value being an array formatted in teh same way |
| 205 | 205 | * @param array $default_data |
| 206 | 206 | */ |
| 207 | - public function populate_defaults($default_data){ |
|
| 208 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
| 209 | - if(isset($default_data[$subsection_name])){ |
|
| 210 | - if($subsection instanceof EE_Form_Input_Base){ |
|
| 207 | + public function populate_defaults($default_data) { |
|
| 208 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
| 209 | + if (isset($default_data[$subsection_name])) { |
|
| 210 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
| 212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
| 212 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
| 228 | 228 | * @return EE_Form_Section_Base |
| 229 | 229 | */ |
| 230 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 231 | - if( $require_construction_to_be_finalized ){ |
|
| 230 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
| 231 | + if ($require_construction_to_be_finalized) { |
|
| 232 | 232 | $this->ensure_construct_finalized_called(); |
| 233 | 233 | } |
| 234 | 234 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | * Gets all the validatable subsections of this form section |
| 241 | 241 | * @return EE_Form_Section_Validatable[] |
| 242 | 242 | */ |
| 243 | - public function get_validatable_subsections(){ |
|
| 243 | + public function get_validatable_subsections() { |
|
| 244 | 244 | $validatable_subsections = array(); |
| 245 | - foreach($this->subsections() as $name=>$obj){ |
|
| 246 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
| 245 | + foreach ($this->subsections() as $name=>$obj) { |
|
| 246 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
| 247 | 247 | $validatable_subsections[$name] = $obj; |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | * @return EE_Form_Input_Base |
| 264 | 264 | * @throws EE_Error |
| 265 | 265 | */ |
| 266 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 266 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
| 267 | 267 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
| 268 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
| 269 | - throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
| 268 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
| 269 | + throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
| 270 | 270 | } |
| 271 | 271 | return $subsection; |
| 272 | 272 | } |
@@ -284,10 +284,10 @@ discard block |
||
| 284 | 284 | * @return EE_Form_Section_Proper |
| 285 | 285 | * @throws EE_Error |
| 286 | 286 | */ |
| 287 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 288 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
| 289 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
| 290 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
| 287 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
| 288 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
| 289 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
| 290 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
| 291 | 291 | } |
| 292 | 292 | return $subsection; |
| 293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @param string $name |
| 301 | 301 | * @return mixed depending on the input's type and its normalization strategy |
| 302 | 302 | */ |
| 303 | - public function get_input_value($name){ |
|
| 303 | + public function get_input_value($name) { |
|
| 304 | 304 | $input = $this->get_input($name); |
| 305 | 305 | return $input->normalized_value(); |
| 306 | 306 | } |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | * @return boolean |
| 314 | 314 | */ |
| 315 | 315 | public function is_valid() { |
| 316 | - if( ! $this->has_received_submission()){ |
|
| 316 | + if ( ! $this->has_received_submission()) { |
|
| 317 | 317 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
| 318 | 318 | } |
| 319 | - if( ! parent::is_valid()){ |
|
| 319 | + if ( ! parent::is_valid()) { |
|
| 320 | 320 | return false; |
| 321 | 321 | } |
| 322 | 322 | //ok so no errors general to this entire form section. so let's check the subsections |
| 323 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
| 324 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
| 325 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
| 323 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 324 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
| 325 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | * gets teh default name of this form section if none is specified |
| 336 | 336 | * @return string |
| 337 | 337 | */ |
| 338 | - protected function _set_default_name_if_empty(){ |
|
| 339 | - if( ! $this->_name ){ |
|
| 338 | + protected function _set_default_name_if_empty() { |
|
| 339 | + if ( ! $this->_name) { |
|
| 340 | 340 | $classname = get_class($this); |
| 341 | 341 | $default_name = str_replace("EE_", "", $classname); |
| 342 | - $this->_name = $default_name; |
|
| 342 | + $this->_name = $default_name; |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * Also returns the HTML for the form, except for the form opening and closing tags |
| 351 | 351 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
| 352 | 352 | */ |
| 353 | - public function get_html_and_js(){ |
|
| 353 | + public function get_html_and_js() { |
|
| 354 | 354 | $this->enqueue_js(); |
| 355 | 355 | return $this->get_html(); |
| 356 | 356 | } |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
| 362 | 362 | * @return string |
| 363 | 363 | */ |
| 364 | - public function get_html(){ |
|
| 364 | + public function get_html() { |
|
| 365 | 365 | $this->ensure_construct_finalized_called(); |
| 366 | 366 | return $this->_layout_strategy->layout_form(); |
| 367 | 367 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * enqueues JS for the form |
| 373 | 373 | * @return string |
| 374 | 374 | */ |
| 375 | - public function enqueue_js(){ |
|
| 375 | + public function enqueue_js() { |
|
| 376 | 376 | $this->_enqueue_and_localize_form_js(); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | * could change until it's actually outputted) |
| 388 | 388 | * @return void |
| 389 | 389 | */ |
| 390 | - public static function wp_enqueue_scripts(){ |
|
| 391 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
| 392 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 390 | + public static function wp_enqueue_scripts() { |
|
| 391 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
| 392 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -399,14 +399,14 @@ discard block |
||
| 399 | 399 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
| 400 | 400 | * but before the wordpress hook wp_loaded |
| 401 | 401 | */ |
| 402 | - public function _enqueue_and_localize_form_js(){ |
|
| 402 | + public function _enqueue_and_localize_form_js() { |
|
| 403 | 403 | $this->ensure_construct_finalized_called(); |
| 404 | 404 | //actually, we don't want to localize just yet. There may be other forms on the page. |
| 405 | 405 | //so we need to add our form section data to a static variable accessible by all form sections |
| 406 | 406 | //and localize it just before the footer |
| 407 | 407 | $this->localize_validation_rules(); |
| 408 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
| 409 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
| 408 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
| 409 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | |
@@ -415,11 +415,11 @@ discard block |
||
| 415 | 415 | * add our form section data to a static variable accessible by all form sections |
| 416 | 416 | * @return void |
| 417 | 417 | */ |
| 418 | - public function localize_validation_rules(){ |
|
| 418 | + public function localize_validation_rules() { |
|
| 419 | 419 | // we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog |
| 420 | - if ( ! $this->parent_section() ) { |
|
| 421 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
| 422 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
| 420 | + if ( ! $this->parent_section()) { |
|
| 421 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
| 422 | + 'form_section_id'=> $this->html_id(TRUE), |
|
| 423 | 423 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
| 424 | 424 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
| 425 | 425 | ); |
@@ -434,12 +434,12 @@ discard block |
||
| 434 | 434 | * Keys are their form names, and values are the inputs themselves |
| 435 | 435 | * @return EE_Form_Input_Base |
| 436 | 436 | */ |
| 437 | - public function inputs_in_subsections(){ |
|
| 437 | + public function inputs_in_subsections() { |
|
| 438 | 438 | $inputs = array(); |
| 439 | - foreach($this->subsections() as $subsection){ |
|
| 440 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
| 441 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
| 442 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
| 439 | + foreach ($this->subsections() as $subsection) { |
|
| 440 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 441 | + $inputs[$subsection->html_name()] = $subsection; |
|
| 442 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 443 | 443 | $inputs += $subsection->inputs_in_subsections(); |
| 444 | 444 | } |
| 445 | 445 | } |
@@ -452,12 +452,12 @@ discard block |
||
| 452 | 452 | * and values are a string of all their validation errors |
| 453 | 453 | * @return string[] |
| 454 | 454 | */ |
| 455 | - public function subsection_validation_errors_by_html_name(){ |
|
| 455 | + public function subsection_validation_errors_by_html_name() { |
|
| 456 | 456 | $inputs = $this->inputs(); |
| 457 | 457 | $errors = array(); |
| 458 | - foreach( $inputs as $form_input ){ |
|
| 459 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
| 460 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
| 458 | + foreach ($inputs as $form_input) { |
|
| 459 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
| 460 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | return $errors; |
@@ -469,12 +469,12 @@ discard block |
||
| 469 | 469 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
| 470 | 470 | * Should be setup by each form during the _enqueues_and_localize_form_js |
| 471 | 471 | */ |
| 472 | - public static function localize_script_for_all_forms(){ |
|
| 472 | + public static function localize_script_for_all_forms() { |
|
| 473 | 473 | //allow inputs and stuff to hook in their JS and stuff here |
| 474 | 474 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
| 475 | 475 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
| 476 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
| 477 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
| 476 | + wp_enqueue_script('ee_form_section_validation'); |
|
| 477 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | /** |
| 483 | 483 | * ensure_scripts_localized |
| 484 | 484 | */ |
| 485 | - public function ensure_scripts_localized(){ |
|
| 486 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
| 485 | + public function ensure_scripts_localized() { |
|
| 486 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
| 487 | 487 | $this->_enqueue_and_localize_form_js(); |
| 488 | 488 | } |
| 489 | 489 | } |
@@ -495,10 +495,10 @@ discard block |
||
| 495 | 495 | * is that the key here should be the same as the custom validation rule put in the JS file |
| 496 | 496 | * @return array keys are custom validation rules, and values are internationalized strings |
| 497 | 497 | */ |
| 498 | - private static function _get_localized_error_messages(){ |
|
| 498 | + private static function _get_localized_error_messages() { |
|
| 499 | 499 | return array( |
| 500 | 500 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
| 501 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
| 501 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
| 502 | 502 | ); |
| 503 | 503 | } |
| 504 | 504 | |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
| 527 | 527 | * @return array |
| 528 | 528 | */ |
| 529 | - function get_jquery_validation_rules(){ |
|
| 529 | + function get_jquery_validation_rules() { |
|
| 530 | 530 | $jquery_validation_rules = array(); |
| 531 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
| 532 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
| 531 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 532 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
| 533 | 533 | } |
| 534 | 534 | return $jquery_validation_rules; |
| 535 | 535 | } |
@@ -544,11 +544,11 @@ discard block |
||
| 544 | 544 | protected function _normalize($req_data) { |
| 545 | 545 | $this->_received_submission = TRUE; |
| 546 | 546 | $this->_validation_errors = array(); |
| 547 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
| 548 | - try{ |
|
| 547 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 548 | + try { |
|
| 549 | 549 | $subsection->_normalize($req_data); |
| 550 | - }catch( EE_Validation_Error $e ){ |
|
| 551 | - $subsection->add_validation_error( $e ); |
|
| 550 | + } catch (EE_Validation_Error $e) { |
|
| 551 | + $subsection->add_validation_error($e); |
|
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | } |
@@ -562,9 +562,9 @@ discard block |
||
| 562 | 562 | * calling parent::_validate() first. |
| 563 | 563 | */ |
| 564 | 564 | protected function _validate() { |
| 565 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
| 566 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
| 567 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 565 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 566 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 567 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
| 568 | 568 | } |
| 569 | 569 | $subsection->_validate(); |
| 570 | 570 | } |
@@ -576,13 +576,13 @@ discard block |
||
| 576 | 576 | * Gets all the validated inputs for the form section |
| 577 | 577 | * @return array |
| 578 | 578 | */ |
| 579 | - public function valid_data(){ |
|
| 579 | + public function valid_data() { |
|
| 580 | 580 | $inputs = array(); |
| 581 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
| 582 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 583 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
| 584 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
| 585 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
| 581 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
| 582 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
| 583 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
| 584 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
| 585 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | return $inputs; |
@@ -594,11 +594,11 @@ discard block |
||
| 594 | 594 | * Gets all the inputs on this form section |
| 595 | 595 | * @return EE_Form_Input_Base[] |
| 596 | 596 | */ |
| 597 | - public function inputs(){ |
|
| 597 | + public function inputs() { |
|
| 598 | 598 | $inputs = array(); |
| 599 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
| 600 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
| 601 | - $inputs[ $subsection_name ] = $subsection; |
|
| 599 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
| 600 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 601 | + $inputs[$subsection_name] = $subsection; |
|
| 602 | 602 | } |
| 603 | 603 | } |
| 604 | 604 | return $inputs; |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | * Gets all the subsections which are a proper form |
| 611 | 611 | * @return EE_Form_Section_Proper[] |
| 612 | 612 | */ |
| 613 | - public function subforms(){ |
|
| 613 | + public function subforms() { |
|
| 614 | 614 | $form_sections = array(); |
| 615 | - foreach($this->subsections() as $name=>$obj){ |
|
| 616 | - if($obj instanceof EE_Form_Section_Proper){ |
|
| 615 | + foreach ($this->subsections() as $name=>$obj) { |
|
| 616 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
| 617 | 617 | $form_sections[$name] = $obj; |
| 618 | 618 | } |
| 619 | 619 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | * if you only want form inputs or proper form sections. |
| 629 | 629 | * @return EE_Form_Section_Proper[] |
| 630 | 630 | */ |
| 631 | - public function subsections(){ |
|
| 631 | + public function subsections() { |
|
| 632 | 632 | $this->ensure_construct_finalized_called(); |
| 633 | 633 | return $this->_subsections; |
| 634 | 634 | } |
@@ -646,8 +646,8 @@ discard block |
||
| 646 | 646 | * it can be a multidimensional array where keys are always subsection names and values are either the |
| 647 | 647 | * input's normalized value, or an array like the top-level array |
| 648 | 648 | */ |
| 649 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
| 650 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
| 649 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
| 650 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
@@ -663,8 +663,8 @@ discard block |
||
| 663 | 663 | * it can be a multidimensional array where keys are always subsection names and values are either the |
| 664 | 664 | * input's normalized value, or an array like the top-level array |
| 665 | 665 | */ |
| 666 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
| 667 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
| 666 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
| 667 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | /** |
@@ -677,17 +677,17 @@ discard block |
||
| 677 | 677 | * it can be a multidimensional array where keys are always subsection names and values are either the |
| 678 | 678 | * input's normalized value, or an array like the top-level array |
| 679 | 679 | */ |
| 680 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
| 680 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
| 681 | 681 | $input_values = array(); |
| 682 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
| 683 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
| 684 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
| 685 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
| 686 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
| 687 | - if( $flatten ) { |
|
| 688 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
| 682 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
| 683 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 684 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
| 685 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
| 686 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
| 687 | + if ($flatten) { |
|
| 688 | + $input_values = array_merge($input_values, $subform_input_values); |
|
| 689 | 689 | } else { |
| 690 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
| 690 | + $input_values[$subsection_name] = $subform_input_values; |
|
| 691 | 691 | } |
| 692 | 692 | } |
| 693 | 693 | } |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | * (ie, had receive_form_submission called on it yet) |
| 702 | 702 | * @return boolean |
| 703 | 703 | */ |
| 704 | - public function has_received_submission(){ |
|
| 704 | + public function has_received_submission() { |
|
| 705 | 705 | $this->ensure_construct_finalized_called(); |
| 706 | 706 | return $this->_received_submission; |
| 707 | 707 | } |
@@ -714,8 +714,8 @@ discard block |
||
| 714 | 714 | * @param array $inputs_to_exclude values are the input names |
| 715 | 715 | * @return void |
| 716 | 716 | */ |
| 717 | - public function exclude($inputs_to_exclude = array()){ |
|
| 718 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
| 717 | + public function exclude($inputs_to_exclude = array()) { |
|
| 718 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
| 719 | 719 | unset($this->_subsections[$input_to_exclude_name]); |
| 720 | 720 | } |
| 721 | 721 | } |
@@ -725,8 +725,8 @@ discard block |
||
| 725 | 725 | /** |
| 726 | 726 | * @param array $inputs_to_hide |
| 727 | 727 | */ |
| 728 | - public function hide($inputs_to_hide= array()){ |
|
| 729 | - foreach($inputs_to_hide as $input_to_hide){ |
|
| 728 | + public function hide($inputs_to_hide = array()) { |
|
| 729 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
| 730 | 730 | $input = $this->get_input($input_to_hide); |
| 731 | 731 | |
| 732 | 732 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -742,13 +742,13 @@ discard block |
||
| 742 | 742 | * @param string $subsection_name_to_add_before name of the section to add these subsections in front of, or null to add at the very end |
| 743 | 743 | * @return void |
| 744 | 744 | */ |
| 745 | - public function add_subsections($subsections,$subsection_name_to_add_before = NULL){ |
|
| 746 | - foreach($subsections as $subsection_name => $subsection){ |
|
| 747 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
| 745 | + public function add_subsections($subsections, $subsection_name_to_add_before = NULL) { |
|
| 746 | + foreach ($subsections as $subsection_name => $subsection) { |
|
| 747 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
| 748 | 748 | EE_Error::add_error( |
| 749 | 749 | sprintf( |
| 750 | 750 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
| 751 | - get_class( $subsection ), |
|
| 751 | + get_class($subsection), |
|
| 752 | 752 | $subsection_name, |
| 753 | 753 | $this->name() |
| 754 | 754 | ) |
@@ -757,23 +757,23 @@ discard block |
||
| 757 | 757 | } |
| 758 | 758 | } |
| 759 | 759 | $subsections_before = array(); |
| 760 | - if( $subsection_name_to_add_before ){ |
|
| 761 | - foreach( $this->_subsections as $subsection_name => $subsection ) { |
|
| 762 | - if ( $subsection_name == $subsection_name_to_add_before ) { |
|
| 760 | + if ($subsection_name_to_add_before) { |
|
| 761 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
| 762 | + if ($subsection_name == $subsection_name_to_add_before) { |
|
| 763 | 763 | break; |
| 764 | 764 | } |
| 765 | 765 | $subsections_before[$subsection_name] = $subsection; |
| 766 | 766 | } |
| 767 | 767 | $subsections_after = array_diff_key($this->_subsections, $subsections_before); |
| 768 | - $this->_subsections = array_merge($subsections_before,$subsections,$subsections_after); |
|
| 769 | - }else{ |
|
| 768 | + $this->_subsections = array_merge($subsections_before, $subsections, $subsections_after); |
|
| 769 | + } else { |
|
| 770 | 770 | //don't use array_merge because keys might be numeric and we want to preserve their keys |
| 771 | - foreach( $subsections as $key => $subsection ){ |
|
| 772 | - $this->_subsections[ $key ] = $subsection; |
|
| 771 | + foreach ($subsections as $key => $subsection) { |
|
| 772 | + $this->_subsections[$key] = $subsection; |
|
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | - if( $this->_construction_finalized ){ |
|
| 776 | - foreach($this->_subsections as $name => $subsection){ |
|
| 775 | + if ($this->_construction_finalized) { |
|
| 776 | + foreach ($this->_subsections as $name => $subsection) { |
|
| 777 | 777 | $subsection->_construct_finalize($this, $name); |
| 778 | 778 | } |
| 779 | 779 | } |
@@ -784,8 +784,8 @@ discard block |
||
| 784 | 784 | /** |
| 785 | 785 | * Just gets all validatable subsections to clean their sensitive data |
| 786 | 786 | */ |
| 787 | - public function clean_sensitive_data(){ |
|
| 788 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
| 787 | + public function clean_sensitive_data() { |
|
| 788 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 789 | 789 | $subsection->clean_sensitive_data(); |
| 790 | 790 | } |
| 791 | 791 | } |
@@ -795,8 +795,8 @@ discard block |
||
| 795 | 795 | /** |
| 796 | 796 | * @param string $form_submission_error_message |
| 797 | 797 | */ |
| 798 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
| 799 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
| 798 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
| 799 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | |
@@ -813,8 +813,8 @@ discard block |
||
| 813 | 813 | /** |
| 814 | 814 | * @param string $form_submission_success_message |
| 815 | 815 | */ |
| 816 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
| 817 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
| 816 | + public function set_submission_success_message($form_submission_success_message) { |
|
| 817 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | |
@@ -836,10 +836,10 @@ discard block |
||
| 836 | 836 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
| 837 | 837 | * @return string |
| 838 | 838 | */ |
| 839 | - public function html_name_prefix(){ |
|
| 840 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
| 841 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
| 842 | - }else{ |
|
| 839 | + public function html_name_prefix() { |
|
| 840 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
| 841 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
| 842 | + } else { |
|
| 843 | 843 | return $this->name(); |
| 844 | 844 | } |
| 845 | 845 | } |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | * was set, which is probably nothing, or the classname) |
| 851 | 851 | * @return string |
| 852 | 852 | */ |
| 853 | - public function name(){ |
|
| 853 | + public function name() { |
|
| 854 | 854 | $this->ensure_construct_finalized_called(); |
| 855 | 855 | return parent::name(); |
| 856 | 856 | } |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | * |
| 860 | 860 | * @return EE_Form_Section_Proper |
| 861 | 861 | */ |
| 862 | - public function parent_section(){ |
|
| 862 | + public function parent_section() { |
|
| 863 | 863 | $this->ensure_construct_finalized_called(); |
| 864 | 864 | return parent::parent_section(); |
| 865 | 865 | } |
@@ -868,9 +868,9 @@ discard block |
||
| 868 | 868 | * make sure construction finalized was called, otherwise children might not be ready |
| 869 | 869 | * @return void |
| 870 | 870 | */ |
| 871 | - public function ensure_construct_finalized_called(){ |
|
| 872 | - if( ! $this->_construction_finalized ){ |
|
| 873 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
| 871 | + public function ensure_construct_finalized_called() { |
|
| 872 | + if ( ! $this->_construction_finalized) { |
|
| 873 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
| 874 | 874 | } |
| 875 | 875 | } |
| 876 | 876 | |
@@ -882,17 +882,17 @@ discard block |
||
| 882 | 882 | * @param array $req_data |
| 883 | 883 | * @return boolean |
| 884 | 884 | */ |
| 885 | - public function form_data_present_in( $req_data = NULL ) { |
|
| 886 | - if( $req_data === NULL){ |
|
| 885 | + public function form_data_present_in($req_data = NULL) { |
|
| 886 | + if ($req_data === NULL) { |
|
| 887 | 887 | $req_data = $_POST; |
| 888 | 888 | } |
| 889 | - foreach( $this->subsections() as $subsection ) { |
|
| 890 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
| 891 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
| 889 | + foreach ($this->subsections() as $subsection) { |
|
| 890 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 891 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 892 | 892 | return TRUE; |
| 893 | 893 | } |
| 894 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 895 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
| 894 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 895 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 896 | 896 | return TRUE; |
| 897 | 897 | } |
| 898 | 898 | } |
@@ -909,14 +909,14 @@ discard block |
||
| 909 | 909 | */ |
| 910 | 910 | public function get_validation_errors_accumulated() { |
| 911 | 911 | $validation_errors = $this->get_validation_errors(); |
| 912 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
| 913 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 912 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 913 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
| 914 | 914 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
| 915 | 915 | } else { |
| 916 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
| 916 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
| 917 | 917 | } |
| 918 | - if( $validation_errors_on_this_subsection ){ |
|
| 919 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
| 918 | + if ($validation_errors_on_this_subsection) { |
|
| 919 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
| 920 | 920 | } |
| 921 | 921 | } |
| 922 | 922 | return $validation_errors; |
@@ -348,6 +348,7 @@ |
||
| 348 | 348 | * Automatically finds the related model info from the form, if present, and |
| 349 | 349 | * save the relations indicated |
| 350 | 350 | * @type string $relation_name |
| 351 | + * @param integer $relation_name |
|
| 351 | 352 | * @return bool |
| 352 | 353 | * @throws EE_Error |
| 353 | 354 | */ |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | if(isset($options_array['subsection_args'])){ |
| 48 | 48 | $subsection_args = $options_array['subsection_args']; |
| 49 | - }else{ |
|
| 49 | + } else{ |
|
| 50 | 50 | $subsection_args = array(); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | if(isset($subsection_args[$relation_name]) && |
| 102 | 102 | isset($subsection_args[$relation_name]['model_objects'])){ |
| 103 | 103 | $model_objects = $subsection_args[$relation_name]['model_objects']; |
| 104 | - }else{ |
|
| 104 | + } else{ |
|
| 105 | 105 | $model_objects = $relation_obj->get_other_model()->get_all(); |
| 106 | 106 | } |
| 107 | 107 | $input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array(); |
| 164 | 164 | if(true || is_array($models_pointed_to) && count($models_pointed_to) > 1){ |
| 165 | 165 | $input_class = 'EE_Text_Input'; |
| 166 | - }else{ |
|
| 166 | + } else{ |
|
| 167 | 167 | //so its just one model |
| 168 | 168 | $model_name = is_array($models_pointed_to) ? reset($models_pointed_to) : $models_pointed_to; |
| 169 | 169 | $model = EE_Registry::instance()->load_model($model_name); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | //then we only expect there to be one |
| 256 | 256 | $related_item = $this->_model_object->get_first_related($relation_name); |
| 257 | 257 | $defaults[$relation_name] = $related_item->ID(); |
| 258 | - }else{ |
|
| 258 | + } else{ |
|
| 259 | 259 | $related_items = $this->_model_object->get_many_related($relation_name); |
| 260 | 260 | $ids = array(); |
| 261 | 261 | foreach($related_items as $related_item){ |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name)); |
| 306 | 306 | if($model_obj){ |
| 307 | 307 | $this->_model_object = $model_obj; |
| 308 | - }else{ |
|
| 308 | + } else{ |
|
| 309 | 309 | $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() ); |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -356,19 +356,19 @@ discard block |
||
| 356 | 356 | if($relation_obj instanceof EE_Belongs_To_Relation){ |
| 357 | 357 | //there is just a foreign key on this model pointing to that one |
| 358 | 358 | $this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name); |
| 359 | - }elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
| 359 | + } elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
| 360 | 360 | //then we want to consider all of its currently-related things. |
| 361 | 361 | //if they're in this list, keep them |
| 362 | 362 | //if they're not in this list, remove them |
| 363 | 363 | //and lastly add all the new items |
| 364 | 364 | throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso"))); |
| 365 | - }elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
| 365 | + } elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
| 366 | 366 | //delete everything NOT in this list |
| 367 | 367 | $normalized_input_value = $this->get_input_value($relation_name); |
| 368 | 368 | if($normalized_input_value && is_array($normalized_input_value)){ |
| 369 | 369 | $where_query_params = array( |
| 370 | 370 | $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value)); |
| 371 | - }else{ |
|
| 371 | + } else{ |
|
| 372 | 372 | $where_query_params = array(); |
| 373 | 373 | } |
| 374 | 374 | $this->_model_object->_remove_relations( $relation_name, $where_query_params ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @since 4.5.0 |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Model_Form_Section extends EE_Form_Section_Proper{ |
|
| 14 | +class EE_Model_Form_Section extends EE_Form_Section_Proper { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * |
@@ -36,36 +36,36 @@ discard block |
||
| 36 | 36 | * } |
| 37 | 37 | * @throws EE_Error |
| 38 | 38 | */ |
| 39 | - public function __construct($options_array = array()){ |
|
| 40 | - if(isset($options_array['model']) && $options_array['model'] instanceof EEM_Base){ |
|
| 39 | + public function __construct($options_array = array()) { |
|
| 40 | + if (isset($options_array['model']) && $options_array['model'] instanceof EEM_Base) { |
|
| 41 | 41 | $this->_model = $options_array['model']; |
| 42 | 42 | } |
| 43 | - if( ! $this->_model || ! $this->_model instanceof EEM_Base ){ |
|
| 43 | + if ( ! $this->_model || ! $this->_model instanceof EEM_Base) { |
|
| 44 | 44 | throw new EE_Error(sprintf(__("Model Form Sections must first specify the _model property to be a subclass of EEM_Base", "event_espresso"))); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if(isset($options_array['subsection_args'])){ |
|
| 47 | + if (isset($options_array['subsection_args'])) { |
|
| 48 | 48 | $subsection_args = $options_array['subsection_args']; |
| 49 | - }else{ |
|
| 49 | + } else { |
|
| 50 | 50 | $subsection_args = array(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | //gather fields and relations to convert to inputs |
| 54 | 54 | //but if they're just going to exclude a field anyways, don't bother converting it to an input |
| 55 | 55 | $exclude = $this->_subsections; |
| 56 | - if(isset($options_array['exclude'])){ |
|
| 57 | - $exclude = array_merge($exclude,array_flip($options_array['exclude'])); |
|
| 56 | + if (isset($options_array['exclude'])) { |
|
| 57 | + $exclude = array_merge($exclude, array_flip($options_array['exclude'])); |
|
| 58 | 58 | } |
| 59 | 59 | $model_fields = array_diff_key($this->_model->field_settings(), $exclude); |
| 60 | 60 | $model_relations = array_diff_key($this->_model->relation_settings(), $exclude); |
| 61 | 61 | //convert fields and relations to inputs |
| 62 | 62 | $this->_subsections = array_merge( |
| 63 | 63 | $this->_convert_model_fields_to_inputs($model_fields), |
| 64 | - $this->_convert_model_relations_to_inputs($model_relations,$subsection_args), |
|
| 64 | + $this->_convert_model_relations_to_inputs($model_relations, $subsection_args), |
|
| 65 | 65 | $this->_subsections |
| 66 | 66 | ); |
| 67 | 67 | parent::__construct($options_array); |
| 68 | - if(isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class){ |
|
| 68 | + if (isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class) { |
|
| 69 | 69 | $this->populate_model_obj($options_array['model_object']); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | * } |
| 84 | 84 | * @return array |
| 85 | 85 | */ |
| 86 | - protected function _convert_model_relations_to_inputs($relations,$subsection_args = array()){ |
|
| 86 | + protected function _convert_model_relations_to_inputs($relations, $subsection_args = array()) { |
|
| 87 | 87 | $inputs = array(); |
| 88 | - foreach( $relations as $relation_name => $relation_obj ) { |
|
| 88 | + foreach ($relations as $relation_name => $relation_obj) { |
|
| 89 | 89 | $input_constructor_args = array( |
| 90 | 90 | array_merge( |
| 91 | 91 | array( |
@@ -96,19 +96,19 @@ discard block |
||
| 96 | 96 | ) |
| 97 | 97 | ); |
| 98 | 98 | $input = NULL; |
| 99 | - switch(get_class($relation_obj)){ |
|
| 99 | + switch (get_class($relation_obj)) { |
|
| 100 | 100 | case 'EE_HABTM_Relation': |
| 101 | - if(isset($subsection_args[$relation_name]) && |
|
| 102 | - isset($subsection_args[$relation_name]['model_objects'])){ |
|
| 101 | + if (isset($subsection_args[$relation_name]) && |
|
| 102 | + isset($subsection_args[$relation_name]['model_objects'])) { |
|
| 103 | 103 | $model_objects = $subsection_args[$relation_name]['model_objects']; |
| 104 | - }else{ |
|
| 104 | + } else { |
|
| 105 | 105 | $model_objects = $relation_obj->get_other_model()->get_all(); |
| 106 | 106 | } |
| 107 | - $input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args); |
|
| 107 | + $input = new EE_Select_Multi_Model_Input($model_objects, $input_constructor_args); |
|
| 108 | 108 | break; |
| 109 | 109 | default: |
| 110 | 110 | } |
| 111 | - if($input){ |
|
| 111 | + if ($input) { |
|
| 112 | 112 | $inputs[$relation_name] = $input; |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -123,16 +123,16 @@ discard block |
||
| 123 | 123 | * @throws EE_Error |
| 124 | 124 | * @return EE_Form_Input_Base[] |
| 125 | 125 | */ |
| 126 | - protected function _convert_model_fields_to_inputs( $model_fields = array() ){ |
|
| 126 | + protected function _convert_model_fields_to_inputs($model_fields = array()) { |
|
| 127 | 127 | $inputs = array(); |
| 128 | - foreach( $model_fields as $field_name=>$model_field ){ |
|
| 129 | - if ( $model_field instanceof EE_Model_Field_Base ) { |
|
| 128 | + foreach ($model_fields as $field_name=>$model_field) { |
|
| 129 | + if ($model_field instanceof EE_Model_Field_Base) { |
|
| 130 | 130 | $input_constructor_args = array(array( |
| 131 | 131 | 'required'=> ! $model_field->is_nullable() && $model_field->get_default_value() === NULL, |
| 132 | 132 | 'html_label_text'=>$model_field->get_nicename(), |
| 133 | 133 | 'default'=>$model_field->get_default_value(), |
| 134 | 134 | )); |
| 135 | - switch(get_class($model_field)){ |
|
| 135 | + switch (get_class($model_field)) { |
|
| 136 | 136 | case 'EE_All_Caps_Text_Field': |
| 137 | 137 | case 'EE_Any_Foreign_Model_Name_Field': |
| 138 | 138 | $input_class = 'EE_Text_Input'; |
@@ -141,16 +141,16 @@ discard block |
||
| 141 | 141 | $input_class = 'EE_Yes_No_Input'; |
| 142 | 142 | break; |
| 143 | 143 | case 'EE_Datetime_Field': |
| 144 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 144 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 145 | 145 | break; |
| 146 | 146 | case 'EE_Email_Field': |
| 147 | 147 | $input_class = 'EE_Email_Input'; |
| 148 | 148 | break; |
| 149 | 149 | case 'EE_Enum_Integer_Field': |
| 150 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 150 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 151 | 151 | break; |
| 152 | 152 | case 'EE_Enum_Text_Field': |
| 153 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 153 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 154 | 154 | break; |
| 155 | 155 | case 'EE_Float_Field': |
| 156 | 156 | $input_class = 'EE_Float_Input'; |
@@ -159,15 +159,15 @@ discard block |
||
| 159 | 159 | case 'EE_Foreign_Key_String_Field': |
| 160 | 160 | case 'EE_WP_User_Field': |
| 161 | 161 | $models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array(); |
| 162 | - if(true || is_array($models_pointed_to) && count($models_pointed_to) > 1){ |
|
| 162 | + if (true || is_array($models_pointed_to) && count($models_pointed_to) > 1) { |
|
| 163 | 163 | $input_class = 'EE_Text_Input'; |
| 164 | - }else{ |
|
| 164 | + } else { |
|
| 165 | 165 | //so its just one model |
| 166 | 166 | $model_name = is_array($models_pointed_to) ? reset($models_pointed_to) : $models_pointed_to; |
| 167 | 167 | $model = EE_Registry::instance()->load_model($model_name); |
| 168 | 168 | $model_names = $model->get_all_names(array('limit'=>10)); |
| 169 | - if($model_field->is_nullable()){ |
|
| 170 | - array_unshift( $model_names, __( "Please Select", 'event_espresso' )); |
|
| 169 | + if ($model_field->is_nullable()) { |
|
| 170 | + array_unshift($model_names, __("Please Select", 'event_espresso')); |
|
| 171 | 171 | } |
| 172 | 172 | $input_constructor_args[1] = $input_constructor_args[0]; |
| 173 | 173 | $input_constructor_args[0] = $model_names; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $input_class = 'EE_Text_Area_Input'; |
| 179 | 179 | break; |
| 180 | 180 | case 'EE_Infinite_Integer': |
| 181 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 181 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 182 | 182 | break; |
| 183 | 183 | case 'EE_Integer_Field': |
| 184 | 184 | $input_class = 'EE_Text_Input'; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $input_class = 'EE_Text_Area_Input'; |
| 188 | 188 | break; |
| 189 | 189 | case 'EE_Money_Field': |
| 190 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 190 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 191 | 191 | break; |
| 192 | 192 | case 'EE_Post_Content_Field': |
| 193 | 193 | $input_class = 'EE_Text_Area_Input'; |
@@ -215,13 +215,13 @@ discard block |
||
| 215 | 215 | $input_class = 'EE_Yes_No_Input'; |
| 216 | 216 | break; |
| 217 | 217 | case 'EE_WP_Post_Status_Field': |
| 218 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 218 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 219 | 219 | break; |
| 220 | 220 | case 'EE_WP_Post_Type_Field': |
| 221 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 221 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 222 | 222 | break; |
| 223 | 223 | default: |
| 224 | - throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"),get_class($model_field))); |
|
| 224 | + throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"), get_class($model_field))); |
|
| 225 | 225 | } |
| 226 | 226 | $reflection = new ReflectionClass($input_class); |
| 227 | 227 | $input = $reflection->newInstanceArgs($input_constructor_args); |
@@ -239,21 +239,21 @@ discard block |
||
| 239 | 239 | * @param EE_Base_Class $model_obj |
| 240 | 240 | * @return void |
| 241 | 241 | */ |
| 242 | - public function populate_model_obj($model_obj){ |
|
| 242 | + public function populate_model_obj($model_obj) { |
|
| 243 | 243 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
| 244 | 244 | $this->_model_object = $model_obj; |
| 245 | 245 | $defaults = $model_obj->model_field_array(); |
| 246 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
| 246 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
| 247 | 247 | $form_inputs = $this->inputs(); |
| 248 | - if(isset($form_inputs[$relation_name])){ |
|
| 249 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
| 248 | + if (isset($form_inputs[$relation_name])) { |
|
| 249 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
| 250 | 250 | //then we only expect there to be one |
| 251 | 251 | $related_item = $this->_model_object->get_first_related($relation_name); |
| 252 | 252 | $defaults[$relation_name] = $related_item->ID(); |
| 253 | - }else{ |
|
| 253 | + } else { |
|
| 254 | 254 | $related_items = $this->_model_object->get_many_related($relation_name); |
| 255 | 255 | $ids = array(); |
| 256 | - foreach($related_items as $related_item){ |
|
| 256 | + foreach ($related_items as $related_item) { |
|
| 257 | 257 | $ids[] = $related_item->ID(); |
| 258 | 258 | } |
| 259 | 259 | $defaults[$relation_name] = $ids; |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | * values are their normalized values |
| 271 | 271 | * @return array |
| 272 | 272 | */ |
| 273 | - public function inputs_values_corresponding_to_model_fields(){ |
|
| 274 | - return array_intersect_key($this->input_values(),$this->_model->field_settings()); |
|
| 273 | + public function inputs_values_corresponding_to_model_fields() { |
|
| 274 | + return array_intersect_key($this->input_values(), $this->_model->field_settings()); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | |
@@ -294,21 +294,21 @@ discard block |
||
| 294 | 294 | public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
| 295 | 295 | parent::receive_form_submission($req_data, $validate); |
| 296 | 296 | //create or set the model object, if it isn't already |
| 297 | - if( ! $this->_model_object ){ |
|
| 297 | + if ( ! $this->_model_object) { |
|
| 298 | 298 | //check to see if the form indicates a PK, in which case we want to only retrieve it and update it |
| 299 | 299 | $pk_name = $this->_model->primary_key_name(); |
| 300 | 300 | $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name)); |
| 301 | - if($model_obj){ |
|
| 301 | + if ($model_obj) { |
|
| 302 | 302 | $this->_model_object = $model_obj; |
| 303 | - }else{ |
|
| 304 | - $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() ); |
|
| 303 | + } else { |
|
| 304 | + $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name()); |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | //ok so the model object is set. Just set it with the submitted form data (don't save yet though) |
| 308 | - foreach($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value){ |
|
| 308 | + foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value) { |
|
| 309 | 309 | //only set the non-primary key |
| 310 | - if($field_name != $this->_model->primary_key_name()){ |
|
| 311 | - $this->_model_object->set($field_name,$field_value); |
|
| 310 | + if ($field_name != $this->_model->primary_key_name()) { |
|
| 311 | + $this->_model_object->set($field_name, $field_value); |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
@@ -324,13 +324,13 @@ discard block |
||
| 324 | 324 | * @return int, 1 on a successful update, the ID of |
| 325 | 325 | * the new entry on insert; 0 on failure |
| 326 | 326 | */ |
| 327 | - public function save(){ |
|
| 328 | - if( ! $this->_model_object){ |
|
| 329 | - throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"),get_class($this->_model))); |
|
| 327 | + public function save() { |
|
| 328 | + if ( ! $this->_model_object) { |
|
| 329 | + throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"), get_class($this->_model))); |
|
| 330 | 330 | } |
| 331 | - $success = $this->_model_object->save(); |
|
| 332 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
| 333 | - if(isset($this->_subsections[$relation_name])){ |
|
| 331 | + $success = $this->_model_object->save(); |
|
| 332 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
| 333 | + if (isset($this->_subsections[$relation_name])) { |
|
| 334 | 334 | $success = $this->_save_related_info($relation_name); |
| 335 | 335 | } |
| 336 | 336 | } |
@@ -346,29 +346,29 @@ discard block |
||
| 346 | 346 | * @return bool |
| 347 | 347 | * @throws EE_Error |
| 348 | 348 | */ |
| 349 | - protected function _save_related_info($relation_name){ |
|
| 349 | + protected function _save_related_info($relation_name) { |
|
| 350 | 350 | $relation_obj = $this->_model->related_settings_for($relation_name); |
| 351 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
| 351 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
| 352 | 352 | //there is just a foreign key on this model pointing to that one |
| 353 | 353 | $this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name); |
| 354 | - }elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
| 354 | + }elseif ($relation_obj instanceof EE_Has_Many_Relation) { |
|
| 355 | 355 | //then we want to consider all of its currently-related things. |
| 356 | 356 | //if they're in this list, keep them |
| 357 | 357 | //if they're not in this list, remove them |
| 358 | 358 | //and lastly add all the new items |
| 359 | 359 | throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso"))); |
| 360 | - }elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
| 360 | + }elseif ($relation_obj instanceof EE_HABTM_Relation) { |
|
| 361 | 361 | //delete everything NOT in this list |
| 362 | 362 | $normalized_input_value = $this->get_input_value($relation_name); |
| 363 | - if($normalized_input_value && is_array($normalized_input_value)){ |
|
| 363 | + if ($normalized_input_value && is_array($normalized_input_value)) { |
|
| 364 | 364 | $where_query_params = array( |
| 365 | - $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value)); |
|
| 366 | - }else{ |
|
| 365 | + $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN', $normalized_input_value)); |
|
| 366 | + } else { |
|
| 367 | 367 | $where_query_params = array(); |
| 368 | 368 | } |
| 369 | - $this->_model_object->_remove_relations( $relation_name, $where_query_params ); |
|
| 370 | - foreach($normalized_input_value as $id){ |
|
| 371 | - $this->_model_object->_add_relation_to( $id, $relation_name ); |
|
| 369 | + $this->_model_object->_remove_relations($relation_name, $where_query_params); |
|
| 370 | + foreach ($normalized_input_value as $id) { |
|
| 371 | + $this->_model_object->_add_relation_to($id, $relation_name); |
|
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | return TRUE; |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * Gets the model of this model form |
| 381 | 381 | * @return EEM_Base |
| 382 | 382 | */ |
| 383 | - public function get_model(){ |
|
| 383 | + public function get_model() { |
|
| 384 | 384 | return $this->_model; |
| 385 | 385 | } |
| 386 | 386 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | * when receive_form_submission($req_data) was called. |
| 394 | 394 | * @return EE_Base_Class |
| 395 | 395 | */ |
| 396 | - public function get_model_object(){ |
|
| 396 | + public function get_model_object() { |
|
| 397 | 397 | return $this->_model_object; |
| 398 | 398 | } |
| 399 | 399 | |
@@ -403,10 +403,10 @@ discard block |
||
| 403 | 403 | * gets teh default name of this form section if none is specified |
| 404 | 404 | * @return string |
| 405 | 405 | */ |
| 406 | - protected function _set_default_name_if_empty(){ |
|
| 407 | - if( ! $this->_name ){ |
|
| 408 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
| 409 | - $this->_name = $default_name; |
|
| 406 | + protected function _set_default_name_if_empty() { |
|
| 407 | + if ( ! $this->_name) { |
|
| 408 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
| 409 | + $this->_name = $default_name; |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | /** |
| 262 | 262 | * Sets sensitive_data_removal_strategy |
| 263 | 263 | * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy |
| 264 | - * @return boolean |
|
| 264 | + * @return boolean|null |
|
| 265 | 265 | */ |
| 266 | 266 | public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy) { |
| 267 | 267 | $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy; |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | * Returns whether or not any validation errors occurred |
| 446 | 446 | * |
| 447 | 447 | * @param array $req_data like $_POST |
| 448 | - * @return boolean whether or not there was an error |
|
| 448 | + * @return boolean|null whether or not there was an error |
|
| 449 | 449 | */ |
| 450 | 450 | protected function _normalize( $req_data ) { |
| 451 | 451 | //any existing validation errors don't apply so clear them |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @subpackage |
| 9 | 9 | * @author Mike Nelson |
| 10 | 10 | */ |
| 11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
| 11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * the input's name attribute |
@@ -141,66 +141,66 @@ discard block |
||
| 141 | 141 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
| 142 | 142 | * } |
| 143 | 143 | */ |
| 144 | - public function __construct( $input_args = array() ){ |
|
| 144 | + public function __construct($input_args = array()) { |
|
| 145 | 145 | // the following properties must be cast as arrays |
| 146 | 146 | $set_as_array = array( |
| 147 | 147 | 'validation_strategies' |
| 148 | 148 | ); |
| 149 | 149 | // loop thru incoming options |
| 150 | - foreach( $input_args as $key => $value ) { |
|
| 150 | + foreach ($input_args as $key => $value) { |
|
| 151 | 151 | // add underscore to $key to match property names |
| 152 | - $_key = '_' . $key; |
|
| 153 | - if ( property_exists( $this, $_key )) { |
|
| 152 | + $_key = '_'.$key; |
|
| 153 | + if (property_exists($this, $_key)) { |
|
| 154 | 154 | // first check if this property needs to be set as an array |
| 155 | - if ( isset( $set_as_array[ $key ] )) { |
|
| 155 | + if (isset($set_as_array[$key])) { |
|
| 156 | 156 | // ensure value is an array |
| 157 | - $value = is_array( $value ) ? $value : array( $value ); |
|
| 157 | + $value = is_array($value) ? $value : array($value); |
|
| 158 | 158 | // and merge with existing values |
| 159 | - $this->$_key = array_merge( $this->$_key, $value ); |
|
| 159 | + $this->$_key = array_merge($this->$_key, $value); |
|
| 160 | 160 | } else { |
| 161 | 161 | $this->$_key = $value; |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | // ensure that "required" is set correctly |
| 166 | - $this->set_required( $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) ? $input_args[ 'required_validation_error_message' ] : NULL ); |
|
| 166 | + $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL); |
|
| 167 | 167 | |
| 168 | - $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
|
| 168 | + $this->_html_name_specified = isset($input_args['html_name']) ? TRUE : FALSE; |
|
| 169 | 169 | |
| 170 | 170 | $this->_display_strategy->_construct_finalize($this); |
| 171 | 171 | |
| 172 | - if ( $this->_validation_strategies ){ |
|
| 173 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
| 172 | + if ($this->_validation_strategies) { |
|
| 173 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
| 174 | 174 | $validation_strategy->_construct_finalize($this); |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if( ! $this->_normalization_strategy){ |
|
| 178 | + if ( ! $this->_normalization_strategy) { |
|
| 179 | 179 | $this->_normalization_strategy = new EE_Text_Normalization(); |
| 180 | 180 | } |
| 181 | 181 | $this->_normalization_strategy->_construct_finalize($this); |
| 182 | 182 | |
| 183 | 183 | //at least we can use the normalization strategy to populate the default |
| 184 | - if( isset( $input_args[ 'default' ] ) ) { |
|
| 185 | - $this->set_default( $input_args[ 'default' ] ); |
|
| 184 | + if (isset($input_args['default'])) { |
|
| 185 | + $this->set_default($input_args['default']); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
| 188 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
| 189 | 189 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
| 190 | 190 | } |
| 191 | 191 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
| 192 | - parent::__construct( $input_args ); |
|
| 192 | + parent::__construct($input_args); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | 196 | * Sets the html_name to its default value, if none was specified in teh constructor. |
| 197 | 197 | * Calculation involves using the name and the parent's html_name |
| 198 | 198 | */ |
| 199 | - protected function _set_default_html_name_if_empty(){ |
|
| 200 | - if( ! $this->_html_name){ |
|
| 201 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
| 202 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
| 203 | - }else{ |
|
| 199 | + protected function _set_default_html_name_if_empty() { |
|
| 200 | + if ( ! $this->_html_name) { |
|
| 201 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
| 202 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
| 203 | + } else { |
|
| 204 | 204 | $this->_html_name = $this->name(); |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | function _construct_finalize($parent_form_section, $name) { |
| 216 | 216 | parent::_construct_finalize($parent_form_section, $name); |
| 217 | 217 | $this->_set_default_html_name_if_empty(); |
| 218 | - if( ! $this->_html_label ){ |
|
| 219 | - if( ! $this->_html_label_text){ |
|
| 220 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
| 218 | + if ( ! $this->_html_label) { |
|
| 219 | + if ( ! $this->_html_label_text) { |
|
| 220 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -227,10 +227,10 @@ discard block |
||
| 227 | 227 | * @return EE_Display_Strategy_Base |
| 228 | 228 | * @throws EE_Error |
| 229 | 229 | */ |
| 230 | - protected function _get_display_strategy(){ |
|
| 231 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
| 232 | - throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
|
| 233 | - }else{ |
|
| 230 | + protected function _get_display_strategy() { |
|
| 231 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
| 232 | + throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"), $this->html_name(), $this->html_id())); |
|
| 233 | + } else { |
|
| 234 | 234 | return $this->_display_strategy; |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * Sets the display strategy. |
| 239 | 239 | * @param EE_Display_Strategy_Base $strategy |
| 240 | 240 | */ |
| 241 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
| 241 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
| 242 | 242 | $this->_display_strategy = $strategy; |
| 243 | 243 | } |
| 244 | 244 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * Sets the sanitization strategy |
| 247 | 247 | * @param EE_Normalization_Strategy_Base $strategy |
| 248 | 248 | */ |
| 249 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
| 249 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
| 250 | 250 | $this->_normalization_strategy = $strategy; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -272,14 +272,14 @@ discard block |
||
| 272 | 272 | * Gets the display strategy for this input |
| 273 | 273 | * @return EE_Display_Strategy_Base |
| 274 | 274 | */ |
| 275 | - public function get_display_strategy(){ |
|
| 275 | + public function get_display_strategy() { |
|
| 276 | 276 | return $this->_display_strategy; |
| 277 | 277 | } |
| 278 | 278 | /** |
| 279 | 279 | * Overwrites the display strategy |
| 280 | 280 | * @param EE_Display_Strategy_Base $display_strategy |
| 281 | 281 | */ |
| 282 | - public function set_display_strategy($display_strategy){ |
|
| 282 | + public function set_display_strategy($display_strategy) { |
|
| 283 | 283 | $this->_display_strategy = $display_strategy; |
| 284 | 284 | $this->_display_strategy->_construct_finalize($this); |
| 285 | 285 | } |
@@ -287,14 +287,14 @@ discard block |
||
| 287 | 287 | * Gets the normalization strategy set on this input |
| 288 | 288 | * @return EE_Normalization_Strategy_Base |
| 289 | 289 | */ |
| 290 | - public function get_normalization_strategy(){ |
|
| 290 | + public function get_normalization_strategy() { |
|
| 291 | 291 | return $this->_normalization_strategy; |
| 292 | 292 | } |
| 293 | 293 | /** |
| 294 | 294 | * Overwrites the normalization strategy |
| 295 | 295 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
| 296 | 296 | */ |
| 297 | - public function set_normalization_strategy($normalization_strategy){ |
|
| 297 | + public function set_normalization_strategy($normalization_strategy) { |
|
| 298 | 298 | $this->_normalization_strategy = $normalization_strategy; |
| 299 | 299 | $this->_normalization_strategy->_construct_finalize($this); |
| 300 | 300 | } |
@@ -303,10 +303,10 @@ discard block |
||
| 303 | 303 | * Returns all teh validation strategies which apply to this field, numerically indexed |
| 304 | 304 | * @return EE_Validation_Strategy_Base[] |
| 305 | 305 | */ |
| 306 | - public function get_validation_strategies(){ |
|
| 307 | - if(is_array($this->_validation_strategies)){ |
|
| 306 | + public function get_validation_strategies() { |
|
| 307 | + if (is_array($this->_validation_strategies)) { |
|
| 308 | 308 | return $this->_validation_strategies; |
| 309 | - }else{ |
|
| 309 | + } else { |
|
| 310 | 310 | return array(); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -316,9 +316,9 @@ discard block |
||
| 316 | 316 | * @param EE_Validation_Strategy_Base $validation_strategy |
| 317 | 317 | * @return void |
| 318 | 318 | */ |
| 319 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
| 320 | - $validation_strategy->_construct_finalize( $this ); |
|
| 321 | - $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy; |
|
| 319 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
| 320 | + $validation_strategy->_construct_finalize($this); |
|
| 321 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
| 322 | 322 | |
| 323 | 323 | } |
| 324 | 324 | |
@@ -327,18 +327,18 @@ discard block |
||
| 327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
| 328 | 328 | * @return void |
| 329 | 329 | */ |
| 330 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
| 331 | - $this->_add_validation_strategy( $validation_strategy ); |
|
| 330 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
| 331 | + $this->_add_validation_strategy($validation_strategy); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | 335 | * The classname of the validation strategy to remove |
| 336 | 336 | * @param string $validation_strategy_classname |
| 337 | 337 | */ |
| 338 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
| 339 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
| 340 | - if( is_subclass_of( $validation_strategy, $validation_strategy_classname ) ){ |
|
| 341 | - unset( $this->_validation_strategies[ $key ] ); |
|
| 338 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
| 339 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
| 340 | + if (is_subclass_of($validation_strategy, $validation_strategy_classname)) { |
|
| 341 | + unset($this->_validation_strategies[$key]); |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * to the parent form's layout strategy |
| 348 | 348 | * @return string |
| 349 | 349 | */ |
| 350 | - public function get_html_and_js(){ |
|
| 350 | + public function get_html_and_js() { |
|
| 351 | 351 | return $this->_parent_section->get_html_for_input($this); |
| 352 | 352 | } |
| 353 | 353 | /** |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * Makes sure the JS and CSS are enqueued for it |
| 357 | 357 | * @return string |
| 358 | 358 | */ |
| 359 | - public function get_html_for_input(){ |
|
| 359 | + public function get_html_for_input() { |
|
| 360 | 360 | return $this->_get_display_strategy()->display(); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | 368 | public function html_other_attributes() { |
| 369 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
| 369 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | /** |
| 375 | 375 | * @param string $html_other_attributes |
| 376 | 376 | */ |
| 377 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
| 377 | + public function set_html_other_attributes($html_other_attributes) { |
|
| 378 | 378 | $this->_html_other_attributes = $html_other_attributes; |
| 379 | 379 | } |
| 380 | 380 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * according to the form section's layout strategy |
| 384 | 384 | * @return string |
| 385 | 385 | */ |
| 386 | - public function get_html_for_label(){ |
|
| 386 | + public function get_html_for_label() { |
|
| 387 | 387 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
| 388 | 388 | } |
| 389 | 389 | /** |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | * according to the form section's layout strategy |
| 392 | 392 | * @return string |
| 393 | 393 | */ |
| 394 | - public function get_html_for_errors(){ |
|
| 394 | + public function get_html_for_errors() { |
|
| 395 | 395 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
| 396 | 396 | } |
| 397 | 397 | /** |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * according to the form section's layout strategy |
| 400 | 400 | * @return string |
| 401 | 401 | */ |
| 402 | - public function get_html_for_help(){ |
|
| 402 | + public function get_html_for_help() { |
|
| 403 | 403 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
| 404 | 404 | } |
| 405 | 405 | /** |
@@ -408,20 +408,20 @@ discard block |
||
| 408 | 408 | * @return boolean |
| 409 | 409 | */ |
| 410 | 410 | protected function _validate() { |
| 411 | - if(is_array($this->_validation_strategies)){ |
|
| 412 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
| 413 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
| 414 | - try{ |
|
| 411 | + if (is_array($this->_validation_strategies)) { |
|
| 412 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
| 413 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
| 414 | + try { |
|
| 415 | 415 | $validation_strategy->validate($this->normalized_value()); |
| 416 | - }catch(EE_Validation_Error $e){ |
|
| 416 | + } catch (EE_Validation_Error $e) { |
|
| 417 | 417 | $this->add_validation_error($e); |
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | - if( $this->get_validation_errors()){ |
|
| 422 | + if ($this->get_validation_errors()) { |
|
| 423 | 423 | return false; |
| 424 | - }else{ |
|
| 424 | + } else { |
|
| 425 | 425 | return true; |
| 426 | 426 | } |
| 427 | 427 | } |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | * @param string $value |
| 435 | 435 | * @return null|string |
| 436 | 436 | */ |
| 437 | - private function _sanitize($value){ |
|
| 438 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
| 437 | + private function _sanitize($value) { |
|
| 438 | + return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
@@ -447,24 +447,24 @@ discard block |
||
| 447 | 447 | * @param array $req_data like $_POST |
| 448 | 448 | * @return boolean whether or not there was an error |
| 449 | 449 | */ |
| 450 | - protected function _normalize( $req_data ) { |
|
| 450 | + protected function _normalize($req_data) { |
|
| 451 | 451 | //any existing validation errors don't apply so clear them |
| 452 | 452 | $this->_validation_errors = array(); |
| 453 | 453 | try { |
| 454 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
| 454 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
| 455 | 455 | //super simple sanitization for now |
| 456 | - if ( is_array( $raw_input )) { |
|
| 456 | + if (is_array($raw_input)) { |
|
| 457 | 457 | $this->_raw_value = array(); |
| 458 | - foreach( $raw_input as $key => $value ) { |
|
| 459 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
| 458 | + foreach ($raw_input as $key => $value) { |
|
| 459 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
| 460 | 460 | } |
| 461 | 461 | } else { |
| 462 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
| 462 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
| 463 | 463 | } |
| 464 | 464 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
| 465 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
| 466 | - } catch ( EE_Validation_Error $e ) { |
|
| 467 | - $this->add_validation_error( $e ); |
|
| 465 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
| 466 | + } catch (EE_Validation_Error $e) { |
|
| 467 | + $this->add_validation_error($e); |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | /** |
| 474 | 474 | * @return string |
| 475 | 475 | */ |
| 476 | - public function html_name(){ |
|
| 476 | + public function html_name() { |
|
| 477 | 477 | return $this->_html_name; |
| 478 | 478 | } |
| 479 | 479 | |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | /** |
| 483 | 483 | * @return string |
| 484 | 484 | */ |
| 485 | - function html_label_id(){ |
|
| 486 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
| 485 | + function html_label_id() { |
|
| 486 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | /** |
| 492 | 492 | * @return string |
| 493 | 493 | */ |
| 494 | - function html_label_class(){ |
|
| 494 | + function html_label_class() { |
|
| 495 | 495 | return $this->_html_label_class; |
| 496 | 496 | } |
| 497 | 497 | |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | /** |
| 501 | 501 | * @return string |
| 502 | 502 | */ |
| 503 | - function html_label_style(){ |
|
| 503 | + function html_label_style() { |
|
| 504 | 504 | return $this->_html_label_style; |
| 505 | 505 | } |
| 506 | 506 | |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | /** |
| 510 | 510 | * @return string |
| 511 | 511 | */ |
| 512 | - function html_label_text(){ |
|
| 512 | + function html_label_text() { |
|
| 513 | 513 | return $this->_html_label_text; |
| 514 | 514 | } |
| 515 | 515 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | /** |
| 519 | 519 | * @return string |
| 520 | 520 | */ |
| 521 | - function html_help_text(){ |
|
| 521 | + function html_help_text() { |
|
| 522 | 522 | return $this->_html_help_text; |
| 523 | 523 | } |
| 524 | 524 | |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | /** |
| 528 | 528 | * @return string |
| 529 | 529 | */ |
| 530 | - function html_help_class(){ |
|
| 530 | + function html_help_class() { |
|
| 531 | 531 | return $this->_html_help_class; |
| 532 | 532 | } |
| 533 | 533 | |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | /** |
| 537 | 537 | * @return string |
| 538 | 538 | */ |
| 539 | - function html_help_style(){ |
|
| 539 | + function html_help_style() { |
|
| 540 | 540 | return $this->_html_style; |
| 541 | 541 | } |
| 542 | 542 | /** |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | * in which case, we would have stored the malicious content to our database. |
| 550 | 550 | * @return string |
| 551 | 551 | */ |
| 552 | - function raw_value(){ |
|
| 552 | + function raw_value() { |
|
| 553 | 553 | return $this->_raw_value; |
| 554 | 554 | } |
| 555 | 555 | /** |
@@ -557,15 +557,15 @@ discard block |
||
| 557 | 557 | * it escapes all html entities |
| 558 | 558 | * @return string |
| 559 | 559 | */ |
| 560 | - function raw_value_in_form(){ |
|
| 561 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
| 560 | + function raw_value_in_form() { |
|
| 561 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
| 562 | 562 | } |
| 563 | 563 | /** |
| 564 | 564 | * returns the value after it's been sanitized, and then converted into it's proper type |
| 565 | 565 | * in PHP. Eg, a string, an int, an array, |
| 566 | 566 | * @return mixed |
| 567 | 567 | */ |
| 568 | - function normalized_value(){ |
|
| 568 | + function normalized_value() { |
|
| 569 | 569 | return $this->_normalized_value; |
| 570 | 570 | } |
| 571 | 571 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * the best thing to display |
| 576 | 576 | * @return string |
| 577 | 577 | */ |
| 578 | - function pretty_value(){ |
|
| 578 | + function pretty_value() { |
|
| 579 | 579 | return $this->_normalized_value; |
| 580 | 580 | } |
| 581 | 581 | /** |
@@ -594,15 +594,15 @@ discard block |
||
| 594 | 594 | }</code> |
| 595 | 595 | * @return array |
| 596 | 596 | */ |
| 597 | - function get_jquery_validation_rules(){ |
|
| 597 | + function get_jquery_validation_rules() { |
|
| 598 | 598 | $jquery_validation_rules = array(); |
| 599 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
| 600 | - $jquery_validation_rules = array_replace_recursive( $jquery_validation_rules, $validation_strategy->get_jquery_validation_rule_array()); |
|
| 599 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
| 600 | + $jquery_validation_rules = array_replace_recursive($jquery_validation_rules, $validation_strategy->get_jquery_validation_rule_array()); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - if(! empty($jquery_validation_rules)){ |
|
| 604 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
| 605 | - }else{ |
|
| 603 | + if ( ! empty($jquery_validation_rules)) { |
|
| 604 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
| 605 | + } else { |
|
| 606 | 606 | return array(); |
| 607 | 607 | } |
| 608 | 608 | return $jquery_validation_js; |
@@ -614,9 +614,9 @@ discard block |
||
| 614 | 614 | * @param mixed $value |
| 615 | 615 | * @return void |
| 616 | 616 | */ |
| 617 | - function set_default($value){ |
|
| 617 | + function set_default($value) { |
|
| 618 | 618 | $this->_normalized_value = $value; |
| 619 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
| 619 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | /** |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | * @param string $label |
| 625 | 625 | * @return void |
| 626 | 626 | */ |
| 627 | - function set_html_label_text($label){ |
|
| 627 | + function set_html_label_text($label) { |
|
| 628 | 628 | $this->_html_label_text = $label; |
| 629 | 629 | } |
| 630 | 630 | |
@@ -636,12 +636,12 @@ discard block |
||
| 636 | 636 | * @param boolean $required |
| 637 | 637 | * @param null $required_text |
| 638 | 638 | */ |
| 639 | - function set_required($required = true, $required_text = NULL ){ |
|
| 640 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
| 641 | - if ( $required ) { |
|
| 642 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
| 639 | + function set_required($required = true, $required_text = NULL) { |
|
| 640 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
| 641 | + if ($required) { |
|
| 642 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
| 643 | 643 | } else { |
| 644 | - unset( $this->_validation_strategies[ get_class( new EE_Required_Validation_Strategy() ) ] ); |
|
| 644 | + unset($this->_validation_strategies[get_class(new EE_Required_Validation_Strategy())]); |
|
| 645 | 645 | } |
| 646 | 646 | $this->_required = $required; |
| 647 | 647 | } |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | * Returns whether or not this field is required |
| 650 | 650 | * @return boolean |
| 651 | 651 | */ |
| 652 | - public function required(){ |
|
| 652 | + public function required() { |
|
| 653 | 653 | return $this->_required; |
| 654 | 654 | } |
| 655 | 655 | |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | /** |
| 659 | 659 | * @param string $required_css_class |
| 660 | 660 | */ |
| 661 | - public function set_required_css_class( $required_css_class ) { |
|
| 661 | + public function set_required_css_class($required_css_class) { |
|
| 662 | 662 | $this->_required_css_class = $required_css_class; |
| 663 | 663 | } |
| 664 | 664 | |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * Sets the help text, in case |
| 678 | 678 | * @param string $text |
| 679 | 679 | */ |
| 680 | - public function set_html_help_text($text){ |
|
| 680 | + public function set_html_help_text($text) { |
|
| 681 | 681 | $this->_html_help_text = $text; |
| 682 | 682 | } |
| 683 | 683 | /** |
@@ -689,8 +689,8 @@ discard block |
||
| 689 | 689 | public function clean_sensitive_data() { |
| 690 | 690 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
| 691 | 691 | //if we need more logic than this we'll make a strategy for it |
| 692 | - if( $this->_sensitive_data_removal_strategy && |
|
| 693 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
| 692 | + if ($this->_sensitive_data_removal_strategy && |
|
| 693 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
| 694 | 694 | $this->_raw_value = NULL; |
| 695 | 695 | } |
| 696 | 696 | //and clean the normalized value according to the appropriate strategy |
@@ -704,10 +704,10 @@ discard block |
||
| 704 | 704 | * @param string $button_size |
| 705 | 705 | * @param string $other_attributes |
| 706 | 706 | */ |
| 707 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
| 707 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
| 708 | 708 | $button_css_attributes = 'button'; |
| 709 | 709 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
| 710 | - switch ( $button_size ) { |
|
| 710 | + switch ($button_size) { |
|
| 711 | 711 | case 'xs' : |
| 712 | 712 | case 'extra-small' : |
| 713 | 713 | $button_css_attributes .= ' button-xs'; |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | default : |
| 729 | 729 | $button_css_attributes .= ''; |
| 730 | 730 | } |
| 731 | - $this->_button_css_attributes .= ! empty( $other_attributes ) ? $button_css_attributes . ' ' . $other_attributes : $button_css_attributes; |
|
| 731 | + $this->_button_css_attributes .= ! empty($other_attributes) ? $button_css_attributes.' '.$other_attributes : $button_css_attributes; |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | * @return string |
| 738 | 738 | */ |
| 739 | 739 | public function button_css_attributes() { |
| 740 | - if ( empty( $this->_button_css_attributes )) { |
|
| 740 | + if (empty($this->_button_css_attributes)) { |
|
| 741 | 741 | $this->set_button_css_attributes(); |
| 742 | 742 | } |
| 743 | 743 | return $this->_button_css_attributes; |
@@ -757,27 +757,27 @@ discard block |
||
| 757 | 757 | * @param array $req_data |
| 758 | 758 | * @return mixed whatever the raw value of this form section is in the request data |
| 759 | 759 | */ |
| 760 | - public function find_form_data_for_this_section( $req_data ){ |
|
| 760 | + public function find_form_data_for_this_section($req_data) { |
|
| 761 | 761 | // break up the html name by "[]" |
| 762 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
| 763 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
| 762 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
| 763 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
| 764 | 764 | } else { |
| 765 | 765 | $before_any_brackets = $this->html_name(); |
| 766 | 766 | } |
| 767 | 767 | // grab all of the segments |
| 768 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
| 769 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
| 770 | - $name_parts = $matches[ 1 ]; |
|
| 768 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
| 769 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
| 770 | + $name_parts = $matches[1]; |
|
| 771 | 771 | array_unshift($name_parts, $before_any_brackets); |
| 772 | - }else{ |
|
| 773 | - $name_parts = array( $before_any_brackets ); |
|
| 772 | + } else { |
|
| 773 | + $name_parts = array($before_any_brackets); |
|
| 774 | 774 | } |
| 775 | 775 | // now get the value for the input |
| 776 | 776 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
| 777 | - if( $value === NULL ){ |
|
| 777 | + if ($value === NULL) { |
|
| 778 | 778 | //check if this thing's name is at the TOP level of the request data |
| 779 | - if( isset( $req_data[ $this->name() ] ) ){ |
|
| 780 | - $value = $req_data[ $this->name() ]; |
|
| 779 | + if (isset($req_data[$this->name()])) { |
|
| 780 | + $value = $req_data[$this->name()]; |
|
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | 783 | return $value; |
@@ -791,15 +791,15 @@ discard block |
||
| 791 | 791 | * @param array $req_data |
| 792 | 792 | * @return array | NULL |
| 793 | 793 | */ |
| 794 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
| 795 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
| 796 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
| 797 | - if( empty($html_name_parts ) ){ |
|
| 798 | - return $req_data[ $first_part_to_consider ]; |
|
| 799 | - }else{ |
|
| 800 | - return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
|
| 794 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
| 795 | + $first_part_to_consider = array_shift($html_name_parts); |
|
| 796 | + if (isset($req_data[$first_part_to_consider])) { |
|
| 797 | + if (empty($html_name_parts)) { |
|
| 798 | + return $req_data[$first_part_to_consider]; |
|
| 799 | + } else { |
|
| 800 | + return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[$first_part_to_consider]); |
|
| 801 | 801 | } |
| 802 | - }else{ |
|
| 802 | + } else { |
|
| 803 | 803 | return NULL; |
| 804 | 804 | } |
| 805 | 805 | } |
@@ -811,14 +811,14 @@ discard block |
||
| 811 | 811 | * @param array $req_data like $_POST |
| 812 | 812 | * @return boolean |
| 813 | 813 | */ |
| 814 | - public function form_data_present_in($req_data = NULL){ |
|
| 815 | - if( $req_data === NULL ){ |
|
| 814 | + public function form_data_present_in($req_data = NULL) { |
|
| 815 | + if ($req_data === NULL) { |
|
| 816 | 816 | $req_data = $_POST; |
| 817 | 817 | } |
| 818 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
| 819 | - if( $checked_value !== null ){ |
|
| 818 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
| 819 | + if ($checked_value !== null) { |
|
| 820 | 820 | return TRUE; |
| 821 | - }else{ |
|
| 821 | + } else { |
|
| 822 | 822 | return FALSE; |
| 823 | 823 | } |
| 824 | 824 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | if( ! $this->_html_name){ |
| 201 | 201 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
| 202 | 202 | $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
| 203 | - }else{ |
|
| 203 | + } else{ |
|
| 204 | 204 | $this->_html_name = $this->name(); |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | protected function _get_display_strategy(){ |
| 231 | 231 | if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
| 232 | 232 | throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
| 233 | - }else{ |
|
| 233 | + } else{ |
|
| 234 | 234 | return $this->_display_strategy; |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | public function get_validation_strategies(){ |
| 307 | 307 | if(is_array($this->_validation_strategies)){ |
| 308 | 308 | return $this->_validation_strategies; |
| 309 | - }else{ |
|
| 309 | + } else{ |
|
| 310 | 310 | return array(); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
| 414 | 414 | try{ |
| 415 | 415 | $validation_strategy->validate($this->normalized_value()); |
| 416 | - }catch(EE_Validation_Error $e){ |
|
| 416 | + } catch(EE_Validation_Error $e){ |
|
| 417 | 417 | $this->add_validation_error($e); |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | if( $this->get_validation_errors()){ |
| 423 | 423 | return false; |
| 424 | - }else{ |
|
| 424 | + } else{ |
|
| 425 | 425 | return true; |
| 426 | 426 | } |
| 427 | 427 | } |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | if(! empty($jquery_validation_rules)){ |
| 604 | 604 | $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
| 605 | - }else{ |
|
| 605 | + } else{ |
|
| 606 | 606 | return array(); |
| 607 | 607 | } |
| 608 | 608 | return $jquery_validation_js; |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
| 770 | 770 | $name_parts = $matches[ 1 ]; |
| 771 | 771 | array_unshift($name_parts, $before_any_brackets); |
| 772 | - }else{ |
|
| 772 | + } else{ |
|
| 773 | 773 | $name_parts = array( $before_any_brackets ); |
| 774 | 774 | } |
| 775 | 775 | // now get the value for the input |
@@ -796,10 +796,10 @@ discard block |
||
| 796 | 796 | if( isset( $req_data[ $first_part_to_consider ] ) ){ |
| 797 | 797 | if( empty($html_name_parts ) ){ |
| 798 | 798 | return $req_data[ $first_part_to_consider ]; |
| 799 | - }else{ |
|
| 799 | + } else{ |
|
| 800 | 800 | return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
| 801 | 801 | } |
| 802 | - }else{ |
|
| 802 | + } else{ |
|
| 803 | 803 | return NULL; |
| 804 | 804 | } |
| 805 | 805 | } |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | $checked_value = $this->find_form_data_for_this_section( $req_data ); |
| 819 | 819 | if( $checked_value !== null ){ |
| 820 | 820 | return TRUE; |
| 821 | - }else{ |
|
| 821 | + } else{ |
|
| 822 | 822 | return FALSE; |
| 823 | 823 | } |
| 824 | 824 | } |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | - * @param $payment_method_type |
|
| 104 | + * @param EE_PMT_Base $payment_method_type |
|
| 105 | 105 | * @throws EE_Error |
| 106 | 106 | */ |
| 107 | 107 | public function set_payment_method_type( $payment_method_type ){ |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * Specialized form for payment methods, allowing for easy setting and retrieving of meta fields. |
| 5 | 5 | * Uses EEM_Payment_Method as the model |
| 6 | 6 | */ |
| 7 | -class EE_Payment_Method_Form extends EE_Model_Form_Section{ |
|
| 7 | +class EE_Payment_Method_Form extends EE_Model_Form_Section { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * All the subsection inputs that correspond ot extra meta rows |
@@ -39,31 +39,31 @@ discard block |
||
| 39 | 39 | * @see EE_Model_Form_Section::__construct() for more |
| 40 | 40 | * } |
| 41 | 41 | */ |
| 42 | - public function __construct($options_array = array()){ |
|
| 42 | + public function __construct($options_array = array()) { |
|
| 43 | 43 | $this->_model = EEM_Payment_Method::instance(); |
| 44 | 44 | $this->_options_array = $options_array; |
| 45 | - if(isset($options_array['payment_method_type'])){ |
|
| 45 | + if (isset($options_array['payment_method_type'])) { |
|
| 46 | 46 | $this->_payment_method_type = $options_array['payment_method_type']; |
| 47 | 47 | } |
| 48 | 48 | $options_array = $this->_options_array; |
| 49 | - if(isset($options_array['extra_meta_inputs'])){ |
|
| 50 | - $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs,$options_array['extra_meta_inputs']); |
|
| 49 | + if (isset($options_array['extra_meta_inputs'])) { |
|
| 50 | + $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']); |
|
| 51 | 51 | } |
| 52 | - if($this->_extra_meta_inputs){ |
|
| 53 | - $this->_subsections = array_merge($this->_subsections,$this->_extra_meta_inputs); |
|
| 52 | + if ($this->_extra_meta_inputs) { |
|
| 53 | + $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs); |
|
| 54 | 54 | } |
| 55 | 55 | $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input( |
| 56 | - array( 'html_label_text'=> __( 'Button URL', 'event_espresso' )) |
|
| 56 | + array('html_label_text'=> __('Button URL', 'event_espresso')) |
|
| 57 | 57 | ); |
| 58 | 58 | $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input( |
| 59 | 59 | EEM_Payment_Method::instance()->scopes(), |
| 60 | - array( 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() . EEH_Template::get_help_tab_link( 'payment_methods_overview' )) |
|
| 60 | + array('html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename().EEH_Template::get_help_tab_link('payment_methods_overview')) |
|
| 61 | 61 | ); |
| 62 | 62 | //setup the currency options |
| 63 | 63 | $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input( |
| 64 | - EEM_Currency::instance()->get_all_currencies_usable_by( $this->_payment_method_type ), |
|
| 64 | + EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type), |
|
| 65 | 65 | array( |
| 66 | - 'html_label_text'=> __( 'Currencies Supported', 'event_espresso' ), |
|
| 66 | + 'html_label_text'=> __('Currencies Supported', 'event_espresso'), |
|
| 67 | 67 | 'required'=>TRUE |
| 68 | 68 | ) |
| 69 | 69 | ); |
@@ -79,15 +79,15 @@ discard block |
||
| 79 | 79 | * @param string $name |
| 80 | 80 | * @throws EE_Error |
| 81 | 81 | */ |
| 82 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
| 83 | - if( ! $this->_payment_method_type instanceof EE_PMT_Base ){ |
|
| 84 | - throw new EE_Error( sprintf( __( 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso' ))); |
|
| 82 | + public function _construct_finalize($parent_form_section, $name) { |
|
| 83 | + if ( ! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
| 84 | + throw new EE_Error(sprintf(__('Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso'))); |
|
| 85 | 85 | } |
| 86 | 86 | //set the name of this form based on the payment method type |
| 87 | - if( ! $this->_name && ! $name ){ |
|
| 88 | - $name = str_replace(" ","_",ucwords(str_replace("_"," ",($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
| 87 | + if ( ! $this->_name && ! $name) { |
|
| 88 | + $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
| 89 | 89 | } |
| 90 | - parent::_construct_finalize( $parent_form_section, $name ); |
|
| 90 | + parent::_construct_finalize($parent_form_section, $name); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | * @param $payment_method_type |
| 97 | 97 | * @throws EE_Error |
| 98 | 98 | */ |
| 99 | - public function set_payment_method_type( $payment_method_type ){ |
|
| 100 | - if( ! $payment_method_type instanceof EE_PMT_Base){ |
|
| 99 | + public function set_payment_method_type($payment_method_type) { |
|
| 100 | + if ( ! $payment_method_type instanceof EE_PMT_Base) { |
|
| 101 | 101 | throw new EE_Error(sprintf(__("Payment Method forms MUST set a payment method type by using _set_payment_method_type", "event_espresso"))); |
| 102 | 102 | } |
| 103 | 103 | $this->_payment_method_type = $payment_method_type; |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | * extends the model form section's save method to also save the extra meta field values |
| 110 | 110 | * @return int ID of the payment method inserted, or true on update |
| 111 | 111 | */ |
| 112 | - public function save(){ |
|
| 112 | + public function save() { |
|
| 113 | 113 | $parent_save_val = parent::save(); |
| 114 | - if( $this->_model_object && $this->_model_object->ID()){ |
|
| 115 | - foreach($this->_extra_meta_inputs as $input_name => $input){ |
|
| 114 | + if ($this->_model_object && $this->_model_object->ID()) { |
|
| 115 | + foreach ($this->_extra_meta_inputs as $input_name => $input) { |
|
| 116 | 116 | $this->_model_object->update_extra_meta($input_name, $input->normalized_value()); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
| 130 | 130 | parent::populate_model_obj($model_obj); |
| 131 | 131 | $extra_meta = $model_obj->all_extra_meta_array(); |
| 132 | - foreach($this->_extra_meta_inputs as $input_name => $extra_meta_input){ |
|
| 133 | - if(isset($extra_meta[$input_name])){ |
|
| 132 | + foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) { |
|
| 133 | + if (isset($extra_meta[$input_name])) { |
|
| 134 | 134 | $extra_meta_input->set_default($extra_meta[$input_name]); |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | * gets the default name of this form section if none is specified |
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | - protected function _set_default_name_if_empty(){ |
|
| 146 | - if( ! $this->_name ){ |
|
| 147 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
| 148 | - $this->_name = $default_name; |
|
| 145 | + protected function _set_default_name_if_empty() { |
|
| 146 | + if ( ! $this->_name) { |
|
| 147 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
| 148 | + $this->_name = $default_name; |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * Gets all the extra meta inputs in this form |
| 156 | 156 | * @return EE_Form_Input_Base[] |
| 157 | 157 | */ |
| 158 | - public function extra_meta_inputs(){ |
|
| 158 | + public function extra_meta_inputs() { |
|
| 159 | 159 | return $this->_extra_meta_inputs; |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | /** |
| 81 | 81 | * Checks if that value is the one selected |
| 82 | 82 | * @param string|int $value unnormalized value option (string) |
| 83 | - * @return string |
|
| 83 | + * @return boolean |
|
| 84 | 84 | */ |
| 85 | 85 | protected function _check_if_option_selected( $value ){ |
| 86 | 86 | return $this->_input->raw_value() == $value ? TRUE : FALSE; |
@@ -11,47 +11,47 @@ discard block |
||
| 11 | 11 | * @since $VID:$ |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Select_Display_Strategy extends EE_Display_Strategy_Base{ |
|
| 14 | +class EE_Select_Display_Strategy extends EE_Display_Strategy_Base { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * |
| 18 | 18 | * @throws EE_Error |
| 19 | 19 | * @return string of html to display the field |
| 20 | 20 | */ |
| 21 | - function display(){ |
|
| 22 | - if( ! $this->_input instanceof EE_Form_Input_With_Options_Base){ |
|
| 23 | - throw new EE_Error( sprintf( __( 'Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso' ))); |
|
| 21 | + function display() { |
|
| 22 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
| 23 | + throw new EE_Error(sprintf(__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso'))); |
|
| 24 | 24 | } |
| 25 | 25 | EE_Registry::instance()->load_helper('Array'); |
| 26 | 26 | |
| 27 | - $html = EEH_HTML::nl( 0, 'select' ); |
|
| 27 | + $html = EEH_HTML::nl(0, 'select'); |
|
| 28 | 28 | $html .= '<select'; |
| 29 | - $html .= ' id="' . $this->_input->html_id() . '"'; |
|
| 30 | - $html .= ' name="' . $this->_input->html_name() . '"'; |
|
| 31 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
| 32 | - $html .= ' class="' . $class . '"'; |
|
| 29 | + $html .= ' id="'.$this->_input->html_id().'"'; |
|
| 30 | + $html .= ' name="'.$this->_input->html_name().'"'; |
|
| 31 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
| 32 | + $html .= ' class="'.$class.'"'; |
|
| 33 | 33 | // add html5 required |
| 34 | 34 | |
| 35 | 35 | $html .= $this->_input->required() ? ' required' : ''; |
| 36 | - $html .= ' style="' . $this->_input->html_style() . '"'; |
|
| 36 | + $html .= ' style="'.$this->_input->html_style().'"'; |
|
| 37 | 37 | $html .= '>'; |
| 38 | 38 | |
| 39 | 39 | // EEH_HTML::indent( 1, 'select' ); |
| 40 | - if ( EEH_Array::is_multi_dimensional_array( $this->_input->options() )) { |
|
| 41 | - EEH_HTML::indent( 1, 'optgroup' ); |
|
| 42 | - foreach( $this->_input->options() as $opt_group_label => $opt_group ){ |
|
| 43 | - $html .= EEH_HTML::nl( 0, 'optgroup' ) . '<optgroup label="' . esc_attr( $opt_group_label ) . '">'; |
|
| 44 | - EEH_HTML::indent( 1, 'option' ); |
|
| 45 | - $html .= $this->_display_options( $opt_group ); |
|
| 40 | + if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
| 41 | + EEH_HTML::indent(1, 'optgroup'); |
|
| 42 | + foreach ($this->_input->options() as $opt_group_label => $opt_group) { |
|
| 43 | + $html .= EEH_HTML::nl(0, 'optgroup').'<optgroup label="'.esc_attr($opt_group_label).'">'; |
|
| 44 | + EEH_HTML::indent(1, 'option'); |
|
| 45 | + $html .= $this->_display_options($opt_group); |
|
| 46 | 46 | $html .= EEH_HTML::indent( -1, 'option' ); |
| 47 | - $html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>'; |
|
| 47 | + $html .= EEH_HTML::nl(0, 'optgroup').'</optgroup>'; |
|
| 48 | 48 | } |
| 49 | 49 | EEH_HTML::indent( -1, 'optgroup' ); |
| 50 | 50 | } else { |
| 51 | - $html.=$this->_display_options( $this->_input->options() ); |
|
| 51 | + $html .= $this->_display_options($this->_input->options()); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $html.= EEH_HTML::nl( 0, 'select' ) . '</select>'; |
|
| 54 | + $html .= EEH_HTML::nl(0, 'select').'</select>'; |
|
| 55 | 55 | // $html.= EEH_HTML::nl( -1, 'select' ) . '</select>'; |
| 56 | 56 | return $html; |
| 57 | 57 | } |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | * @param array $options |
| 64 | 64 | * @return string |
| 65 | 65 | */ |
| 66 | - protected function _display_options($options){ |
|
| 66 | + protected function _display_options($options) { |
|
| 67 | 67 | $html = ''; |
| 68 | - EEH_HTML::indent( 1, 'option' ); |
|
| 69 | - foreach( $options as $value => $display_text ){ |
|
| 70 | - $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value ); |
|
| 71 | - $selected = $this->_check_if_option_selected( $unnormalized_value ) ? ' selected="selected"' : ''; |
|
| 72 | - $html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr( $unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>'; |
|
| 68 | + EEH_HTML::indent(1, 'option'); |
|
| 69 | + foreach ($options as $value => $display_text) { |
|
| 70 | + $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value); |
|
| 71 | + $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : ''; |
|
| 72 | + $html .= EEH_HTML::nl(0, 'option').'<option value="'.esc_attr($unnormalized_value).'"'.$selected.'>'.$display_text.'</option>'; |
|
| 73 | 73 | } |
| 74 | 74 | EEH_HTML::indent( -1, 'option' ); |
| 75 | 75 | return $html; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param string|int $value unnormalized value option (string) |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | - protected function _check_if_option_selected( $value ){ |
|
| 85 | + protected function _check_if_option_selected($value) { |
|
| 86 | 86 | return $this->_input->raw_value() == $value ? TRUE : FALSE; |
| 87 | 87 | } |
| 88 | 88 | |