Completed
Push — master ( bf2930...494091 )
by David
07:08 queued 03:26
created
lib/Dwoo/Block/Plugin.php 2 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -28,92 +28,92 @@
 block discarded – undo
28 28
  */
29 29
 abstract class Plugin extends DwooPlugin
30 30
 {
31
-    /**
32
-     * Stores the contents of the block while it runs.
33
-     *
34
-     * @var string
35
-     */
36
-    protected $buffer = '';
31
+	/**
32
+	 * Stores the contents of the block while it runs.
33
+	 *
34
+	 * @var string
35
+	 */
36
+	protected $buffer = '';
37 37
 
38
-    /**
39
-     * Buffers input, override only if necessary.
40
-     *
41
-     * @var string the content that must be buffered
42
-     */
43
-    public function buffer($input)
44
-    {
45
-        $this->buffer .= $input;
46
-    }
38
+	/**
39
+	 * Buffers input, override only if necessary.
40
+	 *
41
+	 * @var string the content that must be buffered
42
+	 */
43
+	public function buffer($input)
44
+	{
45
+		$this->buffer .= $input;
46
+	}
47 47
 
48
-    // initialization code, receives the parameters from {block param1 param2}
49
-    // public function init($arg, $arg, ...);
48
+	// initialization code, receives the parameters from {block param1 param2}
49
+	// public function init($arg, $arg, ...);
50 50
 
51
-    /**
52
-     * Called when the block ends, this is most of the time followed right away by a call
53
-     * of <em>process()</em> but not always, so this should be used to do any shutdown operations on the
54
-     * block object, if required.
55
-     */
56
-    public function end()
57
-    {
58
-    }
51
+	/**
52
+	 * Called when the block ends, this is most of the time followed right away by a call
53
+	 * of <em>process()</em> but not always, so this should be used to do any shutdown operations on the
54
+	 * block object, if required.
55
+	 */
56
+	public function end()
57
+	{
58
+	}
59 59
 
60
-    /**
61
-     * Called when the block output is required by a parent block.
62
-     * this must read $this->buffer and return it processed
63
-     *
64
-     * @return string
65
-     */
66
-    public function process()
67
-    {
68
-        return $this->buffer;
69
-    }
60
+	/**
61
+	 * Called when the block output is required by a parent block.
62
+	 * this must read $this->buffer and return it processed
63
+	 *
64
+	 * @return string
65
+	 */
66
+	public function process()
67
+	{
68
+		return $this->buffer;
69
+	}
70 70
 
71
-    /**
72
-     * Called at compile time to define what the block should output in the compiled template code, happens when the
73
-     * block is declared basically this will replace the {block arg arg arg} tag in the template.
74
-     *
75
-     * @param DwooCompiler $compiler the compiler instance that calls this function
76
-     * @param array        $params   an array containing original and compiled parameters
77
-     * @param string       $prepend  that is just meant to allow a child class to call
78
-     *                               parent::postProcessing($compiler, $params, "foo();") to add a command before the
79
-     *                               default commands are executed parent::postProcessing($compiler, $params, "foo();")
80
-     *                               to add a command before the default commands are executed
81
-     * @param string       $append   that is just meant to allow a child class to call
82
-     *                               parent::postProcessing($compiler, $params, null, "foo();") to add a command after
83
-     *                               the default commands are executed parent::postProcessing($compiler, $params, null,
84
-     *                               "foo();") to add a command after the default commands are executed
85
-     * @param string       $type     the type is the plugin class name used
86
-     *
87
-     * @return string
88
-     */
89
-    public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type)
90
-    {
91
-        return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE;
92
-    }
71
+	/**
72
+	 * Called at compile time to define what the block should output in the compiled template code, happens when the
73
+	 * block is declared basically this will replace the {block arg arg arg} tag in the template.
74
+	 *
75
+	 * @param DwooCompiler $compiler the compiler instance that calls this function
76
+	 * @param array        $params   an array containing original and compiled parameters
77
+	 * @param string       $prepend  that is just meant to allow a child class to call
78
+	 *                               parent::postProcessing($compiler, $params, "foo();") to add a command before the
79
+	 *                               default commands are executed parent::postProcessing($compiler, $params, "foo();")
80
+	 *                               to add a command before the default commands are executed
81
+	 * @param string       $append   that is just meant to allow a child class to call
82
+	 *                               parent::postProcessing($compiler, $params, null, "foo();") to add a command after
83
+	 *                               the default commands are executed parent::postProcessing($compiler, $params, null,
84
+	 *                               "foo();") to add a command after the default commands are executed
85
+	 * @param string       $type     the type is the plugin class name used
86
+	 *
87
+	 * @return string
88
+	 */
89
+	public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type)
90
+	{
91
+		return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE;
92
+	}
93 93
 
94
-    /**
95
-     * Called at compile time to define what the block should output in the compiled template code, happens when the
96
-     * block is ended basically this will replace the {/block} tag in the template.
97
-     *
98
-     * @see preProcessing
99
-     *
100
-     * @param DwooCompiler $compiler the compiler instance that calls this function
101
-     * @param array        $params   an array containing original and compiled parameters, see preProcessing() for more
102
-     *                               details more details
103
-     * @param string       $prepend  that is just meant to allow a child class to call
104
-     *                               parent::postProcessing($compiler, $params, "foo();") to add a command before the
105
-     *                               default commands are executed parent::postProcessing($compiler, $params, "foo();")
106
-     *                               to add a command before the default commands are executed
107
-     * @param string       $append   that is just meant to allow a child class to call
108
-     *                               parent::postProcessing($compiler, $params, null, "foo();") to add a command after
109
-     *                               the default commands are executed parent::postProcessing($compiler, $params, null,
110
-     *                               "foo();") to add a command after the default commands are executed
111
-     * @param string       $content  the entire content of the block being closed
112
-     *
113
-     * @return string
114
-     */
115
-    public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content)
116
-    {
117
-        return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE;
118
-    }
94
+	/**
95
+	 * Called at compile time to define what the block should output in the compiled template code, happens when the
96
+	 * block is ended basically this will replace the {/block} tag in the template.
97
+	 *
98
+	 * @see preProcessing
99
+	 *
100
+	 * @param DwooCompiler $compiler the compiler instance that calls this function
101
+	 * @param array        $params   an array containing original and compiled parameters, see preProcessing() for more
102
+	 *                               details more details
103
+	 * @param string       $prepend  that is just meant to allow a child class to call
104
+	 *                               parent::postProcessing($compiler, $params, "foo();") to add a command before the
105
+	 *                               default commands are executed parent::postProcessing($compiler, $params, "foo();")
106
+	 *                               to add a command before the default commands are executed
107
+	 * @param string       $append   that is just meant to allow a child class to call
108
+	 *                               parent::postProcessing($compiler, $params, null, "foo();") to add a command after
109
+	 *                               the default commands are executed parent::postProcessing($compiler, $params, null,
110
+	 *                               "foo();") to add a command after the default commands are executed
111
+	 * @param string       $content  the entire content of the block being closed
112
+	 *
113
+	 * @return string
114
+	 */
115
+	public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content)
116
+	{
117
+		return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type)
90 90
     {
91
-        return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE;
91
+        return DwooCompiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.DwooCompiler::implode_r($compiler->getCompiledParams($params)).'));'.$append.DwooCompiler::PHP_CLOSE;
92 92
     }
93 93
 
94 94
     /**
@@ -114,6 +114,6 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content)
116 116
     {
117
-        return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE;
117
+        return $content.DwooCompiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.DwooCompiler::PHP_CLOSE;
118 118
     }
119 119
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginEolCompile.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,5 +25,5 @@
 block discarded – undo
25 25
  */
26 26
 function PluginEolCompile(Compiler $compiler)
