Completed
Pull Request — develop (#547)
by Maxim
09:14 queued 03:38
created
manager/actions/resources/mgrResources.class.php 3 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
     /**
8 8
      * @var array
9 9
      */
10
-	public $types = array();
10
+    public $types = array();
11 11
     /**
12 12
      * @var array
13 13
      */
@@ -25,73 +25,73 @@  discard block
 block discarded – undo
25 25
      * mgrResources constructor.
26 26
      */
27 27
     public function __construct() {
28
-		$this->setTypes();
29
-		$this->queryItemsFromDB();
30
-		$this->prepareCategoryArrays();
31
-	}
28
+        $this->setTypes();
29
+        $this->queryItemsFromDB();
30
+        $this->prepareCategoryArrays();
31
+    }
32 32
 
33 33
     /**
34 34
      * @return void
35 35
      */
36 36
     public function setTypes() {
37
-		global $_lang;
38
-		$this->types['site_templates']    = array(
39
-			'title'=>$_lang["manage_templates"],
40
-			'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ),
41
-			'permissions'=>array('new_template','edit_template'),
42
-			'name'=>'templatename'
43
-		);
44
-		$this->types['site_tmplvars']     = array(
45
-			'title'=>$_lang["tmplvars"],
46
-			'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')),
47
-			'permissions'=>array('new_template','edit_template'),
48
-		);
49
-		$this->types['site_htmlsnippets'] = array(
50
-			'title'=>$_lang["manage_htmlsnippets"],
51
-			'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')),
52
-			'permissions'=>array('new_chunk','edit_chunk'),
53
-		);
54
-		$this->types['site_snippets']     = array(
55
-			'title'=>$_lang["manage_snippets"],
56
-			'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')),
57
-			'permissions'=>array('new_snippet','edit_snippet'),
58
-		);
59
-		$this->types['site_plugins']      = array(
60
-			'title'=>$_lang["manage_plugins"],
61
-			'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')),
62
-			'permissions'=>array('new_plugin','edit_plugin'),
63
-		);
64
-		$this->types['site_modules']      = array(
65
-			'title'=>$_lang["manage_modules"],
66
-			'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')),
67
-			'permissions'=>array('new_module','edit_module'),
68
-		);
69
-	}
37
+        global $_lang;
38
+        $this->types['site_templates']    = array(
39
+            'title'=>$_lang["manage_templates"],
40
+            'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ),
41
+            'permissions'=>array('new_template','edit_template'),
42
+            'name'=>'templatename'
43
+        );
44
+        $this->types['site_tmplvars']     = array(
45
+            'title'=>$_lang["tmplvars"],
46
+            'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')),
47
+            'permissions'=>array('new_template','edit_template'),
48
+        );
49
+        $this->types['site_htmlsnippets'] = array(
50
+            'title'=>$_lang["manage_htmlsnippets"],
51
+            'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')),
52
+            'permissions'=>array('new_chunk','edit_chunk'),
53
+        );
54
+        $this->types['site_snippets']     = array(
55
+            'title'=>$_lang["manage_snippets"],
56
+            'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')),
57
+            'permissions'=>array('new_snippet','edit_snippet'),
58
+        );
59
+        $this->types['site_plugins']      = array(
60
+            'title'=>$_lang["manage_plugins"],
61
+            'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')),
62
+            'permissions'=>array('new_plugin','edit_plugin'),
63
+        );
64
+        $this->types['site_modules']      = array(
65
+            'title'=>$_lang["manage_modules"],
66
+            'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')),
67
+            'permissions'=>array('new_module','edit_module'),
68
+        );
69
+    }
70 70
 
71 71
     /**
72 72
      * @return void
73 73
      */
74 74
     public function queryItemsFromDB() {
75
-		foreach($this->types as $resourceTable=>$type) {
76
-			if($this->hasAnyPermissions($type['permissions'])) {
77
-				$nameField = isset($type['name']) ? $type['name'] : 'name';
78
-				$this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField);
79
-		   }
80
-		 }
81
-	}
75
+        foreach($this->types as $resourceTable=>$type) {
76
+            if($this->hasAnyPermissions($type['permissions'])) {
77
+                $nameField = isset($type['name']) ? $type['name'] : 'name';
78
+                $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField);
79
+            }
80
+            }
81
+    }
82 82
 
83 83
     /**
84 84
      * @param array $permissions
85 85
      * @return bool
86 86
      */
87 87
     public function hasAnyPermissions($permissions) {
88
-		$modx = evolutionCMS();
88
+        $modx = evolutionCMS();
89 89
 
90
-		foreach($permissions as $p)
91
-			if($modx->hasPermission($p)) return true;
90
+        foreach($permissions as $p)
91
+            if($modx->hasPermission($p)) return true;
92 92
 
93
-		return false;
94
-	}
93
+        return false;
94
+    }
95 95
 
96 96
     /**
97 97
      * @param string $resourceTable
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      * @return array|bool
100 100
      */
101 101
     public function queryResources($resourceTable, $nameField = 'name') {
102
-		$modx = evolutionCMS(); global $_lang;
102
+        $modx = evolutionCMS(); global $_lang;
103 103
 
104 104
         $allowed = array(
105 105
             'site_htmlsnippets',
@@ -107,59 +107,59 @@  discard block
 block discarded – undo
107 107
             'site_plugins',
108 108
             'site_modules'
109 109
         );
110
-		$pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : '';
111
-
112
-		$tvsql  = '';
113
-		$tvjoin = '';
114
-		if ($resourceTable === 'site_tmplvars') {
115
-			$tvsql    = 'site_tmplvars.caption, ';
116
-			$tvjoin   = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates'));
117
-			$sttfield = 'IF(stt.templateid,1,0) AS reltpl,';
118
-		}
119
-		else $sttfield = '';
120
-
121
-		$selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : "";
122
-
123
-		$rs = $modx->db->select(
124
-			"{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid",
125
-			$modx->getFullTableName($resourceTable) . " AS {$resourceTable}
110
+        $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : '';
111
+
112
+        $tvsql  = '';
113
+        $tvjoin = '';
114
+        if ($resourceTable === 'site_tmplvars') {
115
+            $tvsql    = 'site_tmplvars.caption, ';
116
+            $tvjoin   = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates'));
117
+            $sttfield = 'IF(stt.templateid,1,0) AS reltpl,';
118
+        }
119
+        else $sttfield = '';
120
+
121
+        $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : "";
122
+
123
+        $rs = $modx->db->select(
124
+            "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid",
125
+            $modx->getFullTableName($resourceTable) . " AS {$resourceTable}
126 126
 	            LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}",
127
-			"",
128
-			"category,name"
129
-		);
130
-		$limit = $modx->db->getRecordCount($rs);
127
+            "",
128
+            "category,name"
129
+        );
130
+        $limit = $modx->db->getRecordCount($rs);
131 131
 
132
-		if($limit < 1) return false;
132
+        if($limit < 1) return false;
133 133
 
134
-		$result = array();
135
-		while ($row = $modx->db->getRow($rs)) {
136
-			$result[] = $row;
137
-		}
138
-		return $result;
139
-	}
134
+        $result = array();
135
+        while ($row = $modx->db->getRow($rs)) {
136
+            $result[] = $row;
137
+        }
138
+        return $result;
139
+    }
140 140
 
141 141
     /**
142 142
      * @return void
143 143
      */
144 144
     public function prepareCategoryArrays() {
145
-		foreach($this->items as $type=>$items) {
146
-			foreach((array)$items as $item) {
147
-				$catid = $item['catid'] ? $item['catid'] : 0;
148
-				$this->categories[$catid] = $item['category'];
149
-
150
-				$item['type'] = $type;
151
-				$this->itemsPerCategory[$catid][] = $item;
152
-			}
153
-		}
154
-
155
-		// Sort categories by name
156
-		natcasesort($this->categories);
157
-
158
-		// Now sort by name
159
-		foreach($this->itemsPerCategory as $catid=>$items) {
160
-			usort($this->itemsPerCategory[$catid], function ($a, $b) {
161
-				return strcasecmp($a['name'], $b['name']);
162
-			});
163
-		}
164
-	}
145
+        foreach($this->items as $type=>$items) {
146
+            foreach((array)$items as $item) {
147
+                $catid = $item['catid'] ? $item['catid'] : 0;
148
+                $this->categories[$catid] = $item['category'];
149
+
150
+                $item['type'] = $type;
151
+                $this->itemsPerCategory[$catid][] = $item;
152
+            }
153
+        }
154
+
155
+        // Sort categories by name
156
+        natcasesort($this->categories);
157
+
158
+        // Now sort by name
159
+        foreach($this->itemsPerCategory as $catid=>$items) {
160
+            usort($this->itemsPerCategory[$catid], function ($a, $b) {
161
+                return strcasecmp($a['name'], $b['name']);
162
+            });
163
+        }
164
+    }
165 165
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  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 5
 
6
-class mgrResources {
6
+class mgrResources{
7 7
     /**
8 8
      * @var array
9 9
      */
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * mgrResources constructor.
26 26
      */
27
-    public function __construct() {
27
+    public function __construct(){
28 28
 		$this->setTypes();
29 29
 		$this->queryItemsFromDB();
30 30
 		$this->prepareCategoryArrays();
@@ -33,47 +33,47 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * @return void
35 35
      */
36
-    public function setTypes() {
36
+    public function setTypes(){
37 37
 		global $_lang;
38
-		$this->types['site_templates']    = array(
38
+		$this->types['site_templates'] = array(
39 39
 			'title'=>$_lang["manage_templates"],
40
-			'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ),
41
-			'permissions'=>array('new_template','edit_template'),
40
+			'actions'=>array('edit'=>array(16, 'edit_template'), 'duplicate'=>array(96, 'new_template'), 'remove'=>array(21, 'delete_template')),
41
+			'permissions'=>array('new_template', 'edit_template'),
42 42
 			'name'=>'templatename'
43 43
 		);
44
-		$this->types['site_tmplvars']     = array(
44
+		$this->types['site_tmplvars'] = array(
45 45
 			'title'=>$_lang["tmplvars"],
46
-			'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')),
47
-			'permissions'=>array('new_template','edit_template'),
46
+			'actions'=>array('edit'=>array(301, 'edit_template'), 'duplicate'=>array(304, 'edit_template'), 'remove'=>array(303, 'edit_template')),
47
+			'permissions'=>array('new_template', 'edit_template'),
48 48
 		);
49 49
 		$this->types['site_htmlsnippets'] = array(
50 50
 			'title'=>$_lang["manage_htmlsnippets"],
51
-			'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')),
52
-			'permissions'=>array('new_chunk','edit_chunk'),
51
+			'actions'=>array('edit'=>array(78, 'edit_chunk'), 'duplicate'=>array(97, 'new_chunk'), 'remove'=>array(80, 'delete_chunk')),
52
+			'permissions'=>array('new_chunk', 'edit_chunk'),
53 53
 		);
54
-		$this->types['site_snippets']     = array(
54
+		$this->types['site_snippets'] = array(
55 55
 			'title'=>$_lang["manage_snippets"],
56
-			'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')),
57
-			'permissions'=>array('new_snippet','edit_snippet'),
56
+			'actions'=>array('edit'=>array(22, 'edit_snippet'), 'duplicate'=>array(98, 'new_snippet'), 'remove'=>array(25, 'delete_snippet')),
57
+			'permissions'=>array('new_snippet', 'edit_snippet'),
58 58
 		);
59
-		$this->types['site_plugins']      = array(
59
+		$this->types['site_plugins'] = array(
60 60
 			'title'=>$_lang["manage_plugins"],
61
-			'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')),
62
-			'permissions'=>array('new_plugin','edit_plugin'),
61
+			'actions'=>array('edit'=>array(102, 'edit_plugin'), 'duplicate'=>array(105, 'new_plugin'), 'remove'=>array(104, 'delete_plugin')),
62
+			'permissions'=>array('new_plugin', 'edit_plugin'),
63 63
 		);
64
-		$this->types['site_modules']      = array(
64
+		$this->types['site_modules'] = array(
65 65
 			'title'=>$_lang["manage_modules"],
66
-			'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')),
67
-			'permissions'=>array('new_module','edit_module'),
66
+			'actions'=>array('edit'=>array(108, 'edit_module'), 'duplicate'=>array(111, 'new_module'), 'remove'=>array(110, 'delete_module')),
67
+			'permissions'=>array('new_module', 'edit_module'),
68 68
 		);
69 69
 	}
70 70
 
71 71
     /**
72 72
      * @return void
73 73
      */
