PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.4
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
← All changes | classes/Visualizer/Source/Csv.php +17 -30 3.0.51.4 View file →
@@ -18,8 +18,9 @@
18 18 // | MA 02110-1301 USA |
19 19 // +----------------------------------------------------------------------+
20 20 // | Author: Eugene Manuilov <eugene@manuilov.org> |
21 21 // +----------------------------------------------------------------------+
22 +
22 23 /**
23 24 * Source manager for local CSV files.
24 25 *
25 26 * @category Visualizer
@@ -60,25 +61,25 @@
60 61 * @param resource $handle The file handle resource.
61 62 */
62 63 private function _fetchSeries( &$handle ) {
63 64 // read column titles
64 - $labels = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE );
65 + $labels = fgetcsv( $handle );
66 +
65 67 // read series types
66 - $types = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE );
68 + $types = fgetcsv( $handle );
67 69
68 - if ( ! $labels || ! $types ) {
70 + if ( !$labels || !$types ) {
69 71 return false;
70 72 }
71 73
72 74 // if no types were setup, re read labels and empty types array
73 - $types = array_map( 'trim', $types );
74 - if ( ! self::_validateTypes( $types ) ) {
75 + if ( !self::_validateTypes( $types ) ) {
75 76 // re open the file
76 77 fclose( $handle );
77 - $handle = $this->_get_file_handle();
78 + $handle = fopen( $this->_filename, 'rb' );
78 79
79 80 // re read the labels and empty types array
80 - $labels = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE );
81 + $labels = fgetcsv( $handle );
81 82 $types = array();
82 83 }
83 84
84 85 for ( $i = 0, $len = count( $labels ); $i < $len; $i++ ) {
@@ -83,10 +84,10 @@
83 84
84 85 for ( $i = 0, $len = count( $labels ); $i < $len; $i++ ) {
85 86 $default_type = $i == 0 ? 'string' : 'number';
86 87 $this->_series[] = array(
87 - 'label' => $labels[ $i ],
88 - 'type' => isset( $types[ $i ] ) ? $types[ $i ] : $default_type,
88 + 'label' => $labels[$i],
89 + 'type' => isset( $types[$i] ) ? $types[$i] : $default_type,
89 90 );
90 91 }
91 92
92 93 return true;
@@ -92,24 +93,8 @@
92 93 return true;
93 94 }
94 95
95 96 /**
96 - * Returns file handle to fetch data from.
97 - *
98 - * @since 1.4.2
99 - *
100 - * @access protected
101 - * @param string $filename Optional file name to get handle. If omitted, $_filename is used.
102 - * @return resource File handle resource on success, otherwise FALSE.
103 - */
104 - protected function _get_file_handle( $filename = false ) {
105 - // set line endings auto detect mode
106 - ini_set( 'auto_detect_line_endings', true );
107 - // open file and return handle
108 - return fopen( $filename ? $filename : $this->_filename, 'rb' );
109 - }
110 -
111 - /**
112 97 * Fetches information from source, parses it and builds series and data arrays.
113 98 *
114 99 * @since 1.0.0
115 100 *
@@ -121,19 +106,21 @@
121 106 if ( empty( $this->_filename ) ) {
122 107 return false;
123 108 }
124 109
110 + // set line endings auto detect mode
111 + @ini_set( 'auto_detect_line_endings', true );
112 +
125 113 // read file and fill arrays
126 - $handle = $this->_get_file_handle();
114 + $handle = fopen( $this->_filename, 'rb' );
127 115 if ( $handle ) {
128 116 // fetch series
129 - if ( ! $this->_fetchSeries( $handle ) ) {
117 + if ( !$this->_fetchSeries( $handle ) ) {
130 118 return false;
131 119 }
132 120
133 121 // fetch data
134 - while ( ( $data = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE ) ) !== false ) {
135 -
122 + while ( ( $data = fgetcsv( $handle ) ) !== false ) {
136 123 $this->_data[] = $this->_normalizeData( $data );
137 124 }
138 125
139 126 // close file handle
@@ -154,5 +141,5 @@
154 141 public function getSourceName() {
155 142 return __CLASS__;
156 143 }
157 144
158 -}
145 +}