Test Failed
Pull Request — 1.2 (#90)
by
unknown
02:45
created
lib/plugins/builtin/processors/pre.smarty_compat.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,56 +20,56 @@
 block discarded – undo
20 20
  */
21 21
 class Dwoo_Processor_smarty_compat extends Dwoo_Processor
22 22
 {
23
-    public function process($input)
24
-    {
25
-        list($l, $r) = $this->compiler->getDelimiters();
23
+	public function process($input)
24
+	{
25
+		list($l, $r) = $this->compiler->getDelimiters();
26 26
 
27
-        $rl = preg_quote($l, '/');
28
-        $rr = preg_quote($r, '/');
29
-        $sectionParam = '(?:(name|loop|start|step|max|show)\s*=\s*(\S+))?\s*';
30
-        $input = preg_replace_callback('/'.$rl.'\s*section '.str_repeat($sectionParam, 6).'\s*'.$rr.'(.+?)(?:'.$rl.'\s*sectionelse\s*'.$rr.'(.+?))?'.$rl.'\s*\/section\s*'.$rr.'/is', array($this, 'convertSection'), $input);
31
-        $input = str_replace('$smarty.section.', '$smarty.for.', $input);
27
+		$rl = preg_quote($l, '/');
28
+		$rr = preg_quote($r, '/');
29
+		$sectionParam = '(?:(name|loop|start|step|max|show)\s*=\s*(\S+))?\s*';
30
+		$input = preg_replace_callback('/'.$rl.'\s*section '.str_repeat($sectionParam, 6).'\s*'.$rr.'(.+?)(?:'.$rl.'\s*sectionelse\s*'.$rr.'(.+?))?'.$rl.'\s*\/section\s*'.$rr.'/is', array($this, 'convertSection'), $input);
31
+		$input = str_replace('$smarty.section.', '$smarty.for.', $input);
32 32
 
33
-        $smarty = array(
34
-            '/'.$rl.'\s*ldelim\s*'.$rr.'/',
35
-            '/'.$rl.'\s*rdelim\s*'.$rr.'/',
36
-            '/'.$rl.'\s*\$smarty\.ldelim\s*'.$rr.'/',
37
-            '/'.$rl.'\s*\$smarty\.rdelim\s*'.$rr.'/',
38
-            '/\$smarty\./',
39
-            '/'.$rl.'\s*php\s*'.$rr.'/',
40
-            '/'.$rl.'\s*\/php\s*'.$rr.'/',
41
-            '/\|(@?)strip(\||'.$rr.')/',
42
-            '/'.$rl.'\s*sectionelse\s*'.$rr.'/',
43
-        );
33
+		$smarty = array(
34
+			'/'.$rl.'\s*ldelim\s*'.$rr.'/',
35
+			'/'.$rl.'\s*rdelim\s*'.$rr.'/',
36
+			'/'.$rl.'\s*\$smarty\.ldelim\s*'.$rr.'/',
37
+			'/'.$rl.'\s*\$smarty\.rdelim\s*'.$rr.'/',
38
+			'/\$smarty\./',
39
+			'/'.$rl.'\s*php\s*'.$rr.'/',
40
+			'/'.$rl.'\s*\/php\s*'.$rr.'/',
41
+			'/\|(@?)strip(\||'.$rr.')/',
42
+			'/'.$rl.'\s*sectionelse\s*'.$rr.'/',
43
+		);
44 44
 
45
-        $dwoo = array(
46
-            '\\'.$l,
47
-            $r,
48
-            '\\'.$l,
49
-            $r,
50
-            '$dwoo.',
51
-            '<?php ',
52
-            ' ?>',
53
-            '|$1whitespace$2',
54
-            $l.'else'.$r,
55
-        );
45
+		$dwoo = array(
46
+			'\\'.$l,
47
+			$r,
48
+			'\\'.$l,
49
+			$r,
50
+			'$dwoo.',
51
+			'<?php ',
52
+			' ?>',
53
+			'|$1whitespace$2',
54
+			$l.'else'.$r,
55
+		);
56 56
 
57
-        if (preg_match('{\|@([a-z][a-z0-9_]*)}i', $input, $matches)) {
58
-            trigger_error('The Smarty Compatibility Module has detected that you use |@'.$matches[1].' in your template, this might lead to problems as Dwoo interprets the @ operator differently than Smarty, see http://wiki.dwoo.org/index.php/Syntax#The_.40_Operator', E_USER_NOTICE);
59
-        }
57
+		if (preg_match('{\|@([a-z][a-z0-9_]*)}i', $input, $matches)) {
58
+			trigger_error('The Smarty Compatibility Module has detected that you use |@'.$matches[1].' in your template, this might lead to problems as Dwoo interprets the @ operator differently than Smarty, see http://wiki.dwoo.org/index.php/Syntax#The_.40_Operator', E_USER_NOTICE);
59
+		}
60 60
 
61
-        return preg_replace($smarty, $dwoo, $input);
62
-    }
61
+		return preg_replace($smarty, $dwoo, $input);
62
+	}
63 63
 
64
-    protected function convertSection(array $matches)
65
-    {
66
-        $params = array();
67
-        $index = 1;
68
-        while (!empty($matches[$index]) && $index < 13) {
69
-            $params[$matches[$index]] = $matches[$index + 1];
70
-            $index += 2;
71
-        }
64
+	protected function convertSection(array $matches)
65
+	{
66
+		$params = array();
67
+		$index = 1;
68
+		while (!empty($matches[$index]) && $index < 13) {
69
+			$params[$matches[$index]] = $matches[$index + 1];
70
+			$index += 2;
71
+		}
72 72
 
73
-        return str_replace('['.trim($params['name'], '"\'').']', '[$'.trim($params['name'], '"\'').']', $matches[0]);
74
-    }
73
+		return str_replace('['.trim($params['name'], '"\'').']', '[$'.trim($params['name'], '"\'').']', $matches[0]);
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
         $params = array();
67 67
         $index = 1;
68 68
         while (!empty($matches[$index]) && $index < 13) {
69
-            $params[$matches[$index]] = $matches[$index + 1];
69
+            $params[$matches[$index]] = $matches[$index+1];
70 70
             $index += 2;
71 71
         }
72 72
 
Please login to merge, or discard this patch.
lib/plugins/builtin/blocks/template.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -22,72 +22,72 @@
 block discarded – undo
22 22
  */
23 23
 class Dwoo_Plugin_template extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
24 24
 {
25
-    public function init($name, array $rest = array())
26
-    {
27
-    }
25
+	public function init($name, array $rest = array())
26
+	{
27
+	}
28 28
 
29
-    public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
30
-    {
31
-        $params = $compiler->getCompiledParams($params);
32
-        $parsedParams = array();
33
-        if (!isset($params['*'])) {
34
-            $params['*'] = array();
35
-        }
36
-        foreach ($params['*'] as $param => $defValue) {
37
-            if (is_numeric($param)) {
38
-                $param = $defValue;
39
-                $defValue = null;
40
-            }
41
-            $param = trim($param, '\'"');
42
-            if (!preg_match('#^[a-z0-9_]+$#i', $param)) {
43
-                throw new Dwoo_Compilation_Exception($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _');
44
-            }
45
-            $parsedParams[$param] = $defValue;
46
-        }
47
-        $params['name'] = substr($params['name'], 1, -1);
48
-        $params['*'] = $parsedParams;
49
-        $params['uuid'] = uniqid();
50
-        $compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']);
51
-        $currentBlock = &$compiler->getCurrentBlock();
52
-        $currentBlock['params'] = $params;
29
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
30
+	{
31
+		$params = $compiler->getCompiledParams($params);
32
+		$parsedParams = array();
33
+		if (!isset($params['*'])) {
34
+			$params['*'] = array();
35
+		}
36
+		foreach ($params['*'] as $param => $defValue) {
37
+			if (is_numeric($param)) {
38
+				$param = $defValue;
39
+				$defValue = null;
40
+			}
41
+			$param = trim($param, '\'"');
42
+			if (!preg_match('#^[a-z0-9_]+$#i', $param)) {
43
+				throw new Dwoo_Compilation_Exception($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _');
44
+			}
45
+			$parsedParams[$param] = $defValue;
46
+		}
47
+		$params['name'] = substr($params['name'], 1, -1);
48
+		$params['*'] = $parsedParams;
49
+		$params['uuid'] = uniqid();
50
+		$compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']);
51
+		$currentBlock = &$compiler->getCurrentBlock();
52
+		$currentBlock['params'] = $params;
53 53
 
54
-        return '';
55
-    }
54
+		return '';
55
+	}
56 56
 
57
-    public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
58
-    {
59
-        $paramstr = 'Dwoo_Core $dwoo';
60
-        $init = 'static $_callCnt = 0;'."\n".
61
-        '$dwoo->scope[\' '.$params['uuid'].'\'.$_callCnt] = array();'."\n".
62
-        '$_scope = $dwoo->setScope(array(\' '.$params['uuid'].'\'.($_callCnt++)));'."\n";
63
-        $cleanup = '/* -- template end output */ $dwoo->setScope($_scope, true);';
64
-        foreach ($params['*'] as $param => $defValue) {
65
-            if ($defValue === null) {
66
-                $paramstr .= ', $'.$param;
67
-            } else {
68
-                $paramstr .= ', $'.$param.' = '.$defValue;
69
-            }
70
-            $init .= '$dwoo->scope[\''.$param.'\'] = $'.$param.";\n";
71
-        }
72
-        $init .= '/* -- template start output */';
57
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
58
+	{
59
+		$paramstr = 'Dwoo_Core $dwoo';
60
+		$init = 'static $_callCnt = 0;'."\n".
61
+		'$dwoo->scope[\' '.$params['uuid'].'\'.$_callCnt] = array();'."\n".
62
+		'$_scope = $dwoo->setScope(array(\' '.$params['uuid'].'\'.($_callCnt++)));'."\n";
63
+		$cleanup = '/* -- template end output */ $dwoo->setScope($_scope, true);';
64
+		foreach ($params['*'] as $param => $defValue) {
65
+			if ($defValue === null) {
66
+				$paramstr .= ', $'.$param;
67
+			} else {
68
+				$paramstr .= ', $'.$param.' = '.$defValue;
69
+			}
70
+			$init .= '$dwoo->scope[\''.$param.'\'] = $'.$param.";\n";
71
+		}
72
+		$init .= '/* -- template start output */';
73 73
 
74
-        $funcName = 'Dwoo_Plugin_'.$params['name'];
74
+		$funcName = 'Dwoo_Plugin_'.$params['name'];
75 75
 
76
-        $search = array(
77
-            '$this->charset',
78
-            '$this->',
79
-            '$this,',
80
-        );
81
-        $replacement = array(
82
-            '$dwoo->getCharset()',
83
-            '$dwoo->',
84
-            '$dwoo,',
85
-        );
86
-        $content = str_replace($search, $replacement, $content);
76
+		$search = array(
77
+			'$this->charset',
78
+			'$this->',
79
+			'$this,',
80
+		);
81
+		$replacement = array(
82
+			'$dwoo->getCharset()',
83
+			'$dwoo->',
84
+			'$dwoo,',
85
+		);
86
+		$content = str_replace($search, $replacement, $content);
87 87
 
88
-        $body = 'if (!function_exists(\''.$funcName."')) {\nfunction ".$funcName.'('.$paramstr.') {'."\n$init".Dwoo_Compiler::PHP_CLOSE.
89
-            $prepend.$content.$append.
90
-            Dwoo_Compiler::PHP_OPEN.$cleanup."\n}\n}";
91
-        $compiler->addTemplatePlugin($params['name'], $params['*'], $params['uuid'], $body);
92
-    }
88
+		$body = 'if (!function_exists(\''.$funcName."')) {\nfunction ".$funcName.'('.$paramstr.') {'."\n$init".Dwoo_Compiler::PHP_CLOSE.
89
+			$prepend.$content.$append.
90
+			Dwoo_Compiler::PHP_OPEN.$cleanup."\n}\n}";
91
+		$compiler->addTemplatePlugin($params['name'], $params['*'], $params['uuid'], $body);
92
+	}
93 93
 }
Please login to merge, or discard this patch.
lib/plugins/builtin/functions/load_templates.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -21,61 +21,61 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function Dwoo_Plugin_load_templates_compile(Dwoo_Compiler $compiler, $file)
23 23
 {
24
-    $file = substr($file, 1, -1);
24
+	$file = substr($file, 1, -1);
25 25
 
26
-    if ($file === '') {
27
-        return '';
28
-    }
26
+	if ($file === '') {
27
+		return '';
28
+	}
29 29
 
30
-    if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
31
-        // resource:identifier given, extract them
32
-        $resource = $m[1];
33
-        $identifier = $m[2];
34
-    } else {
35
-        // get the current template's resource
36
-        $resource = $compiler->getDwoo()->getTemplate()->getResourceName();
37
-        $identifier = $file;
38
-    }
30
+	if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
31
+		// resource:identifier given, extract them
32
+		$resource = $m[1];
33
+		$identifier = $m[2];
34
+	} else {
35
+		// get the current template's resource
36
+		$resource = $compiler->getDwoo()->getTemplate()->getResourceName();
37
+		$identifier = $file;
38
+	}
39 39
 
40
-    $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier);
40
+	$tpl = $compiler->getDwoo()->templateFactory($resource, $identifier);
41 41
 
42
-    if ($tpl === null) {
43
-        throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "'.$resource.':'.$identifier.'" not found.');
44
-    } elseif ($tpl === false) {
45
-        throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "'.$resource.'" does not support includes.');
46
-    }
42
+	if ($tpl === null) {
43
+		throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "'.$resource.':'.$identifier.'" not found.');
44
+	} elseif ($tpl === false) {
45
+		throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "'.$resource.'" does not support includes.');
46
+	}
47 47
 
48
-    $cmp = clone $compiler;
49
-    $cmp->compile($compiler->getDwoo(), $tpl);
50
-    $usedTemplates = array($tpl);
51
-    foreach ($cmp->getTemplatePlugins() as $template=>$args) {
52
-        if (isset($args['sourceTpl'])) {
53
-            $sourceTpl = $args['sourceTpl'];
54
-        } else {
55
-            $sourceTpl = $tpl;
56
-        }
48
+	$cmp = clone $compiler;
49
+	$cmp->compile($compiler->getDwoo(), $tpl);
50
+	$usedTemplates = array($tpl);
51
+	foreach ($cmp->getTemplatePlugins() as $template=>$args) {
52
+		if (isset($args['sourceTpl'])) {
53
+			$sourceTpl = $args['sourceTpl'];
54
+		} else {
55
+			$sourceTpl = $tpl;
56
+		}
57 57
 
58
-        $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body'], $sourceTpl);
58
+		$compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body'], $sourceTpl);
59 59
 
60
-        if (!in_array($sourceTpl, $usedTemplates, true)) {
61
-            $usedTemplates[] = $sourceTpl;
62
-        }
63
-    }
64
-    foreach ($cmp->getUsedPlugins() as $plugin=>$type) {
65
-        $compiler->addUsedPlugin($plugin, $type);
66
-    }
60
+		if (!in_array($sourceTpl, $usedTemplates, true)) {
61
+			$usedTemplates[] = $sourceTpl;
62
+		}
63
+	}
64
+	foreach ($cmp->getUsedPlugins() as $plugin=>$type) {
65
+		$compiler->addUsedPlugin($plugin, $type);
66
+	}
67 67
 
68
-    $out = '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n";
68
+	$out = '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n";
69 69
 
70
-    foreach ($usedTemplates AS $usedTemplate) {
71
-        $modCheck = $usedTemplate->getIsModifiedCode();
70
+	foreach ($usedTemplates AS $usedTemplate) {
71
+		$modCheck = $usedTemplate->getIsModifiedCode();
72 72
 
73
-        if ($modCheck) {
74
-            $out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }';
75
-        } else {
76
-            $usedTemplateResourceName = $usedTemplate->getResourceName();
77
-            $usedTemplateResourceIdentifier = $usedTemplate->getResourceIdentifier();
78
-            $out .= '
73
+		if ($modCheck) {
74
+			$out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }';
75
+		} else {
76
+			$usedTemplateResourceName = $usedTemplate->getResourceName();
77
+			$usedTemplateResourceIdentifier = $usedTemplate->getResourceIdentifier();
78
+			$out .= '
79 79
 try {
80 80
 	$tpl = $this->templateFactory("'.$usedTemplateResourceName.'", "'.$usedTemplateResourceIdentifier.'");
81 81
 } catch (Dwoo_Exception $e) {
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 elseif ($tpl === false)
87 87
 	$this->triggerError(\'Load Templates : Resource "'.$usedTemplateResourceName.'" does not support extends.\', E_USER_WARNING);
88 88
 if ($tpl->getUid() != "'.$usedTemplate->getUid().'") { ob_end_clean(); return false; }';
89
-        }
90
-    }
89
+		}
90
+	}
91 91
 
92
-    return $out;
92
+	return $out;
93 93
 }
Please login to merge, or discard this patch.