@@ -22,5 +22,5 @@ |
||
22 | 22 | */ |
23 | 23 | function Dwoo_Plugin_assign_compile(Dwoo_Compiler $compiler, $value, $var) |
24 | 24 | { |
25 | - return '$this->assignInScope('.$value.', '.$var.')'; |
|
25 | + return '$this->assignInScope('.$value.', '.$var.')'; |
|
26 | 26 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function Dwoo_Plugin_upper_compile(Dwoo_Compiler $compiler, $value) |
23 | 23 | { |
24 | - return 'mb_strtoupper((string) '.$value.', $this->charset)'; |
|
24 | + return 'mb_strtoupper((string) '.$value.', $this->charset)'; |
|
25 | 25 | } |
@@ -19,5 +19,5 @@ |
||
19 | 19 | */ |
20 | 20 | function Dwoo_Plugin_eol_compile(Dwoo_Compiler $compiler) |
21 | 21 | { |
22 | - return 'PHP_EOL'; |
|
22 | + return 'PHP_EOL'; |
|
23 | 23 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function Dwoo_Plugin_count_words_compile(Dwoo_Compiler $compiler, $value) |
23 | 23 | { |
24 | - return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', '.$value.', $tmp)'; |
|
24 | + return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', '.$value.', $tmp)'; |
|
25 | 25 | } |
@@ -22,5 +22,5 @@ |
||
22 | 22 | */ |
23 | 23 | function Dwoo_Plugin_string_format_compile(Dwoo_Compiler $compiler, $value, $format) |
24 | 24 | { |
25 | - return 'sprintf('.$format.','.$value.')'; |
|
25 | + return 'sprintf('.$format.','.$value.')'; |
|
26 | 26 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function Dwoo_Plugin_cat_compile(Dwoo_Compiler $compiler, $value, array $rest) |
23 | 23 | { |
24 | - return '('.$value.').('.implode(').(', $rest).')'; |
|
24 | + return '('.$value.').('.implode(').(', $rest).')'; |
|
25 | 25 | } |
@@ -22,32 +22,32 @@ |
||
22 | 22 | */ |
23 | 23 | function Dwoo_Plugin_fetch(Dwoo_Core $dwoo, $file, $assign = null) |
24 | 24 | { |
25 | - if ($file === '') { |
|
26 | - return ''; |
|
27 | - } |
|
25 | + if ($file === '') { |
|
26 | + return ''; |
|
27 | + } |
|
28 | 28 | |
29 | - if ($policy = $dwoo->getSecurityPolicy()) { |
|
30 | - while (true) { |
|
31 | - if (preg_match('{^([a-z]+?)://}i', $file)) { |
|
32 | - $dwoo->triggerError('The security policy prevents you to read files from external sources.', E_USER_WARNING); |
|
33 | - } |
|
29 | + if ($policy = $dwoo->getSecurityPolicy()) { |
|
30 | + while (true) { |
|
31 | + if (preg_match('{^([a-z]+?)://}i', $file)) { |
|
32 | + $dwoo->triggerError('The security policy prevents you to read files from external sources.', E_USER_WARNING); |
|
33 | + } |
|
34 | 34 | |
35 | - $file = realpath($file); |
|
36 | - $dirs = $policy->getAllowedDirectories(); |
|
37 | - foreach ($dirs as $dir => $dummy) { |
|
38 | - if (strpos($file, $dir) === 0) { |
|
39 | - break 2; |
|
40 | - } |
|
41 | - } |
|
42 | - $dwoo->triggerError('The security policy prevents you to read <em>'.$file.'</em>', E_USER_WARNING); |
|
43 | - } |
|
44 | - } |
|
45 | - $file = str_replace(array("\t", "\n", "\r"), array('\\t', '\\n', '\\r'), $file); |
|
35 | + $file = realpath($file); |
|
36 | + $dirs = $policy->getAllowedDirectories(); |
|
37 | + foreach ($dirs as $dir => $dummy) { |
|
38 | + if (strpos($file, $dir) === 0) { |
|
39 | + break 2; |
|
40 | + } |
|
41 | + } |
|
42 | + $dwoo->triggerError('The security policy prevents you to read <em>'.$file.'</em>', E_USER_WARNING); |
|
43 | + } |
|
44 | + } |
|
45 | + $file = str_replace(array("\t", "\n", "\r"), array('\\t', '\\n', '\\r'), $file); |
|
46 | 46 | |
47 | - $out = file_get_contents($file); |
|
47 | + $out = file_get_contents($file); |
|
48 | 48 | |
49 | - if ($assign === null) { |
|
50 | - return $out; |
|
51 | - } |
|
52 | - $dwoo->assignInScope($out, $assign); |
|
49 | + if ($assign === null) { |
|
50 | + return $out; |
|
51 | + } |
|
52 | + $dwoo->assignInScope($out, $assign); |
|
53 | 53 | } |
@@ -21,47 +21,47 @@ discard block |
||
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 | - foreach ($cmp->getTemplatePlugins() as $template => $args) { |
|
51 | - $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']); |
|
52 | - } |
|
53 | - foreach ($cmp->getUsedPlugins() as $plugin => $type) { |
|
54 | - $compiler->addUsedPlugin($plugin, $type); |
|
55 | - } |
|
48 | + $cmp = clone $compiler; |
|
49 | + $cmp->compile($compiler->getDwoo(), $tpl); |
|
50 | + foreach ($cmp->getTemplatePlugins() as $template => $args) { |
|
51 | + $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']); |
|
52 | + } |
|
53 | + foreach ($cmp->getUsedPlugins() as $plugin => $type) { |
|
54 | + $compiler->addUsedPlugin($plugin, $type); |
|
55 | + } |
|
56 | 56 | |
57 | - $out = '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n"; |
|
57 | + $out = '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n"; |
|
58 | 58 | |
59 | - $modCheck = $tpl->getIsModifiedCode(); |
|
59 | + $modCheck = $tpl->getIsModifiedCode(); |
|
60 | 60 | |
61 | - if ($modCheck) { |
|
62 | - $out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }'; |
|
63 | - } else { |
|
64 | - $out .= 'try { |
|
61 | + if ($modCheck) { |
|
62 | + $out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }'; |
|
63 | + } else { |
|
64 | + $out .= 'try { |
|
65 | 65 | $tpl = $this->templateFactory("'.$resource.'", "'.$identifier.'"); |
66 | 66 | } catch (Dwoo_Exception $e) { |
67 | 67 | $this->triggerError(\'Load Templates : Resource <em>'.$resource.'</em> was not added to Dwoo, can not extend <em>'.$identifier.'</em>\', E_USER_WARNING); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | elseif ($tpl === false) |
72 | 72 | $this->triggerError(\'Load Templates : Resource "'.$resource.'" does not support extends.\', E_USER_WARNING); |
73 | 73 | if ($tpl->getUid() != "'.$tpl->getUid().'") { ob_end_clean(); return false; }'; |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | - return $out; |
|
76 | + return $out; |
|
77 | 77 | } |
@@ -23,36 +23,36 @@ |
||
23 | 23 | */ |
24 | 24 | function Dwoo_Plugin_date_format(Dwoo_Core $dwoo, $value, $format = '%b %e, %Y', $default = null) |
25 | 25 | { |
26 | - if (!empty($value)) { |
|
27 | - // convert if it's not a valid unix timestamp |
|
28 | - if (preg_match('#^-?\d{1,10}$#', $value) === 0) { |
|
29 | - $value = strtotime($value); |
|
30 | - } |
|
31 | - } elseif (!empty($default)) { |
|
32 | - // convert if it's not a valid unix timestamp |
|
33 | - if (preg_match('#^-?\d{1,10}$#', $default) === 0) { |
|
34 | - $value = strtotime($default); |
|
35 | - } else { |
|
36 | - $value = $default; |
|
37 | - } |
|
38 | - } else { |
|
39 | - return ''; |
|
40 | - } |
|
26 | + if (!empty($value)) { |
|
27 | + // convert if it's not a valid unix timestamp |
|
28 | + if (preg_match('#^-?\d{1,10}$#', $value) === 0) { |
|
29 | + $value = strtotime($value); |
|
30 | + } |
|
31 | + } elseif (!empty($default)) { |
|
32 | + // convert if it's not a valid unix timestamp |
|
33 | + if (preg_match('#^-?\d{1,10}$#', $default) === 0) { |
|
34 | + $value = strtotime($default); |
|
35 | + } else { |
|
36 | + $value = $default; |
|
37 | + } |
|
38 | + } else { |
|
39 | + return ''; |
|
40 | + } |
|
41 | 41 | |
42 | - // Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin |
|
43 | - if (DIRECTORY_SEPARATOR == '\\') { |
|
44 | - $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
45 | - $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); |
|
46 | - if (strpos($format, '%e') !== false) { |
|
47 | - $_win_from[] = '%e'; |
|
48 | - $_win_to[] = sprintf('%\' 2d', date('j', $value)); |
|
49 | - } |
|
50 | - if (strpos($format, '%l') !== false) { |
|
51 | - $_win_from[] = '%l'; |
|
52 | - $_win_to[] = sprintf('%\' 2d', date('h', $value)); |
|
53 | - } |
|
54 | - $format = str_replace($_win_from, $_win_to, $format); |
|
55 | - } |
|
42 | + // Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin |
|
43 | + if (DIRECTORY_SEPARATOR == '\\') { |
|
44 | + $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
45 | + $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); |
|
46 | + if (strpos($format, '%e') !== false) { |
|
47 | + $_win_from[] = '%e'; |
|
48 | + $_win_to[] = sprintf('%\' 2d', date('j', $value)); |
|
49 | + } |
|
50 | + if (strpos($format, '%l') !== false) { |
|
51 | + $_win_from[] = '%l'; |
|
52 | + $_win_to[] = sprintf('%\' 2d', date('h', $value)); |
|
53 | + } |
|
54 | + $format = str_replace($_win_from, $_win_to, $format); |
|
55 | + } |
|
56 | 56 | |
57 | - return strftime($format, $value); |
|
57 | + return strftime($format, $value); |
|
58 | 58 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | // Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin |
43 | 43 | if (DIRECTORY_SEPARATOR == '\\') { |
44 | - $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
44 | + $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
45 | 45 | $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); |
46 | 46 | if (strpos($format, '%e') !== false) { |
47 | 47 | $_win_from[] = '%e'; |