1<?php 2/** 3 * PHPTAL templating engine 4 * 5 * PHP Version 5 6 * 7 * @category HTML 8 * @package PHPTAL 9 * @author Laurent Bedubourg <lbedubourg@motion-twin.com> 10 * @author Kornel Lesiński <kornel@aardvarkmedia.co.uk> 11 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License 12 * @version SVN: $Id$ 13 * @link http://phptal.org/ 14 */ 15/** 16 * Fake template source that makes PHPTAL->setString() work 17 * 18 * @package PHPTAL 19 */ 20class PHPTAL_StringSource implements PHPTAL_Source 21{ 22 const NO_PATH_PREFIX = '<string '; 23 24 public function __construct($data, $realpath = null) 25 { 26 $this->_data = $data; 27 $this->_realpath = $realpath ? $realpath : self::NO_PATH_PREFIX.md5($data).'>'; 28 } 29 30 public function getLastModifiedTime() 31 { 32 if (substr($this->_realpath, 0, 8) !== self::NO_PATH_PREFIX && file_exists($this->_realpath)) { 33 return @filemtime($this->_realpath); 34 } 35 return 0; 36 } 37 38 public function getData() 39 { 40 return $this->_data; 41 } 42 43 /** 44 * well, this is not always a real path. If it starts with self::NO_PATH_PREFIX, then it's fake. 45 */ 46 public function getRealPath() 47 { 48 return $this->_realpath; 49 } 50} 51 52