| verzia 1.10, 2002/08/02 20:55:36 |
verzia 1.11, 2002/08/04 18:15:50 |
| Riadok 141 class phpTemplate |
|
| Riadok 141 class phpTemplate |
|
| function _stringTransform($string) |
function _stringTransform($string) |
| { |
{ |
| // TODO: this is absolutely wrong!!! |
// TODO: this is absolutely wrong!!! |
| $string = str_replace(stripslashes($this->_tag['end']), |
$string = str_replace($this->_tag['end_striped'], $this->_tag['end_striped'] . "\n", $string); |
| stripslashes($this->_tag['end']) . "\n", $string); |
|
| //$regexp = $this->_tag['begin'] . '(([^&][^>])*.?)' . $this->_tag['end'];// . '[\n]?'; |
|
| $regexp = $this->_tag['begin'] . '(.+)' . $this->_tag['end'] . '[\n]'; |
$regexp = $this->_tag['begin'] . '(.+)' . $this->_tag['end'] . '[\n]'; |
| $array = preg_split("/$regexp/im", $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
$array = preg_split("/$regexp/im", $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| |
|
| for ($i = 1; $i < count($array); $i += 2) { |
for ($i = 1; $i < count($array); $i += 2) { |
| |
|
| Riadok 221 class phpTemplate |
|
| Riadok 219 class phpTemplate |
|
| } |
} |
| } |
} |
| } else { |
} else { |
| // Yeah, we will *not* check, if it is stupid template variable |
|
| // if (preg_match('/^[a-zA-Z_][\w\d_]*$/', $key)) |
|
| if ($type == PHP_TEMPLATE_SET_CODE) { |
if ($type == PHP_TEMPLATE_SET_CODE) { |
| /* |
/* |
| $this->_set_vars[$key] = array($value); |
$this->_set_vars[$key] = array($value); |
| Riadok 237 class phpTemplate |
|
| Riadok 233 class phpTemplate |
|
| } elseif ($type == PHP_TEMPLATE_SET_PARSE) { |
} elseif ($type == PHP_TEMPLATE_SET_PARSE) { |
| // TODO: lots of work |
// TODO: lots of work |
| $ar = $this->_stringTransform($value); |
$ar = $this->_stringTransform($value); |
| |
if (0) { |
| |
echo '<hr><hr><hr><hr>'; |
| |
echo '<hr><pre><font color=white>SETTING PARSE<br>KEY = '.$key.'<br>VALUE = '.htmlentities($value).'<br>'; |
| |
echo 'AFTER _sT = '; |
| |
ob_start(); |
| |
var_dump($ar); |
| |
$xx = ob_get_contents(); |
| |
ob_end_clean(); |
| |
echo htmlentities($xx); |
| |
echo '</font></pre><hr>'; |
| |
//exit; |
| |
} |
| $this->_array = array_merge( |
$this->_array = array_merge( |
| array('', 'ob_start();'), $ar, |
array('', 'ob_start();'), $ar, |
| array('$'.$key.'=ob_get_contents();ob_end_clean();'), |
array('$'.$key.'=ob_get_contents();ob_end_clean();'), |
| Riadok 253 class phpTemplate |
|
| Riadok 260 class phpTemplate |
|
| |
|
| function getParse() |
function getParse() |
| { |
{ |
| $ret = $this->_tag['begin_striped'] . $this->_tag['command_striped']; |
$ret = ''; |
| |
|
| foreach ($this->_set_vars as $key => $val) { |
foreach ($this->_set_vars as $key => $val) { |
| if (is_array($this->_set_vars[$key])) { |
if (is_array($this->_set_vars[$key])) { |
| $ret .= $val[0]; |
$ret .= $val[0]; |
| Riadok 265 class phpTemplate |
|
| Riadok 271 class phpTemplate |
|
| } |
} |
| } |
} |
| |
|
| $ret .= $this->_tag['end_striped']; |
$ret = $this->_tag['begin_striped'] |
| |
. $this->_tag['command_striped'] |
| |
. str_replace("\n", '\'."\n".\'', $ret) |
| |
. $this->_tag['end_striped'] . "\n"; |
| |
|
| for ($i = 0; $i < count($this->_array); $i++) { |
for ($i = 0; $i < count($this->_array); $i++) { |
| if ($i & 1) { |
if ($i & 1) { |
| $ret .= $this->_tag['begin_striped'] |
$ret .= $this->_tag['begin_striped'] |
| . $this->_tag['command_striped'] |
. $this->_tag['command_striped'] |
| . $this->_array[$i] |
. str_replace("\n", '\'."\n".\'', $this->_array[$i]) |
| . $this->_tag['end_striped']; |
. $this->_tag['end_striped']; |
| } else { |
} else { |
| $ret .= $this->_array[$i]; |
$ret .= $this->_array[$i]; |
| Riadok 282 class phpTemplate |
|
| Riadok 291 class phpTemplate |
|
| echo htmlentities($ret); |
echo htmlentities($ret); |
| echo "</pre>"; |
echo "</pre>"; |
| exit; |
exit; |
| */ |
*/ |
| return $ret; |
return $ret; |
| } |
} |
| |
|