@@ -28,5 +28,5 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | function PluginIssetCompile(Compiler $compiler, $var) |
| 30 | 30 | { |
| 31 | - return '(' . $var . ' !== null)'; |
|
| 31 | + return '(' . $var . ' !== null)'; |
|
| 32 | 32 | } |
@@ -36,17 +36,17 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | function PluginEval(Core $dwoo, $var, $assign = null) |
| 38 | 38 | { |
| 39 | - if ($var == '') { |
|
| 40 | - return ''; |
|
| 41 | - } |
|
| 39 | + if ($var == '') { |
|
| 40 | + return ''; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $tpl = new TemplateString($var); |
|
| 44 | - $clone = clone $dwoo; |
|
| 45 | - $out = $clone->get($tpl, $dwoo->readVar('_parent')); |
|
| 43 | + $tpl = new TemplateString($var); |
|
| 44 | + $clone = clone $dwoo; |
|
| 45 | + $out = $clone->get($tpl, $dwoo->readVar('_parent')); |
|
| 46 | 46 | |
| 47 | - if ($assign !== null) { |
|
| 48 | - $dwoo->assignInScope($out, $assign); |
|
| 49 | - } else { |
|
| 50 | - return $out; |
|
| 51 | - } |
|
| 47 | + if ($assign !== null) { |
|
| 48 | + $dwoo->assignInScope($out, $assign); |
|
| 49 | + } else { |
|
| 50 | + return $out; |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -29,47 +29,47 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function PluginLoadTemplatesCompile(Compiler $compiler, $file) |
| 31 | 31 | { |
| 32 | - $file = substr($file, 1, - 1); |
|
| 32 | + $file = substr($file, 1, - 1); |
|
| 33 | 33 | |
| 34 | - if ($file === '') { |
|
| 35 | - return ''; |
|
| 36 | - } |
|
| 34 | + if ($file === '') { |
|
| 35 | + return ''; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
| 39 | - // resource:identifier given, extract them |
|
| 40 | - $resource = $m[1]; |
|
| 41 | - $identifier = $m[2]; |
|
| 42 | - } else { |
|
| 43 | - // get the current template's resource |
|
| 44 | - $resource = $compiler->getDwoo()->getTemplate()->getResourceName(); |
|
| 45 | - $identifier = $file; |
|
| 46 | - } |
|
| 38 | + if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
| 39 | + // resource:identifier given, extract them |
|
| 40 | + $resource = $m[1]; |
|
| 41 | + $identifier = $m[2]; |
|
| 42 | + } else { |
|
| 43 | + // get the current template's resource |
|
| 44 | + $resource = $compiler->getDwoo()->getTemplate()->getResourceName(); |
|
| 45 | + $identifier = $file; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier); |
|
| 48 | + $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier); |
|
| 49 | 49 | |
| 50 | - if ($tpl === null) { |
|
| 51 | - throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
| 52 | - } elseif ($tpl === false) { |
|
| 53 | - throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.'); |
|
| 54 | - } |
|
| 50 | + if ($tpl === null) { |
|
| 51 | + throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
| 52 | + } elseif ($tpl === false) { |
|
| 53 | + throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.'); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $cmp = clone $compiler; |
|
| 57 | - $cmp->compile($compiler->getDwoo(), $tpl); |
|
| 58 | - foreach ($cmp->getTemplatePlugins() as $template => $args) { |
|
| 59 | - $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']); |
|
| 60 | - } |
|
| 61 | - foreach ($cmp->getUsedPlugins() as $plugin => $type) { |
|
| 62 | - $compiler->addUsedPlugin($plugin, $type); |
|
| 63 | - } |
|
| 56 | + $cmp = clone $compiler; |
|
| 57 | + $cmp->compile($compiler->getDwoo(), $tpl); |
|
| 58 | + foreach ($cmp->getTemplatePlugins() as $template => $args) { |
|
| 59 | + $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']); |
|
| 60 | + } |
|
| 61 | + foreach ($cmp->getUsedPlugins() as $plugin => $type) { |
|
| 62 | + $compiler->addUsedPlugin($plugin, $type); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n"; |
|
| 65 | + $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n"; |
|
| 66 | 66 | |
| 67 | - $modCheck = $tpl->getIsModifiedCode(); |
|
| 67 | + $modCheck = $tpl->getIsModifiedCode(); |
|
| 68 | 68 | |
| 69 | - if ($modCheck) { |
|
| 70 | - $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }'; |
|
| 71 | - } else { |
|
| 72 | - $out .= 'try { |
|
| 69 | + if ($modCheck) { |
|
| 70 | + $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }'; |
|
| 71 | + } else { |
|
| 72 | + $out .= 'try { |
|
| 73 | 73 | $tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '"); |
| 74 | 74 | } catch (Dwoo\Exception $e) { |
| 75 | 75 | $this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | elseif ($tpl === false) |
| 80 | 80 | $this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING); |
| 81 | 81 | if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }'; |
| 82 | - } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - return $out; |
|
| 84 | + return $out; |
|
| 85 | 85 | } |
@@ -29,5 +29,5 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | function PluginStringFormatCompile(Compiler $compiler, $value, $format) |
| 31 | 31 | { |
| 32 | - return 'sprintf(' . $format . ',' . $value . ')'; |
|
| 32 | + return 'sprintf(' . $format . ',' . $value . ')'; |
|
| 33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | function PluginDefaultCompile(Compiler $compiler, $value, $default = '') |
| 31 | 31 | { |
| 32 | - return '(($tmp = ' . $value . ')===null||$tmp===\'\' ? ' . $default . ' : $tmp)'; |
|
| 32 | + return '(($tmp = ' . $value . ')===null||$tmp===\'\' ? ' . $default . ' : $tmp)'; |
|
| 33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | function PluginAssignCompile(Compiler $compiler, $value, $var) |
| 31 | 31 | { |
| 32 | - return '$this->assignInScope(' . $value . ', ' . $var . ')'; |
|
| 32 | + return '$this->assignInScope(' . $value . ', ' . $var . ')'; |
|
| 33 | 33 | } |
@@ -28,5 +28,5 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | function PluginUpperCompile(Compiler $compiler, $value) |
| 30 | 30 | { |
| 31 | - return 'mb_strtoupper((string) ' . $value . ', $this->charset)'; |
|
| 31 | + return 'mb_strtoupper((string) ' . $value . ', $this->charset)'; |
|
| 32 | 32 | } |
@@ -28,5 +28,5 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | function PluginSafeCompile(Compiler $compiler, $var) |
| 30 | 30 | { |
| 31 | - return preg_replace('#\(is_string\(\$tmp=(.+)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $var); |
|
| 31 | + return preg_replace('#\(is_string\(\$tmp=(.+)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $var); |
|
| 32 | 32 | } |
@@ -28,5 +28,5 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | function PluginOptionalCompile(Compiler $compiler, $value) |
| 30 | 30 | { |
| 31 | - return $value; |
|
| 31 | + return $value; |
|
| 32 | 32 | } |