Location: PHPKode > scripts > HoinP > hoinp/hop_node_from_file.php
<?php
/*
«Copyright 2007 Max Barel hide@address.com»
Release : 0.4 ($Rev: 47 $)
$Date: 2007-09-09 15:43:54 +0200 (Dim, 09 sep 2007) $

This file is part of HoP.

HoP is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

HoP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with HoP; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

class Hop_node_from_file extends Hop_node
{
	public $file;
	
	function __construct($file) {
		$this->file = $file;
	}
	
	public function render($indent = '') {
		$text = file_get_contents($this->file);
		// suppress global html to allow insertion of wysiwyg edited html as a chunk
		$text = preg_replace('/^.*< *body[^>]*>/is', '', $text); //from start to body tag
		$text = preg_replace('/< *\/body[^>]*>.*$/is', '', $text); //from /body to end
		$text = preg_replace('/^\t?/m', $indent, trim($text)); //indent the chunk to the current level
		extract($GLOBALS); //for correct substitution of php variable inside the file
		eval ('$text =  "' . addcslashes($text, '"') . '";');
		return "\n$text";
	}
	public static function static_render($file) {
		extract($GLOBALS);
		eval ('$text =  "' . addcslashes(file_get_contents($file), '"') . '";');
		return $text;
	}
}

?>
Return current item: HoinP