protected function resolveCtxDeclarations($string) { $string = str_replace('$$', '__DBLDOLLAR__', $string); preg_match_all('/\\$(?:\\{|\\[)(.*?)(?:\\}|\\])/', $string, $matches); if (!$matches[0]) { return $string; } $replaces = array(); // foreach ${term}, convert it to a PHP statement and resolve // like a TALES expression foreach ($matches[1] as $idx => $attr) { $c = $this->createLocalVariable(); $structure = FALSE; $dump = FALSE; if (strpos($attr, 'structure ') === 0) { $attr = trim(substr($attr, 10)); $structure = TRUE; } if (strpos($attr, 'dump ') === 0) { $attr = trim(substr($attr, 5)); $dump = TRUE; } $str = PXHTMLTales::getInstance()->process($attr, $c . ' = %s;'); if ($structure) { $php_inst = '<' . '?php ' . $str . 'echo ' . $c . '; unset(' . $c . ');' . '?' . '>'; } elseif ($dump) { $php_inst = '<' . '?php ' . $str . 'var_dump(' . $c . '); unset(' . $c . ');' . '?' . '>'; } else { $php_inst = '<' . '?php ' . $str . 'echo htmlspecialchars(' . $c . '); unset(' . $c . ');' . '?' . '>'; } $replaces[$matches[0][$idx]] = $php_inst; } return str_replace('__DBLDOLLAR__', '$', str_replace(array_keys($replaces), array_values($replaces), $string)); }
public function __construct($Dom, $XPath) { $this->Dom = $Dom; $this->XPath = $XPath; $this->Tales = PXHTMLTales::getInstance(); }
public static function registerTales($pfx, $classname) { PXHTMLTales::cfg()->registerTales($pfx, $classname); }