@@ -36,109 +36,109 @@ |
||
36 | 36 | */ |
37 | 37 | class PluginMailto extends Plugin |
38 | 38 | { |
39 | - /** |
|
40 | - * @param $address |
|
41 | - * @param null $text |
|
42 | - * @param null $subject |
|
43 | - * @param null $encode |
|
44 | - * @param null $cc |
|
45 | - * @param null $bcc |
|
46 | - * @param null $newsgroups |
|
47 | - * @param null $followupto |
|
48 | - * @param null $extra |
|
49 | - * |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function process($address, $text = null, $subject = null, $encode = null, $cc = null, $bcc = null, $newsgroups = null, $followupto = null, $extra = null) |
|
53 | - { |
|
54 | - if (empty($address)) { |
|
55 | - return ''; |
|
56 | - } |
|
57 | - if (empty($text)) { |
|
58 | - $text = $address; |
|
59 | - } |
|
60 | - |
|
61 | - // build address string |
|
62 | - $address .= '?'; |
|
63 | - |
|
64 | - if (!empty($subject)) { |
|
65 | - $address .= 'subject=' . rawurlencode($subject) . '&'; |
|
66 | - } |
|
67 | - if (!empty($cc)) { |
|
68 | - $address .= 'cc=' . rawurlencode($cc) . '&'; |
|
69 | - } |
|
70 | - if (!empty($bcc)) { |
|
71 | - $address .= 'bcc=' . rawurlencode($bcc) . '&'; |
|
72 | - } |
|
73 | - if (!empty($newsgroups)) { |
|
74 | - $address .= 'newsgroups=' . rawurlencode($newsgroups) . '&'; |
|
75 | - } |
|
76 | - if (!empty($followupto)) { |
|
77 | - $address .= 'followupto=' . rawurlencode($followupto) . '&'; |
|
78 | - } |
|
79 | - |
|
80 | - $address = rtrim($address, '?&'); |
|
81 | - |
|
82 | - // output |
|
83 | - switch ($encode) { |
|
84 | - |
|
85 | - case 'none': |
|
86 | - case null: |
|
87 | - return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
88 | - |
|
89 | - case 'js': |
|
90 | - case 'javascript': |
|
91 | - $str = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
|
92 | - $len = strlen($str); |
|
93 | - |
|
94 | - $out = ''; |
|
95 | - for ($i = 0; $i < $len; ++ $i) { |
|
96 | - $out .= '%' . bin2hex($str[$i]); |
|
97 | - } |
|
98 | - |
|
99 | - return '<script type="text/javascript">eval(unescape(\'' . $out . '\'));</script>'; |
|
100 | - |
|
101 | - break; |
|
102 | - case 'javascript_charcode': |
|
103 | - case 'js_charcode': |
|
104 | - case 'jscharcode': |
|
105 | - case 'jschar': |
|
106 | - $str = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
107 | - $len = strlen($str); |
|
108 | - |
|
109 | - $out = '<script type="text/javascript">' . "\n<!--\ndocument.write(Str.fromCharCode("; |
|
110 | - for ($i = 0; $i < $len; ++ $i) { |
|
111 | - $out .= ord($str[$i]) . ','; |
|
112 | - } |
|
113 | - |
|
114 | - return rtrim($out, ',') . "));\n-->\n</script>\n"; |
|
115 | - |
|
116 | - break; |
|
117 | - |
|
118 | - case 'hex': |
|
119 | - if (strpos($address, '?') !== false) { |
|
120 | - $this->core->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING); |
|
121 | - } |
|
122 | - |
|
123 | - $out = '<a href="mailto:'; |
|
124 | - $len = strlen($address); |
|
125 | - for ($i = 0; $i < $len; ++ $i) { |
|
126 | - if (preg_match('#\w#', $address[$i])) { |
|
127 | - $out .= '%' . bin2hex($address[$i]); |
|
128 | - } else { |
|
129 | - $out .= $address[$i]; |
|
130 | - } |
|
131 | - } |
|
132 | - $out .= '" ' . $extra . '>'; |
|
133 | - $len = strlen($text); |
|
134 | - for ($i = 0; $i < $len; ++ $i) { |
|
135 | - $out .= '&#x' . bin2hex($text[$i]); |
|
136 | - } |
|
137 | - |
|
138 | - return $out . '</a>'; |
|
139 | - |
|
140 | - default: |
|
141 | - $this->core->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); |
|
142 | - } |
|
143 | - } |
|
39 | + /** |
|
40 | + * @param $address |
|
41 | + * @param null $text |
|
42 | + * @param null $subject |
|
43 | + * @param null $encode |
|
44 | + * @param null $cc |
|
45 | + * @param null $bcc |
|
46 | + * @param null $newsgroups |
|
47 | + * @param null $followupto |
|
48 | + * @param null $extra |
|
49 | + * |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function process($address, $text = null, $subject = null, $encode = null, $cc = null, $bcc = null, $newsgroups = null, $followupto = null, $extra = null) |
|
53 | + { |
|
54 | + if (empty($address)) { |
|
55 | + return ''; |
|
56 | + } |
|
57 | + if (empty($text)) { |
|
58 | + $text = $address; |
|
59 | + } |
|
60 | + |
|
61 | + // build address string |
|
62 | + $address .= '?'; |
|
63 | + |
|
64 | + if (!empty($subject)) { |
|
65 | + $address .= 'subject=' . rawurlencode($subject) . '&'; |
|
66 | + } |
|
67 | + if (!empty($cc)) { |
|
68 | + $address .= 'cc=' . rawurlencode($cc) . '&'; |
|
69 | + } |
|
70 | + if (!empty($bcc)) { |
|
71 | + $address .= 'bcc=' . rawurlencode($bcc) . '&'; |
|
72 | + } |
|
73 | + if (!empty($newsgroups)) { |
|
74 | + $address .= 'newsgroups=' . rawurlencode($newsgroups) . '&'; |
|
75 | + } |
|
76 | + if (!empty($followupto)) { |
|
77 | + $address .= 'followupto=' . rawurlencode($followupto) . '&'; |
|
78 | + } |
|
79 | + |
|
80 | + $address = rtrim($address, '?&'); |
|
81 | + |
|
82 | + // output |
|
83 | + switch ($encode) { |
|
84 | + |
|
85 | + case 'none': |
|
86 | + case null: |
|
87 | + return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
88 | + |
|
89 | + case 'js': |
|
90 | + case 'javascript': |
|
91 | + $str = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
|
92 | + $len = strlen($str); |
|
93 | + |
|
94 | + $out = ''; |
|
95 | + for ($i = 0; $i < $len; ++ $i) { |
|
96 | + $out .= '%' . bin2hex($str[$i]); |
|
97 | + } |
|
98 | + |
|
99 | + return '<script type="text/javascript">eval(unescape(\'' . $out . '\'));</script>'; |
|
100 | + |
|
101 | + break; |
|
102 | + case 'javascript_charcode': |
|
103 | + case 'js_charcode': |
|
104 | + case 'jscharcode': |
|
105 | + case 'jschar': |
|
106 | + $str = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
107 | + $len = strlen($str); |
|
108 | + |
|
109 | + $out = '<script type="text/javascript">' . "\n<!--\ndocument.write(Str.fromCharCode("; |
|
110 | + for ($i = 0; $i < $len; ++ $i) { |
|
111 | + $out .= ord($str[$i]) . ','; |
|
112 | + } |
|
113 | + |
|
114 | + return rtrim($out, ',') . "));\n-->\n</script>\n"; |
|
115 | + |
|
116 | + break; |
|
117 | + |
|
118 | + case 'hex': |
|
119 | + if (strpos($address, '?') !== false) { |
|
120 | + $this->core->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING); |
|
121 | + } |
|
122 | + |
|
123 | + $out = '<a href="mailto:'; |
|
124 | + $len = strlen($address); |
|
125 | + for ($i = 0; $i < $len; ++ $i) { |
|
126 | + if (preg_match('#\w#', $address[$i])) { |
|
127 | + $out .= '%' . bin2hex($address[$i]); |
|
128 | + } else { |
|
129 | + $out .= $address[$i]; |
|
130 | + } |
|
131 | + } |
|
132 | + $out .= '" ' . $extra . '>'; |
|
133 | + $len = strlen($text); |
|
134 | + for ($i = 0; $i < $len; ++ $i) { |
|
135 | + $out .= '&#x' . bin2hex($text[$i]); |
|
136 | + } |
|
137 | + |
|
138 | + return $out . '</a>'; |
|
139 | + |
|
140 | + default: |
|
141 | + $this->core->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); |
|
142 | + } |
|
143 | + } |
|
144 | 144 | } |
145 | 145 | \ No newline at end of file |
@@ -82,63 +82,63 @@ |
||
82 | 82 | // output |
83 | 83 | switch ($encode) { |
84 | 84 | |
85 | - case 'none': |
|
86 | - case null: |
|
87 | - return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
88 | - |
|
89 | - case 'js': |
|
90 | - case 'javascript': |
|
91 | - $str = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
|
92 | - $len = strlen($str); |
|
93 | - |
|
94 | - $out = ''; |
|
95 | - for ($i = 0; $i < $len; ++ $i) { |
|
96 | - $out .= '%' . bin2hex($str[$i]); |
|
85 | + case 'none': |
|
86 | + case null: |
|
87 | + return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
88 | + |
|
89 | + case 'js': |
|
90 | + case 'javascript': |
|
91 | + $str = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
|
92 | + $len = strlen($str); |
|
93 | + |
|
94 | + $out = ''; |
|
95 | + for ($i = 0; $i < $len; ++ $i) { |
|
96 | + $out .= '%' . bin2hex($str[$i]); |
|
97 | + } |
|
98 | + |
|
99 | + return '<script type="text/javascript">eval(unescape(\'' . $out . '\'));</script>'; |
|
100 | + |
|
101 | + break; |
|
102 | + case 'javascript_charcode': |
|
103 | + case 'js_charcode': |
|
104 | + case 'jscharcode': |
|
105 | + case 'jschar': |
|
106 | + $str = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
107 | + $len = strlen($str); |
|
108 | + |
|
109 | + $out = '<script type="text/javascript">' . "\n<!--\ndocument.write(Str.fromCharCode("; |
|
110 | + for ($i = 0; $i < $len; ++ $i) { |
|
111 | + $out .= ord($str[$i]) . ','; |
|
112 | + } |
|
113 | + |
|
114 | + return rtrim($out, ',') . "));\n-->\n</script>\n"; |
|
115 | + |
|
116 | + break; |
|
117 | + |
|
118 | + case 'hex': |
|
119 | + if (strpos($address, '?') !== false) { |
|
120 | + $this->core->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING); |
|
121 | + } |
|
122 | + |
|
123 | + $out = '<a href="mailto:'; |
|
124 | + $len = strlen($address); |
|
125 | + for ($i = 0; $i < $len; ++ $i) { |
|
126 | + if (preg_match('#\w#', $address[$i])) { |
|
127 | + $out .= '%' . bin2hex($address[$i]); |
|
128 | + } else { |
|
129 | + $out .= $address[$i]; |
|
97 | 130 | } |
131 | + } |
|
132 | + $out .= '" ' . $extra . '>'; |
|
133 | + $len = strlen($text); |
|
134 | + for ($i = 0; $i < $len; ++ $i) { |
|
135 | + $out .= '&#x' . bin2hex($text[$i]); |
|
136 | + } |
|
98 | 137 | |
99 | - return '<script type="text/javascript">eval(unescape(\'' . $out . '\'));</script>'; |
|
138 | + return $out . '</a>'; |
|
100 | 139 | |
101 | - break; |
|
102 | - case 'javascript_charcode': |
|
103 | - case 'js_charcode': |
|
104 | - case 'jscharcode': |
|
105 | - case 'jschar': |
|
106 | - $str = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
107 | - $len = strlen($str); |
|
108 | - |
|
109 | - $out = '<script type="text/javascript">' . "\n<!--\ndocument.write(Str.fromCharCode("; |
|
110 | - for ($i = 0; $i < $len; ++ $i) { |
|
111 | - $out .= ord($str[$i]) . ','; |
|
112 | - } |
|
113 | - |
|
114 | - return rtrim($out, ',') . "));\n-->\n</script>\n"; |
|
115 | - |
|
116 | - break; |
|
117 | - |
|
118 | - case 'hex': |
|
119 | - if (strpos($address, '?') !== false) { |
|
120 | - $this->core->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING); |
|
121 | - } |
|
122 | - |
|
123 | - $out = '<a href="mailto:'; |
|
124 | - $len = strlen($address); |
|
125 | - for ($i = 0; $i < $len; ++ $i) { |
|
126 | - if (preg_match('#\w#', $address[$i])) { |
|
127 | - $out .= '%' . bin2hex($address[$i]); |
|
128 | - } else { |
|
129 | - $out .= $address[$i]; |
|
130 | - } |
|
131 | - } |
|
132 | - $out .= '" ' . $extra . '>'; |
|
133 | - $len = strlen($text); |
|
134 | - for ($i = 0; $i < $len; ++ $i) { |
|
135 | - $out .= '&#x' . bin2hex($text[$i]); |
|
136 | - } |
|
137 | - |
|
138 | - return $out . '</a>'; |
|
139 | - |
|
140 | - default: |
|
141 | - $this->core->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); |
|
140 | + default: |
|
141 | + $this->core->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); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
145 | 145 | \ No newline at end of file |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | $address .= '?'; |
63 | 63 | |
64 | 64 | if (!empty($subject)) { |
65 | - $address .= 'subject=' . rawurlencode($subject) . '&'; |
|
65 | + $address .= 'subject='.rawurlencode($subject).'&'; |
|
66 | 66 | } |
67 | 67 | if (!empty($cc)) { |
68 | - $address .= 'cc=' . rawurlencode($cc) . '&'; |
|
68 | + $address .= 'cc='.rawurlencode($cc).'&'; |
|
69 | 69 | } |
70 | 70 | if (!empty($bcc)) { |
71 | - $address .= 'bcc=' . rawurlencode($bcc) . '&'; |
|
71 | + $address .= 'bcc='.rawurlencode($bcc).'&'; |
|
72 | 72 | } |
73 | 73 | if (!empty($newsgroups)) { |
74 | - $address .= 'newsgroups=' . rawurlencode($newsgroups) . '&'; |
|
74 | + $address .= 'newsgroups='.rawurlencode($newsgroups).'&'; |
|
75 | 75 | } |
76 | 76 | if (!empty($followupto)) { |
77 | - $address .= 'followupto=' . rawurlencode($followupto) . '&'; |
|
77 | + $address .= 'followupto='.rawurlencode($followupto).'&'; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $address = rtrim($address, '?&'); |
@@ -84,34 +84,34 @@ discard block |
||
84 | 84 | |
85 | 85 | case 'none': |
86 | 86 | case null: |
87 | - return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
87 | + return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>'; |
|
88 | 88 | |
89 | 89 | case 'js': |
90 | 90 | case 'javascript': |
91 | - $str = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
|
91 | + $str = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');'; |
|
92 | 92 | $len = strlen($str); |
93 | 93 | |
94 | 94 | $out = ''; |
95 | 95 | for ($i = 0; $i < $len; ++ $i) { |
96 | - $out .= '%' . bin2hex($str[$i]); |
|
96 | + $out .= '%'.bin2hex($str[$i]); |
|
97 | 97 | } |
98 | 98 | |
99 | - return '<script type="text/javascript">eval(unescape(\'' . $out . '\'));</script>'; |
|
99 | + return '<script type="text/javascript">eval(unescape(\''.$out.'\'));</script>'; |
|
100 | 100 | |
101 | 101 | break; |
102 | 102 | case 'javascript_charcode': |
103 | 103 | case 'js_charcode': |
104 | 104 | case 'jscharcode': |
105 | 105 | case 'jschar': |
106 | - $str = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
106 | + $str = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>'; |
|
107 | 107 | $len = strlen($str); |
108 | 108 | |
109 | - $out = '<script type="text/javascript">' . "\n<!--\ndocument.write(Str.fromCharCode("; |
|
109 | + $out = '<script type="text/javascript">'."\n<!--\ndocument.write(Str.fromCharCode("; |
|
110 | 110 | for ($i = 0; $i < $len; ++ $i) { |
111 | - $out .= ord($str[$i]) . ','; |
|
111 | + $out .= ord($str[$i]).','; |
|
112 | 112 | } |
113 | 113 | |
114 | - return rtrim($out, ',') . "));\n-->\n</script>\n"; |
|
114 | + return rtrim($out, ',')."));\n-->\n</script>\n"; |
|
115 | 115 | |
116 | 116 | break; |
117 | 117 | |
@@ -124,18 +124,18 @@ discard block |
||
124 | 124 | $len = strlen($address); |
125 | 125 | for ($i = 0; $i < $len; ++ $i) { |
126 | 126 | if (preg_match('#\w#', $address[$i])) { |
127 | - $out .= '%' . bin2hex($address[$i]); |
|
127 | + $out .= '%'.bin2hex($address[$i]); |
|
128 | 128 | } else { |
129 | 129 | $out .= $address[$i]; |
130 | 130 | } |
131 | 131 | } |
132 | - $out .= '" ' . $extra . '>'; |
|
132 | + $out .= '" '.$extra.'>'; |
|
133 | 133 | $len = strlen($text); |
134 | 134 | for ($i = 0; $i < $len; ++ $i) { |
135 | - $out .= '&#x' . bin2hex($text[$i]); |
|
135 | + $out .= '&#x'.bin2hex($text[$i]); |
|
136 | 136 | } |
137 | 137 | |
138 | - return $out . '</a>'; |
|
138 | + return $out.'</a>'; |
|
139 | 139 | |
140 | 140 | default: |
141 | 141 | $this->core->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); |
@@ -36,75 +36,75 @@ |
||
36 | 36 | */ |
37 | 37 | class PluginInclude extends Plugin |
38 | 38 | { |
39 | - /** |
|
40 | - * @param $file |
|
41 | - * @param null $cache_time |
|
42 | - * @param null $cache_id |
|
43 | - * @param null $compile_id |
|
44 | - * @param string $data |
|
45 | - * @param null $assign |
|
46 | - * @param array $rest |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function process($file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array()) |
|
51 | - { |
|
52 | - $include = null; |
|
53 | - if ($file === '') { |
|
54 | - return ''; |
|
55 | - } |
|
39 | + /** |
|
40 | + * @param $file |
|
41 | + * @param null $cache_time |
|
42 | + * @param null $cache_id |
|
43 | + * @param null $compile_id |
|
44 | + * @param string $data |
|
45 | + * @param null $assign |
|
46 | + * @param array $rest |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function process($file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array()) |
|
51 | + { |
|
52 | + $include = null; |
|
53 | + if ($file === '') { |
|
54 | + return ''; |
|
55 | + } |
|
56 | 56 | |
57 | - if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
58 | - // resource:identifier given, extract them |
|
59 | - $resource = $m[1]; |
|
60 | - $identifier = $m[2]; |
|
61 | - } else { |
|
62 | - // get the current template's resource |
|
63 | - $resource = $this->core->getTemplate()->getResourceName(); |
|
64 | - $identifier = $file; |
|
65 | - } |
|
57 | + if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
58 | + // resource:identifier given, extract them |
|
59 | + $resource = $m[1]; |
|
60 | + $identifier = $m[2]; |
|
61 | + } else { |
|
62 | + // get the current template's resource |
|
63 | + $resource = $this->core->getTemplate()->getResourceName(); |
|
64 | + $identifier = $file; |
|
65 | + } |
|
66 | 66 | |
67 | - try { |
|
68 | - $include = $this->core->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
|
69 | - } |
|
70 | - catch (SecurityException $e) { |
|
71 | - $this->core->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); |
|
72 | - } |
|
73 | - catch (Exception $e) { |
|
74 | - $this->core->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); |
|
75 | - } |
|
67 | + try { |
|
68 | + $include = $this->core->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
|
69 | + } |
|
70 | + catch (SecurityException $e) { |
|
71 | + $this->core->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); |
|
72 | + } |
|
73 | + catch (Exception $e) { |
|
74 | + $this->core->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); |
|
75 | + } |
|
76 | 76 | |
77 | - if ($include === null) { |
|
78 | - $this->core->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', |
|
79 | - E_USER_WARNING); |
|
80 | - } elseif ($include === false) { |
|
81 | - $this->core->triggerError('Include : Resource "' . $resource . '" does not support includes.', |
|
82 | - E_USER_WARNING); |
|
83 | - } |
|
77 | + if ($include === null) { |
|
78 | + $this->core->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', |
|
79 | + E_USER_WARNING); |
|
80 | + } elseif ($include === false) { |
|
81 | + $this->core->triggerError('Include : Resource "' . $resource . '" does not support includes.', |
|
82 | + E_USER_WARNING); |
|
83 | + } |
|
84 | 84 | |
85 | - if (is_string($data)) { |
|
86 | - $vars = $this->core->readVar($data); |
|
87 | - } else { |
|
88 | - $vars = $data; |
|
89 | - } |
|
85 | + if (is_string($data)) { |
|
86 | + $vars = $this->core->readVar($data); |
|
87 | + } else { |
|
88 | + $vars = $data; |
|
89 | + } |
|
90 | 90 | |
91 | - if (count($rest)) { |
|
92 | - $vars = $rest + $vars; |
|
93 | - } |
|
91 | + if (count($rest)) { |
|
92 | + $vars = $rest + $vars; |
|
93 | + } |
|
94 | 94 | |
95 | - $clone = clone $this->core; |
|
96 | - $out = $clone->get($include, $vars); |
|
95 | + $clone = clone $this->core; |
|
96 | + $out = $clone->get($include, $vars); |
|
97 | 97 | |
98 | - if ($assign !== null) { |
|
99 | - $this->core->assignInScope($out, $assign); |
|
100 | - } |
|
98 | + if ($assign !== null) { |
|
99 | + $this->core->assignInScope($out, $assign); |
|
100 | + } |
|
101 | 101 | |
102 | - foreach ($clone->getReturnValues() as $name => $value) { |
|
103 | - $this->core->assignInScope($value, $name); |
|
104 | - } |
|
102 | + foreach ($clone->getReturnValues() as $name => $value) { |
|
103 | + $this->core->assignInScope($value, $name); |
|
104 | + } |
|
105 | 105 | |
106 | - if ($assign === null) { |
|
107 | - return $out; |
|
108 | - } |
|
109 | - } |
|
106 | + if ($assign === null) { |
|
107 | + return $out; |
|
108 | + } |
|
109 | + } |
|
110 | 110 | } |
111 | 111 | \ No newline at end of file |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | $include = $this->core->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
69 | 69 | } |
70 | 70 | catch (SecurityException $e) { |
71 | - $this->core->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); |
|
71 | + $this->core->triggerError('Include : Security restriction : '.$e->getMessage(), E_USER_WARNING); |
|
72 | 72 | } |
73 | 73 | catch (Exception $e) { |
74 | - $this->core->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); |
|
74 | + $this->core->triggerError('Include : '.$e->getMessage(), E_USER_WARNING); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | if ($include === null) { |
78 | - $this->core->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', |
|
78 | + $this->core->triggerError('Include : Resource "'.$resource.':'.$identifier.'" not found.', |
|
79 | 79 | E_USER_WARNING); |
80 | 80 | } elseif ($include === false) { |
81 | - $this->core->triggerError('Include : Resource "' . $resource . '" does not support includes.', |
|
81 | + $this->core->triggerError('Include : Resource "'.$resource.'" does not support includes.', |
|
82 | 82 | E_USER_WARNING); |
83 | 83 | } |
84 | 84 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | if (count($rest)) { |
92 | - $vars = $rest + $vars; |
|
92 | + $vars = $rest+$vars; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $clone = clone $this->core; |
@@ -66,11 +66,9 @@ |
||
66 | 66 | |
67 | 67 | try { |
68 | 68 | $include = $this->core->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
69 | - } |
|
70 | - catch (SecurityException $e) { |
|
69 | + } catch (SecurityException $e) { |
|
71 | 70 | $this->core->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); |
72 | - } |
|
73 | - catch (Exception $e) { |
|
71 | + } catch (Exception $e) { |
|
74 | 72 | $this->core->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); |
75 | 73 | } |
76 | 74 |
@@ -37,26 +37,26 @@ |
||
37 | 37 | */ |
38 | 38 | class PluginEval extends Plugin |
39 | 39 | { |
40 | - /** |
|
41 | - * @param string $var |
|
42 | - * @param null $assign |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function process($var, $assign = null) |
|
47 | - { |
|
48 | - if ($var == '') { |
|
49 | - return ''; |
|
50 | - } |
|
40 | + /** |
|
41 | + * @param string $var |
|
42 | + * @param null $assign |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function process($var, $assign = null) |
|
47 | + { |
|
48 | + if ($var == '') { |
|
49 | + return ''; |
|
50 | + } |
|
51 | 51 | |
52 | - $tpl = new TemplateString($var); |
|
53 | - $clone = clone $this->core; |
|
54 | - $out = $clone->get($tpl, $this->core->readVar('_parent')); |
|
52 | + $tpl = new TemplateString($var); |
|
53 | + $clone = clone $this->core; |
|
54 | + $out = $clone->get($tpl, $this->core->readVar('_parent')); |
|
55 | 55 | |
56 | - if ($assign !== null) { |
|
57 | - $this->core->assignInScope($out, $assign); |
|
58 | - } else { |
|
59 | - return $out; |
|
60 | - } |
|
61 | - } |
|
56 | + if ($assign !== null) { |
|
57 | + $this->core->assignInScope($out, $assign); |
|
58 | + } else { |
|
59 | + return $out; |
|
60 | + } |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | \ No newline at end of file |
@@ -32,24 +32,24 @@ |
||
32 | 32 | */ |
33 | 33 | class PluginStripTags extends Plugin implements ICompilable |
34 | 34 | { |
35 | - /** |
|
36 | - * @param Compiler $compiler |
|
37 | - * @param string $value |
|
38 | - * @param bool $addspace |
|
39 | - * @param null|string $allowable_tags |
|
40 | - * |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public static function compile(Compiler $compiler, $value, $addspace = true, $allowable_tags = null) |
|
44 | - { |
|
45 | - if ($addspace === 'true') { |
|
46 | - if ("null" == $allowable_tags) { |
|
47 | - return "preg_replace('#<[^>]*>#', ' ', $value)"; |
|
48 | - } |
|
35 | + /** |
|
36 | + * @param Compiler $compiler |
|
37 | + * @param string $value |
|
38 | + * @param bool $addspace |
|
39 | + * @param null|string $allowable_tags |
|
40 | + * |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public static function compile(Compiler $compiler, $value, $addspace = true, $allowable_tags = null) |
|
44 | + { |
|
45 | + if ($addspace === 'true') { |
|
46 | + if ("null" == $allowable_tags) { |
|
47 | + return "preg_replace('#<[^>]*>#', ' ', $value)"; |
|
48 | + } |
|
49 | 49 | |
50 | - return "preg_replace('#<\\s*\\/?(" . $allowable_tags . ")\\s*[^>]*?>#im', ' ', $value)"; |
|
51 | - } |
|
50 | + return "preg_replace('#<\\s*\\/?(" . $allowable_tags . ")\\s*[^>]*?>#im', ' ', $value)"; |
|
51 | + } |
|
52 | 52 | |
53 | - return "strip_tags($value, $allowable_tags)"; |
|
54 | - } |
|
53 | + return "strip_tags($value, $allowable_tags)"; |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -47,7 +47,7 @@ |
||
47 | 47 | return "preg_replace('#<[^>]*>#', ' ', $value)"; |
48 | 48 | } |
49 | 49 | |
50 | - return "preg_replace('#<\\s*\\/?(" . $allowable_tags . ")\\s*[^>]*?>#im', ' ', $value)"; |
|
50 | + return "preg_replace('#<\\s*\\/?(".$allowable_tags.")\\s*[^>]*?>#im', ' ', $value)"; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | return "strip_tags($value, $allowable_tags)"; |
@@ -31,180 +31,180 @@ |
||
31 | 31 | */ |
32 | 32 | class PluginDump extends Plugin |
33 | 33 | { |
34 | - protected $outputObjects; |
|
35 | - protected $outputMethods; |
|
36 | - |
|
37 | - /** |
|
38 | - * @param string $var |
|
39 | - * @param bool $show_methods |
|
40 | - * |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function process($var = '$', $show_methods = false) |
|
44 | - { |
|
45 | - $this->outputMethods = $show_methods; |
|
46 | - if ($var === '$') { |
|
47 | - $var = $this->core->getData(); |
|
48 | - $out = '<div style="background:#aaa; padding:5px; margin:5px; color:#000;">data'; |
|
49 | - } else { |
|
50 | - $out = '<div style="background:#aaa; padding:5px; margin:5px; color:#000;">dump'; |
|
51 | - } |
|
52 | - |
|
53 | - $this->outputObjects = array(); |
|
54 | - |
|
55 | - if (!is_array($var)) { |
|
56 | - if (is_object($var)) { |
|
57 | - return $this->exportObj('', $var); |
|
58 | - } else { |
|
59 | - return $this->exportVar('', $var); |
|
60 | - } |
|
61 | - } |
|
62 | - |
|
63 | - $scope = $this->core->getScope(); |
|
64 | - |
|
65 | - if ($var === $scope) { |
|
66 | - $out .= ' (current scope): <div style="background:#ccc;">'; |
|
67 | - } else { |
|
68 | - $out .= ':<div style="padding-left:20px;">'; |
|
69 | - } |
|
70 | - |
|
71 | - $out .= $this->export($var, $scope); |
|
72 | - |
|
73 | - return $out . '</div></div>'; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @param $var |
|
78 | - * @param $scope |
|
79 | - * |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - protected function export($var, $scope) |
|
83 | - { |
|
84 | - $out = ''; |
|
85 | - foreach ($var as $i => $v) { |
|
86 | - if (is_array($v) || (is_object($v) && $v instanceof Iterator)) { |
|
87 | - $out .= $i . ' (' . (is_array($v) ? 'array' : 'object: ' . get_class($v)) . ')'; |
|
88 | - if ($v === $scope) { |
|
89 | - $out .= ' (current scope):<div style="background:#ccc;padding-left:20px;">' . $this->export($v, $scope) . '</div>'; |
|
90 | - } else { |
|
91 | - $out .= ':<div style="padding-left:20px;">' . $this->export($v, $scope) . '</div>'; |
|
92 | - } |
|
93 | - } elseif (is_object($v)) { |
|
94 | - $out .= $this->exportObj($i . ' (object: ' . get_class($v) . '):', $v); |
|
95 | - } else { |
|
96 | - $out .= $this->exportVar($i . ' = ', $v); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - return $out; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param $i |
|
105 | - * @param $v |
|
106 | - * |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - protected function exportVar($i, $v) |
|
110 | - { |
|
111 | - if (is_string($v) || is_bool($v) || is_numeric($v)) { |
|
112 | - return $i . htmlentities(var_export($v, true)) . '<br />'; |
|
113 | - } elseif (is_null($v)) { |
|
114 | - return $i . 'null<br />'; |
|
115 | - } elseif (is_resource($v)) { |
|
116 | - return $i . 'resource(' . get_resource_type($v) . ')<br />'; |
|
117 | - } else { |
|
118 | - return $i . htmlentities(var_export($v, true)) . '<br />'; |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @param $i |
|
124 | - * @param $obj |
|
125 | - * |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - protected function exportObj($i, $obj) |
|
129 | - { |
|
130 | - if (array_search($obj, $this->outputObjects, true) !== false) { |
|
131 | - return $i . ' [recursion, skipped]<br />'; |
|
132 | - } |
|
133 | - |
|
134 | - $this->outputObjects[] = $obj; |
|
135 | - |
|
136 | - $list = (array)$obj; |
|
137 | - |
|
138 | - $protectedLength = strlen(get_class($obj)) + 2; |
|
139 | - |
|
140 | - $out = array(); |
|
141 | - |
|
142 | - if ($this->outputMethods) { |
|
143 | - $ref = new ReflectionObject($obj); |
|
144 | - |
|
145 | - foreach ($ref->getMethods() as $method) { |
|
146 | - if (!$method->isPublic()) { |
|
147 | - continue; |
|
148 | - } |
|
149 | - |
|
150 | - if (empty($out['method'])) { |
|
151 | - $out['method'] = ''; |
|
152 | - } |
|
153 | - |
|
154 | - $params = array(); |
|
155 | - foreach ($method->getParameters() as $param) { |
|
156 | - $params[] = ($param->isPassedByReference() ? '&' : '') . '$' . $param->getName() . ($param->isOptional() ? ' = ' . var_export($param->getDefaultValue(), true) : ''); |
|
157 | - } |
|
158 | - |
|
159 | - $out['method'] .= '(method) ' . $method->getName() . '(' . implode(', ', $params) . ')<br />'; |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - foreach ($list as $attributeName => $attributeValue) { |
|
164 | - if (property_exists($obj, $attributeName)) { |
|
165 | - $key = 'public'; |
|
166 | - } elseif (substr($attributeName, 0, 3) === "\0*\0") { |
|
167 | - $key = 'protected'; |
|
168 | - $attributeName = substr($attributeName, 3); |
|
169 | - } else { |
|
170 | - $key = 'private'; |
|
171 | - $attributeName = substr($attributeName, $protectedLength); |
|
172 | - } |
|
173 | - |
|
174 | - if (empty($out[$key])) { |
|
175 | - $out[$key] = ''; |
|
176 | - } |
|
177 | - |
|
178 | - $out[$key] .= '(' . $key . ') '; |
|
179 | - |
|
180 | - if (is_array($attributeValue)) { |
|
181 | - $out[$key] .= $attributeName . ' (array):<br /> |
|
34 | + protected $outputObjects; |
|
35 | + protected $outputMethods; |
|
36 | + |
|
37 | + /** |
|
38 | + * @param string $var |
|
39 | + * @param bool $show_methods |
|
40 | + * |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function process($var = '$', $show_methods = false) |
|
44 | + { |
|
45 | + $this->outputMethods = $show_methods; |
|
46 | + if ($var === '$') { |
|
47 | + $var = $this->core->getData(); |
|
48 | + $out = '<div style="background:#aaa; padding:5px; margin:5px; color:#000;">data'; |
|
49 | + } else { |
|
50 | + $out = '<div style="background:#aaa; padding:5px; margin:5px; color:#000;">dump'; |
|
51 | + } |
|
52 | + |
|
53 | + $this->outputObjects = array(); |
|
54 | + |
|
55 | + if (!is_array($var)) { |
|
56 | + if (is_object($var)) { |
|
57 | + return $this->exportObj('', $var); |
|
58 | + } else { |
|
59 | + return $this->exportVar('', $var); |
|
60 | + } |
|
61 | + } |
|
62 | + |
|
63 | + $scope = $this->core->getScope(); |
|
64 | + |
|
65 | + if ($var === $scope) { |
|
66 | + $out .= ' (current scope): <div style="background:#ccc;">'; |
|
67 | + } else { |
|
68 | + $out .= ':<div style="padding-left:20px;">'; |
|
69 | + } |
|
70 | + |
|
71 | + $out .= $this->export($var, $scope); |
|
72 | + |
|
73 | + return $out . '</div></div>'; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @param $var |
|
78 | + * @param $scope |
|
79 | + * |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + protected function export($var, $scope) |
|
83 | + { |
|
84 | + $out = ''; |
|
85 | + foreach ($var as $i => $v) { |
|
86 | + if (is_array($v) || (is_object($v) && $v instanceof Iterator)) { |
|
87 | + $out .= $i . ' (' . (is_array($v) ? 'array' : 'object: ' . get_class($v)) . ')'; |
|
88 | + if ($v === $scope) { |
|
89 | + $out .= ' (current scope):<div style="background:#ccc;padding-left:20px;">' . $this->export($v, $scope) . '</div>'; |
|
90 | + } else { |
|
91 | + $out .= ':<div style="padding-left:20px;">' . $this->export($v, $scope) . '</div>'; |
|
92 | + } |
|
93 | + } elseif (is_object($v)) { |
|
94 | + $out .= $this->exportObj($i . ' (object: ' . get_class($v) . '):', $v); |
|
95 | + } else { |
|
96 | + $out .= $this->exportVar($i . ' = ', $v); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + return $out; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param $i |
|
105 | + * @param $v |
|
106 | + * |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + protected function exportVar($i, $v) |
|
110 | + { |
|
111 | + if (is_string($v) || is_bool($v) || is_numeric($v)) { |
|
112 | + return $i . htmlentities(var_export($v, true)) . '<br />'; |
|
113 | + } elseif (is_null($v)) { |
|
114 | + return $i . 'null<br />'; |
|
115 | + } elseif (is_resource($v)) { |
|
116 | + return $i . 'resource(' . get_resource_type($v) . ')<br />'; |
|
117 | + } else { |
|
118 | + return $i . htmlentities(var_export($v, true)) . '<br />'; |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @param $i |
|
124 | + * @param $obj |
|
125 | + * |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + protected function exportObj($i, $obj) |
|
129 | + { |
|
130 | + if (array_search($obj, $this->outputObjects, true) !== false) { |
|
131 | + return $i . ' [recursion, skipped]<br />'; |
|
132 | + } |
|
133 | + |
|
134 | + $this->outputObjects[] = $obj; |
|
135 | + |
|
136 | + $list = (array)$obj; |
|
137 | + |
|
138 | + $protectedLength = strlen(get_class($obj)) + 2; |
|
139 | + |
|
140 | + $out = array(); |
|
141 | + |
|
142 | + if ($this->outputMethods) { |
|
143 | + $ref = new ReflectionObject($obj); |
|
144 | + |
|
145 | + foreach ($ref->getMethods() as $method) { |
|
146 | + if (!$method->isPublic()) { |
|
147 | + continue; |
|
148 | + } |
|
149 | + |
|
150 | + if (empty($out['method'])) { |
|
151 | + $out['method'] = ''; |
|
152 | + } |
|
153 | + |
|
154 | + $params = array(); |
|
155 | + foreach ($method->getParameters() as $param) { |
|
156 | + $params[] = ($param->isPassedByReference() ? '&' : '') . '$' . $param->getName() . ($param->isOptional() ? ' = ' . var_export($param->getDefaultValue(), true) : ''); |
|
157 | + } |
|
158 | + |
|
159 | + $out['method'] .= '(method) ' . $method->getName() . '(' . implode(', ', $params) . ')<br />'; |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + foreach ($list as $attributeName => $attributeValue) { |
|
164 | + if (property_exists($obj, $attributeName)) { |
|
165 | + $key = 'public'; |
|
166 | + } elseif (substr($attributeName, 0, 3) === "\0*\0") { |
|
167 | + $key = 'protected'; |
|
168 | + $attributeName = substr($attributeName, 3); |
|
169 | + } else { |
|
170 | + $key = 'private'; |
|
171 | + $attributeName = substr($attributeName, $protectedLength); |
|
172 | + } |
|
173 | + |
|
174 | + if (empty($out[$key])) { |
|
175 | + $out[$key] = ''; |
|
176 | + } |
|
177 | + |
|
178 | + $out[$key] .= '(' . $key . ') '; |
|
179 | + |
|
180 | + if (is_array($attributeValue)) { |
|
181 | + $out[$key] .= $attributeName . ' (array):<br /> |
|
182 | 182 | <div style="padding-left:20px;">' . $this->export($attributeValue, false) . '</div>'; |
183 | - } elseif (is_object($attributeValue)) { |
|
184 | - $out[$key] .= $this->exportObj($attributeName . ' (object: ' . get_class($attributeValue) . '):', $attributeValue); |
|
185 | - } else { |
|
186 | - $out[$key] .= $this->exportVar($attributeName . ' = ', $attributeValue); |
|
187 | - } |
|
188 | - } |
|
183 | + } elseif (is_object($attributeValue)) { |
|
184 | + $out[$key] .= $this->exportObj($attributeName . ' (object: ' . get_class($attributeValue) . '):', $attributeValue); |
|
185 | + } else { |
|
186 | + $out[$key] .= $this->exportVar($attributeName . ' = ', $attributeValue); |
|
187 | + } |
|
188 | + } |
|
189 | 189 | |
190 | - $return = $i . '<br /><div style="padding-left:20px;">'; |
|
190 | + $return = $i . '<br /><div style="padding-left:20px;">'; |
|
191 | 191 | |
192 | - if (!empty($out['method'])) { |
|
193 | - $return .= $out['method']; |
|
194 | - } |
|
192 | + if (!empty($out['method'])) { |
|
193 | + $return .= $out['method']; |
|
194 | + } |
|
195 | 195 | |
196 | - if (!empty($out['public'])) { |
|
197 | - $return .= $out['public']; |
|
198 | - } |
|
196 | + if (!empty($out['public'])) { |
|
197 | + $return .= $out['public']; |
|
198 | + } |
|
199 | 199 | |
200 | - if (!empty($out['protected'])) { |
|
201 | - $return .= $out['protected']; |
|
202 | - } |
|
200 | + if (!empty($out['protected'])) { |
|
201 | + $return .= $out['protected']; |
|
202 | + } |
|
203 | 203 | |
204 | - if (!empty($out['private'])) { |
|
205 | - $return .= $out['private']; |
|
206 | - } |
|
204 | + if (!empty($out['private'])) { |
|
205 | + $return .= $out['private']; |
|
206 | + } |
|
207 | 207 | |
208 | - return $return . '</div>'; |
|
209 | - } |
|
208 | + return $return . '</div>'; |
|
209 | + } |
|
210 | 210 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $out .= $this->export($var, $scope); |
72 | 72 | |
73 | - return $out . '</div></div>'; |
|
73 | + return $out.'</div></div>'; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | $out = ''; |
85 | 85 | foreach ($var as $i => $v) { |
86 | 86 | if (is_array($v) || (is_object($v) && $v instanceof Iterator)) { |
87 | - $out .= $i . ' (' . (is_array($v) ? 'array' : 'object: ' . get_class($v)) . ')'; |
|
87 | + $out .= $i.' ('.(is_array($v) ? 'array' : 'object: '.get_class($v)).')'; |
|
88 | 88 | if ($v === $scope) { |
89 | - $out .= ' (current scope):<div style="background:#ccc;padding-left:20px;">' . $this->export($v, $scope) . '</div>'; |
|
89 | + $out .= ' (current scope):<div style="background:#ccc;padding-left:20px;">'.$this->export($v, $scope).'</div>'; |
|
90 | 90 | } else { |
91 | - $out .= ':<div style="padding-left:20px;">' . $this->export($v, $scope) . '</div>'; |
|
91 | + $out .= ':<div style="padding-left:20px;">'.$this->export($v, $scope).'</div>'; |
|
92 | 92 | } |
93 | 93 | } elseif (is_object($v)) { |
94 | - $out .= $this->exportObj($i . ' (object: ' . get_class($v) . '):', $v); |
|
94 | + $out .= $this->exportObj($i.' (object: '.get_class($v).'):', $v); |
|
95 | 95 | } else { |
96 | - $out .= $this->exportVar($i . ' = ', $v); |
|
96 | + $out .= $this->exportVar($i.' = ', $v); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | protected function exportVar($i, $v) |
110 | 110 | { |
111 | 111 | if (is_string($v) || is_bool($v) || is_numeric($v)) { |
112 | - return $i . htmlentities(var_export($v, true)) . '<br />'; |
|
112 | + return $i.htmlentities(var_export($v, true)).'<br />'; |
|
113 | 113 | } elseif (is_null($v)) { |
114 | - return $i . 'null<br />'; |
|
114 | + return $i.'null<br />'; |
|
115 | 115 | } elseif (is_resource($v)) { |
116 | - return $i . 'resource(' . get_resource_type($v) . ')<br />'; |
|
116 | + return $i.'resource('.get_resource_type($v).')<br />'; |
|
117 | 117 | } else { |
118 | - return $i . htmlentities(var_export($v, true)) . '<br />'; |
|
118 | + return $i.htmlentities(var_export($v, true)).'<br />'; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | protected function exportObj($i, $obj) |
129 | 129 | { |
130 | 130 | if (array_search($obj, $this->outputObjects, true) !== false) { |
131 | - return $i . ' [recursion, skipped]<br />'; |
|
131 | + return $i.' [recursion, skipped]<br />'; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $this->outputObjects[] = $obj; |
135 | 135 | |
136 | - $list = (array)$obj; |
|
136 | + $list = (array) $obj; |
|
137 | 137 | |
138 | - $protectedLength = strlen(get_class($obj)) + 2; |
|
138 | + $protectedLength = strlen(get_class($obj))+2; |
|
139 | 139 | |
140 | 140 | $out = array(); |
141 | 141 | |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | |
154 | 154 | $params = array(); |
155 | 155 | foreach ($method->getParameters() as $param) { |
156 | - $params[] = ($param->isPassedByReference() ? '&' : '') . '$' . $param->getName() . ($param->isOptional() ? ' = ' . var_export($param->getDefaultValue(), true) : ''); |
|
156 | + $params[] = ($param->isPassedByReference() ? '&' : '').'$'.$param->getName().($param->isOptional() ? ' = '.var_export($param->getDefaultValue(), true) : ''); |
|
157 | 157 | } |
158 | 158 | |
159 | - $out['method'] .= '(method) ' . $method->getName() . '(' . implode(', ', $params) . ')<br />'; |
|
159 | + $out['method'] .= '(method) '.$method->getName().'('.implode(', ', $params).')<br />'; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | $out[$key] = ''; |
176 | 176 | } |
177 | 177 | |
178 | - $out[$key] .= '(' . $key . ') '; |
|
178 | + $out[$key] .= '('.$key.') '; |
|
179 | 179 | |
180 | 180 | if (is_array($attributeValue)) { |
181 | - $out[$key] .= $attributeName . ' (array):<br /> |
|
182 | - <div style="padding-left:20px;">' . $this->export($attributeValue, false) . '</div>'; |
|
181 | + $out[$key] .= $attributeName.' (array):<br /> |
|
182 | + <div style="padding-left:20px;">' . $this->export($attributeValue, false).'</div>'; |
|
183 | 183 | } elseif (is_object($attributeValue)) { |
184 | - $out[$key] .= $this->exportObj($attributeName . ' (object: ' . get_class($attributeValue) . '):', $attributeValue); |
|
184 | + $out[$key] .= $this->exportObj($attributeName.' (object: '.get_class($attributeValue).'):', $attributeValue); |
|
185 | 185 | } else { |
186 | - $out[$key] .= $this->exportVar($attributeName . ' = ', $attributeValue); |
|
186 | + $out[$key] .= $this->exportVar($attributeName.' = ', $attributeValue); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - $return = $i . '<br /><div style="padding-left:20px;">'; |
|
190 | + $return = $i.'<br /><div style="padding-left:20px;">'; |
|
191 | 191 | |
192 | 192 | if (!empty($out['method'])) { |
193 | 193 | $return .= $out['method']; |
@@ -205,6 +205,6 @@ discard block |
||
205 | 205 | $return .= $out['private']; |
206 | 206 | } |
207 | 207 | |
208 | - return $return . '</div>'; |
|
208 | + return $return.'</div>'; |
|
209 | 209 | } |
210 | 210 | } |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | |
61 | 61 | if ($tpl === null) { |
62 | 62 | throw new CompilationException($compiler, |
63 | - 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
63 | + 'Load Templates : Resource "'.$resource.':'.$identifier.'" not found.'); |
|
64 | 64 | } elseif ($tpl === false) { |
65 | 65 | throw new CompilationException($compiler, |
66 | - 'Load Templates : Resource "' . $resource . '" does not support includes.'); |
|
66 | + 'Load Templates : Resource "'.$resource.'" does not support includes.'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $cmp = clone $compiler; |
@@ -75,23 +75,23 @@ discard block |
||
75 | 75 | $compiler->addUsedPlugin($plugin, $type); |
76 | 76 | } |
77 | 77 | |
78 | - $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n"; |
|
78 | + $out = '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n"; |
|
79 | 79 | |
80 | 80 | $modCheck = $tpl->getIsModifiedCode(); |
81 | 81 | |
82 | 82 | if ($modCheck) { |
83 | - $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }'; |
|
83 | + $out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }'; |
|
84 | 84 | } else { |
85 | 85 | $out .= 'try { |
86 | - $tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '"); |
|
86 | + $tpl = $this->templateFactory("' . $resource.'", "'.$identifier.'"); |
|
87 | 87 | } catch (Dwoo\Exception $e) { |
88 | - $this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING); |
|
88 | + $this->triggerError(\'Load Templates : Resource <em>' . $resource.'</em> was not added to Dwoo, can not extend <em>'.$identifier.'</em>\', E_USER_WARNING); |
|
89 | 89 | } |
90 | 90 | if ($tpl === null) |
91 | - $this->triggerError(\'Load Templates : Resource "' . $resource . ':' . $identifier . '" was not found.\', E_USER_WARNING); |
|
91 | + $this->triggerError(\'Load Templates : Resource "' . $resource.':'.$identifier.'" was not found.\', E_USER_WARNING); |
|
92 | 92 | elseif ($tpl === false) |
93 | - $this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING); |
|
94 | -if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }'; |
|
93 | + $this->triggerError(\'Load Templates : Resource "' . $resource.'" does not support extends.\', E_USER_WARNING); |
|
94 | +if ($tpl->getUid() != "' . $tpl->getUid().'") { ob_end_clean(); return false; }'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return $out; |
@@ -31,58 +31,58 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class PluginLoadTemplates extends Plugin implements ICompilable |
33 | 33 | { |
34 | - /** |
|
35 | - * @param Compiler $compiler |
|
36 | - * @param string $file |
|
37 | - * |
|
38 | - * @return string |
|
39 | - * @throws CompilationException |
|
40 | - */ |
|
41 | - public static function compile(Compiler $compiler, $file) |
|
42 | - { |
|
43 | - $file = substr($file, 1, - 1); |
|
34 | + /** |
|
35 | + * @param Compiler $compiler |
|
36 | + * @param string $file |
|
37 | + * |
|
38 | + * @return string |
|
39 | + * @throws CompilationException |
|
40 | + */ |
|
41 | + public static function compile(Compiler $compiler, $file) |
|
42 | + { |
|
43 | + $file = substr($file, 1, - 1); |
|
44 | 44 | |
45 | - if ($file === '') { |
|
46 | - return ''; |
|
47 | - } |
|
45 | + if ($file === '') { |
|
46 | + return ''; |
|
47 | + } |
|
48 | 48 | |
49 | - if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
50 | - // resource:identifier given, extract them |
|
51 | - $resource = $m[1]; |
|
52 | - $identifier = $m[2]; |
|
53 | - } else { |
|
54 | - // get the current template's resource |
|
55 | - $resource = $compiler->getCore()->getTemplate()->getResourceName(); |
|
56 | - $identifier = $file; |
|
57 | - } |
|
49 | + if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
50 | + // resource:identifier given, extract them |
|
51 | + $resource = $m[1]; |
|
52 | + $identifier = $m[2]; |
|
53 | + } else { |
|
54 | + // get the current template's resource |
|
55 | + $resource = $compiler->getCore()->getTemplate()->getResourceName(); |
|
56 | + $identifier = $file; |
|
57 | + } |
|
58 | 58 | |
59 | - $tpl = $compiler->getCore()->templateFactory($resource, $identifier); |
|
59 | + $tpl = $compiler->getCore()->templateFactory($resource, $identifier); |
|
60 | 60 | |
61 | - if ($tpl === null) { |
|
62 | - throw new CompilationException($compiler, |
|
63 | - 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
64 | - } elseif ($tpl === false) { |
|
65 | - throw new CompilationException($compiler, |
|
66 | - 'Load Templates : Resource "' . $resource . '" does not support includes.'); |
|
67 | - } |
|
61 | + if ($tpl === null) { |
|
62 | + throw new CompilationException($compiler, |
|
63 | + 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
64 | + } elseif ($tpl === false) { |
|
65 | + throw new CompilationException($compiler, |
|
66 | + 'Load Templates : Resource "' . $resource . '" does not support includes.'); |
|
67 | + } |
|
68 | 68 | |
69 | - $cmp = clone $compiler; |
|
70 | - $cmp->compile($compiler->getCore(), $tpl); |
|
71 | - foreach ($cmp->getTemplatePlugins() as $template => $args) { |
|
72 | - $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']); |
|
73 | - } |
|
74 | - foreach ($cmp->getUsedPlugins() as $plugin => $type) { |
|
75 | - $compiler->addUsedPlugin($plugin, $type); |
|
76 | - } |
|
69 | + $cmp = clone $compiler; |
|
70 | + $cmp->compile($compiler->getCore(), $tpl); |
|
71 | + foreach ($cmp->getTemplatePlugins() as $template => $args) { |
|
72 | + $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']); |
|
73 | + } |
|
74 | + foreach ($cmp->getUsedPlugins() as $plugin => $type) { |
|
75 | + $compiler->addUsedPlugin($plugin, $type); |
|
76 | + } |
|
77 | 77 | |
78 | - $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n"; |
|
78 | + $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n"; |
|
79 | 79 | |
80 | - $modCheck = $tpl->getIsModifiedCode(); |
|
80 | + $modCheck = $tpl->getIsModifiedCode(); |
|
81 | 81 | |
82 | - if ($modCheck) { |
|
83 | - $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }'; |
|
84 | - } else { |
|
85 | - $out .= 'try { |
|
82 | + if ($modCheck) { |
|
83 | + $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }'; |
|
84 | + } else { |
|
85 | + $out .= 'try { |
|
86 | 86 | $tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '"); |
87 | 87 | } catch (Dwoo\Exception $e) { |
88 | 88 | $this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | elseif ($tpl === false) |
93 | 93 | $this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING); |
94 | 94 | if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }'; |
95 | - } |
|
95 | + } |
|
96 | 96 | |
97 | - return $out; |
|
98 | - } |
|
97 | + return $out; |
|
98 | + } |
|
99 | 99 | } |
100 | 100 | \ No newline at end of file |
@@ -30,14 +30,14 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginCountSentences extends Plugin implements ICompilable |
32 | 32 | { |
33 | - /** |
|
34 | - * @param Compiler $compiler |
|
35 | - * @param string $value |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public static function compile(Compiler $compiler, $value) |
|
40 | - { |
|
41 | - return "preg_match_all('#[\\w\\pL]\\.(?![\\w\\pL])#u', $value, \$tmp)"; |
|
42 | - } |
|
33 | + /** |
|
34 | + * @param Compiler $compiler |
|
35 | + * @param string $value |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public static function compile(Compiler $compiler, $value) |
|
40 | + { |
|
41 | + return "preg_match_all('#[\\w\\pL]\\.(?![\\w\\pL])#u', $value, \$tmp)"; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -32,16 +32,16 @@ |
||
32 | 32 | */ |
33 | 33 | class PluginIndent extends Plugin implements ICompilable |
34 | 34 | { |
35 | - /** |
|
36 | - * @param Compiler $compiler |
|
37 | - * @param string $value |
|
38 | - * @param int $by |
|
39 | - * @param string $char |
|
40 | - * |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public static function compile(Compiler $compiler, $value, $by = 4, $char = ' ') |
|
44 | - { |
|
45 | - return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)"; |
|
46 | - } |
|
35 | + /** |
|
36 | + * @param Compiler $compiler |
|
37 | + * @param string $value |
|
38 | + * @param int $by |
|
39 | + * @param string $char |
|
40 | + * |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public static function compile(Compiler $compiler, $value, $by = 4, $char = ' ') |
|
44 | + { |
|
45 | + return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)"; |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -42,6 +42,6 @@ |
||
42 | 42 | */ |
43 | 43 | public static function compile(Compiler $compiler, $value, $by = 4, $char = ' ') |
44 | 44 | { |
45 | - return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)"; |
|
45 | + return "preg_replace('#^#m', '".str_repeat(substr($char, 1, - 1), trim($by, '"\''))."', $value)"; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -33,37 +33,37 @@ |
||
33 | 33 | */ |
34 | 34 | class PluginTruncate extends Plugin |
35 | 35 | { |
36 | - /** |
|
37 | - * @param string $value |
|
38 | - * @param int $length |
|
39 | - * @param string $etc |
|
40 | - * @param bool $break |
|
41 | - * @param bool $middle |
|
42 | - * |
|
43 | - * @return mixed|string |
|
44 | - */ |
|
45 | - public function process($value, $length = 80, $etc = '...', $break = false, $middle = false) |
|
46 | - { |
|
47 | - if ($length == 0) { |
|
48 | - return ''; |
|
49 | - } |
|
36 | + /** |
|
37 | + * @param string $value |
|
38 | + * @param int $length |
|
39 | + * @param string $etc |
|
40 | + * @param bool $break |
|
41 | + * @param bool $middle |
|
42 | + * |
|
43 | + * @return mixed|string |
|
44 | + */ |
|
45 | + public function process($value, $length = 80, $etc = '...', $break = false, $middle = false) |
|
46 | + { |
|
47 | + if ($length == 0) { |
|
48 | + return ''; |
|
49 | + } |
|
50 | 50 | |
51 | - $value = (string)$value; |
|
52 | - $etc = (string)$etc; |
|
53 | - $length = (int)$length; |
|
51 | + $value = (string)$value; |
|
52 | + $etc = (string)$etc; |
|
53 | + $length = (int)$length; |
|
54 | 54 | |
55 | - if (strlen($value) < $length) { |
|
56 | - return $value; |
|
57 | - } |
|
55 | + if (strlen($value) < $length) { |
|
56 | + return $value; |
|
57 | + } |
|
58 | 58 | |
59 | - $length = max($length - strlen($etc), 0); |
|
60 | - if ($break === false && $middle === false) { |
|
61 | - $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
62 | - } |
|
63 | - if ($middle === false) { |
|
64 | - return substr($value, 0, $length) . $etc; |
|
65 | - } |
|
59 | + $length = max($length - strlen($etc), 0); |
|
60 | + if ($break === false && $middle === false) { |
|
61 | + $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
62 | + } |
|
63 | + if ($middle === false) { |
|
64 | + return substr($value, 0, $length) . $etc; |
|
65 | + } |
|
66 | 66 | |
67 | - return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2)); |
|
68 | - } |
|
67 | + return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2)); |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -48,22 +48,22 @@ |
||
48 | 48 | return ''; |
49 | 49 | } |
50 | 50 | |
51 | - $value = (string)$value; |
|
52 | - $etc = (string)$etc; |
|
53 | - $length = (int)$length; |
|
51 | + $value = (string) $value; |
|
52 | + $etc = (string) $etc; |
|
53 | + $length = (int) $length; |
|
54 | 54 | |
55 | 55 | if (strlen($value) < $length) { |
56 | 56 | return $value; |
57 | 57 | } |
58 | 58 | |
59 | - $length = max($length - strlen($etc), 0); |
|
59 | + $length = max($length-strlen($etc), 0); |
|
60 | 60 | if ($break === false && $middle === false) { |
61 | - $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
61 | + $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length+1)); |
|
62 | 62 | } |
63 | 63 | if ($middle === false) { |
64 | - return substr($value, 0, $length) . $etc; |
|
64 | + return substr($value, 0, $length).$etc; |
|
65 | 65 | } |
66 | 66 | |
67 | - return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2)); |
|
67 | + return substr($value, 0, ceil($length/2)).$etc.substr($value, - floor($length/2)); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | \ No newline at end of file |