PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.3.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.3.0
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
visualizer / classes / Visualizer / Source / Csv / Remote.php

Remote.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 1.3.0, at classes/Visualizer/Source/Csv/Remote.php

118 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // +----------------------------------------------------------------------+
4 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
5 // +----------------------------------------------------------------------+
6 // | This program is free software; you can redistribute it and/or modify |
7 // | it under the terms of the GNU General Public License, version 2, as |
8 // | published by the Free Software Foundation. |
9 // | |
10 // | This program is distributed in the hope that it will be useful, |
11 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 // | GNU General Public License for more details. |
14 // | |
15 // | You should have received a copy of the GNU General Public License |
16 // | along with this program; if not, write to the Free Software |
17 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
18 // | MA 02110-1301 USA |
19 // +----------------------------------------------------------------------+
20 // | Author: Eugene Manuilov <eugene@manuilov.org> |
21 // +----------------------------------------------------------------------+
22
23 /**
24 * Source manager for remote CSV files.
25 *
26 * @category Visualizer
27 * @package Source
28 *
29 * @since 1.1.0
30 */
31 class Visualizer_Source_Csv_Remote extends Visualizer_Source_Csv {
32
33 /**
34 * Returns data parsed from source.
35 *
36 * @since 1.1.0
37 *
38 * @access public
39 * @return string The serialized array of data.
40 */
41 public function getData() {
42 return serialize( array(
43 'source' => $this->_filename,
44 'data' => $this->_data,
45 ) );
46 }
47
48 /**
49 * Re populates data and series.
50 *
51 * @since 1.1.0
52 *
53 * @access private
54 * @param int $chart_id The chart id.
55 * @return boolean TRUE on success, otherwise FALSE.
56 */
57 private function _repopulate( $chart_id ) {
58 // if it has been already populated, then just return true
59 if ( !empty( $this->_data ) && !empty( $this->_series ) ) {
60 return true;
61 }
62
63 // if filename is empty, extract it from chart content
64 if ( empty( $this->_filename ) ) {
65 $chart = get_post( $chart_id );
66 $data = unserialize( $chart->post_content );
67 if ( !isset( $data['source'] ) ) {
68 return false;
69 }
70
71 $this->_filename = $data['source'];
72 }
73
74 // populate series and data information
75 return $this->fetch();
76 }
77
78 /**
79 * Re populates data.
80 *
81 * @since 1.1.0
82 *
83 * @access public
84 * @param array $data The actual array of data.
85 * @param int $chart_id The chart id.
86 * @return array The re populated array of data or old one.
87 */
88 public function repopulateData( $data, $chart_id ) {
89 return $this->_repopulate( $chart_id ) ? $this->_data : $data;
90 }
91
92 /**
93 * Re populates series.
94 *
95 * @since 1.1.0
96 *
97 * @access public
98 * @param array $series The actual array of series.
99 * @param int $chart_id The chart id.
100 * @return array The re populated array of series or old one.
101 */
102 public function repopulateSeries( $series, $chart_id ) {
103 return $this->_repopulate( $chart_id ) ? $this->_series : $series;
104 }
105
106 /**
107 * Returns source name.
108 *
109 * @since 1.0.0
110 *
111 * @access public
112 * @return string The name of source.
113 */
114 public function getSourceName() {
115 return __CLASS__;
116 }
117
118 }