Thread: [Astrospaces-commits] SF.net SVN: astrospaces: [21] trunk/functions/template.php
Brought to you by:
p3net
From: <cal...@us...> - 2007-07-29 20:49:07
|
Revision: 21 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=21&view=rev Author: caleb870 Date: 2007-07-29 13:49:09 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Removed file/folder Removed Paths: ------------- trunk/functions/template.php Deleted: trunk/functions/template.php =================================================================== --- trunk/functions/template.php 2007-07-29 06:10:45 UTC (rev 20) +++ trunk/functions/template.php 2007-07-29 20:49:09 UTC (rev 21) @@ -1,50 +0,0 @@ -<?php -/******************************************************* - * Copyright (C) 2007 http://p3net.net - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - @id: $Id$ -*********************************************************/ -$this =& new template; -class template -{ - function template($file=null) - { - $this->$file = $file; - } - function set($name, $value) - { - $this->vars[$name] = is_object($value) ? $value->fetch() : $value; - } - function fetch($file = null) - { - if(!$file) $file = $this->file; - - extract($this->vars); - ob_start(); - include('../template/' . $file); - $contents = ob_get_contents(); - ob_end_clean(); - return $contents; - } - function parse($content) - { - $head =& new template('outer.tpl'); - $head->set('title', $title); - $head->set('content', $content); - } -} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-29 20:49:31
|
Revision: 22 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=22&view=rev Author: caleb870 Date: 2007-07-29 13:49:34 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Added items remotely C:\Program Files\xampp\htdocs\code\functions\template.php Added Paths: ----------- trunk/functions/template.php Added: trunk/functions/template.php =================================================================== --- trunk/functions/template.php (rev 0) +++ trunk/functions/template.php 2007-07-29 20:49:34 UTC (rev 22) @@ -0,0 +1,270 @@ +<?php +class template { + + var $template; + var $result; + var $slices; + var $var; + var $lang; + var $lang_prefix = 'lang:'; + + var $start_symbol = '['; + var $end_symbol = ']'; + + var $slice_start = '<!-- START %s -->'; // The %s is required + var $slice_end = '<!-- END %s -->'; // The %s is required + + /* + [FUNCTIONS] + + [ LOADING ] + load_from_file - Load template from a file's contents + $file - The file + load - Load template from a variable in PHP + $template - Variable with template + + [ VARIABLES ] + define_var - Defines a variable + $var_name - Name of variable, overwrites previous + $value - Value of variable + $parent (optional) - Parent of variable. Meant for situations when using slices. + add_to_var - Add to the existing value of a variable + $var_name - Name of variable + $add_what - Add what to the variable + $parent (optional) - Parent of variable. Meant for situations when using slices. + + [ SLICES & SLICE PARSING ] + parse_slice_to_var - Parse the result of a slice to a variable + $slice_name - Name of slice to be parsed + $root_var_name - Name of variable to parse the slice to. + $parent (optional) - Parent of variable. Meant for situations when using slices. + parse_slice - Parse a slice. Returns the result to the caller. + $slice_name - Name of slice to be parsed. + + [ ROOT PARSING ] + parse - Parses the root with echoing the result, yet returning the result to the caller. + (No parameters needed) + pparse - Parses the root and echoes the result. + + [ MISCELLANEOUS ] + flush_template - Drops the current data of template + flush_slice - Drops the current data of the slice + $slice_name - Name of slice to drop + reset_template - Resets the entire template and drops all information. + + [ TERMINOLOGY ] + Slice - A Removable or a part of a template that can be repetitively parsed. + + Root - The core template. Slices must be parsed to a variable in the root + in order to be seen, otherwise they are never printed. + + [ HOW IT WORKS ] + When you load a file, it loads all the slices in the file and removes them + from the root template. When you define a variable, it is only added to + a list of variables to be parsed. They can still be added to before it + is parsed. Once it is parsed it echoes the result and resets it so that + it may be parsed again. + + */ + + function load_from_file ( $file ) + { + @$content = file( $file ); + if ($content === false) + { + return false; + } else { + $this->load(implode(null,$content)); + return true; + } + } + + function load( $template ) + { + $this->slice_start = preg_quote($this->slice_start); + $this->slice_end = preg_quote($this->slice_end); + + $this->start_symbol = preg_quote($this->start_symbol); + $this->end_symbol = preg_quote($this->end_symbol); + + $this->template = $template; + $this->result = $template; + + $this->compile_slices(); // KEEP THIS HERE! + } + + /* Under development + function load_lang_file ( $filename ) + { + @$array = include($filename); + if (!$array = false) + { + $this->lang = array_merge($this->lang, $array); + } else { + echo '<p>Language file could not be loaded</p>'; + } + } + + function langValue ( $var_name ) + { + if ($this->lang[$var_name] != NULL) + { + return $this->lang[$var_name]; + } else { + return false; + } + } + + function langPrefix($name) + { + return $this->lang_prefix . $name; + } + */ + + function slice_start ( $name ) { return sprintf( $this->slice_start, $name); } + + function slice_end ( $name ) { return sprintf( $this->slice_end, $name); } + + function compile_slices ($parent = null) + { + if (!empty($parent)) + { + // Searchs for slices in a specified slice + $regex = '/'. $this->slice_start($slice_name) .'(?:.*)'.$this->slice_start('(.*)').'(?:.*)'.$this->slice_end($slice_name).'/smiU'; + preg_match_all( $regex, $this->template, $sub_slices); + } else { + $regex = '/'.$this->slice_end('(.*)').'/smiU'; + preg_match_all( $regex, $this->template, $sub_slices); + } + foreach ($sub_slices[1] as $slice) + { + if ($this->count_slices($slice) > 0) + { + $this->compile_slices($slice); + } else { + $this->assemble_slice($slice); + } + } + + if (!empty($parent)) + { + $this->assemble_slice($parent); + } + + } + + function assemble_slice ( $slice_name ) + { + $regex = '/'.$this->slice_start($slice_name).'(.*)\n\s*'.$this->slice_end($slice_name).'\n?/si'; + preg_match($regex, $this->template, $resultset); + + if (count($resultset) > 0) + { + $this->slices[$slice_name]['template'] = $resultset[1]; + $this->slices[$slice_name]['result'] = $resultset[1]; + $this->slices[$slice_name]['name'] = $slice_name; + $newTemplate = preg_replace($regex,'',$this->template); + $this->template = $newTemplate; + $this->result = $newTemplate; + } + } + + function count_slices ( $parent ) + { + $regex = '/'.$this->slice_start($parent).'(?:.*)('.$this->slice_start('(.*)').')(?:.*)'.$this->slice_end($parent).'/smi'; + preg_match( $regex, $this->template, $sub_slices ); + $count = count($sub_slices); + return $count; + } + + function define_var ( $var_name, $value, $parent = 'root') + { + $this->slices[$parent]['vars'][$var_name]['name'] = $var_name; + $this->slices[$parent]['vars'][$var_name]['value'] = $value; + } + + function add_to_var ( $var_name, $add_what, $parent = 'root' ) + { + $this->slices[$parent]['vars'][$var_name]['value'] .= $add_what; + } + + function parse_slice_to_var ( $slice_name, $root_var_name, $parent = 'root' ) + { + $content = $this->parse_slice( $slice_name ); + $this->define_var($root_var_name, $content, $parent); + return $parsed_result; + } + + function parse_slice ( $slice_name ) + { + if ($this->slices[$slice_name]['vars'] != Null) + { + foreach($this->slices[$slice_name]['vars'] as $variable) + { + $replacement_regex = '/' . $this->start_symbol . preg_quote($variable['name']).$this->end_symbol.'\n?/si'; + $result = preg_replace( $replacement_regex, $variable['value'], $this->slices["$slice_name"]['result'] ); + $this->slices[$slice_name]['result'] = $result; + } + } + + $replacement_regex = '/'.$this->start_symbol.'(.*)'.$this->end_symbol.'\n?/si'; + $this->slices[$slice_name]['result'] = preg_replace( $replacement_regex, '', $this->slices[$slice_name]['result'] ); + + $parsed_result = $this->slices[$slice_name]['result']; + + $this->flush_slice( $slice_name ); + return $parsed_result; + } + + function parse() + { + if ($this->slices['root']['vars'] != null) + { + foreach($this->slices['root']['vars'] as $variable) + { + $replacement_regex = '/'.$this->start_symbol.$variable['name'].$this->end_symbol.'\n?/si'; + $result = preg_replace($replacement_regex,$variable['value'],$this->result); + $this->result = $result; + } + } + + $replacement_regex = '/'.$this->start_symbol.'(.*)'.$this->end_symbol.'\n?/si'; + $this->result = preg_replace( $replacement_regex, '', $this->result ); + + $parsed_result = $this->result; + + $this->flush_template(); + + return $parsed_result; + } + + function pparse ($die_on_finish = false) + { + echo $this->parse(); + + if ($die_on_finish == true) + { + die(); + } + } + + function flush_template () + { + $this->result = $this->template; + $this->slices['root']['vars'] = null; + } + + function flush_slice ( $slice_name ) + { + $this->slices[$slice_name]['result'] = $this->slices[$slice_name]['template']; + $this->slices[$slice_name]['vars'] = null; + } + + function reset_template () + { + $this->template = null; + $this->result = null; + $this->slices = null; + } +} +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <p3...@us...> - 2007-07-29 21:01:50
|
Revision: 23 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=23&view=rev Author: p3net Date: 2007-07-29 14:01:52 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Add the header to the new template parser Modified Paths: -------------- trunk/functions/template.php Property Changed: ---------------- trunk/functions/template.php Modified: trunk/functions/template.php =================================================================== --- trunk/functions/template.php 2007-07-29 20:49:34 UTC (rev 22) +++ trunk/functions/template.php 2007-07-29 21:01:52 UTC (rev 23) @@ -1,4 +1,23 @@ <?php +/******************************************************* + * Copyright (C) 2007 http://p3net.net + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + @id: $Id $ +*********************************************************/ class template { var $template; Property changes on: trunk/functions/template.php ___________________________________________________________________ Name: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <p3...@us...> - 2007-07-31 02:35:01
|
Revision: 71 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=71&view=rev Author: p3net Date: 2007-07-30 19:34:33 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Fix a few WTFs in the template function and uncomment the todo that someone *hint* should finish Modified Paths: -------------- trunk/functions/template.php Modified: trunk/functions/template.php =================================================================== --- trunk/functions/template.php 2007-07-31 00:57:42 UTC (rev 70) +++ trunk/functions/template.php 2007-07-31 02:34:33 UTC (rev 71) @@ -112,15 +112,14 @@ $this->compile_slices(); // KEEP THIS HERE! } - /* Under development function load_lang_file ( $filename ) { @$array = include($filename); - if (!$array = false) + if ($array === true) { $this->lang = array_merge($this->lang, $array); } else { - echo '<p>Language file could not be loaded</p>'; + $error->general('Language file could not be loaded', $filename); } } @@ -138,7 +137,6 @@ { return $this->lang_prefix . $name; } - */ function slice_start ( $name ) { return sprintf( $this->slice_start, $name); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-08-06 05:15:14
|
Revision: 95 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=95&view=rev Author: caleb870 Date: 2007-08-05 22:15:04 -0700 (Sun, 05 Aug 2007) Log Message: ----------- A complete fix-up of the template system. It's almost done as language files need to be implemented yet. And I MIGHT even work on caching. Modified Paths: -------------- trunk/functions/template.php Modified: trunk/functions/template.php =================================================================== --- trunk/functions/template.php 2007-08-06 05:12:05 UTC (rev 94) +++ trunk/functions/template.php 2007-08-06 05:15:04 UTC (rev 95) @@ -25,13 +25,20 @@ var $slices; var $var; var $lang; - var $lang_prefix = 'lang:'; + var $lang_prefix = 'lang:'; + var $lang_prefix_reg = 'lang:'; + var $slice_prefix_reg = 'slice:'; + var $slice_prefix = 'slice:'; + var $start_symbol_reg = '\['; + var $end_symbol_reg = '\]'; var $start_symbol = '['; var $end_symbol = ']'; - var $slice_start = '<!-- START %s -->'; // The %s is required - var $slice_end = '<!-- END %s -->'; // The %s is required + var $slice_start = '\<\!-- START %s --\>'; // The %s is required + var $slice_end = '\<\!-- END %s --\>'; // The %s is required + var $slice_array; // System-only variable + //var $line_break = '\r\n'; // Only SINGLE quotes /* [FUNCTIONS] @@ -51,8 +58,20 @@ $var_name - Name of variable $add_what - Add what to the variable $parent (optional) - Parent of variable. Meant for situations when using slices. + set - Sets an array or variables. + $var_array - Array of variables to set. Valid input would be like: + array('var_one' => 'value', 'var_two' => 'another value') + $slice_name - Name of slice to set the variables of. Is set to the root template by default. + set_multi - Sets an array of variables to a slice and then parses it. Then sets the next + set of variables, and parses until the array is fully iterated. + Svar_array - Array of variables to set. Valid input would be like: + array(array('var1' => 'value', 'var2' => 'value again'), + array('var1' => 'new value', 'var2' => 'another new value')) + $slice_name - Name of slice to set the variables of. Is set to the root template by default. [ SLICES & SLICE PARSING ] + parse_slice_to_parent - Parses a slices result to it location in it's parent. + $slice_name - Name of slice to parse. parse_slice_to_var - Parse the result of a slice to a variable $slice_name - Name of slice to be parsed $root_var_name - Name of variable to parse the slice to. @@ -100,22 +119,21 @@ function load( $template ) { - $this->slice_start = preg_quote($this->slice_start); - $this->slice_end = preg_quote($this->slice_end); + $template = $this->parse_lang_vars($template); + $this->slices['root']['template'] = $template; + $this->slices['root']['result'] = $template; + $this->slices['root']['name'] = 'root'; + $regex = '/'.$this->slice_start('(.*)').'/smiU'; + preg_match_all($regex, $template, $slice_array); + $this->slice_array = $slice_array[1]; - $this->start_symbol = preg_quote($this->start_symbol); - $this->end_symbol = preg_quote($this->end_symbol); - - $this->template = $template; - $this->result = $template; - $this->compile_slices(); // KEEP THIS HERE! } function load_lang_file ( $filename ) { @$array = include($filename); - if ($array === true) + if ($array != false) { $this->lang = array_merge($this->lang, $array); } else { @@ -123,132 +141,195 @@ } } - function langValue ( $var_name ) + function langData ( $array ) { - if ($this->lang[$var_name] != NULL) - { - return $this->lang[$var_name]; - } else { - return false; - } + $this->lang = array_merge($this->lang, $array); } - function langPrefix($name) + function parse_lang_vars( $input ) { - return $this->lang_prefix . $name; + if (empty($this->lang)) return $input; + + foreach ($this->lang as $name => $value) + { + $input = str_replace($this->start_symbol.$this->lang_prefix.$name.$this->end_symbol, $value, $input); + } + return $input; } - function slice_start ( $name ) { return sprintf( $this->slice_start, $name); } + function slice_start ( $name ) { return sprintf( $this->slice_start, $name); } // System-only function - function slice_end ( $name ) { return sprintf( $this->slice_end, $name); } + function slice_end ( $name ) { return sprintf( $this->slice_end, $name); } // System-only function - function compile_slices ($parent = null) + function determine_parent( $name ) // System-only function. No longer usable after compile_slices(). { - if (!empty($parent)) + $name_reg = preg_quote( $name ); + + if (count($this->slice_array) === 0) return 'root'; + foreach ($this->slice_array as $slice) { - // Searchs for slices in a specified slice - $regex = '/'. $this->slice_start($slice_name) .'(?:.*)'.$this->slice_start('(.*)').'(?:.*)'.$this->slice_end($slice_name).'/smiU'; - preg_match_all( $regex, $this->template, $sub_slices); - } else { - $regex = '/'.$this->slice_end('(.*)').'/smiU'; - preg_match_all( $regex, $this->template, $sub_slices); + $slice_reg = preg_quote($slice); + $regex = '/'.$this->slice_start($slice_reg).'(?:.*)'.$this->slice_start($name_reg).'(?:.*)'.$this->slice_end($slice_reg).'/sm'; + if (preg_match($regex, $this->slices['root']['template'], $results)) + $array[$slice] = strlen($results[0]); } - foreach ($sub_slices[1] as $slice) + + if (count($array) === 0) return 'root'; + foreach ($array as $slice_name => $number) { - if ($this->count_slices($slice) > 0) + if (isset($biggest_num)) { - $this->compile_slices($slice); + if ($number < $biggest_num) + { + $biggest_num = $number; + $biggest_slice = $slice_name; + } } else { - $this->assemble_slice($slice); + $biggest_num = $number; + $biggest_slice = $slice_name; } } - if (!empty($parent)) + return $biggest_slice; + } + + function compile_slices () // System-only function + { + $regex = '/'.$this->slice_end('(.*)').'/smiU'; + preg_match_all( $regex, $this->slices['root']['template'], $sub_slices); + foreach ($sub_slices[1] as $slice) { - $this->assemble_slice($parent); + $this->assemble_slice($slice); } - } - function assemble_slice ( $slice_name ) + function assemble_slice ( $slice_name ) // System-only function { - $regex = '/'.$this->slice_start($slice_name).'(.*)\n\s*'.$this->slice_end($slice_name).'\n?/si'; - preg_match($regex, $this->template, $resultset); + $regex = '/'.$this->slice_start($slice_name).'(.*)\r\n\s*'.$this->slice_end($slice_name).'\s*\r?\n?/si'; + preg_match($regex, $this->slices['root']['template'], $resultset); if (count($resultset) > 0) { $this->slices[$slice_name]['template'] = $resultset[1]; $this->slices[$slice_name]['result'] = $resultset[1]; $this->slices[$slice_name]['name'] = $slice_name; - $newTemplate = preg_replace($regex,'',$this->template); - $this->template = $newTemplate; - $this->result = $newTemplate; + $this->slices[$slice_name]['parent'] = $this->determine_parent(preg_quote($slice_name)); + $newTemplate = preg_replace($regex, $this->start_symbol.$this->slice_prefix.$slice_name.$this->end_symbol."\r\n", $this->slices['root']['template']); + $this->slices['root']['template'] = $newTemplate; + $this->slices['root']['result'] = $newTemplate; } } function count_slices ( $parent ) { $regex = '/'.$this->slice_start($parent).'(?:.*)('.$this->slice_start('(.*)').')(?:.*)'.$this->slice_end($parent).'/smi'; - preg_match( $regex, $this->template, $sub_slices ); + preg_match( $regex, $this->slices['root']['template'], $sub_slices ); $count = count($sub_slices); return $count; } + + function set($var_array, $slice_name = 'root') + { + foreach ($var_array as $name => $value) + { + $this->define_var($name, $value, $slice_name); + } + } + + function set_multi($var_array, $slice_name = 'root') + { + if ($slice_name == 'root') + { + foreach ($var_array as $id => $vars) + { + foreach ($vars as $var_name => $var_value) + { + $this->define_var($var_name, $var_value, $slice_name); + } + $this->pparse(false); + } + } else { + foreach ($var_array as $id => $vars) + { + foreach ($vars as $var_name => $var_value) + { + $this->define_var($var_name, $var_value, $slice_name); + } + $this->parse_slice_to_var($slice_name, $this->slice_prefix.$slice_name, $this->slices[$parent]['parent'], false); + } + } + } function define_var ( $var_name, $value, $parent = 'root') { - $this->slices[$parent]['vars'][$var_name]['name'] = $var_name; - $this->slices[$parent]['vars'][$var_name]['value'] = $value; + $this->slices[$parent]['vars'][$var_name] = $value; } function add_to_var ( $var_name, $add_what, $parent = 'root' ) { - $this->slices[$parent]['vars'][$var_name]['value'] .= $add_what; + $this->slices[$parent]['vars'][$var_name] .= $add_what; } - function parse_slice_to_var ( $slice_name, $root_var_name, $parent = 'root' ) + function parse_slice_to_var ( $slice_name, $root_var_name, $parent = 'root', $overwrite = true ) // Use parse_slice_to_parent instead { $content = $this->parse_slice( $slice_name ); - $this->define_var($root_var_name, $content, $parent); + if ($overwrite) + { + $this->define_var($root_var_name, $content, $parent); + } else { + $this->add_to_var($root_var_name, $content, $this->slices[$slice_name]['parent']); + } return $parsed_result; } + function parse_slice_to_parent ( $slice_name ) + { + $parent = $this->slices[$slice_name]['parent']; + $root_var_name = $this->slice_prefix.$slice_name; + $content = $this->parse_slice( $slice_name ); + $this->add_to_var($root_var_name, $content, $parent); + return $parsed_result; + } + function parse_slice ( $slice_name ) { if ($this->slices[$slice_name]['vars'] != Null) { - foreach($this->slices[$slice_name]['vars'] as $variable) + foreach($this->slices[$slice_name]['vars'] as $name => $value) { - $replacement_regex = '/' . $this->start_symbol . preg_quote($variable['name']).$this->end_symbol.'\n?/si'; - $result = preg_replace( $replacement_regex, $variable['value'], $this->slices["$slice_name"]['result'] ); + $replacement_regex = '/\r?\n?\s*' . $this->start_symbol_reg . preg_quote($name).$this->end_symbol_reg.'\r?\n?/si'; + $result = preg_replace( $replacement_regex, $value, $this->slices[$slice_name]['result'] ); $this->slices[$slice_name]['result'] = $result; } } - $replacement_regex = '/'.$this->start_symbol.'(.*)'.$this->end_symbol.'\n?/si'; + $replacement_regex = '/\r?\n?'.$this->start_symbol_reg.'(.*)'.$this->end_symbol_reg.'\r?\n?/sU'; $this->slices[$slice_name]['result'] = preg_replace( $replacement_regex, '', $this->slices[$slice_name]['result'] ); $parsed_result = $this->slices[$slice_name]['result']; $this->flush_slice( $slice_name ); + /*$parsed_result = str_replace("\n", "\nLF", $parsed_result); + $parsed_result = str_replace("\r", "CR", $parsed_result);*/ return $parsed_result; } - function parse() + function parse () { if ($this->slices['root']['vars'] != null) { - foreach($this->slices['root']['vars'] as $variable) + foreach($this->slices['root']['vars'] as $name => $value) { - $replacement_regex = '/'.$this->start_symbol.$variable['name'].$this->end_symbol.'\n?/si'; - $result = preg_replace($replacement_regex,$variable['value'],$this->result); - $this->result = $result; + $replacement_regex = '/\r?\n?'.$this->start_symbol_reg.preg_quote($name).$this->end_symbol_reg.'\r?\n?/si'; + $result = preg_replace($replacement_regex,$value,$this->slices['root']['result']); + $this->slices['root']['result'] = $result; } } - $replacement_regex = '/'.$this->start_symbol.'(.*)'.$this->end_symbol.'\n?/si'; - $this->result = preg_replace( $replacement_regex, '', $this->result ); + $replacement_regex = '/\r?\n?'.$this->start_symbol_reg.'(.*)'.$this->end_symbol_reg.'\r?\n?/siU'; + $this->slices['root']['result'] = preg_replace( $replacement_regex, '', $this->slices['root']['result'] ); - $parsed_result = $this->result; + $parsed_result = $this->slices['root']['result']; $this->flush_template(); @@ -267,8 +348,8 @@ function flush_template () { - $this->result = $this->template; - $this->slices['root']['vars'] = null; + $this->slices['root']['result'] = $this->slices['root']['template']; + unset($this->slices['root']['vars']); } function flush_slice ( $slice_name ) @@ -279,9 +360,9 @@ function reset_template () { - $this->template = null; - $this->result = null; + $this->slices['root']['template'] = null; + $this->slices['root']['result'] = null; $this->slices = null; } } -?> +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |