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

195 lines 7.6 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 => $array ) {
102 $label = $array['name'];
103 $link = '<a class="page-numbers" href="' . esc_url( add_query_arg( array( 'type' => $type, 'vpage' => false ) ) ) . '">';
104 if ( ! $array['enabled'] ) {
105 $link = "<a class='pro-upsell page-numbers' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
106 }
107 echo '<li class="visualizer-list-item">';
108 if ( $type == $this->type ) {
109 echo '<a class="page-numbers current" href="', esc_url( add_query_arg( 'vpage', false ) ), '">';
110 echo $label;
111 echo '</a>';
112 } else {
113 echo $link;
114 echo $label;
115 echo '</a>';
116 }
117 echo '</li>';
118 }
119 echo '</ul>';
120 echo '</div>';
121
122 if ( ! empty( $this->charts ) ) {
123 echo '<div id="visualizer-library" class="visualizer-clearfix">';
124 foreach ( $this->charts as $placeholder_id => $chart ) {
125 $this->_renderChartBox( $placeholder_id, $chart['id'] );
126 }
127 echo '</div>';
128
129 if ( is_array( $this->pagination ) ) {
130 echo '<ul class="visualizer-library-pagination">';
131 foreach ( $this->pagination as $page ) {
132 echo '<li class="visualizer-list-item">', $page, '</li>';
133 }
134 echo '</ul>';
135 }
136 } else {
137 echo '<div id="visualizer-library" class="visualizer-clearfix">';
138 echo '<div class="visualizer-chart">';
139 echo '<div class="visualizer-chart-canvas visualizer-nochart-canvas">';
140 echo '<div class="visualizer-notfound">', esc_html__( 'No charts found', 'visualizer' ), '</div>';
141 echo '</div>';
142 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
143 echo '<span class="visualizer-chart-action visualizer-nochart-delete"></span>';
144 echo '<span class="visualizer-chart-action visualizer-nochart-clone"></span>';
145 echo '<span class="visualizer-chart-action visualizer-nochart-edit"></span>';
146 echo '<span class="visualizer-chart-action visualizer-nochart-export"></span>';
147
148 echo '<span class="visualizer-chart-shortcode">';
149 echo '&nbsp;[visualizer]&nbsp;';
150 echo '</span>';
151 echo '</div>';
152 echo '</div>';
153 echo '</div>';
154 }
155 }
156
157 /**
158 * Renders library page.
159 *
160 * @since 1.0.0
161 *
162 * @access protected
163 */
164 protected function _toHTML() {
165 echo '<div class="wrap">';
166 echo '<div id="visualizer-icon" class="icon32"><br></div>';
167 echo '<h2>';
168 esc_html_e( 'Visualizer Library', 'visualizer' );
169 echo ' <a href="javascript:;" class="add-new-h2">', esc_html__( 'Add New', 'visualizer' ), '</a>';
170 echo '</h2>';
171
172 $this->_renderMessages();
173 $this->_renderLibrary();
174 echo '</div>';
175 }
176
177 /**
178 * Renders notification messages if need be.
179 *
180 * @since 1.4.2
181 *
182 * @access private
183 */
184 private function _renderMessages() {
185 if ( ! filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ) ) {
186 echo '<div class="updated error">';
187 echo '<p>';
188 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>' );
189 echo '</p>';
190 echo '</div>';
191 }
192 }
193
194 }
195