74
-    public function queryItemsFromDB() {
75
-		foreach($this->types as $resourceTable=>$type) {
76
-			if($this->hasAnyPermissions($type['permissions'])) {
74
+    public function queryItemsFromDB(){
75
+		foreach ($this->types as $resourceTable=>$type) {
76
+			if ($this->hasAnyPermissions($type['permissions'])) {
77 77
 				$nameField = isset($type['name']) ? $type['name'] : 'name';
78 78
 				$this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField);
79 79
 		   }
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
      * @param array $permissions
85 85
      * @return bool
86 86
      */
87
-    public function hasAnyPermissions($permissions) {
87
+    public function hasAnyPermissions($permissions){
88 88
 		$modx = evolutionCMS();
89 89
 
90
-		foreach($permissions as $p)
91
-			if($modx->hasPermission($p)) return true;
90
+		foreach ($permissions as $p)
91
+			if ($modx->hasPermission($p)) return true;
92 92
 
93 93
 		return false;
94 94
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @param string $nameField
99 99
      * @return array|bool
100 100
      */
101
-    public function queryResources($resourceTable, $nameField = 'name') {
101
+    public function queryResources($resourceTable, $nameField = 'name'){
102 102
 		$modx = evolutionCMS(); global $_lang;
103 103
 
104 104
         $allowed = array(
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             'site_plugins',
108 108
             'site_modules'
109 109
         );
110
-		$pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : '';
110
+		$pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable.'.disabled, ' : '';
111 111
 
112 112
 		$tvsql  = '';
113 113
 		$tvjoin = '';
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 
123 123
 		$rs = $modx->db->select(
124 124
 			"{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid",
125
-			$modx->getFullTableName($resourceTable) . " AS {$resourceTable}
126
-	            LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}",
125
+			$modx->getFullTableName($resourceTable)." AS {$resourceTable}
126
+	            LEFT JOIN ".$modx->getFullTableName('categories')." AS categories ON {$resourceTable}.category = categories.id {$tvjoin}",
127 127
 			"",
128 128
 			"category,name"
129 129
 		);
130 130
 		$limit = $modx->db->getRecordCount($rs);
131 131
 
132
-		if($limit < 1) return false;
132
+		if ($limit < 1) return false;
133 133
 
134 134
 		$result = array();
135 135
 		while ($row = $modx->db->getRow($rs)) {
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
     /**
142 142
      * @return void
143 143
      */
144
-    public function prepareCategoryArrays() {
145
-		foreach($this->items as $type=>$items) {
146
-			foreach((array)$items as $item) {
144
+    public function prepareCategoryArrays(){
145
+		foreach ($this->items as $type=>$items) {
146
+			foreach ((array) $items as $item) {
147 147
 				$catid = $item['catid'] ? $item['catid'] : 0;
148 148
 				$this->categories[$catid] = $item['category'];
149 149
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 		natcasesort($this->categories);
157 157
 
158 158
 		// Now sort by name
159
-		foreach($this->itemsPerCategory as $catid=>$items) {
160
-			usort($this->itemsPerCategory[$catid], function ($a, $b) {
159
+		foreach ($this->itemsPerCategory as $catid=>$items) {
160
+			usort($this->itemsPerCategory[$catid], function($a, $b){
161 161
 				return strcasecmp($a['name'], $b['name']);
162 162
 			});
163 163
 		}
Please login to merge, or discard this patch.
Braces   +23 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,7 +3,8 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 
6
-class mgrResources {
6
+class mgrResources
7
+{
7 8
     /**
8 9
      * @var array
9 10
      */
@@ -24,7 +25,8 @@  discard block
 block discarded – undo
24 25
     /**
25 26
      * mgrResources constructor.
26 27
      */
27
-    public function __construct() {
28
+    public function __construct()
29
+    {
28 30
 		$this->setTypes();
29 31
 		$this->queryItemsFromDB();
30 32
 		$this->prepareCategoryArrays();
@@ -33,7 +35,8 @@  discard block
 block discarded – undo
33 35
     /**
34 36
      * @return void
35 37
      */
36
-    public function setTypes() {
38
+    public function setTypes()
39
+    {
37 40
 		global $_lang;
38 41
 		$this->types['site_templates']    = array(
39 42
 			'title'=>$_lang["manage_templates"],
@@ -71,7 +74,8 @@  discard block
 block discarded – undo
71 74
     /**
72 75
      * @return void
73 76
      */
74
-    public function queryItemsFromDB() {
77
+    public function queryItemsFromDB()
78
+    {
75 79
 		foreach($this->types as $resourceTable=>$type) {
76 80
 			if($this->hasAnyPermissions($type['permissions'])) {
77 81
 				$nameField = isset($type['name']) ? $type['name'] : 'name';
@@ -84,11 +88,13 @@  discard block
 block discarded – undo
84 88
      * @param array $permissions
85 89
      * @return bool
86 90
      */
87
-    public function hasAnyPermissions($permissions) {
91
+    public function hasAnyPermissions($permissions)
92
+    {
88 93
 		$modx = evolutionCMS();
89 94
 
90
-		foreach($permissions as $p)
91
-			if($modx->hasPermission($p)) return true;
95
+		foreach($permissions as $p) {
96
+					if($modx->hasPermission($p)) return true;
97
+		}
92 98
 
93 99
 		return false;
94 100
 	}
@@ -98,7 +104,8 @@  discard block
 block discarded – undo
98 104
      * @param string $nameField
99 105
      * @return array|bool
100 106
      */
101
-    public function queryResources($resourceTable, $nameField = 'name') {
107
+    public function queryResources($resourceTable, $nameField = 'name')
108
+    {
102 109
 		$modx = evolutionCMS(); global $_lang;
103 110
 
104 111
         $allowed = array(
@@ -115,8 +122,9 @@  discard block
 block discarded – undo
115 122
 			$tvsql    = 'site_tmplvars.caption, ';
116 123
 			$tvjoin   = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates'));
117 124
 			$sttfield = 'IF(stt.templateid,1,0) AS reltpl,';
125
+		} else {
126
+		    $sttfield = '';
118 127
 		}
119
-		else $sttfield = '';
120 128
 
121 129
 		$selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : "";
122 130
 
@@ -129,7 +137,9 @@  discard block
 block discarded – undo
129 137
 		);
130 138
 		$limit = $modx->db->getRecordCount($rs);
131 139
 
132
-		if($limit < 1) return false;
140
+		if($limit < 1) {
141
+		    return false;
142
+		}
133 143
 
134 144
 		$result = array();
135 145
 		while ($row = $modx->db->getRow($rs)) {
@@ -141,7 +151,8 @@  discard block
 block discarded – undo
141 151
     /**
142 152
      * @return void
143 153
      */
144
-    public function prepareCategoryArrays() {
154
+    public function prepareCategoryArrays()
155
+    {
145 156
 		foreach($this->items as $type=>$items) {
146 157
 			foreach((array)$items as $item) {
147 158
 				$catid = $item['catid'] ? $item['catid'] : 0;
@@ -157,7 +168,7 @@  discard block
 block discarded – undo
157 168
 
158 169
 		// Now sort by name
159 170
 		foreach($this->itemsPerCategory as $catid=>$items) {
160
-			usort($this->itemsPerCategory[$catid], function ($a, $b) {
171
+			usort($this->itemsPerCategory[$catid], function ($a, $b){
161 172
 				return strcasecmp($a['name'], $b['name']);
162 173
 			});
163 174
 		}
Please login to merge, or discard this patch.
manager/actions/mutate_role.dynamic.php 3 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 
6 6
 switch((int) $modx->manager->action) {
7
-	case 35:
8
-		if(!$modx->hasPermission('edit_role')) {
9
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
-		}
11
-		break;
12
-	case 38:
13
-		if(!$modx->hasPermission('new_role')) {
14
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
-		}
16
-		break;
17
-	default:
18
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7
+    case 35:
8
+        if(!$modx->hasPermission('edit_role')) {
9
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
+        }
11
+        break;
12
+    case 38:
13
+        if(!$modx->hasPermission('new_role')) {
14
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
+        }
16
+        break;
17
+    default:
18
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21 21
 $role = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 // check to see the snippet editor isn't locked
26 26
 if($lockedEl = $modx->elementIsLocked(8, $role)) {
27
-	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['role']));
27
+    $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['role']));
28 28
 }
29 29
 // end check for lock
30 30
 
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
 $modx->lockElement(8, $role);
33 33
 
34 34
 if($modx->manager->action == '35') {
35
-	$rs = $modx->db->select('*', $tbl_user_roles, "id='{$role}'");
36
-	$roledata = $modx->db->getRow($rs);
37
-	if(!$roledata) {
38
-		$modx->webAlertAndQuit("No role returned!");
39
-	}
40
-	$_SESSION['itemname'] = $roledata['name'];
35
+    $rs = $modx->db->select('*', $tbl_user_roles, "id='{$role}'");
36
+    $roledata = $modx->db->getRow($rs);
37
+    if(!$roledata) {
38
+        $modx->webAlertAndQuit("No role returned!");
39
+    }
40
+    $_SESSION['itemname'] = $roledata['name'];
41 41
 } else {
42
-	$roledata = 0;
43
-	$_SESSION['itemname'] = $_lang["new_role"];
42
+    $roledata = 0;
43
+    $_SESSION['itemname'] = $_lang["new_role"];
44 44
 }
45 45
 
46 46
 // Add lock-element JS-Script
@@ -107,63 +107,63 @@  discard block
 block discarded – undo
107 107
 							<div class="form-group">
108 108
 								<h3><?= $_lang['page_data_general'] ?></h3>
109 109
 								<?php
110
-								echo render_form('frames', $_lang['role_frames'], 'disabled');
111
-								echo render_form('home', $_lang['role_home'], 'disabled');
112
-								echo render_form('messages', $_lang['role_messages']);
113
-								echo render_form('logout', $_lang['role_logout'], 'disabled');
114
-								echo render_form('help', $_lang['role_help']);
115
-								echo render_form('action_ok', $_lang['role_actionok'], 'disabled');
116
-								echo render_form('error_dialog', $_lang['role_errors'], 'disabled');
117
-								echo render_form('about', $_lang['role_about'], 'disabled');
118
-								echo render_form('credits', $_lang['role_credits'], 'disabled');
119
-								echo render_form('change_password', $_lang['role_change_password']);
120
-								echo render_form('save_password', $_lang['role_save_password']);
121
-								?>
110
+                                echo render_form('frames', $_lang['role_frames'], 'disabled');
111
+                                echo render_form('home', $_lang['role_home'], 'disabled');
112
+                                echo render_form('messages', $_lang['role_messages']);
113
+                                echo render_form('logout', $_lang['role_logout'], 'disabled');
114
+                                echo render_form('help', $_lang['role_help']);
115
+                                echo render_form('action_ok', $_lang['role_actionok'], 'disabled');
116
+                                echo render_form('error_dialog', $_lang['role_errors'], 'disabled');
117
+                                echo render_form('about', $_lang['role_about'], 'disabled');
118
+                                echo render_form('credits', $_lang['role_credits'], 'disabled');
119
+                                echo render_form('change_password', $_lang['role_change_password']);
120
+                                echo render_form('save_password', $_lang['role_save_password']);
121
+                                ?>
122 122
 							</div>
123 123
 						</div>
124 124
 						<div class="col-sm-6 col-lg-3">
125 125
 							<div class="form-group">
126 126
 								<h3><?= $_lang['role_content_management'] ?></h3>
127 127
 								<?php
128
-								echo render_form('view_document', $_lang['role_view_docdata'], 'disabled');
129
-								echo render_form('new_document', $_lang['role_create_doc']);
130
-								echo render_form('edit_document', $_lang['role_edit_doc']);
131
-								echo render_form('change_resourcetype', $_lang['role_change_resourcetype']);
132
-								echo render_form('save_document', $_lang['role_save_doc']);
133
-								echo render_form('publish_document', $_lang['role_publish_doc']);
134
-								echo render_form('delete_document', $_lang['role_delete_doc']);
135
-								echo render_form('empty_trash', $_lang['role_empty_trash']);
136
-								echo render_form('empty_cache', $_lang['role_cache_refresh']);
137
-								echo render_form('view_unpublished', $_lang['role_view_unpublished']);
138
-								?>
128
+                                echo render_form('view_document', $_lang['role_view_docdata'], 'disabled');
129
+                                echo render_form('new_document', $_lang['role_create_doc']);
130
+                                echo render_form('edit_document', $_lang['role_edit_doc']);
131
+                                echo render_form('change_resourcetype', $_lang['role_change_resourcetype']);
132
+                                echo render_form('save_document', $_lang['role_save_doc']);
133
+                                echo render_form('publish_document', $_lang['role_publish_doc']);
134
+                                echo render_form('delete_document', $_lang['role_delete_doc']);
135
+                                echo render_form('empty_trash', $_lang['role_empty_trash']);
136
+                                echo render_form('empty_cache', $_lang['role_cache_refresh']);
137
+                                echo render_form('view_unpublished', $_lang['role_view_unpublished']);
138
+                                ?>
139 139
 							</div>
140 140
 						</div>
141 141
 						<div class="col-sm-6 col-lg-3 form-group">
142 142
 							<div class="form-group">
143 143
 								<h3><?= $_lang['role_file_management'] ?></h3>
144 144
 								<?php
145
-								echo render_form('file_manager', $_lang['role_file_manager']);
146
-								echo render_form('assets_files', $_lang['role_assets_files']);
147
-								echo render_form('assets_images', $_lang['role_assets_images']);
148
-								?>
145
+                                echo render_form('file_manager', $_lang['role_file_manager']);
146
+                                echo render_form('assets_files', $_lang['role_assets_files']);
147
+                                echo render_form('assets_images', $_lang['role_assets_images']);
148
+                                ?>
149 149
 							</div>
150 150
 							<div class="form-group">
151 151
 								<h3><?= $_lang['category_management'] ?></h3>
152 152
 								<?php
153
-								echo render_form('category_manager', $_lang['role_category_manager']);
154
-								?>
153
+                                echo render_form('category_manager', $_lang['role_category_manager']);
154
+                                ?>
155 155
 							</div>
156 156
 						</div>
157 157
 						<div class="col-sm-6 col-lg-3">
158 158
 							<div class="form-group">
159 159
 								<h3><?= $_lang['role_module_management'] ?></h3>
160 160
 								<?php
161
-								echo render_form('new_module', $_lang['role_new_module']);
162
-								echo render_form('edit_module', $_lang['role_edit_module']);
163
-								echo render_form('save_module', $_lang['role_save_module']);
164
-								echo render_form('delete_module', $_lang['role_delete_module']);
165
-								echo render_form('exec_module', $_lang['role_run_module']);
166
-								?>
161
+                                echo render_form('new_module', $_lang['role_new_module']);
162
+                                echo render_form('edit_module', $_lang['role_edit_module']);
163
+                                echo render_form('save_module', $_lang['role_save_module']);
164
+                                echo render_form('delete_module', $_lang['role_delete_module']);
165
+                                echo render_form('exec_module', $_lang['role_run_module']);
166
+                                ?>
167 167
 							</div>
168 168
 						</div>
169 169
 					</div>
@@ -173,44 +173,44 @@  discard block
 block discarded – undo
173 173
 							<div class="form-group">
174 174
 								<h3><?= $_lang['role_template_management'] ?></h3>
175 175
 								<?php
176
-								echo render_form('new_template', $_lang['role_create_template']);
177
-								echo render_form('edit_template', $_lang['role_edit_template']);
178
-								echo render_form('save_template', $_lang['role_save_template']);
179
-								echo render_form('delete_template', $_lang['role_delete_template']);
180
-								?>
176
+                                echo render_form('new_template', $_lang['role_create_template']);
177
+                                echo render_form('edit_template', $_lang['role_edit_template']);
178
+                                echo render_form('save_template', $_lang['role_save_template']);
179
+                                echo render_form('delete_template', $_lang['role_delete_template']);
180
+                                ?>
181 181
 							</div>
182 182
 						</div>
183 183
 						<div class="col-sm-6 col-lg-3">
184 184
 							<div class="form-group">
185 185
 								<h3><?= $_lang['role_snippet_management'] ?></h3>
186 186
 								<?php
187
-								echo render_form('new_snippet', $_lang['role_create_snippet']);
188
-								echo render_form('edit_snippet', $_lang['role_edit_snippet']);
189
-								echo render_form('save_snippet', $_lang['role_save_snippet']);
190
-								echo render_form('delete_snippet', $_lang['role_delete_snippet']);
191
-								?>
187
+                                echo render_form('new_snippet', $_lang['role_create_snippet']);
188
+                                echo render_form('edit_snippet', $_lang['role_edit_snippet']);
189
+                                echo render_form('save_snippet', $_lang['role_save_snippet']);
190
+                                echo render_form('delete_snippet', $_lang['role_delete_snippet']);
191
+                                ?>
192 192
 							</div>
193 193
 						</div>
194 194
 						<div class="col-sm-6 col-lg-3">
195 195
 							<div class="form-group">
196 196
 								<h3><?= $_lang['role_chunk_management'] ?></h3>
197 197
 								<?php
198
-								echo render_form('new_chunk', $_lang['role_create_chunk']);
199
-								echo render_form('edit_chunk', $_lang['role_edit_chunk']);
200
-								echo render_form('save_chunk', $_lang['role_save_chunk']);
201
-								echo render_form('delete_chunk', $_lang['role_delete_chunk']);
202
-								?>
198
+                                echo render_form('new_chunk', $_lang['role_create_chunk']);
199
+                                echo render_form('edit_chunk', $_lang['role_edit_chunk']);
200
+                                echo render_form('save_chunk', $_lang['role_save_chunk']);
201
+                                echo render_form('delete_chunk', $_lang['role_delete_chunk']);
202
+                                ?>
203 203
 							</div>
204 204
 						</div>
205 205
 						<div class="col-sm-6 col-lg-3">
206 206
 							<div class="form-group">
207 207
 								<h3><?= $_lang['role_plugin_management'] ?></h3>
208 208
 								<?php
209
-								echo render_form('new_plugin', $_lang['role_create_plugin']);
210
-								echo render_form('edit_plugin', $_lang['role_edit_plugin']);
211
-								echo render_form('save_plugin', $_lang['role_save_plugin']);
212
-								echo render_form('delete_plugin', $_lang['role_delete_plugin']);
213
-								?>
209
+                                echo render_form('new_plugin', $_lang['role_create_plugin']);
210
+                                echo render_form('edit_plugin', $_lang['role_edit_plugin']);
211
+                                echo render_form('save_plugin', $_lang['role_save_plugin']);
212
+                                echo render_form('delete_plugin', $_lang['role_delete_plugin']);
213
+                                ?>
214 214
 							</div>
215 215
 						</div>
216 216
 					</div>
@@ -220,42 +220,42 @@  discard block
 block discarded – undo
220 220
 							<div class="form-group">
221 221
 								<h3><?= $_lang['role_user_management'] ?></h3>
222 222
 								<?php
223
-								echo render_form('new_user', $_lang['role_new_user']);
224
-								echo render_form('edit_user', $_lang['role_edit_user']);
225
-								echo render_form('save_user', $_lang['role_save_user']);
226
-								echo render_form('delete_user', $_lang['role_delete_user']);
227
-								?>
223
+                                echo render_form('new_user', $_lang['role_new_user']);
224
+                                echo render_form('edit_user', $_lang['role_edit_user']);
225
+                                echo render_form('save_user', $_lang['role_save_user']);
226
+                                echo render_form('delete_user', $_lang['role_delete_user']);
227
+                                ?>
228 228
 							</div>
229 229
 						</div>
230 230
 						<div class="col-sm-6 col-lg-3">
231 231
 							<div class="form-group">
232 232
 								<h3><?= $_lang['role_web_user_management'] ?></h3>
233 233
 								<?php
234
-								echo render_form('new_web_user', $_lang['role_new_web_user']);
235
-								echo render_form('edit_web_user', $_lang['role_edit_web_user']);
236
-								echo render_form('save_web_user', $_lang['role_save_web_user']);
237
-								echo render_form('delete_web_user', $_lang['role_delete_web_user']);
238
-								?>
234
+                                echo render_form('new_web_user', $_lang['role_new_web_user']);
235
+                                echo render_form('edit_web_user', $_lang['role_edit_web_user']);
236
+                                echo render_form('save_web_user', $_lang['role_save_web_user']);
237
+                                echo render_form('delete_web_user', $_lang['role_delete_web_user']);
238
+                                ?>
239 239
 							</div>
240 240
 						</div>
241 241
 						<div class="col-sm-6 col-lg-3">
242 242
 							<div class="form-group">
243 243
 								<h3><?= $_lang['role_udperms'] ?></h3>
244 244
 								<?php
245
-								echo render_form('access_permissions', $_lang['role_access_persmissions']);
246
-								echo render_form('web_access_permissions', $_lang['role_web_access_persmissions']);
247
-								?>
245
+                                echo render_form('access_permissions', $_lang['role_access_persmissions']);
246
+                                echo render_form('web_access_permissions', $_lang['role_web_access_persmissions']);
247
+                                ?>
248 248
 							</div>
249 249
 						</div>
250 250
 						<div class="col-sm-6 col-lg-3">
251 251
 							<div class="form-group">
252 252
 								<h3><?= $_lang['role_role_management'] ?></h3>
253 253
 								<?php
254
-								echo render_form('new_role', $_lang['role_new_role']);
255
-								echo render_form('edit_role', $_lang['role_edit_role']);
256
-								echo render_form('save_role', $_lang['role_save_role']);
257
-								echo render_form('delete_role', $_lang['role_delete_role']);
258
-								?>
254
+                                echo render_form('new_role', $_lang['role_new_role']);
255
+                                echo render_form('edit_role', $_lang['role_edit_role']);
256
+                                echo render_form('save_role', $_lang['role_save_role']);
257
+                                echo render_form('delete_role', $_lang['role_delete_role']);
258
+                                ?>
259 259
 							</div>
260 260
 						</div>
261 261
 					</div>
@@ -265,23 +265,23 @@  discard block
 block discarded – undo
265 265
 							<div class="form-group">
266 266
 								<h3><?= $_lang['role_eventlog_management'] ?></h3>
267 267
 								<?php
268
-								echo render_form('view_eventlog', $_lang['role_view_eventlog']);
269
-								echo render_form('delete_eventlog', $_lang['role_delete_eventlog']);
270
-								?>
268
+                                echo render_form('view_eventlog', $_lang['role_view_eventlog']);
269
+                                echo render_form('delete_eventlog', $_lang['role_delete_eventlog']);
270
+                                ?>
271 271
 							</div>
272 272
 						</div>
273 273
 						<div class="col-sm-6 col-lg-3">
274 274
 							<div class="form-group">
275 275
 								<h3><?= $_lang['role_config_management'] ?></h3>
276 276
 								<?php
277
-								echo render_form('logs', $_lang['role_view_logs']);
278
-								echo render_form('settings', $_lang['role_edit_settings']);
279
-								echo render_form('bk_manager', $_lang['role_bk_manager']);
280
-								echo render_form('import_static', $_lang['role_import_static']);
281
-								echo render_form('export_static', $_lang['role_export_static']);
282
-								echo render_form('remove_locks', $_lang['role_remove_locks']);
283
-								echo render_form('display_locks', $_lang['role_display_locks']);
284
-								?>
277
+                                echo render_form('logs', $_lang['role_view_logs']);
278
+                                echo render_form('settings', $_lang['role_edit_settings']);
279
+                                echo render_form('bk_manager', $_lang['role_bk_manager']);
280
+                                echo render_form('import_static', $_lang['role_import_static']);
281
+                                echo render_form('export_static', $_lang['role_export_static']);
282
+                                echo render_form('remove_locks', $_lang['role_remove_locks']);
283
+                                echo render_form('display_locks', $_lang['role_display_locks']);
284
+                                ?>
285 285
 							</div>
286 286
 						</div>
287 287
 					</div>
@@ -300,32 +300,32 @@  discard block
 block discarded – undo
300 300
  * @return string
301 301
  */
302 302
 function render_form($name, $label, $status = '') {
303
-	$modx = evolutionCMS(); global $roledata;
303
+    $modx = evolutionCMS(); global $roledata;
304 304
 
305
-	$tpl = '<label class="d-block" for="[+name+]check">
305
+    $tpl = '<label class="d-block" for="[+name+]check">
306 306
 		<input name="[+name+]check" id="[+name+]check" class="click" type="checkbox" onchange="changestate(document.userform.[+name+])" [+checked+] [+status+]>
307 307
 		<input type="hidden" class="[+set+]" name="[+name+]" value="[+value+]">
308 308
 		[+label+]
309 309
 	</label>';
310 310
 
311
-	$checked = ($roledata[$name] == 1) ? 'checked' : '';
312
-	$value = ($roledata[$name] == 1) ? 1 : 0;
313
-	if($status == 'disabled') {
314
-		$checked = 'checked';
315
-		$value = 1;
316
-		$set = 'fix';
317
-	} else {
318
-		$set = 'set';
319
-	}
311
+    $checked = ($roledata[$name] == 1) ? 'checked' : '';
312
+    $value = ($roledata[$name] == 1) ? 1 : 0;
313
+    if($status == 'disabled') {
314
+        $checked = 'checked';
315
+        $value = 1;
316
+        $set = 'fix';
317
+    } else {
318
+        $set = 'set';
319
+    }
320 320
 
321
-	$ph = array(
322
-		'name' => $name,
323
-		'checked' => $checked,
324
-		'status' => $status,
325
-		'value' => $value,
326
-		'label' => $label,
327
-		'set' => $set
328
-	);
321
+    $ph = array(
322
+        'name' => $name,
323
+        'checked' => $checked,
324
+        'status' => $status,
325
+        'value' => $value,
326
+        'label' => $label,
327
+        'set' => $set
328
+    );
329 329
 
330
-	return $modx->parseText($tpl, $ph);
330
+    return $modx->parseText($tpl, $ph);
331 331
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  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 5
 
6
-switch((int) $modx->manager->action) {
6
+switch ((int) $modx->manager->action) {
7 7
 	case 35:
8
-		if(!$modx->hasPermission('edit_role')) {
8
+		if (!$modx->hasPermission('edit_role')) {
9 9
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
10 10
 		}
11 11
 		break;
12 12
 	case 38:
13
-		if(!$modx->hasPermission('new_role')) {
13
+		if (!$modx->hasPermission('new_role')) {
14 14
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
15 15
 		}
16 16
 		break;
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21
-$role = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
21
+$role = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
22 22
 
23 23
 $tbl_user_roles = $modx->getFullTableName('user_roles');
24 24
 
25 25
 // check to see the snippet editor isn't locked
26
-if($lockedEl = $modx->elementIsLocked(8, $role)) {
26
+if ($lockedEl = $modx->elementIsLocked(8, $role)) {
27 27
 	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['role']));
28 28
 }
29 29
 // end check for lock
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 // Lock snippet for other users to edit
32 32
 $modx->lockElement(8, $role);
33 33
 
34
-if($modx->manager->action == '35') {
34
+if ($modx->manager->action == '35') {
35 35
 	$rs = $modx->db->select('*', $tbl_user_roles, "id='{$role}'");
36 36
 	$roledata = $modx->db->getRow($rs);
37
-	if(!$roledata) {
37
+	if (!$roledata) {
38 38
 		$modx->webAlertAndQuit("No role returned!");
39 39
 	}
40 40
 	$_SESSION['itemname'] = $roledata['name'];
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 // Add lock-element JS-Script
47 47
 $lockElementId = $role;
48 48
 $lockElementType = 8;
49
-require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php');
49
+require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php');
50 50
 ?>
51 51
 	<script type="text/javascript">
52 52
 		function changestate(element) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		<input type="hidden" name="id" value="<?= $_GET['id'] ?>">
83 83
 
84 84
 		<h1>
85
-            <i class="fa fa-legal"></i><?= ($roledata['name'] ? $roledata['name'] . '<small>(' . $roledata['id'] . ')</small>' : $_lang['role_title']) ?>
85
+            <i class="fa fa-legal"></i><?= ($roledata['name'] ? $roledata['name'].'<small>('.$roledata['id'].')</small>' : $_lang['role_title']) ?>
86 86
         </h1>
87 87
 
88 88
 		<?= $_style['actionbuttons']['dynamic']['savedelete'] ?>
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
  * @param string $status
300 300
  * @return string
301 301
  */
302
-function render_form($name, $label, $status = '') {
302
+function render_form($name, $label, $status = ''){
303 303
 	$modx = evolutionCMS(); global $roledata;
304 304
 
305 305
 	$tpl = '<label class="d-block" for="[+name+]check">
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 	$checked = ($roledata[$name] == 1) ? 'checked' : '';
312 312
 	$value = ($roledata[$name] == 1) ? 1 : 0;
313
-	if($status == 'disabled') {
313
+	if ($status == 'disabled') {
314 314
 		$checked = 'checked';
315 315
 		$value = 1;
316 316
 		$set = 'fix';
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -299,7 +299,8 @@
 block discarded – undo
299 299
  * @param string $status
300 300
  * @return string
301 301
  */
302
-function render_form($name, $label, $status = '') {
302
+function render_form($name, $label, $status = '')
303
+{
303 304
 	$modx = evolutionCMS(); global $roledata;
304 305
 
305 306
 	$tpl = '<label class="d-block" for="[+name+]check">
Please login to merge, or discard this patch.
manager/actions/files.dynamic.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -893,7 +893,9 @@
 block discarded – undo
893 893
     $modx = evolutionCMS(); global $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions;
894 894
     $msg = '';
895 895
     foreach ($_FILES['userfile']['name'] as $i => $name) {
896
-        if (empty($_FILES['userfile']['tmp_name'][$i])) continue;
896
+        if (empty($_FILES['userfile']['tmp_name'][$i])) {
897
+            continue;
898
+        }
897 899
         $userfile= array();
898 900
 
899 901
         $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i];
Please login to merge, or discard this patch.
manager/includes/tmplvars.inc.php 3 patches
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -14,158 +14,158 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) {
16 16
     $modx = evolutionCMS();
17
-	global $_style;
18
-	global $_lang;
19
-	global $content;
20
-	global $which_browser;
17
+    global $_style;
18
+    global $_lang;
19
+    global $content;
20
+    global $which_browser;
21 21
 
22
-	if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) {
23
-		$eval_str = trim(substr($default_text, 7));
24
-		$default_text = eval($eval_str);
25
-		$field_value = $default_text;
26
-	}
22
+    if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) {
23
+        $eval_str = trim(substr($default_text, 7));
24
+        $default_text = eval($eval_str);
25
+        $field_value = $default_text;
26
+    }
27 27
 
28
-	$field_html = '';
29
-	$cimode = strpos($field_type, ':');
30
-	if($cimode === false) {
31
-		switch($field_type) {
28
+    $field_html = '';
29
+    $cimode = strpos($field_type, ':');
30
+    if($cimode === false) {
31
+        switch($field_type) {
32 32
 
33
-			case "text": // handler for regular text boxes
34
-			case "rawtext"; // non-htmlentity converted text boxes
35
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />';
36
-				break;
37
-			case "email": // handles email input fields
38
-				$field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>';
39
-				break;
40
-			case "number": // handles the input of numbers
41
-				$field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>';
42
-				break;
43
-			case "textareamini": // handler for textarea mini boxes
44
-				$field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
45
-				break;
46
-			case "textarea": // handler for textarea boxes
47
-			case "rawtextarea": // non-htmlentity convertex textarea boxes
48
-			case "htmlarea": // handler for textarea boxes (deprecated)
49
-			case "richtext": // handler for textarea boxes
50
-				$field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
51
-				break;
52
-			case "date":
53
-				$field_id = str_replace(array(
54
-					'-',
55
-					'.'
56
-				), '_', urldecode($field_id));
57
-				if($field_value == '') {
58
-					$field_value = 0;
59
-				}
60
-				$field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />';
61
-				$field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>';
33
+            case "text": // handler for regular text boxes
34
+            case "rawtext"; // non-htmlentity converted text boxes
35
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />';
36
+                break;
37
+            case "email": // handles email input fields
38
+                $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>';
39
+                break;
40
+            case "number": // handles the input of numbers
41
+                $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>';
42
+                break;
43
+            case "textareamini": // handler for textarea mini boxes
44
+                $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
45
+                break;
46
+            case "textarea": // handler for textarea boxes
47
+            case "rawtextarea": // non-htmlentity convertex textarea boxes
48
+            case "htmlarea": // handler for textarea boxes (deprecated)
49
+            case "richtext": // handler for textarea boxes
50
+                $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
51
+                break;
52
+            case "date":
53
+                $field_id = str_replace(array(
54
+                    '-',
55
+                    '.'
56
+                ), '_', urldecode($field_id));
57
+                if($field_value == '') {
58
+                    $field_value = 0;
59
+                }
60
+                $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />';
61
+                $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>';
62 62
 
63
-				break;
64
-			case "dropdown": // handler for select boxes
65
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">';
66
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
67
-				while(list($item, $itemvalue) = each($index_list)) {
68
-					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
69
-					if(strlen($itemvalue) == 0) {
70
-						$itemvalue = $item;
71
-					}
72
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
73
-				}
74
-				$field_html .= "</select>";
75
-				break;
76
-			case "listbox": // handler for select boxes
77
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">';
78
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
79
-				while(list($item, $itemvalue) = each($index_list)) {
80
-					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
81
-					if(strlen($itemvalue) == 0) {
82
-						$itemvalue = $item;
83
-					}
84
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
85
-				}
86
-				$field_html .= "</select>";
87
-				break;
88
-			case "listbox-multiple": // handler for select boxes where you can choose multiple items
89
-				$field_value = explode("||", $field_value);
90
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">';
91
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
92
-				while(list($item, $itemvalue) = each($index_list)) {
93
-					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
94
-					if(strlen($itemvalue) == 0) {
95
-						$itemvalue = $item;
96
-					}
97
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
98
-				}
99
-				$field_html .= "</select>";
100
-				break;
101
-			case "url": // handles url input fields
102
-				$urls = array(
103
-					'' => '--',
104
-					'http://' => 'http://',
105
-					'https://' => 'https://',
106
-					'ftp://' => 'ftp://',
107
-					'mailto:' => 'mailto:'
108
-				);
109
-				$field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">';
110
-				foreach($urls as $k => $v) {
111
-					if(strpos($field_value, $v) === false) {
112
-						$field_html .= '<option value="' . $v . '">' . $k . '</option>';
113
-					} else {
114
-						$field_value = str_replace($v, '', $field_value);
115
-						$field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>';
116
-					}
117
-				}
118
-				$field_html .= '</select></td><td>';
119
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>';
120
-				break;
121
-			case 'checkbox': // handles check boxes
122
-				$values = !is_array($field_value) ? explode('||', $field_value) : $field_value;
123
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
124
-				$tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />';
125
-				static $i = 0;
126
-				$_ = array();
127
-				foreach($index_list as $c => $item) {
128
-					if(is_array($item)) {
129
-						$name = trim($item[0]);
130
-						$value = isset($item[1]) ? $item[1] : $name;
131
-					} else {
132
-						$item = trim($item);
133
-						list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array(
134
-							$item,
135
-							$item
136
-						);
137
-					}
138
-					$checked = in_array($value, $values) ? ' checked="checked"' : '';
139
-					$param = array(
140
-						$modx->htmlspecialchars($value),
141
-						$i,
142
-						$field_id,
143
-						$checked,
144
-						$modx->htmlspecialchars($name)
145
-					);
146
-					$_[] = vsprintf($tpl, $param);
147
-					$i++;
148
-				}
149
-				$field_html = implode("\n", $_);
150
-				break;
151
-			case "option": // handles radio buttons
152
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
153
-				static $i = 0;
154
-				while(list($item, $itemvalue) = each($index_list)) {
155
-					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
156
-					if(strlen($itemvalue) == 0) {
157
-						$itemvalue = $item;
158
-					}
159
-					$field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />';
160
-					$i++;
161
-				}
162
-				break;
163
-			case "image": // handles image fields using htmlarea image manager
164
-				global $_lang;
165
-				global $ResourceManagerLoaded;
166
-				global $content, $use_editor, $which_editor;
167
-				if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
168
-					$field_html .= "
63
+                break;
64
+            case "dropdown": // handler for select boxes
65
+                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">';
66
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
67
+                while(list($item, $itemvalue) = each($index_list)) {
68
+                    list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
69
+                    if(strlen($itemvalue) == 0) {
70
+                        $itemvalue = $item;
71
+                    }
72
+                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
73
+                }
74
+                $field_html .= "</select>";
75
+                break;
76
+            case "listbox": // handler for select boxes
77
+                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">';
78
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
79
+                while(list($item, $itemvalue) = each($index_list)) {
80
+                    list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
81
+                    if(strlen($itemvalue) == 0) {
82
+                        $itemvalue = $item;
83
+                    }
84
+                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
85
+                }
86
+                $field_html .= "</select>";
87
+                break;
88
+            case "listbox-multiple": // handler for select boxes where you can choose multiple items
89
+                $field_value = explode("||", $field_value);
90
+                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">';
91
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
92
+                while(list($item, $itemvalue) = each($index_list)) {
93
+                    list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
94
+                    if(strlen($itemvalue) == 0) {
95
+                        $itemvalue = $item;
96
+                    }
97
+                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
98
+                }
99
+                $field_html .= "</select>";
100
+                break;
101
+            case "url": // handles url input fields
102
+                $urls = array(
103
+                    '' => '--',
104
+                    'http://' => 'http://',
105
+                    'https://' => 'https://',
106
+                    'ftp://' => 'ftp://',
107
+                    'mailto:' => 'mailto:'
108
+                );
109
+                $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">';
110
+                foreach($urls as $k => $v) {
111
+                    if(strpos($field_value, $v) === false) {
112
+                        $field_html .= '<option value="' . $v . '">' . $k . '</option>';
113
+                    } else {
114
+                        $field_value = str_replace($v, '', $field_value);
115
+                        $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>';
116
+                    }
117
+                }
118
+                $field_html .= '</select></td><td>';
119
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>';
120
+                break;
121
+            case 'checkbox': // handles check boxes
122
+                $values = !is_array($field_value) ? explode('||', $field_value) : $field_value;
123
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
124
+                $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />';
125
+                static $i = 0;
126
+                $_ = array();
127
+                foreach($index_list as $c => $item) {
128
+                    if(is_array($item)) {
129
+                        $name = trim($item[0]);
130
+                        $value = isset($item[1]) ? $item[1] : $name;
131
+                    } else {
132
+                        $item = trim($item);
133
+                        list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array(
134
+                            $item,
135
+                            $item
136
+                        );
137
+                    }
138
+                    $checked = in_array($value, $values) ? ' checked="checked"' : '';
139
+                    $param = array(
140
+                        $modx->htmlspecialchars($value),
141
+                        $i,
142
+                        $field_id,
143
+                        $checked,
144
+                        $modx->htmlspecialchars($name)
145
+                    );
146
+                    $_[] = vsprintf($tpl, $param);
147
+                    $i++;
148
+                }
149
+                $field_html = implode("\n", $_);
150
+                break;
151
+            case "option": // handles radio buttons
152
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
153
+                static $i = 0;
154
+                while(list($item, $itemvalue) = each($index_list)) {
155
+                    list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
156
+                    if(strlen($itemvalue) == 0) {
157
+                        $itemvalue = $item;
158
+                    }
159
+                    $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />';
160
+                    $i++;
161
+                }
162
+                break;
163
+            case "image": // handles image fields using htmlarea image manager
164
+                global $_lang;
165
+                global $ResourceManagerLoaded;
166
+                global $content, $use_editor, $which_editor;
167
+                if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
168
+                    $field_html .= "
169 169
 						<script type=\"text/javascript\">
170 170
 							/* <![CDATA[ */
171 171
 								var lastImageCtrl;
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
 								}
225 225
 							/* ]]> */
226 226
 						</script>";
227
-					$ResourceManagerLoaded = true;
228
-				}
229
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />';
230
-				break;
231
-			case "file": // handles the input of file uploads
232
-				/* Modified by Timon for use with resource browser */
233
-				global $_lang;
234
-				global $ResourceManagerLoaded;
235
-				global $content, $use_editor, $which_editor;
236
-				if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
237
-					/* I didn't understand the meaning of the condition above, so I left it untouched ;-) */
238
-					$field_html .= "
227
+                    $ResourceManagerLoaded = true;
228
+                }
229
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />';
230
+                break;
231
+            case "file": // handles the input of file uploads
232
+                /* Modified by Timon for use with resource browser */
233
+                global $_lang;
234
+                global $ResourceManagerLoaded;
235
+                global $content, $use_editor, $which_editor;
236
+                if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
237
+                    /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */
238
+                    $field_html .= "
239 239
 						<script type=\"text/javascript\">
240 240
 							/* <![CDATA[ */
241 241
 								var lastImageCtrl;
@@ -294,90 +294,90 @@  discard block
 block discarded – undo
294 294
 								}
295 295
 							/* ]]> */
296 296
 						</script>";
297
-					$ResourceManagerLoaded = true;
298
-				}
299
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />';
297
+                    $ResourceManagerLoaded = true;
298
+                }
299
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />';
300 300
 
301
-				break;
301
+                break;
302 302
 
303
-			case 'custom_tv':
304
-				$custom_output = '';
305
-				/* If we are loading a file */
306
-				if(substr($field_elements, 0, 5) == "@FILE") {
307
-					$file_name = MODX_BASE_PATH . trim(substr($field_elements, 6));
308
-					if(!file_exists($file_name)) {
309
-						$custom_output = $file_name . ' does not exist';
310
-					} else {
311
-						$custom_output = file_get_contents($file_name);
312
-					}
313
-				} elseif(substr($field_elements, 0, 8) == '@INCLUDE') {
314
-					$file_name = MODX_BASE_PATH . trim(substr($field_elements, 9));
315
-					if(!file_exists($file_name)) {
316
-						$custom_output = $file_name . ' does not exist';
317
-					} else {
318
-						ob_start();
319
-						include $file_name;
320
-						$custom_output = ob_get_contents();
321
-						ob_end_clean();
322
-					}
323
-				} elseif(substr($field_elements, 0, 6) == "@CHUNK") {
324
-					$chunk_name = trim(substr($field_elements, 7));
325
-					$chunk_body = $modx->getChunk($chunk_name);
326
-					if($chunk_body == false) {
327
-						$custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')';
328
-					} else {
329
-						$custom_output = $chunk_body;
330
-					}
331
-				} elseif(substr($field_elements, 0, 5) == "@EVAL") {
332
-					$eval_str = trim(substr($field_elements, 6));
333
-					$custom_output = eval($eval_str);
334
-				} else {
335
-					$custom_output = $field_elements;
336
-				}
337
-				$replacements = array(
338
-					'[+field_type+]' => $field_type,
339
-					'[+field_id+]' => $field_id,
340
-					'[+default_text+]' => $default_text,
341
-					'[+field_value+]' => $modx->htmlspecialchars($field_value),
342
-					'[+field_style+]' => $field_style,
343
-				);
344
-				$custom_output = str_replace(array_keys($replacements), $replacements, $custom_output);
345
-				$modx->documentObject = $content;
346
-				$modx->documentIdentifier = $content['id'];
347
-				$custom_output = $modx->parseDocumentSource($custom_output);
348
-				$field_html .= $custom_output;
349
-				break;
303
+            case 'custom_tv':
304
+                $custom_output = '';
305
+                /* If we are loading a file */
306
+                if(substr($field_elements, 0, 5) == "@FILE") {
307
+                    $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6));
308
+                    if(!file_exists($file_name)) {
309
+                        $custom_output = $file_name . ' does not exist';
310
+                    } else {
311
+                        $custom_output = file_get_contents($file_name);
312
+                    }
313
+                } elseif(substr($field_elements, 0, 8) == '@INCLUDE') {
314
+                    $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9));
315
+                    if(!file_exists($file_name)) {
316
+                        $custom_output = $file_name . ' does not exist';
317
+                    } else {
318
+                        ob_start();
319
+                        include $file_name;
320
+                        $custom_output = ob_get_contents();
321
+                        ob_end_clean();
322
+                    }
323
+                } elseif(substr($field_elements, 0, 6) == "@CHUNK") {
324
+                    $chunk_name = trim(substr($field_elements, 7));
325
+                    $chunk_body = $modx->getChunk($chunk_name);
326
+                    if($chunk_body == false) {
327
+                        $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')';
328
+                    } else {
329
+                        $custom_output = $chunk_body;
330
+                    }
331
+                } elseif(substr($field_elements, 0, 5) == "@EVAL") {
332
+                    $eval_str = trim(substr($field_elements, 6));
333
+                    $custom_output = eval($eval_str);
334
+                } else {
335
+                    $custom_output = $field_elements;
336
+                }
337
+                $replacements = array(
338
+                    '[+field_type+]' => $field_type,
339
+                    '[+field_id+]' => $field_id,
340
+                    '[+default_text+]' => $default_text,
341
+                    '[+field_value+]' => $modx->htmlspecialchars($field_value),
342
+                    '[+field_style+]' => $field_style,
343
+                );
344
+                $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output);
345
+                $modx->documentObject = $content;
346
+                $modx->documentIdentifier = $content['id'];
347
+                $custom_output = $modx->parseDocumentSource($custom_output);
348
+                $field_html .= $custom_output;
349
+                break;
350 350
 
351
-			default: // the default handler -- for errors, mostly
352
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />';
351
+            default: // the default handler -- for errors, mostly
352
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />';
353 353
 
354
-		} // end switch statement
355
-	} else {
356
-		$custom = explode(":", $field_type);
357
-		$custom_output = '';
358
-		$file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php';
359
-		if(!file_exists($file_name)) {
360
-			$custom_output = $file_name . ' does not exist';
361
-		} else {
362
-			ob_start();
363
-			include $file_name;
364
-			$custom_output = ob_get_contents();
365
-			ob_end_clean();
366
-		}
367
-		$replacements = array(
368
-			'[+field_type+]' => $field_type,
369
-			'[+field_id+]' => $field_id,
370
-			'[+default_text+]' => $default_text,
371
-			'[+field_value+]' => $modx->htmlspecialchars($field_value),
372
-			'[+field_style+]' => $field_style,
373
-		);
374
-		$custom_output = str_replace(array_keys($replacements), $replacements, $custom_output);
375
-		$modx->documentObject = $content;
376
-		$custom_output = $modx->parseDocumentSource($custom_output);
377
-		$field_html .= $custom_output;
378
-	}
354
+        } // end switch statement
355
+    } else {
356
+        $custom = explode(":", $field_type);
357
+        $custom_output = '';
358
+        $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php';
359
+        if(!file_exists($file_name)) {
360
+            $custom_output = $file_name . ' does not exist';
361
+        } else {
362
+            ob_start();
363
+            include $file_name;
364
+            $custom_output = ob_get_contents();
365
+            ob_end_clean();
366
+        }
367
+        $replacements = array(
368
+            '[+field_type+]' => $field_type,
369
+            '[+field_id+]' => $field_id,
370
+            '[+default_text+]' => $default_text,
371
+            '[+field_value+]' => $modx->htmlspecialchars($field_value),
372
+            '[+field_style+]' => $field_style,
373
+        );
374
+        $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output);
375
+        $modx->documentObject = $content;
376
+        $custom_output = $modx->parseDocumentSource($custom_output);
377
+        $field_html .= $custom_output;
378
+    }
379 379
 
380
-	return $field_html;
380
+    return $field_html;
381 381
 } // end renderFormElement function
382 382
 
383 383
 /**
@@ -386,13 +386,13 @@  discard block
 block discarded – undo
386 386
  */
387 387
 function ParseIntputOptions($v) {
388 388
     $modx = evolutionCMS();
389
-	$a = array();
390
-	if(is_array($v)) {
391
-		return $v;
392
-	} else if($modx->db->isResult($v)) {
393
-		while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols;
394
-	} else {
395
-		$a = explode("||", $v);
396
-	}
397
-	return $a;
389
+    $a = array();
390
+    if(is_array($v)) {
391
+        return $v;
392
+    } else if($modx->db->isResult($v)) {
393
+        while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols;
394
+    } else {
395
+        $a = explode("||", $v);
396
+    }
397
+    return $a;
398 398
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
  * @param array $tvsArray
13 13
  * @return string
14 14
  */
15
-function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) {
15
+function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()){
16 16
     $modx = evolutionCMS();
17 17
 	global $_style;
18 18
 	global $_lang;
19 19
 	global $content;
20 20
 	global $which_browser;
21 21
 
22
-	if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) {
22
+	if (substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) {
23 23
 		$eval_str = trim(substr($default_text, 7));
24 24
 		$default_text = eval($eval_str);
25 25
 		$field_value = $default_text;
@@ -27,74 +27,74 @@  discard block
 block discarded – undo
27 27
 
28 28
 	$field_html = '';
29 29
 	$cimode = strpos($field_type, ':');
30
-	if($cimode === false) {
31
-		switch($field_type) {
30
+	if ($cimode === false) {
31
+		switch ($field_type) {
32 32
 
33 33
 			case "text": // handler for regular text boxes
34 34
 			case "rawtext"; // non-htmlentity converted text boxes
35
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />';
35
+				$field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" />';
36 36
 				break;
37 37
 			case "email": // handles email input fields
38
-				$field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>';
38
+				$field_html .= '<input type="email" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%"/>';
39 39
 				break;
40 40
 			case "number": // handles the input of numbers
41
-				$field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>';
41
+				$field_html .= '<input type="number" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>';
42 42
 				break;
43 43
 			case "textareamini": // handler for textarea mini boxes
44
-				$field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
44
+				$field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>';
45 45
 				break;
46 46
 			case "textarea": // handler for textarea boxes
47 47
 			case "rawtextarea": // non-htmlentity convertex textarea boxes
48 48
 			case "htmlarea": // handler for textarea boxes (deprecated)
49 49
 			case "richtext": // handler for textarea boxes
50
-				$field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
50
+				$field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>';
51 51
 				break;
52 52
 			case "date":
53 53
 				$field_id = str_replace(array(
54 54
 					'-',
55 55
 					'.'
56 56
 				), '_', urldecode($field_id));
57
-				if($field_value == '') {
57
+				if ($field_value == '') {
58 58
 					$field_value = 0;
59 59
 				}
60
-				$field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />';
61
-				$field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>';
60
+				$field_html .= '<input id="tv'.$field_id.'" name="tv'.$field_id.'" class="DatePicker" type="text" value="'.($field_value == 0 || !isset($field_value) ? "" : $field_value).'" onblur="documentDirty=true;" />';
61
+				$field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].value=\'\';document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="'.$_style["actions_calendar_delete"].'"></i></a>';
62 62
 
63 63
 				break;
64 64
 			case "dropdown": // handler for select boxes
65
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">';
65
+				$field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" size="1" onchange="documentDirty=true;">';
66 66
 				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
67
-				while(list($item, $itemvalue) = each($index_list)) {
67
+				while (list($item, $itemvalue) = each($index_list)) {
68 68
 					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
69
-					if(strlen($itemvalue) == 0) {
69
+					if (strlen($itemvalue) == 0) {
70 70
 						$itemvalue = $item;
71 71
 					}
72
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
72
+					$field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>';
73 73
 				}
74 74
 				$field_html .= "</select>";
75 75
 				break;
76 76
 			case "listbox": // handler for select boxes
77
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">';
77
+				$field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" onchange="documentDirty=true;" size="8">';
78 78
 				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
79
-				while(list($item, $itemvalue) = each($index_list)) {
79
+				while (list($item, $itemvalue) = each($index_list)) {
80 80
 					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
81
-					if(strlen($itemvalue) == 0) {
81
+					if (strlen($itemvalue) == 0) {
82 82
 						$itemvalue = $item;
83 83
 					}
84
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
84
+					$field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>';
85 85
 				}
86 86
 				$field_html .= "</select>";
87 87
 				break;
88 88
 			case "listbox-multiple": // handler for select boxes where you can choose multiple items
89 89
 				$field_value = explode("||", $field_value);
90
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">';
90
+				$field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'[]" multiple="multiple" onchange="documentDirty=true;" size="8">';
91 91
 				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
92
-				while(list($item, $itemvalue) = each($index_list)) {
92
+				while (list($item, $itemvalue) = each($index_list)) {
93 93
 					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
94
-					if(strlen($itemvalue) == 0) {
94
+					if (strlen($itemvalue) == 0) {
95 95
 						$itemvalue = $item;
96 96
 					}
97
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
97
+					$field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.(in_array($itemvalue, $field_value) ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>';
98 98
 				}
99 99
 				$field_html .= "</select>";
100 100
 				break;
@@ -106,17 +106,17 @@  discard block
 block discarded – undo
106 106
 					'ftp://' => 'ftp://',
107 107
 					'mailto:' => 'mailto:'
108 108
 				);
109
-				$field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">';
110
-				foreach($urls as $k => $v) {
111
-					if(strpos($field_value, $v) === false) {
112
-						$field_html .= '<option value="' . $v . '">' . $k . '</option>';
109
+				$field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv'.$field_id.'_prefix" name="tv'.$field_id.'_prefix" onchange="documentDirty=true;">';
110
+				foreach ($urls as $k => $v) {
111
+					if (strpos($field_value, $v) === false) {
112
+						$field_html .= '<option value="'.$v.'">'.$k.'</option>';
113 113
 					} else {
114 114
 						$field_value = str_replace($v, '', $field_value);
115
-						$field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>';
115
+						$field_html .= '<option value="'.$v.'" selected="selected">'.$k.'</option>';
116 116
 					}
117 117
 				}
118 118
 				$field_html .= '</select></td><td>';
119
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>';
119
+				$field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" width="100" '.$field_style.' onchange="documentDirty=true;" /></td></tr></table>';
120 120
 				break;
121 121
 			case 'checkbox': // handles check boxes
122 122
 				$values = !is_array($field_value) ? explode('||', $field_value) : $field_value;
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 				$tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />';
125 125
 				static $i = 0;
126 126
 				$_ = array();
127
-				foreach($index_list as $c => $item) {
128
-					if(is_array($item)) {
127
+				foreach ($index_list as $c => $item) {
128
+					if (is_array($item)) {
129 129
 						$name = trim($item[0]);
130 130
 						$value = isset($item[1]) ? $item[1] : $name;
131 131
 					} else {
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
 			case "option": // handles radio buttons
152 152
 				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
153 153
 				static $i = 0;
154
-				while(list($item, $itemvalue) = each($index_list)) {
154
+				while (list($item, $itemvalue) = each($index_list)) {
155 155
 					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
156
-					if(strlen($itemvalue) == 0) {
156
+					if (strlen($itemvalue) == 0) {
157 157
 						$itemvalue = $item;
158 158
 					}
159
-					$field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />';
159
+					$field_html .= '<input type="radio" value="'.$modx->htmlspecialchars($itemvalue).'" id="tv_'.$i.'" name="tv'.$field_id.'" '.($itemvalue == $field_value ? 'checked="checked"' : '').' onchange="documentDirty=true;" /><label for="tv_'.$i.'" class="radio">'.$item.'</label><br />';
160 160
 					$i++;
161 161
 				}
162 162
 				break;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 				global $_lang;
165 165
 				global $ResourceManagerLoaded;
166 166
 				global $content, $use_editor, $which_editor;
167
-				if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
167
+				if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
168 168
 					$field_html .= "
169 169
 						<script type=\"text/javascript\">
170 170
 							/* <![CDATA[ */
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
 									lastImageCtrl = ctrl;
187 187
 									var w = screen.width * 0.5;
188 188
 									var h = screen.height * 0.5;
189
-									OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h);
189
+									OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h);
190 190
 								}
191 191
 								function BrowseFileServer(ctrl) {
192 192
 									lastFileCtrl = ctrl;
193 193
 									var w = screen.width * 0.5;
194 194
 									var h = screen.height * 0.5;
195
-									OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h);
195
+									OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h);
196 196
 								}
197 197
 								function SetUrlChange(el) {
198 198
 									if ('createEvent' in document) {
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 						</script>";
227 227
 					$ResourceManagerLoaded = true;
228 228
 				}
229
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />';
229
+				$field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'"  value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseServer(\'tv'.$field_id.'\')" />';
230 230
 				break;
231 231
 			case "file": // handles the input of file uploads
232 232
 				/* Modified by Timon for use with resource browser */
233 233
 				global $_lang;
234 234
 				global $ResourceManagerLoaded;
235 235
 				global $content, $use_editor, $which_editor;
236
-				if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
236
+				if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
237 237
 					/* I didn't understand the meaning of the condition above, so I left it untouched ;-) */
238 238
 					$field_html .= "
239 239
 						<script type=\"text/javascript\">
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
 									lastImageCtrl = ctrl;
257 257
 									var w = screen.width * 0.5;
258 258
 									var h = screen.height * 0.5;
259
-									OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h);
259
+									OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h);
260 260
 								}
261 261
 								function BrowseFileServer(ctrl) {
262 262
 									lastFileCtrl = ctrl;
263 263
 									var w = screen.width * 0.5;
264 264
 									var h = screen.height * 0.5;
265
-									OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h);
265
+									OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h);
266 266
 								}
267 267
 								function SetUrlChange(el) {
268 268
 									if ('createEvent' in document) {
@@ -296,39 +296,39 @@  discard block
 block discarded – undo
296 296
 						</script>";
297 297
 					$ResourceManagerLoaded = true;
298 298
 				}
299
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />';
299
+				$field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'"  value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseFileServer(\'tv'.$field_id.'\')" />';
300 300
 
301 301
 				break;
302 302
 
303 303
 			case 'custom_tv':
304 304
 				$custom_output = '';
305 305
 				/* If we are loading a file */
306
-				if(substr($field_elements, 0, 5) == "@FILE") {
307
-					$file_name = MODX_BASE_PATH . trim(substr($field_elements, 6));
308
-					if(!file_exists($file_name)) {
309
-						$custom_output = $file_name . ' does not exist';
306
+				if (substr($field_elements, 0, 5) == "@FILE") {
307
+					$file_name = MODX_BASE_PATH.trim(substr($field_elements, 6));
308
+					if (!file_exists($file_name)) {
309
+						$custom_output = $file_name.' does not exist';
310 310
 					} else {
311 311
 						$custom_output = file_get_contents($file_name);
312 312
 					}
313
-				} elseif(substr($field_elements, 0, 8) == '@INCLUDE') {
314
-					$file_name = MODX_BASE_PATH . trim(substr($field_elements, 9));
315
-					if(!file_exists($file_name)) {
316
-						$custom_output = $file_name . ' does not exist';
313
+				} elseif (substr($field_elements, 0, 8) == '@INCLUDE') {
314
+					$file_name = MODX_BASE_PATH.trim(substr($field_elements, 9));
315
+					if (!file_exists($file_name)) {
316
+						$custom_output = $file_name.' does not exist';
317 317
 					} else {
318 318
 						ob_start();
319 319
 						include $file_name;
320 320
 						$custom_output = ob_get_contents();
321 321
 						ob_end_clean();
322 322
 					}
323
-				} elseif(substr($field_elements, 0, 6) == "@CHUNK") {
323
+				} elseif (substr($field_elements, 0, 6) == "@CHUNK") {
324 324
 					$chunk_name = trim(substr($field_elements, 7));
325 325
 					$chunk_body = $modx->getChunk($chunk_name);
326
-					if($chunk_body == false) {
327
-						$custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')';
326
+					if ($chunk_body == false) {
327
+						$custom_output = $_lang['chunk_no_exist'].'('.$_lang['htmlsnippet_name'].':'.$chunk_name.')';
328 328
 					} else {
329 329
 						$custom_output = $chunk_body;
330 330
 					}
331
-				} elseif(substr($field_elements, 0, 5) == "@EVAL") {
331
+				} elseif (substr($field_elements, 0, 5) == "@EVAL") {
332 332
 					$eval_str = trim(substr($field_elements, 6));
333 333
 					$custom_output = eval($eval_str);
334 334
 				} else {
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
 				break;
350 350
 
351 351
 			default: // the default handler -- for errors, mostly
352
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />';
352
+				$field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' onchange="documentDirty=true;" />';
353 353
 
354 354
 		} // end switch statement
355 355
 	} else {
356 356
 		$custom = explode(":", $field_type);
357 357
 		$custom_output = '';
358
-		$file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php';
359
-		if(!file_exists($file_name)) {
360
-			$custom_output = $file_name . ' does not exist';
358
+		$file_name = MODX_BASE_PATH.'assets/tvs/'.$custom['1'].'/'.$custom['1'].'.customtv.php';
359
+		if (!file_exists($file_name)) {
360
+			$custom_output = $file_name.' does not exist';
361 361
 		} else {
362 362
 			ob_start();
363 363
 			include $file_name;
@@ -384,13 +384,13 @@  discard block
 block discarded – undo
384 384
  * @param string|array|mysqli_result $v
385 385
  * @return array
386 386
  */
387
-function ParseIntputOptions($v) {
387
+function ParseIntputOptions($v){
388 388
     $modx = evolutionCMS();
389 389
 	$a = array();
390
-	if(is_array($v)) {
390
+	if (is_array($v)) {
391 391
 		return $v;
392
-	} else if($modx->db->isResult($v)) {
393
-		while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols;
392
+	} else if ($modx->db->isResult($v)) {
393
+		while ($cols = $modx->db->getRow($v, 'num')) $a[] = $cols;
394 394
 	} else {
395 395
 		$a = explode("||", $v);
396 396
 	}
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
  * @param array $tvsArray
13 13
  * @return string
14 14
  */
15
-function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) {
15
+function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array())
16
+{
16 17
     $modx = evolutionCMS();
17 18
 	global $_style;
18 19
 	global $_lang;
@@ -384,13 +385,16 @@  discard block
 block discarded – undo
384 385
  * @param string|array|mysqli_result $v
385 386
  * @return array
386 387
  */
387
-function ParseIntputOptions($v) {
388
+function ParseIntputOptions($v)
389
+{
388 390
     $modx = evolutionCMS();
389 391
 	$a = array();
390 392
 	if(is_array($v)) {
391 393
 		return $v;
392 394
 	} else if($modx->db->isResult($v)) {
393
-		while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols;
395
+		while($cols = $modx->db->getRow($v, 'num')) {
396
+		    $a[] = $cols;
397
+		}
394 398
 	} else {
395 399
 		$a = explode("||", $v);
396 400
 	}
Please login to merge, or discard this patch.
manager/includes/veriword.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $modx->getSettings();
6 6
 $modx->invokeEvent('OnWebPageInit');
7 7
 
8
-$vword = new VeriWord(148,60);
8
+$vword = new VeriWord(148, 60);
9 9
 $vword->output_image();
10 10
 $vword->destroy_image();
11 11
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 ## see sample.php for test and usage
42 42
 ## sample URL: http://www.program-ruti.org/veriword/
43 43
 ####
44
-class VeriWord {
44
+class VeriWord{
45 45
 
46 46
     /* path to font directory*/
47 47
     public $dir_font   = "ttf/";
@@ -52,44 +52,44 @@  discard block
 block discarded – undo
52 52
     public $im_height  = 0;
53 53
     public $im;
54 54
 
55
-    public function __construct($w=200, $h=80) {
55
+    public function __construct($w = 200, $h = 80){
56 56
         /* create session to set word for verification */
57 57
         $this->set_veriword();
58
-        $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font;
58
+        $this->dir_font = dirname(__FILE__).'/'.$this->dir_font;
59 59
         $this->im_width         = $w;
60 60
         $this->im_height        = $h;
61 61
     }
62 62
 
63
-    public function set_veriword() {
63
+    public function set_veriword(){
64 64
         /* create session variable for verification,
65 65
            you may change the session variable name */
66 66
         $this->word             = $this->pick_word();
67 67
         $_SESSION['veriword']   = $this->word;
68 68
     }
69 69
 
70
-    public function output_image() {
70
+    public function output_image(){
71 71
         /* output the image as jpeg */
72 72
         $this->draw_image();
73 73
         header("Content-type: image/jpeg");
74 74
         imagejpeg($this->im);
75 75
     }
76 76
 
77
-    public function pick_word() {
77
+    public function pick_word(){
78 78
         $modx = evolutionCMS();
79 79
         // set default words
80
-        $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
80
+        $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
81 81
         $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words;
82 82
         $arr_words = array_filter(array_map('trim', explode(',', $words)));
83 83
 
84 84
         /* pick one randomly for text verification */
85
-        return (string) $arr_words[array_rand($arr_words)].rand(10,999);
85
+        return (string) $arr_words[array_rand($arr_words)].rand(10, 999);
86 86
     }
87 87
 
88
-    public function draw_text() {
88
+    public function draw_text(){
89 89
         $dir = dir($this->dir_font);
90 90
         $fontstmp = array();
91 91
         while (false !== ($file = $dir->read())) {
92
-            if(substr($file, -4) == '.ttf') {
92
+            if (substr($file, -4) == '.ttf') {
93 93
                 $fontstmp[] = $this->dir_font.$file;
94 94
             }
95 95
         }
@@ -97,35 +97,35 @@  discard block
 block discarded – undo
97 97
         $text_font = (string) $fontstmp[array_rand($fontstmp)];
98 98
 
99 99
         /* angle for text inclination */
100
-        $text_angle = rand(-9,9);
100
+        $text_angle = rand(-9, 9);
101 101
         /* initial text size */
102 102
         $text_size  = 30;
103 103
         /* calculate text width and height */
104
-        $box        = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);
105
-        $text_width = $box[2]-$box[0]; //text width
106
-        $text_height= $box[5]-$box[3]; //text height
104
+        $box        = imagettfbbox($text_size, $text_angle, $text_font, $this->word);
105
+        $text_width = $box[2] - $box[0]; //text width
106
+        $text_height = $box[5] - $box[3]; //text height
107 107
 
108 108
         /* adjust text size */
109
-        $text_size  = round((20 * $this->im_width)/$text_width);
109
+        $text_size  = round((20 * $this->im_width) / $text_width);
110 110
 
111 111
         /* recalculate text width and height */
112
-        $box        = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);
113
-        $text_width = $box[2]-$box[0]; //text width
114
-        $text_height= $box[5]-$box[3]; //text height
112
+        $box        = imagettfbbox($text_size, $text_angle, $text_font, $this->word);
113
+        $text_width = $box[2] - $box[0]; //text width
114
+        $text_height = $box[5] - $box[3]; //text height
115 115
 
116 116
         /* calculate center position of text */
117
-        $text_x         = ($this->im_width - $text_width)/2;
118
-        $text_y         = ($this->im_height - $text_height)/2;
117
+        $text_x         = ($this->im_width - $text_width) / 2;
118
+        $text_y         = ($this->im_height - $text_height) / 2;
119 119
 
120 120
         /* create canvas for text drawing */
121
-        $im_text        = imagecreate ($this->im_width, $this->im_height);
122
-        $bg_color       = imagecolorallocate ($im_text, 255, 255, 255);
121
+        $im_text        = imagecreate($this->im_width, $this->im_height);
122
+        $bg_color       = imagecolorallocate($im_text, 255, 255, 255);
123 123
 
124 124
         /* pick color for text */
125
-        $text_color     = imagecolorallocate ($im_text, 0, 51, 153);
125
+        $text_color     = imagecolorallocate($im_text, 0, 51, 153);
126 126
 
127 127
         /* draw text into canvas */
128
-        imagettftext    (   $im_text,
128
+        imagettftext($im_text,
129 129
             $text_size,
130 130
             $text_angle,
131 131
             $text_x,
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
     }
141 141
 
142 142
 
143
-    public function draw_image() {
143
+    public function draw_image(){
144 144
 
145 145
         /* pick one background image randomly from image directory */
146
-        $img_file       = $this->dir_noise."noise".rand(1,4).".jpg";
146
+        $img_file       = $this->dir_noise."noise".rand(1, 4).".jpg";
147 147
 
148 148
         /* create "noise" background image from your image stock*/
149
-        $noise_img      = @imagecreatefromjpeg ($img_file);
149
+        $noise_img      = @imagecreatefromjpeg($img_file);
150 150
         $noise_width    = imagesx($noise_img);
151 151
         $noise_height   = imagesy($noise_img);
152 152
 
153 153
         /* resize the background image to fit the size of image output */
154
-        $this->im       = imagecreatetruecolor($this->im_width,$this->im_height);
155
-        imagecopyresampled ($this->im,
154
+        $this->im       = imagecreatetruecolor($this->im_width, $this->im_height);
155
+        imagecopyresampled($this->im,
156 156
             $noise_img,
157 157
             0, 0, 0, 0,
158 158
             $this->im_width,
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
             $noise_height);
162 162
 
163 163
         /* put text image into background image */
164
-        imagecopymerge (    $this->im,
164
+        imagecopymerge($this->im,
165 165
             $this->draw_text(),
166 166
             0, 0, 0, 0,
167 167
             $this->im_width,
168 168
             $this->im_height,
169
-            70 );
169
+            70);
170 170
 
171 171
         return $this->im;
172 172
     }
173 173
 
174
-    public function destroy_image() {
174
+    public function destroy_image(){
175 175
 
176 176
         imagedestroy($this->im);
177 177
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@  discard block
 block discarded – undo
41 41
 ## see sample.php for test and usage
42 42
 ## sample URL: http://www.program-ruti.org/veriword/
43 43
 ####
44
-class VeriWord {
44
+class VeriWord
45
+{
45 46
 
46 47
     /* path to font directory*/
47 48
     public $dir_font   = "ttf/";
@@ -52,7 +53,8 @@  discard block
 block discarded – undo
52 53
     public $im_height  = 0;
53 54
     public $im;
54 55
 
55
-    public function __construct($w=200, $h=80) {
56
+    public function __construct($w=200, $h=80)
57
+    {
56 58
         /* create session to set word for verification */
57 59
         $this->set_veriword();
58 60
         $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font;
@@ -60,21 +62,24 @@  discard block
 block discarded – undo
60 62
         $this->im_height        = $h;
61 63
     }
62 64
 
63
-    public function set_veriword() {
65
+    public function set_veriword()
66
+    {
64 67
         /* create session variable for verification,
65 68
            you may change the session variable name */
66 69
         $this->word             = $this->pick_word();
67 70
         $_SESSION['veriword']   = $this->word;
68 71
     }
69 72
 
70
-    public function output_image() {
73
+    public function output_image()
74
+    {
71 75
         /* output the image as jpeg */
72 76
         $this->draw_image();
73 77
         header("Content-type: image/jpeg");
74 78
         imagejpeg($this->im);
75 79
     }
76 80
 
77
-    public function pick_word() {
81
+    public function pick_word()
82
+    {
78 83
         $modx = evolutionCMS();
79 84
         // set default words
80 85
         $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
@@ -85,7 +90,8 @@  discard block
 block discarded – undo
85 90
         return (string) $arr_words[array_rand($arr_words)].rand(10,999);
86 91
     }
87 92
 
88
-    public function draw_text() {
93
+    public function draw_text()
94
+    {
89 95
         $dir = dir($this->dir_font);
90 96
         $fontstmp = array();
91 97
         while (false !== ($file = $dir->read())) {
@@ -140,7 +146,8 @@  discard block
 block discarded – undo
140 146
     }
141 147
 
142 148
 
143
-    public function draw_image() {
149
+    public function draw_image()
150
+    {
144 151
 
145 152
         /* pick one background image randomly from image directory */
146 153
         $img_file       = $this->dir_noise."noise".rand(1,4).".jpg";
@@ -171,7 +178,8 @@  discard block
 block discarded – undo
171 178
         return $this->im;
172 179
     }
173 180
 
174
-    public function destroy_image() {
181
+    public function destroy_image()
182
+    {
175 183
 
176 184
         imagedestroy($this->im);
177 185
 
Please login to merge, or discard this patch.
manager/includes/extenders/maketable.class.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function setTableWidth($value)
132 132
     {
133
-        $this->tableWidth = (int)$value;
133
+        $this->tableWidth = (int) $value;
134 134
     }
135 135
 
136 136
     /**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     {
318 318
         $currentWidth = '';
319 319
         if (is_array($this->columnWidths)) {
320
-            $currentWidth = $this->columnWidths[$columnPosition] ? ' width="' . $this->columnWidths[$columnPosition] . '" ' : '';
320
+            $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : '';
321 321
         }
322 322
 
323 323
         return $currentWidth;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
             $currentClass = $this->rowAlternateClass;
347 347
         }
348 348
 
349
-        return ' class="' . $currentClass . '"';
349
+        return ' class="'.$currentClass.'"';
350 350
     }
351 351
 
352 352
     /**
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
     {
361 361
         $cellAction = '';
362 362
         if ($this->cellAction) {
363
-            $cellAction = ' onClick="javascript:window.location=\'' . $this->cellAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '\'" ';
363
+            $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" ';
364 364
         }
365 365
 
366 366
         return $cellAction;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     {
378 378
         $cell = $value;
379 379
         if ($this->linkAction) {
380
-            $cell = '<a href="' . $this->linkAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '">' . $cell . '</a>';
380
+            $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>';
381 381
         }
382 382
 
383 383
         return $cell;
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
             $end = '?';
407 407
         }
408 408
 
409
-        return $link . $end;
409
+        return $link.$end;
410 410
     }
411 411
 
412 412
     /**
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
         if (is_array($fieldsArray)) {
427 427
             $i = 0;
428 428
             foreach ($fieldsArray as $fieldName => $fieldValue) {
429
-                $table .= "\t<tr" . $this->determineRowClass($i) . ">\n";
429
+                $table .= "\t<tr".$this->determineRowClass($i).">\n";
430 430
                 $currentActionFieldValue = $fieldValue[$this->actionField];
431 431
                 if (is_array($this->selectedValues)) {
432 432
                     $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1;
@@ -437,15 +437,15 @@  discard block
 block discarded – undo
437 437
                 $colPosition = 0;
438 438
                 foreach ($fieldValue as $key => $value) {
439 439
                     if (!in_array($key, $this->excludeFields)) {
440
-                        $table .= "\t\t<td" . $this->getCellAction($currentActionFieldValue) . ">";
440
+                        $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">";
441 441
                         $table .= $this->createCellText($currentActionFieldValue, $value);
442 442
                         $table .= "</td>\n";
443 443
                         if ($i == 0) {
444 444
                             if (empty ($header) && $this->formElementType) {
445
-                                $header .= "\t\t<th style=\"width:32px\" " . ($this->thClass ? 'class="' . $this->thClass . '"' : '') . ">" . ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '') . "</th>\n";
445
+                                $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n";
446 446
                             }
447 447
                             $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key;
448
-                            $header .= "\t\t<th" . $this->getColumnWidth($colPosition) . ($this->thClass ? ' class="' . $this->thClass . '" ' : '') . ">" . $headerText . "</th>\n";
448
+                            $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n";
449 449
                         }
450 450
                         $colPosition++;
451 451
                     }
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
                 $i++;
454 454
                 $table .= "\t</tr>\n";
455 455
             }
456
-            $table = "\n" . '<table' . ($this->tableWidth > 0 ? ' width="' . $this->tableWidth . '"' : '') . ($this->tableClass ? ' class="' . $this->tableClass . '"' : '') . ($this->tableID ? ' id="' . $this->tableID . '"' : '') . ">\n" . ($header ? "\t<thead>\n\t<tr class=\"" . $this->rowHeaderClass . "\">\n" . $header . "\t</tr>\n\t</thead>\n" : '') . $table . "</table>\n";
456
+            $table = "\n".'<table'.($this->tableWidth > 0 ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n";
457 457
             if ($this->formElementType) {
458
-                $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table;
458
+                $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table;
459 459
             }
460 460
             if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists.
461 461
                 /* commented this part because of cookie
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
                 $table .= '</select>'.$_lang["pagination_table_perpage"].'</div>';
471 471
                 */
472
-                $table .= '<div id="pagination" class="paginate">' . $_lang["pagination_table_gotopage"] . '<ul>' . $this->pageNav . '</ul></div>';
472
+                $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>';
473 473
                 //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>';
474 474
 
475 475
             }
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 <script language="javascript">
479 479
 	toggled = 0;
480 480
 	function clickAll() {
481
-		myform = document.getElementById("' . $this->formName . '");
481
+		myform = document.getElementById("' . $this->formName.'");
482 482
 		for(i=0;i<myform.length;i++) {
483 483
 			if(myform.elements[i].type==\'checkbox\') {
484 484
 				myform.elements[i].checked=(toggled?false:true);
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
             }
491 491
             if ($this->formElementType) {
492 492
                 if ($this->extra) {
493
-                    $table .= "\n" . $this->extra . "\n";
493
+                    $table .= "\n".$this->extra."\n";
494 494
                 }
495
-                $table .= "\n" . '</form>' . "\n";
495
+                $table .= "\n".'</form>'."\n";
496 496
             }
497 497
 
498 498
             return $table;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM);
516 516
         $nav = '';
517 517
         if ($numPages > 1) {
518
-            $currentURL = empty($qs) ? '' : '?' . $qs;
518
+            $currentURL = empty($qs) ? '' : '?'.$qs;
519 519
             if ($currentPage > 6) {
520 520
                 $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]);
521 521
             }
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
                 $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]);
541 541
             }
542 542
         }
543
-        $this->pageNav = ' ' . $nav;
543
+        $this->pageNav = ' '.$nav;
544 544
     }
545 545
 
546 546
     /**
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
     public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = '')
557 557
     {
558 558
         $modx = evolutionCMS();
559
-        $orderBy = !empty($_GET['orderby']) ? '&orderby=' . $_GET['orderby'] : '';
560
-        $orderDir = !empty($_GET['orderdir']) ? '&orderdir=' . $_GET['orderdir'] : '';
559
+        $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : '';
560
+        $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : '';
561 561
         if (!empty($qs)) {
562 562
             $qs = "?$qs";
563 563
         }
564 564
         $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'],
565
-            $qs . "page=$pageNum$orderBy$orderDir") : $this->prepareLink($link) . "page=$pageNum";
566
-        $nav = '<li' . ($currentPage ? ' class="currentPage"' : '') . '><a' . ($currentPage ? ' class="currentPage"' : '') . ' href="' . $link . '">' . $displayText . '</a></li>' . "\n";
565
+            $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum";
566
+        $nav = '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n";
567 567
 
568 568
         return $nav;
569 569
     }
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         $field = '';
582 582
         if ($this->formElementType) {
583 583
             $checked = $isChecked ? "checked " : "";
584
-            $field = "\t\t" . '<td><input type="' . $this->formElementType . '" name="' . ($this->formElementName ? $this->formElementName : $value) . '"  value="' . $value . '" ' . $checked . '/></td>' . "\n";
584
+            $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'"  value="'.$value.'" '.$checked.'/></td>'."\n";
585 585
         }
586 586
 
587 587
         return $field;
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
     public function handlePaging()
596 596
     {
597 597
         $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0;
598
-        $limitClause = ' LIMIT ' . ($offset * MAX_DISPLAY_RECORDS_NUM) . ', ' . MAX_DISPLAY_RECORDS_NUM;
598
+        $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM;
599 599
 
600 600
         return $limitClause;
601 601
     }
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
     public function handleSorting($natural_order = false)
611 611
     {
612 612
         $orderByClause = '';
613
-        if ((bool)$natural_order === false) {
613
+        if ((bool) $natural_order === false) {
614 614
             $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id";
615 615
             $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC";
616
-            $orderByClause = !empty($orderby) ? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ' : "";
616
+            $orderByClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : "";
617 617
         }
618 618
 
619 619
         return $orderByClause;
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
             }
643 643
         }
644 644
 
645
-        return '<a href="[~' . $modx->documentIdentifier . '~]?' . $qs . 'orderby=' . $key . $orderDir . '">' . $text . '</a>';
645
+        return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>';
646 646
     }
647 647
 
648 648
 }
Please login to merge, or discard this patch.
manager/includes/extenders/manager.api.class.inc.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -144,33 +144,33 @@  discard block
 block discarded – undo
144 144
             $algorithm = 'UNCRYPT';
145 145
         }
146 146
 
147
-        $salt = md5($password . $seed);
147
+        $salt = md5($password.$seed);
148 148
 
149 149
         switch ($algorithm) {
150 150
             case 'BLOWFISH_Y':
151
-                $salt = '$2y$07$' . substr($salt, 0, 22);
151
+                $salt = '$2y$07$'.substr($salt, 0, 22);
152 152
                 break;
153 153
             case 'BLOWFISH_A':
154
-                $salt = '$2a$07$' . substr($salt, 0, 22);
154
+                $salt = '$2a$07$'.substr($salt, 0, 22);
155 155
                 break;
156 156
             case 'SHA512':
157
-                $salt = '$6$' . substr($salt, 0, 16);
157
+                $salt = '$6$'.substr($salt, 0, 16);
158 158
                 break;
159 159
             case 'SHA256':
160
-                $salt = '$5$' . substr($salt, 0, 16);
160
+                $salt = '$5$'.substr($salt, 0, 16);
161 161
                 break;
162 162
             case 'MD5':
163
-                $salt = '$1$' . substr($salt, 0, 8);
163
+                $salt = '$1$'.substr($salt, 0, 8);
164 164
                 break;
165 165
         }
166 166
 
167 167
         if ($algorithm !== 'UNCRYPT') {
168
-            $password = sha1($password) . crypt($password, $salt);
168
+            $password = sha1($password).crypt($password, $salt);
169 169
         } else {
170
-            $password = sha1($salt . $password);
170
+            $password = sha1($salt.$password);
171 171
         }
172 172
 
173
-        $result = strtolower($algorithm) . '>' . md5($salt . $password) . substr(md5($salt), 0, 8);
173
+        $result = strtolower($algorithm).'>'.md5($salt.$password).substr(md5($salt), 0, 8);
174 174
 
175 175
         return $result;
176 176
     }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $check_files = explode("\n", $check_files);
253 253
         foreach ($check_files as $file) {
254 254
             $file = trim($file);
255
-            $file = MODX_BASE_PATH . $file;
255
+            $file = MODX_BASE_PATH.$file;
256 256
             if (!is_file($file)) {
257 257
                 continue;
258 258
             }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         $checksum = unserialize($checksum);
276 276
         foreach ($check_files as $file) {
277 277
             $file = trim($file);
278
-            $filePath = MODX_BASE_PATH . $file;
278
+            $filePath = MODX_BASE_PATH.$file;
279 279
             if (!is_file($filePath)) {
280 280
                 continue;
281 281
             }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     {
295 295
         $modx = evolutionCMS();
296 296
         $tbl_system_settings = $modx->getFullTableName('system_settings');
297
-        $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')";
297
+        $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','".$modx->db->escape($checksum)."')";
298 298
         $modx->db->query($sql);
299 299
     }
300 300
 
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
             foreach ($settings as $key => $val) {
372 372
                 $f = array();
373 373
                 $f['user'] = $_SESSION['mgrInternalKey'];
374
-                $f['setting_name'] = '_LAST_' . $key;
374
+                $f['setting_name'] = '_LAST_'.$key;
375 375
                 $f['setting_value'] = $val;
376 376
                 $f = $modx->db->escape($f);
377
-                $f = "(`" . implode("`, `", array_keys($f)) . "`) VALUES('" . implode("', '", array_values($f)) . "')";
377
+                $f = "(`".implode("`, `", array_keys($f))."`) VALUES('".implode("', '", array_values($f))."')";
378 378
                 $f .= " ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)";
379 379
                 $modx->db->insert($f, $modx->getFullTableName('user_settings'));
380 380
             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -116,7 +116,8 @@  discard block
 block discarded – undo
116 116
      * @return string
117 117
      */
118 118
     public function getHashType($db_value = '')
119
-    { // md5 | v1 | phpass
119
+    {
120
+// md5 | v1 | phpass
120 121
         $c = substr($db_value, 0, 1);
121 122
         if ($c === '$') {
122 123
             return 'phpass';
@@ -135,7 +136,8 @@  discard block
 block discarded – undo
135 136
      * @return string
136 137
      */
137 138
     public function genV1Hash($password, $seed = '1')
138
-    { // $seed is user_id basically
139
+    {
140
+// $seed is user_id basically
139 141
         $modx = evolutionCMS();
140 142
 
141 143
         if (isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) {
Please login to merge, or discard this patch.
manager/includes/extenders/export.class.inc.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $this->count = 0;
58 58
         $this->setUrlMode();
59 59
         $this->generate_mode = 'crawl';
60
-        $this->targetDir = $modx->config['base_path'] . 'temp/export';
60
+        $this->targetDir = $modx->config['base_path'].'temp/export';
61 61
         if (!isset($this->total)) {
62 62
             $this->getTotal();
63 63
         }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
         $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
114 114
         if (count($ignore_ids) > 0) {
115
-            $ignore_ids = "AND NOT id IN ('" . implode("','", $ignore_ids) . "')";
115
+            $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
116 116
         } else {
117 117
             $ignore_ids = '';
118 118
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $noncache = ($noncache == 1) ? '' : 'AND cacheable=1';
123 123
         $where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
124 124
         $rs = $modx->db->select('count(id)', $tbl_site_content, $where);
125
-        $this->total = (int)$modx->db->getValue($rs);
125
+        $this->total = (int) $modx->db->getValue($rs);
126 126
 
127 127
         return $this->total;
128 128
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         } elseif (!is_readable($directory)) {
152 152
             return $rs;
153 153
         } else {
154
-            $files = glob($directory . '/*');
154
+            $files = glob($directory.'/*');
155 155
             if (!empty($files)) {
156 156
                 foreach ($files as $path) {
157 157
                     $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path);
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
             $_lang = $back_lang;
182 182
         } else {
183
-            $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
183
+            $src = $this->curl_get_contents(MODX_SITE_URL."index.php?id={$docid}");
184 184
         }
185 185
 
186 186
 
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
         $modx = evolutionCMS();
216 216
 
217 217
         if ($alias === '') {
218
-            $filename = $prefix . $docid . $suffix;
218
+            $filename = $prefix.$docid.$suffix;
219 219
         } else {
220 220
             if ($modx->config['suffix_mode'] === '1' && strpos($alias, '.') !== false) {
221 221
                 $suffix = '';
222 222
             }
223
-            $filename = $prefix . $alias . $suffix;
223
+            $filename = $prefix.$alias.$suffix;
224 224
         }
225 225
 
226 226
         return $filename;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         $tbl_site_content = $modx->getFullTableName('site_content');
239 239
 
240 240
         $ignore_ids = $this->ignore_ids;
241
-        $dirpath = $this->targetDir . '/';
241
+        $dirpath = $this->targetDir.'/';
242 242
 
243 243
         $prefix = $modx->config['friendly_url_prefix'];
244 244
         $suffix = $modx->config['friendly_url_suffix'];
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
         $ph['status'] = 'fail';
250 250
         $ph['msg1'] = $_lang['export_site_failed'];
251
-        $ph['msg2'] = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath;
251
+        $ph['msg2'] = $_lang["export_site_failed_no_write"].' - '.$dirpath;
252 252
         $msg_failed_no_write = $this->parsePlaceholder($tpl, $ph);
253 253
 
254 254
         $ph['msg2'] = $_lang["export_site_failed_no_retrieve"];
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
             if (!$row['wasNull']) { // needs writing a document
283 283
                 $docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix);
284
-                $filename = $dirpath . $docname;
284
+                $filename = $dirpath.$docname;
285 285
                 if (!is_file($filename)) {
286 286
                     if ($row['published'] === '1') {
287 287
                         $status = $this->makeFile($row['id'], $filename);
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             if ($row['isfolder'] === '1' && ($modx->config['suffix_mode'] !== '1' || strpos($row['alias'],
310 310
                         '.') === false)) { // needs making a folder
311 311
                 $end_dir = ($row['alias'] !== '') ? $row['alias'] : $row['id'];
312
-                $dir_path = $dirpath . $end_dir;
312
+                $dir_path = $dirpath.$end_dir;
313 313
                 if (strpos($dir_path, MODX_BASE_PATH) === false) {
314 314
                     return false;
315 315
                 }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
                 if ($modx->config['make_folders'] === '1' && $row['published'] === '1') {
327 327
                     if (!empty($filename) && is_file($filename)) {
328
-                        rename($filename, $dir_path . '/index.html');
328
+                        rename($filename, $dir_path.'/index.html');
329 329
                     }
330 330
                 }
331 331
                 $this->targetDir = $dir_path;
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
 
350 350
         $ch = curl_init();
351 351
         curl_setopt($ch, CURLOPT_URL, $url);
352
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);    // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT
353
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);    // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER
352
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT
353
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER
354 354
         curl_setopt($ch, CURLOPT_HEADER, false);
355 355
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
356 356
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
Please login to merge, or discard this patch.
manager/includes/controls/datagrid.class.php 3 patches
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 class DataGrid {
14 14
 
15
-	public $ds; // datasource
15
+    public $ds; // datasource
16 16
     public $id;
17 17
     public $pageSize;            // pager settings
18 18
     public $pageNumber;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public $colWraps;
37 37
     public $colColors;
38 38
     public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39
-	// data type: integer,float,currency,date
39
+    // data type: integer,float,currency,date
40 40
 
41 41
     public $header;
42 42
     public $footer;
@@ -73,239 +73,239 @@  discard block
 block discarded – undo
73 73
     public $cdelim;
74 74
 
75 75
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
76
-		global $__DataGridCnt;
76
+        global $__DataGridCnt;
77 77
 
78
-		// set id
79
-		$__DataGridCnt++;
80
-		$this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
78
+        // set id
79
+        $__DataGridCnt++;
80
+        $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
81 81
 
82
-		// set datasource
83
-		$this->ds = $ds;
82
+        // set datasource
83
+        $this->ds = $ds;
84 84
 
85
-		// set pager
86
-		$this->pageSize = $pageSize;
87
-		$this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number
88
-		$this->pagerLocation = 'top-right';
89
-	}
85
+        // set pager
86
+        $this->pageSize = $pageSize;
87
+        $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number
88
+        $this->pagerLocation = 'top-right';
89
+    }
90 90
 
91 91
     public function setDataSource($ds) {
92
-		$this->ds = $ds;
93
-	}
92
+        $this->ds = $ds;
93
+    }
94 94
 
95 95
     public function render() {
96 96
         $modx = evolutionCMS();
97
-		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98
-		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
99
-		$cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
100
-		$cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
101
-
102
-		$pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
103
-		$pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
104
-
105
-		$this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
106
-		$this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
107
-		$this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
108
-		$this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
109
-
110
-		$this->_alt = 0;
111
-		$this->_total = 0;
112
-
113
-		$this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
114
-
115
-		if(!$cssStyle && !$cssClass) {
116
-			$cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
117
-		}
118
-		if(!$columnHeaderStyle && !$columnHeaderClass) {
119
-			$columnHeaderStyle = "style='color:black;background-color:silver'";
120
-		}
121
-		if(!$this->_itemStyle && !$this->_itemClass) {
122
-			$this->_itemStyle = "style='color:black;'";
123
-		}
124
-		if(!$this->_altItemStyle && !$this->_altItemClass) {
125
-			$this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
126
-		}
127
-
128
-		if($this->_isDataset && !$this->columns) {
129
-			$cols = $modx->db->numFields($this->ds);
130
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
131
-		}
132
-
133
-		// start grid
134
-		$tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
135
-		$tblEnd = "</table>";
136
-
137
-		// build column header
138
-		$this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
139
-		$this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
140
-		$this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
141
-		$this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
142
-		$this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
143
-		$this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
144
-		$this->_colcount = count($this->_colnames);
145
-		if(!$this->_isDataset) {
146
-			$this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
147
-			$this->ds = array_chunk($this->ds, $this->_colcount);
148
-		}
149
-		$tblColHdr = "<thead><tr>";
150
-		for($c = 0; $c < $this->_colcount; $c++) {
151
-			$name = $this->_colnames[$c];
152
-			$width = $this->_colwidths[$c];
153
-			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
154
-		}
155
-		$tblColHdr .= "</tr></thead>\n";
156
-
157
-		// build rows
158
-		$rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
159
-		$this->_fieldnames = explode(",", $this->fields);
160
-		if($rowcount == 0) {
161
-			$tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
162
-		} else {
163
-			// render grid items
164
-			if($this->pageSize <= 0) {
165
-				for($r = 0; $r < $rowcount; $r++) {
166
-					$row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
167
-					$tblRows .= $this->RenderRowFnc($r + 1, $row);
168
-				}
169
-			} else {
170
-				if(!$this->pager) {
171
-					include_once dirname(__FILE__) . "/datasetpager.class.php";
172
-					$this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173
-					$this->pager->setRenderRowFnc($this); // pass this object
174
-					$this->pager->cssStyle = $pagerStyle;
175
-					$this->pager->cssClass = $pagerClass;
176
-				} else {
177
-					$this->pager->pageSize = $this->pageSize;
178
-					$this->pager->pageNumber = $this->pageNumber;
179
-				}
180
-
181
-				$this->pager->render();
182
-				$tblRows = $this->pager->getRenderedRows();
183
-				$tblPager = $this->pager->getRenderedPager();
184
-			}
185
-		}
186
-
187
-		// setup header,pager and footer
188
-		$o = $tblStart;
189
-		$ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190
-		$pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
-		if($this->header) {
192
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
193
-		}
194
-		if($tblPager && $ptop) {
195
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
196
-		}
197
-		$o .= $tblColHdr . $tblRows;
198
-		if($tblPager && $pbot) {
199
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
-		}
201
-		if($this->footer) {
202
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
203
-		}
204
-		$o .= $tblEnd;
205
-		return $o;
206
-	}
207
-
208
-	// format column values
97
+        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98
+        $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
99
+        $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
100
+        $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
101
+
102
+        $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
103
+        $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
104
+
105
+        $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
106
+        $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
107
+        $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
108
+        $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
109
+
110
+        $this->_alt = 0;
111
+        $this->_total = 0;
112
+
113
+        $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
114
+
115
+        if(!$cssStyle && !$cssClass) {
116
+            $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
117
+        }
118
+        if(!$columnHeaderStyle && !$columnHeaderClass) {
119
+            $columnHeaderStyle = "style='color:black;background-color:silver'";
120
+        }
121
+        if(!$this->_itemStyle && !$this->_itemClass) {
122
+            $this->_itemStyle = "style='color:black;'";
123
+        }
124
+        if(!$this->_altItemStyle && !$this->_altItemClass) {
125
+            $this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
126
+        }
127
+
128
+        if($this->_isDataset && !$this->columns) {
129
+            $cols = $modx->db->numFields($this->ds);
130
+            for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
131
+        }
132
+
133
+        // start grid
134
+        $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
135
+        $tblEnd = "</table>";
136
+
137
+        // build column header
138
+        $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
139
+        $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
140
+        $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
141
+        $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
142
+        $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
143
+        $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
144
+        $this->_colcount = count($this->_colnames);
145
+        if(!$this->_isDataset) {
146
+            $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
147
+            $this->ds = array_chunk($this->ds, $this->_colcount);
148
+        }
149
+        $tblColHdr = "<thead><tr>";
150
+        for($c = 0; $c < $this->_colcount; $c++) {
151
+            $name = $this->_colnames[$c];
152
+            $width = $this->_colwidths[$c];
153
+            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
154
+        }
155
+        $tblColHdr .= "</tr></thead>\n";
156
+
157
+        // build rows
158
+        $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
159
+        $this->_fieldnames = explode(",", $this->fields);
160
+        if($rowcount == 0) {
161
+            $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
162
+        } else {
163
+            // render grid items
164
+            if($this->pageSize <= 0) {
165
+                for($r = 0; $r < $rowcount; $r++) {
166
+                    $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
167
+                    $tblRows .= $this->RenderRowFnc($r + 1, $row);
168
+                }
169
+            } else {
170
+                if(!$this->pager) {
171
+                    include_once dirname(__FILE__) . "/datasetpager.class.php";
172
+                    $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173
+                    $this->pager->setRenderRowFnc($this); // pass this object
174
+                    $this->pager->cssStyle = $pagerStyle;
175
+                    $this->pager->cssClass = $pagerClass;
176
+                } else {
177
+                    $this->pager->pageSize = $this->pageSize;
178
+                    $this->pager->pageNumber = $this->pageNumber;
179
+                }
180
+
181
+                $this->pager->render();
182
+                $tblRows = $this->pager->getRenderedRows();
183
+                $tblPager = $this->pager->getRenderedPager();
184
+            }
185
+        }
186
+
187
+        // setup header,pager and footer
188
+        $o = $tblStart;
189
+        $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190
+        $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
+        if($this->header) {
192
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
193
+        }
194
+        if($tblPager && $ptop) {
195
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
196
+        }
197
+        $o .= $tblColHdr . $tblRows;
198
+        if($tblPager && $pbot) {
199
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
+        }
201
+        if($this->footer) {
202
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
203
+        }
204
+        $o .= $tblEnd;
205
+        return $o;
206
+    }
207
+
208
+    // format column values
209 209
 
210 210
     public function RenderRowFnc($n, $row) {
211
-		if($this->_alt == 0) {
212
-			$Style = $this->_itemStyle;
213
-			$Class = $this->_itemClass;
214
-			$this->_alt = 1;
215
-		} else {
216
-			$Style = $this->_altItemStyle;
217
-			$Class = $this->_altItemClass;
218
-			$this->_alt = 0;
219
-		}
220
-		$o = "<tr>";
221
-		for($c = 0; $c < $this->_colcount; $c++) {
222
-			$colStyle = $Style;
223
-			$fld = trim($this->_fieldnames[$c]);
224
-			$width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
225
-			$align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
226
-			$color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
227
-			$type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228
-			$nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229
-			$value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
-			if($color && $Style) {
231
-				$colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
232
-			}
233
-			$value = $this->formatColumnValue($row, $value, $type, $align);
234
-			$o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
235
-		}
236
-		$o .= "</tr>\n";
237
-		return $o;
238
-	}
211
+        if($this->_alt == 0) {
212
+            $Style = $this->_itemStyle;
213
+            $Class = $this->_itemClass;
214
+            $this->_alt = 1;
215
+        } else {
216
+            $Style = $this->_altItemStyle;
217
+            $Class = $this->_altItemClass;
218
+            $this->_alt = 0;
219
+        }
220
+        $o = "<tr>";
221
+        for($c = 0; $c < $this->_colcount; $c++) {
222
+            $colStyle = $Style;
223
+            $fld = trim($this->_fieldnames[$c]);
224
+            $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
225
+            $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
226
+            $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
227
+            $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228
+            $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229
+            $value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
+            if($color && $Style) {
231
+                $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
232
+            }
233
+            $value = $this->formatColumnValue($row, $value, $type, $align);
234
+            $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
235
+        }
236
+        $o .= "</tr>\n";
237
+        return $o;
238
+    }
239 239
 
240 240
     public function formatColumnValue($row, $value, $type, &$align) {
241
-		if(strpos($type, ":") !== false) {
242
-			list($type, $type_format) = explode(":", $type, 2);
243
-		}
244
-		switch(strtolower($type)) {
245
-			case "integer":
246
-				if($align == "") {
247
-					$align = "right";
248
-				}
249
-				$value = number_format($value);
250
-				break;
251
-
252
-			case "float":
253
-				if($align == "") {
254
-					$align = "right";
255
-				}
256
-				if(!$type_format) {
257
-					$type_format = 2;
258
-				}
259
-				$value = number_format($value, $type_format);
260
-				break;
261
-
262
-			case "currency":
263
-				if($align == "") {
264
-					$align = "right";
265
-				}
266
-				if(!$type_format) {
267
-					$type_format = 2;
268
-				}
269
-				$value = "$" . number_format($value, $type_format);
270
-				break;
271
-
272
-			case "date":
273
-				if($align == "") {
274
-					$align = "right";
275
-				}
276
-				if(!is_numeric($value)) {
277
-					$value = strtotime($value);
278
-				}
279
-				if(!$type_format) {
280
-					$type_format = "%A %d, %B %Y";
281
-				}
282
-				$value = strftime($type_format, $value);
283
-				break;
284
-
285
-			case "boolean":
286
-				if($align == '') {
287
-					$align = "center";
288
-				}
289
-				$value = number_format($value);
290
-				if($value) {
291
-					$value = '&bull;';
292
-				} else {
293
-					$value = '&nbsp;';
294
-				}
295
-				break;
296
-
297
-			case "template":
298
-				// replace [+value+] first
299
-				$value = str_replace("[+value+]", $value, $type_format);
300
-				// replace other [+fields+]
301
-				if(strpos($value, "[+") !== false) {
302
-					foreach($row as $k => $v) {
303
-						$value = str_replace("[+$k+]", $v, $value);
304
-					}
305
-				}
306
-				break;
307
-
308
-		}
309
-		return $value;
310
-	}
241
+        if(strpos($type, ":") !== false) {
242
+            list($type, $type_format) = explode(":", $type, 2);
243
+        }
244
+        switch(strtolower($type)) {
245
+            case "integer":
246
+                if($align == "") {
247
+                    $align = "right";
248
+                }
249
+                $value = number_format($value);
250
+                break;
251
+
252
+            case "float":
253
+                if($align == "") {
254
+                    $align = "right";
255
+                }
256
+                if(!$type_format) {
257
+                    $type_format = 2;
258
+                }
259
+                $value = number_format($value, $type_format);
260
+                break;
261
+
262
+            case "currency":
263
+                if($align == "") {
264
+                    $align = "right";
265
+                }
266
+                if(!$type_format) {
267
+                    $type_format = 2;
268
+                }
269
+                $value = "$" . number_format($value, $type_format);
270
+                break;
271
+
272
+            case "date":
273
+                if($align == "") {
274
+                    $align = "right";
275
+                }
276
+                if(!is_numeric($value)) {
277
+                    $value = strtotime($value);
278
+                }
279
+                if(!$type_format) {
280
+                    $type_format = "%A %d, %B %Y";
281
+                }
282
+                $value = strftime($type_format, $value);
283
+                break;
284
+
285
+            case "boolean":
286
+                if($align == '') {
287
+                    $align = "center";
288
+                }
289
+                $value = number_format($value);
290
+                if($value) {
291
+                    $value = '&bull;';
292
+                } else {
293
+                    $value = '&nbsp;';
294
+                }
295
+                break;
296
+
297
+            case "template":
298
+                // replace [+value+] first
299
+                $value = str_replace("[+value+]", $value, $type_format);
300
+                // replace other [+fields+]
301
+                if(strpos($value, "[+") !== false) {
302
+                    foreach($row as $k => $v) {
303
+                        $value = str_replace("[+$k+]", $v, $value);
304
+                    }
305
+                }
306
+                break;
307
+
308
+        }
309
+        return $value;
310
+    }
311 311
 }
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataGridCnt = 0;
12 12
 
13
-class DataGrid {
13
+class DataGrid{
14 14
 
15 15
 	public $ds; // datasource
16 16
     public $id;
17
-    public $pageSize;            // pager settings
17
+    public $pageSize; // pager settings
18 18
     public $pageNumber;
19 19
     public $pager;
20
-    public $pagerLocation;        // top-right, top-left, bottom-left, bottom-right, both-left, both-right
20
+    public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right
21 21
 
22 22
     public $cssStyle;
23 23
     public $cssClass;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public $colAligns;
36 36
     public $colWraps;
37 37
     public $colColors;
38
-    public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
38
+    public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39 39
 	// data type: integer,float,currency,date
40 40
 
41 41
     public $header;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public $cellPadding;
44 44
     public $cellSpacing;
45 45
 
46
-    public $rowAlign;            // vertical alignment: top, middle, bottom
46
+    public $rowAlign; // vertical alignment: top, middle, bottom
47 47
     public $rowIdField;
48 48
 
49 49
     public $pagerStyle;
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public $cdelim;
74 74
 
75
-    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
75
+    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){
76 76
 		global $__DataGridCnt;
77 77
 
78 78
 		// set id
79 79
 		$__DataGridCnt++;
80
-		$this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
80
+		$this->id = $this->id ? empty($id) : "dg".$__DataGridCnt;
81 81
 
82 82
 		// set datasource
83 83
 		$this->ds = $ds;
@@ -88,50 +88,50 @@  discard block
 block discarded – undo
88 88
 		$this->pagerLocation = 'top-right';
89 89
 	}
90 90
 
91
-    public function setDataSource($ds) {
91
+    public function setDataSource($ds){
92 92
 		$this->ds = $ds;
93 93
 	}
94 94
 
95
-    public function render() {
95
+    public function render(){
96 96
         $modx = evolutionCMS();
97
-		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98
-		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
99
-		$cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
100
-		$cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
97
+		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : '';
98
+		$columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : "";
99
+		$cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : '';
100
+		$cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : '';
101 101
 
102
-		$pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
103
-		$pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
102
+		$pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : '';
103
+		$pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'";
104 104
 
105
-		$this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
106
-		$this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
107
-		$this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
108
-		$this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
105
+		$this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : '';
106
+		$this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : '';
107
+		$this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : '';
108
+		$this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : '';
109 109
 
110 110
 		$this->_alt = 0;
111 111
 		$this->_total = 0;
112 112
 
113 113
 		$this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
114 114
 
115
-		if(!$cssStyle && !$cssClass) {
115
+		if (!$cssStyle && !$cssClass) {
116 116
 			$cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
117 117
 		}
118
-		if(!$columnHeaderStyle && !$columnHeaderClass) {
118
+		if (!$columnHeaderStyle && !$columnHeaderClass) {
119 119
 			$columnHeaderStyle = "style='color:black;background-color:silver'";
120 120
 		}
121
-		if(!$this->_itemStyle && !$this->_itemClass) {
121
+		if (!$this->_itemStyle && !$this->_itemClass) {
122 122
 			$this->_itemStyle = "style='color:black;'";
123 123
 		}
124
-		if(!$this->_altItemStyle && !$this->_altItemClass) {
124
+		if (!$this->_altItemStyle && !$this->_altItemClass) {
125 125
 			$this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
126 126
 		}
127 127
 
128
-		if($this->_isDataset && !$this->columns) {
128
+		if ($this->_isDataset && !$this->columns) {
129 129
 			$cols = $modx->db->numFields($this->ds);
130
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
130
+			for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->db->fieldName($this->ds, $i);
131 131
 		}
132 132
 
133 133
 		// start grid
134
-		$tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
134
+		$tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>";
135 135
 		$tblEnd = "</table>";
136 136
 
137 137
 		// build column header
@@ -142,33 +142,33 @@  discard block
 block discarded – undo
142 142
 		$this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
143 143
 		$this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
144 144
 		$this->_colcount = count($this->_colnames);
145
-		if(!$this->_isDataset) {
145
+		if (!$this->_isDataset) {
146 146
 			$this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
147 147
 			$this->ds = array_chunk($this->ds, $this->_colcount);
148 148
 		}
149 149
 		$tblColHdr = "<thead><tr>";
150
-		for($c = 0; $c < $this->_colcount; $c++) {
150
+		for ($c = 0; $c < $this->_colcount; $c++) {
151 151
 			$name = $this->_colnames[$c];
152 152
 			$width = $this->_colwidths[$c];
153
-			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
153
+			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>";
154 154
 		}
155 155
 		$tblColHdr .= "</tr></thead>\n";
156 156
 
157 157
 		// build rows
158 158
 		$rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
159 159
 		$this->_fieldnames = explode(",", $this->fields);
160
-		if($rowcount == 0) {
161
-			$tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
160
+		if ($rowcount == 0) {
161
+			$tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n";
162 162
 		} else {
163 163
 			// render grid items
164
-			if($this->pageSize <= 0) {
165
-				for($r = 0; $r < $rowcount; $r++) {
164
+			if ($this->pageSize <= 0) {
165
+				for ($r = 0; $r < $rowcount; $r++) {
166 166
 					$row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
167 167
 					$tblRows .= $this->RenderRowFnc($r + 1, $row);
168 168
 				}
169 169
 			} else {
170
-				if(!$this->pager) {
171
-					include_once dirname(__FILE__) . "/datasetpager.class.php";
170
+				if (!$this->pager) {
171
+					include_once dirname(__FILE__)."/datasetpager.class.php";
172 172
 					$this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173 173
 					$this->pager->setRenderRowFnc($this); // pass this object
174 174
 					$this->pager->cssStyle = $pagerStyle;
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
 		$o = $tblStart;
189 189
 		$ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190 190
 		$pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
-		if($this->header) {
192
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
191
+		if ($this->header) {
192
+			$o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>";
193 193
 		}
194
-		if($tblPager && $ptop) {
195
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
194
+		if ($tblPager && $ptop) {
195
+			$o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
196 196
 		}
197
-		$o .= $tblColHdr . $tblRows;
198
-		if($tblPager && $pbot) {
199
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
197
+		$o .= $tblColHdr.$tblRows;
198
+		if ($tblPager && $pbot) {
199
+			$o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
200 200
 		}
201
-		if($this->footer) {
202
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
201
+		if ($this->footer) {
202
+			$o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>";
203 203
 		}
204 204
 		$o .= $tblEnd;
205 205
 		return $o;
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 
208 208
 	// format column values
209 209
 
210
-    public function RenderRowFnc($n, $row) {
211
-		if($this->_alt == 0) {
210
+    public function RenderRowFnc($n, $row){
211
+		if ($this->_alt == 0) {
212 212
 			$Style = $this->_itemStyle;
213 213
 			$Class = $this->_itemClass;
214 214
 			$this->_alt = 1;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 			$this->_alt = 0;
219 219
 		}
220 220
 		$o = "<tr>";
221
-		for($c = 0; $c < $this->_colcount; $c++) {
221
+		for ($c = 0; $c < $this->_colcount; $c++) {
222 222
 			$colStyle = $Style;
223 223
 			$fld = trim($this->_fieldnames[$c]);
224 224
 			$width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
@@ -227,67 +227,67 @@  discard block
 block discarded – undo
227 227
 			$type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228 228
 			$nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229 229
 			$value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
-			if($color && $Style) {
231
-				$colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
230
+			if ($color && $Style) {
231
+				$colStyle = substr($colStyle, 0, -1).";background-color:$color;'";
232 232
 			}
233 233
 			$value = $this->formatColumnValue($row, $value, $type, $align);
234
-			$o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
234
+			$o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>";
235 235
 		}
236 236
 		$o .= "</tr>\n";
237 237
 		return $o;
238 238
 	}
239 239
 
240
-    public function formatColumnValue($row, $value, $type, &$align) {
241
-		if(strpos($type, ":") !== false) {
240
+    public function formatColumnValue($row, $value, $type, &$align){
241
+		if (strpos($type, ":") !== false) {
242 242
 			list($type, $type_format) = explode(":", $type, 2);
243 243
 		}
244
-		switch(strtolower($type)) {
244
+		switch (strtolower($type)) {
245 245
 			case "integer":
246
-				if($align == "") {
246
+				if ($align == "") {
247 247
 					$align = "right";
248 248
 				}
249 249
 				$value = number_format($value);
250 250
 				break;
251 251
 
252 252
 			case "float":
253
-				if($align == "") {
253
+				if ($align == "") {
254 254
 					$align = "right";
255 255
 				}
256
-				if(!$type_format) {
256
+				if (!$type_format) {
257 257
 					$type_format = 2;
258 258
 				}
259 259
 				$value = number_format($value, $type_format);
260 260
 				break;
261 261
 
262 262
 			case "currency":
263
-				if($align == "") {
263
+				if ($align == "") {
264 264
 					$align = "right";
265 265
 				}
266
-				if(!$type_format) {
266
+				if (!$type_format) {
267 267
 					$type_format = 2;
268 268
 				}
269
-				$value = "$" . number_format($value, $type_format);
269
+				$value = "$".number_format($value, $type_format);
270 270
 				break;
271 271
 
272 272
 			case "date":
273
-				if($align == "") {
273
+				if ($align == "") {
274 274
 					$align = "right";
275 275
 				}
276
-				if(!is_numeric($value)) {
276
+				if (!is_numeric($value)) {
277 277
 					$value = strtotime($value);
278 278
 				}
279
-				if(!$type_format) {
279
+				if (!$type_format) {
280 280
 					$type_format = "%A %d, %B %Y";
281 281
 				}
282 282
 				$value = strftime($type_format, $value);
283 283
 				break;
284 284
 
285 285
 			case "boolean":
286
-				if($align == '') {
286
+				if ($align == '') {
287 287
 					$align = "center";
288 288
 				}
289 289
 				$value = number_format($value);
290
-				if($value) {
290
+				if ($value) {
291 291
 					$value = '&bull;';
292 292
 				} else {
293 293
 					$value = '&nbsp;';
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 				// replace [+value+] first
299 299
 				$value = str_replace("[+value+]", $value, $type_format);
300 300
 				// replace other [+fields+]
301
-				if(strpos($value, "[+") !== false) {
302
-					foreach($row as $k => $v) {
301
+				if (strpos($value, "[+") !== false) {
302
+					foreach ($row as $k => $v) {
303 303
 						$value = str_replace("[+$k+]", $v, $value);
304 304
 					}
305 305
 				}
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
         $modx = evolutionCMS();
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.