{\$3}
EOF
);
function PccLayout() {
// nothing to do
}
/* Apply Template function, variable parameter list */
public function applyTemplate($templateName) {
$param = func_get_args();
$template = self::$templates[$templateName];
return $this->applyTemplateString($template, $param);
}
public function applyTemplateString($template, $param) {
// small trick to make class variables available in callback function
$templates = self::$templates;
$self = $this;
$callback = // Start of anonymous callback function
function ($match) use ($param, $templates, $self) {
if ($match[1] == '$') {
if (is_numeric($match[2])) { // Numeric, use parameter $x
$return = (string) $param[$match[2]];
} else { // non-numeric, apply template again
$return = $templates[$match[2]];
if (strpos($return, '{') !== false) {
$return = $self->applyTemplateString($return, $param);
}
}
} else { // does not start with $, eval result
$return = $self->applyTemplateString($match[2]);
$return = eval("return $return;");
}
return $return;
}; // End of anonymous callback function
$return = preg_replace_callback('/\{([$@]?)(((?>[^\{\}]+)|(?R))*)\}/', $callback, $template);
return $return;
}
}
?>