@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -include_once(MODX_BASE_PATH . "assets/lib/Helpers/Collection.php"); |
|
2 | +include_once(MODX_BASE_PATH."assets/lib/Helpers/Collection.php"); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Class DLCollection |
@@ -74,7 +74,7 @@ |
||
74 | 74 | */ |
75 | 75 | private function setOptions($options) |
76 | 76 | { |
77 | - $options = strtr($options, Array("," => "&", "_" => "=", '{' => '[', '}' => ']')); |
|
77 | + $options = strtr($options, array("," => "&", "_" => "=", '{' => '[', '}' => ']')); |
|
78 | 78 | parse_str($options, $params); |
79 | 79 | if(!is_array($params)) $params = array(); |
80 | 80 |
@@ -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 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $this->thumb->sourceFilename = $inputFile; |
35 | 35 | $ext = explode('.', $inputFile); |
36 | 36 | $ext = str_replace('jpeg', 'jpg', strtolower(array_pop($ext))); |
37 | - $options = 'f=' . $ext . '&' . $options; |
|
37 | + $options = 'f='.$ext.'&'.$options; |
|
38 | 38 | $this->setOptions($options); |
39 | 39 | if ($this->thumb->GenerateThumbnail() && $this->thumb->RenderToFile($outputFile)) { |
40 | 40 | return true; |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | case 'jpg': |
56 | 56 | $ext = $this->fs->takeFileExt($file); |
57 | 57 | if ($ext == 'jpeg' || $ext == 'jpg') { |
58 | - $cmd = '/usr/bin/jpegtran -optimize -progressive -copy none -outfile ' . escapeshellarg($file . '_') . ' ' . escapeshellarg($file); |
|
58 | + $cmd = '/usr/bin/jpegtran -optimize -progressive -copy none -outfile '.escapeshellarg($file.'_').' '.escapeshellarg($file); |
|
59 | 59 | exec($cmd, $result, $return_var); |
60 | - if ($this->fs->fileSize($file) > $this->fs->fileSize($file . '_')) { |
|
61 | - $this->fs->moveFile($file . '_', $file); |
|
60 | + if ($this->fs->fileSize($file) > $this->fs->fileSize($file.'_')) { |
|
61 | + $this->fs->moveFile($file.'_', $file); |
|
62 | 62 | } else { |
63 | - $this->fs->unlink($file . '_'); |
|
63 | + $this->fs->unlink($file.'_'); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | break; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $options = strtr($options, Array("," => "&", "_" => "=", '{' => '[', '}' => ']')); |
78 | 78 | parse_str($options, $params); |
79 | - if(!is_array($params)) $params = array(); |
|
79 | + if (!is_array($params)) $params = array(); |
|
80 | 80 | |
81 | 81 | foreach ($params as $key => $value) { |
82 | 82 | $this->thumb->setParameter($key, $value); |
@@ -76,7 +76,9 @@ |
||
76 | 76 | { |
77 | 77 | $options = strtr($options, Array("," => "&", "_" => "=", '{' => '[', '}' => ']')); |
78 | 78 | parse_str($options, $params); |
79 | - if(!is_array($params)) $params = array(); |
|
79 | + if(!is_array($params)) { |
|
80 | + $params = array(); |
|
81 | + } |
|
80 | 82 | |
81 | 83 | foreach ($params as $key => $value) { |
82 | 84 | $this->thumb->setParameter($key, $value); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function setIDs($IDs) |
29 | 29 | { |
30 | - $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2); |
|
30 | + $this->debug->debug('set ID list '.$this->debug->dumpData($IDs), 'setIDs', 2); |
|
31 | 31 | $IDs = $this->cleanIDs($IDs); |
32 | 32 | $this->debug->debugEnd("setIDs"); |
33 | 33 | |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | if (isset($data['wrap'])) { |
283 | - if(is_array($data['wrap'])) $data['wrap'] = $this->parseRow($data['wrap']); |
|
283 | + if (is_array($data['wrap'])) $data['wrap'] = $this->parseRow($data['wrap']); |
|
284 | 284 | $data['wrap'] = $this->parseOuter($data); |
285 | 285 | } |
286 | 286 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
287 | - $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'], |
|
287 | + $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int) $data['parent'], |
|
288 | 288 | $this->activeBranch)); |
289 | 289 | if ($hideSubMenus) { |
290 | 290 | $docs[$currentLevel - 1][$data['parent']]['wrap'][] = $data; |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function getHereId() |
435 | 435 | { |
436 | - if (!$hereId = (int)$this->getCFGDef('hereId')) { |
|
437 | - $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0; |
|
436 | + if (!$hereId = (int) $this->getCFGDef('hereId')) { |
|
437 | + $hereId = isset($this->modx->documentIdentifier) ? (int) $this->modx->documentIdentifier : 0; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | return $hereId; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | 'evenClass' => '' |
461 | 461 | ); |
462 | 462 | if (isset($data['state'])) { |
463 | - $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']); |
|
463 | + $classes['stateClass'] = $this->getCFGDef($data['state'].'Class', $data['state']); |
|
464 | 464 | } |
465 | 465 | if (isset($data['here'])) { |
466 | 466 | $classes['hereClass'] = $this->getCFGDef('hereClass', 'current'); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | $classes['lastClass'] = $this->getCFGDef('lastClass', 'last'); |
482 | 482 | } |
483 | 483 | if ($levelClass = $this->getCFGDef('levelClass', 'level')) { |
484 | - $classes['levelClass'] = $levelClass . $data['level']; |
|
484 | + $classes['levelClass'] = $levelClass.$data['level']; |
|
485 | 485 | } |
486 | 486 | if (isset($data['type']) && $data['type'] == 'reference') { |
487 | 487 | $classes['webLinkClass'] = $this->getCFGDef('webLinkClass'); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | } |
571 | 571 | |
572 | 572 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
573 | - $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'], |
|
573 | + $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int) $data['parent'], |
|
574 | 574 | $this->activeBranch)); |
575 | 575 | if ($hideSubMenus) { |
576 | 576 | $docs[$currentLevel - 1][$data['parent']]['children'][] = $data; |
@@ -605,6 +605,6 @@ discard block |
||
605 | 605 | */ |
606 | 606 | public function getCFGDef($name, $def = null) |
607 | 607 | { |
608 | - return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def)); |
|
608 | + return parent::getCFGDef($name.$this->currentLevel, parent::getCFGDef($name, $def)); |
|
609 | 609 | } |
610 | 610 | } |
@@ -280,7 +280,9 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | if (isset($data['wrap'])) { |
283 | - if(is_array($data['wrap'])) $data['wrap'] = $this->parseRow($data['wrap']); |
|
283 | + if(is_array($data['wrap'])) { |
|
284 | + $data['wrap'] = $this->parseRow($data['wrap']); |
|
285 | + } |
|
284 | 286 | $data['wrap'] = $this->parseOuter($data); |
285 | 287 | } |
286 | 288 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
@@ -306,7 +308,9 @@ discard block |
||
306 | 308 | } |
307 | 309 | } |
308 | 310 | } |
309 | - if ($joinMenus) $out = $this->parseOuter(array('wrap' => $out)); |
|
311 | + if ($joinMenus) { |
|
312 | + $out = $this->parseOuter(array('wrap' => $out)); |
|
313 | + } |
|
310 | 314 | |
311 | 315 | return $out; |
312 | 316 | } |
@@ -542,7 +546,9 @@ discard block |
||
542 | 546 | $currentLevel = count($this->levels); |
543 | 547 | $docs = $this->levels; |
544 | 548 | |
545 | - if (empty($docs)) return '[]'; |
|
549 | + if (empty($docs)) { |
|
550 | + return '[]'; |
|
551 | + } |
|
546 | 552 | |
547 | 553 | /** @var prepare_DL_Extender_ $extPrepare */ |
548 | 554 | $extPrepare = $this->getExtender('prepare'); |
@@ -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 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $this->user["usrid"] = isset($_SESSION['webInternalKey']) ? intval($_SESSION['webInternalKey']) : 0; |
52 | 52 | $this->user["id"] = ($this->user["usrid"] > 0) ? (-$this->user["usrid"]) : $this->user["mgrid"]; |
53 | 53 | |
54 | - $this->debug = (bool)$debug; |
|
54 | + $this->debug = (bool) $debug; |
|
55 | 55 | |
56 | 56 | $this->maxPasses = ($maxpass != '') ? $maxpass : 50; |
57 | 57 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | preg_match_all('~(?:=`[^`@]*?)(\[\+([^:\+\[\]]+)([^\[\]]*?)\+\])~s', $template, $matches); |
96 | 96 | if ($matches[0]) { |
97 | 97 | $template = str_replace($matches[1], '', $template); |
98 | - $this->Log("Cleaning unsolved tags: \n" . implode("\n", $matches[2])); |
|
98 | + $this->Log("Cleaning unsolved tags: \n".implode("\n", $matches[2])); |
|
99 | 99 | } |
100 | 100 | // Restore non-call characters in the template: [, ] |
101 | 101 | $template = str_replace($this->safetags[1], $this->safetags[2], $template); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | // Write an event log if debugging is enabled and there is something to log |
109 | 109 | if ($this->debug && $this->debugLog) { |
110 | - $modx->logEvent($this->curPass, 1, $this->createEventLog(), $this->name . ' ' . $this->version); |
|
110 | + $modx->logEvent($this->curPass, 1, $this->createEventLog(), $this->name.' '.$this->version); |
|
111 | 111 | $this->debugLog = false; |
112 | 112 | } |
113 | 113 | |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | for ($i = 0; $i < $count; $i++) { |
139 | 139 | $var_search[] = $matches[0][$i]; |
140 | 140 | $input = $matches[1][$i]; |
141 | - $this->Log('MODX Chunk: ' . $input); |
|
142 | - $input = $modx->mergeChunkContent('{{' . $input . '}}'); |
|
141 | + $this->Log('MODX Chunk: '.$input); |
|
142 | + $input = $modx->mergeChunkContent('{{'.$input.'}}'); |
|
143 | 143 | $var_replace[] = $this->Filter($input, $matches[2][$i]); |
144 | 144 | } |
145 | 145 | $template = str_replace($var_search, $var_replace, $template); |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | // for each detected snippet |
156 | 156 | for ($i = 0; $i < $count; $i++) { |
157 | 157 | $snippet = $matches[2][$i]; // snippet call |
158 | - $this->Log("MODx Snippet -> " . $snippet); |
|
158 | + $this->Log("MODx Snippet -> ".$snippet); |
|
159 | 159 | |
160 | 160 | // Let MODx evaluate snippet |
161 | - $replace = $modx->evalSnippets("[[" . $snippet . "]]"); |
|
161 | + $replace = $modx->evalSnippets("[[".$snippet."]]"); |
|
162 | 162 | $this->LogSnippet($replace); |
163 | 163 | |
164 | 164 | // Replace values |
@@ -187,19 +187,19 @@ discard block |
||
187 | 187 | switch ($matches[1][$i]) { |
188 | 188 | // Document / Template Variable eXtended |
189 | 189 | case "*": |
190 | - $this->Log("MODx TV/DV: " . $input); |
|
191 | - $input = $modx->mergeDocumentContent("[*" . $input . "*]"); |
|
190 | + $this->Log("MODx TV/DV: ".$input); |
|
191 | + $input = $modx->mergeDocumentContent("[*".$input."*]"); |
|
192 | 192 | $replace = $this->Filter($input, $modifiers); |
193 | 193 | break; |
194 | 194 | // MODx Setting eXtended |
195 | 195 | case "(": |
196 | - $this->Log("MODx Setting variable: " . $input); |
|
197 | - $input = $modx->mergeSettingsContent("[(" . $input . ")]"); |
|
196 | + $this->Log("MODx Setting variable: ".$input); |
|
197 | + $input = $modx->mergeSettingsContent("[(".$input.")]"); |
|
198 | 198 | $replace = $this->Filter($input, $modifiers); |
199 | 199 | break; |
200 | 200 | // MODx Placeholder eXtended |
201 | 201 | default: |
202 | - $this->Log("MODx / PHx placeholder variable: " . $input); |
|
202 | + $this->Log("MODx / PHx placeholder variable: ".$input); |
|
203 | 203 | // Check if placeholder is set |
204 | 204 | if (!array_key_exists($input, $this->placeholders) && !array_key_exists($input, |
205 | 205 | $modx->placeholders) |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | { |
242 | 242 | global $modx; |
243 | 243 | $output = $input; |
244 | - $this->Log(" |--- Input = '" . $output . "'"); |
|
244 | + $this->Log(" |--- Input = '".$output."'"); |
|
245 | 245 | if (preg_match_all('~:([^:=]+)(?:=`(.*?)`(?=:[^:=]+|$))?~s', $modifiers, $matches)) { |
246 | 246 | $modifier_cmd = $matches[1]; // modifier command |
247 | 247 | $modifier_value = $matches[2]; // modifier value |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | $condition = array(); |
250 | 250 | for ($i = 0; $i < $count; $i++) { |
251 | 251 | $output = trim($output); |
252 | - $this->Log(" |--- Modifier = '" . $modifier_cmd[$i] . "'"); |
|
252 | + $this->Log(" |--- Modifier = '".$modifier_cmd[$i]."'"); |
|
253 | 253 | if ($modifier_value[$i] != '') { |
254 | - $this->Log(" |--- Options = '" . $modifier_value[$i] . "'"); |
|
254 | + $this->Log(" |--- Options = '".$modifier_value[$i]."'"); |
|
255 | 255 | } |
256 | 256 | switch ($modifier_cmd[$i]) { |
257 | 257 | ##### Conditional Modifiers |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | break; |
393 | 393 | case "wordwrap": // default: 70 |
394 | 394 | $wrapat = intval($modifier_value[$i]) ? intval($modifier_value[$i]) : 70; |
395 | - $output = preg_replace_callback("@(\b\w+\b)@",function($m) use($wrapat) {return wordwrap($m[1],$wrapat,' ',1);},$output); |
|
395 | + $output = preg_replace_callback("@(\b\w+\b)@", function($m) use($wrapat) {return wordwrap($m[1], $wrapat, ' ', 1); },$output); |
|
396 | 396 | break; |
397 | 397 | case "limit": // default: 100 |
398 | 398 | $limit = intval($modifier_value[$i]) ? intval($modifier_value[$i]) : 100; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | case "math": |
413 | 413 | $filter = preg_replace("~([a-zA-Z\n\r\t\s])~", "", $modifier_value[$i]); |
414 | 414 | $filter = str_replace("?", $output, $filter); |
415 | - $output = eval("return " . $filter . ";"); |
|
415 | + $output = eval("return ".$filter.";"); |
|
416 | 416 | break; |
417 | 417 | case "isnotempty": |
418 | 418 | if (!empty($output)) { |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | break; |
440 | 440 | case "value": |
441 | 441 | if ($i > 0 && $modifier_cmd[$i - 1] == "set") { |
442 | - $modx->SetPlaceholder("phx." . $output, $modifier_value[$i]); |
|
442 | + $modx->SetPlaceholder("phx.".$output, $modifier_value[$i]); |
|
443 | 443 | } |
444 | 444 | $output = null; |
445 | 445 | break; |
@@ -464,11 +464,11 @@ discard block |
||
464 | 464 | default: |
465 | 465 | $snippet = ''; |
466 | 466 | // modified by Anton Kuzmin (23.06.2010) // |
467 | - $snippetName = 'phx:' . $modifier_cmd[$i]; |
|
467 | + $snippetName = 'phx:'.$modifier_cmd[$i]; |
|
468 | 468 | if (isset($modx->snippetCache[$snippetName])) { |
469 | 469 | $snippet = $modx->snippetCache[$snippetName]; |
470 | 470 | } else { // not in cache so let's check the db |
471 | - $sql = "SELECT snippet FROM " . $modx->getFullTableName("site_snippets") . " WHERE " . $modx->getFullTableName("site_snippets") . ".name='" . $modx->db->escape($snippetName) . "';"; |
|
471 | + $sql = "SELECT snippet FROM ".$modx->getFullTableName("site_snippets")." WHERE ".$modx->getFullTableName("site_snippets").".name='".$modx->db->escape($snippetName)."';"; |
|
472 | 472 | $result = $modx->dbQuery($sql); |
473 | 473 | if ($modx->recordCount($result) == 1) { |
474 | 474 | $row = $modx->fetchRow($result); |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | $this->Log(" |--- DB -> Custom Modifier"); |
477 | 477 | } else { |
478 | 478 | if ($modx->recordCount($result) == 0) { // If snippet not found, look in the modifiers folder |
479 | - $filename = $modx->config['rb_base_dir'] . 'plugins/phx/modifiers/' . $modifier_cmd[$i] . '.phx.php'; |
|
479 | + $filename = $modx->config['rb_base_dir'].'plugins/phx/modifiers/'.$modifier_cmd[$i].'.phx.php'; |
|
480 | 480 | if (@file_exists($filename)) { |
481 | 481 | $file_contents = @file_get_contents($filename); |
482 | - $file_contents = str_replace('<' . '?php', '', $file_contents); |
|
483 | - $file_contents = str_replace('?' . '>', '', $file_contents); |
|
482 | + $file_contents = str_replace('<'.'?php', '', $file_contents); |
|
483 | + $file_contents = str_replace('?'.'>', '', $file_contents); |
|
484 | 484 | $file_contents = str_replace('<?', '', $file_contents); |
485 | 485 | $snippet = $modx->snippetCache[$snippetName] = $file_contents; |
486 | - $modx->snippetCache[$snippetName . 'Props'] = ''; |
|
486 | + $modx->snippetCache[$snippetName.'Props'] = ''; |
|
487 | 487 | $this->Log(" |--- File ($filename) -> Custom Modifier"); |
488 | 488 | } else { |
489 | 489 | $this->Log(" |--- PHX Error: {$modifier_cmd[$i]} could not be found"); |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | $options = $modifier_value[$i]; |
500 | 500 | $custom = eval($cm); |
501 | 501 | $msg = ob_get_contents(); |
502 | - $output = $msg . $custom; |
|
502 | + $output = $msg.$custom; |
|
503 | 503 | ob_end_clean(); |
504 | 504 | } else { |
505 | 505 | $output = ''; |
@@ -507,9 +507,9 @@ discard block |
||
507 | 507 | break; |
508 | 508 | } |
509 | 509 | if (count($condition)) { |
510 | - $this->Log(" |--- Condition = '" . $condition[count($condition) - 1] . "'"); |
|
510 | + $this->Log(" |--- Condition = '".$condition[count($condition) - 1]."'"); |
|
511 | 511 | } |
512 | - $this->Log(" |--- Output = '" . $output . "'"); |
|
512 | + $this->Log(" |--- Output = '".$output."'"); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | } |
518 | 518 | |
519 | 519 | private function runCode($code){ |
520 | - return eval("return (" . $code . ");"); |
|
520 | + return eval("return (".$code.");"); |
|
521 | 521 | } |
522 | 522 | // Event logging (debug) |
523 | 523 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $console = implode("\n", $this->console); |
530 | 530 | $this->console = array(); |
531 | 531 | |
532 | - return '<pre style="overflow: auto;">' . $console . '</pre>'; |
|
532 | + return '<pre style="overflow: auto;">'.$console.'</pre>'; |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | { |
555 | 555 | if ($this->debug) { |
556 | 556 | $this->debugLog = true; |
557 | - $this->console[] = (count($this->console) + 1 - $this->curPass) . " [" . strftime("%H:%M:%S", |
|
558 | - time()) . "] " . $this->LogClean($string); |
|
557 | + $this->console[] = (count($this->console) + 1 - $this->curPass)." [".strftime("%H:%M:%S", |
|
558 | + time())."] ".$this->LogClean($string); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
@@ -567,15 +567,15 @@ discard block |
||
567 | 567 | { |
568 | 568 | if ($this->debug) { |
569 | 569 | $this->debugLog = true; |
570 | - $this->console[] = (count($this->console) + 1 - $this->curPass) . " [" . strftime("%H:%M:%S", |
|
571 | - time()) . "] " . " |--- Returns: <div style='margin: 10px;'>" . $this->LogClean($string) . "</div>"; |
|
570 | + $this->console[] = (count($this->console) + 1 - $this->curPass)." [".strftime("%H:%M:%S", |
|
571 | + time())."] "." |--- Returns: <div style='margin: 10px;'>".$this->LogClean($string)."</div>"; |
|
572 | 572 | } |
573 | 573 | } |
574 | 574 | |
575 | 575 | // Log pass |
576 | 576 | public function LogPass() |
577 | 577 | { |
578 | - $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Pass " . $this->curPass . "</div>"; |
|
578 | + $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Pass ".$this->curPass."</div>"; |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | // Log pass |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | */ |
585 | 585 | public function LogSource($string) |
586 | 586 | { |
587 | - $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Source:</div>" . $this->LogClean($string); |
|
587 | + $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Source:</div>".$this->LogClean($string); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | if (!array_key_exists($userid, $this->cache["mo"])) { |
637 | 637 | $tbl = $modx->getFullTableName("webgroup_names"); |
638 | 638 | $tbl2 = $modx->getFullTableName("web_groups"); |
639 | - $sql = "SELECT wgn.name FROM $tbl wgn INNER JOIN $tbl2 wg ON wg.webgroup=wgn.id AND wg.webuser='" . $userid . "'"; |
|
639 | + $sql = "SELECT wgn.name FROM $tbl wgn INNER JOIN $tbl2 wg ON wg.webgroup=wgn.id AND wg.webuser='".$userid."'"; |
|
640 | 640 | $this->cache["mo"][$userid] = $grpNames = $modx->db->getColumn("name", $sql); |
641 | 641 | } else { |
642 | 642 | $grpNames = $this->cache["mo"][$userid]; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | public function ucfirst($str) |
745 | 745 | { |
746 | 746 | if (function_exists('mb_strtoupper') && function_exists('mb_substr') && function_exists('mb_strlen')) { |
747 | - return mb_strtoupper(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str)); |
|
747 | + return mb_strtoupper(mb_substr($str, 0, 1)).mb_substr($str, 1, mb_strlen($str)); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | return ucfirst($str); |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | public function lcfirst($str) |
758 | 758 | { |
759 | 759 | if (function_exists('mb_strtolower') && function_exists('mb_substr') && function_exists('mb_strlen')) { |
760 | - return mb_strtolower(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str)); |
|
760 | + return mb_strtolower(mb_substr($str, 0, 1)).mb_substr($str, 1, mb_strlen($str)); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | return lcfirst($str); |
@@ -467,7 +467,8 @@ discard block |
||
467 | 467 | $snippetName = 'phx:' . $modifier_cmd[$i]; |
468 | 468 | if (isset($modx->snippetCache[$snippetName])) { |
469 | 469 | $snippet = $modx->snippetCache[$snippetName]; |
470 | - } else { // not in cache so let's check the db |
|
470 | + } else { |
|
471 | +// not in cache so let's check the db |
|
471 | 472 | $sql = "SELECT snippet FROM " . $modx->getFullTableName("site_snippets") . " WHERE " . $modx->getFullTableName("site_snippets") . ".name='" . $modx->db->escape($snippetName) . "';"; |
472 | 473 | $result = $modx->dbQuery($sql); |
473 | 474 | if ($modx->recordCount($result) == 1) { |
@@ -475,7 +476,8 @@ discard block |
||
475 | 476 | $snippet = $modx->snippetCache[$row['name']] = $row['snippet']; |
476 | 477 | $this->Log(" |--- DB -> Custom Modifier"); |
477 | 478 | } else { |
478 | - if ($modx->recordCount($result) == 0) { // If snippet not found, look in the modifiers folder |
|
479 | + if ($modx->recordCount($result) == 0) { |
|
480 | +// If snippet not found, look in the modifiers folder |
|
479 | 481 | $filename = $modx->config['rb_base_dir'] . 'plugins/phx/modifiers/' . $modifier_cmd[$i] . '.phx.php'; |
480 | 482 | if (@file_exists($filename)) { |
481 | 483 | $file_contents = @file_get_contents($filename); |
@@ -516,7 +518,8 @@ discard block |
||
516 | 518 | return $output; |
517 | 519 | } |
518 | 520 | |
519 | - private function runCode($code){ |
|
521 | + private function runCode($code) |
|
522 | + { |
|
520 | 523 | return eval("return (" . $code . ");"); |
521 | 524 | } |
522 | 525 | // Event logging (debug) |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public static function mb_lcfirst($str, $encoding = 'UTF-8') |
15 | 15 | { |
16 | - return mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, mb_strlen($str), |
|
16 | + return mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding).mb_substr($str, 1, mb_strlen($str), |
|
17 | 17 | $encoding); |
18 | 18 | } |
19 | 19 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public static function mb_ucfirst($str, $encoding = 'UTF-8') |
27 | 27 | { |
28 | 28 | $str = mb_ereg_replace('^[\ ]+', '', $str); |
29 | - $str = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, mb_strlen($str), |
|
29 | + $str = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding).mb_substr($str, 1, mb_strlen($str), |
|
30 | 30 | $encoding); |
31 | 31 | |
32 | 32 | return $str; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | '`' => '`', |
256 | 256 | '%60' => '`' |
257 | 257 | ) |
258 | - ) { |
|
258 | + ){ |
|
259 | 259 | switch (true) { |
260 | 260 | case is_scalar($data): |
261 | 261 | $out = str_replace( |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | case 'num': |
350 | 350 | $tmp = range('0', '9'); |
351 | 351 | foreach ($tmp as $t) { |
352 | - $data[] = (string)$t; |
|
352 | + $data[] = (string) $t; |
|
353 | 353 | } |
354 | 354 | break; |
355 | 355 | case 'eng': |
@@ -388,22 +388,22 @@ discard block |
||
388 | 388 | if ($prefix == '' && $suffix == '') { |
389 | 389 | $out = $data; |
390 | 390 | } else { |
391 | - $InsertPrefix = ($prefix != '') ? ($prefix . $addPS) : ''; |
|
392 | - $InsertSuffix = ($suffix != '') ? ($addPS . $suffix) : ''; |
|
391 | + $InsertPrefix = ($prefix != '') ? ($prefix.$addPS) : ''; |
|
392 | + $InsertSuffix = ($suffix != '') ? ($addPS.$suffix) : ''; |
|
393 | 393 | foreach ($data as $key => $item) { |
394 | - $key = $InsertPrefix . $key; |
|
394 | + $key = $InsertPrefix.$key; |
|
395 | 395 | $val = null; |
396 | 396 | switch (true) { |
397 | 397 | case is_scalar($item): |
398 | 398 | $val = $item; |
399 | 399 | break; |
400 | 400 | case is_array($item): |
401 | - $val = self::renameKeyArr($item, $key . $sep, $InsertSuffix, '', $sep); |
|
401 | + $val = self::renameKeyArr($item, $key.$sep, $InsertSuffix, '', $sep); |
|
402 | 402 | $out = array_merge($out, $val); |
403 | 403 | $val = ''; |
404 | 404 | break; |
405 | 405 | } |
406 | - $out[$key . $InsertSuffix] = $val; |
|
406 | + $out[$key.$InsertSuffix] = $val; |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 |
@@ -757,15 +757,15 @@ discard block |
||
757 | 757 | self::$reserved = array_keys($reservedMap); |
758 | 758 | |
759 | 759 | // Set up regular expressions |
760 | - self::$regex_boundaries = '(' . implode('|', |
|
761 | - array_map(array(__CLASS__, 'quote_regex'), self::$boundaries)) . ')'; |
|
762 | - self::$regex_reserved = '(' . implode('|', array_map(array(__CLASS__, 'quote_regex'), self::$reserved)) . ')'; |
|
760 | + self::$regex_boundaries = '('.implode('|', |
|
761 | + array_map(array(__CLASS__, 'quote_regex'), self::$boundaries)).')'; |
|
762 | + self::$regex_reserved = '('.implode('|', array_map(array(__CLASS__, 'quote_regex'), self::$reserved)).')'; |
|
763 | 763 | self::$regex_reserved_toplevel = str_replace(' ', '\\s+', |
764 | - '(' . implode('|', array_map(array(__CLASS__, 'quote_regex'), self::$reserved_toplevel)) . ')'); |
|
764 | + '('.implode('|', array_map(array(__CLASS__, 'quote_regex'), self::$reserved_toplevel)).')'); |
|
765 | 765 | self::$regex_reserved_newline = str_replace(' ', '\\s+', |
766 | - '(' . implode('|', array_map(array(__CLASS__, 'quote_regex'), self::$reserved_newline)) . ')'); |
|
766 | + '('.implode('|', array_map(array(__CLASS__, 'quote_regex'), self::$reserved_newline)).')'); |
|
767 | 767 | |
768 | - self::$regex_function = '(' . implode('|', array_map(array(__CLASS__, 'quote_regex'), self::$functions)) . ')'; |
|
768 | + self::$regex_function = '('.implode('|', array_map(array(__CLASS__, 'quote_regex'), self::$functions)).')'; |
|
769 | 769 | |
770 | 770 | self::$init = true; |
771 | 771 | } |
@@ -829,10 +829,10 @@ discard block |
||
829 | 829 | |
830 | 830 | // If the variable name is quoted |
831 | 831 | if ($string[1] === '"' || $string[1] === '\'' || $string[1] === '`') { |
832 | - $ret[self::TOKEN_VALUE] = $string[0] . self::getQuotedString(substr($string, 1)); |
|
832 | + $ret[self::TOKEN_VALUE] = $string[0].self::getQuotedString(substr($string, 1)); |
|
833 | 833 | } // Non-quoted variable name |
834 | 834 | else { |
835 | - preg_match('/^(' . $string[0] . '[a-zA-Z0-9\._\$]+)/', $string, $matches); |
|
835 | + preg_match('/^('.$string[0].'[a-zA-Z0-9\._\$]+)/', $string, $matches); |
|
836 | 836 | if (!empty($matches)) { |
837 | 837 | $ret[self::TOKEN_VALUE] = $matches[1]; |
838 | 838 | } |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | } |
845 | 845 | |
846 | 846 | // Number (decimal, binary, or hex) |
847 | - if (preg_match('/^([0-9]+(\.[0-9]+)?|0x[0-9a-fA-F]+|0b[01]+)($|\s|"\'`|' . self::$regex_boundaries . ')/', |
|
847 | + if (preg_match('/^([0-9]+(\.[0-9]+)?|0x[0-9a-fA-F]+|0b[01]+)($|\s|"\'`|'.self::$regex_boundaries.')/', |
|
848 | 848 | $string, $matches)) { |
849 | 849 | return array( |
850 | 850 | self::TOKEN_VALUE => $matches[1], |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | } |
854 | 854 | |
855 | 855 | // Boundary Character (punctuation and symbols) |
856 | - if (preg_match('/^(' . self::$regex_boundaries . ')/', $string, $matches)) { |
|
856 | + if (preg_match('/^('.self::$regex_boundaries.')/', $string, $matches)) { |
|
857 | 857 | return array( |
858 | 858 | self::TOKEN_VALUE => $matches[1], |
859 | 859 | self::TOKEN_TYPE => self::TOKEN_TYPE_BOUNDARY |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | if (!$previous || !isset($previous[self::TOKEN_VALUE]) || $previous[self::TOKEN_VALUE] !== '.') { |
866 | 866 | $upper = strtoupper($string); |
867 | 867 | // Top Level Reserved Word |
868 | - if (preg_match('/^(' . self::$regex_reserved_toplevel . ')($|\s|' . self::$regex_boundaries . ')/', $upper, |
|
868 | + if (preg_match('/^('.self::$regex_reserved_toplevel.')($|\s|'.self::$regex_boundaries.')/', $upper, |
|
869 | 869 | $matches)) { |
870 | 870 | return array( |
871 | 871 | self::TOKEN_TYPE => self::TOKEN_TYPE_RESERVED_TOPLEVEL, |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | ); |
874 | 874 | } |
875 | 875 | // Newline Reserved Word |
876 | - if (preg_match('/^(' . self::$regex_reserved_newline . ')($|\s|' . self::$regex_boundaries . ')/', $upper, |
|
876 | + if (preg_match('/^('.self::$regex_reserved_newline.')($|\s|'.self::$regex_boundaries.')/', $upper, |
|
877 | 877 | $matches)) { |
878 | 878 | return array( |
879 | 879 | self::TOKEN_TYPE => self::TOKEN_TYPE_RESERVED_NEWLINE, |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | ); |
882 | 882 | } |
883 | 883 | // Other Reserved Word |
884 | - if (preg_match('/^(' . self::$regex_reserved . ')($|\s|' . self::$regex_boundaries . ')/', $upper, |
|
884 | + if (preg_match('/^('.self::$regex_reserved.')($|\s|'.self::$regex_boundaries.')/', $upper, |
|
885 | 885 | $matches)) { |
886 | 886 | return array( |
887 | 887 | self::TOKEN_TYPE => self::TOKEN_TYPE_RESERVED, |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | // this makes it so "count(" is considered a function, but "count" alone is not |
895 | 895 | $upper = strtoupper($string); |
896 | 896 | // function |
897 | - if (preg_match('/^(' . self::$regex_function . '[(]|\s|[)])/', $upper, $matches)) { |
|
897 | + if (preg_match('/^('.self::$regex_function.'[(]|\s|[)])/', $upper, $matches)) { |
|
898 | 898 | return array( |
899 | 899 | self::TOKEN_TYPE => self::TOKEN_TYPE_RESERVED, |
900 | 900 | self::TOKEN_VALUE => substr($string, 0, strlen($matches[1]) - 1) |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | } |
903 | 903 | |
904 | 904 | // Non reserved word |
905 | - preg_match('/^(.*?)($|\s|["\'`]|' . self::$regex_boundaries . ')/', $string, $matches); |
|
905 | + preg_match('/^(.*?)($|\s|["\'`]|'.self::$regex_boundaries.')/', $string, $matches); |
|
906 | 906 | |
907 | 907 | return array( |
908 | 908 | self::TOKEN_VALUE => $matches[1], |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | |
1064 | 1064 | // If we need a new line before the token |
1065 | 1065 | if ($newline) { |
1066 | - $return .= "\n" . str_repeat($tab, $indent_level); |
|
1066 | + $return .= "\n".str_repeat($tab, $indent_level); |
|
1067 | 1067 | $newline = false; |
1068 | 1068 | $added_newline = true; |
1069 | 1069 | } else { |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) { |
1075 | 1075 | if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) { |
1076 | 1076 | $indent = str_repeat($tab, $indent_level); |
1077 | - $return .= "\n" . $indent; |
|
1078 | - $highlighted = str_replace("\n", "\n" . $indent, $highlighted); |
|
1077 | + $return .= "\n".$indent; |
|
1078 | + $highlighted = str_replace("\n", "\n".$indent, $highlighted); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | $return .= $highlighted; |
@@ -1091,12 +1091,12 @@ discard block |
||
1091 | 1091 | if ($inline_indented) { |
1092 | 1092 | array_shift($indent_types); |
1093 | 1093 | $indent_level--; |
1094 | - $return .= "\n" . str_repeat($tab, $indent_level); |
|
1094 | + $return .= "\n".str_repeat($tab, $indent_level); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | $inline_parentheses = false; |
1098 | 1098 | |
1099 | - $return .= $highlighted . ' '; |
|
1099 | + $return .= $highlighted.' '; |
|
1100 | 1100 | continue; |
1101 | 1101 | } |
1102 | 1102 | |
@@ -1183,14 +1183,14 @@ discard block |
||
1183 | 1183 | $indent_level = 0; |
1184 | 1184 | |
1185 | 1185 | if ($highlight) { |
1186 | - $return .= "\n" . self::highlightError($token[self::TOKEN_VALUE]); |
|
1186 | + $return .= "\n".self::highlightError($token[self::TOKEN_VALUE]); |
|
1187 | 1187 | continue; |
1188 | 1188 | } |
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | // Add a newline before the closing parentheses (if not already added) |
1192 | 1192 | if (!$added_newline) { |
1193 | - $return .= "\n" . str_repeat($tab, $indent_level); |
|
1193 | + $return .= "\n".str_repeat($tab, $indent_level); |
|
1194 | 1194 | } |
1195 | 1195 | } // Top level reserved words start a new line and increase the special indent level |
1196 | 1196 | elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_TOPLEVEL) { |
@@ -1207,10 +1207,10 @@ discard block |
||
1207 | 1207 | $newline = true; |
1208 | 1208 | // Add a newline before the top level reserved word (if not already added) |
1209 | 1209 | if (!$added_newline) { |
1210 | - $return .= "\n" . str_repeat($tab, $indent_level); |
|
1210 | + $return .= "\n".str_repeat($tab, $indent_level); |
|
1211 | 1211 | } // If we already added a newline, redo the indentation since it may be different now |
1212 | 1212 | else { |
1213 | - $return = rtrim($return, $tab) . str_repeat($tab, $indent_level); |
|
1213 | + $return = rtrim($return, $tab).str_repeat($tab, $indent_level); |
|
1214 | 1214 | } |
1215 | 1215 | |
1216 | 1216 | // If the token may have extra whitespace |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_NEWLINE) { |
1241 | 1241 | // Add a newline before the reserved word (if not already added) |
1242 | 1242 | if (!$added_newline) { |
1243 | - $return .= "\n" . str_repeat($tab, $indent_level); |
|
1243 | + $return .= "\n".str_repeat($tab, $indent_level); |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | 1246 | // If the token may have extra whitespace |
@@ -1263,7 +1263,7 @@ discard block |
||
1263 | 1263 | $return = rtrim($return, ' '); |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - $return .= $highlighted . ' '; |
|
1266 | + $return .= $highlighted.' '; |
|
1267 | 1267 | |
1268 | 1268 | // If the token shouldn't have a space after it |
1269 | 1269 | if ($token[self::TOKEN_VALUE] === '(' || $token[self::TOKEN_VALUE] === '.') { |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | |
1282 | 1282 | // If there are unmatched parentheses |
1283 | 1283 | if ($highlight && array_search('block', $indent_types) !== false) { |
1284 | - $return .= "\n" . self::highlightError("WARNING: unclosed parentheses or section"); |
|
1284 | + $return .= "\n".self::highlightError("WARNING: unclosed parentheses or section"); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | // Replace tab characters with the configuration tab character |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | // If this is a query separator |
1335 | 1335 | if ($token[self::TOKEN_VALUE] === ';') { |
1336 | 1336 | if (!$empty) { |
1337 | - $queries[] = $current_query . ';'; |
|
1337 | + $queries[] = $current_query.';'; |
|
1338 | 1338 | } |
1339 | 1339 | $current_query = ''; |
1340 | 1340 | $empty = true; |
@@ -1480,9 +1480,9 @@ discard block |
||
1480 | 1480 | protected static function highlightQuote($value) |
1481 | 1481 | { |
1482 | 1482 | if (self::is_cli()) { |
1483 | - return self::$cli_quote . $value . "\x1b[0m"; |
|
1483 | + return self::$cli_quote.$value."\x1b[0m"; |
|
1484 | 1484 | } else { |
1485 | - return '<span ' . self::$quote_attributes . '>' . $value . '</span>'; |
|
1485 | + return '<span '.self::$quote_attributes.'>'.$value.'</span>'; |
|
1486 | 1486 | } |
1487 | 1487 | } |
1488 | 1488 | |
@@ -1496,9 +1496,9 @@ discard block |
||
1496 | 1496 | protected static function highlightBacktickQuote($value) |
1497 | 1497 | { |
1498 | 1498 | if (self::is_cli()) { |
1499 | - return self::$cli_backtick_quote . $value . "\x1b[0m"; |
|
1499 | + return self::$cli_backtick_quote.$value."\x1b[0m"; |
|
1500 | 1500 | } else { |
1501 | - return '<span ' . self::$backtick_quote_attributes . '>' . $value . '</span>'; |
|
1501 | + return '<span '.self::$backtick_quote_attributes.'>'.$value.'</span>'; |
|
1502 | 1502 | } |
1503 | 1503 | } |
1504 | 1504 | |
@@ -1512,9 +1512,9 @@ discard block |
||
1512 | 1512 | protected static function highlightReservedWord($value) |
1513 | 1513 | { |
1514 | 1514 | if (self::is_cli()) { |
1515 | - return self::$cli_reserved . $value . "\x1b[0m"; |
|
1515 | + return self::$cli_reserved.$value."\x1b[0m"; |
|
1516 | 1516 | } else { |
1517 | - return '<span ' . self::$reserved_attributes . '>' . $value . '</span>'; |
|
1517 | + return '<span '.self::$reserved_attributes.'>'.$value.'</span>'; |
|
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | |
@@ -1532,9 +1532,9 @@ discard block |
||
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | if (self::is_cli()) { |
1535 | - return self::$cli_boundary . $value . "\x1b[0m"; |
|
1535 | + return self::$cli_boundary.$value."\x1b[0m"; |
|
1536 | 1536 | } else { |
1537 | - return '<span ' . self::$boundary_attributes . '>' . $value . '</span>'; |
|
1537 | + return '<span '.self::$boundary_attributes.'>'.$value.'</span>'; |
|
1538 | 1538 | } |
1539 | 1539 | } |
1540 | 1540 | |
@@ -1548,9 +1548,9 @@ discard block |
||
1548 | 1548 | protected static function highlightNumber($value) |
1549 | 1549 | { |
1550 | 1550 | if (self::is_cli()) { |
1551 | - return self::$cli_number . $value . "\x1b[0m"; |
|
1551 | + return self::$cli_number.$value."\x1b[0m"; |
|
1552 | 1552 | } else { |
1553 | - return '<span ' . self::$number_attributes . '>' . $value . '</span>'; |
|
1553 | + return '<span '.self::$number_attributes.'>'.$value.'</span>'; |
|
1554 | 1554 | } |
1555 | 1555 | } |
1556 | 1556 | |
@@ -1564,9 +1564,9 @@ discard block |
||
1564 | 1564 | protected static function highlightError($value) |
1565 | 1565 | { |
1566 | 1566 | if (self::is_cli()) { |
1567 | - return self::$cli_error . $value . "\x1b[0m"; |
|
1567 | + return self::$cli_error.$value."\x1b[0m"; |
|
1568 | 1568 | } else { |
1569 | - return '<span ' . self::$error_attributes . '>' . $value . '</span>'; |
|
1569 | + return '<span '.self::$error_attributes.'>'.$value.'</span>'; |
|
1570 | 1570 | } |
1571 | 1571 | } |
1572 | 1572 | |
@@ -1580,9 +1580,9 @@ discard block |
||
1580 | 1580 | protected static function highlightComment($value) |
1581 | 1581 | { |
1582 | 1582 | if (self::is_cli()) { |
1583 | - return self::$cli_comment . $value . "\x1b[0m"; |
|
1583 | + return self::$cli_comment.$value."\x1b[0m"; |
|
1584 | 1584 | } else { |
1585 | - return '<span ' . self::$comment_attributes . '>' . $value . '</span>'; |
|
1585 | + return '<span '.self::$comment_attributes.'>'.$value.'</span>'; |
|
1586 | 1586 | } |
1587 | 1587 | } |
1588 | 1588 | |
@@ -1596,9 +1596,9 @@ discard block |
||
1596 | 1596 | protected static function highlightWord($value) |
1597 | 1597 | { |
1598 | 1598 | if (self::is_cli()) { |
1599 | - return self::$cli_word . $value . "\x1b[0m"; |
|
1599 | + return self::$cli_word.$value."\x1b[0m"; |
|
1600 | 1600 | } else { |
1601 | - return '<span ' . self::$word_attributes . '>' . $value . '</span>'; |
|
1601 | + return '<span '.self::$word_attributes.'>'.$value.'</span>'; |
|
1602 | 1602 | } |
1603 | 1603 | } |
1604 | 1604 | |
@@ -1612,9 +1612,9 @@ discard block |
||
1612 | 1612 | protected static function highlightVariable($value) |
1613 | 1613 | { |
1614 | 1614 | if (self::is_cli()) { |
1615 | - return self::$cli_variable . $value . "\x1b[0m"; |
|
1615 | + return self::$cli_variable.$value."\x1b[0m"; |
|
1616 | 1616 | } else { |
1617 | - return '<span ' . self::$variable_attributes . '>' . $value . '</span>'; |
|
1617 | + return '<span '.self::$variable_attributes.'>'.$value.'</span>'; |
|
1618 | 1618 | } |
1619 | 1619 | } |
1620 | 1620 | |
@@ -1640,14 +1640,14 @@ discard block |
||
1640 | 1640 | private static function output($string) |
1641 | 1641 | { |
1642 | 1642 | if (self::is_cli()) { |
1643 | - return $string . "\n"; |
|
1643 | + return $string."\n"; |
|
1644 | 1644 | } else { |
1645 | 1645 | $string = trim($string); |
1646 | 1646 | if (!self::$use_pre) { |
1647 | 1647 | return $string; |
1648 | 1648 | } |
1649 | 1649 | |
1650 | - return '<pre ' . self::$pre_attributes . '>' . $string . '</pre>'; |
|
1650 | + return '<pre '.self::$pre_attributes.'>'.$string.'</pre>'; |
|
1651 | 1651 | } |
1652 | 1652 | } |
1653 | 1653 |
@@ -795,7 +795,8 @@ discard block |
||
795 | 795 | if ($string[0] === '-' || $string[0] === '#') { |
796 | 796 | $last = strpos($string, "\n"); |
797 | 797 | $type = self::TOKEN_TYPE_COMMENT; |
798 | - } else { // Comment until closing comment tag |
|
798 | + } else { |
|
799 | +// Comment until closing comment tag |
|
799 | 800 | $last = strpos($string, "*/", 2) + 2; |
800 | 801 | $type = self::TOKEN_TYPE_BLOCK_COMMENT; |
801 | 802 | } |
@@ -1044,7 +1045,8 @@ discard block |
||
1044 | 1045 | // Get highlighted token if doing syntax highlighting |
1045 | 1046 | if ($highlight) { |
1046 | 1047 | $highlighted = self::highlightToken($token); |
1047 | - } else { // If returning raw text |
|
1048 | + } else { |
|
1049 | +// If returning raw text |
|
1048 | 1050 | $highlighted = $token[self::TOKEN_VALUE]; |
1049 | 1051 | } |
1050 | 1052 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php namespace SimpleTab; |
2 | 2 | |
3 | -require_once(MODX_BASE_PATH . 'assets/lib/MODxAPI/autoTable.abstract.php'); |
|
4 | -require_once(MODX_BASE_PATH . 'assets/lib/Helpers/FS.php'); |
|
5 | -require_once(MODX_BASE_PATH . 'assets/lib/Helpers/PHPThumb.php'); |
|
3 | +require_once(MODX_BASE_PATH.'assets/lib/MODxAPI/autoTable.abstract.php'); |
|
4 | +require_once(MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
|
5 | +require_once(MODX_BASE_PATH.'assets/lib/Helpers/PHPThumb.php'); |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * Class dataTable |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $rows = $this->query("SELECT MIN(`{$this->indexName}`) FROM {$table} WHERE `{$this->pkName}` IN ({$ids})"); |
60 | 60 | $index = $this->modx->db->getValue($rows); |
61 | 61 | $index = $index - 1; |
62 | - $this->query("SET @index := " . $index); |
|
62 | + $this->query("SET @index := ".$index); |
|
63 | 63 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->indexName}`>{$index} AND `{$this->rfName}`={$rid} AND `{$this->pkName}` NOT IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
64 | 64 | $out = $this->modx->db->getAffectedRows(); |
65 | 65 | |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | $cnt = count($ids); |
95 | 95 | $ids = implode(',', $ids); |
96 | 96 | if ($dir == 'top') { |
97 | - $this->query("SET @index := " . ($index - $cnt - 1)); |
|
97 | + $this->query("SET @index := ".($index - $cnt - 1)); |
|
98 | 98 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
99 | 99 | $this->query("SET @index := -1"); |
100 | 100 | } else { |
101 | 101 | $this->query("SET @index := -1"); |
102 | 102 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
103 | - $this->query("SET @index := " . ($cnt - 1)); |
|
103 | + $this->query("SET @index := ".($cnt - 1)); |
|
104 | 104 | } |
105 | 105 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` NOT IN ({$ids})) AND `{$this->rfName}` = {$rid} ORDER BY `{$this->indexName}` ASC"); |
106 | 106 | $out = $this->modx->db->getAffectedRows(); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | return; |
120 | 120 | } |
121 | 121 | if ($this->fs->checkFile($url)) { |
122 | - unlink(MODX_BASE_PATH . $url); |
|
122 | + unlink(MODX_BASE_PATH.$url); |
|
123 | 123 | } |
124 | 124 | $dir = $this->fs->takeFileDir($url); |
125 | 125 | $iterator = new \FilesystemIterator($dir); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | if ($cache) { |
130 | 130 | return; |
131 | 131 | } |
132 | - $thumbsCache = \APIhelpers::getkey($this->params,'thumbsCache',$this->thumbsCache); |
|
133 | - $thumb = $thumbsCache . $url; |
|
132 | + $thumbsCache = \APIhelpers::getkey($this->params, 'thumbsCache', $this->thumbsCache); |
|
133 | + $thumb = $thumbsCache.$url; |
|
134 | 134 | if ($this->fs->checkFile($thumb)) { |
135 | 135 | $this->deleteThumb($thumb, true); |
136 | 136 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $filename = $this->fs->takeFileName($name); |
184 | 184 | $ext = $this->fs->takeFileExt($name); |
185 | 185 | |
186 | - return $this->modx->stripAlias($filename) . '.' . $ext; |
|
186 | + return $this->modx->stripAlias($filename).'.'.$ext; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function reorder($source, $target, $point, $rid, $orderDir) |
198 | 198 | { |
199 | - $rid = (int)$rid; |
|
199 | + $rid = (int) $rid; |
|
200 | 200 | $point = strtolower($point); |
201 | 201 | $orderDir = strtolower($orderDir); |
202 | - $sourceIndex = (int)$source[$this->indexName]; |
|
203 | - $targetIndex = (int)$target[$this->indexName]; |
|
204 | - $sourceId = (int)$source[$this->pkName]; |
|
202 | + $sourceIndex = (int) $source[$this->indexName]; |
|
203 | + $targetIndex = (int) $target[$this->indexName]; |
|
204 | + $sourceId = (int) $source[$this->pkName]; |
|
205 | 205 | $table = $this->makeTable($this->table); |
206 | 206 | $rows = 0; |
207 | 207 | /* more refactoring needed */ |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | $thumb = new \Helpers\PHPThumb(); |
249 | - $inputFile = MODX_BASE_PATH . $this->fs->relativePath($url); |
|
250 | - $outputFile = MODX_BASE_PATH . $this->fs->relativePath($folder) . '/' . $this->fs->relativePath($url); |
|
249 | + $inputFile = MODX_BASE_PATH.$this->fs->relativePath($url); |
|
250 | + $outputFile = MODX_BASE_PATH.$this->fs->relativePath($folder).'/'.$this->fs->relativePath($url); |
|
251 | 251 | $dir = $this->fs->takeFileDir($outputFile); |
252 | 252 | $this->fs->makeDir($dir, $this->modx->config['new_folder_permissions']); |
253 | 253 | if ($thumb->create($inputFile, $outputFile, $options)) { |
@@ -272,6 +272,8 @@ |
||
272 | 272 | */ |
273 | 273 | public function setParams($params = array()) |
274 | 274 | { |
275 | - if (is_array($params)) $this->params = $params; |
|
275 | + if (is_array($params)) { |
|
276 | + $this->params = $params; |
|
277 | + } |
|
276 | 278 | } |
277 | 279 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $this->get_TV(); |
164 | 164 | $uTable = $this->makeTable("manager_users"); |
165 | 165 | $aTable = $this->makeTable("user_attributes"); |
166 | - $query = "SELECT `u`.`id`, `a`.`email`, `u`.`username` FROM " . $aTable . " as `a` LEFT JOIN " . $uTable . " as `u` ON `u`.`id`=`a`.`internalKey`"; |
|
166 | + $query = "SELECT `u`.`id`, `a`.`email`, `u`.`username` FROM ".$aTable." as `a` LEFT JOIN ".$uTable." as `u` ON `u`.`id`=`a`.`internalKey`"; |
|
167 | 167 | $query = $this->query($query); |
168 | 168 | $this->managerUsers = new DLCollection($modx, empty($query) ? array() : $query); |
169 | 169 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | public function getUrl() |
226 | 226 | { |
227 | 227 | $out = null; |
228 | - $id = (int)$this->getID(); |
|
228 | + $id = (int) $this->getID(); |
|
229 | 229 | if (!empty($id)) { |
230 | 230 | $out = $this->modx->makeUrl($id); |
231 | 231 | } |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | { |
279 | 279 | $out = null; |
280 | 280 | if ($this->getID() > 0) { |
281 | - include_once MODX_MANAGER_PATH . "includes/tmplvars.format.inc.php"; |
|
282 | - include_once MODX_MANAGER_PATH . "includes/tmplvars.commands.inc.php"; |
|
281 | + include_once MODX_MANAGER_PATH."includes/tmplvars.format.inc.php"; |
|
282 | + include_once MODX_MANAGER_PATH."includes/tmplvars.commands.inc.php"; |
|
283 | 283 | $tvval = $this->get($tvname); |
284 | 284 | if ($this->isTVarrayField($tvname) && is_array($tvval)) { |
285 | 285 | $tvval = implode('||', $tvval); |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | if ((is_scalar($value) || $this->isTVarrayField($key) || $this->isJsonField($key)) && is_scalar($key) && !empty($key)) { |
324 | 324 | switch ($key) { |
325 | 325 | case 'parent': |
326 | - $value = (int)$value; |
|
326 | + $value = (int) $value; |
|
327 | 327 | break; |
328 | 328 | case 'template': |
329 | 329 | $value = trim($value); |
330 | 330 | $value = $this->setTemplate($value); |
331 | 331 | break; |
332 | 332 | case 'published': |
333 | - $value = (int)((bool)$value); |
|
333 | + $value = (int) ((bool) $value); |
|
334 | 334 | if ($value) { |
335 | 335 | $this->field['publishedon'] = time() + $this->modxConfig('server_offset_time'); |
336 | 336 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | } |
351 | 351 | break; |
352 | 352 | case 'deleted': |
353 | - $value = (int)((bool)$value); |
|
353 | + $value = (int) ((bool) $value); |
|
354 | 354 | if ($value) { |
355 | 355 | $this->field['deletedon'] = time() + $this->modxConfig('server_offset_time'); |
356 | 356 | } else { |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | protected function getUser($value, $default = 0) |
393 | 393 | { |
394 | 394 | $currentAdmin = APIHelpers::getkey($_SESSION, 'mgrInternalKey', 0); |
395 | - $value = (int)$value; |
|
395 | + $value = (int) $value; |
|
396 | 396 | if (!empty($value)) { |
397 | 397 | $by = $this->findUserBy($value); |
398 | - $exists = $this->managerUsers->exists(function ($key, Helpers\Collection $val) use ($by, $value) { |
|
399 | - return ($val->containsKey($by) && $val->get($by) === (string)$value); |
|
398 | + $exists = $this->managerUsers->exists(function($key, Helpers\Collection $val) use ($by, $value) { |
|
399 | + return ($val->containsKey($by) && $val->get($by) === (string) $value); |
|
400 | 400 | }); |
401 | 401 | if (!$exists) { |
402 | 402 | $value = 0; |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | protected function findUserBy($data) |
417 | 417 | { |
418 | 418 | switch (true) { |
419 | - case (is_int($data) || ((int)$data > 0 && (string)intval($data) === $data)): |
|
419 | + case (is_int($data) || ((int) $data > 0 && (string) intval($data) === $data)): |
|
420 | 420 | $find = 'id'; |
421 | 421 | break; |
422 | 422 | case filter_var($data, FILTER_VALIDATE_EMAIL): |
@@ -466,9 +466,9 @@ discard block |
||
466 | 466 | $this->markAllEncode(); |
467 | 467 | $this->newDoc = false; |
468 | 468 | |
469 | - $result = $this->query("SELECT * from {$this->makeTable('site_content')} where `id`=" . (int)$id); |
|
469 | + $result = $this->query("SELECT * from {$this->makeTable('site_content')} where `id`=".(int) $id); |
|
470 | 470 | $this->fromArray($this->modx->db->getRow($result)); |
471 | - $result = $this->query("SELECT * from {$this->makeTable('site_tmplvar_contentvalues')} where `contentid`=" . (int)$id); |
|
471 | + $result = $this->query("SELECT * from {$this->makeTable('site_tmplvar_contentvalues')} where `contentid`=".(int) $id); |
|
472 | 472 | while ($row = $this->modx->db->getRow($result)) { |
473 | 473 | $this->field[$this->tvid[$row['tmplvarid']]] = $row['value']; |
474 | 474 | } |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | { |
496 | 496 | $parent = null; |
497 | 497 | if ($this->field['pagetitle'] == '') { |
498 | - $this->log['emptyPagetitle'] = 'Pagetitle is empty in <pre>' . print_r($this->field, true) . '</pre>'; |
|
498 | + $this->log['emptyPagetitle'] = 'Pagetitle is empty in <pre>'.print_r($this->field, true).'</pre>'; |
|
499 | 499 | |
500 | 500 | return false; |
501 | 501 | } |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | } |
549 | 549 | switch (true) { |
550 | 550 | case $key == 'parent': |
551 | - $parent = (int)$this->get($key); |
|
551 | + $parent = (int) $this->get($key); |
|
552 | 552 | $q = $this->query("SELECT count(`id`) FROM {$this->makeTable('site_content')} WHERE `id`='{$parent}'"); |
553 | 553 | if ($this->modx->db->getValue($q) != 1) { |
554 | 554 | $parent = 0; |
@@ -567,10 +567,10 @@ discard block |
||
567 | 567 | |
568 | 568 | if (!empty($this->set)) { |
569 | 569 | if ($this->newDoc) { |
570 | - $SQL = "INSERT into {$this->makeTable('site_content')} SET " . implode(', ', $this->set); |
|
570 | + $SQL = "INSERT into {$this->makeTable('site_content')} SET ".implode(', ', $this->set); |
|
571 | 571 | } else { |
572 | - $SQL = "UPDATE {$this->makeTable('site_content')} SET " . implode(', ', |
|
573 | - $this->set) . " WHERE `id` = " . $this->id; |
|
572 | + $SQL = "UPDATE {$this->makeTable('site_content')} SET ".implode(', ', |
|
573 | + $this->set)." WHERE `id` = ".$this->id; |
|
574 | 574 | } |
575 | 575 | $this->query($SQL); |
576 | 576 | |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | * @param $tvId |
635 | 635 | * @return bool |
636 | 636 | */ |
637 | - protected function belongsToTemplate($tvId) { |
|
637 | + protected function belongsToTemplate($tvId){ |
|
638 | 638 | $template = $this->get('template'); |
639 | 639 | |
640 | 640 | return isset($this->tvTpl[$template]) && in_array($tvId, $this->tvTpl[$template]); |
@@ -651,12 +651,12 @@ discard block |
||
651 | 651 | $_ids = $this->cleanIDs($ids, ',', $ignore); |
652 | 652 | if (is_array($_ids) && $_ids != array()) { |
653 | 653 | $id = $this->sanitarIn($_ids); |
654 | - $uid = (int)$this->modx->getLoginUserId(); |
|
654 | + $uid = (int) $this->modx->getLoginUserId(); |
|
655 | 655 | $deletedon = time() + $this->modxConfig('server_offset_time'); |
656 | 656 | $this->query("UPDATE {$this->makeTable('site_content')} SET `deleted`=1, `deletedby`={$uid}, `deletedon`={$deletedon} WHERE `id` IN ({$id})"); |
657 | 657 | } else { |
658 | - throw new Exception('Invalid IDs list for mark trash: <pre>' . print_r($ids, |
|
659 | - 1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>'); |
|
658 | + throw new Exception('Invalid IDs list for mark trash: <pre>'.print_r($ids, |
|
659 | + 1).'</pre> please, check ignore list: <pre>'.print_r($ignore, 1).'</pre>'); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | return $this; |
@@ -738,15 +738,15 @@ discard block |
||
738 | 738 | { |
739 | 739 | $ignore = array( |
740 | 740 | 0, //empty document |
741 | - (int)$this->modxConfig('site_start'), |
|
742 | - (int)$this->modxConfig('error_page'), |
|
743 | - (int)$this->modxConfig('unauthorized_page'), |
|
744 | - (int)$this->modxConfig('site_unavailable_page') |
|
741 | + (int) $this->modxConfig('site_start'), |
|
742 | + (int) $this->modxConfig('error_page'), |
|
743 | + (int) $this->modxConfig('unauthorized_page'), |
|
744 | + (int) $this->modxConfig('site_unavailable_page') |
|
745 | 745 | ); |
746 | 746 | $data = $this->query("SELECT DISTINCT setting_value FROM {$this->makeTable('web_user_settings')} WHERE `setting_name`='login_home' AND `setting_value`!=''"); |
747 | 747 | $data = $this->modx->db->makeArray($data); |
748 | 748 | foreach ($data as $item) { |
749 | - $ignore[] = (int)$item['setting_value']; |
|
749 | + $ignore[] = (int) $item['setting_value']; |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | return array_unique($ignore); |
@@ -769,9 +769,9 @@ discard block |
||
769 | 769 | } |
770 | 770 | if (($flag && $this->newDoc) || (!$this->newDoc && $flag && $this->id != $flag)) { |
771 | 771 | $suffix = substr($alias, -2); |
772 | - if (preg_match('/-(\d+)/', $suffix, $tmp) && isset($tmp[1]) && (int)$tmp[1] > 1) { |
|
773 | - $suffix = (int)$tmp[1] + 1; |
|
774 | - $alias = substr($alias, 0, -2) . '-' . $suffix; |
|
772 | + if (preg_match('/-(\d+)/', $suffix, $tmp) && isset($tmp[1]) && (int) $tmp[1] > 1) { |
|
773 | + $suffix = (int) $tmp[1] + 1; |
|
774 | + $alias = substr($alias, 0, -2).'-'.$suffix; |
|
775 | 775 | } else { |
776 | 776 | $alias .= '-2'; |
777 | 777 | } |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | { |
800 | 800 | $this->modx->_TVnames = array(); |
801 | 801 | if (empty($this->modx->_TVnames) || $reload) { |
802 | - $result = $this->query('SELECT `id`,`name`,`type` FROM ' . $this->makeTable('site_tmplvars')); |
|
802 | + $result = $this->query('SELECT `id`,`name`,`type` FROM '.$this->makeTable('site_tmplvars')); |
|
803 | 803 | while ($row = $this->modx->db->GetRow($result)) { |
804 | 804 | $this->modx->_TVnames[$row['name']] = array( |
805 | 805 | "id" => $row['id'], |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | */ |
828 | 828 | protected function loadTVTemplate() |
829 | 829 | { |
830 | - $q = $this->query("SELECT `tmplvarid`, `templateid` FROM " . $this->makeTable('site_tmplvar_templates')); |
|
830 | + $q = $this->query("SELECT `tmplvarid`, `templateid` FROM ".$this->makeTable('site_tmplvar_templates')); |
|
831 | 831 | $q = $this->modx->db->makeArray($q); |
832 | 832 | $this->tvTpl = array(); |
833 | 833 | foreach ($q as $item) { |
@@ -865,20 +865,20 @@ discard block |
||
865 | 865 | */ |
866 | 866 | public function setTemplate($tpl) |
867 | 867 | { |
868 | - if (!is_numeric($tpl) || $tpl != (int)$tpl) { |
|
868 | + if (!is_numeric($tpl) || $tpl != (int) $tpl) { |
|
869 | 869 | if (is_scalar($tpl)) { |
870 | - $sql = "SELECT `id` FROM {$this->makeTable('site_templates')} WHERE `templatename` = '" . $this->escape($tpl) . "'"; |
|
870 | + $sql = "SELECT `id` FROM {$this->makeTable('site_templates')} WHERE `templatename` = '".$this->escape($tpl)."'"; |
|
871 | 871 | $rs = $this->query($sql); |
872 | 872 | if (!$rs || $this->modx->db->getRecordCount($rs) <= 0) { |
873 | 873 | throw new Exception("Template {$tpl} is not exists"); |
874 | 874 | } |
875 | 875 | $tpl = $this->modx->db->getValue($rs); |
876 | 876 | } else { |
877 | - throw new Exception("Invalid template name: " . print_r($tpl, 1)); |
|
877 | + throw new Exception("Invalid template name: ".print_r($tpl, 1)); |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
881 | - return (int)$tpl; |
|
881 | + return (int) $tpl; |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | if ($this->isEncodableField($field)) { |
1003 | 1003 | $data = $this->get($field); |
1004 | 1004 | if ($this->isTVarrayField($field)) { |
1005 | - $out = is_array($data) ? implode('||', $data) : (string)$data; |
|
1005 | + $out = is_array($data) ? implode('||', $data) : (string) $data; |
|
1006 | 1006 | } else { |
1007 | 1007 | $out = json_encode($data); |
1008 | 1008 | } |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | /** |
1057 | 1057 | * @param int $docId |
1058 | 1058 | */ |
1059 | - public function getDocumentGroups($docId = 0) { |
|
1059 | + public function getDocumentGroups($docId = 0){ |
|
1060 | 1060 | $out = array(); |
1061 | 1061 | $doc = $this->switchObject($docId); |
1062 | 1062 | if (null !== $doc->getID()) { |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | $docgroup_names = $this->makeTable('documentgroup_names'); |
1065 | 1065 | |
1066 | 1066 | $rs = $this->query("SELECT `dg`.`document_group`, `dgn`.`name` FROM {$doc_groups} as `dg` INNER JOIN {$docgroup_names} as `dgn` ON `dgn`.`id`=`dg`.`document_group` |
1067 | - WHERE `dg`.`document` = " . $doc->getID()); |
|
1067 | + WHERE `dg`.`document` = ".$doc->getID()); |
|
1068 | 1068 | while ($row = $this->modx->db->getRow($rs)) { |
1069 | 1069 | $out[$row['document_group']] = $row['name']; |
1070 | 1070 | } |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $value = (int)$value; |
396 | 396 | if (!empty($value)) { |
397 | 397 | $by = $this->findUserBy($value); |
398 | - $exists = $this->managerUsers->exists(function ($key, Helpers\Collection $val) use ($by, $value) { |
|
398 | + $exists = $this->managerUsers->exists(function ($key, Helpers\Collection $val) use ($by, $value){ |
|
399 | 399 | return ($val->containsKey($by) && $val->get($by) === (string)$value); |
400 | 400 | }); |
401 | 401 | if (!$exists) { |
@@ -614,7 +614,9 @@ discard block |
||
614 | 614 | $this->newDoc = false; |
615 | 615 | } |
616 | 616 | |
617 | - if (!empty($this->groupIds)) $this->setDocumentGroups($this->id, $this->groupIds); |
|
617 | + if (!empty($this->groupIds)) { |
|
618 | + $this->setDocumentGroups($this->id, $this->groupIds); |
|
619 | + } |
|
618 | 620 | $this->invokeEvent('OnDocFormSave', array( |
619 | 621 | 'mode' => $this->mode, |
620 | 622 | 'id' => isset($this->id) ? $this->id : '', |
@@ -634,7 +636,8 @@ discard block |
||
634 | 636 | * @param $tvId |
635 | 637 | * @return bool |
636 | 638 | */ |
637 | - protected function belongsToTemplate($tvId) { |
|
639 | + protected function belongsToTemplate($tvId) |
|
640 | + { |
|
638 | 641 | $template = $this->get('template'); |
639 | 642 | |
640 | 643 | return isset($this->tvTpl[$template]) && in_array($tvId, $this->tvTpl[$template]); |
@@ -816,7 +819,9 @@ discard block |
||
816 | 819 | $arrayTVs[] = $name; |
817 | 820 | } |
818 | 821 | } |
819 | - if (empty($this->tvaFields)) $this->tvaFields = $arrayTVs; |
|
822 | + if (empty($this->tvaFields)) { |
|
823 | + $this->tvaFields = $arrayTVs; |
|
824 | + } |
|
820 | 825 | $this->loadTVTemplate()->loadTVDefault(array_values($this->tv)); |
821 | 826 | |
822 | 827 | return $this; |
@@ -1056,7 +1061,8 @@ discard block |
||
1056 | 1061 | /** |
1057 | 1062 | * @param int $docId |
1058 | 1063 | */ |
1059 | - public function getDocumentGroups($docId = 0) { |
|
1064 | + public function getDocumentGroups($docId = 0) |
|
1065 | + { |
|
1060 | 1066 | $out = array(); |
1061 | 1067 | $doc = $this->switchObject($docId); |
1062 | 1068 | if (null !== $doc->getID()) { |
@@ -1082,7 +1088,9 @@ discard block |
||
1082 | 1088 | */ |
1083 | 1089 | public function setDocumentGroups($docId = 0, $groupIds = array()) |
1084 | 1090 | { |
1085 | - if (!is_array($groupIds)) return $this; |
|
1091 | + if (!is_array($groupIds)) { |
|
1092 | + return $this; |
|
1093 | + } |
|
1086 | 1094 | if ($this->newDoc && $docId == 0) { |
1087 | 1095 | $this->groupIds = $groupIds; |
1088 | 1096 | } else { |