PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.2
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 / Render / Library.php

Library.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.2, at classes/Visualizer/Render/Library.php

273 lines 11.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // +----------------------------------------------------------------------+
3 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
4 // +----------------------------------------------------------------------+
5 // | This program is free software; you can redistribute it and/or modify |
6 // | it under the terms of the GNU General Public License, version 2, as |
7 // | published by the Free Software Foundation. |
8 // | |
9 // | This program is distributed in the hope that it will be useful, |
10 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 // | GNU General Public License for more details. |
13 // | |
14 // | You should have received a copy of the GNU General Public License |
15 // | along with this program; if not, write to the Free Software |
16 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
17 // | MA 02110-1301 USA |
18 // +----------------------------------------------------------------------+
19 // | Author: Eugene Manuilov <eugene@manuilov.org> |
20 // +----------------------------------------------------------------------+
21 /**
22 * Renders visualizer library page.
23 *
24 * @category Visualizer
25 * @package Render
26 *
27 * @since 1.0.0
28 */
29 class Visualizer_Render_Library extends Visualizer_Render {
30
31 /**
32 * Renders library page.
33 *
34 * @since 1.0.0
35 *
36 * @access protected
37 */
38 protected function _toHTML() {
39 echo '<div class="wrap">';
40 echo '<div id="visualizer-icon" class="icon32"><br></div>';
41 echo '<h2>';
42 esc_html_e( 'Visualizer Library', 'visualizer' );
43 echo ' <a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New', 'visualizer' ), '</a>';
44 if ( Visualizer_Module::is_pro() ) {
45 echo ' <a href="' . admin_url( 'options-general.php' ) . '" class="page-title-action">', esc_html__( 'License Settings', 'visualizer' ), '</a>';
46 }
47 echo '</h2>';
48 $this->_renderMessages();
49 $this->_renderLibrary();
50 echo '</div>';
51 }
52
53 /**
54 * Renders notification messages if need be.
55 *
56 * @since 1.4.2
57 *
58 * @access private
59 */
60 private function _renderMessages() {
61 if ( ! filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ) ) {
62 echo '<div class="updated error">';
63 echo '<p>';
64 printf( esc_html__( '%s option is disabled in your php.ini config. Please, enable it by change its value to 1. This option increases the speed of remote CSV uploading.', 'visualizer' ), '<b>allow_url_fopen</b>' );
65 echo '</p>';
66 echo '</div>';
67 }
68 }
69
70 /**
71 * Renders library content.
72 *
73 * @since 1.0.0
74 *
75 * @access private
76 */
77 private function _renderLibrary() {
78 // Added by Ash/Upwork
79 $filterBy = null;
80 if ( isset( $_GET['s'] ) && strlen( $_GET['s'] ) > 0 ) {
81 $filterBy = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
82 }
83 // Added by Ash/Upwork
84 echo $this->custom_css;
85 echo '<div id="visualizer-types" class="visualizer-clearfix">';
86 echo '<ul class="subsubsub">';
87 // All tab.
88 echo '<li class="visualizer-list-item all"><a class="' . ( ! isset( $_GET['type'] ) || empty( $_GET['type'] ) ? 'current' : '' ) . '" href="', esc_url( add_query_arg( array( 'vpage' => false, 'type' => false, 'vaction' => false, 's' => false ) ) ), '">' . __( 'All', 'visualizer' ) . '</a> | </li>';
89 foreach ( $this->types as $type => $array ) {
90 if ( ! is_array( $array ) ) {
91 // support for old pro
92 $array = array( 'enabled' => true, 'name' => $array );
93 }
94 $label = $array['name'];
95 $link = '<a class=" " href="' . esc_url(
96 add_query_arg(
97 array(
98 'type' => $type,
99 'vpage' => false,
100 'vaction' => false,
101 's' => false,
102 )
103 )
104 ) . '">';
105 if ( ! $array['enabled'] ) {
106 $link = "<a class=' visualizer-pro-only' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
107 }
108 echo '<li class="visualizer-list-item ' . esc_attr( $this->type ) . '">';
109 if ( $type === $this->type ) {
110 echo '<a class="current" href="', esc_url( add_query_arg( 'vpage', false ) ), '">';
111 echo $label;
112 echo '</a>';
113 } else {
114 echo $link;
115 echo $label;
116 echo '</a>';
117 }
118 echo ' | </li>';
119 }
120 echo '</ul>';
121
122 echo '<form action="" method="get"><p id="visualizer-search" class="search-box">
123 <input type="search" placeholder="' . __( 'Enter title', 'visualizer' ) . '" name="s" value="' . $filterBy . '">
124 <input type="hidden" name="page" value="visualizer">
125 <button type="submit" id="search-submit" title="' . __( 'Search', 'visualizer' ) . '"><i class="dashicons dashicons-search"></i></button>
126 </p> </form>';
127
128 echo '</div>';
129 echo '<div id="visualizer-content-wrapper">';
130 if ( ! empty( $this->charts ) ) {
131 echo '<div id="visualizer-library" class="visualizer-clearfix">';
132 $count = 0;
133 foreach ( $this->charts as $placeholder_id => $chart ) {
134 $this->_renderChartBox( $placeholder_id, $chart['id'] );
135 // show the sidebar after the first 3 charts.
136 if ( $count++ === 2 ) {
137 $this->_renderSidebar();
138 }
139 }
140 // show the sidebar if there are less than 3 charts.
141 if ( $count < 3 ) {
142 $this->_renderSidebar();
143 }
144 echo '</div>';
145 } else {
146 echo '<div id="visualizer-library" class="visualizer-clearfix">';
147 echo '<div class="visualizer-chart">';
148 echo '<div class="visualizer-chart-canvas visualizer-nochart-canvas">';
149 echo '<div class="visualizer-notfound">', esc_html__( 'No charts found', 'visualizer' ), '<p><h2><a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New', 'visualizer' ), '</a></h2></p></div>';
150 echo '</div>';
151 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
152 echo '<span class="visualizer-chart-action visualizer-nochart-delete"></span>';
153 echo '<span class="visualizer-chart-action visualizer-nochart-clone"></span>';
154 echo '<span class="visualizer-chart-action visualizer-nochart-edit"></span>';
155 echo '<span class="visualizer-chart-action visualizer-nochart-export"></span>';
156 echo '<span class="visualizer-chart-shortcode">';
157 echo '&nbsp;[visualizer]&nbsp;';
158 echo '</span>';
159 echo '</div>';
160 echo '</div>';
161 $this->_renderSidebar();
162 echo '</div>';
163 }
164 echo '</div>';
165 if ( is_array( $this->pagination ) ) {
166 echo '<ul class=" subsubsub">';
167 foreach ( $this->pagination as $page ) {
168 echo '<li class="all">', $page, '</li>';
169 }
170 echo '</ul>';
171 }
172 }
173
174 /**
175 * Renders chart's box block.
176 *
177 * @since 1.0.0
178 *
179 * @access private
180 *
181 * @param string $placeholder_id The placeholder's id for the chart.
182 * @param int $chart_id The id of the chart.
183 */
184 private function _renderChartBox( $placeholder_id, $chart_id ) {
185 $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS );
186 $title = '#' . $chart_id;
187 if ( ! empty( $settings[0]['title'] ) ) {
188 $title = $settings[0]['title'];
189 }
190 // for ChartJS, title is an array.
191 if ( is_array( $title ) && isset( $title['text'] ) ) {
192 $title = $title['text'];
193 }
194 if ( empty( $title ) ) {
195 $title = '#' . $chart_id;
196 }
197
198 $ajax_url = admin_url( 'admin-ajax.php' );
199 $delete_url = add_query_arg(
200 array(
201 'action' => Visualizer_Plugin::ACTION_DELETE_CHART,
202 'nonce' => wp_create_nonce(),
203 'chart' => $chart_id,
204 ),
205 $ajax_url
206 );
207 $clone_url = add_query_arg(
208 array(
209 'action' => Visualizer_Plugin::ACTION_CLONE_CHART,
210 'nonce' => wp_create_nonce( Visualizer_Plugin::ACTION_CLONE_CHART ),
211 'chart' => $chart_id,
212 'type' => $this->type,
213 ),
214 $ajax_url
215 );
216 $export_link = add_query_arg(
217 array(
218 'action' => Visualizer_Plugin::ACTION_EXPORT_DATA,
219 'chart' => $chart_id,
220 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_EXPORT_DATA . Visualizer_Plugin::VERSION ),
221 ),
222 admin_url( 'admin-ajax.php' )
223 );
224
225 $chart_status = array( 'date' => get_the_modified_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $chart_id ), 'error' => get_post_meta( $chart_id, Visualizer_Plugin::CF_ERROR, true ), 'icon' => 'dashicons-yes-alt', 'title' => '' );
226 if ( ! empty( $chart_status['error'] ) ) {
227 $chart_status['icon'] = 'error dashicons-dismiss';
228 $chart_status['title'] = __( 'Click to view the error', 'visualizer' );
229 }
230
231 echo '<div class="visualizer-chart"><div class="visualizer-chart-title">', esc_html( $title ), '</div>';
232 echo '<div id="', $placeholder_id, '" class="visualizer-chart-canvas">';
233 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
234 echo '</div>';
235 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
236 echo '<a class="visualizer-chart-action visualizer-chart-delete" href="', $delete_url, '" title="', esc_attr__( 'Delete', 'visualizer' ), '" onclick="return showNotice.warn();"></a>';
237 echo '<a class="visualizer-chart-action visualizer-chart-clone" href="', $clone_url, '" title="', esc_attr__( 'Clone', 'visualizer' ), '"></a>';
238 echo '<a class="visualizer-chart-action visualizer-chart-edit" href="javascript:;" title="', esc_attr__( 'Edit', 'visualizer' ), '" data-chart="', $chart_id, '"></a>';
239 echo '<a class="visualizer-chart-action visualizer-chart-export" href="javascript:;" title="', esc_attr__( 'Export', 'visualizer' ), '" data-chart="', $export_link, '"></a>';
240 echo '<span class="visualizer-chart-shortcode" title="', esc_attr__( 'Click to select', 'visualizer' ), '">';
241 echo '&nbsp;[visualizer id=&quot;', $chart_id, '&quot;]&nbsp;';
242 echo '</span>';
243 echo '<hr><div class="visualizer-chart-status"><span class="visualizer-date" title="' . __( 'Last Updated', 'visualizer' ) . '">' . $chart_status['date'] . '</span><span class="visualizer-error"><i class="dashicons ' . $chart_status['icon'] . '" data-viz-error="' . esc_attr( str_replace( '"', "'", $chart_status['error'] ) ) . '" title="' . esc_attr( $chart_status['title'] ) . '"></i></span></div>';
244 echo '</div>';
245 echo '</div>';
246 }
247
248 /**
249 * Render sidebar.
250 */
251 private function _renderSidebar() {
252 if ( ! Visualizer_Module::is_pro() ) {
253 echo '<div id="visualizer-sidebar">';
254 echo '<div class="visualizer-sidebar-box">';
255 echo '<h3>' . __( 'Discover the power of PRO!', 'visualizer' ) . '</h3><ul>';
256 echo '<li>' . __( 'Spreadsheet like editor', 'visualizer' ) . '</li>';
257 echo '<li>' . __( 'Import from other charts', 'visualizer' ) . '</li>';
258 echo '<li>' . __( 'Use database query to create charts', 'visualizer' ) . '</li>';
259 echo '<li>' . __( 'Create charts from WordPress tables', 'visualizer' ) . '</li>';
260 echo '<li>' . __( 'Frontend editor', 'visualizer' ) . '</li>';
261 echo '<li>' . __( 'Private charts', 'visualizer' ) . '</li>';
262 echo '<li>' . __( 'Auto-sync with online files', 'visualizer' ) . '</li>';
263 echo '<li>' . __( '6 more chart types', 'visualizer' ) . '</li></ul>';
264 echo '<p><a href="' . Visualizer_Plugin::PRO_TEASER_URL . '" target="_blank" class="button button-primary">' . __( 'View more features', 'visualizer' ) . '</a></p>';
265 echo '<p style="background-color: #0073aac7; color: #ffffff; padding: 2px; font-weight: bold;">' . __( 'We offer a 30-day no-questions-asked money back guarantee!', 'visualizer' ) . '</p>';
266 echo '<p><a href="' . VISUALIZER_SURVEY . '" target="_blank" class="">' . __( 'Don\'t see the features you need? Help us improve!', 'visualizer' ) . '</a></p>';
267 echo '</div>';
268 echo '</div>';
269 }
270 }
271
272 }
273