@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function setTableWidth($value) |
132 | 132 | { |
133 | - $this->tableWidth = (int)$value; |
|
133 | + $this->tableWidth = (int) $value; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | { |
318 | 318 | $currentWidth = ''; |
319 | 319 | if (is_array($this->columnWidths)) { |
320 | - $currentWidth = $this->columnWidths[$columnPosition] ? ' width="' . $this->columnWidths[$columnPosition] . '" ' : ''; |
|
320 | + $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | return $currentWidth; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $currentClass = $this->rowAlternateClass; |
347 | 347 | } |
348 | 348 | |
349 | - return ' class="' . $currentClass . '"'; |
|
349 | + return ' class="'.$currentClass.'"'; |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | { |
361 | 361 | $cellAction = ''; |
362 | 362 | if ($this->cellAction) { |
363 | - $cellAction = ' onClick="javascript:window.location=\'' . $this->cellAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '\'" '; |
|
363 | + $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | return $cellAction; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | { |
378 | 378 | $cell = $value; |
379 | 379 | if ($this->linkAction) { |
380 | - $cell = '<a href="' . $this->linkAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '">' . $cell . '</a>'; |
|
380 | + $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | return $cell; |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $end = '?'; |
407 | 407 | } |
408 | 408 | |
409 | - return $link . $end; |
|
409 | + return $link.$end; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | if (is_array($fieldsArray)) { |
427 | 427 | $i = 0; |
428 | 428 | foreach ($fieldsArray as $fieldName => $fieldValue) { |
429 | - $table .= "\t<tr" . $this->determineRowClass($i) . ">\n"; |
|
429 | + $table .= "\t<tr".$this->determineRowClass($i).">\n"; |
|
430 | 430 | $currentActionFieldValue = $fieldValue[$this->actionField]; |
431 | 431 | if (is_array($this->selectedValues)) { |
432 | 432 | $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1; |
@@ -437,15 +437,15 @@ discard block |
||
437 | 437 | $colPosition = 0; |
438 | 438 | foreach ($fieldValue as $key => $value) { |
439 | 439 | if (!in_array($key, $this->excludeFields)) { |
440 | - $table .= "\t\t<td" . $this->getCellAction($currentActionFieldValue) . ">"; |
|
440 | + $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">"; |
|
441 | 441 | $table .= $this->createCellText($currentActionFieldValue, $value); |
442 | 442 | $table .= "</td>\n"; |
443 | 443 | if ($i == 0) { |
444 | 444 | if (empty ($header) && $this->formElementType) { |
445 | - $header .= "\t\t<th style=\"width:32px\" " . ($this->thClass ? 'class="' . $this->thClass . '"' : '') . ">" . ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '') . "</th>\n"; |
|
445 | + $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n"; |
|
446 | 446 | } |
447 | 447 | $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key; |
448 | - $header .= "\t\t<th" . $this->getColumnWidth($colPosition) . ($this->thClass ? ' class="' . $this->thClass . '" ' : '') . ">" . $headerText . "</th>\n"; |
|
448 | + $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n"; |
|
449 | 449 | } |
450 | 450 | $colPosition++; |
451 | 451 | } |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | $i++; |
454 | 454 | $table .= "\t</tr>\n"; |
455 | 455 | } |
456 | - $table = "\n" . '<table' . ($this->tableWidth > 0 ? ' width="' . $this->tableWidth . '"' : '') . ($this->tableClass ? ' class="' . $this->tableClass . '"' : '') . ($this->tableID ? ' id="' . $this->tableID . '"' : '') . ">\n" . ($header ? "\t<thead>\n\t<tr class=\"" . $this->rowHeaderClass . "\">\n" . $header . "\t</tr>\n\t</thead>\n" : '') . $table . "</table>\n"; |
|
456 | + $table = "\n".'<table'.($this->tableWidth > 0 ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n"; |
|
457 | 457 | if ($this->formElementType) { |
458 | - $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
|
458 | + $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
|
459 | 459 | } |
460 | 460 | if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
461 | 461 | /* commented this part because of cookie |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | |
470 | 470 | $table .= '</select>'.$_lang["pagination_table_perpage"].'</div>'; |
471 | 471 | */ |
472 | - $table .= '<div id="pagination" class="paginate">' . $_lang["pagination_table_gotopage"] . '<ul>' . $this->pageNav . '</ul></div>'; |
|
472 | + $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>'; |
|
473 | 473 | //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>'; |
474 | 474 | |
475 | 475 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | <script language="javascript"> |
479 | 479 | toggled = 0; |
480 | 480 | function clickAll() { |
481 | - myform = document.getElementById("' . $this->formName . '"); |
|
481 | + myform = document.getElementById("' . $this->formName.'"); |
|
482 | 482 | for(i=0;i<myform.length;i++) { |
483 | 483 | if(myform.elements[i].type==\'checkbox\') { |
484 | 484 | myform.elements[i].checked=(toggled?false:true); |
@@ -490,9 +490,9 @@ discard block |
||
490 | 490 | } |
491 | 491 | if ($this->formElementType) { |
492 | 492 | if ($this->extra) { |
493 | - $table .= "\n" . $this->extra . "\n"; |
|
493 | + $table .= "\n".$this->extra."\n"; |
|
494 | 494 | } |
495 | - $table .= "\n" . '</form>' . "\n"; |
|
495 | + $table .= "\n".'</form>'."\n"; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | return $table; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
516 | 516 | $nav = ''; |
517 | 517 | if ($numPages > 1) { |
518 | - $currentURL = empty($qs) ? '' : '?' . $qs; |
|
518 | + $currentURL = empty($qs) ? '' : '?'.$qs; |
|
519 | 519 | if ($currentPage > 6) { |
520 | 520 | $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]); |
521 | 521 | } |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]); |
541 | 541 | } |
542 | 542 | } |
543 | - $this->pageNav = ' ' . $nav; |
|
543 | + $this->pageNav = ' '.$nav; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -556,14 +556,14 @@ discard block |
||
556 | 556 | public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = '') |
557 | 557 | { |
558 | 558 | $modx = evolutionCMS(); |
559 | - $orderBy = !empty($_GET['orderby']) ? '&orderby=' . $_GET['orderby'] : ''; |
|
560 | - $orderDir = !empty($_GET['orderdir']) ? '&orderdir=' . $_GET['orderdir'] : ''; |
|
559 | + $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : ''; |
|
560 | + $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : ''; |
|
561 | 561 | if (!empty($qs)) { |
562 | 562 | $qs = "?$qs"; |
563 | 563 | } |
564 | 564 | $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], |
565 | - $qs . "page=$pageNum$orderBy$orderDir") : $this->prepareLink($link) . "page=$pageNum"; |
|
566 | - $nav = '<li' . ($currentPage ? ' class="currentPage"' : '') . '><a' . ($currentPage ? ' class="currentPage"' : '') . ' href="' . $link . '">' . $displayText . '</a></li>' . "\n"; |
|
565 | + $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum"; |
|
566 | + $nav = '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
|
567 | 567 | |
568 | 568 | return $nav; |
569 | 569 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | $field = ''; |
582 | 582 | if ($this->formElementType) { |
583 | 583 | $checked = $isChecked ? "checked " : ""; |
584 | - $field = "\t\t" . '<td><input type="' . $this->formElementType . '" name="' . ($this->formElementName ? $this->formElementName : $value) . '" value="' . $value . '" ' . $checked . '/></td>' . "\n"; |
|
584 | + $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | return $field; |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | public function handlePaging() |
596 | 596 | { |
597 | 597 | $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
598 | - $limitClause = ' LIMIT ' . ($offset * MAX_DISPLAY_RECORDS_NUM) . ', ' . MAX_DISPLAY_RECORDS_NUM; |
|
598 | + $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
|
599 | 599 | |
600 | 600 | return $limitClause; |
601 | 601 | } |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | public function handleSorting($natural_order = false) |
611 | 611 | { |
612 | 612 | $orderByClause = ''; |
613 | - if ((bool)$natural_order === false) { |
|
613 | + if ((bool) $natural_order === false) { |
|
614 | 614 | $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id"; |
615 | 615 | $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC"; |
616 | - $orderByClause = !empty($orderby) ? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ' : ""; |
|
616 | + $orderByClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : ""; |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | return $orderByClause; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | } |
643 | 643 | } |
644 | 644 | |
645 | - return '<a href="[~' . $modx->documentIdentifier . '~]?' . $qs . 'orderby=' . $key . $orderDir . '">' . $text . '</a>'; |
|
645 | + return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>'; |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | } |
@@ -144,33 +144,33 @@ discard block |
||
144 | 144 | $algorithm = 'UNCRYPT'; |
145 | 145 | } |
146 | 146 | |
147 | - $salt = md5($password . $seed); |
|
147 | + $salt = md5($password.$seed); |
|
148 | 148 | |
149 | 149 | switch ($algorithm) { |
150 | 150 | case 'BLOWFISH_Y': |
151 | - $salt = '$2y$07$' . substr($salt, 0, 22); |
|
151 | + $salt = '$2y$07$'.substr($salt, 0, 22); |
|
152 | 152 | break; |
153 | 153 | case 'BLOWFISH_A': |
154 | - $salt = '$2a$07$' . substr($salt, 0, 22); |
|
154 | + $salt = '$2a$07$'.substr($salt, 0, 22); |
|
155 | 155 | break; |
156 | 156 | case 'SHA512': |
157 | - $salt = '$6$' . substr($salt, 0, 16); |
|
157 | + $salt = '$6$'.substr($salt, 0, 16); |
|
158 | 158 | break; |
159 | 159 | case 'SHA256': |
160 | - $salt = '$5$' . substr($salt, 0, 16); |
|
160 | + $salt = '$5$'.substr($salt, 0, 16); |
|
161 | 161 | break; |
162 | 162 | case 'MD5': |
163 | - $salt = '$1$' . substr($salt, 0, 8); |
|
163 | + $salt = '$1$'.substr($salt, 0, 8); |
|
164 | 164 | break; |
165 | 165 | } |
166 | 166 | |
167 | 167 | if ($algorithm !== 'UNCRYPT') { |
168 | - $password = sha1($password) . crypt($password, $salt); |
|
168 | + $password = sha1($password).crypt($password, $salt); |
|
169 | 169 | } else { |
170 | - $password = sha1($salt . $password); |
|
170 | + $password = sha1($salt.$password); |
|
171 | 171 | } |
172 | 172 | |
173 | - $result = strtolower($algorithm) . '>' . md5($salt . $password) . substr(md5($salt), 0, 8); |
|
173 | + $result = strtolower($algorithm).'>'.md5($salt.$password).substr(md5($salt), 0, 8); |
|
174 | 174 | |
175 | 175 | return $result; |
176 | 176 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $check_files = explode("\n", $check_files); |
253 | 253 | foreach ($check_files as $file) { |
254 | 254 | $file = trim($file); |
255 | - $file = MODX_BASE_PATH . $file; |
|
255 | + $file = MODX_BASE_PATH.$file; |
|
256 | 256 | if (!is_file($file)) { |
257 | 257 | continue; |
258 | 258 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $checksum = unserialize($checksum); |
276 | 276 | foreach ($check_files as $file) { |
277 | 277 | $file = trim($file); |
278 | - $filePath = MODX_BASE_PATH . $file; |
|
278 | + $filePath = MODX_BASE_PATH.$file; |
|
279 | 279 | if (!is_file($filePath)) { |
280 | 280 | continue; |
281 | 281 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | { |
295 | 295 | $modx = evolutionCMS(); |
296 | 296 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
297 | - $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')"; |
|
297 | + $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','".$modx->db->escape($checksum)."')"; |
|
298 | 298 | $modx->db->query($sql); |
299 | 299 | } |
300 | 300 | |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | foreach ($settings as $key => $val) { |
372 | 372 | $f = array(); |
373 | 373 | $f['user'] = $_SESSION['mgrInternalKey']; |
374 | - $f['setting_name'] = '_LAST_' . $key; |
|
374 | + $f['setting_name'] = '_LAST_'.$key; |
|
375 | 375 | $f['setting_value'] = $val; |
376 | 376 | $f = $modx->db->escape($f); |
377 | - $f = "(`" . implode("`, `", array_keys($f)) . "`) VALUES('" . implode("', '", array_values($f)) . "')"; |
|
377 | + $f = "(`".implode("`, `", array_keys($f))."`) VALUES('".implode("', '", array_values($f))."')"; |
|
378 | 378 | $f .= " ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)"; |
379 | 379 | $modx->db->insert($f, $modx->getFullTableName('user_settings')); |
380 | 380 | } |
@@ -1,8 +1,8 @@ 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')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/'); |
|
4 | 4 | |
5 | -class MODIFIERS { |
|
5 | +class MODIFIERS{ |
|
6 | 6 | /** |
7 | 7 | * @var array |
8 | 8 | */ |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @param string $modifiers |
71 | 71 | * @return bool|mixed|string |
72 | 72 | */ |
73 | - public function phxFilter($key,$value,$modifiers) |
|
73 | + public function phxFilter($key, $value, $modifiers) |
|
74 | 74 | { |
75 | 75 | $modx = evolutionCMS(); |
76 | - if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value); |
|
76 | + if (substr($modifiers, 0, 3) !== 'id(') $value = $this->parseDocumentSource($value); |
|
77 | 77 | $this->srcValue = $value; |
78 | 78 | $modifiers = trim($modifiers); |
79 | - $modifiers = ':'.trim($modifiers,':'); |
|
80 | - $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers); |
|
79 | + $modifiers = ':'.trim($modifiers, ':'); |
|
80 | + $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers); |
|
81 | 81 | $modifiers = $this->splitEachModifiers($modifiers); |
82 | 82 | |
83 | 83 | $this->placeholders = array(); |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | $this->placeholders['dummy'] = ''; |
86 | 86 | $this->condition = array(); |
87 | 87 | $this->vars = array(); |
88 | - $this->vars['name'] = & $key; |
|
89 | - $value = $this->parsePhx($key,$value,$modifiers); |
|
88 | + $this->vars['name'] = & $key; |
|
89 | + $value = $this->parsePhx($key, $value, $modifiers); |
|
90 | 90 | $this->vars = array(); |
91 | 91 | return $value; |
92 | 92 | } |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | * @param string $modifiers |
97 | 97 | * @return bool|string |
98 | 98 | */ |
99 | - public function _getDelim($mode,$modifiers) { |
|
100 | - $c = substr($modifiers,0,1); |
|
101 | - if(!in_array($c, array('"', "'", '`')) ) return false; |
|
99 | + public function _getDelim($mode, $modifiers){ |
|
100 | + $c = substr($modifiers, 0, 1); |
|
101 | + if (!in_array($c, array('"', "'", '`'))) return false; |
|
102 | 102 | |
103 | - $modifiers = substr($modifiers,1); |
|
104 | - $closure = $mode=='(' ? "{$c})" : $c; |
|
105 | - if(strpos($modifiers, $closure)===false) return false; |
|
103 | + $modifiers = substr($modifiers, 1); |
|
104 | + $closure = $mode == '(' ? "{$c})" : $c; |
|
105 | + if (strpos($modifiers, $closure) === false) return false; |
|
106 | 106 | |
107 | 107 | return $c; |
108 | 108 | } |
@@ -113,101 +113,101 @@ discard block |
||
113 | 113 | * @param string $modifiers |
114 | 114 | * @return bool|string |
115 | 115 | */ |
116 | - public function _getOpt($mode,$delim,$modifiers) { |
|
117 | - if($delim) { |
|
118 | - if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
116 | + public function _getOpt($mode, $delim, $modifiers){ |
|
117 | + if ($delim) { |
|
118 | + if ($mode == '(') return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1); |
|
119 | 119 | |
120 | - return substr($modifiers,1,strpos($modifiers,$delim,1)-1); |
|
120 | + return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1); |
|
121 | 121 | } |
122 | 122 | else { |
123 | - if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') ); |
|
123 | + if ($mode == '(') return substr($modifiers, 0, strpos($modifiers, ')')); |
|
124 | 124 | |
125 | 125 | $chars = str_split($modifiers); |
126 | - $opt=''; |
|
127 | - foreach($chars as $c) { |
|
128 | - if($c==':' || $c==')') break; |
|
129 | - $opt .=$c; |
|
126 | + $opt = ''; |
|
127 | + foreach ($chars as $c) { |
|
128 | + if ($c == ':' || $c == ')') break; |
|
129 | + $opt .= $c; |
|
130 | 130 | } |
131 | 131 | return $opt; |
132 | 132 | } |
133 | 133 | } |
134 | - public function _getRemainModifiers($mode,$delim,$modifiers) { |
|
135 | - if($delim) { |
|
136 | - if($mode=='(') |
|
137 | - return $this->_fetchContent($modifiers, $delim . ')'); |
|
134 | + public function _getRemainModifiers($mode, $delim, $modifiers){ |
|
135 | + if ($delim) { |
|
136 | + if ($mode == '(') |
|
137 | + return $this->_fetchContent($modifiers, $delim.')'); |
|
138 | 138 | else { |
139 | 139 | $modifiers = trim($modifiers); |
140 | - $modifiers = substr($modifiers,1); |
|
140 | + $modifiers = substr($modifiers, 1); |
|
141 | 141 | return $this->_fetchContent($modifiers, $delim); |
142 | 142 | } |
143 | 143 | } |
144 | 144 | else { |
145 | - if($mode=='(') return $this->_fetchContent($modifiers, ')'); |
|
145 | + if ($mode == '(') return $this->_fetchContent($modifiers, ')'); |
|
146 | 146 | $chars = str_split($modifiers); |
147 | - foreach($chars as $c) { |
|
148 | - if($c==':') return $modifiers; |
|
149 | - else $modifiers = substr($modifiers,1); |
|
147 | + foreach ($chars as $c) { |
|
148 | + if ($c == ':') return $modifiers; |
|
149 | + else $modifiers = substr($modifiers, 1); |
|
150 | 150 | } |
151 | 151 | return $modifiers; |
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | - public function _fetchContent($string,$delim) { |
|
155 | + public function _fetchContent($string, $delim){ |
|
156 | 156 | $len = strlen($delim); |
157 | 157 | $string = $this->parseDocumentSource($string); |
158 | - return substr($string,strpos($string, $delim)+$len); |
|
158 | + return substr($string, strpos($string, $delim) + $len); |
|
159 | 159 | } |
160 | 160 | |
161 | - public function splitEachModifiers($modifiers) { |
|
161 | + public function splitEachModifiers($modifiers){ |
|
162 | 162 | $modx = evolutionCMS(); |
163 | 163 | |
164 | 164 | $cmd = ''; |
165 | 165 | $bt = ''; |
166 | 166 | $result = array(); |
167 | - while($bt!==$modifiers) { |
|
167 | + while ($bt !== $modifiers) { |
|
168 | 168 | $bt = $modifiers; |
169 | - $c = substr($modifiers,0,1); |
|
170 | - $modifiers = substr($modifiers,1); |
|
169 | + $c = substr($modifiers, 0, 1); |
|
170 | + $modifiers = substr($modifiers, 1); |
|
171 | 171 | |
172 | - if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
173 | - $c = substr($modifiers,strlen($match[1]),1); |
|
172 | + if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
173 | + $c = substr($modifiers, strlen($match[1]), 1); |
|
174 | 174 | $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])); |
|
175 | + if ($c === '(') $modifiers = substr($modifiers, strlen($match[1]) + 1); |
|
176 | + else $modifiers = substr($modifiers, strlen($match[1])); |
|
177 | 177 | |
178 | - $delim = $this->_getDelim($c,$modifiers); |
|
179 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
180 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
178 | + $delim = $this->_getDelim($c, $modifiers); |
|
179 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
180 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
181 | 181 | |
182 | - $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
182 | + $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
183 | 183 | $cmd = ''; |
184 | 184 | } |
185 | - elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
186 | - $modifiers = substr($modifiers,strlen($match[0])); |
|
187 | - $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]); |
|
185 | + elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
186 | + $modifiers = substr($modifiers, strlen($match[0])); |
|
187 | + $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]); |
|
188 | 188 | $cmd = ''; |
189 | 189 | } |
190 | - elseif($c==='(' || $c==='=') { |
|
190 | + elseif ($c === '(' || $c === '=') { |
|
191 | 191 | $modifiers = $m1 = trim($modifiers); |
192 | - $delim = $this->_getDelim($c,$modifiers); |
|
193 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
194 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
192 | + $delim = $this->_getDelim($c, $modifiers); |
|
193 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
194 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
195 | 195 | $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]"; |
196 | 196 | |
197 | - $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
197 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
198 | 198 | |
199 | 199 | $cmd = ''; |
200 | 200 | } |
201 | - elseif($c==':') { |
|
201 | + elseif ($c == ':') { |
|
202 | 202 | $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]"; |
203 | - if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
203 | + if ($cmd !== '') $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
204 | 204 | |
205 | 205 | $cmd = ''; |
206 | 206 | } |
207 | - elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
207 | + elseif (trim($modifiers) == '' && trim($cmd) !== '') { |
|
208 | 208 | $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]"; |
209 | 209 | $cmd .= $c; |
210 | - $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
210 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
211 | 211 | |
212 | 212 | break; |
213 | 213 | } |
@@ -216,65 +216,65 @@ discard block |
||
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | - if(empty($result)) return array(); |
|
219 | + if (empty($result)) return array(); |
|
220 | 220 | |
221 | - foreach($result as $i=>$a) |
|
221 | + foreach ($result as $i=>$a) |
|
222 | 222 | { |
223 | 223 | $a['opt'] = $this->parseDocumentSource($a['opt']); |
224 | - $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders); |
|
224 | + $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'], $this->placeholders); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $result; |
228 | 228 | } |
229 | 229 | |
230 | - public function parsePhx($key,$value,$modifiers) |
|
230 | + public function parsePhx($key, $value, $modifiers) |
|
231 | 231 | { |
232 | 232 | $modx = evolutionCMS(); |
233 | 233 | $lastKey = ''; |
234 | - $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 ''; |
|
234 | + $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 ''; |
|
237 | 237 | |
238 | - foreach($modifiers as $m) |
|
238 | + foreach ($modifiers as $m) |
|
239 | 239 | { |
240 | 240 | $lastKey = strtolower($m['cmd']); |
241 | 241 | } |
242 | - $_ = explode(',',$this->condModifiers); |
|
243 | - if(in_array($lastKey,$_)) |
|
242 | + $_ = explode(',', $this->condModifiers); |
|
243 | + if (in_array($lastKey, $_)) |
|
244 | 244 | { |
245 | - $modifiers[] = array('cmd'=>'then','opt'=>'1'); |
|
246 | - $modifiers[] = array('cmd'=>'else','opt'=>'0'); |
|
245 | + $modifiers[] = array('cmd'=>'then', 'opt'=>'1'); |
|
246 | + $modifiers[] = array('cmd'=>'else', 'opt'=>'0'); |
|
247 | 247 | } |
248 | 248 | |
249 | - foreach($modifiers as $i=>$a) |
|
249 | + foreach ($modifiers as $i=>$a) |
|
250 | 250 | { |
251 | - $value = $this->Filter($key,$value, $a['cmd'], $a['opt']); |
|
251 | + $value = $this->Filter($key, $value, $a['cmd'], $a['opt']); |
|
252 | 252 | } |
253 | 253 | $this->tmpCache[$cacheKey] = $value; |
254 | 254 | return $value; |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Parser: modifier detection and eXtended processing if needed |
258 | - public function Filter($key, $value, $cmd, $opt='') |
|
258 | + public function Filter($key, $value, $cmd, $opt = '') |
|
259 | 259 | { |
260 | 260 | $modx = evolutionCMS(); |
261 | 261 | |
262 | - if($key==='documentObject') $value = $modx->documentIdentifier; |
|
262 | + if ($key === 'documentObject') $value = $modx->documentIdentifier; |
|
263 | 263 | $cmd = $this->parseDocumentSource($cmd); |
264 | - if(preg_match('@^[1-9][/0-9]*$@',$cmd)) |
|
264 | + if (preg_match('@^[1-9][/0-9]*$@', $cmd)) |
|
265 | 265 | { |
266 | - if(strpos($cmd,'/')!==false) |
|
267 | - $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
266 | + if (strpos($cmd, '/') !== false) |
|
267 | + $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1); |
|
268 | 268 | $opt = $cmd; |
269 | 269 | $cmd = 'id'; |
270 | 270 | } |
271 | 271 | |
272 | - if(isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
273 | - elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
272 | + if (isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
273 | + elseif (isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
274 | 274 | else $this->elmName = ''; |
275 | 275 | |
276 | 276 | $cmd = strtolower($cmd); |
277 | - if($this->elmName!=='') |
|
277 | + if ($this->elmName !== '') |
|
278 | 278 | $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
279 | 279 | else |
280 | 280 | $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | return $value; |
285 | 285 | } |
286 | 286 | |
287 | - public function isEmpty($cmd,$value) |
|
287 | + public function isEmpty($cmd, $value) |
|
288 | 288 | { |
289 | - if($value!=='') return false; |
|
289 | + if ($value !== '') return false; |
|
290 | 290 | |
291 | - $_ = 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; |
|
291 | + $_ = 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 | 293 | else return true; |
294 | 294 | } |
295 | 295 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | { |
298 | 298 | $modx = evolutionCMS(); |
299 | 299 | |
300 | - if($this->isEmpty($cmd,$value)) return ''; |
|
300 | + if ($this->isEmpty($cmd, $value)) return ''; |
|
301 | 301 | |
302 | 302 | $this->key = $key; |
303 | 303 | $this->value = $value; |
@@ -308,83 +308,83 @@ discard block |
||
308 | 308 | ##### Conditional Modifiers |
309 | 309 | case 'input': |
310 | 310 | case 'if': |
311 | - if(!$opt) return $value; |
|
311 | + if (!$opt) return $value; |
|
312 | 312 | return $opt; |
313 | 313 | case '=': |
314 | 314 | case 'eq': |
315 | 315 | case 'is': |
316 | 316 | case 'equals': |
317 | - $this->condition[] = (int)($value == $opt); break; |
|
317 | + $this->condition[] = (int) ($value == $opt); break; |
|
318 | 318 | case 'neq': |
319 | 319 | case 'ne': |
320 | 320 | case 'notequals': |
321 | 321 | case 'isnot': |
322 | 322 | case 'isnt': |
323 | 323 | case 'not': |
324 | - $this->condition[] = (int)($value != $opt);break; |
|
324 | + $this->condition[] = (int) ($value != $opt); break; |
|
325 | 325 | case '%': |
326 | - $this->condition[] = (int)($value%$opt==0);break; |
|
326 | + $this->condition[] = (int) ($value % $opt == 0); break; |
|
327 | 327 | case 'isempty': |
328 | - $this->condition[] = (int)(empty($value)); break; |
|
328 | + $this->condition[] = (int) (empty($value)); break; |
|
329 | 329 | case 'isntempty': |
330 | 330 | case 'isnotempty': |
331 | - $this->condition[] = (int)(!empty($value)); break; |
|
331 | + $this->condition[] = (int) (!empty($value)); break; |
|
332 | 332 | case '>=': |
333 | 333 | case 'gte': |
334 | 334 | case 'eg': |
335 | 335 | case 'isgte': |
336 | - $this->condition[] = (int)($value >= $opt);break; |
|
336 | + $this->condition[] = (int) ($value >= $opt); break; |
|
337 | 337 | case '<=': |
338 | 338 | case 'lte': |
339 | 339 | case 'el': |
340 | 340 | case 'islte': |
341 | - $this->condition[] = (int)($value <= $opt);break; |
|
341 | + $this->condition[] = (int) ($value <= $opt); break; |
|
342 | 342 | case '>': |
343 | 343 | case 'gt': |
344 | 344 | case 'greaterthan': |
345 | 345 | case 'isgreaterthan': |
346 | 346 | case 'isgt': |
347 | - $this->condition[] = (int)($value > $opt);break; |
|
347 | + $this->condition[] = (int) ($value > $opt); break; |
|
348 | 348 | case '<': |
349 | 349 | case 'lt': |
350 | 350 | case 'lowerthan': |
351 | 351 | case 'islowerthan': |
352 | 352 | case 'islt': |
353 | - $this->condition[] = (int)($value < $opt);break; |
|
353 | + $this->condition[] = (int) ($value < $opt); break; |
|
354 | 354 | case 'find': |
355 | - $this->condition[] = (int)(strpos($value, $opt)!==false);break; |
|
355 | + $this->condition[] = (int) (strpos($value, $opt) !== false); break; |
|
356 | 356 | case 'inarray': |
357 | 357 | case 'in_array': |
358 | 358 | case 'in': |
359 | 359 | $opt = explode(',', $opt); |
360 | - $this->condition[] = (int)(in_array($value, $opt)!==false);break; |
|
360 | + $this->condition[] = (int) (in_array($value, $opt) !== false); break; |
|
361 | 361 | case 'wildcard_match': |
362 | 362 | case 'wcard_match': |
363 | 363 | case 'wildcard': |
364 | 364 | case 'wcard': |
365 | 365 | case 'fnmatch': |
366 | - $this->condition[] = (int)(fnmatch($opt, $value)!==false);break; |
|
366 | + $this->condition[] = (int) (fnmatch($opt, $value) !== false); break; |
|
367 | 367 | case 'is_file': |
368 | 368 | case 'is_dir': |
369 | 369 | case 'file_exists': |
370 | 370 | case 'is_readable': |
371 | 371 | case 'is_writable': |
372 | - if(!$opt) $path = $value; |
|
372 | + if (!$opt) $path = $value; |
|
373 | 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,'/'); |
|
376 | - $this->condition[] = (int)($cmd($path)!==false);break; |
|
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, '/'); |
|
376 | + $this->condition[] = (int) ($cmd($path) !== false); break; |
|
377 | 377 | case 'is_image': |
378 | - if(!$opt) $path = $value; |
|
378 | + if (!$opt) $path = $value; |
|
379 | 379 | else $path = $opt; |
380 | - if(!is_file($path)) {$this->condition[]='0';break;} |
|
380 | + if (!is_file($path)) {$this->condition[] = '0'; break; } |
|
381 | 381 | $_ = getimagesize($path); |
382 | - $this->condition[] = (int)($_[0]);break; |
|
382 | + $this->condition[] = (int) ($_[0]); break; |
|
383 | 383 | case 'regex': |
384 | 384 | case 'preg': |
385 | 385 | case 'preg_match': |
386 | 386 | case 'isinrole': |
387 | - $this->condition[] = (int)(preg_match($opt,$value));break; |
|
387 | + $this->condition[] = (int) (preg_match($opt, $value)); break; |
|
388 | 388 | case 'ir': |
389 | 389 | case 'memberof': |
390 | 390 | case 'mo': |
@@ -392,50 +392,50 @@ discard block |
||
392 | 392 | $this->condition[] = $this->includeMdfFile('memberof'); |
393 | 393 | break; |
394 | 394 | case 'or': |
395 | - $this->condition[] = '||';break; |
|
395 | + $this->condition[] = '||'; break; |
|
396 | 396 | case 'and': |
397 | - $this->condition[] = '&&';break; |
|
397 | + $this->condition[] = '&&'; break; |
|
398 | 398 | case 'show': |
399 | 399 | case 'this': |
400 | - $conditional = implode(' ',$this->condition); |
|
401 | - $isvalid = (int)(eval("return ({$conditional});")); |
|
400 | + $conditional = implode(' ', $this->condition); |
|
401 | + $isvalid = (int) (eval("return ({$conditional});")); |
|
402 | 402 | if ($isvalid) return $this->srcValue; |
403 | 403 | return NULL; |
404 | 404 | case 'then': |
405 | - $conditional = implode(' ',$this->condition); |
|
406 | - $isvalid = (int)eval("return ({$conditional});"); |
|
405 | + $conditional = implode(' ', $this->condition); |
|
406 | + $isvalid = (int) eval("return ({$conditional});"); |
|
407 | 407 | if ($isvalid) return $opt; |
408 | 408 | return null; |
409 | 409 | case 'else': |
410 | - $conditional = implode(' ',$this->condition); |
|
411 | - $isvalid = (int)eval("return ({$conditional});"); |
|
410 | + $conditional = implode(' ', $this->condition); |
|
411 | + $isvalid = (int) eval("return ({$conditional});"); |
|
412 | 412 | if (!$isvalid) return $opt; |
413 | 413 | break; |
414 | 414 | case 'select': |
415 | 415 | case 'switch': |
416 | - $raw = explode('&',$opt); |
|
416 | + $raw = explode('&', $opt); |
|
417 | 417 | $map = array(); |
418 | 418 | $c = count($raw); |
419 | - for($m=0; $m<$c; $m++) { |
|
420 | - $mi = explode('=',$raw[$m],2); |
|
419 | + for ($m = 0; $m < $c; $m++) { |
|
420 | + $mi = explode('=', $raw[$m], 2); |
|
421 | 421 | $map[$mi[0]] = $mi[1]; |
422 | 422 | } |
423 | - if(isset($map[$value])) return $map[$value]; |
|
423 | + if (isset($map[$value])) return $map[$value]; |
|
424 | 424 | else return ''; |
425 | 425 | ##### End of Conditional Modifiers |
426 | 426 | |
427 | 427 | ##### Encode / Decode / Hash / Escape |
428 | 428 | case 'htmlent': |
429 | 429 | case 'htmlentities': |
430 | - return htmlentities($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
430 | + return htmlentities($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
431 | 431 | case 'html_entity_decode': |
432 | 432 | case 'decode_html': |
433 | 433 | case 'html_decode': |
434 | - return html_entity_decode($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
434 | + return html_entity_decode($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
435 | 435 | case 'esc': |
436 | 436 | case 'escape': |
437 | 437 | $value = preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
438 | - return str_replace(array('[', ']', '`'),array('[', ']', '`'),$value); |
|
438 | + return str_replace(array('[', ']', '`'), array('[', ']', '`'), $value); |
|
439 | 439 | case 'sql_escape': |
440 | 440 | case 'encode_js': |
441 | 441 | return $modx->db->escape($value); |
@@ -445,39 +445,39 @@ discard block |
||
445 | 445 | case 'html_encode': |
446 | 446 | return preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
447 | 447 | case 'spam_protect': |
448 | - return str_replace(array('@','.'),array('@','.'),$value); |
|
448 | + return str_replace(array('@', '.'), array('@', '.'), $value); |
|
449 | 449 | case 'strip': |
450 | - if($opt==='') $opt = ' '; |
|
450 | + if ($opt === '') $opt = ' '; |
|
451 | 451 | return preg_replace('/[\n\r\t\s]+/', $opt, $value); |
452 | 452 | case 'strip_linefeeds': |
453 | - return str_replace(array("\n","\r"), '', $value); |
|
453 | + return str_replace(array("\n", "\r"), '', $value); |
|
454 | 454 | case 'notags': |
455 | 455 | case 'strip_tags': |
456 | 456 | case 'remove_html': |
457 | - if($opt!=='') |
|
457 | + if ($opt !== '') |
|
458 | 458 | { |
459 | 459 | $param = array(); |
460 | - foreach(explode(',',$opt) as $v) |
|
460 | + foreach (explode(',', $opt) as $v) |
|
461 | 461 | { |
462 | - $v = trim($v,'</> '); |
|
462 | + $v = trim($v, '</> '); |
|
463 | 463 | $param[] = "<{$v}>"; |
464 | 464 | } |
465 | - $params = implode(',',$param); |
|
465 | + $params = implode(',', $param); |
|
466 | 466 | } |
467 | 467 | else $params = ''; |
468 | - if(!strpos($params,'<br>')===false) { |
|
469 | - $value = preg_replace('@(<br[ /]*>)\n@','$1',$value); |
|
470 | - $value = preg_replace('@<br[ /]*>@',"\n",$value); |
|
468 | + if (!strpos($params, '<br>') === false) { |
|
469 | + $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value); |
|
470 | + $value = preg_replace('@<br[ /]*>@', "\n", $value); |
|
471 | 471 | } |
472 | - return $this->strip_tags($value,$params); |
|
472 | + return $this->strip_tags($value, $params); |
|
473 | 473 | case 'urlencode': |
474 | 474 | case 'url_encode': |
475 | 475 | case 'encode_url': |
476 | 476 | return urlencode($value); |
477 | 477 | case 'base64_decode': |
478 | - if($opt!=='false') $opt = true; |
|
478 | + if ($opt !== 'false') $opt = true; |
|
479 | 479 | else $opt = false; |
480 | - return base64_decode($value,$opt); |
|
480 | + return base64_decode($value, $opt); |
|
481 | 481 | case 'encode_sha1': $cmd = 'sha1'; |
482 | 482 | case 'addslashes': |
483 | 483 | case 'urldecode': |
@@ -501,18 +501,18 @@ discard block |
||
501 | 501 | case 'upper_case': |
502 | 502 | return $this->strtoupper($value); |
503 | 503 | case 'capitalize': |
504 | - $_ = explode(' ',$value); |
|
505 | - foreach($_ as $i=>$v) |
|
504 | + $_ = explode(' ', $value); |
|
505 | + foreach ($_ as $i=>$v) |
|
506 | 506 | { |
507 | 507 | $_[$i] = ucfirst($v); |
508 | 508 | } |
509 | - return implode(' ',$_); |
|
509 | + return implode(' ', $_); |
|
510 | 510 | case 'zenhan': |
511 | - if(empty($opt)) $opt='VKas'; |
|
512 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
511 | + if (empty($opt)) $opt = 'VKas'; |
|
512 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
513 | 513 | case 'hanzen': |
514 | - if(empty($opt)) $opt='VKAS'; |
|
515 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
514 | + if (empty($opt)) $opt = 'VKAS'; |
|
515 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
516 | 516 | case 'str_shuffle': |
517 | 517 | case 'shuffle': |
518 | 518 | return $this->str_shuffle($value); |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | return $this->strlen($value); |
527 | 527 | case 'count_words': |
528 | 528 | $value = trim($value); |
529 | - return count(preg_split('/\s+/',$value)); |
|
529 | + return count(preg_split('/\s+/', $value)); |
|
530 | 530 | case 'str_word_count': |
531 | 531 | case 'word_count': |
532 | 532 | case 'wordcount': |
@@ -534,55 +534,55 @@ discard block |
||
534 | 534 | case 'count_paragraphs': |
535 | 535 | $value = trim($value); |
536 | 536 | $value = preg_replace('/\r/', '', $value); |
537 | - return count(preg_split('/\n+/',$value)); |
|
537 | + return count(preg_split('/\n+/', $value)); |
|
538 | 538 | case 'strpos': |
539 | - if($opt!=0&&empty($opt)) return $value; |
|
540 | - return $this->strpos($value,$opt); |
|
539 | + if ($opt != 0 && empty($opt)) return $value; |
|
540 | + return $this->strpos($value, $opt); |
|
541 | 541 | case 'wordwrap': |
542 | 542 | // default: 70 |
543 | - $wrapat = (int)$opt > 0 ? (int)$opt : 70; |
|
543 | + $wrapat = (int) $opt > 0 ? (int) $opt : 70; |
|
544 | 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); |
|
545 | + else return preg_replace("@(\b\w+\b)@e", "wordwrap('\\1',\$wrapat,' ',1)", $value); |
|
546 | 546 | case 'wrap_text': |
547 | - $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70; |
|
548 | - if($modx->config['manager_language']==='japanese-utf8') { |
|
547 | + $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70; |
|
548 | + if ($modx->config['manager_language'] === 'japanese-utf8') { |
|
549 | 549 | $chunk = array(); |
550 | - $bt=''; |
|
551 | - while($bt!=$value) { |
|
550 | + $bt = ''; |
|
551 | + while ($bt != $value) { |
|
552 | 552 | $bt = $value; |
553 | - if($this->strlen($value)<$width) { |
|
553 | + if ($this->strlen($value) < $width) { |
|
554 | 554 | $chunk[] = $value; |
555 | 555 | break; |
556 | 556 | } |
557 | - $chunk[] = $this->substr($value,0,$width); |
|
558 | - $value = $this->substr($value,$width); |
|
557 | + $chunk[] = $this->substr($value, 0, $width); |
|
558 | + $value = $this->substr($value, $width); |
|
559 | 559 | } |
560 | - return implode("\n",$chunk); |
|
560 | + return implode("\n", $chunk); |
|
561 | 561 | } |
562 | 562 | else |
563 | - return wordwrap($value,$width,"\n",true); |
|
563 | + return wordwrap($value, $width, "\n", true); |
|
564 | 564 | case 'substr': |
565 | - if(empty($opt)) break; |
|
566 | - if(strpos($opt,',')!==false) { |
|
567 | - list($b,$e) = explode(',',$opt,2); |
|
568 | - return $this->substr($value,$b,(int)$e); |
|
565 | + if (empty($opt)) break; |
|
566 | + if (strpos($opt, ',') !== false) { |
|
567 | + list($b, $e) = explode(',', $opt, 2); |
|
568 | + return $this->substr($value, $b, (int) $e); |
|
569 | 569 | } |
570 | - else return $this->substr($value,$opt); |
|
570 | + else return $this->substr($value, $opt); |
|
571 | 571 | case 'limit': |
572 | 572 | 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); |
|
573 | + if (strpos($opt, '+') !== false) |
|
574 | + list($len, $str) = explode('+', $opt, 2); |
|
575 | 575 | else { |
576 | 576 | $len = $opt; |
577 | 577 | $str = ''; |
578 | 578 | } |
579 | - if($len==='') $len = 100; |
|
580 | - if(abs($len) > $this->strlen($value)) $str =''; |
|
581 | - if(preg_match('/^[1-9][0-9]*$/',$len)) { |
|
582 | - return $this->substr($value,0,$len) . $str; |
|
579 | + if ($len === '') $len = 100; |
|
580 | + if (abs($len) > $this->strlen($value)) $str = ''; |
|
581 | + if (preg_match('/^[1-9][0-9]*$/', $len)) { |
|
582 | + return $this->substr($value, 0, $len).$str; |
|
583 | 583 | } |
584 | - elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
585 | - return $str . $this->substr($value,$len); |
|
584 | + elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) { |
|
585 | + return $str.$this->substr($value, $len); |
|
586 | 586 | } |
587 | 587 | break; |
588 | 588 | case 'summary': |
@@ -591,81 +591,81 @@ discard block |
||
591 | 591 | return $this->includeMdfFile('summary'); |
592 | 592 | case 'replace': |
593 | 593 | 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 = '/'; |
|
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 | 599 | else break; |
600 | - list($s,$r) = explode($delim,$opt); |
|
601 | - if($value!=='') return str_replace($s,$r,$value); |
|
600 | + list($s, $r) = explode($delim, $opt); |
|
601 | + if ($value !== '') return str_replace($s, $r, $value); |
|
602 | 602 | break; |
603 | 603 | case 'replace_to': |
604 | 604 | case 'tpl': |
605 | - if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
605 | + if ($value !== '') return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt); |
|
606 | 606 | break; |
607 | 607 | case 'eachtpl': |
608 | - $value = explode('||',$value); |
|
608 | + $value = explode('||', $value); |
|
609 | 609 | $_ = array(); |
610 | - foreach($value as $v) { |
|
611 | - $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'),$v,$opt); |
|
610 | + foreach ($value as $v) { |
|
611 | + $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt); |
|
612 | 612 | } |
613 | 613 | return implode("\n", $_); |
614 | 614 | case 'array_pop': |
615 | 615 | case 'array_shift': |
616 | - if(strpos($value,'||')!==false) $delim = '||'; |
|
616 | + if (strpos($value, '||') !== false) $delim = '||'; |
|
617 | 617 | else $delim = ','; |
618 | - return $cmd(explode($delim,$value)); |
|
618 | + return $cmd(explode($delim, $value)); |
|
619 | 619 | case 'preg_replace': |
620 | 620 | case 'regex_replace': |
621 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
622 | - list($s,$r) = explode(',',$opt,2); |
|
623 | - if($value!=='') return preg_replace($s,$r,$value); |
|
621 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
622 | + list($s, $r) = explode(',', $opt, 2); |
|
623 | + if ($value !== '') return preg_replace($s, $r, $value); |
|
624 | 624 | break; |
625 | 625 | case 'cat': |
626 | 626 | case 'concatenate': |
627 | 627 | case '.': |
628 | - if($value!=='') return $value . $opt; |
|
628 | + if ($value !== '') return $value.$opt; |
|
629 | 629 | break; |
630 | 630 | case 'sprintf': |
631 | 631 | case 'string_format': |
632 | - if($value!=='') return sprintf($opt,$value); |
|
632 | + if ($value !== '') return sprintf($opt, $value); |
|
633 | 633 | break; |
634 | 634 | case 'number_format': |
635 | - if($opt=='') $opt = 0; |
|
636 | - return number_format($value,$opt); |
|
635 | + if ($opt == '') $opt = 0; |
|
636 | + return number_format($value, $opt); |
|
637 | 637 | case 'money_format': |
638 | - setlocale(LC_MONETARY,setlocale(LC_TIME,0)); |
|
639 | - if($value!=='') return money_format($opt,(double)$value); |
|
638 | + setlocale(LC_MONETARY, setlocale(LC_TIME, 0)); |
|
639 | + if ($value !== '') return money_format($opt, (double) $value); |
|
640 | 640 | break; |
641 | 641 | case 'tobool': |
642 | 642 | return boolval($value); |
643 | 643 | case 'nl2lf': |
644 | - if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
644 | + if ($value !== '') return str_replace(array("\r\n", "\n", "\r"), '\n', $value); |
|
645 | 645 | break; |
646 | 646 | case 'br2nl': |
647 | 647 | return preg_replace('@<br[\s/]*>@i', "\n", $value); |
648 | 648 | case 'nl2br': |
649 | 649 | if (version_compare(PHP_VERSION, '5.3.0', '<')) |
650 | 650 | return nl2br($value); |
651 | - if($opt!=='') |
|
651 | + if ($opt !== '') |
|
652 | 652 | { |
653 | 653 | $opt = trim($opt); |
654 | 654 | $opt = strtolower($opt); |
655 | - if($opt==='false') $opt = false; |
|
656 | - elseif($opt==='0') $opt = false; |
|
655 | + if ($opt === 'false') $opt = false; |
|
656 | + elseif ($opt === '0') $opt = false; |
|
657 | 657 | else $opt = true; |
658 | 658 | } |
659 | - elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') |
|
659 | + elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html') |
|
660 | 660 | $opt = false; |
661 | 661 | else $opt = true; |
662 | - return nl2br($value,$opt); |
|
662 | + return nl2br($value, $opt); |
|
663 | 663 | case 'ltrim': |
664 | 664 | case 'rtrim': |
665 | 665 | case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html |
666 | - if($opt==='') |
|
666 | + if ($opt === '') |
|
667 | 667 | return $cmd($value); |
668 | - else return $cmd($value,$opt); |
|
668 | + else return $cmd($value, $opt); |
|
669 | 669 | // These are all straight wrappers for PHP functions |
670 | 670 | case 'ucfirst': |
671 | 671 | case 'lcfirst': |
@@ -676,58 +676,58 @@ discard block |
||
676 | 676 | case 'strftime': |
677 | 677 | case 'date': |
678 | 678 | 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); |
|
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 | 683 | else |
684 | - return date($opt,0+$value); |
|
684 | + return date($opt, 0 + $value); |
|
685 | 685 | case 'time': |
686 | - if(empty($opt)) $opt = '%H:%M'; |
|
687 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
688 | - return strftime($opt,0+$value); |
|
686 | + if (empty($opt)) $opt = '%H:%M'; |
|
687 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
688 | + return strftime($opt, 0 + $value); |
|
689 | 689 | case 'strtotime': |
690 | 690 | return strtotime($value); |
691 | 691 | ##### mathematical function |
692 | 692 | case 'toint': |
693 | - return (int)$value; |
|
693 | + return (int) $value; |
|
694 | 694 | case 'tofloat': |
695 | 695 | return floatval($value); |
696 | 696 | case 'round': |
697 | - if(!$opt) $opt = 0; |
|
698 | - return $cmd($value,$opt); |
|
697 | + if (!$opt) $opt = 0; |
|
698 | + return $cmd($value, $opt); |
|
699 | 699 | case 'max': |
700 | 700 | case 'min': |
701 | - return $cmd(explode(',',$value)); |
|
701 | + return $cmd(explode(',', $value)); |
|
702 | 702 | case 'floor': |
703 | 703 | case 'ceil': |
704 | 704 | case 'abs': |
705 | 705 | return $cmd($value); |
706 | 706 | case 'math': |
707 | 707 | case 'calc': |
708 | - $value = (int)$value; |
|
709 | - if(empty($value)) $value = '0'; |
|
710 | - $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt); |
|
711 | - $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter); |
|
712 | - if(strpos($filter,'?')===false) $filter = "?{$filter}"; |
|
713 | - $filter = str_replace('?',$value,$filter); |
|
708 | + $value = (int) $value; |
|
709 | + if (empty($value)) $value = '0'; |
|
710 | + $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt); |
|
711 | + $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter); |
|
712 | + if (strpos($filter, '?') === false) $filter = "?{$filter}"; |
|
713 | + $filter = str_replace('?', $value, $filter); |
|
714 | 714 | return eval("return {$filter};"); |
715 | 715 | case 'count': |
716 | - if($value=='') return 0; |
|
717 | - $value = explode(',',$value); |
|
716 | + if ($value == '') return 0; |
|
717 | + $value = explode(',', $value); |
|
718 | 718 | return count($value); |
719 | 719 | case 'sort': |
720 | 720 | case 'rsort': |
721 | - if(strpos($value,"\n")!==false) $delim="\n"; |
|
721 | + if (strpos($value, "\n") !== false) $delim = "\n"; |
|
722 | 722 | else $delim = ','; |
723 | - $swap = explode($delim,$value); |
|
724 | - if(!$opt) $opt = SORT_REGULAR; |
|
723 | + $swap = explode($delim, $value); |
|
724 | + if (!$opt) $opt = SORT_REGULAR; |
|
725 | 725 | else $opt = constant($opt); |
726 | - $cmd($swap,$opt); |
|
727 | - return implode($delim,$swap); |
|
726 | + $cmd($swap, $opt); |
|
727 | + return implode($delim, $swap); |
|
728 | 728 | ##### Resource fields |
729 | 729 | case 'id': |
730 | - if($opt) return $this->getDocumentObject($opt,$key); |
|
730 | + if ($opt) return $this->getDocumentObject($opt, $key); |
|
731 | 731 | break; |
732 | 732 | case 'type': |
733 | 733 | case 'contenttype': |
@@ -764,36 +764,36 @@ discard block |
||
764 | 764 | case 'privatemgr': |
765 | 765 | case 'content_dispo': |
766 | 766 | case 'hidemenu': |
767 | - if($cmd==='contenttype') $cmd = 'contentType'; |
|
768 | - return $this->getDocumentObject($value,$cmd); |
|
767 | + if ($cmd === 'contenttype') $cmd = 'contentType'; |
|
768 | + return $this->getDocumentObject($value, $cmd); |
|
769 | 769 | case 'title': |
770 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
771 | - $longtitle = $this->getDocumentObject($value,'longtitle'); |
|
770 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
771 | + $longtitle = $this->getDocumentObject($value, 'longtitle'); |
|
772 | 772 | return $longtitle ? $longtitle : $pagetitle; |
773 | 773 | case 'shorttitle': |
774 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
775 | - $menutitle = $this->getDocumentObject($value,'menutitle'); |
|
774 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
775 | + $menutitle = $this->getDocumentObject($value, 'menutitle'); |
|
776 | 776 | return $menutitle ? $menutitle : $pagetitle; |
777 | 777 | case 'templatename': |
778 | - $rs = $modx->db->select('templatename','[+prefix+]site_templates',"id='{$value}'"); |
|
778 | + $rs = $modx->db->select('templatename', '[+prefix+]site_templates', "id='{$value}'"); |
|
779 | 779 | $templateName = $modx->db->getValue($rs); |
780 | 780 | return !$templateName ? '(blank)' : $templateName; |
781 | 781 | case 'getfield': |
782 | - if(!$opt) $opt = 'content'; |
|
783 | - return $modx->getField($opt,$value); |
|
782 | + if (!$opt) $opt = 'content'; |
|
783 | + return $modx->getField($opt, $value); |
|
784 | 784 | case 'children': |
785 | 785 | case 'childids': |
786 | - if($value=='') $value = 0; // 値がない場合はルートと見なす |
|
786 | + if ($value == '') $value = 0; // 値がない場合はルートと見なす |
|
787 | 787 | $published = 1; |
788 | - if($opt=='') $opt = 'page'; |
|
789 | - $_ = explode(',',$opt); |
|
788 | + if ($opt == '') $opt = 'page'; |
|
789 | + $_ = explode(',', $opt); |
|
790 | 790 | $where = array(); |
791 | - foreach($_ as $opt) { |
|
792 | - switch(trim($opt)) { |
|
791 | + foreach ($_ as $opt) { |
|
792 | + switch (trim($opt)) { |
|
793 | 793 | case 'page'; case '!folder'; case '!isfolder': $where[] = 'sc.isfolder=0'; break; |
794 | 794 | case 'folder'; case 'isfolder': $where[] = 'sc.isfolder=1'; break; |
795 | - case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
796 | - case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
795 | + case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
796 | + case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
797 | 797 | case 'published': $published = 1; break; |
798 | 798 | case '!published': $published = 0; break; |
799 | 799 | } |
@@ -801,69 +801,69 @@ discard block |
||
801 | 801 | $where = implode(' AND ', $where); |
802 | 802 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); |
803 | 803 | $result = array(); |
804 | - foreach((array)$children as $child){ |
|
804 | + foreach ((array) $children as $child) { |
|
805 | 805 | $result[] = $child['id']; |
806 | 806 | } |
807 | 807 | return implode(',', $result); |
808 | 808 | case 'fullurl': |
809 | - if(!is_numeric($value)) return $value; |
|
809 | + if (!is_numeric($value)) return $value; |
|
810 | 810 | return $modx->makeUrl($value); |
811 | 811 | case 'makeurl': |
812 | - if(!is_numeric($value)) return $value; |
|
813 | - if(!$opt) $opt = 'full'; |
|
814 | - return $modx->makeUrl($value,'','',$opt); |
|
812 | + if (!is_numeric($value)) return $value; |
|
813 | + if (!$opt) $opt = 'full'; |
|
814 | + return $modx->makeUrl($value, '', '', $opt); |
|
815 | 815 | |
816 | 816 | ##### File system |
817 | 817 | case 'getimageinfo': |
818 | 818 | case 'imageinfo': |
819 | - if(!is_file($value)) return ''; |
|
819 | + if (!is_file($value)) return ''; |
|
820 | 820 | $_ = getimagesize($value); |
821 | - if(!$_[0]) return ''; |
|
821 | + if (!$_[0]) return ''; |
|
822 | 822 | $info['width'] = $_[0]; |
823 | 823 | $info['height'] = $_[1]; |
824 | - if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
825 | - elseif($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
824 | + if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
825 | + elseif ($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
826 | 826 | else $info['aspect'] = 'square'; |
827 | - switch($_[2]) { |
|
827 | + switch ($_[2]) { |
|
828 | 828 | case IMAGETYPE_GIF : $info['type'] = 'gif'; break; |
829 | 829 | case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break; |
830 | 830 | case IMAGETYPE_PNG : $info['type'] = 'png'; break; |
831 | 831 | default : $info['type'] = 'unknown'; |
832 | 832 | } |
833 | 833 | $info['attrib'] = $_[3]; |
834 | - switch($opt) { |
|
834 | + switch ($opt) { |
|
835 | 835 | case 'width' : return $info['width']; |
836 | 836 | case 'height': return $info['height']; |
837 | 837 | case 'aspect': return $info['aspect']; |
838 | 838 | case 'type' : return $info['type']; |
839 | 839 | case 'attrib': return $info['attrib']; |
840 | - default : return print_r($info,true); |
|
840 | + default : return print_r($info, true); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | case 'file_get_contents': |
844 | 844 | case 'readfile': |
845 | - if(!is_file($value)) return $value; |
|
845 | + if (!is_file($value)) return $value; |
|
846 | 846 | $value = realpath($value); |
847 | - if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file'); |
|
848 | - $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'); |
|
847 | + if (strpos($value, MODX_MANAGER_PATH) !== false) exit('Can not read core file'); |
|
848 | + $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'); |
|
851 | 851 | return file_get_contents($value); |
852 | 852 | case 'filesize': |
853 | - if($value == '') return ''; |
|
853 | + if ($value == '') return ''; |
|
854 | 854 | $filename = $value; |
855 | 855 | |
856 | 856 | $site_url = $modx->config['site_url']; |
857 | - if(strpos($filename,$site_url) === 0) |
|
858 | - $filename = substr($filename,0,strlen($site_url)); |
|
859 | - $filename = trim($filename,'/'); |
|
857 | + if (strpos($filename, $site_url) === 0) |
|
858 | + $filename = substr($filename, 0, strlen($site_url)); |
|
859 | + $filename = trim($filename, '/'); |
|
860 | 860 | |
861 | - $opt = trim($opt,'/'); |
|
862 | - if($opt!=='') $opt .= '/'; |
|
861 | + $opt = trim($opt, '/'); |
|
862 | + if ($opt !== '') $opt .= '/'; |
|
863 | 863 | |
864 | 864 | $filename = MODX_BASE_PATH.$opt.$filename; |
865 | 865 | |
866 | - if(is_file($filename)){ |
|
866 | + if (is_file($filename)) { |
|
867 | 867 | clearstatcache(); |
868 | 868 | $size = filesize($filename); |
869 | 869 | return $size; |
@@ -896,10 +896,10 @@ discard block |
||
896 | 896 | $this->opt = $cmd; |
897 | 897 | return $this->includeMdfFile('moduser'); |
898 | 898 | case 'userinfo': |
899 | - if(empty($opt)) $this->opt = 'username'; |
|
899 | + if (empty($opt)) $this->opt = 'username'; |
|
900 | 900 | return $this->includeMdfFile('moduser'); |
901 | 901 | case 'webuserinfo': |
902 | - if(empty($opt)) $this->opt = 'username'; |
|
902 | + if (empty($opt)) $this->opt = 'username'; |
|
903 | 903 | $this->value = -$value; |
904 | 904 | return $this->includeMdfFile('moduser'); |
905 | 905 | ##### Special functions |
@@ -910,27 +910,27 @@ discard block |
||
910 | 910 | case 'ifnotempty': |
911 | 911 | if (!empty($value)) return $opt; break; |
912 | 912 | case 'datagrid': |
913 | - include_once(MODX_CORE_PATH . 'controls/datagrid.class.php'); |
|
913 | + include_once(MODX_CORE_PATH.'controls/datagrid.class.php'); |
|
914 | 914 | $grd = new DataGrid(null, trim($value)); |
915 | 915 | $grd->itemStyle = ''; |
916 | 916 | $grd->altItemStyle = ''; |
917 | - $pos = strpos($value,"\n"); |
|
918 | - if($pos) $_ = substr($value,0,$pos); |
|
917 | + $pos = strpos($value, "\n"); |
|
918 | + if ($pos) $_ = substr($value, 0, $pos); |
|
919 | 919 | else $_ = $pos; |
920 | - $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ','; |
|
920 | + $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ','; |
|
921 | 921 | return $grd->render(); |
922 | 922 | case 'rotate': |
923 | 923 | case 'evenodd': |
924 | - if(strpos($opt,',')===false) $opt = 'odd,even'; |
|
924 | + if (strpos($opt, ',') === false) $opt = 'odd,even'; |
|
925 | 925 | $_ = explode(',', $opt); |
926 | 926 | $c = count($_); |
927 | 927 | $i = $value + $c; |
928 | 928 | $i = $i % $c; |
929 | 929 | return $_[$i]; |
930 | 930 | case 'takeval': |
931 | - $arr = explode(",",$opt); |
|
931 | + $arr = explode(",", $opt); |
|
932 | 932 | $idx = $value; |
933 | - if(!is_numeric($idx)) return $value; |
|
933 | + if (!is_numeric($idx)) return $value; |
|
934 | 934 | return $arr[$idx]; |
935 | 935 | case 'getimage': |
936 | 936 | return $this->includeMdfFile('getimage'); |
@@ -938,17 +938,17 @@ discard block |
||
938 | 938 | return $modx->nicesize($value); |
939 | 939 | case 'googlemap': |
940 | 940 | case 'googlemaps': |
941 | - if(empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
941 | + if (empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
942 | 942 | $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>'; |
943 | 943 | $ph['style'] = $opt; |
944 | 944 | $ph['value'] = $value; |
945 | - return $modx->parseText($tpl,$ph); |
|
945 | + return $modx->parseText($tpl, $ph); |
|
946 | 946 | case 'youtube': |
947 | 947 | case 'youtube16x9': |
948 | - if(empty($opt)) $opt = 560; |
|
949 | - $h = round($opt*0.5625); |
|
948 | + if (empty($opt)) $opt = 560; |
|
949 | + $h = round($opt * 0.5625); |
|
950 | 950 | $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>'; |
951 | - return sprintf($tpl,$opt,$h,$value); |
|
951 | + return sprintf($tpl, $opt, $h, $value); |
|
952 | 952 | //case 'youtube4x3':%s*0.75+25 |
953 | 953 | case 'setvar': |
954 | 954 | $modx->placeholders[$opt] = $value; |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | return $value; |
979 | 979 | } |
980 | 980 | |
981 | - public function includeMdfFile($cmd) { |
|
981 | + public function includeMdfFile($cmd){ |
|
982 | 982 | $modx = evolutionCMS(); |
983 | 983 | $key = $this->key; |
984 | 984 | $value = $this->value; |
@@ -989,54 +989,54 @@ discard block |
||
989 | 989 | public function getValueFromElement($key, $value, $cmd, $opt) |
990 | 990 | { |
991 | 991 | $modx = evolutionCMS(); |
992 | - if( isset($modx->snippetCache[$this->elmName]) ) |
|
992 | + if (isset($modx->snippetCache[$this->elmName])) |
|
993 | 993 | { |
994 | 994 | $php = $modx->snippetCache[$this->elmName]; |
995 | 995 | } |
996 | 996 | else |
997 | 997 | { |
998 | 998 | $esc_elmName = $modx->db->escape($this->elmName); |
999 | - $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'"); |
|
999 | + $result = $modx->db->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'"); |
|
1000 | 1000 | $total = $modx->db->getRecordCount($result); |
1001 | - if($total == 1) |
|
1001 | + if ($total == 1) |
|
1002 | 1002 | { |
1003 | 1003 | $row = $modx->db->getRow($result); |
1004 | 1004 | $php = $row['snippet']; |
1005 | 1005 | } |
1006 | - elseif($total == 0) |
|
1006 | + elseif ($total == 0) |
|
1007 | 1007 | { |
1008 | 1008 | $assets_path = MODX_BASE_PATH.'assets/'; |
1009 | - if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
1009 | + if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
1010 | 1010 | $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
1011 | - elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
1011 | + elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
1012 | 1012 | $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
1013 | - elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
1013 | + elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
1014 | 1014 | $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
1015 | 1015 | else $modifiers_path = false; |
1016 | 1016 | |
1017 | - if($modifiers_path !== false) { |
|
1017 | + if ($modifiers_path !== false) { |
|
1018 | 1018 | $php = @file_get_contents($modifiers_path); |
1019 | 1019 | $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!=='') |
|
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 | 1024 | $modx->snippetCache[$this->elmName.'Props'] = ''; |
1025 | 1025 | } |
1026 | 1026 | else |
1027 | 1027 | $php = false; |
1028 | 1028 | } |
1029 | 1029 | else $php = false; |
1030 | - if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php; |
|
1030 | + if ($this->elmName !== '') $modx->snippetCache[$this->elmName] = $php; |
|
1031 | 1031 | } |
1032 | - if($php==='') $php=false; |
|
1032 | + if ($php === '') $php = false; |
|
1033 | 1033 | |
1034 | - if($php===false) $html = $modx->getChunk($this->elmName); |
|
1034 | + if ($php === false) $html = $modx->getChunk($this->elmName); |
|
1035 | 1035 | else $html = false; |
1036 | 1036 | |
1037 | 1037 | $self = '[+output+]'; |
1038 | 1038 | |
1039 | - if($php !== false) |
|
1039 | + if ($php !== false) |
|
1040 | 1040 | { |
1041 | 1041 | ob_start(); |
1042 | 1042 | $options = $opt; |
@@ -1049,71 +1049,71 @@ discard block |
||
1049 | 1049 | $this->vars['options'] = & $opt; |
1050 | 1050 | $custom = eval($php); |
1051 | 1051 | $msg = ob_get_contents(); |
1052 | - if($value===$this->bt) $value = $msg . $custom; |
|
1052 | + if ($value === $this->bt) $value = $msg.$custom; |
|
1053 | 1053 | ob_end_clean(); |
1054 | 1054 | } |
1055 | - elseif($html!==false && isset($value) && $value!=='') |
|
1055 | + elseif ($html !== false && isset($value) && $value !== '') |
|
1056 | 1056 | { |
1057 | - $html = str_replace(array($self,'[+value+]'), $value, $html); |
|
1058 | - $value = str_replace(array('[+options+]','[+param+]'), $opt, $html); |
|
1057 | + $html = str_replace(array($self, '[+value+]'), $value, $html); |
|
1058 | + $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html); |
|
1059 | 1059 | } |
1060 | 1060 | else return false; |
1061 | 1061 | |
1062 | - if($php===false && $html===false && $value!=='' |
|
1063 | - && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) |
|
1062 | + if ($php === false && $html === false && $value !== '' |
|
1063 | + && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false)) |
|
1064 | 1064 | { |
1065 | - $value = str_replace(array('[+value+]',$self),$value,$cmd); |
|
1065 | + $value = str_replace(array('[+value+]', $self), $value, $cmd); |
|
1066 | 1066 | } |
1067 | 1067 | return $value; |
1068 | 1068 | } |
1069 | 1069 | |
1070 | - public function parseDocumentSource($content='') |
|
1070 | + public function parseDocumentSource($content = '') |
|
1071 | 1071 | { |
1072 | 1072 | $modx = evolutionCMS(); |
1073 | 1073 | |
1074 | - if(strpos($content,'[')===false && strpos($content,'{')===false) return $content; |
|
1074 | + if (strpos($content, '[') === false && strpos($content, '{') === false) return $content; |
|
1075 | 1075 | |
1076 | - if(!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1077 | - $bt=''; |
|
1078 | - $i=0; |
|
1079 | - while($bt!==$content) |
|
1076 | + if (!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1077 | + $bt = ''; |
|
1078 | + $i = 0; |
|
1079 | + while ($bt !== $content) |
|
1080 | 1080 | { |
1081 | 1081 | $bt = $content; |
1082 | - if(strpos($content,'[*')!==false && $modx->documentIdentifier) |
|
1082 | + if (strpos($content, '[*') !== false && $modx->documentIdentifier) |
|
1083 | 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); |
|
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 | 1088 | |
1089 | - if($content===$bt) break; |
|
1090 | - if($modx->maxParserPasses < $i) break; |
|
1089 | + if ($content === $bt) break; |
|
1090 | + if ($modx->maxParserPasses < $i) break; |
|
1091 | 1091 | $i++; |
1092 | 1092 | } |
1093 | 1093 | return $content; |
1094 | 1094 | } |
1095 | 1095 | |
1096 | - public function getDocumentObject($target='',$field='pagetitle') |
|
1096 | + public function getDocumentObject($target = '', $field = 'pagetitle') |
|
1097 | 1097 | { |
1098 | 1098 | $modx = evolutionCMS(); |
1099 | 1099 | |
1100 | 1100 | $target = trim($target); |
1101 | - if(empty($target)) $target = $modx->config['site_start']; |
|
1102 | - if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id'; |
|
1101 | + if (empty($target)) $target = $modx->config['site_start']; |
|
1102 | + if (preg_match('@^[1-9][0-9]*$@', $target)) $method = 'id'; |
|
1103 | 1103 | else $method = 'alias'; |
1104 | 1104 | |
1105 | - if(!isset($this->documentObject[$target])) |
|
1105 | + if (!isset($this->documentObject[$target])) |
|
1106 | 1106 | { |
1107 | - $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct'); |
|
1107 | + $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct'); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | - if($this->documentObject[$target]['publishedon']==='0') |
|
1110 | + if ($this->documentObject[$target]['publishedon'] === '0') |
|
1111 | 1111 | return ''; |
1112 | - elseif(isset($this->documentObject[$target][$field])) |
|
1112 | + elseif (isset($this->documentObject[$target][$field])) |
|
1113 | 1113 | { |
1114 | - if(is_array($this->documentObject[$target][$field])) |
|
1114 | + if (is_array($this->documentObject[$target][$field])) |
|
1115 | 1115 | { |
1116 | - $a = $modx->getTemplateVarOutput($field,$target); |
|
1116 | + $a = $modx->getTemplateVarOutput($field, $target); |
|
1117 | 1117 | $this->documentObject[$target][$field] = $a[$field]; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1122,8 +1122,8 @@ discard block |
||
1122 | 1122 | return $this->documentObject[$target][$field]; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - public function setPlaceholders($value = '', $key = '', $path = '') { |
|
1126 | - if($path!=='') $key = "{$path}.{$key}"; |
|
1125 | + public function setPlaceholders($value = '', $key = '', $path = ''){ |
|
1126 | + if ($path !== '') $key = "{$path}.{$key}"; |
|
1127 | 1127 | if (is_array($value)) { |
1128 | 1128 | foreach ($value as $subkey => $subval) { |
1129 | 1129 | $this->setPlaceholders($subval, $subkey, $key); |
@@ -1133,77 +1133,77 @@ discard block |
||
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | // Sets a placeholder variable which can only be access by Modifiers |
1136 | - public function setModifiersVariable($key, $value) { |
|
1136 | + public function setModifiersVariable($key, $value){ |
|
1137 | 1137 | if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; |
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | //mbstring |
1141 | - public function substr($str, $s, $l = null) { |
|
1141 | + public function substr($str, $s, $l = null){ |
|
1142 | 1142 | $modx = evolutionCMS(); |
1143 | - if(is_null($l)) $l = $this->strlen($str); |
|
1143 | + if (is_null($l)) $l = $this->strlen($str); |
|
1144 | 1144 | if (function_exists('mb_substr')) |
1145 | 1145 | { |
1146 | - if(strpos($str,"\r")!==false) |
|
1147 | - $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
1146 | + if (strpos($str, "\r") !== false) |
|
1147 | + $str = str_replace(array("\r\n", "\r"), "\n", $str); |
|
1148 | 1148 | return mb_substr($str, $s, $l, $modx->config['modx_charset']); |
1149 | 1149 | } |
1150 | 1150 | return substr($str, $s, $l); |
1151 | 1151 | } |
1152 | - public function strpos($haystack,$needle,$offset=0) { |
|
1152 | + public function strpos($haystack, $needle, $offset = 0){ |
|
1153 | 1153 | $modx = evolutionCMS(); |
1154 | - if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
1155 | - return strpos($haystack,$needle,$offset); |
|
1154 | + if (function_exists('mb_strpos')) return mb_strpos($haystack, $needle, $offset, $modx->config['modx_charset']); |
|
1155 | + return strpos($haystack, $needle, $offset); |
|
1156 | 1156 | } |
1157 | - public function strlen($str) { |
|
1157 | + public function strlen($str){ |
|
1158 | 1158 | $modx = evolutionCMS(); |
1159 | - if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
1159 | + if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str), $modx->config['modx_charset']); |
|
1160 | 1160 | return strlen($str); |
1161 | 1161 | } |
1162 | - public function strtolower($str) { |
|
1162 | + public function strtolower($str){ |
|
1163 | 1163 | if (function_exists('mb_strtolower')) return mb_strtolower($str); |
1164 | 1164 | return strtolower($str); |
1165 | 1165 | } |
1166 | - public function strtoupper($str) { |
|
1166 | + public function strtoupper($str){ |
|
1167 | 1167 | if (function_exists('mb_strtoupper')) return mb_strtoupper($str); |
1168 | 1168 | return strtoupper($str); |
1169 | 1169 | } |
1170 | - public function ucfirst($str) { |
|
1170 | + public function ucfirst($str){ |
|
1171 | 1171 | if (function_exists('mb_strtoupper')) |
1172 | 1172 | return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
1173 | 1173 | return ucfirst($str); |
1174 | 1174 | } |
1175 | - public function lcfirst($str) { |
|
1175 | + public function lcfirst($str){ |
|
1176 | 1176 | if (function_exists('mb_strtolower')) |
1177 | 1177 | return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
1178 | 1178 | return lcfirst($str); |
1179 | 1179 | } |
1180 | - public function ucwords($str) { |
|
1180 | + public function ucwords($str){ |
|
1181 | 1181 | if (function_exists('mb_convert_case')) |
1182 | 1182 | return mb_convert_case($str, MB_CASE_TITLE); |
1183 | 1183 | return ucwords($str); |
1184 | 1184 | } |
1185 | - public function strrev($str) { |
|
1185 | + public function strrev($str){ |
|
1186 | 1186 | preg_match_all('/./us', $str, $ar); |
1187 | 1187 | return implode(array_reverse($ar[0])); |
1188 | 1188 | } |
1189 | - public function str_shuffle($str) { |
|
1189 | + public function str_shuffle($str){ |
|
1190 | 1190 | preg_match_all('/./us', $str, $ar); |
1191 | 1191 | shuffle($ar[0]); |
1192 | 1192 | return implode($ar[0]); |
1193 | 1193 | } |
1194 | - public function str_word_count($str) { |
|
1195 | - return count(preg_split('~[^\p{L}\p{N}\']+~u',$str)); |
|
1194 | + public function str_word_count($str){ |
|
1195 | + return count(preg_split('~[^\p{L}\p{N}\']+~u', $str)); |
|
1196 | 1196 | } |
1197 | - public function strip_tags($value,$params='') { |
|
1197 | + public function strip_tags($value, $params = ''){ |
|
1198 | 1198 | $modx = evolutionCMS(); |
1199 | 1199 | |
1200 | - if(stripos($params,'style')===false && stripos($value,'</style>')!==false) { |
|
1200 | + if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) { |
|
1201 | 1201 | $value = preg_replace('@<style.*?>.*?</style>@is', '', $value); |
1202 | 1202 | } |
1203 | - if(stripos($params,'script')===false && stripos($value,'</script>')!==false) { |
|
1203 | + if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) { |
|
1204 | 1204 | $value = preg_replace('@<script.*?>.*?</script>@is', '', $value); |
1205 | 1205 | } |
1206 | 1206 | |
1207 | - return trim(strip_tags($value,$params)); |
|
1207 | + return trim(strip_tags($value, $params)); |
|
1208 | 1208 | } |
1209 | 1209 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $this->count = 0; |
58 | 58 | $this->setUrlMode(); |
59 | 59 | $this->generate_mode = 'crawl'; |
60 | - $this->targetDir = $modx->config['base_path'] . 'temp/export'; |
|
60 | + $this->targetDir = $modx->config['base_path'].'temp/export'; |
|
61 | 61 | if (!isset($this->total)) { |
62 | 62 | $this->getTotal(); |
63 | 63 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids))); |
114 | 114 | if (count($ignore_ids) > 0) { |
115 | - $ignore_ids = "AND NOT id IN ('" . implode("','", $ignore_ids) . "')"; |
|
115 | + $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')"; |
|
116 | 116 | } else { |
117 | 117 | $ignore_ids = ''; |
118 | 118 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $noncache = ($noncache == 1) ? '' : 'AND cacheable=1'; |
123 | 123 | $where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}"; |
124 | 124 | $rs = $modx->db->select('count(id)', $tbl_site_content, $where); |
125 | - $this->total = (int)$modx->db->getValue($rs); |
|
125 | + $this->total = (int) $modx->db->getValue($rs); |
|
126 | 126 | |
127 | 127 | return $this->total; |
128 | 128 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } elseif (!is_readable($directory)) { |
152 | 152 | return $rs; |
153 | 153 | } else { |
154 | - $files = glob($directory . '/*'); |
|
154 | + $files = glob($directory.'/*'); |
|
155 | 155 | if (!empty($files)) { |
156 | 156 | foreach ($files as $path) { |
157 | 157 | $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | $_lang = $back_lang; |
182 | 182 | } else { |
183 | - $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}"); |
|
183 | + $src = $this->curl_get_contents(MODX_SITE_URL."index.php?id={$docid}"); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | $modx = evolutionCMS(); |
216 | 216 | |
217 | 217 | if ($alias === '') { |
218 | - $filename = $prefix . $docid . $suffix; |
|
218 | + $filename = $prefix.$docid.$suffix; |
|
219 | 219 | } else { |
220 | 220 | if ($modx->config['suffix_mode'] === '1' && strpos($alias, '.') !== false) { |
221 | 221 | $suffix = ''; |
222 | 222 | } |
223 | - $filename = $prefix . $alias . $suffix; |
|
223 | + $filename = $prefix.$alias.$suffix; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | return $filename; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $tbl_site_content = $modx->getFullTableName('site_content'); |
239 | 239 | |
240 | 240 | $ignore_ids = $this->ignore_ids; |
241 | - $dirpath = $this->targetDir . '/'; |
|
241 | + $dirpath = $this->targetDir.'/'; |
|
242 | 242 | |
243 | 243 | $prefix = $modx->config['friendly_url_prefix']; |
244 | 244 | $suffix = $modx->config['friendly_url_suffix']; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | $ph['status'] = 'fail'; |
250 | 250 | $ph['msg1'] = $_lang['export_site_failed']; |
251 | - $ph['msg2'] = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath; |
|
251 | + $ph['msg2'] = $_lang["export_site_failed_no_write"].' - '.$dirpath; |
|
252 | 252 | $msg_failed_no_write = $this->parsePlaceholder($tpl, $ph); |
253 | 253 | |
254 | 254 | $ph['msg2'] = $_lang["export_site_failed_no_retrieve"]; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | if (!$row['wasNull']) { // needs writing a document |
283 | 283 | $docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix); |
284 | - $filename = $dirpath . $docname; |
|
284 | + $filename = $dirpath.$docname; |
|
285 | 285 | if (!is_file($filename)) { |
286 | 286 | if ($row['published'] === '1') { |
287 | 287 | $status = $this->makeFile($row['id'], $filename); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | if ($row['isfolder'] === '1' && ($modx->config['suffix_mode'] !== '1' || strpos($row['alias'], |
310 | 310 | '.') === false)) { // needs making a folder |
311 | 311 | $end_dir = ($row['alias'] !== '') ? $row['alias'] : $row['id']; |
312 | - $dir_path = $dirpath . $end_dir; |
|
312 | + $dir_path = $dirpath.$end_dir; |
|
313 | 313 | if (strpos($dir_path, MODX_BASE_PATH) === false) { |
314 | 314 | return false; |
315 | 315 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | if ($modx->config['make_folders'] === '1' && $row['published'] === '1') { |
327 | 327 | if (!empty($filename) && is_file($filename)) { |
328 | - rename($filename, $dir_path . '/index.html'); |
|
328 | + rename($filename, $dir_path.'/index.html'); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | $this->targetDir = $dir_path; |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | |
350 | 350 | $ch = curl_init(); |
351 | 351 | curl_setopt($ch, CURLOPT_URL, $url); |
352 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT |
|
353 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER |
|
352 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT |
|
353 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER |
|
354 | 354 | curl_setopt($ch, CURLOPT_HEADER, false); |
355 | 355 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
356 | 356 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataGridCnt = 0; |
12 | 12 | |
13 | -class DataGrid { |
|
13 | +class DataGrid{ |
|
14 | 14 | |
15 | 15 | public $ds; // datasource |
16 | 16 | public $id; |
17 | - public $pageSize; // pager settings |
|
17 | + public $pageSize; // pager settings |
|
18 | 18 | public $pageNumber; |
19 | 19 | public $pager; |
20 | - public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
20 | + public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
21 | 21 | |
22 | 22 | public $cssStyle; |
23 | 23 | public $cssClass; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public $colAligns; |
36 | 36 | public $colWraps; |
37 | 37 | public $colColors; |
38 | - public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
38 | + public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
39 | 39 | // data type: integer,float,currency,date |
40 | 40 | |
41 | 41 | public $header; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public $cellPadding; |
44 | 44 | public $cellSpacing; |
45 | 45 | |
46 | - public $rowAlign; // vertical alignment: top, middle, bottom |
|
46 | + public $rowAlign; // vertical alignment: top, middle, bottom |
|
47 | 47 | public $rowIdField; |
48 | 48 | |
49 | 49 | public $pagerStyle; |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public $cdelim; |
74 | 74 | |
75 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
75 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){ |
|
76 | 76 | global $__DataGridCnt; |
77 | 77 | |
78 | 78 | // set id |
79 | 79 | $__DataGridCnt++; |
80 | - $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt; |
|
80 | + $this->id = $this->id ? empty($id) : "dg".$__DataGridCnt; |
|
81 | 81 | |
82 | 82 | // set datasource |
83 | 83 | $this->ds = $ds; |
@@ -88,50 +88,50 @@ discard block |
||
88 | 88 | $this->pagerLocation = 'top-right'; |
89 | 89 | } |
90 | 90 | |
91 | - public function setDataSource($ds) { |
|
91 | + public function setDataSource($ds){ |
|
92 | 92 | $this->ds = $ds; |
93 | 93 | } |
94 | 94 | |
95 | - public function render() { |
|
95 | + public function render(){ |
|
96 | 96 | $modx = evolutionCMS(); |
97 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
98 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
99 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
100 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
97 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : ''; |
|
98 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : ""; |
|
99 | + $cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : ''; |
|
100 | + $cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : ''; |
|
101 | 101 | |
102 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
103 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
102 | + $pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : ''; |
|
103 | + $pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'"; |
|
104 | 104 | |
105 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
106 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
107 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
108 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
105 | + $this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : ''; |
|
106 | + $this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : ''; |
|
107 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : ''; |
|
108 | + $this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : ''; |
|
109 | 109 | |
110 | 110 | $this->_alt = 0; |
111 | 111 | $this->_total = 0; |
112 | 112 | |
113 | 113 | $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
114 | 114 | |
115 | - if(!$cssStyle && !$cssClass) { |
|
115 | + if (!$cssStyle && !$cssClass) { |
|
116 | 116 | $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
117 | 117 | } |
118 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
118 | + if (!$columnHeaderStyle && !$columnHeaderClass) { |
|
119 | 119 | $columnHeaderStyle = "style='color:black;background-color:silver'"; |
120 | 120 | } |
121 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
121 | + if (!$this->_itemStyle && !$this->_itemClass) { |
|
122 | 122 | $this->_itemStyle = "style='color:black;'"; |
123 | 123 | } |
124 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
124 | + if (!$this->_altItemStyle && !$this->_altItemClass) { |
|
125 | 125 | $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
126 | 126 | } |
127 | 127 | |
128 | - if($this->_isDataset && !$this->columns) { |
|
128 | + if ($this->_isDataset && !$this->columns) { |
|
129 | 129 | $cols = $modx->db->numFields($this->ds); |
130 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
130 | + for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->db->fieldName($this->ds, $i); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // start grid |
134 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
134 | + $tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>"; |
|
135 | 135 | $tblEnd = "</table>"; |
136 | 136 | |
137 | 137 | // build column header |
@@ -142,33 +142,33 @@ discard block |
||
142 | 142 | $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
143 | 143 | $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
144 | 144 | $this->_colcount = count($this->_colnames); |
145 | - if(!$this->_isDataset) { |
|
145 | + if (!$this->_isDataset) { |
|
146 | 146 | $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
147 | 147 | $this->ds = array_chunk($this->ds, $this->_colcount); |
148 | 148 | } |
149 | 149 | $tblColHdr = "<thead><tr>"; |
150 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
150 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
151 | 151 | $name = $this->_colnames[$c]; |
152 | 152 | $width = $this->_colwidths[$c]; |
153 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
153 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>"; |
|
154 | 154 | } |
155 | 155 | $tblColHdr .= "</tr></thead>\n"; |
156 | 156 | |
157 | 157 | // build rows |
158 | 158 | $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
159 | 159 | $this->_fieldnames = explode(",", $this->fields); |
160 | - if($rowcount == 0) { |
|
161 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
160 | + if ($rowcount == 0) { |
|
161 | + $tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n"; |
|
162 | 162 | } else { |
163 | 163 | // render grid items |
164 | - if($this->pageSize <= 0) { |
|
165 | - for($r = 0; $r < $rowcount; $r++) { |
|
164 | + if ($this->pageSize <= 0) { |
|
165 | + for ($r = 0; $r < $rowcount; $r++) { |
|
166 | 166 | $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
167 | 167 | $tblRows .= $this->RenderRowFnc($r + 1, $row); |
168 | 168 | } |
169 | 169 | } else { |
170 | - if(!$this->pager) { |
|
171 | - include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
170 | + if (!$this->pager) { |
|
171 | + include_once dirname(__FILE__)."/datasetpager.class.php"; |
|
172 | 172 | $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
173 | 173 | $this->pager->setRenderRowFnc($this); // pass this object |
174 | 174 | $this->pager->cssStyle = $pagerStyle; |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | $o = $tblStart; |
189 | 189 | $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
190 | 190 | $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
191 | - if($this->header) { |
|
192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
191 | + if ($this->header) { |
|
192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>"; |
|
193 | 193 | } |
194 | - if($tblPager && $ptop) { |
|
195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
194 | + if ($tblPager && $ptop) { |
|
195 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
196 | 196 | } |
197 | - $o .= $tblColHdr . $tblRows; |
|
198 | - if($tblPager && $pbot) { |
|
199 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
197 | + $o .= $tblColHdr.$tblRows; |
|
198 | + if ($tblPager && $pbot) { |
|
199 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
200 | 200 | } |
201 | - if($this->footer) { |
|
202 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
201 | + if ($this->footer) { |
|
202 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>"; |
|
203 | 203 | } |
204 | 204 | $o .= $tblEnd; |
205 | 205 | return $o; |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | |
208 | 208 | // format column values |
209 | 209 | |
210 | - public function RenderRowFnc($n, $row) { |
|
211 | - if($this->_alt == 0) { |
|
210 | + public function RenderRowFnc($n, $row){ |
|
211 | + if ($this->_alt == 0) { |
|
212 | 212 | $Style = $this->_itemStyle; |
213 | 213 | $Class = $this->_itemClass; |
214 | 214 | $this->_alt = 1; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $this->_alt = 0; |
219 | 219 | } |
220 | 220 | $o = "<tr>"; |
221 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
221 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
222 | 222 | $colStyle = $Style; |
223 | 223 | $fld = trim($this->_fieldnames[$c]); |
224 | 224 | $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
@@ -227,67 +227,67 @@ discard block |
||
227 | 227 | $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
228 | 228 | $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
229 | 229 | $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
230 | - if($color && $Style) { |
|
231 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
230 | + if ($color && $Style) { |
|
231 | + $colStyle = substr($colStyle, 0, -1).";background-color:$color;'"; |
|
232 | 232 | } |
233 | 233 | $value = $this->formatColumnValue($row, $value, $type, $align); |
234 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
234 | + $o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>"; |
|
235 | 235 | } |
236 | 236 | $o .= "</tr>\n"; |
237 | 237 | return $o; |
238 | 238 | } |
239 | 239 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
241 | - if(strpos($type, ":") !== false) { |
|
240 | + public function formatColumnValue($row, $value, $type, &$align){ |
|
241 | + if (strpos($type, ":") !== false) { |
|
242 | 242 | list($type, $type_format) = explode(":", $type, 2); |
243 | 243 | } |
244 | - switch(strtolower($type)) { |
|
244 | + switch (strtolower($type)) { |
|
245 | 245 | case "integer": |
246 | - if($align == "") { |
|
246 | + if ($align == "") { |
|
247 | 247 | $align = "right"; |
248 | 248 | } |
249 | 249 | $value = number_format($value); |
250 | 250 | break; |
251 | 251 | |
252 | 252 | case "float": |
253 | - if($align == "") { |
|
253 | + if ($align == "") { |
|
254 | 254 | $align = "right"; |
255 | 255 | } |
256 | - if(!$type_format) { |
|
256 | + if (!$type_format) { |
|
257 | 257 | $type_format = 2; |
258 | 258 | } |
259 | 259 | $value = number_format($value, $type_format); |
260 | 260 | break; |
261 | 261 | |
262 | 262 | case "currency": |
263 | - if($align == "") { |
|
263 | + if ($align == "") { |
|
264 | 264 | $align = "right"; |
265 | 265 | } |
266 | - if(!$type_format) { |
|
266 | + if (!$type_format) { |
|
267 | 267 | $type_format = 2; |
268 | 268 | } |
269 | - $value = "$" . number_format($value, $type_format); |
|
269 | + $value = "$".number_format($value, $type_format); |
|
270 | 270 | break; |
271 | 271 | |
272 | 272 | case "date": |
273 | - if($align == "") { |
|
273 | + if ($align == "") { |
|
274 | 274 | $align = "right"; |
275 | 275 | } |
276 | - if(!is_numeric($value)) { |
|
276 | + if (!is_numeric($value)) { |
|
277 | 277 | $value = strtotime($value); |
278 | 278 | } |
279 | - if(!$type_format) { |
|
279 | + if (!$type_format) { |
|
280 | 280 | $type_format = "%A %d, %B %Y"; |
281 | 281 | } |
282 | 282 | $value = strftime($type_format, $value); |
283 | 283 | break; |
284 | 284 | |
285 | 285 | case "boolean": |
286 | - if($align == '') { |
|
286 | + if ($align == '') { |
|
287 | 287 | $align = "center"; |
288 | 288 | } |
289 | 289 | $value = number_format($value); |
290 | - if($value) { |
|
290 | + if ($value) { |
|
291 | 291 | $value = '•'; |
292 | 292 | } else { |
293 | 293 | $value = ' '; |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | // replace [+value+] first |
299 | 299 | $value = str_replace("[+value+]", $value, $type_format); |
300 | 300 | // replace other [+fields+] |
301 | - if(strpos($value, "[+") !== false) { |
|
302 | - foreach($row as $k => $v) { |
|
301 | + if (strpos($value, "[+") !== false) { |
|
302 | + foreach ($row as $k => $v) { |
|
303 | 303 | $value = str_replace("[+$k+]", $v, $value); |
304 | 304 | } |
305 | 305 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataSetPagerCnt = 0; |
12 | 12 | |
13 | -class DataSetPager { |
|
13 | +class DataSetPager{ |
|
14 | 14 | |
15 | 15 | public $ds; // datasource |
16 | 16 | public $pageSize; |
@@ -31,26 +31,26 @@ discard block |
||
31 | 31 | public $renderPagerFnc; |
32 | 32 | public $renderPagerFncArgs; |
33 | 33 | |
34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
34 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){ |
|
35 | 35 | global $_PAGE; // use view state object |
36 | 36 | |
37 | 37 | global $__DataSetPagerCnt; |
38 | 38 | |
39 | 39 | // set id |
40 | 40 | $__DataSetPagerCnt++; |
41 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
41 | + $this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt; |
|
42 | 42 | |
43 | 43 | // get pagenumber |
44 | 44 | // by setting pager to -1 cause pager to load it's last page number |
45 | - if($pageNumber == -1) { |
|
45 | + if ($pageNumber == -1) { |
|
46 | 46 | $pageNumber = 1; |
47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
47 | + if (isset($_GET["dpgn".$this->id])) { |
|
48 | + $pageNumber = $_GET["dpgn".$this->id]; |
|
49 | + } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) { |
|
50 | + $pageNumber = $_PAGE['vs'][$id.'_dpgn']; |
|
51 | 51 | } |
52 | 52 | } |
53 | - if(!is_numeric($pageNumber)) { |
|
53 | + if (!is_numeric($pageNumber)) { |
|
54 | 54 | $pageNumber = 1; |
55 | 55 | } |
56 | 56 | |
@@ -61,40 +61,40 @@ discard block |
||
61 | 61 | $this->pager = ''; |
62 | 62 | } |
63 | 63 | |
64 | - public function getRenderedPager() { |
|
64 | + public function getRenderedPager(){ |
|
65 | 65 | return $this->pager; |
66 | 66 | } |
67 | 67 | |
68 | - public function getRenderedRows() { |
|
68 | + public function getRenderedRows(){ |
|
69 | 69 | return $this->rows; |
70 | 70 | } |
71 | 71 | |
72 | - public function setDataSource($ds) { |
|
72 | + public function setDataSource($ds){ |
|
73 | 73 | $this->ds = $ds; |
74 | 74 | } |
75 | 75 | |
76 | - public function setPageSize($ps) { |
|
76 | + public function setPageSize($ps){ |
|
77 | 77 | $this->pageSize = $ps; |
78 | 78 | } |
79 | 79 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
80 | + public function setRenderRowFnc($fncName, $args = ""){ |
|
81 | 81 | $this->renderRowFnc = &$fncName; |
82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
83 | 83 | |
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
87 | + public function setRenderPagerFnc($fncName, $args = ""){ |
|
88 | 88 | $this->renderPagerFnc = $fncName; |
89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | 90 | } |
91 | 91 | |
92 | - public function render() { |
|
92 | + public function render(){ |
|
93 | 93 | $modx = evolutionCMS(); global $_PAGE; |
94 | 94 | |
95 | 95 | $isDataset = $modx->db->isResult($this->ds); |
96 | 96 | |
97 | - if(!$this->selPageStyle) { |
|
97 | + if (!$this->selPageStyle) { |
|
98 | 98 | $this->selPageStyle = "font-weight:bold"; |
99 | 99 | } |
100 | 100 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
103 | 103 | |
104 | 104 | // render: no records found |
105 | - if($tnr <= 0) { |
|
105 | + if ($tnr <= 0) { |
|
106 | 106 | $fnc = $this->renderRowFnc; |
107 | 107 | $args = $this->renderRowFncArgs; |
108 | - if(isset($fnc)) { |
|
109 | - if($args != "") { |
|
108 | + if (isset($fnc)) { |
|
109 | + if ($args != "") { |
|
110 | 110 | $this->rows .= $fnc(0, null, $args); |
111 | 111 | } // if agrs was specified then we will pass three params |
112 | 112 | else { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // get total pages |
120 | 120 | $tp = ceil($tnr / $this->pageSize); |
121 | - if($this->pageNumber > $tp) { |
|
121 | + if ($this->pageNumber > $tp) { |
|
122 | 122 | $this->pageNumber = 1; |
123 | 123 | } |
124 | 124 | |
@@ -126,39 +126,39 @@ discard block |
||
126 | 126 | $p = $this->pageNumber; |
127 | 127 | |
128 | 128 | // save page number to view state if available |
129 | - if(isset($_PAGE['vs'])) { |
|
130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
129 | + if (isset($_PAGE['vs'])) { |
|
130 | + $_PAGE['vs'][$this->id.'_dpgn'] = $p; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
134 | - if($tp > 1) { |
|
134 | + if ($tp > 1) { |
|
135 | 135 | $url = ''; |
136 | 136 | $fnc = $this->renderPagerFnc; |
137 | 137 | $args = $this->renderPagerFncArgs; |
138 | - if(!isset($fnc)) { |
|
139 | - if($modx->isFrontend()) { |
|
140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
138 | + if (!isset($fnc)) { |
|
139 | + if ($modx->isFrontend()) { |
|
140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?'; |
|
141 | 141 | } else { |
142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
142 | + $url = $_SERVER['PHP_SELF'].'?'; |
|
143 | 143 | } |
144 | 144 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
145 | + foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) { |
|
146 | 146 | $i++; |
147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
147 | + $url .= (($i > 1) ? "&" : "")."$n=$v"; |
|
148 | 148 | } |
149 | - if($i >= 1) { |
|
149 | + if ($i >= 1) { |
|
150 | 150 | $url .= "&"; |
151 | 151 | } |
152 | 152 | } |
153 | - for($i = 1; $i <= $tp; $i++) { |
|
154 | - if(isset($fnc)) { |
|
155 | - if($args != "") { |
|
153 | + for ($i = 1; $i <= $tp; $i++) { |
|
154 | + if (isset($fnc)) { |
|
155 | + if ($args != "") { |
|
156 | 156 | $this->pager .= $fnc($p, $i, $args); |
157 | 157 | } else { |
158 | 158 | $this->pager .= $fnc($p, $i); |
159 | 159 | } |
160 | 160 | } else { |
161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
161 | + $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> "; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | $fnc = $this->renderRowFnc; |
168 | 168 | $args = $this->renderRowFncArgs; |
169 | 169 | |
170 | - if(isset($fnc)) { |
|
170 | + if (isset($fnc)) { |
|
171 | 171 | $i = 1; |
172 | 172 | $fncObject = is_object($fnc); |
173 | 173 | $minitems = (($p - 1) * $this->pageSize) + 1; |
174 | 174 | $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | - if($i >= $minitems && $i <= $maxitems) { |
|
177 | - if($fncObject) { |
|
178 | - if($args != "") { |
|
175 | + while ($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | + if ($i >= $minitems && $i <= $maxitems) { |
|
177 | + if ($fncObject) { |
|
178 | + if ($args != "") { |
|
179 | 179 | $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
180 | 180 | } else { |
181 | 181 | $this->rows .= $fnc->RenderRowFnc($i, $row); |
182 | 182 | } |
183 | 183 | } else { |
184 | - if($args != "") { |
|
184 | + if ($args != "") { |
|
185 | 185 | $this->rows .= $fnc($i, $row, $args); |
186 | 186 | } // if agrs was specified then we wil pass three params |
187 | 187 | else { |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
5 | 5 | |
6 | 6 | |
7 | -if( ! function_exists('evolutionCMS')) { |
|
7 | +if (!function_exists('evolutionCMS')) { |
|
8 | 8 | /** |
9 | 9 | * @return DocumentParser |
10 | 10 | */ |
11 | 11 | function evolutionCMS() |
12 | 12 | { |
13 | - if( ! defined('MODX_CLASS')) { |
|
14 | - if( ! class_exists('DocumentParser')) { |
|
13 | + if (!defined('MODX_CLASS')) { |
|
14 | + if (!class_exists('DocumentParser')) { |
|
15 | 15 | throw new RuntimeException('MODX_CLASS not defined and DocumentParser class not exists'); |
16 | 16 | } |
17 | 17 | define('MODX_CLASS', 'DocumentParser'); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $_ = crc32(__FILE__); |
30 | 30 | $_ = sprintf('%u', $_); |
31 | 31 | |
32 | - return 'evo' . base_convert($_, 10, 36); |
|
32 | + return 'evo'.base_convert($_, 10, 36); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | session_start(); |
51 | 51 | $key = "modx.mgr.session.cookie.lifetime"; |
52 | 52 | if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
53 | - $cookieLifetime = (int)$_SESSION[$key]; |
|
53 | + $cookieLifetime = (int) $_SESSION[$key]; |
|
54 | 54 | if ($cookieLifetime) { |
55 | 55 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
56 | 56 | } |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | $action = "", |
37 | 37 | $itemid = "", |
38 | 38 | $itemname = "" |
39 | - ) { |
|
39 | + ){ |
|
40 | 40 | $modx = evolutionCMS(); |
41 | 41 | $this->entry['msg'] = $msg; // writes testmessage to the object |
42 | - $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
42 | + $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
43 | 43 | |
44 | 44 | // User Credentials |
45 | 45 | $this->entry['internalKey'] = $internalKey == "" ? $modx->getLoginUserID() : $internalKey; |
46 | 46 | $this->entry['username'] = $username == "" ? $modx->getLoginUserName() : $username; |
47 | 47 | |
48 | - $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int)$_REQUEST['id'] : $itemid; // writes the id to the object |
|
48 | + $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int) $_REQUEST['id'] : $itemid; // writes the id to the object |
|
49 | 49 | if ($this->entry['itemId'] == 0) { |
50 | 50 | $this->entry['itemId'] = "-"; |
51 | 51 | } // to stop items having id 0 |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | $fields['message'] = $modx->db->escape($this->entry['msg']); |
94 | 94 | $insert_id = $modx->db->insert($fields, $tbl_manager_log); |
95 | 95 | if (!$insert_id) { |
96 | - $modx->messageQuit("Logging error: couldn't save log to table! Error code: " . $modx->db->getLastError()); |
|
96 | + $modx->messageQuit("Logging error: couldn't save log to table! Error code: ".$modx->db->getLastError()); |
|
97 | 97 | } else { |
98 | - $limit = (isset($modx->config['manager_log_limit'])) ? (int)$modx->config['manager_log_limit'] : 3000; |
|
99 | - $trim = (isset($modx->config['manager_log_trim'])) ? (int)$modx->config['manager_log_trim'] : 100; |
|
98 | + $limit = (isset($modx->config['manager_log_limit'])) ? (int) $modx->config['manager_log_limit'] : 3000; |
|
99 | + $trim = (isset($modx->config['manager_log_trim'])) ? (int) $modx->config['manager_log_trim'] : 100; |
|
100 | 100 | if (($insert_id % $trim) === 0) { |
101 | 101 | $modx->rotate_log('manager_log', $limit, $trim); |
102 | 102 | } |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | 6 | // PROCESSOR FIRST |
7 | -if($_SESSION['mgrRole'] == 1) { |
|
8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
7 | +if ($_SESSION['mgrRole'] == 1) { |
|
8 | + if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | 9 | $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
10 | - if(!empty($current)) { |
|
10 | + if (!empty($current)) { |
|
11 | 11 | $modx->manager->setSystemChecksum($current); |
12 | 12 | $modx->clearCache('full'); |
13 | 13 | $modx->config['sys_files_checksum'] = $current; |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | $warningspresent = 0; |
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
22 | -if ($sysfiles_check!=='0'){ |
|
22 | +if ($sysfiles_check !== '0') { |
|
23 | 23 | $warningspresent = 1; |
24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
25 | 25 | } |
26 | 26 | |
27 | -if (is_writable("includes/config.inc.php")){ |
|
27 | +if (is_writable("includes/config.inc.php")) { |
|
28 | 28 | // Warn if world writable |
29 | - if(@fileperms('includes/config.inc.php') & 0x0002) { |
|
29 | + if (@fileperms('includes/config.inc.php') & 0x0002) { |
|
30 | 30 | $warningspresent = 1; |
31 | 31 | $warnings[] = array($_lang['configcheck_configinc']); |
32 | 32 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $warnings[] = array($_lang['configcheck_php_gdzip']); |
43 | 43 | } |
44 | 44 | |
45 | -if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | - if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
45 | +if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | + if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
47 | 47 | if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) { |
48 | 48 | $warningspresent = 1; |
49 | 49 | $warnings[] = array($_lang['configcheck_validate_referer']); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | // check for Template Switcher plugin |
55 | -if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | - if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
55 | +if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | + if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
57 | 57 | $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'"); |
58 | 58 | $row = $modx->db->getRow($rs); |
59 | - if($row && $row['disabled'] == 0) { |
|
59 | + if ($row && $row['disabled'] == 0) { |
|
60 | 60 | $warningspresent = 1; |
61 | 61 | $warnings[] = array($_lang['configcheck_templateswitcher_present']); |
62 | 62 | $tplName = $row['name']; |
@@ -120,36 +120,36 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - function checkSiteCache() { |
|
123 | + function checkSiteCache(){ |
|
124 | 124 | $modx = evolutionCMS(); |
125 | - $checked= true; |
|
126 | - if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
|
127 | - $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php'); |
|
125 | + $checked = true; |
|
126 | + if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) { |
|
127 | + $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php'); |
|
128 | 128 | } |
129 | 129 | return $checked; |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | -if (!is_writable(MODX_BASE_PATH . "assets/cache/")) { |
|
133 | +if (!is_writable(MODX_BASE_PATH."assets/cache/")) { |
|
134 | 134 | $warningspresent = 1; |
135 | 135 | $warnings[] = array($_lang['configcheck_cache']); |
136 | 136 | } |
137 | 137 | |
138 | 138 | if (!checkSiteCache()) { |
139 | 139 | $warningspresent = 1; |
140 | - $warnings[]= array($lang['configcheck_sitecache_integrity']); |
|
140 | + $warnings[] = array($lang['configcheck_sitecache_integrity']); |
|
141 | 141 | } |
142 | 142 | |
143 | -if (!is_writable(MODX_BASE_PATH . "assets/images/")) { |
|
143 | +if (!is_writable(MODX_BASE_PATH."assets/images/")) { |
|
144 | 144 | $warningspresent = 1; |
145 | 145 | $warnings[] = array($_lang['configcheck_images']); |
146 | 146 | } |
147 | 147 | |
148 | -if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) { |
|
148 | +if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) { |
|
149 | 149 | $warningspresent = 1; |
150 | 150 | $warnings[] = array($_lang['configcheck_rb_base_dir']); |
151 | 151 | } |
152 | -if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) { |
|
152 | +if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) { |
|
153 | 153 | $warningspresent = 1; |
154 | 154 | $warnings[] = array($_lang['configcheck_filemanager_path']); |
155 | 155 | } |
@@ -157,36 +157,36 @@ discard block |
||
157 | 157 | // clear file info cache |
158 | 158 | clearstatcache(); |
159 | 159 | |
160 | -if ($warningspresent==1) { |
|
160 | +if ($warningspresent == 1) { |
|
161 | 161 | |
162 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
162 | +if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3'; |
|
163 | 163 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
164 | 164 | |
165 | -for ($i=0;$i<count($warnings);$i++) { |
|
165 | +for ($i = 0; $i < count($warnings); $i++) { |
|
166 | 166 | switch ($warnings[$i][0]) { |
167 | 167 | case $_lang['configcheck_configinc']; |
168 | 168 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
169 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
169 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']); |
|
170 | 170 | break; |
171 | 171 | case $_lang['configcheck_installer'] : |
172 | 172 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
173 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
173 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']); |
|
174 | 174 | break; |
175 | 175 | case $_lang['configcheck_cache'] : |
176 | 176 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
177 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
177 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']); |
|
178 | 178 | break; |
179 | 179 | case $_lang['configcheck_images'] : |
180 | 180 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
181 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
181 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']); |
|
182 | 182 | break; |
183 | 183 | case $_lang['configcheck_sysfiles_mod']: |
184 | 184 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
185 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
186 | - if($modx->hasPermission('settings')) { |
|
187 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
185 | + $warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>'; |
|
186 | + if ($modx->hasPermission('settings')) { |
|
187 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>'; |
|
188 | 188 | } |
189 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
189 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']); |
|
190 | 190 | break; |
191 | 191 | case $_lang['configcheck_lang_difference'] : |
192 | 192 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -208,18 +208,18 @@ discard block |
||
208 | 208 | break; |
209 | 209 | case $_lang['configcheck_validate_referer'] : |
210 | 210 | $msg = $_lang['configcheck_validate_referer_msg']; |
211 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
211 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
212 | 212 | $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n"; |
213 | 213 | break; |
214 | 214 | case $_lang['configcheck_templateswitcher_present'] : |
215 | 215 | $msg = $_lang["configcheck_templateswitcher_present_msg"]; |
216 | - if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
217 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"]; |
|
216 | + if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
217 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"]; |
|
218 | 218 | } |
219 | - if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
220 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"]; |
|
219 | + if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
220 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"]; |
|
221 | 221 | } |
222 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
222 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
223 | 223 | $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n"; |
224 | 224 | break; |
225 | 225 | case $_lang['configcheck_rb_base_dir'] : |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $warnings[$i][1] = $_lang['configcheck_default_msg']; |
233 | 233 | } |
234 | 234 | |
235 | - $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ; |
|
235 | + $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : ""; |
|
236 | 236 | $config_check_results .= " |
237 | 237 | <fieldset> |
238 | 238 | <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p> |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')." |
242 | 242 | </fieldset> |
243 | 243 | "; |
244 | - if ($i!=count($warnings)-1) { |
|
244 | + if ($i != count($warnings) - 1) { |
|
245 | 245 | $config_check_results .= "<br />"; |
246 | 246 | } |
247 | 247 | } |
248 | - $_SESSION["mgrConfigCheck"]=true; |
|
248 | + $_SESSION["mgrConfigCheck"] = true; |
|
249 | 249 | } else { |
250 | 250 | $config_check_results = $_lang['configcheck_ok']; |
251 | 251 | } |