27 27
 {
28
-    return 'PHP_EOL';
28
+	return 'PHP_EOL';
29 29
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginCapitalize.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@
 block discarded – undo
29 29
  */
30 30
 function PluginCapitalize(Core $dwoo, $value, $numwords = false)
31 31
 {
32
-    if ($numwords || preg_match('#^[^0-9]+$#', $value)) {
33
-        return mb_convert_case((string)$value, MB_CASE_TITLE, $dwoo->getCharset());
34
-    } else {
35
-        $bits = explode(' ', (string)$value);
36
-        $out  = '';
37
-        while (list(, $v) = each($bits)) {
38
-            if (preg_match('#^[^0-9]+$#', $v)) {
39
-                $out .= ' ' . mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset());
40
-            } else {
41
-                $out .= ' ' . $v;
42
-            }
43
-        }
32
+	if ($numwords || preg_match('#^[^0-9]+$#', $value)) {
33
+		return mb_convert_case((string)$value, MB_CASE_TITLE, $dwoo->getCharset());
34
+	} else {
35
+		$bits = explode(' ', (string)$value);
36
+		$out  = '';
37
+		while (list(, $v) = each($bits)) {
38
+			if (preg_match('#^[^0-9]+$#', $v)) {
39
+				$out .= ' ' . mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset());
40
+			} else {
41
+				$out .= ' ' . $v;
42
+			}
43
+		}
44 44
 
45
-        return substr($out, 1);
46
-    }
45
+		return substr($out, 1);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@
 block discarded – undo
30 30
 function PluginCapitalize(Core $dwoo, $value, $numwords = false)
31 31
 {
32 32
     if ($numwords || preg_match('#^[^0-9]+$#', $value)) {
33
-        return mb_convert_case((string)$value, MB_CASE_TITLE, $dwoo->getCharset());
33
+        return mb_convert_case((string) $value, MB_CASE_TITLE, $dwoo->getCharset());
34 34
     } else {
35
-        $bits = explode(' ', (string)$value);
35
+        $bits = explode(' ', (string) $value);
36 36
         $out  = '';
37 37
         while (list(, $v) = each($bits)) {
38 38
             if (preg_match('#^[^0-9]+$#', $v)) {
39
-                $out .= ' ' . mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset());
39
+                $out .= ' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset());
40 40
             } else {
41
-                $out .= ' ' . $v;
41
+                $out .= ' '.$v;
42 42
             }
43 43
         }
44 44
 
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginInclude.php 3 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -36,58 +36,58 @@
 block discarded – undo
36 36
  */
37 37
 function PluginInclude(Core $dwoo, $file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array())
38 38
 {
39
-    if ($file === '') {
40
-        return '';
41
-    }
39
+	if ($file === '') {
40
+		return '';
41
+	}
42 42
 
43
-    if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
44
-        // resource:identifier given, extract them
45
-        $resource   = $m[1];
46
-        $identifier = $m[2];
47
-    } else {
48
-        // get the current template's resource
49
-        $resource   = $dwoo->getTemplate()->getResourceName();
50
-        $identifier = $file;
51
-    }
43
+	if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
44
+		// resource:identifier given, extract them
45
+		$resource   = $m[1];
46
+		$identifier = $m[2];
47
+	} else {
48
+		// get the current template's resource
49
+		$resource   = $dwoo->getTemplate()->getResourceName();
50
+		$identifier = $file;
51
+	}
52 52
 
53
-    try {
54
-        $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
55
-    }
56
-    catch (SecurityException $e) {
57
-        $dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING);
58
-    }
59
-    catch (Exception $e) {
60
-        $dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING);
61
-    }
53
+	try {
54
+		$include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
55
+	}
56
+	catch (SecurityException $e) {
57
+		$dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING);
58
+	}
59
+	catch (Exception $e) {
60
+		$dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING);
61
+	}
62 62
 
63
-    if ($include === null) {
64
-        $dwoo->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', E_USER_WARNING);
65
-    } elseif ($include === false) {
66
-        $dwoo->triggerError('Include : Resource "' . $resource . '" does not support includes.', E_USER_WARNING);
67
-    }
63
+	if ($include === null) {
64
+		$dwoo->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', E_USER_WARNING);
65
+	} elseif ($include === false) {
66
+		$dwoo->triggerError('Include : Resource "' . $resource . '" does not support includes.', E_USER_WARNING);
67
+	}
68 68
 
69
-    if (is_string($data)) {
70
-        $vars = $dwoo->readVar($data);
71
-    } else {
72
-        $vars = $data;
73
-    }
69
+	if (is_string($data)) {
70
+		$vars = $dwoo->readVar($data);
71
+	} else {
72
+		$vars = $data;
73
+	}
74 74
 
75
-    if (count($rest)) {
76
-        $vars = $rest + $vars;
77
-    }
75
+	if (count($rest)) {
76
+		$vars = $rest + $vars;
77
+	}
78 78
 
79
-    $clone = clone $dwoo;
80
-    $out   = $clone->get($include, $vars);
79
+	$clone = clone $dwoo;
80
+	$out   = $clone->get($include, $vars);
81 81
 
82
-    if ($assign !== null) {
83
-        $dwoo->assignInScope($out, $assign);
84
-    }
82
+	if ($assign !== null) {
83
+		$dwoo->assignInScope($out, $assign);
84
+	}
85 85
 
86
-    foreach ($clone->getReturnValues() as $name => $value) {
87
-        $dwoo->assignInScope($value, $name);
88
-    }
86
+	foreach ($clone->getReturnValues() as $name => $value) {
87
+		$dwoo->assignInScope($value, $name);
88
+	}
89 89
 
90
-    if ($assign === null) {
91
-        return $out;
92
-    }
90
+	if ($assign === null) {
91
+		return $out;
92
+	}
93 93
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
         $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
55 55
     }
56 56
     catch (SecurityException $e) {
57
-        $dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING);
57
+        $dwoo->triggerError('Include : Security restriction : '.$e->getMessage(), E_USER_WARNING);
58 58
     }
59 59
     catch (Exception $e) {
60
-        $dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING);
60
+        $dwoo->triggerError('Include : '.$e->getMessage(), E_USER_WARNING);
61 61
     }
62 62
 
63 63
     if ($include === null) {
64
-        $dwoo->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', E_USER_WARNING);
64
+        $dwoo->triggerError('Include : Resource "'.$resource.':'.$identifier.'" not found.', E_USER_WARNING);
65 65
     } elseif ($include === false) {
66
-        $dwoo->triggerError('Include : Resource "' . $resource . '" does not support includes.', E_USER_WARNING);
66
+        $dwoo->triggerError('Include : Resource "'.$resource.'" does not support includes.', E_USER_WARNING);
67 67
     }
68 68
 
69 69
     if (is_string($data)) {
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     }
74 74
 
75 75
     if (count($rest)) {
76
-        $vars = $rest + $vars;
76
+        $vars = $rest+$vars;
77 77
     }
78 78
 
79 79
     $clone = clone $dwoo;
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,11 +52,9 @@
 block discarded – undo
52 52
 
53 53
     try {
54 54
         $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
55
-    }
56
-    catch (SecurityException $e) {
55
+    } catch (SecurityException $e) {
57 56
         $dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING);
58
-    }
59
-    catch (Exception $e) {
57
+    } catch (Exception $e) {
60 58
         $dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING);
61 59
     }
62 60
 
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginCountWordsCompile.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
  */
29 29
 function PluginCountWordsCompile(Compiler $compiler, $value)
30 30
 {
31
-    return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', ' . $value . ', $tmp)';
31
+	return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', ' . $value . ', $tmp)';
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
  */
29 29
 function PluginCountWordsCompile(Compiler $compiler, $value)
30 30
 {
31
-    return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', ' . $value . ', $tmp)';
31
+    return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', '.$value.', $tmp)';
32 32
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginIndentCompile.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,5 +30,5 @@
 block discarded – undo
30 30
  */
31 31
 function PluginIndentCompile(Compiler $compiler, $value, $by = 4, $char = ' ')
32 32
 {
33
-    return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)";
33
+	return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)";
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,5 +30,5 @@
 block discarded – undo
30 30
  */
31 31
 function PluginIndentCompile(Compiler $compiler, $value, $by = 4, $char = ' ')
32 32
 {
33
-    return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)";
33
+    return "preg_replace('#^#m', '".str_repeat(substr($char, 1, - 1), trim($by, '"\''))."', $value)";
34 34
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginCountCharactersCompile.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@
 block discarded – undo
29 29
  */
30 30
 function PluginCountCharactersCompile(Compiler $compiler, $value, $count_spaces = false)
31 31
 {
32
-    if ($count_spaces === 'false') {
33
-        return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)';
34
-    } else {
35
-        return 'mb_strlen(' . $value . ', $this->charset)';
36
-    }
32
+	if ($count_spaces === 'false') {
33
+		return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)';
34
+	} else {
35
+		return 'mb_strlen(' . $value . ', $this->charset)';
36
+	}
37 37
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@
 block discarded – undo
30 30
 function PluginCountCharactersCompile(Compiler $compiler, $value, $count_spaces = false)
31 31
 {
32 32
     if ($count_spaces === 'false') {
33
-        return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)';
33
+        return 'preg_match_all(\'#[^\s\pZ]#u\', '.$value.', $tmp)';
34 34
     } else {
35
-        return 'mb_strlen(' . $value . ', $this->charset)';
35
+        return 'mb_strlen('.$value.', $this->charset)';
36 36
     }
