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

235 lines 8.9 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">', esc_html__( 'Add New', 'visualizer' ), '</a>';
44 echo '</h2>';
45 $this->_renderMessages();
46 $this->_renderLibrary();
47 echo '</div>';
48 }
49
50 /**
51 * Renders notification messages if need be.
52 *
53 * @since 1.4.2
54 *
55 * @access private
56 */
57 private function _renderMessages() {
58 if ( ! filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ) ) {
59 echo '<div class="updated error">';
60 echo '<p>';
61 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>' );
62 echo '</p>';
63 echo '</div>';
64 }
65 }
66
67 /**
68 * Renders library content.
69 *
70 * @since 1.0.0
71 *
72 * @access private
73 */
74 private function _renderLibrary() {
75 // Added by Ash/Upwork
76 $filterBy = null;
77 if ( isset( $_GET['s'] ) && strlen( $_GET['s'] ) > 0 ) {
78 $filterBy = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
79 }
80 // Added by Ash/Upwork
81 echo $this->custom_css;
82 echo '<div id="visualizer-types" class="visualizer-clearfix">';
83 echo '<ul class="subsubsub">';
84 foreach ( $this->types as $type => $array ) {
85 if ( ! is_array( $array ) ) {
86 // support for old pro
87 $array = array( 'enabled' => true, 'name' => $array );
88 }
89 $label = $array['name'];
90 $link = '<a class=" " href="' . esc_url(
91 add_query_arg(
92 array(
93 'type' => $type,
94 'vpage' => false,
95 )
96 )
97 ) . '">';
98 if ( ! $array['enabled'] ) {
99 $link = "<a class=' visualizer-pro-only' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
100 }
101 echo '<li class="visualizer-list-item all">';
102 if ( $type == $this->type ) {
103 echo '<a class=" current" href="', esc_url( add_query_arg( 'vpage', false ) ), '">';
104 echo $label;
105 echo '</a>';
106 } else {
107 echo $link;
108 echo $label;
109 echo '</a>';
110 }
111 echo ' | </li>';
112 }
113 echo '</ul>';
114 echo '<form action="" method="get"><p id="visualizer-search" class="search-box">
115 <input type="search" name="s" value="' . $filterBy . '">
116 <input type="hidden" name="page" value="visualizer">
117 <input type="submit" id="search-submit" class="button button-secondary" value="' . esc_attr__( 'Search', 'visualizer' ) . '">
118 </p> </form>';
119 echo '</div>';
120 echo '<div id="visualizer-content-wrapper">';
121 if ( ! empty( $this->charts ) ) {
122 echo '<div id="visualizer-library" class="visualizer-clearfix">';
123 foreach ( $this->charts as $placeholder_id => $chart ) {
124 $this->_renderChartBox( $placeholder_id, $chart['id'] );
125 }
126 echo '</div>';
127 } else {
128 echo '<div id="visualizer-library" class="visualizer-clearfix">';
129 echo '<div class="visualizer-chart">';
130 echo '<div class="visualizer-chart-canvas visualizer-nochart-canvas">';
131 echo '<div class="visualizer-notfound">', esc_html__( 'No charts found', 'visualizer' ), '</div>';
132 echo '</div>';
133 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
134 echo '<span class="visualizer-chart-action visualizer-nochart-delete"></span>';
135 echo '<span class="visualizer-chart-action visualizer-nochart-clone"></span>';
136 echo '<span class="visualizer-chart-action visualizer-nochart-edit"></span>';
137 echo '<span class="visualizer-chart-action visualizer-nochart-export"></span>';
138 echo '<span class="visualizer-chart-shortcode">';
139 echo '&nbsp;[visualizer]&nbsp;';
140 echo '</span>';
141 echo '</div>';
142 echo '</div>';
143 echo '</div>';
144 }
145 $this->_renderSidebar();
146 echo '</div>';
147 if ( is_array( $this->pagination ) ) {
148 echo '<ul class=" subsubsub">';
149 foreach ( $this->pagination as $page ) {
150 echo '<li class="all">', $page, '</li>';
151 }
152 echo '</ul>';
153 }
154 }
155
156 /**
157 * Renders chart's box block.
158 *
159 * @since 1.0.0
160 *
161 * @access private
162 *
163 * @param string $placeholder_id The placeholder's id for the chart.
164 * @param int $chart_id The id of the chart.
165 */
166 private function _renderChartBox( $placeholder_id, $chart_id ) {
167 $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS );
168 $title = '#' . $chart_id;
169 if ( ! empty( $settings[0]['title'] ) ) {
170 $title = $settings[0]['title'];
171 }
172 $ajax_url = admin_url( 'admin-ajax.php' );
173 $delete_url = add_query_arg(
174 array(
175 'action' => Visualizer_Plugin::ACTION_DELETE_CHART,
176 'nonce' => wp_create_nonce(),
177 'chart' => $chart_id,
178 ),
179 $ajax_url
180 );
181 $clone_url = add_query_arg(
182 array(
183 'action' => Visualizer_Plugin::ACTION_CLONE_CHART,
184 'nonce' => wp_create_nonce( Visualizer_Plugin::ACTION_CLONE_CHART ),
185 'chart' => $chart_id,
186 'type' => $this->type,
187 ),
188 $ajax_url
189 );
190 $export_link = add_query_arg(
191 array(
192 'action' => Visualizer_Plugin::ACTION_EXPORT_DATA,
193 'chart' => $chart_id,
194 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_EXPORT_DATA . Visualizer_Plugin::VERSION ),
195 ),
196 admin_url( 'admin-ajax.php' )
197 );
198 echo '<div class="visualizer-chart"><div class="visualizer-chart-title">', esc_html( $title ), '</div>';
199 echo '<div id="', $placeholder_id, '" class="visualizer-chart-canvas">';
200 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
201 echo '</div>';
202 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
203 echo '<a class="visualizer-chart-action visualizer-chart-delete" href="', $delete_url, '" title="', esc_attr__( 'Delete', 'visualizer' ), '" onclick="return showNotice.warn();"></a>';
204 echo '<a class="visualizer-chart-action visualizer-chart-clone" href="', $clone_url, '" title="', esc_attr__( 'Clone', 'visualizer' ), '"></a>';
205 echo '<a class="visualizer-chart-action visualizer-chart-edit" href="javascript:;" title="', esc_attr__( 'Edit', 'visualizer' ), '" data-chart="', $chart_id, '"></a>';
206 echo '<a class="visualizer-chart-action visualizer-chart-export" href="javascript:;" title="', esc_attr__( 'Export', 'visualizer' ), '" data-chart="', $export_link, '"></a>';
207 echo '<span class="visualizer-chart-shortcode" title="', esc_attr__( 'Click to select', 'visualizer' ), '">';
208 echo '&nbsp;[visualizer id=&quot;', $chart_id, '&quot;]&nbsp;';
209 echo '</span>';
210 echo '</div>';
211 echo '</div>';
212 }
213
214 /**
215 * Render sidebar.
216 */
217 private function _renderSidebar() {
218 if ( ! VISUALIZER_PRO ) {
219 echo '<div id="visualizer-sidebar">';
220 echo '<div class="visualizer-sidebar-box">';
221 echo '<h3>' . __( 'Gain more editing power', 'visualizer' ) . '</h3><ul>';
222 echo '<li>' . __( 'Spreadsheet like editor', 'visualizer' ) . '</li>';
223 echo '<li>' . __( 'Import from other charts', 'visualizer' ) . '</li>';
224 echo '<li>' . __( 'Frontend editor', 'visualizer' ) . '</li>';
225 echo '<li>' . __( 'Private charts', 'visualizer' ) . '</li>';
226 echo '<li>' . __( 'Auto-sync with online files', 'visualizer' ) . '</li>';
227 echo '<li>' . __( '3 more chart types', 'visualizer' ) . '</li></ul>';
228 echo '<a href="' . Visualizer_Plugin::PRO_TEASER_URL . '" target="_blank" class="button button-primary">' . __( 'View more features', 'visualizer' ) . '</a>';
229 echo '</div>';
230 echo '</div>';
231 }
232 }
233
234 }
235