Completed
Branch BUG/reg-status-change-recursio... (2db0c9)
by
unknown
20:03 queued 10:32
created
entities/route_match/specifications/admin/EspressoVenueEditorEdit.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class EspressoVenueEditorEdit extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since $VID:$
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return $this->request->getRequestParam('page') === 'espresso_venues'
26
-            && $this->request->getRequestParam('action') === 'edit';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since $VID:$
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return $this->request->getRequestParam('page') === 'espresso_venues'
26
+			&& $this->request->getRequestParam('action') === 'edit';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/EspressoEventEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
  */
20 20
 class EspressoEventEditor extends MatchAnyRouteSpecification
21 21
 {
22
-    /**
23
-     * EspressoEventEditor constructor.
24
-     *
25
-     * @param EspressoEventEditorEdit   $edit_event_route_match
26
-     * @param EspressoEventEditorAddNew $create_event_route_match
27
-     * @param RequestInterface          $request
28
-     * @throws InvalidEntityException
29
-     */
30
-    public function __construct(
31
-        EspressoEventEditorEdit $edit_event_route_match,
32
-        EspressoEventEditorAddNew $create_event_route_match,
33
-        RequestInterface $request
34
-    ) {
35
-        parent::__construct(
36
-            array($edit_event_route_match, $create_event_route_match),
37
-            $request
38
-        );
39
-    }
22
+	/**
23
+	 * EspressoEventEditor constructor.
24
+	 *
25
+	 * @param EspressoEventEditorEdit   $edit_event_route_match
26
+	 * @param EspressoEventEditorAddNew $create_event_route_match
27
+	 * @param RequestInterface          $request
28
+	 * @throws InvalidEntityException
29
+	 */
30
+	public function __construct(
31
+		EspressoEventEditorEdit $edit_event_route_match,
32
+		EspressoEventEditorAddNew $create_event_route_match,
33
+		RequestInterface $request
34
+	) {
35
+		parent::__construct(
36
+			array($edit_event_route_match, $create_event_route_match),
37
+			$request
38
+		);
39
+	}
40 40
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/EspressoVenueEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
  */
20 20
 class EspressoVenueEditor extends MatchAnyRouteSpecification
21 21
 {
22
-    /**
23
-     * EspressoVenueEditor constructor.
24
-     *
25
-     * @param EspressoVenueEditorEdit $edit_venue_route_match
26
-     * @param EspressoVenueEditorAddNew $create_venue_route_match
27
-     * @param RequestInterface          $request
28
-     * @throws InvalidEntityException
29
-     */
30
-    public function __construct(
31
-        EspressoVenueEditorEdit $edit_venue_route_match,
32
-        EspressoVenueEditorAddNew $create_venue_route_match,
33
-        RequestInterface $request
34
-    ) {
35
-        parent::__construct(
36
-            array($edit_venue_route_match, $create_venue_route_match),
37
-            $request
38
-        );
39
-    }
22
+	/**
23
+	 * EspressoVenueEditor constructor.
24
+	 *
25
+	 * @param EspressoVenueEditorEdit $edit_venue_route_match
26
+	 * @param EspressoVenueEditorAddNew $create_venue_route_match
27
+	 * @param RequestInterface          $request
28
+	 * @throws InvalidEntityException
29
+	 */
30
+	public function __construct(
31
+		EspressoVenueEditorEdit $edit_venue_route_match,
32
+		EspressoVenueEditorAddNew $create_venue_route_match,
33
+		RequestInterface $request
34
+	) {
35
+		parent::__construct(
36
+			array($edit_venue_route_match, $create_venue_route_match),
37
+			$request
38
+		);
39
+	}
40 40
 }
Please login to merge, or discard this patch.
route_match/specifications/admin/EspressoStandardPostTypeEditor.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@
 block discarded – undo
15 15
 class EspressoStandardPostTypeEditor extends RouteMatchSpecification
16 16
 {
17 17
 
18
-    /**
19
-     * returns true if current request matches specification
20
-     *
21
-     * @since $VID:$
22
-     * @return boolean
23
-     */
24
-    public function isMatchingRoute()
25
-    {
26
-        return $this->request->getMatch('espresso_*') !== false
27
-               && (
28
-                   $this->request->getRequestParam('action') === 'edit'
29
-                   || $this->request->getRequestParam('action') === 'create_new'
30
-               );
31
-    }
18
+	/**
19
+	 * returns true if current request matches specification
20
+	 *
21
+	 * @since $VID:$
22
+	 * @return boolean
23
+	 */
24
+	public function isMatchingRoute()
25
+	{
26
+		return $this->request->getMatch('espresso_*') !== false
27
+			   && (
28
+				   $this->request->getRequestParam('action') === 'edit'
29
+				   || $this->request->getRequestParam('action') === 'create_new'
30
+			   );
31
+	}
32 32
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/EspressoPostTypeEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class EspressoPostTypeEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * EspressoEventEditor constructor.
23
-     *
24
-     * @param EspressoStandardPostTypeEditor $standard_route_match
25
-     * @param EspressoAttendeePostTypeEditor $attendee_route_match
26
-     * @param RequestInterface          $request
27
-     * @throws InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        EspressoStandardPostTypeEditor $standard_route_match,
31
-        EspressoAttendeePostTypeEditor $attendee_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($standard_route_match, $attendee_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * EspressoEventEditor constructor.
23
+	 *
24
+	 * @param EspressoStandardPostTypeEditor $standard_route_match
25
+	 * @param EspressoAttendeePostTypeEditor $attendee_route_match
26
+	 * @param RequestInterface          $request
27
+	 * @throws InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		EspressoStandardPostTypeEditor $standard_route_match,
31
+		EspressoAttendeePostTypeEditor $attendee_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($standard_route_match, $attendee_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPageEditorAddNew.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class WordPressPageEditorAddNew extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since $VID:$
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
-            && $this->request->getRequestParam('post_type', 'post') === 'page';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since $VID:$
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
+			&& $this->request->getRequestParam('post_type', 'post') === 'page';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/WordPressPageEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class WordPressPageEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * WordPressPostsEditor constructor.
23
-     *
24
-     * @param WordPressPostsEditorEdit $edit_page_route_match
25
-     * @param WordPressPostsEditorAddNew $create_page_route_match
26
-     * @param RequestInterface           $request
27
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        WordPressPageEditorEdit $edit_page_route_match,
31
-        WordPressPageEditorAddNew $create_page_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($edit_page_route_match, $create_page_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * WordPressPostsEditor constructor.
23
+	 *
24
+	 * @param WordPressPostsEditorEdit $edit_page_route_match
25
+	 * @param WordPressPostsEditorAddNew $create_page_route_match
26
+	 * @param RequestInterface           $request
27
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		WordPressPageEditorEdit $edit_page_route_match,
31
+		WordPressPageEditorAddNew $create_page_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($edit_page_route_match, $create_page_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
route_match/specifications/admin/EspressoAttendeePostTypeEditor.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class EspressoAttendeePostTypeEditor extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since $VID:$
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return $this->request->getRequestParam('page') === 'espresso_registrations'
26
-               && $this->request->getRequestParam('action') === 'edit_attendee';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since $VID:$
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return $this->request->getRequestParam('page') === 'espresso_registrations'
26
+			   && $this->request->getRequestParam('action') === 'edit_attendee';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Export.helper.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
                     EEH_Array::is_associative_array($item_in_top_level_array)) {
59 59
                 // its associative, so we want to output its keys as column headers
60 60
                 $keys = array_keys($item_in_top_level_array);
61
-                $new_file_contents .=  EEH_Export::get_csv_row($keys);
61
+                $new_file_contents .= EEH_Export::get_csv_row($keys);
62 62
             }
63 63
             // start writing data
64 64
             foreach ($data as $data_row) {
65 65
                 $new_file_contents .= EEH_Export::get_csv_row($data_row);
66 66
             }
67
-            return EEH_File::write_to_file($filepath, EEH_File::get_file_contents($filepath) . $new_file_contents);
67
+            return EEH_File::write_to_file($filepath, EEH_File::get_file_contents($filepath).$new_file_contents);
68 68
         } else {
69 69
             // no data TO write... so we can assume that's a success
70 70
             return true;
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
             }
103 103
 
104 104
             $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ?
105
-                ( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value;
105
+                ($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value;
106 106
         }
107 107
 
108
-        return  implode($delimiter, $output) . PHP_EOL;
108
+        return  implode($delimiter, $output).PHP_EOL;
109 109
     }
110 110
 
111 111
 
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -12,161 +12,161 @@
 block discarded – undo
12 12
  */
13 13
 class EEH_Export
14 14
 {
15
-    /**
16
-     * Gets the 'normal' column named for fields
17
-     * @param EE_Model_Field_Base $field
18
-     * @return string
19
-     * @throws EE_Error
20
-     */
21
-    public static function get_column_name_for_field(EE_Model_Field_Base $field)
22
-    {
23
-        $column_name = wp_specialchars_decode($field->get_nicename(), ENT_QUOTES);
24
-        if (apply_filters(
25
-            'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
26
-            false,
27
-            $column_name,
28
-            $field
29
-        )) {
30
-            $column_name .= "["
31
-                . wp_specialchars_decode($field->get_name(), ENT_QUOTES)
32
-                . "]";
33
-        }
34
-        return $column_name;
35
-    }
36
-
37
-    /**
38
-     * Writes $data to the csv file open in $filehandle. uses the array indices of $data for column headers
39
-     *
40
-     * @param string    $filepath
41
-     * @param array     $data 2D array,         first numerically-indexed,
42
-     *                                          and next-level-down preferably indexed by string
43
-     * @param boolean   $write_column_headers   whether or not we should add the keys in the bottom-most array
44
-     *                                          as a row for headers in the CSV.
45
-     *                                            Eg, if $data looked like:
46
-     *                                            array(
47
-     *                                                  0=>array('EVT_ID'=>1,'EVT_name'=>'monkey'...),
48
-     *                                                  1=>array(...,...)
49
-     *                                            )
50
-     *
51
-     * @return boolean      if we successfully wrote to the CSV or not. If there's no $data,
52
-     *                      we consider that a success (because we wrote everything there was...nothing)
53
-     * @throws EE_Error
54
-     */
55
-    public static function write_data_array_to_csv($filepath, $data, $write_column_headers = true)
56
-    {
57
-
58
-        $new_file_contents = '';
59
-        // determine if $data is actually a 2d array
60
-        if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) {
61
-            // make sure top level is numerically indexed,
62
-
63
-            if (EEH_Array::is_associative_array($data)) {
64
-                throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data))));
65
-            }
66
-            $item_in_top_level_array = EEH_Array::get_one_item_from_array($data);
67
-            // now, is the last item in the top-level array of $data an associative or numeric array?
68
-            if ($write_column_headers &&
69
-                    EEH_Array::is_associative_array($item_in_top_level_array)) {
70
-                // its associative, so we want to output its keys as column headers
71
-                $keys = array_keys($item_in_top_level_array);
72
-                $new_file_contents .=  EEH_Export::get_csv_row($keys);
73
-            }
74
-            // start writing data
75
-            foreach ($data as $data_row) {
76
-                $new_file_contents .= EEH_Export::get_csv_row($data_row);
77
-            }
78
-            return EEH_File::write_to_file($filepath, EEH_File::get_file_contents($filepath) . $new_file_contents);
79
-        } else {
80
-            // no data TO write... so we can assume that's a success
81
-            return true;
82
-        }
83
-    }
84
-
85
-
86
-
87
-     /**
88
-      *
89
-     *  Writes a row to the csv file
90
-     *  @param array $row - individual row of csv data
91
-     *  @param string $delimiter - csv delimiter
92
-     *  @param string $enclosure - csv enclosure
93
-     *  @param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
94
-     *  @return string of text for teh csv file
95
-     */
96
-    public static function get_csv_row(array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false)
97
-    {
98
-        // Allow user to filter the csv delimiter and enclosure for other countries csv standards
99
-        $delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter);
100
-        $enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure);
101
-
102
-        $delimiter_esc = preg_quote($delimiter, '/');
103
-        $enclosure_esc = preg_quote($enclosure, '/');
104
-
105
-        $output = array();
106
-        foreach ($row as $field_value) {
107
-            if (is_object($field_value) || is_array($field_value)) {
108
-                $field_value = serialize($field_value);
109
-            }
110
-            if ($field_value === null && $mysql_null) {
111
-                $output[] = 'NULL';
112
-                continue;
113
-            }
114
-
115
-            $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ?
116
-                ( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value;
117
-        }
118
-
119
-        return  implode($delimiter, $output) . PHP_EOL;
120
-    }
121
-
122
-
123
-
124
-    /**
125
-     * Shortcut for preparing a database result for display
126
-     * @param EEM_Base $model
127
-     * @param string $field_name
128
-     * @param string $raw_db_value
129
-     * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty
130
-     * @return string
131
-     */
132
-    public static function prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true)
133
-    {
134
-        $field_obj = $model->field_settings_for($field_name);
135
-        $value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value);
136
-        if ($field_obj instanceof EE_Datetime_Field) {
137
-            $field_obj->set_date_format(EEH_Export::get_date_format_for_export($field_obj->get_date_format($pretty_schema)), $pretty_schema);
138
-            $field_obj->set_time_format(EEH_Export::get_time_format_for_export($field_obj->get_time_format($pretty_schema)), $pretty_schema);
139
-        }
140
-        if ($pretty_schema === true) {
141
-            return $field_obj->prepare_for_pretty_echoing($value_on_model_obj);
142
-        } elseif (is_string($pretty_schema)) {
143
-            return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema);
144
-        } else {
145
-            return $field_obj->prepare_for_get($value_on_model_obj);
146
-        }
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * Gets the date format to use in exports. filterable
153
-     * @param string $current_format
154
-     * @return string
155
-     */
156
-    public static function get_date_format_for_export($current_format = null)
157
-    {
158
-        return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format);
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * Gets the time format we want to use in exports. Filterable
165
-     * @param string $current_format
166
-     * @return string
167
-     */
168
-    public static function get_time_format_for_export($current_format = null)
169
-    {
170
-        return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format);
171
-    }
15
+	/**
16
+	 * Gets the 'normal' column named for fields
17
+	 * @param EE_Model_Field_Base $field
18
+	 * @return string
19
+	 * @throws EE_Error
20
+	 */
21
+	public static function get_column_name_for_field(EE_Model_Field_Base $field)
22
+	{
23
+		$column_name = wp_specialchars_decode($field->get_nicename(), ENT_QUOTES);
24
+		if (apply_filters(
25
+			'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
26
+			false,
27
+			$column_name,
28
+			$field
29
+		)) {
30
+			$column_name .= "["
31
+				. wp_specialchars_decode($field->get_name(), ENT_QUOTES)
32
+				. "]";
33
+		}
34
+		return $column_name;
35
+	}
36
+
37
+	/**
38
+	 * Writes $data to the csv file open in $filehandle. uses the array indices of $data for column headers
39
+	 *
40
+	 * @param string    $filepath
41
+	 * @param array     $data 2D array,         first numerically-indexed,
42
+	 *                                          and next-level-down preferably indexed by string
43
+	 * @param boolean   $write_column_headers   whether or not we should add the keys in the bottom-most array
44
+	 *                                          as a row for headers in the CSV.
45
+	 *                                            Eg, if $data looked like:
46
+	 *                                            array(
47
+	 *                                                  0=>array('EVT_ID'=>1,'EVT_name'=>'monkey'...),
48
+	 *                                                  1=>array(...,...)
49
+	 *                                            )
50
+	 *
51
+	 * @return boolean      if we successfully wrote to the CSV or not. If there's no $data,
52
+	 *                      we consider that a success (because we wrote everything there was...nothing)
53
+	 * @throws EE_Error
54
+	 */
55
+	public static function write_data_array_to_csv($filepath, $data, $write_column_headers = true)
56
+	{
57
+
58
+		$new_file_contents = '';
59
+		// determine if $data is actually a 2d array
60
+		if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) {
61
+			// make sure top level is numerically indexed,
62
+
63
+			if (EEH_Array::is_associative_array($data)) {
64
+				throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data))));
65
+			}
66
+			$item_in_top_level_array = EEH_Array::get_one_item_from_array($data);
67
+			// now, is the last item in the top-level array of $data an associative or numeric array?
68
+			if ($write_column_headers &&
69
+					EEH_Array::is_associative_array($item_in_top_level_array)) {
70
+				// its associative, so we want to output its keys as column headers
71
+				$keys = array_keys($item_in_top_level_array);
72
+				$new_file_contents .=  EEH_Export::get_csv_row($keys);
73
+			}
74
+			// start writing data
75
+			foreach ($data as $data_row) {
76
+				$new_file_contents .= EEH_Export::get_csv_row($data_row);
77
+			}
78
+			return EEH_File::write_to_file($filepath, EEH_File::get_file_contents($filepath) . $new_file_contents);
79
+		} else {
80
+			// no data TO write... so we can assume that's a success
81
+			return true;
82
+		}
83
+	}
84
+
85
+
86
+
87
+	 /**
88
+	  *
89
+	  *  Writes a row to the csv file
90
+	  *  @param array $row - individual row of csv data
91
+	  *  @param string $delimiter - csv delimiter
92
+	  *  @param string $enclosure - csv enclosure
93
+	  *  @param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
94
+	  *  @return string of text for teh csv file
95
+	  */
96
+	public static function get_csv_row(array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false)
97
+	{
98
+		// Allow user to filter the csv delimiter and enclosure for other countries csv standards
99
+		$delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter);
100
+		$enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure);
101
+
102
+		$delimiter_esc = preg_quote($delimiter, '/');
103
+		$enclosure_esc = preg_quote($enclosure, '/');
104
+
105
+		$output = array();
106
+		foreach ($row as $field_value) {
107
+			if (is_object($field_value) || is_array($field_value)) {
108
+				$field_value = serialize($field_value);
109
+			}
110
+			if ($field_value === null && $mysql_null) {
111
+				$output[] = 'NULL';
112
+				continue;
113
+			}
114
+
115
+			$output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ?
116
+				( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value;
117
+		}
118
+
119
+		return  implode($delimiter, $output) . PHP_EOL;
120
+	}
121
+
122
+
123
+
124
+	/**
125
+	 * Shortcut for preparing a database result for display
126
+	 * @param EEM_Base $model
127
+	 * @param string $field_name
128
+	 * @param string $raw_db_value
129
+	 * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty
130
+	 * @return string
131
+	 */
132
+	public static function prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true)
133
+	{
134
+		$field_obj = $model->field_settings_for($field_name);
135
+		$value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value);
136
+		if ($field_obj instanceof EE_Datetime_Field) {
137
+			$field_obj->set_date_format(EEH_Export::get_date_format_for_export($field_obj->get_date_format($pretty_schema)), $pretty_schema);
138
+			$field_obj->set_time_format(EEH_Export::get_time_format_for_export($field_obj->get_time_format($pretty_schema)), $pretty_schema);
139
+		}
140
+		if ($pretty_schema === true) {
141
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj);
142
+		} elseif (is_string($pretty_schema)) {
143
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema);
144
+		} else {
145
+			return $field_obj->prepare_for_get($value_on_model_obj);
146
+		}
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * Gets the date format to use in exports. filterable
153
+	 * @param string $current_format
154
+	 * @return string
155
+	 */
156
+	public static function get_date_format_for_export($current_format = null)
157
+	{
158
+		return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format);
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * Gets the time format we want to use in exports. Filterable
165
+	 * @param string $current_format
166
+	 * @return string
167
+	 */
168
+	public static function get_time_format_for_export($current_format = null)
169
+	{
170
+		return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format);
171
+	}
172 172
 }
Please login to merge, or discard this patch.