| @@ -1,112 +1,113 @@ | ||
| 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 | - * Media view template rendering class. | |
| 24 | - * | |
| 25 | - * @category Visualizer | |
| 26 | - * @package Render | |
| 27 | - * | |
| 28 | - * @since 1.0.0 | |
| 29 | - */ | |
| 30 | -class Visualizer_Render_Templates extends Visualizer_Render { | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * The array of template names. | |
| 34 | - * | |
| 35 | - * @since 1.0.0 | |
| 36 | - * | |
| 37 | - * @access private | |
| 38 | - * @var array | |
| 39 | - */ | |
| 40 | - private $_templates = array( | |
| 41 | - 'library-chart', | |
| 42 | - 'library-empty', | |
| 43 | - ); | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * Renders concreate template and wraps it into script tag. | |
| 47 | - * | |
| 48 | - * @since 1.0.0 | |
| 49 | - * | |
| 50 | - * @param string $id The name of a template. | |
| 51 | - * @param string $callback The name of the function to render a template. | |
| 52 | - */ | |
| 53 | - private function _renderTemplate( $id, $callback ) { | |
| 54 | - echo '<script id="tmpl-visualizer-', $id, '" type="text/html">'; | |
| 55 | - call_user_func( array( $this, $callback ) ); | |
| 56 | - echo '</script>'; | |
| 57 | - } | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * Renders library-chart template. | |
| 61 | - * | |
| 62 | - * @since 1.0.0 | |
| 63 | - * | |
| 64 | - * @access protected | |
| 65 | - */ | |
| 66 | - protected function _renderLibraryChart() { | |
| 67 | - echo '<div class="visualizer-library-chart-footer visualizer-clearfix">'; | |
| 68 | - echo '<a class="visualizer-library-chart-action visualizer-library-chart-delete" href="javascript:;" title="', esc_attr__( 'Delete', 'visualizer' ), '"></a>'; | |
| 69 | - echo '<a class="visualizer-library-chart-action visualizer-library-chart-insert" href="javascript:;" title="', esc_attr__( 'Insert', 'visualizer' ), '"></a>'; | |
| 70 | - | |
| 71 | - echo '<span class="visualizer-library-chart-shortcode" title="', esc_attr__( 'Click to select', 'visualizer' ), '"> [visualizer id="{{data.id}}"] </span>'; | |
| 72 | - echo '</div>'; | |
| 73 | - } | |
| 74 | - | |
| 75 | - /** | |
| 76 | - * Renders library-empty template. | |
| 77 | - * | |
| 78 | - * @since 1.0.0 | |
| 79 | - * | |
| 80 | - * @access protected | |
| 81 | - */ | |
| 82 | - protected function _renderLibraryEmpty() { | |
| 83 | - echo '<div class="visualizer-library-chart">'; | |
| 84 | - echo '<div class="visualizer-library-chart-canvas visualizer-library-nochart-canvas">'; | |
| 85 | - echo '<div class="visualizer-library-notfound">', esc_html__( 'No charts found', 'visualizer' ), '</div>'; | |
| 86 | - echo '</div>'; | |
| 87 | - echo '<div class="visualizer-library-chart-footer visualizer-clearfix">'; | |
| 88 | - echo '<span class="visualizer-library-chart-action visualizer-library-nochart-delete"></span>'; | |
| 89 | - echo '<span class="visualizer-library-chart-action visualizer-library-nochart-insert"></span>'; | |
| 90 | - | |
| 91 | - echo '<span class="visualizer-library-chart-shortcode">'; | |
| 92 | - echo ' [visualizer] '; | |
| 93 | - echo '</span>'; | |
| 94 | - echo '</div>'; | |
| 95 | - echo '</div>'; | |
| 96 | - } | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * Renders templates. | |
| 100 | - * | |
| 101 | - * @since 1.0.0 | |
| 102 | - * | |
| 103 | - * @access protected | |
| 104 | - */ | |
| 105 | - protected function _toHTML() { | |
| 106 | - foreach ( $this->_templates as $template ) { | |
| 107 | - $callback = '_render' . str_replace( ' ', '', ucwords( str_replace( '-', ' ', $template ) ) ); | |
| 108 | - $this->_renderTemplate( $template, $callback ); | |
| 109 | - } | |
| 110 | - } | |
| 111 | - | |
| 112 | -} | |
| 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 | + * Media view template rendering class. | |
| 25 | + * | |
| 26 | + * @category Visualizer | |
| 27 | + * @package Render | |
| 28 | + * | |
| 29 | + * @since 1.0.0 | |
| 30 | + */ | |
| 31 | +class Visualizer_Render_Templates extends Visualizer_Render { | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * The array of template names. | |
| 35 | + * | |
| 36 | + * @since 1.0.0 | |
| 37 | + * | |
| 38 | + * @access private | |
| 39 | + * @var array | |
| 40 | + */ | |
| 41 | + private $_templates = array( | |
| 42 | + 'library-chart', | |
| 43 | + 'library-empty', | |
| 44 | + ); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Renders concreate template and wraps it into script tag. | |
| 48 | + * | |
| 49 | + * @since 1.0.0 | |
| 50 | + * | |
| 51 | + * @param string $id The name of a template. | |
| 52 | + * @param string $callback The name of the function to render a template. | |
| 53 | + */ | |
| 54 | + private function _renderTemplate( $id, $callback ) { | |
| 55 | + echo '<script id="tmpl-visualizer-', $id, '" type="text/html">'; | |
| 56 | + call_user_func( array( $this, $callback ) ); | |
| 57 | + echo '</script>'; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Renders library-chart template. | |
| 62 | + * | |
| 63 | + * @since 1.0.0 | |
| 64 | + * | |
| 65 | + * @access protected | |
| 66 | + */ | |
| 67 | + protected function _renderLibraryChart() { | |
| 68 | + echo '<div class="visualizer-library-chart-footer visualizer-clearfix">'; | |
| 69 | + echo '<a class="visualizer-library-chart-action visualizer-library-chart-delete" href="javascript:;" title="', esc_attr__( 'Delete', Visualizer_Plugin::NAME ), '"></a>'; | |
| 70 | + echo '<a class="visualizer-library-chart-action visualizer-library-chart-insert" href="javascript:;" title="', esc_attr__( 'Insert', Visualizer_Plugin::NAME ), '"></a>'; | |
| 71 | + | |
| 72 | + echo '<span class="visualizer-library-chart-shortcode" title="', esc_attr__( 'Click to select', Visualizer_Plugin::NAME ), '"> [visualizer id="{{data.id}}"] </span>'; | |
| 73 | + echo '</div>'; | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * Renders library-empty template. | |
| 78 | + * | |
| 79 | + * @since 1.0.0 | |
| 80 | + * | |
| 81 | + * @access protected | |
| 82 | + */ | |
| 83 | + protected function _renderLibraryEmpty() { | |
| 84 | + echo '<div class="visualizer-library-chart">'; | |
| 85 | + echo '<div class="visualizer-library-chart-canvas visualizer-library-nochart-canvas">'; | |
| 86 | + echo '<div class="visualizer-library-notfound">', esc_html__( 'No charts found', Visualizer_Plugin::NAME ), '</div>'; | |
| 87 | + echo '</div>'; | |
| 88 | + echo '<div class="visualizer-library-chart-footer visualizer-clearfix">'; | |
| 89 | + echo '<span class="visualizer-library-chart-action visualizer-library-nochart-delete"></span>'; | |
| 90 | + echo '<span class="visualizer-library-chart-action visualizer-library-nochart-insert"></span>'; | |
| 91 | + | |
| 92 | + echo '<span class="visualizer-library-chart-shortcode">'; | |
| 93 | + echo ' [visualizer] '; | |
| 94 | + echo '</span>'; | |
| 95 | + echo '</div>'; | |
| 96 | + echo '</div>'; | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * Renders templates. | |
| 101 | + * | |
| 102 | + * @since 1.0.0 | |
| 103 | + * | |
| 104 | + * @access protected | |
| 105 | + */ | |
| 106 | + protected function _toHTML() { | |
| 107 | + foreach ( $this->_templates as $template ) { | |
| 108 | + $callback = '_render' . str_replace( ' ', '', ucwords( str_replace( '-', ' ', $template ) ) ); | |
| 109 | + $this->_renderTemplate( $template, $callback ); | |
| 110 | + } | |
| 111 | + } | |
| 112 | + | |
| 113 | +} | |