37 37
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginExtends.php 3 patches
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -34,28 +34,28 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class PluginExtends extends Plugin implements ICompilable
36 36
 {
37
-    protected static $childSource;
38
-    protected static $regex;
39
-    protected static $l;
40
-    protected static $r;
41
-    protected static $lastReplacement;
42
-
43
-    public function process()
44
-    {
45
-    }
46
-
47
-    /**
48
-     * @param Compiler $compiler
49
-     * @param          $file
50
-     *
51
-     * @throws CompilationException
52
-     */
53
-    public static function compile(Compiler $compiler, $file)
54
-    {
55
-        list($l, $r) = $compiler->getDelimiters();
56
-        self::$l     = preg_quote($l, '/');
57
-        self::$r     = preg_quote($r, '/');
58
-        self::$regex = '/
37
+	protected static $childSource;
38
+	protected static $regex;
39
+	protected static $l;
40
+	protected static $r;
41
+	protected static $lastReplacement;
42
+
43
+	public function process()
44
+	{
45
+	}
46
+
47
+	/**
48
+	 * @param Compiler $compiler
49
+	 * @param          $file
50
+	 *
51
+	 * @throws CompilationException
52
+	 */
53
+	public static function compile(Compiler $compiler, $file)
54
+	{
55
+		list($l, $r) = $compiler->getDelimiters();
56
+		self::$l     = preg_quote($l, '/');
57
+		self::$r     = preg_quote($r, '/');
58
+		self::$regex = '/
59 59
 			' . self::$l . 'block\s(["\']?)(.+?)\1' . self::$r . '(?:\r?\n?)
60 60
 			((?:
61 61
 				(?R)
@@ -70,137 +70,137 @@  discard block
 block discarded – undo
70 70
 			' . self::$l . '\/block' . self::$r . '
71 71
 			/six';
72 72
 
73
-        if ($compiler->getLooseOpeningHandling()) {
74
-            self::$l .= '\s*';
75
-            self::$r = '\s*' . self::$r;
76
-        }
77
-        $inheritanceTree = array(array('source' => $compiler->getTemplateSource()));
78
-        $curPath         = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
79
-        $curTpl          = $compiler->getDwoo()->getTemplate();
80
-
81
-        while (!empty($file)) {
82
-            if ($file === '""' || $file === "''" || (substr($file, 0, 1) !== '"' && substr($file, 0, 1) !== '\'')) {
83
-                throw new CompilationException($compiler, 'Extends : The file name must be a non-empty string');
84
-            }
85
-
86
-            if (preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m)) {
87
-                // resource:identifier given, extract them
88
-                $resource   = $m[1];
89
-                $identifier = $m[2];
90
-            } else {
91
-                // get the current template's resource
92
-                $resource   = $curTpl->getResourceName();
93
-                $identifier = substr($file, 1, - 1);
94
-            }
95
-
96
-            try {
97
-                $parent = $compiler->getDwoo()->templateFactory($resource, $identifier, null, null, null, $curTpl);
98
-            }
99
-            catch (SecurityException $e) {
100
-                throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage());
101
-            }
102
-            catch (Exception $e) {
103
-                throw new CompilationException($compiler, 'Extends : ' . $e->getMessage());
104
-            }
105
-
106
-            if ($parent === null) {
107
-                throw new CompilationException($compiler, 'Extends : Resource "' . $resource . ':' . $identifier . '" not found.');
108
-            } elseif ($parent === false) {
109
-                throw new CompilationException($compiler, 'Extends : Resource "' . $resource . '" does not support extends.');
110
-            }
111
-
112
-            $curTpl    = $parent;
113
-            $newParent = array(
114
-                'source'     => $parent->getSource(),
115
-                'resource'   => $resource,
116
-                'identifier' => $parent->getResourceIdentifier(),
117
-                'uid'        => $parent->getUid()
118
-            );
119
-            if (array_search($newParent, $inheritanceTree, true) !== false) {
120
-                throw new CompilationException($compiler, 'Extends : Recursive template inheritance detected');
121
-            }
122
-            $inheritanceTree[] = $newParent;
123
-
124
-            if (preg_match('/^' . self::$l . 'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?' . self::$r . '/i', $parent->getSource(), $match)) {
125
-                $curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
126
-                if (isset($match[2]) && $match[2] == '"') {
127
-                    $file = '"' . str_replace('"', '\\"', substr($match[1], 1, - 1)) . '"';
128
-                } elseif (isset($match[2]) && $match[2] == "'") {
129
-                    $file = '"' . substr($match[1], 1, - 1) . '"';
130
-                } else {
131
-                    $file = '"' . $match[1] . '"';
132
-                }
133
-            } else {
134
-                $file = false;
135
-            }
136
-        }
137
-
138
-        while (true) {
139
-            $parent                = array_pop($inheritanceTree);
140
-            $child                 = end($inheritanceTree);
141
-            self::$childSource     = $child['source'];
142
-            self::$lastReplacement = count($inheritanceTree) === 1;
143
-            if (!isset($newSource)) {
144
-                $newSource = $parent['source'];
145
-            }
146
-            $newSource = preg_replace_callback(self::$regex, array(
147
-                'Dwoo\Plugins\Functions\PluginExtends',
148
-                'replaceBlock'
149
-            ), $newSource);
150
-            $newSource = $l . 'do extendsCheck(' . var_export($parent['resource'] . ':' . $parent['identifier'], true) . ')' . $r . $newSource;
151
-
152
-            if (self::$lastReplacement) {
153
-                break;
154
-            }
155
-        }
156
-        $compiler->setTemplateSource($newSource);
157
-        $compiler->recompile();
158
-    }
159
-
160
-    /**
161
-     * @param array $matches
162
-     *
163
-     * @return mixed|string
164
-     */
165
-    protected static function replaceBlock(array $matches)
166
-    {
167
-        $matches[3] = self::removeTrailingNewline($matches[3]);
168
-
169
-        if (preg_match_all(self::$regex, self::$childSource, $override) && in_array($matches[2], $override[2])) {
170
-            $key      = array_search($matches[2], $override[2]);
171
-            $override = self::removeTrailingNewline($override[3][$key]);
172
-
173
-            $l = stripslashes(self::$l);
174
-            $r = stripslashes(self::$r);
175
-
176
-            if (self::$lastReplacement) {
177
-                return preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override);
178
-            }
179
-
180
-            return $l . 'block ' . $matches[1] . $matches[2] . $matches[1] . $r . preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override) . $l . '/block' . $r;
181
-        }
182
-
183
-        if (preg_match(self::$regex, $matches[3])) {
184
-            return preg_replace_callback(self::$regex, array(
185
-                'Dwoo\Plugins\Functions\PluginExtends',
186
-                'replaceBlock'
187
-            ), $matches[3]);
188
-        }
189
-
190
-        if (self::$lastReplacement) {
191
-            return $matches[3];
192
-        }
193
-
194
-        return $matches[0];
195
-    }
196
-
197
-    /**
198
-     * @param $text
199
-     *
200
-     * @return string
201
-     */
202
-    protected static function removeTrailingNewline($text)
203
-    {
204
-        return substr($text, - 1) === "\n" ? substr($text, - 2, 1) === "\r" ? substr($text, 0, - 2) : substr($text, 0, - 1) : $text;
205
-    }
73
+		if ($compiler->getLooseOpeningHandling()) {
74
+			self::$l .= '\s*';
75
+			self::$r = '\s*' . self::$r;
76
+		}
77
+		$inheritanceTree = array(array('source' => $compiler->getTemplateSource()));
78
+		$curPath         = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
79
+		$curTpl          = $compiler->getDwoo()->getTemplate();
80
+
81
+		while (!empty($file)) {
82
+			if ($file === '""' || $file === "''" || (substr($file, 0, 1) !== '"' && substr($file, 0, 1) !== '\'')) {
83
+				throw new CompilationException($compiler, 'Extends : The file name must be a non-empty string');
84
+			}
85
+
86
+			if (preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m)) {
87
+				// resource:identifier given, extract them
88
+				$resource   = $m[1];
89
+				$identifier = $m[2];
90
+			} else {
91
+				// get the current template's resource
92
+				$resource   = $curTpl->getResourceName();
93
+				$identifier = substr($file, 1, - 1);
94
+			}
95
+
96
+			try {
97
+				$parent = $compiler->getDwoo()->templateFactory($resource, $identifier, null, null, null, $curTpl);
98
+			}
99
+			catch (SecurityException $e) {
100
+				throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage());
101
+			}
102
+			catch (Exception $e) {
103
+				throw new CompilationException($compiler, 'Extends : ' . $e->getMessage());
104
+			}
105
+
106
+			if ($parent === null) {
107
+				throw new CompilationException($compiler, 'Extends : Resource "' . $resource . ':' . $identifier . '" not found.');
108
+			} elseif ($parent === false) {
109
+				throw new CompilationException($compiler, 'Extends : Resource "' . $resource . '" does not support extends.');
110
+			}
111
+
112
+			$curTpl    = $parent;
113
+			$newParent = array(
114
+				'source'     => $parent->getSource(),
115
+				'resource'   => $resource,
116
+				'identifier' => $parent->getResourceIdentifier(),
117
+				'uid'        => $parent->getUid()
118
+			);
119
+			if (array_search($newParent, $inheritanceTree, true) !== false) {
120
+				throw new CompilationException($compiler, 'Extends : Recursive template inheritance detected');
121
+			}
122
+			$inheritanceTree[] = $newParent;
123
+
124
+			if (preg_match('/^' . self::$l . 'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?' . self::$r . '/i', $parent->getSource(), $match)) {
125
+				$curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
126
+				if (isset($match[2]) && $match[2] == '"') {
127
+					$file = '"' . str_replace('"', '\\"', substr($match[1], 1, - 1)) . '"';
128
+				} elseif (isset($match[2]) && $match[2] == "'") {
129
+					$file = '"' . substr($match[1], 1, - 1) . '"';
130
+				} else {
131
+					$file = '"' . $match[1] . '"';
132
+				}
133
+			} else {
134
+				$file = false;
135
+			}
136
+		}
137
+
138
+		while (true) {
139
+			$parent                = array_pop($inheritanceTree);
140
+			$child                 = end($inheritanceTree);
141
+			self::$childSource     = $child['source'];
142
+			self::$lastReplacement = count($inheritanceTree) === 1;
143
+			if (!isset($newSource)) {
144
+				$newSource = $parent['source'];
145
+			}
146
+			$newSource = preg_replace_callback(self::$regex, array(
147
+				'Dwoo\Plugins\Functions\PluginExtends',
148
+				'replaceBlock'
149
+			), $newSource);
150
+			$newSource = $l . 'do extendsCheck(' . var_export($parent['resource'] . ':' . $parent['identifier'], true) . ')' . $r . $newSource;
151
+
152
+			if (self::$lastReplacement) {
153
+				break;
154
+			}
155
+		}
156
+		$compiler->setTemplateSource($newSource);
157
+		$compiler->recompile();
158
+	}
159
+
160
+	/**
161
+	 * @param array $matches
162
+	 *
163
+	 * @return mixed|string
164
+	 */
165
+	protected static function replaceBlock(array $matches)
166
+	{
167
+		$matches[3] = self::removeTrailingNewline($matches[3]);
168
+
169
+		if (preg_match_all(self::$regex, self::$childSource, $override) && in_array($matches[2], $override[2])) {
170
+			$key      = array_search($matches[2], $override[2]);
171
+			$override = self::removeTrailingNewline($override[3][$key]);
172
+
173
+			$l = stripslashes(self::$l);
174
+			$r = stripslashes(self::$r);
175
+
176
+			if (self::$lastReplacement) {
177
+				return preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override);
178
+			}
179
+
180
+			return $l . 'block ' . $matches[1] . $matches[2] . $matches[1] . $r . preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override) . $l . '/block' . $r;
181
+		}
182
+
183
+		if (preg_match(self::$regex, $matches[3])) {
184
+			return preg_replace_callback(self::$regex, array(
185
+				'Dwoo\Plugins\Functions\PluginExtends',
186
+				'replaceBlock'
187
+			), $matches[3]);
188
+		}
189
+
190
+		if (self::$lastReplacement) {
191
+			return $matches[3];
192
+		}
193
+
194
+		return $matches[0];
195
+	}
196
+
197
+	/**
198
+	 * @param $text
199
+	 *
200
+	 * @return string
201
+	 */
202
+	protected static function removeTrailingNewline($text)
203
+	{
204
+		return substr($text, - 1) === "\n" ? substr($text, - 2, 1) === "\r" ? substr($text, 0, - 2) : substr($text, 0, - 1) : $text;
205
+	}
206 206
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -56,26 +56,26 @@  discard block
 block discarded – undo
56 56
         self::$l     = preg_quote($l, '/');
57 57
         self::$r     = preg_quote($r, '/');
58 58
         self::$regex = '/
59
-			' . self::$l . 'block\s(["\']?)(.+?)\1' . self::$r . '(?:\r?\n?)
59
+			' . self::$l.'block\s(["\']?)(.+?)\1'.self::$r.'(?:\r?\n?)
60 60
 			((?:
61 61
 				(?R)
62 62
 				|
63
-				[^' . self::$l . ']*
63
+				[^' . self::$l.']*
64 64
 				(?:
65
-					(?! ' . self::$l . '\/?block\b )
66
-					' . self::$l . '
67
-					[^' . self::$l . ']*+
65
+					(?! ' . self::$l.'\/?block\b )
66
+					' . self::$l.'
67
+					[^' . self::$l.']*+
68 68
 				)*
69 69
 			)*)
70
-			' . self::$l . '\/block' . self::$r . '
70
+			' . self::$l.'\/block'.self::$r.'
71 71
 			/six';
72 72
 
73 73
         if ($compiler->getLooseOpeningHandling()) {
74 74
             self::$l .= '\s*';
75
-            self::$r = '\s*' . self::$r;
75
+            self::$r = '\s*'.self::$r;
76 76
         }
77 77
         $inheritanceTree = array(array('source' => $compiler->getTemplateSource()));
78
-        $curPath         = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
78
+        $curPath         = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()).DIRECTORY_SEPARATOR;
79 79
         $curTpl          = $compiler->getDwoo()->getTemplate();
80 80
 
81 81
         while (!empty($file)) {
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
                 $parent = $compiler->getDwoo()->templateFactory($resource, $identifier, null, null, null, $curTpl);
98 98
             }
99 99
             catch (SecurityException $e) {
100
-                throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage());
100
+                throw new CompilationException($compiler, 'Extends : Security restriction : '.$e->getMessage());
101 101
             }
102 102
             catch (Exception $e) {
103
-                throw new CompilationException($compiler, 'Extends : ' . $e->getMessage());
103
+                throw new CompilationException($compiler, 'Extends : '.$e->getMessage());
104 104
             }
105 105
 
106 106
             if ($parent === null) {
107
-                throw new CompilationException($compiler, 'Extends : Resource "' . $resource . ':' . $identifier . '" not found.');
107
+                throw new CompilationException($compiler, 'Extends : Resource "'.$resource.':'.$identifier.'" not found.');
108 108
             } elseif ($parent === false) {
109
-                throw new CompilationException($compiler, 'Extends : Resource "' . $resource . '" does not support extends.');
109
+                throw new CompilationException($compiler, 'Extends : Resource "'.$resource.'" does not support extends.');
110 110
             }
111 111
 
112 112
             $curTpl    = $parent;
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
             }
122 122
             $inheritanceTree[] = $newParent;
123 123
 
124
-            if (preg_match('/^' . self::$l . 'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?' . self::$r . '/i', $parent->getSource(), $match)) {
125
-                $curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
124
+            if (preg_match('/^'.self::$l.'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?'.self::$r.'/i', $parent->getSource(), $match)) {
125
+                $curPath = dirname($identifier).DIRECTORY_SEPARATOR;
126 126
                 if (isset($match[2]) && $match[2] == '"') {
127
-                    $file = '"' . str_replace('"', '\\"', substr($match[1], 1, - 1)) . '"';
127
+                    $file = '"'.str_replace('"', '\\"', substr($match[1], 1, - 1)).'"';
128 128
                 } elseif (isset($match[2]) && $match[2] == "'") {
129
-                    $file = '"' . substr($match[1], 1, - 1) . '"';
129
+                    $file = '"'.substr($match[1], 1, - 1).'"';
130 130
                 } else {
131
-                    $file = '"' . $match[1] . '"';
131
+                    $file = '"'.$match[1].'"';
132 132
                 }
133 133
             } else {
134 134
                 $file = false;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                 'Dwoo\Plugins\Functions\PluginExtends',
148 148
                 'replaceBlock'
149 149
             ), $newSource);
150
-            $newSource = $l . 'do extendsCheck(' . var_export($parent['resource'] . ':' . $parent['identifier'], true) . ')' . $r . $newSource;
150
+            $newSource = $l.'do extendsCheck('.var_export($parent['resource'].':'.$parent['identifier'], true).')'.$r.$newSource;
151 151
 
152 152
             if (self::$lastReplacement) {
153 153
                 break;
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
             $r = stripslashes(self::$r);
175 175
 
176 176
             if (self::$lastReplacement) {
177
-                return preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override);
177
+                return preg_replace('/'.self::$l.'\$dwoo\.parent'.self::$r.'/is', $matches[3], $override);
178 178
             }
179 179
 
180
-            return $l . 'block ' . $matches[1] . $matches[2] . $matches[1] . $r . preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override) . $l . '/block' . $r;
180
+            return $l.'block '.$matches[1].$matches[2].$matches[1].$r.preg_replace('/'.self::$l.'\$dwoo\.parent'.self::$r.'/is', $matches[3], $override).$l.'/block'.$r;
181 181
         }
182 182
 
183 183
         if (preg_match(self::$regex, $matches[3])) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -95,11 +95,9 @@
 block discarded – undo
95 95
 
96 96
             try {
97 97
                 $parent = $compiler->getDwoo()->templateFactory($resource, $identifier, null, null, null, $curTpl);
98
-            }
99
-            catch (SecurityException $e) {
98
+            } catch (SecurityException $e) {
100 99
                 throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage());
101
-            }
102
-            catch (Exception $e) {
100
+            } catch (Exception $e) {
103 101
                 throw new CompilationException($compiler, 'Extends : ' . $e->getMessage());
104 102
             }
105 103
 
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginReturnCompile.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@
 block discarded – undo
34 34
  */
35 35
 function PluginReturnCompile(Compiler $compiler, array $rest = array())
36 36
 {
37
-    $out = array();
38
-    foreach ($rest as $var => $val) {
39
-        $out[] = '$this->setReturnValue(' . var_export($var, true) . ', ' . $val . ')';
40
-    }
37
+	$out = array();
38
+	foreach ($rest as $var => $val) {
39
+		$out[] = '$this->setReturnValue(' . var_export($var, true) . ', ' . $val . ')';
40
+	}
41 41
 
42
-    return '(' . implode('.', $out) . ')';
42
+	return '(' . implode('.', $out) . ')';
43 43
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@
 block discarded – undo
36 36
 {
37 37
     $out = array();
38 38
     foreach ($rest as $var => $val) {
39
-        $out[] = '$this->setReturnValue(' . var_export($var, true) . ', ' . $val . ')';
39
+        $out[] = '$this->setReturnValue('.var_export($var, true).', '.$val.')';
40 40
     }
41 41
 
42
-    return '(' . implode('.', $out) . ')';
42
+    return '('.implode('.', $out).')';
43 43
 }
Please login to merge, or discard this patch.