@@ -24,5 +24,5 @@ |
||
24 | 24 | */ |
25 | 25 | function Dwoo_Plugin_wordwrap_compile(Dwoo_Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
26 | 26 | { |
27 | - return 'wordwrap('.$value.','.$length.','.$break.','.$cut.')'; |
|
27 | + return 'wordwrap('.$value.','.$length.','.$break.','.$cut.')'; |
|
28 | 28 | } |
@@ -33,99 +33,99 @@ |
||
33 | 33 | */ |
34 | 34 | function Dwoo_Plugin_math_compile(Dwoo_Compiler $compiler, $equation, $format = '', $assign = '', array $rest = array()) |
35 | 35 | { |
36 | - /* |
|
36 | + /* |
|
37 | 37 | * Holds the allowed function, characters, operators and constants |
38 | 38 | */ |
39 | - $allowed = array( |
|
40 | - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
|
41 | - '+', '-', '/', '*', '.', ' ', '<<', '>>', '%', '&', '^', '|', '~', |
|
42 | - 'abs(', 'ceil(', 'floor(', 'exp(', 'log10(', |
|
43 | - 'cos(', 'sin(', 'sqrt(', 'tan(', |
|
44 | - 'M_PI', 'INF', 'M_E', |
|
45 | - ); |
|
39 | + $allowed = array( |
|
40 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
|
41 | + '+', '-', '/', '*', '.', ' ', '<<', '>>', '%', '&', '^', '|', '~', |
|
42 | + 'abs(', 'ceil(', 'floor(', 'exp(', 'log10(', |
|
43 | + 'cos(', 'sin(', 'sqrt(', 'tan(', |
|
44 | + 'M_PI', 'INF', 'M_E', |
|
45 | + ); |
|
46 | 46 | |
47 | - /* |
|
47 | + /* |
|
48 | 48 | * Holds the functions that can accept multiple arguments |
49 | 49 | */ |
50 | - $funcs = array( |
|
51 | - 'round(', 'log(', 'pow(', |
|
52 | - 'max(', 'min(', 'rand(', |
|
53 | - ); |
|
50 | + $funcs = array( |
|
51 | + 'round(', 'log(', 'pow(', |
|
52 | + 'max(', 'min(', 'rand(', |
|
53 | + ); |
|
54 | 54 | |
55 | - $equation = $equationSrc = str_ireplace(array('pi', 'M_PI()', 'inf', ' e '), array('M_PI', 'M_PI', 'INF', ' M_E '), $equation); |
|
55 | + $equation = $equationSrc = str_ireplace(array('pi', 'M_PI()', 'inf', ' e '), array('M_PI', 'M_PI', 'INF', ' M_E '), $equation); |
|
56 | 56 | |
57 | - $delim = $equation[0]; |
|
58 | - $open = $delim.'.'; |
|
59 | - $close = '.'.$delim; |
|
60 | - $equation = substr($equation, 1, -1); |
|
61 | - $out = ''; |
|
62 | - $ptr = 1; |
|
63 | - $allowcomma = 0; |
|
64 | - while (strlen($equation) > 0) { |
|
65 | - $substr = substr($equation, 0, $ptr); |
|
66 | - if (array_search($substr, $allowed) !== false) { |
|
67 | - // allowed string |
|
68 | - $out .= $substr; |
|
69 | - $equation = substr($equation, $ptr); |
|
70 | - $ptr = 0; |
|
71 | - } elseif (array_search($substr, $funcs) !== false) { |
|
72 | - // allowed func |
|
73 | - $out .= $substr; |
|
74 | - $equation = substr($equation, $ptr); |
|
75 | - $ptr = 0; |
|
76 | - ++$allowcomma; |
|
77 | - if ($allowcomma === 1) { |
|
78 | - $allowed[] = ','; |
|
79 | - } |
|
80 | - } elseif (isset($rest[$substr])) { |
|
81 | - // variable |
|
82 | - $out .= $rest[$substr]; |
|
83 | - $equation = substr($equation, $ptr); |
|
84 | - $ptr = 0; |
|
85 | - } elseif ($substr === $open) { |
|
86 | - // pre-replaced variable |
|
87 | - preg_match('#.*\((?:[^()]*?|(?R))\)'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m); |
|
88 | - if (empty($m)) { |
|
89 | - preg_match('#.*?'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m); |
|
90 | - } |
|
91 | - $out .= substr($m[0], 0, -2); |
|
92 | - $equation = substr($equation, strlen($m[0]) + 2); |
|
93 | - $ptr = 0; |
|
94 | - } elseif ($substr === '(') { |
|
95 | - // opening parenthesis |
|
96 | - if ($allowcomma > 0) { |
|
97 | - ++$allowcomma; |
|
98 | - } |
|
57 | + $delim = $equation[0]; |
|
58 | + $open = $delim.'.'; |
|
59 | + $close = '.'.$delim; |
|
60 | + $equation = substr($equation, 1, -1); |
|
61 | + $out = ''; |
|
62 | + $ptr = 1; |
|
63 | + $allowcomma = 0; |
|
64 | + while (strlen($equation) > 0) { |
|
65 | + $substr = substr($equation, 0, $ptr); |
|
66 | + if (array_search($substr, $allowed) !== false) { |
|
67 | + // allowed string |
|
68 | + $out .= $substr; |
|
69 | + $equation = substr($equation, $ptr); |
|
70 | + $ptr = 0; |
|
71 | + } elseif (array_search($substr, $funcs) !== false) { |
|
72 | + // allowed func |
|
73 | + $out .= $substr; |
|
74 | + $equation = substr($equation, $ptr); |
|
75 | + $ptr = 0; |
|
76 | + ++$allowcomma; |
|
77 | + if ($allowcomma === 1) { |
|
78 | + $allowed[] = ','; |
|
79 | + } |
|
80 | + } elseif (isset($rest[$substr])) { |
|
81 | + // variable |
|
82 | + $out .= $rest[$substr]; |
|
83 | + $equation = substr($equation, $ptr); |
|
84 | + $ptr = 0; |
|
85 | + } elseif ($substr === $open) { |
|
86 | + // pre-replaced variable |
|
87 | + preg_match('#.*\((?:[^()]*?|(?R))\)'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m); |
|
88 | + if (empty($m)) { |
|
89 | + preg_match('#.*?'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m); |
|
90 | + } |
|
91 | + $out .= substr($m[0], 0, -2); |
|
92 | + $equation = substr($equation, strlen($m[0]) + 2); |
|
93 | + $ptr = 0; |
|
94 | + } elseif ($substr === '(') { |
|
95 | + // opening parenthesis |
|
96 | + if ($allowcomma > 0) { |
|
97 | + ++$allowcomma; |
|
98 | + } |
|
99 | 99 | |
100 | - $out .= $substr; |
|
101 | - $equation = substr($equation, $ptr); |
|
102 | - $ptr = 0; |
|
103 | - } elseif ($substr === ')') { |
|
104 | - // closing parenthesis |
|
105 | - if ($allowcomma > 0) { |
|
106 | - --$allowcomma; |
|
107 | - if ($allowcomma === 0) { |
|
108 | - array_pop($allowed); |
|
109 | - } |
|
110 | - } |
|
100 | + $out .= $substr; |
|
101 | + $equation = substr($equation, $ptr); |
|
102 | + $ptr = 0; |
|
103 | + } elseif ($substr === ')') { |
|
104 | + // closing parenthesis |
|
105 | + if ($allowcomma > 0) { |
|
106 | + --$allowcomma; |
|
107 | + if ($allowcomma === 0) { |
|
108 | + array_pop($allowed); |
|
109 | + } |
|
110 | + } |
|
111 | 111 | |
112 | - $out .= $substr; |
|
113 | - $equation = substr($equation, $ptr); |
|
114 | - $ptr = 0; |
|
115 | - } elseif ($ptr >= strlen($equation)) { |
|
116 | - // parse error if we've consumed the entire equation without finding anything valid |
|
117 | - throw new Dwoo_Compilation_Exception($compiler, 'Math : Syntax error or variable undefined in equation '.$equationSrc.' at '.$substr); |
|
118 | - } else { |
|
119 | - // nothing special, advance |
|
120 | - ++$ptr; |
|
121 | - } |
|
122 | - } |
|
123 | - if ($format !== '\'\'') { |
|
124 | - $out = 'sprintf('.$format.', '.$out.')'; |
|
125 | - } |
|
126 | - if ($assign !== '\'\'') { |
|
127 | - return '($this->assignInScope('.$out.', '.$assign.'))'; |
|
128 | - } |
|
112 | + $out .= $substr; |
|
113 | + $equation = substr($equation, $ptr); |
|
114 | + $ptr = 0; |
|
115 | + } elseif ($ptr >= strlen($equation)) { |
|
116 | + // parse error if we've consumed the entire equation without finding anything valid |
|
117 | + throw new Dwoo_Compilation_Exception($compiler, 'Math : Syntax error or variable undefined in equation '.$equationSrc.' at '.$substr); |
|
118 | + } else { |
|
119 | + // nothing special, advance |
|
120 | + ++$ptr; |
|
121 | + } |
|
122 | + } |
|
123 | + if ($format !== '\'\'') { |
|
124 | + $out = 'sprintf('.$format.', '.$out.')'; |
|
125 | + } |
|
126 | + if ($assign !== '\'\'') { |
|
127 | + return '($this->assignInScope('.$out.', '.$assign.'))'; |
|
128 | + } |
|
129 | 129 | |
130 | - return '('.$out.')'; |
|
130 | + return '('.$out.')'; |
|
131 | 131 | } |
@@ -89,7 +89,7 @@ |
||
89 | 89 | preg_match('#.*?'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m); |
90 | 90 | } |
91 | 91 | $out .= substr($m[0], 0, -2); |
92 | - $equation = substr($equation, strlen($m[0]) + 2); |
|
92 | + $equation = substr($equation, strlen($m[0])+2); |
|
93 | 93 | $ptr = 0; |
94 | 94 | } elseif ($substr === '(') { |
95 | 95 | // opening parenthesis |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function Dwoo_Plugin_lower_compile(Dwoo_Compiler $compiler, $value) |
23 | 23 | { |
24 | - return 'mb_strtolower((string) '.$value.', $this->charset)'; |
|
24 | + return 'mb_strtolower((string) '.$value.', $this->charset)'; |
|
25 | 25 | } |
@@ -29,94 +29,94 @@ |
||
29 | 29 | */ |
30 | 30 | function Dwoo_Plugin_mailto(Dwoo_Core $dwoo, $address, $text = null, $subject = null, $encode = null, $cc = null, $bcc = null, $newsgroups = null, $followupto = null, $extra = null) |
31 | 31 | { |
32 | - if (empty($address)) { |
|
33 | - return ''; |
|
34 | - } |
|
35 | - if (empty($text)) { |
|
36 | - $text = $address; |
|
37 | - } |
|
38 | - |
|
39 | - // build address string |
|
40 | - $address .= '?'; |
|
41 | - |
|
42 | - if (!empty($subject)) { |
|
43 | - $address .= 'subject='.rawurlencode($subject).'&'; |
|
44 | - } |
|
45 | - if (!empty($cc)) { |
|
46 | - $address .= 'cc='.rawurlencode($cc).'&'; |
|
47 | - } |
|
48 | - if (!empty($bcc)) { |
|
49 | - $address .= 'bcc='.rawurlencode($bcc).'&'; |
|
50 | - } |
|
51 | - if (!empty($newsgroups)) { |
|
52 | - $address .= 'newsgroups='.rawurlencode($newsgroups).'&'; |
|
53 | - } |
|
54 | - if (!empty($followupto)) { |
|
55 | - $address .= 'followupto='.rawurlencode($followupto).'&'; |
|
56 | - } |
|
57 | - |
|
58 | - $address = rtrim($address, '?&'); |
|
59 | - |
|
60 | - // output |
|
61 | - switch ($encode) { |
|
62 | - |
|
63 | - case 'none': |
|
64 | - case null: |
|
65 | - return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>'; |
|
66 | - |
|
67 | - case 'js': |
|
68 | - case 'javascript': |
|
69 | - $str = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');'; |
|
70 | - $len = strlen($str); |
|
71 | - |
|
72 | - $out = ''; |
|
73 | - for ($i = 0; $i < $len; ++$i) { |
|
74 | - $out .= '%'.bin2hex($str[$i]); |
|
75 | - } |
|
76 | - |
|
77 | - return '<script type="text/javascript">eval(unescape(\''.$out.'\'));</script>'; |
|
78 | - |
|
79 | - break; |
|
80 | - case 'javascript_charcode': |
|
81 | - case 'js_charcode': |
|
82 | - case 'jscharcode': |
|
83 | - case 'jschar': |
|
84 | - $str = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>'; |
|
85 | - $len = strlen($str); |
|
86 | - |
|
87 | - $out = '<script type="text/javascript">'."\n<!--\ndocument.write(String.fromCharCode("; |
|
88 | - for ($i = 0; $i < $len; ++$i) { |
|
89 | - $out .= ord($str[$i]).','; |
|
90 | - } |
|
91 | - |
|
92 | - return rtrim($out, ',')."));\n-->\n</script>\n"; |
|
93 | - |
|
94 | - break; |
|
95 | - |
|
96 | - case 'hex': |
|
97 | - if (strpos($address, '?') !== false) { |
|
98 | - $dwoo->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING); |
|
99 | - } |
|
100 | - |
|
101 | - $out = '<a href="mailto:'; |
|
102 | - $len = strlen($address); |
|
103 | - for ($i = 0; $i < $len; ++$i) { |
|
104 | - if (preg_match('#\w#', $address[$i])) { |
|
105 | - $out .= '%'.bin2hex($address[$i]); |
|
106 | - } else { |
|
107 | - $out .= $address[$i]; |
|
108 | - } |
|
109 | - } |
|
110 | - $out .= '" '.$extra.'>'; |
|
111 | - $len = strlen($text); |
|
112 | - for ($i = 0; $i < $len; ++$i) { |
|
113 | - $out .= '&#x'.bin2hex($text[$i]); |
|
114 | - } |
|
115 | - |
|
116 | - return $out.'</a>'; |
|
117 | - |
|
118 | - default: |
|
119 | - $dwoo->triggerError('Mailto: <em>encode</em> argument is invalid, it must be one of : <em>none (= no value), js, js_charcode or hex</em>', E_USER_WARNING); |
|
120 | - |
|
121 | - } |
|
32 | + if (empty($address)) { |
|
33 | + return ''; |
|
34 | + } |
|
35 | + if (empty($text)) { |
|
36 | + $text = $address; |
|
37 | + } |
|
38 | + |
|
39 | + // build address string |
|
40 | + $address .= '?'; |
|
41 | + |
|
42 | + if (!empty($subject)) { |
|
43 | + $address .= 'subject='.rawurlencode($subject).'&'; |
|
44 | + } |
|
45 | + if (!empty($cc)) { |
|
46 | + $address .= 'cc='.rawurlencode($cc).'&'; |
|
47 | + } |
|
48 | + if (!empty($bcc)) { |
|
49 | + $address .= 'bcc='.rawurlencode($bcc).'&'; |
|
50 | + } |
|
51 | + if (!empty($newsgroups)) { |
|
52 | + $address .= 'newsgroups='.rawurlencode($newsgroups).'&'; |
|
53 | + } |
|
54 | + if (!empty($followupto)) { |
|
55 | + $address .= 'followupto='.rawurlencode($followupto).'&'; |
|
56 | + } |
|
57 | + |
|
58 | + $address = rtrim($address, '?&'); |
|
59 | + |
|
60 | + // output |
|
61 | + switch ($encode) { |
|
62 | + |
|
63 | + case 'none': |
|
64 | + case null: |
|
65 | + return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>'; |
|
66 | + |
|
67 | + case 'js': |
|
68 | + case 'javascript': |
|
69 | + $str = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');'; |
|
70 | + $len = strlen($str); |
|
71 | + |
|
72 | + $out = ''; |
|
73 | + for ($i = 0; $i < $len; ++$i) { |
|
74 | + $out .= '%'.bin2hex($str[$i]); |
|
75 | + } |
|
76 | + |
|
77 | + return '<script type="text/javascript">eval(unescape(\''.$out.'\'));</script>'; |
|
78 | + |
|
79 | + break; |
|
80 | + case 'javascript_charcode': |
|
81 | + case 'js_charcode': |
|
82 | + case 'jscharcode': |
|
83 | + case 'jschar': |
|
84 | + $str = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>'; |
|
85 | + $len = strlen($str); |
|
86 | + |
|
87 | + $out = '<script type="text/javascript">'."\n<!--\ndocument.write(String.fromCharCode("; |
|
88 | + for ($i = 0; $i < $len; ++$i) { |
|
89 | + $out .= ord($str[$i]).','; |
|
90 | + } |
|
91 | + |
|
92 | + return rtrim($out, ',')."));\n-->\n</script>\n"; |
|
93 | + |
|
94 | + break; |
|
95 | + |
|
96 | + case 'hex': |
|
97 | + if (strpos($address, '?') !== false) { |
|
98 | + $dwoo->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING); |
|
99 | + } |
|
100 | + |
|
101 | + $out = '<a href="mailto:'; |
|
102 | + $len = strlen($address); |
|
103 | + for ($i = 0; $i < $len; ++$i) { |
|
104 | + if (preg_match('#\w#', $address[$i])) { |
|
105 | + $out .= '%'.bin2hex($address[$i]); |
|
106 | + } else { |
|
107 | + $out .= $address[$i]; |
|
108 | + } |
|
109 | + } |
|
110 | + $out .= '" '.$extra.'>'; |
|
111 | + $len = strlen($text); |
|
112 | + for ($i = 0; $i < $len; ++$i) { |
|
113 | + $out .= '&#x'.bin2hex($text[$i]); |
|
114 | + } |
|
115 | + |
|
116 | + return $out.'</a>'; |
|
117 | + |
|
118 | + default: |
|
119 | + $dwoo->triggerError('Mailto: <em>encode</em> argument is invalid, it must be one of : <em>none (= no value), js, js_charcode or hex</em>', E_USER_WARNING); |
|
120 | + |
|
121 | + } |
|
122 | 122 | } |
@@ -25,25 +25,25 @@ |
||
25 | 25 | */ |
26 | 26 | function Dwoo_Plugin_truncate(Dwoo_Core $dwoo, $value, $length = 80, $etc = '...', $break = false, $middle = false) |
27 | 27 | { |
28 | - if ($length == 0) { |
|
29 | - return ''; |
|
30 | - } |
|
28 | + if ($length == 0) { |
|
29 | + return ''; |
|
30 | + } |
|
31 | 31 | |
32 | - $value = (string) $value; |
|
33 | - $etc = (string) $etc; |
|
34 | - $length = (int) $length; |
|
32 | + $value = (string) $value; |
|
33 | + $etc = (string) $etc; |
|
34 | + $length = (int) $length; |
|
35 | 35 | |
36 | - if (strlen($value) < $length) { |
|
37 | - return $value; |
|
38 | - } |
|
36 | + if (strlen($value) < $length) { |
|
37 | + return $value; |
|
38 | + } |
|
39 | 39 | |
40 | - $length = max($length - strlen($etc), 0); |
|
41 | - if ($break === false && $middle === false) { |
|
42 | - $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
43 | - } |
|
44 | - if ($middle === false) { |
|
45 | - return substr($value, 0, $length).$etc; |
|
46 | - } |
|
40 | + $length = max($length - strlen($etc), 0); |
|
41 | + if ($break === false && $middle === false) { |
|
42 | + $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
43 | + } |
|
44 | + if ($middle === false) { |
|
45 | + return substr($value, 0, $length).$etc; |
|
46 | + } |
|
47 | 47 | |
48 | - return substr($value, 0, ceil($length / 2)).$etc.substr($value, -floor($length / 2)); |
|
48 | + return substr($value, 0, ceil($length / 2)).$etc.substr($value, -floor($length / 2)); |
|
49 | 49 | } |
@@ -37,13 +37,13 @@ |
||
37 | 37 | return $value; |
38 | 38 | } |
39 | 39 | |
40 | - $length = max($length - strlen($etc), 0); |
|
40 | + $length = max($length-strlen($etc), 0); |
|
41 | 41 | if ($break === false && $middle === false) { |
42 | - $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
42 | + $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length+1)); |
|
43 | 43 | } |
44 | 44 | if ($middle === false) { |
45 | 45 | return substr($value, 0, $length).$etc; |
46 | 46 | } |
47 | 47 | |
48 | - return substr($value, 0, ceil($length / 2)).$etc.substr($value, -floor($length / 2)); |
|
48 | + return substr($value, 0, ceil($length/2)).$etc.substr($value, -floor($length/2)); |
|
49 | 49 | } |
@@ -22,5 +22,5 @@ |
||
22 | 22 | */ |
23 | 23 | function Dwoo_Plugin_spacify_compile(Dwoo_Compiler $compiler, $value, $space_char = ' ') |
24 | 24 | { |
25 | - return 'implode('.$space_char.', str_split('.$value.', 1))'; |
|
25 | + return 'implode('.$space_char.', str_split('.$value.', 1))'; |
|
26 | 26 | } |
@@ -22,5 +22,5 @@ |
||
22 | 22 | */ |
23 | 23 | function Dwoo_Plugin_optional_compile(Dwoo_Compiler $compiler, $value) |
24 | 24 | { |
25 | - return $value; |
|
25 | + return $value; |
|
26 | 26 | } |
@@ -23,9 +23,9 @@ |
||
23 | 23 | */ |
24 | 24 | function Dwoo_Plugin_replace_compile(Dwoo_Compiler $compiler, $value, $search, $replace, $case_sensitive = true) |
25 | 25 | { |
26 | - if ($case_sensitive == 'false' || (bool) $case_sensitive === false) { |
|
27 | - return 'str_ireplace('.$search.', '.$replace.', '.$value.')'; |
|
28 | - } else { |
|
29 | - return 'str_replace('.$search.', '.$replace.', '.$value.')'; |
|
30 | - } |
|
26 | + if ($case_sensitive == 'false' || (bool) $case_sensitive === false) { |
|
27 | + return 'str_ireplace('.$search.', '.$replace.', '.$value.')'; |
|
28 | + } else { |
|
29 | + return 'str_replace('.$search.', '.$replace.', '.$value.')'; |
|
30 | + } |
|
31 | 31 | } |
@@ -27,56 +27,56 @@ |
||
27 | 27 | */ |
28 | 28 | function Dwoo_Plugin_include(Dwoo_Core $dwoo, $file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array()) |
29 | 29 | { |
30 | - if ($file === '') { |
|
31 | - return ''; |
|
32 | - } |
|
30 | + if ($file === '') { |
|
31 | + return ''; |
|
32 | + } |
|
33 | 33 | |
34 | - if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
35 | - // resource:identifier given, extract them |
|
36 | - $resource = $m[1]; |
|
37 | - $identifier = $m[2]; |
|
38 | - } else { |
|
39 | - // get the current template's resource |
|
40 | - $resource = $dwoo->getTemplate()->getResourceName(); |
|
41 | - $identifier = $file; |
|
42 | - } |
|
34 | + if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
35 | + // resource:identifier given, extract them |
|
36 | + $resource = $m[1]; |
|
37 | + $identifier = $m[2]; |
|
38 | + } else { |
|
39 | + // get the current template's resource |
|
40 | + $resource = $dwoo->getTemplate()->getResourceName(); |
|
41 | + $identifier = $file; |
|
42 | + } |
|
43 | 43 | |
44 | - try { |
|
45 | - $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
|
46 | - } catch (Dwoo_Security_Exception $e) { |
|
47 | - $dwoo->triggerError('Include : Security restriction : '.$e->getMessage(), E_USER_WARNING); |
|
48 | - } catch (Dwoo_Exception $e) { |
|
49 | - $dwoo->triggerError('Include : '.$e->getMessage(), E_USER_WARNING); |
|
50 | - } |
|
44 | + try { |
|
45 | + $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
|
46 | + } catch (Dwoo_Security_Exception $e) { |
|
47 | + $dwoo->triggerError('Include : Security restriction : '.$e->getMessage(), E_USER_WARNING); |
|
48 | + } catch (Dwoo_Exception $e) { |
|
49 | + $dwoo->triggerError('Include : '.$e->getMessage(), E_USER_WARNING); |
|
50 | + } |
|
51 | 51 | |
52 | - if ($include === null) { |
|
53 | - $dwoo->triggerError('Include : Resource "'.$resource.':'.$identifier.'" not found.', E_USER_WARNING); |
|
54 | - } elseif ($include === false) { |
|
55 | - $dwoo->triggerError('Include : Resource "'.$resource.'" does not support includes.', E_USER_WARNING); |
|
56 | - } |
|
52 | + if ($include === null) { |
|
53 | + $dwoo->triggerError('Include : Resource "'.$resource.':'.$identifier.'" not found.', E_USER_WARNING); |
|
54 | + } elseif ($include === false) { |
|
55 | + $dwoo->triggerError('Include : Resource "'.$resource.'" does not support includes.', E_USER_WARNING); |
|
56 | + } |
|
57 | 57 | |
58 | - if (is_string($data)) { |
|
59 | - $vars = $dwoo->readVar($data); |
|
60 | - } else { |
|
61 | - $vars = $data; |
|
62 | - } |
|
58 | + if (is_string($data)) { |
|
59 | + $vars = $dwoo->readVar($data); |
|
60 | + } else { |
|
61 | + $vars = $data; |
|
62 | + } |
|
63 | 63 | |
64 | - if (count($rest)) { |
|
65 | - $vars = $rest + $vars; |
|
66 | - } |
|
64 | + if (count($rest)) { |
|
65 | + $vars = $rest + $vars; |
|
66 | + } |
|
67 | 67 | |
68 | - $clone = clone $dwoo; |
|
69 | - $out = $clone->get($include, $vars); |
|
68 | + $clone = clone $dwoo; |
|
69 | + $out = $clone->get($include, $vars); |
|
70 | 70 | |
71 | - if ($assign !== null) { |
|
72 | - $dwoo->assignInScope($out, $assign); |
|
73 | - } |
|
71 | + if ($assign !== null) { |
|
72 | + $dwoo->assignInScope($out, $assign); |
|
73 | + } |
|
74 | 74 | |
75 | - foreach ($clone->getReturnValues() as $name => $value) { |
|
76 | - $dwoo->assignInScope($value, $name); |
|
77 | - } |
|
75 | + foreach ($clone->getReturnValues() as $name => $value) { |
|
76 | + $dwoo->assignInScope($value, $name); |
|
77 | + } |
|
78 | 78 | |
79 | - if ($assign === null) { |
|
80 | - return $out; |
|
81 | - } |
|
79 | + if ($assign === null) { |
|
80 | + return $out; |
|
81 | + } |
|
82 | 82 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | if (count($rest)) { |
65 | - $vars = $rest + $vars; |
|
65 | + $vars = $rest+$vars; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $clone = clone $dwoo; |