| @@ -1,155 +1,155 @@ | ||
| 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 | - * Abstract render class implements all routine stuff required for template | |
| 25 | - * rendering. | |
| 26 | - * | |
| 27 | - * @category Visualizer | |
| 28 | - * @package Render | |
| 29 | - * | |
| 30 | - * @since 1.0.0 | |
| 31 | - * @abstract | |
| 32 | - */ | |
| 33 | -abstract class Visualizer_Render { | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * The storage of all data associated with this render. | |
| 37 | - * | |
| 38 | - * @since 1.0.0 | |
| 39 | - * | |
| 40 | - * @access protected | |
| 41 | - * @var array | |
| 42 | - */ | |
| 43 | - protected $_data; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * Constructor. | |
| 47 | - * | |
| 48 | - * @since 1.0.0 | |
| 49 | - * | |
| 50 | - * @access public | |
| 51 | - * @param array $data The data what has to be associated with this render. | |
| 52 | - */ | |
| 53 | - public function __construct( $data = array() ) { | |
| 54 | - $this->_data = $data; | |
| 55 | - } | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * Returns property associated with the render. | |
| 59 | - * | |
| 60 | - * @since 1.0.0 | |
| 61 | - * | |
| 62 | - * @access public | |
| 63 | - * @param string $name The name of a property. | |
| 64 | - * @return mixed Returns mixed value of a property or NULL if a property doesn't exist. | |
| 65 | - */ | |
| 66 | - public function __get( $name ) { | |
| 67 | - return array_key_exists( $name, $this->_data ) ? $this->_data[$name] : null; | |
| 68 | - } | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * Checks whether the render has specific property or not. | |
| 72 | - * | |
| 73 | - * @since 1.0.0 | |
| 74 | - * | |
| 75 | - * @access public | |
| 76 | - * @param string $name | |
| 77 | - * @return boolean TRUE if the property exists, otherwise FALSE. | |
| 78 | - */ | |
| 79 | - public function __isset( $name ) { | |
| 80 | - return array_key_exists( $name, $this->_data ); | |
| 81 | - } | |
| 82 | - | |
| 83 | - /** | |
| 84 | - * Associates the render with specific property. | |
| 85 | - * | |
| 86 | - * @since 1.0.0 | |
| 87 | - * | |
| 88 | - * @access public | |
| 89 | - * @param string $name The name of a property to associate. | |
| 90 | - * @param mixed $value The value of a property. | |
| 91 | - */ | |
| 92 | - public function __set( $name, $value ) { | |
| 93 | - $this->_data[$name] = $value; | |
| 94 | - } | |
| 95 | - | |
| 96 | - /** | |
| 97 | - * Unassociates specific property from the render. | |
| 98 | - * | |
| 99 | - * @since 1.0.0 | |
| 100 | - * | |
| 101 | - * @access public | |
| 102 | - * @param string $name The name of the property to unassociate. | |
| 103 | - */ | |
| 104 | - public function __unset( $name ) { | |
| 105 | - unset( $this->_data[$name] ); | |
| 106 | - } | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * Renders template. | |
| 110 | - * | |
| 111 | - * @since 1.0.0 | |
| 112 | - * | |
| 113 | - * @abstract | |
| 114 | - * @access protected | |
| 115 | - */ | |
| 116 | - protected abstract function _toHTML(); | |
| 117 | - | |
| 118 | - /** | |
| 119 | - * Builds template and return it as string. | |
| 120 | - * | |
| 121 | - * @since 1.0.0 | |
| 122 | - * | |
| 123 | - * @access public | |
| 124 | - * @return string | |
| 125 | - */ | |
| 126 | - public function toHtml() { | |
| 127 | - ob_start(); | |
| 128 | - $this->_toHTML(); | |
| 129 | - return ob_get_clean(); | |
| 130 | - } | |
| 131 | - | |
| 132 | - /** | |
| 133 | - * Returns built template as string. | |
| 134 | - * | |
| 135 | - * @since 1.0.0 | |
| 136 | - * | |
| 137 | - * @access public | |
| 138 | - * @return type | |
| 139 | - */ | |
| 140 | - public function __toString() { | |
| 141 | - return $this->toHtml(); | |
| 142 | - } | |
| 143 | - | |
| 144 | - /** | |
| 145 | - * Renders the template. | |
| 146 | - * | |
| 147 | - * @since 1.0.0 | |
| 148 | - * | |
| 149 | - * @access public | |
| 150 | - */ | |
| 151 | - public function render() { | |
| 152 | - $this->_toHTML(); | |
| 153 | - } | |
| 154 | - | |
| 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 | + * Abstract render class implements all routine stuff required for template | |
| 25 | + * rendering. | |
| 26 | + * | |
| 27 | + * @category Visualizer | |
| 28 | + * @package Render | |
| 29 | + * | |
| 30 | + * @since 1.0.0 | |
| 31 | + * @abstract | |
| 32 | + */ | |
| 33 | +abstract class Visualizer_Render { | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * The storage of all data associated with this render. | |
| 37 | + * | |
| 38 | + * @since 1.0.0 | |
| 39 | + * | |
| 40 | + * @access protected | |
| 41 | + * @var array | |
| 42 | + */ | |
| 43 | + protected $_data; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Constructor. | |
| 47 | + * | |
| 48 | + * @since 1.0.0 | |
| 49 | + * | |
| 50 | + * @access public | |
| 51 | + * @param array $data The data what has to be associated with this render. | |
| 52 | + */ | |
| 53 | + public function __construct( $data = array() ) { | |
| 54 | + $this->_data = $data; | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Returns property associated with the render. | |
| 59 | + * | |
| 60 | + * @since 1.0.0 | |
| 61 | + * | |
| 62 | + * @access public | |
| 63 | + * @param string $name The name of a property. | |
| 64 | + * @return mixed Returns mixed value of a property or NULL if a property doesn't exist. | |
| 65 | + */ | |
| 66 | + public function __get( $name ) { | |
| 67 | + return array_key_exists( $name, $this->_data ) ? $this->_data[$name] : null; | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Checks whether the render has specific property or not. | |
| 72 | + * | |
| 73 | + * @since 1.0.0 | |
| 74 | + * | |
| 75 | + * @access public | |
| 76 | + * @param string $name | |
| 77 | + * @return boolean TRUE if the property exists, otherwise FALSE. | |
| 78 | + */ | |
| 79 | + public function __isset( $name ) { | |
| 80 | + return array_key_exists( $name, $this->_data ); | |
| 81 | + } | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * Associates the render with specific property. | |
| 85 | + * | |
| 86 | + * @since 1.0.0 | |
| 87 | + * | |
| 88 | + * @access public | |
| 89 | + * @param string $name The name of a property to associate. | |
| 90 | + * @param mixed $value The value of a property. | |
| 91 | + */ | |
| 92 | + public function __set( $name, $value ) { | |
| 93 | + $this->_data[$name] = $value; | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * Unassociates specific property from the render. | |
| 98 | + * | |
| 99 | + * @since 1.0.0 | |
| 100 | + * | |
| 101 | + * @access public | |
| 102 | + * @param string $name The name of the property to unassociate. | |
| 103 | + */ | |
| 104 | + public function __unset( $name ) { | |
| 105 | + unset( $this->_data[$name] ); | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * Renders template. | |
| 110 | + * | |
| 111 | + * @since 1.0.0 | |
| 112 | + * | |
| 113 | + * @abstract | |
| 114 | + * @access protected | |
| 115 | + */ | |
| 116 | + protected abstract function _toHTML(); | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * Builds template and return it as string. | |
| 120 | + * | |
| 121 | + * @since 1.0.0 | |
| 122 | + * | |
| 123 | + * @access public | |
| 124 | + * @return string | |
| 125 | + */ | |
| 126 | + public function toHtml() { | |
| 127 | + ob_start(); | |
| 128 | + $this->_toHTML(); | |
| 129 | + return ob_get_clean(); | |
| 130 | + } | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * Returns built template as string. | |
| 134 | + * | |
| 135 | + * @since 1.0.0 | |
| 136 | + * | |
| 137 | + * @access public | |
| 138 | + * @return type | |
| 139 | + */ | |
| 140 | + public function __toString() { | |
| 141 | + return $this->toHtml(); | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 145 | + * Renders the template. | |
| 146 | + * | |
| 147 | + * @since 1.0.0 | |
| 148 | + * | |
| 149 | + * @access public | |
| 150 | + */ | |
| 151 | + public function render() { | |
| 152 | + $this->_toHTML(); | |
| 153 | + } | |
| 154 | + | |
| 155 | 155 | } |