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

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

264 lines 10.8 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 echo '<form action="" method="get"><p id="visualizer-search" class="search-box">
122 <input type="search" placeholder="' . __( 'Enter title', 'visualizer' ) . '" name="s" value="' . $filterBy . '">
123 <input type="hidden" name="page" value="visualizer">
124 <button type="submit" id="search-submit" title="' . __( 'Search', 'visualizer' ) . '"><i class="dashicons dashicons-search"></i></button>
125 <button type="button" class="add-new-chart" title="' . __( 'Add New', 'visualizer' ) . '"><i class="dashicons dashicons-plus-alt"></i></button>
126 </p> </form>';
127 echo '</div>';
128 echo '<div id="visualizer-content-wrapper">';
129 if ( ! empty( $this->charts ) ) {
130 echo '<div id="visualizer-library" class="visualizer-clearfix">';
131 $count = 0;
132 foreach ( $this->charts as $placeholder_id => $chart ) {
133 $this->_renderChartBox( $placeholder_id, $chart['id'] );
134 // show the sidebar after the first 3 charts.
135 if ( $count++ === 2 ) {
136 $this->_renderSidebar();
137 }
138 }
139 // show the sidebar if there are less than 3 charts.
140 if ( $count < 3 ) {
141 $this->_renderSidebar();
142 }
143 echo '</div>';
144 } else {
145 echo '<div id="visualizer-library" class="visualizer-clearfix">';
146 echo '<div class="visualizer-chart">';
147 echo '<div class="visualizer-chart-canvas visualizer-nochart-canvas">';
148 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>';
149 echo '</div>';
150 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
151 echo '<span class="visualizer-chart-action visualizer-nochart-delete"></span>';
152 echo '<span class="visualizer-chart-action visualizer-nochart-clone"></span>';
153 echo '<span class="visualizer-chart-action visualizer-nochart-edit"></span>';
154 echo '<span class="visualizer-chart-action visualizer-nochart-export"></span>';
155 echo '<span class="visualizer-chart-shortcode">';
156 echo '&nbsp;[visualizer]&nbsp;';
157 echo '</span>';
158 echo '</div>';
159 echo '</div>';
160 $this->_renderSidebar();
161 echo '</div>';
162 }
163 echo '</div>';
164 if ( is_array( $this->pagination ) ) {
165 echo '<ul class=" subsubsub">';
166 foreach ( $this->pagination as $page ) {
167 echo '<li class="all">', $page, '</li>';
168 }
169 echo '</ul>';
170 }
171 }
172
173 /**
174 * Renders chart's box block.
175 *
176 * @since 1.0.0
177 *
178 * @access private
179 *
180 * @param string $placeholder_id The placeholder's id for the chart.
181 * @param int $chart_id The id of the chart.
182 */
183 private function _renderChartBox( $placeholder_id, $chart_id ) {
184 $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS );
185 $title = '#' . $chart_id;
186 if ( ! empty( $settings[0]['title'] ) ) {
187 $title = $settings[0]['title'];
188 }
189 // for ChartJS, title is an array.
190 if ( is_array( $title ) && isset( $title['text'] ) ) {
191 $title = $title['text'];
192 }
193 if ( empty( $title ) ) {
194 $title = '#' . $chart_id;
195 }
196
197 $ajax_url = admin_url( 'admin-ajax.php' );
198 $delete_url = add_query_arg(
199 array(
200 'action' => Visualizer_Plugin::ACTION_DELETE_CHART,
201 'nonce' => wp_create_nonce(),
202 'chart' => $chart_id,
203 ),
204 $ajax_url
205 );
206 $clone_url = add_query_arg(
207 array(
208 'action' => Visualizer_Plugin::ACTION_CLONE_CHART,
209 'nonce' => wp_create_nonce( Visualizer_Plugin::ACTION_CLONE_CHART ),
210 'chart' => $chart_id,
211 'type' => $this->type,
212 ),
213 $ajax_url
214 );
215 $export_link = add_query_arg(
216 array(
217 'action' => Visualizer_Plugin::ACTION_EXPORT_DATA,
218 'chart' => $chart_id,
219 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_EXPORT_DATA . Visualizer_Plugin::VERSION ),
220 ),
221 admin_url( 'admin-ajax.php' )
222 );
223 echo '<div class="visualizer-chart"><div class="visualizer-chart-title">', esc_html( $title ), '</div>';
224 echo '<div id="', $placeholder_id, '" class="visualizer-chart-canvas">';
225 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
226 echo '</div>';
227 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
228 echo '<a class="visualizer-chart-action visualizer-chart-delete" href="', $delete_url, '" title="', esc_attr__( 'Delete', 'visualizer' ), '" onclick="return showNotice.warn();"></a>';
229 echo '<a class="visualizer-chart-action visualizer-chart-clone" href="', $clone_url, '" title="', esc_attr__( 'Clone', 'visualizer' ), '"></a>';
230 echo '<a class="visualizer-chart-action visualizer-chart-edit" href="javascript:;" title="', esc_attr__( 'Edit', 'visualizer' ), '" data-chart="', $chart_id, '"></a>';
231 echo '<a class="visualizer-chart-action visualizer-chart-export" href="javascript:;" title="', esc_attr__( 'Export', 'visualizer' ), '" data-chart="', $export_link, '"></a>';
232 echo '<span class="visualizer-chart-shortcode" title="', esc_attr__( 'Click to select', 'visualizer' ), '">';
233 echo '&nbsp;[visualizer id=&quot;', $chart_id, '&quot;]&nbsp;';
234 echo '</span>';
235 echo '</div>';
236 echo '</div>';
237 }
238
239 /**
240 * Render sidebar.
241 */
242 private function _renderSidebar() {
243 if ( ! Visualizer_Module::is_pro() ) {
244 echo '<div id="visualizer-sidebar">';
245 echo '<div class="visualizer-sidebar-box">';
246 echo '<h3>' . __( 'Discover the power of PRO!', 'visualizer' ) . '</h3><ul>';
247 echo '<li>' . __( 'Spreadsheet like editor', 'visualizer' ) . '</li>';
248 echo '<li>' . __( 'Import from other charts', 'visualizer' ) . '</li>';
249 echo '<li>' . __( 'Use database query to create charts', 'visualizer' ) . '</li>';
250 echo '<li>' . __( 'Create charts from WordPress tables', 'visualizer' ) . '</li>';
251 echo '<li>' . __( 'Frontend editor', 'visualizer' ) . '</li>';
252 echo '<li>' . __( 'Private charts', 'visualizer' ) . '</li>';
253 echo '<li>' . __( 'Auto-sync with online files', 'visualizer' ) . '</li>';
254 echo '<li>' . __( '6 more chart types', 'visualizer' ) . '</li></ul>';
255 echo '<p><a href="' . Visualizer_Plugin::PRO_TEASER_URL . '" target="_blank" class="button button-primary">' . __( 'View more features', 'visualizer' ) . '</a></p>';
256 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>';
257 echo '<p><a href="' . VISUALIZER_SURVEY . '" target="_blank" class="">' . __( 'Don\'t see the features you need? Help us improve!', 'visualizer' ) . '</a></p>';
258 echo '</div>';
259 echo '</div>';
260 }
261 }
262
263 }
264