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

190 lines 7.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 * Renders visualizer library page.
24 *
25 * @category Visualizer
26 * @package Render
27 *
28 * @since 1.0.0
29 */
30 class Visualizer_Render_Library extends Visualizer_Render {
31
32 /**
33 * Renders chart's box block.
34 *
35 * @since 1.0.0
36 *
37 * @access private
38 * @param string $placeholder_id The placeholder's id for the chart.
39 * @param int $chart_id The id of the chart.
40 */
41 private function _renderChartBox( $placeholder_id, $chart_id ) {
42 $ajax_url = admin_url( 'admin-ajax.php' );
43
44 $delete_url = add_query_arg( array(
45 'action' => Visualizer_Plugin::ACTION_DELETE_CHART,
46 'nonce' => wp_create_nonce(),
47 'chart' => $chart_id,
48 ), $ajax_url );
49
50 $clone_url = add_query_arg( array(
51 'action' => Visualizer_Plugin::ACTION_CLONE_CHART,
52 'nonce' => wp_create_nonce( Visualizer_Plugin::ACTION_CLONE_CHART ),
53 'chart' => $chart_id,
54 'type' => $this->type,
55 ), $ajax_url );
56
57 $export_link = add_query_arg( array(
58 'action' => Visualizer_Plugin::ACTION_EXPORT_DATA,
59 'chart' => $chart_id,
60 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_EXPORT_DATA . Visualizer_Plugin::VERSION ),
61 ), admin_url( 'admin-ajax.php' ) );
62
63 echo '<div class="visualizer-chart">';
64 echo '<div id="', $placeholder_id, '" class="visualizer-chart-canvas">';
65 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
66 echo '</div>';
67 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
68 echo '<a class="visualizer-chart-action visualizer-chart-delete" href="', $delete_url, '" title="', esc_attr__( 'Delete', 'visualizer' ), '" onclick="return showNotice.warn();"></a>';
69 echo '<a class="visualizer-chart-action visualizer-chart-clone" href="', $clone_url, '" title="', esc_attr__( 'Clone', 'visualizer' ), '"></a>';
70 echo '<a class="visualizer-chart-action visualizer-chart-edit" href="javascript:;" title="', esc_attr__( 'Edit', 'visualizer' ), '" data-chart="', $chart_id, '"></a>';
71 echo '<a class="visualizer-chart-action visualizer-chart-export" href="javascript:;" title="', esc_attr__( 'Export', 'visualizer' ), '" data-chart="', $export_link, '"></a>';
72
73 echo '<span class="visualizer-chart-shortcode" title="', esc_attr__( 'Click to select', 'visualizer' ), '">';
74 echo '&nbsp;[visualizer id=&quot;', $chart_id, '&quot;]&nbsp;';
75 echo '</span>';
76 echo '</div>';
77 echo '</div>';
78 }
79
80 /**
81 * Renders library content.
82 *
83 * @since 1.0.0
84 *
85 * @access private
86 */
87 private function _renderLibrary() {
88 // Added by Ash/Upwork
89 $filterBy = null;
90 if ( isset( $_GET['filter'] ) && strlen( $_GET['filter'] ) > 0 ) {
91 $filterBy = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
92 }
93 echo '<div id="visualizer-search"><form action="" method="get">
94 <input type="text" name="filter" value="' . $filterBy . '">
95 <input type="hidden" name="page" value="visualizer">
96 <input type="submit" class="button button-secondary" value="' . esc_attr__( 'Search', 'visualizer' ) . '">
97 </form></div>';
98 // Added by Ash/Upwork
99 echo '<div id="visualizer-types" class="visualizer-clearfix">';
100 echo '<ul>';
101 foreach ( $this->types as $type => $label ) {
102 echo '<li class="visualizer-list-item">';
103 if ( $type == $this->type ) {
104 echo '<a class="page-numbers current" href="', esc_url( add_query_arg( 'vpage', false ) ), '">';
105 echo $label;
106 echo '</a>';
107 } else {
108 echo '<a class="page-numbers" href="', esc_url( add_query_arg( array( 'type' => $type, 'vpage' => false ) ) ), '">';
109 echo $label;
110 echo '</a>';
111 }
112 echo '</li>';
113 }
114 echo '</ul>';
115 echo '</div>';
116
117 if ( ! empty( $this->charts ) ) {
118 echo '<div id="visualizer-library" class="visualizer-clearfix">';
119 foreach ( $this->charts as $placeholder_id => $chart ) {
120 $this->_renderChartBox( $placeholder_id, $chart['id'] );
121 }
122 echo '</div>';
123
124 if ( is_array( $this->pagination ) ) {
125 echo '<ul class="visualizer-library-pagination">';
126 foreach ( $this->pagination as $page ) {
127 echo '<li class="visualizer-list-item">', $page, '</li>';
128 }
129 echo '</ul>';
130 }
131 } else {
132 echo '<div id="visualizer-library" class="visualizer-clearfix">';
133 echo '<div class="visualizer-chart">';
134 echo '<div class="visualizer-chart-canvas visualizer-nochart-canvas">';
135 echo '<div class="visualizer-notfound">', esc_html__( 'No charts found', 'visualizer' ), '</div>';
136 echo '</div>';
137 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
138 echo '<span class="visualizer-chart-action visualizer-nochart-delete"></span>';
139 echo '<span class="visualizer-chart-action visualizer-nochart-clone"></span>';
140 echo '<span class="visualizer-chart-action visualizer-nochart-edit"></span>';
141 echo '<span class="visualizer-chart-action visualizer-nochart-export"></span>';
142
143 echo '<span class="visualizer-chart-shortcode">';
144 echo '&nbsp;[visualizer]&nbsp;';
145 echo '</span>';
146 echo '</div>';
147 echo '</div>';
148 echo '</div>';
149 }
150 }
151
152 /**
153 * Renders library page.
154 *
155 * @since 1.0.0
156 *
157 * @access protected
158 */
159 protected function _toHTML() {
160 echo '<div class="wrap">';
161 echo '<div id="visualizer-icon" class="icon32"><br></div>';
162 echo '<h2>';
163 esc_html_e( 'Visualizer Library', 'visualizer' );
164 echo ' <a href="javascript:;" class="add-new-h2">', esc_html__( 'Add New', 'visualizer' ), '</a>';
165 echo '</h2>';
166
167 $this->_renderMessages();
168 $this->_renderLibrary();
169 echo '</div>';
170 }
171
172 /**
173 * Renders notification messages if need be.
174 *
175 * @since 1.4.2
176 *
177 * @access private
178 */
179 private function _renderMessages() {
180 if ( ! filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ) ) {
181 echo '<div class="updated error">';
182 echo '<p>';
183 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>' );
184 echo '</p>';
185 echo '</div>';
186 }
187 }
188
189 }
190