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

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