| @@ -414,6 +414,9 @@ discard block | ||
| 414 | 414 | } | 
| 415 | 415 | } | 
| 416 | 416 | |
| 417 | + /** | |
| 418 | + * @param string $table | |
| 419 | + */ | |
| 417 | 420 | public function save($fields, $table, $where = '') | 
| 418 | 421 |      { | 
| 419 | 422 | |
| @@ -444,6 +447,7 @@ discard block | ||
| 444 | 447 | /** | 
| 445 | 448 | * @name: freeResult | 
| 446 | 449 | * | 
| 450 | + * @param mysqli_result $rs | |
| 447 | 451 | */ | 
| 448 | 452 | public function freeResult($rs) | 
| 449 | 453 |      { | 
| @@ -554,6 +558,7 @@ discard block | ||
| 554 | 558 | * @name: getColumn | 
| 555 | 559 | * @desc: returns an array of the values found on colun $name | 
| 556 | 560 | * @param: $dsq - dataset or query string | 
| 561 | + * @param string $name | |
| 557 | 562 | */ | 
| 558 | 563 | public function getColumn($name, $dsq) | 
| 559 | 564 |      { | 
| @@ -720,6 +725,9 @@ discard block | ||
| 720 | 725 | return $result; | 
| 721 | 726 | } | 
| 722 | 727 | |
| 728 | + /** | |
| 729 | + * @param string $table_name | |
| 730 | + */ | |
| 723 | 731 | public function optimize($table_name) | 
| 724 | 732 |      { | 
| 725 | 733 |          $rs = $this->query("OPTIMIZE TABLE {$table_name}"); | 
| @@ -730,6 +738,9 @@ discard block | ||
| 730 | 738 | return $rs; | 
| 731 | 739 | } | 
| 732 | 740 | |
| 741 | + /** | |
| 742 | + * @param string $table_name | |
| 743 | + */ | |
| 733 | 744 | public function truncate($table_name) | 
| 734 | 745 |      { | 
| 735 | 746 |          $rs = $this->query("TRUNCATE {$table_name}"); | 
| @@ -240,9 +240,9 @@ discard block | ||
| 240 | 240 | } | 
| 241 | 241 | |
| 242 | 242 | /** | 
| 243 | - * @param string|array $fields | |
| 244 | - * @param string|array $from | |
| 245 | - * @param string|array $where | |
| 243 | + * @param string $fields | |
| 244 | + * @param string $from | |
| 245 | + * @param string $where | |
| 246 | 246 | * @param string $orderBy | 
| 247 | 247 | * @param string $limit | 
| 248 | 248 | * @return bool|mysqli_result | 
| @@ -326,7 +326,7 @@ discard block | ||
| 326 | 326 | * @param string $fromtable | 
| 327 | 327 | * @param string $where | 
| 328 | 328 | * @param string $limit | 
| 329 | - * @return mixed | |
| 329 | + * @return null|integer | |
| 330 | 330 | */ | 
| 331 | 331 | public function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = "") | 
| 332 | 332 |      { | 
| @@ -368,7 +368,7 @@ discard block | ||
| 368 | 368 | |
| 369 | 369 | /** | 
| 370 | 370 | * @param $fields | 
| 371 | - * @param $table | |
| 371 | + * @param string $table | |
| 372 | 372 | * @param string $where | 
| 373 | 373 | * @return bool|mixed|mysqli_result | 
| 374 | 374 | */ | 
| @@ -435,7 +435,7 @@ discard block | ||
| 435 | 435 | |
| 436 | 436 | /** | 
| 437 | 437 | * @param null|mysqli $conn | 
| 438 | - * @return mixed | |
| 438 | + * @return integer | |
| 439 | 439 | */ | 
| 440 | 440 | public function getInsertId($conn = null) | 
| 441 | 441 |      { | 
| @@ -513,7 +513,7 @@ discard block | ||
| 513 | 513 | } | 
| 514 | 514 | |
| 515 | 515 | /** | 
| 516 | - * @param $name | |
| 516 | + * @param string $name | |
| 517 | 517 | * @param mysqli_result|string $dsq | 
| 518 | 518 | * @return array | 
| 519 | 519 | */ | 
| @@ -572,7 +572,7 @@ discard block | ||
| 572 | 572 | |
| 573 | 573 | /** | 
| 574 | 574 | * @param string $table | 
| 575 | - * @return array | |
| 575 | + * @return boolean | |
| 576 | 576 | */ | 
| 577 | 577 | public function getTableMetaData($table) | 
| 578 | 578 |      { | 
| @@ -619,7 +619,7 @@ discard block | ||
| 619 | 619 | } | 
| 620 | 620 | |
| 621 | 621 | /** | 
| 622 | - * @param string|mysqli_result $rs | |
| 622 | + * @param string $rs | |
| 623 | 623 | * @param bool $index | 
| 624 | 624 | * @return array | 
| 625 | 625 | */ | 
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | * @deprecated | 
| 73 | 73 | * | 
| 74 | 74 | * @param $rs | 
| 75 | - * @return int|mixed | |
| 75 | + * @return integer | |
| 76 | 76 | */ | 
| 77 | 77 | public function insertId($rs) | 
| 78 | 78 |      { | 
| @@ -177,7 +177,8 @@ | ||
| 177 | 177 | * @return bool|string | 
| 178 | 178 | */ | 
| 179 | 179 | public function putChunk($chunkName) | 
| 180 | -    { // alias name >.< | |
| 180 | +    { | |
| 181 | +// alias name >.< | |
| 181 | 182 | $modx = evolutionCMS(); | 
| 182 | 183 | |
| 183 | 184 | return $modx->getChunk($chunkName); | 
| @@ -280,7 +280,7 @@ discard block | ||
| 280 | 280 |       * MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php" | 
| 281 | 281 | * $extname - extension name in lowercase | 
| 282 | 282 | * | 
| 283 | - * @param $extname | |
| 283 | + * @param string $extname | |
| 284 | 284 | * @param bool $reload | 
| 285 | 285 | * @return bool | 
| 286 | 286 | */ | 
| @@ -325,7 +325,7 @@ discard block | ||
| 325 | 325 | * @param int $count_attempts | 
| 326 | 326 | * @param string $type $type | 
| 327 | 327 | * @param string $responseCode | 
| 328 | - * @return bool|null | |
| 328 | + * @return false|null | |
| 329 | 329 | * @global string $base_url | 
| 330 | 330 | * @global string $site_url | 
| 331 | 331 | */ | 
| @@ -1041,7 +1041,7 @@ discard block | ||
| 1041 | 1041 | } | 
| 1042 | 1042 | |
| 1043 | 1043 | /** | 
| 1044 | - * @param $contents | |
| 1044 | + * @param string $contents | |
| 1045 | 1045 | * @return mixed | 
| 1046 | 1046 | */ | 
| 1047 | 1047 | public function RecoveryEscapedTags($contents) | 
| @@ -1067,7 +1067,7 @@ discard block | ||
| 1067 | 1067 | } | 
| 1068 | 1068 | |
| 1069 | 1069 | /** | 
| 1070 | - * @param $tstart | |
| 1070 | + * @param double $tstart | |
| 1071 | 1071 | * @return array | 
| 1072 | 1072 | */ | 
| 1073 | 1073 | public function getTimerStats($tstart) | 
| @@ -1850,7 +1850,7 @@ discard block | ||
| 1850 | 1850 | |
| 1851 | 1851 | /** | 
| 1852 | 1852 | * Remove Comment-Tags from output like <!--@- Comment -@--> | 
| 1853 | - * @param $content | |
| 1853 | + * @param string $content | |
| 1854 | 1854 | * @param string $left | 
| 1855 | 1855 | * @param string $right | 
| 1856 | 1856 | * @return mixed | 
| @@ -2028,7 +2028,7 @@ discard block | ||
| 2028 | 2028 | /** | 
| 2029 | 2029 | * Run snippets as per the tags in $documentSource and replace the tags with the returned values. | 
| 2030 | 2030 | * | 
| 2031 | - * @param $content | |
| 2031 | + * @param string $content | |
| 2032 | 2032 | * @return string | 
| 2033 | 2033 | * @internal param string $documentSource | 
| 2034 | 2034 | */ | 
| @@ -3095,7 +3095,7 @@ discard block | ||
| 3095 | 3095 | |
| 3096 | 3096 | /** | 
| 3097 | 3097 | * @param $templateID | 
| 3098 | - * @return mixed | |
| 3098 | + * @return string | |
| 3099 | 3099 | */ | 
| 3100 | 3100 | public function _getTemplateCodeFromDB($templateID) | 
| 3101 | 3101 |      { | 
| @@ -3137,9 +3137,9 @@ discard block | ||
| 3137 | 3137 | } | 
| 3138 | 3138 | |
| 3139 | 3139 | /** | 
| 3140 | - * @param $id | |
| 3140 | + * @param integer $id | |
| 3141 | 3141 | * @param int $top | 
| 3142 | - * @return mixed | |
| 3142 | + * @return string | |
| 3143 | 3143 | */ | 
| 3144 | 3144 | public function getUltimateParentId($id, $top = 0) | 
| 3145 | 3145 |      { | 
| @@ -3479,7 +3479,7 @@ discard block | ||
| 3479 | 3479 | * | 
| 3480 | 3480 | * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role | 
| 3481 | 3481 | * @param int $id Element- / Resource-id | 
| 3482 | - * @return bool | |
| 3482 | + * @return false|null | |
| 3483 | 3483 | */ | 
| 3484 | 3484 | public function lockElement($type, $id) | 
| 3485 | 3485 |      { | 
| @@ -3502,7 +3502,7 @@ discard block | ||
| 3502 | 3502 | * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role | 
| 3503 | 3503 | * @param int $id Element- / Resource-id | 
| 3504 | 3504 | * @param bool $includeAllUsers true = Deletes not only own user-locks | 
| 3505 | - * @return bool | |
| 3505 | + * @return false|null | |
| 3506 | 3506 | */ | 
| 3507 | 3507 | public function unlockElement($type, $id, $includeAllUsers = false) | 
| 3508 | 3508 |      { | 
| @@ -3613,7 +3613,7 @@ discard block | ||
| 3613 | 3613 | * @param array $params | 
| 3614 | 3614 | * @param string $msg | 
| 3615 | 3615 | * @param array $files | 
| 3616 | - * @return mixed | |
| 3616 | + * @return boolean | |
| 3617 | 3617 | */ | 
| 3618 | 3618 | public function sendmail($params = array(), $msg = '', $files = array()) | 
| 3619 | 3619 |      { | 
| @@ -4050,7 +4050,7 @@ discard block | ||
| 4050 | 4050 | * Default: 1 | 
| 4051 | 4051 | * @param string $fields List of fields | 
| 4052 | 4052 | * Default: id, pagetitle, description, alias | 
| 4053 | - * @return boolean|array | |
| 4053 | + * @return string | |
| 4054 | 4054 | */ | 
| 4055 | 4055 | public function getPageInfo($pageid = -1, $active = 1, $fields = 'id, pagetitle, description, alias') | 
| 4056 | 4056 |      { | 
| @@ -4148,7 +4148,7 @@ discard block | ||
| 4148 | 4148 | * | 
| 4149 | 4149 | * @param string $type | 
| 4150 | 4150 | * @param bool $report | 
| 4151 | - * @return bool | |
| 4151 | + * @return boolean|null | |
| 4152 | 4152 | */ | 
| 4153 | 4153 | public function clearCache($type = '', $report = false) | 
| 4154 | 4154 |      { | 
| @@ -4521,7 +4521,7 @@ discard block | ||
| 4521 | 4521 |       * - Placeholders prefix. Default: '{'. | 
| 4522 | 4522 |       * @param string $suffix {string} | 
| 4523 | 4523 | * - Placeholders suffix. Default: '}'. | 
| 4524 | -     * @return bool|mixed|string {string; false} - Parsed chunk or false if $chunkArr is not array. | |
| 4524 | +     * @return false|string {string; false} - Parsed chunk or false if $chunkArr is not array. | |
| 4525 | 4525 | * - Parsed chunk or false if $chunkArr is not array. | 
| 4526 | 4526 | */ | 
| 4527 | 4527 |      public function parseChunk($chunkName, $chunkArr, $prefix = '{', $suffix = '}') | 
| @@ -5555,7 +5555,7 @@ discard block | ||
| 5555 | 5555 | * Remove event listener - only for use within the current execution cycle | 
| 5556 | 5556 | * | 
| 5557 | 5557 | * @param string $evtName | 
| 5558 | - * @return boolean | |
| 5558 | + * @return false|null | |
| 5559 | 5559 | */ | 
| 5560 | 5560 | public function removeEventListener($evtName) | 
| 5561 | 5561 |      { | 
| @@ -5579,7 +5579,7 @@ discard block | ||
| 5579 | 5579 | * | 
| 5580 | 5580 | * @param string $evtName | 
| 5581 | 5581 | * @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. | 
| 5582 | - * @return boolean|array | |
| 5582 | + * @return false|null | |
| 5583 | 5583 | */ | 
| 5584 | 5584 | public function invokeEvent($evtName, $extParams = array()) | 
| 5585 | 5585 |      { | 
| @@ -6201,7 +6201,7 @@ discard block | ||
| 6201 | 6201 | |
| 6202 | 6202 | /** | 
| 6203 | 6203 | * @param string $str | 
| 6204 | - * @return bool|mixed|string | |
| 6204 | + * @return string | |
| 6205 | 6205 | */ | 
| 6206 | 6206 | public function atBindFileContent($str = '') | 
| 6207 | 6207 |      { | 
| @@ -6258,8 +6258,8 @@ discard block | ||
| 6258 | 6258 | } | 
| 6259 | 6259 | |
| 6260 | 6260 | /** | 
| 6261 | - * @param $str | |
| 6262 | - * @return bool|string | |
| 6261 | + * @param string $str | |
| 6262 | + * @return false|string | |
| 6263 | 6263 | */ | 
| 6264 | 6264 | public function getExtFromFilename($str) | 
| 6265 | 6265 |      { | 
| @@ -6287,7 +6287,7 @@ discard block | ||
| 6287 | 6287 | * @param string $text Error message | 
| 6288 | 6288 | * @param string $file File where the error was detected | 
| 6289 | 6289 | * @param string $line Line number within $file | 
| 6290 | - * @return boolean | |
| 6290 | + * @return boolean|null | |
| 6291 | 6291 | */ | 
| 6292 | 6292 | public function phpError($nr, $text, $file, $line) | 
| 6293 | 6293 |      { | 
| @@ -6339,7 +6339,7 @@ discard block | ||
| 6339 | 6339 | * @param string $text | 
| 6340 | 6340 | * @param string $line | 
| 6341 | 6341 | * @param string $output | 
| 6342 | - * @return bool | |
| 6342 | + * @return null|boolean | |
| 6343 | 6343 | */ | 
| 6344 | 6344 | public function messageQuit( | 
| 6345 | 6345 | $msg = 'unspecified error', | 
| @@ -6782,7 +6782,7 @@ discard block | ||
| 6782 | 6782 | |
| 6783 | 6783 | /** | 
| 6784 | 6784 | * @param string $str | 
| 6785 | - * @return bool|mixed|string | |
| 6785 | + * @return string | |
| 6786 | 6786 | */ | 
| 6787 | 6787 | public function atBindInclude($str = '') | 
| 6788 | 6788 |      { | 
| @@ -6834,7 +6834,7 @@ discard block | ||
| 6834 | 6834 | * @param $str | 
| 6835 | 6835 | * @param int $flags | 
| 6836 | 6836 | * @param string $encode | 
| 6837 | - * @return mixed | |
| 6837 | + * @return string | |
| 6838 | 6838 | */ | 
| 6839 | 6839 | public function htmlspecialchars($str, $flags = ENT_COMPAT, $encode = '') | 
| 6840 | 6840 |      { | 
| @@ -6844,7 +6844,7 @@ discard block | ||
| 6844 | 6844 | } | 
| 6845 | 6845 | |
| 6846 | 6846 | /** | 
| 6847 | - * @param $string | |
| 6847 | + * @param string $string | |
| 6848 | 6848 | * @param bool $returnData | 
| 6849 | 6849 | * @return bool|mixed | 
| 6850 | 6850 | */ | 
| @@ -729,7 +729,8 @@ discard block | ||
| 729 | 729 | } | 
| 730 | 730 | |
| 731 | 731 |          if (preg_match('@^[1-9][0-9]*$@', | 
| 732 | -                $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */ | |
| 732 | +                $q) && !isset($this->documentListing[$q])) { | |
| 733 | +/* we got an ID returned, check to make sure it's not an alias */ | |
| 733 | 734 | /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */ | 
| 734 | 735 |              if ($this->config['use_alias_path'] == 1) { | 
| 735 | 736 | 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, | 
| @@ -738,7 +739,8 @@ discard block | ||
| 738 | 739 | $this->documentMethod = 'id'; | 
| 739 | 740 | |
| 740 | 741 | return $q; | 
| 741 | -                } else { /* not a valid id in terms of virtualDir, treat as alias */ | |
| 742 | +                } else { | |
| 743 | +/* not a valid id in terms of virtualDir, treat as alias */ | |
| 742 | 744 | $this->documentMethod = 'alias'; | 
| 743 | 745 | |
| 744 | 746 | return $q; | 
| @@ -748,7 +750,8 @@ discard block | ||
| 748 | 750 | |
| 749 | 751 | return $q; | 
| 750 | 752 | } | 
| 751 | -        } else { /* we didn't get an ID back, so instead we assume it's an alias */ | |
| 753 | +        } else { | |
| 754 | +/* we didn't get an ID back, so instead we assume it's an alias */ | |
| 752 | 755 |              if ($this->config['friendly_alias_urls'] != 1) { | 
| 753 | 756 | $q = $qOrig; | 
| 754 | 757 | } | 
| @@ -1278,7 +1281,8 @@ discard block | ||
| 1278 | 1281 | } | 
| 1279 | 1282 | } | 
| 1280 | 1283 | |
| 1281 | -                    if (!in_array($fetch, $tags)) {  // Avoid double Matches | |
| 1284 | +                    if (!in_array($fetch, $tags)) { | |
| 1285 | +// Avoid double Matches | |
| 1282 | 1286 | $tags[] = $fetch; // Fetch | 
| 1283 | 1287 | }; | 
| 1284 | 1288 | $fetch = ''; // and reset | 
| @@ -2089,7 +2093,8 @@ discard block | ||
| 2089 | 2093 | * @return mixed|string | 
| 2090 | 2094 | */ | 
| 2091 | 2095 | public function _getSGVar($value) | 
| 2092 | -    { // Get super globals | |
| 2096 | +    { | |
| 2097 | +// Get super globals | |
| 2093 | 2098 | $key = $value; | 
| 2094 | 2099 | $_ = $this->config['enable_filter']; | 
| 2095 | 2100 | $this->config['enable_filter'] = 1; | 
| @@ -2510,7 +2515,8 @@ discard block | ||
| 2510 | 2515 |          if ($this->config['friendly_urls'] == 1) { | 
| 2511 | 2516 | $aliases = array(); | 
| 2512 | 2517 |              if (is_array($this->documentListing)) { | 
| 2513 | -                foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site! | |
| 2518 | +                foreach ($this->documentListing as $path => $docid) { | |
| 2519 | +// This is big Loop on large site! | |
| 2514 | 2520 | $aliases[$docid] = $path; | 
| 2515 | 2521 | $isfolder[$docid] = $this->aliasListing[$docid]['isfolder']; | 
| 2516 | 2522 | } | 
| @@ -2545,7 +2551,7 @@ discard block | ||
| 2545 | 2551 | $pref = $this->config['friendly_url_prefix']; | 
| 2546 | 2552 | $suff = $this->config['friendly_url_suffix']; | 
| 2547 | 2553 | $documentSource = preg_replace_callback($in, | 
| 2548 | -                function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { | |
| 2554 | +                function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){ | |
| 2549 | 2555 | $modx = evolutionCMS(); | 
| 2550 | 2556 | $thealias = $aliases[$m[1]]; | 
| 2551 | 2557 | $thefolder = $isfolder[$m[1]]; | 
| @@ -4387,7 +4393,8 @@ discard block | ||
| 4387 | 4393 |          if (isset ($this->snippetCache[$snippetName])) { | 
| 4388 | 4394 | $snippet = $this->snippetCache[$snippetName]; | 
| 4389 | 4395 | $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; | 
| 4390 | -        } else { // not in cache so let's check the db | |
| 4396 | +        } else { | |
| 4397 | +// not in cache so let's check the db | |
| 4391 | 4398 |              $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->db->escape($snippetName) . "'  AND ss.disabled=0;"; | 
| 4392 | 4399 | $result = $this->db->query($sql); | 
| 4393 | 4400 |              if ($this->db->getRecordCount($result) == 1) { | 
| @@ -5426,12 +5433,16 @@ discard block | ||
| 5426 | 5433 | return ''; | 
| 5427 | 5434 | } // nothing to register | 
| 5428 | 5435 |          if (!is_array($options)) { | 
| 5429 | - if (is_bool($options)) // backward compatibility with old plaintext parameter | |
| 5436 | +            if (is_bool($options)) { | |
| 5437 | + // backward compatibility with old plaintext parameter | |
| 5430 | 5438 |              { | 
| 5431 | 5439 |                  $options = array('plaintext' => $options); | 
| 5432 | - } elseif (is_string($options)) // Also allow script name as 2nd param | |
| 5440 | + } | |
| 5441 | +            } elseif (is_string($options)) { | |
| 5442 | + // Also allow script name as 2nd param | |
| 5433 | 5443 |              { | 
| 5434 | 5444 |                  $options = array('name' => $options); | 
| 5445 | + } | |
| 5435 | 5446 |              } else { | 
| 5436 | 5447 | $options = array(); | 
| 5437 | 5448 | } | 
| @@ -5443,7 +5454,8 @@ discard block | ||
| 5443 | 5454 | unset($overwritepos); // probably unnecessary--just making sure | 
| 5444 | 5455 | |
| 5445 | 5456 | $useThisVer = true; | 
| 5446 | -        if (isset($this->loadedjscripts[$key])) { // a matching script was found | |
| 5457 | +        if (isset($this->loadedjscripts[$key])) { | |
| 5458 | +// a matching script was found | |
| 5447 | 5459 | // if existing script is a startup script, make sure the candidate is also a startup script | 
| 5448 | 5460 |              if ($this->loadedjscripts[$key]['startup']) { | 
| 5449 | 5461 | $startup = true; | 
| @@ -5463,7 +5475,8 @@ discard block | ||
| 5463 | 5475 | // overwrite the old script (the position may be important for dependent scripts) | 
| 5464 | 5476 | $overwritepos = $this->loadedjscripts[$key]['pos']; | 
| 5465 | 5477 | } | 
| 5466 | -            } else { // Use the original version | |
| 5478 | +            } else { | |
| 5479 | +// Use the original version | |
| 5467 | 5480 |                  if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) { | 
| 5468 | 5481 | // need to move the exisiting script to the head | 
| 5469 | 5482 | $version = $this->loadedjscripts[$key][$version]; | 
| @@ -5591,7 +5604,8 @@ discard block | ||
| 5591 | 5604 | } | 
| 5592 | 5605 | |
| 5593 | 5606 | $results = null; | 
| 5594 | -        foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop | |
| 5607 | +        foreach ($this->pluginEvent[$evtName] as $pluginName) { | |
| 5608 | +// start for loop | |
| 5595 | 5609 |              if ($this->dumpPlugins) { | 
| 5596 | 5610 | $eventtime = $this->getMicroTime(); | 
| 5597 | 5611 | } | 
| @@ -6161,7 +6175,8 @@ discard block | ||
| 6161 | 6175 | * @return bool | 
| 6162 | 6176 | */ | 
| 6163 | 6177 | public function isSafeCode($phpcode = '', $safe_functions = '') | 
| 6164 | -    { // return true or false | |
| 6178 | +    { | |
| 6179 | +// return true or false | |
| 6165 | 6180 |          if ($safe_functions == '') { | 
| 6166 | 6181 | return false; | 
| 6167 | 6182 | } | 
| @@ -6599,7 +6614,7 @@ discard block | ||
| 6599 | 6614 | $args = array_pad(array(), $_, '$var'); | 
| 6600 | 6615 |              $args = implode(", ", $args); | 
| 6601 | 6616 | $modx = &$this; | 
| 6602 | -            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { | |
| 6617 | +            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){ | |
| 6603 | 6618 | $arg = $val['args'][$tmp - 1]; | 
| 6604 | 6619 |                  switch (true) { | 
| 6605 | 6620 |                      case is_null($arg): { | 
| @@ -94,7 +94,7 @@ discard block | ||
| 94 | 94 | /** | 
| 95 | 95 | * @param string $mode | 
| 96 | 96 | * @param string $modifiers | 
| 97 | - * @return bool|string | |
| 97 | + * @return false|string | |
| 98 | 98 | */ | 
| 99 | 99 |      public function _getDelim($mode,$modifiers) { | 
| 100 | 100 | $c = substr($modifiers,0,1); | 
| @@ -131,6 +131,14 @@ discard block | ||
| 131 | 131 | return $opt; | 
| 132 | 132 | } | 
| 133 | 133 | } | 
| 134 | + | |
| 135 | + /** | |
| 136 | + * @param string $mode | |
| 137 | + * @param false|string $delim | |
| 138 | + * @param string $modifiers | |
| 139 | + * | |
| 140 | + * @return string | |
| 141 | + */ | |
| 134 | 142 |      public function _getRemainModifiers($mode,$delim,$modifiers) { | 
| 135 | 143 |          if($delim) { | 
| 136 | 144 |              if($mode=='(') | 
| @@ -158,6 +166,9 @@ discard block | ||
| 158 | 166 | return substr($string,strpos($string, $delim)+$len); | 
| 159 | 167 | } | 
| 160 | 168 | |
| 169 | + /** | |
| 170 | + * @param string $modifiers | |
| 171 | + */ | |
| 161 | 172 |      public function splitEachModifiers($modifiers) { | 
| 162 | 173 | $modx = evolutionCMS(); | 
| 163 | 174 | |
| @@ -227,6 +238,10 @@ discard block | ||
| 227 | 238 | return $result; | 
| 228 | 239 | } | 
| 229 | 240 | |
| 241 | + /** | |
| 242 | + * @param string $key | |
| 243 | + * @param string $value | |
| 244 | + */ | |
| 230 | 245 | public function parsePhx($key,$value,$modifiers) | 
| 231 | 246 |      { | 
| 232 | 247 | $modx = evolutionCMS(); | 
| @@ -293,6 +308,10 @@ discard block | ||
| 293 | 308 | else return true; | 
| 294 | 309 | } | 
| 295 | 310 | |
| 311 | + /** | |
| 312 | + * @param string $cmd | |
| 313 | + * @param string $opt | |
| 314 | + */ | |
| 296 | 315 | public function getValueFromPreset($key, $value, $cmd, $opt) | 
| 297 | 316 |      { | 
| 298 | 317 | $modx = evolutionCMS(); | 
| @@ -978,6 +997,9 @@ discard block | ||
| 978 | 997 | return $value; | 
| 979 | 998 | } | 
| 980 | 999 | |
| 1000 | + /** | |
| 1001 | + * @param string $cmd | |
| 1002 | + */ | |
| 981 | 1003 |      public function includeMdfFile($cmd) { | 
| 982 | 1004 | $modx = evolutionCMS(); | 
| 983 | 1005 | $key = $this->key; | 
| @@ -1133,6 +1155,10 @@ discard block | ||
| 1133 | 1155 | } | 
| 1134 | 1156 | |
| 1135 | 1157 | // Sets a placeholder variable which can only be access by Modifiers | 
| 1158 | + | |
| 1159 | + /** | |
| 1160 | + * @param string $value | |
| 1161 | + */ | |
| 1136 | 1162 |      public function setModifiersVariable($key, $value) { | 
| 1137 | 1163 | if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; | 
| 1138 | 1164 | } | 
| @@ -1,8 +1,11 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/'); | |
| 3 | +if(!defined('MODX_CORE_PATH')) { | |
| 4 | +    define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/'); | |
| 5 | +} | |
| 4 | 6 | |
| 5 | -class MODIFIERS { | |
| 7 | +class MODIFIERS | |
| 8 | +{ | |
| 6 | 9 | /** | 
| 7 | 10 | * @var array | 
| 8 | 11 | */ | 
| @@ -60,7 +63,9 @@ discard block | ||
| 60 | 63 | public function __construct() | 
| 61 | 64 |      { | 
| 62 | 65 | $modx = evolutionCMS(); | 
| 63 | -        if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']); | |
| 66 | +        if (function_exists('mb_internal_encoding')) { | |
| 67 | + mb_internal_encoding($modx->config['modx_charset']); | |
| 68 | + } | |
| 64 | 69 | $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'; | 
| 65 | 70 | } | 
| 66 | 71 | |
| @@ -73,7 +78,9 @@ discard block | ||
| 73 | 78 | public function phxFilter($key,$value,$modifiers) | 
| 74 | 79 |      { | 
| 75 | 80 | $modx = evolutionCMS(); | 
| 76 | -        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value); | |
| 81 | +        if(substr($modifiers,0,3)!=='id(') { | |
| 82 | + $value = $this->parseDocumentSource($value); | |
| 83 | + } | |
| 77 | 84 | $this->srcValue = $value; | 
| 78 | 85 | $modifiers = trim($modifiers); | 
| 79 | 86 | $modifiers = ':'.trim($modifiers,':'); | 
| @@ -96,13 +103,18 @@ discard block | ||
| 96 | 103 | * @param string $modifiers | 
| 97 | 104 | * @return bool|string | 
| 98 | 105 | */ | 
| 99 | -    public function _getDelim($mode,$modifiers) { | |
| 106 | + public function _getDelim($mode,$modifiers) | |
| 107 | +    { | |
| 100 | 108 | $c = substr($modifiers,0,1); | 
| 101 | -        if(!in_array($c, array('"', "'", '`')) ) return false; | |
| 109 | +        if(!in_array($c, array('"', "'", '`')) ) { | |
| 110 | + return false; | |
| 111 | + } | |
| 102 | 112 | |
| 103 | 113 | $modifiers = substr($modifiers,1); | 
| 104 | 114 |          $closure = $mode=='(' ? "{$c})" : $c; | 
| 105 | - if(strpos($modifiers, $closure)===false) return false; | |
| 115 | +        if(strpos($modifiers, $closure)===false) { | |
| 116 | + return false; | |
| 117 | + } | |
| 106 | 118 | |
| 107 | 119 | return $c; | 
| 108 | 120 | } | 
| @@ -113,52 +125,65 @@ discard block | ||
| 113 | 125 | * @param string $modifiers | 
| 114 | 126 | * @return bool|string | 
| 115 | 127 | */ | 
| 116 | -    public function _getOpt($mode,$delim,$modifiers) { | |
| 128 | + public function _getOpt($mode,$delim,$modifiers) | |
| 129 | +    { | |
| 117 | 130 |          if($delim) { | 
| 118 | -            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); | |
| 131 | +            if($mode=='(') { | |
| 132 | + return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); | |
| 133 | + } | |
| 119 | 134 | |
| 120 | 135 | return substr($modifiers,1,strpos($modifiers,$delim,1)-1); | 
| 121 | - } | |
| 122 | -        else { | |
| 123 | -            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') ); | |
| 136 | +        } else { | |
| 137 | +            if($mode=='(') { | |
| 138 | + return substr($modifiers,0,strpos($modifiers, ')') ); | |
| 139 | + } | |
| 124 | 140 | |
| 125 | 141 | $chars = str_split($modifiers); | 
| 126 | 142 | $opt=''; | 
| 127 | 143 |              foreach($chars as $c) { | 
| 128 | - if($c==':' || $c==')') break; | |
| 144 | +                if($c==':' || $c==')') { | |
| 145 | + break; | |
| 146 | + } | |
| 129 | 147 | $opt .=$c; | 
| 130 | 148 | } | 
| 131 | 149 | return $opt; | 
| 132 | 150 | } | 
| 133 | 151 | } | 
| 134 | -    public function _getRemainModifiers($mode,$delim,$modifiers) { | |
| 152 | + public function _getRemainModifiers($mode,$delim,$modifiers) | |
| 153 | +    { | |
| 135 | 154 |          if($delim) { | 
| 136 | -            if($mode=='(') | |
| 137 | - return $this->_fetchContent($modifiers, $delim . ')'); | |
| 138 | -            else { | |
| 155 | +            if($mode=='(') { | |
| 156 | + return $this->_fetchContent($modifiers, $delim . ')'); | |
| 157 | +            } else { | |
| 139 | 158 | $modifiers = trim($modifiers); | 
| 140 | 159 | $modifiers = substr($modifiers,1); | 
| 141 | 160 | return $this->_fetchContent($modifiers, $delim); | 
| 142 | 161 | } | 
| 143 | - } | |
| 144 | -        else { | |
| 145 | -            if($mode=='(') return $this->_fetchContent($modifiers, ')'); | |
| 162 | +        } else { | |
| 163 | +            if($mode=='(') { | |
| 164 | + return $this->_fetchContent($modifiers, ')'); | |
| 165 | + } | |
| 146 | 166 | $chars = str_split($modifiers); | 
| 147 | 167 |              foreach($chars as $c) { | 
| 148 | - if($c==':') return $modifiers; | |
| 149 | - else $modifiers = substr($modifiers,1); | |
| 168 | +                if($c==':') { | |
| 169 | + return $modifiers; | |
| 170 | +                } else { | |
| 171 | + $modifiers = substr($modifiers,1); | |
| 172 | + } | |
| 150 | 173 | } | 
| 151 | 174 | return $modifiers; | 
| 152 | 175 | } | 
| 153 | 176 | } | 
| 154 | 177 | |
| 155 | -    public function _fetchContent($string,$delim) { | |
| 178 | + public function _fetchContent($string,$delim) | |
| 179 | +    { | |
| 156 | 180 | $len = strlen($delim); | 
| 157 | 181 | $string = $this->parseDocumentSource($string); | 
| 158 | 182 | return substr($string,strpos($string, $delim)+$len); | 
| 159 | 183 | } | 
| 160 | 184 | |
| 161 | -    public function splitEachModifiers($modifiers) { | |
| 185 | + public function splitEachModifiers($modifiers) | |
| 186 | +    { | |
| 162 | 187 | $modx = evolutionCMS(); | 
| 163 | 188 | |
| 164 | 189 | $cmd = ''; | 
| @@ -169,11 +194,15 @@ discard block | ||
| 169 | 194 | $c = substr($modifiers,0,1); | 
| 170 | 195 | $modifiers = substr($modifiers,1); | 
| 171 | 196 | |
| 172 | -            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= | |
| 197 | +            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { | |
| 198 | +// :=, :!=, :<=, :>=, :!<=, :!>= | |
| 173 | 199 | $c = substr($modifiers,strlen($match[1]),1); | 
| 174 | 200 |                  $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]"; | 
| 175 | -                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1); | |
| 176 | - else $modifiers = substr($modifiers,strlen($match[1])); | |
| 201 | +                if($c==='(') { | |
| 202 | + $modifiers = substr($modifiers,strlen($match[1])+1); | |
| 203 | +                } else { | |
| 204 | + $modifiers = substr($modifiers,strlen($match[1])); | |
| 205 | + } | |
| 177 | 206 | |
| 178 | 207 | $delim = $this->_getDelim($c,$modifiers); | 
| 179 | 208 | $opt = $this->_getOpt($c,$delim,$modifiers); | 
| @@ -181,13 +210,12 @@ discard block | ||
| 181 | 210 | |
| 182 | 211 |                  $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo); | 
| 183 | 212 | $cmd = ''; | 
| 184 | - } | |
| 185 | -            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... | |
| 213 | +            } elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { | |
| 214 | +// :+3, :-3, :*3 ... | |
| 186 | 215 | $modifiers = substr($modifiers,strlen($match[0])); | 
| 187 | 216 |                  $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]); | 
| 188 | 217 | $cmd = ''; | 
| 189 | - } | |
| 190 | -            elseif($c==='(' || $c==='=') { | |
| 218 | +            } elseif($c==='(' || $c==='=') { | |
| 191 | 219 | $modifiers = $m1 = trim($modifiers); | 
| 192 | 220 | $delim = $this->_getDelim($c,$modifiers); | 
| 193 | 221 | $opt = $this->_getOpt($c,$delim,$modifiers); | 
| @@ -197,29 +225,29 @@ discard block | ||
| 197 | 225 |                  $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo); | 
| 198 | 226 | |
| 199 | 227 | $cmd = ''; | 
| 200 | - } | |
| 201 | -            elseif($c==':') { | |
| 228 | +            } elseif($c==':') { | |
| 202 | 229 |                  $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]"; | 
| 203 | -                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); | |
| 230 | +                if($cmd!=='') { | |
| 231 | +                    $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); | |
| 232 | + } | |
| 204 | 233 | |
| 205 | 234 | $cmd = ''; | 
| 206 | - } | |
| 207 | -            elseif(trim($modifiers)=='' && trim($cmd)!=='') { | |
| 235 | +            } elseif(trim($modifiers)=='' && trim($cmd)!=='') { | |
| 208 | 236 |                  $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]"; | 
| 209 | 237 | $cmd .= $c; | 
| 210 | 238 |                  $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); | 
| 211 | 239 | |
| 212 | 240 | break; | 
| 213 | - } | |
| 214 | -            else { | |
| 241 | +            } else { | |
| 215 | 242 | $cmd .= $c; | 
| 216 | 243 | } | 
| 217 | 244 | } | 
| 218 | 245 | |
| 219 | - if(empty($result)) return array(); | |
| 246 | +        if(empty($result)) { | |
| 247 | + return array(); | |
| 248 | + } | |
| 220 | 249 | |
| 221 | - foreach($result as $i=>$a) | |
| 222 | -        { | |
| 250 | +        foreach($result as $i=>$a) { | |
| 223 | 251 | $a['opt'] = $this->parseDocumentSource($a['opt']); | 
| 224 | 252 | $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders); | 
| 225 | 253 | } | 
| @@ -232,22 +260,23 @@ discard block | ||
| 232 | 260 | $modx = evolutionCMS(); | 
| 233 | 261 | $lastKey = ''; | 
| 234 | 262 |          $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true))); | 
| 235 | - if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; | |
| 236 | - if(empty($modifiers)) return ''; | |
| 263 | +        if(isset($this->tmpCache[$cacheKey])) { | |
| 264 | + return $this->tmpCache[$cacheKey]; | |
| 265 | + } | |
| 266 | +        if(empty($modifiers)) { | |
| 267 | + return ''; | |
| 268 | + } | |
| 237 | 269 | |
| 238 | - foreach($modifiers as $m) | |
| 239 | -        { | |
| 270 | +        foreach($modifiers as $m) { | |
| 240 | 271 | $lastKey = strtolower($m['cmd']); | 
| 241 | 272 | } | 
| 242 | 273 |          $_ = explode(',',$this->condModifiers); | 
| 243 | - if(in_array($lastKey,$_)) | |
| 244 | -        { | |
| 274 | +        if(in_array($lastKey,$_)) { | |
| 245 | 275 |              $modifiers[] = array('cmd'=>'then','opt'=>'1'); | 
| 246 | 276 |              $modifiers[] = array('cmd'=>'else','opt'=>'0'); | 
| 247 | 277 | } | 
| 248 | 278 | |
| 249 | - foreach($modifiers as $i=>$a) | |
| 250 | -        { | |
| 279 | +        foreach($modifiers as $i=>$a) { | |
| 251 | 280 | $value = $this->Filter($key,$value, $a['cmd'], $a['opt']); | 
| 252 | 281 | } | 
| 253 | 282 | $this->tmpCache[$cacheKey] = $value; | 
| @@ -259,25 +288,32 @@ discard block | ||
| 259 | 288 |      { | 
| 260 | 289 | $modx = evolutionCMS(); | 
| 261 | 290 | |
| 262 | - if($key==='documentObject') $value = $modx->documentIdentifier; | |
| 291 | +        if($key==='documentObject') { | |
| 292 | + $value = $modx->documentIdentifier; | |
| 293 | + } | |
| 263 | 294 | $cmd = $this->parseDocumentSource($cmd); | 
| 264 | -        if(preg_match('@^[1-9][/0-9]*$@',$cmd)) | |
| 265 | -        { | |
| 266 | - if(strpos($cmd,'/')!==false) | |
| 267 | - $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); | |
| 295 | +        if(preg_match('@^[1-9][/0-9]*$@',$cmd)) { | |
| 296 | +            if(strpos($cmd,'/')!==false) { | |
| 297 | + $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); | |
| 298 | + } | |
| 268 | 299 | $opt = $cmd; | 
| 269 | 300 | $cmd = 'id'; | 
| 270 | 301 | } | 
| 271 | 302 | |
| 272 | -        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}"; | |
| 273 | -        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; | |
| 274 | - else $this->elmName = ''; | |
| 303 | +        if(isset($modx->snippetCache["phx:{$cmd}"])) { | |
| 304 | +            $this->elmName = "phx:{$cmd}"; | |
| 305 | +        } elseif(isset($modx->chunkCache["phx:{$cmd}"])) { | |
| 306 | +            $this->elmName = "phx:{$cmd}"; | |
| 307 | +        } else { | |
| 308 | + $this->elmName = ''; | |
| 309 | + } | |
| 275 | 310 | |
| 276 | 311 | $cmd = strtolower($cmd); | 
| 277 | - if($this->elmName!=='') | |
| 278 | - $value = $this->getValueFromElement($key, $value, $cmd, $opt); | |
| 279 | - else | |
| 280 | - $value = $this->getValueFromPreset($key, $value, $cmd, $opt); | |
| 312 | +        if($this->elmName!=='') { | |
| 313 | + $value = $this->getValueFromElement($key, $value, $cmd, $opt); | |
| 314 | +        } else { | |
| 315 | + $value = $this->getValueFromPreset($key, $value, $cmd, $opt); | |
| 316 | + } | |
| 281 | 317 | |
| 282 | 318 |          $value = str_replace('[+key+]', $key, $value); | 
| 283 | 319 | |
| @@ -286,29 +322,37 @@ discard block | ||
| 286 | 322 | |
| 287 | 323 | public function isEmpty($cmd,$value) | 
| 288 | 324 |      { | 
| 289 | - if($value!=='') return false; | |
| 325 | +        if($value!=='') { | |
| 326 | + return false; | |
| 327 | + } | |
| 290 | 328 | |
| 291 | 329 |          $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); | 
| 292 | - if(in_array($cmd,$_)) return false; | |
| 293 | - else return true; | |
| 330 | +        if(in_array($cmd,$_)) { | |
| 331 | + return false; | |
| 332 | +        } else { | |
| 333 | + return true; | |
| 334 | + } | |
| 294 | 335 | } | 
| 295 | 336 | |
| 296 | 337 | public function getValueFromPreset($key, $value, $cmd, $opt) | 
| 297 | 338 |      { | 
| 298 | 339 | $modx = evolutionCMS(); | 
| 299 | 340 | |
| 300 | - if($this->isEmpty($cmd,$value)) return ''; | |
| 341 | +        if($this->isEmpty($cmd,$value)) { | |
| 342 | + return ''; | |
| 343 | + } | |
| 301 | 344 | |
| 302 | 345 | $this->key = $key; | 
| 303 | 346 | $this->value = $value; | 
| 304 | 347 | $this->opt = $opt; | 
| 305 | 348 | |
| 306 | - switch ($cmd) | |
| 307 | -        { | |
| 349 | +        switch ($cmd) { | |
| 308 | 350 | ##### Conditional Modifiers | 
| 309 | 351 | case 'input': | 
| 310 | 352 | case 'if': | 
| 311 | - if(!$opt) return $value; | |
| 353 | +                if(!$opt) { | |
| 354 | + return $value; | |
| 355 | + } | |
| 312 | 356 | return $opt; | 
| 313 | 357 | case '=': | 
| 314 | 358 | case 'eq': | 
| @@ -369,14 +413,24 @@ discard block | ||
| 369 | 413 | case 'file_exists': | 
| 370 | 414 | case 'is_readable': | 
| 371 | 415 | case 'is_writable': | 
| 372 | - if(!$opt) $path = $value; | |
| 373 | - else $path = $opt; | |
| 374 | -                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path'); | |
| 375 | - if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/'); | |
| 416 | +                if(!$opt) { | |
| 417 | + $path = $value; | |
| 418 | +                } else { | |
| 419 | + $path = $opt; | |
| 420 | + } | |
| 421 | +                if(strpos($path,MODX_MANAGER_PATH)!==false) { | |
| 422 | +                    exit('Can not read core path'); | |
| 423 | + } | |
| 424 | +                if(strpos($path,$modx->config['base_path'])===false) { | |
| 425 | + $path = ltrim($path,'/'); | |
| 426 | + } | |
| 376 | 427 | $this->condition[] = (int)($cmd($path)!==false);break; | 
| 377 | 428 | case 'is_image': | 
| 378 | - if(!$opt) $path = $value; | |
| 379 | - else $path = $opt; | |
| 429 | +                if(!$opt) { | |
| 430 | + $path = $value; | |
| 431 | +                } else { | |
| 432 | + $path = $opt; | |
| 433 | + } | |
| 380 | 434 |                  if(!is_file($path)) {$this->condition[]='0';break;} | 
| 381 | 435 | $_ = getimagesize($path); | 
| 382 | 436 | $this->condition[] = (int)($_[0]);break; | 
| @@ -399,17 +453,23 @@ discard block | ||
| 399 | 453 | case 'this': | 
| 400 | 454 |                  $conditional = implode(' ',$this->condition); | 
| 401 | 455 |                  $isvalid = (int)(eval("return ({$conditional});")); | 
| 402 | - if ($isvalid) return $this->srcValue; | |
| 456 | +                if ($isvalid) { | |
| 457 | + return $this->srcValue; | |
| 458 | + } | |
| 403 | 459 | return NULL; | 
| 404 | 460 | case 'then': | 
| 405 | 461 |                  $conditional = implode(' ',$this->condition); | 
| 406 | 462 |                  $isvalid = (int)eval("return ({$conditional});"); | 
| 407 | - if ($isvalid) return $opt; | |
| 463 | +                if ($isvalid) { | |
| 464 | + return $opt; | |
| 465 | + } | |
| 408 | 466 | return null; | 
| 409 | 467 | case 'else': | 
| 410 | 468 |                  $conditional = implode(' ',$this->condition); | 
| 411 | 469 |                  $isvalid = (int)eval("return ({$conditional});"); | 
| 412 | - if (!$isvalid) return $opt; | |
| 470 | +                if (!$isvalid) { | |
| 471 | + return $opt; | |
| 472 | + } | |
| 413 | 473 | break; | 
| 414 | 474 | case 'select': | 
| 415 | 475 | case 'switch': | 
| @@ -420,8 +480,11 @@ discard block | ||
| 420 | 480 |                      $mi = explode('=',$raw[$m],2); | 
| 421 | 481 | $map[$mi[0]] = $mi[1]; | 
| 422 | 482 | } | 
| 423 | - if(isset($map[$value])) return $map[$value]; | |
| 424 | - else return ''; | |
| 483 | +                if(isset($map[$value])) { | |
| 484 | + return $map[$value]; | |
| 485 | +                } else { | |
| 486 | + return ''; | |
| 487 | + } | |
| 425 | 488 | ##### End of Conditional Modifiers | 
| 426 | 489 | |
| 427 | 490 | ##### Encode / Decode / Hash / Escape | 
| @@ -447,24 +510,25 @@ discard block | ||
| 447 | 510 | case 'spam_protect': | 
| 448 | 511 |                  return str_replace(array('@','.'),array('@','.'),$value); | 
| 449 | 512 | case 'strip': | 
| 450 | - if($opt==='') $opt = ' '; | |
| 513 | +                if($opt==='') { | |
| 514 | + $opt = ' '; | |
| 515 | + } | |
| 451 | 516 |                  return preg_replace('/[\n\r\t\s]+/', $opt, $value); | 
| 452 | 517 | case 'strip_linefeeds': | 
| 453 | 518 |                  return str_replace(array("\n","\r"), '', $value); | 
| 454 | 519 | case 'notags': | 
| 455 | 520 | case 'strip_tags': | 
| 456 | 521 | case 'remove_html': | 
| 457 | - if($opt!=='') | |
| 458 | -                { | |
| 522 | +                if($opt!=='') { | |
| 459 | 523 | $param = array(); | 
| 460 | -                    foreach(explode(',',$opt) as $v) | |
| 461 | -                    { | |
| 524 | +                    foreach(explode(',',$opt) as $v) { | |
| 462 | 525 | $v = trim($v,'</> '); | 
| 463 | 526 |                          $param[] = "<{$v}>"; | 
| 464 | 527 | } | 
| 465 | 528 |                      $params = implode(',',$param); | 
| 529 | +                } else { | |
| 530 | + $params = ''; | |
| 466 | 531 | } | 
| 467 | - else $params = ''; | |
| 468 | 532 |                  if(!strpos($params,'<br>')===false) { | 
| 469 | 533 |                      $value = preg_replace('@(<br[ /]*>)\n@','$1',$value); | 
| 470 | 534 |                      $value = preg_replace('@<br[ /]*>@',"\n",$value); | 
| @@ -475,8 +539,11 @@ discard block | ||
| 475 | 539 | case 'encode_url': | 
| 476 | 540 | return urlencode($value); | 
| 477 | 541 | case 'base64_decode': | 
| 478 | - if($opt!=='false') $opt = true; | |
| 479 | - else $opt = false; | |
| 542 | +                if($opt!=='false') { | |
| 543 | + $opt = true; | |
| 544 | +                } else { | |
| 545 | + $opt = false; | |
| 546 | + } | |
| 480 | 547 | return base64_decode($value,$opt); | 
| 481 | 548 | case 'encode_sha1': $cmd = 'sha1'; | 
| 482 | 549 | case 'addslashes': | 
| @@ -502,16 +569,19 @@ discard block | ||
| 502 | 569 | return $this->strtoupper($value); | 
| 503 | 570 | case 'capitalize': | 
| 504 | 571 |                  $_ = explode(' ',$value); | 
| 505 | - foreach($_ as $i=>$v) | |
| 506 | -                { | |
| 572 | +                foreach($_ as $i=>$v) { | |
| 507 | 573 | $_[$i] = ucfirst($v); | 
| 508 | 574 | } | 
| 509 | 575 |                  return implode(' ',$_); | 
| 510 | 576 | case 'zenhan': | 
| 511 | - if(empty($opt)) $opt='VKas'; | |
| 577 | +                if(empty($opt)) { | |
| 578 | + $opt='VKas'; | |
| 579 | + } | |
| 512 | 580 | return mb_convert_kana($value,$opt,$modx->config['modx_charset']); | 
| 513 | 581 | case 'hanzen': | 
| 514 | - if(empty($opt)) $opt='VKAS'; | |
| 582 | +                if(empty($opt)) { | |
| 583 | + $opt='VKAS'; | |
| 584 | + } | |
| 515 | 585 | return mb_convert_kana($value,$opt,$modx->config['modx_charset']); | 
| 516 | 586 | case 'str_shuffle': | 
| 517 | 587 | case 'shuffle': | 
| @@ -536,13 +606,18 @@ discard block | ||
| 536 | 606 |                  $value = preg_replace('/\r/', '', $value); | 
| 537 | 607 |                  return count(preg_split('/\n+/',$value)); | 
| 538 | 608 | case 'strpos': | 
| 539 | - if($opt!=0&&empty($opt)) return $value; | |
| 609 | +                if($opt!=0&&empty($opt)) { | |
| 610 | + return $value; | |
| 611 | + } | |
| 540 | 612 | return $this->strpos($value,$opt); | 
| 541 | 613 | case 'wordwrap': | 
| 542 | 614 | // default: 70 | 
| 543 | 615 | $wrapat = (int)$opt > 0 ? (int)$opt : 70; | 
| 544 | -                if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap'); | |
| 545 | -                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); | |
| 616 | +                if (version_compare(PHP_VERSION, '5.3.0') >= 0) { | |
| 617 | +                    return $this->includeMdfFile('wordwrap'); | |
| 618 | +                } else { | |
| 619 | +                    return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); | |
| 620 | + } | |
| 546 | 621 | case 'wrap_text': | 
| 547 | 622 |                  $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70; | 
| 548 | 623 |                  if($modx->config['manager_language']==='japanese-utf8') { | 
| @@ -558,30 +633,36 @@ discard block | ||
| 558 | 633 | $value = $this->substr($value,$width); | 
| 559 | 634 | } | 
| 560 | 635 |                      return implode("\n",$chunk); | 
| 636 | +                } else { | |
| 637 | + return wordwrap($value,$width,"\n",true); | |
| 561 | 638 | } | 
| 562 | - else | |
| 563 | - return wordwrap($value,$width,"\n",true); | |
| 564 | 639 | case 'substr': | 
| 565 | - if(empty($opt)) break; | |
| 640 | +                if(empty($opt)) { | |
| 641 | + break; | |
| 642 | + } | |
| 566 | 643 |                  if(strpos($opt,',')!==false) { | 
| 567 | 644 |                      list($b,$e) = explode(',',$opt,2); | 
| 568 | 645 | return $this->substr($value,$b,(int)$e); | 
| 646 | +                } else { | |
| 647 | + return $this->substr($value,$opt); | |
| 569 | 648 | } | 
| 570 | - else return $this->substr($value,$opt); | |
| 571 | 649 | case 'limit': | 
| 572 | 650 | case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html | 
| 573 | - if(strpos($opt,'+')!==false) | |
| 574 | -                    list($len,$str) = explode('+',$opt,2); | |
| 575 | -                else { | |
| 651 | +                if(strpos($opt,'+')!==false) { | |
| 652 | +                                    list($len,$str) = explode('+',$opt,2); | |
| 653 | +                } else { | |
| 576 | 654 | $len = $opt; | 
| 577 | 655 | $str = ''; | 
| 578 | 656 | } | 
| 579 | - if($len==='') $len = 100; | |
| 580 | - if(abs($len) > $this->strlen($value)) $str =''; | |
| 657 | +                if($len==='') { | |
| 658 | + $len = 100; | |
| 659 | + } | |
| 660 | +                if(abs($len) > $this->strlen($value)) { | |
| 661 | + $str =''; | |
| 662 | + } | |
| 581 | 663 |                  if(preg_match('/^[1-9][0-9]*$/',$len)) { | 
| 582 | 664 | return $this->substr($value,0,$len) . $str; | 
| 583 | - } | |
| 584 | -                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { | |
| 665 | +                } elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { | |
| 585 | 666 | return $str . $this->substr($value,$len); | 
| 586 | 667 | } | 
| 587 | 668 | break; | 
| @@ -591,18 +672,30 @@ discard block | ||
| 591 | 672 |                  return $this->includeMdfFile('summary'); | 
| 592 | 673 | case 'replace': | 
| 593 | 674 | case 'str_replace': | 
| 594 | - if(empty($opt) || strpos($opt,',')===false) break; | |
| 595 | - if (substr_count($opt, ',') ==1) $delim = ','; | |
| 596 | - elseif(substr_count($opt, '|') ==1) $delim = '|'; | |
| 597 | - elseif(substr_count($opt, '=>')==1) $delim = '=>'; | |
| 598 | - elseif(substr_count($opt, '/') ==1) $delim = '/'; | |
| 599 | - else break; | |
| 675 | +                if(empty($opt) || strpos($opt,',')===false) { | |
| 676 | + break; | |
| 677 | + } | |
| 678 | +                if    (substr_count($opt, ',') ==1) { | |
| 679 | + $delim = ','; | |
| 680 | +                } elseif(substr_count($opt, '|') ==1) { | |
| 681 | + $delim = '|'; | |
| 682 | +                } elseif(substr_count($opt, '=>')==1) { | |
| 683 | + $delim = '=>'; | |
| 684 | +                } elseif(substr_count($opt, '/') ==1) { | |
| 685 | + $delim = '/'; | |
| 686 | +                } else { | |
| 687 | + break; | |
| 688 | + } | |
| 600 | 689 | list($s,$r) = explode($delim,$opt); | 
| 601 | - if($value!=='') return str_replace($s,$r,$value); | |
| 690 | +                if($value!=='') { | |
| 691 | + return str_replace($s,$r,$value); | |
| 692 | + } | |
| 602 | 693 | break; | 
| 603 | 694 | case 'replace_to': | 
| 604 | 695 | case 'tpl': | 
| 605 | -                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); | |
| 696 | +                if($value!=='') { | |
| 697 | +                    return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); | |
| 698 | + } | |
| 606 | 699 | break; | 
| 607 | 700 | case 'eachtpl': | 
| 608 | 701 |                  $value = explode('||',$value); | 
| @@ -613,59 +706,83 @@ discard block | ||
| 613 | 706 |                  return implode("\n", $_); | 
| 614 | 707 | case 'array_pop': | 
| 615 | 708 | case 'array_shift': | 
| 616 | - if(strpos($value,'||')!==false) $delim = '||'; | |
| 617 | - else $delim = ','; | |
| 709 | +                if(strpos($value,'||')!==false) { | |
| 710 | + $delim = '||'; | |
| 711 | +                } else { | |
| 712 | + $delim = ','; | |
| 713 | + } | |
| 618 | 714 | return $cmd(explode($delim,$value)); | 
| 619 | 715 | case 'preg_replace': | 
| 620 | 716 | case 'regex_replace': | 
| 621 | - if(empty($opt) || strpos($opt,',')===false) break; | |
| 717 | +                if(empty($opt) || strpos($opt,',')===false) { | |
| 718 | + break; | |
| 719 | + } | |
| 622 | 720 |                  list($s,$r) = explode(',',$opt,2); | 
| 623 | - if($value!=='') return preg_replace($s,$r,$value); | |
| 721 | +                if($value!=='') { | |
| 722 | + return preg_replace($s,$r,$value); | |
| 723 | + } | |
| 624 | 724 | break; | 
| 625 | 725 | case 'cat': | 
| 626 | 726 | case 'concatenate': | 
| 627 | 727 | case '.': | 
| 628 | - if($value!=='') return $value . $opt; | |
| 728 | +                if($value!=='') { | |
| 729 | + return $value . $opt; | |
| 730 | + } | |
| 629 | 731 | break; | 
| 630 | 732 | case 'sprintf': | 
| 631 | 733 | case 'string_format': | 
| 632 | - if($value!=='') return sprintf($opt,$value); | |
| 734 | +                if($value!=='') { | |
| 735 | + return sprintf($opt,$value); | |
| 736 | + } | |
| 633 | 737 | break; | 
| 634 | 738 | case 'number_format': | 
| 635 | - if($opt=='') $opt = 0; | |
| 739 | +                    if($opt=='') { | |
| 740 | + $opt = 0; | |
| 741 | + } | |
| 636 | 742 | return number_format($value,$opt); | 
| 637 | 743 | case 'money_format': | 
| 638 | 744 | setlocale(LC_MONETARY,setlocale(LC_TIME,0)); | 
| 639 | - if($value!=='') return money_format($opt,(double)$value); | |
| 745 | +                    if($value!=='') { | |
| 746 | + return money_format($opt,(double)$value); | |
| 747 | + } | |
| 640 | 748 | break; | 
| 641 | 749 | case 'tobool': | 
| 642 | 750 | return boolval($value); | 
| 643 | 751 | case 'nl2lf': | 
| 644 | -                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value); | |
| 752 | +                if($value!=='') { | |
| 753 | +                    return str_replace(array("\r\n","\n", "\r"), '\n', $value); | |
| 754 | + } | |
| 645 | 755 | break; | 
| 646 | 756 | case 'br2nl': | 
| 647 | 757 |                  return preg_replace('@<br[\s/]*>@i', "\n", $value); | 
| 648 | 758 | case 'nl2br': | 
| 649 | - if (version_compare(PHP_VERSION, '5.3.0', '<')) | |
| 650 | - return nl2br($value); | |
| 651 | - if($opt!=='') | |
| 652 | -                { | |
| 759 | +                if (version_compare(PHP_VERSION, '5.3.0', '<')) { | |
| 760 | + return nl2br($value); | |
| 761 | + } | |
| 762 | +                if($opt!=='') { | |
| 653 | 763 | $opt = trim($opt); | 
| 654 | 764 | $opt = strtolower($opt); | 
| 655 | - if($opt==='false') $opt = false; | |
| 656 | - elseif($opt==='0') $opt = false; | |
| 657 | - else $opt = true; | |
| 765 | +                    if($opt==='false') { | |
| 766 | + $opt = false; | |
| 767 | +                    } elseif($opt==='0') { | |
| 768 | + $opt = false; | |
| 769 | +                    } else { | |
| 770 | + $opt = true; | |
| 771 | + } | |
| 772 | +                } elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') { | |
| 773 | + $opt = false; | |
| 774 | +                } else { | |
| 775 | + $opt = true; | |
| 658 | 776 | } | 
| 659 | - elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') | |
| 660 | - $opt = false; | |
| 661 | - else $opt = true; | |
| 662 | 777 | return nl2br($value,$opt); | 
| 663 | 778 | case 'ltrim': | 
| 664 | 779 | case 'rtrim': | 
| 665 | 780 | case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html | 
| 666 | - if($opt==='') | |
| 667 | - return $cmd($value); | |
| 668 | - else return $cmd($value,$opt); | |
| 781 | +                if($opt==='') { | |
| 782 | + return $cmd($value); | |
| 783 | +                } else { | |
| 784 | + return $cmd($value,$opt); | |
| 785 | + } | |
| 669 | 786 | // These are all straight wrappers for PHP functions | 
| 670 | 787 | case 'ucfirst': | 
| 671 | 788 | case 'lcfirst': | 
| @@ -676,15 +793,24 @@ discard block | ||
| 676 | 793 | case 'strftime': | 
| 677 | 794 | case 'date': | 
| 678 | 795 | case 'dateformat': | 
| 679 | - if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); | |
| 680 | -                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); | |
| 681 | - if(strpos($opt,'%')!==false) | |
| 682 | - return strftime($opt,0+$value); | |
| 683 | - else | |
| 684 | - return date($opt,0+$value); | |
| 796 | +                if(empty($opt)) { | |
| 797 | + $opt = $modx->toDateFormat(null, 'formatOnly'); | |
| 798 | + } | |
| 799 | +                if(!preg_match('@^[0-9]+$@',$value)) { | |
| 800 | + $value = strtotime($value); | |
| 801 | + } | |
| 802 | +                if(strpos($opt,'%')!==false) { | |
| 803 | + return strftime($opt,0+$value); | |
| 804 | +                } else { | |
| 805 | + return date($opt,0+$value); | |
| 806 | + } | |
| 685 | 807 | case 'time': | 
| 686 | - if(empty($opt)) $opt = '%H:%M'; | |
| 687 | -                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); | |
| 808 | +                if(empty($opt)) { | |
| 809 | + $opt = '%H:%M'; | |
| 810 | + } | |
| 811 | +                if(!preg_match('@^[0-9]+$@',$value)) { | |
| 812 | + $value = strtotime($value); | |
| 813 | + } | |
| 688 | 814 | return strftime($opt,0+$value); | 
| 689 | 815 | case 'strtotime': | 
| 690 | 816 | return strtotime($value); | 
| @@ -694,7 +820,9 @@ discard block | ||
| 694 | 820 | case 'tofloat': | 
| 695 | 821 | return floatval($value); | 
| 696 | 822 | case 'round': | 
| 697 | - if(!$opt) $opt = 0; | |
| 823 | +                if(!$opt) { | |
| 824 | + $opt = 0; | |
| 825 | + } | |
| 698 | 826 | return $cmd($value,$opt); | 
| 699 | 827 | case 'max': | 
| 700 | 828 | case 'min': | 
| @@ -706,28 +834,42 @@ discard block | ||
| 706 | 834 | case 'math': | 
| 707 | 835 | case 'calc': | 
| 708 | 836 | $value = (int)$value; | 
| 709 | - if(empty($value)) $value = '0'; | |
| 837 | +                if(empty($value)) { | |
| 838 | + $value = '0'; | |
| 839 | + } | |
| 710 | 840 |                  $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt); | 
| 711 | 841 |                  $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter); | 
| 712 | -                if(strpos($filter,'?')===false) $filter = "?{$filter}"; | |
| 842 | +                if(strpos($filter,'?')===false) { | |
| 843 | +                    $filter = "?{$filter}"; | |
| 844 | + } | |
| 713 | 845 |                  $filter = str_replace('?',$value,$filter); | 
| 714 | 846 |                  return eval("return {$filter};"); | 
| 715 | 847 | case 'count': | 
| 716 | - if($value=='') return 0; | |
| 848 | +                if($value=='') { | |
| 849 | + return 0; | |
| 850 | + } | |
| 717 | 851 |                  $value = explode(',',$value); | 
| 718 | 852 | return count($value); | 
| 719 | 853 | case 'sort': | 
| 720 | 854 | case 'rsort': | 
| 721 | - if(strpos($value,"\n")!==false) $delim="\n"; | |
| 722 | - else $delim = ','; | |
| 855 | +                if(strpos($value,"\n")!==false) { | |
| 856 | + $delim="\n"; | |
| 857 | +                } else { | |
| 858 | + $delim = ','; | |
| 859 | + } | |
| 723 | 860 | $swap = explode($delim,$value); | 
| 724 | - if(!$opt) $opt = SORT_REGULAR; | |
| 725 | - else $opt = constant($opt); | |
| 861 | +                if(!$opt) { | |
| 862 | + $opt = SORT_REGULAR; | |
| 863 | +                } else { | |
| 864 | + $opt = constant($opt); | |
| 865 | + } | |
| 726 | 866 | $cmd($swap,$opt); | 
| 727 | 867 | return implode($delim,$swap); | 
| 728 | 868 | ##### Resource fields | 
| 729 | 869 | case 'id': | 
| 730 | - if($opt) return $this->getDocumentObject($opt,$key); | |
| 870 | +                if($opt) { | |
| 871 | + return $this->getDocumentObject($opt,$key); | |
| 872 | + } | |
| 731 | 873 | break; | 
| 732 | 874 | case 'type': | 
| 733 | 875 | case 'contenttype': | 
| @@ -764,7 +906,9 @@ discard block | ||
| 764 | 906 | case 'privatemgr': | 
| 765 | 907 | case 'content_dispo': | 
| 766 | 908 | case 'hidemenu': | 
| 767 | - if($cmd==='contenttype') $cmd = 'contentType'; | |
| 909 | +                if($cmd==='contenttype') { | |
| 910 | + $cmd = 'contentType'; | |
| 911 | + } | |
| 768 | 912 | return $this->getDocumentObject($value,$cmd); | 
| 769 | 913 | case 'title': | 
| 770 | 914 | $pagetitle = $this->getDocumentObject($value,'pagetitle'); | 
| @@ -779,13 +923,20 @@ discard block | ||
| 779 | 923 | $templateName = $modx->db->getValue($rs); | 
| 780 | 924 | return !$templateName ? '(blank)' : $templateName; | 
| 781 | 925 | case 'getfield': | 
| 782 | - if(!$opt) $opt = 'content'; | |
| 926 | +                if(!$opt) { | |
| 927 | + $opt = 'content'; | |
| 928 | + } | |
| 783 | 929 | return $modx->getField($opt,$value); | 
| 784 | 930 | case 'children': | 
| 785 | 931 | case 'childids': | 
| 786 | - if($value=='') $value = 0; // 値がない場合はルートと見なす | |
| 932 | +                if($value=='') { | |
| 933 | + $value = 0; | |
| 934 | + } | |
| 935 | + // 値がない場合はルートと見なす | |
| 787 | 936 | $published = 1; | 
| 788 | - if($opt=='') $opt = 'page'; | |
| 937 | +                if($opt=='') { | |
| 938 | + $opt = 'page'; | |
| 939 | + } | |
| 789 | 940 |                  $_ = explode(',',$opt); | 
| 790 | 941 | $where = array(); | 
| 791 | 942 |                  foreach($_ as $opt) { | 
| @@ -801,29 +952,43 @@ discard block | ||
| 801 | 952 |                  $where = implode(' AND ', $where); | 
| 802 | 953 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); | 
| 803 | 954 | $result = array(); | 
| 804 | -                foreach((array)$children as $child){ | |
| 955 | +                foreach((array)$children as $child) { | |
| 805 | 956 | $result[] = $child['id']; | 
| 806 | 957 | } | 
| 807 | 958 |                  return implode(',', $result); | 
| 808 | 959 | case 'fullurl': | 
| 809 | - if(!is_numeric($value)) return $value; | |
| 960 | +                if(!is_numeric($value)) { | |
| 961 | + return $value; | |
| 962 | + } | |
| 810 | 963 | return $modx->makeUrl($value); | 
| 811 | 964 | case 'makeurl': | 
| 812 | - if(!is_numeric($value)) return $value; | |
| 813 | - if(!$opt) $opt = 'full'; | |
| 965 | +                if(!is_numeric($value)) { | |
| 966 | + return $value; | |
| 967 | + } | |
| 968 | +                if(!$opt) { | |
| 969 | + $opt = 'full'; | |
| 970 | + } | |
| 814 | 971 | return $modx->makeUrl($value,'','',$opt); | 
| 815 | 972 | |
| 816 | 973 | ##### File system | 
| 817 | 974 | case 'getimageinfo': | 
| 818 | 975 | case 'imageinfo': | 
| 819 | - if(!is_file($value)) return ''; | |
| 976 | +                if(!is_file($value)) { | |
| 977 | + return ''; | |
| 978 | + } | |
| 820 | 979 | $_ = getimagesize($value); | 
| 821 | - if(!$_[0]) return ''; | |
| 980 | +                if(!$_[0]) { | |
| 981 | + return ''; | |
| 982 | + } | |
| 822 | 983 | $info['width'] = $_[0]; | 
| 823 | 984 | $info['height'] = $_[1]; | 
| 824 | - if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; | |
| 825 | - elseif($_[0] < $_[1]) $info['aspect'] = 'portrait'; | |
| 826 | - else $info['aspect'] = 'square'; | |
| 985 | +                if    ($_[0] > $_[1]) { | |
| 986 | + $info['aspect'] = 'landscape'; | |
| 987 | +                } elseif($_[0] < $_[1]) { | |
| 988 | + $info['aspect'] = 'portrait'; | |
| 989 | +                } else { | |
| 990 | + $info['aspect'] = 'square'; | |
| 991 | + } | |
| 827 | 992 |                  switch($_[2]) { | 
| 828 | 993 | case IMAGETYPE_GIF : $info['type'] = 'gif'; break; | 
| 829 | 994 | case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break; | 
| @@ -842,33 +1007,47 @@ discard block | ||
| 842 | 1007 | |
| 843 | 1008 | case 'file_get_contents': | 
| 844 | 1009 | case 'readfile': | 
| 845 | - if(!is_file($value)) return $value; | |
| 1010 | +                if(!is_file($value)) { | |
| 1011 | + return $value; | |
| 1012 | + } | |
| 846 | 1013 | $value = realpath($value); | 
| 847 | -                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file'); | |
| 1014 | +                if(strpos($value,MODX_MANAGER_PATH)!==false) { | |
| 1015 | +                    exit('Can not read core file'); | |
| 1016 | + } | |
| 848 | 1017 | $ext = strtolower(substr($value,-4)); | 
| 849 | -                if($ext==='.php') exit('Can not read php file'); | |
| 850 | -                if($ext==='.cgi') exit('Can not read cgi file'); | |
| 1018 | +                if($ext==='.php') { | |
| 1019 | +                    exit('Can not read php file'); | |
| 1020 | + } | |
| 1021 | +                if($ext==='.cgi') { | |
| 1022 | +                    exit('Can not read cgi file'); | |
| 1023 | + } | |
| 851 | 1024 | return file_get_contents($value); | 
| 852 | 1025 | case 'filesize': | 
| 853 | - if($value == '') return ''; | |
| 1026 | +                if($value == '') { | |
| 1027 | + return ''; | |
| 1028 | + } | |
| 854 | 1029 | $filename = $value; | 
| 855 | 1030 | |
| 856 | 1031 | $site_url = $modx->config['site_url']; | 
| 857 | - if(strpos($filename,$site_url) === 0) | |
| 858 | - $filename = substr($filename,0,strlen($site_url)); | |
| 1032 | +                if(strpos($filename,$site_url) === 0) { | |
| 1033 | + $filename = substr($filename,0,strlen($site_url)); | |
| 1034 | + } | |
| 859 | 1035 | $filename = trim($filename,'/'); | 
| 860 | 1036 | |
| 861 | 1037 | $opt = trim($opt,'/'); | 
| 862 | - if($opt!=='') $opt .= '/'; | |
| 1038 | +                if($opt!=='') { | |
| 1039 | + $opt .= '/'; | |
| 1040 | + } | |
| 863 | 1041 | |
| 864 | 1042 | $filename = MODX_BASE_PATH.$opt.$filename; | 
| 865 | 1043 | |
| 866 | -                if(is_file($filename)){ | |
| 1044 | +                if(is_file($filename)) { | |
| 867 | 1045 | clearstatcache(); | 
| 868 | 1046 | $size = filesize($filename); | 
| 869 | 1047 | return $size; | 
| 1048 | +                } else { | |
| 1049 | + return ''; | |
| 870 | 1050 | } | 
| 871 | - else return ''; | |
| 872 | 1051 | ##### User info | 
| 873 | 1052 | case 'username': | 
| 874 | 1053 | case 'fullname': | 
| @@ -896,32 +1075,47 @@ discard block | ||
| 896 | 1075 | $this->opt = $cmd; | 
| 897 | 1076 |                  return $this->includeMdfFile('moduser'); | 
| 898 | 1077 | case 'userinfo': | 
| 899 | - if(empty($opt)) $this->opt = 'username'; | |
| 1078 | +                if(empty($opt)) { | |
| 1079 | + $this->opt = 'username'; | |
| 1080 | + } | |
| 900 | 1081 |                  return $this->includeMdfFile('moduser'); | 
| 901 | 1082 | case 'webuserinfo': | 
| 902 | - if(empty($opt)) $this->opt = 'username'; | |
| 1083 | +                if(empty($opt)) { | |
| 1084 | + $this->opt = 'username'; | |
| 1085 | + } | |
| 903 | 1086 | $this->value = -$value; | 
| 904 | 1087 |                  return $this->includeMdfFile('moduser'); | 
| 905 | 1088 | ##### Special functions | 
| 906 | 1089 | case 'ifempty': | 
| 907 | 1090 | case '_default': | 
| 908 | 1091 | case 'default': | 
| 909 | - if (empty($value)) return $opt; break; | |
| 1092 | +                if (empty($value)) { | |
| 1093 | + return $opt; | |
| 1094 | + } | |
| 1095 | + break; | |
| 910 | 1096 | case 'ifnotempty': | 
| 911 | - if (!empty($value)) return $opt; break; | |
| 1097 | +                if (!empty($value)) { | |
| 1098 | + return $opt; | |
| 1099 | + } | |
| 1100 | + break; | |
| 912 | 1101 | case 'datagrid': | 
| 913 | 1102 | include_once(MODX_CORE_PATH . 'controls/datagrid.class.php'); | 
| 914 | 1103 | $grd = new DataGrid(null, trim($value)); | 
| 915 | 1104 | $grd->itemStyle = ''; | 
| 916 | 1105 | $grd->altItemStyle = ''; | 
| 917 | 1106 | $pos = strpos($value,"\n"); | 
| 918 | - if($pos) $_ = substr($value,0,$pos); | |
| 919 | - else $_ = $pos; | |
| 1107 | +                if($pos) { | |
| 1108 | + $_ = substr($value,0,$pos); | |
| 1109 | +                } else { | |
| 1110 | + $_ = $pos; | |
| 1111 | + } | |
| 920 | 1112 | $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ','; | 
| 921 | 1113 | return $grd->render(); | 
| 922 | 1114 | case 'rotate': | 
| 923 | 1115 | case 'evenodd': | 
| 924 | - if(strpos($opt,',')===false) $opt = 'odd,even'; | |
| 1116 | +                if(strpos($opt,',')===false) { | |
| 1117 | + $opt = 'odd,even'; | |
| 1118 | + } | |
| 925 | 1119 |                  $_ = explode(',', $opt); | 
| 926 | 1120 | $c = count($_); | 
| 927 | 1121 | $i = $value + $c; | 
| @@ -930,7 +1124,9 @@ discard block | ||
| 930 | 1124 | case 'takeval': | 
| 931 | 1125 |                  $arr = explode(",",$opt); | 
| 932 | 1126 | $idx = $value; | 
| 933 | - if(!is_numeric($idx)) return $value; | |
| 1127 | +                if(!is_numeric($idx)) { | |
| 1128 | + return $value; | |
| 1129 | + } | |
| 934 | 1130 | return $arr[$idx]; | 
| 935 | 1131 | case 'getimage': | 
| 936 | 1132 |                  return $this->includeMdfFile('getimage'); | 
| @@ -938,14 +1134,18 @@ discard block | ||
| 938 | 1134 | return $modx->nicesize($value); | 
| 939 | 1135 | case 'googlemap': | 
| 940 | 1136 | case 'googlemaps': | 
| 941 | - if(empty($opt)) $opt = 'border:none;width:500px;height:350px;'; | |
| 1137 | +                if(empty($opt)) { | |
| 1138 | + $opt = 'border:none;width:500px;height:350px;'; | |
| 1139 | + } | |
| 942 | 1140 | $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>'; | 
| 943 | 1141 | $ph['style'] = $opt; | 
| 944 | 1142 | $ph['value'] = $value; | 
| 945 | 1143 | return $modx->parseText($tpl,$ph); | 
| 946 | 1144 | case 'youtube': | 
| 947 | 1145 | case 'youtube16x9': | 
| 948 | - if(empty($opt)) $opt = 560; | |
| 1146 | +                if(empty($opt)) { | |
| 1147 | + $opt = 560; | |
| 1148 | + } | |
| 949 | 1149 | $h = round($opt*0.5625); | 
| 950 | 1150 | $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>'; | 
| 951 | 1151 | return sprintf($tpl,$opt,$h,$value); | 
| @@ -978,7 +1178,8 @@ discard block | ||
| 978 | 1178 | return $value; | 
| 979 | 1179 | } | 
| 980 | 1180 | |
| 981 | -    public function includeMdfFile($cmd) { | |
| 1181 | + public function includeMdfFile($cmd) | |
| 1182 | +    { | |
| 982 | 1183 | $modx = evolutionCMS(); | 
| 983 | 1184 | $key = $this->key; | 
| 984 | 1185 | $value = $this->value; | 
| @@ -989,55 +1190,65 @@ discard block | ||
| 989 | 1190 | public function getValueFromElement($key, $value, $cmd, $opt) | 
| 990 | 1191 |      { | 
| 991 | 1192 | $modx = evolutionCMS(); | 
| 992 | - if( isset($modx->snippetCache[$this->elmName]) ) | |
| 993 | -        { | |
| 1193 | +        if( isset($modx->snippetCache[$this->elmName]) ) { | |
| 994 | 1194 | $php = $modx->snippetCache[$this->elmName]; | 
| 995 | - } | |
| 996 | - else | |
| 997 | -        { | |
| 1195 | +        } else { | |
| 998 | 1196 | $esc_elmName = $modx->db->escape($this->elmName); | 
| 999 | 1197 |              $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'"); | 
| 1000 | 1198 | $total = $modx->db->getRecordCount($result); | 
| 1001 | - if($total == 1) | |
| 1002 | -            { | |
| 1199 | +            if($total == 1) { | |
| 1003 | 1200 | $row = $modx->db->getRow($result); | 
| 1004 | 1201 | $php = $row['snippet']; | 
| 1005 | - } | |
| 1006 | - elseif($total == 0) | |
| 1007 | -            { | |
| 1202 | +            } elseif($total == 0) { | |
| 1008 | 1203 | $assets_path = MODX_BASE_PATH.'assets/'; | 
| 1009 | -                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) | |
| 1010 | -                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; | |
| 1011 | -                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) | |
| 1012 | -                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; | |
| 1013 | -                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) | |
| 1014 | -                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; | |
| 1015 | - else $modifiers_path = false; | |
| 1204 | +                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) { | |
| 1205 | +                                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; | |
| 1206 | +                } elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) { | |
| 1207 | +                                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; | |
| 1208 | +                } elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) { | |
| 1209 | +                                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; | |
| 1210 | +                } else { | |
| 1211 | + $modifiers_path = false; | |
| 1212 | + } | |
| 1016 | 1213 | |
| 1017 | 1214 |                  if($modifiers_path !== false) { | 
| 1018 | 1215 | $php = @file_get_contents($modifiers_path); | 
| 1019 | 1216 | $php = trim($php); | 
| 1020 | - if(substr($php,0,5)==='<?php') $php = substr($php,6); | |
| 1021 | - if(substr($php,0,2)==='<?') $php = substr($php,3); | |
| 1022 | - if(substr($php,-2)==='?>') $php = substr($php,0,-2); | |
| 1023 | - if($this->elmName!=='') | |
| 1024 | - $modx->snippetCache[$this->elmName.'Props'] = ''; | |
| 1025 | - } | |
| 1026 | - else | |
| 1027 | - $php = false; | |
| 1217 | +                    if(substr($php,0,5)==='<?php') { | |
| 1218 | + $php = substr($php,6); | |
| 1219 | + } | |
| 1220 | +                    if(substr($php,0,2)==='<?') { | |
| 1221 | + $php = substr($php,3); | |
| 1222 | + } | |
| 1223 | +                    if(substr($php,-2)==='?>') { | |
| 1224 | + $php = substr($php,0,-2); | |
| 1225 | + } | |
| 1226 | +                    if($this->elmName!=='') { | |
| 1227 | + $modx->snippetCache[$this->elmName.'Props'] = ''; | |
| 1228 | + } | |
| 1229 | +                } else { | |
| 1230 | + $php = false; | |
| 1231 | + } | |
| 1232 | +            } else { | |
| 1233 | + $php = false; | |
| 1234 | + } | |
| 1235 | +            if($this->elmName!=='') { | |
| 1236 | + $modx->snippetCache[$this->elmName]= $php; | |
| 1028 | 1237 | } | 
| 1029 | - else $php = false; | |
| 1030 | - if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php; | |
| 1031 | 1238 | } | 
| 1032 | - if($php==='') $php=false; | |
| 1239 | +        if($php==='') { | |
| 1240 | + $php=false; | |
| 1241 | + } | |
| 1033 | 1242 | |
| 1034 | - if($php===false) $html = $modx->getChunk($this->elmName); | |
| 1035 | - else $html = false; | |
| 1243 | +        if($php===false) { | |
| 1244 | + $html = $modx->getChunk($this->elmName); | |
| 1245 | +        } else { | |
| 1246 | + $html = false; | |
| 1247 | + } | |
| 1036 | 1248 | |
| 1037 | 1249 | $self = '[+output+]'; | 
| 1038 | 1250 | |
| 1039 | - if($php !== false) | |
| 1040 | -        { | |
| 1251 | +        if($php !== false) { | |
| 1041 | 1252 | ob_start(); | 
| 1042 | 1253 | $options = $opt; | 
| 1043 | 1254 | $output = $value; | 
| @@ -1049,19 +1260,19 @@ discard block | ||
| 1049 | 1260 | $this->vars['options'] = & $opt; | 
| 1050 | 1261 | $custom = eval($php); | 
| 1051 | 1262 | $msg = ob_get_contents(); | 
| 1052 | - if($value===$this->bt) $value = $msg . $custom; | |
| 1263 | +            if($value===$this->bt) { | |
| 1264 | + $value = $msg . $custom; | |
| 1265 | + } | |
| 1053 | 1266 | ob_end_clean(); | 
| 1054 | - } | |
| 1055 | - elseif($html!==false && isset($value) && $value!=='') | |
| 1056 | -        { | |
| 1267 | +        } elseif($html!==false && isset($value) && $value!=='') { | |
| 1057 | 1268 | $html = str_replace(array($self,'[+value+]'), $value, $html); | 
| 1058 | 1269 |              $value = str_replace(array('[+options+]','[+param+]'), $opt, $html); | 
| 1270 | +        } else { | |
| 1271 | + return false; | |
| 1059 | 1272 | } | 
| 1060 | - else return false; | |
| 1061 | 1273 | |
| 1062 | 1274 | if($php===false && $html===false && $value!=='' | 
| 1063 | - && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) | |
| 1064 | -        { | |
| 1275 | +           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) { | |
| 1065 | 1276 |              $value = str_replace(array('[+value+]',$self),$value,$cmd); | 
| 1066 | 1277 | } | 
| 1067 | 1278 | return $value; | 
| @@ -1071,23 +1282,39 @@ discard block | ||
| 1071 | 1282 |      { | 
| 1072 | 1283 | $modx = evolutionCMS(); | 
| 1073 | 1284 | |
| 1074 | -        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content; | |
| 1285 | +        if(strpos($content,'[')===false && strpos($content,'{')===false) { | |
| 1286 | + return $content; | |
| 1287 | + } | |
| 1075 | 1288 | |
| 1076 | - if(!$modx->maxParserPasses) $modx->maxParserPasses = 10; | |
| 1289 | +        if(!$modx->maxParserPasses) { | |
| 1290 | + $modx->maxParserPasses = 10; | |
| 1291 | + } | |
| 1077 | 1292 | $bt=''; | 
| 1078 | 1293 | $i=0; | 
| 1079 | - while($bt!==$content) | |
| 1080 | -        { | |
| 1294 | +        while($bt!==$content) { | |
| 1081 | 1295 | $bt = $content; | 
| 1082 | - if(strpos($content,'[*')!==false && $modx->documentIdentifier) | |
| 1083 | - $content = $modx->mergeDocumentContent($content); | |
| 1084 | -            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content); | |
| 1085 | -            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content); | |
| 1086 | -            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content); | |
| 1087 | - if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content); | |
| 1088 | - | |
| 1089 | - if($content===$bt) break; | |
| 1090 | - if($modx->maxParserPasses < $i) break; | |
| 1296 | +            if(strpos($content,'[*')!==false && $modx->documentIdentifier) { | |
| 1297 | + $content = $modx->mergeDocumentContent($content); | |
| 1298 | + } | |
| 1299 | +            if(strpos($content,'[(')!==false) { | |
| 1300 | + $content = $modx->mergeSettingsContent($content); | |
| 1301 | + } | |
| 1302 | +            if(strpos($content,'{{')!==false) { | |
| 1303 | + $content = $modx->mergeChunkContent($content); | |
| 1304 | + } | |
| 1305 | +            if(strpos($content,'[!')!==false) { | |
| 1306 | +                $content = str_replace(array('[!','!]'),array('[[',']]'),$content); | |
| 1307 | + } | |
| 1308 | +            if(strpos($content,'[[')!==false) { | |
| 1309 | + $content = $modx->evalSnippets($content); | |
| 1310 | + } | |
| 1311 | + | |
| 1312 | +            if($content===$bt) { | |
| 1313 | + break; | |
| 1314 | + } | |
| 1315 | +            if($modx->maxParserPasses < $i) { | |
| 1316 | + break; | |
| 1317 | + } | |
| 1091 | 1318 | $i++; | 
| 1092 | 1319 | } | 
| 1093 | 1320 | return $content; | 
| @@ -1098,103 +1325,138 @@ discard block | ||
| 1098 | 1325 | $modx = evolutionCMS(); | 
| 1099 | 1326 | |
| 1100 | 1327 | $target = trim($target); | 
| 1101 | - if(empty($target)) $target = $modx->config['site_start']; | |
| 1102 | -        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id'; | |
| 1103 | - else $method = 'alias'; | |
| 1328 | +        if(empty($target)) { | |
| 1329 | + $target = $modx->config['site_start']; | |
| 1330 | + } | |
| 1331 | +        if(preg_match('@^[1-9][0-9]*$@',$target)) { | |
| 1332 | + $method='id'; | |
| 1333 | +        } else { | |
| 1334 | + $method = 'alias'; | |
| 1335 | + } | |
| 1104 | 1336 | |
| 1105 | - if(!isset($this->documentObject[$target])) | |
| 1106 | -        { | |
| 1337 | +        if(!isset($this->documentObject[$target])) { | |
| 1107 | 1338 | $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct'); | 
| 1108 | 1339 | } | 
| 1109 | 1340 | |
| 1110 | - if($this->documentObject[$target]['publishedon']==='0') | |
| 1111 | - return ''; | |
| 1112 | - elseif(isset($this->documentObject[$target][$field])) | |
| 1113 | -        { | |
| 1114 | - if(is_array($this->documentObject[$target][$field])) | |
| 1115 | -            { | |
| 1341 | +        if($this->documentObject[$target]['publishedon']==='0') { | |
| 1342 | + return ''; | |
| 1343 | +        } elseif(isset($this->documentObject[$target][$field])) { | |
| 1344 | +            if(is_array($this->documentObject[$target][$field])) { | |
| 1116 | 1345 | $a = $modx->getTemplateVarOutput($field,$target); | 
| 1117 | 1346 | $this->documentObject[$target][$field] = $a[$field]; | 
| 1118 | 1347 | } | 
| 1348 | +        } else { | |
| 1349 | + $this->documentObject[$target][$field] = false; | |
| 1119 | 1350 | } | 
| 1120 | - else $this->documentObject[$target][$field] = false; | |
| 1121 | 1351 | |
| 1122 | 1352 | return $this->documentObject[$target][$field]; | 
| 1123 | 1353 | } | 
| 1124 | 1354 | |
| 1125 | -    public function setPlaceholders($value = '', $key = '', $path = '') { | |
| 1126 | -        if($path!=='') $key = "{$path}.{$key}"; | |
| 1355 | + public function setPlaceholders($value = '', $key = '', $path = '') | |
| 1356 | +    { | |
| 1357 | +        if($path!=='') { | |
| 1358 | +            $key = "{$path}.{$key}"; | |
| 1359 | + } | |
| 1127 | 1360 |          if (is_array($value)) { | 
| 1128 | 1361 |              foreach ($value as $subkey => $subval) { | 
| 1129 | 1362 | $this->setPlaceholders($subval, $subkey, $key); | 
| 1130 | 1363 | } | 
| 1364 | +        } else { | |
| 1365 | + $this->setModifiersVariable($key, $value); | |
| 1131 | 1366 | } | 
| 1132 | - else $this->setModifiersVariable($key, $value); | |
| 1133 | 1367 | } | 
| 1134 | 1368 | |
| 1135 | 1369 | // Sets a placeholder variable which can only be access by Modifiers | 
| 1136 | -    public function setModifiersVariable($key, $value) { | |
| 1137 | - if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; | |
| 1370 | + public function setModifiersVariable($key, $value) | |
| 1371 | +    { | |
| 1372 | +        if ($key != 'phx' && $key != 'dummy') { | |
| 1373 | + $this->placeholders[$key] = $value; | |
| 1374 | + } | |
| 1138 | 1375 | } | 
| 1139 | 1376 | |
| 1140 | 1377 | //mbstring | 
| 1141 | -    public function substr($str, $s, $l = null) { | |
| 1378 | + public function substr($str, $s, $l = null) | |
| 1379 | +    { | |
| 1142 | 1380 | $modx = evolutionCMS(); | 
| 1143 | - if(is_null($l)) $l = $this->strlen($str); | |
| 1144 | -        if (function_exists('mb_substr')) | |
| 1145 | -        { | |
| 1146 | - if(strpos($str,"\r")!==false) | |
| 1147 | -                $str = str_replace(array("\r\n","\r"), "\n", $str); | |
| 1381 | +        if(is_null($l)) { | |
| 1382 | + $l = $this->strlen($str); | |
| 1383 | + } | |
| 1384 | +        if (function_exists('mb_substr')) { | |
| 1385 | +            if(strpos($str,"\r")!==false) { | |
| 1386 | +                            $str = str_replace(array("\r\n","\r"), "\n", $str); | |
| 1387 | + } | |
| 1148 | 1388 | return mb_substr($str, $s, $l, $modx->config['modx_charset']); | 
| 1149 | 1389 | } | 
| 1150 | 1390 | return substr($str, $s, $l); | 
| 1151 | 1391 | } | 
| 1152 | -    public function strpos($haystack,$needle,$offset=0) { | |
| 1392 | + public function strpos($haystack,$needle,$offset=0) | |
| 1393 | +    { | |
| 1153 | 1394 | $modx = evolutionCMS(); | 
| 1154 | -        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); | |
| 1395 | +        if (function_exists('mb_strpos')) { | |
| 1396 | + return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); | |
| 1397 | + } | |
| 1155 | 1398 | return strpos($haystack,$needle,$offset); | 
| 1156 | 1399 | } | 
| 1157 | -    public function strlen($str) { | |
| 1400 | + public function strlen($str) | |
| 1401 | +    { | |
| 1158 | 1402 | $modx = evolutionCMS(); | 
| 1159 | -        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); | |
| 1403 | +        if (function_exists('mb_strlen')) { | |
| 1404 | +            return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); | |
| 1405 | + } | |
| 1160 | 1406 | return strlen($str); | 
| 1161 | 1407 | } | 
| 1162 | -    public function strtolower($str) { | |
| 1163 | -        if (function_exists('mb_strtolower')) return mb_strtolower($str); | |
| 1408 | + public function strtolower($str) | |
| 1409 | +    { | |
| 1410 | +        if (function_exists('mb_strtolower')) { | |
| 1411 | + return mb_strtolower($str); | |
| 1412 | + } | |
| 1164 | 1413 | return strtolower($str); | 
| 1165 | 1414 | } | 
| 1166 | -    public function strtoupper($str) { | |
| 1167 | -        if (function_exists('mb_strtoupper')) return mb_strtoupper($str); | |
| 1415 | + public function strtoupper($str) | |
| 1416 | +    { | |
| 1417 | +        if (function_exists('mb_strtoupper')) { | |
| 1418 | + return mb_strtoupper($str); | |
| 1419 | + } | |
| 1168 | 1420 | return strtoupper($str); | 
| 1169 | 1421 | } | 
| 1170 | -    public function ucfirst($str) { | |
| 1171 | -        if (function_exists('mb_strtoupper')) | |
| 1172 | - return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); | |
| 1422 | + public function ucfirst($str) | |
| 1423 | +    { | |
| 1424 | +        if (function_exists('mb_strtoupper')) { | |
| 1425 | + return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); | |
| 1426 | + } | |
| 1173 | 1427 | return ucfirst($str); | 
| 1174 | 1428 | } | 
| 1175 | -    public function lcfirst($str) { | |
| 1176 | -        if (function_exists('mb_strtolower')) | |
| 1177 | - return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); | |
| 1429 | + public function lcfirst($str) | |
| 1430 | +    { | |
| 1431 | +        if (function_exists('mb_strtolower')) { | |
| 1432 | + return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); | |
| 1433 | + } | |
| 1178 | 1434 | return lcfirst($str); | 
| 1179 | 1435 | } | 
| 1180 | -    public function ucwords($str) { | |
| 1181 | -        if (function_exists('mb_convert_case')) | |
| 1182 | - return mb_convert_case($str, MB_CASE_TITLE); | |
| 1436 | + public function ucwords($str) | |
| 1437 | +    { | |
| 1438 | +        if (function_exists('mb_convert_case')) { | |
| 1439 | + return mb_convert_case($str, MB_CASE_TITLE); | |
| 1440 | + } | |
| 1183 | 1441 | return ucwords($str); | 
| 1184 | 1442 | } | 
| 1185 | -    public function strrev($str) { | |
| 1443 | + public function strrev($str) | |
| 1444 | +    { | |
| 1186 | 1445 |          preg_match_all('/./us', $str, $ar); | 
| 1187 | 1446 | return implode(array_reverse($ar[0])); | 
| 1188 | 1447 | } | 
| 1189 | -    public function str_shuffle($str) { | |
| 1448 | + public function str_shuffle($str) | |
| 1449 | +    { | |
| 1190 | 1450 |          preg_match_all('/./us', $str, $ar); | 
| 1191 | 1451 | shuffle($ar[0]); | 
| 1192 | 1452 | return implode($ar[0]); | 
| 1193 | 1453 | } | 
| 1194 | -    public function str_word_count($str) { | |
| 1454 | + public function str_word_count($str) | |
| 1455 | +    { | |
| 1195 | 1456 |          return count(preg_split('~[^\p{L}\p{N}\']+~u',$str)); | 
| 1196 | 1457 | } | 
| 1197 | -    public function strip_tags($value,$params='') { | |
| 1458 | + public function strip_tags($value,$params='') | |
| 1459 | +    { | |
| 1198 | 1460 | $modx = evolutionCMS(); | 
| 1199 | 1461 | |
| 1200 | 1462 |          if(stripos($params,'style')===false && stripos($value,'</style>')!==false) { | 
| @@ -1,11 +1,11 @@ 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 | unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes | 
| 7 | 7 | |
| 8 | -if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
 | |
| 8 | +if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) { | |
| 9 | 9 | // seems to be a new install - send the user to the configuration page | 
| 10 | 10 |  	exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
 | 
| 11 | 11 | } | 
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 | $_SESSION['nrnewmessages'] = 0; | 
| 17 | 17 | |
| 18 | 18 | // setup message info | 
| 19 | -if($modx->hasPermission('messages')) {
 | |
| 19 | +if($modx->hasPermission('messages')) { | |
| 20 | 20 | include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); | 
| 21 | 21 | $_SESSION['nrtotalmessages'] = $nrtotalmessages; | 
| 22 | 22 | $_SESSION['nrnewmessages'] = $nrnewmessages; | 
| @@ -32,46 +32,46 @@ discard block | ||
| 32 | 32 | } | 
| 33 | 33 | |
| 34 | 34 | // setup icons | 
| 35 | -if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
 | |
| 35 | +if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) { | |
| 36 | 36 | $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]'; | 
| 37 | 37 | $ph['SecurityIcon'] = wrapIcon($icon, 75); | 
| 38 | 38 | } | 
| 39 | -if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
 | |
| 39 | +if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) { | |
| 40 | 40 | $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]'; | 
| 41 | 41 | $ph['WebUserIcon'] = wrapIcon($icon, 99); | 
| 42 | 42 | } | 
| 43 | -if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
 | |
| 43 | +if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) { | |
| 44 | 44 | $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]'; | 
| 45 | 45 | $ph['ModulesIcon'] = wrapIcon($icon, 106); | 
| 46 | 46 | } | 
| 47 | -if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
 | |
| 47 | +if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) { | |
| 48 | 48 | $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]'; | 
| 49 | 49 | $ph['ResourcesIcon'] = wrapIcon($icon, 76); | 
| 50 | 50 | } | 
| 51 | -if($modx->hasPermission('bk_manager')) {
 | |
| 51 | +if($modx->hasPermission('bk_manager')) { | |
| 52 | 52 | $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]'; | 
| 53 | 53 | $ph['BackupIcon'] = wrapIcon($icon, 93); | 
| 54 | 54 | } | 
| 55 | -if($modx->hasPermission('help')) {
 | |
| 55 | +if($modx->hasPermission('help')) { | |
| 56 | 56 | $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]'; | 
| 57 | 57 | $ph['HelpIcon'] = wrapIcon($icon, 9); | 
| 58 | 58 | } | 
| 59 | 59 | // do some config checks | 
| 60 | -if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
 | |
| 60 | +if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) { | |
| 61 | 61 | include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); | 
| 62 | -	if($config_check_results != $_lang['configcheck_ok']) {
 | |
| 62 | +	if($config_check_results != $_lang['configcheck_ok']) { | |
| 63 | 63 | $ph['config_check_results'] = $config_check_results; | 
| 64 | 64 | $ph['config_display'] = 'block'; | 
| 65 | -	} else {
 | |
| 65 | +	} else { | |
| 66 | 66 | $ph['config_display'] = 'none'; | 
| 67 | 67 | } | 
| 68 | -} else {
 | |
| 68 | +} else { | |
| 69 | 69 | $ph['config_display'] = 'none'; | 
| 70 | 70 | } | 
| 71 | 71 | |
| 72 | 72 | // Check logout-reminder | 
| 73 | -if(isset($_SESSION['show_logout_reminder'])) {
 | |
| 74 | -	switch($_SESSION['show_logout_reminder']['type']) {
 | |
| 73 | +if(isset($_SESSION['show_logout_reminder'])) { | |
| 74 | +	switch($_SESSION['show_logout_reminder']['type']) { | |
| 75 | 75 | case 'logout_reminder': | 
| 76 | 76 | $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); | 
| 77 | 77 |  			$ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
 | 
| @@ -79,7 +79,7 @@ discard block | ||
| 79 | 79 | } | 
| 80 | 80 | $ph['show_logout_reminder'] = 'block'; | 
| 81 | 81 | unset($_SESSION['show_logout_reminder']); | 
| 82 | -} else {
 | |
| 82 | +} else { | |
| 83 | 83 | $ph['show_logout_reminder'] = 'none'; | 
| 84 | 84 | } | 
| 85 | 85 | |
| @@ -140,9 +140,9 @@ discard block | ||
| 140 | 140 | $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'"; | 
| 141 | 141 |  $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
 | 
| 142 | 142 | |
| 143 | -if($modx->db->getRecordCount($rs) < 1) {
 | |
| 143 | +if($modx->db->getRecordCount($rs) < 1) { | |
| 144 | 144 | $html = '<p>[%no_active_users_found%]</p>'; | 
| 145 | -} else {
 | |
| 145 | +} else { | |
| 146 | 146 | include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); | 
| 147 | 147 | $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; | 
| 148 | 148 |  	$ph['now'] = strftime('%H:%M:%S', $now);
 | 
| @@ -168,7 +168,7 @@ discard block | ||
| 168 | 168 | $userList = array(); | 
| 169 | 169 | $userCount = array(); | 
| 170 | 170 | // Create userlist with session-count first before output | 
| 171 | -	while($activeusers = $modx->db->getRow($rs)) {
 | |
| 171 | +	while($activeusers = $modx->db->getRow($rs)) { | |
| 172 | 172 | $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; | 
| 173 | 173 | |
| 174 | 174 | $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; | 
| @@ -186,7 +186,7 @@ discard block | ||
| 186 | 186 | $currentaction | 
| 187 | 187 | ); | 
| 188 | 188 | } | 
| 189 | -	foreach($userList as $params) {
 | |
| 189 | +	foreach($userList as $params) { | |
| 190 | 190 | $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; | 
| 191 | 191 |  		$html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
 | 
| 192 | 192 | } | 
| @@ -231,7 +231,7 @@ discard block | ||
| 231 | 231 | |
| 232 | 232 | // invoke event OnManagerWelcomePrerender | 
| 233 | 233 |  $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
 | 
| 234 | -if(is_array($evtOut)) {
 | |
| 234 | +if(is_array($evtOut)) { | |
| 235 | 235 |  	$output = implode('', $evtOut);
 | 
| 236 | 236 | $ph['OnManagerWelcomePrerender'] = $output; | 
| 237 | 237 | } | 
| @@ -340,7 +340,7 @@ discard block | ||
| 340 | 340 | 'body' => '<div class="widget-stage">[+RecentInfo+]</div>', | 
| 341 | 341 | 'hide'=>'0' | 
| 342 | 342 | ); | 
| 343 | -if ($modx->config['rss_url_news']) {
 | |
| 343 | +if ($modx->config['rss_url_news']) { | |
| 344 | 344 | $widgets['news'] = array( | 
| 345 | 345 | 'menuindex' => '40', | 
| 346 | 346 | 'id' => 'news', | 
| @@ -351,7 +351,7 @@ discard block | ||
| 351 | 351 | 'hide'=>'0' | 
| 352 | 352 | ); | 
| 353 | 353 | } | 
| 354 | -if ($modx->config['rss_url_security']) {
 | |
| 354 | +if ($modx->config['rss_url_security']) { | |
| 355 | 355 | $widgets['security'] = array( | 
| 356 | 356 | 'menuindex' => '50', | 
| 357 | 357 | 'id' => 'security', | 
| @@ -365,29 +365,29 @@ discard block | ||
| 365 | 365 | |
| 366 | 366 | // invoke OnManagerWelcomeHome event | 
| 367 | 367 |  $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
 | 
| 368 | -if(is_array($sitewidgets)) {
 | |
| 368 | +if(is_array($sitewidgets)) { | |
| 369 | 369 | $newwidgets = array(); | 
| 370 | -    foreach($sitewidgets as $widget){
 | |
| 370 | +    foreach($sitewidgets as $widget) { | |
| 371 | 371 | $newwidgets = array_merge($newwidgets, unserialize($widget)); | 
| 372 | 372 | } | 
| 373 | 373 | $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets; | 
| 374 | 374 | } | 
| 375 | 375 | |
| 376 | -usort($widgets, function ($a, $b) {
 | |
| 376 | +usort($widgets, function ($a, $b){ | |
| 377 | 377 | return $a['menuindex'] - $b['menuindex']; | 
| 378 | 378 | }); | 
| 379 | 379 | |
| 380 | 380 | $tpl = getTplWidget(); | 
| 381 | 381 | $output = ''; | 
| 382 | -foreach($widgets as $widget) {
 | |
| 383 | -	if ($widget['hide'] != '1'){
 | |
| 382 | +foreach($widgets as $widget) { | |
| 383 | +	if ($widget['hide'] != '1') { | |
| 384 | 384 | $output .= $modx->parseText($tpl, $widget); | 
| 385 | 385 | } | 
| 386 | 386 | } | 
| 387 | 387 | $ph['widgets'] = $output; | 
| 388 | 388 | |
| 389 | 389 | // load template | 
| 390 | -if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
 | |
| 390 | +if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) { | |
| 391 | 391 | $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'; | 
| 392 | 392 | } | 
| 393 | 393 | |
| @@ -395,26 +395,28 @@ discard block | ||
| 395 | 395 |  $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target);
 | 
| 396 | 396 | $target = $modx->mergeSettingsContent($target); | 
| 397 | 397 | |
| 398 | -if(substr($target, 0, 1) === '@') {
 | |
| 399 | -	if(substr($target, 0, 6) === '@CHUNK') {
 | |
| 398 | +if(substr($target, 0, 1) === '@') { | |
| 399 | +	if(substr($target, 0, 6) === '@CHUNK') { | |
| 400 | 400 | $content = $modx->getChunk(trim(substr($target, 7))); | 
| 401 | -	} elseif(substr($target, 0, 5) === '@FILE') {
 | |
| 401 | +	} elseif(substr($target, 0, 5) === '@FILE') { | |
| 402 | 402 | $content = file_get_contents(trim(substr($target, 6))); | 
| 403 | -	} else {
 | |
| 403 | +	} else { | |
| 404 | 404 | $content = ''; | 
| 405 | 405 | } | 
| 406 | -} else {
 | |
| 406 | +} else { | |
| 407 | 407 | $chunk = $modx->getChunk($target); | 
| 408 | -	if($chunk !== false && !empty($chunk)) {
 | |
| 408 | +	if($chunk !== false && !empty($chunk)) { | |
| 409 | 409 | $content = $chunk; | 
| 410 | -	} elseif(is_file(MODX_BASE_PATH . $target)) {
 | |
| 410 | +	} elseif(is_file(MODX_BASE_PATH . $target)) { | |
| 411 | 411 | $content = file_get_contents(MODX_BASE_PATH . $target); | 
| 412 | -	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
 | |
| 412 | +	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) { | |
| 413 | 413 | $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); | 
| 414 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible | |
| 414 | +	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) { | |
| 415 | + // ClipperCMS compatible | |
| 415 | 416 |  	{
 | 
| 416 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); | |
| 417 | -	} else {
 | |
| 417 | + $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); | |
| 418 | + } | |
| 419 | +	} else { | |
| 418 | 420 | $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); | 
| 419 | 421 | } | 
| 420 | 422 | } | 
| @@ -423,7 +425,7 @@ discard block | ||
| 423 | 425 | $content = $modx->mergeConditionalTagsContent($content); | 
| 424 | 426 | $content = $modx->mergeSettingsContent($content); | 
| 425 | 427 | $content = $modx->parseText($content, $ph); | 
| 426 | -if(strpos($content, '[+') !== false) {
 | |
| 428 | +if(strpos($content, '[+') !== false) { | |
| 427 | 429 | $modx->toPlaceholders($ph); | 
| 428 | 430 | $content = $modx->mergePlaceholderContent($content); | 
| 429 | 431 | } | 
| @@ -432,7 +434,7 @@ discard block | ||
| 432 | 434 | $content = $modx->parseText($content, $_style, '[&', '&]'); | 
| 433 | 435 | $content = $modx->cleanUpMODXTags($content); //cleanup | 
| 434 | 436 | |
| 435 | -if($js = $modx->getRegisteredClientScripts()) {
 | |
| 437 | +if($js = $modx->getRegisteredClientScripts()) { | |
| 436 | 438 | $content .= $js; | 
| 437 | 439 | } | 
| 438 | 440 | |
| @@ -442,7 +444,9 @@ discard block | ||
| 442 | 444 | // <a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a> | 
| 443 | 445 | // <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a> | 
| 444 | 446 | //</span> | 
| 445 | -function getTplWidget() { // recent document info
 | |
| 447 | +function getTplWidget() | |
| 448 | +{ | |
| 449 | +// recent document info | |
| 446 | 450 | return ' | 
| 447 | 451 | <div class="[+cols+]" id="[+id+]"> | 
| 448 | 452 | <div class="card"[+cardAttr+]> | 
| @@ -453,7 +457,9 @@ discard block | ||
| 453 | 457 | '; | 
| 454 | 458 | } | 
| 455 | 459 | |
| 456 | -function getRecentInfo() { // recent document info
 | |
| 460 | +function getRecentInfo() | |
| 461 | +{ | |
| 462 | +// recent document info | |
| 457 | 463 | $modx = evolutionCMS(); | 
| 458 | 464 | |
| 459 | 465 |  	$modx->addSnippet('recentInfoList', 'getRecentInfoList');
 | 
| @@ -479,12 +485,13 @@ discard block | ||
| 479 | 485 | return $html; | 
| 480 | 486 | } | 
| 481 | 487 | |
| 482 | -function getRecentInfoList() {
 | |
| 488 | +function getRecentInfoList() | |
| 489 | +{ | |
| 483 | 490 | $modx = evolutionCMS(); | 
| 484 | 491 | |
| 485 | 492 |  	$rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
 | 
| 486 | 493 | |
| 487 | -	if($modx->db->getRecordCount($rs) < 1) {
 | |
| 494 | +	if($modx->db->getRecordCount($rs) < 1) { | |
| 488 | 495 | return '<tr><td>[%no_activity_message%]</td></tr>'; | 
| 489 | 496 | } | 
| 490 | 497 | |
| @@ -494,22 +501,22 @@ discard block | ||
| 494 | 501 | $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> '; | 
| 495 | 502 | |
| 496 | 503 | $output = array(); | 
| 497 | -	while($ph = $modx->db->getRow($rs)) {
 | |
| 504 | +	while($ph = $modx->db->getRow($rs)) { | |
| 498 | 505 | $docid = $ph['id']; | 
| 499 | 506 | $_ = $modx->getUserInfo($ph['editedby']); | 
| 500 | 507 | $ph['username'] = $_['username']; | 
| 501 | 508 | |
| 502 | -		if($ph['deleted'] == 1) {
 | |
| 509 | +		if($ph['deleted'] == 1) { | |
| 503 | 510 | $ph['status'] = 'deleted text-danger'; | 
| 504 | -		} elseif($ph['published'] == 0) {
 | |
| 511 | +		} elseif($ph['published'] == 0) { | |
| 505 | 512 | $ph['status'] = 'unpublished font-italic text-muted'; | 
| 506 | -		} else {
 | |
| 513 | +		} else { | |
| 507 | 514 | $ph['status'] = 'published'; | 
| 508 | 515 | } | 
| 509 | 516 | |
| 510 | -		if($modx->hasPermission('edit_document')) {
 | |
| 517 | +		if($modx->hasPermission('edit_document')) { | |
| 511 | 518 |  			$ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
 | 
| 512 | -		} else {
 | |
| 519 | +		} else { | |
| 513 | 520 | $ph['edit_btn'] = ''; | 
| 514 | 521 | } | 
| 515 | 522 | |
| @@ -522,40 +529,40 @@ discard block | ||
| 522 | 529 | $preview_disabled | 
| 523 | 530 | ), $btntpl['preview_btn']); | 
| 524 | 531 | |
| 525 | -		if($modx->hasPermission('delete_document')) {
 | |
| 526 | -			if($ph['deleted'] == 0) {
 | |
| 532 | +		if($modx->hasPermission('delete_document')) { | |
| 533 | +			if($ph['deleted'] == 0) { | |
| 527 | 534 | $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> '; | 
| 528 | -			} else {
 | |
| 535 | +			} else { | |
| 529 | 536 | $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> '; | 
| 530 | 537 | } | 
| 531 | 538 |  			$ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
 | 
| 532 | -		} else {
 | |
| 539 | +		} else { | |
| 533 | 540 | $ph['delete_btn'] = ''; | 
| 534 | 541 | } | 
| 535 | 542 | |
| 536 | -		if($ph['deleted'] == 1 && $ph['published'] == 0) {
 | |
| 543 | +		if($ph['deleted'] == 1 && $ph['published'] == 0) { | |
| 537 | 544 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; | 
| 538 | -		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
 | |
| 545 | +		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) { | |
| 539 | 546 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; | 
| 540 | -		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
 | |
| 547 | +		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) { | |
| 541 | 548 | $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; | 
| 542 | -		} else {
 | |
| 549 | +		} else { | |
| 543 | 550 | $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; | 
| 544 | 551 | } | 
| 545 | 552 |  		$ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
 | 
| 546 | 553 | |
| 547 | 554 |  		$ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
 | 
| 548 | 555 | |
| 549 | -		if($ph['longtitle'] == '') {
 | |
| 556 | +		if($ph['longtitle'] == '') { | |
| 550 | 557 | $ph['longtitle'] = '(<i>[%not_set%]</i>)'; | 
| 551 | 558 | } | 
| 552 | -		if($ph['description'] == '') {
 | |
| 559 | +		if($ph['description'] == '') { | |
| 553 | 560 | $ph['description'] = '(<i>[%not_set%]</i>)'; | 
| 554 | 561 | } | 
| 555 | -		if($ph['introtext'] == '') {
 | |
| 562 | +		if($ph['introtext'] == '') { | |
| 556 | 563 | $ph['introtext'] = '(<i>[%not_set%]</i>)'; | 
| 557 | 564 | } | 
| 558 | -		if($ph['alias'] == '') {
 | |
| 565 | +		if($ph['alias'] == '') { | |
| 559 | 566 | $ph['alias'] = '(<i>[%not_set%]</i>)'; | 
| 560 | 567 | } | 
| 561 | 568 | |
| @@ -564,7 +571,8 @@ discard block | ||
| 564 | 571 |  	return implode("\n", $output);
 | 
| 565 | 572 | } | 
| 566 | 573 | |
| 567 | -function getRecentInfoRowTpl() {
 | |
| 574 | +function getRecentInfoRowTpl() | |
| 575 | +{ | |
| 568 | 576 | $tpl = ' | 
| 569 | 577 | <tr> | 
| 570 | 578 | <td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td> | 
| @@ -593,11 +601,13 @@ discard block | ||
| 593 | 601 | } | 
| 594 | 602 | |
| 595 | 603 | // setup icons | 
| 596 | -function wrapIcon($i, $action) {
 | |
| 604 | +function wrapIcon($i, $action) | |
| 605 | +{ | |
| 597 | 606 |  	return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
 | 
| 598 | 607 | } | 
| 599 | 608 | |
| 600 | -function getStartUpScript() {
 | |
| 609 | +function getStartUpScript() | |
| 610 | +{ | |
| 601 | 611 | $script = ' | 
| 602 | 612 | <script type="text/javascript"> | 
| 603 | 613 |          function hideConfigCheckWarning(key) {
 | 
| @@ -104,7 +104,8 @@ discard block | ||
| 104 | 104 | /** | 
| 105 | 105 | * @return string | 
| 106 | 106 | */ | 
| 107 | -function run() { | |
| 107 | +function run() | |
| 108 | +{ | |
| 108 | 109 | $modx = evolutionCMS(); global $_lang; | 
| 109 | 110 | |
| 110 | 111 |  	$tbl_site_content = $modx->getFullTableName('site_content'); | 
| @@ -171,7 +172,8 @@ discard block | ||
| 171 | 172 | * @param array $files | 
| 172 | 173 | * @param string $mode | 
| 173 | 174 | */ | 
| 174 | -function importFiles($parent, $filedir, $files, $mode) { | |
| 175 | +function importFiles($parent, $filedir, $files, $mode) | |
| 176 | +{ | |
| 175 | 177 | $modx = evolutionCMS(); | 
| 176 | 178 | global $_lang, $allowedfiles; | 
| 177 | 179 | global $search_default, $cache_default, $publish_default; | 
| @@ -318,7 +320,8 @@ discard block | ||
| 318 | 320 | * @param int $count | 
| 319 | 321 | * @return array | 
| 320 | 322 | */ | 
| 321 | -function getFiles($directory, $listing = array(), $count = 0) { | |
| 323 | +function getFiles($directory, $listing = array(), $count = 0) | |
| 324 | +{ | |
| 322 | 325 | global $_lang; | 
| 323 | 326 | global $filesfound; | 
| 324 | 327 | $dummy = $count; | 
| @@ -346,7 +349,8 @@ discard block | ||
| 346 | 349 | * @param string $filepath | 
| 347 | 350 | * @return bool|string | 
| 348 | 351 | */ | 
| 349 | -function getFileContent($filepath) { | |
| 352 | +function getFileContent($filepath) | |
| 353 | +{ | |
| 350 | 354 | global $_lang; | 
| 351 | 355 | // get the file | 
| 352 | 356 |  	if(!$buffer = file_get_contents($filepath)) { | 
| @@ -360,7 +364,8 @@ discard block | ||
| 360 | 364 | * @param array $array | 
| 361 | 365 | * @return array | 
| 362 | 366 | */ | 
| 363 | -function pop_index($array) { | |
| 367 | +function pop_index($array) | |
| 368 | +{ | |
| 364 | 369 | $new_array = array(); | 
| 365 | 370 |  	foreach($array as $k => $v) { | 
| 366 | 371 |  		if($v !== 'index.html' && $v !== 'index.htm') { | 
| @@ -383,7 +388,8 @@ discard block | ||
| 383 | 388 | * @param string $alias | 
| 384 | 389 | * @return array | 
| 385 | 390 | */ | 
| 386 | -function treatContent($src, $filename, $alias) { | |
| 391 | +function treatContent($src, $filename, $alias) | |
| 392 | +{ | |
| 387 | 393 | $modx = evolutionCMS(); | 
| 388 | 394 | |
| 389 | 395 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); | 
| @@ -427,7 +433,8 @@ discard block | ||
| 427 | 433 | /** | 
| 428 | 434 | * @return void | 
| 429 | 435 | */ | 
| 430 | -function convertLink() { | |
| 436 | +function convertLink() | |
| 437 | +{ | |
| 431 | 438 | $modx = evolutionCMS(); | 
| 432 | 439 |  	$tbl_site_content = $modx->getFullTableName('site_content'); | 
| 433 | 440 | |
| @@ -478,7 +478,8 @@ discard block | ||
| 478 | 478 | return s; | 
| 479 | 479 | } | 
| 480 | 480 | |
| 481 | -		<?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> | |
| 481 | +		<?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { | |
| 482 | +// Web Link specific ?> | |
| 482 | 483 | var lastImageCtrl; | 
| 483 | 484 | var lastFileCtrl; | 
| 484 | 485 | |
| @@ -694,7 +695,8 @@ discard block | ||
| 694 | 695 | </td> | 
| 695 | 696 | </tr> | 
| 696 | 697 | |
| 697 | -								<?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> | |
| 698 | +								<?php if($content['type'] == 'reference' || $modx->manager->action == '72') { | |
| 699 | +// Web Link specific ?> | |
| 698 | 700 | |
| 699 | 701 | <tr> | 
| 700 | 702 | <td><span class="warning"><?= $_lang['weblink'] ?></span> | 
| @@ -1353,7 +1355,9 @@ discard block | ||
| 1353 | 1355 |  						if($documentId > 0) { | 
| 1354 | 1356 | // Load up, the permissions from the parent (if new document) or existing document | 
| 1355 | 1357 |  							$rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); | 
| 1356 | - while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; | |
| 1358 | +							while($currentgroup = $modx->db->getRow($rs)) { | |
| 1359 | + $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; | |
| 1360 | + } | |
| 1357 | 1361 | |
| 1358 | 1362 | // Load up the current permissions and names | 
| 1359 | 1363 | $vs = array( | 
| @@ -1415,7 +1419,9 @@ discard block | ||
| 1415 | 1419 | |
| 1416 | 1420 | // Create attribute string list | 
| 1417 | 1421 | $inputString = array(); | 
| 1418 | - foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; | |
| 1422 | +							foreach($inputAttributes as $k => $v) { | |
| 1423 | + $inputString[] = $k . '="' . $v . '"'; | |
| 1424 | + } | |
| 1419 | 1425 | |
| 1420 | 1426 | // Make the <input> HTML | 
| 1421 | 1427 |  							$inputHTML = '<input ' . implode(' ', $inputString) . ' />'; | 
| @@ -1535,7 +1541,8 @@ discard block | ||
| 1535 | 1541 | /** | 
| 1536 | 1542 | * @return string | 
| 1537 | 1543 | */ | 
| 1538 | -function getDefaultTemplate() { | |
| 1544 | +function getDefaultTemplate() | |
| 1545 | +{ | |
| 1539 | 1546 | $modx = evolutionCMS(); | 
| 1540 | 1547 | |
| 1541 | 1548 | $default_template = ''; | 
| @@ -1,5 +1,5 @@ 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 | |
| @@ -16,7 +16,8 @@ discard block | ||
| 16 | 16 | * @param array $ph | 
| 17 | 17 | * @return string | 
| 18 | 18 | */ | 
| 19 | -function parsePh($tpl, $ph) {
 | |
| 19 | +function parsePh($tpl, $ph) | |
| 20 | +{ | |
| 20 | 21 | $modx = evolutionCMS(); global $_lang; | 
| 21 | 22 | $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); | 
| 22 | 23 | return $modx->parseText($tpl, $ph); | 
| @@ -26,7 +27,8 @@ discard block | ||
| 26 | 27 | * @param string|int $cssId | 
| 27 | 28 | * @return string | 
| 28 | 29 | */ | 
| 29 | -function renderViewSwitchButtons($cssId) {
 | |
| 30 | +function renderViewSwitchButtons($cssId) | |
| 31 | +{ | |
| 30 | 32 | $modx = evolutionCMS(); global $_lang, $tpl; | 
| 31 | 33 | |
| 32 | 34 | return parsePh($tpl['viewForm'], array( | 
| @@ -39,19 +41,20 @@ discard block | ||
| 39 | 41 | * @param mgrResources $resources | 
| 40 | 42 | * @return string | 
| 41 | 43 | */ | 
| 42 | -function createResourceList($resourceTable, $resources) {
 | |
| 44 | +function createResourceList($resourceTable, $resources) | |
| 45 | +{ | |
| 43 | 46 | $modx = evolutionCMS(); global $_lang, $_style, $modx_textdir, $tpl; | 
| 44 | 47 | |
| 45 | 48 | $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; | 
| 46 | 49 | |
| 47 | -	if( ! is_array($items) || empty($items)) {
 | |
| 50 | +	if( ! is_array($items) || empty($items)) { | |
| 48 | 51 | return $_lang['no_results']; | 
| 49 | 52 | } | 
| 50 | 53 | |
| 51 | 54 | // Prepare elements- and categories-list | 
| 52 | 55 | $elements = array(); | 
| 53 | 56 | $categories = array(); | 
| 54 | -	foreach($items as $row) {
 | |
| 57 | +	foreach($items as $row) { | |
| 55 | 58 | $catid = $row['catid'] ? $row['catid'] : 0; | 
| 56 | 59 |  		$categories[$catid] = array('name' => stripslashes($row['category']));
 | 
| 57 | 60 | $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); | 
| @@ -59,7 +62,7 @@ discard block | ||
| 59 | 62 | |
| 60 | 63 | // Now render categories / panel-collapse | 
| 61 | 64 | $panelGroup = ''; | 
| 62 | -	foreach($elements as $catid => $elList) {
 | |
| 65 | +	foreach($elements as $catid => $elList) { | |
| 63 | 66 | // Add panel-heading / category-collapse to output | 
| 64 | 67 | $panelGroup .= parsePh($tpl['panelHeading'], array( | 
| 65 | 68 | 'tab' => $resourceTable, | 
| @@ -70,7 +73,7 @@ discard block | ||
| 70 | 73 | |
| 71 | 74 | // Prepare content for panel-collapse | 
| 72 | 75 | $panelCollapse = ''; | 
| 73 | -		foreach($elList as $el) {
 | |
| 76 | +		foreach($elList as $el) { | |
| 74 | 77 | $panelCollapse .= parsePh($tpl['elementsRow'], $el); | 
| 75 | 78 | } | 
| 76 | 79 | |
| @@ -92,14 +95,15 @@ discard block | ||
| 92 | 95 | * @param mgrResources $resources | 
| 93 | 96 | * @return string | 
| 94 | 97 | */ | 
| 95 | -function createCombinedView($resources) {
 | |
| 98 | +function createCombinedView($resources) | |
| 99 | +{ | |
| 96 | 100 | $modx = evolutionCMS(); global $_lang, $_style, $modx_textdir; | 
| 97 | 101 | |
| 98 | 102 | $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; | 
| 99 | 103 | $types = isset($resources->types) ? $resources->types : false; | 
| 100 | 104 | $categories = isset($resources->categories) ? $resources->categories : false; | 
| 101 | 105 | |
| 102 | -	if(!$itemsPerCategory) {
 | |
| 106 | +	if(!$itemsPerCategory) { | |
| 103 | 107 | return $_lang['no_results']; | 
| 104 | 108 | } | 
| 105 | 109 | |
| @@ -112,10 +116,10 @@ discard block | ||
| 112 | 116 | |
| 113 | 117 | // Easily loop through $itemsPerCategory-Array | 
| 114 | 118 | $panelGroup = ''; | 
| 115 | -	foreach($categories as $catid => $category) {
 | |
| 119 | +	foreach($categories as $catid => $category) { | |
| 116 | 120 | // Prepare collapse content / elements-list | 
| 117 | 121 | $panelCollapse = ''; | 
| 118 | -		foreach($itemsPerCategory[$catid] as $el) {
 | |
| 122 | +		foreach($itemsPerCategory[$catid] as $el) { | |
| 119 | 123 | $resourceTable = $el['type']; | 
| 120 | 124 | $ph = prepareElementRowPh($el, $resourceTable, $resources); | 
| 121 | 125 | $panelCollapse .= parsePh($tpl['elementsRow'], $ph); | 
| @@ -149,14 +153,15 @@ discard block | ||
| 149 | 153 | * @param mgrResources $resources | 
| 150 | 154 | * @return array | 
| 151 | 155 | */ | 
| 152 | -function prepareElementRowPh($row, $resourceTable, $resources) {
 | |
| 156 | +function prepareElementRowPh($row, $resourceTable, $resources) | |
| 157 | +{ | |
| 153 | 158 | $modx = evolutionCMS(); global $modx_textdir, $_style, $_lang; | 
| 154 | 159 | |
| 155 | 160 | $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; | 
| 156 | 161 | |
| 157 | 162 | $_lang["confirm_delete"] = $_lang["delete"]; | 
| 158 | 163 | |
| 159 | -	switch($resourceTable){
 | |
| 164 | +	switch($resourceTable) { | |
| 160 | 165 | case 'site_templates': | 
| 161 | 166 | $class = $row['selectable'] ? '' : 'disabledPlugin'; | 
| 162 | 167 | $lockElementType = 1; | 
| @@ -193,56 +198,56 @@ discard block | ||
| 193 | 198 | // Prepare displaying user-locks | 
| 194 | 199 | $lockedByUser = ''; | 
| 195 | 200 | $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); | 
| 196 | -	if($rowLock && $modx->hasPermission('display_locks')) {
 | |
| 197 | -		if($rowLock['sid'] == $modx->sid) {
 | |
| 201 | +	if($rowLock && $modx->hasPermission('display_locks')) { | |
| 202 | +		if($rowLock['sid'] == $modx->sid) { | |
| 198 | 203 | $title = $modx->parseText($_lang["lock_element_editing"], array( | 
| 199 | 204 | 'element_type' => $_lang["lock_element_type_" . $lockElementType], | 
| 200 | 205 | 'lasthit_df' => $rowLock['lasthit_df'] | 
| 201 | 206 | )); | 
| 202 | 207 | $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; | 
| 203 | -		} else {
 | |
| 208 | +		} else { | |
| 204 | 209 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( | 
| 205 | 210 | 'element_type' => $_lang["lock_element_type_" . $lockElementType], | 
| 206 | 211 | 'username' => $rowLock['username'], | 
| 207 | 212 | 'lasthit_df' => $rowLock['lasthit_df'] | 
| 208 | 213 | )); | 
| 209 | -			if($modx->hasPermission('remove_locks')) {
 | |
| 214 | +			if($modx->hasPermission('remove_locks')) { | |
| 210 | 215 |  				$lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
 | 
| 211 | -			} else {
 | |
| 216 | +			} else { | |
| 212 | 217 | $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; | 
| 213 | 218 | } | 
| 214 | 219 | } | 
| 215 | 220 | } | 
| 216 | -	if($lockedByUser) {
 | |
| 221 | +	if($lockedByUser) { | |
| 217 | 222 | $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; | 
| 218 | 223 | } | 
| 219 | 224 | |
| 220 | 225 | // Caption | 
| 221 | -	if($resourceTable == 'site_tmplvars') {
 | |
| 226 | +	if($resourceTable == 'site_tmplvars') { | |
| 222 | 227 |  		$caption = !empty($row['description']) ? ' ' . $row['caption'] . '   <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
 | 
| 223 | -	} else {
 | |
| 228 | +	} else { | |
| 224 | 229 | $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; | 
| 225 | 230 | } | 
| 226 | 231 | |
| 227 | 232 | // Special marks | 
| 228 | 233 | $tplInfo = array(); | 
| 229 | -	if($row['locked']) {
 | |
| 234 | +	if($row['locked']) { | |
| 230 | 235 | $tplInfo[] = $_lang['locked']; | 
| 231 | 236 | } | 
| 232 | -	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
 | |
| 237 | +	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { | |
| 233 | 238 | $tplInfo[] = $_lang['defaulttemplate_title']; | 
| 234 | 239 | } | 
| 235 | 240 |  	$marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
 | 
| 236 | 241 | |
| 237 | 242 | /* row buttons */ | 
| 238 | 243 | $buttons = ''; | 
| 239 | -	if($modx->hasPermission($types['actions']['edit'][1])) {
 | |
| 244 | +	if($modx->hasPermission($types['actions']['edit'][1])) { | |
| 240 | 245 | $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; | 
| 241 | 246 | } | 
| 242 | -	if($modx->hasPermission($types['actions']['duplicate'][1])) {
 | |
| 247 | +	if($modx->hasPermission($types['actions']['duplicate'][1])) { | |
| 243 | 248 | $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; | 
| 244 | 249 | } | 
| 245 | -	if($modx->hasPermission($types['actions']['remove'][1])) {
 | |
| 250 | +	if($modx->hasPermission($types['actions']['remove'][1])) { | |
| 246 | 251 | $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; | 
| 247 | 252 | } | 
| 248 | 253 | $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |