Completed
Branch master (b65d76)
by David
04:29
created
lib/Dwoo/Plugins/Functions/PluginCycle.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -34,56 +34,56 @@
 block discarded – undo
34 34
  */
35 35
 class PluginCycle extends Plugin
36 36
 {
37
-    protected $cycles = array();
37
+	protected $cycles = array();
38 38
 
39
-    /**
40
-     * @param string $name
41
-     * @param null   $values
42
-     * @param bool   $print
43
-     * @param bool   $advance
44
-     * @param string $delimiter
45
-     * @param null   $assign
46
-     * @param bool   $reset
47
-     *
48
-     * @return null
49
-     */
50
-    public function process($name = 'default', $values = null, $print = true, $advance = true, $delimiter = ',', $assign = null, $reset = false)
51
-    {
52
-        if ($values !== null) {
53
-            if (is_string($values)) {
54
-                $values = explode($delimiter, $values);
55
-            }
39
+	/**
40
+	 * @param string $name
41
+	 * @param null   $values
42
+	 * @param bool   $print
43
+	 * @param bool   $advance
44
+	 * @param string $delimiter
45
+	 * @param null   $assign
46
+	 * @param bool   $reset
47
+	 *
48
+	 * @return null
49
+	 */
50
+	public function process($name = 'default', $values = null, $print = true, $advance = true, $delimiter = ',', $assign = null, $reset = false)
51
+	{
52
+		if ($values !== null) {
53
+			if (is_string($values)) {
54
+				$values = explode($delimiter, $values);
55
+			}
56 56
 
57
-            if (!isset($this->cycles[$name]) || $this->cycles[$name]['values'] !== $values) {
58
-                $this->cycles[$name]['index'] = 0;
59
-            }
57
+			if (!isset($this->cycles[$name]) || $this->cycles[$name]['values'] !== $values) {
58
+				$this->cycles[$name]['index'] = 0;
59
+			}
60 60
 
61
-            $this->cycles[$name]['values'] = array_values($values);
62
-        } elseif (isset($this->cycles[$name])) {
63
-            $values = $this->cycles[$name]['values'];
64
-        }
61
+			$this->cycles[$name]['values'] = array_values($values);
62
+		} elseif (isset($this->cycles[$name])) {
63
+			$values = $this->cycles[$name]['values'];
64
+		}
65 65
 
66
-        if ($reset) {
67
-            $this->cycles[$name]['index'] = 0;
68
-        }
66
+		if ($reset) {
67
+			$this->cycles[$name]['index'] = 0;
68
+		}
69 69
 
70
-        if ($print) {
71
-            $out = $values[$this->cycles[$name]['index']];
72
-        } else {
73
-            $out = null;
74
-        }
70
+		if ($print) {
71
+			$out = $values[$this->cycles[$name]['index']];
72
+		} else {
73
+			$out = null;
74
+		}
75 75
 
76
-        if ($advance) {
77
-            if ($this->cycles[$name]['index'] >= count($values) - 1) {
78
-                $this->cycles[$name]['index'] = 0;
79
-            } else {
80
-                ++ $this->cycles[$name]['index'];
81
-            }
82
-        }
76
+		if ($advance) {
77
+			if ($this->cycles[$name]['index'] >= count($values) - 1) {
78
+				$this->cycles[$name]['index'] = 0;
79
+			} else {
80
+				++ $this->cycles[$name]['index'];
81
+			}
82
+		}
83 83
 
84
-        if ($assign === null) {
85
-            return $out;
86
-        }
87
-        $this->core->assignInScope($out, $assign);
88
-    }
84
+		if ($assign === null) {
85
+			return $out;
86
+		}
87
+		$this->core->assignInScope($out, $assign);
88
+	}
89 89
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginExtendsCheckCompile.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function PluginExtendsCheckCompile(Compiler $compiler, $file)
28 28
 {
29
-    preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m);
30
-    $resource   = $m[1];
31
-    $identifier = $m[2];
29
+	preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m);
30
+	$resource   = $m[1];
31
+	$identifier = $m[2];
32 32
 
33
-    $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier);
33
+	$tpl = $compiler->getDwoo()->templateFactory($resource, $identifier);
34 34
 
35
-    if ($tpl === null) {
36
-        throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
37
-    } elseif ($tpl === false) {
38
-        throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.');
39
-    }
35
+	if ($tpl === null) {
36
+		throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
37
+	} elseif ($tpl === false) {
38
+		throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.');
39
+	}
40 40
 
41
-    $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
41
+	$out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
42 42
 
43
-    $modCheck = $tpl->getIsModifiedCode();
43
+	$modCheck = $tpl->getIsModifiedCode();
44 44
 
45
-    if ($modCheck) {
46
-        $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
47
-    } else {
48
-        $out .= 'try {
45
+	if ($modCheck) {
46
+		$out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
47
+	} else {
48
+		$out .= 'try {
49 49
 	$tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '");
50 50
 } catch (Dwoo\Exception $e) {
51 51
 	$this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 elseif ($tpl === false)
56 56
 	$this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING);
57 57
 if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }';
58
-    }
58
+	}
59 59
 
60
-    return $out;
60
+	return $out;
61 61
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginWhitespaceCompile.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,5 +37,5 @@
 block discarded – undo
37 37
  */
38 38
 function PluginWhitespaceCompile(Compiler $compiler, $value, $with = ' ')
39 39
 {
40
-    return "preg_replace('#\s+#'.(strcasecmp(\$this->charset, 'utf-8')===0?'u':''), $with, $value)";
40
+	return "preg_replace('#\s+#'.(strcasecmp(\$this->charset, 'utf-8')===0?'u':''), $with, $value)";
41 41
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginWordwrapCompile.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,5 +31,5 @@
 block discarded – undo
31 31
  */
32 32
 function PluginWordwrapCompile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false)
33 33
 {
34
-    return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')';
34
+	return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')';
35 35
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginCountSentencesCompile.php 1 patch
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 PluginCountSentencesCompile(Compiler $compiler, $value)
30 30
 {
31
-    return "preg_match_all('#[\w\pL]\.(?![\w\pL])#u', $value, \$tmp)";
31
+	return "preg_match_all('#[\w\pL]\.(?![\w\pL])#u', $value, \$tmp)";
32 32
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginTruncate.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -33,25 +33,25 @@
 block discarded – undo
33 33
  */
34 34
 function PluginTruncate(Core $dwoo, $value, $length = 80, $etc = '...', $break = false, $middle = false)
35 35
 {
36
-    if ($length == 0) {
37
-        return '';
38
-    }
36
+	if ($length == 0) {
37
+		return '';
38
+	}
39 39
 
40
-    $value  = (string)$value;
41
-    $etc    = (string)$etc;
42
-    $length = (int)$length;
40
+	$value  = (string)$value;
41
+	$etc    = (string)$etc;
42
+	$length = (int)$length;
43 43
 
44
-    if (strlen($value) < $length) {
45
-        return $value;
46
-    }
44
+	if (strlen($value) < $length) {
45
+		return $value;
46
+	}
47 47
 
48
-    $length = max($length - strlen($etc), 0);
49
-    if ($break === false && $middle === false) {
50
-        $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1));
51
-    }
52
-    if ($middle === false) {
53
-        return substr($value, 0, $length) . $etc;
54
-    }
48
+	$length = max($length - strlen($etc), 0);
49
+	if ($break === false && $middle === false) {
50
+		$value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1));
51
+	}
52
+	if ($middle === false) {
53
+		return substr($value, 0, $length) . $etc;
54
+	}
55 55
 
56
-    return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2));
56
+	return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2));
57 57
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginTifCompile.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -34,56 +34,56 @@
 block discarded – undo
34 34
  */
35 35
 function PluginTifCompile(Compiler $compiler, array $rest, array $tokens)
36 36
 {
37
-    // load if plugin
38
-    if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
39
-        try {
40
-            $compiler->getDwoo()->getLoader()->loadPlugin('if');
41
-        }
42
-        catch (Exception $e) {
43
-            throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
44
-        }
45
-    }
37
+	// load if plugin
38
+	if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
39
+		try {
40
+			$compiler->getDwoo()->getLoader()->loadPlugin('if');
41
+		}
42
+		catch (Exception $e) {
43
+			throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
44
+		}
45
+	}
46 46
 
47
-    if (count($rest) == 1) {
48
-        return $rest[0];
49
-    }
47
+	if (count($rest) == 1) {
48
+		return $rest[0];
49
+	}
50 50
 
51
-    // fetch false result and remove the ":" if it was present
52
-    $falseResult = array_pop($rest);
51
+	// fetch false result and remove the ":" if it was present
52
+	$falseResult = array_pop($rest);
53 53
 
54
-    if (trim(end($rest), '"\'') === ':') {
55
-        // remove the ':' if present
56
-        array_pop($rest);
57
-    } elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
58
-        if ($falseResult === '?' || $falseResult === ':') {
59
-            throw new CompilationException($compiler, 'Tif: incomplete tif statement, value missing after ' . $falseResult);
60
-        }
61
-        // there was in fact no false result provided, so we move it to be the true result instead
62
-        $trueResult  = $falseResult;
63
-        $falseResult = "''";
64
-    }
54
+	if (trim(end($rest), '"\'') === ':') {
55
+		// remove the ':' if present
56
+		array_pop($rest);
57
+	} elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
58
+		if ($falseResult === '?' || $falseResult === ':') {
59
+			throw new CompilationException($compiler, 'Tif: incomplete tif statement, value missing after ' . $falseResult);
60
+		}
61
+		// there was in fact no false result provided, so we move it to be the true result instead
62
+		$trueResult  = $falseResult;
63
+		$falseResult = "''";
64
+	}
65 65
 
66
-    // fetch true result if needed
67
-    if (!isset($trueResult)) {
68
-        $trueResult = array_pop($rest);
69
-        // no true result provided so we use the expression arg
70
-        if ($trueResult === '?') {
71
-            $trueResult = true;
72
-        }
73
-    }
66
+	// fetch true result if needed
67
+	if (!isset($trueResult)) {
68
+		$trueResult = array_pop($rest);
69
+		// no true result provided so we use the expression arg
70
+		if ($trueResult === '?') {
71
+			$trueResult = true;
72
+		}
73
+	}
74 74
 
75
-    // remove the '?' if present
76
-    if (trim(end($rest), '"\'') === '?') {
77
-        array_pop($rest);
78
-    }
75
+	// remove the '?' if present
76
+	if (trim(end($rest), '"\'') === '?') {
77
+		array_pop($rest);
78
+	}
79 79
 
80
-    // check params were correctly provided
81
-    if (empty($rest) || $trueResult === null || $falseResult === null) {
82
-        throw new CompilationException($compiler, 'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>');
83
-    }
80
+	// check params were correctly provided
81
+	if (empty($rest) || $trueResult === null || $falseResult === null) {
82
+		throw new CompilationException($compiler, 'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>');
83
+	}
84 84
 
85
-    // parse condition
86
-    $condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
85
+	// parse condition
86
+	$condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
87 87
 
88
-    return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ', $condition) : $trueResult) . ' : ' . $falseResult . ')';
88
+	return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ', $condition) : $trueResult) . ' : ' . $falseResult . ')';
89 89
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginReplaceCompile.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@
 block discarded – undo
30 30
  */
31 31
 function PluginReplaceCompile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true)
32 32
 {
33
-    if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
34
-        return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')';
35
-    } else {
36
-        return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')';
37
-    }
33
+	if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
34
+		return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')';
35
+	} else {
36
+		return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')';
37
+	}
38 38
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginCountParagraphsCompile.php 1 patch
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 PluginCountParagraphsCompile(Compiler $compiler, $value)
30 30
 {
31
-    return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)';
31
+	return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)';
32 32
 }
Please login to merge, or discard this patch.