Completed
Pull Request — develop (#534)
by Agel_Nash
05:08
created
manager/includes/controls/datagrid.class.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -72,6 +72,9 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public $cdelim;
74 74
 
75
+    /**
76
+     * @param null|string $id
77
+     */
75 78
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
76 79
 		global $__DataGridCnt;
77 80
 
@@ -207,6 +210,9 @@  discard block
 block discarded – undo
207 210
 
208 211
 	// format column values
209 212
 
213
+    /**
214
+     * @param integer $n
215
+     */
210 216
     public function RenderRowFnc($n, $row) {
211 217
 		if($this->_alt == 0) {
212 218
 			$Style = $this->_itemStyle;
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataGridCnt = 0;
12 12
 
13
-class DataGrid {
13
+class DataGrid
14
+{
14 15
 
15 16
 	public $ds; // datasource
16 17
     public $id;
@@ -72,7 +73,8 @@  discard block
 block discarded – undo
72 73
      */
73 74
     public $cdelim;
74 75
 
75
-    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
76
+    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1)
77
+    {
76 78
 		global $__DataGridCnt;
77 79
 
78 80
 		// set id
@@ -88,11 +90,13 @@  discard block
 block discarded – undo
88 90
 		$this->pagerLocation = 'top-right';
89 91
 	}
90 92
 
91
-    public function setDataSource($ds) {
93
+    public function setDataSource($ds)
94
+    {
92 95
 		$this->ds = $ds;
93 96
 	}
94 97
 
95
-    public function render() {
98
+    public function render()
99
+    {
96 100
 		global $modx;
97 101
 		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98 102
 		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
 
128 132
 		if($this->_isDataset && !$this->columns) {
129 133
 			$cols = $modx->db->numFields($this->ds);
130
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
134
+			for($i = 0; $i < $cols; $i++) {
135
+			    $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
136
+			}
131 137
 		}
132 138
 
133 139
 		// start grid
@@ -207,7 +213,8 @@  discard block
 block discarded – undo
207 213
 
208 214
 	// format column values
209 215
 
210
-    public function RenderRowFnc($n, $row) {
216
+    public function RenderRowFnc($n, $row)
217
+    {
211 218
 		if($this->_alt == 0) {
212 219
 			$Style = $this->_itemStyle;
213 220
 			$Class = $this->_itemClass;
@@ -237,7 +244,8 @@  discard block
 block discarded – undo
237 244
 		return $o;
238 245
 	}
239 246
 
240
-    public function formatColumnValue($row, $value, $type, &$align) {
247
+    public function formatColumnValue($row, $value, $type, &$align)
248
+    {
241 249
 		if(strpos($type, ":") !== false) {
242 250
 			list($type, $type_format) = explode(":", $type, 2);
243 251
 		}
Please login to merge, or discard this patch.
manager/includes/controls/datasetpager.class.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -31,6 +31,9 @@  discard block
 block discarded – undo
31 31
     public $renderPagerFnc;
32 32
     public $renderPagerFncArgs;
33 33
 
34
+    /**
35
+     * @param boolean|string $id
36
+     */
34 37
     public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35 38
 		global $_PAGE; // use view state object
36 39
 
@@ -77,6 +80,9 @@  discard block
 block discarded – undo
77 80
 		$this->pageSize = $ps;
78 81
 	}
79 82
 
83
+    /**
84
+     * @param DataGrid $fncName
85
+     */
80 86
     public function setRenderRowFnc($fncName, $args = "") {
81 87
 		$this->renderRowFnc = &$fncName;
82 88
 		$this->renderRowFncArgs = $args;    // extra agruments
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataSetPagerCnt = 0;
12 12
 
13
-class DataSetPager {
13
+class DataSetPager
14
+{
14 15
 
15 16
 	public $ds; // datasource
16 17
     public $pageSize;
@@ -31,7 +32,8 @@  discard block
 block discarded – undo
31 32
     public $renderPagerFnc;
32 33
     public $renderPagerFncArgs;
33 34
 
34
-    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35
+    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1)
36
+    {
35 37
 		global $_PAGE; // use view state object
36 38
 
37 39
 		global $__DataSetPagerCnt;
@@ -61,35 +63,42 @@  discard block
 block discarded – undo
61 63
 		$this->pager = '';
62 64
 	}
63 65
 
64
-    public function getRenderedPager() {
66
+    public function getRenderedPager()
67
+    {
65 68
 		return $this->pager;
66 69
 	}
67 70
 
68
-    public function getRenderedRows() {
71
+    public function getRenderedRows()
72
+    {
69 73
 		return $this->rows;
70 74
 	}
71 75
 
72
-    public function setDataSource($ds) {
76
+    public function setDataSource($ds)
77
+    {
73 78
 		$this->ds = $ds;
74 79
 	}
75 80
 
76
-    public function setPageSize($ps) {
81
+    public function setPageSize($ps)
82
+    {
77 83
 		$this->pageSize = $ps;
78 84
 	}
79 85
 
80
-    public function setRenderRowFnc($fncName, $args = "") {
86
+    public function setRenderRowFnc($fncName, $args = "")
87
+    {
81 88
 		$this->renderRowFnc = &$fncName;
82 89
 		$this->renderRowFncArgs = $args;    // extra agruments
83 90
 
84 91
 
85 92
 	}
86 93
 
87
-    public function setRenderPagerFnc($fncName, $args = "") {
94
+    public function setRenderPagerFnc($fncName, $args = "")
95
+    {
88 96
 		$this->renderPagerFnc = $fncName;
89 97
 		$this->renderPagerFncArgs = $args;    // extra agruments
90 98
 	}
91 99
 
92
-    public function render() {
100
+    public function render()
101
+    {
93 102
 		global $modx, $_PAGE;
94 103
 
95 104
 		$isDataset = $modx->db->isResult($this->ds);
@@ -142,8 +151,10 @@  discard block
 block discarded – undo
142 151
 					$url = $_SERVER['PHP_SELF'] . '?';
143 152
 				}
144 153
 				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
154
+				foreach($_GET as $n => $v) {
155
+				    if($n != 'dpgn' . $this->id) {
146 156
 					$i++;
157
+				}
147 158
 					$url .= (($i > 1) ? "&" : "") . "$n=$v";
148 159
 				}
149 160
 				if($i >= 1) {
Please login to merge, or discard this patch.
manager/includes/document.parser.class.inc.php 1 patch
Doc Comments   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      * MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php"
257 257
      * $extname - extension name in lowercase
258 258
      *
259
-     * @param $extname
259
+     * @param string $extname
260 260
      * @param bool $reload
261 261
      * @return bool
262 262
      */
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
      * @param int $count_attempts
300 300
      * @param string $type $type
301 301
      * @param string $responseCode
302
-     * @return bool
302
+     * @return false|null
303 303
      * @global string $base_url
304 304
      * @global string $site_url
305 305
      */
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
     }
1000 1000
 
1001 1001
     /**
1002
-     * @param $contents
1002
+     * @param string $contents
1003 1003
      * @return mixed
1004 1004
      */
1005 1005
     public function RecoveryEscapedTags($contents)
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
     }
1024 1024
 
1025 1025
     /**
1026
-     * @param $tstart
1026
+     * @param double $tstart
1027 1027
      * @return array
1028 1028
      */
1029 1029
     public function getTimerStats($tstart)
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 
1776 1776
     /**
1777 1777
      * Remove Comment-Tags from output like <!--@- Comment -@-->
1778
-     * @param $content
1778
+     * @param string $content
1779 1779
      * @param string $left
1780 1780
      * @param string $right
1781 1781
      * @return mixed
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
     /**
1949 1949
      * Run snippets as per the tags in $documentSource and replace the tags with the returned values.
1950 1950
      *
1951
-     * @param $content
1951
+     * @param string $content
1952 1952
      * @return string
1953 1953
      * @internal param string $documentSource
1954 1954
      */
@@ -2980,7 +2980,7 @@  discard block
 block discarded – undo
2980 2980
 
2981 2981
     /**
2982 2982
      * @param $templateID
2983
-     * @return mixed
2983
+     * @return string
2984 2984
      */
2985 2985
     public function _getTemplateCodeFromDB($templateID)
2986 2986
     {
@@ -3021,9 +3021,9 @@  discard block
 block discarded – undo
3021 3021
     }
3022 3022
 
3023 3023
     /**
3024
-     * @param $id
3024
+     * @param integer $id
3025 3025
      * @param int $top
3026
-     * @return mixed
3026
+     * @return string
3027 3027
      */
3028 3028
     public function getUltimateParentId($id, $top = 0)
3029 3029
     {
@@ -3354,7 +3354,7 @@  discard block
 block discarded – undo
3354 3354
      *
3355 3355
      * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role
3356 3356
      * @param int $id Element- / Resource-id
3357
-     * @return bool
3357
+     * @return false|null
3358 3358
      */
3359 3359
     public function lockElement($type, $id)
3360 3360
     {
@@ -3376,7 +3376,7 @@  discard block
 block discarded – undo
3376 3376
      * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role
3377 3377
      * @param int $id Element- / Resource-id
3378 3378
      * @param bool $includeAllUsers true = Deletes not only own user-locks
3379
-     * @return bool
3379
+     * @return false|null
3380 3380
      */
3381 3381
     public function unlockElement($type, $id, $includeAllUsers = false)
3382 3382
     {
@@ -3484,7 +3484,7 @@  discard block
 block discarded – undo
3484 3484
      * @param array $params
3485 3485
      * @param string $msg
3486 3486
      * @param array $files
3487
-     * @return mixed
3487
+     * @return boolean
3488 3488
      */
3489 3489
     public function sendmail($params = array(), $msg = '', $files = array())
3490 3490
     {
@@ -3980,7 +3980,7 @@  discard block
 block discarded – undo
3980 3980
      *
3981 3981
      * @param string $type
3982 3982
      * @param bool $report
3983
-     * @return bool
3983
+     * @return boolean|null
3984 3984
      */
3985 3985
     public function clearCache($type = '', $report = false)
3986 3986
     {
@@ -5024,7 +5024,7 @@  discard block
 block discarded – undo
5024 5024
      * Returns a record for the web user
5025 5025
      *
5026 5026
      * @param int $uid
5027
-     * @return boolean|string
5027
+     * @return boolean|null
5028 5028
      */
5029 5029
     public function getWebUserInfo($uid)
5030 5030
     {
@@ -5322,7 +5322,7 @@  discard block
 block discarded – undo
5322 5322
      * Remove event listener - only for use within the current execution cycle
5323 5323
      *
5324 5324
      * @param string $evtName
5325
-     * @return boolean
5325
+     * @return false|null
5326 5326
      */
5327 5327
     public function removeEventListener($evtName)
5328 5328
     {
@@ -5346,7 +5346,7 @@  discard block
 block discarded – undo
5346 5346
      *
5347 5347
      * @param string $evtName
5348 5348
      * @param array $extParams Parameters available to plugins. Each array key will be the PHP variable name, and the array value will be the variable value.
5349
-     * @return boolean|array
5349
+     * @return false|null
5350 5350
      */
5351 5351
     public function invokeEvent($evtName, $extParams = array())
5352 5352
     {
@@ -5767,7 +5767,7 @@  discard block
 block discarded – undo
5767 5767
 
5768 5768
     /**
5769 5769
      * @param string $string
5770
-     * @return mixed|string
5770
+     * @return string
5771 5771
      */
5772 5772
     public function removeSanitizeSeed($string = '')
5773 5773
     {
@@ -5782,7 +5782,7 @@  discard block
 block discarded – undo
5782 5782
 
5783 5783
     /**
5784 5784
      * @param string $content
5785
-     * @return mixed|string
5785
+     * @return string
5786 5786
      */
5787 5787
     public function cleanUpMODXTags($content = '')
5788 5788
     {
@@ -5945,7 +5945,7 @@  discard block
 block discarded – undo
5945 5945
 
5946 5946
     /**
5947 5947
      * @param string $str
5948
-     * @return bool|mixed|string
5948
+     * @return string
5949 5949
      */
5950 5950
     public function atBindFileContent($str = '')
5951 5951
     {
@@ -5996,8 +5996,8 @@  discard block
 block discarded – undo
5996 5996
     }
5997 5997
 
5998 5998
     /**
5999
-     * @param $str
6000
-     * @return bool|string
5999
+     * @param string $str
6000
+     * @return false|string
6001 6001
      */
6002 6002
     public function getExtFromFilename($str)
6003 6003
     {
@@ -6025,7 +6025,7 @@  discard block
 block discarded – undo
6025 6025
      * @param string $text Error message
6026 6026
      * @param string $file File where the error was detected
6027 6027
      * @param string $line Line number within $file
6028
-     * @return boolean
6028
+     * @return boolean|null
6029 6029
      */
6030 6030
     public function phpError($nr, $text, $file, $line)
6031 6031
     {
@@ -6077,7 +6077,7 @@  discard block
 block discarded – undo
6077 6077
      * @param string $text
6078 6078
      * @param string $line
6079 6079
      * @param string $output
6080
-     * @return bool
6080
+     * @return null|boolean
6081 6081
      */
6082 6082
     public function messageQuit($msg = 'unspecified error', $query = '', $is_error = true, $nr = '', $file = '', $source = '', $text = '', $line = '', $output = '')
6083 6083
     {
@@ -6499,7 +6499,7 @@  discard block
 block discarded – undo
6499 6499
 
6500 6500
     /**
6501 6501
      * @param string $str
6502
-     * @return bool|mixed|string
6502
+     * @return string
6503 6503
      */
6504 6504
     public function atBindInclude($str = '')
6505 6505
     {
@@ -6550,7 +6550,7 @@  discard block
 block discarded – undo
6550 6550
      * @param $str
6551 6551
      * @param int $flags
6552 6552
      * @param string $encode
6553
-     * @return mixed
6553
+     * @return string
6554 6554
      */
6555 6555
     public function htmlspecialchars($str, $flags = ENT_COMPAT, $encode = '')
6556 6556
     {
@@ -6559,7 +6559,7 @@  discard block
 block discarded – undo
6559 6559
     }
6560 6560
 
6561 6561
     /**
6562
-     * @param $string
6562
+     * @param string $string
6563 6563
      * @param bool $returnData
6564 6564
      * @return bool|mixed
6565 6565
      */
Please login to merge, or discard this patch.
manager/includes/extenders/export.class.inc.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -102,6 +102,9 @@  discard block
 block discarded – undo
102 102
 		return $rs;
103 103
 	}
104 104
 
105
+    /**
106
+     * @param string $filepath
107
+     */
105 108
     public function makeFile($docid, $filepath)
106 109
 	{
107 110
 		global  $modx,$_lang;
@@ -250,6 +253,9 @@  discard block
 block discarded – undo
250 253
 		return implode("\n", $this->output);
251 254
 	}
252 255
 
256
+    /**
257
+     * @param string $url
258
+     */
253 259
     public function curl_get_contents($url, $timeout = 30 )
254 260
     {
255 261
     	if(!function_exists('curl_init')) return @file_get_contents($url);
Please login to merge, or discard this patch.
Braces   +85 added lines, -69 removed lines patch added patch discarded remove patch
@@ -13,27 +13,31 @@  discard block
 block discarded – undo
13 13
     public $dirCheckCount = 0;
14 14
 
15 15
     public function __construct()
16
-	{
16
+    {
17 17
 		global $modx;
18 18
 
19
-		if(!defined('MODX_BASE_PATH'))  return false;
19
+		if(!defined('MODX_BASE_PATH')) {
20
+		    return false;
21
+		}
20 22
 		$this->exportstart = $this->get_mtime();
21 23
 		$this->count = 0;
22 24
 		$this->setUrlMode();
23 25
 		$this->generate_mode = 'crawl';
24 26
 		$this->targetDir = $modx->config['base_path'] . 'temp/export';
25
-		if(!isset($this->total)) $this->getTotal();
27
+		if(!isset($this->total)) {
28
+		    $this->getTotal();
29
+		}
26 30
 	}
27 31
 
28 32
     public function setExportDir($dir)
29
-	{
33
+    {
30 34
 		$dir = str_replace('\\','/',$dir);
31 35
 		$dir = rtrim($dir, '/');
32 36
 		$this->targetDir = $dir;
33 37
 	}
34 38
 
35 39
     public function get_mtime()
36
-	{
40
+    {
37 41
 		$mtime = microtime();
38 42
 		$mtime = explode(' ', $mtime);
39 43
 		$mtime = $mtime[1] + $mtime[0];
@@ -41,11 +45,10 @@  discard block
 block discarded – undo
41 45
 	}
42 46
 
43 47
     public function setUrlMode()
44
-	{
48
+    {
45 49
 		global $modx;
46 50
 
47
-		if($modx->config['friendly_urls']==0)
48
-		{
51
+		if($modx->config['friendly_urls']==0) {
49 52
 			$modx->config['friendly_urls']  = 1;
50 53
 			$modx->config['use_alias_path'] = 1;
51 54
 			$modx->clearCache('full');
@@ -54,13 +57,12 @@  discard block
 block discarded – undo
54 57
 	}
55 58
 
56 59
     public function getTotal($ignore_ids='', $noncache='0')
57
-	{
60
+    {
58 61
 		global $modx;
59 62
 		$tbl_site_content = $modx->getFullTableName('site_content');
60 63
 
61 64
 		$ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
62
-		if(count($ignore_ids)>0)
63
-		{
65
+		if(count($ignore_ids)>0) {
64 66
 			$ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
65 67
 		} else {
66 68
 			$ignore_ids = '';
@@ -76,67 +78,80 @@  discard block
 block discarded – undo
76 78
 	}
77 79
 
78 80
     public function removeDirectoryAll($directory='')
79
-	{
81
+    {
80 82
 	    $rs = false;
81
-		if(empty($directory)) $directory = $this->targetDir;
83
+		if(empty($directory)) {
84
+		    $directory = $this->targetDir;
85
+		}
82 86
 		$directory = rtrim($directory,'/');
83 87
 		// if the path is not valid or is not a directory ...
84
-		if(empty($directory)) return false;
85
-		if(strpos($directory,MODX_BASE_PATH)===false) return $rs;
88
+		if(empty($directory)) {
89
+		    return false;
90
+		}
91
+		if(strpos($directory,MODX_BASE_PATH)===false) {
92
+		    return $rs;
93
+		}
86 94
 
87
-		if(!is_dir($directory))          return $rs;
88
-		elseif(!is_readable($directory)) return $rs;
89
-		else
90
-		{
95
+		if(!is_dir($directory)) {
96
+		    return $rs;
97
+		} elseif(!is_readable($directory)) {
98
+		    return $rs;
99
+		} else {
91 100
 			$files = glob($directory . '/*');
92
-			if(!empty($files))
93
-			{
94
-    			foreach($files as $path)
95
-    			{
101
+			if(!empty($files)) {
102
+    			foreach($files as $path) {
96 103
                     $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path);
97 104
     			}
98 105
 			}
99 106
 		}
100
-		if($directory !== $this->targetDir) $rs = rmdir($directory);
107
+		if($directory !== $this->targetDir) {
108
+		    $rs = rmdir($directory);
109
+		}
101 110
 
102 111
 		return $rs;
103 112
 	}
104 113
 
105 114
     public function makeFile($docid, $filepath)
106
-	{
115
+    {
107 116
 		global  $modx,$_lang;
108 117
 		$file_permission = octdec($modx->config['new_file_permissions']);
109
-		if($this->generate_mode==='direct')
110
-		{
118
+		if($this->generate_mode==='direct') {
111 119
 			$back_lang = $_lang;
112 120
 			$src = $modx->executeParser($docid);
113 121
 
114 122
 			$_lang = $back_lang;
123
+		} else {
124
+		    $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
115 125
 		}
116
-		else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
117 126
 
118 127
 
119
-		if($src !== false)
120
-		{
121
-			if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src);
128
+		if($src !== false) {
129
+			if($this->repl_before!==$this->repl_after) {
130
+			    $src = str_replace($this->repl_before,$this->repl_after,$src);
131
+			}
122 132
 			$result = file_put_contents($filepath,$src);
123
-			if($result!==false) @chmod($filepath, $file_permission);
133
+			if($result!==false) {
134
+			    @chmod($filepath, $file_permission);
135
+			}
124 136
 
125
-			if($result !== false) return 'success';
126
-			else                  return 'failed_no_write';
137
+			if($result !== false) {
138
+			    return 'success';
139
+			} else {
140
+			    return 'failed_no_write';
141
+			}
142
+		} else {
143
+		    return 'failed_no_retrieve';
127 144
 		}
128
-		else                      return 'failed_no_retrieve';
129 145
 	}
130 146
 
131 147
     public function getFileName($docid, $alias='', $prefix, $suffix)
132
-	{
148
+    {
133 149
 		global $modx;
134 150
 
135
-		if($alias==='') $filename = $prefix.$docid.$suffix;
136
-		else
137
-		{
138
-			if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false)
139
-			{
151
+		if($alias==='') {
152
+		    $filename = $prefix.$docid.$suffix;
153
+		} else {
154
+			if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false) {
140 155
 				$suffix = '';
141 156
 			}
142 157
 			$filename = $prefix.$alias.$suffix;
@@ -145,7 +160,7 @@  discard block
 block discarded – undo
145 160
 	}
146 161
 
147 162
     public function run($parent=0)
148
-	{
163
+    {
149 164
 		global $_lang;
150 165
 		global $modx;
151 166
 
@@ -187,24 +202,20 @@  discard block
 block discarded – undo
187 202
 		$ph = array();
188 203
 		$ph['total']     = $this->total;
189 204
 		$folder_permission = octdec($modx->config['new_folder_permissions']);
190
-		while($row = $modx->db->getRow($rs))
191
-		{
205
+		while($row = $modx->db->getRow($rs)) {
192 206
 			$this->count++;
193 207
             $filename = '';
194 208
 			$row['count']     = $this->count;
195 209
 			$row['url'] = $modx->makeUrl($row['id']);
196 210
 
197
-			if (!$row['wasNull'])
198
-			{ // needs writing a document
211
+			if (!$row['wasNull']) {
212
+// needs writing a document
199 213
 				$docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix);
200 214
 				$filename = $dirpath.$docname;
201
-				if (!is_file($filename))
202
-				{
203
-					if($row['published']==='1')
204
-					{
215
+				if (!is_file($filename)) {
216
+					if($row['published']==='1') {
205 217
 						$status = $this->makeFile($row['id'], $filename);
206
-						switch($status)
207
-						{
218
+						switch($status) {
208 219
 							case 'failed_no_write'   :
209 220
                                                             $row['status'] = $msg_failed_no_write;
210 221
                                                             break;
@@ -214,34 +225,38 @@  discard block
 block discarded – undo
214 225
 							default:
215 226
                                                             $row['status'] = $msg_success;
216 227
 						}
228
+					} else {
229
+					    $row['status'] = $msg_failed_no_retrieve;
217 230
 					}
218
-					else $row['status'] = $msg_failed_no_retrieve;
231
+				} else {
232
+				    $row['status'] = $msg_success_skip_doc;
219 233
 				}
220
-				else     $row['status'] = $msg_success_skip_doc;
221 234
 				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
222
-			}
223
-			else
224
-			{
235
+			} else {
225 236
 				$row['status'] = $msg_success_skip_dir;
226 237
 				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
227 238
 			}
228
-			if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false))
229
-			{ // needs making a folder
239
+			if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false)) {
240
+// needs making a folder
230 241
 				$end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231 242
 				$dir_path = $dirpath . $end_dir;
232
-				if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
233
-				if (!is_dir($dir_path))
234
-				{
235
-					if (is_file($dir_path)) @unlink($dir_path);
243
+				if(strpos($dir_path,MODX_BASE_PATH)===false) {
244
+				    return FALSE;
245
+				}
246
+				if (!is_dir($dir_path)) {
247
+					if (is_file($dir_path)) {
248
+					    @unlink($dir_path);
249
+					}
236 250
 					mkdir($dir_path);
237 251
 					@chmod($dir_path, $folder_permission);
238 252
 
239 253
 				}
240 254
 
241 255
 
242
-				if($modx->config['make_folders']==='1' && $row['published']==='1')
243
-				{
244
-					if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html');
256
+				if($modx->config['make_folders']==='1' && $row['published']==='1') {
257
+					if( ! empty($filename) && is_file($filename)) {
258
+					    rename($filename,$dir_path . '/index.html');
259
+					}
245 260
 				}
246 261
 				$this->targetDir = $dir_path;
247 262
 				$this->run($row['id']);
@@ -252,7 +267,9 @@  discard block
 block discarded – undo
252 267
 
253 268
     public function curl_get_contents($url, $timeout = 30 )
254 269
     {
255
-    	if(!function_exists('curl_init')) return @file_get_contents($url);
270
+    	if(!function_exists('curl_init')) {
271
+    	    return @file_get_contents($url);
272
+    	}
256 273
 
257 274
         $ch = curl_init();
258 275
         curl_setopt($ch, CURLOPT_URL, $url);
@@ -269,8 +286,7 @@  discard block
 block discarded – undo
269 286
 
270 287
     public function parsePlaceholder($tpl,$ph=array())
271 288
     {
272
-    	foreach($ph as $k=>$v)
273
-    	{
289
+    	foreach($ph as $k=>$v) {
274 290
     		$k = "[+{$k}+]";
275 291
     		$tpl = str_replace($k,$v,$tpl);
276 292
     	}
Please login to merge, or discard this patch.
manager/includes/extenders/maketable.class.php 2 patches
Doc Comments   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	/**
86 86
 	 * Sets the class attribute of the main HTML TABLE.
87 87
 	 *
88
-	 * @param $value A class for the main HTML TABLE.
88
+	 * @param string $value A class for the main HTML TABLE.
89 89
 	 */
90 90
     public function setTableClass($value) {
91 91
 		$this->tableClass= $value;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	/**
131 131
 	 * Sets the class attribute of regular table rows.
132 132
 	 *
133
-	 * @param $value A class for regular table rows.
133
+	 * @param string $value A class for regular table rows.
134 134
 	 */
135 135
     public function setRowRegularClass($value) {
136 136
 		$this->rowRegularClass= $value;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	/**
140 140
 	 * Sets the class attribute of alternate table rows.
141 141
 	 *
142
-	 * @param $value A class for alternate table rows.
142
+	 * @param string $value A class for alternate table rows.
143 143
 	 */
144 144
     public function setRowAlternateClass($value) {
145 145
 		$this->rowAlternateClass= $value;
@@ -215,6 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @param $value An Array of column widths in the order of the keys in the
217 217
 	 * 			source table array.
218
+	 * @param string[] $widthArray
218 219
 	 */
219 220
     public function setColumnWidths($widthArray) {
220 221
 		$this->columnWidths= $widthArray;
@@ -242,7 +243,7 @@  discard block
 block discarded – undo
242 243
 	/**
243 244
 	 * Retrieves the width of a specific table column by index position.
244 245
 	 *
245
-	 * @param $columnPosition The index of the column to get the width for.
246
+	 * @param integer $columnPosition The index of the column to get the width for.
246 247
 	 */
247 248
     public function getColumnWidth($columnPosition) {
248 249
 		$currentWidth= '';
@@ -256,6 +257,7 @@  discard block
 block discarded – undo
256 257
 	 * Determines what class the current row should have applied.
257 258
 	 *
258 259
 	 * @param $value The position of the current row being rendered.
260
+	 * @param integer $position
259 261
 	 */
260 262
     public function determineRowClass($position) {
261 263
 		switch ($this->rowAlternatingScheme) {
Please login to merge, or discard this patch.
Braces   +83 added lines, -42 removed lines patch added patch discarded remove patch
@@ -8,7 +8,8 @@  discard block
 block discarded – undo
8 8
  *
9 9
  * @author Jason Coward <[email protected]> (MODX)
10 10
  */
11
-class MakeTable {
11
+class MakeTable
12
+{
12 13
 	public $actionField;
13 14
     public $cellAction;
14 15
     public $linkAction;
@@ -33,7 +34,8 @@  discard block
 block discarded – undo
33 34
     public $fieldHeaders;
34 35
     public $extra;
35 36
 
36
-    public function __construct() {
37
+    public function __construct()
38
+    {
37 39
 		$this->fieldHeaders= array();
38 40
 		$this->excludeFields= array();
39 41
 		$this->actionField= '';
@@ -60,7 +62,8 @@  discard block
 block discarded – undo
60 62
 	 *
61 63
 	 * @param $value A URL to execute when table cells are clicked.
62 64
 	 */
63
-    public function setCellAction($value) {
65
+    public function setCellAction($value)
66
+    {
64 67
 		$this->cellAction= $this->prepareLink($value);
65 68
 	}
66 69
 
@@ -69,7 +72,8 @@  discard block
 block discarded – undo
69 72
 	 *
70 73
 	 * @param $value A URL to execute when text within table cells are clicked.
71 74
 	 */
72
-    public function setLinkAction($value) {
75
+    public function setLinkAction($value)
76
+    {
73 77
 		$this->linkAction= $this->prepareLink($value);
74 78
 	}
75 79
 
@@ -78,7 +82,8 @@  discard block
 block discarded – undo
78 82
 	 *
79 83
 	 * @param $value A valid width attribute for the HTML TABLE tag
80 84
 	 */
81
-    public function setTableWidth($value) {
85
+    public function setTableWidth($value)
86
+    {
82 87
 		$this->tableWidth= $value;
83 88
 	}
84 89
 
@@ -87,7 +92,8 @@  discard block
 block discarded – undo
87 92
 	 *
88 93
 	 * @param $value A class for the main HTML TABLE.
89 94
 	 */
90
-    public function setTableClass($value) {
95
+    public function setTableClass($value)
96
+    {
91 97
 		$this->tableClass= $value;
92 98
 	}
93 99
 
@@ -96,7 +102,8 @@  discard block
 block discarded – undo
96 102
 	 *
97 103
 	 * @param $value A class for the main HTML TABLE.
98 104
 	 */
99
-    public function setTableID($value) {
105
+    public function setTableID($value)
106
+    {
100 107
 		$this->tableID= $value;
101 108
 	}
102 109
 
@@ -105,7 +112,8 @@  discard block
 block discarded – undo
105 112
 	 *
106 113
 	 * @param $value A class for the table header row.
107 114
 	 */
108
-    public function setRowHeaderClass($value) {
115
+    public function setRowHeaderClass($value)
116
+    {
109 117
 		$this->rowHeaderClass= $value;
110 118
 	}
111 119
 
@@ -114,7 +122,8 @@  discard block
 block discarded – undo
114 122
 	 *
115 123
 	 * @param $value A class for the table header row.
116 124
 	 */
117
-    public function setThHeaderClass($value) {
125
+    public function setThHeaderClass($value)
126
+    {
118 127
 		$this->thClass= $value;
119 128
 	}
120 129
 
@@ -123,7 +132,8 @@  discard block
 block discarded – undo
123 132
 	 *
124 133
 	 * @param $value A class for the column header row.
125 134
 	 */
126
-    public function setColumnHeaderClass($value) {
135
+    public function setColumnHeaderClass($value)
136
+    {
127 137
 		$this->columnHeaderClass= $value;
128 138
 	}
129 139
 
@@ -132,7 +142,8 @@  discard block
 block discarded – undo
132 142
 	 *
133 143
 	 * @param $value A class for regular table rows.
134 144
 	 */
135
-    public function setRowRegularClass($value) {
145
+    public function setRowRegularClass($value)
146
+    {
136 147
 		$this->rowRegularClass= $value;
137 148
 	}
138 149
 
@@ -141,7 +152,8 @@  discard block
 block discarded – undo
141 152
 	 *
142 153
 	 * @param $value A class for alternate table rows.
143 154
 	 */
144
-    public function setRowAlternateClass($value) {
155
+    public function setRowAlternateClass($value)
156
+    {
145 157
 		$this->rowAlternateClass= $value;
146 158
 	}
147 159
 
@@ -150,7 +162,8 @@  discard block
 block discarded – undo
150 162
 	 *
151 163
 	 * @param $value Indicates the INPUT form element type attribute.
152 164
 	 */
153
-    public function setFormElementType($value) {
165
+    public function setFormElementType($value)
166
+    {
154 167
 		$this->formElementType= $value;
155 168
 	}
156 169
 
@@ -159,7 +172,8 @@  discard block
 block discarded – undo
159 172
 	 *
160 173
 	 * @param $value Indicates the INPUT form element name attribute.
161 174
 	 */
162
-    public function setFormElementName($value) {
175
+    public function setFormElementName($value)
176
+    {
163 177
 		$this->formElementName= $value;
164 178
 	}
165 179
 
@@ -169,7 +183,8 @@  discard block
 block discarded – undo
169 183
 	 *
170 184
 	 * @param $value Indicates the FORM name attribute.
171 185
 	 */
172
-    public function setFormName($value) {
186
+    public function setFormName($value)
187
+    {
173 188
 		$this->formName= $value;
174 189
 	}
175 190
 
@@ -178,7 +193,8 @@  discard block
 block discarded – undo
178 193
 	 *
179 194
 	 * @param $value Indicates the FORM action attribute.
180 195
 	 */
181
-    public function setFormAction($value) {
196
+    public function setFormAction($value)
197
+    {
182 198
 		$this->formAction= $value;
183 199
 	}
184 200
 
@@ -187,7 +203,8 @@  discard block
 block discarded – undo
187 203
 	 *
188 204
 	 * @param $value An Array of field keys to exclude from the table.
189 205
 	 */
190
-    public function setExcludeFields($value) {
206
+    public function setExcludeFields($value)
207
+    {
191 208
 		$this->excludeFields= $value;
192 209
 	}
193 210
 
@@ -196,7 +213,8 @@  discard block
 block discarded – undo
196 213
 	 *
197 214
 	 * @param $value 'ODD' or 'EVEN' to indicate the alternate row scheme.
198 215
 	 */
199
-    public function setRowAlternatingScheme($value) {
216
+    public function setRowAlternatingScheme($value)
217
+    {
200 218
 		$this->rowAlternatingScheme= $value;
201 219
 	}
202 220
 
@@ -206,7 +224,8 @@  discard block
 block discarded – undo
206 224
 	 *
207 225
 	 * @param $value The key of the field to add as a query string parameter.
208 226
 	 */
209
-    public function setActionFieldName($value) {
227
+    public function setActionFieldName($value)
228
+    {
210 229
 		$this->actionField= $value;
211 230
 	}
212 231
 
@@ -216,7 +235,8 @@  discard block
 block discarded – undo
216 235
 	 * @param $value An Array of column widths in the order of the keys in the
217 236
 	 * 			source table array.
218 237
 	 */
219
-    public function setColumnWidths($widthArray) {
238
+    public function setColumnWidths($widthArray)
239
+    {
220 240
 		$this->columnWidths= $widthArray;
221 241
 	}
222 242
 
@@ -225,7 +245,8 @@  discard block
 block discarded – undo
225 245
 	 *
226 246
 	 * @param $value Indicates the INPUT form element type attribute.
227 247
 	 */
228
-    public function setSelectedValues($valueArray) {
248
+    public function setSelectedValues($valueArray)
249
+    {
229 250
 		$this->selectedValues= $valueArray;
230 251
 	}
231 252
 
@@ -235,7 +256,8 @@  discard block
 block discarded – undo
235 256
 	 *
236 257
 	 * @param $value A string of additional content.
237 258
 	 */
238
-    public function setExtra($value) {
259
+    public function setExtra($value)
260
+    {
239 261
 		$this->extra= $value;
240 262
 	}
241 263
 
@@ -244,7 +266,8 @@  discard block
 block discarded – undo
244 266
 	 *
245 267
 	 * @param $columnPosition The index of the column to get the width for.
246 268
 	 */
247
-    public function getColumnWidth($columnPosition) {
269
+    public function getColumnWidth($columnPosition)
270
+    {
248 271
 		$currentWidth= '';
249 272
 		if (is_array($this->columnWidths)) {
250 273
 			$currentWidth= $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : '';
@@ -257,7 +280,8 @@  discard block
 block discarded – undo
257 280
 	 *
258 281
 	 * @param $value The position of the current row being rendered.
259 282
 	 */
260
-    public function determineRowClass($position) {
283
+    public function determineRowClass($position)
284
+    {
261 285
 		switch ($this->rowAlternatingScheme) {
262 286
 			case 'ODD' :
263 287
 				$modRemainder= 1;
@@ -280,7 +304,8 @@  discard block
 block discarded – undo
280 304
 	 *
281 305
 	 * @param $value Indicates the INPUT form element type attribute.
282 306
 	 */
283
-    public function getCellAction($currentActionFieldValue) {
307
+    public function getCellAction($currentActionFieldValue)
308
+    {
284 309
 		if ($this->cellAction) {
285 310
 			$cellAction= ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" ';
286 311
 		}
@@ -293,7 +318,8 @@  discard block
 block discarded – undo
293 318
 	 * @param $currentActionFieldValue The value to be applied to the link action.
294 319
 	 * @param $value The value of the cell.
295 320
 	 */
296
-    public function createCellText($currentActionFieldValue, $value) {
321
+    public function createCellText($currentActionFieldValue, $value)
322
+    {
297 323
 		$cell .= $value;
298 324
 		if ($this->linkAction) {
299 325
 			$cell= '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>';
@@ -305,7 +331,8 @@  discard block
 block discarded – undo
305 331
 	 * Sets an option to generate a check all link when checkbox is indicated
306 332
 	 * as the table formElementType.
307 333
 	 */
308
-    public function setAllOption() {
334
+    public function setAllOption()
335
+    {
309 336
 		$this->allOption= 1;
310 337
 	}
311 338
 
@@ -314,7 +341,8 @@  discard block
 block discarded – undo
314 341
 	 *
315 342
 	 * @param $value Indicates the INPUT form element type attribute.
316 343
 	 */
317
-    public function prepareLink($link) {
344
+    public function prepareLink($link)
345
+    {
318 346
 		if (strstr($link, '?')) {
319 347
 			$end= '&';
320 348
 		} else {
@@ -333,7 +361,8 @@  discard block
 block discarded – undo
333 361
 	 * the $fieldsArray where the values represent the alt heading content
334 362
 	 * for each column.
335 363
 	 */
336
-    public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="") {
364
+    public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="")
365
+    {
337 366
 	    global $_lang;
338 367
 		if (is_array($fieldsArray)) {
339 368
 			$i= 0;
@@ -369,7 +398,8 @@  discard block
 block discarded – undo
369 398
 			if ($this->formElementType) {
370 399
 				$table= "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table;
371 400
 			}
372
-			if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists.
401
+			if (strlen($this->pageNav) > 1) {
402
+//changed to display the pagination if exists.
373 403
 				/* commented this part because of cookie
374 404
 				$table .= '<div id="max-display-records" ><select style="display:inline" onchange="javascript:updatePageSize(this[this.selectedIndex].value);">';
375 405
 				$pageSizes= array (10, 25, 50, 100, 250);
@@ -416,7 +446,8 @@  discard block
 block discarded – undo
416 446
 	 * @param $numRecords The number of records to show per page.
417 447
 	 * @param $qs An optional query string to be appended to the paging links
418 448
 	 */
419
-    public function createPagingNavigation($numRecords, $qs='') {
449
+    public function createPagingNavigation($numRecords, $qs='')
450
+    {
420 451
 		global $_lang;
421 452
 		$currentPage= (is_numeric($_GET['page']) ? $_GET['page'] : 1);
422 453
 		$numPages= ceil($numRecords / MAX_DISPLAY_RECORDS_NUM);
@@ -431,10 +462,11 @@  discard block
 block discarded – undo
431 462
 			$offset= -4 + ($currentPage < 5 ? (5 - $currentPage) : 0);
432 463
 			$i= 1;
433 464
 			while ($i < 10 && ($currentPage + $offset <= $numPages)) {
434
-				if ($currentPage == $currentPage + $offset)
435
-					$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true);
436
-				else
437
-					$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset);
465
+				if ($currentPage == $currentPage + $offset) {
466
+									$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true);
467
+				} else {
468
+									$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset);
469
+				}
438 470
 				$i ++;
439 471
 				$offset ++;
440 472
 			}
@@ -457,11 +489,14 @@  discard block
 block discarded – undo
457 489
 	 * @param $currentPage Indicates if the link is to the current page.
458 490
 	 * @param $qs And optional query string to be appended to the link.
459 491
 	 */
460
-    public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='') {
492
+    public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='')
493
+    {
461 494
 		global $modx;
462 495
 		$orderBy= !empty($_GET['orderby'])? '&orderby=' . $_GET['orderby']: '';
463 496
 		$orderDir= !empty($_GET['orderdir'])? '&orderdir=' . $_GET['orderdir']: '';
464
-		if (!empty($qs)) $qs= "?$qs";
497
+		if (!empty($qs)) {
498
+		    $qs= "?$qs";
499
+		}
465 500
 		$link= empty($link)? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs . "page=$pageNum$orderBy$orderDir"): $this->prepareLink($link) . "page=$pageNum";
466 501
 		$nav .= '<li'.($currentPage? ' class="currentPage"': '').'><a'.($currentPage? ' class="currentPage"': '').' href="'.$link.'">'.$displayText.'</a></li>'."\n";
467 502
 		return $nav;
@@ -474,7 +509,8 @@  discard block
 block discarded – undo
474 509
 	 * @param $isChecked Indicates if the checked attribute should apply to the
475 510
 	 * element.
476 511
 	 */
477
-    public function addFormField($value, $isChecked) {
512
+    public function addFormField($value, $isChecked)
513
+    {
478 514
 		if ($this->formElementType) {
479 515
 			$checked= $isChecked? "checked ": "";
480 516
 			$field= "\t\t".'<td><input type="'.$this->formElementType.'" name="'. ($this->formElementName ? $this->formElementName : $value).'"  value="'.$value.'" '.$checked.'/></td>'."\n";
@@ -486,7 +522,8 @@  discard block
 block discarded – undo
486 522
 	 * Generates the proper LIMIT clause for queries to retrieve paged results in
487 523
 	 * a MakeTable $fieldsArray.
488 524
 	 */
489
-    public function handlePaging() {
525
+    public function handlePaging()
526
+    {
490 527
 		$offset= (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0;
491 528
 		$limitClause= ' LIMIT '. ($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM;
492 529
 		return $limitClause;
@@ -498,7 +535,8 @@  discard block
 block discarded – undo
498 535
 	 *
499 536
 	 * @param $natural_order If true, the results are returned in natural order.
500 537
 	 */
501
-    public function handleSorting($natural_order=false) {
538
+    public function handleSorting($natural_order=false)
539
+    {
502 540
 		$orderByClause= '';
503 541
 		if (!$natural_order) {
504 542
 			$orderby= !empty($_GET['orderby'])? $_GET['orderby']: "id";
@@ -516,7 +554,8 @@  discard block
 block discarded – undo
516 554
 	 * @param $text The text for the link (e.g. table column header).
517 555
 	 * @param $qs An optional query string to append to the order by link.
518 556
 	 */
519
-    public function prepareOrderByLink($key, $text, $qs='') {
557
+    public function prepareOrderByLink($key, $text, $qs='')
558
+    {
520 559
 		global $modx;
521 560
 		if (!empty($_GET['orderdir'])) {
522 561
 			$orderDir= strtolower($_GET['orderdir'])=='desc'? '&orderdir=asc': '&orderdir=desc';
@@ -524,7 +563,9 @@  discard block
 block discarded – undo
524 563
 			$orderDir= '&orderdir=asc';
525 564
 		}
526 565
 		if (!empty($qs)) {
527
-			if (!strrpos($qs, '&')==strlen($qs)-1) $qs.= '&';
566
+			if (!strrpos($qs, '&')==strlen($qs)-1) {
567
+			    $qs.= '&';
568
+			}
528 569
 		}
529 570
 		return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>';
530 571
 	}
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers.class.inc.php 2 patches
Doc Comments   +35 added lines patch added patch discarded remove patch
@@ -30,6 +30,11 @@  discard block
 block discarded – undo
30 30
         $this->condModifiers = '=,is,eq,equals,ne,neq,notequals,isnot,isnt,not,%,isempty,isnotempty,isntempty,>=,gte,eg,gte,greaterthan,>,gt,isgreaterthan,isgt,lowerthan,<,lt,<=,lte,islte,islowerthan,islt,el,find,in,inarray,in_array,fnmatch,wcard,wcard_match,wildcard,wildcard_match,is_file,is_dir,file_exists,is_readable,is_writable,is_image,regex,preg,preg_match,memberof,mo,isinrole,ir';
31 31
     }
32 32
 
33
+    /**
34
+     * @param string $key
35
+     * @param string $value
36
+     * @param string|false $modifiers
37
+     */
33 38
     public function phxFilter($key,$value,$modifiers)
34 39
     {
35 40
         global $modx;
@@ -51,6 +56,10 @@  discard block
 block discarded – undo
51 56
         return $value;
52 57
     }
53 58
 
59
+    /**
60
+     * @param string $mode
61
+     * @param string $modifiers
62
+     */
54 63
     public function _getDelim($mode,$modifiers) {
55 64
         $c = substr($modifiers,0,1);
56 65
         if(!in_array($c, array('"', "'", '`')) ) return false;
@@ -62,6 +71,11 @@  discard block
 block discarded – undo
62 71
         return  $c;
63 72
     }
64 73
 
74
+    /**
75
+     * @param string $mode
76
+     * @param false|string $delim
77
+     * @param string $modifiers
78
+     */
65 79
     public function _getOpt($mode,$delim,$modifiers) {
66 80
         if($delim) {
67 81
             if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
@@ -80,6 +94,14 @@  discard block
 block discarded – undo
80 94
             return $opt;
81 95
         }
82 96
     }
97
+
98
+    /**
99
+     * @param string $mode
100
+     * @param false|string $delim
101
+     * @param string $modifiers
102
+     *
103
+     * @return string
104
+     */
83 105
     public function _getRemainModifiers($mode,$delim,$modifiers) {
84 106
         if($delim) {
85 107
             if($mode=='(')
@@ -107,6 +129,9 @@  discard block
 block discarded – undo
107 129
         return substr($string,strpos($string, $delim)+$len);
108 130
     }
109 131
 
132
+    /**
133
+     * @param string $modifiers
134
+     */
110 135
     public function splitEachModifiers($modifiers) {
111 136
         global $modx;
112 137
 
@@ -242,6 +267,9 @@  discard block
 block discarded – undo
242 267
         else                  return true;
243 268
     }
244 269
 
270
+    /**
271
+     * @param string $cmd
272
+     */
245 273
     public function getValueFromPreset($key, $value, $cmd, $opt)
246 274
     {
247 275
         global $modx;
@@ -927,6 +955,9 @@  discard block
 block discarded – undo
927 955
         return $value;
928 956
     }
929 957
 
958
+    /**
959
+     * @param string $cmd
960
+     */
930 961
     public function includeMdfFile($cmd) {
931 962
         global $modx;
932 963
         $key = $this->key;
@@ -1082,6 +1113,10 @@  discard block
 block discarded – undo
1082 1113
     }
1083 1114
 
1084 1115
     // Sets a placeholder variable which can only be access by Modifiers
1116
+
1117
+    /**
1118
+     * @param string $value
1119
+     */
1085 1120
     public function setModifiersVariable($key, $value) {
1086 1121
         if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1087 1122
     }
Please login to merge, or discard this patch.
Braces   +544 added lines, -282 removed lines patch added patch discarded remove patch
@@ -1,8 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
3
+if(!defined('MODX_CORE_PATH')) {
4
+    define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
5
+}
4 6
 
5
-class MODIFIERS {
7
+class MODIFIERS
8
+{
6 9
 
7 10
     public $placeholders = array();
8 11
     public $vars = array();
@@ -26,14 +29,18 @@  discard block
 block discarded – undo
26 29
     {
27 30
         global $modx;
28 31
 
29
-        if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']);
32
+        if (function_exists('mb_internal_encoding')) {
33
+            mb_internal_encoding($modx->config['modx_charset']);
34
+        }
30 35
         $this->condModifiers = '=,is,eq,equals,ne,neq,notequals,isnot,isnt,not,%,isempty,isnotempty,isntempty,>=,gte,eg,gte,greaterthan,>,gt,isgreaterthan,isgt,lowerthan,<,lt,<=,lte,islte,islowerthan,islt,el,find,in,inarray,in_array,fnmatch,wcard,wcard_match,wildcard,wildcard_match,is_file,is_dir,file_exists,is_readable,is_writable,is_image,regex,preg,preg_match,memberof,mo,isinrole,ir';
31 36
     }
32 37
 
33 38
     public function phxFilter($key,$value,$modifiers)
34 39
     {
35 40
         global $modx;
36
-        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value);
41
+        if(substr($modifiers,0,3)!=='id(') {
42
+            $value = $this->parseDocumentSource($value);
43
+        }
37 44
         $this->srcValue = $value;
38 45
         $modifiers = trim($modifiers);
39 46
         $modifiers = ':'.trim($modifiers,':');
@@ -51,63 +58,81 @@  discard block
 block discarded – undo
51 58
         return $value;
52 59
     }
53 60
 
54
-    public function _getDelim($mode,$modifiers) {
61
+    public function _getDelim($mode,$modifiers)
62
+    {
55 63
         $c = substr($modifiers,0,1);
56
-        if(!in_array($c, array('"', "'", '`')) ) return false;
64
+        if(!in_array($c, array('"', "'", '`')) ) {
65
+            return false;
66
+        }
57 67
 
58 68
         $modifiers = substr($modifiers,1);
59 69
         $closure = $mode=='(' ? "{$c})" : $c;
60
-        if(strpos($modifiers, $closure)===false) return false;
70
+        if(strpos($modifiers, $closure)===false) {
71
+            return false;
72
+        }
61 73
 
62 74
         return  $c;
63 75
     }
64 76
 
65
-    public function _getOpt($mode,$delim,$modifiers) {
77
+    public function _getOpt($mode,$delim,$modifiers)
78
+    {
66 79
         if($delim) {
67
-            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
80
+            if($mode=='(') {
81
+                return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
82
+            }
68 83
 
69 84
             return substr($modifiers,1,strpos($modifiers,$delim,1)-1);
70
-        }
71
-        else {
72
-            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') );
85
+        } else {
86
+            if($mode=='(') {
87
+                return substr($modifiers,0,strpos($modifiers, ')') );
88
+            }
73 89
 
74 90
             $chars = str_split($modifiers);
75 91
             $opt='';
76 92
             foreach($chars as $c) {
77
-                if($c==':' || $c==')') break;
93
+                if($c==':' || $c==')') {
94
+                    break;
95
+                }
78 96
                 $opt .=$c;
79 97
             }
80 98
             return $opt;
81 99
         }
82 100
     }
83
-    public function _getRemainModifiers($mode,$delim,$modifiers) {
101
+    public function _getRemainModifiers($mode,$delim,$modifiers)
102
+    {
84 103
         if($delim) {
85
-            if($mode=='(')
86
-                return $this->_fetchContent($modifiers, $delim . ')');
87
-            else {
104
+            if($mode=='(') {
105
+                            return $this->_fetchContent($modifiers, $delim . ')');
106
+            } else {
88 107
                 $modifiers = trim($modifiers);
89 108
                 $modifiers = substr($modifiers,1);
90 109
                 return $this->_fetchContent($modifiers, $delim);
91 110
             }
92
-        }
93
-        else {
94
-            if($mode=='(') return $this->_fetchContent($modifiers, ')');
111
+        } else {
112
+            if($mode=='(') {
113
+                return $this->_fetchContent($modifiers, ')');
114
+            }
95 115
             $chars = str_split($modifiers);
96 116
             foreach($chars as $c) {
97
-                if($c==':') return $modifiers;
98
-                else $modifiers = substr($modifiers,1);
117
+                if($c==':') {
118
+                    return $modifiers;
119
+                } else {
120
+                    $modifiers = substr($modifiers,1);
121
+                }
99 122
             }
100 123
             return $modifiers;
101 124
         }
102 125
     }
103 126
 
104
-    public function _fetchContent($string,$delim) {
127
+    public function _fetchContent($string,$delim)
128
+    {
105 129
         $len = strlen($delim);
106 130
         $string = $this->parseDocumentSource($string);
107 131
         return substr($string,strpos($string, $delim)+$len);
108 132
     }
109 133
 
110
-    public function splitEachModifiers($modifiers) {
134
+    public function splitEachModifiers($modifiers)
135
+    {
111 136
         global $modx;
112 137
 
113 138
         $cmd = '';
@@ -118,11 +143,15 @@  discard block
 block discarded – undo
118 143
             $c = substr($modifiers,0,1);
119 144
             $modifiers = substr($modifiers,1);
120 145
 
121
-            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
146
+            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) {
147
+// :=, :!=, :<=, :>=, :!<=, :!>=
122 148
                 $c = substr($modifiers,strlen($match[1]),1);
123 149
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
124
-                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1);
125
-                else         $modifiers = substr($modifiers,strlen($match[1]));
150
+                if($c==='(') {
151
+                    $modifiers = substr($modifiers,strlen($match[1])+1);
152
+                } else {
153
+                    $modifiers = substr($modifiers,strlen($match[1]));
154
+                }
126 155
 
127 156
                 $delim     = $this->_getDelim($c,$modifiers);
128 157
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -130,13 +159,12 @@  discard block
 block discarded – undo
130 159
 
131 160
                 $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
132 161
                 $cmd = '';
133
-            }
134
-            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
162
+            } elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) {
163
+// :+3, :-3, :*3 ...
135 164
                 $modifiers = substr($modifiers,strlen($match[0]));
136 165
                 $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]);
137 166
                 $cmd = '';
138
-            }
139
-            elseif($c==='(' || $c==='=') {
167
+            } elseif($c==='(' || $c==='=') {
140 168
                 $modifiers = $m1 = trim($modifiers);
141 169
                 $delim     = $this->_getDelim($c,$modifiers);
142 170
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -146,29 +174,29 @@  discard block
 block discarded – undo
146 174
                 $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
147 175
 
148 176
                 $cmd = '';
149
-            }
150
-            elseif($c==':') {
177
+            } elseif($c==':') {
151 178
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
152
-                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
179
+                if($cmd!=='') {
180
+                    $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
181
+                }
153 182
 
154 183
                 $cmd = '';
155
-            }
156
-            elseif(trim($modifiers)=='' && trim($cmd)!=='') {
184
+            } elseif(trim($modifiers)=='' && trim($cmd)!=='') {
157 185
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
158 186
                 $cmd .= $c;
159 187
                 $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
160 188
 
161 189
                 break;
162
-            }
163
-            else {
190
+            } else {
164 191
                 $cmd .= $c;
165 192
             }
166 193
         }
167 194
 
168
-        if(empty($result)) return array();
195
+        if(empty($result)) {
196
+            return array();
197
+        }
169 198
 
170
-        foreach($result as $i=>$a)
171
-        {
199
+        foreach($result as $i=>$a) {
172 200
             $a['opt'] = $this->parseDocumentSource($a['opt']);
173 201
             $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders);
174 202
         }
@@ -181,22 +209,23 @@  discard block
 block discarded – undo
181 209
         global $modx;
182 210
         $lastKey = '';
183 211
         $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true)));
184
-        if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
185
-        if(empty($modifiers)) return '';
212
+        if(isset($this->tmpCache[$cacheKey])) {
213
+            return $this->tmpCache[$cacheKey];
214
+        }
215
+        if(empty($modifiers)) {
216
+            return '';
217
+        }
186 218
 
187
-        foreach($modifiers as $m)
188
-        {
219
+        foreach($modifiers as $m) {
189 220
             $lastKey = strtolower($m['cmd']);
190 221
         }
191 222
         $_ = explode(',',$this->condModifiers);
192
-        if(in_array($lastKey,$_))
193
-        {
223
+        if(in_array($lastKey,$_)) {
194 224
             $modifiers[] = array('cmd'=>'then','opt'=>'1');
195 225
             $modifiers[] = array('cmd'=>'else','opt'=>'0');
196 226
         }
197 227
 
198
-        foreach($modifiers as $i=>$a)
199
-        {
228
+        foreach($modifiers as $i=>$a) {
200 229
             $value = $this->Filter($key,$value, $a['cmd'], $a['opt']);
201 230
         }
202 231
         $this->tmpCache[$cacheKey] = $value;
@@ -208,25 +237,32 @@  discard block
 block discarded – undo
208 237
     {
209 238
         global $modx;
210 239
 
211
-        if($key==='documentObject') $value = $modx->documentIdentifier;
240
+        if($key==='documentObject') {
241
+            $value = $modx->documentIdentifier;
242
+        }
212 243
         $cmd = $this->parseDocumentSource($cmd);
213
-        if(preg_match('@^[1-9][/0-9]*$@',$cmd))
214
-        {
215
-            if(strpos($cmd,'/')!==false)
216
-                $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
244
+        if(preg_match('@^[1-9][/0-9]*$@',$cmd)) {
245
+            if(strpos($cmd,'/')!==false) {
246
+                            $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
247
+            }
217 248
             $opt = $cmd;
218 249
             $cmd = 'id';
219 250
         }
220 251
 
221
-        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
222
-        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
223
-        else                                           $this->elmName = '';
252
+        if(isset($modx->snippetCache["phx:{$cmd}"])) {
253
+            $this->elmName = "phx:{$cmd}";
254
+        } elseif(isset($modx->chunkCache["phx:{$cmd}"])) {
255
+            $this->elmName = "phx:{$cmd}";
256
+        } else {
257
+            $this->elmName = '';
258
+        }
224 259
 
225 260
         $cmd = strtolower($cmd);
226
-        if($this->elmName!=='')
227
-            $value = $this->getValueFromElement($key, $value, $cmd, $opt);
228
-        else
229
-            $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
261
+        if($this->elmName!=='') {
262
+                    $value = $this->getValueFromElement($key, $value, $cmd, $opt);
263
+        } else {
264
+                    $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
265
+        }
230 266
 
231 267
         $value = str_replace('[+key+]', $key, $value);
232 268
 
@@ -235,29 +271,37 @@  discard block
 block discarded – undo
235 271
 
236 272
     public function isEmpty($cmd,$value)
237 273
     {
238
-        if($value!=='') return false;
274
+        if($value!=='') {
275
+            return false;
276
+        }
239 277
 
240 278
         $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
241
-        if(in_array($cmd,$_)) return false;
242
-        else                  return true;
279
+        if(in_array($cmd,$_)) {
280
+            return false;
281
+        } else {
282
+            return true;
283
+        }
243 284
     }
244 285
 
245 286
     public function getValueFromPreset($key, $value, $cmd, $opt)
246 287
     {
247 288
         global $modx;
248 289
 
249
-        if($this->isEmpty($cmd,$value)) return '';
290
+        if($this->isEmpty($cmd,$value)) {
291
+            return '';
292
+        }
250 293
 
251 294
         $this->key = $key;
252 295
         $this->value  = $value;
253 296
         $this->opt    = $opt;
254 297
 
255
-        switch ($cmd)
256
-        {
298
+        switch ($cmd) {
257 299
             #####  Conditional Modifiers
258 300
             case 'input':
259 301
             case 'if':
260
-                if(!$opt) return $value;
302
+                if(!$opt) {
303
+                    return $value;
304
+                }
261 305
                 return $opt;
262 306
             case '=':
263 307
             case 'eq':
@@ -318,14 +362,24 @@  discard block
 block discarded – undo
318 362
             case 'file_exists':
319 363
             case 'is_readable':
320 364
             case 'is_writable':
321
-                if(!$opt) $path = $value;
322
-                else      $path = $opt;
323
-                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path');
324
-                if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/');
365
+                if(!$opt) {
366
+                    $path = $value;
367
+                } else {
368
+                    $path = $opt;
369
+                }
370
+                if(strpos($path,MODX_MANAGER_PATH)!==false) {
371
+                    exit('Can not read core path');
372
+                }
373
+                if(strpos($path,$modx->config['base_path'])===false) {
374
+                    $path = ltrim($path,'/');
375
+                }
325 376
                 $this->condition[] = (int)($cmd($path)!==false);break;
326 377
             case 'is_image':
327
-                if(!$opt) $path = $value;
328
-                else      $path = $opt;
378
+                if(!$opt) {
379
+                    $path = $value;
380
+                } else {
381
+                    $path = $opt;
382
+                }
329 383
                 if(!is_file($path)) {$this->condition[]='0';break;}
330 384
                 $_ = getimagesize($path);
331 385
                 $this->condition[] = (int)($_[0]);break;
@@ -348,17 +402,23 @@  discard block
 block discarded – undo
348 402
             case 'this':
349 403
                 $conditional = implode(' ',$this->condition);
350 404
                 $isvalid = (int)(eval("return ({$conditional});"));
351
-                if ($isvalid) return $this->srcValue;
405
+                if ($isvalid) {
406
+                    return $this->srcValue;
407
+                }
352 408
                 return NULL;
353 409
             case 'then':
354 410
                 $conditional = implode(' ',$this->condition);
355 411
                 $isvalid = (int)eval("return ({$conditional});");
356
-                if ($isvalid)  return $opt;
412
+                if ($isvalid) {
413
+                    return $opt;
414
+                }
357 415
                 return null;
358 416
             case 'else':
359 417
                 $conditional = implode(' ',$this->condition);
360 418
                 $isvalid = (int)eval("return ({$conditional});");
361
-                if (!$isvalid) return $opt;
419
+                if (!$isvalid) {
420
+                    return $opt;
421
+                }
362 422
                 break;
363 423
             case 'select':
364 424
             case 'switch':
@@ -369,8 +429,11 @@  discard block
 block discarded – undo
369 429
                     $mi = explode('=',$raw[$m],2);
370 430
                     $map[$mi[0]] = $mi[1];
371 431
                 }
372
-                if(isset($map[$value])) return $map[$value];
373
-                else                    return '';
432
+                if(isset($map[$value])) {
433
+                    return $map[$value];
434
+                } else {
435
+                    return '';
436
+                }
374 437
             ##### End of Conditional Modifiers
375 438
 
376 439
             #####  Encode / Decode / Hash / Escape
@@ -396,24 +459,25 @@  discard block
 block discarded – undo
396 459
             case 'spam_protect':
397 460
                 return str_replace(array('@','.'),array('&#64;','&#46;'),$value);
398 461
             case 'strip':
399
-                if($opt==='') $opt = ' ';
462
+                if($opt==='') {
463
+                    $opt = ' ';
464
+                }
400 465
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
401 466
             case 'strip_linefeeds':
402 467
                 return str_replace(array("\n","\r"), '', $value);
403 468
             case 'notags':
404 469
             case 'strip_tags':
405 470
             case 'remove_html':
406
-                if($opt!=='')
407
-                {
471
+                if($opt!=='') {
408 472
                     $param = array();
409
-                    foreach(explode(',',$opt) as $v)
410
-                    {
473
+                    foreach(explode(',',$opt) as $v) {
411 474
                         $v = trim($v,'</> ');
412 475
                         $param[] = "<{$v}>";
413 476
                     }
414 477
                     $params = implode(',',$param);
478
+                } else {
479
+                    $params = '';
415 480
                 }
416
-                else $params = '';
417 481
                 if(!strpos($params,'<br>')===false) {
418 482
                     $value = preg_replace('@(<br[ /]*>)\n@','$1',$value);
419 483
                     $value = preg_replace('@<br[ /]*>@',"\n",$value);
@@ -424,8 +488,11 @@  discard block
 block discarded – undo
424 488
             case 'encode_url':
425 489
                 return urlencode($value);
426 490
             case 'base64_decode':
427
-                if($opt!=='false') $opt = true;
428
-                else               $opt = false;
491
+                if($opt!=='false') {
492
+                    $opt = true;
493
+                } else {
494
+                    $opt = false;
495
+                }
429 496
                 return base64_decode($value,$opt);
430 497
             case 'encode_sha1': $cmd = 'sha1';
431 498
             case 'addslashes':
@@ -451,16 +518,19 @@  discard block
 block discarded – undo
451 518
                 return $this->strtoupper($value);
452 519
             case 'capitalize':
453 520
                 $_ = explode(' ',$value);
454
-                foreach($_ as $i=>$v)
455
-                {
521
+                foreach($_ as $i=>$v) {
456 522
                     $_[$i] = ucfirst($v);
457 523
                 }
458 524
                 return implode(' ',$_);
459 525
             case 'zenhan':
460
-                if(empty($opt)) $opt='VKas';
526
+                if(empty($opt)) {
527
+                    $opt='VKas';
528
+                }
461 529
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
462 530
             case 'hanzen':
463
-                if(empty($opt)) $opt='VKAS';
531
+                if(empty($opt)) {
532
+                    $opt='VKAS';
533
+                }
464 534
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
465 535
             case 'str_shuffle':
466 536
             case 'shuffle':
@@ -485,13 +555,18 @@  discard block
 block discarded – undo
485 555
                 $value = preg_replace('/\r/', '', $value);
486 556
                 return count(preg_split('/\n+/',$value));
487 557
             case 'strpos':
488
-                if($opt!=0&&empty($opt)) return $value;
558
+                if($opt!=0&&empty($opt)) {
559
+                    return $value;
560
+                }
489 561
                 return $this->strpos($value,$opt);
490 562
             case 'wordwrap':
491 563
                 // default: 70
492 564
                   $wrapat = (int)$opt > 0 ? (int)$opt : 70;
493
-                if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap');
494
-                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
565
+                if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
566
+                    return $this->includeMdfFile('wordwrap');
567
+                } else {
568
+                    return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
569
+                }
495 570
             case 'wrap_text':
496 571
                 $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70;
497 572
                 if($modx->config['manager_language']==='japanese-utf8') {
@@ -507,30 +582,36 @@  discard block
 block discarded – undo
507 582
                         $value = $this->substr($value,$width);
508 583
                     }
509 584
                     return implode("\n",$chunk);
585
+                } else {
586
+                                    return wordwrap($value,$width,"\n",true);
510 587
                 }
511
-                else
512
-                    return wordwrap($value,$width,"\n",true);
513 588
             case 'substr':
514
-                if(empty($opt)) break;
589
+                if(empty($opt)) {
590
+                    break;
591
+                }
515 592
                 if(strpos($opt,',')!==false) {
516 593
                     list($b,$e) = explode(',',$opt,2);
517 594
                     return $this->substr($value,$b,(int)$e);
595
+                } else {
596
+                    return $this->substr($value,$opt);
518 597
                 }
519
-                else return $this->substr($value,$opt);
520 598
             case 'limit':
521 599
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
522
-                if(strpos($opt,'+')!==false)
523
-                    list($len,$str) = explode('+',$opt,2);
524
-                else {
600
+                if(strpos($opt,'+')!==false) {
601
+                                    list($len,$str) = explode('+',$opt,2);
602
+                } else {
525 603
                     $len = $opt;
526 604
                     $str = '';
527 605
                 }
528
-                if($len==='') $len = 100;
529
-                if(abs($len) > $this->strlen($value)) $str ='';
606
+                if($len==='') {
607
+                    $len = 100;
608
+                }
609
+                if(abs($len) > $this->strlen($value)) {
610
+                    $str ='';
611
+                }
530 612
                 if(preg_match('/^[1-9][0-9]*$/',$len)) {
531 613
                     return $this->substr($value,0,$len) . $str;
532
-                }
533
-                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
614
+                } elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
534 615
                     return $str . $this->substr($value,$len);
535 616
                 }
536 617
                 break;
@@ -540,18 +621,30 @@  discard block
 block discarded – undo
540 621
                 return $this->includeMdfFile('summary');
541 622
             case 'replace':
542 623
             case 'str_replace':
543
-                if(empty($opt) || strpos($opt,',')===false) break;
544
-                if    (substr_count($opt, ',') ==1) $delim = ',';
545
-                elseif(substr_count($opt, '|') ==1) $delim = '|';
546
-                elseif(substr_count($opt, '=>')==1) $delim = '=>';
547
-                elseif(substr_count($opt, '/') ==1) $delim = '/';
548
-                else break;
624
+                if(empty($opt) || strpos($opt,',')===false) {
625
+                    break;
626
+                }
627
+                if    (substr_count($opt, ',') ==1) {
628
+                    $delim = ',';
629
+                } elseif(substr_count($opt, '|') ==1) {
630
+                    $delim = '|';
631
+                } elseif(substr_count($opt, '=>')==1) {
632
+                    $delim = '=>';
633
+                } elseif(substr_count($opt, '/') ==1) {
634
+                    $delim = '/';
635
+                } else {
636
+                    break;
637
+                }
549 638
                 list($s,$r) = explode($delim,$opt);
550
-                if($value!=='') return str_replace($s,$r,$value);
639
+                if($value!=='') {
640
+                    return str_replace($s,$r,$value);
641
+                }
551 642
                 break;
552 643
             case 'replace_to':
553 644
             case 'tpl':
554
-                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
645
+                if($value!=='') {
646
+                    return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
647
+                }
555 648
                 break;
556 649
             case 'eachtpl':
557 650
                 $value = explode('||',$value);
@@ -562,59 +655,83 @@  discard block
 block discarded – undo
562 655
                 return implode("\n", $_);
563 656
             case 'array_pop':
564 657
             case 'array_shift':
565
-                if(strpos($value,'||')!==false) $delim = '||';
566
-                else                            $delim = ',';
658
+                if(strpos($value,'||')!==false) {
659
+                    $delim = '||';
660
+                } else {
661
+                    $delim = ',';
662
+                }
567 663
                 return $cmd(explode($delim,$value));
568 664
             case 'preg_replace':
569 665
             case 'regex_replace':
570
-                if(empty($opt) || strpos($opt,',')===false) break;
666
+                if(empty($opt) || strpos($opt,',')===false) {
667
+                    break;
668
+                }
571 669
                 list($s,$r) = explode(',',$opt,2);
572
-                if($value!=='') return preg_replace($s,$r,$value);
670
+                if($value!=='') {
671
+                    return preg_replace($s,$r,$value);
672
+                }
573 673
                 break;
574 674
             case 'cat':
575 675
             case 'concatenate':
576 676
             case '.':
577
-                if($value!=='') return $value . $opt;
677
+                if($value!=='') {
678
+                    return $value . $opt;
679
+                }
578 680
                 break;
579 681
             case 'sprintf':
580 682
             case 'string_format':
581
-                if($value!=='') return sprintf($opt,$value);
683
+                if($value!=='') {
684
+                    return sprintf($opt,$value);
685
+                }
582 686
                 break;
583 687
             case 'number_format':
584
-                    if($opt=='') $opt = 0;
688
+                    if($opt=='') {
689
+                        $opt = 0;
690
+                    }
585 691
                     return number_format($value,$opt);
586 692
             case 'money_format':
587 693
                     setlocale(LC_MONETARY,setlocale(LC_TIME,0));
588
-                    if($value!=='') return money_format($opt,(double)$value);
694
+                    if($value!=='') {
695
+                        return money_format($opt,(double)$value);
696
+                    }
589 697
                     break;
590 698
             case 'tobool':
591 699
                 return boolval($value);
592 700
             case 'nl2lf':
593
-                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value);
701
+                if($value!=='') {
702
+                    return str_replace(array("\r\n","\n", "\r"), '\n', $value);
703
+                }
594 704
                 break;
595 705
             case 'br2nl':
596 706
                 return preg_replace('@<br[\s/]*>@i', "\n", $value);
597 707
             case 'nl2br':
598
-                if (version_compare(PHP_VERSION, '5.3.0', '<'))
599
-                    return nl2br($value);
600
-                if($opt!=='')
601
-                {
708
+                if (version_compare(PHP_VERSION, '5.3.0', '<')) {
709
+                                    return nl2br($value);
710
+                }
711
+                if($opt!=='') {
602 712
                     $opt = trim($opt);
603 713
                     $opt = strtolower($opt);
604
-                    if($opt==='false') $opt = false;
605
-                    elseif($opt==='0') $opt = false;
606
-                    else               $opt = true;
714
+                    if($opt==='false') {
715
+                        $opt = false;
716
+                    } elseif($opt==='0') {
717
+                        $opt = false;
718
+                    } else {
719
+                        $opt = true;
720
+                    }
721
+                } elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') {
722
+                                                       $opt = false;
723
+                } else {
724
+                    $opt = true;
607 725
                 }
608
-                elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
609
-                                       $opt = false;
610
-                else                   $opt = true;
611 726
                 return nl2br($value,$opt);
612 727
             case 'ltrim':
613 728
             case 'rtrim':
614 729
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
615
-                if($opt==='')
616
-                    return $cmd($value);
617
-                else return $cmd($value,$opt);
730
+                if($opt==='') {
731
+                                    return $cmd($value);
732
+                } else {
733
+                    return $cmd($value,$opt);
734
+                }
618 735
             // These are all straight wrappers for PHP functions
619 736
             case 'ucfirst':
620 737
             case 'lcfirst':
@@ -625,15 +742,24 @@  discard block
 block discarded – undo
625 742
             case 'strftime':
626 743
             case 'date':
627 744
             case 'dateformat':
628
-                if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
629
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
630
-                if(strpos($opt,'%')!==false)
631
-                    return strftime($opt,0+$value);
632
-                else
633
-                    return date($opt,0+$value);
745
+                if(empty($opt)) {
746
+                    $opt = $modx->toDateFormat(null, 'formatOnly');
747
+                }
748
+                if(!preg_match('@^[0-9]+$@',$value)) {
749
+                    $value = strtotime($value);
750
+                }
751
+                if(strpos($opt,'%')!==false) {
752
+                                    return strftime($opt,0+$value);
753
+                } else {
754
+                                    return date($opt,0+$value);
755
+                }
634 756
             case 'time':
635
-                if(empty($opt)) $opt = '%H:%M';
636
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
757
+                if(empty($opt)) {
758
+                    $opt = '%H:%M';
759
+                }
760
+                if(!preg_match('@^[0-9]+$@',$value)) {
761
+                    $value = strtotime($value);
762
+                }
637 763
                 return strftime($opt,0+$value);
638 764
             case 'strtotime':
639 765
                 return strtotime($value);
@@ -643,7 +769,9 @@  discard block
 block discarded – undo
643 769
             case 'tofloat':
644 770
                 return floatval($value);
645 771
             case 'round':
646
-                if(!$opt) $opt = 0;
772
+                if(!$opt) {
773
+                    $opt = 0;
774
+                }
647 775
                 return $cmd($value,$opt);
648 776
             case 'max':
649 777
             case 'min':
@@ -655,28 +783,42 @@  discard block
 block discarded – undo
655 783
             case 'math':
656 784
             case 'calc':
657 785
                 $value = (int)$value;
658
-                if(empty($value)) $value = '0';
786
+                if(empty($value)) {
787
+                    $value = '0';
788
+                }
659 789
                 $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt);
660 790
                 $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter);
661
-                if(strpos($filter,'?')===false) $filter = "?{$filter}";
791
+                if(strpos($filter,'?')===false) {
792
+                    $filter = "?{$filter}";
793
+                }
662 794
                 $filter = str_replace('?',$value,$filter);
663 795
                 return eval("return {$filter};");
664 796
             case 'count':
665
-                if($value=='') return 0;
797
+                if($value=='') {
798
+                    return 0;
799
+                }
666 800
                 $value = explode(',',$value);
667 801
                 return count($value);
668 802
             case 'sort':
669 803
             case 'rsort':
670
-                if(strpos($value,"\n")!==false) $delim="\n";
671
-                else $delim = ',';
804
+                if(strpos($value,"\n")!==false) {
805
+                    $delim="\n";
806
+                } else {
807
+                    $delim = ',';
808
+                }
672 809
                 $swap = explode($delim,$value);
673
-                if(!$opt) $opt = SORT_REGULAR;
674
-                else      $opt = constant($opt);
810
+                if(!$opt) {
811
+                    $opt = SORT_REGULAR;
812
+                } else {
813
+                    $opt = constant($opt);
814
+                }
675 815
                 $cmd($swap,$opt);
676 816
                 return implode($delim,$swap);
677 817
             #####  Resource fields
678 818
             case 'id':
679
-                if($opt) return $this->getDocumentObject($opt,$key);
819
+                if($opt) {
820
+                    return $this->getDocumentObject($opt,$key);
821
+                }
680 822
                 break;
681 823
             case 'type':
682 824
             case 'contenttype':
@@ -713,7 +855,9 @@  discard block
 block discarded – undo
713 855
             case 'privatemgr':
714 856
             case 'content_dispo':
715 857
             case 'hidemenu':
716
-                if($cmd==='contenttype') $cmd = 'contentType';
858
+                if($cmd==='contenttype') {
859
+                    $cmd = 'contentType';
860
+                }
717 861
                 return $this->getDocumentObject($value,$cmd);
718 862
             case 'title':
719 863
                 $pagetitle = $this->getDocumentObject($value,'pagetitle');
@@ -728,13 +872,20 @@  discard block
 block discarded – undo
728 872
                 $templateName = $modx->db->getValue($rs);
729 873
                 return !$templateName ? '(blank)' : $templateName;
730 874
             case 'getfield':
731
-                if(!$opt) $opt = 'content';
875
+                if(!$opt) {
876
+                    $opt = 'content';
877
+                }
732 878
                 return $modx->getField($opt,$value);
733 879
             case 'children':
734 880
             case 'childids':
735
-                if($value=='') $value = 0; // 値がない場合はルートと見なす
881
+                if($value=='') {
882
+                    $value = 0;
883
+                }
884
+                // 値がない場合はルートと見なす
736 885
                 $published = 1;
737
-                if($opt=='') $opt = 'page';
886
+                if($opt=='') {
887
+                    $opt = 'page';
888
+                }
738 889
                 $_ = explode(',',$opt);
739 890
                 $where = array();
740 891
                 foreach($_ as $opt) {
@@ -750,29 +901,43 @@  discard block
 block discarded – undo
750 901
                 $where = implode(' AND ', $where);
751 902
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
752 903
                 $result = array();
753
-                foreach((array)$children as $child){
904
+                foreach((array)$children as $child) {
754 905
                     $result[] = $child['id'];
755 906
                 }
756 907
                 return implode(',', $result);
757 908
             case 'fullurl':
758
-                if(!is_numeric($value)) return $value;
909
+                if(!is_numeric($value)) {
910
+                    return $value;
911
+                }
759 912
                 return $modx->makeUrl($value);
760 913
             case 'makeurl':
761
-                if(!is_numeric($value)) return $value;
762
-                if(!$opt) $opt = 'full';
914
+                if(!is_numeric($value)) {
915
+                    return $value;
916
+                }
917
+                if(!$opt) {
918
+                    $opt = 'full';
919
+                }
763 920
                 return $modx->makeUrl($value,'','',$opt);
764 921
 
765 922
             #####  File system
766 923
             case 'getimageinfo':
767 924
             case 'imageinfo':
768
-                if(!is_file($value)) return '';
925
+                if(!is_file($value)) {
926
+                    return '';
927
+                }
769 928
                 $_ = getimagesize($value);
770
-                if(!$_[0]) return '';
929
+                if(!$_[0]) {
930
+                    return '';
931
+                }
771 932
                 $info['width']  = $_[0];
772 933
                 $info['height'] = $_[1];
773
-                if    ($_[0] > $_[1]) $info['aspect'] = 'landscape';
774
-                elseif($_[0] < $_[1]) $info['aspect'] = 'portrait';
775
-                else                  $info['aspect'] = 'square';
934
+                if    ($_[0] > $_[1]) {
935
+                    $info['aspect'] = 'landscape';
936
+                } elseif($_[0] < $_[1]) {
937
+                    $info['aspect'] = 'portrait';
938
+                } else {
939
+                    $info['aspect'] = 'square';
940
+                }
776 941
                 switch($_[2]) {
777 942
                     case IMAGETYPE_GIF  : $info['type'] = 'gif'; break;
778 943
                     case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break;
@@ -791,33 +956,47 @@  discard block
 block discarded – undo
791 956
 
792 957
             case 'file_get_contents':
793 958
             case 'readfile':
794
-                if(!is_file($value)) return $value;
959
+                if(!is_file($value)) {
960
+                    return $value;
961
+                }
795 962
                 $value = realpath($value);
796
-                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file');
963
+                if(strpos($value,MODX_MANAGER_PATH)!==false) {
964
+                    exit('Can not read core file');
965
+                }
797 966
                 $ext = strtolower(substr($value,-4));
798
-                if($ext==='.php') exit('Can not read php file');
799
-                if($ext==='.cgi') exit('Can not read cgi file');
967
+                if($ext==='.php') {
968
+                    exit('Can not read php file');
969
+                }
970
+                if($ext==='.cgi') {
971
+                    exit('Can not read cgi file');
972
+                }
800 973
                 return file_get_contents($value);
801 974
             case 'filesize':
802
-                if($value == '') return '';
975
+                if($value == '') {
976
+                    return '';
977
+                }
803 978
                 $filename = $value;
804 979
 
805 980
                 $site_url = $modx->config['site_url'];
806
-                if(strpos($filename,$site_url) === 0)
807
-                    $filename = substr($filename,0,strlen($site_url));
981
+                if(strpos($filename,$site_url) === 0) {
982
+                                    $filename = substr($filename,0,strlen($site_url));
983
+                }
808 984
                 $filename = trim($filename,'/');
809 985
 
810 986
                 $opt = trim($opt,'/');
811
-                if($opt!=='') $opt .= '/';
987
+                if($opt!=='') {
988
+                    $opt .= '/';
989
+                }
812 990
 
813 991
                 $filename = MODX_BASE_PATH.$opt.$filename;
814 992
 
815
-                if(is_file($filename)){
993
+                if(is_file($filename)) {
816 994
                     clearstatcache();
817 995
                     $size = filesize($filename);
818 996
                     return $size;
997
+                } else {
998
+                    return '';
819 999
                 }
820
-                else return '';
821 1000
             #####  User info
822 1001
             case 'username':
823 1002
             case 'fullname':
@@ -845,32 +1024,47 @@  discard block
 block discarded – undo
845 1024
                 $this->opt = $cmd;
846 1025
                 return $this->includeMdfFile('moduser');
847 1026
             case 'userinfo':
848
-                if(empty($opt)) $this->opt = 'username';
1027
+                if(empty($opt)) {
1028
+                    $this->opt = 'username';
1029
+                }
849 1030
                 return $this->includeMdfFile('moduser');
850 1031
             case 'webuserinfo':
851
-                if(empty($opt)) $this->opt = 'username';
1032
+                if(empty($opt)) {
1033
+                    $this->opt = 'username';
1034
+                }
852 1035
                 $this->value = -$value;
853 1036
                 return $this->includeMdfFile('moduser');
854 1037
             #####  Special functions
855 1038
             case 'ifempty':
856 1039
             case '_default':
857 1040
             case 'default':
858
-                if (empty($value)) return $opt; break;
1041
+                if (empty($value)) {
1042
+                    return $opt;
1043
+                }
1044
+                break;
859 1045
             case 'ifnotempty':
860
-                if (!empty($value)) return $opt; break;
1046
+                if (!empty($value)) {
1047
+                    return $opt;
1048
+                }
1049
+                break;
861 1050
             case 'datagrid':
862 1051
                 include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
863 1052
                 $grd = new DataGrid(null, trim($value));
864 1053
                 $grd->itemStyle = '';
865 1054
                 $grd->altItemStyle = '';
866 1055
                 $pos = strpos($value,"\n");
867
-                if($pos) $_ = substr($value,0,$pos);
868
-                else $_ = $pos;
1056
+                if($pos) {
1057
+                    $_ = substr($value,0,$pos);
1058
+                } else {
1059
+                    $_ = $pos;
1060
+                }
869 1061
                 $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ',';
870 1062
                 return $grd->render();
871 1063
             case 'rotate':
872 1064
             case 'evenodd':
873
-                if(strpos($opt,',')===false) $opt = 'odd,even';
1065
+                if(strpos($opt,',')===false) {
1066
+                    $opt = 'odd,even';
1067
+                }
874 1068
                 $_ = explode(',', $opt);
875 1069
                 $c = count($_);
876 1070
                 $i = $value + $c;
@@ -879,7 +1073,9 @@  discard block
 block discarded – undo
879 1073
             case 'takeval':
880 1074
                 $arr = explode(",",$opt);
881 1075
                 $idx = $value;
882
-                if(!is_numeric($idx)) return $value;
1076
+                if(!is_numeric($idx)) {
1077
+                    return $value;
1078
+                }
883 1079
                 return $arr[$idx];
884 1080
             case 'getimage':
885 1081
                 return $this->includeMdfFile('getimage');
@@ -887,14 +1083,18 @@  discard block
 block discarded – undo
887 1083
                     return $modx->nicesize($value);
888 1084
             case 'googlemap':
889 1085
             case 'googlemaps':
890
-                if(empty($opt)) $opt = 'border:none;width:500px;height:350px;';
1086
+                if(empty($opt)) {
1087
+                    $opt = 'border:none;width:500px;height:350px;';
1088
+                }
891 1089
                 $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>';
892 1090
                 $ph['style'] = $opt;
893 1091
                 $ph['value'] = $value;
894 1092
                 return $modx->parseText($tpl,$ph);
895 1093
             case 'youtube':
896 1094
             case 'youtube16x9':
897
-                if(empty($opt)) $opt = 560;
1095
+                if(empty($opt)) {
1096
+                    $opt = 560;
1097
+                }
898 1098
                 $h = round($opt*0.5625);
899 1099
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
900 1100
                 return sprintf($tpl,$opt,$h,$value);
@@ -927,7 +1127,8 @@  discard block
 block discarded – undo
927 1127
         return $value;
928 1128
     }
929 1129
 
930
-    public function includeMdfFile($cmd) {
1130
+    public function includeMdfFile($cmd)
1131
+    {
931 1132
         global $modx;
932 1133
         $key = $this->key;
933 1134
         $value  = $this->value;
@@ -938,55 +1139,65 @@  discard block
 block discarded – undo
938 1139
     public function getValueFromElement($key, $value, $cmd, $opt)
939 1140
     {
940 1141
         global $modx;
941
-        if( isset($modx->snippetCache[$this->elmName]) )
942
-        {
1142
+        if( isset($modx->snippetCache[$this->elmName]) ) {
943 1143
             $php = $modx->snippetCache[$this->elmName];
944
-        }
945
-        else
946
-        {
1144
+        } else {
947 1145
             $esc_elmName = $modx->db->escape($this->elmName);
948 1146
             $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
949 1147
             $total = $modx->db->getRecordCount($result);
950
-            if($total == 1)
951
-            {
1148
+            if($total == 1) {
952 1149
                 $row = $modx->db->getRow($result);
953 1150
                 $php = $row['snippet'];
954
-            }
955
-            elseif($total == 0)
956
-            {
1151
+            } elseif($total == 0) {
957 1152
                 $assets_path = MODX_BASE_PATH.'assets/';
958
-                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
959
-                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
960
-                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
961
-                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
962
-                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
963
-                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
964
-                else $modifiers_path = false;
1153
+                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) {
1154
+                                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1155
+                } elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) {
1156
+                                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1157
+                } elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) {
1158
+                                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1159
+                } else {
1160
+                    $modifiers_path = false;
1161
+                }
965 1162
 
966 1163
                 if($modifiers_path !== false) {
967 1164
                     $php = @file_get_contents($modifiers_path);
968 1165
                     $php = trim($php);
969
-                    if(substr($php,0,5)==='<?php') $php = substr($php,6);
970
-                    if(substr($php,0,2)==='<?')    $php = substr($php,3);
971
-                    if(substr($php,-2)==='?>')     $php = substr($php,0,-2);
972
-                    if($this->elmName!=='')
973
-                        $modx->snippetCache[$this->elmName.'Props'] = '';
974
-                }
975
-                else
976
-                    $php = false;
1166
+                    if(substr($php,0,5)==='<?php') {
1167
+                        $php = substr($php,6);
1168
+                    }
1169
+                    if(substr($php,0,2)==='<?') {
1170
+                        $php = substr($php,3);
1171
+                    }
1172
+                    if(substr($php,-2)==='?>') {
1173
+                        $php = substr($php,0,-2);
1174
+                    }
1175
+                    if($this->elmName!=='') {
1176
+                                            $modx->snippetCache[$this->elmName.'Props'] = '';
1177
+                    }
1178
+                } else {
1179
+                                    $php = false;
1180
+                }
1181
+            } else {
1182
+                $php = false;
1183
+            }
1184
+            if($this->elmName!=='') {
1185
+                $modx->snippetCache[$this->elmName]= $php;
977 1186
             }
978
-            else $php = false;
979
-            if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php;
980 1187
         }
981
-        if($php==='') $php=false;
1188
+        if($php==='') {
1189
+            $php=false;
1190
+        }
982 1191
 
983
-        if($php===false) $html = $modx->getChunk($this->elmName);
984
-        else             $html = false;
1192
+        if($php===false) {
1193
+            $html = $modx->getChunk($this->elmName);
1194
+        } else {
1195
+            $html = false;
1196
+        }
985 1197
 
986 1198
         $self = '[+output+]';
987 1199
 
988
-        if($php !== false)
989
-        {
1200
+        if($php !== false) {
990 1201
             ob_start();
991 1202
             $options = $opt;
992 1203
             $output = $value;
@@ -998,19 +1209,19 @@  discard block
 block discarded – undo
998 1209
             $this->vars['options'] = & $opt;
999 1210
             $custom = eval($php);
1000 1211
             $msg = ob_get_contents();
1001
-            if($value===$this->bt) $value = $msg . $custom;
1212
+            if($value===$this->bt) {
1213
+                $value = $msg . $custom;
1214
+            }
1002 1215
             ob_end_clean();
1003
-        }
1004
-        elseif($html!==false && isset($value) && $value!=='')
1005
-        {
1216
+        } elseif($html!==false && isset($value) && $value!=='') {
1006 1217
             $html = str_replace(array($self,'[+value+]'), $value, $html);
1007 1218
             $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1219
+        } else {
1220
+            return false;
1008 1221
         }
1009
-        else return false;
1010 1222
 
1011 1223
         if($php===false && $html===false && $value!==''
1012
-           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false))
1013
-        {
1224
+           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) {
1014 1225
             $value = str_replace(array('[+value+]',$self),$value,$cmd);
1015 1226
         }
1016 1227
         return $value;
@@ -1020,23 +1231,39 @@  discard block
 block discarded – undo
1020 1231
     {
1021 1232
         global $modx;
1022 1233
 
1023
-        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
1234
+        if(strpos($content,'[')===false && strpos($content,'{')===false) {
1235
+            return $content;
1236
+        }
1024 1237
 
1025
-        if(!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1238
+        if(!$modx->maxParserPasses) {
1239
+            $modx->maxParserPasses = 10;
1240
+        }
1026 1241
         $bt='';
1027 1242
         $i=0;
1028
-        while($bt!==$content)
1029
-        {
1243
+        while($bt!==$content) {
1030 1244
             $bt = $content;
1031
-            if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1032
-                                              $content = $modx->mergeDocumentContent($content);
1033
-            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1034
-            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1035
-            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1036
-            if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
1037
-
1038
-            if($content===$bt)              break;
1039
-            if($modx->maxParserPasses < $i) break;
1245
+            if(strpos($content,'[*')!==false && $modx->documentIdentifier) {
1246
+                                                          $content = $modx->mergeDocumentContent($content);
1247
+            }
1248
+            if(strpos($content,'[(')!==false) {
1249
+                $content = $modx->mergeSettingsContent($content);
1250
+            }
1251
+            if(strpos($content,'{{')!==false) {
1252
+                $content = $modx->mergeChunkContent($content);
1253
+            }
1254
+            if(strpos($content,'[!')!==false) {
1255
+                $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1256
+            }
1257
+            if(strpos($content,'[[')!==false) {
1258
+                $content = $modx->evalSnippets($content);
1259
+            }
1260
+
1261
+            if($content===$bt) {
1262
+                break;
1263
+            }
1264
+            if($modx->maxParserPasses < $i) {
1265
+                break;
1266
+            }
1040 1267
             $i++;
1041 1268
         }
1042 1269
         return $content;
@@ -1047,103 +1274,138 @@  discard block
 block discarded – undo
1047 1274
         global $modx;
1048 1275
 
1049 1276
         $target = trim($target);
1050
-        if(empty($target)) $target = $modx->config['site_start'];
1051
-        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id';
1052
-        else $method = 'alias';
1277
+        if(empty($target)) {
1278
+            $target = $modx->config['site_start'];
1279
+        }
1280
+        if(preg_match('@^[1-9][0-9]*$@',$target)) {
1281
+            $method='id';
1282
+        } else {
1283
+            $method = 'alias';
1284
+        }
1053 1285
 
1054
-        if(!isset($this->documentObject[$target]))
1055
-        {
1286
+        if(!isset($this->documentObject[$target])) {
1056 1287
             $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct');
1057 1288
         }
1058 1289
 
1059
-        if($this->documentObject[$target]['publishedon']==='0')
1060
-            return '';
1061
-        elseif(isset($this->documentObject[$target][$field]))
1062
-        {
1063
-            if(is_array($this->documentObject[$target][$field]))
1064
-            {
1290
+        if($this->documentObject[$target]['publishedon']==='0') {
1291
+                    return '';
1292
+        } elseif(isset($this->documentObject[$target][$field])) {
1293
+            if(is_array($this->documentObject[$target][$field])) {
1065 1294
                 $a = $modx->getTemplateVarOutput($field,$target);
1066 1295
                 $this->documentObject[$target][$field] = $a[$field];
1067 1296
             }
1297
+        } else {
1298
+            $this->documentObject[$target][$field] = false;
1068 1299
         }
1069
-        else $this->documentObject[$target][$field] = false;
1070 1300
 
1071 1301
         return $this->documentObject[$target][$field];
1072 1302
     }
1073 1303
 
1074
-    public function setPlaceholders($value = '', $key = '', $path = '') {
1075
-        if($path!=='') $key = "{$path}.{$key}";
1304
+    public function setPlaceholders($value = '', $key = '', $path = '')
1305
+    {
1306
+        if($path!=='') {
1307
+            $key = "{$path}.{$key}";
1308
+        }
1076 1309
         if (is_array($value)) {
1077 1310
             foreach ($value as $subkey => $subval) {
1078 1311
                 $this->setPlaceholders($subval, $subkey, $key);
1079 1312
             }
1313
+        } else {
1314
+            $this->setModifiersVariable($key, $value);
1080 1315
         }
1081
-        else $this->setModifiersVariable($key, $value);
1082 1316
     }
1083 1317
 
1084 1318
     // Sets a placeholder variable which can only be access by Modifiers
1085
-    public function setModifiersVariable($key, $value) {
1086
-        if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1319
+    public function setModifiersVariable($key, $value)
1320
+    {
1321
+        if ($key != 'phx' && $key != 'dummy') {
1322
+            $this->placeholders[$key] = $value;
1323
+        }
1087 1324
     }
1088 1325
 
1089 1326
     //mbstring
1090
-    public function substr($str, $s, $l = null) {
1327
+    public function substr($str, $s, $l = null)
1328
+    {
1091 1329
         global $modx;
1092
-        if(is_null($l)) $l = $this->strlen($str);
1093
-        if (function_exists('mb_substr'))
1094
-        {
1095
-            if(strpos($str,"\r")!==false)
1096
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1330
+        if(is_null($l)) {
1331
+            $l = $this->strlen($str);
1332
+        }
1333
+        if (function_exists('mb_substr')) {
1334
+            if(strpos($str,"\r")!==false) {
1335
+                            $str = str_replace(array("\r\n","\r"), "\n", $str);
1336
+            }
1097 1337
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1098 1338
         }
1099 1339
         return substr($str, $s, $l);
1100 1340
     }
1101
-    public function strpos($haystack,$needle,$offset=0) {
1341
+    public function strpos($haystack,$needle,$offset=0)
1342
+    {
1102 1343
         global $modx;
1103
-        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1344
+        if (function_exists('mb_strpos')) {
1345
+            return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1346
+        }
1104 1347
         return strpos($haystack,$needle,$offset);
1105 1348
     }
1106
-    public function strlen($str) {
1349
+    public function strlen($str)
1350
+    {
1107 1351
         global $modx;
1108
-        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1352
+        if (function_exists('mb_strlen')) {
1353
+            return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1354
+        }
1109 1355
         return strlen($str);
1110 1356
     }
1111
-    public function strtolower($str) {
1112
-        if (function_exists('mb_strtolower')) return mb_strtolower($str);
1357
+    public function strtolower($str)
1358
+    {
1359
+        if (function_exists('mb_strtolower')) {
1360
+            return mb_strtolower($str);
1361
+        }
1113 1362
         return strtolower($str);
1114 1363
     }
1115
-    public function strtoupper($str) {
1116
-        if (function_exists('mb_strtoupper')) return mb_strtoupper($str);
1364
+    public function strtoupper($str)
1365
+    {
1366
+        if (function_exists('mb_strtoupper')) {
1367
+            return mb_strtoupper($str);
1368
+        }
1117 1369
         return strtoupper($str);
1118 1370
     }
1119
-    public function ucfirst($str) {
1120
-        if (function_exists('mb_strtoupper'))
1121
-            return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1371
+    public function ucfirst($str)
1372
+    {
1373
+        if (function_exists('mb_strtoupper')) {
1374
+                    return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1375
+        }
1122 1376
         return ucfirst($str);
1123 1377
     }
1124
-    public function lcfirst($str) {
1125
-        if (function_exists('mb_strtolower'))
1126
-            return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1378
+    public function lcfirst($str)
1379
+    {
1380
+        if (function_exists('mb_strtolower')) {
1381
+                    return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1382
+        }
1127 1383
         return lcfirst($str);
1128 1384
     }
1129
-    public function ucwords($str) {
1130
-        if (function_exists('mb_convert_case'))
1131
-            return mb_convert_case($str, MB_CASE_TITLE);
1385
+    public function ucwords($str)
1386
+    {
1387
+        if (function_exists('mb_convert_case')) {
1388
+                    return mb_convert_case($str, MB_CASE_TITLE);
1389
+        }
1132 1390
         return ucwords($str);
1133 1391
     }
1134
-    public function strrev($str) {
1392
+    public function strrev($str)
1393
+    {
1135 1394
         preg_match_all('/./us', $str, $ar);
1136 1395
         return implode(array_reverse($ar[0]));
1137 1396
     }
1138
-    public function str_shuffle($str) {
1397
+    public function str_shuffle($str)
1398
+    {
1139 1399
         preg_match_all('/./us', $str, $ar);
1140 1400
         shuffle($ar[0]);
1141 1401
         return implode($ar[0]);
1142 1402
     }
1143
-    public function str_word_count($str) {
1403
+    public function str_word_count($str)
1404
+    {
1144 1405
         return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
1145 1406
     }
1146
-    public function strip_tags($value,$params='') {
1407
+    public function strip_tags($value,$params='')
1408
+    {
1147 1409
         global $modx;
1148 1410
 
1149 1411
         if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
Please login to merge, or discard this patch.
manager/includes/menu.class.inc.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -41,6 +41,10 @@
 block discarded – undo
41 41
         $this->menu = $new;
42 42
     }
43 43
 
44
+    /**
45
+     * @param string $parentid
46
+     * @param integer $level
47
+     */
44 48
     public function DrawSub($parentid, $level)
45 49
     {
46 50
         global $modx;
Please login to merge, or discard this patch.
manager/processors/cache_sync.class.processor.php 2 patches
Doc Comments   +13 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,11 +19,17 @@  discard block
 block discarded – undo
19 19
         $this->request_time = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time'];
20 20
     }
21 21
 
22
+    /**
23
+     * @param string $path
24
+     */
22 25
     public function setCachepath($path)
23 26
     {
24 27
         $this->cachePath = $path;
25 28
     }
26 29
 
30
+    /**
31
+     * @param boolean $bool
32
+     */
27 33
     public function setReport($bool)
28 34
     {
29 35
         $this->showReport = $bool;
@@ -46,6 +52,9 @@  discard block
 block discarded – undo
46 52
         return str_replace($q1, $q2, $s);
47 53
     }
48 54
 
55
+    /**
56
+     * @return string
57
+     */
49 58
     public function getParents($id, $path = '')
50 59
     { // modx:returns child's parent
51 60
         global $modx;
@@ -149,6 +158,9 @@  discard block
 block discarded – undo
149 158
         }
150 159
     }
151 160
 
161
+    /**
162
+     * @return string
163
+     */
152 164
     public function getCacheRefreshTime()
153 165
     {
154 166
         global $modx;
@@ -191,7 +203,7 @@  discard block
 block discarded – undo
191 203
     /**
192 204
      * build siteCache file
193 205
      * @param  DocumentParser $modx
194
-     * @return boolean success
206
+     * @return null|boolean success
195 207
      */
196 208
     public function buildCache($modx)
197 209
     {
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@  discard block
 block discarded – undo
47 47
     }
48 48
 
49 49
     public function getParents($id, $path = '')
50
-    { // modx:returns child's parent
50
+    {
51
+// modx:returns child's parent
51 52
         global $modx;
52 53
         if (empty($this->aliases)) {
53 54
             $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible";
@@ -404,7 +405,8 @@  discard block
 block discarded – undo
404 405
                         $_ = trim($_);
405 406
                     }
406 407
                     $lastChar = substr($_, -1);
407
-                    if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289
408
+                    if (!in_array($lastChar, $chars)) {
409
+// ,320,327,288,284,289
408 410
                         if (!in_array($prev_token, array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) {
409 411
                             $_ .= ' ';
410 412
                         }
Please login to merge, or discard this patch.
manager/actions/logging.static.php 1 patch
Braces   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
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
-if (!$modx->hasPermission('logs')) {
5
+if (!$modx->hasPermission('logs')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-function array_unique_multi($array, $checkKey)
10
-{
9
+function array_unique_multi($array, $checkKey)
10
+{
11 11
     // Use the builtin if we're not a multi-dimensional array
12
-    if (!is_array(current($array)) || empty($checkKey)) {
12
+    if (!is_array(current($array)) || empty($checkKey)) {
13 13
         return array_unique($array);
14 14
     }
15 15
 
16 16
     $ret = array();
17 17
     $checkValues = array(); // contains the unique key Values
18
-    foreach ($array as $key => $current) {
19
-        if (in_array($current[$checkKey], $checkValues)) {
18
+    foreach ($array as $key => $current) {
19
+        if (in_array($current[$checkKey], $checkValues)) {
20 20
             continue;
21 21
         } // duplicate
22 22
 
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
     return $ret;
27 27
 }
28 28
 
29
-function record_sort($array, $key)
30
-{
29
+function record_sort($array, $key)
30
+{
31 31
     $hash = array();
32
-    foreach ($array as $k => $v) {
32
+    foreach ($array as $k => $v) {
33 33
         $hash[$k] = $v[$key];
34 34
     }
35 35
 
36 36
     natsort($hash);
37 37
 
38 38
     $records = array();
39
-    foreach ($hash as $k => $row) {
39
+    foreach ($hash as $k => $row) {
40 40
         $records[$k] = $array[$k];
41 41
     }
42 42
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                             <?php
64 64
                             // get all users currently in the log
65 65
                             $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username');
66
-                            foreach ($logs_user as $row) {
66
+                            foreach ($logs_user as $row) {
67 67
                                 $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : '';
68 68
                                 echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n";
69 69
                             }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
                             // get all available actions in the log
81 81
                             include_once "actionlist.inc.php";
82 82
                             $logs_actions = record_sort(array_unique_multi($logs, 'action'), 'action');
83
-                            foreach ($logs_actions as $row) {
83
+                            foreach ($logs_actions as $row) {
84 84
                                 $action = getAction($row['action']);
85
-                                if ($action == 'Idle') {
85
+                                if ($action == 'Idle') {
86 86
                                     continue;
87 87
                                 }
88 88
                                 $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                             <?php
101 101
                             // get all itemid currently in logging
102 102
                             $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid');
103
-                            foreach ($logs_items as $row) {
103
+                            foreach ($logs_items as $row) {
104 104
                                 $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : '';
105 105
                                 echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n";
106 106
                             }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                             <?php
117 117
                             // get all itemname currently in logging
118 118
                             $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname');
119
-                            foreach ($logs_names as $row) {
119
+                            foreach ($logs_names as $row) {
120 120
                                 $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : '';
121 121
                                 echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n";
122 122
                             }
@@ -172,36 +172,36 @@  discard block
 block discarded – undo
172 172
     <div class="container container-body">
173 173
 
174 174
 <?php
175
-if (isset($_REQUEST['log_submit'])) {
175
+if (isset($_REQUEST['log_submit'])) {
176 176
     // get the selections the user made.
177 177
     $sqladd = array();
178
-    if ($_REQUEST['searchuser'] != 0) {
178
+    if ($_REQUEST['searchuser'] != 0) {
179 179
         $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'";
180 180
     }
181
-    if ($_REQUEST['action'] != 0) {
181
+    if ($_REQUEST['action'] != 0) {
182 182
         $sqladd[] = "action=" . (int)$_REQUEST['action'];
183 183
     }
184
-    if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
184
+    if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
185 185
         $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'";
186 186
     }
187
-    if ($_REQUEST['itemname'] != '0') {
187
+    if ($_REQUEST['itemname'] != '0') {
188 188
         $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'";
189 189
     }
190
-    if ($_REQUEST['message'] != "") {
190
+    if ($_REQUEST['message'] != "") {
191 191
         $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'";
192 192
     }
193 193
     // date stuff
194
-    if ($_REQUEST['datefrom'] != "") {
194
+    if ($_REQUEST['datefrom'] != "") {
195 195
         $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']);
196 196
     }
197
-    if ($_REQUEST['dateto'] != "") {
197
+    if ($_REQUEST['dateto'] != "") {
198 198
         $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']);
199 199
     }
200 200
 
201 201
     // If current position is not set, set it to zero
202
-    if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) {
202
+    if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) {
203 203
         $int_cur_position = 0;
204
-    } else {
204
+    } else {
205 205
         $int_cur_position = $_REQUEST['int_cur_position'];
206 206
     }
207 207
 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 
216 216
     $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}");
217 217
 
218
-if ($limit < 1) {
218
+if ($limit < 1) {
219 219
     echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>';
220
-} else {
220
+} else {
221 221
     echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>';
222 222
 
223 223
     include_once "paginate.inc.php";
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
     $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " ");
237 237
     $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " ");
238 238
     $pagesfound = sizeof($array_row_paging);
239
-    if ($pagesfound > 6) {
239
+    if ($pagesfound > 6) {
240 240
         $paging .= $array_row_paging[$current_row - 2]; // ."&nbsp;";
241 241
         $paging .= $array_row_paging[$current_row - 1]; // ."&nbsp;";
242 242
         $paging .= $array_row_paging[$current_row]; // ."&nbsp;";
243 243
         $paging .= $array_row_paging[$current_row + 1]; // ."&nbsp;";
244 244
         $paging .= $array_row_paging[$current_row + 2]; // ."&nbsp;";
245
-    } else {
246
-        for ($i = 0; $i < $pagesfound; $i++) {
245
+    } else {
246
+        for ($i = 0; $i < $pagesfound; $i++) {
247 247
             $paging .= $array_row_paging[$i] . "&nbsp;";
248 248
         }
249 249
     }
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
                 // grab the entire log file...
279 279
                 $logentries = array();
280 280
                 $i = 0;
281
-                while ($logentry = $modx->db->getRow($rs)) {
282
-                    if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
281
+                while ($logentry = $modx->db->getRow($rs)) {
282
+                    if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
283 283
                         $item = '<div style="text-align:center;">-</div>';
284
-                    } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
284
+                    } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
285 285
                         $item = '<a href="index.php?a=3&amp;id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>';
286
-                    } else {
286
+                    } else {
287 287
                         $item = $logentry['itemname'];
288 288
                     }
289 289
                     //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true'
@@ -318,6 +318,6 @@  discard block
 block discarded – undo
318 318
     // @see index.php @ 915
319 319
     global $action;
320 320
     $action = 1;
321
-} else {
321
+} else {
322 322
     echo $_lang["mgrlog_noquery"];
323 323
 }
Please login to merge, or discard this patch.