@@ -212,7 +212,6 @@ discard block |
||
212 | 212 | |
213 | 213 | /** |
214 | 214 | * @param array $services |
215 | - * @param array $parameters |
|
216 | 215 | */ |
217 | 216 | public function __construct(array $services = array()) |
218 | 217 | { |
@@ -282,6 +281,9 @@ discard block |
||
282 | 281 | return $service; |
283 | 282 | } |
284 | 283 | |
284 | + /** |
|
285 | + * @param string $name |
|
286 | + */ |
|
285 | 287 | private function checkServiceAlias($name){ |
286 | 288 | foreach ($this->providerAliases as $alias => $interface) { |
287 | 289 | if($name === $interface) { |
@@ -319,7 +321,7 @@ discard block |
||
319 | 321 | * |
320 | 322 | * @param object $service The service. |
321 | 323 | * @param string $name The service name. |
322 | - * @param array $callDefinitions The service calls definition. |
|
324 | + * @param boolean $callDefinitions The service calls definition. |
|
323 | 325 | * |
324 | 326 | * @throws Exceptions\ContainerException On failure. |
325 | 327 | */ |
@@ -561,7 +563,7 @@ discard block |
||
561 | 563 | * @param int $count_attempts |
562 | 564 | * @param string $type $type |
563 | 565 | * @param string $responseCode |
564 | - * @return bool|null |
|
566 | + * @return false|null |
|
565 | 567 | * @global string $base_url |
566 | 568 | * @global string $site_url |
567 | 569 | */ |
@@ -1262,7 +1264,7 @@ discard block |
||
1262 | 1264 | } |
1263 | 1265 | |
1264 | 1266 | /** |
1265 | - * @param $contents |
|
1267 | + * @param string $contents |
|
1266 | 1268 | * @return mixed |
1267 | 1269 | */ |
1268 | 1270 | public function RecoveryEscapedTags($contents) |
@@ -1286,7 +1288,7 @@ discard block |
||
1286 | 1288 | } |
1287 | 1289 | |
1288 | 1290 | /** |
1289 | - * @param $tstart |
|
1291 | + * @param double $tstart |
|
1290 | 1292 | * @return array |
1291 | 1293 | */ |
1292 | 1294 | public function getTimerStats($tstart) |
@@ -2052,7 +2054,7 @@ discard block |
||
2052 | 2054 | |
2053 | 2055 | /** |
2054 | 2056 | * Remove Comment-Tags from output like <!--@- Comment -@--> |
2055 | - * @param $content |
|
2057 | + * @param string $content |
|
2056 | 2058 | * @param string $left |
2057 | 2059 | * @param string $right |
2058 | 2060 | * @return mixed |
@@ -2228,7 +2230,7 @@ discard block |
||
2228 | 2230 | /** |
2229 | 2231 | * Run snippets as per the tags in $documentSource and replace the tags with the returned values. |
2230 | 2232 | * |
2231 | - * @param $content |
|
2233 | + * @param string $content |
|
2232 | 2234 | * @return string |
2233 | 2235 | * @internal param string $documentSource |
2234 | 2236 | */ |
@@ -3263,7 +3265,7 @@ discard block |
||
3263 | 3265 | |
3264 | 3266 | /** |
3265 | 3267 | * @param $templateID |
3266 | - * @return mixed |
|
3268 | + * @return string |
|
3267 | 3269 | */ |
3268 | 3270 | public function _getTemplateCodeFromDB($templateID) |
3269 | 3271 | { |
@@ -3306,7 +3308,7 @@ discard block |
||
3306 | 3308 | /** |
3307 | 3309 | * @param $id |
3308 | 3310 | * @param int $top |
3309 | - * @return mixed |
|
3311 | + * @return string |
|
3310 | 3312 | */ |
3311 | 3313 | public function getUltimateParentId($id, $top = 0) |
3312 | 3314 | { |
@@ -3646,7 +3648,7 @@ discard block |
||
3646 | 3648 | * |
3647 | 3649 | * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role |
3648 | 3650 | * @param int $id Element- / Resource-id |
3649 | - * @return bool |
|
3651 | + * @return false|null |
|
3650 | 3652 | */ |
3651 | 3653 | public function lockElement($type, $id) |
3652 | 3654 | { |
@@ -3668,7 +3670,7 @@ discard block |
||
3668 | 3670 | * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role |
3669 | 3671 | * @param int $id Element- / Resource-id |
3670 | 3672 | * @param bool $includeAllUsers true = Deletes not only own user-locks |
3671 | - * @return bool |
|
3673 | + * @return false|null |
|
3672 | 3674 | */ |
3673 | 3675 | public function unlockElement($type, $id, $includeAllUsers = false) |
3674 | 3676 | { |
@@ -4181,7 +4183,7 @@ discard block |
||
4181 | 4183 | * Default: 1 |
4182 | 4184 | * @param string $fields List of fields |
4183 | 4185 | * Default: id, pagetitle, description, alias |
4184 | - * @return boolean|array |
|
4186 | + * @return string |
|
4185 | 4187 | */ |
4186 | 4188 | public function getPageInfo($pageid = -1, $active = 1, $fields = 'id, pagetitle, description, alias') |
4187 | 4189 | { |
@@ -4273,7 +4275,7 @@ discard block |
||
4273 | 4275 | * |
4274 | 4276 | * @param string $type |
4275 | 4277 | * @param bool $report |
4276 | - * @return bool |
|
4278 | + * @return boolean|null |
|
4277 | 4279 | */ |
4278 | 4280 | public function clearCache($type = '', $report = false) |
4279 | 4281 | { |
@@ -4639,7 +4641,7 @@ discard block |
||
4639 | 4641 | * - Placeholders prefix. Default: '{'. |
4640 | 4642 | * @param string $suffix {string} |
4641 | 4643 | * - Placeholders suffix. Default: '}'. |
4642 | - * @return bool|mixed|string {string; false} - Parsed chunk or false if $chunkArr is not array. |
|
4644 | + * @return false|string {string; false} - Parsed chunk or false if $chunkArr is not array. |
|
4643 | 4645 | * - Parsed chunk or false if $chunkArr is not array. |
4644 | 4646 | */ |
4645 | 4647 | public function parseChunk($chunkName, $chunkArr, $prefix = '{', $suffix = '}') |
@@ -5611,7 +5613,7 @@ discard block |
||
5611 | 5613 | * Remove event listener - only for use within the current execution cycle |
5612 | 5614 | * |
5613 | 5615 | * @param string $evtName |
5614 | - * @return boolean |
|
5616 | + * @return false|null |
|
5615 | 5617 | */ |
5616 | 5618 | public function removeEventListener($evtName) |
5617 | 5619 | { |
@@ -5635,7 +5637,7 @@ discard block |
||
5635 | 5637 | * |
5636 | 5638 | * @param string $evtName |
5637 | 5639 | * @param array $extParams Parameters available to plugins. Each array key will be the PHP variable name, and the array value will be the variable value. |
5638 | - * @return boolean|array |
|
5640 | + * @return false|null |
|
5639 | 5641 | */ |
5640 | 5642 | public function invokeEvent($evtName, $extParams = array()) |
5641 | 5643 | { |
@@ -6280,7 +6282,7 @@ discard block |
||
6280 | 6282 | |
6281 | 6283 | /** |
6282 | 6284 | * @param string $str |
6283 | - * @return bool|mixed|string |
|
6285 | + * @return string |
|
6284 | 6286 | */ |
6285 | 6287 | public function atBindFileContent($str = '') |
6286 | 6288 | { |
@@ -6331,8 +6333,8 @@ discard block |
||
6331 | 6333 | } |
6332 | 6334 | |
6333 | 6335 | /** |
6334 | - * @param $str |
|
6335 | - * @return bool|string |
|
6336 | + * @param string $str |
|
6337 | + * @return false|string |
|
6336 | 6338 | */ |
6337 | 6339 | public function getExtFromFilename($str) |
6338 | 6340 | { |
@@ -6360,7 +6362,7 @@ discard block |
||
6360 | 6362 | * @param string $text Error message |
6361 | 6363 | * @param string $file File where the error was detected |
6362 | 6364 | * @param string $line Line number within $file |
6363 | - * @return boolean |
|
6365 | + * @return boolean|null |
|
6364 | 6366 | */ |
6365 | 6367 | public function phpError($nr, $text, $file, $line) |
6366 | 6368 | { |
@@ -6412,7 +6414,7 @@ discard block |
||
6412 | 6414 | * @param string $text |
6413 | 6415 | * @param string $line |
6414 | 6416 | * @param string $output |
6415 | - * @return bool |
|
6417 | + * @return null|boolean |
|
6416 | 6418 | */ |
6417 | 6419 | public function messageQuit($msg = 'unspecified error', $query = '', $is_error = true, $nr = '', $file = '', $source = '', $text = '', $line = '', $output = '') |
6418 | 6420 | { |
@@ -6827,7 +6829,7 @@ discard block |
||
6827 | 6829 | |
6828 | 6830 | /** |
6829 | 6831 | * @param string $str |
6830 | - * @return bool|mixed|string |
|
6832 | + * @return string |
|
6831 | 6833 | */ |
6832 | 6834 | public function atBindInclude($str = '') |
6833 | 6835 | { |
@@ -6878,7 +6880,7 @@ discard block |
||
6878 | 6880 | * @param $str |
6879 | 6881 | * @param int $flags |
6880 | 6882 | * @param string $encode |
6881 | - * @return mixed |
|
6883 | + * @return null|string |
|
6882 | 6884 | */ |
6883 | 6885 | public function htmlspecialchars($str, $flags = ENT_COMPAT, $encode = '') |
6884 | 6886 | { |
@@ -6886,7 +6888,7 @@ discard block |
||
6886 | 6888 | } |
6887 | 6889 | |
6888 | 6890 | /** |
6889 | - * @param $string |
|
6891 | + * @param string $string |
|
6890 | 6892 | * @param bool $returnData |
6891 | 6893 | * @return bool|mixed |
6892 | 6894 | */ |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | if (empty($services)) { |
221 | 221 | $services = include EVO_SERVICES_FILE; |
222 | 222 | } |
223 | - $this->services = $services; |
|
223 | + $this->services = $services; |
|
224 | 224 | |
225 | 225 | $this->initialize(); |
226 | 226 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | private function checkServiceAlias($name){ |
286 | 286 | foreach ($this->providerAliases as $alias => $interface) { |
287 | - if($name === $interface) { |
|
287 | + if ($name === $interface) { |
|
288 | 288 | return $alias; |
289 | 289 | } |
290 | 290 | } |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | $info = debug_backtrace(); |
481 | 481 | $m[] = $msg; |
482 | 482 | if (!empty($this->currentSnippet)) { |
483 | - $m[] = 'Snippet - ' . $this->currentSnippet; |
|
483 | + $m[] = 'Snippet - '.$this->currentSnippet; |
|
484 | 484 | } elseif (!empty($this->event->activePlugin)) { |
485 | - $m[] = 'Plugin - ' . $this->event->activePlugin; |
|
485 | + $m[] = 'Plugin - '.$this->event->activePlugin; |
|
486 | 486 | } |
487 | 487 | $m[] = $this->decoded_request_uri; |
488 | - $m[] = str_replace('\\', '/', $info[0]['file']) . '(line:' . $info[0]['line'] . ')'; |
|
488 | + $m[] = str_replace('\\', '/', $info[0]['file']).'(line:'.$info[0]['line'].')'; |
|
489 | 489 | $msg = implode('<br />', $m); |
490 | 490 | $this->logEvent(0, $error_type, $msg, $title); |
491 | 491 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | { |
503 | 503 | $flag = false; |
504 | 504 | if (is_scalar($connector) && !empty($connector) && isset($this->{$connector}) && $this->{$connector} instanceof Interfaces\DatabaseInterface) { |
505 | - $flag = (bool)$this->{$connector}->conn; |
|
505 | + $flag = (bool) $this->{$connector}->conn; |
|
506 | 506 | } |
507 | 507 | return $flag; |
508 | 508 | } |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | } |
534 | 534 | if (!$out && $flag) { |
535 | 535 | $extname = trim(str_replace(array('..', '/', '\\'), '', strtolower($extname))); |
536 | - $filename = MODX_MANAGER_PATH . "includes/extenders/ex_{$extname}.inc.php"; |
|
536 | + $filename = MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php"; |
|
537 | 537 | $out = is_file($filename) ? include $filename : false; |
538 | 538 | } |
539 | 539 | if ($out && !in_array($extname, $this->extensions)) { |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | public function getMicroTime() |
552 | 552 | { |
553 | 553 | list ($usec, $sec) = explode(' ', microtime()); |
554 | - return ((float)$usec + (float)$sec); |
|
554 | + return ((float) $usec + (float) $sec); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | // append the redirect count string to the url |
576 | 576 | $currentNumberOfRedirects = isset ($_REQUEST['err']) ? $_REQUEST['err'] : 0; |
577 | 577 | if ($currentNumberOfRedirects > 3) { |
578 | - $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>' . $url . '</i></p>'); |
|
578 | + $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>'.$url.'</i></p>'); |
|
579 | 579 | } else { |
580 | 580 | $currentNumberOfRedirects += 1; |
581 | 581 | if (strpos($url, "?") > 0) { |
@@ -586,9 +586,9 @@ discard block |
||
586 | 586 | } |
587 | 587 | } |
588 | 588 | if ($type == 'REDIRECT_REFRESH') { |
589 | - $header = 'Refresh: 0;URL=' . $url; |
|
589 | + $header = 'Refresh: 0;URL='.$url; |
|
590 | 590 | } elseif ($type == 'REDIRECT_META') { |
591 | - $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $url . '" />'; |
|
591 | + $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL='.$url.'" />'; |
|
592 | 592 | echo $header; |
593 | 593 | exit; |
594 | 594 | } elseif ($type == 'REDIRECT_HEADER' || empty ($type)) { |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | global $base_url, $site_url; |
597 | 597 | if (substr($url, 0, strlen($base_url)) == $base_url) { |
598 | 598 | // append $site_url to make it work with Location: |
599 | - $url = $site_url . substr($url, strlen($base_url)); |
|
599 | + $url = $site_url.substr($url, strlen($base_url)); |
|
600 | 600 | } |
601 | 601 | if (strpos($url, "\n") === false) { |
602 | - $header = 'Location: ' . $url; |
|
602 | + $header = 'Location: '.$url; |
|
603 | 603 | } else { |
604 | 604 | $this->messageQuit('No newline allowed in redirect url.'); |
605 | 605 | } |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | header($responseCode); |
609 | 609 | } |
610 | 610 | |
611 | - if(!empty($header)) { |
|
611 | + if (!empty($header)) { |
|
612 | 612 | header($header); |
613 | 613 | } |
614 | 614 | |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | |
714 | 714 | private function recoverySiteCache() |
715 | 715 | { |
716 | - $site_cache_dir = MODX_BASE_PATH . $this->getCacheFolder(); |
|
717 | - $site_cache_path = $site_cache_dir . 'siteCache.idx.php'; |
|
716 | + $site_cache_dir = MODX_BASE_PATH.$this->getCacheFolder(); |
|
717 | + $site_cache_path = $site_cache_dir.'siteCache.idx.php'; |
|
718 | 718 | |
719 | 719 | if (is_file($site_cache_path)) { |
720 | 720 | include($site_cache_path); |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | $this->invokeEvent("OnBeforeManagerPageInit"); |
775 | 775 | } |
776 | 776 | |
777 | - if (isset ($_SESSION[$usrType . 'UsrConfigSet'])) { |
|
778 | - $usrSettings = &$_SESSION[$usrType . 'UsrConfigSet']; |
|
777 | + if (isset ($_SESSION[$usrType.'UsrConfigSet'])) { |
|
778 | + $usrSettings = &$_SESSION[$usrType.'UsrConfigSet']; |
|
779 | 779 | } else { |
780 | 780 | if ($usrType == 'web') { |
781 | 781 | $from = $tbl_web_user_settings; |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | $usrSettings[$row['setting_name']] = $row['setting_value']; |
796 | 796 | } |
797 | 797 | if (isset ($usrType)) { |
798 | - $_SESSION[$usrType . 'UsrConfigSet'] = $usrSettings; |
|
798 | + $_SESSION[$usrType.'UsrConfigSet'] = $usrSettings; |
|
799 | 799 | } // store user settings in session |
800 | 800 | } |
801 | 801 | } |
@@ -940,10 +940,10 @@ discard block |
||
940 | 940 | $suf = $this->config['friendly_url_suffix']; |
941 | 941 | $pre = preg_quote($pre, '/'); |
942 | 942 | $suf = preg_quote($suf, '/'); |
943 | - if ($pre && preg_match('@^' . $pre . '(.*)$@', $q, $_)) { |
|
943 | + if ($pre && preg_match('@^'.$pre.'(.*)$@', $q, $_)) { |
|
944 | 944 | $q = $_[1]; |
945 | 945 | } |
946 | - if ($suf && preg_match('@(.*)' . $suf . '$@', $q, $_)) { |
|
946 | + if ($suf && preg_match('@(.*)'.$suf.'$@', $q, $_)) { |
|
947 | 947 | $q = $_[1]; |
948 | 948 | } |
949 | 949 | |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */ |
966 | 966 | /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */ |
967 | 967 | if ($this->config['use_alias_path'] == 1) { |
968 | - if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
|
968 | + if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir.'/'.$q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
|
969 | 969 | $this->documentMethod = 'id'; |
970 | 970 | return $q; |
971 | 971 | } else { /* not a valid id in terms of virtualDir, treat as alias */ |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | */ |
1000 | 1000 | public function getHashFile($key) |
1001 | 1001 | { |
1002 | - return $this->getCacheFolder() . "docid_" . $key . ".pageCache.php"; |
|
1002 | + return $this->getCacheFolder()."docid_".$key.".pageCache.php"; |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | /** |
@@ -1010,9 +1010,9 @@ discard block |
||
1010 | 1010 | $hash = $id; |
1011 | 1011 | $tmp = null; |
1012 | 1012 | $params = array(); |
1013 | - if(!empty($this->systemCacheKey)){ |
|
1013 | + if (!empty($this->systemCacheKey)) { |
|
1014 | 1014 | $hash = $this->systemCacheKey; |
1015 | - }else { |
|
1015 | + } else { |
|
1016 | 1016 | if (!empty($_GET)) { |
1017 | 1017 | // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID. |
1018 | 1018 | $params = $_GET; |
@@ -1020,8 +1020,8 @@ discard block |
||
1020 | 1020 | $hash .= '_'.md5(http_build_query($params)); |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | - $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params)); |
|
1024 | - if (is_array($evtOut) && count($evtOut) > 0){ |
|
1023 | + $evtOut = $this->invokeEvent("OnMakePageCacheKey", array("hash" => $hash, "id" => $id, 'params' => $params)); |
|
1024 | + if (is_array($evtOut) && count($evtOut) > 0) { |
|
1025 | 1025 | $tmp = array_pop($evtOut); |
1026 | 1026 | } |
1027 | 1027 | return empty($tmp) ? $hash : $tmp; |
@@ -1163,12 +1163,12 @@ discard block |
||
1163 | 1163 | if ($js = $this->getRegisteredClientStartupScripts()) { |
1164 | 1164 | // change to just before closing </head> |
1165 | 1165 | // $this->documentContent = preg_replace("/(<head[^>]*>)/i", "\\1\n".$js, $this->documentContent); |
1166 | - $this->documentOutput = preg_replace("/(<\/head>)/i", $js . "\n\\1", $this->documentOutput); |
|
1166 | + $this->documentOutput = preg_replace("/(<\/head>)/i", $js."\n\\1", $this->documentOutput); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | // Insert jscripts & html block into template - template must have a </body> tag |
1170 | 1170 | if ($js = $this->getRegisteredClientScripts()) { |
1171 | - $this->documentOutput = preg_replace("/(<\/body>)/i", $js . "\n\\1", $this->documentOutput); |
|
1171 | + $this->documentOutput = preg_replace("/(<\/body>)/i", $js."\n\\1", $this->documentOutput); |
|
1172 | 1172 | } |
1173 | 1173 | // End fix by sirlancelot |
1174 | 1174 | |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | // send out content-type and content-disposition headers |
1180 | 1180 | if (IN_PARSER_MODE == "true") { |
1181 | 1181 | $type = !empty ($this->contentTypes[$this->documentIdentifier]) ? $this->contentTypes[$this->documentIdentifier] : "text/html"; |
1182 | - header('Content-Type: ' . $type . '; charset=' . $this->config['modx_charset']); |
|
1182 | + header('Content-Type: '.$type.'; charset='.$this->config['modx_charset']); |
|
1183 | 1183 | // if (($this->documentIdentifier == $this->config['error_page']) || $redirect_error) |
1184 | 1184 | // header('HTTP/1.0 404 Not Found'); |
1185 | 1185 | if (!$this->checkPreview() && $this->documentObject['content_dispo'] == 1) { |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | $name = preg_replace('|-+|', '-', $name); |
1198 | 1198 | $name = trim($name, '-'); |
1199 | 1199 | } |
1200 | - $header = 'Content-Disposition: attachment; filename=' . $name; |
|
1200 | + $header = 'Content-Disposition: attachment; filename='.$name; |
|
1201 | 1201 | header($header); |
1202 | 1202 | } |
1203 | 1203 | } |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | |
1206 | 1206 | $stats = $this->getTimerStats($this->tstart); |
1207 | 1207 | |
1208 | - $out =& $this->documentOutput; |
|
1208 | + $out = & $this->documentOutput; |
|
1209 | 1209 | $out = str_replace("[^q^]", $stats['queries'], $out); |
1210 | 1210 | $out = str_replace("[^qt^]", $stats['queryTime'], $out); |
1211 | 1211 | $out = str_replace("[^p^]", $stats['phpTime'], $out); |
@@ -1244,17 +1244,17 @@ discard block |
||
1244 | 1244 | $sc .= sprintf("%s. %s (%s)<br>", $s, $sname, sprintf("%2.2f ms", $t)); // currentSnippet |
1245 | 1245 | $tt += $t; |
1246 | 1246 | } |
1247 | - echo "<fieldset><legend><b>Snippets</b> (" . count($this->snippetsTime) . " / " . sprintf("%2.2f ms", $tt) . ")</legend>{$sc}</fieldset><br />"; |
|
1247 | + echo "<fieldset><legend><b>Snippets</b> (".count($this->snippetsTime)." / ".sprintf("%2.2f ms", $tt).")</legend>{$sc}</fieldset><br />"; |
|
1248 | 1248 | echo $this->snippetsCode; |
1249 | 1249 | } |
1250 | 1250 | if ($this->dumpPlugins) { |
1251 | 1251 | $ps = ""; |
1252 | 1252 | $tt = 0; |
1253 | 1253 | foreach ($this->pluginsTime as $s => $t) { |
1254 | - $ps .= "$s (" . sprintf("%2.2f ms", $t * 1000) . ")<br>"; |
|
1254 | + $ps .= "$s (".sprintf("%2.2f ms", $t * 1000).")<br>"; |
|
1255 | 1255 | $tt += $t; |
1256 | 1256 | } |
1257 | - echo "<fieldset><legend><b>Plugins</b> (" . count($this->pluginsTime) . " / " . sprintf("%2.2f ms", $tt * 1000) . ")</legend>{$ps}</fieldset><br />"; |
|
1257 | + echo "<fieldset><legend><b>Plugins</b> (".count($this->pluginsTime)." / ".sprintf("%2.2f ms", $tt * 1000).")</legend>{$ps}</fieldset><br />"; |
|
1258 | 1258 | echo $this->pluginsCode; |
1259 | 1259 | } |
1260 | 1260 | |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | $srcTags = explode(',', $tags); |
1281 | 1281 | $repTags = array(); |
1282 | 1282 | foreach ($srcTags as $tag) { |
1283 | - $repTags[] = '\\' . $tag[0] . '\\' . $tag[1]; |
|
1283 | + $repTags[] = '\\'.$tag[0].'\\'.$tag[1]; |
|
1284 | 1284 | } |
1285 | 1285 | return array($srcTags, $repTags); |
1286 | 1286 | } |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | $stats['phpTime'] = sprintf("%2.4f s", $stats['phpTime']); |
1303 | 1303 | $stats['source'] = $this->documentGenerated == 1 ? "database" : "cache"; |
1304 | 1304 | $stats['queries'] = isset ($this->executedQueries) ? $this->executedQueries : 0; |
1305 | - $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024) . " mb"; |
|
1305 | + $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024)." mb"; |
|
1306 | 1306 | |
1307 | 1307 | return $stats; |
1308 | 1308 | } |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | { |
1336 | 1336 | $cacheRefreshTime = 0; |
1337 | 1337 | $recent_update = 0; |
1338 | - @include(MODX_BASE_PATH . $this->getCacheFolder() . 'sitePublishing.idx.php'); |
|
1338 | + @include(MODX_BASE_PATH.$this->getCacheFolder().'sitePublishing.idx.php'); |
|
1339 | 1339 | $this->recentUpdate = $recent_update; |
1340 | 1340 | |
1341 | 1341 | $timeNow = $_SERVER['REQUEST_TIME'] + $this->config['server_offset_time']; |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | // now, check for documents that need publishing |
1347 | 1347 | $field = array('published' => 1, 'publishedon' => $timeNow); |
1348 | 1348 | $where = "pub_date <= {$timeNow} AND pub_date!=0 AND published=0"; |
1349 | - $result_pub = $this->getDatabase()->select( 'id', '[+prefix+]site_content', $where); |
|
1349 | + $result_pub = $this->getDatabase()->select('id', '[+prefix+]site_content', $where); |
|
1350 | 1350 | $this->getDatabase()->update($field, '[+prefix+]site_content', $where); |
1351 | 1351 | if ($this->getDatabase()->getRecordCount($result_pub) >= 1) { //Event unPublished doc |
1352 | 1352 | while ($row_pub = $this->getDatabase()->getRow($result_pub)) { |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | // now, check for documents that need un-publishing |
1360 | 1360 | $field = array('published' => 0, 'publishedon' => 0); |
1361 | 1361 | $where = "unpub_date <= {$timeNow} AND unpub_date!=0 AND published=1"; |
1362 | - $result_unpub = $this->getDatabase()->select( 'id', '[+prefix+]site_content', $where); |
|
1362 | + $result_unpub = $this->getDatabase()->select('id', '[+prefix+]site_content', $where); |
|
1363 | 1363 | $this->getDatabase()->update($field, '[+prefix+]site_content', $where); |
1364 | 1364 | if ($this->getDatabase()->getRecordCount($result_unpub) >= 1) { //Event unPublished doc |
1365 | 1365 | while ($row_unpub = $this->getDatabase()->getRow($result_unpub)) { |
@@ -1405,8 +1405,8 @@ discard block |
||
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | $docObjSerial = serialize($this->documentObject); |
1408 | - $cacheContent = $docObjSerial . "<!--__MODxCacheSpliter__-->" . $this->documentContent; |
|
1409 | - $page_cache_path = MODX_BASE_PATH . $this->getHashFile($this->cacheKey); |
|
1408 | + $cacheContent = $docObjSerial."<!--__MODxCacheSpliter__-->".$this->documentContent; |
|
1409 | + $page_cache_path = MODX_BASE_PATH.$this->getHashFile($this->cacheKey); |
|
1410 | 1410 | file_put_contents($page_cache_path, "<?php die('Unauthorized access.'); ?>$cacheContent"); |
1411 | 1411 | } |
1412 | 1412 | } |
@@ -1448,16 +1448,16 @@ discard block |
||
1448 | 1448 | return array(); |
1449 | 1449 | } |
1450 | 1450 | $spacer = md5('<<<EVO>>>'); |
1451 | - if($left==='{{' && strpos($content,';}}')!==false) $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
1452 | - if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
1453 | - if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
1454 | - if($left==='[[' && strpos($content,']]]')!==false) $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
1451 | + if ($left === '{{' && strpos($content, ';}}') !== false) $content = str_replace(';}}', sprintf(';}%s}', $spacer), $content); |
|
1452 | + if ($left === '{{' && strpos($content, '{{}}') !== false) $content = str_replace('{{}}', sprintf('{%$1s{}%$1s}', $spacer), $content); |
|
1453 | + if ($left === '[[' && strpos($content, ']]]]') !== false) $content = str_replace(']]]]', sprintf(']]%s]]', $spacer), $content); |
|
1454 | + if ($left === '[[' && strpos($content, ']]]') !== false) $content = str_replace(']]]', sprintf(']%s]]', $spacer), $content); |
|
1455 | 1455 | |
1456 | 1456 | $pos['<![CDATA['] = strpos($content, '<![CDATA['); |
1457 | 1457 | $pos[']]>'] = strpos($content, ']]>'); |
1458 | 1458 | |
1459 | 1459 | if ($pos['<![CDATA['] !== false && $pos[']]>'] !== false) { |
1460 | - $content = substr($content, 0, $pos['<![CDATA[']) . substr($content, $pos[']]>'] + 3); |
|
1460 | + $content = substr($content, 0, $pos['<![CDATA[']).substr($content, $pos[']]>'] + 3); |
|
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | $lp = explode($left, $content); |
@@ -1521,8 +1521,8 @@ discard block |
||
1521 | 1521 | } |
1522 | 1522 | } |
1523 | 1523 | } |
1524 | - foreach($tags as $i=>$tag) { |
|
1525 | - if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag); |
|
1524 | + foreach ($tags as $i=>$tag) { |
|
1525 | + if (strpos($tag, $spacer) !== false) $tags[$i] = str_replace($spacer, '', $tag); |
|
1526 | 1526 | } |
1527 | 1527 | return $tags; |
1528 | 1528 | } |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | } |
1563 | 1563 | |
1564 | 1564 | foreach ($matches[1] as $i => $key) { |
1565 | - if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
1565 | + if (strpos($key, '[+') !== false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
1566 | 1566 | if (substr($key, 0, 1) == '#') { |
1567 | 1567 | $key = substr($key, 1); |
1568 | 1568 | } // remove # for QuickEdit format |
@@ -1592,8 +1592,8 @@ discard block |
||
1592 | 1592 | |
1593 | 1593 | if (strpos($content, $s) !== false) { |
1594 | 1594 | $content = str_replace($s, $value, $content); |
1595 | - } elseif($this->debug) { |
|
1596 | - $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
1595 | + } elseif ($this->debug) { |
|
1596 | + $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
1597 | 1597 | } |
1598 | 1598 | } |
1599 | 1599 | |
@@ -1760,8 +1760,8 @@ discard block |
||
1760 | 1760 | $s = &$matches[0][$i]; |
1761 | 1761 | if (strpos($content, $s) !== false) { |
1762 | 1762 | $content = str_replace($s, $value, $content); |
1763 | - } elseif($this->debug) { |
|
1764 | - $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
1763 | + } elseif ($this->debug) { |
|
1764 | + $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
1765 | 1765 | } |
1766 | 1766 | } |
1767 | 1767 | return $content; |
@@ -1814,7 +1814,7 @@ discard block |
||
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | $value = $this->parseText($value, $params); // parse local scope placeholers for ConditionalTags |
1817 | - $value = $this->mergePlaceholderContent($value, $params); // parse page global placeholers |
|
1817 | + $value = $this->mergePlaceholderContent($value, $params); // parse page global placeholers |
|
1818 | 1818 | if ($this->config['enable_at_syntax']) { |
1819 | 1819 | $value = $this->mergeConditionalTagsContent($value); |
1820 | 1820 | } |
@@ -1829,8 +1829,8 @@ discard block |
||
1829 | 1829 | $s = &$matches[0][$i]; |
1830 | 1830 | if (strpos($content, $s) !== false) { |
1831 | 1831 | $content = str_replace($s, $value, $content); |
1832 | - } elseif($this->debug) { |
|
1833 | - $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
1832 | + } elseif ($this->debug) { |
|
1833 | + $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
1834 | 1834 | } |
1835 | 1835 | } |
1836 | 1836 | return $content; |
@@ -1888,8 +1888,8 @@ discard block |
||
1888 | 1888 | $s = &$matches[0][$i]; |
1889 | 1889 | if (strpos($content, $s) !== false) { |
1890 | 1890 | $content = str_replace($s, $value, $content); |
1891 | - } elseif($this->debug) { |
|
1892 | - $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
1891 | + } elseif ($this->debug) { |
|
1892 | + $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
1893 | 1893 | } |
1894 | 1894 | } |
1895 | 1895 | return $content; |
@@ -1913,7 +1913,7 @@ discard block |
||
1913 | 1913 | return $content; |
1914 | 1914 | } |
1915 | 1915 | |
1916 | - $sp = '#' . md5('ConditionalTags' . $_SERVER['REQUEST_TIME']) . '#'; |
|
1916 | + $sp = '#'.md5('ConditionalTags'.$_SERVER['REQUEST_TIME']).'#'; |
|
1917 | 1917 | $content = str_replace(array('<?php', '<?=', '<?', '?>'), array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), $content); |
1918 | 1918 | |
1919 | 1919 | $pieces = explode('<@IF:', $content); |
@@ -1924,7 +1924,7 @@ discard block |
||
1924 | 1924 | } |
1925 | 1925 | list($cmd, $text) = explode('>', $split, 2); |
1926 | 1926 | $cmd = str_replace("'", "\'", $cmd); |
1927 | - $content .= "<?php if(\$this->_parseCTagCMD('" . $cmd . "')): ?>"; |
|
1927 | + $content .= "<?php if(\$this->_parseCTagCMD('".$cmd."')): ?>"; |
|
1928 | 1928 | $content .= $text; |
1929 | 1929 | } |
1930 | 1930 | $pieces = explode('<@ELSEIF:', $content); |
@@ -1935,13 +1935,13 @@ discard block |
||
1935 | 1935 | } |
1936 | 1936 | list($cmd, $text) = explode('>', $split, 2); |
1937 | 1937 | $cmd = str_replace("'", "\'", $cmd); |
1938 | - $content .= "<?php elseif(\$this->_parseCTagCMD('" . $cmd . "')): ?>"; |
|
1938 | + $content .= "<?php elseif(\$this->_parseCTagCMD('".$cmd."')): ?>"; |
|
1939 | 1939 | $content .= $text; |
1940 | 1940 | } |
1941 | 1941 | |
1942 | 1942 | $content = str_replace(array('<@ELSE>', '<@ENDIF>'), array('<?php else:?>', '<?php endif;?>'), $content); |
1943 | 1943 | ob_start(); |
1944 | - $content = eval('?>' . $content); |
|
1944 | + $content = eval('?>'.$content); |
|
1945 | 1945 | $content = ob_get_clean(); |
1946 | 1946 | $content = str_replace(array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), array('<?php', '<?=', '<?', '?>'), $content); |
1947 | 1947 | |
@@ -2066,7 +2066,7 @@ discard block |
||
2066 | 2066 | $matches = $this->getTagsFromContent($content, $left, $right); |
2067 | 2067 | if (!empty($matches)) { |
2068 | 2068 | foreach ($matches[0] as $i => $v) { |
2069 | - $addBreakMatches[$i] = $v . "\n"; |
|
2069 | + $addBreakMatches[$i] = $v."\n"; |
|
2070 | 2070 | } |
2071 | 2071 | $content = str_replace($addBreakMatches, '', $content); |
2072 | 2072 | if (strpos($content, $left) !== false) { |
@@ -2099,8 +2099,8 @@ discard block |
||
2099 | 2099 | $s = &$matches[0][$i]; |
2100 | 2100 | if (strpos($content, $s) !== false) { |
2101 | 2101 | $content = str_replace($s, $v, $content); |
2102 | - } elseif($this->debug) { |
|
2103 | - $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
2102 | + } elseif ($this->debug) { |
|
2103 | + $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
2104 | 2104 | } |
2105 | 2105 | } |
2106 | 2106 | return $content; |
@@ -2164,7 +2164,7 @@ discard block |
||
2164 | 2164 | $msg = ($msg === false) ? 'ob_get_contents() error' : $msg; |
2165 | 2165 | $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Plugin', $error_info['message'], $error_info['line'], $msg); |
2166 | 2166 | if ($this->isBackend()) { |
2167 | - $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>' . $msg . '</p>'); |
|
2167 | + $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>'.$msg.'</p>'); |
|
2168 | 2168 | } |
2169 | 2169 | } |
2170 | 2170 | } else { |
@@ -2213,7 +2213,7 @@ discard block |
||
2213 | 2213 | $echo = ($echo === false) ? 'ob_get_contents() error' : $echo; |
2214 | 2214 | $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Snippet', $error_info['message'], $error_info['line'], $echo); |
2215 | 2215 | if ($this->isBackend()) { |
2216 | - $this->event->alert('An error occurred while loading. Please see the event log for more information<p>' . $echo . $return . '</p>'); |
|
2216 | + $this->event->alert('An error occurred while loading. Please see the event log for more information<p>'.$echo.$return.'</p>'); |
|
2217 | 2217 | } |
2218 | 2218 | } |
2219 | 2219 | } |
@@ -2221,7 +2221,7 @@ discard block |
||
2221 | 2221 | if (is_array($return) || is_object($return)) { |
2222 | 2222 | return $return; |
2223 | 2223 | } else { |
2224 | - return $echo . $return; |
|
2224 | + return $echo.$return; |
|
2225 | 2225 | } |
2226 | 2226 | } |
2227 | 2227 | |
@@ -2259,8 +2259,8 @@ discard block |
||
2259 | 2259 | } |
2260 | 2260 | if (strpos($content, $s) !== false) { |
2261 | 2261 | $content = str_replace($s, $value, $content); |
2262 | - } elseif($this->debug) { |
|
2263 | - $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
2262 | + } elseif ($this->debug) { |
|
2263 | + $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
2264 | 2264 | } |
2265 | 2265 | continue; |
2266 | 2266 | } |
@@ -2271,8 +2271,8 @@ discard block |
||
2271 | 2271 | |
2272 | 2272 | if (strpos($content, $s) !== false) { |
2273 | 2273 | $content = str_replace($s, $value, $content); |
2274 | - } elseif($this->debug) { |
|
2275 | - $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
2274 | + } elseif ($this->debug) { |
|
2275 | + $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
2276 | 2276 | } |
2277 | 2277 | } |
2278 | 2278 | |
@@ -2363,7 +2363,7 @@ discard block |
||
2363 | 2363 | $eventtime = sprintf('%2.2f ms', $eventtime * 1000); |
2364 | 2364 | $code = str_replace("\t", ' ', $this->getPhpCompat()->htmlspecialchars($value)); |
2365 | 2365 | $piece = str_replace("\t", ' ', $this->getPhpCompat()->htmlspecialchars($piece)); |
2366 | - $print_r_params = str_replace("\t", ' ', $this->getPhpCompat()->htmlspecialchars('$modx->event->params = ' . print_r($params, true))); |
|
2366 | + $print_r_params = str_replace("\t", ' ', $this->getPhpCompat()->htmlspecialchars('$modx->event->params = '.print_r($params, true))); |
|
2367 | 2367 | $this->snippetsCode .= sprintf('<fieldset style="margin:1em;"><legend><b>%s</b>(%s)</legend><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">[[%s]]</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre></fieldset>', $snippetObject['name'], $eventtime, $piece, $print_r_params, $code); |
2368 | 2368 | $this->snippetsTime[] = array('sname' => $key, 'time' => $eventtime); |
2369 | 2369 | } |
@@ -2608,7 +2608,7 @@ discard block |
||
2608 | 2608 | $rs = $this->getDatabase()->select('name,snippet,properties', '[+prefix+]site_snippets', $where); |
2609 | 2609 | $count = $this->getDatabase()->getRecordCount($rs); |
2610 | 2610 | if (1 < $count) { |
2611 | - exit('Error $modx->_getSnippetObject()' . $snip_name); |
|
2611 | + exit('Error $modx->_getSnippetObject()'.$snip_name); |
|
2612 | 2612 | } |
2613 | 2613 | if ($count) { |
2614 | 2614 | $row = $this->getDatabase()->getRow($rs); |
@@ -2634,7 +2634,7 @@ discard block |
||
2634 | 2634 | public function toAlias($text) |
2635 | 2635 | { |
2636 | 2636 | $suff = $this->config['friendly_url_suffix']; |
2637 | - return str_replace(array('.xml' . $suff, '.rss' . $suff, '.js' . $suff, '.css' . $suff, '.txt' . $suff, '.json' . $suff, '.pdf' . $suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text); |
|
2637 | + return str_replace(array('.xml'.$suff, '.rss'.$suff, '.js'.$suff, '.css'.$suff, '.txt'.$suff, '.json'.$suff, '.pdf'.$suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text); |
|
2638 | 2638 | } |
2639 | 2639 | |
2640 | 2640 | /** |
@@ -2666,7 +2666,7 @@ discard block |
||
2666 | 2666 | $suff = '/'; |
2667 | 2667 | } |
2668 | 2668 | |
2669 | - $url = ($dir != '' ? $dir . '/' : '') . $pre . $alias . $suff; |
|
2669 | + $url = ($dir != '' ? $dir.'/' : '').$pre.$alias.$suff; |
|
2670 | 2670 | } |
2671 | 2671 | |
2672 | 2672 | $evtOut = $this->invokeEvent('OnMakeDocUrl', array( |
@@ -2703,7 +2703,7 @@ discard block |
||
2703 | 2703 | preg_match_all('!\[\~([0-9]+)\~\]!ise', $documentSource, $match); |
2704 | 2704 | $ids = implode(',', array_unique($match['1'])); |
2705 | 2705 | if ($ids) { |
2706 | - $res = $this->getDatabase()->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (" . $ids . ") AND isfolder = '0'"); |
|
2706 | + $res = $this->getDatabase()->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (".$ids.") AND isfolder = '0'"); |
|
2707 | 2707 | while ($row = $this->getDatabase()->getRow($res)) { |
2708 | 2708 | if ($this->config['use_alias_path'] == '1' && $row['parent'] != 0) { |
2709 | 2709 | $parent = $row['parent']; |
@@ -2714,7 +2714,7 @@ discard block |
||
2714 | 2714 | $parent = $this->aliasListing[$parent]['parent']; |
2715 | 2715 | } |
2716 | 2716 | |
2717 | - $aliases[$row['id']] = $path . '/' . $row['alias']; |
|
2717 | + $aliases[$row['id']] = $path.'/'.$row['alias']; |
|
2718 | 2718 | } else { |
2719 | 2719 | $aliases[$row['id']] = $row['alias']; |
2720 | 2720 | } |
@@ -2726,7 +2726,7 @@ discard block |
||
2726 | 2726 | $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0); |
2727 | 2727 | $pref = $this->config['friendly_url_prefix']; |
2728 | 2728 | $suff = $this->config['friendly_url_suffix']; |
2729 | - $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
2729 | + $documentSource = preg_replace_callback($in, function($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
2730 | 2730 | global $modx; |
2731 | 2731 | $thealias = $aliases[$m[1]]; |
2732 | 2732 | $thefolder = $isfolder[$m[1]]; |
@@ -2742,7 +2742,7 @@ discard block |
||
2742 | 2742 | |
2743 | 2743 | } else { |
2744 | 2744 | $in = '!\[\~([0-9]+)\~\]!is'; |
2745 | - $out = "index.php?id=" . '\1'; |
|
2745 | + $out = "index.php?id=".'\1'; |
|
2746 | 2746 | $documentSource = preg_replace($in, $out, $documentSource); |
2747 | 2747 | } |
2748 | 2748 | |
@@ -2763,7 +2763,7 @@ discard block |
||
2763 | 2763 | $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; |
2764 | 2764 | $len_base_url = strlen($this->config['base_url']); |
2765 | 2765 | |
2766 | - $url_path = $q;//LANG |
|
2766 | + $url_path = $q; //LANG |
|
2767 | 2767 | |
2768 | 2768 | if (substr($url_path, 0, $len_base_url) === $this->config['base_url']) { |
2769 | 2769 | $url_path = substr($url_path, $len_base_url); |
@@ -2775,7 +2775,7 @@ discard block |
||
2775 | 2775 | $strictURL = substr($strictURL, $len_base_url); |
2776 | 2776 | } |
2777 | 2777 | $http_host = $_SERVER['HTTP_HOST']; |
2778 | - $requestedURL = "{$scheme}://{$http_host}" . '/' . $q; //LANG |
|
2778 | + $requestedURL = "{$scheme}://{$http_host}".'/'.$q; //LANG |
|
2779 | 2779 | |
2780 | 2780 | $site_url = $this->config['site_url']; |
2781 | 2781 | $url_query_string = explode('?', $_SERVER['REQUEST_URI']); |
@@ -2793,7 +2793,7 @@ discard block |
||
2793 | 2793 | } |
2794 | 2794 | if ($this->config['base_url'] != $_SERVER['REQUEST_URI']) { |
2795 | 2795 | if (empty($_POST)) { |
2796 | - if (($this->config['base_url'] . '?' . $qstring) != $_SERVER['REQUEST_URI']) { |
|
2796 | + if (($this->config['base_url'].'?'.$qstring) != $_SERVER['REQUEST_URI']) { |
|
2797 | 2797 | $this->sendRedirect($url, 0, 'REDIRECT_HEADER', 'HTTP/1.0 301 Moved Permanently'); |
2798 | 2798 | exit(0); |
2799 | 2799 | } |
@@ -2852,7 +2852,7 @@ discard block |
||
2852 | 2852 | $docgrp = implode(",", $docgrp); |
2853 | 2853 | } |
2854 | 2854 | // get document |
2855 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
2855 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
2856 | 2856 | $rs = $this->getDatabase()->select('sc.*', "{$tblsc} sc |
2857 | 2857 | LEFT JOIN {$tbldg} dg ON dg.document = sc.id", "sc.{$method} = '{$identifier}' AND ({$access})", "", 1); |
2858 | 2858 | if ($this->getDatabase()->getRecordCount($rs) < 1) { |
@@ -2888,9 +2888,9 @@ discard block |
||
2888 | 2888 | } |
2889 | 2889 | if ($documentObject['template']) { |
2890 | 2890 | // load TVs and merge with document - Orig by Apodigm - Docvars |
2891 | - $rs = $this->getDatabase()->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars") . " tv |
|
2892 | - INNER JOIN " . $this->getFullTableName("site_tmplvar_templates") . " tvtpl ON tvtpl.tmplvarid = tv.id |
|
2893 | - LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues") . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'"); |
|
2891 | + $rs = $this->getDatabase()->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars")." tv |
|
2892 | + INNER JOIN " . $this->getFullTableName("site_tmplvar_templates")." tvtpl ON tvtpl.tmplvarid = tv.id |
|
2893 | + LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues")." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'"); |
|
2894 | 2894 | $tmplvars = array(); |
2895 | 2895 | while ($row = $this->getDatabase()->getRow($rs)) { |
2896 | 2896 | $tmplvars[$row['name']] = array( |
@@ -2936,7 +2936,7 @@ discard block |
||
2936 | 2936 | $st = md5($source); |
2937 | 2937 | } |
2938 | 2938 | if ($this->dumpSnippets == 1) { |
2939 | - $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS " . ($i + 1) . "</b></legend><p>The following snippets (if any) were parsed during this pass.</p>"; |
|
2939 | + $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS ".($i + 1)."</b></legend><p>The following snippets (if any) were parsed during this pass.</p>"; |
|
2940 | 2940 | } |
2941 | 2941 | |
2942 | 2942 | // invoke OnParseDocument event |
@@ -2978,7 +2978,7 @@ discard block |
||
2978 | 2978 | */ |
2979 | 2979 | public function executeParser() |
2980 | 2980 | { |
2981 | - if(MODX_CLI) { |
|
2981 | + if (MODX_CLI) { |
|
2982 | 2982 | throw new \RuntimeException('Call DocumentParser::executeParser on CLI mode'); |
2983 | 2983 | } |
2984 | 2984 | |
@@ -3024,7 +3024,7 @@ discard block |
||
3024 | 3024 | |
3025 | 3025 | // Check use_alias_path and check if $this->virtualDir is set to anything, then parse the path |
3026 | 3026 | if ($this->config['use_alias_path'] == 1) { |
3027 | - $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir . '/' : '') . $this->documentIdentifier; |
|
3027 | + $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir.'/' : '').$this->documentIdentifier; |
|
3028 | 3028 | if (isset($this->documentListing[$alias])) { |
3029 | 3029 | $this->documentIdentifier = $this->documentListing[$alias]; |
3030 | 3030 | } else { |
@@ -3085,7 +3085,7 @@ discard block |
||
3085 | 3085 | } else { |
3086 | 3086 | $docAlias = $this->getDatabase()->escape($this->documentIdentifier); |
3087 | 3087 | $rs = $this->getDatabase()->select('id', $this->getFullTableName('site_content'), "deleted=0 and alias='{$docAlias}'"); |
3088 | - $this->documentIdentifier = (int)$this->getDatabase()->getValue($rs); |
|
3088 | + $this->documentIdentifier = (int) $this->getDatabase()->getValue($rs); |
|
3089 | 3089 | } |
3090 | 3090 | } |
3091 | 3091 | $this->documentMethod = 'id'; |
@@ -3142,7 +3142,7 @@ discard block |
||
3142 | 3142 | $_REQUEST[$n] = $_GET[$n] = $v; |
3143 | 3143 | } |
3144 | 3144 | } |
3145 | - $_SERVER['PHP_SELF'] = $this->config['base_url'] . $qp['path']; |
|
3145 | + $_SERVER['PHP_SELF'] = $this->config['base_url'].$qp['path']; |
|
3146 | 3146 | $this->q = $qp['path']; |
3147 | 3147 | return $qp['path']; |
3148 | 3148 | } |
@@ -3288,7 +3288,7 @@ discard block |
||
3288 | 3288 | while ($id && $height--) { |
3289 | 3289 | $thisid = $id; |
3290 | 3290 | if ($this->config['aliaslistingfolder'] == 1) { |
3291 | - $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->getDatabase()->getValue("SELECT `parent` FROM " . $this->getFullTableName("site_content") . " WHERE `id` = '{$id}' LIMIT 0,1"); |
|
3291 | + $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->getDatabase()->getValue("SELECT `parent` FROM ".$this->getFullTableName("site_content")." WHERE `id` = '{$id}' LIMIT 0,1"); |
|
3292 | 3292 | if (!$id || $id == '0') { |
3293 | 3293 | break; |
3294 | 3294 | } |
@@ -3339,15 +3339,15 @@ discard block |
||
3339 | 3339 | |
3340 | 3340 | if ($this->config['aliaslistingfolder'] == 1) { |
3341 | 3341 | |
3342 | - $res = $this->getDatabase()->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (" . $id . ") AND deleted = '0'"); |
|
3342 | + $res = $this->getDatabase()->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (".$id.") AND deleted = '0'"); |
|
3343 | 3343 | $idx = array(); |
3344 | 3344 | while ($row = $this->getDatabase()->getRow($res)) { |
3345 | 3345 | $pAlias = ''; |
3346 | 3346 | if (isset($this->aliasListing[$row['parent']])) { |
3347 | - $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'] . '/' : ''; |
|
3348 | - $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'] . '/' : ''; |
|
3347 | + $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'].'/' : ''; |
|
3348 | + $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'].'/' : ''; |
|
3349 | 3349 | }; |
3350 | - $children[$pAlias . $row['alias']] = $row['id']; |
|
3350 | + $children[$pAlias.$row['alias']] = $row['id']; |
|
3351 | 3351 | if ($row['isfolder'] == 1) { |
3352 | 3352 | $idx[] = $row['id']; |
3353 | 3353 | } |
@@ -3379,7 +3379,7 @@ discard block |
||
3379 | 3379 | $depth--; |
3380 | 3380 | |
3381 | 3381 | foreach ($documentMap_cache[$id] as $childId) { |
3382 | - $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '') . $this->aliasListing[$childId]['alias']; |
|
3382 | + $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '').$this->aliasListing[$childId]['alias']; |
|
3383 | 3383 | if (!strlen($pkey)) { |
3384 | 3384 | $pkey = "{$childId}"; |
3385 | 3385 | } |
@@ -3416,7 +3416,7 @@ discard block |
||
3416 | 3416 | $fnc = 'history.back(-1);'; |
3417 | 3417 | break; |
3418 | 3418 | default: |
3419 | - $fnc = "window.location.href='" . addslashes($url) . "';"; |
|
3419 | + $fnc = "window.location.href='".addslashes($url)."';"; |
|
3420 | 3420 | } |
3421 | 3421 | |
3422 | 3422 | echo "<html><head> |
@@ -3448,9 +3448,9 @@ discard block |
||
3448 | 3448 | $state = 0; |
3449 | 3449 | $pms = $_SESSION['mgrPermissions']; |
3450 | 3450 | if ($pms) { |
3451 | - $state = ((bool)$pms[$pm] === true); |
|
3451 | + $state = ((bool) $pms[$pm] === true); |
|
3452 | 3452 | } |
3453 | - return (int)$state; |
|
3453 | + return (int) $state; |
|
3454 | 3454 | } |
3455 | 3455 | |
3456 | 3456 | /** |
@@ -3463,8 +3463,8 @@ discard block |
||
3463 | 3463 | */ |
3464 | 3464 | public function elementIsLocked($type, $id, $includeThisUser = false) |
3465 | 3465 | { |
3466 | - $id = (int)$id; |
|
3467 | - $type = (int)$type; |
|
3466 | + $id = (int) $id; |
|
3467 | + $type = (int) $type; |
|
3468 | 3468 | if (!$type || !$id) { |
3469 | 3469 | return null; |
3470 | 3470 | } |
@@ -3514,7 +3514,7 @@ discard block |
||
3514 | 3514 | return $lockedElements; |
3515 | 3515 | } |
3516 | 3516 | |
3517 | - $type = (int)$type; |
|
3517 | + $type = (int) $type; |
|
3518 | 3518 | if (isset($lockedElements[$type])) { |
3519 | 3519 | return $lockedElements[$type]; |
3520 | 3520 | } else { |
@@ -3531,7 +3531,7 @@ discard block |
||
3531 | 3531 | $this->lockedElements = array(); |
3532 | 3532 | $this->cleanupExpiredLocks(); |
3533 | 3533 | |
3534 | - $rs = $this->getDatabase()->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks') . " ul |
|
3534 | + $rs = $this->getDatabase()->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks')." ul |
|
3535 | 3535 | LEFT JOIN {$this->getFullTableName('manager_users')} mu on ul.internalKey = mu.id"); |
3536 | 3536 | while ($row = $this->getDatabase()->getRow($rs)) { |
3537 | 3537 | $this->lockedElements[$row['elementType']][$row['elementId']] = array( |
@@ -3554,7 +3554,7 @@ discard block |
||
3554 | 3554 | public function cleanupExpiredLocks() |
3555 | 3555 | { |
3556 | 3556 | // Clean-up active_user_sessions first |
3557 | - $timeout = (int)$this->config['session_timeout'] < 2 ? 120 : $this->config['session_timeout'] * 60; // session.js pings every 10min, updateMail() in mainMenu pings every minute, so 2min is minimum |
|
3557 | + $timeout = (int) $this->config['session_timeout'] < 2 ? 120 : $this->config['session_timeout'] * 60; // session.js pings every 10min, updateMail() in mainMenu pings every minute, so 2min is minimum |
|
3558 | 3558 | $validSessionTimeLimit = $this->time - $timeout; |
3559 | 3559 | $this->getDatabase()->delete($this->getFullTableName('active_user_sessions'), "lasthit < {$validSessionTimeLimit}"); |
3560 | 3560 | |
@@ -3567,7 +3567,7 @@ discard block |
||
3567 | 3567 | foreach ($rs as $row) { |
3568 | 3568 | $userSids[] = $row['sid']; |
3569 | 3569 | } |
3570 | - $userSids = "'" . implode("','", $userSids) . "'"; |
|
3570 | + $userSids = "'".implode("','", $userSids)."'"; |
|
3571 | 3571 | $this->getDatabase()->delete($this->getFullTableName('active_user_locks'), "sid NOT IN({$userSids})"); |
3572 | 3572 | } else { |
3573 | 3573 | $this->getDatabase()->delete($this->getFullTableName('active_user_locks')); |
@@ -3651,8 +3651,8 @@ discard block |
||
3651 | 3651 | public function lockElement($type, $id) |
3652 | 3652 | { |
3653 | 3653 | $userId = $this->isBackend() && $_SESSION['mgrInternalKey'] ? $_SESSION['mgrInternalKey'] : 0; |
3654 | - $type = (int)$type; |
|
3655 | - $id = (int)$id; |
|
3654 | + $type = (int) $type; |
|
3655 | + $id = (int) $id; |
|
3656 | 3656 | if (!$type || !$id || !$userId) { |
3657 | 3657 | return false; |
3658 | 3658 | } |
@@ -3673,8 +3673,8 @@ discard block |
||
3673 | 3673 | public function unlockElement($type, $id, $includeAllUsers = false) |
3674 | 3674 | { |
3675 | 3675 | $userId = $this->isBackend() && $_SESSION['mgrInternalKey'] ? $_SESSION['mgrInternalKey'] : 0; |
3676 | - $type = (int)$type; |
|
3677 | - $id = (int)$id; |
|
3676 | + $type = (int) $type; |
|
3677 | + $id = (int) $id; |
|
3678 | 3678 | if (!$type || !$id) { |
3679 | 3679 | return false; |
3680 | 3680 | } |
@@ -3741,8 +3741,8 @@ discard block |
||
3741 | 3741 | } |
3742 | 3742 | |
3743 | 3743 | $usertype = $this->isFrontend() ? 1 : 0; |
3744 | - $evtid = (int)$evtid; |
|
3745 | - $type = (int)$type; |
|
3744 | + $evtid = (int) $evtid; |
|
3745 | + $type = (int) $type; |
|
3746 | 3746 | |
3747 | 3747 | // Types: 1 = information, 2 = warning, 3 = error |
3748 | 3748 | if ($type < 1) { |
@@ -3764,8 +3764,8 @@ discard block |
||
3764 | 3764 | if (isset($this->config['send_errormail']) && $this->config['send_errormail'] !== '0') { |
3765 | 3765 | if ($this->config['send_errormail'] <= $type) { |
3766 | 3766 | $this->sendmail(array( |
3767 | - 'subject' => 'MODX System Error on ' . $this->config['site_name'], |
|
3768 | - 'body' => 'Source: ' . $source . ' - The details of the error could be seen in the MODX system events log.', |
|
3767 | + 'subject' => 'MODX System Error on '.$this->config['site_name'], |
|
3768 | + 'body' => 'Source: '.$source.' - The details of the error could be seen in the MODX system events log.', |
|
3769 | 3769 | 'type' => 'text' |
3770 | 3770 | )); |
3771 | 3771 | } |
@@ -3814,7 +3814,7 @@ discard block |
||
3814 | 3814 | $p['fromname'] = $userinfo['username']; |
3815 | 3815 | } |
3816 | 3816 | if ($msg === '' && !isset($p['body'])) { |
3817 | - $p['body'] = $_SERVER['REQUEST_URI'] . "\n" . $_SERVER['HTTP_USER_AGENT'] . "\n" . $_SERVER['HTTP_REFERER']; |
|
3817 | + $p['body'] = $_SERVER['REQUEST_URI']."\n".$_SERVER['HTTP_USER_AGENT']."\n".$_SERVER['HTTP_REFERER']; |
|
3818 | 3818 | } elseif (is_string($msg) && 0 < strlen($msg)) { |
3819 | 3819 | $p['body'] = $msg; |
3820 | 3820 | } |
@@ -3855,8 +3855,8 @@ discard block |
||
3855 | 3855 | $files = array(); |
3856 | 3856 | } |
3857 | 3857 | foreach ($files as $f) { |
3858 | - if (file_exists(MODX_BASE_PATH . $f) && is_file(MODX_BASE_PATH . $f) && is_readable(MODX_BASE_PATH . $f)) { |
|
3859 | - $this->getMail()->AddAttachment(MODX_BASE_PATH . $f); |
|
3858 | + if (file_exists(MODX_BASE_PATH.$f) && is_file(MODX_BASE_PATH.$f) && is_readable(MODX_BASE_PATH.$f)) { |
|
3859 | + $this->getMail()->AddAttachment(MODX_BASE_PATH.$f); |
|
3860 | 3860 | } |
3861 | 3861 | } |
3862 | 3862 | return $this->getMail()->send(); |
@@ -3900,7 +3900,7 @@ discard block |
||
3900 | 3900 | */ |
3901 | 3901 | public function isFrontend() |
3902 | 3902 | { |
3903 | - return ! $this->isBackend(); |
|
3903 | + return !$this->isBackend(); |
|
3904 | 3904 | } |
3905 | 3905 | |
3906 | 3906 | /** |
@@ -3925,14 +3925,14 @@ discard block |
||
3925 | 3925 | $tblsc = $this->getFullTableName("site_content"); |
3926 | 3926 | $tbldg = $this->getFullTableName("document_groups"); |
3927 | 3927 | // modify field names to use sc. table reference |
3928 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
3929 | - $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
3928 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
3929 | + $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
3930 | 3930 | // get document groups for current user |
3931 | 3931 | if ($docgrp = $this->getUserDocGroups()) { |
3932 | 3932 | $docgrp = implode(",", $docgrp); |
3933 | 3933 | } |
3934 | 3934 | // build query |
3935 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
3935 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
3936 | 3936 | $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
3937 | 3937 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
3938 | 3938 | $resourceArray = $this->getDatabase()->makeArray($result); |
@@ -3962,14 +3962,14 @@ discard block |
||
3962 | 3962 | $tbldg = $this->getFullTableName("document_groups"); |
3963 | 3963 | |
3964 | 3964 | // modify field names to use sc. table reference |
3965 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
3966 | - $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
3965 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
3966 | + $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
3967 | 3967 | // get document groups for current user |
3968 | 3968 | if ($docgrp = $this->getUserDocGroups()) { |
3969 | 3969 | $docgrp = implode(",", $docgrp); |
3970 | 3970 | } |
3971 | 3971 | // build query |
3972 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
3972 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
3973 | 3973 | $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
3974 | 3974 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND sc.published=1 AND sc.deleted=0 AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
3975 | 3975 | $resourceArray = $this->getDatabase()->makeArray($result); |
@@ -4004,16 +4004,16 @@ discard block |
||
4004 | 4004 | return $this->tmpCache[__FUNCTION__][$cacheKey]; |
4005 | 4005 | } |
4006 | 4006 | |
4007 | - $published = ($published !== 'all') ? 'AND sc.published = ' . $published : ''; |
|
4008 | - $deleted = ($deleted !== 'all') ? 'AND sc.deleted = ' . $deleted : ''; |
|
4007 | + $published = ($published !== 'all') ? 'AND sc.published = '.$published : ''; |
|
4008 | + $deleted = ($deleted !== 'all') ? 'AND sc.deleted = '.$deleted : ''; |
|
4009 | 4009 | |
4010 | 4010 | if ($where != '') { |
4011 | - $where = 'AND ' . $where; |
|
4011 | + $where = 'AND '.$where; |
|
4012 | 4012 | } |
4013 | 4013 | |
4014 | 4014 | // modify field names to use sc. table reference |
4015 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
4016 | - $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
4015 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
4016 | + $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
4017 | 4017 | |
4018 | 4018 | // get document groups for current user |
4019 | 4019 | if ($docgrp = $this->getUserDocGroups()) { |
@@ -4021,7 +4021,7 @@ discard block |
||
4021 | 4021 | } |
4022 | 4022 | |
4023 | 4023 | // build query |
4024 | - $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')'); |
|
4024 | + $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')'); |
|
4025 | 4025 | |
4026 | 4026 | $tblsc = $this->getFullTableName('site_content'); |
4027 | 4027 | $tbldg = $this->getFullTableName('document_groups'); |
@@ -4073,10 +4073,10 @@ discard block |
||
4073 | 4073 | return false; |
4074 | 4074 | } else { |
4075 | 4075 | // modify field names to use sc. table reference |
4076 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
4077 | - $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
4076 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
4077 | + $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
4078 | 4078 | if ($where != '') { |
4079 | - $where = 'AND ' . $where; |
|
4079 | + $where = 'AND '.$where; |
|
4080 | 4080 | } |
4081 | 4081 | |
4082 | 4082 | $published = ($published !== 'all') ? "AND sc.published = '{$published}'" : ''; |
@@ -4087,13 +4087,13 @@ discard block |
||
4087 | 4087 | $docgrp = implode(',', $docgrp); |
4088 | 4088 | } |
4089 | 4089 | |
4090 | - $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')'); |
|
4090 | + $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')'); |
|
4091 | 4091 | |
4092 | 4092 | $tblsc = $this->getFullTableName('site_content'); |
4093 | 4093 | $tbldg = $this->getFullTableName('document_groups'); |
4094 | 4094 | |
4095 | 4095 | $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
4096 | - LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (" . implode(',', $ids) . ") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit); |
|
4096 | + LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (".implode(',', $ids).") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit); |
|
4097 | 4097 | |
4098 | 4098 | $resourceArray = $this->getDatabase()->makeArray($result); |
4099 | 4099 | |
@@ -4198,12 +4198,12 @@ discard block |
||
4198 | 4198 | $tbldg = $this->getFullTableName("document_groups"); |
4199 | 4199 | $activeSql = $active == 1 ? "AND sc.published=1 AND sc.deleted=0" : ""; |
4200 | 4200 | // modify field names to use sc. table reference |
4201 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
4201 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
4202 | 4202 | // get document groups for current user |
4203 | 4203 | if ($docgrp = $this->getUserDocGroups()) { |
4204 | 4204 | $docgrp = implode(",", $docgrp); |
4205 | 4205 | } |
4206 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
4206 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
4207 | 4207 | $result = $this->getDatabase()->select($fields, "{$tblsc} sc LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id='{$pageid}' {$activeSql}) AND ({$access})", "", 1); |
4208 | 4208 | $pageInfo = $this->getDatabase()->getRow($result); |
4209 | 4209 | |
@@ -4250,7 +4250,7 @@ discard block |
||
4250 | 4250 | { |
4251 | 4251 | if ($this->currentSnippet) { |
4252 | 4252 | $tbl = $this->getFullTableName("site_snippets"); |
4253 | - $rs = $this->getDatabase()->select('id', $tbl, "name='" . $this->getDatabase()->escape($this->currentSnippet) . "'", '', 1); |
|
4253 | + $rs = $this->getDatabase()->select('id', $tbl, "name='".$this->getDatabase()->escape($this->currentSnippet)."'", '', 1); |
|
4254 | 4254 | if ($snippetId = $this->getDatabase()->getValue($rs)) { |
4255 | 4255 | return $snippetId; |
4256 | 4256 | } |
@@ -4277,7 +4277,7 @@ discard block |
||
4277 | 4277 | */ |
4278 | 4278 | public function clearCache($type = '', $report = false) |
4279 | 4279 | { |
4280 | - $cache_dir = MODX_BASE_PATH . $this->getCacheFolder(); |
|
4280 | + $cache_dir = MODX_BASE_PATH.$this->getCacheFolder(); |
|
4281 | 4281 | if (is_array($type)) { |
4282 | 4282 | foreach ($type as $_) { |
4283 | 4283 | $this->clearCache($_, $report); |
@@ -4289,10 +4289,10 @@ discard block |
||
4289 | 4289 | $sync->emptyCache(); |
4290 | 4290 | } elseif (preg_match('@^[1-9][0-9]*$@', $type)) { |
4291 | 4291 | $key = ($this->config['cache_type'] == 2) ? $this->makePageCacheKey($type) : $type; |
4292 | - $file_name = "docid_" . $key . "_*.pageCache.php"; |
|
4293 | - $cache_path = $cache_dir . $file_name; |
|
4292 | + $file_name = "docid_".$key."_*.pageCache.php"; |
|
4293 | + $cache_path = $cache_dir.$file_name; |
|
4294 | 4294 | $files = glob($cache_path); |
4295 | - $files[] = $cache_dir . "docid_" . $key . ".pageCache.php"; |
|
4295 | + $files[] = $cache_dir."docid_".$key.".pageCache.php"; |
|
4296 | 4296 | foreach ($files as $file) { |
4297 | 4297 | if (!is_file($file)) { |
4298 | 4298 | continue; |
@@ -4300,7 +4300,7 @@ discard block |
||
4300 | 4300 | unlink($file); |
4301 | 4301 | } |
4302 | 4302 | } else { |
4303 | - $files = glob($cache_dir . '*'); |
|
4303 | + $files = glob($cache_dir.'*'); |
|
4304 | 4304 | foreach ($files as $file) { |
4305 | 4305 | $name = basename($file); |
4306 | 4306 | if (strpos($name, '.pageCache.php') === false) { |
@@ -4369,7 +4369,7 @@ discard block |
||
4369 | 4369 | $f_url_suffix = '/'; |
4370 | 4370 | } |
4371 | 4371 | |
4372 | - $alPath = !empty ($al['path']) ? $al['path'] . '/' : ''; |
|
4372 | + $alPath = !empty ($al['path']) ? $al['path'].'/' : ''; |
|
4373 | 4373 | |
4374 | 4374 | if ($al && $al['alias']) { |
4375 | 4375 | $alias = $al['alias']; |
@@ -4377,7 +4377,7 @@ discard block |
||
4377 | 4377 | |
4378 | 4378 | } |
4379 | 4379 | |
4380 | - $alias = $alPath . $f_url_prefix . $alias . $f_url_suffix; |
|
4380 | + $alias = $alPath.$f_url_prefix.$alias.$f_url_suffix; |
|
4381 | 4381 | $url = "{$alias}{$args}"; |
4382 | 4382 | } else { |
4383 | 4383 | $url = "index.php?id={$id}{$args}"; |
@@ -4396,7 +4396,7 @@ discard block |
||
4396 | 4396 | } |
4397 | 4397 | |
4398 | 4398 | //TODO: check to make sure that $site_url incudes the url :port (e.g. :8080) |
4399 | - $host = $scheme == 'full' ? $this->config['site_url'] : $scheme . '://' . $_SERVER['HTTP_HOST'] . $host; |
|
4399 | + $host = $scheme == 'full' ? $this->config['site_url'] : $scheme.'://'.$_SERVER['HTTP_HOST'].$host; |
|
4400 | 4400 | } |
4401 | 4401 | |
4402 | 4402 | //fix strictUrl by Bumkaka |
@@ -4405,9 +4405,9 @@ discard block |
||
4405 | 4405 | } |
4406 | 4406 | |
4407 | 4407 | if ($this->config['xhtml_urls']) { |
4408 | - $url = preg_replace("/&(?!amp;)/", "&", $host . $virtualDir . $url); |
|
4408 | + $url = preg_replace("/&(?!amp;)/", "&", $host.$virtualDir.$url); |
|
4409 | 4409 | } else { |
4410 | - $url = $host . $virtualDir . $url; |
|
4410 | + $url = $host.$virtualDir.$url; |
|
4411 | 4411 | } |
4412 | 4412 | |
4413 | 4413 | $evtOut = $this->invokeEvent('OnMakeDocUrl', array( |
@@ -4431,21 +4431,21 @@ discard block |
||
4431 | 4431 | if (isset($this->aliasListing[$id])) { |
4432 | 4432 | $out = $this->aliasListing[$id]; |
4433 | 4433 | } else { |
4434 | - $q = $this->getDatabase()->query("SELECT id,alias,isfolder,parent FROM " . $this->getFullTableName("site_content") . " WHERE id=" . (int)$id); |
|
4434 | + $q = $this->getDatabase()->query("SELECT id,alias,isfolder,parent FROM ".$this->getFullTableName("site_content")." WHERE id=".(int) $id); |
|
4435 | 4435 | if ($this->getDatabase()->getRecordCount($q) == '1') { |
4436 | 4436 | $q = $this->getDatabase()->getRow($q); |
4437 | 4437 | $this->aliasListing[$id] = array( |
4438 | - 'id' => (int)$q['id'], |
|
4438 | + 'id' => (int) $q['id'], |
|
4439 | 4439 | 'alias' => $q['alias'] == '' ? $q['id'] : $q['alias'], |
4440 | - 'parent' => (int)$q['parent'], |
|
4441 | - 'isfolder' => (int)$q['isfolder'], |
|
4440 | + 'parent' => (int) $q['parent'], |
|
4441 | + 'isfolder' => (int) $q['isfolder'], |
|
4442 | 4442 | ); |
4443 | 4443 | if ($this->aliasListing[$id]['parent'] > 0) { |
4444 | 4444 | //fix alias_path_usage |
4445 | 4445 | if ($this->config['use_alias_path'] == '1') { |
4446 | 4446 | //&& $tmp['path'] != '' - fix error slash with epty path |
4447 | 4447 | $tmp = $this->getAliasListing($this->aliasListing[$id]['parent']); |
4448 | - $this->aliasListing[$id]['path'] = $tmp['path'] . ($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '') . $tmp['alias'] : ''); |
|
4448 | + $this->aliasListing[$id]['path'] = $tmp['path'].($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '').$tmp['alias'] : ''); |
|
4449 | 4449 | } else { |
4450 | 4450 | $this->aliasListing[$id]['path'] = ''; |
4451 | 4451 | } |
@@ -4486,7 +4486,7 @@ discard block |
||
4486 | 4486 | $out = array(); |
4487 | 4487 | if (empty($this->version) || !is_array($this->version)) { |
4488 | 4488 | //include for compatibility modx version < 1.0.10 |
4489 | - include MODX_MANAGER_PATH . "includes/version.inc.php"; |
|
4489 | + include MODX_MANAGER_PATH."includes/version.inc.php"; |
|
4490 | 4490 | $this->version = array(); |
4491 | 4491 | $this->version['version'] = isset($modx_version) ? $modx_version : ''; |
4492 | 4492 | $this->version['branch'] = isset($modx_branch) ? $modx_branch : ''; |
@@ -4508,18 +4508,18 @@ discard block |
||
4508 | 4508 | { |
4509 | 4509 | if (isset ($this->snippetCache[$snippetName])) { |
4510 | 4510 | $snippet = $this->snippetCache[$snippetName]; |
4511 | - $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; |
|
4511 | + $properties = !empty($this->snippetCache[$snippetName."Props"]) ? $this->snippetCache[$snippetName."Props"] : ''; |
|
4512 | 4512 | } else { // not in cache so let's check the db |
4513 | - $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->getDatabase()->escape($snippetName) . "' AND ss.disabled=0;"; |
|
4513 | + $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM ".$this->getFullTableName("site_snippets")." as ss LEFT JOIN ".$this->getFullTableName('site_modules')." as sm on sm.guid=ss.moduleguid WHERE ss.`name`='".$this->getDatabase()->escape($snippetName)."' AND ss.disabled=0;"; |
|
4514 | 4514 | $result = $this->getDatabase()->query($sql); |
4515 | 4515 | if ($this->getDatabase()->getRecordCount($result) == 1) { |
4516 | 4516 | $row = $this->getDatabase()->getRow($result); |
4517 | 4517 | $snippet = $this->snippetCache[$snippetName] = $row['snippet']; |
4518 | 4518 | $mergedProperties = array_merge($this->parseProperties($row['properties']), $this->parseProperties($row['sharedproperties'])); |
4519 | - $properties = $this->snippetCache[$snippetName . "Props"] = json_encode($mergedProperties); |
|
4519 | + $properties = $this->snippetCache[$snippetName."Props"] = json_encode($mergedProperties); |
|
4520 | 4520 | } else { |
4521 | 4521 | $snippet = $this->snippetCache[$snippetName] = "return false;"; |
4522 | - $properties = $this->snippetCache[$snippetName . "Props"] = ''; |
|
4522 | + $properties = $this->snippetCache[$snippetName."Props"] = ''; |
|
4523 | 4523 | } |
4524 | 4524 | } |
4525 | 4525 | // load default params/properties |
@@ -4619,8 +4619,8 @@ discard block |
||
4619 | 4619 | } |
4620 | 4620 | if (strpos($tpl, $s) !== false) { |
4621 | 4621 | $tpl = str_replace($s, $value, $tpl); |
4622 | - } elseif($this->debug) { |
|
4623 | - $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
4622 | + } elseif ($this->debug) { |
|
4623 | + $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
4624 | 4624 | } |
4625 | 4625 | } |
4626 | 4626 | |
@@ -4669,7 +4669,7 @@ discard block |
||
4669 | 4669 | case 'CODE': |
4670 | 4670 | break; |
4671 | 4671 | case 'FILE': |
4672 | - $template = file_get_contents(MODX_BASE_PATH . $template); |
|
4672 | + $template = file_get_contents(MODX_BASE_PATH.$template); |
|
4673 | 4673 | break; |
4674 | 4674 | case 'CHUNK': |
4675 | 4675 | $template = $this->getChunk($template); |
@@ -4702,7 +4702,7 @@ discard block |
||
4702 | 4702 | if ($mode !== 'formatOnly' && empty($timestamp)) { |
4703 | 4703 | return '-'; |
4704 | 4704 | } |
4705 | - $timestamp = (int)$timestamp; |
|
4705 | + $timestamp = (int) $timestamp; |
|
4706 | 4706 | |
4707 | 4707 | switch ($this->config['datetime_format']) { |
4708 | 4708 | case 'YYYY/mm/dd': |
@@ -4722,7 +4722,7 @@ discard block |
||
4722 | 4722 | } |
4723 | 4723 | |
4724 | 4724 | if (empty($mode)) { |
4725 | - $strTime = strftime($dateFormat . " %H:%M:%S", $timestamp); |
|
4725 | + $strTime = strftime($dateFormat." %H:%M:%S", $timestamp); |
|
4726 | 4726 | } elseif ($mode == 'dateOnly') { |
4727 | 4727 | $strTime = strftime($dateFormat, $timestamp); |
4728 | 4728 | } elseif ($mode == 'formatOnly') { |
@@ -4776,7 +4776,7 @@ discard block |
||
4776 | 4776 | $S = 0; |
4777 | 4777 | } |
4778 | 4778 | $timeStamp = mktime($H, $M, $S, $m, $d, $Y); |
4779 | - $timeStamp = (int)$timeStamp; |
|
4779 | + $timeStamp = (int) $timeStamp; |
|
4780 | 4780 | return $timeStamp; |
4781 | 4781 | } |
4782 | 4782 | |
@@ -4818,7 +4818,7 @@ discard block |
||
4818 | 4818 | if ($v === 'value') { |
4819 | 4819 | unset($_[$i]); |
4820 | 4820 | } else { |
4821 | - $_[$i] = 'tv.' . $v; |
|
4821 | + $_[$i] = 'tv.'.$v; |
|
4822 | 4822 | } |
4823 | 4823 | } |
4824 | 4824 | $fields = implode(',', $_); |
@@ -4827,12 +4827,12 @@ discard block |
||
4827 | 4827 | } |
4828 | 4828 | |
4829 | 4829 | if ($tvsort != '') { |
4830 | - $tvsort = 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $tvsort)))); |
|
4830 | + $tvsort = 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $tvsort)))); |
|
4831 | 4831 | } |
4832 | 4832 | if ($tvidnames == "*") { |
4833 | 4833 | $query = "tv.id<>0"; |
4834 | 4834 | } else { |
4835 | - $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name") . " IN ('" . implode("','", $tvidnames) . "')"; |
|
4835 | + $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name")." IN ('".implode("','", $tvidnames)."')"; |
|
4836 | 4836 | } |
4837 | 4837 | |
4838 | 4838 | $this->getUserDocGroups(); |
@@ -4976,7 +4976,7 @@ discard block |
||
4976 | 4976 | return $this->tmpCache[__FUNCTION__][$cacheKey]; |
4977 | 4977 | } |
4978 | 4978 | |
4979 | - if (($idnames != '*' && !is_array($idnames)) || empty($idnames) ) { |
|
4979 | + if (($idnames != '*' && !is_array($idnames)) || empty($idnames)) { |
|
4980 | 4980 | return false; |
4981 | 4981 | } else { |
4982 | 4982 | |
@@ -4994,23 +4994,23 @@ discard block |
||
4994 | 4994 | } |
4995 | 4995 | |
4996 | 4996 | // get user defined template variables |
4997 | - $fields = ($fields == '') ? 'tv.*' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $fields)))); |
|
4998 | - $sort = ($sort == '') ? '' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $sort)))); |
|
4997 | + $fields = ($fields == '') ? 'tv.*' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $fields)))); |
|
4998 | + $sort = ($sort == '') ? '' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $sort)))); |
|
4999 | 4999 | |
5000 | 5000 | if ($idnames == '*') { |
5001 | 5001 | $query = 'tv.id<>0'; |
5002 | 5002 | } else { |
5003 | - $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name') . " IN ('" . implode("','", $idnames) . "')"; |
|
5003 | + $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name')." IN ('".implode("','", $idnames)."')"; |
|
5004 | 5004 | } |
5005 | 5005 | |
5006 | - $rs = $this->getDatabase()->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars') . " tv |
|
5007 | - INNER JOIN " . $this->getFullTableName('site_tmplvar_templates') . " tvtpl ON tvtpl.tmplvarid = tv.id |
|
5008 | - LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues') . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : "")); |
|
5006 | + $rs = $this->getDatabase()->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars')." tv |
|
5007 | + INNER JOIN " . $this->getFullTableName('site_tmplvar_templates')." tvtpl ON tvtpl.tmplvarid = tv.id |
|
5008 | + LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues')." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : "")); |
|
5009 | 5009 | |
5010 | 5010 | $result = $this->getDatabase()->makeArray($rs); |
5011 | 5011 | |
5012 | 5012 | // get default/built-in template variables |
5013 | - if(is_array($docRow)){ |
|
5013 | + if (is_array($docRow)) { |
|
5014 | 5014 | ksort($docRow); |
5015 | 5015 | |
5016 | 5016 | foreach ($docRow as $key => $value) { |
@@ -5048,13 +5048,13 @@ discard block |
||
5048 | 5048 | */ |
5049 | 5049 | public function getTemplateVarOutput($idnames = array(), $docid = '', $published = 1, $sep = '') |
5050 | 5050 | { |
5051 | - if (is_array($idnames) && empty($idnames) ) { |
|
5051 | + if (is_array($idnames) && empty($idnames)) { |
|
5052 | 5052 | return false; |
5053 | 5053 | } else { |
5054 | 5054 | $output = array(); |
5055 | 5055 | $vars = ($idnames == '*' || is_array($idnames)) ? $idnames : array($idnames); |
5056 | 5056 | |
5057 | - $docid = (int)$docid > 0 ? (int)$docid : $this->documentIdentifier; |
|
5057 | + $docid = (int) $docid > 0 ? (int) $docid : $this->documentIdentifier; |
|
5058 | 5058 | // remove sort for speed |
5059 | 5059 | $result = $this->getTemplateVars($vars, '*', $docid, $published, '', ''); |
5060 | 5060 | |
@@ -5084,7 +5084,7 @@ discard block |
||
5084 | 5084 | */ |
5085 | 5085 | public function getFullTableName($tbl) |
5086 | 5086 | { |
5087 | - return $this->getDatabase()->config['dbase'] . ".`" . $this->getDatabase()->config['table_prefix'] . $tbl . "`"; |
|
5087 | + return $this->getDatabase()->config['dbase'].".`".$this->getDatabase()->config['table_prefix'].$tbl."`"; |
|
5088 | 5088 | } |
5089 | 5089 | |
5090 | 5090 | /** |
@@ -5163,7 +5163,7 @@ discard block |
||
5163 | 5163 | public function getCachePath() |
5164 | 5164 | { |
5165 | 5165 | global $base_url; |
5166 | - $pth = $base_url . $this->getCacheFolder(); |
|
5166 | + $pth = $base_url.$this->getCacheFolder(); |
|
5167 | 5167 | return $pth; |
5168 | 5168 | } |
5169 | 5169 | |
@@ -5215,8 +5215,8 @@ discard block |
||
5215 | 5215 | $out = false; |
5216 | 5216 | |
5217 | 5217 | if (!empty($context)) { |
5218 | - if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) { |
|
5219 | - $out = $_SESSION[$context . 'InternalKey']; |
|
5218 | + if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) { |
|
5219 | + $out = $_SESSION[$context.'InternalKey']; |
|
5220 | 5220 | } |
5221 | 5221 | } else { |
5222 | 5222 | switch (true) { |
@@ -5244,8 +5244,8 @@ discard block |
||
5244 | 5244 | $out = false; |
5245 | 5245 | |
5246 | 5246 | if (!empty($context)) { |
5247 | - if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) { |
|
5248 | - $out = $_SESSION[$context . 'Shortname']; |
|
5247 | + if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) { |
|
5248 | + $out = $_SESSION[$context.'Shortname']; |
|
5249 | 5249 | } |
5250 | 5250 | } else { |
5251 | 5251 | switch (true) { |
@@ -5316,8 +5316,8 @@ discard block |
||
5316 | 5316 | */ |
5317 | 5317 | public function getWebUserInfo($uid) |
5318 | 5318 | { |
5319 | - $rs = $this->getDatabase()->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users") . " wu |
|
5320 | - INNER JOIN " . $this->getFullTableName("web_user_attributes") . " wua ON wua.internalkey=wu.id", "wu.id='{$uid}'"); |
|
5319 | + $rs = $this->getDatabase()->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users")." wu |
|
5320 | + INNER JOIN " . $this->getFullTableName("web_user_attributes")." wua ON wua.internalkey=wu.id", "wu.id='{$uid}'"); |
|
5321 | 5321 | if ($row = $this->getDatabase()->getRow($rs)) { |
5322 | 5322 | if (!isset($row['usertype']) or !$row["usertype"]) { |
5323 | 5323 | $row["usertype"] = "web"; |
@@ -5353,7 +5353,7 @@ discard block |
||
5353 | 5353 | } else if (is_array($dg)) { |
5354 | 5354 | // resolve ids to names |
5355 | 5355 | $dgn = array(); |
5356 | - $ds = $this->getDatabase()->select('name', $this->getFullTableName("documentgroup_names"), "id IN (" . implode(",", $dg) . ")"); |
|
5356 | + $ds = $this->getDatabase()->select('name', $this->getFullTableName("documentgroup_names"), "id IN (".implode(",", $dg).")"); |
|
5357 | 5357 | while ($row = $this->getDatabase()->getRow($ds)) { |
5358 | 5358 | $dgn[] = $row['name']; |
5359 | 5359 | } |
@@ -5381,7 +5381,7 @@ discard block |
||
5381 | 5381 | $rt = false; |
5382 | 5382 | if ($_SESSION["webValidated"] == 1) { |
5383 | 5383 | $tbl = $this->getFullTableName("web_users"); |
5384 | - $ds = $this->getDatabase()->select('id, username, password', $tbl, "id='" . $this->getLoginUserID() . "'"); |
|
5384 | + $ds = $this->getDatabase()->select('id, username, password', $tbl, "id='".$this->getLoginUserID()."'"); |
|
5385 | 5385 | if ($row = $this->getDatabase()->getRow($ds)) { |
5386 | 5386 | if ($row["password"] == md5($oldPwd)) { |
5387 | 5387 | if (strlen($newPwd) < 6) { |
@@ -5391,7 +5391,7 @@ discard block |
||
5391 | 5391 | } else { |
5392 | 5392 | $this->getDatabase()->update(array( |
5393 | 5393 | 'password' => $this->getDatabase()->escape($newPwd), |
5394 | - ), $tbl, "id='" . $this->getLoginUserID() . "'"); |
|
5394 | + ), $tbl, "id='".$this->getLoginUserID()."'"); |
|
5395 | 5395 | // invoke OnWebChangePassword event |
5396 | 5396 | $this->invokeEvent("OnWebChangePassword", array( |
5397 | 5397 | "userid" => $row["id"], |
@@ -5422,8 +5422,8 @@ discard block |
||
5422 | 5422 | // check cache |
5423 | 5423 | $grpNames = isset ($_SESSION['webUserGroupNames']) ? $_SESSION['webUserGroupNames'] : false; |
5424 | 5424 | if (!is_array($grpNames)) { |
5425 | - $rs = $this->getDatabase()->select('wgn.name', $this->getFullTableName("webgroup_names") . " wgn |
|
5426 | - INNER JOIN " . $this->getFullTableName("web_groups") . " wg ON wg.webgroup=wgn.id AND wg.webuser='" . $this->getLoginUserID() . "'"); |
|
5425 | + $rs = $this->getDatabase()->select('wgn.name', $this->getFullTableName("webgroup_names")." wgn |
|
5426 | + INNER JOIN " . $this->getFullTableName("web_groups")." wg ON wg.webgroup=wgn.id AND wg.webuser='".$this->getLoginUserID()."'"); |
|
5427 | 5427 | $grpNames = $this->getDatabase()->getColumn("name", $rs); |
5428 | 5428 | // save to cache |
5429 | 5429 | $_SESSION['webUserGroupNames'] = $grpNames; |
@@ -5456,7 +5456,7 @@ discard block |
||
5456 | 5456 | if (strpos(strtolower($src), "<style") !== false || strpos(strtolower($src), "<link") !== false) { |
5457 | 5457 | $this->sjscripts[$nextpos] = $src; |
5458 | 5458 | } else { |
5459 | - $this->sjscripts[$nextpos] = "\t" . '<link rel="stylesheet" type="text/css" href="' . $src . '" ' . ($media ? 'media="' . $media . '" ' : '') . '/>'; |
|
5459 | + $this->sjscripts[$nextpos] = "\t".'<link rel="stylesheet" type="text/css" href="'.$src.'" '.($media ? 'media="'.$media.'" ' : '').'/>'; |
|
5460 | 5460 | } |
5461 | 5461 | } |
5462 | 5462 | |
@@ -5535,7 +5535,7 @@ discard block |
||
5535 | 5535 | } |
5536 | 5536 | |
5537 | 5537 | if ($useThisVer && $plaintext != true && (strpos(strtolower($src), "<script") === false)) { |
5538 | - $src = "\t" . '<script type="text/javascript" src="' . $src . '"></script>'; |
|
5538 | + $src = "\t".'<script type="text/javascript" src="'.$src.'"></script>'; |
|
5539 | 5539 | } |
5540 | 5540 | if ($startup) { |
5541 | 5541 | $pos = isset($overwritepos) ? $overwritepos : max(array_merge(array(0), array_keys($this->sjscripts))) + 1; |
@@ -5682,7 +5682,7 @@ discard block |
||
5682 | 5682 | $eventtime = $this->getMicroTime() - $eventtime; |
5683 | 5683 | $this->pluginsCode .= sprintf('<fieldset><legend><b>%s / %s</b> (%2.2f ms)</legend>', $evtName, $pluginName, $eventtime * 1000); |
5684 | 5684 | foreach ($parameter as $k => $v) { |
5685 | - $this->pluginsCode .= "{$k} => " . print_r($v, true) . '<br>'; |
|
5685 | + $this->pluginsCode .= "{$k} => ".print_r($v, true).'<br>'; |
|
5686 | 5686 | } |
5687 | 5687 | $this->pluginsCode .= '</fieldset><br />'; |
5688 | 5688 | $this->pluginsTime["{$evtName} / {$pluginName}"] += $eventtime; |
@@ -5710,13 +5710,13 @@ discard block |
||
5710 | 5710 | $plugin = array(); |
5711 | 5711 | if (isset ($this->pluginCache[$pluginName])) { |
5712 | 5712 | $pluginCode = $this->pluginCache[$pluginName]; |
5713 | - $pluginProperties = isset($this->pluginCache[$pluginName . "Props"]) ? $this->pluginCache[$pluginName . "Props"] : ''; |
|
5713 | + $pluginProperties = isset($this->pluginCache[$pluginName."Props"]) ? $this->pluginCache[$pluginName."Props"] : ''; |
|
5714 | 5714 | } else { |
5715 | 5715 | $pluginName = $this->getDatabase()->escape($pluginName); |
5716 | 5716 | $result = $this->getDatabase()->select('name, plugincode, properties', $this->getFullTableName("site_plugins"), "name='{$pluginName}' AND disabled=0"); |
5717 | 5717 | if ($row = $this->getDatabase()->getRow($result)) { |
5718 | 5718 | $pluginCode = $this->pluginCache[$row['name']] = $row['plugincode']; |
5719 | - $pluginProperties = $this->pluginCache[$row['name'] . "Props"] = $row['properties']; |
|
5719 | + $pluginProperties = $this->pluginCache[$row['name']."Props"] = $row['properties']; |
|
5720 | 5720 | } else { |
5721 | 5721 | $pluginCode = $this->pluginCache[$pluginName] = "return false;"; |
5722 | 5722 | $pluginProperties = ''; |
@@ -5740,7 +5740,7 @@ discard block |
||
5740 | 5740 | { |
5741 | 5741 | $property = array(); |
5742 | 5742 | |
5743 | - if(\is_scalar($propertyString)) { |
|
5743 | + if (\is_scalar($propertyString)) { |
|
5744 | 5744 | $propertyString = trim($propertyString); |
5745 | 5745 | $propertyString = str_replace('{}', '', $propertyString); |
5746 | 5746 | $propertyString = str_replace('} {', ',', $propertyString); |
@@ -5794,7 +5794,7 @@ discard block |
||
5794 | 5794 | } |
5795 | 5795 | } |
5796 | 5796 | } |
5797 | - elseif(\is_array($propertyString)) { |
|
5797 | + elseif (\is_array($propertyString)) { |
|
5798 | 5798 | $property = $propertyString; |
5799 | 5799 | } |
5800 | 5800 | if (!empty($elementName) && !empty($elementType)) { |
@@ -5825,7 +5825,7 @@ discard block |
||
5825 | 5825 | public function parseDocBlockFromFile($element_dir, $filename, $escapeValues = false) |
5826 | 5826 | { |
5827 | 5827 | $params = array(); |
5828 | - $fullpath = $element_dir . '/' . $filename; |
|
5828 | + $fullpath = $element_dir.'/'.$filename; |
|
5829 | 5829 | if (is_readable($fullpath)) { |
5830 | 5830 | $tpl = @fopen($fullpath, "r"); |
5831 | 5831 | if ($tpl) { |
@@ -5992,8 +5992,8 @@ discard block |
||
5992 | 5992 | $ph = array('site_url' => MODX_SITE_URL); |
5993 | 5993 | $regexUrl = "/((http|https|ftp|ftps)\:\/\/[^\/]+(\/[^\s]+[^,.?!:;\s])?)/"; |
5994 | 5994 | $regexEmail = '#([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)#i'; |
5995 | - $emailSubject = isset($parsed['name']) ? '?subject=' . $parsed['name'] : ''; |
|
5996 | - $emailSubject .= isset($parsed['version']) ? ' v' . $parsed['version'] : ''; |
|
5995 | + $emailSubject = isset($parsed['name']) ? '?subject='.$parsed['name'] : ''; |
|
5996 | + $emailSubject .= isset($parsed['version']) ? ' v'.$parsed['version'] : ''; |
|
5997 | 5997 | foreach ($parsed as $key => $val) { |
5998 | 5998 | if (is_array($val)) { |
5999 | 5999 | foreach ($val as $key2 => $val2) { |
@@ -6002,7 +6002,7 @@ discard block |
||
6002 | 6002 | $val2 = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val2); |
6003 | 6003 | } |
6004 | 6004 | if (preg_match($regexEmail, $val2, $url)) { |
6005 | - $val2 = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val2); |
|
6005 | + $val2 = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val2); |
|
6006 | 6006 | } |
6007 | 6007 | $parsed[$key][$key2] = $val2; |
6008 | 6008 | } |
@@ -6012,7 +6012,7 @@ discard block |
||
6012 | 6012 | $val = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val); |
6013 | 6013 | } |
6014 | 6014 | if (preg_match($regexEmail, $val, $url)) { |
6015 | - $val = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val); |
|
6015 | + $val = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val); |
|
6016 | 6016 | } |
6017 | 6017 | $parsed[$key] = $val; |
6018 | 6018 | } |
@@ -6026,32 +6026,32 @@ discard block |
||
6026 | 6026 | ); |
6027 | 6027 | |
6028 | 6028 | $nl = "\n"; |
6029 | - $list = isset($parsed['logo']) ? '<img src="' . $this->config['base_url'] . ltrim($parsed['logo'], "/") . '" style="float:right;max-width:100px;height:auto;" />' . $nl : ''; |
|
6030 | - $list .= '<p>' . $nl; |
|
6031 | - $list .= isset($parsed['name']) ? '<strong>' . $parsed['name'] . '</strong><br/>' . $nl : ''; |
|
6032 | - $list .= isset($parsed['description']) ? $parsed['description'] . $nl : ''; |
|
6033 | - $list .= '</p><br/>' . $nl; |
|
6034 | - $list .= isset($parsed['version']) ? '<p><strong>' . $_lang['version'] . ':</strong> ' . $parsed['version'] . '</p>' . $nl : ''; |
|
6035 | - $list .= isset($parsed['license']) ? '<p><strong>' . $_lang['license'] . ':</strong> ' . $parsed['license'] . '</p>' . $nl : ''; |
|
6036 | - $list .= isset($parsed['lastupdate']) ? '<p><strong>' . $_lang['last_update'] . ':</strong> ' . $parsed['lastupdate'] . '</p>' . $nl : ''; |
|
6037 | - $list .= '<br/>' . $nl; |
|
6029 | + $list = isset($parsed['logo']) ? '<img src="'.$this->config['base_url'].ltrim($parsed['logo'], "/").'" style="float:right;max-width:100px;height:auto;" />'.$nl : ''; |
|
6030 | + $list .= '<p>'.$nl; |
|
6031 | + $list .= isset($parsed['name']) ? '<strong>'.$parsed['name'].'</strong><br/>'.$nl : ''; |
|
6032 | + $list .= isset($parsed['description']) ? $parsed['description'].$nl : ''; |
|
6033 | + $list .= '</p><br/>'.$nl; |
|
6034 | + $list .= isset($parsed['version']) ? '<p><strong>'.$_lang['version'].':</strong> '.$parsed['version'].'</p>'.$nl : ''; |
|
6035 | + $list .= isset($parsed['license']) ? '<p><strong>'.$_lang['license'].':</strong> '.$parsed['license'].'</p>'.$nl : ''; |
|
6036 | + $list .= isset($parsed['lastupdate']) ? '<p><strong>'.$_lang['last_update'].':</strong> '.$parsed['lastupdate'].'</p>'.$nl : ''; |
|
6037 | + $list .= '<br/>'.$nl; |
|
6038 | 6038 | $first = true; |
6039 | 6039 | foreach ($arrayParams as $param => $label) { |
6040 | 6040 | if (isset($parsed[$param])) { |
6041 | 6041 | if ($first) { |
6042 | - $list .= '<p><strong>' . $_lang['references'] . '</strong></p>' . $nl; |
|
6043 | - $list .= '<ul class="docBlockList">' . $nl; |
|
6042 | + $list .= '<p><strong>'.$_lang['references'].'</strong></p>'.$nl; |
|
6043 | + $list .= '<ul class="docBlockList">'.$nl; |
|
6044 | 6044 | $first = false; |
6045 | 6045 | } |
6046 | - $list .= ' <li><strong>' . $label . '</strong>' . $nl; |
|
6047 | - $list .= ' <ul>' . $nl; |
|
6046 | + $list .= ' <li><strong>'.$label.'</strong>'.$nl; |
|
6047 | + $list .= ' <ul>'.$nl; |
|
6048 | 6048 | foreach ($parsed[$param] as $val) { |
6049 | - $list .= ' <li>' . $val . '</li>' . $nl; |
|
6049 | + $list .= ' <li>'.$val.'</li>'.$nl; |
|
6050 | 6050 | } |
6051 | - $list .= ' </ul></li>' . $nl; |
|
6051 | + $list .= ' </ul></li>'.$nl; |
|
6052 | 6052 | } |
6053 | 6053 | } |
6054 | - $list .= !$first ? '</ul>' . $nl : ''; |
|
6054 | + $list .= !$first ? '</ul>'.$nl : ''; |
|
6055 | 6055 | |
6056 | 6056 | return $list; |
6057 | 6057 | } |
@@ -6126,8 +6126,8 @@ discard block |
||
6126 | 6126 | */ |
6127 | 6127 | public function addSnippet($name, $phpCode, $namespace = '#', array $defaultParams = array()) |
6128 | 6128 | { |
6129 | - $this->snippetCache[$namespace . $name] = $phpCode; |
|
6130 | - $this->snippetCache[$namespace . $name . 'Props'] = $defaultParams; |
|
6129 | + $this->snippetCache[$namespace.$name] = $phpCode; |
|
6130 | + $this->snippetCache[$namespace.$name.'Props'] = $defaultParams; |
|
6131 | 6131 | } |
6132 | 6132 | |
6133 | 6133 | /** |
@@ -6135,7 +6135,7 @@ discard block |
||
6135 | 6135 | */ |
6136 | 6136 | public function addChunk($name, $text, $namespace = '#') |
6137 | 6137 | { |
6138 | - $this->chunkCache[$namespace . $name] = $text; |
|
6138 | + $this->chunkCache[$namespace.$name] = $text; |
|
6139 | 6139 | } |
6140 | 6140 | |
6141 | 6141 | /** |
@@ -6145,7 +6145,7 @@ discard block |
||
6145 | 6145 | { |
6146 | 6146 | $out = array(); |
6147 | 6147 | |
6148 | - if (! is_dir($scanPath) || empty($ext)) { |
|
6148 | + if (!is_dir($scanPath) || empty($ext)) { |
|
6149 | 6149 | return $out; |
6150 | 6150 | } |
6151 | 6151 | $iterator = new \RecursiveIteratorIterator( |
@@ -6157,22 +6157,22 @@ discard block |
||
6157 | 6157 | * @var \SplFileInfo $item |
6158 | 6158 | */ |
6159 | 6159 | if ($item->isFile() && $item->isReadable() && \in_array($item->getExtension(), $ext)) { |
6160 | - $name = $item->getBasename('.' . $item->getExtension()); |
|
6160 | + $name = $item->getBasename('.'.$item->getExtension()); |
|
6161 | 6161 | $path = ltrim(str_replace( |
6162 | 6162 | array(rtrim($scanPath, '//'), '/'), |
6163 | 6163 | array('', '\\'), |
6164 | - $item->getPath() . '/' |
|
6164 | + $item->getPath().'/' |
|
6165 | 6165 | ), '\\'); |
6166 | 6166 | |
6167 | 6167 | if (!empty($path)) { |
6168 | - $name = $path . $name; |
|
6168 | + $name = $path.$name; |
|
6169 | 6169 | } |
6170 | 6170 | switch ($type) { |
6171 | 6171 | case 'chunk': |
6172 | 6172 | $out[$name] = file_get_contents($item->getRealPath()); |
6173 | 6173 | break; |
6174 | 6174 | case 'snippet': |
6175 | - $out[$name] = "return require '" . $item->getRealPath() . "';"; |
|
6175 | + $out[$name] = "return require '".$item->getRealPath()."';"; |
|
6176 | 6176 | break; |
6177 | 6177 | default: |
6178 | 6178 | throw new \Exception; |
@@ -6216,7 +6216,7 @@ discard block |
||
6216 | 6216 | } |
6217 | 6217 | |
6218 | 6218 | if (!$isSafe) { |
6219 | - $msg = $phpcode . "\n" . $this->currentSnippet . "\n" . print_r($_SERVER, true); |
|
6219 | + $msg = $phpcode."\n".$this->currentSnippet."\n".print_r($_SERVER, true); |
|
6220 | 6220 | $title = sprintf('Unknown eval was executed (%s)', $this->getPhpCompat()->htmlspecialchars(substr(trim($phpcode), 0, 50))); |
6221 | 6221 | $this->messageQuit($title, '', true, '', '', 'Parser', $msg); |
6222 | 6222 | return; |
@@ -6230,7 +6230,7 @@ discard block |
||
6230 | 6230 | return 'array()'; |
6231 | 6231 | } |
6232 | 6232 | |
6233 | - $output = $echo . $return; |
|
6233 | + $output = $echo.$return; |
|
6234 | 6234 | modx_sanitize_gpc($output); |
6235 | 6235 | return $this->getPhpCompat()->htmlspecialchars($output); // Maybe, all html tags are dangerous |
6236 | 6236 | } |
@@ -6248,8 +6248,8 @@ discard block |
||
6248 | 6248 | |
6249 | 6249 | $safe = explode(',', $safe_functions); |
6250 | 6250 | |
6251 | - $phpcode = rtrim($phpcode, ';') . ';'; |
|
6252 | - $tokens = token_get_all('<?php ' . $phpcode); |
|
6251 | + $phpcode = rtrim($phpcode, ';').';'; |
|
6252 | + $tokens = token_get_all('<?php '.$phpcode); |
|
6253 | 6253 | foreach ($tokens as $i => $token) { |
6254 | 6254 | if (!is_array($token)) { |
6255 | 6255 | continue; |
@@ -6285,7 +6285,7 @@ discard block |
||
6285 | 6285 | public function atBindFileContent($str = '') |
6286 | 6286 | { |
6287 | 6287 | |
6288 | - $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'] . 'files/', ''); |
|
6288 | + $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'].'files/', ''); |
|
6289 | 6289 | |
6290 | 6290 | if (stripos($str, '@FILE') !== 0) { |
6291 | 6291 | return $str; |
@@ -6308,7 +6308,7 @@ discard block |
||
6308 | 6308 | $errorMsg = sprintf("Could not retrieve string '%s'.", $str); |
6309 | 6309 | |
6310 | 6310 | foreach ($search_path as $path) { |
6311 | - $file_path = MODX_BASE_PATH . $path . $str; |
|
6311 | + $file_path = MODX_BASE_PATH.$path.$str; |
|
6312 | 6312 | if (strpos($file_path, MODX_MANAGER_PATH) === 0) { |
6313 | 6313 | return $errorMsg; |
6314 | 6314 | } elseif (is_file($file_path)) { |
@@ -6322,7 +6322,7 @@ discard block |
||
6322 | 6322 | return $errorMsg; |
6323 | 6323 | } |
6324 | 6324 | |
6325 | - $content = (string)file_get_contents($file_path); |
|
6325 | + $content = (string) file_get_contents($file_path); |
|
6326 | 6326 | if ($content === false) { |
6327 | 6327 | return $errorMsg; |
6328 | 6328 | } |
@@ -6431,22 +6431,22 @@ discard block |
||
6431 | 6431 | |
6432 | 6432 | $version = isset ($GLOBALS['modx_version']) ? $GLOBALS['modx_version'] : ''; |
6433 | 6433 | $release_date = isset ($GLOBALS['release_date']) ? $GLOBALS['release_date'] : ''; |
6434 | - $request_uri = "http://" . $_SERVER['HTTP_HOST'] . ($_SERVER["SERVER_PORT"] == 80 ? "" : (":" . $_SERVER["SERVER_PORT"])) . $_SERVER['REQUEST_URI']; |
|
6434 | + $request_uri = "http://".$_SERVER['HTTP_HOST'].($_SERVER["SERVER_PORT"] == 80 ? "" : (":".$_SERVER["SERVER_PORT"])).$_SERVER['REQUEST_URI']; |
|
6435 | 6435 | $request_uri = $this->getPhpCompat()->htmlspecialchars($request_uri, ENT_QUOTES, $this->config['modx_charset']); |
6436 | 6436 | $ua = $this->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $this->config['modx_charset']); |
6437 | 6437 | $referer = $this->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES, $this->config['modx_charset']); |
6438 | 6438 | if ($is_error) { |
6439 | 6439 | $str = '<h2 style="color:red">« Evo Parse Error »</h2>'; |
6440 | 6440 | if ($msg != 'PHP Parse Error') { |
6441 | - $str .= '<h3 style="color:red">' . $msg . '</h3>'; |
|
6441 | + $str .= '<h3 style="color:red">'.$msg.'</h3>'; |
|
6442 | 6442 | } |
6443 | 6443 | } else { |
6444 | 6444 | $str = '<h2 style="color:#003399">« Evo Debug/ stop message »</h2>'; |
6445 | - $str .= '<h3 style="color:#003399">' . $msg . '</h3>'; |
|
6445 | + $str .= '<h3 style="color:#003399">'.$msg.'</h3>'; |
|
6446 | 6446 | } |
6447 | 6447 | |
6448 | 6448 | if (!empty ($query)) { |
6449 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL > <span id="sqlHolder">' . $query . '</span></div>'; |
|
6449 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL > <span id="sqlHolder">'.$query.'</span></div>'; |
|
6450 | 6450 | } |
6451 | 6451 | |
6452 | 6452 | $errortype = array( |
@@ -6469,13 +6469,13 @@ discard block |
||
6469 | 6469 | |
6470 | 6470 | if (!empty($nr) || !empty($file)) { |
6471 | 6471 | if ($text != '') { |
6472 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : ' . $text . '</div>'; |
|
6472 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : '.$text.'</div>'; |
|
6473 | 6473 | } |
6474 | 6474 | if ($output != '') { |
6475 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">' . $output . '</div>'; |
|
6475 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">'.$output.'</div>'; |
|
6476 | 6476 | } |
6477 | 6477 | if ($nr !== '') { |
6478 | - $table[] = array('ErrorType[num]', $errortype [$nr] . "[" . $nr . "]"); |
|
6478 | + $table[] = array('ErrorType[num]', $errortype [$nr]."[".$nr."]"); |
|
6479 | 6479 | } |
6480 | 6480 | if ($file) { |
6481 | 6481 | $table[] = array('File', $file); |
@@ -6495,7 +6495,7 @@ discard block |
||
6495 | 6495 | } |
6496 | 6496 | |
6497 | 6497 | if (!empty($this->event->activePlugin)) { |
6498 | - $table[] = array('Current Plugin', $this->event->activePlugin . '(' . $this->event->name . ')'); |
|
6498 | + $table[] = array('Current Plugin', $this->event->activePlugin.'('.$this->event->name.')'); |
|
6499 | 6499 | } |
6500 | 6500 | |
6501 | 6501 | $str .= $MakeTable->create($table, array('Error information', '')); |
@@ -6505,17 +6505,17 @@ discard block |
||
6505 | 6505 | $table[] = array('REQUEST_URI', $request_uri); |
6506 | 6506 | |
6507 | 6507 | if ($this->getManagerApi()->action) { |
6508 | - include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
|
6508 | + include_once(MODX_MANAGER_PATH.'includes/actionlist.inc.php'); |
|
6509 | 6509 | global $action_list; |
6510 | 6510 | $actionName = (isset($action_list[$this->getManagerApi()->action])) ? " - {$action_list[$this->getManagerApi()->action]}" : ''; |
6511 | 6511 | |
6512 | - $table[] = array('Manager action', $this->getManagerApi()->action . $actionName); |
|
6512 | + $table[] = array('Manager action', $this->getManagerApi()->action.$actionName); |
|
6513 | 6513 | } |
6514 | 6514 | |
6515 | 6515 | if (preg_match('@^[0-9]+@', $this->documentIdentifier)) { |
6516 | 6516 | $resource = $this->getDocumentObject('id', $this->documentIdentifier); |
6517 | 6517 | $url = $this->makeUrl($this->documentIdentifier, '', '', 'full'); |
6518 | - $table[] = array('Resource', '[' . $this->documentIdentifier . '] <a href="' . $url . '" target="_blank">' . $resource['pagetitle'] . '</a>'); |
|
6518 | + $table[] = array('Resource', '['.$this->documentIdentifier.'] <a href="'.$url.'" target="_blank">'.$resource['pagetitle'].'</a>'); |
|
6519 | 6519 | } |
6520 | 6520 | $table[] = array('Referer', $referer); |
6521 | 6521 | $table[] = array('User Agent', $ua); |
@@ -6536,7 +6536,7 @@ discard block |
||
6536 | 6536 | |
6537 | 6537 | $mem = memory_get_peak_usage(true); |
6538 | 6538 | $total_mem = $mem - $this->mstart; |
6539 | - $total_mem = ($total_mem / 1024 / 1024) . ' mb'; |
|
6539 | + $total_mem = ($total_mem / 1024 / 1024).' mb'; |
|
6540 | 6540 | |
6541 | 6541 | $queryTime = $this->queryTime; |
6542 | 6542 | $phpTime = $totalTime - $queryTime; |
@@ -6557,18 +6557,18 @@ discard block |
||
6557 | 6557 | $str .= $this->get_backtrace(debug_backtrace()); |
6558 | 6558 | // Log error |
6559 | 6559 | if (!empty($this->currentSnippet)) { |
6560 | - $source = 'Snippet - ' . $this->currentSnippet; |
|
6560 | + $source = 'Snippet - '.$this->currentSnippet; |
|
6561 | 6561 | } elseif (!empty($this->event->activePlugin)) { |
6562 | - $source = 'Plugin - ' . $this->event->activePlugin; |
|
6562 | + $source = 'Plugin - '.$this->event->activePlugin; |
|
6563 | 6563 | } elseif ($source !== '') { |
6564 | - $source = 'Parser - ' . $source; |
|
6564 | + $source = 'Parser - '.$source; |
|
6565 | 6565 | } elseif ($query !== '') { |
6566 | 6566 | $source = 'SQL Query'; |
6567 | 6567 | } else { |
6568 | 6568 | $source = 'Parser'; |
6569 | 6569 | } |
6570 | 6570 | if ($msg) { |
6571 | - $source .= ' / ' . $msg; |
|
6571 | + $source .= ' / '.$msg; |
|
6572 | 6572 | } |
6573 | 6573 | if (isset($actionName) && !empty($actionName)) { |
6574 | 6574 | $source .= $actionName; |
@@ -6600,12 +6600,12 @@ discard block |
||
6600 | 6600 | |
6601 | 6601 | // Display error |
6602 | 6602 | if (isset($_SESSION['mgrValidated'])) { |
6603 | - echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager ' . $version . ' » ' . $release_date . '</title> |
|
6603 | + echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager '.$version.' » '.$release_date.'</title> |
|
6604 | 6604 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
6605 | - <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'] . 'media/style/' . $this->config['manager_theme'] . '/style.css" /> |
|
6605 | + <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'].'media/style/'.$this->config['manager_theme'].'/style.css" /> |
|
6606 | 6606 | <style type="text/css">body { padding:10px; } td {font:inherit;}</style> |
6607 | 6607 | </head><body> |
6608 | - ' . $str . '</body></html>'; |
|
6608 | + ' . $str.'</body></html>'; |
|
6609 | 6609 | |
6610 | 6610 | } else { |
6611 | 6611 | echo 'Error'; |
@@ -6640,7 +6640,7 @@ discard block |
||
6640 | 6640 | switch ($val['type']) { |
6641 | 6641 | case '->': |
6642 | 6642 | case '::': |
6643 | - $functionName = $val['function'] = $val['class'] . $val['type'] . $val['function']; |
|
6643 | + $functionName = $val['function'] = $val['class'].$val['type'].$val['function']; |
|
6644 | 6644 | break; |
6645 | 6645 | default: |
6646 | 6646 | $functionName = $val['function']; |
@@ -6650,7 +6650,7 @@ discard block |
||
6650 | 6650 | $args = array_pad(array(), $_, '$var'); |
6651 | 6651 | $args = implode(", ", $args); |
6652 | 6652 | $modx = &$this; |
6653 | - $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { |
|
6653 | + $args = preg_replace_callback('/\$var/', function() use ($modx, &$tmp, $val) { |
|
6654 | 6654 | $arg = $val['args'][$tmp - 1]; |
6655 | 6655 | switch (true) { |
6656 | 6656 | case is_null($arg): { |
@@ -6662,7 +6662,7 @@ discard block |
||
6662 | 6662 | break; |
6663 | 6663 | } |
6664 | 6664 | case is_scalar($arg): { |
6665 | - $out = strlen($arg) > 20 ? 'string $var' . $tmp : ("'" . $this->getPhpCompat()->htmlspecialchars(str_replace("'", "\\'", $arg)) . "'"); |
|
6665 | + $out = strlen($arg) > 20 ? 'string $var'.$tmp : ("'".$this->getPhpCompat()->htmlspecialchars(str_replace("'", "\\'", $arg))."'"); |
|
6666 | 6666 | break; |
6667 | 6667 | } |
6668 | 6668 | case is_bool($arg): { |
@@ -6670,23 +6670,23 @@ discard block |
||
6670 | 6670 | break; |
6671 | 6671 | } |
6672 | 6672 | case is_array($arg): { |
6673 | - $out = 'array $var' . $tmp; |
|
6673 | + $out = 'array $var'.$tmp; |
|
6674 | 6674 | break; |
6675 | 6675 | } |
6676 | 6676 | case is_object($arg): { |
6677 | - $out = get_class($arg) . ' $var' . $tmp; |
|
6677 | + $out = get_class($arg).' $var'.$tmp; |
|
6678 | 6678 | break; |
6679 | 6679 | } |
6680 | 6680 | default: { |
6681 | - $out = '$var' . $tmp; |
|
6681 | + $out = '$var'.$tmp; |
|
6682 | 6682 | } |
6683 | 6683 | } |
6684 | 6684 | $tmp++; |
6685 | 6685 | return $out; |
6686 | 6686 | }, $args); |
6687 | 6687 | $line = array( |
6688 | - "<strong>" . $functionName . "</strong>(" . $args . ")", |
|
6689 | - $path . " on line " . $val['line'] |
|
6688 | + "<strong>".$functionName."</strong>(".$args.")", |
|
6689 | + $path." on line ".$val['line'] |
|
6690 | 6690 | ); |
6691 | 6691 | $table[] = array(implode("<br />", $line)); |
6692 | 6692 | } |
@@ -6727,7 +6727,7 @@ discard block |
||
6727 | 6727 | $alias = strip_tags($alias); // strip HTML |
6728 | 6728 | $alias = preg_replace('/[^\.A-Za-z0-9 _-]/', '', $alias); // strip non-alphanumeric characters |
6729 | 6729 | $alias = preg_replace('/\s+/', '-', $alias); // convert white-space to dash |
6730 | - $alias = preg_replace('/-+/', '-', $alias); // convert multiple dashes to one |
|
6730 | + $alias = preg_replace('/-+/', '-', $alias); // convert multiple dashes to one |
|
6731 | 6731 | $alias = trim($alias, '-'); // trim excess |
6732 | 6732 | return $alias; |
6733 | 6733 | } |
@@ -6743,7 +6743,7 @@ discard block |
||
6743 | 6743 | $precisions = count($sizes) - 1; |
6744 | 6744 | foreach ($sizes as $unit => $bytes) { |
6745 | 6745 | if ($size >= $bytes) { |
6746 | - return number_format($size / $bytes, $precisions) . ' ' . $unit; |
|
6746 | + return number_format($size / $bytes, $precisions).' '.$unit; |
|
6747 | 6747 | } |
6748 | 6748 | $precisions--; |
6749 | 6749 | } |
@@ -6847,10 +6847,10 @@ discard block |
||
6847 | 6847 | |
6848 | 6848 | if (strpos($str, MODX_MANAGER_PATH) === 0) { |
6849 | 6849 | return false; |
6850 | - } elseif (is_file(MODX_BASE_PATH . $str)) { |
|
6851 | - $file_path = MODX_BASE_PATH . $str; |
|
6852 | - } elseif (is_file(MODX_BASE_PATH . "{$tpl_dir}{$str}")) { |
|
6853 | - $file_path = MODX_BASE_PATH . $tpl_dir . $str; |
|
6850 | + } elseif (is_file(MODX_BASE_PATH.$str)) { |
|
6851 | + $file_path = MODX_BASE_PATH.$str; |
|
6852 | + } elseif (is_file(MODX_BASE_PATH."{$tpl_dir}{$str}")) { |
|
6853 | + $file_path = MODX_BASE_PATH.$tpl_dir.$str; |
|
6854 | 6854 | } else { |
6855 | 6855 | return false; |
6856 | 6856 | } |
@@ -6974,7 +6974,7 @@ discard block |
||
6974 | 6974 | $title = 'no title'; |
6975 | 6975 | } |
6976 | 6976 | if (is_array($msg)) { |
6977 | - $msg = '<pre>' . print_r($msg, true) . '</pre>'; |
|
6977 | + $msg = '<pre>'.print_r($msg, true).'</pre>'; |
|
6978 | 6978 | } elseif ($msg === '') { |
6979 | 6979 | $msg = $_SERVER['REQUEST_URI']; |
6980 | 6980 | } |
@@ -282,7 +282,8 @@ discard block |
||
282 | 282 | return $service; |
283 | 283 | } |
284 | 284 | |
285 | - private function checkServiceAlias($name){ |
|
285 | + private function checkServiceAlias($name) |
|
286 | + { |
|
286 | 287 | foreach ($this->providerAliases as $alias => $interface) { |
287 | 288 | if($name === $interface) { |
288 | 289 | return $alias; |
@@ -962,13 +963,15 @@ discard block |
||
962 | 963 | $this->virtualDir = ''; |
963 | 964 | } |
964 | 965 | |
965 | - if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */ |
|
966 | + if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { |
|
967 | +/* we got an ID returned, check to make sure it's not an alias */ |
|
966 | 968 | /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */ |
967 | 969 | if ($this->config['use_alias_path'] == 1) { |
968 | 970 | if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
969 | 971 | $this->documentMethod = 'id'; |
970 | 972 | return $q; |
971 | - } else { /* not a valid id in terms of virtualDir, treat as alias */ |
|
973 | + } else { |
|
974 | +/* not a valid id in terms of virtualDir, treat as alias */ |
|
972 | 975 | $this->documentMethod = 'alias'; |
973 | 976 | return $q; |
974 | 977 | } |
@@ -976,7 +979,8 @@ discard block |
||
976 | 979 | $this->documentMethod = 'id'; |
977 | 980 | return $q; |
978 | 981 | } |
979 | - } else { /* we didn't get an ID back, so instead we assume it's an alias */ |
|
982 | + } else { |
|
983 | +/* we didn't get an ID back, so instead we assume it's an alias */ |
|
980 | 984 | if ($this->config['friendly_alias_urls'] != 1) { |
981 | 985 | $q = $qOrig; |
982 | 986 | } |
@@ -1006,13 +1010,14 @@ discard block |
||
1006 | 1010 | * @param $id |
1007 | 1011 | * @return array|mixed|null|string |
1008 | 1012 | */ |
1009 | - public function makePageCacheKey($id){ |
|
1013 | + public function makePageCacheKey($id) |
|
1014 | + { |
|
1010 | 1015 | $hash = $id; |
1011 | 1016 | $tmp = null; |
1012 | 1017 | $params = array(); |
1013 | - if(!empty($this->systemCacheKey)){ |
|
1018 | + if(!empty($this->systemCacheKey)) { |
|
1014 | 1019 | $hash = $this->systemCacheKey; |
1015 | - }else { |
|
1020 | + } else { |
|
1016 | 1021 | if (!empty($_GET)) { |
1017 | 1022 | // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID. |
1018 | 1023 | $params = $_GET; |
@@ -1021,7 +1026,7 @@ discard block |
||
1021 | 1026 | } |
1022 | 1027 | } |
1023 | 1028 | $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params)); |
1024 | - if (is_array($evtOut) && count($evtOut) > 0){ |
|
1029 | + if (is_array($evtOut) && count($evtOut) > 0) { |
|
1025 | 1030 | $tmp = array_pop($evtOut); |
1026 | 1031 | } |
1027 | 1032 | return empty($tmp) ? $hash : $tmp; |
@@ -1348,7 +1353,8 @@ discard block |
||
1348 | 1353 | $where = "pub_date <= {$timeNow} AND pub_date!=0 AND published=0"; |
1349 | 1354 | $result_pub = $this->getDatabase()->select( 'id', '[+prefix+]site_content', $where); |
1350 | 1355 | $this->getDatabase()->update($field, '[+prefix+]site_content', $where); |
1351 | - if ($this->getDatabase()->getRecordCount($result_pub) >= 1) { //Event unPublished doc |
|
1356 | + if ($this->getDatabase()->getRecordCount($result_pub) >= 1) { |
|
1357 | +//Event unPublished doc |
|
1352 | 1358 | while ($row_pub = $this->getDatabase()->getRow($result_pub)) { |
1353 | 1359 | $this->invokeEvent("OnDocUnPublished", array( |
1354 | 1360 | "docid" => $row_pub['id'] |
@@ -1361,7 +1367,8 @@ discard block |
||
1361 | 1367 | $where = "unpub_date <= {$timeNow} AND unpub_date!=0 AND published=1"; |
1362 | 1368 | $result_unpub = $this->getDatabase()->select( 'id', '[+prefix+]site_content', $where); |
1363 | 1369 | $this->getDatabase()->update($field, '[+prefix+]site_content', $where); |
1364 | - if ($this->getDatabase()->getRecordCount($result_unpub) >= 1) { //Event unPublished doc |
|
1370 | + if ($this->getDatabase()->getRecordCount($result_unpub) >= 1) { |
|
1371 | +//Event unPublished doc |
|
1365 | 1372 | while ($row_unpub = $this->getDatabase()->getRow($result_unpub)) { |
1366 | 1373 | $this->invokeEvent("OnDocUnPublished", array( |
1367 | 1374 | "docid" => $row_unpub['id'] |
@@ -1448,10 +1455,18 @@ discard block |
||
1448 | 1455 | return array(); |
1449 | 1456 | } |
1450 | 1457 | $spacer = md5('<<<EVO>>>'); |
1451 | - if($left==='{{' && strpos($content,';}}')!==false) $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
1452 | - if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
1453 | - if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
1454 | - if($left==='[[' && strpos($content,']]]')!==false) $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
1458 | + if($left==='{{' && strpos($content,';}}')!==false) { |
|
1459 | + $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
1460 | + } |
|
1461 | + if($left==='{{' && strpos($content,'{{}}')!==false) { |
|
1462 | + $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
1463 | + } |
|
1464 | + if($left==='[[' && strpos($content,']]]]')!==false) { |
|
1465 | + $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
1466 | + } |
|
1467 | + if($left==='[[' && strpos($content,']]]')!==false) { |
|
1468 | + $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
1469 | + } |
|
1455 | 1470 | |
1456 | 1471 | $pos['<![CDATA['] = strpos($content, '<![CDATA['); |
1457 | 1472 | $pos[']]>'] = strpos($content, ']]>'); |
@@ -1504,7 +1519,8 @@ discard block |
||
1504 | 1519 | } |
1505 | 1520 | } |
1506 | 1521 | |
1507 | - if (!in_array($fetch, $tags)) { // Avoid double Matches |
|
1522 | + if (!in_array($fetch, $tags)) { |
|
1523 | +// Avoid double Matches |
|
1508 | 1524 | $tags[] = $fetch; // Fetch |
1509 | 1525 | }; |
1510 | 1526 | $fetch = ''; // and reset |
@@ -1522,7 +1538,9 @@ discard block |
||
1522 | 1538 | } |
1523 | 1539 | } |
1524 | 1540 | foreach($tags as $i=>$tag) { |
1525 | - if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag); |
|
1541 | + if(strpos($tag,$spacer)!==false) { |
|
1542 | + $tags[$i] = str_replace($spacer, '', $tag); |
|
1543 | + } |
|
1526 | 1544 | } |
1527 | 1545 | return $tags; |
1528 | 1546 | } |
@@ -1562,7 +1580,10 @@ discard block |
||
1562 | 1580 | } |
1563 | 1581 | |
1564 | 1582 | foreach ($matches[1] as $i => $key) { |
1565 | - if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
1583 | + if(strpos($key,'[+')!==false) { |
|
1584 | + continue; |
|
1585 | + } |
|
1586 | + // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
1566 | 1587 | if (substr($key, 0, 1) == '#') { |
1567 | 1588 | $key = substr($key, 1); |
1568 | 1589 | } // remove # for QuickEdit format |
@@ -2288,7 +2309,8 @@ discard block |
||
2288 | 2309 | * @return mixed|string |
2289 | 2310 | */ |
2290 | 2311 | public function _getSGVar($value) |
2291 | - { // Get super globals |
|
2312 | + { |
|
2313 | +// Get super globals |
|
2292 | 2314 | $key = $value; |
2293 | 2315 | $_ = $this->config['enable_filter']; |
2294 | 2316 | $this->config['enable_filter'] = 1; |
@@ -2693,7 +2715,8 @@ discard block |
||
2693 | 2715 | if ($this->config['friendly_urls'] == 1) { |
2694 | 2716 | $aliases = array(); |
2695 | 2717 | if (is_array($this->documentListing)) { |
2696 | - foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site! |
|
2718 | + foreach ($this->documentListing as $path => $docid) { |
|
2719 | +// This is big Loop on large site! |
|
2697 | 2720 | $aliases[$docid] = $path; |
2698 | 2721 | $isfolder[$docid] = $this->aliasListing[$docid]['isfolder']; |
2699 | 2722 | } |
@@ -2726,7 +2749,7 @@ discard block |
||
2726 | 2749 | $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0); |
2727 | 2750 | $pref = $this->config['friendly_url_prefix']; |
2728 | 2751 | $suff = $this->config['friendly_url_suffix']; |
2729 | - $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
2752 | + $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){ |
|
2730 | 2753 | global $modx; |
2731 | 2754 | $thealias = $aliases[$m[1]]; |
2732 | 2755 | $thefolder = $isfolder[$m[1]]; |
@@ -4509,7 +4532,8 @@ discard block |
||
4509 | 4532 | if (isset ($this->snippetCache[$snippetName])) { |
4510 | 4533 | $snippet = $this->snippetCache[$snippetName]; |
4511 | 4534 | $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; |
4512 | - } else { // not in cache so let's check the db |
|
4535 | + } else { |
|
4536 | +// not in cache so let's check the db |
|
4513 | 4537 | $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->getDatabase()->escape($snippetName) . "' AND ss.disabled=0;"; |
4514 | 4538 | $result = $this->getDatabase()->query($sql); |
4515 | 4539 | if ($this->getDatabase()->getRecordCount($result) == 1) { |
@@ -5010,7 +5034,7 @@ discard block |
||
5010 | 5034 | $result = $this->getDatabase()->makeArray($rs); |
5011 | 5035 | |
5012 | 5036 | // get default/built-in template variables |
5013 | - if(is_array($docRow)){ |
|
5037 | + if(is_array($docRow)) { |
|
5014 | 5038 | ksort($docRow); |
5015 | 5039 | |
5016 | 5040 | foreach ($docRow as $key => $value) { |
@@ -5485,12 +5509,16 @@ discard block |
||
5485 | 5509 | return ''; |
5486 | 5510 | } // nothing to register |
5487 | 5511 | if (!is_array($options)) { |
5488 | - if (is_bool($options)) // backward compatibility with old plaintext parameter |
|
5512 | + if (is_bool($options)) { |
|
5513 | + // backward compatibility with old plaintext parameter |
|
5489 | 5514 | { |
5490 | 5515 | $options = array('plaintext' => $options); |
5491 | - } elseif (is_string($options)) // Also allow script name as 2nd param |
|
5516 | + } |
|
5517 | + } elseif (is_string($options)) { |
|
5518 | + // Also allow script name as 2nd param |
|
5492 | 5519 | { |
5493 | 5520 | $options = array('name' => $options); |
5521 | + } |
|
5494 | 5522 | } else { |
5495 | 5523 | $options = array(); |
5496 | 5524 | } |
@@ -5502,7 +5530,8 @@ discard block |
||
5502 | 5530 | unset($overwritepos); // probably unnecessary--just making sure |
5503 | 5531 | |
5504 | 5532 | $useThisVer = true; |
5505 | - if (isset($this->loadedjscripts[$key])) { // a matching script was found |
|
5533 | + if (isset($this->loadedjscripts[$key])) { |
|
5534 | +// a matching script was found |
|
5506 | 5535 | // if existing script is a startup script, make sure the candidate is also a startup script |
5507 | 5536 | if ($this->loadedjscripts[$key]['startup']) { |
5508 | 5537 | $startup = true; |
@@ -5522,7 +5551,8 @@ discard block |
||
5522 | 5551 | // overwrite the old script (the position may be important for dependent scripts) |
5523 | 5552 | $overwritepos = $this->loadedjscripts[$key]['pos']; |
5524 | 5553 | } |
5525 | - } else { // Use the original version |
|
5554 | + } else { |
|
5555 | +// Use the original version |
|
5526 | 5556 | if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) { |
5527 | 5557 | // need to move the exisiting script to the head |
5528 | 5558 | $version = $this->loadedjscripts[$key][$version]; |
@@ -5647,7 +5677,8 @@ discard block |
||
5647 | 5677 | } |
5648 | 5678 | |
5649 | 5679 | $results = null; |
5650 | - foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop |
|
5680 | + foreach ($this->pluginEvent[$evtName] as $pluginName) { |
|
5681 | +// start for loop |
|
5651 | 5682 | if ($this->dumpPlugins) { |
5652 | 5683 | $eventtime = $this->getMicroTime(); |
5653 | 5684 | } |
@@ -5793,8 +5824,7 @@ discard block |
||
5793 | 5824 | } |
5794 | 5825 | } |
5795 | 5826 | } |
5796 | - } |
|
5797 | - elseif(\is_array($propertyString)) { |
|
5827 | + } elseif(\is_array($propertyString)) { |
|
5798 | 5828 | $property = $propertyString; |
5799 | 5829 | } |
5800 | 5830 | if (!empty($elementName) && !empty($elementType)) { |
@@ -6241,7 +6271,8 @@ discard block |
||
6241 | 6271 | * @return bool |
6242 | 6272 | */ |
6243 | 6273 | public function isSafeCode($phpcode = '', $safe_functions = '') |
6244 | - { // return true or false |
|
6274 | + { |
|
6275 | +// return true or false |
|
6245 | 6276 | if ($safe_functions == '') { |
6246 | 6277 | return false; |
6247 | 6278 | } |
@@ -6650,7 +6681,7 @@ discard block |
||
6650 | 6681 | $args = array_pad(array(), $_, '$var'); |
6651 | 6682 | $args = implode(", ", $args); |
6652 | 6683 | $modx = &$this; |
6653 | - $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { |
|
6684 | + $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){ |
|
6654 | 6685 | $arg = $val['args'][$tmp - 1]; |
6655 | 6686 | switch (true) { |
6656 | 6687 | case is_null($arg): { |
@@ -2593,11 +2593,11 @@ discard block |
||
2593 | 2593 | if (isset($this->snippetCache[$snip_name])) { |
2594 | 2594 | $snippetObject['name'] = $snip_name; |
2595 | 2595 | $snippetObject['content'] = $this->snippetCache[$snip_name]; |
2596 | - if (isset($this->snippetCache["{$snip_name}Props"])) { |
|
2597 | - if (!isset($this->snippetCache["{$snip_name}Props"])) { |
|
2598 | - $this->snippetCache["{$snip_name}Props"] = ''; |
|
2596 | + if (isset($this->snippetCache["{$snip_name}props"])) { |
|
2597 | + if (!isset($this->snippetCache["{$snip_name}props"])) { |
|
2598 | + $this->snippetCache["{$snip_name}props"] = ''; |
|
2599 | 2599 | } |
2600 | - $snippetObject['properties'] = $this->snippetCache["{$snip_name}Props"]; |
|
2600 | + $snippetObject['properties'] = $this->snippetCache["{$snip_name}props"]; |
|
2601 | 2601 | } |
2602 | 2602 | } elseif (substr($snip_name, 0, 1) === '@' && isset($this->pluginEvent[trim($snip_name, '@')])) { |
2603 | 2603 | $snippetObject['name'] = trim($snip_name, '@'); |
@@ -2622,7 +2622,7 @@ discard block |
||
2622 | 2622 | $snippetObject['content'] = $snip_content; |
2623 | 2623 | $snippetObject['properties'] = $snip_prop; |
2624 | 2624 | $this->snippetCache[$snip_name] = $snip_content; |
2625 | - $this->snippetCache["{$snip_name}Props"] = $snip_prop; |
|
2625 | + $this->snippetCache["{$snip_name}props"] = $snip_prop; |
|
2626 | 2626 | } |
2627 | 2627 | return $snippetObject; |
2628 | 2628 | } |
@@ -3933,7 +3933,7 @@ discard block |
||
3933 | 3933 | } |
3934 | 3934 | // build query |
3935 | 3935 | $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
3936 | - $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
|
3936 | + $result = $this->getDatabase()->select("distinct {$fields}", "{$tblsc} sc |
|
3937 | 3937 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
3938 | 3938 | $resourceArray = $this->getDatabase()->makeArray($result); |
3939 | 3939 | $this->tmpCache[__FUNCTION__][$cacheKey] = $resourceArray; |
@@ -3970,7 +3970,7 @@ discard block |
||
3970 | 3970 | } |
3971 | 3971 | // build query |
3972 | 3972 | $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
3973 | - $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
|
3973 | + $result = $this->getDatabase()->select("distinct {$fields}", "{$tblsc} sc |
|
3974 | 3974 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND sc.published=1 AND sc.deleted=0 AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
3975 | 3975 | $resourceArray = $this->getDatabase()->makeArray($result); |
3976 | 3976 | |
@@ -4026,7 +4026,7 @@ discard block |
||
4026 | 4026 | $tblsc = $this->getFullTableName('site_content'); |
4027 | 4027 | $tbldg = $this->getFullTableName('document_groups'); |
4028 | 4028 | |
4029 | - $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
|
4029 | + $result = $this->getDatabase()->select("distinct {$fields}", "{$tblsc} sc |
|
4030 | 4030 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$parentid}' {$published} {$deleted} {$where} AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit); |
4031 | 4031 | |
4032 | 4032 | $resourceArray = $this->getDatabase()->makeArray($result); |
@@ -4092,7 +4092,7 @@ discard block |
||
4092 | 4092 | $tblsc = $this->getFullTableName('site_content'); |
4093 | 4093 | $tbldg = $this->getFullTableName('document_groups'); |
4094 | 4094 | |
4095 | - $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
|
4095 | + $result = $this->getDatabase()->select("distinct {$fields}", "{$tblsc} sc |
|
4096 | 4096 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (" . implode(',', $ids) . ") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit); |
4097 | 4097 | |
4098 | 4098 | $resourceArray = $this->getDatabase()->makeArray($result); |
@@ -4679,7 +4679,7 @@ discard block |
||
4679 | 4679 | $template = $doc['content']; |
4680 | 4680 | break; |
4681 | 4681 | case 'SELECT': |
4682 | - $this->getDatabase()->getValue($this->getDatabase()->query("SELECT {$template}")); |
|
4682 | + $this->getDatabase()->getValue($this->getDatabase()->query("select {$template}")); |
|
4683 | 4683 | break; |
4684 | 4684 | default: |
4685 | 4685 | if (!($template = $this->getChunk($tpl))) { |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | /** |
373 | 373 | * @param $fields |
374 | - * @param $table |
|
374 | + * @param string $table |
|
375 | 375 | * @param string $where |
376 | 376 | * @return bool|mixed|mysqli_result |
377 | 377 | */ |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
519 | - * @param $name |
|
519 | + * @param string $name |
|
520 | 520 | * @param mysqli_result|string $dsq |
521 | 521 | * @return array |
522 | 522 | */ |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $pre = null, |
34 | 34 | $charset = '', |
35 | 35 | $connection_method = 'SET CHARACTER SET' |
36 | - ) { |
|
36 | + ){ |
|
37 | 37 | $this->config['host'] = $host ? $host : $GLOBALS['database_server']; |
38 | 38 | $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase']; |
39 | 39 | $this->config['user'] = $uid ? $uid : $GLOBALS['database_user']; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $ua = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_USER_AGENT']); |
74 | 74 | $referer = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_REFERER']); |
75 | 75 | $modx->sendmail(array( |
76 | - 'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'], |
|
76 | + 'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'], |
|
77 | 77 | 'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}", |
78 | 78 | 'type' => 'text' |
79 | 79 | )); |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | $tend = $modx->getMicroTime(); |
89 | 89 | $totaltime = $tend - $tstart; |
90 | 90 | if ($modx->dumpSQL) { |
91 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", |
|
92 | - $totaltime) . "</fieldset><br />"; |
|
91 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", |
|
92 | + $totaltime)."</fieldset><br />"; |
|
93 | 93 | } |
94 | 94 | $this->conn->set_charset($this->config['charset']); |
95 | 95 | $this->isConnected = true; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | if (1000 < $safeCount) { |
123 | 123 | exit("Too many loops '{$safeCount}'"); |
124 | 124 | } |
125 | - if ( ! ($this->conn instanceof mysqli)) { |
|
125 | + if (!($this->conn instanceof mysqli)) { |
|
126 | 126 | $this->connect(); |
127 | 127 | } |
128 | 128 | if (is_array($s)) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | public function query($sql, $watchError = true) |
149 | 149 | { |
150 | 150 | $modx = evolutionCMS(); |
151 | - if ( ! ($this->conn instanceof mysqli)) { |
|
151 | + if (!($this->conn instanceof mysqli)) { |
|
152 | 152 | $this->connect(); |
153 | 153 | } |
154 | 154 | $tStart = $modx->getMicroTime(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | case 1091: |
169 | 169 | break; |
170 | 170 | default: |
171 | - $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql); |
|
171 | + $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql); |
|
172 | 172 | } |
173 | 173 | } else { |
174 | 174 | $tend = $modx->getMicroTime(); |
@@ -182,24 +182,24 @@ discard block |
||
182 | 182 | $debug_path[] = $line['function']; |
183 | 183 | } |
184 | 184 | $debug_path = implode(' > ', array_reverse($debug_path)); |
185 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", |
|
186 | - $totalTime * 1000) . "</legend>"; |
|
187 | - $modx->queryCode .= $sql . '<br><br>'; |
|
185 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", |
|
186 | + $totalTime * 1000)."</legend>"; |
|
187 | + $modx->queryCode .= $sql.'<br><br>'; |
|
188 | 188 | if ($modx->event->name) { |
189 | - $modx->queryCode .= 'Current Event => ' . $modx->event->name . '<br>'; |
|
189 | + $modx->queryCode .= 'Current Event => '.$modx->event->name.'<br>'; |
|
190 | 190 | } |
191 | 191 | if ($modx->event->activePlugin) { |
192 | - $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>'; |
|
192 | + $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>'; |
|
193 | 193 | } |
194 | 194 | if ($modx->currentSnippet) { |
195 | - $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>'; |
|
195 | + $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>'; |
|
196 | 196 | } |
197 | 197 | if (stripos($sql, 'select') === 0) { |
198 | - $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>'; |
|
198 | + $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>'; |
|
199 | 199 | } else { |
200 | - $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>'; |
|
200 | + $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>'; |
|
201 | 201 | } |
202 | - $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>'; |
|
202 | + $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>'; |
|
203 | 203 | $modx->queryCode .= "</fieldset><br />"; |
204 | 204 | } |
205 | 205 | $modx->executedQueries++; |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | if ($value === null || strtolower($value) === 'null') { |
307 | 307 | $f = 'NULL'; |
308 | 308 | } else { |
309 | - $f = "'" . $value . "'"; |
|
309 | + $f = "'".$value."'"; |
|
310 | 310 | } |
311 | - $fields[$key] = "`{$key}` = " . $f; |
|
311 | + $fields[$key] = "`{$key}` = ".$f; |
|
312 | 312 | } |
313 | 313 | $fields = implode(',', $fields); |
314 | 314 | } |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | $this->query("INSERT INTO {$intotable} {$fields}"); |
344 | 344 | } else { |
345 | 345 | if (empty($fromtable)) { |
346 | - $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '", |
|
347 | - array_values($fields)) . "')"; |
|
346 | + $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '", |
|
347 | + array_values($fields))."')"; |
|
348 | 348 | $this->query("INSERT INTO {$intotable} {$fields}"); |
349 | 349 | } else { |
350 | 350 | $fromtable = $this->replaceFullTableName($fromtable); |
351 | - $fields = "(" . implode(",", array_keys($fields)) . ")"; |
|
351 | + $fields = "(".implode(",", array_keys($fields)).")"; |
|
352 | 352 | $where = trim($where); |
353 | 353 | $limit = trim($limit); |
354 | 354 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | */ |
443 | 443 | public function getInsertId($conn = null) |
444 | 444 | { |
445 | - if (! ($conn instanceof mysqli)) { |
|
446 | - $conn =& $this->conn; |
|
445 | + if (!($conn instanceof mysqli)) { |
|
446 | + $conn = & $this->conn; |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | return $conn->insert_id; |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | */ |
456 | 456 | public function getAffectedRows($conn = null) |
457 | 457 | { |
458 | - if (! ($conn instanceof mysqli)) { |
|
459 | - $conn =& $this->conn; |
|
458 | + if (!($conn instanceof mysqli)) { |
|
459 | + $conn = & $this->conn; |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | return $conn->affected_rows; |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | */ |
469 | 469 | public function getLastError($conn = null) |
470 | 470 | { |
471 | - if (! ($conn instanceof mysqli)) { |
|
472 | - $conn =& $this->conn; |
|
471 | + if (!($conn instanceof mysqli)) { |
|
472 | + $conn = & $this->conn; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | return $conn->error; |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | { |
494 | 494 | $out = false; |
495 | 495 | if ($ds instanceof mysqli_result) { |
496 | - switch($mode){ |
|
496 | + switch ($mode) { |
|
497 | 497 | case 'assoc': |
498 | 498 | $out = $ds->fetch_assoc(); |
499 | 499 | break; |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | public function getColumn($name, $dsq) |
524 | 524 | { |
525 | 525 | $col = array(); |
526 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
526 | + if (!($dsq instanceof mysqli_result)) { |
|
527 | 527 | $dsq = $this->query($dsq); |
528 | 528 | } |
529 | 529 | if ($dsq) { |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | public function getColumnNames($dsq) |
543 | 543 | { |
544 | 544 | $names = array(); |
545 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
545 | + if (!($dsq instanceof mysqli_result)) { |
|
546 | 546 | $dsq = $this->query($dsq); |
547 | 547 | } |
548 | 548 | if ($dsq) { |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | public function getValue($dsq) |
563 | 563 | { |
564 | 564 | $out = false; |
565 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
565 | + if (!($dsq instanceof mysqli_result)) { |
|
566 | 566 | $dsq = $this->query($dsq); |
567 | 567 | } |
568 | 568 | if ($dsq) { |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $tableName = trim($tableName); |
661 | 661 | $dbase = trim($this->config['dbase'], '`'); |
662 | 662 | $prefix = $this->config['table_prefix']; |
663 | - if ((bool)$force === true) { |
|
663 | + if ((bool) $force === true) { |
|
664 | 664 | $result = "`{$dbase}`.`{$prefix}{$tableName}`"; |
665 | 665 | } elseif (strpos($tableName, '[+prefix+]') !== false) { |
666 | 666 | $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName); |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Legacy; |
2 | 2 | |
3 | -use EvolutionCMS\Interfaces\ModifiersInterface; |
|
4 | 3 | use DataGrid; |
4 | +use EvolutionCMS\Interfaces\ModifiersInterface; |
|
5 | 5 | |
6 | 6 | class Modifiers implements ModifiersInterface{ |
7 | 7 | /** |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | * @param string $modifiers |
72 | 72 | * @return bool|mixed|string |
73 | 73 | */ |
74 | - public function phxFilter($key,$value,$modifiers) |
|
74 | + public function phxFilter($key, $value, $modifiers) |
|
75 | 75 | { |
76 | 76 | $modx = evolutionCMS(); |
77 | - if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value); |
|
77 | + if (substr($modifiers, 0, 3) !== 'id(') $value = $this->parseDocumentSource($value); |
|
78 | 78 | $this->srcValue = $value; |
79 | 79 | $modifiers = trim($modifiers); |
80 | - $modifiers = ':'.trim($modifiers,':'); |
|
81 | - $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers); |
|
80 | + $modifiers = ':'.trim($modifiers, ':'); |
|
81 | + $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers); |
|
82 | 82 | $modifiers = $this->splitEachModifiers($modifiers); |
83 | 83 | |
84 | 84 | $this->placeholders = array(); |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | $this->placeholders['dummy'] = ''; |
87 | 87 | $this->condition = array(); |
88 | 88 | $this->vars = array(); |
89 | - $this->vars['name'] = & $key; |
|
90 | - $value = $this->parsePhx($key,$value,$modifiers); |
|
89 | + $this->vars['name'] = & $key; |
|
90 | + $value = $this->parsePhx($key, $value, $modifiers); |
|
91 | 91 | $this->vars = array(); |
92 | 92 | return $value; |
93 | 93 | } |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | * @param string $modifiers |
98 | 98 | * @return bool|string |
99 | 99 | */ |
100 | - public function _getDelim($mode,$modifiers) { |
|
101 | - $c = substr($modifiers,0,1); |
|
102 | - if(!in_array($c, array('"', "'", '`')) ) return false; |
|
100 | + public function _getDelim($mode, $modifiers){ |
|
101 | + $c = substr($modifiers, 0, 1); |
|
102 | + if (!in_array($c, array('"', "'", '`'))) return false; |
|
103 | 103 | |
104 | - $modifiers = substr($modifiers,1); |
|
105 | - $closure = $mode=='(' ? "{$c})" : $c; |
|
106 | - if(strpos($modifiers, $closure)===false) return false; |
|
104 | + $modifiers = substr($modifiers, 1); |
|
105 | + $closure = $mode == '(' ? "{$c})" : $c; |
|
106 | + if (strpos($modifiers, $closure) === false) return false; |
|
107 | 107 | |
108 | 108 | return $c; |
109 | 109 | } |
@@ -114,101 +114,101 @@ discard block |
||
114 | 114 | * @param string $modifiers |
115 | 115 | * @return bool|string |
116 | 116 | */ |
117 | - public function _getOpt($mode,$delim,$modifiers) { |
|
118 | - if($delim) { |
|
119 | - if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
117 | + public function _getOpt($mode, $delim, $modifiers){ |
|
118 | + if ($delim) { |
|
119 | + if ($mode == '(') return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1); |
|
120 | 120 | |
121 | - return substr($modifiers,1,strpos($modifiers,$delim,1)-1); |
|
121 | + return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1); |
|
122 | 122 | } |
123 | 123 | else { |
124 | - if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') ); |
|
124 | + if ($mode == '(') return substr($modifiers, 0, strpos($modifiers, ')')); |
|
125 | 125 | |
126 | 126 | $chars = str_split($modifiers); |
127 | - $opt=''; |
|
128 | - foreach($chars as $c) { |
|
129 | - if($c==':' || $c==')') break; |
|
130 | - $opt .=$c; |
|
127 | + $opt = ''; |
|
128 | + foreach ($chars as $c) { |
|
129 | + if ($c == ':' || $c == ')') break; |
|
130 | + $opt .= $c; |
|
131 | 131 | } |
132 | 132 | return $opt; |
133 | 133 | } |
134 | 134 | } |
135 | - public function _getRemainModifiers($mode,$delim,$modifiers) { |
|
136 | - if($delim) { |
|
137 | - if($mode=='(') |
|
138 | - return $this->_fetchContent($modifiers, $delim . ')'); |
|
135 | + public function _getRemainModifiers($mode, $delim, $modifiers){ |
|
136 | + if ($delim) { |
|
137 | + if ($mode == '(') |
|
138 | + return $this->_fetchContent($modifiers, $delim.')'); |
|
139 | 139 | else { |
140 | 140 | $modifiers = trim($modifiers); |
141 | - $modifiers = substr($modifiers,1); |
|
141 | + $modifiers = substr($modifiers, 1); |
|
142 | 142 | return $this->_fetchContent($modifiers, $delim); |
143 | 143 | } |
144 | 144 | } |
145 | 145 | else { |
146 | - if($mode=='(') return $this->_fetchContent($modifiers, ')'); |
|
146 | + if ($mode == '(') return $this->_fetchContent($modifiers, ')'); |
|
147 | 147 | $chars = str_split($modifiers); |
148 | - foreach($chars as $c) { |
|
149 | - if($c==':') return $modifiers; |
|
150 | - else $modifiers = substr($modifiers,1); |
|
148 | + foreach ($chars as $c) { |
|
149 | + if ($c == ':') return $modifiers; |
|
150 | + else $modifiers = substr($modifiers, 1); |
|
151 | 151 | } |
152 | 152 | return $modifiers; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - public function _fetchContent($string,$delim) { |
|
156 | + public function _fetchContent($string, $delim){ |
|
157 | 157 | $len = strlen($delim); |
158 | 158 | $string = $this->parseDocumentSource($string); |
159 | - return substr($string,strpos($string, $delim)+$len); |
|
159 | + return substr($string, strpos($string, $delim) + $len); |
|
160 | 160 | } |
161 | 161 | |
162 | - public function splitEachModifiers($modifiers) { |
|
162 | + public function splitEachModifiers($modifiers){ |
|
163 | 163 | $modx = evolutionCMS(); |
164 | 164 | |
165 | 165 | $cmd = ''; |
166 | 166 | $bt = ''; |
167 | 167 | $result = array(); |
168 | - while($bt!==$modifiers) { |
|
168 | + while ($bt !== $modifiers) { |
|
169 | 169 | $bt = $modifiers; |
170 | - $c = substr($modifiers,0,1); |
|
171 | - $modifiers = substr($modifiers,1); |
|
170 | + $c = substr($modifiers, 0, 1); |
|
171 | + $modifiers = substr($modifiers, 1); |
|
172 | 172 | |
173 | - if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
174 | - $c = substr($modifiers,strlen($match[1]),1); |
|
173 | + if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
174 | + $c = substr($modifiers, strlen($match[1]), 1); |
|
175 | 175 | $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]"; |
176 | - if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1); |
|
177 | - else $modifiers = substr($modifiers,strlen($match[1])); |
|
176 | + if ($c === '(') $modifiers = substr($modifiers, strlen($match[1]) + 1); |
|
177 | + else $modifiers = substr($modifiers, strlen($match[1])); |
|
178 | 178 | |
179 | - $delim = $this->_getDelim($c,$modifiers); |
|
180 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
181 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
179 | + $delim = $this->_getDelim($c, $modifiers); |
|
180 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
181 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
182 | 182 | |
183 | - $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
183 | + $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
184 | 184 | $cmd = ''; |
185 | 185 | } |
186 | - elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
187 | - $modifiers = substr($modifiers,strlen($match[0])); |
|
188 | - $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]); |
|
186 | + elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
187 | + $modifiers = substr($modifiers, strlen($match[0])); |
|
188 | + $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]); |
|
189 | 189 | $cmd = ''; |
190 | 190 | } |
191 | - elseif($c==='(' || $c==='=') { |
|
191 | + elseif ($c === '(' || $c === '=') { |
|
192 | 192 | $modifiers = $m1 = trim($modifiers); |
193 | - $delim = $this->_getDelim($c,$modifiers); |
|
194 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
195 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
193 | + $delim = $this->_getDelim($c, $modifiers); |
|
194 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
195 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
196 | 196 | $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]"; |
197 | 197 | |
198 | - $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
198 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
199 | 199 | |
200 | 200 | $cmd = ''; |
201 | 201 | } |
202 | - elseif($c==':') { |
|
202 | + elseif ($c == ':') { |
|
203 | 203 | $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]"; |
204 | - if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
204 | + if ($cmd !== '') $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
205 | 205 | |
206 | 206 | $cmd = ''; |
207 | 207 | } |
208 | - elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
208 | + elseif (trim($modifiers) == '' && trim($cmd) !== '') { |
|
209 | 209 | $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]"; |
210 | 210 | $cmd .= $c; |
211 | - $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
211 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
212 | 212 | |
213 | 213 | break; |
214 | 214 | } |
@@ -217,65 +217,65 @@ discard block |
||
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - if(empty($result)) return array(); |
|
220 | + if (empty($result)) return array(); |
|
221 | 221 | |
222 | - foreach($result as $i=>$a) |
|
222 | + foreach ($result as $i=>$a) |
|
223 | 223 | { |
224 | 224 | $a['opt'] = $this->parseDocumentSource($a['opt']); |
225 | - $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders); |
|
225 | + $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'], $this->placeholders); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return $result; |
229 | 229 | } |
230 | 230 | |
231 | - public function parsePhx($key,$value,$modifiers) |
|
231 | + public function parsePhx($key, $value, $modifiers) |
|
232 | 232 | { |
233 | 233 | $modx = evolutionCMS(); |
234 | 234 | $lastKey = ''; |
235 | - $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true))); |
|
236 | - if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
237 | - if(empty($modifiers)) return ''; |
|
235 | + $cacheKey = md5(sprintf('parsePhx#%s#%s#%s', $key, $value, print_r($modifiers, true))); |
|
236 | + if (isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
237 | + if (empty($modifiers)) return ''; |
|
238 | 238 | |
239 | - foreach($modifiers as $m) |
|
239 | + foreach ($modifiers as $m) |
|
240 | 240 | { |
241 | 241 | $lastKey = strtolower($m['cmd']); |
242 | 242 | } |
243 | - $_ = explode(',',$this->condModifiers); |
|
244 | - if(in_array($lastKey,$_)) |
|
243 | + $_ = explode(',', $this->condModifiers); |
|
244 | + if (in_array($lastKey, $_)) |
|
245 | 245 | { |
246 | - $modifiers[] = array('cmd'=>'then','opt'=>'1'); |
|
247 | - $modifiers[] = array('cmd'=>'else','opt'=>'0'); |
|
246 | + $modifiers[] = array('cmd'=>'then', 'opt'=>'1'); |
|
247 | + $modifiers[] = array('cmd'=>'else', 'opt'=>'0'); |
|
248 | 248 | } |
249 | 249 | |
250 | - foreach($modifiers as $i=>$a) |
|
250 | + foreach ($modifiers as $i=>$a) |
|
251 | 251 | { |
252 | - $value = $this->Filter($key,$value, $a['cmd'], $a['opt']); |
|
252 | + $value = $this->Filter($key, $value, $a['cmd'], $a['opt']); |
|
253 | 253 | } |
254 | 254 | $this->tmpCache[$cacheKey] = $value; |
255 | 255 | return $value; |
256 | 256 | } |
257 | 257 | |
258 | 258 | // Parser: modifier detection and eXtended processing if needed |
259 | - public function Filter($key, $value, $cmd, $opt='') |
|
259 | + public function Filter($key, $value, $cmd, $opt = '') |
|
260 | 260 | { |
261 | 261 | $modx = evolutionCMS(); |
262 | 262 | |
263 | - if($key==='documentObject') $value = $modx->documentIdentifier; |
|
263 | + if ($key === 'documentObject') $value = $modx->documentIdentifier; |
|
264 | 264 | $cmd = $this->parseDocumentSource($cmd); |
265 | - if(preg_match('@^[1-9][/0-9]*$@',$cmd)) |
|
265 | + if (preg_match('@^[1-9][/0-9]*$@', $cmd)) |
|
266 | 266 | { |
267 | - if(strpos($cmd,'/')!==false) |
|
268 | - $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
267 | + if (strpos($cmd, '/') !== false) |
|
268 | + $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1); |
|
269 | 269 | $opt = $cmd; |
270 | 270 | $cmd = 'id'; |
271 | 271 | } |
272 | 272 | |
273 | - if(isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
274 | - elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
273 | + if (isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
274 | + elseif (isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
275 | 275 | else $this->elmName = ''; |
276 | 276 | |
277 | 277 | $cmd = strtolower($cmd); |
278 | - if($this->elmName!=='') |
|
278 | + if ($this->elmName !== '') |
|
279 | 279 | $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
280 | 280 | else |
281 | 281 | $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
@@ -285,12 +285,12 @@ discard block |
||
285 | 285 | return $value; |
286 | 286 | } |
287 | 287 | |
288 | - public function isEmpty($cmd,$value) |
|
288 | + public function isEmpty($cmd, $value) |
|
289 | 289 | { |
290 | - if($value!=='') return false; |
|
290 | + if ($value !== '') return false; |
|
291 | 291 | |
292 | - $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
293 | - if(in_array($cmd,$_)) return false; |
|
292 | + $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
293 | + if (in_array($cmd, $_)) return false; |
|
294 | 294 | else return true; |
295 | 295 | } |
296 | 296 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | $modx = evolutionCMS(); |
300 | 300 | |
301 | - if($this->isEmpty($cmd,$value)) return ''; |
|
301 | + if ($this->isEmpty($cmd, $value)) return ''; |
|
302 | 302 | |
303 | 303 | $this->key = $key; |
304 | 304 | $this->value = $value; |
@@ -309,83 +309,83 @@ discard block |
||
309 | 309 | ##### Conditional Modifiers |
310 | 310 | case 'input': |
311 | 311 | case 'if': |
312 | - if(!$opt) return $value; |
|
312 | + if (!$opt) return $value; |
|
313 | 313 | return $opt; |
314 | 314 | case '=': |
315 | 315 | case 'eq': |
316 | 316 | case 'is': |
317 | 317 | case 'equals': |
318 | - $this->condition[] = (int)($value == $opt); break; |
|
318 | + $this->condition[] = (int) ($value == $opt); break; |
|
319 | 319 | case 'neq': |
320 | 320 | case 'ne': |
321 | 321 | case 'notequals': |
322 | 322 | case 'isnot': |
323 | 323 | case 'isnt': |
324 | 324 | case 'not': |
325 | - $this->condition[] = (int)($value != $opt);break; |
|
325 | + $this->condition[] = (int) ($value != $opt); break; |
|
326 | 326 | case '%': |
327 | - $this->condition[] = (int)($value%$opt==0);break; |
|
327 | + $this->condition[] = (int) ($value % $opt == 0); break; |
|
328 | 328 | case 'isempty': |
329 | - $this->condition[] = (int)(empty($value)); break; |
|
329 | + $this->condition[] = (int) (empty($value)); break; |
|
330 | 330 | case 'isntempty': |
331 | 331 | case 'isnotempty': |
332 | - $this->condition[] = (int)(!empty($value)); break; |
|
332 | + $this->condition[] = (int) (!empty($value)); break; |
|
333 | 333 | case '>=': |
334 | 334 | case 'gte': |
335 | 335 | case 'eg': |
336 | 336 | case 'isgte': |
337 | - $this->condition[] = (int)($value >= $opt);break; |
|
337 | + $this->condition[] = (int) ($value >= $opt); break; |
|
338 | 338 | case '<=': |
339 | 339 | case 'lte': |
340 | 340 | case 'el': |
341 | 341 | case 'islte': |
342 | - $this->condition[] = (int)($value <= $opt);break; |
|
342 | + $this->condition[] = (int) ($value <= $opt); break; |
|
343 | 343 | case '>': |
344 | 344 | case 'gt': |
345 | 345 | case 'greaterthan': |
346 | 346 | case 'isgreaterthan': |
347 | 347 | case 'isgt': |
348 | - $this->condition[] = (int)($value > $opt);break; |
|
348 | + $this->condition[] = (int) ($value > $opt); break; |
|
349 | 349 | case '<': |
350 | 350 | case 'lt': |
351 | 351 | case 'lowerthan': |
352 | 352 | case 'islowerthan': |
353 | 353 | case 'islt': |
354 | - $this->condition[] = (int)($value < $opt);break; |
|
354 | + $this->condition[] = (int) ($value < $opt); break; |
|
355 | 355 | case 'find': |
356 | - $this->condition[] = (int)(strpos($value, $opt)!==false);break; |
|
356 | + $this->condition[] = (int) (strpos($value, $opt) !== false); break; |
|
357 | 357 | case 'inarray': |
358 | 358 | case 'in_array': |
359 | 359 | case 'in': |
360 | 360 | $opt = explode(',', $opt); |
361 | - $this->condition[] = (int)(in_array($value, $opt)!==false);break; |
|
361 | + $this->condition[] = (int) (in_array($value, $opt) !== false); break; |
|
362 | 362 | case 'wildcard_match': |
363 | 363 | case 'wcard_match': |
364 | 364 | case 'wildcard': |
365 | 365 | case 'wcard': |
366 | 366 | case 'fnmatch': |
367 | - $this->condition[] = (int)(fnmatch($opt, $value)!==false);break; |
|
367 | + $this->condition[] = (int) (fnmatch($opt, $value) !== false); break; |
|
368 | 368 | case 'is_file': |
369 | 369 | case 'is_dir': |
370 | 370 | case 'file_exists': |
371 | 371 | case 'is_readable': |
372 | 372 | case 'is_writable': |
373 | - if(!$opt) $path = $value; |
|
373 | + if (!$opt) $path = $value; |
|
374 | 374 | else $path = $opt; |
375 | - if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path'); |
|
376 | - if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/'); |
|
377 | - $this->condition[] = (int)($cmd($path)!==false);break; |
|
375 | + if (strpos($path, MODX_MANAGER_PATH) !== false) exit('Can not read core path'); |
|
376 | + if (strpos($path, $modx->config['base_path']) === false) $path = ltrim($path, '/'); |
|
377 | + $this->condition[] = (int) ($cmd($path) !== false); break; |
|
378 | 378 | case 'is_image': |
379 | - if(!$opt) $path = $value; |
|
379 | + if (!$opt) $path = $value; |
|
380 | 380 | else $path = $opt; |
381 | - if(!is_file($path)) {$this->condition[]='0';break;} |
|
381 | + if (!is_file($path)) {$this->condition[] = '0'; break; } |
|
382 | 382 | $_ = getimagesize($path); |
383 | - $this->condition[] = (int)($_[0]);break; |
|
383 | + $this->condition[] = (int) ($_[0]); break; |
|
384 | 384 | case 'regex': |
385 | 385 | case 'preg': |
386 | 386 | case 'preg_match': |
387 | 387 | case 'isinrole': |
388 | - $this->condition[] = (int)(preg_match($opt,$value));break; |
|
388 | + $this->condition[] = (int) (preg_match($opt, $value)); break; |
|
389 | 389 | case 'ir': |
390 | 390 | case 'memberof': |
391 | 391 | case 'mo': |
@@ -393,50 +393,50 @@ discard block |
||
393 | 393 | $this->condition[] = $this->includeMdfFile('memberof'); |
394 | 394 | break; |
395 | 395 | case 'or': |
396 | - $this->condition[] = '||';break; |
|
396 | + $this->condition[] = '||'; break; |
|
397 | 397 | case 'and': |
398 | - $this->condition[] = '&&';break; |
|
398 | + $this->condition[] = '&&'; break; |
|
399 | 399 | case 'show': |
400 | 400 | case 'this': |
401 | - $conditional = implode(' ',$this->condition); |
|
402 | - $isvalid = (int)(eval("return ({$conditional});")); |
|
401 | + $conditional = implode(' ', $this->condition); |
|
402 | + $isvalid = (int) (eval("return ({$conditional});")); |
|
403 | 403 | if ($isvalid) return $this->srcValue; |
404 | 404 | return NULL; |
405 | 405 | case 'then': |
406 | - $conditional = implode(' ',$this->condition); |
|
407 | - $isvalid = (int)eval("return ({$conditional});"); |
|
406 | + $conditional = implode(' ', $this->condition); |
|
407 | + $isvalid = (int) eval("return ({$conditional});"); |
|
408 | 408 | if ($isvalid) return $opt; |
409 | 409 | return null; |
410 | 410 | case 'else': |
411 | - $conditional = implode(' ',$this->condition); |
|
412 | - $isvalid = (int)eval("return ({$conditional});"); |
|
411 | + $conditional = implode(' ', $this->condition); |
|
412 | + $isvalid = (int) eval("return ({$conditional});"); |
|
413 | 413 | if (!$isvalid) return $opt; |
414 | 414 | break; |
415 | 415 | case 'select': |
416 | 416 | case 'switch': |
417 | - $raw = explode('&',$opt); |
|
417 | + $raw = explode('&', $opt); |
|
418 | 418 | $map = array(); |
419 | 419 | $c = count($raw); |
420 | - for($m=0; $m<$c; $m++) { |
|
421 | - $mi = explode('=',$raw[$m],2); |
|
420 | + for ($m = 0; $m < $c; $m++) { |
|
421 | + $mi = explode('=', $raw[$m], 2); |
|
422 | 422 | $map[$mi[0]] = $mi[1]; |
423 | 423 | } |
424 | - if(isset($map[$value])) return $map[$value]; |
|
424 | + if (isset($map[$value])) return $map[$value]; |
|
425 | 425 | else return ''; |
426 | 426 | ##### End of Conditional Modifiers |
427 | 427 | |
428 | 428 | ##### Encode / Decode / Hash / Escape |
429 | 429 | case 'htmlent': |
430 | 430 | case 'htmlentities': |
431 | - return htmlentities($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
431 | + return htmlentities($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
432 | 432 | case 'html_entity_decode': |
433 | 433 | case 'decode_html': |
434 | 434 | case 'html_decode': |
435 | - return html_entity_decode($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
435 | + return html_entity_decode($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
436 | 436 | case 'esc': |
437 | 437 | case 'escape': |
438 | 438 | $value = preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
439 | - return str_replace(array('[', ']', '`'),array('[', ']', '`'),$value); |
|
439 | + return str_replace(array('[', ']', '`'), array('[', ']', '`'), $value); |
|
440 | 440 | case 'sql_escape': |
441 | 441 | case 'encode_js': |
442 | 442 | return $modx->getDatabase()->escape($value); |
@@ -446,39 +446,39 @@ discard block |
||
446 | 446 | case 'html_encode': |
447 | 447 | return preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
448 | 448 | case 'spam_protect': |
449 | - return str_replace(array('@','.'),array('@','.'),$value); |
|
449 | + return str_replace(array('@', '.'), array('@', '.'), $value); |
|
450 | 450 | case 'strip': |
451 | - if($opt==='') $opt = ' '; |
|
451 | + if ($opt === '') $opt = ' '; |
|
452 | 452 | return preg_replace('/[\n\r\t\s]+/', $opt, $value); |
453 | 453 | case 'strip_linefeeds': |
454 | - return str_replace(array("\n","\r"), '', $value); |
|
454 | + return str_replace(array("\n", "\r"), '', $value); |
|
455 | 455 | case 'notags': |
456 | 456 | case 'strip_tags': |
457 | 457 | case 'remove_html': |
458 | - if($opt!=='') |
|
458 | + if ($opt !== '') |
|
459 | 459 | { |
460 | 460 | $param = array(); |
461 | - foreach(explode(',',$opt) as $v) |
|
461 | + foreach (explode(',', $opt) as $v) |
|
462 | 462 | { |
463 | - $v = trim($v,'</> '); |
|
463 | + $v = trim($v, '</> '); |
|
464 | 464 | $param[] = "<{$v}>"; |
465 | 465 | } |
466 | - $params = implode(',',$param); |
|
466 | + $params = implode(',', $param); |
|
467 | 467 | } |
468 | 468 | else $params = ''; |
469 | - if(!strpos($params,'<br>')===false) { |
|
470 | - $value = preg_replace('@(<br[ /]*>)\n@','$1',$value); |
|
471 | - $value = preg_replace('@<br[ /]*>@',"\n",$value); |
|
469 | + if (!strpos($params, '<br>') === false) { |
|
470 | + $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value); |
|
471 | + $value = preg_replace('@<br[ /]*>@', "\n", $value); |
|
472 | 472 | } |
473 | - return $this->strip_tags($value,$params); |
|
473 | + return $this->strip_tags($value, $params); |
|
474 | 474 | case 'urlencode': |
475 | 475 | case 'url_encode': |
476 | 476 | case 'encode_url': |
477 | 477 | return urlencode($value); |
478 | 478 | case 'base64_decode': |
479 | - if($opt!=='false') $opt = true; |
|
479 | + if ($opt !== 'false') $opt = true; |
|
480 | 480 | else $opt = false; |
481 | - return base64_decode($value,$opt); |
|
481 | + return base64_decode($value, $opt); |
|
482 | 482 | case 'encode_sha1': $cmd = 'sha1'; |
483 | 483 | case 'addslashes': |
484 | 484 | case 'urldecode': |
@@ -502,18 +502,18 @@ discard block |
||
502 | 502 | case 'upper_case': |
503 | 503 | return $this->strtoupper($value); |
504 | 504 | case 'capitalize': |
505 | - $_ = explode(' ',$value); |
|
506 | - foreach($_ as $i=>$v) |
|
505 | + $_ = explode(' ', $value); |
|
506 | + foreach ($_ as $i=>$v) |
|
507 | 507 | { |
508 | 508 | $_[$i] = ucfirst($v); |
509 | 509 | } |
510 | - return implode(' ',$_); |
|
510 | + return implode(' ', $_); |
|
511 | 511 | case 'zenhan': |
512 | - if(empty($opt)) $opt='VKas'; |
|
513 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
512 | + if (empty($opt)) $opt = 'VKas'; |
|
513 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
514 | 514 | case 'hanzen': |
515 | - if(empty($opt)) $opt='VKAS'; |
|
516 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
515 | + if (empty($opt)) $opt = 'VKAS'; |
|
516 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
517 | 517 | case 'str_shuffle': |
518 | 518 | case 'shuffle': |
519 | 519 | return $this->str_shuffle($value); |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | return $this->strlen($value); |
528 | 528 | case 'count_words': |
529 | 529 | $value = trim($value); |
530 | - return count(preg_split('/\s+/',$value)); |
|
530 | + return count(preg_split('/\s+/', $value)); |
|
531 | 531 | case 'str_word_count': |
532 | 532 | case 'word_count': |
533 | 533 | case 'wordcount': |
@@ -535,55 +535,55 @@ discard block |
||
535 | 535 | case 'count_paragraphs': |
536 | 536 | $value = trim($value); |
537 | 537 | $value = preg_replace('/\r/', '', $value); |
538 | - return count(preg_split('/\n+/',$value)); |
|
538 | + return count(preg_split('/\n+/', $value)); |
|
539 | 539 | case 'strpos': |
540 | - if($opt!=0&&empty($opt)) return $value; |
|
541 | - return $this->strpos($value,$opt); |
|
540 | + if ($opt != 0 && empty($opt)) return $value; |
|
541 | + return $this->strpos($value, $opt); |
|
542 | 542 | case 'wordwrap': |
543 | 543 | // default: 70 |
544 | - $wrapat = (int)$opt > 0 ? (int)$opt : 70; |
|
544 | + $wrapat = (int) $opt > 0 ? (int) $opt : 70; |
|
545 | 545 | if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap'); |
546 | - else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); |
|
546 | + else return preg_replace("@(\b\w+\b)@e", "wordwrap('\\1',\$wrapat,' ',1)", $value); |
|
547 | 547 | case 'wrap_text': |
548 | - $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70; |
|
549 | - if($modx->config['manager_language']==='japanese-utf8') { |
|
548 | + $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70; |
|
549 | + if ($modx->config['manager_language'] === 'japanese-utf8') { |
|
550 | 550 | $chunk = array(); |
551 | - $bt=''; |
|
552 | - while($bt!=$value) { |
|
551 | + $bt = ''; |
|
552 | + while ($bt != $value) { |
|
553 | 553 | $bt = $value; |
554 | - if($this->strlen($value)<$width) { |
|
554 | + if ($this->strlen($value) < $width) { |
|
555 | 555 | $chunk[] = $value; |
556 | 556 | break; |
557 | 557 | } |
558 | - $chunk[] = $this->substr($value,0,$width); |
|
559 | - $value = $this->substr($value,$width); |
|
558 | + $chunk[] = $this->substr($value, 0, $width); |
|
559 | + $value = $this->substr($value, $width); |
|
560 | 560 | } |
561 | - return implode("\n",$chunk); |
|
561 | + return implode("\n", $chunk); |
|
562 | 562 | } |
563 | 563 | else |
564 | - return wordwrap($value,$width,"\n",true); |
|
564 | + return wordwrap($value, $width, "\n", true); |
|
565 | 565 | case 'substr': |
566 | - if(empty($opt)) break; |
|
567 | - if(strpos($opt,',')!==false) { |
|
568 | - list($b,$e) = explode(',',$opt,2); |
|
569 | - return $this->substr($value,$b,(int)$e); |
|
566 | + if (empty($opt)) break; |
|
567 | + if (strpos($opt, ',') !== false) { |
|
568 | + list($b, $e) = explode(',', $opt, 2); |
|
569 | + return $this->substr($value, $b, (int) $e); |
|
570 | 570 | } |
571 | - else return $this->substr($value,$opt); |
|
571 | + else return $this->substr($value, $opt); |
|
572 | 572 | case 'limit': |
573 | 573 | case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html |
574 | - if(strpos($opt,'+')!==false) |
|
575 | - list($len,$str) = explode('+',$opt,2); |
|
574 | + if (strpos($opt, '+') !== false) |
|
575 | + list($len, $str) = explode('+', $opt, 2); |
|
576 | 576 | else { |
577 | 577 | $len = $opt; |
578 | 578 | $str = ''; |
579 | 579 | } |
580 | - if($len==='') $len = 100; |
|
581 | - if(abs($len) > $this->strlen($value)) $str =''; |
|
582 | - if(preg_match('/^[1-9][0-9]*$/',$len)) { |
|
583 | - return $this->substr($value,0,$len) . $str; |
|
580 | + if ($len === '') $len = 100; |
|
581 | + if (abs($len) > $this->strlen($value)) $str = ''; |
|
582 | + if (preg_match('/^[1-9][0-9]*$/', $len)) { |
|
583 | + return $this->substr($value, 0, $len).$str; |
|
584 | 584 | } |
585 | - elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
586 | - return $str . $this->substr($value,$len); |
|
585 | + elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) { |
|
586 | + return $str.$this->substr($value, $len); |
|
587 | 587 | } |
588 | 588 | break; |
589 | 589 | case 'summary': |
@@ -592,81 +592,81 @@ discard block |
||
592 | 592 | return $this->includeMdfFile('summary'); |
593 | 593 | case 'replace': |
594 | 594 | case 'str_replace': |
595 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
596 | - if (substr_count($opt, ',') ==1) $delim = ','; |
|
597 | - elseif(substr_count($opt, '|') ==1) $delim = '|'; |
|
598 | - elseif(substr_count($opt, '=>')==1) $delim = '=>'; |
|
599 | - elseif(substr_count($opt, '/') ==1) $delim = '/'; |
|
595 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
596 | + if (substr_count($opt, ',') == 1) $delim = ','; |
|
597 | + elseif (substr_count($opt, '|') == 1) $delim = '|'; |
|
598 | + elseif (substr_count($opt, '=>') == 1) $delim = '=>'; |
|
599 | + elseif (substr_count($opt, '/') == 1) $delim = '/'; |
|
600 | 600 | else break; |
601 | - list($s,$r) = explode($delim,$opt); |
|
602 | - if($value!=='') return str_replace($s,$r,$value); |
|
601 | + list($s, $r) = explode($delim, $opt); |
|
602 | + if ($value !== '') return str_replace($s, $r, $value); |
|
603 | 603 | break; |
604 | 604 | case 'replace_to': |
605 | 605 | case 'tpl': |
606 | - if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
606 | + if ($value !== '') return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt); |
|
607 | 607 | break; |
608 | 608 | case 'eachtpl': |
609 | - $value = explode('||',$value); |
|
609 | + $value = explode('||', $value); |
|
610 | 610 | $_ = array(); |
611 | - foreach($value as $v) { |
|
612 | - $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'),$v,$opt); |
|
611 | + foreach ($value as $v) { |
|
612 | + $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt); |
|
613 | 613 | } |
614 | 614 | return implode("\n", $_); |
615 | 615 | case 'array_pop': |
616 | 616 | case 'array_shift': |
617 | - if(strpos($value,'||')!==false) $delim = '||'; |
|
617 | + if (strpos($value, '||') !== false) $delim = '||'; |
|
618 | 618 | else $delim = ','; |
619 | - return $cmd(explode($delim,$value)); |
|
619 | + return $cmd(explode($delim, $value)); |
|
620 | 620 | case 'preg_replace': |
621 | 621 | case 'regex_replace': |
622 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
623 | - list($s,$r) = explode(',',$opt,2); |
|
624 | - if($value!=='') return preg_replace($s,$r,$value); |
|
622 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
623 | + list($s, $r) = explode(',', $opt, 2); |
|
624 | + if ($value !== '') return preg_replace($s, $r, $value); |
|
625 | 625 | break; |
626 | 626 | case 'cat': |
627 | 627 | case 'concatenate': |
628 | 628 | case '.': |
629 | - if($value!=='') return $value . $opt; |
|
629 | + if ($value !== '') return $value.$opt; |
|
630 | 630 | break; |
631 | 631 | case 'sprintf': |
632 | 632 | case 'string_format': |
633 | - if($value!=='') return sprintf($opt,$value); |
|
633 | + if ($value !== '') return sprintf($opt, $value); |
|
634 | 634 | break; |
635 | 635 | case 'number_format': |
636 | - if($opt=='') $opt = 0; |
|
637 | - return number_format($value,$opt); |
|
636 | + if ($opt == '') $opt = 0; |
|
637 | + return number_format($value, $opt); |
|
638 | 638 | case 'money_format': |
639 | - setlocale(LC_MONETARY,setlocale(LC_TIME,0)); |
|
640 | - if($value!=='') return money_format($opt,(double)$value); |
|
639 | + setlocale(LC_MONETARY, setlocale(LC_TIME, 0)); |
|
640 | + if ($value !== '') return money_format($opt, (double) $value); |
|
641 | 641 | break; |
642 | 642 | case 'tobool': |
643 | 643 | return boolval($value); |
644 | 644 | case 'nl2lf': |
645 | - if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
645 | + if ($value !== '') return str_replace(array("\r\n", "\n", "\r"), '\n', $value); |
|
646 | 646 | break; |
647 | 647 | case 'br2nl': |
648 | 648 | return preg_replace('@<br[\s/]*>@i', "\n", $value); |
649 | 649 | case 'nl2br': |
650 | 650 | if (version_compare(PHP_VERSION, '5.3.0', '<')) |
651 | 651 | return nl2br($value); |
652 | - if($opt!=='') |
|
652 | + if ($opt !== '') |
|
653 | 653 | { |
654 | 654 | $opt = trim($opt); |
655 | 655 | $opt = strtolower($opt); |
656 | - if($opt==='false') $opt = false; |
|
657 | - elseif($opt==='0') $opt = false; |
|
656 | + if ($opt === 'false') $opt = false; |
|
657 | + elseif ($opt === '0') $opt = false; |
|
658 | 658 | else $opt = true; |
659 | 659 | } |
660 | - elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') |
|
660 | + elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html') |
|
661 | 661 | $opt = false; |
662 | 662 | else $opt = true; |
663 | - return nl2br($value,$opt); |
|
663 | + return nl2br($value, $opt); |
|
664 | 664 | case 'ltrim': |
665 | 665 | case 'rtrim': |
666 | 666 | case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html |
667 | - if($opt==='') |
|
667 | + if ($opt === '') |
|
668 | 668 | return $cmd($value); |
669 | - else return $cmd($value,$opt); |
|
669 | + else return $cmd($value, $opt); |
|
670 | 670 | // These are all straight wrappers for PHP functions |
671 | 671 | case 'ucfirst': |
672 | 672 | case 'lcfirst': |
@@ -677,58 +677,58 @@ discard block |
||
677 | 677 | case 'strftime': |
678 | 678 | case 'date': |
679 | 679 | case 'dateformat': |
680 | - if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
681 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
682 | - if(strpos($opt,'%')!==false) |
|
683 | - return strftime($opt,0+$value); |
|
680 | + if (empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
681 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
682 | + if (strpos($opt, '%') !== false) |
|
683 | + return strftime($opt, 0 + $value); |
|
684 | 684 | else |
685 | - return date($opt,0+$value); |
|
685 | + return date($opt, 0 + $value); |
|
686 | 686 | case 'time': |
687 | - if(empty($opt)) $opt = '%H:%M'; |
|
688 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
689 | - return strftime($opt,0+$value); |
|
687 | + if (empty($opt)) $opt = '%H:%M'; |
|
688 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
689 | + return strftime($opt, 0 + $value); |
|
690 | 690 | case 'strtotime': |
691 | 691 | return strtotime($value); |
692 | 692 | ##### mathematical function |
693 | 693 | case 'toint': |
694 | - return (int)$value; |
|
694 | + return (int) $value; |
|
695 | 695 | case 'tofloat': |
696 | 696 | return floatval($value); |
697 | 697 | case 'round': |
698 | - if(!$opt) $opt = 0; |
|
699 | - return $cmd($value,$opt); |
|
698 | + if (!$opt) $opt = 0; |
|
699 | + return $cmd($value, $opt); |
|
700 | 700 | case 'max': |
701 | 701 | case 'min': |
702 | - return $cmd(explode(',',$value)); |
|
702 | + return $cmd(explode(',', $value)); |
|
703 | 703 | case 'floor': |
704 | 704 | case 'ceil': |
705 | 705 | case 'abs': |
706 | 706 | return $cmd($value); |
707 | 707 | case 'math': |
708 | 708 | case 'calc': |
709 | - $value = (int)$value; |
|
710 | - if(empty($value)) $value = '0'; |
|
711 | - $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt); |
|
712 | - $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter); |
|
713 | - if(strpos($filter,'?')===false) $filter = "?{$filter}"; |
|
714 | - $filter = str_replace('?',$value,$filter); |
|
709 | + $value = (int) $value; |
|
710 | + if (empty($value)) $value = '0'; |
|
711 | + $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt); |
|
712 | + $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter); |
|
713 | + if (strpos($filter, '?') === false) $filter = "?{$filter}"; |
|
714 | + $filter = str_replace('?', $value, $filter); |
|
715 | 715 | return eval("return {$filter};"); |
716 | 716 | case 'count': |
717 | - if($value=='') return 0; |
|
718 | - $value = explode(',',$value); |
|
717 | + if ($value == '') return 0; |
|
718 | + $value = explode(',', $value); |
|
719 | 719 | return count($value); |
720 | 720 | case 'sort': |
721 | 721 | case 'rsort': |
722 | - if(strpos($value,"\n")!==false) $delim="\n"; |
|
722 | + if (strpos($value, "\n") !== false) $delim = "\n"; |
|
723 | 723 | else $delim = ','; |
724 | - $swap = explode($delim,$value); |
|
725 | - if(!$opt) $opt = SORT_REGULAR; |
|
724 | + $swap = explode($delim, $value); |
|
725 | + if (!$opt) $opt = SORT_REGULAR; |
|
726 | 726 | else $opt = constant($opt); |
727 | - $cmd($swap,$opt); |
|
728 | - return implode($delim,$swap); |
|
727 | + $cmd($swap, $opt); |
|
728 | + return implode($delim, $swap); |
|
729 | 729 | ##### Resource fields |
730 | 730 | case 'id': |
731 | - if($opt) return $this->getDocumentObject($opt,$key); |
|
731 | + if ($opt) return $this->getDocumentObject($opt, $key); |
|
732 | 732 | break; |
733 | 733 | case 'type': |
734 | 734 | case 'contenttype': |
@@ -765,36 +765,36 @@ discard block |
||
765 | 765 | case 'privatemgr': |
766 | 766 | case 'content_dispo': |
767 | 767 | case 'hidemenu': |
768 | - if($cmd==='contenttype') $cmd = 'contentType'; |
|
769 | - return $this->getDocumentObject($value,$cmd); |
|
768 | + if ($cmd === 'contenttype') $cmd = 'contentType'; |
|
769 | + return $this->getDocumentObject($value, $cmd); |
|
770 | 770 | case 'title': |
771 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
772 | - $longtitle = $this->getDocumentObject($value,'longtitle'); |
|
771 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
772 | + $longtitle = $this->getDocumentObject($value, 'longtitle'); |
|
773 | 773 | return $longtitle ? $longtitle : $pagetitle; |
774 | 774 | case 'shorttitle': |
775 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
776 | - $menutitle = $this->getDocumentObject($value,'menutitle'); |
|
775 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
776 | + $menutitle = $this->getDocumentObject($value, 'menutitle'); |
|
777 | 777 | return $menutitle ? $menutitle : $pagetitle; |
778 | 778 | case 'templatename': |
779 | - $rs = $modx->getDatabase()->select('templatename','[+prefix+]site_templates',"id='{$value}'"); |
|
779 | + $rs = $modx->getDatabase()->select('templatename', '[+prefix+]site_templates', "id='{$value}'"); |
|
780 | 780 | $templateName = $modx->getDatabase()->getValue($rs); |
781 | 781 | return !$templateName ? '(blank)' : $templateName; |
782 | 782 | case 'getfield': |
783 | - if(!$opt) $opt = 'content'; |
|
784 | - return $modx->getField($opt,$value); |
|
783 | + if (!$opt) $opt = 'content'; |
|
784 | + return $modx->getField($opt, $value); |
|
785 | 785 | case 'children': |
786 | 786 | case 'childids': |
787 | - if($value=='') $value = 0; // 値がない場合はルートと見なす |
|
787 | + if ($value == '') $value = 0; // 値がない場合はルートと見なす |
|
788 | 788 | $published = 1; |
789 | - if($opt=='') $opt = 'page'; |
|
790 | - $_ = explode(',',$opt); |
|
789 | + if ($opt == '') $opt = 'page'; |
|
790 | + $_ = explode(',', $opt); |
|
791 | 791 | $where = array(); |
792 | - foreach($_ as $opt) { |
|
793 | - switch(trim($opt)) { |
|
792 | + foreach ($_ as $opt) { |
|
793 | + switch (trim($opt)) { |
|
794 | 794 | case 'page'; case '!folder'; case '!isfolder': $where[] = 'sc.isfolder=0'; break; |
795 | 795 | case 'folder'; case 'isfolder': $where[] = 'sc.isfolder=1'; break; |
796 | - case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
797 | - case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
796 | + case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
797 | + case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
798 | 798 | case 'published': $published = 1; break; |
799 | 799 | case '!published': $published = 0; break; |
800 | 800 | } |
@@ -802,69 +802,69 @@ discard block |
||
802 | 802 | $where = implode(' AND ', $where); |
803 | 803 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); |
804 | 804 | $result = array(); |
805 | - foreach((array)$children as $child){ |
|
805 | + foreach ((array) $children as $child) { |
|
806 | 806 | $result[] = $child['id']; |
807 | 807 | } |
808 | 808 | return implode(',', $result); |
809 | 809 | case 'fullurl': |
810 | - if(!is_numeric($value)) return $value; |
|
810 | + if (!is_numeric($value)) return $value; |
|
811 | 811 | return $modx->makeUrl($value); |
812 | 812 | case 'makeurl': |
813 | - if(!is_numeric($value)) return $value; |
|
814 | - if(!$opt) $opt = 'full'; |
|
815 | - return $modx->makeUrl($value,'','',$opt); |
|
813 | + if (!is_numeric($value)) return $value; |
|
814 | + if (!$opt) $opt = 'full'; |
|
815 | + return $modx->makeUrl($value, '', '', $opt); |
|
816 | 816 | |
817 | 817 | ##### File system |
818 | 818 | case 'getimageinfo': |
819 | 819 | case 'imageinfo': |
820 | - if(!is_file($value)) return ''; |
|
820 | + if (!is_file($value)) return ''; |
|
821 | 821 | $_ = getimagesize($value); |
822 | - if(!$_[0]) return ''; |
|
822 | + if (!$_[0]) return ''; |
|
823 | 823 | $info['width'] = $_[0]; |
824 | 824 | $info['height'] = $_[1]; |
825 | - if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
826 | - elseif($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
825 | + if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
826 | + elseif ($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
827 | 827 | else $info['aspect'] = 'square'; |
828 | - switch($_[2]) { |
|
828 | + switch ($_[2]) { |
|
829 | 829 | case IMAGETYPE_GIF : $info['type'] = 'gif'; break; |
830 | 830 | case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break; |
831 | 831 | case IMAGETYPE_PNG : $info['type'] = 'png'; break; |
832 | 832 | default : $info['type'] = 'unknown'; |
833 | 833 | } |
834 | 834 | $info['attrib'] = $_[3]; |
835 | - switch($opt) { |
|
835 | + switch ($opt) { |
|
836 | 836 | case 'width' : return $info['width']; |
837 | 837 | case 'height': return $info['height']; |
838 | 838 | case 'aspect': return $info['aspect']; |
839 | 839 | case 'type' : return $info['type']; |
840 | 840 | case 'attrib': return $info['attrib']; |
841 | - default : return print_r($info,true); |
|
841 | + default : return print_r($info, true); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | case 'file_get_contents': |
845 | 845 | case 'readfile': |
846 | - if(!is_file($value)) return $value; |
|
846 | + if (!is_file($value)) return $value; |
|
847 | 847 | $value = realpath($value); |
848 | - if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file'); |
|
849 | - $ext = strtolower(substr($value,-4)); |
|
850 | - if($ext==='.php') exit('Can not read php file'); |
|
851 | - if($ext==='.cgi') exit('Can not read cgi file'); |
|
848 | + if (strpos($value, MODX_MANAGER_PATH) !== false) exit('Can not read core file'); |
|
849 | + $ext = strtolower(substr($value, -4)); |
|
850 | + if ($ext === '.php') exit('Can not read php file'); |
|
851 | + if ($ext === '.cgi') exit('Can not read cgi file'); |
|
852 | 852 | return file_get_contents($value); |
853 | 853 | case 'filesize': |
854 | - if($value == '') return ''; |
|
854 | + if ($value == '') return ''; |
|
855 | 855 | $filename = $value; |
856 | 856 | |
857 | 857 | $site_url = $modx->config['site_url']; |
858 | - if(strpos($filename,$site_url) === 0) |
|
859 | - $filename = substr($filename,0,strlen($site_url)); |
|
860 | - $filename = trim($filename,'/'); |
|
858 | + if (strpos($filename, $site_url) === 0) |
|
859 | + $filename = substr($filename, 0, strlen($site_url)); |
|
860 | + $filename = trim($filename, '/'); |
|
861 | 861 | |
862 | - $opt = trim($opt,'/'); |
|
863 | - if($opt!=='') $opt .= '/'; |
|
862 | + $opt = trim($opt, '/'); |
|
863 | + if ($opt !== '') $opt .= '/'; |
|
864 | 864 | |
865 | 865 | $filename = MODX_BASE_PATH.$opt.$filename; |
866 | 866 | |
867 | - if(is_file($filename)){ |
|
867 | + if (is_file($filename)) { |
|
868 | 868 | clearstatcache(); |
869 | 869 | $size = filesize($filename); |
870 | 870 | return $size; |
@@ -897,10 +897,10 @@ discard block |
||
897 | 897 | $this->opt = $cmd; |
898 | 898 | return $this->includeMdfFile('moduser'); |
899 | 899 | case 'userinfo': |
900 | - if(empty($opt)) $this->opt = 'username'; |
|
900 | + if (empty($opt)) $this->opt = 'username'; |
|
901 | 901 | return $this->includeMdfFile('moduser'); |
902 | 902 | case 'webuserinfo': |
903 | - if(empty($opt)) $this->opt = 'username'; |
|
903 | + if (empty($opt)) $this->opt = 'username'; |
|
904 | 904 | $this->value = -$value; |
905 | 905 | return $this->includeMdfFile('moduser'); |
906 | 906 | ##### Special functions |
@@ -911,27 +911,27 @@ discard block |
||
911 | 911 | case 'ifnotempty': |
912 | 912 | if (!empty($value)) return $opt; break; |
913 | 913 | case 'datagrid': |
914 | - include_once(MODX_CORE_PATH . 'controls/datagrid.class.php'); |
|
914 | + include_once(MODX_CORE_PATH.'controls/datagrid.class.php'); |
|
915 | 915 | $grd = new DataGrid(null, trim($value)); |
916 | 916 | $grd->itemStyle = ''; |
917 | 917 | $grd->altItemStyle = ''; |
918 | - $pos = strpos($value,"\n"); |
|
919 | - if($pos) $_ = substr($value,0,$pos); |
|
918 | + $pos = strpos($value, "\n"); |
|
919 | + if ($pos) $_ = substr($value, 0, $pos); |
|
920 | 920 | else $_ = $pos; |
921 | - $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ','; |
|
921 | + $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ','; |
|
922 | 922 | return $grd->render(); |
923 | 923 | case 'rotate': |
924 | 924 | case 'evenodd': |
925 | - if(strpos($opt,',')===false) $opt = 'odd,even'; |
|
925 | + if (strpos($opt, ',') === false) $opt = 'odd,even'; |
|
926 | 926 | $_ = explode(',', $opt); |
927 | 927 | $c = count($_); |
928 | 928 | $i = $value + $c; |
929 | 929 | $i = $i % $c; |
930 | 930 | return $_[$i]; |
931 | 931 | case 'takeval': |
932 | - $arr = explode(",",$opt); |
|
932 | + $arr = explode(",", $opt); |
|
933 | 933 | $idx = $value; |
934 | - if(!is_numeric($idx)) return $value; |
|
934 | + if (!is_numeric($idx)) return $value; |
|
935 | 935 | return $arr[$idx]; |
936 | 936 | case 'getimage': |
937 | 937 | return $this->includeMdfFile('getimage'); |
@@ -939,17 +939,17 @@ discard block |
||
939 | 939 | return $modx->nicesize($value); |
940 | 940 | case 'googlemap': |
941 | 941 | case 'googlemaps': |
942 | - if(empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
942 | + if (empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
943 | 943 | $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>'; |
944 | 944 | $ph['style'] = $opt; |
945 | 945 | $ph['value'] = $value; |
946 | - return $modx->parseText($tpl,$ph); |
|
946 | + return $modx->parseText($tpl, $ph); |
|
947 | 947 | case 'youtube': |
948 | 948 | case 'youtube16x9': |
949 | - if(empty($opt)) $opt = 560; |
|
950 | - $h = round($opt*0.5625); |
|
949 | + if (empty($opt)) $opt = 560; |
|
950 | + $h = round($opt * 0.5625); |
|
951 | 951 | $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>'; |
952 | - return sprintf($tpl,$opt,$h,$value); |
|
952 | + return sprintf($tpl, $opt, $h, $value); |
|
953 | 953 | //case 'youtube4x3':%s*0.75+25 |
954 | 954 | case 'setvar': |
955 | 955 | $modx->placeholders[$opt] = $value; |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | return $value; |
980 | 980 | } |
981 | 981 | |
982 | - public function includeMdfFile($cmd) { |
|
982 | + public function includeMdfFile($cmd){ |
|
983 | 983 | $modx = evolutionCMS(); |
984 | 984 | $key = $this->key; |
985 | 985 | $value = $this->value; |
@@ -990,54 +990,54 @@ discard block |
||
990 | 990 | public function getValueFromElement($key, $value, $cmd, $opt) |
991 | 991 | { |
992 | 992 | $modx = evolutionCMS(); |
993 | - if( isset($modx->snippetCache[$this->elmName]) ) |
|
993 | + if (isset($modx->snippetCache[$this->elmName])) |
|
994 | 994 | { |
995 | 995 | $php = $modx->snippetCache[$this->elmName]; |
996 | 996 | } |
997 | 997 | else |
998 | 998 | { |
999 | 999 | $esc_elmName = $modx->getDatabase()->escape($this->elmName); |
1000 | - $result = $modx->getDatabase()->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'"); |
|
1000 | + $result = $modx->getDatabase()->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'"); |
|
1001 | 1001 | $total = $modx->getDatabase()->getRecordCount($result); |
1002 | - if($total == 1) |
|
1002 | + if ($total == 1) |
|
1003 | 1003 | { |
1004 | 1004 | $row = $modx->getDatabase()->getRow($result); |
1005 | 1005 | $php = $row['snippet']; |
1006 | 1006 | } |
1007 | - elseif($total == 0) |
|
1007 | + elseif ($total == 0) |
|
1008 | 1008 | { |
1009 | 1009 | $assets_path = MODX_BASE_PATH.'assets/'; |
1010 | - if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
1010 | + if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
1011 | 1011 | $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
1012 | - elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
1012 | + elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
1013 | 1013 | $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
1014 | - elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
1014 | + elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
1015 | 1015 | $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
1016 | 1016 | else $modifiers_path = false; |
1017 | 1017 | |
1018 | - if($modifiers_path !== false) { |
|
1018 | + if ($modifiers_path !== false) { |
|
1019 | 1019 | $php = @file_get_contents($modifiers_path); |
1020 | 1020 | $php = trim($php); |
1021 | - if(substr($php,0,5)==='<?php') $php = substr($php,6); |
|
1022 | - if(substr($php,0,2)==='<?') $php = substr($php,3); |
|
1023 | - if(substr($php,-2)==='?>') $php = substr($php,0,-2); |
|
1024 | - if($this->elmName!=='') |
|
1021 | + if (substr($php, 0, 5) === '<?php') $php = substr($php, 6); |
|
1022 | + if (substr($php, 0, 2) === '<?') $php = substr($php, 3); |
|
1023 | + if (substr($php, -2) === '?>') $php = substr($php, 0, -2); |
|
1024 | + if ($this->elmName !== '') |
|
1025 | 1025 | $modx->snippetCache[$this->elmName.'Props'] = ''; |
1026 | 1026 | } |
1027 | 1027 | else |
1028 | 1028 | $php = false; |
1029 | 1029 | } |
1030 | 1030 | else $php = false; |
1031 | - if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php; |
|
1031 | + if ($this->elmName !== '') $modx->snippetCache[$this->elmName] = $php; |
|
1032 | 1032 | } |
1033 | - if($php==='') $php=false; |
|
1033 | + if ($php === '') $php = false; |
|
1034 | 1034 | |
1035 | - if($php===false) $html = $modx->getChunk($this->elmName); |
|
1035 | + if ($php === false) $html = $modx->getChunk($this->elmName); |
|
1036 | 1036 | else $html = false; |
1037 | 1037 | |
1038 | 1038 | $self = '[+output+]'; |
1039 | 1039 | |
1040 | - if($php !== false) |
|
1040 | + if ($php !== false) |
|
1041 | 1041 | { |
1042 | 1042 | ob_start(); |
1043 | 1043 | $options = $opt; |
@@ -1050,71 +1050,71 @@ discard block |
||
1050 | 1050 | $this->vars['options'] = & $opt; |
1051 | 1051 | $custom = eval($php); |
1052 | 1052 | $msg = ob_get_contents(); |
1053 | - if($value===$this->bt) $value = $msg . $custom; |
|
1053 | + if ($value === $this->bt) $value = $msg.$custom; |
|
1054 | 1054 | ob_end_clean(); |
1055 | 1055 | } |
1056 | - elseif($html!==false && isset($value) && $value!=='') |
|
1056 | + elseif ($html !== false && isset($value) && $value !== '') |
|
1057 | 1057 | { |
1058 | - $html = str_replace(array($self,'[+value+]'), $value, $html); |
|
1059 | - $value = str_replace(array('[+options+]','[+param+]'), $opt, $html); |
|
1058 | + $html = str_replace(array($self, '[+value+]'), $value, $html); |
|
1059 | + $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html); |
|
1060 | 1060 | } |
1061 | 1061 | else return false; |
1062 | 1062 | |
1063 | - if($php===false && $html===false && $value!=='' |
|
1064 | - && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) |
|
1063 | + if ($php === false && $html === false && $value !== '' |
|
1064 | + && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false)) |
|
1065 | 1065 | { |
1066 | - $value = str_replace(array('[+value+]',$self),$value,$cmd); |
|
1066 | + $value = str_replace(array('[+value+]', $self), $value, $cmd); |
|
1067 | 1067 | } |
1068 | 1068 | return $value; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - public function parseDocumentSource($content='') |
|
1071 | + public function parseDocumentSource($content = '') |
|
1072 | 1072 | { |
1073 | 1073 | $modx = evolutionCMS(); |
1074 | 1074 | |
1075 | - if(strpos($content,'[')===false && strpos($content,'{')===false) return $content; |
|
1075 | + if (strpos($content, '[') === false && strpos($content, '{') === false) return $content; |
|
1076 | 1076 | |
1077 | - if(!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1078 | - $bt=''; |
|
1079 | - $i=0; |
|
1080 | - while($bt!==$content) |
|
1077 | + if (!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1078 | + $bt = ''; |
|
1079 | + $i = 0; |
|
1080 | + while ($bt !== $content) |
|
1081 | 1081 | { |
1082 | 1082 | $bt = $content; |
1083 | - if(strpos($content,'[*')!==false && $modx->documentIdentifier) |
|
1083 | + if (strpos($content, '[*') !== false && $modx->documentIdentifier) |
|
1084 | 1084 | $content = $modx->mergeDocumentContent($content); |
1085 | - if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content); |
|
1086 | - if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content); |
|
1087 | - if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content); |
|
1088 | - if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content); |
|
1085 | + if (strpos($content, '[(') !== false) $content = $modx->mergeSettingsContent($content); |
|
1086 | + if (strpos($content, '{{') !== false) $content = $modx->mergeChunkContent($content); |
|
1087 | + if (strpos($content, '[!') !== false) $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content); |
|
1088 | + if (strpos($content, '[[') !== false) $content = $modx->evalSnippets($content); |
|
1089 | 1089 | |
1090 | - if($content===$bt) break; |
|
1091 | - if($modx->maxParserPasses < $i) break; |
|
1090 | + if ($content === $bt) break; |
|
1091 | + if ($modx->maxParserPasses < $i) break; |
|
1092 | 1092 | $i++; |
1093 | 1093 | } |
1094 | 1094 | return $content; |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - public function getDocumentObject($target='',$field='pagetitle') |
|
1097 | + public function getDocumentObject($target = '', $field = 'pagetitle') |
|
1098 | 1098 | { |
1099 | 1099 | $modx = evolutionCMS(); |
1100 | 1100 | |
1101 | 1101 | $target = trim($target); |
1102 | - if(empty($target)) $target = $modx->config['site_start']; |
|
1103 | - if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id'; |
|
1102 | + if (empty($target)) $target = $modx->config['site_start']; |
|
1103 | + if (preg_match('@^[1-9][0-9]*$@', $target)) $method = 'id'; |
|
1104 | 1104 | else $method = 'alias'; |
1105 | 1105 | |
1106 | - if(!isset($this->documentObject[$target])) |
|
1106 | + if (!isset($this->documentObject[$target])) |
|
1107 | 1107 | { |
1108 | - $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct'); |
|
1108 | + $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct'); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | - if($this->documentObject[$target]['publishedon']==='0') |
|
1111 | + if ($this->documentObject[$target]['publishedon'] === '0') |
|
1112 | 1112 | return ''; |
1113 | - elseif(isset($this->documentObject[$target][$field])) |
|
1113 | + elseif (isset($this->documentObject[$target][$field])) |
|
1114 | 1114 | { |
1115 | - if(is_array($this->documentObject[$target][$field])) |
|
1115 | + if (is_array($this->documentObject[$target][$field])) |
|
1116 | 1116 | { |
1117 | - $a = $modx->getTemplateVarOutput($field,$target); |
|
1117 | + $a = $modx->getTemplateVarOutput($field, $target); |
|
1118 | 1118 | $this->documentObject[$target][$field] = $a[$field]; |
1119 | 1119 | } |
1120 | 1120 | } |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | return $this->documentObject[$target][$field]; |
1124 | 1124 | } |
1125 | 1125 | |
1126 | - public function setPlaceholders($value = '', $key = '', $path = '') { |
|
1127 | - if($path!=='') $key = "{$path}.{$key}"; |
|
1126 | + public function setPlaceholders($value = '', $key = '', $path = ''){ |
|
1127 | + if ($path !== '') $key = "{$path}.{$key}"; |
|
1128 | 1128 | if (is_array($value)) { |
1129 | 1129 | foreach ($value as $subkey => $subval) { |
1130 | 1130 | $this->setPlaceholders($subval, $subkey, $key); |
@@ -1134,77 +1134,77 @@ discard block |
||
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | // Sets a placeholder variable which can only be access by Modifiers |
1137 | - public function setModifiersVariable($key, $value) { |
|
1137 | + public function setModifiersVariable($key, $value){ |
|
1138 | 1138 | if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; |
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | //mbstring |
1142 | - public function substr($str, $s, $l = null) { |
|
1142 | + public function substr($str, $s, $l = null){ |
|
1143 | 1143 | $modx = evolutionCMS(); |
1144 | - if(is_null($l)) $l = $this->strlen($str); |
|
1144 | + if (is_null($l)) $l = $this->strlen($str); |
|
1145 | 1145 | if (function_exists('mb_substr')) |
1146 | 1146 | { |
1147 | - if(strpos($str,"\r")!==false) |
|
1148 | - $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
1147 | + if (strpos($str, "\r") !== false) |
|
1148 | + $str = str_replace(array("\r\n", "\r"), "\n", $str); |
|
1149 | 1149 | return mb_substr($str, $s, $l, $modx->config['modx_charset']); |
1150 | 1150 | } |
1151 | 1151 | return substr($str, $s, $l); |
1152 | 1152 | } |
1153 | - public function strpos($haystack,$needle,$offset=0) { |
|
1153 | + public function strpos($haystack, $needle, $offset = 0){ |
|
1154 | 1154 | $modx = evolutionCMS(); |
1155 | - if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
1156 | - return strpos($haystack,$needle,$offset); |
|
1155 | + if (function_exists('mb_strpos')) return mb_strpos($haystack, $needle, $offset, $modx->config['modx_charset']); |
|
1156 | + return strpos($haystack, $needle, $offset); |
|
1157 | 1157 | } |
1158 | - public function strlen($str) { |
|
1158 | + public function strlen($str){ |
|
1159 | 1159 | $modx = evolutionCMS(); |
1160 | - if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
1160 | + if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str), $modx->config['modx_charset']); |
|
1161 | 1161 | return strlen($str); |
1162 | 1162 | } |
1163 | - public function strtolower($str) { |
|
1163 | + public function strtolower($str){ |
|
1164 | 1164 | if (function_exists('mb_strtolower')) return mb_strtolower($str); |
1165 | 1165 | return strtolower($str); |
1166 | 1166 | } |
1167 | - public function strtoupper($str) { |
|
1167 | + public function strtoupper($str){ |
|
1168 | 1168 | if (function_exists('mb_strtoupper')) return mb_strtoupper($str); |
1169 | 1169 | return strtoupper($str); |
1170 | 1170 | } |
1171 | - public function ucfirst($str) { |
|
1171 | + public function ucfirst($str){ |
|
1172 | 1172 | if (function_exists('mb_strtoupper')) |
1173 | 1173 | return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
1174 | 1174 | return ucfirst($str); |
1175 | 1175 | } |
1176 | - public function lcfirst($str) { |
|
1176 | + public function lcfirst($str){ |
|
1177 | 1177 | if (function_exists('mb_strtolower')) |
1178 | 1178 | return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
1179 | 1179 | return lcfirst($str); |
1180 | 1180 | } |
1181 | - public function ucwords($str) { |
|
1181 | + public function ucwords($str){ |
|
1182 | 1182 | if (function_exists('mb_convert_case')) |
1183 | 1183 | return mb_convert_case($str, MB_CASE_TITLE); |
1184 | 1184 | return ucwords($str); |
1185 | 1185 | } |
1186 | - public function strrev($str) { |
|
1186 | + public function strrev($str){ |
|
1187 | 1187 | preg_match_all('/./us', $str, $ar); |
1188 | 1188 | return implode(array_reverse($ar[0])); |
1189 | 1189 | } |
1190 | - public function str_shuffle($str) { |
|
1190 | + public function str_shuffle($str){ |
|
1191 | 1191 | preg_match_all('/./us', $str, $ar); |
1192 | 1192 | shuffle($ar[0]); |
1193 | 1193 | return implode($ar[0]); |
1194 | 1194 | } |
1195 | - public function str_word_count($str) { |
|
1196 | - return count(preg_split('~[^\p{L}\p{N}\']+~u',$str)); |
|
1195 | + public function str_word_count($str){ |
|
1196 | + return count(preg_split('~[^\p{L}\p{N}\']+~u', $str)); |
|
1197 | 1197 | } |
1198 | - public function strip_tags($value,$params='') { |
|
1198 | + public function strip_tags($value, $params = ''){ |
|
1199 | 1199 | $modx = evolutionCMS(); |
1200 | 1200 | |
1201 | - if(stripos($params,'style')===false && stripos($value,'</style>')!==false) { |
|
1201 | + if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) { |
|
1202 | 1202 | $value = preg_replace('@<style.*?>.*?</style>@is', '', $value); |
1203 | 1203 | } |
1204 | - if(stripos($params,'script')===false && stripos($value,'</script>')!==false) { |
|
1204 | + if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) { |
|
1205 | 1205 | $value = preg_replace('@<script.*?>.*?</script>@is', '', $value); |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - return trim(strip_tags($value,$params)); |
|
1208 | + return trim(strip_tags($value, $params)); |
|
1209 | 1209 | } |
1210 | 1210 | } |
@@ -3,7 +3,8 @@ discard block |
||
3 | 3 | use EvolutionCMS\Interfaces\ModifiersInterface; |
4 | 4 | use DataGrid; |
5 | 5 | |
6 | -class Modifiers implements ModifiersInterface{ |
|
6 | +class Modifiers implements ModifiersInterface |
|
7 | +{ |
|
7 | 8 | /** |
8 | 9 | * @var array |
9 | 10 | */ |
@@ -61,7 +62,9 @@ discard block |
||
61 | 62 | public function __construct() |
62 | 63 | { |
63 | 64 | $modx = evolutionCMS(); |
64 | - if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']); |
|
65 | + if (function_exists('mb_internal_encoding')) { |
|
66 | + mb_internal_encoding($modx->config['modx_charset']); |
|
67 | + } |
|
65 | 68 | $this->condModifiers = '=,is,eq,equals,ne,neq,notequals,isnot,isnt,not,%,isempty,isnotempty,isntempty,>=,gte,eg,gte,greaterthan,>,gt,isgreaterthan,isgt,lowerthan,<,lt,<=,lte,islte,islowerthan,islt,el,find,in,inarray,in_array,fnmatch,wcard,wcard_match,wildcard,wildcard_match,is_file,is_dir,file_exists,is_readable,is_writable,is_image,regex,preg,preg_match,memberof,mo,isinrole,ir'; |
66 | 69 | } |
67 | 70 | |
@@ -74,7 +77,9 @@ discard block |
||
74 | 77 | public function phxFilter($key,$value,$modifiers) |
75 | 78 | { |
76 | 79 | $modx = evolutionCMS(); |
77 | - if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value); |
|
80 | + if(substr($modifiers,0,3)!=='id(') { |
|
81 | + $value = $this->parseDocumentSource($value); |
|
82 | + } |
|
78 | 83 | $this->srcValue = $value; |
79 | 84 | $modifiers = trim($modifiers); |
80 | 85 | $modifiers = ':'.trim($modifiers,':'); |
@@ -97,13 +102,18 @@ discard block |
||
97 | 102 | * @param string $modifiers |
98 | 103 | * @return bool|string |
99 | 104 | */ |
100 | - public function _getDelim($mode,$modifiers) { |
|
105 | + public function _getDelim($mode,$modifiers) |
|
106 | + { |
|
101 | 107 | $c = substr($modifiers,0,1); |
102 | - if(!in_array($c, array('"', "'", '`')) ) return false; |
|
108 | + if(!in_array($c, array('"', "'", '`')) ) { |
|
109 | + return false; |
|
110 | + } |
|
103 | 111 | |
104 | 112 | $modifiers = substr($modifiers,1); |
105 | 113 | $closure = $mode=='(' ? "{$c})" : $c; |
106 | - if(strpos($modifiers, $closure)===false) return false; |
|
114 | + if(strpos($modifiers, $closure)===false) { |
|
115 | + return false; |
|
116 | + } |
|
107 | 117 | |
108 | 118 | return $c; |
109 | 119 | } |
@@ -114,52 +124,65 @@ discard block |
||
114 | 124 | * @param string $modifiers |
115 | 125 | * @return bool|string |
116 | 126 | */ |
117 | - public function _getOpt($mode,$delim,$modifiers) { |
|
127 | + public function _getOpt($mode,$delim,$modifiers) |
|
128 | + { |
|
118 | 129 | if($delim) { |
119 | - if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
130 | + if($mode=='(') { |
|
131 | + return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
132 | + } |
|
120 | 133 | |
121 | 134 | return substr($modifiers,1,strpos($modifiers,$delim,1)-1); |
122 | - } |
|
123 | - else { |
|
124 | - if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') ); |
|
135 | + } else { |
|
136 | + if($mode=='(') { |
|
137 | + return substr($modifiers,0,strpos($modifiers, ')') ); |
|
138 | + } |
|
125 | 139 | |
126 | 140 | $chars = str_split($modifiers); |
127 | 141 | $opt=''; |
128 | 142 | foreach($chars as $c) { |
129 | - if($c==':' || $c==')') break; |
|
143 | + if($c==':' || $c==')') { |
|
144 | + break; |
|
145 | + } |
|
130 | 146 | $opt .=$c; |
131 | 147 | } |
132 | 148 | return $opt; |
133 | 149 | } |
134 | 150 | } |
135 | - public function _getRemainModifiers($mode,$delim,$modifiers) { |
|
151 | + public function _getRemainModifiers($mode,$delim,$modifiers) |
|
152 | + { |
|
136 | 153 | if($delim) { |
137 | - if($mode=='(') |
|
138 | - return $this->_fetchContent($modifiers, $delim . ')'); |
|
139 | - else { |
|
154 | + if($mode=='(') { |
|
155 | + return $this->_fetchContent($modifiers, $delim . ')'); |
|
156 | + } else { |
|
140 | 157 | $modifiers = trim($modifiers); |
141 | 158 | $modifiers = substr($modifiers,1); |
142 | 159 | return $this->_fetchContent($modifiers, $delim); |
143 | 160 | } |
144 | - } |
|
145 | - else { |
|
146 | - if($mode=='(') return $this->_fetchContent($modifiers, ')'); |
|
161 | + } else { |
|
162 | + if($mode=='(') { |
|
163 | + return $this->_fetchContent($modifiers, ')'); |
|
164 | + } |
|
147 | 165 | $chars = str_split($modifiers); |
148 | 166 | foreach($chars as $c) { |
149 | - if($c==':') return $modifiers; |
|
150 | - else $modifiers = substr($modifiers,1); |
|
167 | + if($c==':') { |
|
168 | + return $modifiers; |
|
169 | + } else { |
|
170 | + $modifiers = substr($modifiers,1); |
|
171 | + } |
|
151 | 172 | } |
152 | 173 | return $modifiers; |
153 | 174 | } |
154 | 175 | } |
155 | 176 | |
156 | - public function _fetchContent($string,$delim) { |
|
177 | + public function _fetchContent($string,$delim) |
|
178 | + { |
|
157 | 179 | $len = strlen($delim); |
158 | 180 | $string = $this->parseDocumentSource($string); |
159 | 181 | return substr($string,strpos($string, $delim)+$len); |
160 | 182 | } |
161 | 183 | |
162 | - public function splitEachModifiers($modifiers) { |
|
184 | + public function splitEachModifiers($modifiers) |
|
185 | + { |
|
163 | 186 | $modx = evolutionCMS(); |
164 | 187 | |
165 | 188 | $cmd = ''; |
@@ -170,11 +193,15 @@ discard block |
||
170 | 193 | $c = substr($modifiers,0,1); |
171 | 194 | $modifiers = substr($modifiers,1); |
172 | 195 | |
173 | - if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
196 | + if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { |
|
197 | +// :=, :!=, :<=, :>=, :!<=, :!>= |
|
174 | 198 | $c = substr($modifiers,strlen($match[1]),1); |
175 | 199 | $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]"; |
176 | - if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1); |
|
177 | - else $modifiers = substr($modifiers,strlen($match[1])); |
|
200 | + if($c==='(') { |
|
201 | + $modifiers = substr($modifiers,strlen($match[1])+1); |
|
202 | + } else { |
|
203 | + $modifiers = substr($modifiers,strlen($match[1])); |
|
204 | + } |
|
178 | 205 | |
179 | 206 | $delim = $this->_getDelim($c,$modifiers); |
180 | 207 | $opt = $this->_getOpt($c,$delim,$modifiers); |
@@ -182,13 +209,12 @@ discard block |
||
182 | 209 | |
183 | 210 | $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo); |
184 | 211 | $cmd = ''; |
185 | - } |
|
186 | - elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
212 | + } elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { |
|
213 | +// :+3, :-3, :*3 ... |
|
187 | 214 | $modifiers = substr($modifiers,strlen($match[0])); |
188 | 215 | $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]); |
189 | 216 | $cmd = ''; |
190 | - } |
|
191 | - elseif($c==='(' || $c==='=') { |
|
217 | + } elseif($c==='(' || $c==='=') { |
|
192 | 218 | $modifiers = $m1 = trim($modifiers); |
193 | 219 | $delim = $this->_getDelim($c,$modifiers); |
194 | 220 | $opt = $this->_getOpt($c,$delim,$modifiers); |
@@ -198,29 +224,29 @@ discard block |
||
198 | 224 | $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo); |
199 | 225 | |
200 | 226 | $cmd = ''; |
201 | - } |
|
202 | - elseif($c==':') { |
|
227 | + } elseif($c==':') { |
|
203 | 228 | $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]"; |
204 | - if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
229 | + if($cmd!=='') { |
|
230 | + $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
231 | + } |
|
205 | 232 | |
206 | 233 | $cmd = ''; |
207 | - } |
|
208 | - elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
234 | + } elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
209 | 235 | $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]"; |
210 | 236 | $cmd .= $c; |
211 | 237 | $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
212 | 238 | |
213 | 239 | break; |
214 | - } |
|
215 | - else { |
|
240 | + } else { |
|
216 | 241 | $cmd .= $c; |
217 | 242 | } |
218 | 243 | } |
219 | 244 | |
220 | - if(empty($result)) return array(); |
|
245 | + if(empty($result)) { |
|
246 | + return array(); |
|
247 | + } |
|
221 | 248 | |
222 | - foreach($result as $i=>$a) |
|
223 | - { |
|
249 | + foreach($result as $i=>$a) { |
|
224 | 250 | $a['opt'] = $this->parseDocumentSource($a['opt']); |
225 | 251 | $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders); |
226 | 252 | } |
@@ -233,22 +259,23 @@ discard block |
||
233 | 259 | $modx = evolutionCMS(); |
234 | 260 | $lastKey = ''; |
235 | 261 | $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true))); |
236 | - if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
237 | - if(empty($modifiers)) return ''; |
|
262 | + if(isset($this->tmpCache[$cacheKey])) { |
|
263 | + return $this->tmpCache[$cacheKey]; |
|
264 | + } |
|
265 | + if(empty($modifiers)) { |
|
266 | + return ''; |
|
267 | + } |
|
238 | 268 | |
239 | - foreach($modifiers as $m) |
|
240 | - { |
|
269 | + foreach($modifiers as $m) { |
|
241 | 270 | $lastKey = strtolower($m['cmd']); |
242 | 271 | } |
243 | 272 | $_ = explode(',',$this->condModifiers); |
244 | - if(in_array($lastKey,$_)) |
|
245 | - { |
|
273 | + if(in_array($lastKey,$_)) { |
|
246 | 274 | $modifiers[] = array('cmd'=>'then','opt'=>'1'); |
247 | 275 | $modifiers[] = array('cmd'=>'else','opt'=>'0'); |
248 | 276 | } |
249 | 277 | |
250 | - foreach($modifiers as $i=>$a) |
|
251 | - { |
|
278 | + foreach($modifiers as $i=>$a) { |
|
252 | 279 | $value = $this->Filter($key,$value, $a['cmd'], $a['opt']); |
253 | 280 | } |
254 | 281 | $this->tmpCache[$cacheKey] = $value; |
@@ -260,25 +287,32 @@ discard block |
||
260 | 287 | { |
261 | 288 | $modx = evolutionCMS(); |
262 | 289 | |
263 | - if($key==='documentObject') $value = $modx->documentIdentifier; |
|
290 | + if($key==='documentObject') { |
|
291 | + $value = $modx->documentIdentifier; |
|
292 | + } |
|
264 | 293 | $cmd = $this->parseDocumentSource($cmd); |
265 | - if(preg_match('@^[1-9][/0-9]*$@',$cmd)) |
|
266 | - { |
|
267 | - if(strpos($cmd,'/')!==false) |
|
268 | - $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
294 | + if(preg_match('@^[1-9][/0-9]*$@',$cmd)) { |
|
295 | + if(strpos($cmd,'/')!==false) { |
|
296 | + $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
297 | + } |
|
269 | 298 | $opt = $cmd; |
270 | 299 | $cmd = 'id'; |
271 | 300 | } |
272 | 301 | |
273 | - if(isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
274 | - elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
275 | - else $this->elmName = ''; |
|
302 | + if(isset($modx->snippetCache["phx:{$cmd}"])) { |
|
303 | + $this->elmName = "phx:{$cmd}"; |
|
304 | + } elseif(isset($modx->chunkCache["phx:{$cmd}"])) { |
|
305 | + $this->elmName = "phx:{$cmd}"; |
|
306 | + } else { |
|
307 | + $this->elmName = ''; |
|
308 | + } |
|
276 | 309 | |
277 | 310 | $cmd = strtolower($cmd); |
278 | - if($this->elmName!=='') |
|
279 | - $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
|
280 | - else |
|
281 | - $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
|
311 | + if($this->elmName!=='') { |
|
312 | + $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
|
313 | + } else { |
|
314 | + $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
|
315 | + } |
|
282 | 316 | |
283 | 317 | $value = str_replace('[+key+]', $key, $value); |
284 | 318 | |
@@ -287,29 +321,37 @@ discard block |
||
287 | 321 | |
288 | 322 | public function isEmpty($cmd,$value) |
289 | 323 | { |
290 | - if($value!=='') return false; |
|
324 | + if($value!=='') { |
|
325 | + return false; |
|
326 | + } |
|
291 | 327 | |
292 | 328 | $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
293 | - if(in_array($cmd,$_)) return false; |
|
294 | - else return true; |
|
329 | + if(in_array($cmd,$_)) { |
|
330 | + return false; |
|
331 | + } else { |
|
332 | + return true; |
|
333 | + } |
|
295 | 334 | } |
296 | 335 | |
297 | 336 | public function getValueFromPreset($key, $value, $cmd, $opt) |
298 | 337 | { |
299 | 338 | $modx = evolutionCMS(); |
300 | 339 | |
301 | - if($this->isEmpty($cmd,$value)) return ''; |
|
340 | + if($this->isEmpty($cmd,$value)) { |
|
341 | + return ''; |
|
342 | + } |
|
302 | 343 | |
303 | 344 | $this->key = $key; |
304 | 345 | $this->value = $value; |
305 | 346 | $this->opt = $opt; |
306 | 347 | |
307 | - switch ($cmd) |
|
308 | - { |
|
348 | + switch ($cmd) { |
|
309 | 349 | ##### Conditional Modifiers |
310 | 350 | case 'input': |
311 | 351 | case 'if': |
312 | - if(!$opt) return $value; |
|
352 | + if(!$opt) { |
|
353 | + return $value; |
|
354 | + } |
|
313 | 355 | return $opt; |
314 | 356 | case '=': |
315 | 357 | case 'eq': |
@@ -370,14 +412,24 @@ discard block |
||
370 | 412 | case 'file_exists': |
371 | 413 | case 'is_readable': |
372 | 414 | case 'is_writable': |
373 | - if(!$opt) $path = $value; |
|
374 | - else $path = $opt; |
|
375 | - if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path'); |
|
376 | - if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/'); |
|
415 | + if(!$opt) { |
|
416 | + $path = $value; |
|
417 | + } else { |
|
418 | + $path = $opt; |
|
419 | + } |
|
420 | + if(strpos($path,MODX_MANAGER_PATH)!==false) { |
|
421 | + exit('Can not read core path'); |
|
422 | + } |
|
423 | + if(strpos($path,$modx->config['base_path'])===false) { |
|
424 | + $path = ltrim($path,'/'); |
|
425 | + } |
|
377 | 426 | $this->condition[] = (int)($cmd($path)!==false);break; |
378 | 427 | case 'is_image': |
379 | - if(!$opt) $path = $value; |
|
380 | - else $path = $opt; |
|
428 | + if(!$opt) { |
|
429 | + $path = $value; |
|
430 | + } else { |
|
431 | + $path = $opt; |
|
432 | + } |
|
381 | 433 | if(!is_file($path)) {$this->condition[]='0';break;} |
382 | 434 | $_ = getimagesize($path); |
383 | 435 | $this->condition[] = (int)($_[0]);break; |
@@ -400,17 +452,23 @@ discard block |
||
400 | 452 | case 'this': |
401 | 453 | $conditional = implode(' ',$this->condition); |
402 | 454 | $isvalid = (int)(eval("return ({$conditional});")); |
403 | - if ($isvalid) return $this->srcValue; |
|
455 | + if ($isvalid) { |
|
456 | + return $this->srcValue; |
|
457 | + } |
|
404 | 458 | return NULL; |
405 | 459 | case 'then': |
406 | 460 | $conditional = implode(' ',$this->condition); |
407 | 461 | $isvalid = (int)eval("return ({$conditional});"); |
408 | - if ($isvalid) return $opt; |
|
462 | + if ($isvalid) { |
|
463 | + return $opt; |
|
464 | + } |
|
409 | 465 | return null; |
410 | 466 | case 'else': |
411 | 467 | $conditional = implode(' ',$this->condition); |
412 | 468 | $isvalid = (int)eval("return ({$conditional});"); |
413 | - if (!$isvalid) return $opt; |
|
469 | + if (!$isvalid) { |
|
470 | + return $opt; |
|
471 | + } |
|
414 | 472 | break; |
415 | 473 | case 'select': |
416 | 474 | case 'switch': |
@@ -421,8 +479,11 @@ discard block |
||
421 | 479 | $mi = explode('=',$raw[$m],2); |
422 | 480 | $map[$mi[0]] = $mi[1]; |
423 | 481 | } |
424 | - if(isset($map[$value])) return $map[$value]; |
|
425 | - else return ''; |
|
482 | + if(isset($map[$value])) { |
|
483 | + return $map[$value]; |
|
484 | + } else { |
|
485 | + return ''; |
|
486 | + } |
|
426 | 487 | ##### End of Conditional Modifiers |
427 | 488 | |
428 | 489 | ##### Encode / Decode / Hash / Escape |
@@ -448,24 +509,25 @@ discard block |
||
448 | 509 | case 'spam_protect': |
449 | 510 | return str_replace(array('@','.'),array('@','.'),$value); |
450 | 511 | case 'strip': |
451 | - if($opt==='') $opt = ' '; |
|
512 | + if($opt==='') { |
|
513 | + $opt = ' '; |
|
514 | + } |
|
452 | 515 | return preg_replace('/[\n\r\t\s]+/', $opt, $value); |
453 | 516 | case 'strip_linefeeds': |
454 | 517 | return str_replace(array("\n","\r"), '', $value); |
455 | 518 | case 'notags': |
456 | 519 | case 'strip_tags': |
457 | 520 | case 'remove_html': |
458 | - if($opt!=='') |
|
459 | - { |
|
521 | + if($opt!=='') { |
|
460 | 522 | $param = array(); |
461 | - foreach(explode(',',$opt) as $v) |
|
462 | - { |
|
523 | + foreach(explode(',',$opt) as $v) { |
|
463 | 524 | $v = trim($v,'</> '); |
464 | 525 | $param[] = "<{$v}>"; |
465 | 526 | } |
466 | 527 | $params = implode(',',$param); |
528 | + } else { |
|
529 | + $params = ''; |
|
467 | 530 | } |
468 | - else $params = ''; |
|
469 | 531 | if(!strpos($params,'<br>')===false) { |
470 | 532 | $value = preg_replace('@(<br[ /]*>)\n@','$1',$value); |
471 | 533 | $value = preg_replace('@<br[ /]*>@',"\n",$value); |
@@ -476,8 +538,11 @@ discard block |
||
476 | 538 | case 'encode_url': |
477 | 539 | return urlencode($value); |
478 | 540 | case 'base64_decode': |
479 | - if($opt!=='false') $opt = true; |
|
480 | - else $opt = false; |
|
541 | + if($opt!=='false') { |
|
542 | + $opt = true; |
|
543 | + } else { |
|
544 | + $opt = false; |
|
545 | + } |
|
481 | 546 | return base64_decode($value,$opt); |
482 | 547 | case 'encode_sha1': $cmd = 'sha1'; |
483 | 548 | case 'addslashes': |
@@ -503,16 +568,19 @@ discard block |
||
503 | 568 | return $this->strtoupper($value); |
504 | 569 | case 'capitalize': |
505 | 570 | $_ = explode(' ',$value); |
506 | - foreach($_ as $i=>$v) |
|
507 | - { |
|
571 | + foreach($_ as $i=>$v) { |
|
508 | 572 | $_[$i] = ucfirst($v); |
509 | 573 | } |
510 | 574 | return implode(' ',$_); |
511 | 575 | case 'zenhan': |
512 | - if(empty($opt)) $opt='VKas'; |
|
576 | + if(empty($opt)) { |
|
577 | + $opt='VKas'; |
|
578 | + } |
|
513 | 579 | return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
514 | 580 | case 'hanzen': |
515 | - if(empty($opt)) $opt='VKAS'; |
|
581 | + if(empty($opt)) { |
|
582 | + $opt='VKAS'; |
|
583 | + } |
|
516 | 584 | return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
517 | 585 | case 'str_shuffle': |
518 | 586 | case 'shuffle': |
@@ -537,13 +605,18 @@ discard block |
||
537 | 605 | $value = preg_replace('/\r/', '', $value); |
538 | 606 | return count(preg_split('/\n+/',$value)); |
539 | 607 | case 'strpos': |
540 | - if($opt!=0&&empty($opt)) return $value; |
|
608 | + if($opt!=0&&empty($opt)) { |
|
609 | + return $value; |
|
610 | + } |
|
541 | 611 | return $this->strpos($value,$opt); |
542 | 612 | case 'wordwrap': |
543 | 613 | // default: 70 |
544 | 614 | $wrapat = (int)$opt > 0 ? (int)$opt : 70; |
545 | - if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap'); |
|
546 | - else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); |
|
615 | + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { |
|
616 | + return $this->includeMdfFile('wordwrap'); |
|
617 | + } else { |
|
618 | + return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); |
|
619 | + } |
|
547 | 620 | case 'wrap_text': |
548 | 621 | $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70; |
549 | 622 | if($modx->config['manager_language']==='japanese-utf8') { |
@@ -559,30 +632,36 @@ discard block |
||
559 | 632 | $value = $this->substr($value,$width); |
560 | 633 | } |
561 | 634 | return implode("\n",$chunk); |
635 | + } else { |
|
636 | + return wordwrap($value,$width,"\n",true); |
|
562 | 637 | } |
563 | - else |
|
564 | - return wordwrap($value,$width,"\n",true); |
|
565 | 638 | case 'substr': |
566 | - if(empty($opt)) break; |
|
639 | + if(empty($opt)) { |
|
640 | + break; |
|
641 | + } |
|
567 | 642 | if(strpos($opt,',')!==false) { |
568 | 643 | list($b,$e) = explode(',',$opt,2); |
569 | 644 | return $this->substr($value,$b,(int)$e); |
645 | + } else { |
|
646 | + return $this->substr($value,$opt); |
|
570 | 647 | } |
571 | - else return $this->substr($value,$opt); |
|
572 | 648 | case 'limit': |
573 | 649 | case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html |
574 | - if(strpos($opt,'+')!==false) |
|
575 | - list($len,$str) = explode('+',$opt,2); |
|
576 | - else { |
|
650 | + if(strpos($opt,'+')!==false) { |
|
651 | + list($len,$str) = explode('+',$opt,2); |
|
652 | + } else { |
|
577 | 653 | $len = $opt; |
578 | 654 | $str = ''; |
579 | 655 | } |
580 | - if($len==='') $len = 100; |
|
581 | - if(abs($len) > $this->strlen($value)) $str =''; |
|
656 | + if($len==='') { |
|
657 | + $len = 100; |
|
658 | + } |
|
659 | + if(abs($len) > $this->strlen($value)) { |
|
660 | + $str =''; |
|
661 | + } |
|
582 | 662 | if(preg_match('/^[1-9][0-9]*$/',$len)) { |
583 | 663 | return $this->substr($value,0,$len) . $str; |
584 | - } |
|
585 | - elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
664 | + } elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
586 | 665 | return $str . $this->substr($value,$len); |
587 | 666 | } |
588 | 667 | break; |
@@ -592,18 +671,30 @@ discard block |
||
592 | 671 | return $this->includeMdfFile('summary'); |
593 | 672 | case 'replace': |
594 | 673 | case 'str_replace': |
595 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
596 | - if (substr_count($opt, ',') ==1) $delim = ','; |
|
597 | - elseif(substr_count($opt, '|') ==1) $delim = '|'; |
|
598 | - elseif(substr_count($opt, '=>')==1) $delim = '=>'; |
|
599 | - elseif(substr_count($opt, '/') ==1) $delim = '/'; |
|
600 | - else break; |
|
674 | + if(empty($opt) || strpos($opt,',')===false) { |
|
675 | + break; |
|
676 | + } |
|
677 | + if (substr_count($opt, ',') ==1) { |
|
678 | + $delim = ','; |
|
679 | + } elseif(substr_count($opt, '|') ==1) { |
|
680 | + $delim = '|'; |
|
681 | + } elseif(substr_count($opt, '=>')==1) { |
|
682 | + $delim = '=>'; |
|
683 | + } elseif(substr_count($opt, '/') ==1) { |
|
684 | + $delim = '/'; |
|
685 | + } else { |
|
686 | + break; |
|
687 | + } |
|
601 | 688 | list($s,$r) = explode($delim,$opt); |
602 | - if($value!=='') return str_replace($s,$r,$value); |
|
689 | + if($value!=='') { |
|
690 | + return str_replace($s,$r,$value); |
|
691 | + } |
|
603 | 692 | break; |
604 | 693 | case 'replace_to': |
605 | 694 | case 'tpl': |
606 | - if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
695 | + if($value!=='') { |
|
696 | + return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
697 | + } |
|
607 | 698 | break; |
608 | 699 | case 'eachtpl': |
609 | 700 | $value = explode('||',$value); |
@@ -614,59 +705,83 @@ discard block |
||
614 | 705 | return implode("\n", $_); |
615 | 706 | case 'array_pop': |
616 | 707 | case 'array_shift': |
617 | - if(strpos($value,'||')!==false) $delim = '||'; |
|
618 | - else $delim = ','; |
|
708 | + if(strpos($value,'||')!==false) { |
|
709 | + $delim = '||'; |
|
710 | + } else { |
|
711 | + $delim = ','; |
|
712 | + } |
|
619 | 713 | return $cmd(explode($delim,$value)); |
620 | 714 | case 'preg_replace': |
621 | 715 | case 'regex_replace': |
622 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
716 | + if(empty($opt) || strpos($opt,',')===false) { |
|
717 | + break; |
|
718 | + } |
|
623 | 719 | list($s,$r) = explode(',',$opt,2); |
624 | - if($value!=='') return preg_replace($s,$r,$value); |
|
720 | + if($value!=='') { |
|
721 | + return preg_replace($s,$r,$value); |
|
722 | + } |
|
625 | 723 | break; |
626 | 724 | case 'cat': |
627 | 725 | case 'concatenate': |
628 | 726 | case '.': |
629 | - if($value!=='') return $value . $opt; |
|
727 | + if($value!=='') { |
|
728 | + return $value . $opt; |
|
729 | + } |
|
630 | 730 | break; |
631 | 731 | case 'sprintf': |
632 | 732 | case 'string_format': |
633 | - if($value!=='') return sprintf($opt,$value); |
|
733 | + if($value!=='') { |
|
734 | + return sprintf($opt,$value); |
|
735 | + } |
|
634 | 736 | break; |
635 | 737 | case 'number_format': |
636 | - if($opt=='') $opt = 0; |
|
738 | + if($opt=='') { |
|
739 | + $opt = 0; |
|
740 | + } |
|
637 | 741 | return number_format($value,$opt); |
638 | 742 | case 'money_format': |
639 | 743 | setlocale(LC_MONETARY,setlocale(LC_TIME,0)); |
640 | - if($value!=='') return money_format($opt,(double)$value); |
|
744 | + if($value!=='') { |
|
745 | + return money_format($opt,(double)$value); |
|
746 | + } |
|
641 | 747 | break; |
642 | 748 | case 'tobool': |
643 | 749 | return boolval($value); |
644 | 750 | case 'nl2lf': |
645 | - if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
751 | + if($value!=='') { |
|
752 | + return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
753 | + } |
|
646 | 754 | break; |
647 | 755 | case 'br2nl': |
648 | 756 | return preg_replace('@<br[\s/]*>@i', "\n", $value); |
649 | 757 | case 'nl2br': |
650 | - if (version_compare(PHP_VERSION, '5.3.0', '<')) |
|
651 | - return nl2br($value); |
|
652 | - if($opt!=='') |
|
653 | - { |
|
758 | + if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
759 | + return nl2br($value); |
|
760 | + } |
|
761 | + if($opt!=='') { |
|
654 | 762 | $opt = trim($opt); |
655 | 763 | $opt = strtolower($opt); |
656 | - if($opt==='false') $opt = false; |
|
657 | - elseif($opt==='0') $opt = false; |
|
658 | - else $opt = true; |
|
764 | + if($opt==='false') { |
|
765 | + $opt = false; |
|
766 | + } elseif($opt==='0') { |
|
767 | + $opt = false; |
|
768 | + } else { |
|
769 | + $opt = true; |
|
770 | + } |
|
771 | + } elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') { |
|
772 | + $opt = false; |
|
773 | + } else { |
|
774 | + $opt = true; |
|
659 | 775 | } |
660 | - elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') |
|
661 | - $opt = false; |
|
662 | - else $opt = true; |
|
663 | 776 | return nl2br($value,$opt); |
664 | 777 | case 'ltrim': |
665 | 778 | case 'rtrim': |
666 | 779 | case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html |
667 | - if($opt==='') |
|
668 | - return $cmd($value); |
|
669 | - else return $cmd($value,$opt); |
|
780 | + if($opt==='') { |
|
781 | + return $cmd($value); |
|
782 | + } else { |
|
783 | + return $cmd($value,$opt); |
|
784 | + } |
|
670 | 785 | // These are all straight wrappers for PHP functions |
671 | 786 | case 'ucfirst': |
672 | 787 | case 'lcfirst': |
@@ -677,15 +792,24 @@ discard block |
||
677 | 792 | case 'strftime': |
678 | 793 | case 'date': |
679 | 794 | case 'dateformat': |
680 | - if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
681 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
682 | - if(strpos($opt,'%')!==false) |
|
683 | - return strftime($opt,0+$value); |
|
684 | - else |
|
685 | - return date($opt,0+$value); |
|
795 | + if(empty($opt)) { |
|
796 | + $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
797 | + } |
|
798 | + if(!preg_match('@^[0-9]+$@',$value)) { |
|
799 | + $value = strtotime($value); |
|
800 | + } |
|
801 | + if(strpos($opt,'%')!==false) { |
|
802 | + return strftime($opt,0+$value); |
|
803 | + } else { |
|
804 | + return date($opt,0+$value); |
|
805 | + } |
|
686 | 806 | case 'time': |
687 | - if(empty($opt)) $opt = '%H:%M'; |
|
688 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
807 | + if(empty($opt)) { |
|
808 | + $opt = '%H:%M'; |
|
809 | + } |
|
810 | + if(!preg_match('@^[0-9]+$@',$value)) { |
|
811 | + $value = strtotime($value); |
|
812 | + } |
|
689 | 813 | return strftime($opt,0+$value); |
690 | 814 | case 'strtotime': |
691 | 815 | return strtotime($value); |
@@ -695,7 +819,9 @@ discard block |
||
695 | 819 | case 'tofloat': |
696 | 820 | return floatval($value); |
697 | 821 | case 'round': |
698 | - if(!$opt) $opt = 0; |
|
822 | + if(!$opt) { |
|
823 | + $opt = 0; |
|
824 | + } |
|
699 | 825 | return $cmd($value,$opt); |
700 | 826 | case 'max': |
701 | 827 | case 'min': |
@@ -707,28 +833,42 @@ discard block |
||
707 | 833 | case 'math': |
708 | 834 | case 'calc': |
709 | 835 | $value = (int)$value; |
710 | - if(empty($value)) $value = '0'; |
|
836 | + if(empty($value)) { |
|
837 | + $value = '0'; |
|
838 | + } |
|
711 | 839 | $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt); |
712 | 840 | $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter); |
713 | - if(strpos($filter,'?')===false) $filter = "?{$filter}"; |
|
841 | + if(strpos($filter,'?')===false) { |
|
842 | + $filter = "?{$filter}"; |
|
843 | + } |
|
714 | 844 | $filter = str_replace('?',$value,$filter); |
715 | 845 | return eval("return {$filter};"); |
716 | 846 | case 'count': |
717 | - if($value=='') return 0; |
|
847 | + if($value=='') { |
|
848 | + return 0; |
|
849 | + } |
|
718 | 850 | $value = explode(',',$value); |
719 | 851 | return count($value); |
720 | 852 | case 'sort': |
721 | 853 | case 'rsort': |
722 | - if(strpos($value,"\n")!==false) $delim="\n"; |
|
723 | - else $delim = ','; |
|
854 | + if(strpos($value,"\n")!==false) { |
|
855 | + $delim="\n"; |
|
856 | + } else { |
|
857 | + $delim = ','; |
|
858 | + } |
|
724 | 859 | $swap = explode($delim,$value); |
725 | - if(!$opt) $opt = SORT_REGULAR; |
|
726 | - else $opt = constant($opt); |
|
860 | + if(!$opt) { |
|
861 | + $opt = SORT_REGULAR; |
|
862 | + } else { |
|
863 | + $opt = constant($opt); |
|
864 | + } |
|
727 | 865 | $cmd($swap,$opt); |
728 | 866 | return implode($delim,$swap); |
729 | 867 | ##### Resource fields |
730 | 868 | case 'id': |
731 | - if($opt) return $this->getDocumentObject($opt,$key); |
|
869 | + if($opt) { |
|
870 | + return $this->getDocumentObject($opt,$key); |
|
871 | + } |
|
732 | 872 | break; |
733 | 873 | case 'type': |
734 | 874 | case 'contenttype': |
@@ -765,7 +905,9 @@ discard block |
||
765 | 905 | case 'privatemgr': |
766 | 906 | case 'content_dispo': |
767 | 907 | case 'hidemenu': |
768 | - if($cmd==='contenttype') $cmd = 'contentType'; |
|
908 | + if($cmd==='contenttype') { |
|
909 | + $cmd = 'contentType'; |
|
910 | + } |
|
769 | 911 | return $this->getDocumentObject($value,$cmd); |
770 | 912 | case 'title': |
771 | 913 | $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
@@ -780,13 +922,20 @@ discard block |
||
780 | 922 | $templateName = $modx->getDatabase()->getValue($rs); |
781 | 923 | return !$templateName ? '(blank)' : $templateName; |
782 | 924 | case 'getfield': |
783 | - if(!$opt) $opt = 'content'; |
|
925 | + if(!$opt) { |
|
926 | + $opt = 'content'; |
|
927 | + } |
|
784 | 928 | return $modx->getField($opt,$value); |
785 | 929 | case 'children': |
786 | 930 | case 'childids': |
787 | - if($value=='') $value = 0; // 値がない場合はルートと見なす |
|
931 | + if($value=='') { |
|
932 | + $value = 0; |
|
933 | + } |
|
934 | + // 値がない場合はルートと見なす |
|
788 | 935 | $published = 1; |
789 | - if($opt=='') $opt = 'page'; |
|
936 | + if($opt=='') { |
|
937 | + $opt = 'page'; |
|
938 | + } |
|
790 | 939 | $_ = explode(',',$opt); |
791 | 940 | $where = array(); |
792 | 941 | foreach($_ as $opt) { |
@@ -802,29 +951,43 @@ discard block |
||
802 | 951 | $where = implode(' AND ', $where); |
803 | 952 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); |
804 | 953 | $result = array(); |
805 | - foreach((array)$children as $child){ |
|
954 | + foreach((array)$children as $child) { |
|
806 | 955 | $result[] = $child['id']; |
807 | 956 | } |
808 | 957 | return implode(',', $result); |
809 | 958 | case 'fullurl': |
810 | - if(!is_numeric($value)) return $value; |
|
959 | + if(!is_numeric($value)) { |
|
960 | + return $value; |
|
961 | + } |
|
811 | 962 | return $modx->makeUrl($value); |
812 | 963 | case 'makeurl': |
813 | - if(!is_numeric($value)) return $value; |
|
814 | - if(!$opt) $opt = 'full'; |
|
964 | + if(!is_numeric($value)) { |
|
965 | + return $value; |
|
966 | + } |
|
967 | + if(!$opt) { |
|
968 | + $opt = 'full'; |
|
969 | + } |
|
815 | 970 | return $modx->makeUrl($value,'','',$opt); |
816 | 971 | |
817 | 972 | ##### File system |
818 | 973 | case 'getimageinfo': |
819 | 974 | case 'imageinfo': |
820 | - if(!is_file($value)) return ''; |
|
975 | + if(!is_file($value)) { |
|
976 | + return ''; |
|
977 | + } |
|
821 | 978 | $_ = getimagesize($value); |
822 | - if(!$_[0]) return ''; |
|
979 | + if(!$_[0]) { |
|
980 | + return ''; |
|
981 | + } |
|
823 | 982 | $info['width'] = $_[0]; |
824 | 983 | $info['height'] = $_[1]; |
825 | - if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
826 | - elseif($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
827 | - else $info['aspect'] = 'square'; |
|
984 | + if ($_[0] > $_[1]) { |
|
985 | + $info['aspect'] = 'landscape'; |
|
986 | + } elseif($_[0] < $_[1]) { |
|
987 | + $info['aspect'] = 'portrait'; |
|
988 | + } else { |
|
989 | + $info['aspect'] = 'square'; |
|
990 | + } |
|
828 | 991 | switch($_[2]) { |
829 | 992 | case IMAGETYPE_GIF : $info['type'] = 'gif'; break; |
830 | 993 | case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break; |
@@ -843,33 +1006,47 @@ discard block |
||
843 | 1006 | |
844 | 1007 | case 'file_get_contents': |
845 | 1008 | case 'readfile': |
846 | - if(!is_file($value)) return $value; |
|
1009 | + if(!is_file($value)) { |
|
1010 | + return $value; |
|
1011 | + } |
|
847 | 1012 | $value = realpath($value); |
848 | - if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file'); |
|
1013 | + if(strpos($value,MODX_MANAGER_PATH)!==false) { |
|
1014 | + exit('Can not read core file'); |
|
1015 | + } |
|
849 | 1016 | $ext = strtolower(substr($value,-4)); |
850 | - if($ext==='.php') exit('Can not read php file'); |
|
851 | - if($ext==='.cgi') exit('Can not read cgi file'); |
|
1017 | + if($ext==='.php') { |
|
1018 | + exit('Can not read php file'); |
|
1019 | + } |
|
1020 | + if($ext==='.cgi') { |
|
1021 | + exit('Can not read cgi file'); |
|
1022 | + } |
|
852 | 1023 | return file_get_contents($value); |
853 | 1024 | case 'filesize': |
854 | - if($value == '') return ''; |
|
1025 | + if($value == '') { |
|
1026 | + return ''; |
|
1027 | + } |
|
855 | 1028 | $filename = $value; |
856 | 1029 | |
857 | 1030 | $site_url = $modx->config['site_url']; |
858 | - if(strpos($filename,$site_url) === 0) |
|
859 | - $filename = substr($filename,0,strlen($site_url)); |
|
1031 | + if(strpos($filename,$site_url) === 0) { |
|
1032 | + $filename = substr($filename,0,strlen($site_url)); |
|
1033 | + } |
|
860 | 1034 | $filename = trim($filename,'/'); |
861 | 1035 | |
862 | 1036 | $opt = trim($opt,'/'); |
863 | - if($opt!=='') $opt .= '/'; |
|
1037 | + if($opt!=='') { |
|
1038 | + $opt .= '/'; |
|
1039 | + } |
|
864 | 1040 | |
865 | 1041 | $filename = MODX_BASE_PATH.$opt.$filename; |
866 | 1042 | |
867 | - if(is_file($filename)){ |
|
1043 | + if(is_file($filename)) { |
|
868 | 1044 | clearstatcache(); |
869 | 1045 | $size = filesize($filename); |
870 | 1046 | return $size; |
1047 | + } else { |
|
1048 | + return ''; |
|
871 | 1049 | } |
872 | - else return ''; |
|
873 | 1050 | ##### User info |
874 | 1051 | case 'username': |
875 | 1052 | case 'fullname': |
@@ -897,32 +1074,47 @@ discard block |
||
897 | 1074 | $this->opt = $cmd; |
898 | 1075 | return $this->includeMdfFile('moduser'); |
899 | 1076 | case 'userinfo': |
900 | - if(empty($opt)) $this->opt = 'username'; |
|
1077 | + if(empty($opt)) { |
|
1078 | + $this->opt = 'username'; |
|
1079 | + } |
|
901 | 1080 | return $this->includeMdfFile('moduser'); |
902 | 1081 | case 'webuserinfo': |
903 | - if(empty($opt)) $this->opt = 'username'; |
|
1082 | + if(empty($opt)) { |
|
1083 | + $this->opt = 'username'; |
|
1084 | + } |
|
904 | 1085 | $this->value = -$value; |
905 | 1086 | return $this->includeMdfFile('moduser'); |
906 | 1087 | ##### Special functions |
907 | 1088 | case 'ifempty': |
908 | 1089 | case '_default': |
909 | 1090 | case 'default': |
910 | - if (empty($value)) return $opt; break; |
|
1091 | + if (empty($value)) { |
|
1092 | + return $opt; |
|
1093 | + } |
|
1094 | + break; |
|
911 | 1095 | case 'ifnotempty': |
912 | - if (!empty($value)) return $opt; break; |
|
1096 | + if (!empty($value)) { |
|
1097 | + return $opt; |
|
1098 | + } |
|
1099 | + break; |
|
913 | 1100 | case 'datagrid': |
914 | 1101 | include_once(MODX_CORE_PATH . 'controls/datagrid.class.php'); |
915 | 1102 | $grd = new DataGrid(null, trim($value)); |
916 | 1103 | $grd->itemStyle = ''; |
917 | 1104 | $grd->altItemStyle = ''; |
918 | 1105 | $pos = strpos($value,"\n"); |
919 | - if($pos) $_ = substr($value,0,$pos); |
|
920 | - else $_ = $pos; |
|
1106 | + if($pos) { |
|
1107 | + $_ = substr($value,0,$pos); |
|
1108 | + } else { |
|
1109 | + $_ = $pos; |
|
1110 | + } |
|
921 | 1111 | $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ','; |
922 | 1112 | return $grd->render(); |
923 | 1113 | case 'rotate': |
924 | 1114 | case 'evenodd': |
925 | - if(strpos($opt,',')===false) $opt = 'odd,even'; |
|
1115 | + if(strpos($opt,',')===false) { |
|
1116 | + $opt = 'odd,even'; |
|
1117 | + } |
|
926 | 1118 | $_ = explode(',', $opt); |
927 | 1119 | $c = count($_); |
928 | 1120 | $i = $value + $c; |
@@ -931,7 +1123,9 @@ discard block |
||
931 | 1123 | case 'takeval': |
932 | 1124 | $arr = explode(",",$opt); |
933 | 1125 | $idx = $value; |
934 | - if(!is_numeric($idx)) return $value; |
|
1126 | + if(!is_numeric($idx)) { |
|
1127 | + return $value; |
|
1128 | + } |
|
935 | 1129 | return $arr[$idx]; |
936 | 1130 | case 'getimage': |
937 | 1131 | return $this->includeMdfFile('getimage'); |
@@ -939,14 +1133,18 @@ discard block |
||
939 | 1133 | return $modx->nicesize($value); |
940 | 1134 | case 'googlemap': |
941 | 1135 | case 'googlemaps': |
942 | - if(empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
1136 | + if(empty($opt)) { |
|
1137 | + $opt = 'border:none;width:500px;height:350px;'; |
|
1138 | + } |
|
943 | 1139 | $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>'; |
944 | 1140 | $ph['style'] = $opt; |
945 | 1141 | $ph['value'] = $value; |
946 | 1142 | return $modx->parseText($tpl,$ph); |
947 | 1143 | case 'youtube': |
948 | 1144 | case 'youtube16x9': |
949 | - if(empty($opt)) $opt = 560; |
|
1145 | + if(empty($opt)) { |
|
1146 | + $opt = 560; |
|
1147 | + } |
|
950 | 1148 | $h = round($opt*0.5625); |
951 | 1149 | $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>'; |
952 | 1150 | return sprintf($tpl,$opt,$h,$value); |
@@ -979,7 +1177,8 @@ discard block |
||
979 | 1177 | return $value; |
980 | 1178 | } |
981 | 1179 | |
982 | - public function includeMdfFile($cmd) { |
|
1180 | + public function includeMdfFile($cmd) |
|
1181 | + { |
|
983 | 1182 | $modx = evolutionCMS(); |
984 | 1183 | $key = $this->key; |
985 | 1184 | $value = $this->value; |
@@ -990,55 +1189,65 @@ discard block |
||
990 | 1189 | public function getValueFromElement($key, $value, $cmd, $opt) |
991 | 1190 | { |
992 | 1191 | $modx = evolutionCMS(); |
993 | - if( isset($modx->snippetCache[$this->elmName]) ) |
|
994 | - { |
|
1192 | + if( isset($modx->snippetCache[$this->elmName]) ) { |
|
995 | 1193 | $php = $modx->snippetCache[$this->elmName]; |
996 | - } |
|
997 | - else |
|
998 | - { |
|
1194 | + } else { |
|
999 | 1195 | $esc_elmName = $modx->getDatabase()->escape($this->elmName); |
1000 | 1196 | $result = $modx->getDatabase()->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'"); |
1001 | 1197 | $total = $modx->getDatabase()->getRecordCount($result); |
1002 | - if($total == 1) |
|
1003 | - { |
|
1198 | + if($total == 1) { |
|
1004 | 1199 | $row = $modx->getDatabase()->getRow($result); |
1005 | 1200 | $php = $row['snippet']; |
1006 | - } |
|
1007 | - elseif($total == 0) |
|
1008 | - { |
|
1201 | + } elseif($total == 0) { |
|
1009 | 1202 | $assets_path = MODX_BASE_PATH.'assets/'; |
1010 | - if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
1011 | - $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
|
1012 | - elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
1013 | - $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
|
1014 | - elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
1015 | - $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
|
1016 | - else $modifiers_path = false; |
|
1203 | + if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) { |
|
1204 | + $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
|
1205 | + } elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) { |
|
1206 | + $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
|
1207 | + } elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) { |
|
1208 | + $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
|
1209 | + } else { |
|
1210 | + $modifiers_path = false; |
|
1211 | + } |
|
1017 | 1212 | |
1018 | 1213 | if($modifiers_path !== false) { |
1019 | 1214 | $php = @file_get_contents($modifiers_path); |
1020 | 1215 | $php = trim($php); |
1021 | - if(substr($php,0,5)==='<?php') $php = substr($php,6); |
|
1022 | - if(substr($php,0,2)==='<?') $php = substr($php,3); |
|
1023 | - if(substr($php,-2)==='?>') $php = substr($php,0,-2); |
|
1024 | - if($this->elmName!=='') |
|
1025 | - $modx->snippetCache[$this->elmName.'Props'] = ''; |
|
1026 | - } |
|
1027 | - else |
|
1028 | - $php = false; |
|
1216 | + if(substr($php,0,5)==='<?php') { |
|
1217 | + $php = substr($php,6); |
|
1218 | + } |
|
1219 | + if(substr($php,0,2)==='<?') { |
|
1220 | + $php = substr($php,3); |
|
1221 | + } |
|
1222 | + if(substr($php,-2)==='?>') { |
|
1223 | + $php = substr($php,0,-2); |
|
1224 | + } |
|
1225 | + if($this->elmName!=='') { |
|
1226 | + $modx->snippetCache[$this->elmName.'Props'] = ''; |
|
1227 | + } |
|
1228 | + } else { |
|
1229 | + $php = false; |
|
1230 | + } |
|
1231 | + } else { |
|
1232 | + $php = false; |
|
1233 | + } |
|
1234 | + if($this->elmName!=='') { |
|
1235 | + $modx->snippetCache[$this->elmName]= $php; |
|
1029 | 1236 | } |
1030 | - else $php = false; |
|
1031 | - if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php; |
|
1032 | 1237 | } |
1033 | - if($php==='') $php=false; |
|
1238 | + if($php==='') { |
|
1239 | + $php=false; |
|
1240 | + } |
|
1034 | 1241 | |
1035 | - if($php===false) $html = $modx->getChunk($this->elmName); |
|
1036 | - else $html = false; |
|
1242 | + if($php===false) { |
|
1243 | + $html = $modx->getChunk($this->elmName); |
|
1244 | + } else { |
|
1245 | + $html = false; |
|
1246 | + } |
|
1037 | 1247 | |
1038 | 1248 | $self = '[+output+]'; |
1039 | 1249 | |
1040 | - if($php !== false) |
|
1041 | - { |
|
1250 | + if($php !== false) { |
|
1042 | 1251 | ob_start(); |
1043 | 1252 | $options = $opt; |
1044 | 1253 | $output = $value; |
@@ -1050,19 +1259,19 @@ discard block |
||
1050 | 1259 | $this->vars['options'] = & $opt; |
1051 | 1260 | $custom = eval($php); |
1052 | 1261 | $msg = ob_get_contents(); |
1053 | - if($value===$this->bt) $value = $msg . $custom; |
|
1262 | + if($value===$this->bt) { |
|
1263 | + $value = $msg . $custom; |
|
1264 | + } |
|
1054 | 1265 | ob_end_clean(); |
1055 | - } |
|
1056 | - elseif($html!==false && isset($value) && $value!=='') |
|
1057 | - { |
|
1266 | + } elseif($html!==false && isset($value) && $value!=='') { |
|
1058 | 1267 | $html = str_replace(array($self,'[+value+]'), $value, $html); |
1059 | 1268 | $value = str_replace(array('[+options+]','[+param+]'), $opt, $html); |
1269 | + } else { |
|
1270 | + return false; |
|
1060 | 1271 | } |
1061 | - else return false; |
|
1062 | 1272 | |
1063 | 1273 | if($php===false && $html===false && $value!=='' |
1064 | - && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) |
|
1065 | - { |
|
1274 | + && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) { |
|
1066 | 1275 | $value = str_replace(array('[+value+]',$self),$value,$cmd); |
1067 | 1276 | } |
1068 | 1277 | return $value; |
@@ -1072,23 +1281,39 @@ discard block |
||
1072 | 1281 | { |
1073 | 1282 | $modx = evolutionCMS(); |
1074 | 1283 | |
1075 | - if(strpos($content,'[')===false && strpos($content,'{')===false) return $content; |
|
1284 | + if(strpos($content,'[')===false && strpos($content,'{')===false) { |
|
1285 | + return $content; |
|
1286 | + } |
|
1076 | 1287 | |
1077 | - if(!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1288 | + if(!$modx->maxParserPasses) { |
|
1289 | + $modx->maxParserPasses = 10; |
|
1290 | + } |
|
1078 | 1291 | $bt=''; |
1079 | 1292 | $i=0; |
1080 | - while($bt!==$content) |
|
1081 | - { |
|
1293 | + while($bt!==$content) { |
|
1082 | 1294 | $bt = $content; |
1083 | - if(strpos($content,'[*')!==false && $modx->documentIdentifier) |
|
1084 | - $content = $modx->mergeDocumentContent($content); |
|
1085 | - if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content); |
|
1086 | - if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content); |
|
1087 | - if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content); |
|
1088 | - if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content); |
|
1089 | - |
|
1090 | - if($content===$bt) break; |
|
1091 | - if($modx->maxParserPasses < $i) break; |
|
1295 | + if(strpos($content,'[*')!==false && $modx->documentIdentifier) { |
|
1296 | + $content = $modx->mergeDocumentContent($content); |
|
1297 | + } |
|
1298 | + if(strpos($content,'[(')!==false) { |
|
1299 | + $content = $modx->mergeSettingsContent($content); |
|
1300 | + } |
|
1301 | + if(strpos($content,'{{')!==false) { |
|
1302 | + $content = $modx->mergeChunkContent($content); |
|
1303 | + } |
|
1304 | + if(strpos($content,'[!')!==false) { |
|
1305 | + $content = str_replace(array('[!','!]'),array('[[',']]'),$content); |
|
1306 | + } |
|
1307 | + if(strpos($content,'[[')!==false) { |
|
1308 | + $content = $modx->evalSnippets($content); |
|
1309 | + } |
|
1310 | + |
|
1311 | + if($content===$bt) { |
|
1312 | + break; |
|
1313 | + } |
|
1314 | + if($modx->maxParserPasses < $i) { |
|
1315 | + break; |
|
1316 | + } |
|
1092 | 1317 | $i++; |
1093 | 1318 | } |
1094 | 1319 | return $content; |
@@ -1099,103 +1324,138 @@ discard block |
||
1099 | 1324 | $modx = evolutionCMS(); |
1100 | 1325 | |
1101 | 1326 | $target = trim($target); |
1102 | - if(empty($target)) $target = $modx->config['site_start']; |
|
1103 | - if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id'; |
|
1104 | - else $method = 'alias'; |
|
1327 | + if(empty($target)) { |
|
1328 | + $target = $modx->config['site_start']; |
|
1329 | + } |
|
1330 | + if(preg_match('@^[1-9][0-9]*$@',$target)) { |
|
1331 | + $method='id'; |
|
1332 | + } else { |
|
1333 | + $method = 'alias'; |
|
1334 | + } |
|
1105 | 1335 | |
1106 | - if(!isset($this->documentObject[$target])) |
|
1107 | - { |
|
1336 | + if(!isset($this->documentObject[$target])) { |
|
1108 | 1337 | $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct'); |
1109 | 1338 | } |
1110 | 1339 | |
1111 | - if($this->documentObject[$target]['publishedon']==='0') |
|
1112 | - return ''; |
|
1113 | - elseif(isset($this->documentObject[$target][$field])) |
|
1114 | - { |
|
1115 | - if(is_array($this->documentObject[$target][$field])) |
|
1116 | - { |
|
1340 | + if($this->documentObject[$target]['publishedon']==='0') { |
|
1341 | + return ''; |
|
1342 | + } elseif(isset($this->documentObject[$target][$field])) { |
|
1343 | + if(is_array($this->documentObject[$target][$field])) { |
|
1117 | 1344 | $a = $modx->getTemplateVarOutput($field,$target); |
1118 | 1345 | $this->documentObject[$target][$field] = $a[$field]; |
1119 | 1346 | } |
1347 | + } else { |
|
1348 | + $this->documentObject[$target][$field] = false; |
|
1120 | 1349 | } |
1121 | - else $this->documentObject[$target][$field] = false; |
|
1122 | 1350 | |
1123 | 1351 | return $this->documentObject[$target][$field]; |
1124 | 1352 | } |
1125 | 1353 | |
1126 | - public function setPlaceholders($value = '', $key = '', $path = '') { |
|
1127 | - if($path!=='') $key = "{$path}.{$key}"; |
|
1354 | + public function setPlaceholders($value = '', $key = '', $path = '') |
|
1355 | + { |
|
1356 | + if($path!=='') { |
|
1357 | + $key = "{$path}.{$key}"; |
|
1358 | + } |
|
1128 | 1359 | if (is_array($value)) { |
1129 | 1360 | foreach ($value as $subkey => $subval) { |
1130 | 1361 | $this->setPlaceholders($subval, $subkey, $key); |
1131 | 1362 | } |
1363 | + } else { |
|
1364 | + $this->setModifiersVariable($key, $value); |
|
1132 | 1365 | } |
1133 | - else $this->setModifiersVariable($key, $value); |
|
1134 | 1366 | } |
1135 | 1367 | |
1136 | 1368 | // Sets a placeholder variable which can only be access by Modifiers |
1137 | - public function setModifiersVariable($key, $value) { |
|
1138 | - if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; |
|
1369 | + public function setModifiersVariable($key, $value) |
|
1370 | + { |
|
1371 | + if ($key != 'phx' && $key != 'dummy') { |
|
1372 | + $this->placeholders[$key] = $value; |
|
1373 | + } |
|
1139 | 1374 | } |
1140 | 1375 | |
1141 | 1376 | //mbstring |
1142 | - public function substr($str, $s, $l = null) { |
|
1377 | + public function substr($str, $s, $l = null) |
|
1378 | + { |
|
1143 | 1379 | $modx = evolutionCMS(); |
1144 | - if(is_null($l)) $l = $this->strlen($str); |
|
1145 | - if (function_exists('mb_substr')) |
|
1146 | - { |
|
1147 | - if(strpos($str,"\r")!==false) |
|
1148 | - $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
1380 | + if(is_null($l)) { |
|
1381 | + $l = $this->strlen($str); |
|
1382 | + } |
|
1383 | + if (function_exists('mb_substr')) { |
|
1384 | + if(strpos($str,"\r")!==false) { |
|
1385 | + $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
1386 | + } |
|
1149 | 1387 | return mb_substr($str, $s, $l, $modx->config['modx_charset']); |
1150 | 1388 | } |
1151 | 1389 | return substr($str, $s, $l); |
1152 | 1390 | } |
1153 | - public function strpos($haystack,$needle,$offset=0) { |
|
1391 | + public function strpos($haystack,$needle,$offset=0) |
|
1392 | + { |
|
1154 | 1393 | $modx = evolutionCMS(); |
1155 | - if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
1394 | + if (function_exists('mb_strpos')) { |
|
1395 | + return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
1396 | + } |
|
1156 | 1397 | return strpos($haystack,$needle,$offset); |
1157 | 1398 | } |
1158 | - public function strlen($str) { |
|
1399 | + public function strlen($str) |
|
1400 | + { |
|
1159 | 1401 | $modx = evolutionCMS(); |
1160 | - if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
1402 | + if (function_exists('mb_strlen')) { |
|
1403 | + return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
1404 | + } |
|
1161 | 1405 | return strlen($str); |
1162 | 1406 | } |
1163 | - public function strtolower($str) { |
|
1164 | - if (function_exists('mb_strtolower')) return mb_strtolower($str); |
|
1407 | + public function strtolower($str) |
|
1408 | + { |
|
1409 | + if (function_exists('mb_strtolower')) { |
|
1410 | + return mb_strtolower($str); |
|
1411 | + } |
|
1165 | 1412 | return strtolower($str); |
1166 | 1413 | } |
1167 | - public function strtoupper($str) { |
|
1168 | - if (function_exists('mb_strtoupper')) return mb_strtoupper($str); |
|
1414 | + public function strtoupper($str) |
|
1415 | + { |
|
1416 | + if (function_exists('mb_strtoupper')) { |
|
1417 | + return mb_strtoupper($str); |
|
1418 | + } |
|
1169 | 1419 | return strtoupper($str); |
1170 | 1420 | } |
1171 | - public function ucfirst($str) { |
|
1172 | - if (function_exists('mb_strtoupper')) |
|
1173 | - return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
1421 | + public function ucfirst($str) |
|
1422 | + { |
|
1423 | + if (function_exists('mb_strtoupper')) { |
|
1424 | + return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
1425 | + } |
|
1174 | 1426 | return ucfirst($str); |
1175 | 1427 | } |
1176 | - public function lcfirst($str) { |
|
1177 | - if (function_exists('mb_strtolower')) |
|
1178 | - return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
1428 | + public function lcfirst($str) |
|
1429 | + { |
|
1430 | + if (function_exists('mb_strtolower')) { |
|
1431 | + return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
1432 | + } |
|
1179 | 1433 | return lcfirst($str); |
1180 | 1434 | } |
1181 | - public function ucwords($str) { |
|
1182 | - if (function_exists('mb_convert_case')) |
|
1183 | - return mb_convert_case($str, MB_CASE_TITLE); |
|
1435 | + public function ucwords($str) |
|
1436 | + { |
|
1437 | + if (function_exists('mb_convert_case')) { |
|
1438 | + return mb_convert_case($str, MB_CASE_TITLE); |
|
1439 | + } |
|
1184 | 1440 | return ucwords($str); |
1185 | 1441 | } |
1186 | - public function strrev($str) { |
|
1442 | + public function strrev($str) |
|
1443 | + { |
|
1187 | 1444 | preg_match_all('/./us', $str, $ar); |
1188 | 1445 | return implode(array_reverse($ar[0])); |
1189 | 1446 | } |
1190 | - public function str_shuffle($str) { |
|
1447 | + public function str_shuffle($str) |
|
1448 | + { |
|
1191 | 1449 | preg_match_all('/./us', $str, $ar); |
1192 | 1450 | shuffle($ar[0]); |
1193 | 1451 | return implode($ar[0]); |
1194 | 1452 | } |
1195 | - public function str_word_count($str) { |
|
1453 | + public function str_word_count($str) |
|
1454 | + { |
|
1196 | 1455 | return count(preg_split('~[^\p{L}\p{N}\']+~u',$str)); |
1197 | 1456 | } |
1198 | - public function strip_tags($value,$params='') { |
|
1457 | + public function strip_tags($value,$params='') |
|
1458 | + { |
|
1199 | 1459 | $modx = evolutionCMS(); |
1200 | 1460 | |
1201 | 1461 | if(stripos($params,'style')===false && stripos($value,'</style>')!==false) { |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php namespace EvolutionCMS; |
2 | 2 | |
3 | -use PHPMailer\PHPMailer\PHPMailer; |
|
4 | 3 | use PHPMailer\PHPMailer\Exception as PHPMailerException; |
4 | +use PHPMailer\PHPMailer\PHPMailer; |
|
5 | 5 | |
6 | 6 | class Mail extends PHPMailer |
7 | 7 | { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $modx = evolutionCMS(); |
31 | 31 | $this->modx = $modx; |
32 | - $this->PluginDir = MODX_MANAGER_PATH . 'includes/controls/phpmailer/'; |
|
32 | + $this->PluginDir = MODX_MANAGER_PATH.'includes/controls/phpmailer/'; |
|
33 | 33 | |
34 | 34 | switch ($modx->config['email_method']) { |
35 | 35 | case 'smtp': |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | mb_language($this->mb_language); |
96 | 96 | mb_internal_encoding($modx->config['modx_charset']); |
97 | 97 | } |
98 | - $exconf = MODX_MANAGER_PATH . 'includes/controls/phpmailer/config.inc.php'; |
|
98 | + $exconf = MODX_MANAGER_PATH.'includes/controls/phpmailer/config.inc.php'; |
|
99 | 99 | if (is_file($exconf)) { |
100 | 100 | include($exconf); |
101 | 101 | } |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | if ($this->modx->debug) { |
166 | - $debug_info = 'CharSet = ' . $this->CharSet . "\n"; |
|
167 | - $debug_info .= 'Encoding = ' . $this->Encoding . "\n"; |
|
168 | - $debug_info .= 'mb_language = ' . $this->mb_language . "\n"; |
|
169 | - $debug_info .= 'encode_header_method = ' . $this->encode_header_method . "\n"; |
|
166 | + $debug_info = 'CharSet = '.$this->CharSet."\n"; |
|
167 | + $debug_info .= 'Encoding = '.$this->Encoding."\n"; |
|
168 | + $debug_info .= 'mb_language = '.$this->mb_language."\n"; |
|
169 | + $debug_info .= 'encode_header_method = '.$this->encode_header_method."\n"; |
|
170 | 170 | $debug_info .= "send_mode = {$mode}\n"; |
171 | - $debug_info .= 'Subject = ' . $this->Subject . "\n"; |
|
171 | + $debug_info .= 'Subject = '.$this->Subject."\n"; |
|
172 | 172 | $log = "<pre>{$debug_info}\n{$header}\n{$org_body}</pre>"; |
173 | 173 | $this->modx->logEvent(1, 1, $log, 'MODxMailer debug information'); |
174 | 174 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | ini_set('sendmail_from', $old_from); |
235 | 235 | } |
236 | 236 | if (!$rt) { |
237 | - $msg = $this->Lang('instantiate') . "<br />\n"; |
|
237 | + $msg = $this->Lang('instantiate')."<br />\n"; |
|
238 | 238 | $msg .= "{$this->Subject}<br />\n"; |
239 | 239 | $msg .= "{$this->FromName}<{$this->From}><br />\n"; |
240 | 240 | $msg .= mb_convert_encoding($body, $this->modx->config['modx_charset'], $this->CharSet); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $classDump = call_user_func('get_object_vars', $this); |
257 | 257 | unset($classDump['modx']); |
258 | 258 | $this->modx->config['send_errormail'] = '0'; |
259 | - $this->modx->logEvent(0, 3, $msg . '<pre>' . print_r($classDump, true) . '</pre>', 'phpmailer'); |
|
259 | + $this->modx->logEvent(0, 3, $msg.'<pre>'.print_r($classDump, true).'</pre>', 'phpmailer'); |
|
260 | 260 | |
261 | 261 | return parent::SetError($msg); |
262 | 262 | } |
@@ -207,6 +207,9 @@ |
||
207 | 207 | |
208 | 208 | // format column values |
209 | 209 | |
210 | + /** |
|
211 | + * @param integer $n |
|
212 | + */ |
|
210 | 213 | public function RenderRowFnc($n, $row) { |
211 | 214 | if($this->_alt == 0) { |
212 | 215 | $Style = $this->_itemStyle; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | class DataGrid implements DataGridInterface{ |
15 | 15 | |
16 | - public $ds; // datasource |
|
16 | + public $ds; // datasource |
|
17 | 17 | public $id; |
18 | 18 | public $pageSize; // pager settings |
19 | 19 | public $pageNumber; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public $colWraps; |
38 | 38 | public $colColors; |
39 | 39 | public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
40 | - // data type: integer,float,currency,date |
|
40 | + // data type: integer,float,currency,date |
|
41 | 41 | |
42 | 42 | public $header; |
43 | 43 | public $footer; |
@@ -76,236 +76,236 @@ discard block |
||
76 | 76 | public static $dataGridCnt; |
77 | 77 | |
78 | 78 | public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
79 | - // set id |
|
80 | - self::$dataGridCnt++; |
|
81 | - $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt; |
|
79 | + // set id |
|
80 | + self::$dataGridCnt++; |
|
81 | + $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt; |
|
82 | 82 | |
83 | - // set datasource |
|
84 | - $this->ds = $ds; |
|
83 | + // set datasource |
|
84 | + $this->ds = $ds; |
|
85 | 85 | |
86 | - // set pager |
|
87 | - $this->pageSize = $pageSize; |
|
88 | - $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
89 | - $this->pagerLocation = 'top-right'; |
|
90 | - } |
|
86 | + // set pager |
|
87 | + $this->pageSize = $pageSize; |
|
88 | + $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
89 | + $this->pagerLocation = 'top-right'; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | public function setDataSource($ds) { |
93 | - $this->ds = $ds; |
|
94 | - } |
|
93 | + $this->ds = $ds; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | public function render() { |
97 | 97 | $modx = evolutionCMS(); |
98 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
99 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
100 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
101 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
102 | - |
|
103 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
104 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
105 | - |
|
106 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
107 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
108 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
109 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
110 | - |
|
111 | - $this->_alt = 0; |
|
112 | - $this->_total = 0; |
|
113 | - |
|
114 | - $this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array |
|
115 | - |
|
116 | - if(!$cssStyle && !$cssClass) { |
|
117 | - $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
118 | - } |
|
119 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
120 | - $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
121 | - } |
|
122 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
123 | - $this->_itemStyle = "style='color:black;'"; |
|
124 | - } |
|
125 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
126 | - $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
127 | - } |
|
128 | - |
|
129 | - if($this->_isDataset && !$this->columns) { |
|
130 | - $cols = $modx->getDatabase()->numFields($this->ds); |
|
131 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
132 | - } |
|
133 | - |
|
134 | - // start grid |
|
135 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
136 | - $tblEnd = "</table>"; |
|
137 | - |
|
138 | - // build column header |
|
139 | - $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
140 | - $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
141 | - $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
142 | - $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
143 | - $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
144 | - $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
145 | - $this->_colcount = count($this->_colnames); |
|
146 | - if(!$this->_isDataset) { |
|
147 | - $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
148 | - $this->ds = array_chunk($this->ds, $this->_colcount); |
|
149 | - } |
|
150 | - $tblColHdr = "<thead><tr>"; |
|
151 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
152 | - $name = $this->_colnames[$c]; |
|
153 | - $width = $this->_colwidths[$c]; |
|
154 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
155 | - } |
|
156 | - $tblColHdr .= "</tr></thead>\n"; |
|
157 | - |
|
158 | - // build rows |
|
159 | - $rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
|
160 | - $this->_fieldnames = explode(",", $this->fields); |
|
161 | - if($rowcount == 0) { |
|
162 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
163 | - } else { |
|
164 | - // render grid items |
|
165 | - if($this->pageSize <= 0) { |
|
166 | - for($r = 0; $r < $rowcount; $r++) { |
|
167 | - $row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r]; |
|
168 | - $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
169 | - } |
|
170 | - } else { |
|
171 | - if(!$this->pager) { |
|
172 | - $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
173 | - $this->pager->setRenderRowFnc($this); // pass this object |
|
174 | - $this->pager->cssStyle = $pagerStyle; |
|
175 | - $this->pager->cssClass = $pagerClass; |
|
176 | - } else { |
|
177 | - $this->pager->pageSize = $this->pageSize; |
|
178 | - $this->pager->pageNumber = $this->pageNumber; |
|
179 | - } |
|
180 | - |
|
181 | - $this->pager->render(); |
|
182 | - $tblRows = $this->pager->getRenderedRows(); |
|
183 | - $tblPager = $this->pager->getRenderedPager(); |
|
184 | - } |
|
185 | - } |
|
186 | - |
|
187 | - // setup header,pager and footer |
|
188 | - $o = $tblStart; |
|
189 | - $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
190 | - $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
191 | - if($this->header) { |
|
192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
193 | - } |
|
194 | - if($tblPager && $ptop) { |
|
195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
196 | - } |
|
197 | - $o .= $tblColHdr . $tblRows; |
|
198 | - if($tblPager && $pbot) { |
|
199 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
200 | - } |
|
201 | - if($this->footer) { |
|
202 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
203 | - } |
|
204 | - $o .= $tblEnd; |
|
205 | - return $o; |
|
206 | - } |
|
207 | - |
|
208 | - // format column values |
|
98 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
99 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
100 | + $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
101 | + $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
102 | + |
|
103 | + $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
104 | + $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
105 | + |
|
106 | + $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
107 | + $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
108 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
109 | + $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
110 | + |
|
111 | + $this->_alt = 0; |
|
112 | + $this->_total = 0; |
|
113 | + |
|
114 | + $this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array |
|
115 | + |
|
116 | + if(!$cssStyle && !$cssClass) { |
|
117 | + $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
118 | + } |
|
119 | + if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
120 | + $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
121 | + } |
|
122 | + if(!$this->_itemStyle && !$this->_itemClass) { |
|
123 | + $this->_itemStyle = "style='color:black;'"; |
|
124 | + } |
|
125 | + if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
126 | + $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
127 | + } |
|
128 | + |
|
129 | + if($this->_isDataset && !$this->columns) { |
|
130 | + $cols = $modx->getDatabase()->numFields($this->ds); |
|
131 | + for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
132 | + } |
|
133 | + |
|
134 | + // start grid |
|
135 | + $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
136 | + $tblEnd = "</table>"; |
|
137 | + |
|
138 | + // build column header |
|
139 | + $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
140 | + $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
141 | + $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
142 | + $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
143 | + $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
144 | + $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
145 | + $this->_colcount = count($this->_colnames); |
|
146 | + if(!$this->_isDataset) { |
|
147 | + $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
148 | + $this->ds = array_chunk($this->ds, $this->_colcount); |
|
149 | + } |
|
150 | + $tblColHdr = "<thead><tr>"; |
|
151 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
152 | + $name = $this->_colnames[$c]; |
|
153 | + $width = $this->_colwidths[$c]; |
|
154 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
155 | + } |
|
156 | + $tblColHdr .= "</tr></thead>\n"; |
|
157 | + |
|
158 | + // build rows |
|
159 | + $rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
|
160 | + $this->_fieldnames = explode(",", $this->fields); |
|
161 | + if($rowcount == 0) { |
|
162 | + $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
163 | + } else { |
|
164 | + // render grid items |
|
165 | + if($this->pageSize <= 0) { |
|
166 | + for($r = 0; $r < $rowcount; $r++) { |
|
167 | + $row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r]; |
|
168 | + $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
169 | + } |
|
170 | + } else { |
|
171 | + if(!$this->pager) { |
|
172 | + $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
173 | + $this->pager->setRenderRowFnc($this); // pass this object |
|
174 | + $this->pager->cssStyle = $pagerStyle; |
|
175 | + $this->pager->cssClass = $pagerClass; |
|
176 | + } else { |
|
177 | + $this->pager->pageSize = $this->pageSize; |
|
178 | + $this->pager->pageNumber = $this->pageNumber; |
|
179 | + } |
|
180 | + |
|
181 | + $this->pager->render(); |
|
182 | + $tblRows = $this->pager->getRenderedRows(); |
|
183 | + $tblPager = $this->pager->getRenderedPager(); |
|
184 | + } |
|
185 | + } |
|
186 | + |
|
187 | + // setup header,pager and footer |
|
188 | + $o = $tblStart; |
|
189 | + $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
190 | + $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
191 | + if($this->header) { |
|
192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
193 | + } |
|
194 | + if($tblPager && $ptop) { |
|
195 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
196 | + } |
|
197 | + $o .= $tblColHdr . $tblRows; |
|
198 | + if($tblPager && $pbot) { |
|
199 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
200 | + } |
|
201 | + if($this->footer) { |
|
202 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
203 | + } |
|
204 | + $o .= $tblEnd; |
|
205 | + return $o; |
|
206 | + } |
|
207 | + |
|
208 | + // format column values |
|
209 | 209 | |
210 | 210 | public function RenderRowFnc($n, $row) { |
211 | - if($this->_alt == 0) { |
|
212 | - $Style = $this->_itemStyle; |
|
213 | - $Class = $this->_itemClass; |
|
214 | - $this->_alt = 1; |
|
215 | - } else { |
|
216 | - $Style = $this->_altItemStyle; |
|
217 | - $Class = $this->_altItemClass; |
|
218 | - $this->_alt = 0; |
|
219 | - } |
|
220 | - $o = "<tr>"; |
|
221 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
222 | - $colStyle = $Style; |
|
223 | - $fld = trim($this->_fieldnames[$c]); |
|
224 | - $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
|
225 | - $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null; |
|
226 | - $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null; |
|
227 | - $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
|
228 | - $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
|
229 | - $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
|
230 | - if($color && $Style) { |
|
231 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
232 | - } |
|
233 | - $value = $this->formatColumnValue($row, $value, $type, $align); |
|
234 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
235 | - } |
|
236 | - $o .= "</tr>\n"; |
|
237 | - return $o; |
|
238 | - } |
|
211 | + if($this->_alt == 0) { |
|
212 | + $Style = $this->_itemStyle; |
|
213 | + $Class = $this->_itemClass; |
|
214 | + $this->_alt = 1; |
|
215 | + } else { |
|
216 | + $Style = $this->_altItemStyle; |
|
217 | + $Class = $this->_altItemClass; |
|
218 | + $this->_alt = 0; |
|
219 | + } |
|
220 | + $o = "<tr>"; |
|
221 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
222 | + $colStyle = $Style; |
|
223 | + $fld = trim($this->_fieldnames[$c]); |
|
224 | + $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
|
225 | + $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null; |
|
226 | + $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null; |
|
227 | + $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
|
228 | + $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
|
229 | + $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
|
230 | + if($color && $Style) { |
|
231 | + $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
232 | + } |
|
233 | + $value = $this->formatColumnValue($row, $value, $type, $align); |
|
234 | + $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
235 | + } |
|
236 | + $o .= "</tr>\n"; |
|
237 | + return $o; |
|
238 | + } |
|
239 | 239 | |
240 | 240 | public function formatColumnValue($row, $value, $type, &$align) { |
241 | - if(strpos($type, ":") !== false) { |
|
242 | - list($type, $type_format) = explode(":", $type, 2); |
|
243 | - } |
|
244 | - switch(strtolower($type)) { |
|
245 | - case "integer": |
|
246 | - if($align == "") { |
|
247 | - $align = "right"; |
|
248 | - } |
|
249 | - $value = number_format($value); |
|
250 | - break; |
|
251 | - |
|
252 | - case "float": |
|
253 | - if($align == "") { |
|
254 | - $align = "right"; |
|
255 | - } |
|
256 | - if(!$type_format) { |
|
257 | - $type_format = 2; |
|
258 | - } |
|
259 | - $value = number_format($value, $type_format); |
|
260 | - break; |
|
261 | - |
|
262 | - case "currency": |
|
263 | - if($align == "") { |
|
264 | - $align = "right"; |
|
265 | - } |
|
266 | - if(!$type_format) { |
|
267 | - $type_format = 2; |
|
268 | - } |
|
269 | - $value = "$" . number_format($value, $type_format); |
|
270 | - break; |
|
271 | - |
|
272 | - case "date": |
|
273 | - if($align == "") { |
|
274 | - $align = "right"; |
|
275 | - } |
|
276 | - if(!is_numeric($value)) { |
|
277 | - $value = strtotime($value); |
|
278 | - } |
|
279 | - if(!$type_format) { |
|
280 | - $type_format = "%A %d, %B %Y"; |
|
281 | - } |
|
282 | - $value = strftime($type_format, $value); |
|
283 | - break; |
|
284 | - |
|
285 | - case "boolean": |
|
286 | - if($align == '') { |
|
287 | - $align = "center"; |
|
288 | - } |
|
289 | - $value = number_format($value); |
|
290 | - if($value) { |
|
291 | - $value = '•'; |
|
292 | - } else { |
|
293 | - $value = ' '; |
|
294 | - } |
|
295 | - break; |
|
296 | - |
|
297 | - case "template": |
|
298 | - // replace [+value+] first |
|
299 | - $value = str_replace("[+value+]", $value, $type_format); |
|
300 | - // replace other [+fields+] |
|
301 | - if(strpos($value, "[+") !== false) { |
|
302 | - foreach($row as $k => $v) { |
|
303 | - $value = str_replace("[+$k+]", $v, $value); |
|
304 | - } |
|
305 | - } |
|
306 | - break; |
|
307 | - |
|
308 | - } |
|
309 | - return $value; |
|
310 | - } |
|
241 | + if(strpos($type, ":") !== false) { |
|
242 | + list($type, $type_format) = explode(":", $type, 2); |
|
243 | + } |
|
244 | + switch(strtolower($type)) { |
|
245 | + case "integer": |
|
246 | + if($align == "") { |
|
247 | + $align = "right"; |
|
248 | + } |
|
249 | + $value = number_format($value); |
|
250 | + break; |
|
251 | + |
|
252 | + case "float": |
|
253 | + if($align == "") { |
|
254 | + $align = "right"; |
|
255 | + } |
|
256 | + if(!$type_format) { |
|
257 | + $type_format = 2; |
|
258 | + } |
|
259 | + $value = number_format($value, $type_format); |
|
260 | + break; |
|
261 | + |
|
262 | + case "currency": |
|
263 | + if($align == "") { |
|
264 | + $align = "right"; |
|
265 | + } |
|
266 | + if(!$type_format) { |
|
267 | + $type_format = 2; |
|
268 | + } |
|
269 | + $value = "$" . number_format($value, $type_format); |
|
270 | + break; |
|
271 | + |
|
272 | + case "date": |
|
273 | + if($align == "") { |
|
274 | + $align = "right"; |
|
275 | + } |
|
276 | + if(!is_numeric($value)) { |
|
277 | + $value = strtotime($value); |
|
278 | + } |
|
279 | + if(!$type_format) { |
|
280 | + $type_format = "%A %d, %B %Y"; |
|
281 | + } |
|
282 | + $value = strftime($type_format, $value); |
|
283 | + break; |
|
284 | + |
|
285 | + case "boolean": |
|
286 | + if($align == '') { |
|
287 | + $align = "center"; |
|
288 | + } |
|
289 | + $value = number_format($value); |
|
290 | + if($value) { |
|
291 | + $value = '•'; |
|
292 | + } else { |
|
293 | + $value = ' '; |
|
294 | + } |
|
295 | + break; |
|
296 | + |
|
297 | + case "template": |
|
298 | + // replace [+value+] first |
|
299 | + $value = str_replace("[+value+]", $value, $type_format); |
|
300 | + // replace other [+fields+] |
|
301 | + if(strpos($value, "[+") !== false) { |
|
302 | + foreach($row as $k => $v) { |
|
303 | + $value = str_replace("[+$k+]", $v, $value); |
|
304 | + } |
|
305 | + } |
|
306 | + break; |
|
307 | + |
|
308 | + } |
|
309 | + return $value; |
|
310 | + } |
|
311 | 311 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | |
16 | 16 | public $ds; // datasource |
17 | 17 | public $id; |
18 | - public $pageSize; // pager settings |
|
18 | + public $pageSize; // pager settings |
|
19 | 19 | public $pageNumber; |
20 | 20 | public $pager; |
21 | - public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
21 | + public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
22 | 22 | |
23 | 23 | public $cssStyle; |
24 | 24 | public $cssClass; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public $colAligns; |
37 | 37 | public $colWraps; |
38 | 38 | public $colColors; |
39 | - public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
39 | + public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
40 | 40 | // data type: integer,float,currency,date |
41 | 41 | |
42 | 42 | public $header; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public $cellPadding; |
45 | 45 | public $cellSpacing; |
46 | 46 | |
47 | - public $rowAlign; // vertical alignment: top, middle, bottom |
|
47 | + public $rowAlign; // vertical alignment: top, middle, bottom |
|
48 | 48 | public $rowIdField; |
49 | 49 | |
50 | 50 | public $pagerStyle; |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | |
76 | 76 | public static $dataGridCnt; |
77 | 77 | |
78 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
78 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){ |
|
79 | 79 | // set id |
80 | 80 | self::$dataGridCnt++; |
81 | - $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt; |
|
81 | + $this->id = $this->id ? empty($id) : "dg".self::$dataGridCnt; |
|
82 | 82 | |
83 | 83 | // set datasource |
84 | 84 | $this->ds = $ds; |
@@ -89,50 +89,50 @@ discard block |
||
89 | 89 | $this->pagerLocation = 'top-right'; |
90 | 90 | } |
91 | 91 | |
92 | - public function setDataSource($ds) { |
|
92 | + public function setDataSource($ds){ |
|
93 | 93 | $this->ds = $ds; |
94 | 94 | } |
95 | 95 | |
96 | - public function render() { |
|
96 | + public function render(){ |
|
97 | 97 | $modx = evolutionCMS(); |
98 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
99 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
100 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
101 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
98 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : ''; |
|
99 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : ""; |
|
100 | + $cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : ''; |
|
101 | + $cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : ''; |
|
102 | 102 | |
103 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
104 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
103 | + $pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : ''; |
|
104 | + $pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'"; |
|
105 | 105 | |
106 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
107 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
108 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
109 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
106 | + $this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : ''; |
|
107 | + $this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : ''; |
|
108 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : ''; |
|
109 | + $this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : ''; |
|
110 | 110 | |
111 | 111 | $this->_alt = 0; |
112 | 112 | $this->_total = 0; |
113 | 113 | |
114 | 114 | $this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array |
115 | 115 | |
116 | - if(!$cssStyle && !$cssClass) { |
|
116 | + if (!$cssStyle && !$cssClass) { |
|
117 | 117 | $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
118 | 118 | } |
119 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
119 | + if (!$columnHeaderStyle && !$columnHeaderClass) { |
|
120 | 120 | $columnHeaderStyle = "style='color:black;background-color:silver'"; |
121 | 121 | } |
122 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
122 | + if (!$this->_itemStyle && !$this->_itemClass) { |
|
123 | 123 | $this->_itemStyle = "style='color:black;'"; |
124 | 124 | } |
125 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
125 | + if (!$this->_altItemStyle && !$this->_altItemClass) { |
|
126 | 126 | $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
127 | 127 | } |
128 | 128 | |
129 | - if($this->_isDataset && !$this->columns) { |
|
129 | + if ($this->_isDataset && !$this->columns) { |
|
130 | 130 | $cols = $modx->getDatabase()->numFields($this->ds); |
131 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
131 | + for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->getDatabase()->fieldName($this->ds, $i); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // start grid |
135 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
135 | + $tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>"; |
|
136 | 136 | $tblEnd = "</table>"; |
137 | 137 | |
138 | 138 | // build column header |
@@ -143,32 +143,32 @@ discard block |
||
143 | 143 | $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
144 | 144 | $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
145 | 145 | $this->_colcount = count($this->_colnames); |
146 | - if(!$this->_isDataset) { |
|
146 | + if (!$this->_isDataset) { |
|
147 | 147 | $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
148 | 148 | $this->ds = array_chunk($this->ds, $this->_colcount); |
149 | 149 | } |
150 | 150 | $tblColHdr = "<thead><tr>"; |
151 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
151 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
152 | 152 | $name = $this->_colnames[$c]; |
153 | 153 | $width = $this->_colwidths[$c]; |
154 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
154 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>"; |
|
155 | 155 | } |
156 | 156 | $tblColHdr .= "</tr></thead>\n"; |
157 | 157 | |
158 | 158 | // build rows |
159 | 159 | $rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
160 | 160 | $this->_fieldnames = explode(",", $this->fields); |
161 | - if($rowcount == 0) { |
|
162 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
161 | + if ($rowcount == 0) { |
|
162 | + $tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n"; |
|
163 | 163 | } else { |
164 | 164 | // render grid items |
165 | - if($this->pageSize <= 0) { |
|
166 | - for($r = 0; $r < $rowcount; $r++) { |
|
165 | + if ($this->pageSize <= 0) { |
|
166 | + for ($r = 0; $r < $rowcount; $r++) { |
|
167 | 167 | $row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r]; |
168 | 168 | $tblRows .= $this->RenderRowFnc($r + 1, $row); |
169 | 169 | } |
170 | 170 | } else { |
171 | - if(!$this->pager) { |
|
171 | + if (!$this->pager) { |
|
172 | 172 | $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
173 | 173 | $this->pager->setRenderRowFnc($this); // pass this object |
174 | 174 | $this->pager->cssStyle = $pagerStyle; |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | $o = $tblStart; |
189 | 189 | $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
190 | 190 | $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
191 | - if($this->header) { |
|
192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
191 | + if ($this->header) { |
|
192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>"; |
|
193 | 193 | } |
194 | - if($tblPager && $ptop) { |
|
195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
194 | + if ($tblPager && $ptop) { |
|
195 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
196 | 196 | } |
197 | - $o .= $tblColHdr . $tblRows; |
|
198 | - if($tblPager && $pbot) { |
|
199 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
197 | + $o .= $tblColHdr.$tblRows; |
|
198 | + if ($tblPager && $pbot) { |
|
199 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
200 | 200 | } |
201 | - if($this->footer) { |
|
202 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
201 | + if ($this->footer) { |
|
202 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>"; |
|
203 | 203 | } |
204 | 204 | $o .= $tblEnd; |
205 | 205 | return $o; |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | |
208 | 208 | // format column values |
209 | 209 | |
210 | - public function RenderRowFnc($n, $row) { |
|
211 | - if($this->_alt == 0) { |
|
210 | + public function RenderRowFnc($n, $row){ |
|
211 | + if ($this->_alt == 0) { |
|
212 | 212 | $Style = $this->_itemStyle; |
213 | 213 | $Class = $this->_itemClass; |
214 | 214 | $this->_alt = 1; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $this->_alt = 0; |
219 | 219 | } |
220 | 220 | $o = "<tr>"; |
221 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
221 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
222 | 222 | $colStyle = $Style; |
223 | 223 | $fld = trim($this->_fieldnames[$c]); |
224 | 224 | $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
@@ -227,67 +227,67 @@ discard block |
||
227 | 227 | $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
228 | 228 | $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
229 | 229 | $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
230 | - if($color && $Style) { |
|
231 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
230 | + if ($color && $Style) { |
|
231 | + $colStyle = substr($colStyle, 0, -1).";background-color:$color;'"; |
|
232 | 232 | } |
233 | 233 | $value = $this->formatColumnValue($row, $value, $type, $align); |
234 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
234 | + $o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>"; |
|
235 | 235 | } |
236 | 236 | $o .= "</tr>\n"; |
237 | 237 | return $o; |
238 | 238 | } |
239 | 239 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
241 | - if(strpos($type, ":") !== false) { |
|
240 | + public function formatColumnValue($row, $value, $type, &$align){ |
|
241 | + if (strpos($type, ":") !== false) { |
|
242 | 242 | list($type, $type_format) = explode(":", $type, 2); |
243 | 243 | } |
244 | - switch(strtolower($type)) { |
|
244 | + switch (strtolower($type)) { |
|
245 | 245 | case "integer": |
246 | - if($align == "") { |
|
246 | + if ($align == "") { |
|
247 | 247 | $align = "right"; |
248 | 248 | } |
249 | 249 | $value = number_format($value); |
250 | 250 | break; |
251 | 251 | |
252 | 252 | case "float": |
253 | - if($align == "") { |
|
253 | + if ($align == "") { |
|
254 | 254 | $align = "right"; |
255 | 255 | } |
256 | - if(!$type_format) { |
|
256 | + if (!$type_format) { |
|
257 | 257 | $type_format = 2; |
258 | 258 | } |
259 | 259 | $value = number_format($value, $type_format); |
260 | 260 | break; |
261 | 261 | |
262 | 262 | case "currency": |
263 | - if($align == "") { |
|
263 | + if ($align == "") { |
|
264 | 264 | $align = "right"; |
265 | 265 | } |
266 | - if(!$type_format) { |
|
266 | + if (!$type_format) { |
|
267 | 267 | $type_format = 2; |
268 | 268 | } |
269 | - $value = "$" . number_format($value, $type_format); |
|
269 | + $value = "$".number_format($value, $type_format); |
|
270 | 270 | break; |
271 | 271 | |
272 | 272 | case "date": |
273 | - if($align == "") { |
|
273 | + if ($align == "") { |
|
274 | 274 | $align = "right"; |
275 | 275 | } |
276 | - if(!is_numeric($value)) { |
|
276 | + if (!is_numeric($value)) { |
|
277 | 277 | $value = strtotime($value); |
278 | 278 | } |
279 | - if(!$type_format) { |
|
279 | + if (!$type_format) { |
|
280 | 280 | $type_format = "%A %d, %B %Y"; |
281 | 281 | } |
282 | 282 | $value = strftime($type_format, $value); |
283 | 283 | break; |
284 | 284 | |
285 | 285 | case "boolean": |
286 | - if($align == '') { |
|
286 | + if ($align == '') { |
|
287 | 287 | $align = "center"; |
288 | 288 | } |
289 | 289 | $value = number_format($value); |
290 | - if($value) { |
|
290 | + if ($value) { |
|
291 | 291 | $value = '•'; |
292 | 292 | } else { |
293 | 293 | $value = ' '; |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | // replace [+value+] first |
299 | 299 | $value = str_replace("[+value+]", $value, $type_format); |
300 | 300 | // replace other [+fields+] |
301 | - if(strpos($value, "[+") !== false) { |
|
302 | - foreach($row as $k => $v) { |
|
301 | + if (strpos($value, "[+") !== false) { |
|
302 | + foreach ($row as $k => $v) { |
|
303 | 303 | $value = str_replace("[+$k+]", $v, $value); |
304 | 304 | } |
305 | 305 | } |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | # ----------------------------------------- |
12 | 12 | # |
13 | 13 | |
14 | -class DataGrid implements DataGridInterface{ |
|
14 | +class DataGrid implements DataGridInterface |
|
15 | +{ |
|
15 | 16 | |
16 | 17 | public $ds; // datasource |
17 | 18 | public $id; |
@@ -75,7 +76,8 @@ discard block |
||
75 | 76 | |
76 | 77 | public static $dataGridCnt; |
77 | 78 | |
78 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
79 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) |
|
80 | + { |
|
79 | 81 | // set id |
80 | 82 | self::$dataGridCnt++; |
81 | 83 | $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt; |
@@ -89,11 +91,13 @@ discard block |
||
89 | 91 | $this->pagerLocation = 'top-right'; |
90 | 92 | } |
91 | 93 | |
92 | - public function setDataSource($ds) { |
|
94 | + public function setDataSource($ds) |
|
95 | + { |
|
93 | 96 | $this->ds = $ds; |
94 | 97 | } |
95 | 98 | |
96 | - public function render() { |
|
99 | + public function render() |
|
100 | + { |
|
97 | 101 | $modx = evolutionCMS(); |
98 | 102 | $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
99 | 103 | $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
@@ -128,7 +132,9 @@ discard block |
||
128 | 132 | |
129 | 133 | if($this->_isDataset && !$this->columns) { |
130 | 134 | $cols = $modx->getDatabase()->numFields($this->ds); |
131 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
135 | + for($i = 0; $i < $cols; $i++) { |
|
136 | + $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
137 | + } |
|
132 | 138 | } |
133 | 139 | |
134 | 140 | // start grid |
@@ -207,7 +213,8 @@ discard block |
||
207 | 213 | |
208 | 214 | // format column values |
209 | 215 | |
210 | - public function RenderRowFnc($n, $row) { |
|
216 | + public function RenderRowFnc($n, $row) |
|
217 | + { |
|
211 | 218 | if($this->_alt == 0) { |
212 | 219 | $Style = $this->_itemStyle; |
213 | 220 | $Class = $this->_itemClass; |
@@ -237,7 +244,8 @@ discard block |
||
237 | 244 | return $o; |
238 | 245 | } |
239 | 246 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
247 | + public function formatColumnValue($row, $value, $type, &$align) |
|
248 | + { |
|
241 | 249 | if(strpos($type, ":") !== false) { |
242 | 250 | list($type, $type_format) = explode(":", $type, 2); |
243 | 251 | } |
@@ -33,6 +33,9 @@ discard block |
||
33 | 33 | public $renderPagerFncArgs; |
34 | 34 | public static $dataSetPagerCnt; |
35 | 35 | |
36 | + /** |
|
37 | + * @param boolean|string $id |
|
38 | + */ |
|
36 | 39 | public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
37 | 40 | global $_PAGE; // use view state object |
38 | 41 | |
@@ -77,6 +80,9 @@ discard block |
||
77 | 80 | $this->pageSize = $ps; |
78 | 81 | } |
79 | 82 | |
83 | + /** |
|
84 | + * @param DataGrid $fncName |
|
85 | + */ |
|
80 | 86 | public function setRenderRowFnc($fncName, $args = "") { |
81 | 87 | $this->renderRowFnc = &$fncName; |
82 | 88 | $this->renderRowFncArgs = $args; // extra agruments |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | |
14 | 14 | class DataSetPager implements DataSetPagerInterface{ |
15 | 15 | |
16 | - public $ds; // datasource |
|
16 | + public $ds; // datasource |
|
17 | 17 | public $pageSize; |
18 | 18 | public $pageNumber; |
19 | 19 | public $rows; |
20 | 20 | public $pager; |
21 | 21 | public $id; |
22 | 22 | |
23 | - // normal page |
|
23 | + // normal page |
|
24 | 24 | public $pageStyle; |
25 | 25 | public $pageClass; |
26 | 26 | |
27 | - // selected page |
|
27 | + // selected page |
|
28 | 28 | public $selPageStyle; |
29 | 29 | public $selPageClass; |
30 | 30 | public $renderRowFnc; |
@@ -34,164 +34,164 @@ discard block |
||
34 | 34 | public static $dataSetPagerCnt; |
35 | 35 | |
36 | 36 | public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
37 | - global $_PAGE; // use view state object |
|
38 | - |
|
39 | - // set id |
|
40 | - self::$dataSetPagerCnt++; |
|
41 | - $this->id = !empty($id) ? $id : "dsp" . self::$dataSetPagerCnt; |
|
42 | - |
|
43 | - // get pagenumber |
|
44 | - // by setting pager to -1 cause pager to load it's last page number |
|
45 | - if($pageNumber == -1) { |
|
46 | - $pageNumber = 1; |
|
47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
51 | - } |
|
52 | - } |
|
53 | - if(!is_numeric($pageNumber)) { |
|
54 | - $pageNumber = 1; |
|
55 | - } |
|
56 | - |
|
57 | - $this->ds = $ds; // datasource |
|
58 | - $this->pageSize = $pageSize; |
|
59 | - $this->pageNumber = $pageNumber; |
|
60 | - $this->rows = ''; |
|
61 | - $this->pager = ''; |
|
62 | - } |
|
37 | + global $_PAGE; // use view state object |
|
38 | + |
|
39 | + // set id |
|
40 | + self::$dataSetPagerCnt++; |
|
41 | + $this->id = !empty($id) ? $id : "dsp" . self::$dataSetPagerCnt; |
|
42 | + |
|
43 | + // get pagenumber |
|
44 | + // by setting pager to -1 cause pager to load it's last page number |
|
45 | + if($pageNumber == -1) { |
|
46 | + $pageNumber = 1; |
|
47 | + if(isset($_GET["dpgn" . $this->id])) { |
|
48 | + $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | + } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | + $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
51 | + } |
|
52 | + } |
|
53 | + if(!is_numeric($pageNumber)) { |
|
54 | + $pageNumber = 1; |
|
55 | + } |
|
56 | + |
|
57 | + $this->ds = $ds; // datasource |
|
58 | + $this->pageSize = $pageSize; |
|
59 | + $this->pageNumber = $pageNumber; |
|
60 | + $this->rows = ''; |
|
61 | + $this->pager = ''; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | public function getRenderedPager() { |
65 | - return $this->pager; |
|
66 | - } |
|
65 | + return $this->pager; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | public function getRenderedRows() { |
69 | - return $this->rows; |
|
70 | - } |
|
69 | + return $this->rows; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | public function setDataSource($ds) { |
73 | - $this->ds = $ds; |
|
74 | - } |
|
73 | + $this->ds = $ds; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | public function setPageSize($ps) { |
77 | - $this->pageSize = $ps; |
|
78 | - } |
|
77 | + $this->pageSize = $ps; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | public function setRenderRowFnc($fncName, $args = "") { |
81 | - $this->renderRowFnc = &$fncName; |
|
82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
81 | + $this->renderRowFnc = &$fncName; |
|
82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
83 | 83 | |
84 | 84 | |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | public function setRenderPagerFnc($fncName, $args = "") { |
88 | - $this->renderPagerFnc = $fncName; |
|
89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | - } |
|
88 | + $this->renderPagerFnc = $fncName; |
|
89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | + } |
|
91 | 91 | |
92 | 92 | public function render() { |
93 | - $modx = evolutionCMS(); global $_PAGE; |
|
94 | - |
|
95 | - $isDataset = $modx->getDatabase()->isResult($this->ds); |
|
96 | - |
|
97 | - if(!$this->selPageStyle) { |
|
98 | - $this->selPageStyle = "font-weight:bold"; |
|
99 | - } |
|
100 | - |
|
101 | - // get total number of rows |
|
102 | - $tnr = ($isDataset) ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
|
103 | - |
|
104 | - // render: no records found |
|
105 | - if($tnr <= 0) { |
|
106 | - $fnc = $this->renderRowFnc; |
|
107 | - $args = $this->renderRowFncArgs; |
|
108 | - if(isset($fnc)) { |
|
109 | - if($args != "") { |
|
110 | - $this->rows .= $fnc(0, null, $args); |
|
111 | - } // if agrs was specified then we will pass three params |
|
112 | - else { |
|
113 | - $this->rows .= $fnc(0, null); |
|
114 | - } // otherwise two will be passed |
|
115 | - } |
|
116 | - return; |
|
117 | - } |
|
118 | - |
|
119 | - // get total pages |
|
120 | - $tp = ceil($tnr / $this->pageSize); |
|
121 | - if($this->pageNumber > $tp) { |
|
122 | - $this->pageNumber = 1; |
|
123 | - } |
|
124 | - |
|
125 | - // get page number |
|
126 | - $p = $this->pageNumber; |
|
127 | - |
|
128 | - // save page number to view state if available |
|
129 | - if(isset($_PAGE['vs'])) { |
|
130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
131 | - } |
|
132 | - |
|
133 | - // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
134 | - if($tp > 1) { |
|
135 | - $url = ''; |
|
136 | - $fnc = $this->renderPagerFnc; |
|
137 | - $args = $this->renderPagerFncArgs; |
|
138 | - if(!isset($fnc)) { |
|
139 | - if($modx->isFrontend()) { |
|
140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
141 | - } else { |
|
142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
143 | - } |
|
144 | - $i = 0; |
|
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
146 | - $i++; |
|
147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
148 | - } |
|
149 | - if($i >= 1) { |
|
150 | - $url .= "&"; |
|
151 | - } |
|
152 | - } |
|
153 | - for($i = 1; $i <= $tp; $i++) { |
|
154 | - if(isset($fnc)) { |
|
155 | - if($args != "") { |
|
156 | - $this->pager .= $fnc($p, $i, $args); |
|
157 | - } else { |
|
158 | - $this->pager .= $fnc($p, $i); |
|
159 | - } |
|
160 | - } else { |
|
161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
167 | - $fnc = $this->renderRowFnc; |
|
168 | - $args = $this->renderRowFncArgs; |
|
169 | - |
|
170 | - if(isset($fnc)) { |
|
171 | - $i = 1; |
|
172 | - $fncObject = is_object($fnc); |
|
173 | - $minitems = (($p - 1) * $this->pageSize) + 1; |
|
174 | - $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | - if($i >= $minitems && $i <= $maxitems) { |
|
177 | - if($fncObject) { |
|
178 | - if($args != "") { |
|
179 | - $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
180 | - } else { |
|
181 | - $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
182 | - } |
|
183 | - } else { |
|
184 | - if($args != "") { |
|
185 | - $this->rows .= $fnc($i, $row, $args); |
|
186 | - } // if agrs was specified then we wil pass three params |
|
187 | - else { |
|
188 | - $this->rows .= $fnc($i, $row); |
|
189 | - } // otherwise two will be passed |
|
190 | - } |
|
191 | - |
|
192 | - } |
|
193 | - $i++; |
|
194 | - } |
|
195 | - } |
|
196 | - } |
|
93 | + $modx = evolutionCMS(); global $_PAGE; |
|
94 | + |
|
95 | + $isDataset = $modx->getDatabase()->isResult($this->ds); |
|
96 | + |
|
97 | + if(!$this->selPageStyle) { |
|
98 | + $this->selPageStyle = "font-weight:bold"; |
|
99 | + } |
|
100 | + |
|
101 | + // get total number of rows |
|
102 | + $tnr = ($isDataset) ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
|
103 | + |
|
104 | + // render: no records found |
|
105 | + if($tnr <= 0) { |
|
106 | + $fnc = $this->renderRowFnc; |
|
107 | + $args = $this->renderRowFncArgs; |
|
108 | + if(isset($fnc)) { |
|
109 | + if($args != "") { |
|
110 | + $this->rows .= $fnc(0, null, $args); |
|
111 | + } // if agrs was specified then we will pass three params |
|
112 | + else { |
|
113 | + $this->rows .= $fnc(0, null); |
|
114 | + } // otherwise two will be passed |
|
115 | + } |
|
116 | + return; |
|
117 | + } |
|
118 | + |
|
119 | + // get total pages |
|
120 | + $tp = ceil($tnr / $this->pageSize); |
|
121 | + if($this->pageNumber > $tp) { |
|
122 | + $this->pageNumber = 1; |
|
123 | + } |
|
124 | + |
|
125 | + // get page number |
|
126 | + $p = $this->pageNumber; |
|
127 | + |
|
128 | + // save page number to view state if available |
|
129 | + if(isset($_PAGE['vs'])) { |
|
130 | + $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
131 | + } |
|
132 | + |
|
133 | + // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
134 | + if($tp > 1) { |
|
135 | + $url = ''; |
|
136 | + $fnc = $this->renderPagerFnc; |
|
137 | + $args = $this->renderPagerFncArgs; |
|
138 | + if(!isset($fnc)) { |
|
139 | + if($modx->isFrontend()) { |
|
140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
141 | + } else { |
|
142 | + $url = $_SERVER['PHP_SELF'] . '?'; |
|
143 | + } |
|
144 | + $i = 0; |
|
145 | + foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
146 | + $i++; |
|
147 | + $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
148 | + } |
|
149 | + if($i >= 1) { |
|
150 | + $url .= "&"; |
|
151 | + } |
|
152 | + } |
|
153 | + for($i = 1; $i <= $tp; $i++) { |
|
154 | + if(isset($fnc)) { |
|
155 | + if($args != "") { |
|
156 | + $this->pager .= $fnc($p, $i, $args); |
|
157 | + } else { |
|
158 | + $this->pager .= $fnc($p, $i); |
|
159 | + } |
|
160 | + } else { |
|
161 | + $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
167 | + $fnc = $this->renderRowFnc; |
|
168 | + $args = $this->renderRowFncArgs; |
|
169 | + |
|
170 | + if(isset($fnc)) { |
|
171 | + $i = 1; |
|
172 | + $fncObject = is_object($fnc); |
|
173 | + $minitems = (($p - 1) * $this->pageSize) + 1; |
|
174 | + $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
175 | + while($i <= $maxitems && ($row = ($isDataset) ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | + if($i >= $minitems && $i <= $maxitems) { |
|
177 | + if($fncObject) { |
|
178 | + if($args != "") { |
|
179 | + $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
180 | + } else { |
|
181 | + $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
182 | + } |
|
183 | + } else { |
|
184 | + if($args != "") { |
|
185 | + $this->rows .= $fnc($i, $row, $args); |
|
186 | + } // if agrs was specified then we wil pass three params |
|
187 | + else { |
|
188 | + $this->rows .= $fnc($i, $row); |
|
189 | + } // otherwise two will be passed |
|
190 | + } |
|
191 | + |
|
192 | + } |
|
193 | + $i++; |
|
194 | + } |
|
195 | + } |
|
196 | + } |
|
197 | 197 | } |
@@ -33,24 +33,24 @@ discard block |
||
33 | 33 | public $renderPagerFncArgs; |
34 | 34 | public static $dataSetPagerCnt; |
35 | 35 | |
36 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
36 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){ |
|
37 | 37 | global $_PAGE; // use view state object |
38 | 38 | |
39 | 39 | // set id |
40 | 40 | self::$dataSetPagerCnt++; |
41 | - $this->id = !empty($id) ? $id : "dsp" . self::$dataSetPagerCnt; |
|
41 | + $this->id = !empty($id) ? $id : "dsp".self::$dataSetPagerCnt; |
|
42 | 42 | |
43 | 43 | // get pagenumber |
44 | 44 | // by setting pager to -1 cause pager to load it's last page number |
45 | - if($pageNumber == -1) { |
|
45 | + if ($pageNumber == -1) { |
|
46 | 46 | $pageNumber = 1; |
47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
47 | + if (isset($_GET["dpgn".$this->id])) { |
|
48 | + $pageNumber = $_GET["dpgn".$this->id]; |
|
49 | + } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) { |
|
50 | + $pageNumber = $_PAGE['vs'][$id.'_dpgn']; |
|
51 | 51 | } |
52 | 52 | } |
53 | - if(!is_numeric($pageNumber)) { |
|
53 | + if (!is_numeric($pageNumber)) { |
|
54 | 54 | $pageNumber = 1; |
55 | 55 | } |
56 | 56 | |
@@ -61,40 +61,40 @@ discard block |
||
61 | 61 | $this->pager = ''; |
62 | 62 | } |
63 | 63 | |
64 | - public function getRenderedPager() { |
|
64 | + public function getRenderedPager(){ |
|
65 | 65 | return $this->pager; |
66 | 66 | } |
67 | 67 | |
68 | - public function getRenderedRows() { |
|
68 | + public function getRenderedRows(){ |
|
69 | 69 | return $this->rows; |
70 | 70 | } |
71 | 71 | |
72 | - public function setDataSource($ds) { |
|
72 | + public function setDataSource($ds){ |
|
73 | 73 | $this->ds = $ds; |
74 | 74 | } |
75 | 75 | |
76 | - public function setPageSize($ps) { |
|
76 | + public function setPageSize($ps){ |
|
77 | 77 | $this->pageSize = $ps; |
78 | 78 | } |
79 | 79 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
80 | + public function setRenderRowFnc($fncName, $args = ""){ |
|
81 | 81 | $this->renderRowFnc = &$fncName; |
82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
83 | 83 | |
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
87 | + public function setRenderPagerFnc($fncName, $args = ""){ |
|
88 | 88 | $this->renderPagerFnc = $fncName; |
89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | 90 | } |
91 | 91 | |
92 | - public function render() { |
|
92 | + public function render(){ |
|
93 | 93 | $modx = evolutionCMS(); global $_PAGE; |
94 | 94 | |
95 | 95 | $isDataset = $modx->getDatabase()->isResult($this->ds); |
96 | 96 | |
97 | - if(!$this->selPageStyle) { |
|
97 | + if (!$this->selPageStyle) { |
|
98 | 98 | $this->selPageStyle = "font-weight:bold"; |
99 | 99 | } |
100 | 100 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $tnr = ($isDataset) ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
103 | 103 | |
104 | 104 | // render: no records found |
105 | - if($tnr <= 0) { |
|
105 | + if ($tnr <= 0) { |
|
106 | 106 | $fnc = $this->renderRowFnc; |
107 | 107 | $args = $this->renderRowFncArgs; |
108 | - if(isset($fnc)) { |
|
109 | - if($args != "") { |
|
108 | + if (isset($fnc)) { |
|
109 | + if ($args != "") { |
|
110 | 110 | $this->rows .= $fnc(0, null, $args); |
111 | 111 | } // if agrs was specified then we will pass three params |
112 | 112 | else { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // get total pages |
120 | 120 | $tp = ceil($tnr / $this->pageSize); |
121 | - if($this->pageNumber > $tp) { |
|
121 | + if ($this->pageNumber > $tp) { |
|
122 | 122 | $this->pageNumber = 1; |
123 | 123 | } |
124 | 124 | |
@@ -126,39 +126,39 @@ discard block |
||
126 | 126 | $p = $this->pageNumber; |
127 | 127 | |
128 | 128 | // save page number to view state if available |
129 | - if(isset($_PAGE['vs'])) { |
|
130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
129 | + if (isset($_PAGE['vs'])) { |
|
130 | + $_PAGE['vs'][$this->id.'_dpgn'] = $p; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
134 | - if($tp > 1) { |
|
134 | + if ($tp > 1) { |
|
135 | 135 | $url = ''; |
136 | 136 | $fnc = $this->renderPagerFnc; |
137 | 137 | $args = $this->renderPagerFncArgs; |
138 | - if(!isset($fnc)) { |
|
139 | - if($modx->isFrontend()) { |
|
140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
138 | + if (!isset($fnc)) { |
|
139 | + if ($modx->isFrontend()) { |
|
140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?'; |
|
141 | 141 | } else { |
142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
142 | + $url = $_SERVER['PHP_SELF'].'?'; |
|
143 | 143 | } |
144 | 144 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
145 | + foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) { |
|
146 | 146 | $i++; |
147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
147 | + $url .= (($i > 1) ? "&" : "")."$n=$v"; |
|
148 | 148 | } |
149 | - if($i >= 1) { |
|
149 | + if ($i >= 1) { |
|
150 | 150 | $url .= "&"; |
151 | 151 | } |
152 | 152 | } |
153 | - for($i = 1; $i <= $tp; $i++) { |
|
154 | - if(isset($fnc)) { |
|
155 | - if($args != "") { |
|
153 | + for ($i = 1; $i <= $tp; $i++) { |
|
154 | + if (isset($fnc)) { |
|
155 | + if ($args != "") { |
|
156 | 156 | $this->pager .= $fnc($p, $i, $args); |
157 | 157 | } else { |
158 | 158 | $this->pager .= $fnc($p, $i); |
159 | 159 | } |
160 | 160 | } else { |
161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
161 | + $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> "; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | $fnc = $this->renderRowFnc; |
168 | 168 | $args = $this->renderRowFncArgs; |
169 | 169 | |
170 | - if(isset($fnc)) { |
|
170 | + if (isset($fnc)) { |
|
171 | 171 | $i = 1; |
172 | 172 | $fncObject = is_object($fnc); |
173 | 173 | $minitems = (($p - 1) * $this->pageSize) + 1; |
174 | 174 | $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | - if($i >= $minitems && $i <= $maxitems) { |
|
177 | - if($fncObject) { |
|
178 | - if($args != "") { |
|
175 | + while ($i <= $maxitems && ($row = ($isDataset) ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | + if ($i >= $minitems && $i <= $maxitems) { |
|
177 | + if ($fncObject) { |
|
178 | + if ($args != "") { |
|
179 | 179 | $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
180 | 180 | } else { |
181 | 181 | $this->rows .= $fnc->RenderRowFnc($i, $row); |
182 | 182 | } |
183 | 183 | } else { |
184 | - if($args != "") { |
|
184 | + if ($args != "") { |
|
185 | 185 | $this->rows .= $fnc($i, $row, $args); |
186 | 186 | } // if agrs was specified then we wil pass three params |
187 | 187 | else { |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | # ----------------------------------------- |
12 | 12 | # |
13 | 13 | |
14 | -class DataSetPager implements DataSetPagerInterface{ |
|
14 | +class DataSetPager implements DataSetPagerInterface |
|
15 | +{ |
|
15 | 16 | |
16 | 17 | public $ds; // datasource |
17 | 18 | public $pageSize; |
@@ -33,7 +34,8 @@ discard block |
||
33 | 34 | public $renderPagerFncArgs; |
34 | 35 | public static $dataSetPagerCnt; |
35 | 36 | |
36 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
37 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
38 | + { |
|
37 | 39 | global $_PAGE; // use view state object |
38 | 40 | |
39 | 41 | // set id |
@@ -61,35 +63,42 @@ discard block |
||
61 | 63 | $this->pager = ''; |
62 | 64 | } |
63 | 65 | |
64 | - public function getRenderedPager() { |
|
66 | + public function getRenderedPager() |
|
67 | + { |
|
65 | 68 | return $this->pager; |
66 | 69 | } |
67 | 70 | |
68 | - public function getRenderedRows() { |
|
71 | + public function getRenderedRows() |
|
72 | + { |
|
69 | 73 | return $this->rows; |
70 | 74 | } |
71 | 75 | |
72 | - public function setDataSource($ds) { |
|
76 | + public function setDataSource($ds) |
|
77 | + { |
|
73 | 78 | $this->ds = $ds; |
74 | 79 | } |
75 | 80 | |
76 | - public function setPageSize($ps) { |
|
81 | + public function setPageSize($ps) |
|
82 | + { |
|
77 | 83 | $this->pageSize = $ps; |
78 | 84 | } |
79 | 85 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
86 | + public function setRenderRowFnc($fncName, $args = "") |
|
87 | + { |
|
81 | 88 | $this->renderRowFnc = &$fncName; |
82 | 89 | $this->renderRowFncArgs = $args; // extra agruments |
83 | 90 | |
84 | 91 | |
85 | 92 | } |
86 | 93 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
94 | + public function setRenderPagerFnc($fncName, $args = "") |
|
95 | + { |
|
88 | 96 | $this->renderPagerFnc = $fncName; |
89 | 97 | $this->renderPagerFncArgs = $args; // extra agruments |
90 | 98 | } |
91 | 99 | |
92 | - public function render() { |
|
100 | + public function render() |
|
101 | + { |
|
93 | 102 | $modx = evolutionCMS(); global $_PAGE; |
94 | 103 | |
95 | 104 | $isDataset = $modx->getDatabase()->isResult($this->ds); |
@@ -142,8 +151,10 @@ discard block |
||
142 | 151 | $url = $_SERVER['PHP_SELF'] . '?'; |
143 | 152 | } |
144 | 153 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
154 | + foreach($_GET as $n => $v) { |
|
155 | + if($n != 'dpgn' . $this->id) { |
|
146 | 156 | $i++; |
157 | + } |
|
147 | 158 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
148 | 159 | } |
149 | 160 | if($i >= 1) { |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | * EVO Installer |
4 | 4 | */ |
5 | 5 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); |
6 | -$base_path = dirname(__DIR__) . '/'; |
|
6 | +$base_path = dirname(__DIR__).'/'; |
|
7 | 7 | |
8 | -if (is_file($base_path . 'assets/cache/siteManager.php')) { |
|
9 | - include_once $base_path . 'assets/cache/siteManager.php'; |
|
8 | +if (is_file($base_path.'assets/cache/siteManager.php')) { |
|
9 | + include_once $base_path.'assets/cache/siteManager.php'; |
|
10 | 10 | } |
11 | -if (! defined('MGR_DIR')) { |
|
12 | - if (is_dir($base_path . 'manager')) { |
|
11 | +if (!defined('MGR_DIR')) { |
|
12 | + if (is_dir($base_path.'manager')) { |
|
13 | 13 | define('MGR_DIR', 'manager'); |
14 | 14 | } else { |
15 | 15 | die('MGR_DIR is not defined'); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | require_once 'src/functions.php'; |
20 | 20 | |
21 | 21 | if (empty($_GET['self'])) { |
22 | - require_once '../' . MGR_DIR . '/includes/version.inc.php'; |
|
22 | + require_once '../'.MGR_DIR.'/includes/version.inc.php'; |
|
23 | 23 | |
24 | 24 | // start session |
25 | 25 | session_start(); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | install_sessionCheck(); |
28 | 28 | |
29 | 29 | $moduleName = 'EVO'; |
30 | - $moduleVersion = $modx_branch . ' ' . $modx_version; |
|
30 | + $moduleVersion = $modx_branch.' '.$modx_version; |
|
31 | 31 | $moduleRelease = $modx_release_date; |
32 | 32 | $moduleSQLBaseFile = 'stubs/sql/setup.sql'; |
33 | 33 | $moduleSQLDataFile = 'stubs/sql/setup.data.sql'; |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | $action = isset($_GET['action']) ? trim(strip_tags($_GET['action'])) : 'language'; |
69 | 69 | str_replace('.', '', $action); |
70 | 70 | |
71 | - $controller = 'src/controllers/' . $action . '.php'; |
|
72 | - if (! file_exists($controller)) { |
|
71 | + $controller = 'src/controllers/'.$action.'.php'; |
|
72 | + if (!file_exists($controller)) { |
|
73 | 73 | die("Invalid install action attempted. [action={$action}]"); |
74 | 74 | } |
75 | 75 | require $controller; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | } else { |
82 | 82 | $action = isset($_GET['action']) && is_scalar($_GET['action']) ? trim($_GET['action']) : 'language'; |
83 | 83 | str_replace('.', '', $action); |
84 | - $controller = 'src/controllers/' . $action . '.php'; |
|
85 | - if (! file_exists($controller)) { |
|
84 | + $controller = 'src/controllers/'.$action.'.php'; |
|
85 | + if (!file_exists($controller)) { |
|
86 | 86 | die("Invalid install action attempted. [action={$action}]"); |
87 | 87 | } |
88 | 88 | require $controller; |
@@ -1,75 +1,75 @@ |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | -if($modx->getManagerApi()->action!='8' && isset($_SESSION['mgrValidated'])){ |
|
6 | +if ($modx->getManagerApi()->action != '8' && isset($_SESSION['mgrValidated'])) { |
|
7 | 7 | |
8 | - $homeurl = $modx->makeUrl($manager_login_startup>0 ? $manager_login_startup:$site_start); |
|
8 | + $homeurl = $modx->makeUrl($manager_login_startup > 0 ? $manager_login_startup : $site_start); |
|
9 | 9 | $logouturl = MODX_MANAGER_URL.'index.php?a=8'; |
10 | 10 | |
11 | - $modx->setPlaceholder('modx_charset',$modx_manager_charset); |
|
12 | - $modx->setPlaceholder('theme',$manager_theme); |
|
11 | + $modx->setPlaceholder('modx_charset', $modx_manager_charset); |
|
12 | + $modx->setPlaceholder('theme', $manager_theme); |
|
13 | 13 | |
14 | - $modx->setPlaceholder('site_name',$site_name); |
|
15 | - $modx->setPlaceholder('logo_slogan',$_lang["logo_slogan"]); |
|
16 | - $modx->setPlaceholder('manager_lockout_message',$_lang["manager_lockout_message"]); |
|
14 | + $modx->setPlaceholder('site_name', $site_name); |
|
15 | + $modx->setPlaceholder('logo_slogan', $_lang["logo_slogan"]); |
|
16 | + $modx->setPlaceholder('manager_lockout_message', $_lang["manager_lockout_message"]); |
|
17 | 17 | |
18 | - $modx->setPlaceholder('home',$_lang["home"]); |
|
19 | - $modx->setPlaceholder('homeurl',$homeurl); |
|
20 | - $modx->setPlaceholder('logout',$_lang["logout"]); |
|
21 | - $modx->setPlaceholder('logouturl',$logouturl); |
|
22 | - $modx->setPlaceholder('manager_theme_url',MODX_MANAGER_URL . 'media/style/' . $modx->config['manager_theme'] . '/'); |
|
23 | - $modx->setPlaceholder('year',date('Y')); |
|
18 | + $modx->setPlaceholder('home', $_lang["home"]); |
|
19 | + $modx->setPlaceholder('homeurl', $homeurl); |
|
20 | + $modx->setPlaceholder('logout', $_lang["logout"]); |
|
21 | + $modx->setPlaceholder('logouturl', $logouturl); |
|
22 | + $modx->setPlaceholder('manager_theme_url', MODX_MANAGER_URL.'media/style/'.$modx->config['manager_theme'].'/'); |
|
23 | + $modx->setPlaceholder('year', date('Y')); |
|
24 | 24 | |
25 | 25 | // load template |
26 | - if(!isset($modx->config['manager_lockout_tpl']) || empty($modx->config['manager_lockout_tpl'])) { |
|
27 | - $modx->config['manager_lockout_tpl'] = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
|
26 | + if (!isset($modx->config['manager_lockout_tpl']) || empty($modx->config['manager_lockout_tpl'])) { |
|
27 | + $modx->config['manager_lockout_tpl'] = MODX_MANAGER_PATH.'media/style/common/manager.lockout.tpl'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $target = $modx->config['manager_lockout_tpl']; |
31 | 31 | $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target); |
32 | 32 | $target = $modx->mergeSettingsContent($target); |
33 | 33 | |
34 | - if(substr($target,0,1)==='@') { |
|
35 | - if(substr($target,0,6)==='@CHUNK') { |
|
36 | - $target = trim(substr($target,7)); |
|
34 | + if (substr($target, 0, 1) === '@') { |
|
35 | + if (substr($target, 0, 6) === '@CHUNK') { |
|
36 | + $target = trim(substr($target, 7)); |
|
37 | 37 | $lockout_tpl = $modx->getChunk($target); |
38 | 38 | } |
39 | - elseif(substr($target,0,5)==='@FILE') { |
|
40 | - $target = trim(substr($target,6)); |
|
39 | + elseif (substr($target, 0, 5) === '@FILE') { |
|
40 | + $target = trim(substr($target, 6)); |
|
41 | 41 | $lockout_tpl = file_get_contents($target); |
42 | 42 | } |
43 | 43 | } else { |
44 | 44 | $chunk = $modx->getChunk($target); |
45 | - if($chunk!==false && !empty($chunk)) { |
|
45 | + if ($chunk !== false && !empty($chunk)) { |
|
46 | 46 | $lockout_tpl = $chunk; |
47 | 47 | } |
48 | - elseif(is_file(MODX_BASE_PATH . $target)) { |
|
49 | - $target = MODX_BASE_PATH . $target; |
|
48 | + elseif (is_file(MODX_BASE_PATH.$target)) { |
|
49 | + $target = MODX_BASE_PATH.$target; |
|
50 | 50 | $lockout_tpl = file_get_contents($target); |
51 | 51 | } |
52 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl')) { |
|
53 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl'; |
|
52 | + elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/manager.lockout.tpl')) { |
|
53 | + $target = MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/manager.lockout.tpl'; |
|
54 | 54 | $lockout_tpl = file_get_contents($target); |
55 | 55 | } |
56 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl')) { |
|
57 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl'; |
|
56 | + elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/templates/actions/manager.lockout.tpl')) { |
|
57 | + $target = MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/templates/actions/manager.lockout.tpl'; |
|
58 | 58 | $login_tpl = file_get_contents($target); |
59 | 59 | } |
60 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html')) { // ClipperCMS compatible |
|
61 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html'; |
|
60 | + elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/manager.lockout.html')) { // ClipperCMS compatible |
|
61 | + $target = MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/manager.lockout.html'; |
|
62 | 62 | $lockout_tpl = file_get_contents($target); |
63 | 63 | } |
64 | 64 | else { |
65 | - $target = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
|
65 | + $target = MODX_MANAGER_PATH.'media/style/common/manager.lockout.tpl'; |
|
66 | 66 | $lockout_tpl = file_get_contents($target); |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | 70 | // merge placeholders |
71 | 71 | $lockout_tpl = $modx->mergePlaceholderContent($lockout_tpl); |
72 | - $regx = strpos($lockout_tpl,'[[+')!==false ? '~\[\[\+(.*?)\]\]~' : '~\[\+(.*?)\+\]~'; // little tweak for newer parsers |
|
72 | + $regx = strpos($lockout_tpl, '[[+') !== false ? '~\[\[\+(.*?)\]\]~' : '~\[\+(.*?)\+\]~'; // little tweak for newer parsers |
|
73 | 73 | $lockout_tpl = preg_replace($regx, '', $lockout_tpl); //cleanup |
74 | 74 | |
75 | 75 | echo $lockout_tpl; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | -if($modx->getManagerApi()->action!='8' && isset($_SESSION['mgrValidated'])){ |
|
6 | +if($modx->getManagerApi()->action!='8' && isset($_SESSION['mgrValidated'])) { |
|
7 | 7 | |
8 | 8 | $homeurl = $modx->makeUrl($manager_login_startup>0 ? $manager_login_startup:$site_start); |
9 | 9 | $logouturl = MODX_MANAGER_URL.'index.php?a=8'; |
@@ -35,8 +35,7 @@ discard block |
||
35 | 35 | if(substr($target,0,6)==='@CHUNK') { |
36 | 36 | $target = trim(substr($target,7)); |
37 | 37 | $lockout_tpl = $modx->getChunk($target); |
38 | - } |
|
39 | - elseif(substr($target,0,5)==='@FILE') { |
|
38 | + } elseif(substr($target,0,5)==='@FILE') { |
|
40 | 39 | $target = trim(substr($target,6)); |
41 | 40 | $lockout_tpl = file_get_contents($target); |
42 | 41 | } |
@@ -44,24 +43,20 @@ discard block |
||
44 | 43 | $chunk = $modx->getChunk($target); |
45 | 44 | if($chunk!==false && !empty($chunk)) { |
46 | 45 | $lockout_tpl = $chunk; |
47 | - } |
|
48 | - elseif(is_file(MODX_BASE_PATH . $target)) { |
|
46 | + } elseif(is_file(MODX_BASE_PATH . $target)) { |
|
49 | 47 | $target = MODX_BASE_PATH . $target; |
50 | 48 | $lockout_tpl = file_get_contents($target); |
51 | - } |
|
52 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl')) { |
|
49 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl')) { |
|
53 | 50 | $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl'; |
54 | 51 | $lockout_tpl = file_get_contents($target); |
55 | - } |
|
56 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl')) { |
|
52 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl')) { |
|
57 | 53 | $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl'; |
58 | 54 | $login_tpl = file_get_contents($target); |
59 | - } |
|
60 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html')) { // ClipperCMS compatible |
|
55 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html')) { |
|
56 | +// ClipperCMS compatible |
|
61 | 57 | $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html'; |
62 | 58 | $lockout_tpl = file_get_contents($target); |
63 | - } |
|
64 | - else { |
|
59 | + } else { |
|
65 | 60 | $target = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
66 | 61 | $lockout_tpl = file_get_contents($target); |
67 | 62 | } |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | |
6 | 6 | // PROCESSOR FIRST |
7 | 7 | if($_SESSION['mgrRole'] == 1) { |
8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | - $current = $modx->getManagerApi()->getSystemChecksum($modx->config['check_files_onlogin']); |
|
10 | - if(!empty($current)) { |
|
11 | - $modx->getManagerApi()->setSystemChecksum($current); |
|
12 | - $modx->clearCache('full'); |
|
13 | - $modx->config['sys_files_checksum'] = $current; |
|
14 | - }; |
|
15 | - } |
|
8 | + if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | + $current = $modx->getManagerApi()->getSystemChecksum($modx->config['check_files_onlogin']); |
|
10 | + if(!empty($current)) { |
|
11 | + $modx->getManagerApi()->setSystemChecksum($current); |
|
12 | + $modx->clearCache('full'); |
|
13 | + $modx->config['sys_files_checksum'] = $current; |
|
14 | + }; |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | // NOW CHECK CONFIG |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->getManagerApi()->checkSystemChecksum(); |
22 | 22 | if ($sysfiles_check!=='0'){ |
23 | - $warningspresent = 1; |
|
24 | - $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
|
23 | + $warningspresent = 1; |
|
24 | + $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | if (is_writable("includes/config.inc.php")){ |
28 | 28 | // Warn if world writable |
29 | 29 | if(@fileperms('includes/config.inc.php') & 0x0002) { |
30 | - $warningspresent = 1; |
|
31 | - $warnings[] = array($_lang['configcheck_configinc']); |
|
30 | + $warningspresent = 1; |
|
31 | + $warnings[] = array($_lang['configcheck_configinc']); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | break; |
183 | 183 | case $_lang['configcheck_sysfiles_mod']: |
184 | 184 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
185 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
186 | - if($modx->hasPermission('settings')) { |
|
187 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
188 | - } |
|
185 | + $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
186 | + if($modx->hasPermission('settings')) { |
|
187 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
188 | + } |
|
189 | 189 | if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
190 | 190 | break; |
191 | 191 | case $_lang['configcheck_lang_difference'] : |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | 6 | // PROCESSOR FIRST |
7 | -if($_SESSION['mgrRole'] == 1) { |
|
8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
7 | +if ($_SESSION['mgrRole'] == 1) { |
|
8 | + if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | 9 | $current = $modx->getManagerApi()->getSystemChecksum($modx->config['check_files_onlogin']); |
10 | - if(!empty($current)) { |
|
10 | + if (!empty($current)) { |
|
11 | 11 | $modx->getManagerApi()->setSystemChecksum($current); |
12 | 12 | $modx->clearCache('full'); |
13 | 13 | $modx->config['sys_files_checksum'] = $current; |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | $warningspresent = 0; |
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->getManagerApi()->checkSystemChecksum(); |
22 | -if ($sysfiles_check!=='0'){ |
|
22 | +if ($sysfiles_check !== '0') { |
|
23 | 23 | $warningspresent = 1; |
24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
25 | 25 | } |
26 | 26 | |
27 | -if (is_writable("includes/config.inc.php")){ |
|
27 | +if (is_writable("includes/config.inc.php")) { |
|
28 | 28 | // Warn if world writable |
29 | - if(@fileperms('includes/config.inc.php') & 0x0002) { |
|
29 | + if (@fileperms('includes/config.inc.php') & 0x0002) { |
|
30 | 30 | $warningspresent = 1; |
31 | 31 | $warnings[] = array($_lang['configcheck_configinc']); |
32 | 32 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $warnings[] = array($_lang['configcheck_php_gdzip']); |
43 | 43 | } |
44 | 44 | |
45 | -if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | - if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
45 | +if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | + if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
47 | 47 | if ($modx->getDatabase()->getValue($modx->getDatabase()->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) { |
48 | 48 | $warningspresent = 1; |
49 | 49 | $warnings[] = array($_lang['configcheck_validate_referer']); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | // check for Template Switcher plugin |
55 | -if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | - if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
55 | +if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | + if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
57 | 57 | $rs = $modx->getDatabase()->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'"); |
58 | 58 | $row = $modx->getDatabase()->getRow($rs); |
59 | - if($row && $row['disabled'] == 0) { |
|
59 | + if ($row && $row['disabled'] == 0) { |
|
60 | 60 | $warningspresent = 1; |
61 | 61 | $warnings[] = array($_lang['configcheck_templateswitcher_present']); |
62 | 62 | $tplName = $row['name']; |
@@ -120,36 +120,36 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - function checkSiteCache() { |
|
123 | + function checkSiteCache(){ |
|
124 | 124 | $modx = evolutionCMS(); |
125 | - $checked= true; |
|
126 | - if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
|
127 | - $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php'); |
|
125 | + $checked = true; |
|
126 | + if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) { |
|
127 | + $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php'); |
|
128 | 128 | } |
129 | 129 | return $checked; |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | -if (!is_writable(MODX_BASE_PATH . "assets/cache/")) { |
|
133 | +if (!is_writable(MODX_BASE_PATH."assets/cache/")) { |
|
134 | 134 | $warningspresent = 1; |
135 | 135 | $warnings[] = array($_lang['configcheck_cache']); |
136 | 136 | } |
137 | 137 | |
138 | 138 | if (!checkSiteCache()) { |
139 | 139 | $warningspresent = 1; |
140 | - $warnings[]= array($lang['configcheck_sitecache_integrity']); |
|
140 | + $warnings[] = array($lang['configcheck_sitecache_integrity']); |
|
141 | 141 | } |
142 | 142 | |
143 | -if (!is_writable(MODX_BASE_PATH . "assets/images/")) { |
|
143 | +if (!is_writable(MODX_BASE_PATH."assets/images/")) { |
|
144 | 144 | $warningspresent = 1; |
145 | 145 | $warnings[] = array($_lang['configcheck_images']); |
146 | 146 | } |
147 | 147 | |
148 | -if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) { |
|
148 | +if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) { |
|
149 | 149 | $warningspresent = 1; |
150 | 150 | $warnings[] = array($_lang['configcheck_rb_base_dir']); |
151 | 151 | } |
152 | -if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) { |
|
152 | +if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) { |
|
153 | 153 | $warningspresent = 1; |
154 | 154 | $warnings[] = array($_lang['configcheck_filemanager_path']); |
155 | 155 | } |
@@ -157,36 +157,36 @@ discard block |
||
157 | 157 | // clear file info cache |
158 | 158 | clearstatcache(); |
159 | 159 | |
160 | -if ($warningspresent==1) { |
|
160 | +if ($warningspresent == 1) { |
|
161 | 161 | |
162 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
162 | +if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3'; |
|
163 | 163 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
164 | 164 | |
165 | -for ($i=0;$i<count($warnings);$i++) { |
|
165 | +for ($i = 0; $i < count($warnings); $i++) { |
|
166 | 166 | switch ($warnings[$i][0]) { |
167 | 167 | case $_lang['configcheck_configinc']; |
168 | 168 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
169 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
169 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']); |
|
170 | 170 | break; |
171 | 171 | case $_lang['configcheck_installer'] : |
172 | 172 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
173 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
173 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']); |
|
174 | 174 | break; |
175 | 175 | case $_lang['configcheck_cache'] : |
176 | 176 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
177 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
177 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']); |
|
178 | 178 | break; |
179 | 179 | case $_lang['configcheck_images'] : |
180 | 180 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
181 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
181 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']); |
|
182 | 182 | break; |
183 | 183 | case $_lang['configcheck_sysfiles_mod']: |
184 | 184 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
185 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
186 | - if($modx->hasPermission('settings')) { |
|
187 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
185 | + $warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>'; |
|
186 | + if ($modx->hasPermission('settings')) { |
|
187 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>'; |
|
188 | 188 | } |
189 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
189 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']); |
|
190 | 190 | break; |
191 | 191 | case $_lang['configcheck_lang_difference'] : |
192 | 192 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -208,18 +208,18 @@ discard block |
||
208 | 208 | break; |
209 | 209 | case $_lang['configcheck_validate_referer'] : |
210 | 210 | $msg = $_lang['configcheck_validate_referer_msg']; |
211 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
211 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
212 | 212 | $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n"; |
213 | 213 | break; |
214 | 214 | case $_lang['configcheck_templateswitcher_present'] : |
215 | 215 | $msg = $_lang["configcheck_templateswitcher_present_msg"]; |
216 | - if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
217 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"]; |
|
216 | + if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
217 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"]; |
|
218 | 218 | } |
219 | - if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
220 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"]; |
|
219 | + if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
220 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"]; |
|
221 | 221 | } |
222 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
222 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
223 | 223 | $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n"; |
224 | 224 | break; |
225 | 225 | case $_lang['configcheck_rb_base_dir'] : |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $warnings[$i][1] = $_lang['configcheck_default_msg']; |
233 | 233 | } |
234 | 234 | |
235 | - $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ; |
|
235 | + $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : ""; |
|
236 | 236 | $config_check_results .= " |
237 | 237 | <fieldset> |
238 | 238 | <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p> |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')." |
242 | 242 | </fieldset> |
243 | 243 | "; |
244 | - if ($i!=count($warnings)-1) { |
|
244 | + if ($i != count($warnings) - 1) { |
|
245 | 245 | $config_check_results .= "<br />"; |
246 | 246 | } |
247 | 247 | } |
248 | - $_SESSION["mgrConfigCheck"]=true; |
|
248 | + $_SESSION["mgrConfigCheck"] = true; |
|
249 | 249 | } else { |
250 | 250 | $config_check_results = $_lang['configcheck_ok']; |
251 | 251 | } |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | $warningspresent = 0; |
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->getManagerApi()->checkSystemChecksum(); |
22 | -if ($sysfiles_check!=='0'){ |
|
22 | +if ($sysfiles_check!=='0') { |
|
23 | 23 | $warningspresent = 1; |
24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
25 | 25 | } |
26 | 26 | |
27 | -if (is_writable("includes/config.inc.php")){ |
|
27 | +if (is_writable("includes/config.inc.php")) { |
|
28 | 28 | // Warn if world writable |
29 | 29 | if(@fileperms('includes/config.inc.php') & 0x0002) { |
30 | 30 | $warningspresent = 1; |
@@ -120,7 +120,8 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - function checkSiteCache() { |
|
123 | + function checkSiteCache() |
|
124 | + { |
|
124 | 125 | $modx = evolutionCMS(); |
125 | 126 | $checked= true; |
126 | 127 | if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
@@ -159,26 +160,36 @@ discard block |
||
159 | 160 | |
160 | 161 | if ($warningspresent==1) { |
161 | 162 | |
162 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
163 | +if(!isset($modx->config['send_errormail'])) { |
|
164 | + $modx->config['send_errormail']='3'; |
|
165 | +} |
|
163 | 166 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
164 | 167 | |
165 | 168 | for ($i=0;$i<count($warnings);$i++) { |
166 | 169 | switch ($warnings[$i][0]) { |
167 | 170 | case $_lang['configcheck_configinc']; |
168 | 171 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
169 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
172 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
173 | + $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
174 | + } |
|
170 | 175 | break; |
171 | 176 | case $_lang['configcheck_installer'] : |
172 | 177 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
173 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
178 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
179 | + $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
180 | + } |
|
174 | 181 | break; |
175 | 182 | case $_lang['configcheck_cache'] : |
176 | 183 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
177 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
184 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
185 | + $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
186 | + } |
|
178 | 187 | break; |
179 | 188 | case $_lang['configcheck_images'] : |
180 | 189 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
181 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
190 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
191 | + $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
192 | + } |
|
182 | 193 | break; |
183 | 194 | case $_lang['configcheck_sysfiles_mod']: |
184 | 195 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
@@ -186,7 +197,9 @@ discard block |
||
186 | 197 | if($modx->hasPermission('settings')) { |
187 | 198 | $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
188 | 199 | } |
189 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
200 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
201 | + $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
202 | + } |
|
190 | 203 | break; |
191 | 204 | case $_lang['configcheck_lang_difference'] : |
192 | 205 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |