@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | $this->maxPasses = ($maxpass != '') ? $maxpass : 50; |
41 | 41 | $this->swapSnippetCache = array(); |
42 | 42 | $modx->setPlaceholder("phx", "&_PHX_INTERNAL_&"); |
43 | - if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']); |
|
43 | + if (function_exists('mb_internal_encoding')) { |
|
44 | + mb_internal_encoding($modx->config['modx_charset']); |
|
45 | + } |
|
44 | 46 | } |
45 | 47 | |
46 | 48 | // Plugin event hook for MODx |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | { |
61 | 63 | global $modx; |
62 | 64 | // If we already reached max passes don't get at it again. |
63 | - if ($this->curPass == $this->maxPasses) return $template; |
|
65 | + if ($this->curPass == $this->maxPasses) { |
|
66 | + return $template; |
|
67 | + } |
|
64 | 68 | // Set template pre-process hash |
65 | 69 | $st = md5($template); |
66 | 70 | // Replace non-call characters in the template: [, ] |
@@ -78,7 +82,9 @@ discard block |
||
78 | 82 | // Set template post-process hash |
79 | 83 | $et = md5($template); |
80 | 84 | // If template has changed, parse it once more... |
81 | - if ($st != $et) $template = $this->Parse($template); |
|
85 | + if ($st != $et) { |
|
86 | + $template = $this->Parse($template); |
|
87 | + } |
|
82 | 88 | // Write an event log if debugging is enabled and there is something to log |
83 | 89 | if ($this->debug && $this->debugLog) { |
84 | 90 | $modx->logEvent($this->curPass, 1, $this->createEventLog(), $this->name . ' ' . $this->version); |
@@ -196,9 +202,13 @@ discard block |
||
196 | 202 | $et = md5($template); // Post-process template hash |
197 | 203 | |
198 | 204 | // Log an event if this was the maximum pass |
199 | - if ($this->curPass == $this->maxPasses) $this->Log("Max passes reached. infinite loop protection so exiting.\n If you need the extra passes set the max passes to the highest count of nested tags in your template."); |
|
205 | + if ($this->curPass == $this->maxPasses) { |
|
206 | + $this->Log("Max passes reached. infinite loop protection so exiting.\n If you need the extra passes set the max passes to the highest count of nested tags in your template."); |
|
207 | + } |
|
200 | 208 | // If this pass is not at maximum passes and the template hash is not the same, get at it again. |
201 | - if (($this->curPass < $this->maxPasses) && ($st != $et)) $template = $this->ParseValues($template); |
|
209 | + if (($this->curPass < $this->maxPasses) && ($st != $et)) { |
|
210 | + $template = $this->ParseValues($template); |
|
211 | + } |
|
202 | 212 | |
203 | 213 | return $template; |
204 | 214 | } |
@@ -217,7 +227,9 @@ discard block |
||
217 | 227 | for ($i = 0; $i < $count; $i++) { |
218 | 228 | $output = trim($output); |
219 | 229 | $this->Log(" |--- Modifier = '" . $modifier_cmd[$i] . "'"); |
220 | - if ($modifier_value[$i] != '') $this->Log(" |--- Options = '" . $modifier_value[$i] . "'"); |
|
230 | + if ($modifier_value[$i] != '') { |
|
231 | + $this->Log(" |--- Options = '" . $modifier_value[$i] . "'"); |
|
232 | + } |
|
221 | 233 | switch ($modifier_cmd[$i]) { |
222 | 234 | ##### Conditional Modifiers |
223 | 235 | case "input": |
@@ -260,7 +272,9 @@ discard block |
||
260 | 272 | case "ir": |
261 | 273 | case "memberof": |
262 | 274 | case "mo": // Is Member Of (same as inrole but this one can be stringed as a conditional) |
263 | - if ($output == "&_PHX_INTERNAL_&") $output = $this->user["id"]; |
|
275 | + if ($output == "&_PHX_INTERNAL_&") { |
|
276 | + $output = $this->user["id"]; |
|
277 | + } |
|
264 | 278 | $grps = ($this->strlen($modifier_value[$i]) > 0) ? explode(",", $modifier_value[$i]) : array(); |
265 | 279 | $condition[] = intval($this->isMemberOfWebGroupByUserId($output, $grps)); |
266 | 280 | break; |
@@ -377,11 +391,15 @@ discard block |
||
377 | 391 | $output = eval("return " . $filter . ";"); |
378 | 392 | break; |
379 | 393 | case "isnotempty": |
380 | - if (!empty($output)) $output = $modifier_value[$i]; |
|
394 | + if (!empty($output)) { |
|
395 | + $output = $modifier_value[$i]; |
|
396 | + } |
|
381 | 397 | break; |
382 | 398 | case "isempty": |
383 | 399 | case "ifempty": |
384 | - if (empty($output)) $output = $modifier_value[$i]; |
|
400 | + if (empty($output)) { |
|
401 | + $output = $modifier_value[$i]; |
|
402 | + } |
|
385 | 403 | break; |
386 | 404 | case "nl2br": |
387 | 405 | $output = nl2br($output); |
@@ -391,7 +409,9 @@ discard block |
||
391 | 409 | break; |
392 | 410 | case "set": |
393 | 411 | $c = $i + 1; |
394 | - if ($count > $c && $modifier_cmd[$c] == "value") $output = preg_replace("~([^a-zA-Z0-9])~", "", $modifier_value[$i]); |
|
412 | + if ($count > $c && $modifier_cmd[$c] == "value") { |
|
413 | + $output = preg_replace("~([^a-zA-Z0-9])~", "", $modifier_value[$i]); |
|
414 | + } |
|
395 | 415 | break; |
396 | 416 | case "value": |
397 | 417 | if ($i > 0 && $modifier_cmd[$i - 1] == "set") { |
@@ -403,11 +423,15 @@ discard block |
||
403 | 423 | $output = md5($output); |
404 | 424 | break; |
405 | 425 | case "userinfo": |
406 | - if ($output == "&_PHX_INTERNAL_&") $output = $this->user["id"]; |
|
426 | + if ($output == "&_PHX_INTERNAL_&") { |
|
427 | + $output = $this->user["id"]; |
|
428 | + } |
|
407 | 429 | $output = $this->ModUser($output, $modifier_value[$i]); |
408 | 430 | break; |
409 | 431 | case "inrole": // deprecated |
410 | - if ($output == "&_PHX_INTERNAL_&") $output = $this->user["id"]; |
|
432 | + if ($output == "&_PHX_INTERNAL_&") { |
|
433 | + $output = $this->user["id"]; |
|
434 | + } |
|
411 | 435 | $grps = ($this->strlen($modifier_value[$i]) > 0) ? explode(",", $modifier_value[$i]) : array(); |
412 | 436 | $output = intval($this->isMemberOfWebGroupByUserId($output, $grps)); |
413 | 437 | break; |
@@ -451,7 +475,9 @@ discard block |
||
451 | 475 | ob_end_clean(); |
452 | 476 | break; |
453 | 477 | } |
454 | - if (count($condition)) $this->Log(" |--- Condition = '" . $condition[count($condition) - 1] . "'"); |
|
478 | + if (count($condition)) { |
|
479 | + $this->Log(" |--- Condition = '" . $condition[count($condition) - 1] . "'"); |
|
480 | + } |
|
455 | 481 | $this->Log(" |--- Output = '" . $output . "'"); |
456 | 482 | } |
457 | 483 | } |
@@ -531,7 +557,9 @@ discard block |
||
531 | 557 | global $modx; |
532 | 558 | |
533 | 559 | // if $groupNames is not an array return false |
534 | - if (!is_array($groupNames)) return false; |
|
560 | + if (!is_array($groupNames)) { |
|
561 | + return false; |
|
562 | + } |
|
535 | 563 | |
536 | 564 | // if the user id is a negative number make it positive |
537 | 565 | if (intval($userid) < 0) { |
@@ -548,8 +576,9 @@ discard block |
||
548 | 576 | $grpNames = $this->cache["mo"][$userid]; |
549 | 577 | } |
550 | 578 | // Check if a supplied group matches a webgroup from the array we just created |
551 | - foreach ($groupNames as $k => $v) |
|
552 | - if (in_array(trim($v), $grpNames)) return true; |
|
579 | + foreach ($groupNames as $k => $v) { |
|
580 | + if (in_array(trim($v), $grpNames)) return true; |
|
581 | + } |
|
553 | 582 | |
554 | 583 | // If we get here the above logic did not find a match, so return false |
555 | 584 | return false; |
@@ -572,52 +601,65 @@ discard block |
||
572 | 601 | // Sets a placeholder variable which can only be access by PHx |
573 | 602 | function setPHxVariable($name, $value) |
574 | 603 | { |
575 | - if ($name != "phx") $this->placeholders[$name] = $value; |
|
604 | + if ($name != "phx") { |
|
605 | + $this->placeholders[$name] = $value; |
|
606 | + } |
|
576 | 607 | } |
577 | 608 | |
578 | 609 | //mbstring |
579 | 610 | function substr($str, $s, $l = null) |
580 | 611 | { |
581 | - if (function_exists('mb_substr')) return mb_substr($str, $s, $l); |
|
612 | + if (function_exists('mb_substr')) { |
|
613 | + return mb_substr($str, $s, $l); |
|
614 | + } |
|
582 | 615 | return substr($str, $s, $l); |
583 | 616 | } |
584 | 617 | |
585 | 618 | function strlen($str) |
586 | 619 | { |
587 | - if (function_exists('mb_strlen')) return mb_strlen($str); |
|
620 | + if (function_exists('mb_strlen')) { |
|
621 | + return mb_strlen($str); |
|
622 | + } |
|
588 | 623 | return strlen($str); |
589 | 624 | } |
590 | 625 | |
591 | 626 | function strtolower($str) |
592 | 627 | { |
593 | - if (function_exists('mb_strtolower')) return mb_strtolower($str); |
|
628 | + if (function_exists('mb_strtolower')) { |
|
629 | + return mb_strtolower($str); |
|
630 | + } |
|
594 | 631 | return strtolower($str); |
595 | 632 | } |
596 | 633 | |
597 | 634 | function strtoupper($str) |
598 | 635 | { |
599 | - if (function_exists('mb_strtoupper')) return mb_strtoupper($str); |
|
636 | + if (function_exists('mb_strtoupper')) { |
|
637 | + return mb_strtoupper($str); |
|
638 | + } |
|
600 | 639 | return strtoupper($str); |
601 | 640 | } |
602 | 641 | |
603 | 642 | function ucfirst($str) |
604 | 643 | { |
605 | - if (function_exists('mb_strtoupper') && function_exists('mb_substr') && function_exists('mb_strlen')) |
|
606 | - return mb_strtoupper(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str)); |
|
644 | + if (function_exists('mb_strtoupper') && function_exists('mb_substr') && function_exists('mb_strlen')) { |
|
645 | + return mb_strtoupper(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str)); |
|
646 | + } |
|
607 | 647 | return ucfirst($str); |
608 | 648 | } |
609 | 649 | |
610 | 650 | function lcfirst($str) |
611 | 651 | { |
612 | - if (function_exists('mb_strtolower') && function_exists('mb_substr') && function_exists('mb_strlen')) |
|
613 | - return mb_strtolower(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str)); |
|
652 | + if (function_exists('mb_strtolower') && function_exists('mb_substr') && function_exists('mb_strlen')) { |
|
653 | + return mb_strtolower(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str)); |
|
654 | + } |
|
614 | 655 | return lcfirst($str); |
615 | 656 | } |
616 | 657 | |
617 | 658 | function ucwords($str) |
618 | 659 | { |
619 | - if (function_exists('mb_convert_case')) |
|
620 | - return mb_convert_case($str, MB_CASE_TITLE); |
|
660 | + if (function_exists('mb_convert_case')) { |
|
661 | + return mb_convert_case($str, MB_CASE_TITLE); |
|
662 | + } |
|
621 | 663 | return ucwords($str); |
622 | 664 | } |
623 | 665 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | # Date: March 22, 2013 |
11 | 11 | # |
12 | 12 | ####*/ |
13 | -include_once(MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php'); |
|
13 | +include_once(MODX_BASE_PATH.'assets/lib/APIHelpers.class.php'); |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Class DLphx |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | preg_match_all('~(?:=`[^`@]*?)(\[\+([^:\+\[\]]+)([^\[\]]*?)\+\])~s', $template, $matches); |
138 | 138 | if ($matches[0]) { |
139 | 139 | $template = str_replace($matches[1], '', $template); |
140 | - $this->Log("Cleaning unsolved tags: \n" . implode("\n", $matches[2])); |
|
140 | + $this->Log("Cleaning unsolved tags: \n".implode("\n", $matches[2])); |
|
141 | 141 | } |
142 | 142 | // Restore non-call characters in the template: [, ] |
143 | 143 | $template = str_replace($this->safetags[1], $this->safetags[2], $template); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | if ($st != $et) $template = $this->Parse($template); |
148 | 148 | // Write an event log if debugging is enabled and there is something to log |
149 | 149 | if ($this->debug && $this->debugLog) { |
150 | - $modx->logEvent($this->curPass, 1, $this->createEventLog(), $this->name . ' ' . $this->version); |
|
150 | + $modx->logEvent($this->curPass, 1, $this->createEventLog(), $this->name.' '.$this->version); |
|
151 | 151 | $this->debugLog = false; |
152 | 152 | } |
153 | 153 | // Return the processed template |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | for ($i = 0; $i < $count; $i++) { |
179 | 179 | $var_search[] = $matches[0][$i]; |
180 | 180 | $input = $matches[1][$i]; |
181 | - $this->Log('MODX Chunk: ' . $input); |
|
182 | - $input = $modx->mergeChunkContent('{{' . $input . '}}'); |
|
181 | + $this->Log('MODX Chunk: '.$input); |
|
182 | + $input = $modx->mergeChunkContent('{{'.$input.'}}'); |
|
183 | 183 | $var_replace[] = $this->Filter($input, $matches[2][$i]); |
184 | 184 | } |
185 | 185 | $template = str_replace($var_search, $var_replace, $template); |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | // for each detected snippet |
196 | 196 | for ($i = 0; $i < $count; $i++) { |
197 | 197 | $snippet = $matches[2][$i]; // snippet call |
198 | - $this->Log("MODx Snippet -> " . $snippet); |
|
198 | + $this->Log("MODx Snippet -> ".$snippet); |
|
199 | 199 | |
200 | 200 | // Let MODx evaluate snippet |
201 | - $replace = $modx->evalSnippets("[[" . $snippet . "]]"); |
|
201 | + $replace = $modx->evalSnippets("[[".$snippet."]]"); |
|
202 | 202 | $this->LogSnippet($replace); |
203 | 203 | |
204 | 204 | // Replace values |
@@ -227,19 +227,19 @@ discard block |
||
227 | 227 | switch ($matches[1][$i]) { |
228 | 228 | // Document / Template Variable eXtended |
229 | 229 | case "*": |
230 | - $this->Log("MODx TV/DV: " . $input); |
|
231 | - $input = $modx->mergeDocumentContent("[*" . $input . "*]"); |
|
230 | + $this->Log("MODx TV/DV: ".$input); |
|
231 | + $input = $modx->mergeDocumentContent("[*".$input."*]"); |
|
232 | 232 | $replace = $this->Filter($input, $modifiers); |
233 | 233 | break; |
234 | 234 | // MODx Setting eXtended |
235 | 235 | case "(": |
236 | - $this->Log("MODx Setting variable: " . $input); |
|
237 | - $input = $modx->mergeSettingsContent("[(" . $input . ")]"); |
|
236 | + $this->Log("MODx Setting variable: ".$input); |
|
237 | + $input = $modx->mergeSettingsContent("[(".$input.")]"); |
|
238 | 238 | $replace = $this->Filter($input, $modifiers); |
239 | 239 | break; |
240 | 240 | // MODx Placeholder eXtended |
241 | 241 | default: |
242 | - $this->Log("MODx / PHx placeholder variable: " . $input); |
|
242 | + $this->Log("MODx / PHx placeholder variable: ".$input); |
|
243 | 243 | // Check if placeholder is set |
244 | 244 | if (!array_key_exists($input, $this->placeholders) && !array_key_exists($input, $modx->placeholders)) { |
245 | 245 | // not set so try again later. |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | { |
276 | 276 | global $modx; |
277 | 277 | $output = $input; |
278 | - $this->Log(" |--- Input = '" . $output . "'"); |
|
278 | + $this->Log(" |--- Input = '".$output."'"); |
|
279 | 279 | if (preg_match_all('~:([^:=]+)(?:=`(.*?)`(?=:[^:=]+|$))?~s', $modifiers, $matches)) { |
280 | 280 | $modifier_cmd = $matches[1]; // modifier command |
281 | 281 | $modifier_value = $matches[2]; // modifier value |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | $condition = array(); |
284 | 284 | for ($i = 0; $i < $count; $i++) { |
285 | 285 | $output = trim($output); |
286 | - $this->Log(" |--- Modifier = '" . $modifier_cmd[$i] . "'"); |
|
287 | - if ($modifier_value[$i] != '') $this->Log(" |--- Options = '" . $modifier_value[$i] . "'"); |
|
286 | + $this->Log(" |--- Modifier = '".$modifier_cmd[$i]."'"); |
|
287 | + if ($modifier_value[$i] != '') $this->Log(" |--- Options = '".$modifier_value[$i]."'"); |
|
288 | 288 | switch ($modifier_cmd[$i]) { |
289 | 289 | ##### Conditional Modifiers |
290 | 290 | case "input": |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | break; |
340 | 340 | case "show": |
341 | 341 | $conditional = implode(' ', $condition); |
342 | - $isvalid = intval(eval("return (" . $conditional . ");")); |
|
342 | + $isvalid = intval(eval("return (".$conditional.");")); |
|
343 | 343 | if (!$isvalid) { |
344 | 344 | $output = NULL; |
345 | 345 | } |
346 | 346 | break; |
347 | 347 | case "then": |
348 | 348 | $conditional = implode(' ', $condition); |
349 | - $isvalid = intval(eval("return (" . $conditional . ");")); |
|
349 | + $isvalid = intval(eval("return (".$conditional.");")); |
|
350 | 350 | if ($isvalid) { |
351 | 351 | $output = $modifier_value[$i]; |
352 | 352 | } else { |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | break; |
356 | 356 | case "else": |
357 | 357 | $conditional = implode(' ', $condition); |
358 | - $isvalid = intval(eval("return (" . $conditional . ");")); |
|
358 | + $isvalid = intval(eval("return (".$conditional.");")); |
|
359 | 359 | if (!$isvalid) { |
360 | 360 | $output = $modifier_value[$i]; |
361 | 361 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | case "math": |
443 | 443 | $filter = preg_replace("~([a-zA-Z\n\r\t\s])~", "", $modifier_value[$i]); |
444 | 444 | $filter = str_replace("?", $output, $filter); |
445 | - $output = eval("return " . $filter . ";"); |
|
445 | + $output = eval("return ".$filter.";"); |
|
446 | 446 | break; |
447 | 447 | case "isnotempty": |
448 | 448 | if (!empty($output)) $output = $modifier_value[$i]; |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | break; |
464 | 464 | case "value": |
465 | 465 | if ($i > 0 && $modifier_cmd[$i - 1] == "set") { |
466 | - $modx->SetPlaceholder("phx." . $output, $modifier_value[$i]); |
|
466 | + $modx->SetPlaceholder("phx.".$output, $modifier_value[$i]); |
|
467 | 467 | } |
468 | 468 | $output = NULL; |
469 | 469 | break; |
@@ -484,25 +484,25 @@ discard block |
||
484 | 484 | default: |
485 | 485 | $snippet = ''; |
486 | 486 | // modified by Anton Kuzmin (23.06.2010) // |
487 | - $snippetName = 'phx:' . $modifier_cmd[$i]; |
|
487 | + $snippetName = 'phx:'.$modifier_cmd[$i]; |
|
488 | 488 | if (isset($modx->snippetCache[$snippetName])) { |
489 | 489 | $snippet = $modx->snippetCache[$snippetName]; |
490 | 490 | } else { // not in cache so let's check the db |
491 | - $sql = "SELECT snippet FROM " . $modx->getFullTableName("site_snippets") . " WHERE " . $modx->getFullTableName("site_snippets") . ".name='" . $modx->db->escape($snippetName) . "';"; |
|
491 | + $sql = "SELECT snippet FROM ".$modx->getFullTableName("site_snippets")." WHERE ".$modx->getFullTableName("site_snippets").".name='".$modx->db->escape($snippetName)."';"; |
|
492 | 492 | $result = $modx->dbQuery($sql); |
493 | 493 | if ($modx->recordCount($result) == 1) { |
494 | 494 | $row = $modx->fetchRow($result); |
495 | 495 | $snippet = $modx->snippetCache[$row['name']] = $row['snippet']; |
496 | 496 | $this->Log(" |--- DB -> Custom Modifier"); |
497 | 497 | } else if ($modx->recordCount($result) == 0) { // If snippet not found, look in the modifiers folder |
498 | - $filename = $modx->config['rb_base_dir'] . 'plugins/phx/modifiers/' . $modifier_cmd[$i] . '.phx.php'; |
|
498 | + $filename = $modx->config['rb_base_dir'].'plugins/phx/modifiers/'.$modifier_cmd[$i].'.phx.php'; |
|
499 | 499 | if (@file_exists($filename)) { |
500 | 500 | $file_contents = @file_get_contents($filename); |
501 | - $file_contents = str_replace('<' . '?php', '', $file_contents); |
|
502 | - $file_contents = str_replace('?' . '>', '', $file_contents); |
|
501 | + $file_contents = str_replace('<'.'?php', '', $file_contents); |
|
502 | + $file_contents = str_replace('?'.'>', '', $file_contents); |
|
503 | 503 | $file_contents = str_replace('<?', '', $file_contents); |
504 | 504 | $snippet = $modx->snippetCache[$snippetName] = $file_contents; |
505 | - $modx->snippetCache[$snippetName . 'Props'] = ''; |
|
505 | + $modx->snippetCache[$snippetName.'Props'] = ''; |
|
506 | 506 | $this->Log(" |--- File ($filename) -> Custom Modifier"); |
507 | 507 | } else { |
508 | 508 | $this->Log(" |--- PHX Error: {$modifier_cmd[$i]} could not be found"); |
@@ -517,15 +517,15 @@ discard block |
||
517 | 517 | $options = $modifier_value[$i]; |
518 | 518 | $custom = eval($cm); |
519 | 519 | $msg = ob_get_contents(); |
520 | - $output = $msg . $custom; |
|
520 | + $output = $msg.$custom; |
|
521 | 521 | ob_end_clean(); |
522 | 522 | } else { |
523 | 523 | $output = ''; |
524 | 524 | } |
525 | 525 | break; |
526 | 526 | } |
527 | - if (count($condition)) $this->Log(" |--- Condition = '" . $condition[count($condition) - 1] . "'"); |
|
528 | - $this->Log(" |--- Output = '" . $output . "'"); |
|
527 | + if (count($condition)) $this->Log(" |--- Condition = '".$condition[count($condition) - 1]."'"); |
|
528 | + $this->Log(" |--- Output = '".$output."'"); |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | return $output; |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | if (!empty($this->console)) { |
541 | 541 | $console = implode("\n", $this->console); |
542 | 542 | $this->console = array(); |
543 | - return '<pre style="overflow: auto;">' . $console . '</pre>'; |
|
543 | + return '<pre style="overflow: auto;">'.$console.'</pre>'; |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | { |
565 | 565 | if ($this->debug) { |
566 | 566 | $this->debugLog = true; |
567 | - $this->console[] = (count($this->console) + 1 - $this->curPass) . " [" . strftime("%H:%M:%S", time()) . "] " . $this->LogClean($string); |
|
567 | + $this->console[] = (count($this->console) + 1 - $this->curPass)." [".strftime("%H:%M:%S", time())."] ".$this->LogClean($string); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
@@ -576,14 +576,14 @@ discard block |
||
576 | 576 | { |
577 | 577 | if ($this->debug) { |
578 | 578 | $this->debugLog = true; |
579 | - $this->console[] = (count($this->console) + 1 - $this->curPass) . " [" . strftime("%H:%M:%S", time()) . "] " . " |--- Returns: <div style='margin: 10px;'>" . $this->LogClean($string) . "</div>"; |
|
579 | + $this->console[] = (count($this->console) + 1 - $this->curPass)." [".strftime("%H:%M:%S", time())."] "." |--- Returns: <div style='margin: 10px;'>".$this->LogClean($string)."</div>"; |
|
580 | 580 | } |
581 | 581 | } |
582 | 582 | |
583 | 583 | // Log pass |
584 | 584 | public function LogPass() |
585 | 585 | { |
586 | - $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Pass " . $this->curPass . "</div>"; |
|
586 | + $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Pass ".$this->curPass."</div>"; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | // Log pass |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | */ |
593 | 593 | public function LogSource($string) |
594 | 594 | { |
595 | - $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Source:</div>" . $this->LogClean($string); |
|
595 | + $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Source:</div>".$this->LogClean($string); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | if (!array_key_exists($userid, $this->cache["mo"])) { |
642 | 642 | $tbl = $modx->getFullTableName("webgroup_names"); |
643 | 643 | $tbl2 = $modx->getFullTableName("web_groups"); |
644 | - $sql = "SELECT wgn.name FROM $tbl wgn INNER JOIN $tbl2 wg ON wg.webgroup=wgn.id AND wg.webuser='" . $userid . "'"; |
|
644 | + $sql = "SELECT wgn.name FROM $tbl wgn INNER JOIN $tbl2 wg ON wg.webgroup=wgn.id AND wg.webuser='".$userid."'"; |
|
645 | 645 | $this->cache["mo"][$userid] = $grpNames = $modx->db->getColumn("name", $sql); |
646 | 646 | } else { |
647 | 647 | $grpNames = $this->cache["mo"][$userid]; |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | public function ucfirst($str) |
733 | 733 | { |
734 | 734 | if (function_exists('mb_strtoupper') && function_exists('mb_substr') && function_exists('mb_strlen')) |
735 | - return mb_strtoupper(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str)); |
|
735 | + return mb_strtoupper(mb_substr($str, 0, 1)).mb_substr($str, 1, mb_strlen($str)); |
|
736 | 736 | return ucfirst($str); |
737 | 737 | } |
738 | 738 | |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | public function lcfirst($str) |
744 | 744 | { |
745 | 745 | if (function_exists('mb_strtolower') && function_exists('mb_substr') && function_exists('mb_strlen')) |
746 | - return mb_strtolower(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str)); |
|
746 | + return mb_strtolower(mb_substr($str, 0, 1)).mb_substr($str, 1, mb_strlen($str)); |
|
747 | 747 | return lcfirst($str); |
748 | 748 | } |
749 | 749 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $file = $mode = ''; |
69 | 69 | } |
70 | 70 | $flag = !(empty($file) || empty($mode)); |
71 | - $f = MODX_BASE_PATH . $this->relativePath($file); |
|
71 | + $f = MODX_BASE_PATH.$this->relativePath($file); |
|
72 | 72 | if ($flag && !isset($this->_fileInfo[$f], $this->_fileInfo[$f][$mode])) { |
73 | 73 | $this->_fileInfo[$f] = pathinfo($f); |
74 | 74 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function checkFile($file) |
120 | 120 | { |
121 | - $f = is_scalar($file) ? MODX_BASE_PATH . $this->relativePath($file) : ''; |
|
121 | + $f = is_scalar($file) ? MODX_BASE_PATH.$this->relativePath($file) : ''; |
|
122 | 122 | return (!empty($f) && is_file($f) && is_readable($f)); |
123 | 123 | } |
124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function checkDir($path) |
130 | 130 | { |
131 | 131 | $f = is_scalar($path) ? $this->relativePath($path) : ''; |
132 | - return (!empty($f) && is_dir(MODX_BASE_PATH . $f) && is_readable(MODX_BASE_PATH . $f)); |
|
132 | + return (!empty($f) && is_dir(MODX_BASE_PATH.$f) && is_readable(MODX_BASE_PATH.$f)); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | { |
142 | 142 | $out = 0; |
143 | 143 | if ($this->checkFile($file)) { |
144 | - $out = filesize(MODX_BASE_PATH . $this->relativePath($file)); |
|
144 | + $out = filesize(MODX_BASE_PATH.$this->relativePath($file)); |
|
145 | 145 | } |
146 | 146 | if ($format) { |
147 | 147 | $types = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); |
148 | 148 | $size = $out > 0 ? floor(log($out, 1024)) : 0; |
149 | - $out = number_format($out / pow(1024, $size), 2, '.', ',') . ' ' . $types[$size]; |
|
149 | + $out = number_format($out / pow(1024, $size), 2, '.', ',').' '.$types[$size]; |
|
150 | 150 | } |
151 | 151 | return $out; |
152 | 152 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $out = null; |
167 | 167 | $path = $this->relativePath($file); |
168 | 168 | if ($this->checkFile($path)) { |
169 | - $fname = MODX_BASE_PATH . $path; |
|
169 | + $fname = MODX_BASE_PATH.$path; |
|
170 | 170 | switch (true) { |
171 | 171 | /** need fileinfo extension */ |
172 | 172 | case (extension_loaded('fileinfo') && class_exists('\finfo')): |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function makeDir($path, $perm = 0755) |
217 | 217 | { |
218 | 218 | if (!$this->checkDir($path)) { |
219 | - $path = MODX_BASE_PATH . $this->relativePath($path); |
|
219 | + $path = MODX_BASE_PATH.$this->relativePath($path); |
|
220 | 220 | $flag = mkdir($path, $this->toOct($perm), true); |
221 | 221 | } else { |
222 | 222 | $flag = true; |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | public function copyFile($from, $to, $chmod = 0644) |
235 | 235 | { |
236 | 236 | $flag = false; |
237 | - $from = MODX_BASE_PATH . $this->relativePath($from); |
|
238 | - $to = MODX_BASE_PATH . $this->relativePath($to); |
|
237 | + $from = MODX_BASE_PATH.$this->relativePath($from); |
|
238 | + $to = MODX_BASE_PATH.$this->relativePath($to); |
|
239 | 239 | $dir = $this->takeFileDir($to); |
240 | 240 | if ($this->checkFile($from) && $this->makeDir($dir) && copy($from, $to)) { |
241 | 241 | chmod($to, $this->toOct($chmod)); |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | public function moveFile($from, $to, $chmod = 0644) |
255 | 255 | { |
256 | 256 | $flag = false; |
257 | - $from = MODX_BASE_PATH . $this->relativePath($from); |
|
258 | - $to = MODX_BASE_PATH . $this->relativePath($to); |
|
257 | + $from = MODX_BASE_PATH.$this->relativePath($from); |
|
258 | + $to = MODX_BASE_PATH.$this->relativePath($to); |
|
259 | 259 | $dir = $this->takeFileDir($to); |
260 | 260 | if ($this->checkFile($from) && $this->makeDir($dir) && rename($from, $to)) { |
261 | 261 | chmod($to, $this->toOct($chmod)); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $owner = MODX_BASE_PATH; |
278 | 278 | } |
279 | 279 | if (!(empty($path) || !is_scalar($path)) && !preg_match("/^http(s)?:\/\/\w+/", $path)) { |
280 | - $path = trim(preg_replace("#^" . $owner . "#", '', $path), '/'); |
|
280 | + $path = trim(preg_replace("#^".$owner."#", '', $path), '/'); |
|
281 | 281 | } else { |
282 | 282 | $path = ''; |
283 | 283 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | public function rmDir($dirPath) |
309 | 309 | { |
310 | 310 | $flag = false; |
311 | - $path = $_path = MODX_BASE_PATH . $this->relativePath($dirPath); |
|
311 | + $path = $_path = MODX_BASE_PATH.$this->relativePath($dirPath); |
|
312 | 312 | if ($this->checkDir($path)) { |
313 | 313 | $dirIterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS); |
314 | 314 | $dirRecursiveIterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::CHILD_FIRST); |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | { |
329 | 329 | $flag = false; |
330 | 330 | if ($this->checkFile($file)) { |
331 | - $flag = unlink(MODX_BASE_PATH . $this->relativePath($file)); |
|
331 | + $flag = unlink(MODX_BASE_PATH.$this->relativePath($file)); |
|
332 | 332 | } |
333 | 333 | return $flag; |
334 | 334 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function delete($path) |
341 | 341 | { |
342 | - $path = MODX_BASE_PATH . $this->relativePath($path); |
|
342 | + $path = MODX_BASE_PATH.$this->relativePath($path); |
|
343 | 343 | switch (true) { |
344 | 344 | case $this->checkDir($path): |
345 | 345 | $flag = $this->rmDir($path); |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | public function getInexistantFilename($file, $full = false) |
362 | 362 | { |
363 | 363 | $i = 1; |
364 | - $file = $mainFile = MODX_BASE_PATH . $this->relativePath($file); |
|
364 | + $file = $mainFile = MODX_BASE_PATH.$this->relativePath($file); |
|
365 | 365 | while ($this->checkFile($file)) { |
366 | 366 | $i++; |
367 | - $out = $this->takeFileDir($file) . '/'; |
|
368 | - $out .= $this->takeFileName($mainFile) . "({$i})." . $this->takeFileExt($file); |
|
367 | + $out = $this->takeFileDir($file).'/'; |
|
368 | + $out .= $this->takeFileName($mainFile)."({$i}).".$this->takeFileExt($file); |
|
369 | 369 | $file = $out; |
370 | 370 | } |
371 | 371 | return $full ? $file : $this->takeFileBasename($file); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php namespace Helpers; |
2 | 2 | |
3 | -include_once(MODX_BASE_PATH . 'assets/snippets/phpthumb/phpthumb.class.php'); |
|
4 | -require_once(MODX_BASE_PATH . 'assets/lib/Helpers/FS.php'); |
|
3 | +include_once(MODX_BASE_PATH.'assets/snippets/phpthumb/phpthumb.class.php'); |
|
4 | +require_once(MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Class PHPThumb |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $this->thumb->sourceFilename = $inputFile; |
45 | 45 | $ext = explode('.', $inputFile); |
46 | 46 | $ext = str_replace('jpeg', 'jpg', strtolower(array_pop($ext))); |
47 | - $options = 'f=' . $ext . '&' . $options; |
|
47 | + $options = 'f='.$ext.'&'.$options; |
|
48 | 48 | $this->setOptions($options); |
49 | 49 | if ($this->thumb->GenerateThumbnail() && $this->thumb->RenderToFile($outputFile)) { |
50 | 50 | return true; |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | case 'jpg': |
65 | 65 | $ext = $this->fs->takeFileExt($file); |
66 | 66 | if ($ext == 'jpeg' || $ext == 'jpg') { |
67 | - $cmd = '/usr/bin/jpegtran -optimize -progressive -copy none -outfile ' . escapeshellarg($file . '_') . ' ' . escapeshellarg($file); |
|
67 | + $cmd = '/usr/bin/jpegtran -optimize -progressive -copy none -outfile '.escapeshellarg($file.'_').' '.escapeshellarg($file); |
|
68 | 68 | exec($cmd, $result, $return_var); |
69 | - if ($this->fs->fileSize($file) > $this->fs->fileSize($file . '_')) { |
|
70 | - $this->fs->moveFile($file . '_', $file); |
|
69 | + if ($this->fs->fileSize($file) > $this->fs->fileSize($file.'_')) { |
|
70 | + $this->fs->moveFile($file.'_', $file); |
|
71 | 71 | } else { |
72 | - $this->fs->unlink($file . '_'); |
|
72 | + $this->fs->unlink($file.'_'); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | break; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function max($key) |
375 | 375 | { |
376 | - return $this->reduce(function ($result, $item) use ($key) { |
|
376 | + return $this->reduce(function($result, $item) use ($key) { |
|
377 | 377 | return (is_null($result) || $item[$key] > $result) ? $item[$key] : $result; |
378 | 378 | }); |
379 | 379 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | */ |
387 | 387 | public function min($key) |
388 | 388 | { |
389 | - return $this->reduce(function ($result, $item) use ($key) { |
|
389 | + return $this->reduce(function($result, $item) use ($key) { |
|
390 | 390 | return (is_null($result) || $item[$key] < $result) ? $item[$key] : $result; |
391 | 391 | }); |
392 | 392 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | /** Ссылка на превью */ |
181 | 181 | public function getImage() |
182 | 182 | { |
183 | - return $this->getScheme() . $this->image; |
|
183 | + return $this->getScheme().$this->image; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** Ссылка на видео */ |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $url .= '&autoplay=1'; |
192 | 192 | } |
193 | 193 | |
194 | - return $this->getScheme() . $url; |
|
194 | + return $this->getScheme().$url; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** Название видео */ |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | protected function cleanLink() |
252 | 252 | { |
253 | 253 | if (!preg_match('/^(http|https)\:\/\//i', $this->link)) { |
254 | - $this->link = 'http://' . $this->link; |
|
254 | + $this->link = 'http://'.$this->link; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | if (!$this->link_parts = parse_url($this->link)) { |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | |
330 | 330 | $this->hosting = self::YOUTUBE; |
331 | 331 | $this->id = $id; |
332 | - $this->image = 'img.youtube.com/vi/' . $id . '/0.jpg'; |
|
332 | + $this->image = 'img.youtube.com/vi/'.$id.'/0.jpg'; |
|
333 | 333 | /** @see https://developers.google.com/youtube/player_parameters */ |
334 | - $this->video = 'www.youtube.com/embed/' . $id . '?showinfo=0&modestbranding=1&rel=0'; |
|
334 | + $this->video = 'www.youtube.com/embed/'.$id.'?showinfo=0&modestbranding=1&rel=0'; |
|
335 | 335 | |
336 | 336 | if ($this->info) { |
337 | 337 | $this->getYoutubeInfo($id); |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | |
349 | 349 | $this->hosting = self::VIMEO; |
350 | 350 | $this->id = $id; |
351 | - $this->video = 'player.vimeo.com/video/' . $id . '?'; |
|
351 | + $this->video = 'player.vimeo.com/video/'.$id.'?'; |
|
352 | 352 | |
353 | 353 | if ($this->info) { |
354 | 354 | $this->getVimeoInfo($id); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | { |
362 | 362 | $this->hosting = self::RUTUBE; |
363 | 363 | $this->id = $id; |
364 | - $this->video = 'rutube.ru/video/embed/' . $id . '?'; |
|
364 | + $this->video = 'rutube.ru/video/embed/'.$id.'?'; |
|
365 | 365 | |
366 | 366 | if ($this->info) { |
367 | 367 | $this->getRutubeInfo($id); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | /** Парсинг XML от RUTUBE и определение превьюхи */ |
373 | 373 | protected function getRutubeInfo($id) |
374 | 374 | { |
375 | - if (@$xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=" . $id . "&utf=1")) { |
|
375 | + if (@$xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=".$id."&utf=1")) { |
|
376 | 376 | $this->title = (string)$xml->title; |
377 | 377 | $this->image = (string)$xml->thumbnail_url; |
378 | 378 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | /** Парсинг XML от VIMEO и определение превьюхи */ |
382 | 382 | protected function getVimeoInfo($id) |
383 | 383 | { |
384 | - if (@$xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $id . '.xml')) { |
|
384 | + if (@$xml = simplexml_load_file('http://vimeo.com/api/v2/video/'.$id.'.xml')) { |
|
385 | 385 | $this->title = (string)$xml->video->title; |
386 | 386 | $this->image = (string)$xml->video->thumbnail_large ?: $xml->video->thumbnail_medium; |
387 | 387 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | /** Получение названия ролика */ |
391 | 391 | protected function getYoutubeInfo($id) |
392 | 392 | { |
393 | - if (@$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $id)) { |
|
393 | + if (@$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/'.$id)) { |
|
394 | 394 | $this->title = (string)$xml->title; |
395 | 395 | } |
396 | 396 | } |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | |
421 | 421 | $url = $this->getVideo($autoplay); |
422 | 422 | if (!empty($class)) { |
423 | - $class = ' class="' . $class . '"'; |
|
423 | + $class = ' class="'.$class.'"'; |
|
424 | 424 | } |
425 | - return '<iframe src="' . $url . '" width="' . $width . '" height="' . $height . '" frameborder="0" allowfullscreen' . $class . '></iframe>'; |
|
425 | + return '<iframe src="'.$url.'" width="'.$width.'" height="'.$height.'" frameborder="0" allowfullscreen'.$class.'></iframe>'; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** Прогоняем тест по видам URL */ |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | foreach ($links as $link) { |
436 | 436 | $v = new static($link); |
437 | 437 | echo "<h1>$link</h1>\n" |
438 | - . "<h3>" . $v->getHosting() . "</h3>" |
|
439 | - . "<b>Видео:</b> " . $v->getVideo() . "<br />\n" |
|
440 | - . "<b>Название:</b> " . $v->getTitle() . "<br />\n" |
|
441 | - . "<b>Картинка:</b> " . $v->getImage() . "<hr />\n"; |
|
438 | + . "<h3>".$v->getHosting()."</h3>" |
|
439 | + . "<b>Видео:</b> ".$v->getVideo()."<br />\n" |
|
440 | + . "<b>Название:</b> ".$v->getTitle()."<br />\n" |
|
441 | + . "<b>Картинка:</b> ".$v->getImage()."<hr />\n"; |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | } |
445 | 445 | \ No newline at end of file |
@@ -211,8 +211,12 @@ |
||
211 | 211 | /** Обработка ссылки. Возвращает идентификатор видеохостинга или false */ |
212 | 212 | public function process($link = null, $info = null) |
213 | 213 | { |
214 | - if (!empty($link)) $this->setLink($link); |
|
215 | - if (!empty($info)) $this->setInfo($info); |
|
214 | + if (!empty($link)) { |
|
215 | + $this->setLink($link); |
|
216 | + } |
|
217 | + if (!empty($info)) { |
|
218 | + $this->setInfo($info); |
|
219 | + } |
|
216 | 220 | |
217 | 221 | if ($this->cleanLink()) { |
218 | 222 | if ($this->maybeYoutube()) { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once(MODX_BASE_PATH . 'assets/lib/Helpers/FS.php'); |
|
3 | +require_once(MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Class AssetsHelper |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | $src = $params['src']; |
98 | 98 | $remote = strpos($src, "http") !== false; |
99 | 99 | if (!$remote) { |
100 | - $src = $this->modx->config['site_url'] . $src; |
|
100 | + $src = $this->modx->config['site_url'].$src; |
|
101 | 101 | if (!$this->fs->checkFile($params['src'])) { |
102 | - $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper'); |
|
102 | + $this->modx->logEvent(0, 3, 'Cannot load '.$src, 'Assets helper'); |
|
103 | 103 | return $out; |
104 | 104 | } |
105 | 105 | } |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | $tmp = explode('.', $src); |
108 | 108 | $type = isset($params['type']) ? $params['type'] : end($tmp); |
109 | 109 | if ($type == 'js') { |
110 | - $out = '<script type="text/javascript" src="' . $src . '"></script>'; |
|
110 | + $out = '<script type="text/javascript" src="'.$src.'"></script>'; |
|
111 | 111 | } else { |
112 | - $out = '<link rel="stylesheet" type="text/css" href="' . $src . '">'; |
|
112 | + $out = '<link rel="stylesheet" type="text/css" href="'.$src.'">'; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $this->modx->loadedjscripts[$name] = $params; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php namespace Module; |
2 | 2 | |
3 | -include_once(dirname(dirname(__FILE__)) . '/APIHelpers.class.php'); |
|
3 | +include_once(dirname(dirname(__FILE__)).'/APIHelpers.class.php'); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Class Helper |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function isErrorJSON($json) |
111 | 111 | { |
112 | - require_once(MODX_BASE_PATH . "assets/snippets/DocLister/lib/jsonHelper.class.php"); |
|
112 | + require_once(MODX_BASE_PATH."assets/snippets/DocLister/lib/jsonHelper.class.php"); |
|
113 | 113 | $error = \jsonHelper::json_last_error_msg(); |
114 | 114 | if (!in_array($error, array('error_none', 'other'))) { |
115 | 115 | $error = true; |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $FS = \Helpers\FS::getInstance(); |
66 | 66 | $tplFolder = $FS->relativePath($tplFolder); |
67 | 67 | |
68 | - $this->_publicFolder = "/" . $tplFolder . "/public/"; |
|
69 | - $this->_tplFolder = MODX_BASE_PATH . $tplFolder . "/template/"; |
|
68 | + $this->_publicFolder = "/".$tplFolder."/public/"; |
|
69 | + $this->_tplFolder = MODX_BASE_PATH.$tplFolder."/template/"; |
|
70 | 70 | |
71 | 71 | if (!defined('MODX_MAIN_URL')) { |
72 | 72 | define('MODX_MAIN_URL', MODX_SITE_URL); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function src($path) |
97 | 97 | { |
98 | - return rtrim(MODX_MAIN_URL, '/') . $this->publicFolder() . ltrim($path, '/'); |
|
98 | + return rtrim(MODX_MAIN_URL, '/').$this->publicFolder().ltrim($path, '/'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | |
118 | 118 | ob_start(); |
119 | 119 | extract($this->vars); |
120 | - if (file_exists($incPath . $name)) { |
|
121 | - include($incPath . $name); |
|
120 | + if (file_exists($incPath.$name)) { |
|
121 | + include($incPath.$name); |
|
122 | 122 | $content = ob_get_contents(); |
123 | 123 | } |
124 | 124 | ob_end_clean(); |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | public function showBody($TplName, array $tplParams = array()) |
158 | 158 | { |
159 | 159 | ob_start(); |
160 | - if (file_exists($this->_tplFolder . $TplName . "." . self::TPL_EXT)) { |
|
160 | + if (file_exists($this->_tplFolder.$TplName.".".self::TPL_EXT)) { |
|
161 | 161 | extract($this->vars); |
162 | - include($this->_tplFolder . $TplName . "." . self::TPL_EXT); |
|
162 | + include($this->_tplFolder.$TplName.".".self::TPL_EXT); |
|
163 | 163 | } |
164 | 164 | $content = ob_get_contents(); |
165 | 165 | ob_end_clean(); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | ); |
202 | 202 | $out = implode("?", array($this->_modx->getManagerPath(), http_build_query($data))); |
203 | 203 | if ($full) { |
204 | - $out = $this->_modx->getConfig('site_url') . ltrim($out, '/'); |
|
204 | + $out = $this->_modx->getConfig('site_url').ltrim($out, '/'); |
|
205 | 205 | } |
206 | 206 | return $out; |
207 | 207 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected static function _checkObj($id) |
71 | 71 | { |
72 | - $q = self::$modx->db->select('id', self::$modx->getFullTableName(self::TABLE()), "id = " . $id); |
|
72 | + $q = self::$modx->db->select('id', self::$modx->getFullTableName(self::TABLE()), "id = ".$id); |
|
73 | 73 | return (self::$modx->db->getRecordCount($q) == 1); |
74 | 74 | } |
75 | 75 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected static function _getValue($field, $id) |
82 | 82 | { |
83 | - $q = self::$modx->db->select($field, self::$modx->getFullTableName(self::TABLE()), "id = " . $id); |
|
83 | + $q = self::$modx->db->select($field, self::$modx->getFullTableName(self::TABLE()), "id = ".$id); |
|
84 | 84 | return self::$modx->db->getValue($q); |
85 | 85 | } |
86 | 86 | |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public static function listValue() |
91 | 91 | { |
92 | - $out = self::_workValue(function ($data, $modObj) { |
|
93 | - $listFunction = $data['key'] . 'Lists'; |
|
92 | + $out = self::_workValue(function($data, $modObj) { |
|
93 | + $listFunction = $data['key'].'Lists'; |
|
94 | 94 | $out = method_exists($modObj, $listFunction) ? $modObj->$listFunction() : array(); |
95 | 95 | $out['selected'] = $modObj->get($data['key']); |
96 | 96 | return $out; |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public static function saveValue() |
126 | 126 | { |
127 | - return self::_workValue(function ($data, $modObj) { |
|
127 | + return self::_workValue(function($data, $modObj) { |
|
128 | 128 | $out = array(); |
129 | 129 | if (isset($_POST['value']) && is_scalar($_POST['value'])) { |
130 | 130 | if ($modObj->set($data['key'], $_POST['value'])->save()) { |
131 | - $textMethod = $data['key'] . 'Text'; |
|
131 | + $textMethod = $data['key'].'Text'; |
|
132 | 132 | if (method_exists($modObj, $textMethod)) { |
133 | 133 | $out['value'] = $modObj->$textMethod(); |
134 | 134 | } else { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public static function getValue() |
147 | 147 | { |
148 | - return self::_workValue(function ($data, $modObj) { |
|
148 | + return self::_workValue(function($data, $modObj) { |
|
149 | 149 | return array( |
150 | 150 | 'value' => $modObj->get($data['key']) |
151 | 151 | ); |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | $oldValue = self::_getValue('deleted_at', $dataID); |
164 | 164 | $q = self::$modx->db->update(array( |
165 | 165 | 'deleted_at' => empty($oldValue) ? date('Y-m-d H:i:s') : null |
166 | - ), self::$modx->getFullTableName(self::TABLE()), "id = " . $dataID); |
|
166 | + ), self::$modx->getFullTableName(self::TABLE()), "id = ".$dataID); |
|
167 | 167 | if ($q) { |
168 | - $data['log'] = $oldValue ? 'Запись с ID ' . $dataID . ' восстановлена' : 'Запись с ID ' . $dataID . ' удалена'; |
|
168 | + $data['log'] = $oldValue ? 'Запись с ID '.$dataID.' восстановлена' : 'Запись с ID '.$dataID.' удалена'; |
|
169 | 169 | } else { |
170 | - $data['log'] = $oldValue ? 'Не удалось восстановить запись с ID ' . $dataID : 'Не удалось удалить запись с ID ' . $dataID; |
|
170 | + $data['log'] = $oldValue ? 'Не удалось восстановить запись с ID '.$dataID : 'Не удалось удалить запись с ID '.$dataID; |
|
171 | 171 | } |
172 | 172 | } else { |
173 | 173 | $data['log'] = '<span class="error">Ошибка</span>. Не удалось определить обновляему запись'; |