|
// +----------------------------------------------------------------------+
/**
* Renders visualizer library page.
*
* @category Visualizer
* @package Render
*
* @since 1.0.0
*/
class Visualizer_Render_Library extends Visualizer_Render {
/**
* Renders library page.
*
* @since 1.0.0
*
* @access protected
*/
protected function _toHTML() {
echo '
';
echo '
';
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' ), 'allow_url_fopen' );
echo '
';
echo '
';
}
}
/**
* Renders library content.
*
* @since 1.0.0
*
* @access private
*/
private function _renderLibrary() {
// Added by Ash/Upwork
$filterBy = null;
if ( isset( $_GET['s'] ) && strlen( $_GET['s'] ) > 0 ) {
$filterBy = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
}
// Added by Ash/Upwork
echo '';
if ( ! empty( $this->charts ) ) {
echo '
';
foreach ( $this->charts as $placeholder_id => $chart ) {
$this->_renderChartBox( $placeholder_id, $chart['id'] );
}
echo '
';
if ( is_array( $this->pagination ) ) {
echo '
';
foreach ( $this->pagination as $page ) {
echo '- ', $page, '
';
}
echo '
';
}
} else {
echo '
';
echo '
';
echo '
';
echo '
', esc_html__( 'No charts found', 'visualizer' ), '
';
echo '
';
echo '';
echo '
';
echo '
';
}
$this->_renderSidebar();
echo '
';
}
/**
* Renders chart's box block.
*
* @since 1.0.0
*
* @access private
*
* @param string $placeholder_id The placeholder's id for the chart.
* @param int $chart_id The id of the chart.
*/
private function _renderChartBox( $placeholder_id, $chart_id ) {
$ajax_url = admin_url( 'admin-ajax.php' );
$delete_url = add_query_arg( array(
'action' => Visualizer_Plugin::ACTION_DELETE_CHART,
'nonce' => wp_create_nonce(),
'chart' => $chart_id,
), $ajax_url );
$clone_url = add_query_arg( array(
'action' => Visualizer_Plugin::ACTION_CLONE_CHART,
'nonce' => wp_create_nonce( Visualizer_Plugin::ACTION_CLONE_CHART ),
'chart' => $chart_id,
'type' => $this->type,
), $ajax_url );
$export_link = add_query_arg( array(
'action' => Visualizer_Plugin::ACTION_EXPORT_DATA,
'chart' => $chart_id,
'security' => wp_create_nonce( Visualizer_Plugin::ACTION_EXPORT_DATA . Visualizer_Plugin::VERSION ),
), admin_url( 'admin-ajax.php' ) );
echo '