@@ -15,38 +15,38 @@ discard block |
||
15 | 15 | * @param string $sep |
16 | 16 | * @return mixed|string |
17 | 17 | */ |
18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = ''){ |
|
19 | 19 | |
20 | 20 | $modx = DocumentParser::getInstance(); |
21 | 21 | $o = ''; |
22 | 22 | |
23 | 23 | // process any TV commands in value |
24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
24 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
25 | 25 | $value = ProcessTVCommand($value, $name, $docid); |
26 | 26 | |
27 | 27 | $params = array(); |
28 | - if($paramstring) { |
|
28 | + if ($paramstring) { |
|
29 | 29 | $cp = explode("&", $paramstring); |
30 | - foreach($cp as $p => $v) { |
|
30 | + foreach ($cp as $p => $v) { |
|
31 | 31 | $v = trim($v); // trim |
32 | 32 | $ar = explode("=", $v); |
33 | - if(is_array($ar) && count($ar) == 2) { |
|
33 | + if (is_array($ar) && count($ar) == 2) { |
|
34 | 34 | $params[$ar[0]] = decodeParamValue($ar[1]); |
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | $id = "tv$name"; |
40 | - switch($format) { |
|
40 | + switch ($format) { |
|
41 | 41 | case 'image': |
42 | 42 | $images = parseInput($value, '||', 'array'); |
43 | - foreach($images as $image) { |
|
44 | - if(!is_array($image)) { |
|
43 | + foreach ($images as $image) { |
|
44 | + if (!is_array($image)) { |
|
45 | 45 | $image = explode('==', $image); |
46 | 46 | } |
47 | 47 | $src = $image[0]; |
48 | 48 | |
49 | - if($src) { |
|
49 | + if ($src) { |
|
50 | 50 | // We have a valid source |
51 | 51 | $attributes = ''; |
52 | 52 | $attr = array( |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | 'alt' => $modx->htmlspecialchars($params['alttext']), |
57 | 57 | 'style' => $params['style'] |
58 | 58 | ); |
59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
59 | + if (isset($params['align']) && $params['align'] != 'none') { |
|
60 | 60 | $attr['align'] = $params['align']; |
61 | 61 | } |
62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
63 | - $attributes .= ' ' . $params['attrib']; |
|
62 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
63 | + $attributes .= ' '.$params['attrib']; |
|
64 | 64 | |
65 | 65 | // Output the image with attributes |
66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
66 | + $o .= '<img'.rtrim($attributes).' />'; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | break; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | case "delim": // display as delimitted list |
72 | 72 | $value = parseInput($value, "||"); |
73 | 73 | $p = $params['format'] ? $params['format'] : " "; |
74 | - if($p == "\\n") { |
|
74 | + if ($p == "\\n") { |
|
75 | 75 | $p = "\n"; |
76 | 76 | } |
77 | 77 | $o = str_replace("||", $p, $value); |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | case "string": |
81 | 81 | $value = parseInput($value); |
82 | 82 | $format = strtolower($params['format']); |
83 | - if($format == 'upper case') { |
|
83 | + if ($format == 'upper case') { |
|
84 | 84 | $o = strtoupper($value); |
85 | - } else if($format == 'lower case') { |
|
85 | + } else if ($format == 'lower case') { |
|
86 | 86 | $o = strtolower($value); |
87 | - } else if($format == 'sentence case') { |
|
87 | + } else if ($format == 'sentence case') { |
|
88 | 88 | $o = ucfirst($value); |
89 | - } else if($format == 'capitalize') { |
|
89 | + } else if ($format == 'capitalize') { |
|
90 | 90 | $o = ucwords($value); |
91 | 91 | } else { |
92 | 92 | $o = $value; |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | break; |
95 | 95 | |
96 | 96 | case "date": |
97 | - if($value != '' || $params['default'] == 'Yes') { |
|
98 | - if(empty($value)) { |
|
97 | + if ($value != '' || $params['default'] == 'Yes') { |
|
98 | + if (empty($value)) { |
|
99 | 99 | $value = 'now'; |
100 | 100 | } |
101 | 101 | $timestamp = getUnixtimeFromDateString($value); |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $value = parseInput($value, "||", "array"); |
111 | 111 | $o = ''; |
112 | 112 | $countValue = count($value); |
113 | - for($i = 0; $i < $countValue; $i++) { |
|
113 | + for ($i = 0; $i < $countValue; $i++) { |
|
114 | 114 | list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
115 | - if(!$url) { |
|
115 | + if (!$url) { |
|
116 | 116 | $url = $name; |
117 | 117 | } |
118 | - if($url) { |
|
119 | - if($o) { |
|
118 | + if ($url) { |
|
119 | + if ($o) { |
|
120 | 120 | $o .= '<br />'; |
121 | 121 | } |
122 | 122 | $attributes = ''; |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | 'style' => $params['style'], |
129 | 129 | 'target' => $params['target'], |
130 | 130 | ); |
131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
131 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
132 | + $attributes .= ' '.$params['attrib']; // add extra |
|
133 | 133 | |
134 | 134 | // Output the link |
135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
135 | + $o .= '<a'.rtrim($attributes).'>'.($params['text'] ? $modx->htmlspecialchars($params['text']) : $name).'</a>'; |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | break; |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | $o = ''; |
145 | 145 | // Loop through a list of tags |
146 | 146 | $countValue = count($value); |
147 | - for($i = 0; $i < $countValue; $i++) { |
|
147 | + for ($i = 0; $i < $countValue; $i++) { |
|
148 | 148 | $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
149 | - if(!$tagvalue) { |
|
149 | + if (!$tagvalue) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | 'class' => $params['class'], |
158 | 158 | 'style' => $params['style'], |
159 | 159 | ); |
160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
160 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
161 | + $attributes .= ' '.$params['attrib']; // add extra |
|
162 | 162 | |
163 | 163 | // Output the HTML Tag |
164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
164 | + $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>'; |
|
165 | 165 | } |
166 | 166 | break; |
167 | 167 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $w = $params['w'] ? $params['w'] : '100%'; |
171 | 171 | $h = $params['h'] ? $params['h'] : '400px'; |
172 | 172 | $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">'; |
|
174 | 174 | $o .= $modx->htmlspecialchars($value); |
175 | 175 | $o .= '</textarea></div>'; |
176 | 176 | $replace_richtext = array($id); |
177 | 177 | // setup editors |
178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
178 | + if (!empty($replace_richtext) && !empty($richtexteditor)) { |
|
179 | 179 | // invoke OnRichTextEditorInit event |
180 | 180 | $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
181 | 181 | 'editor' => $richtexteditor, |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'width' => $w, |
185 | 185 | 'height' => $h |
186 | 186 | )); |
187 | - if(is_array($evtOut)) { |
|
187 | + if (is_array($evtOut)) { |
|
188 | 188 | $o .= implode("", $evtOut); |
189 | 189 | } |
190 | 190 | } |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | |
198 | 198 | case "viewport": |
199 | 199 | $value = parseInput($value); |
200 | - $id = '_' . time(); |
|
201 | - if(!$params['vpid']) { |
|
200 | + $id = '_'.time(); |
|
201 | + if (!$params['vpid']) { |
|
202 | 202 | $params['vpid'] = $id; |
203 | 203 | } |
204 | 204 | $sTag = "<iframe"; |
@@ -206,42 +206,42 @@ discard block |
||
206 | 206 | $autoMode = "0"; |
207 | 207 | $w = $params['width']; |
208 | 208 | $h = $params['height']; |
209 | - if($params['stretch'] == 'Yes') { |
|
209 | + if ($params['stretch'] == 'Yes') { |
|
210 | 210 | $w = "100%"; |
211 | 211 | $h = "100%"; |
212 | 212 | } |
213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
214 | - $autoMode = "3"; //both |
|
215 | - } else if($params['awidth'] == 'Yes') { |
|
213 | + if ($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
214 | + $autoMode = "3"; //both |
|
215 | + } else if ($params['awidth'] == 'Yes') { |
|
216 | 216 | $autoMode = "1"; //width only |
217 | - } else if($params['aheight'] == 'Yes') { |
|
218 | - $autoMode = "2"; //height only |
|
217 | + } else if ($params['aheight'] == 'Yes') { |
|
218 | + $autoMode = "2"; //height only |
|
219 | 219 | } |
220 | 220 | |
221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
221 | + $modx->regClientStartupScript(MODX_MANAGER_URL."media/script/bin/viewport.js", array( |
|
222 | 222 | 'name' => 'viewport', |
223 | 223 | 'version' => '0', |
224 | 224 | 'plaintext' => false |
225 | 225 | )); |
226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
227 | - if($params['class']) { |
|
228 | - $o .= " class='" . $params['class'] . "' "; |
|
226 | + $o = $sTag." id='".$params['vpid']."' name='".$params['vpid']."' "; |
|
227 | + if ($params['class']) { |
|
228 | + $o .= " class='".$params['class']."' "; |
|
229 | 229 | } |
230 | - if($params['style']) { |
|
231 | - $o .= " style='" . $params['style'] . "' "; |
|
230 | + if ($params['style']) { |
|
231 | + $o .= " style='".$params['style']."' "; |
|
232 | 232 | } |
233 | - if($params['attrib']) { |
|
234 | - $o .= $params['attrib'] . " "; |
|
233 | + if ($params['attrib']) { |
|
234 | + $o .= $params['attrib']." "; |
|
235 | 235 | } |
236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
236 | + $o .= "scrolling='".($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto"))."' "; |
|
237 | + $o .= "src='".$value."' frameborder='".$params['borsize']."' "; |
|
238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'".$params['vpid']."\\',".$autoMode.")',100);\" width='".$w."' height='".$h."' "; |
|
239 | 239 | $o .= ">"; |
240 | 240 | $o .= $eTag; |
241 | 241 | break; |
242 | 242 | |
243 | 243 | case "datagrid": |
244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
244 | + include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; |
|
245 | 245 | $grd = new DataGrid('', $value); |
246 | 246 | |
247 | 247 | $grd->noRecordMsg = $params['egmsg']; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | case 'htmlentities': |
278 | 278 | $value = parseInput($value); |
279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
279 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
280 | 280 | // remove delimiter from checkbox and listbox-multiple TVs |
281 | 281 | $value = str_replace('||', '', $value); |
282 | 282 | } |
@@ -287,33 +287,33 @@ discard block |
||
287 | 287 | $widget_output = ''; |
288 | 288 | $o = ''; |
289 | 289 | /* If we are loading a file */ |
290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
292 | - if(!file_exists($file_name)) { |
|
293 | - $widget_output = $file_name . ' does not exist'; |
|
290 | + if (substr($params['output'], 0, 5) == "@FILE") { |
|
291 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 6)); |
|
292 | + if (!file_exists($file_name)) { |
|
293 | + $widget_output = $file_name.' does not exist'; |
|
294 | 294 | } else { |
295 | 295 | $widget_output = file_get_contents($file_name); |
296 | 296 | } |
297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
299 | - if(!file_exists($file_name)) { |
|
300 | - $widget_output = $file_name . ' does not exist'; |
|
297 | + } elseif (substr($params['output'], 0, 8) == '@INCLUDE') { |
|
298 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 9)); |
|
299 | + if (!file_exists($file_name)) { |
|
300 | + $widget_output = $file_name.' does not exist'; |
|
301 | 301 | } else { |
302 | 302 | /* The included file needs to set $widget_output. Can be string, array, object */ |
303 | 303 | include $file_name; |
304 | 304 | } |
305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
305 | + } elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
306 | 306 | $chunk_name = trim(substr($params['output'], 7)); |
307 | 307 | $widget_output = $modx->getChunk($chunk_name); |
308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
308 | + } elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
309 | 309 | $eval_str = trim(substr($params['output'], 6)); |
310 | 310 | $widget_output = eval($eval_str); |
311 | - } elseif($value !== '') { |
|
311 | + } elseif ($value !== '') { |
|
312 | 312 | $widget_output = $params['output']; |
313 | 313 | } else { |
314 | 314 | $widget_output = ''; |
315 | 315 | } |
316 | - if(is_string($widget_output)) { |
|
316 | + if (is_string($widget_output)) { |
|
317 | 317 | $_ = $modx->config['enable_filter']; |
318 | 318 | $modx->config['enable_filter'] = 1; |
319 | 319 | $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | default: |
328 | 328 | $value = parseInput($value); |
329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
329 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
330 | 330 | // add separator |
331 | 331 | $value = explode('||', $value); |
332 | 332 | $value = implode($sep, $value); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param string $s |
342 | 342 | * @return string |
343 | 343 | */ |
344 | -function decodeParamValue($s) { |
|
344 | +function decodeParamValue($s){ |
|
345 | 345 | $s = str_replace("%3D", '=', $s); // = |
346 | 346 | return str_replace("%26", '&', $s); // & |
347 | 347 | } |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | * @param bool $columns |
356 | 356 | * @return array|string |
357 | 357 | */ |
358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
358 | +function parseInput($src, $delim = "||", $type = "string", $columns = true){ // type can be: string, array |
|
359 | 359 | $modx = DocumentParser::getInstance(); |
360 | - if($modx->db->isResult($src)) { |
|
360 | + if ($modx->db->isResult($src)) { |
|
361 | 361 | // must be a recordset |
362 | 362 | $rows = array(); |
363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
363 | + while ($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
364 | 364 | return ($type == "array") ? $rows : implode($delim, $rows); |
365 | 365 | } else { |
366 | 366 | // must be a text |
367 | - if($type == "array") { |
|
367 | + if ($type == "array") { |
|
368 | 368 | return explode($delim, $src); |
369 | 369 | } else { |
370 | 370 | return $src; |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | * @param string $value |
377 | 377 | * @return bool|false|int |
378 | 378 | */ |
379 | -function getUnixtimeFromDateString($value) { |
|
379 | +function getUnixtimeFromDateString($value){ |
|
380 | 380 | $timestamp = false; |
381 | 381 | // Check for MySQL or legacy style date |
382 | 382 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
383 | 383 | $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
384 | 384 | $matches = array(); |
385 | - if(strpos($value, '-') !== false) { |
|
386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
385 | + if (strpos($value, '-') !== false) { |
|
386 | + if (preg_match($date_match_1, $value, $matches)) { |
|
387 | 387 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
388 | + } elseif (preg_match($date_match_2, $value, $matches)) { |
|
389 | 389 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
390 | 390 | } |
391 | 391 | } |
392 | 392 | // If those didn't work, use strtotime to figure out the date |
393 | - if($timestamp === false || $timestamp === -1) { |
|
393 | + if ($timestamp === false || $timestamp === -1) { |
|
394 | 394 | $timestamp = strtotime($value); |
395 | 395 | } |
396 | 396 | return $timestamp; |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | * @param array $tvsArray |
13 | 13 | * @return string |
14 | 14 | */ |
15 | -function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) { |
|
15 | +function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()){ |
|
16 | 16 | $modx = DocumentParser::getInstance(); |
17 | 17 | global $_style; |
18 | 18 | global $_lang; |
19 | 19 | global $content; |
20 | 20 | global $which_browser; |
21 | 21 | |
22 | - if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
22 | + if (substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
23 | 23 | $eval_str = trim(substr($default_text, 7)); |
24 | 24 | $default_text = eval($eval_str); |
25 | 25 | $field_value = $default_text; |
@@ -27,74 +27,74 @@ discard block |
||
27 | 27 | |
28 | 28 | $field_html = ''; |
29 | 29 | $cimode = strpos($field_type, ':'); |
30 | - if($cimode === false) { |
|
31 | - switch($field_type) { |
|
30 | + if ($cimode === false) { |
|
31 | + switch ($field_type) { |
|
32 | 32 | |
33 | 33 | case "text": // handler for regular text boxes |
34 | 34 | case "rawtext"; // non-htmlentity converted text boxes |
35 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
35 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" />'; |
|
36 | 36 | break; |
37 | 37 | case "email": // handles email input fields |
38 | - $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
38 | + $field_html .= '<input type="email" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%"/>'; |
|
39 | 39 | break; |
40 | 40 | case "number": // handles the input of numbers |
41 | - $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
41 | + $field_html .= '<input type="number" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
42 | 42 | break; |
43 | 43 | case "textareamini": // handler for textarea mini boxes |
44 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
44 | + $field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>'; |
|
45 | 45 | break; |
46 | 46 | case "textarea": // handler for textarea boxes |
47 | 47 | case "rawtextarea": // non-htmlentity convertex textarea boxes |
48 | 48 | case "htmlarea": // handler for textarea boxes (deprecated) |
49 | 49 | case "richtext": // handler for textarea boxes |
50 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
50 | + $field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>'; |
|
51 | 51 | break; |
52 | 52 | case "date": |
53 | 53 | $field_id = str_replace(array( |
54 | 54 | '-', |
55 | 55 | '.' |
56 | 56 | ), '_', urldecode($field_id)); |
57 | - if($field_value == '') { |
|
57 | + if ($field_value == '') { |
|
58 | 58 | $field_value = 0; |
59 | 59 | } |
60 | - $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
61 | - $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
60 | + $field_html .= '<input id="tv'.$field_id.'" name="tv'.$field_id.'" class="DatePicker" type="text" value="'.($field_value == 0 || !isset($field_value) ? "" : $field_value).'" onblur="documentDirty=true;" />'; |
|
61 | + $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].value=\'\';document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="'.$_style["actions_calendar_delete"].'"></i></a>'; |
|
62 | 62 | |
63 | 63 | break; |
64 | 64 | case "dropdown": // handler for select boxes |
65 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
65 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" size="1" onchange="documentDirty=true;">'; |
|
66 | 66 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
67 | - while(list($item, $itemvalue) = each($index_list)) { |
|
67 | + while (list($item, $itemvalue) = each($index_list)) { |
|
68 | 68 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
69 | - if(strlen($itemvalue) == 0) { |
|
69 | + if (strlen($itemvalue) == 0) { |
|
70 | 70 | $itemvalue = $item; |
71 | 71 | } |
72 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
72 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
73 | 73 | } |
74 | 74 | $field_html .= "</select>"; |
75 | 75 | break; |
76 | 76 | case "listbox": // handler for select boxes |
77 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
77 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" onchange="documentDirty=true;" size="8">'; |
|
78 | 78 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
79 | - while(list($item, $itemvalue) = each($index_list)) { |
|
79 | + while (list($item, $itemvalue) = each($index_list)) { |
|
80 | 80 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
81 | - if(strlen($itemvalue) == 0) { |
|
81 | + if (strlen($itemvalue) == 0) { |
|
82 | 82 | $itemvalue = $item; |
83 | 83 | } |
84 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
84 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
85 | 85 | } |
86 | 86 | $field_html .= "</select>"; |
87 | 87 | break; |
88 | 88 | case "listbox-multiple": // handler for select boxes where you can choose multiple items |
89 | 89 | $field_value = explode("||", $field_value); |
90 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
90 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
91 | 91 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
92 | - while(list($item, $itemvalue) = each($index_list)) { |
|
92 | + while (list($item, $itemvalue) = each($index_list)) { |
|
93 | 93 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
94 | - if(strlen($itemvalue) == 0) { |
|
94 | + if (strlen($itemvalue) == 0) { |
|
95 | 95 | $itemvalue = $item; |
96 | 96 | } |
97 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
97 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.(in_array($itemvalue, $field_value) ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
98 | 98 | } |
99 | 99 | $field_html .= "</select>"; |
100 | 100 | break; |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | 'ftp://' => 'ftp://', |
107 | 107 | 'mailto:' => 'mailto:' |
108 | 108 | ); |
109 | - $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
110 | - foreach($urls as $k => $v) { |
|
111 | - if(strpos($field_value, $v) === false) { |
|
112 | - $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
109 | + $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv'.$field_id.'_prefix" name="tv'.$field_id.'_prefix" onchange="documentDirty=true;">'; |
|
110 | + foreach ($urls as $k => $v) { |
|
111 | + if (strpos($field_value, $v) === false) { |
|
112 | + $field_html .= '<option value="'.$v.'">'.$k.'</option>'; |
|
113 | 113 | } else { |
114 | 114 | $field_value = str_replace($v, '', $field_value); |
115 | - $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
115 | + $field_html .= '<option value="'.$v.'" selected="selected">'.$k.'</option>'; |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | $field_html .= '</select></td><td>'; |
119 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
119 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" width="100" '.$field_style.' onchange="documentDirty=true;" /></td></tr></table>'; |
|
120 | 120 | break; |
121 | 121 | case 'checkbox': // handles check boxes |
122 | 122 | $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
125 | 125 | static $i = 0; |
126 | 126 | $_ = array(); |
127 | - foreach($index_list as $c => $item) { |
|
128 | - if(is_array($item)) { |
|
127 | + foreach ($index_list as $c => $item) { |
|
128 | + if (is_array($item)) { |
|
129 | 129 | $name = trim($item[0]); |
130 | 130 | $value = isset($item[1]) ? $item[1] : $name; |
131 | 131 | } else { |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | case "option": // handles radio buttons |
152 | 152 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
153 | 153 | static $i = 0; |
154 | - while(list($item, $itemvalue) = each($index_list)) { |
|
154 | + while (list($item, $itemvalue) = each($index_list)) { |
|
155 | 155 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
156 | - if(strlen($itemvalue) == 0) { |
|
156 | + if (strlen($itemvalue) == 0) { |
|
157 | 157 | $itemvalue = $item; |
158 | 158 | } |
159 | - $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
159 | + $field_html .= '<input type="radio" value="'.$modx->htmlspecialchars($itemvalue).'" id="tv_'.$i.'" name="tv'.$field_id.'" '.($itemvalue == $field_value ? 'checked="checked"' : '').' onchange="documentDirty=true;" /><label for="tv_'.$i.'" class="radio">'.$item.'</label><br />'; |
|
160 | 160 | $i++; |
161 | 161 | } |
162 | 162 | break; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | global $_lang; |
165 | 165 | global $ResourceManagerLoaded; |
166 | 166 | global $content, $use_editor, $which_editor; |
167 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
167 | + if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
168 | 168 | $field_html .= " |
169 | 169 | <script type=\"text/javascript\"> |
170 | 170 | /* <![CDATA[ */ |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | lastImageCtrl = ctrl; |
187 | 187 | var w = screen.width * 0.5; |
188 | 188 | var h = screen.height * 0.5; |
189 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
189 | + OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
190 | 190 | } |
191 | 191 | function BrowseFileServer(ctrl) { |
192 | 192 | lastFileCtrl = ctrl; |
193 | 193 | var w = screen.width * 0.5; |
194 | 194 | var h = screen.height * 0.5; |
195 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
195 | + OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
196 | 196 | } |
197 | 197 | function SetUrlChange(el) { |
198 | 198 | if ('createEvent' in document) { |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | </script>"; |
227 | 227 | $ResourceManagerLoaded = true; |
228 | 228 | } |
229 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
229 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseServer(\'tv'.$field_id.'\')" />'; |
|
230 | 230 | break; |
231 | 231 | case "file": // handles the input of file uploads |
232 | 232 | /* Modified by Timon for use with resource browser */ |
233 | 233 | global $_lang; |
234 | 234 | global $ResourceManagerLoaded; |
235 | 235 | global $content, $use_editor, $which_editor; |
236 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
236 | + if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
237 | 237 | /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
238 | 238 | $field_html .= " |
239 | 239 | <script type=\"text/javascript\"> |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | lastImageCtrl = ctrl; |
257 | 257 | var w = screen.width * 0.5; |
258 | 258 | var h = screen.height * 0.5; |
259 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
259 | + OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
260 | 260 | } |
261 | 261 | function BrowseFileServer(ctrl) { |
262 | 262 | lastFileCtrl = ctrl; |
263 | 263 | var w = screen.width * 0.5; |
264 | 264 | var h = screen.height * 0.5; |
265 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
265 | + OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
266 | 266 | } |
267 | 267 | function SetUrlChange(el) { |
268 | 268 | if ('createEvent' in document) { |
@@ -296,39 +296,39 @@ discard block |
||
296 | 296 | </script>"; |
297 | 297 | $ResourceManagerLoaded = true; |
298 | 298 | } |
299 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
299 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseFileServer(\'tv'.$field_id.'\')" />'; |
|
300 | 300 | |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'custom_tv': |
304 | 304 | $custom_output = ''; |
305 | 305 | /* If we are loading a file */ |
306 | - if(substr($field_elements, 0, 5) == "@FILE") { |
|
307 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
308 | - if(!file_exists($file_name)) { |
|
309 | - $custom_output = $file_name . ' does not exist'; |
|
306 | + if (substr($field_elements, 0, 5) == "@FILE") { |
|
307 | + $file_name = MODX_BASE_PATH.trim(substr($field_elements, 6)); |
|
308 | + if (!file_exists($file_name)) { |
|
309 | + $custom_output = $file_name.' does not exist'; |
|
310 | 310 | } else { |
311 | 311 | $custom_output = file_get_contents($file_name); |
312 | 312 | } |
313 | - } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
314 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
315 | - if(!file_exists($file_name)) { |
|
316 | - $custom_output = $file_name . ' does not exist'; |
|
313 | + } elseif (substr($field_elements, 0, 8) == '@INCLUDE') { |
|
314 | + $file_name = MODX_BASE_PATH.trim(substr($field_elements, 9)); |
|
315 | + if (!file_exists($file_name)) { |
|
316 | + $custom_output = $file_name.' does not exist'; |
|
317 | 317 | } else { |
318 | 318 | ob_start(); |
319 | 319 | include $file_name; |
320 | 320 | $custom_output = ob_get_contents(); |
321 | 321 | ob_end_clean(); |
322 | 322 | } |
323 | - } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
323 | + } elseif (substr($field_elements, 0, 6) == "@CHUNK") { |
|
324 | 324 | $chunk_name = trim(substr($field_elements, 7)); |
325 | 325 | $chunk_body = $modx->getChunk($chunk_name); |
326 | - if($chunk_body == false) { |
|
327 | - $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
326 | + if ($chunk_body == false) { |
|
327 | + $custom_output = $_lang['chunk_no_exist'].'('.$_lang['htmlsnippet_name'].':'.$chunk_name.')'; |
|
328 | 328 | } else { |
329 | 329 | $custom_output = $chunk_body; |
330 | 330 | } |
331 | - } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
331 | + } elseif (substr($field_elements, 0, 5) == "@EVAL") { |
|
332 | 332 | $eval_str = trim(substr($field_elements, 6)); |
333 | 333 | $custom_output = eval($eval_str); |
334 | 334 | } else { |
@@ -349,15 +349,15 @@ discard block |
||
349 | 349 | break; |
350 | 350 | |
351 | 351 | default: // the default handler -- for errors, mostly |
352 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
352 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' onchange="documentDirty=true;" />'; |
|
353 | 353 | |
354 | 354 | } // end switch statement |
355 | 355 | } else { |
356 | 356 | $custom = explode(":", $field_type); |
357 | 357 | $custom_output = ''; |
358 | - $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
359 | - if(!file_exists($file_name)) { |
|
360 | - $custom_output = $file_name . ' does not exist'; |
|
358 | + $file_name = MODX_BASE_PATH.'assets/tvs/'.$custom['1'].'/'.$custom['1'].'.customtv.php'; |
|
359 | + if (!file_exists($file_name)) { |
|
360 | + $custom_output = $file_name.' does not exist'; |
|
361 | 361 | } else { |
362 | 362 | ob_start(); |
363 | 363 | include $file_name; |
@@ -384,13 +384,13 @@ discard block |
||
384 | 384 | * @param string|array|mysqli_result $v |
385 | 385 | * @return array |
386 | 386 | */ |
387 | -function ParseIntputOptions($v) { |
|
387 | +function ParseIntputOptions($v){ |
|
388 | 388 | $modx = DocumentParser::getInstance(); |
389 | 389 | $a = array(); |
390 | - if(is_array($v)) { |
|
390 | + if (is_array($v)) { |
|
391 | 391 | return $v; |
392 | - } else if($modx->db->isResult($v)) { |
|
393 | - while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
392 | + } else if ($modx->db->isResult($v)) { |
|
393 | + while ($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
394 | 394 | } else { |
395 | 395 | $a = explode("||", $v); |
396 | 396 | } |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | 6 | // PROCESSOR FIRST |
7 | -if($_SESSION['mgrRole'] == 1) { |
|
8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
7 | +if ($_SESSION['mgrRole'] == 1) { |
|
8 | + if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | 9 | $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
10 | - if(!empty($current)) { |
|
10 | + if (!empty($current)) { |
|
11 | 11 | $modx->manager->setSystemChecksum($current); |
12 | 12 | $modx->clearCache('full'); |
13 | 13 | $modx->config['sys_files_checksum'] = $current; |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | $warningspresent = 0; |
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
22 | -if ($sysfiles_check!=='0'){ |
|
22 | +if ($sysfiles_check !== '0') { |
|
23 | 23 | $warningspresent = 1; |
24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
25 | 25 | } |
26 | 26 | |
27 | -if (is_writable("includes/config.inc.php")){ |
|
27 | +if (is_writable("includes/config.inc.php")) { |
|
28 | 28 | // Warn if world writable |
29 | - if(@fileperms('includes/config.inc.php') & 0x0002) { |
|
29 | + if (@fileperms('includes/config.inc.php') & 0x0002) { |
|
30 | 30 | $warningspresent = 1; |
31 | 31 | $warnings[] = array($_lang['configcheck_configinc']); |
32 | 32 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $warnings[] = array($_lang['configcheck_php_gdzip']); |
43 | 43 | } |
44 | 44 | |
45 | -if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | - if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
45 | +if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | + if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
47 | 47 | if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) { |
48 | 48 | $warningspresent = 1; |
49 | 49 | $warnings[] = array($_lang['configcheck_validate_referer']); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | // check for Template Switcher plugin |
55 | -if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | - if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
55 | +if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | + if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
57 | 57 | $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'"); |
58 | 58 | $row = $modx->db->getRow($rs); |
59 | - if($row && $row['disabled'] == 0) { |
|
59 | + if ($row && $row['disabled'] == 0) { |
|
60 | 60 | $warningspresent = 1; |
61 | 61 | $warnings[] = array($_lang['configcheck_templateswitcher_present']); |
62 | 62 | $tplName = $row['name']; |
@@ -120,36 +120,36 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - function checkSiteCache() { |
|
123 | + function checkSiteCache(){ |
|
124 | 124 | $modx = DocumentParser::getInstance(); |
125 | - $checked= true; |
|
126 | - if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
|
127 | - $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php'); |
|
125 | + $checked = true; |
|
126 | + if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) { |
|
127 | + $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php'); |
|
128 | 128 | } |
129 | 129 | return $checked; |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | -if (!is_writable(MODX_BASE_PATH . "assets/cache/")) { |
|
133 | +if (!is_writable(MODX_BASE_PATH."assets/cache/")) { |
|
134 | 134 | $warningspresent = 1; |
135 | 135 | $warnings[] = array($_lang['configcheck_cache']); |
136 | 136 | } |
137 | 137 | |
138 | 138 | if (!checkSiteCache()) { |
139 | 139 | $warningspresent = 1; |
140 | - $warnings[]= array($lang['configcheck_sitecache_integrity']); |
|
140 | + $warnings[] = array($lang['configcheck_sitecache_integrity']); |
|
141 | 141 | } |
142 | 142 | |
143 | -if (!is_writable(MODX_BASE_PATH . "assets/images/")) { |
|
143 | +if (!is_writable(MODX_BASE_PATH."assets/images/")) { |
|
144 | 144 | $warningspresent = 1; |
145 | 145 | $warnings[] = array($_lang['configcheck_images']); |
146 | 146 | } |
147 | 147 | |
148 | -if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) { |
|
148 | +if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) { |
|
149 | 149 | $warningspresent = 1; |
150 | 150 | $warnings[] = array($_lang['configcheck_rb_base_dir']); |
151 | 151 | } |
152 | -if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) { |
|
152 | +if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) { |
|
153 | 153 | $warningspresent = 1; |
154 | 154 | $warnings[] = array($_lang['configcheck_filemanager_path']); |
155 | 155 | } |
@@ -157,36 +157,36 @@ discard block |
||
157 | 157 | // clear file info cache |
158 | 158 | clearstatcache(); |
159 | 159 | |
160 | -if ($warningspresent==1) { |
|
160 | +if ($warningspresent == 1) { |
|
161 | 161 | |
162 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
162 | +if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3'; |
|
163 | 163 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
164 | 164 | |
165 | -for ($i=0;$i<count($warnings);$i++) { |
|
165 | +for ($i = 0; $i < count($warnings); $i++) { |
|
166 | 166 | switch ($warnings[$i][0]) { |
167 | 167 | case $_lang['configcheck_configinc']; |
168 | 168 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
169 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
169 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']); |
|
170 | 170 | break; |
171 | 171 | case $_lang['configcheck_installer'] : |
172 | 172 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
173 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
173 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']); |
|
174 | 174 | break; |
175 | 175 | case $_lang['configcheck_cache'] : |
176 | 176 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
177 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
177 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']); |
|
178 | 178 | break; |
179 | 179 | case $_lang['configcheck_images'] : |
180 | 180 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
181 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
181 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']); |
|
182 | 182 | break; |
183 | 183 | case $_lang['configcheck_sysfiles_mod']: |
184 | 184 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
185 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
186 | - if($modx->hasPermission('settings')) { |
|
187 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
185 | + $warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>'; |
|
186 | + if ($modx->hasPermission('settings')) { |
|
187 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>'; |
|
188 | 188 | } |
189 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
189 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']); |
|
190 | 190 | break; |
191 | 191 | case $_lang['configcheck_lang_difference'] : |
192 | 192 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -208,18 +208,18 @@ discard block |
||
208 | 208 | break; |
209 | 209 | case $_lang['configcheck_validate_referer'] : |
210 | 210 | $msg = $_lang['configcheck_validate_referer_msg']; |
211 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
211 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
212 | 212 | $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n"; |
213 | 213 | break; |
214 | 214 | case $_lang['configcheck_templateswitcher_present'] : |
215 | 215 | $msg = $_lang["configcheck_templateswitcher_present_msg"]; |
216 | - if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
217 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"]; |
|
216 | + if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
217 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"]; |
|
218 | 218 | } |
219 | - if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
220 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"]; |
|
219 | + if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
220 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"]; |
|
221 | 221 | } |
222 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
222 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
223 | 223 | $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n"; |
224 | 224 | break; |
225 | 225 | case $_lang['configcheck_rb_base_dir'] : |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $warnings[$i][1] = $_lang['configcheck_default_msg']; |
233 | 233 | } |
234 | 234 | |
235 | - $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ; |
|
235 | + $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : ""; |
|
236 | 236 | $config_check_results .= " |
237 | 237 | <fieldset> |
238 | 238 | <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p> |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')." |
242 | 242 | </fieldset> |
243 | 243 | "; |
244 | - if ($i!=count($warnings)-1) { |
|
244 | + if ($i != count($warnings) - 1) { |
|
245 | 245 | $config_check_results .= "<br />"; |
246 | 246 | } |
247 | 247 | } |
248 | - $_SESSION["mgrConfigCheck"]=true; |
|
248 | + $_SESSION["mgrConfigCheck"] = true; |
|
249 | 249 | } else { |
250 | 250 | $config_check_results = $_lang['configcheck_ok']; |
251 | 251 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class uploader { |
|
15 | +class uploader{ |
|
16 | 16 | |
17 | 17 | /** Release version */ |
18 | 18 | const VERSION = "2.54"; |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | |
73 | 73 | /** Next three properties are got from the current language file |
74 | 74 | * @var string */ |
75 | - protected $dateTimeFull; // Currently not used |
|
76 | - protected $dateTimeMid; // Currently not used |
|
75 | + protected $dateTimeFull; // Currently not used |
|
76 | + protected $dateTimeMid; // Currently not used |
|
77 | 77 | protected $dateTimeSmall; |
78 | 78 | |
79 | 79 | /** Contain Specified language labels |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | /** Magic method which allows read-only access to protected or private class properties |
105 | 105 | * @param string $property |
106 | 106 | * @return mixed */ |
107 | - public function __get($property) { |
|
107 | + public function __get($property){ |
|
108 | 108 | return property_exists($this, $property) ? $this->$property : null; |
109 | 109 | } |
110 | 110 | |
111 | - public function __construct($modx) { |
|
111 | + public function __construct($modx){ |
|
112 | 112 | |
113 | 113 | //MODX |
114 | 114 | try { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | // COOKIES INIT |
208 | 208 | $ip = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; |
209 | - $ip = '/^' . implode('\.', array($ip, $ip, $ip, $ip)) . '$/'; |
|
209 | + $ip = '/^'.implode('\.', array($ip, $ip, $ip, $ip)).'$/'; |
|
210 | 210 | if (preg_match($ip, $_SERVER['HTTP_HOST']) || |
211 | 211 | preg_match('/^[^\.]+$/', $_SERVER['HTTP_HOST']) |
212 | 212 | ) |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | ) { |
225 | 225 | list($unused, $protocol, $domain, $unused, $port, $path) = $patt; |
226 | 226 | $path = path::normalize($path); |
227 | - $this->config['uploadURL'] = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/$path"; |
|
227 | + $this->config['uploadURL'] = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/$path"; |
|
228 | 228 | $this->config['uploadDir'] = strlen($this->config['uploadDir']) |
229 | 229 | ? path::normalize($this->config['uploadDir']) |
230 | 230 | : path::url2fullPath("/$path"); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | foreach ($this->langInputNames as $key) |
268 | 268 | if (isset($this->get[$key]) && |
269 | 269 | preg_match('/^[a-z][a-z\._\-]*$/i', $this->get[$key]) && |
270 | - file_exists("lang/" . strtolower($this->get[$key]) . ".php") |
|
270 | + file_exists("lang/".strtolower($this->get[$key]).".php") |
|
271 | 271 | ) { |
272 | 272 | $this->lang = $this->get[$key]; |
273 | 273 | break; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $this->backMsg("Cannot read upload folder."); |
299 | 299 | } |
300 | 300 | |
301 | - public function upload() { |
|
301 | + public function upload(){ |
|
302 | 302 | $config = &$this->config; |
303 | 303 | $file = &$this->file; |
304 | 304 | $url = $message = ""; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | @mkdir(path::normalize($dir), $this->config['dirPerms'], true); |
330 | 330 | |
331 | 331 | $filename = $this->normalizeFilename($file['name']); |
332 | - $target = file::getInexistantFilename($dir . $filename); |
|
332 | + $target = file::getInexistantFilename($dir.$filename); |
|
333 | 333 | |
334 | 334 | if (!@move_uploaded_file($file['tmp_name'], $target) && |
335 | 335 | !@rename($file['tmp_name'], $target) && |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | $this->makeThumb($target); |
343 | 343 | $url = $this->typeURL; |
344 | 344 | if (isset($udir)) $url .= "/$udir"; |
345 | - $url .= "/" . basename($target); |
|
345 | + $url .= "/".basename($target); |
|
346 | 346 | if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)$/', $url, $patt)) { |
347 | 347 | list($unused, $protocol, $domain, $unused, $port, $path) = $patt; |
348 | - $base = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/"; |
|
349 | - $url = $base . path::urlPathEncode($path); |
|
348 | + $base = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/"; |
|
349 | + $url = $base.path::urlPathEncode($path); |
|
350 | 350 | } else |
351 | 351 | $url = path::urlPathEncode($url); |
352 | 352 | } |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | - protected function getTransaliasSettings() { |
|
368 | + protected function getTransaliasSettings(){ |
|
369 | 369 | $modx = DocumentParser::getInstance(); |
370 | 370 | |
371 | 371 | // Cleaning uploaded filename? |
372 | 372 | $setting = $modx->db->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1'); |
373 | - if ($modx->db->getValue($setting)>0) { |
|
373 | + if ($modx->db->getValue($setting) > 0) { |
|
374 | 374 | // Transalias plugin active? |
375 | 375 | $res = $modx->db->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0'); |
376 | 376 | if ($properties = $modx->db->getValue($res)) { |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | |
388 | - protected function normalizeFilename($filename) { |
|
388 | + protected function normalizeFilename($filename){ |
|
389 | 389 | if ($this->getTransaliasSettings()) { |
390 | 390 | $format = strrchr($filename, "."); |
391 | 391 | $filename = str_replace($format, "", $filename); |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | return $filename; |
395 | 395 | } |
396 | 396 | |
397 | - protected function normalizeDirname($dirname) { |
|
397 | + protected function normalizeDirname($dirname){ |
|
398 | 398 | return $this->modx->stripAlias($dirname); |
399 | 399 | } |
400 | 400 | |
401 | - protected function checkUploadedFile(array $aFile=null) { |
|
401 | + protected function checkUploadedFile(array $aFile = null){ |
|
402 | 402 | $config = &$this->config; |
403 | 403 | $file = ($aFile === null) ? $this->file : $aFile; |
404 | 404 | |
@@ -437,8 +437,7 @@ discard block |
||
437 | 437 | ($file['error'] == UPLOAD_ERR_NO_TMP_DIR) ? |
438 | 438 | $this->label("Missing a temporary folder.") : ( |
439 | 439 | ($file['error'] == UPLOAD_ERR_CANT_WRITE) ? |
440 | - $this->label("Failed to write file.") : |
|
441 | - $this->label("Unknown error.") |
|
440 | + $this->label("Failed to write file.") : $this->label("Unknown error.") |
|
442 | 441 | ))))); |
443 | 442 | |
444 | 443 | // HIDDEN FILENAMES CHECK |
@@ -473,14 +472,14 @@ discard block |
||
473 | 472 | |
474 | 473 | |
475 | 474 | // CHECK FOR MODX MAX FILE SIZE |
476 | - $actualfilesize=filesize($file['tmp_name']); |
|
475 | + $actualfilesize = filesize($file['tmp_name']); |
|
477 | 476 | if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize']) |
478 | 477 | return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)"); |
479 | 478 | |
480 | 479 | return true; |
481 | 480 | } |
482 | 481 | |
483 | - protected function checkInputDir($dir, $inclType=true, $existing=true) { |
|
482 | + protected function checkInputDir($dir, $inclType = true, $existing = true){ |
|
484 | 483 | $dir = path::normalize($dir); |
485 | 484 | if (substr($dir, 0, 1) == "/") |
486 | 485 | $dir = substr($dir, 1); |
@@ -506,7 +505,7 @@ discard block |
||
506 | 505 | return (is_dir($path) && is_readable($path)) ? $return : false; |
507 | 506 | } |
508 | 507 | |
509 | - protected function validateExtension($ext, $type) { |
|
508 | + protected function validateExtension($ext, $type){ |
|
510 | 509 | $ext = trim(strtolower($ext)); |
511 | 510 | if (!isset($this->types[$type])) |
512 | 511 | return false; |
@@ -531,17 +530,17 @@ discard block |
||
531 | 530 | return in_array($ext, $exts); |
532 | 531 | } |
533 | 532 | |
534 | - protected function getTypeFromPath($path) { |
|
533 | + protected function getTypeFromPath($path){ |
|
535 | 534 | return preg_match('/^([^\/]*)\/.*$/', $path, $patt) |
536 | 535 | ? $patt[1] : $path; |
537 | 536 | } |
538 | 537 | |
539 | - protected function removeTypeFromPath($path) { |
|
538 | + protected function removeTypeFromPath($path){ |
|
540 | 539 | return preg_match('/^[^\/]*\/(.*)$/', $path, $patt) |
541 | 540 | ? $patt[1] : ""; |
542 | 541 | } |
543 | 542 | |
544 | - protected function imageResize($image, $file=null) { |
|
543 | + protected function imageResize($image, $file = null){ |
|
545 | 544 | |
546 | 545 | if (!($image instanceof image)) { |
547 | 546 | $img = image::factory($this->imageDriver, $image); |
@@ -629,24 +628,24 @@ discard block |
||
629 | 628 | $img->watermark($this->config['watermark']['file'], $left, $top); |
630 | 629 | } |
631 | 630 | |
632 | - $options = array( 'file' => $file ); |
|
631 | + $options = array('file' => $file); |
|
633 | 632 | |
634 | - $type = exif_imagetype( $file ); |
|
633 | + $type = exif_imagetype($file); |
|
635 | 634 | |
636 | - switch ( $type ) { |
|
635 | + switch ($type) { |
|
637 | 636 | case IMAGETYPE_GIF: |
638 | - return $img->output( 'gif', $options ); |
|
637 | + return $img->output('gif', $options); |
|
639 | 638 | |
640 | 639 | case IMAGETYPE_PNG: |
641 | - return $img->output( 'png', $options ); |
|
640 | + return $img->output('png', $options); |
|
642 | 641 | |
643 | 642 | default: |
644 | - return $img->output( 'jpeg', array_merge( $options, array( 'quality' => $this->config['jpegQuality'] ) ) ); |
|
643 | + return $img->output('jpeg', array_merge($options, array('quality' => $this->config['jpegQuality']))); |
|
645 | 644 | } |
646 | 645 | |
647 | 646 | } |
648 | 647 | |
649 | - protected function makeThumb($file, $overwrite=true) { |
|
648 | + protected function makeThumb($file, $overwrite = true){ |
|
650 | 649 | $img = image::factory($this->imageDriver, $file); |
651 | 650 | |
652 | 651 | // Drop files which are not images |
@@ -654,7 +653,7 @@ discard block |
||
654 | 653 | return true; |
655 | 654 | |
656 | 655 | $thumb = substr($file, strlen($this->config['uploadDir'])); |
657 | - $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb; |
|
656 | + $thumb = $this->config['uploadDir']."/".$this->config['thumbsDir']."/".$thumb; |
|
658 | 657 | $thumb = path::normalize($thumb); |
659 | 658 | $thumbDir = dirname($thumb); |
660 | 659 | if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) |
@@ -677,15 +676,15 @@ discard block |
||
677 | 676 | if (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight'])) |
678 | 677 | return false; |
679 | 678 | |
680 | - if ( $this->imageDriver == 'gd' ) { |
|
681 | - $width = imagesx( $img->image ); |
|
682 | - $height = imagesy( $img->image ); |
|
683 | - $back = image::factory( $this->imageDriver, array( $width, $height ) ); |
|
684 | - $tile = image::factory( $this->imageDriver, __DIR__ . '/../themes/' . $this->config['theme'] . '/img/bg_transparent.png' ); |
|
679 | + if ($this->imageDriver == 'gd') { |
|
680 | + $width = imagesx($img->image); |
|
681 | + $height = imagesy($img->image); |
|
682 | + $back = image::factory($this->imageDriver, array($width, $height)); |
|
683 | + $tile = image::factory($this->imageDriver, __DIR__.'/../themes/'.$this->config['theme'].'/img/bg_transparent.png'); |
|
685 | 684 | |
686 | - imagesettile( $back->image, $tile->image ); |
|
687 | - imagefilledrectangle( $back->image, 0, 0, $width, $height, IMG_COLOR_TILED ); |
|
688 | - imagecopy( $back->image, $img->image, 0, 0, 0, 0, $width, $height ); |
|
685 | + imagesettile($back->image, $tile->image); |
|
686 | + imagefilledrectangle($back->image, 0, 0, $width, $height, IMG_COLOR_TILED); |
|
687 | + imagecopy($back->image, $img->image, 0, 0, 0, 0, $width, $height); |
|
689 | 688 | |
690 | 689 | $img = $back; |
691 | 690 | } |
@@ -697,7 +696,7 @@ discard block |
||
697 | 696 | )); |
698 | 697 | } |
699 | 698 | |
700 | - protected function localize($langCode) { |
|
699 | + protected function localize($langCode){ |
|
701 | 700 | require "lang/{$langCode}.php"; |
702 | 701 | setlocale(LC_ALL, $lang['_locale']); |
703 | 702 | $this->charset = $lang['_charset']; |
@@ -712,7 +711,7 @@ discard block |
||
712 | 711 | $this->labels = $lang; |
713 | 712 | } |
714 | 713 | |
715 | - protected function label($string, array $data=null) { |
|
714 | + protected function label($string, array $data = null){ |
|
716 | 715 | $return = isset($this->labels[$string]) ? $this->labels[$string] : $string; |
717 | 716 | if (is_array($data)) |
718 | 717 | foreach ($data as $key => $val) |
@@ -720,7 +719,7 @@ discard block |
||
720 | 719 | return $return; |
721 | 720 | } |
722 | 721 | |
723 | - protected function backMsg($message, array $data=null) { |
|
722 | + protected function backMsg($message, array $data = null){ |
|
724 | 723 | $message = $this->label($message, $data); |
725 | 724 | if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) |
726 | 725 | @unlink($this->file['tmp_name']); |
@@ -728,7 +727,7 @@ discard block |
||
728 | 727 | die; |
729 | 728 | } |
730 | 729 | |
731 | - protected function callBack($url, $message="") { |
|
730 | + protected function callBack($url, $message = ""){ |
|
732 | 731 | $message = text::jsValue($message); |
733 | 732 | $CKfuncNum = isset($this->opener['CKEditor']['funcNum']) |
734 | 733 | ? $this->opener['CKEditor']['funcNum'] : 0; |
@@ -769,7 +768,7 @@ discard block |
||
769 | 768 | |
770 | 769 | } |
771 | 770 | |
772 | - protected function get_htaccess() { |
|
771 | + protected function get_htaccess(){ |
|
773 | 772 | return "<IfModule mod_php4.c> |
774 | 773 | php_value engine off |
775 | 774 | </IfModule> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $modx = DocumentParser::getInstance(); |
27 | 27 | $modx->db->connect(); |
28 | 28 | startCMSSession(); |
29 | -if(!isset($_SESSION['mgrValidated'])) { |
|
29 | +if (!isset($_SESSION['mgrValidated'])) { |
|
30 | 30 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
31 | 31 | } |
32 | 32 | define('IN_MANAGER_MODE', true); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $manager_language = $modx->config['manager_language']; |
36 | 36 | // Pass language code from MODX to KCFinder |
37 | -if(!file_exists("../../../includes/lang/".$manager_language.".inc.php")) { |
|
37 | +if (!file_exists("../../../includes/lang/".$manager_language.".inc.php")) { |
|
38 | 38 | $manager_language = "english"; // if not set, get the english language file. |
39 | 39 | } |
40 | 40 | include_once "../../../includes/lang/".$manager_language.".inc.php"; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | // PHP VERSION CHECK |
44 | 44 | if (substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.')) < 5) |
45 | - die("You are using PHP " . PHP_VERSION . " when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution."); |
|
45 | + die("You are using PHP ".PHP_VERSION." when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution."); |
|
46 | 46 | |
47 | 47 | |
48 | 48 | // SAFE MODE CHECK |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | |
53 | 53 | // MAGIC AUTOLOAD CLASSES FUNCTION |
54 | -function autoloadda9d06472ccb71b84928677ce2a6ca89($class) { |
|
54 | +function autoloadda9d06472ccb71b84928677ce2a6ca89($class){ |
|
55 | 55 | static $classes = null; |
56 | 56 | if ($classes === null) { |
57 | 57 | $classes = array( |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ); |
76 | 76 | } |
77 | 77 | if (isset($classes[$class])) { |
78 | - require dirname(__FILE__) . $classes[$class]; |
|
78 | + require dirname(__FILE__).$classes[$class]; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | spl_autoload_register('autoloadda9d06472ccb71b84928677ce2a6ca89', true); |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | // json_encode() IMPLEMENTATION IF JSON EXTENSION IS MISSING |
85 | 85 | if (!function_exists("json_encode")) { |
86 | 86 | |
87 | - function kcfinder_json_string_encode($string) { |
|
88 | - return '"' . |
|
87 | + function kcfinder_json_string_encode($string){ |
|
88 | + return '"'. |
|
89 | 89 | str_replace('/', "\\/", |
90 | 90 | str_replace("\t", "\\t", |
91 | 91 | str_replace("\r", "\\r", |
92 | 92 | str_replace("\n", "\\n", |
93 | 93 | str_replace('"', "\\\"", |
94 | 94 | str_replace("\\", "\\\\", |
95 | - $string)))))) . '"'; |
|
95 | + $string)))))).'"'; |
|
96 | 96 | } |
97 | 97 | |
98 | - function json_encode($data) { |
|
98 | + function json_encode($data){ |
|
99 | 99 | |
100 | 100 | if (is_array($data)) { |
101 | 101 | $ret = array(); |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | // OBJECT |
104 | 104 | if (array_keys($data) !== range(0, count($data) - 1)) { |
105 | 105 | foreach ($data as $key => $val) |
106 | - $ret[] = kcfinder_json_string_encode($key) . ':' . json_encode($val); |
|
107 | - return "{" . implode(",", $ret) . "}"; |
|
106 | + $ret[] = kcfinder_json_string_encode($key).':'.json_encode($val); |
|
107 | + return "{".implode(",", $ret)."}"; |
|
108 | 108 | |
109 | 109 | // ARRAY |
110 | 110 | } else { |
111 | 111 | foreach ($data as $val) |
112 | 112 | $ret[] = json_encode($val); |
113 | - return "[" . implode(",", $ret) . "]"; |
|
113 | + return "[".implode(",", $ret)."]"; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // BOOLEAN OR NULL |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -class DATEPICKER { |
|
2 | +class DATEPICKER{ |
|
3 | 3 | /** |
4 | 4 | * @return string |
5 | 5 | */ |
6 | - public function getDP() { |
|
6 | + public function getDP(){ |
|
7 | 7 | $modx = DocumentParser::getInstance(); |
8 | 8 | |
9 | 9 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
10 | - if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
10 | + if (!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
11 | 11 | $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
12 | 12 | return $modx->mergeSettingsContent($load_script); |
13 | 13 | } |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - public function getLangCode() { |
|
18 | + public function getLangCode(){ |
|
19 | 19 | $modx = DocumentParser::getInstance(); global $modx_lang_attribute; |
20 | 20 | |
21 | - if(!$modx_lang_attribute) return 'en'; |
|
21 | + if (!$modx_lang_attribute) return 'en'; |
|
22 | 22 | |
23 | 23 | $lc = $modx_lang_attribute; |
24 | - if($lc === 'uk') return 'ru'; |
|
25 | - $dp_path = str_replace('\\','/',dirname(__FILE__)); |
|
24 | + if ($lc === 'uk') return 'ru'; |
|
25 | + $dp_path = str_replace('\\', '/', dirname(__FILE__)); |
|
26 | 26 | |
27 | 27 | return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en'; |
28 | 28 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | -class DATEPICKER { |
|
3 | - function __construct() { |
|
2 | +class DATEPICKER{ |
|
3 | + function __construct(){ |
|
4 | 4 | } |
5 | - function getDP() { |
|
5 | + function getDP(){ |
|
6 | 6 | $modx = DocumentParser::getInstance(); global$_lang; |
7 | 7 | |
8 | 8 | $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
9 | - return $modx->parseText($tpl,$_lang,'[%','%]'); |
|
9 | + return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
10 | 10 | } |
11 | 11 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class DATEPICKER { |
|
4 | - function __construct() { |
|
3 | +class DATEPICKER{ |
|
4 | + function __construct(){ |
|
5 | 5 | } |
6 | 6 | |
7 | - function getDP() { |
|
7 | + function getDP(){ |
|
8 | 8 | $modx = DocumentParser::getInstance(); global $_lang; |
9 | 9 | |
10 | - $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
10 | + $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
|
11 | 11 | return $modx->parseText($tpl, $_lang, '[%', '%]'); |
12 | 12 | } |
13 | 13 | } |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | -switch((int) $modx->manager->action) { |
|
6 | +switch ((int) $modx->manager->action) { |
|
7 | 7 | case 35: |
8 | - if(!$modx->hasPermission('edit_role')) { |
|
8 | + if (!$modx->hasPermission('edit_role')) { |
|
9 | 9 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
10 | 10 | } |
11 | 11 | break; |
12 | 12 | case 38: |
13 | - if(!$modx->hasPermission('new_role')) { |
|
13 | + if (!$modx->hasPermission('new_role')) { |
|
14 | 14 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
15 | 15 | } |
16 | 16 | break; |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
19 | 19 | } |
20 | 20 | |
21 | -$role = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
21 | +$role = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
22 | 22 | |
23 | 23 | $tbl_user_roles = $modx->getFullTableName('user_roles'); |
24 | 24 | |
25 | 25 | // check to see the snippet editor isn't locked |
26 | -if($lockedEl = $modx->elementIsLocked(8, $role)) { |
|
26 | +if ($lockedEl = $modx->elementIsLocked(8, $role)) { |
|
27 | 27 | $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['role'])); |
28 | 28 | } |
29 | 29 | // end check for lock |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | // Lock snippet for other users to edit |
32 | 32 | $modx->lockElement(8, $role); |
33 | 33 | |
34 | -if($modx->manager->action == '35') { |
|
34 | +if ($modx->manager->action == '35') { |
|
35 | 35 | $rs = $modx->db->select('*', $tbl_user_roles, "id='{$role}'"); |
36 | 36 | $roledata = $modx->db->getRow($rs); |
37 | - if(!$roledata) { |
|
37 | + if (!$roledata) { |
|
38 | 38 | $modx->webAlertAndQuit("No role returned!"); |
39 | 39 | } |
40 | 40 | $_SESSION['itemname'] = $roledata['name']; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | // Add lock-element JS-Script |
47 | 47 | $lockElementId = $role; |
48 | 48 | $lockElementType = 8; |
49 | -require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); |
|
49 | +require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php'); |
|
50 | 50 | ?> |
51 | 51 | <script type="text/javascript"> |
52 | 52 | function changestate(element) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | <input type="hidden" name="id" value="<?= $_GET['id'] ?>"> |
83 | 83 | |
84 | 84 | <h1> |
85 | - <i class="fa fa-legal"></i><?= ($roledata['name'] ? $roledata['name'] . '<small>(' . $roledata['id'] . ')</small>' : $_lang['role_title']) ?> |
|
85 | + <i class="fa fa-legal"></i><?= ($roledata['name'] ? $roledata['name'].'<small>('.$roledata['id'].')</small>' : $_lang['role_title']) ?> |
|
86 | 86 | </h1> |
87 | 87 | |
88 | 88 | <?= $_style['actionbuttons']['dynamic']['savedelete'] ?> |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param string $status |
300 | 300 | * @return string |
301 | 301 | */ |
302 | -function render_form($name, $label, $status = '') { |
|
302 | +function render_form($name, $label, $status = ''){ |
|
303 | 303 | $modx = DocumentParser::getInstance(); global $roledata; |
304 | 304 | |
305 | 305 | $tpl = '<label class="d-block" for="[+name+]check"> |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | $checked = ($roledata[$name] == 1) ? 'checked' : ''; |
312 | 312 | $value = ($roledata[$name] == 1) ? 1 : 0; |
313 | - if($status == 'disabled') { |
|
313 | + if ($status == 'disabled') { |
|
314 | 314 | $checked = 'checked'; |
315 | 315 | $value = 1; |
316 | 316 | $set = 'fix'; |