public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) { $params = $compiler->getCompiledParams($params); $parsedParams = array(); if (!isset($params['*'])) { $params['*'] = array(); } foreach ($params['*'] as $param => $defValue) { if (is_numeric($param)) { $param = $defValue; $defValue = null; } $param = trim($param, '\'"'); if (!preg_match('#^[a-z0-9_]+$#i', $param)) { throw new CompilationException($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _'); } $parsedParams[$param] = $defValue; } $params['name'] = substr($params['name'], 1, -1); $params['*'] = $parsedParams; $params['uuid'] = uniqid(); $compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']); $currentBlock =& $compiler->getCurrentBlock(); $currentBlock['params'] = $params; return ''; }
public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) { // get block params and save the current template pointer to use it in the postProcessing method $currentBlock =& $compiler->getCurrentBlock(); $currentBlock['params']['tplPointer'] = $compiler->getPointer(); return ''; }
public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) { $params = $compiler->getCompiledParams($params); $func = $params['__funcname']; $pluginType = $params['__functype']; $params = $params['*']; if ($pluginType & Core::CUSTOM_PLUGIN) { $customPlugins = $compiler->getCore()->getCustomPlugins(); $callback = $customPlugins[$func]['callback']; if (is_array($callback)) { if (is_object($callback[0])) { $callback = '$this->customPlugins[\'' . $func . '\'][0]->' . $callback[1] . '('; } else { $callback = '' . $callback[0] . '::' . $callback[1] . '('; } } else { $callback = $callback . '('; } } else { $callback = 'smarty_block_' . $func . '('; } $paramsOut = ''; foreach ($params as $i => $p) { $paramsOut .= var_export($i, true) . ' => ' . $p . ','; } $curBlock =& $compiler->getCurrentBlock(); $curBlock['params']['postOut'] = Compiler::PHP_OPEN . ' $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $callback . '$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);' . Compiler::PHP_CLOSE; return Compiler::PHP_OPEN . $prepend . ' if (!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = array(' . $paramsOut . '); $_block_repeat=true; ' . $callback . '$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();' . Compiler::PHP_CLOSE; }
public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) { if (!isset($params['initialized'])) { return ''; } $block =& $compiler->getCurrentBlock(); $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; return ''; }
public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) { $preContent = ''; while (true) { $preContent .= $compiler->removeTopBlock(); $block =& $compiler->getCurrentBlock(); $reflectionClass = new \ReflectionClass($block['class']); if ($reflectionClass->implementsInterface('Dwoo\\IElseable')) { break; } } $params['initialized'] = true; $compiler->injectBlock($type, $params); return $preContent; }