Completed
Pull Request — develop (#545)
by Agel_Nash
05:36
created
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 = DocumentParser::getInstance();
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 = DocumentParser::getInstance();
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 = DocumentParser::getInstance();
97 101
 		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98 102
 		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
 
128 132
 		if($this->_isDataset && !$this->columns) {
129 133
 			$cols = $modx->db->numFields($this->ds);
130
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
134
+			for($i = 0; $i < $cols; $i++) {
135
+			    $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
136
+			}
131 137
 		}
132 138
 
133 139
 		// start grid
@@ -207,7 +213,8 @@  discard block
 block discarded – undo
207 213
 
208 214
 	// format column values
209 215
 
210
-    public function RenderRowFnc($n, $row) {
216
+    public function RenderRowFnc($n, $row)
217
+    {
211 218
 		if($this->_alt == 0) {
212 219
 			$Style = $this->_itemStyle;
213 220
 			$Class = $this->_itemClass;
@@ -237,7 +244,8 @@  discard block
 block discarded – undo
237 244
 		return $o;
238 245
 	}
239 246
 
240
-    public function formatColumnValue($row, $value, $type, &$align) {
247
+    public function formatColumnValue($row, $value, $type, &$align)
248
+    {
241 249
 		if(strpos($type, ":") !== false) {
242 250
 			list($type, $type_format) = explode(":", $type, 2);
243 251
 		}
Please login to merge, or discard this patch.
manager/includes/controls/datasetpager.class.php 3 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -12,18 +12,18 @@  discard block
 block discarded – undo
12 12
 
13 13
 class DataSetPager {
14 14
 
15
-	public $ds; // datasource
15
+    public $ds; // datasource
16 16
     public $pageSize;
17 17
     public $pageNumber;
18 18
     public $rows;
19 19
     public $pager;
20 20
     public $id;
21 21
 
22
-	// normal page
22
+    // normal page
23 23
     public $pageStyle;
24 24
     public $pageClass;
25 25
 
26
-	// selected page
26
+    // selected page
27 27
     public $selPageStyle;
28 28
     public $selPageClass;
29 29
     public $renderRowFnc;
@@ -32,166 +32,166 @@  discard block
 block discarded – undo
32 32
     public $renderPagerFncArgs;
33 33
 
34 34
     public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35
-		global $_PAGE; // use view state object
36
-
37
-		global $__DataSetPagerCnt;
38
-
39
-		// set id
40
-		$__DataSetPagerCnt++;
41
-		$this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
42
-
43
-		// get pagenumber
44
-		// by setting pager to -1 cause pager to load it's last page number
45
-		if($pageNumber == -1) {
46
-			$pageNumber = 1;
47
-			if(isset($_GET["dpgn" . $this->id])) {
48
-				$pageNumber = $_GET["dpgn" . $this->id];
49
-			} elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
50
-				$pageNumber = $_PAGE['vs'][$id . '_dpgn'];
51
-			}
52
-		}
53
-		if(!is_numeric($pageNumber)) {
54
-			$pageNumber = 1;
55
-		}
56
-
57
-		$this->ds = $ds; // datasource
58
-		$this->pageSize = $pageSize;
59
-		$this->pageNumber = $pageNumber;
60
-		$this->rows = '';
61
-		$this->pager = '';
62
-	}
35
+        global $_PAGE; // use view state object
36
+
37
+        global $__DataSetPagerCnt;
38
+
39
+        // set id
40
+        $__DataSetPagerCnt++;
41
+        $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
42
+
43
+        // get pagenumber
44
+        // by setting pager to -1 cause pager to load it's last page number
45
+        if($pageNumber == -1) {
46
+            $pageNumber = 1;
47
+            if(isset($_GET["dpgn" . $this->id])) {
48
+                $pageNumber = $_GET["dpgn" . $this->id];
49
+            } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
50
+                $pageNumber = $_PAGE['vs'][$id . '_dpgn'];
51
+            }
52
+        }
53
+        if(!is_numeric($pageNumber)) {
54
+            $pageNumber = 1;
55
+        }
56
+
57
+        $this->ds = $ds; // datasource
58
+        $this->pageSize = $pageSize;
59
+        $this->pageNumber = $pageNumber;
60
+        $this->rows = '';
61
+        $this->pager = '';
62
+    }
63 63
 
64 64
     public function getRenderedPager() {
65
-		return $this->pager;
66
-	}
65
+        return $this->pager;
66
+    }
67 67
 
68 68
     public function getRenderedRows() {
69
-		return $this->rows;
70
-	}
69
+        return $this->rows;
70
+    }
71 71
 
72 72
     public function setDataSource($ds) {
73
-		$this->ds = $ds;
74
-	}
73
+        $this->ds = $ds;
74
+    }
75 75
 
76 76
     public function setPageSize($ps) {
77
-		$this->pageSize = $ps;
78
-	}
77
+        $this->pageSize = $ps;
78
+    }
79 79
 
80 80
     public function setRenderRowFnc($fncName, $args = "") {
81
-		$this->renderRowFnc = &$fncName;
82
-		$this->renderRowFncArgs = $args;    // extra agruments
81
+        $this->renderRowFnc = &$fncName;
82
+        $this->renderRowFncArgs = $args;    // extra agruments
83 83
 
84 84
 
85
-	}
85
+    }
86 86
 
87 87
     public function setRenderPagerFnc($fncName, $args = "") {
88
-		$this->renderPagerFnc = $fncName;
89
-		$this->renderPagerFncArgs = $args;    // extra agruments
90
-	}
88
+        $this->renderPagerFnc = $fncName;
89
+        $this->renderPagerFncArgs = $args;    // extra agruments
90
+    }
91 91
 
92 92
     public function render() {
93
-		$modx = DocumentParser::getInstance(); global $_PAGE;
94
-
95
-		$isDataset = $modx->db->isResult($this->ds);
96
-
97
-		if(!$this->selPageStyle) {
98
-			$this->selPageStyle = "font-weight:bold";
99
-		}
100
-
101
-		// get total number of rows
102
-		$tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
103
-
104
-		// render: no records found
105
-		if($tnr <= 0) {
106
-			$fnc = $this->renderRowFnc;
107
-			$args = $this->renderRowFncArgs;
108
-			if(isset($fnc)) {
109
-				if($args != "") {
110
-					$this->rows .= $fnc(0, null, $args);
111
-				} // if agrs was specified then we will pass three params
112
-				else {
113
-					$this->rows .= $fnc(0, null);
114
-				}                 // otherwise two will be passed
115
-			}
116
-			return;
117
-		}
118
-
119
-		// get total pages
120
-		$tp = ceil($tnr / $this->pageSize);
121
-		if($this->pageNumber > $tp) {
122
-			$this->pageNumber = 1;
123
-		}
124
-
125
-		// get page number
126
-		$p = $this->pageNumber;
127
-
128
-		// save page number to view state if available
129
-		if(isset($_PAGE['vs'])) {
130
-			$_PAGE['vs'][$this->id . '_dpgn'] = $p;
131
-		}
132
-
133
-		// render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
134
-		if($tp > 1) {
135
-		    $url = '';
136
-			$fnc = $this->renderPagerFnc;
137
-			$args = $this->renderPagerFncArgs;
138
-			if(!isset($fnc)) {
139
-				if($modx->isFrontend()) {
140
-					$url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
141
-				} else {
142
-					$url = $_SERVER['PHP_SELF'] . '?';
143
-				}
144
-				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
146
-					$i++;
147
-					$url .= (($i > 1) ? "&" : "") . "$n=$v";
148
-				}
149
-				if($i >= 1) {
150
-					$url .= "&";
151
-				}
152
-			}
153
-			for($i = 1; $i <= $tp; $i++) {
154
-				if(isset($fnc)) {
155
-					if($args != "") {
156
-						$this->pager .= $fnc($p, $i, $args);
157
-					} else {
158
-						$this->pager .= $fnc($p, $i);
159
-					}
160
-				} else {
161
-					$this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
162
-				}
163
-			}
164
-		}
165
-
166
-		// render row : renderRowFnc($rowNumber,$row,$arguments="")
167
-		$fnc = $this->renderRowFnc;
168
-		$args = $this->renderRowFncArgs;
169
-
170
-		if(isset($fnc)) {
171
-			$i = 1;
172
-			$fncObject = is_object($fnc);
173
-			$minitems = (($p - 1) * $this->pageSize) + 1;
174
-			$maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
175
-			while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
-				if($i >= $minitems && $i <= $maxitems) {
177
-					if($fncObject) {
178
-						if($args != "") {
179
-							$this->rows .= $fnc->RenderRowFnc($i, $row, $args);
180
-						} else {
181
-							$this->rows .= $fnc->RenderRowFnc($i, $row);
182
-						}
183
-					} else {
184
-						if($args != "") {
185
-							$this->rows .= $fnc($i, $row, $args);
186
-						} // if agrs was specified then we wil pass three params
187
-						else {
188
-							$this->rows .= $fnc($i, $row);
189
-						}                 // otherwise two will be passed
190
-					}
191
-
192
-				}
193
-				$i++;
194
-			}
195
-		}
196
-	}
93
+        $modx = DocumentParser::getInstance(); global $_PAGE;
94
+
95
+        $isDataset = $modx->db->isResult($this->ds);
96
+
97
+        if(!$this->selPageStyle) {
98
+            $this->selPageStyle = "font-weight:bold";
99
+        }
100
+
101
+        // get total number of rows
102
+        $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
103
+
104
+        // render: no records found
105
+        if($tnr <= 0) {
106
+            $fnc = $this->renderRowFnc;
107
+            $args = $this->renderRowFncArgs;
108
+            if(isset($fnc)) {
109
+                if($args != "") {
110
+                    $this->rows .= $fnc(0, null, $args);
111
+                } // if agrs was specified then we will pass three params
112
+                else {
113
+                    $this->rows .= $fnc(0, null);
114
+                }                 // otherwise two will be passed
115
+            }
116
+            return;
117
+        }
118
+
119
+        // get total pages
120
+        $tp = ceil($tnr / $this->pageSize);
121
+        if($this->pageNumber > $tp) {
122
+            $this->pageNumber = 1;
123
+        }
124
+
125
+        // get page number
126
+        $p = $this->pageNumber;
127
+
128
+        // save page number to view state if available
129
+        if(isset($_PAGE['vs'])) {
130
+            $_PAGE['vs'][$this->id . '_dpgn'] = $p;
131
+        }
132
+
133
+        // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
134
+        if($tp > 1) {
135
+            $url = '';
136
+            $fnc = $this->renderPagerFnc;
137
+            $args = $this->renderPagerFncArgs;
138
+            if(!isset($fnc)) {
139
+                if($modx->isFrontend()) {
140
+                    $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
141
+                } else {
142
+                    $url = $_SERVER['PHP_SELF'] . '?';
143
+                }
144
+                $i = 0;
145
+                foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
146
+                    $i++;
147
+                    $url .= (($i > 1) ? "&" : "") . "$n=$v";
148
+                }
149
+                if($i >= 1) {
150
+                    $url .= "&";
151
+                }
152
+            }
153
+            for($i = 1; $i <= $tp; $i++) {
154
+                if(isset($fnc)) {
155
+                    if($args != "") {
156
+                        $this->pager .= $fnc($p, $i, $args);
157
+                    } else {
158
+                        $this->pager .= $fnc($p, $i);
159
+                    }
160
+                } else {
161
+                    $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
162
+                }
163
+            }
164
+        }
165
+
166
+        // render row : renderRowFnc($rowNumber,$row,$arguments="")
167
+        $fnc = $this->renderRowFnc;
168
+        $args = $this->renderRowFncArgs;
169
+
170
+        if(isset($fnc)) {
171
+            $i = 1;
172
+            $fncObject = is_object($fnc);
173
+            $minitems = (($p - 1) * $this->pageSize) + 1;
174
+            $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
175
+            while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
+                if($i >= $minitems && $i <= $maxitems) {
177
+                    if($fncObject) {
178
+                        if($args != "") {
179
+                            $this->rows .= $fnc->RenderRowFnc($i, $row, $args);
180
+                        } else {
181
+                            $this->rows .= $fnc->RenderRowFnc($i, $row);
182
+                        }
183
+                    } else {
184
+                        if($args != "") {
185
+                            $this->rows .= $fnc($i, $row, $args);
186
+                        } // if agrs was specified then we wil pass three params
187
+                        else {
188
+                            $this->rows .= $fnc($i, $row);
189
+                        }                 // otherwise two will be passed
190
+                    }
191
+
192
+                }
193
+                $i++;
194
+            }
195
+        }
196
+    }
197 197
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataSetPagerCnt = 0;
12 12
 
13
-class DataSetPager {
13
+class DataSetPager{
14 14
 
15 15
 	public $ds; // datasource
16 16
     public $pageSize;
@@ -31,26 +31,26 @@  discard block
 block discarded – undo
31 31
     public $renderPagerFnc;
32 32
     public $renderPagerFncArgs;
33 33
 
34
-    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
34
+    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){
35 35
 		global $_PAGE; // use view state object
36 36
 
37 37
 		global $__DataSetPagerCnt;
38 38
 
39 39
 		// set id
40 40
 		$__DataSetPagerCnt++;
41
-		$this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
41
+		$this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt;
42 42
 
43 43
 		// get pagenumber
44 44
 		// by setting pager to -1 cause pager to load it's last page number
45
-		if($pageNumber == -1) {
45
+		if ($pageNumber == -1) {
46 46
 			$pageNumber = 1;
47
-			if(isset($_GET["dpgn" . $this->id])) {
48
-				$pageNumber = $_GET["dpgn" . $this->id];
49
-			} elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
50
-				$pageNumber = $_PAGE['vs'][$id . '_dpgn'];
47
+			if (isset($_GET["dpgn".$this->id])) {
48
+				$pageNumber = $_GET["dpgn".$this->id];
49
+			} elseif (isset($_PAGE['vs'][$id.'_dpgn'])) {
50
+				$pageNumber = $_PAGE['vs'][$id.'_dpgn'];
51 51
 			}
52 52
 		}
53
-		if(!is_numeric($pageNumber)) {
53
+		if (!is_numeric($pageNumber)) {
54 54
 			$pageNumber = 1;
55 55
 		}
56 56
 
@@ -61,40 +61,40 @@  discard block
 block discarded – undo
61 61
 		$this->pager = '';
62 62
 	}
63 63
 
64
-    public function getRenderedPager() {
64
+    public function getRenderedPager(){
65 65
 		return $this->pager;
66 66
 	}
67 67
 
68
-    public function getRenderedRows() {
68
+    public function getRenderedRows(){
69 69
 		return $this->rows;
70 70
 	}
71 71
 
72
-    public function setDataSource($ds) {
72
+    public function setDataSource($ds){
73 73
 		$this->ds = $ds;
74 74
 	}
75 75
 
76
-    public function setPageSize($ps) {
76
+    public function setPageSize($ps){
77 77
 		$this->pageSize = $ps;
78 78
 	}
79 79
 
80
-    public function setRenderRowFnc($fncName, $args = "") {
80
+    public function setRenderRowFnc($fncName, $args = ""){
81 81
 		$this->renderRowFnc = &$fncName;
82
-		$this->renderRowFncArgs = $args;    // extra agruments
82
+		$this->renderRowFncArgs = $args; // extra agruments
83 83
 
84 84
 
85 85
 	}
86 86
 
87
-    public function setRenderPagerFnc($fncName, $args = "") {
87
+    public function setRenderPagerFnc($fncName, $args = ""){
88 88
 		$this->renderPagerFnc = $fncName;
89
-		$this->renderPagerFncArgs = $args;    // extra agruments
89
+		$this->renderPagerFncArgs = $args; // extra agruments
90 90
 	}
91 91
 
92
-    public function render() {
92
+    public function render(){
93 93
 		$modx = DocumentParser::getInstance(); global $_PAGE;
94 94
 
95 95
 		$isDataset = $modx->db->isResult($this->ds);
96 96
 
97
-		if(!$this->selPageStyle) {
97
+		if (!$this->selPageStyle) {
98 98
 			$this->selPageStyle = "font-weight:bold";
99 99
 		}
100 100
 
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 		$tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
103 103
 
104 104
 		// render: no records found
105
-		if($tnr <= 0) {
105
+		if ($tnr <= 0) {
106 106
 			$fnc = $this->renderRowFnc;
107 107
 			$args = $this->renderRowFncArgs;
108
-			if(isset($fnc)) {
109
-				if($args != "") {
108
+			if (isset($fnc)) {
109
+				if ($args != "") {
110 110
 					$this->rows .= $fnc(0, null, $args);
111 111
 				} // if agrs was specified then we will pass three params
112 112
 				else {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 		// get total pages
120 120
 		$tp = ceil($tnr / $this->pageSize);
121
-		if($this->pageNumber > $tp) {
121
+		if ($this->pageNumber > $tp) {
122 122
 			$this->pageNumber = 1;
123 123
 		}
124 124
 
@@ -126,39 +126,39 @@  discard block
 block discarded – undo
126 126
 		$p = $this->pageNumber;
127 127
 
128 128
 		// save page number to view state if available
129
-		if(isset($_PAGE['vs'])) {
130
-			$_PAGE['vs'][$this->id . '_dpgn'] = $p;
129
+		if (isset($_PAGE['vs'])) {
130
+			$_PAGE['vs'][$this->id.'_dpgn'] = $p;
131 131
 		}
132 132
 
133 133
 		// render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
134
-		if($tp > 1) {
134
+		if ($tp > 1) {
135 135
 		    $url = '';
136 136
 			$fnc = $this->renderPagerFnc;
137 137
 			$args = $this->renderPagerFncArgs;
138
-			if(!isset($fnc)) {
139
-				if($modx->isFrontend()) {
140
-					$url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
138
+			if (!isset($fnc)) {
139
+				if ($modx->isFrontend()) {
140
+					$url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?';
141 141
 				} else {
142
-					$url = $_SERVER['PHP_SELF'] . '?';
142
+					$url = $_SERVER['PHP_SELF'].'?';
143 143
 				}
144 144
 				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
145
+				foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) {
146 146
 					$i++;
147
-					$url .= (($i > 1) ? "&" : "") . "$n=$v";
147
+					$url .= (($i > 1) ? "&" : "")."$n=$v";
148 148
 				}
149
-				if($i >= 1) {
149
+				if ($i >= 1) {
150 150
 					$url .= "&";
151 151
 				}
152 152
 			}
153
-			for($i = 1; $i <= $tp; $i++) {
154
-				if(isset($fnc)) {
155
-					if($args != "") {
153
+			for ($i = 1; $i <= $tp; $i++) {
154
+				if (isset($fnc)) {
155
+					if ($args != "") {
156 156
 						$this->pager .= $fnc($p, $i, $args);
157 157
 					} else {
158 158
 						$this->pager .= $fnc($p, $i);
159 159
 					}
160 160
 				} else {
161
-					$this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
161
+					$this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> ";
162 162
 				}
163 163
 			}
164 164
 		}
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
 		$fnc = $this->renderRowFnc;
168 168
 		$args = $this->renderRowFncArgs;
169 169
 
170
-		if(isset($fnc)) {
170
+		if (isset($fnc)) {
171 171
 			$i = 1;
172 172
 			$fncObject = is_object($fnc);
173 173
 			$minitems = (($p - 1) * $this->pageSize) + 1;
174 174
 			$maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
175
-			while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
-				if($i >= $minitems && $i <= $maxitems) {
177
-					if($fncObject) {
178
-						if($args != "") {
175
+			while ($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
+				if ($i >= $minitems && $i <= $maxitems) {
177
+					if ($fncObject) {
178
+						if ($args != "") {
179 179
 							$this->rows .= $fnc->RenderRowFnc($i, $row, $args);
180 180
 						} else {
181 181
 							$this->rows .= $fnc->RenderRowFnc($i, $row);
182 182
 						}
183 183
 					} else {
184
-						if($args != "") {
184
+						if ($args != "") {
185 185
 							$this->rows .= $fnc($i, $row, $args);
186 186
 						} // if agrs was specified then we wil pass three params
187 187
 						else {
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataSetPagerCnt = 0;
12 12
 
13
-class DataSetPager {
13
+class DataSetPager
14
+{
14 15
 
15 16
 	public $ds; // datasource
16 17
     public $pageSize;
@@ -31,7 +32,8 @@  discard block
 block discarded – undo
31 32
     public $renderPagerFnc;
32 33
     public $renderPagerFncArgs;
33 34
 
34
-    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35
+    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1)
36
+    {
35 37
 		global $_PAGE; // use view state object
36 38
 
37 39
 		global $__DataSetPagerCnt;
@@ -61,35 +63,42 @@  discard block
 block discarded – undo
61 63
 		$this->pager = '';
62 64
 	}
63 65
 
64
-    public function getRenderedPager() {
66
+    public function getRenderedPager()
67
+    {
65 68
 		return $this->pager;
66 69
 	}
67 70
 
68
-    public function getRenderedRows() {
71
+    public function getRenderedRows()
72
+    {
69 73
 		return $this->rows;
70 74
 	}
71 75
 
72
-    public function setDataSource($ds) {
76
+    public function setDataSource($ds)
77
+    {
73 78
 		$this->ds = $ds;
74 79
 	}
75 80
 
76
-    public function setPageSize($ps) {
81
+    public function setPageSize($ps)
82
+    {
77 83
 		$this->pageSize = $ps;
78 84
 	}
79 85
 
80
-    public function setRenderRowFnc($fncName, $args = "") {
86
+    public function setRenderRowFnc($fncName, $args = "")
87
+    {
81 88
 		$this->renderRowFnc = &$fncName;
82 89
 		$this->renderRowFncArgs = $args;    // extra agruments
83 90
 
84 91
 
85 92
 	}
86 93
 
87
-    public function setRenderPagerFnc($fncName, $args = "") {
94
+    public function setRenderPagerFnc($fncName, $args = "")
95
+    {
88 96
 		$this->renderPagerFnc = $fncName;
89 97
 		$this->renderPagerFncArgs = $args;    // extra agruments
90 98
 	}
91 99
 
92
-    public function render() {
100
+    public function render()
101
+    {
93 102
 		$modx = DocumentParser::getInstance(); global $_PAGE;
94 103
 
95 104
 		$isDataset = $modx->db->isResult($this->ds);
@@ -142,8 +151,10 @@  discard block
 block discarded – undo
142 151
 					$url = $_SERVER['PHP_SELF'] . '?';
143 152
 				}
144 153
 				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
154
+				foreach($_GET as $n => $v) {
155
+				    if($n != 'dpgn' . $this->id) {
146 156
 					$i++;
157
+				}
147 158
 					$url .= (($i > 1) ? "&" : "") . "$n=$v";
148 159
 				}
149 160
 				if($i >= 1) {
Please login to merge, or discard this patch.
manager/includes/log.class.inc.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
         $action = "",
37 37
         $itemid = "",
38 38
         $itemname = ""
39
-    ) {
39
+    ){
40 40
         $modx = DocumentParser::getInstance();
41 41
         $this->entry['msg'] = $msg; // writes testmessage to the object
42
-        $this->entry['action'] = empty($action) ? $modx->manager->action : $action;    // writes the action to the object
42
+        $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object
43 43
 
44 44
         // User Credentials
45 45
         $this->entry['internalKey'] = $internalKey == "" ? $modx->getLoginUserID() : $internalKey;
46 46
         $this->entry['username'] = $username == "" ? $modx->getLoginUserName() : $username;
47 47
 
48
-        $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int)$_REQUEST['id'] : $itemid;  // writes the id to the object
48
+        $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int) $_REQUEST['id'] : $itemid; // writes the id to the object
49 49
         if ($this->entry['itemId'] == 0) {
50 50
             $this->entry['itemId'] = "-";
51 51
         } // to stop items having id 0
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
         $fields['message'] = $modx->db->escape($this->entry['msg']);
94 94
         $insert_id = $modx->db->insert($fields, $tbl_manager_log);
95 95
         if (!$insert_id) {
96
-            $modx->messageQuit("Logging error: couldn't save log to table! Error code: " . $modx->db->getLastError());
96
+            $modx->messageQuit("Logging error: couldn't save log to table! Error code: ".$modx->db->getLastError());
97 97
         } else {
98
-            $limit = (isset($modx->config['manager_log_limit'])) ? (int)$modx->config['manager_log_limit'] : 3000;
99
-            $trim = (isset($modx->config['manager_log_trim'])) ? (int)$modx->config['manager_log_trim'] : 100;
98
+            $limit = (isset($modx->config['manager_log_limit'])) ? (int) $modx->config['manager_log_limit'] : 3000;
99
+            $trim = (isset($modx->config['manager_log_trim'])) ? (int) $modx->config['manager_log_trim'] : 100;
100 100
             if (($insert_id % $trim) === 0) {
101 101
                 $modx->rotate_log('manager_log', $limit, $trim);
102 102
             }
Please login to merge, or discard this patch.
manager/includes/tmplvars.format.inc.php 3 patches
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -21,320 +21,320 @@  discard block
 block discarded – undo
21 21
     $o = '';
22 22
 
23 23
     // process any TV commands in value
24
-	$docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier;
25
-	$value = ProcessTVCommand($value, $name, $docid);
24
+    $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier;
25
+    $value = ProcessTVCommand($value, $name, $docid);
26 26
 
27
-	$params = array();
28
-	if($paramstring) {
29
-		$cp = explode("&", $paramstring);
30
-		foreach($cp as $p => $v) {
31
-			$v = trim($v); // trim
32
-			$ar = explode("=", $v);
33
-			if(is_array($ar) && count($ar) == 2) {
34
-				$params[$ar[0]] = decodeParamValue($ar[1]);
35
-			}
36
-		}
37
-	}
27
+    $params = array();
28
+    if($paramstring) {
29
+        $cp = explode("&", $paramstring);
30
+        foreach($cp as $p => $v) {
31
+            $v = trim($v); // trim
32
+            $ar = explode("=", $v);
33
+            if(is_array($ar) && count($ar) == 2) {
34
+                $params[$ar[0]] = decodeParamValue($ar[1]);
35
+            }
36
+        }
37
+    }
38 38
 
39
-	$id = "tv$name";
40
-	switch($format) {
41
-		case 'image':
42
-			$images = parseInput($value, '||', 'array');
43
-			foreach($images as $image) {
44
-				if(!is_array($image)) {
45
-					$image = explode('==', $image);
46
-				}
47
-				$src = $image[0];
39
+    $id = "tv$name";
40
+    switch($format) {
41
+        case 'image':
42
+            $images = parseInput($value, '||', 'array');
43
+            foreach($images as $image) {
44
+                if(!is_array($image)) {
45
+                    $image = explode('==', $image);
46
+                }
47
+                $src = $image[0];
48 48
 
49
-				if($src) {
50
-					// We have a valid source
51
-					$attributes = '';
52
-					$attr = array(
53
-						'class' => $params['class'],
54
-						'src' => $src,
55
-						'id' => ($params['id'] ? $params['id'] : ''),
56
-						'alt' => $modx->htmlspecialchars($params['alttext']),
57
-						'style' => $params['style']
58
-					);
59
-					if(isset($params['align']) && $params['align'] != 'none') {
60
-						$attr['align'] = $params['align'];
61
-					}
62
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
63
-					$attributes .= ' ' . $params['attrib'];
49
+                if($src) {
50
+                    // We have a valid source
51
+                    $attributes = '';
52
+                    $attr = array(
53
+                        'class' => $params['class'],
54
+                        'src' => $src,
55
+                        'id' => ($params['id'] ? $params['id'] : ''),
56
+                        'alt' => $modx->htmlspecialchars($params['alttext']),
57
+                        'style' => $params['style']
58
+                    );
59
+                    if(isset($params['align']) && $params['align'] != 'none') {
60
+                        $attr['align'] = $params['align'];
61
+                    }
62
+                    foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
63
+                    $attributes .= ' ' . $params['attrib'];
64 64
 
65
-					// Output the image with attributes
66
-					$o .= '<img' . rtrim($attributes) . ' />';
67
-				}
68
-			}
69
-			break;
65
+                    // Output the image with attributes
66
+                    $o .= '<img' . rtrim($attributes) . ' />';
67
+                }
68
+            }
69
+            break;
70 70
 
71
-		case "delim":    // display as delimitted list
72
-			$value = parseInput($value, "||");
73
-			$p = $params['format'] ? $params['format'] : " ";
74
-			if($p == "\\n") {
75
-				$p = "\n";
76
-			}
77
-			$o = str_replace("||", $p, $value);
78
-			break;
71
+        case "delim":    // display as delimitted list
72
+            $value = parseInput($value, "||");
73
+            $p = $params['format'] ? $params['format'] : " ";
74
+            if($p == "\\n") {
75
+                $p = "\n";
76
+            }
77
+            $o = str_replace("||", $p, $value);
78
+            break;
79 79
 
80
-		case "string":
81
-			$value = parseInput($value);
82
-			$format = strtolower($params['format']);
83
-			if($format == 'upper case') {
84
-				$o = strtoupper($value);
85
-			} else if($format == 'lower case') {
86
-				$o = strtolower($value);
87
-			} else if($format == 'sentence case') {
88
-				$o = ucfirst($value);
89
-			} else if($format == 'capitalize') {
90
-				$o = ucwords($value);
91
-			} else {
92
-				$o = $value;
93
-			}
94
-			break;
80
+        case "string":
81
+            $value = parseInput($value);
82
+            $format = strtolower($params['format']);
83
+            if($format == 'upper case') {
84
+                $o = strtoupper($value);
85
+            } else if($format == 'lower case') {
86
+                $o = strtolower($value);
87
+            } else if($format == 'sentence case') {
88
+                $o = ucfirst($value);
89
+            } else if($format == 'capitalize') {
90
+                $o = ucwords($value);
91
+            } else {
92
+                $o = $value;
93
+            }
94
+            break;
95 95
 
96
-		case "date":
97
-			if($value != '' || $params['default'] == 'Yes') {
98
-				if(empty($value)) {
99
-					$value = 'now';
100
-				}
101
-				$timestamp = getUnixtimeFromDateString($value);
102
-				$p = $params['format'] ? $params['format'] : "%A %d, %B %Y";
103
-				$o = strftime($p, $timestamp);
104
-			} else {
105
-				$value = '';
106
-			}
107
-			break;
96
+        case "date":
97
+            if($value != '' || $params['default'] == 'Yes') {
98
+                if(empty($value)) {
99
+                    $value = 'now';
100
+                }
101
+                $timestamp = getUnixtimeFromDateString($value);
102
+                $p = $params['format'] ? $params['format'] : "%A %d, %B %Y";
103
+                $o = strftime($p, $timestamp);
104
+            } else {
105
+                $value = '';
106
+            }
107
+            break;
108 108
 
109
-		case "hyperlink":
110
-			$value = parseInput($value, "||", "array");
111
-			$o = '';
112
-			$countValue = count($value);
113
-			for($i = 0; $i < $countValue; $i++) {
114
-				list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]);
115
-				if(!$url) {
116
-					$url = $name;
117
-				}
118
-				if($url) {
119
-					if($o) {
120
-						$o .= '<br />';
121
-					}
122
-					$attributes = '';
123
-					// setup the link attributes
124
-					$attr = array(
125
-						'href' => $url,
126
-						'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name,
127
-						'class' => $params['class'],
128
-						'style' => $params['style'],
129
-						'target' => $params['target'],
130
-					);
131
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
132
-					$attributes .= ' ' . $params['attrib']; // add extra
109
+        case "hyperlink":
110
+            $value = parseInput($value, "||", "array");
111
+            $o = '';
112
+            $countValue = count($value);
113
+            for($i = 0; $i < $countValue; $i++) {
114
+                list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]);
115
+                if(!$url) {
116
+                    $url = $name;
117
+                }
118
+                if($url) {
119
+                    if($o) {
120
+                        $o .= '<br />';
121
+                    }
122
+                    $attributes = '';
123
+                    // setup the link attributes
124
+                    $attr = array(
125
+                        'href' => $url,
126
+                        'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name,
127
+                        'class' => $params['class'],
128
+                        'style' => $params['style'],
129
+                        'target' => $params['target'],
130
+                    );
131
+                    foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
132
+                    $attributes .= ' ' . $params['attrib']; // add extra
133 133
 
134
-					// Output the link
135
-					$o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>';
136
-				}
137
-			}
138
-			break;
134
+                    // Output the link
135
+                    $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>';
136
+                }
137
+            }
138
+            break;
139 139
 
140
-		case "htmltag":
141
-			$value = parseInput($value, "||", "array");
142
-			$tagid = $params['tagid'];
143
-			$tagname = ($params['tagname']) ? $params['tagname'] : 'div';
144
-			$o = '';
145
-			// Loop through a list of tags
140
+        case "htmltag":
141
+            $value = parseInput($value, "||", "array");
142
+            $tagid = $params['tagid'];
143
+            $tagname = ($params['tagname']) ? $params['tagname'] : 'div';
144
+            $o = '';
145
+            // Loop through a list of tags
146 146
             $countValue = count($value);
147
-			for($i = 0; $i < $countValue; $i++) {
148
-				$tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i];
149
-				if(!$tagvalue) {
150
-					continue;
151
-				}
147
+            for($i = 0; $i < $countValue; $i++) {
148
+                $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i];
149
+                if(!$tagvalue) {
150
+                    continue;
151
+                }
152 152
 
153
-				$attributes = '';
154
-				$attr = array(
155
-					'id' => ($tagid ? $tagid : $id),
156
-					// 'tv' already added to id
157
-					'class' => $params['class'],
158
-					'style' => $params['style'],
159
-				);
160
-				foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
161
-				$attributes .= ' ' . $params['attrib']; // add extra
153
+                $attributes = '';
154
+                $attr = array(
155
+                    'id' => ($tagid ? $tagid : $id),
156
+                    // 'tv' already added to id
157
+                    'class' => $params['class'],
158
+                    'style' => $params['style'],
159
+                );
160
+                foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
161
+                $attributes .= ' ' . $params['attrib']; // add extra
162 162
 
163
-				// Output the HTML Tag
164
-				$o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>';
165
-			}
166
-			break;
163
+                // Output the HTML Tag
164
+                $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>';
165
+            }
166
+            break;
167 167
 
168
-		case "richtext":
169
-			$value = parseInput($value);
170
-			$w = $params['w'] ? $params['w'] : '100%';
171
-			$h = $params['h'] ? $params['h'] : '400px';
172
-			$richtexteditor = $params['edt'] ? $params['edt'] : "";
173
-			$o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">';
174
-			$o .= $modx->htmlspecialchars($value);
175
-			$o .= '</textarea></div>';
176
-			$replace_richtext = array($id);
177
-			// setup editors
178
-			if(!empty($replace_richtext) && !empty($richtexteditor)) {
179
-				// invoke OnRichTextEditorInit event
180
-				$evtOut = $modx->invokeEvent("OnRichTextEditorInit", array(
181
-					'editor' => $richtexteditor,
182
-					'elements' => $replace_richtext,
183
-					'forfrontend' => 1,
184
-					'width' => $w,
185
-					'height' => $h
186
-				));
187
-				if(is_array($evtOut)) {
188
-					$o .= implode("", $evtOut);
189
-				}
190
-			}
191
-			break;
168
+        case "richtext":
169
+            $value = parseInput($value);
170
+            $w = $params['w'] ? $params['w'] : '100%';
171
+            $h = $params['h'] ? $params['h'] : '400px';
172
+            $richtexteditor = $params['edt'] ? $params['edt'] : "";
173
+            $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">';
174
+            $o .= $modx->htmlspecialchars($value);
175
+            $o .= '</textarea></div>';
176
+            $replace_richtext = array($id);
177
+            // setup editors
178
+            if(!empty($replace_richtext) && !empty($richtexteditor)) {
179
+                // invoke OnRichTextEditorInit event
180
+                $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array(
181
+                    'editor' => $richtexteditor,
182
+                    'elements' => $replace_richtext,
183
+                    'forfrontend' => 1,
184
+                    'width' => $w,
185
+                    'height' => $h
186
+                ));
187
+                if(is_array($evtOut)) {
188
+                    $o .= implode("", $evtOut);
189
+                }
190
+            }
191
+            break;
192 192
 
193
-		case "unixtime":
194
-			$value = parseInput($value);
195
-			$o = getUnixtimeFromDateString($value);
196
-			break;
193
+        case "unixtime":
194
+            $value = parseInput($value);
195
+            $o = getUnixtimeFromDateString($value);
196
+            break;
197 197
 
198
-		case "viewport":
199
-			$value = parseInput($value);
200
-			$id = '_' . time();
201
-			if(!$params['vpid']) {
202
-				$params['vpid'] = $id;
203
-			}
204
-			$sTag = "<iframe";
205
-			$eTag = "</iframe>";
206
-			$autoMode = "0";
207
-			$w = $params['width'];
208
-			$h = $params['height'];
209
-			if($params['stretch'] == 'Yes') {
210
-				$w = "100%";
211
-				$h = "100%";
212
-			}
213
-			if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) {
214
-				$autoMode = "3";  //both
215
-			} else if($params['awidth'] == 'Yes') {
216
-				$autoMode = "1"; //width only
217
-			} else if($params['aheight'] == 'Yes') {
218
-				$autoMode = "2";    //height only
219
-			}
198
+        case "viewport":
199
+            $value = parseInput($value);
200
+            $id = '_' . time();
201
+            if(!$params['vpid']) {
202
+                $params['vpid'] = $id;
203
+            }
204
+            $sTag = "<iframe";
205
+            $eTag = "</iframe>";
206
+            $autoMode = "0";
207
+            $w = $params['width'];
208
+            $h = $params['height'];
209
+            if($params['stretch'] == 'Yes') {
210
+                $w = "100%";
211
+                $h = "100%";
212
+            }
213
+            if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) {
214
+                $autoMode = "3";  //both
215
+            } else if($params['awidth'] == 'Yes') {
216
+                $autoMode = "1"; //width only
217
+            } else if($params['aheight'] == 'Yes') {
218
+                $autoMode = "2";    //height only
219
+            }
220 220
 
221
-			$modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array(
222
-				'name' => 'viewport',
223
-				'version' => '0',
224
-				'plaintext' => false
225
-			));
226
-			$o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' ";
227
-			if($params['class']) {
228
-				$o .= " class='" . $params['class'] . "' ";
229
-			}
230
-			if($params['style']) {
231
-				$o .= " style='" . $params['style'] . "' ";
232
-			}
233
-			if($params['attrib']) {
234
-				$o .= $params['attrib'] . " ";
235
-			}
236
-			$o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' ";
237
-			$o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' ";
238
-			$o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' ";
239
-			$o .= ">";
240
-			$o .= $eTag;
241
-			break;
221
+            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array(
222
+                'name' => 'viewport',
223
+                'version' => '0',
224
+                'plaintext' => false
225
+            ));
226
+            $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' ";
227
+            if($params['class']) {
228
+                $o .= " class='" . $params['class'] . "' ";
229
+            }
230
+            if($params['style']) {
231
+                $o .= " style='" . $params['style'] . "' ";
232
+            }
233
+            if($params['attrib']) {
234
+                $o .= $params['attrib'] . " ";
235
+            }
236
+            $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' ";
237
+            $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' ";
238
+            $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' ";
239
+            $o .= ">";
240
+            $o .= $eTag;
241
+            break;
242 242
 
243
-		case "datagrid":
244
-			include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
245
-			$grd = new DataGrid('', $value);
243
+        case "datagrid":
244
+            include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
245
+            $grd = new DataGrid('', $value);
246 246
 
247
-			$grd->noRecordMsg = $params['egmsg'];
247
+            $grd->noRecordMsg = $params['egmsg'];
248 248
 
249
-			$grd->columnHeaderClass = $params['chdrc'];
250
-			$grd->cssClass = $params['tblc'];
251
-			$grd->itemClass = $params['itmc'];
252
-			$grd->altItemClass = $params['aitmc'];
249
+            $grd->columnHeaderClass = $params['chdrc'];
250
+            $grd->cssClass = $params['tblc'];
251
+            $grd->itemClass = $params['itmc'];
252
+            $grd->altItemClass = $params['aitmc'];
253 253
 
254
-			$grd->columnHeaderStyle = $params['chdrs'];
255
-			$grd->cssStyle = $params['tbls'];
256
-			$grd->itemStyle = $params['itms'];
257
-			$grd->altItemStyle = $params['aitms'];
254
+            $grd->columnHeaderStyle = $params['chdrs'];
255
+            $grd->cssStyle = $params['tbls'];
256
+            $grd->itemStyle = $params['itms'];
257
+            $grd->altItemStyle = $params['aitms'];
258 258
 
259
-			$grd->columns = $params['cols'];
260
-			$grd->fields = $params['flds'];
261
-			$grd->colWidths = $params['cwidth'];
262
-			$grd->colAligns = $params['calign'];
263
-			$grd->colColors = $params['ccolor'];
264
-			$grd->colTypes = $params['ctype'];
259
+            $grd->columns = $params['cols'];
260
+            $grd->fields = $params['flds'];
261
+            $grd->colWidths = $params['cwidth'];
262
+            $grd->colAligns = $params['calign'];
263
+            $grd->colColors = $params['ccolor'];
264
+            $grd->colTypes = $params['ctype'];
265 265
 
266
-			$grd->cellPadding = $params['cpad'];
267
-			$grd->cellSpacing = $params['cspace'];
268
-			$grd->header = $params['head'];
269
-			$grd->footer = $params['foot'];
270
-			$grd->pageSize = $params['psize'];
271
-			$grd->pagerLocation = $params['ploc'];
272
-			$grd->pagerClass = $params['pclass'];
273
-			$grd->pagerStyle = $params['pstyle'];
274
-			$o = $grd->render();
275
-			break;
266
+            $grd->cellPadding = $params['cpad'];
267
+            $grd->cellSpacing = $params['cspace'];
268
+            $grd->header = $params['head'];
269
+            $grd->footer = $params['foot'];
270
+            $grd->pageSize = $params['psize'];
271
+            $grd->pagerLocation = $params['ploc'];
272
+            $grd->pagerClass = $params['pclass'];
273
+            $grd->pagerStyle = $params['pstyle'];
274
+            $o = $grd->render();
275
+            break;
276 276
 
277
-		case 'htmlentities':
278
-			$value = parseInput($value);
279
-			if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
280
-				// remove delimiter from checkbox and listbox-multiple TVs
281
-				$value = str_replace('||', '', $value);
282
-			}
283
-			$o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']);
284
-			break;
277
+        case 'htmlentities':
278
+            $value = parseInput($value);
279
+            if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
280
+                // remove delimiter from checkbox and listbox-multiple TVs
281
+                $value = str_replace('||', '', $value);
282
+            }
283
+            $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']);
284
+            break;
285 285
 
286
-		case 'custom_widget':
287
-			$widget_output = '';
288
-			$o = '';
289
-			/* If we are loading a file */
290
-			if(substr($params['output'], 0, 5) == "@FILE") {
291
-				$file_name = MODX_BASE_PATH . trim(substr($params['output'], 6));
292
-				if(!file_exists($file_name)) {
293
-					$widget_output = $file_name . ' does not exist';
294
-				} else {
295
-					$widget_output = file_get_contents($file_name);
296
-				}
297
-			} elseif(substr($params['output'], 0, 8) == '@INCLUDE') {
298
-				$file_name = MODX_BASE_PATH . trim(substr($params['output'], 9));
299
-				if(!file_exists($file_name)) {
300
-					$widget_output = $file_name . ' does not exist';
301
-				} else {
302
-					/* The included file needs to set $widget_output. Can be string, array, object */
303
-					include $file_name;
304
-				}
305
-			} elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') {
306
-				$chunk_name = trim(substr($params['output'], 7));
307
-				$widget_output = $modx->getChunk($chunk_name);
308
-			} elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') {
309
-				$eval_str = trim(substr($params['output'], 6));
310
-				$widget_output = eval($eval_str);
311
-			} elseif($value !== '') {
312
-				$widget_output = $params['output'];
313
-			} else {
314
-				$widget_output = '';
315
-			}
316
-			if(is_string($widget_output)) {
317
-				$_ = $modx->config['enable_filter'];
318
-				$modx->config['enable_filter'] = 1;
319
-				$widget_output = $modx->parseText($widget_output, array('value' => $value));
320
-				$modx->config['enable_filter'] = $_;
321
-				$o = $modx->parseDocumentSource($widget_output);
322
-			} else {
323
-				$o = $widget_output;
324
-			}
325
-			break;
286
+        case 'custom_widget':
287
+            $widget_output = '';
288
+            $o = '';
289
+            /* If we are loading a file */
290
+            if(substr($params['output'], 0, 5) == "@FILE") {
291
+                $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6));
292
+                if(!file_exists($file_name)) {
293
+                    $widget_output = $file_name . ' does not exist';
294
+                } else {
295
+                    $widget_output = file_get_contents($file_name);
296
+                }
297
+            } elseif(substr($params['output'], 0, 8) == '@INCLUDE') {
298
+                $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9));
299
+                if(!file_exists($file_name)) {
300
+                    $widget_output = $file_name . ' does not exist';
301
+                } else {
302
+                    /* The included file needs to set $widget_output. Can be string, array, object */
303
+                    include $file_name;
304
+                }
305
+            } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') {
306
+                $chunk_name = trim(substr($params['output'], 7));
307
+                $widget_output = $modx->getChunk($chunk_name);
308
+            } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') {
309
+                $eval_str = trim(substr($params['output'], 6));
310
+                $widget_output = eval($eval_str);
311
+            } elseif($value !== '') {
312
+                $widget_output = $params['output'];
313
+            } else {
314
+                $widget_output = '';
315
+            }
316
+            if(is_string($widget_output)) {
317
+                $_ = $modx->config['enable_filter'];
318
+                $modx->config['enable_filter'] = 1;
319
+                $widget_output = $modx->parseText($widget_output, array('value' => $value));
320
+                $modx->config['enable_filter'] = $_;
321
+                $o = $modx->parseDocumentSource($widget_output);
322
+            } else {
323
+                $o = $widget_output;
324
+            }
325
+            break;
326 326
 
327
-		default:
328
-			$value = parseInput($value);
329
-			if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
330
-				// add separator
331
-				$value = explode('||', $value);
332
-				$value = implode($sep, $value);
333
-			}
334
-			$o = $value;
335
-			break;
336
-	}
337
-	return $o;
327
+        default:
328
+            $value = parseInput($value);
329
+            if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
330
+                // add separator
331
+                $value = explode('||', $value);
332
+                $value = implode($sep, $value);
333
+            }
334
+            $o = $value;
335
+            break;
336
+    }
337
+    return $o;
338 338
 }
339 339
 
340 340
 /**
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
  * @return string
343 343
  */
344 344
 function decodeParamValue($s) {
345
-	$s = str_replace("%3D", '=', $s); // =
346
-	return str_replace("%26", '&', $s); // &
345
+    $s = str_replace("%3D", '=', $s); // =
346
+    return str_replace("%26", '&', $s); // &
347 347
 }
348 348
 
349 349
 /**
@@ -357,19 +357,19 @@  discard block
 block discarded – undo
357 357
  */
358 358
 function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array
359 359
     $modx = DocumentParser::getInstance();
360
-	if($modx->db->isResult($src)) {
361
-		// must be a recordset
362
-		$rows = array();
363
-		while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols);
364
-		return ($type == "array") ? $rows : implode($delim, $rows);
365
-	} else {
366
-		// must be a text
367
-		if($type == "array") {
368
-			return explode($delim, $src);
369
-		} else {
370
-			return $src;
371
-		}
372
-	}
360
+    if($modx->db->isResult($src)) {
361
+        // must be a recordset
362
+        $rows = array();
363
+        while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols);
364
+        return ($type == "array") ? $rows : implode($delim, $rows);
365
+    } else {
366
+        // must be a text
367
+        if($type == "array") {
368
+            return explode($delim, $src);
369
+        } else {
370
+            return $src;
371
+        }
372
+    }
373 373
 }
374 374
 
375 375
 /**
@@ -377,21 +377,21 @@  discard block
 block discarded – undo
377 377
  * @return bool|false|int
378 378
  */
379 379
 function getUnixtimeFromDateString($value) {
380
-	$timestamp = false;
381
-	// Check for MySQL or legacy style date
382
-	$date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
383
-	$date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
384
-	$matches = array();
385
-	if(strpos($value, '-') !== false) {
386
-		if(preg_match($date_match_1, $value, $matches)) {
387
-			$timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
388
-		} elseif(preg_match($date_match_2, $value, $matches)) {
389
-			$timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
390
-		}
391
-	}
392
-	// If those didn't work, use strtotime to figure out the date
393
-	if($timestamp === false || $timestamp === -1) {
394
-		$timestamp = strtotime($value);
395
-	}
396
-	return $timestamp;
380
+    $timestamp = false;
381
+    // Check for MySQL or legacy style date
382
+    $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
383
+    $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
384
+    $matches = array();
385
+    if(strpos($value, '-') !== false) {
386
+        if(preg_match($date_match_1, $value, $matches)) {
387
+            $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
388
+        } elseif(preg_match($date_match_2, $value, $matches)) {
389
+            $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
390
+        }
391
+    }
392
+    // If those didn't work, use strtotime to figure out the date
393
+    if($timestamp === false || $timestamp === -1) {
394
+        $timestamp = strtotime($value);
395
+    }
396
+    return $timestamp;
397 397
 }
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -15,38 +15,38 @@  discard block
 block discarded – undo
15 15
  * @param string $sep
16 16
  * @return mixed|string
17 17
  */
18
-function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') {
18
+function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = ''){
19 19
 
20 20
     $modx = DocumentParser::getInstance();
21 21
     $o = '';
22 22
 
23 23
     // process any TV commands in value
24
-	$docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier;
24
+	$docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier;
25 25
 	$value = ProcessTVCommand($value, $name, $docid);
26 26
 
27 27
 	$params = array();
28
-	if($paramstring) {
28
+	if ($paramstring) {
29 29
 		$cp = explode("&", $paramstring);
30
-		foreach($cp as $p => $v) {
30
+		foreach ($cp as $p => $v) {
31 31
 			$v = trim($v); // trim
32 32
 			$ar = explode("=", $v);
33
-			if(is_array($ar) && count($ar) == 2) {
33
+			if (is_array($ar) && count($ar) == 2) {
34 34
 				$params[$ar[0]] = decodeParamValue($ar[1]);
35 35
 			}
36 36
 		}
37 37
 	}
38 38
 
39 39
 	$id = "tv$name";
40
-	switch($format) {
40
+	switch ($format) {
41 41
 		case 'image':
42 42
 			$images = parseInput($value, '||', 'array');
43
-			foreach($images as $image) {
44
-				if(!is_array($image)) {
43
+			foreach ($images as $image) {
44
+				if (!is_array($image)) {
45 45
 					$image = explode('==', $image);
46 46
 				}
47 47
 				$src = $image[0];
48 48
 
49
-				if($src) {
49
+				if ($src) {
50 50
 					// We have a valid source
51 51
 					$attributes = '';
52 52
 					$attr = array(
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 						'alt' => $modx->htmlspecialchars($params['alttext']),
57 57
 						'style' => $params['style']
58 58
 					);
59
-					if(isset($params['align']) && $params['align'] != 'none') {
59
+					if (isset($params['align']) && $params['align'] != 'none') {
60 60
 						$attr['align'] = $params['align'];
61 61
 					}
62
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
63
-					$attributes .= ' ' . $params['attrib'];
62
+					foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : '');
63
+					$attributes .= ' '.$params['attrib'];
64 64
 
65 65
 					// Output the image with attributes
66
-					$o .= '<img' . rtrim($attributes) . ' />';
66
+					$o .= '<img'.rtrim($attributes).' />';
67 67
 				}
68 68
 			}
69 69
 			break;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		case "delim":    // display as delimitted list
72 72
 			$value = parseInput($value, "||");
73 73
 			$p = $params['format'] ? $params['format'] : " ";
74
-			if($p == "\\n") {
74
+			if ($p == "\\n") {
75 75
 				$p = "\n";
76 76
 			}
77 77
 			$o = str_replace("||", $p, $value);
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 		case "string":
81 81
 			$value = parseInput($value);
82 82
 			$format = strtolower($params['format']);
83
-			if($format == 'upper case') {
83
+			if ($format == 'upper case') {
84 84
 				$o = strtoupper($value);
85
-			} else if($format == 'lower case') {
85
+			} else if ($format == 'lower case') {
86 86
 				$o = strtolower($value);
87
-			} else if($format == 'sentence case') {
87
+			} else if ($format == 'sentence case') {
88 88
 				$o = ucfirst($value);
89
-			} else if($format == 'capitalize') {
89
+			} else if ($format == 'capitalize') {
90 90
 				$o = ucwords($value);
91 91
 			} else {
92 92
 				$o = $value;
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 			break;
95 95
 
96 96
 		case "date":
97
-			if($value != '' || $params['default'] == 'Yes') {
98
-				if(empty($value)) {
97
+			if ($value != '' || $params['default'] == 'Yes') {
98
+				if (empty($value)) {
99 99
 					$value = 'now';
100 100
 				}
101 101
 				$timestamp = getUnixtimeFromDateString($value);
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 			$value = parseInput($value, "||", "array");
111 111
 			$o = '';
112 112
 			$countValue = count($value);
113
-			for($i = 0; $i < $countValue; $i++) {
113
+			for ($i = 0; $i < $countValue; $i++) {
114 114
 				list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]);
115
-				if(!$url) {
115
+				if (!$url) {
116 116
 					$url = $name;
117 117
 				}
118
-				if($url) {
119
-					if($o) {
118
+				if ($url) {
119
+					if ($o) {
120 120
 						$o .= '<br />';
121 121
 					}
122 122
 					$attributes = '';
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 						'style' => $params['style'],
129 129
 						'target' => $params['target'],
130 130
 					);
131
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
132
-					$attributes .= ' ' . $params['attrib']; // add extra
131
+					foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : '');
132
+					$attributes .= ' '.$params['attrib']; // add extra
133 133
 
134 134
 					// Output the link
135
-					$o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>';
135
+					$o .= '<a'.rtrim($attributes).'>'.($params['text'] ? $modx->htmlspecialchars($params['text']) : $name).'</a>';
136 136
 				}
137 137
 			}
138 138
 			break;
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 			$o = '';
145 145
 			// Loop through a list of tags
146 146
             $countValue = count($value);
147
-			for($i = 0; $i < $countValue; $i++) {
147
+			for ($i = 0; $i < $countValue; $i++) {
148 148
 				$tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i];
149
-				if(!$tagvalue) {
149
+				if (!$tagvalue) {
150 150
 					continue;
151 151
 				}
152 152
 
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 					'class' => $params['class'],
158 158
 					'style' => $params['style'],
159 159
 				);
160
-				foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
161
-				$attributes .= ' ' . $params['attrib']; // add extra
160
+				foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : '');
161
+				$attributes .= ' '.$params['attrib']; // add extra
162 162
 
163 163
 				// Output the HTML Tag
164
-				$o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>';
164
+				$o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>';
165 165
 			}
166 166
 			break;
167 167
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 			$w = $params['w'] ? $params['w'] : '100%';
171 171
 			$h = $params['h'] ? $params['h'] : '400px';
172 172
 			$richtexteditor = $params['edt'] ? $params['edt'] : "";
173
-			$o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">';
173
+			$o = '<div class="MODX_RichTextWidget"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">';
174 174
 			$o .= $modx->htmlspecialchars($value);
175 175
 			$o .= '</textarea></div>';
176 176
 			$replace_richtext = array($id);
177 177
 			// setup editors
178
-			if(!empty($replace_richtext) && !empty($richtexteditor)) {
178
+			if (!empty($replace_richtext) && !empty($richtexteditor)) {
179 179
 				// invoke OnRichTextEditorInit event
180 180
 				$evtOut = $modx->invokeEvent("OnRichTextEditorInit", array(
181 181
 					'editor' => $richtexteditor,
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 					'width' => $w,
185 185
 					'height' => $h
186 186
 				));
187
-				if(is_array($evtOut)) {
187
+				if (is_array($evtOut)) {
188 188
 					$o .= implode("", $evtOut);
189 189
 				}
190 190
 			}
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 
198 198
 		case "viewport":
199 199
 			$value = parseInput($value);
200
-			$id = '_' . time();
201
-			if(!$params['vpid']) {
200
+			$id = '_'.time();
201
+			if (!$params['vpid']) {
202 202
 				$params['vpid'] = $id;
203 203
 			}
204 204
 			$sTag = "<iframe";
@@ -206,42 +206,42 @@  discard block
 block discarded – undo
206 206
 			$autoMode = "0";
207 207
 			$w = $params['width'];
208 208
 			$h = $params['height'];
209
-			if($params['stretch'] == 'Yes') {
209
+			if ($params['stretch'] == 'Yes') {
210 210
 				$w = "100%";
211 211
 				$h = "100%";
212 212
 			}
213
-			if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) {
214
-				$autoMode = "3";  //both
215
-			} else if($params['awidth'] == 'Yes') {
213
+			if ($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) {
214
+				$autoMode = "3"; //both
215
+			} else if ($params['awidth'] == 'Yes') {
216 216
 				$autoMode = "1"; //width only
217
-			} else if($params['aheight'] == 'Yes') {
218
-				$autoMode = "2";    //height only
217
+			} else if ($params['aheight'] == 'Yes') {
218
+				$autoMode = "2"; //height only
219 219
 			}
220 220
 
221
-			$modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array(
221
+			$modx->regClientStartupScript(MODX_MANAGER_URL."media/script/bin/viewport.js", array(
222 222
 				'name' => 'viewport',
223 223
 				'version' => '0',
224 224
 				'plaintext' => false
225 225
 			));
226
-			$o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' ";
227
-			if($params['class']) {
228
-				$o .= " class='" . $params['class'] . "' ";
226
+			$o = $sTag." id='".$params['vpid']."' name='".$params['vpid']."' ";
227
+			if ($params['class']) {
228
+				$o .= " class='".$params['class']."' ";
229 229
 			}
230
-			if($params['style']) {
231
-				$o .= " style='" . $params['style'] . "' ";
230
+			if ($params['style']) {
231
+				$o .= " style='".$params['style']."' ";
232 232
 			}
233
-			if($params['attrib']) {
234
-				$o .= $params['attrib'] . " ";
233
+			if ($params['attrib']) {
234
+				$o .= $params['attrib']." ";
235 235
 			}
236
-			$o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' ";
237
-			$o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' ";
238
-			$o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' ";
236
+			$o .= "scrolling='".($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto"))."' ";
237
+			$o .= "src='".$value."' frameborder='".$params['borsize']."' ";
238
+			$o .= "onload=\"window.setTimeout('ResizeViewPort(\\'".$params['vpid']."\\',".$autoMode.")',100);\" width='".$w."' height='".$h."' ";
239 239
 			$o .= ">";
240 240
 			$o .= $eTag;
241 241
 			break;
242 242
 
243 243
 		case "datagrid":
244
-			include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
244
+			include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php";
245 245
 			$grd = new DataGrid('', $value);
246 246
 
247 247
 			$grd->noRecordMsg = $params['egmsg'];
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		case 'htmlentities':
278 278
 			$value = parseInput($value);
279
-			if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
279
+			if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
280 280
 				// remove delimiter from checkbox and listbox-multiple TVs
281 281
 				$value = str_replace('||', '', $value);
282 282
 			}
@@ -287,33 +287,33 @@  discard block
 block discarded – undo
287 287
 			$widget_output = '';
288 288
 			$o = '';
289 289
 			/* If we are loading a file */
290
-			if(substr($params['output'], 0, 5) == "@FILE") {
291
-				$file_name = MODX_BASE_PATH . trim(substr($params['output'], 6));
292
-				if(!file_exists($file_name)) {
293
-					$widget_output = $file_name . ' does not exist';
290
+			if (substr($params['output'], 0, 5) == "@FILE") {
291
+				$file_name = MODX_BASE_PATH.trim(substr($params['output'], 6));
292
+				if (!file_exists($file_name)) {
293
+					$widget_output = $file_name.' does not exist';
294 294
 				} else {
295 295
 					$widget_output = file_get_contents($file_name);
296 296
 				}
297
-			} elseif(substr($params['output'], 0, 8) == '@INCLUDE') {
298
-				$file_name = MODX_BASE_PATH . trim(substr($params['output'], 9));
299
-				if(!file_exists($file_name)) {
300
-					$widget_output = $file_name . ' does not exist';
297
+			} elseif (substr($params['output'], 0, 8) == '@INCLUDE') {
298
+				$file_name = MODX_BASE_PATH.trim(substr($params['output'], 9));
299
+				if (!file_exists($file_name)) {
300
+					$widget_output = $file_name.' does not exist';
301 301
 				} else {
302 302
 					/* The included file needs to set $widget_output. Can be string, array, object */
303 303
 					include $file_name;
304 304
 				}
305
-			} elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') {
305
+			} elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') {
306 306
 				$chunk_name = trim(substr($params['output'], 7));
307 307
 				$widget_output = $modx->getChunk($chunk_name);
308
-			} elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') {
308
+			} elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') {
309 309
 				$eval_str = trim(substr($params['output'], 6));
310 310
 				$widget_output = eval($eval_str);
311
-			} elseif($value !== '') {
311
+			} elseif ($value !== '') {
312 312
 				$widget_output = $params['output'];
313 313
 			} else {
314 314
 				$widget_output = '';
315 315
 			}
316
-			if(is_string($widget_output)) {
316
+			if (is_string($widget_output)) {
317 317
 				$_ = $modx->config['enable_filter'];
318 318
 				$modx->config['enable_filter'] = 1;
319 319
 				$widget_output = $modx->parseText($widget_output, array('value' => $value));
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 
327 327
 		default:
328 328
 			$value = parseInput($value);
329
-			if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
329
+			if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
330 330
 				// add separator
331 331
 				$value = explode('||', $value);
332 332
 				$value = implode($sep, $value);
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
  * @param string $s
342 342
  * @return string
343 343
  */
344
-function decodeParamValue($s) {
344
+function decodeParamValue($s){
345 345
 	$s = str_replace("%3D", '=', $s); // =
346 346
 	return str_replace("%26", '&', $s); // &
347 347
 }
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
  * @param bool $columns
356 356
  * @return array|string
357 357
  */
358
-function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array
358
+function parseInput($src, $delim = "||", $type = "string", $columns = true){ // type can be: string, array
359 359
     $modx = DocumentParser::getInstance();
360
-	if($modx->db->isResult($src)) {
360
+	if ($modx->db->isResult($src)) {
361 361
 		// must be a recordset
362 362
 		$rows = array();
363
-		while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols);
363
+		while ($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols);
364 364
 		return ($type == "array") ? $rows : implode($delim, $rows);
365 365
 	} else {
366 366
 		// must be a text
367
-		if($type == "array") {
367
+		if ($type == "array") {
368 368
 			return explode($delim, $src);
369 369
 		} else {
370 370
 			return $src;
@@ -376,21 +376,21 @@  discard block
 block discarded – undo
376 376
  * @param string $value
377 377
  * @return bool|false|int
378 378
  */
379
-function getUnixtimeFromDateString($value) {
379
+function getUnixtimeFromDateString($value){
380 380
 	$timestamp = false;
381 381
 	// Check for MySQL or legacy style date
382 382
 	$date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
383 383
 	$date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
384 384
 	$matches = array();
385
-	if(strpos($value, '-') !== false) {
386
-		if(preg_match($date_match_1, $value, $matches)) {
385
+	if (strpos($value, '-') !== false) {
386
+		if (preg_match($date_match_1, $value, $matches)) {
387 387
 			$timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
388
-		} elseif(preg_match($date_match_2, $value, $matches)) {
388
+		} elseif (preg_match($date_match_2, $value, $matches)) {
389 389
 			$timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
390 390
 		}
391 391
 	}
392 392
 	// If those didn't work, use strtotime to figure out the date
393
-	if($timestamp === false || $timestamp === -1) {
393
+	if ($timestamp === false || $timestamp === -1) {
394 394
 		$timestamp = strtotime($value);
395 395
 	}
396 396
 	return $timestamp;
Please login to merge, or discard this patch.
Braces   +21 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
  * @param string $sep
16 16
  * @return mixed|string
17 17
  */
18
-function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') {
18
+function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '')
19
+{
19 20
 
20 21
     $modx = DocumentParser::getInstance();
21 22
     $o = '';
@@ -59,7 +60,9 @@  discard block
 block discarded – undo
59 60
 					if(isset($params['align']) && $params['align'] != 'none') {
60 61
 						$attr['align'] = $params['align'];
61 62
 					}
62
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
63
+					foreach($attr as $k => $v) {
64
+					    $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
65
+					}
63 66
 					$attributes .= ' ' . $params['attrib'];
64 67
 
65 68
 					// Output the image with attributes
@@ -128,7 +131,9 @@  discard block
 block discarded – undo
128 131
 						'style' => $params['style'],
129 132
 						'target' => $params['target'],
130 133
 					);
131
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
134
+					foreach($attr as $k => $v) {
135
+					    $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
136
+					}
132 137
 					$attributes .= ' ' . $params['attrib']; // add extra
133 138
 
134 139
 					// Output the link
@@ -157,7 +162,9 @@  discard block
 block discarded – undo
157 162
 					'class' => $params['class'],
158 163
 					'style' => $params['style'],
159 164
 				);
160
-				foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
165
+				foreach($attr as $k => $v) {
166
+				    $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
167
+				}
161 168
 				$attributes .= ' ' . $params['attrib']; // add extra
162 169
 
163 170
 				// Output the HTML Tag
@@ -341,7 +348,8 @@  discard block
 block discarded – undo
341 348
  * @param string $s
342 349
  * @return string
343 350
  */
344
-function decodeParamValue($s) {
351
+function decodeParamValue($s)
352
+{
345 353
 	$s = str_replace("%3D", '=', $s); // =
346 354
 	return str_replace("%26", '&', $s); // &
347 355
 }
@@ -355,12 +363,16 @@  discard block
 block discarded – undo
355 363
  * @param bool $columns
356 364
  * @return array|string
357 365
  */
358
-function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array
366
+function parseInput($src, $delim = "||", $type = "string", $columns = true)
367
+{
368
+// type can be: string, array
359 369
     $modx = DocumentParser::getInstance();
360 370
 	if($modx->db->isResult($src)) {
361 371
 		// must be a recordset
362 372
 		$rows = array();
363
-		while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols);
373
+		while($cols = $modx->db->getRow($src, 'num')) {
374
+		    $rows[] = ($columns) ? $cols : implode(" ", $cols);
375
+		}
364 376
 		return ($type == "array") ? $rows : implode($delim, $rows);
365 377
 	} else {
366 378
 		// must be a text
@@ -376,7 +388,8 @@  discard block
 block discarded – undo
376 388
  * @param string $value
377 389
  * @return bool|false|int
378 390
  */
379
-function getUnixtimeFromDateString($value) {
391
+function getUnixtimeFromDateString($value)
392
+{
380 393
 	$timestamp = false;
381 394
 	// Check for MySQL or legacy style date
382 395
 	$date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
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 = DocumentParser::getInstance();
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 = DocumentParser::getInstance();
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 = DocumentParser::getInstance();
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 = DocumentParser::getInstance();
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 = DocumentParser::getInstance();
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 = DocumentParser::getInstance();
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/config_check.inc.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  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 6
 // PROCESSOR FIRST
7
-if($_SESSION['mgrRole'] == 1) {
8
-	if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) {
7
+if ($_SESSION['mgrRole'] == 1) {
8
+	if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) {
9 9
 		$current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']);
10
-		if(!empty($current)) {
10
+		if (!empty($current)) {
11 11
 			$modx->manager->setSystemChecksum($current);
12 12
 			$modx->clearCache('full');
13 13
 			$modx->config['sys_files_checksum'] = $current;
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
 $warningspresent = 0;
20 20
 
21 21
 $sysfiles_check = $modx->manager->checkSystemChecksum();
22
-if ($sysfiles_check!=='0'){
22
+if ($sysfiles_check !== '0') {
23 23
       $warningspresent = 1;
24 24
       $warnings[] = array($_lang['configcheck_sysfiles_mod']);
25 25
 }
26 26
 
27
-if (is_writable("includes/config.inc.php")){
27
+if (is_writable("includes/config.inc.php")) {
28 28
     // Warn if world writable
29
-    if(@fileperms('includes/config.inc.php') & 0x0002) {
29
+    if (@fileperms('includes/config.inc.php') & 0x0002) {
30 30
       $warningspresent = 1;
31 31
       $warnings[] = array($_lang['configcheck_configinc']);
32 32
     }
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     $warnings[] = array($_lang['configcheck_php_gdzip']);
43 43
 }
44 44
 
45
-if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') {
46
-    if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') {
45
+if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') {
46
+    if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') {
47 47
         if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) {
48 48
             $warningspresent = 1;
49 49
             $warnings[] = array($_lang['configcheck_validate_referer']);
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 }
53 53
 
54 54
 // check for Template Switcher plugin
55
-if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') {
56
-    if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') {
55
+if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') {
56
+    if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') {
57 57
         $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'");
58 58
         $row = $modx->db->getRow($rs);
59
-        if($row && $row['disabled'] == 0) {
59
+        if ($row && $row['disabled'] == 0) {
60 60
             $warningspresent = 1;
61 61
             $warnings[] = array($_lang['configcheck_templateswitcher_present']);
62 62
             $tplName = $row['name'];
@@ -120,36 +120,36 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @return bool
122 122
      */
123
-    function checkSiteCache() {
123
+    function checkSiteCache(){
124 124
         $modx = DocumentParser::getInstance();
125
-        $checked= true;
126
-        if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) {
127
-            $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php');
125
+        $checked = true;
126
+        if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) {
127
+            $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php');
128 128
         }
129 129
         return $checked;
130 130
     }
131 131
 }
132 132
 
133
-if (!is_writable(MODX_BASE_PATH . "assets/cache/")) {
133
+if (!is_writable(MODX_BASE_PATH."assets/cache/")) {
134 134
     $warningspresent = 1;
135 135
     $warnings[] = array($_lang['configcheck_cache']);
136 136
 }
137 137
 
138 138
 if (!checkSiteCache()) {
139 139
     $warningspresent = 1;
140
-    $warnings[]= array($lang['configcheck_sitecache_integrity']);
140
+    $warnings[] = array($lang['configcheck_sitecache_integrity']);
141 141
 }
142 142
 
143
-if (!is_writable(MODX_BASE_PATH . "assets/images/")) {
143
+if (!is_writable(MODX_BASE_PATH."assets/images/")) {
144 144
     $warningspresent = 1;
145 145
     $warnings[] = array($_lang['configcheck_images']);
146 146
 }
147 147
 
148
-if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) {
148
+if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) {
149 149
     $warningspresent = 1;
150 150
     $warnings[] = array($_lang['configcheck_rb_base_dir']);
151 151
 }
152
-if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) {
152
+if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) {
153 153
     $warningspresent = 1;
154 154
     $warnings[] = array($_lang['configcheck_filemanager_path']);
155 155
 }
@@ -157,36 +157,36 @@  discard block
 block discarded – undo
157 157
 // clear file info cache
158 158
 clearstatcache();
159 159
 
160
-if ($warningspresent==1) {
160
+if ($warningspresent == 1) {
161 161
 
162
-if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3';
162
+if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3';
163 163
 $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>";
164 164
 
165
-for ($i=0;$i<count($warnings);$i++) {
165
+for ($i = 0; $i < count($warnings); $i++) {
166 166
     switch ($warnings[$i][0]) {
167 167
         case $_lang['configcheck_configinc'];
168 168
             $warnings[$i][1] = $_lang['configcheck_configinc_msg'];
169
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
169
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']);
170 170
             break;
171 171
         case $_lang['configcheck_installer'] :
172 172
             $warnings[$i][1] = $_lang['configcheck_installer_msg'];
173
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
173
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']);
174 174
             break;
175 175
         case $_lang['configcheck_cache'] :
176 176
             $warnings[$i][1] = $_lang['configcheck_cache_msg'];
177
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
177
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']);
178 178
             break;
179 179
         case $_lang['configcheck_images'] :
180 180
             $warnings[$i][1] = $_lang['configcheck_images_msg'];
181
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
181
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']);
182 182
             break;
183 183
         case $_lang['configcheck_sysfiles_mod']:
184 184
             $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"];
185
-			$warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>';
186
-			if($modx->hasPermission('settings')) {
187
-				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>';
185
+			$warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>';
186
+			if ($modx->hasPermission('settings')) {
187
+				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>';
188 188
 			}
189
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
189
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']);
190 190
             break;
191 191
         case $_lang['configcheck_lang_difference'] :
192 192
             $warnings[$i][1] = $_lang['configcheck_lang_difference_msg'];
@@ -208,18 +208,18 @@  discard block
 block discarded – undo
208 208
             break;
209 209
         case $_lang['configcheck_validate_referer'] :
210 210
             $msg = $_lang['configcheck_validate_referer_msg'];
211
-            $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer');
211
+            $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer');
212 212
             $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n";
213 213
             break;
214 214
         case $_lang['configcheck_templateswitcher_present'] :
215 215
             $msg = $_lang["configcheck_templateswitcher_present_msg"];
216
-            if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') {
217
-                $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"];
216
+            if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') {
217
+                $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"];
218 218
             }
219
-            if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') {
220
-                $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"];
219
+            if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') {
220
+                $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"];
221 221
             }
222
-            $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present');
222
+            $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present');
223 223
             $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n";
224 224
             break;
225 225
         case $_lang['configcheck_rb_base_dir'] :
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
             $warnings[$i][1] = $_lang['configcheck_default_msg'];
233 233
     }
234 234
 
235
-    $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ;
235
+    $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : "";
236 236
     $config_check_results .= "
237 237
             <fieldset>
238 238
             <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p>
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
             ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')."
242 242
             </fieldset>
243 243
 ";
244
-        if ($i!=count($warnings)-1) {
244
+        if ($i != count($warnings) - 1) {
245 245
             $config_check_results .= "<br />";
246 246
         }
247 247
     }
248
-    $_SESSION["mgrConfigCheck"]=true;
248
+    $_SESSION["mgrConfigCheck"] = true;
249 249
 } else {
250 250
     $config_check_results = $_lang['configcheck_ok'];
251 251
 }
Please login to merge, or discard this patch.
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 $warningspresent = 0;
20 20
 
21 21
 $sysfiles_check = $modx->manager->checkSystemChecksum();
22
-if ($sysfiles_check!=='0'){
22
+if ($sysfiles_check!=='0') {
23 23
       $warningspresent = 1;
24 24
       $warnings[] = array($_lang['configcheck_sysfiles_mod']);
25 25
 }
26 26
 
27
-if (is_writable("includes/config.inc.php")){
27
+if (is_writable("includes/config.inc.php")) {
28 28
     // Warn if world writable
29 29
     if(@fileperms('includes/config.inc.php') & 0x0002) {
30 30
       $warningspresent = 1;
@@ -120,7 +120,8 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @return bool
122 122
      */
123
-    function checkSiteCache() {
123
+    function checkSiteCache()
124
+    {
124 125
         $modx = DocumentParser::getInstance();
125 126
         $checked= true;
126 127
         if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) {
@@ -159,26 +160,36 @@  discard block
 block discarded – undo
159 160
 
160 161
 if ($warningspresent==1) {
161 162
 
162
-if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3';
163
+if(!isset($modx->config['send_errormail'])) {
164
+    $modx->config['send_errormail']='3';
165
+}
163 166
 $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>";
164 167
 
165 168
 for ($i=0;$i<count($warnings);$i++) {
166 169
     switch ($warnings[$i][0]) {
167 170
         case $_lang['configcheck_configinc'];
168 171
             $warnings[$i][1] = $_lang['configcheck_configinc_msg'];
169
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
172
+            if(!$_SESSION["mgrConfigCheck"]) {
173
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
174
+            }
170 175
             break;
171 176
         case $_lang['configcheck_installer'] :
172 177
             $warnings[$i][1] = $_lang['configcheck_installer_msg'];
173
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
178
+            if(!$_SESSION["mgrConfigCheck"]) {
179
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
180
+            }
174 181
             break;
175 182
         case $_lang['configcheck_cache'] :
176 183
             $warnings[$i][1] = $_lang['configcheck_cache_msg'];
177
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
184
+            if(!$_SESSION["mgrConfigCheck"]) {
185
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
186
+            }
178 187
             break;
179 188
         case $_lang['configcheck_images'] :
180 189
             $warnings[$i][1] = $_lang['configcheck_images_msg'];
181
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
190
+            if(!$_SESSION["mgrConfigCheck"]) {
191
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
192
+            }
182 193
             break;
183 194
         case $_lang['configcheck_sysfiles_mod']:
184 195
             $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"];
@@ -186,7 +197,9 @@  discard block
 block discarded – undo
186 197
 			if($modx->hasPermission('settings')) {
187 198
 				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>';
188 199
 			}
189
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
200
+            if(!$_SESSION["mgrConfigCheck"]) {
201
+                $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
202
+            }
190 203
             break;
191 204
         case $_lang['configcheck_lang_difference'] :
192 205
             $warnings[$i][1] = $_lang['configcheck_lang_difference_msg'];
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/uploader.php 3 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Uploader class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Uploader class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class uploader {
16 16
 
@@ -18,92 +18,92 @@  discard block
 block discarded – undo
18 18
     const VERSION = "2.54";
19 19
 
20 20
 /** Config session-overrided settings
21
-  * @var array */
21
+ * @var array */
22 22
     protected $config = array();
23 23
 
24 24
 /** Default image driver
25
-  * @var string */
25
+ * @var string */
26 26
     protected $imageDriver = "gd";
27 27
 
28 28
 /** Opener applocation properties
29
-  *   $opener['name']                 Got from $_GET['opener'];
30
-  *   $opener['CKEditor']['funcNum']  CKEditor function number (got from $_GET)
31
-  *   $opener['TinyMCE']              Boolean
32
-  * @var array */
29
+ *   $opener['name']                 Got from $_GET['opener'];
30
+ *   $opener['CKEditor']['funcNum']  CKEditor function number (got from $_GET)
31
+ *   $opener['TinyMCE']              Boolean
32
+ * @var array */
33 33
     protected $opener = array();
34 34
 
35 35
 /** Got from $_GET['type'] or first one $config['types'] array key, if inexistant
36
-  * @var string */
36
+ * @var string */
37 37
     protected $type;
38 38
 
39 39
 /** Helper property. Local filesystem path to the Type Directory
40
-  * Equivalent: $config['uploadDir'] . "/" . $type
41
-  * @var string */
40
+ * Equivalent: $config['uploadDir'] . "/" . $type
41
+ * @var string */
42 42
     protected $typeDir;
43 43
 
44 44
 /** Helper property. Web URL to the Type Directory
45
-  * Equivalent: $config['uploadURL'] . "/" . $type
46
-  * @var string */
45
+ * Equivalent: $config['uploadURL'] . "/" . $type
46
+ * @var string */
47 47
     protected $typeURL;
48 48
 
49 49
 /** Linked to $config['types']
50
-  * @var array */
50
+ * @var array */
51 51
     protected $types = array();
52 52
 
53 53
 /** Settings which can override default settings if exists as keys in $config['types'][$type] array
54
-  * @var array */
54
+ * @var array */
55 55
     protected $typeSettings = array('disabled', 'theme', 'dirPerms', 'filePerms', 'denyZipDownload', 'maxImageWidth', 'maxImageHeight', 'thumbWidth', 'thumbHeight', 'jpegQuality', 'access', 'filenameChangeChars', 'dirnameChangeChars', 'denyExtensionRename', 'deniedExts', 'watermark');
56 56
 
57 57
 /** Got from language file
58
-  * @var string */
58
+ * @var string */
59 59
     protected $charset;
60 60
 
61 61
 /** The language got from $_GET['lng'] or $_GET['lang'] or... Please see next property
62
-  * @var string */
62
+ * @var string */
63 63
     protected $lang = 'en';
64 64
 
65 65
 /** Possible language $_GET keys
66
-  * @var array */
66
+ * @var array */
67 67
     protected $langInputNames = array('lang', 'langCode', 'lng', 'language', 'lang_code');
68 68
 
69 69
 /** Uploaded file(s) info. Linked to first $_FILES element
70
-  * @var array */
70
+ * @var array */
71 71
     protected $file;
72 72
 
73 73
 /** Next three properties are got from the current language file
74
-  * @var string */
74
+ * @var string */
75 75
     protected $dateTimeFull;   // Currently not used
76 76
     protected $dateTimeMid;    // Currently not used
77 77
     protected $dateTimeSmall;
78 78
 
79 79
 /** Contain Specified language labels
80
-  * @var array */
80
+ * @var array */
81 81
     protected $labels = array();
82 82
 
83 83
 /** Contain unprocessed $_GET array. Please use this instead of $_GET
84
-  * @var array */
84
+ * @var array */
85 85
     protected $get;
86 86
 
87 87
 /** Contain unprocessed $_POST array. Please use this instead of $_POST
88
-  * @var array */
88
+ * @var array */
89 89
     protected $post;
90 90
 
91 91
 /** Contain unprocessed $_COOKIE array. Please use this instead of $_COOKIE
92
-  * @var array */
92
+ * @var array */
93 93
     protected $cookie;
94 94
 
95 95
 /** Session array. Please use this property instead of $_SESSION
96
-  * @var array */
96
+ * @var array */
97 97
     protected $session;
98 98
 
99 99
 /** CMS integration attribute (got from $_GET['cms'])
100
-  * @var string */
100
+ * @var string */
101 101
     protected $cms = "";
102 102
 
103 103
     protected $modx = null;
104 104
 /** Magic method which allows read-only access to protected or private class properties
105
-  * @param string $property
106
-  * @return mixed */
105
+     * @param string $property
106
+     * @return mixed */
107 107
     public function __get($property) {
108 108
         return property_exists($this, $property) ? $this->$property : null;
109 109
     }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         )
133 133
             $this->cms = $this->get['cms'];
134 134
 
135
-		// LINKING UPLOADED FILE
135
+        // LINKING UPLOADED FILE
136 136
         if (count($_FILES))
137 137
             $this->file = &$_FILES[key($_FILES)];
138 138
 
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
             $this->config['uploadDir'] = strlen($this->config['uploadDir'])
229 229
                 ? path::normalize($this->config['uploadDir'])
230 230
                 : path::url2fullPath("/$path");
231
-         $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
232
-         $this->typeURL = "{$this->config['siteURL']}/{$this->config['uploadURL']}/{$this->type}";
231
+            $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
232
+            $this->typeURL = "{$this->config['siteURL']}/{$this->config['uploadURL']}/{$this->type}";
233 233
 
234 234
         // SITE ROOT
235 235
         } elseif ($this->config['uploadURL'] == "/") {
@@ -365,36 +365,36 @@  discard block
 block discarded – undo
365 365
     }
366 366
 
367 367
 
368
-	protected function getTransaliasSettings() {
369
-		$modx = DocumentParser::getInstance();
370
-
371
-		// Cleaning uploaded filename?
372
-		$setting = $modx->db->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1');
373
-		if ($modx->db->getValue($setting)>0) {
374
-			// Transalias plugin active?
375
-			$res = $modx->db->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0');
376
-			if ($properties = $modx->db->getValue($res)) {
377
-				$properties = $modx->parseProperties($properties, 'TransAlias', 'plugin');
378
-			} else {
379
-				$properties = NULL;
380
-			}
381
-		} else {
382
-			$properties = NULL;
383
-		}
384
-		return $properties;
385
-	}
386
-
387
-
388
-	protected function normalizeFilename($filename) {
389
-		if ($this->getTransaliasSettings()) {
390
-        		$format = strrchr($filename, ".");
391
-        		$filename = str_replace($format, "", $filename);
392
-            		$filename = $this->modx->stripAlias($filename).$format;
393
-        	}
394
-        	return $filename;
395
-	}
396
-
397
-	protected function normalizeDirname($dirname) {
368
+    protected function getTransaliasSettings() {
369
+        $modx = DocumentParser::getInstance();
370
+
371
+        // Cleaning uploaded filename?
372
+        $setting = $modx->db->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1');
373
+        if ($modx->db->getValue($setting)>0) {
374
+            // Transalias plugin active?
375
+            $res = $modx->db->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0');
376
+            if ($properties = $modx->db->getValue($res)) {
377
+                $properties = $modx->parseProperties($properties, 'TransAlias', 'plugin');
378
+            } else {
379
+                $properties = NULL;
380
+            }
381
+        } else {
382
+            $properties = NULL;
383
+        }
384
+        return $properties;
385
+    }
386
+
387
+
388
+    protected function normalizeFilename($filename) {
389
+        if ($this->getTransaliasSettings()) {
390
+                $format = strrchr($filename, ".");
391
+                $filename = str_replace($format, "", $filename);
392
+                    $filename = $this->modx->stripAlias($filename).$format;
393
+            }
394
+            return $filename;
395
+    }
396
+
397
+    protected function normalizeDirname($dirname) {
398 398
         return $this->modx->stripAlias($dirname);
399 399
     }
400 400
 
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
             return $this->label("The image is too big and/or cannot be resized.");
473 473
 
474 474
 
475
-	// CHECK FOR MODX MAX FILE SIZE
476
-	$actualfilesize=filesize($file['tmp_name']);
477
-	if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478
-	    return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
475
+    // CHECK FOR MODX MAX FILE SIZE
476
+    $actualfilesize=filesize($file['tmp_name']);
477
+    if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478
+        return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
479 479
 
480 480
         return true;
481 481
     }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             $top = isset($this->config['watermark']['top'])
628 628
                 ? $this->config['watermark']['top'] : false;
629 629
             $img->watermark($this->config['watermark']['file'], $left, $top);
630
-		}
630
+        }
631 631
 
632 632
         $options = array( 'file' => $file );
633 633
 
Please login to merge, or discard this patch.
Spacing   +46 added lines, -47 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class uploader {
15
+class uploader{
16 16
 
17 17
 /** Release version */
18 18
     const VERSION = "2.54";
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 
73 73
 /** Next three properties are got from the current language file
74 74
   * @var string */
75
-    protected $dateTimeFull;   // Currently not used
76
-    protected $dateTimeMid;    // Currently not used
75
+    protected $dateTimeFull; // Currently not used
76
+    protected $dateTimeMid; // Currently not used
77 77
     protected $dateTimeSmall;
78 78
 
79 79
 /** Contain Specified language labels
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 /** Magic method which allows read-only access to protected or private class properties
105 105
   * @param string $property
106 106
   * @return mixed */
107
-    public function __get($property) {
107
+    public function __get($property){
108 108
         return property_exists($this, $property) ? $this->$property : null;
109 109
     }
110 110
 
111
-    public function __construct($modx) {
111
+    public function __construct($modx){
112 112
 
113 113
         //MODX
114 114
         try {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
         // COOKIES INIT
208 208
         $ip = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
209
-        $ip = '/^' . implode('\.', array($ip, $ip, $ip, $ip)) . '$/';
209
+        $ip = '/^'.implode('\.', array($ip, $ip, $ip, $ip)).'$/';
210 210
         if (preg_match($ip, $_SERVER['HTTP_HOST']) ||
211 211
             preg_match('/^[^\.]+$/', $_SERVER['HTTP_HOST'])
212 212
         )
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
         ) {
225 225
             list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
226 226
             $path = path::normalize($path);
227
-            $this->config['uploadURL'] = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/$path";
227
+            $this->config['uploadURL'] = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/$path";
228 228
             $this->config['uploadDir'] = strlen($this->config['uploadDir'])
229 229
                 ? path::normalize($this->config['uploadDir'])
230 230
                 : path::url2fullPath("/$path");
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         foreach ($this->langInputNames as $key)
268 268
             if (isset($this->get[$key]) &&
269 269
                 preg_match('/^[a-z][a-z\._\-]*$/i', $this->get[$key]) &&
270
-                file_exists("lang/" . strtolower($this->get[$key]) . ".php")
270
+                file_exists("lang/".strtolower($this->get[$key]).".php")
271 271
             ) {
272 272
                 $this->lang = $this->get[$key];
273 273
                 break;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
             $this->backMsg("Cannot read upload folder.");
299 299
     }
300 300
 
301
-    public function upload() {
301
+    public function upload(){
302 302
         $config = &$this->config;
303 303
         $file = &$this->file;
304 304
         $url = $message = "";
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                     @mkdir(path::normalize($dir), $this->config['dirPerms'], true);
330 330
 
331 331
                 $filename = $this->normalizeFilename($file['name']);
332
-                $target = file::getInexistantFilename($dir . $filename);
332
+                $target = file::getInexistantFilename($dir.$filename);
333 333
 
334 334
                 if (!@move_uploaded_file($file['tmp_name'], $target) &&
335 335
                     !@rename($file['tmp_name'], $target) &&
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
                     $this->makeThumb($target);
343 343
                     $url = $this->typeURL;
344 344
                     if (isset($udir)) $url .= "/$udir";
345
-                    $url .= "/" . basename($target);
345
+                    $url .= "/".basename($target);
346 346
                     if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)$/', $url, $patt)) {
347 347
                         list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
348
-                        $base = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/";
349
-                        $url = $base . path::urlPathEncode($path);
348
+                        $base = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/";
349
+                        $url = $base.path::urlPathEncode($path);
350 350
                     } else
351 351
                         $url = path::urlPathEncode($url);
352 352
                 }
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
     }
366 366
 
367 367
 
368
-	protected function getTransaliasSettings() {
368
+	protected function getTransaliasSettings(){
369 369
 		$modx = DocumentParser::getInstance();
370 370
 
371 371
 		// Cleaning uploaded filename?
372 372
 		$setting = $modx->db->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1');
373
-		if ($modx->db->getValue($setting)>0) {
373
+		if ($modx->db->getValue($setting) > 0) {
374 374
 			// Transalias plugin active?
375 375
 			$res = $modx->db->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0');
376 376
 			if ($properties = $modx->db->getValue($res)) {
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	}
386 386
 
387 387
 
388
-	protected function normalizeFilename($filename) {
388
+	protected function normalizeFilename($filename){
389 389
 		if ($this->getTransaliasSettings()) {
390 390
         		$format = strrchr($filename, ".");
391 391
         		$filename = str_replace($format, "", $filename);
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
         	return $filename;
395 395
 	}
396 396
 
397
-	protected function normalizeDirname($dirname) {
397
+	protected function normalizeDirname($dirname){
398 398
         return $this->modx->stripAlias($dirname);
399 399
     }
400 400
 
401
-    protected function checkUploadedFile(array $aFile=null) {
401
+    protected function checkUploadedFile(array $aFile = null){
402 402
         $config = &$this->config;
403 403
         $file = ($aFile === null) ? $this->file : $aFile;
404 404
 
@@ -437,8 +437,7 @@  discard block
 block discarded – undo
437 437
                 ($file['error'] == UPLOAD_ERR_NO_TMP_DIR) ?
438 438
                     $this->label("Missing a temporary folder.") : (
439 439
                 ($file['error'] == UPLOAD_ERR_CANT_WRITE) ?
440
-                    $this->label("Failed to write file.") :
441
-                    $this->label("Unknown error.")
440
+                    $this->label("Failed to write file.") : $this->label("Unknown error.")
442 441
             )))));
443 442
 
444 443
         // HIDDEN FILENAMES CHECK
@@ -473,14 +472,14 @@  discard block
 block discarded – undo
473 472
 
474 473
 
475 474
 	// CHECK FOR MODX MAX FILE SIZE
476
-	$actualfilesize=filesize($file['tmp_name']);
475
+	$actualfilesize = filesize($file['tmp_name']);
477 476
 	if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478 477
 	    return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
479 478
 
480 479
         return true;
481 480
     }
482 481
 
483
-    protected function checkInputDir($dir, $inclType=true, $existing=true) {
482
+    protected function checkInputDir($dir, $inclType = true, $existing = true){
484 483
         $dir = path::normalize($dir);
485 484
         if (substr($dir, 0, 1) == "/")
486 485
             $dir = substr($dir, 1);
@@ -506,7 +505,7 @@  discard block
 block discarded – undo
506 505
         return (is_dir($path) && is_readable($path)) ? $return : false;
507 506
     }
508 507
 
509
-    protected function validateExtension($ext, $type) {
508
+    protected function validateExtension($ext, $type){
510 509
         $ext = trim(strtolower($ext));
511 510
         if (!isset($this->types[$type]))
512 511
             return false;
@@ -531,17 +530,17 @@  discard block
 block discarded – undo
531 530
         return in_array($ext, $exts);
532 531
     }
533 532
 
534
-    protected function getTypeFromPath($path) {
533
+    protected function getTypeFromPath($path){
535 534
         return preg_match('/^([^\/]*)\/.*$/', $path, $patt)
536 535
             ? $patt[1] : $path;
537 536
     }
538 537
 
539
-    protected function removeTypeFromPath($path) {
538
+    protected function removeTypeFromPath($path){
540 539
         return preg_match('/^[^\/]*\/(.*)$/', $path, $patt)
541 540
             ? $patt[1] : "";
542 541
     }
543 542
 
544
-    protected function imageResize($image, $file=null) {
543
+    protected function imageResize($image, $file = null){
545 544
 
546 545
         if (!($image instanceof image)) {
547 546
             $img = image::factory($this->imageDriver, $image);
@@ -629,24 +628,24 @@  discard block
 block discarded – undo
629 628
             $img->watermark($this->config['watermark']['file'], $left, $top);
630 629
 		}
631 630
 
632
-        $options = array( 'file' => $file );
631
+        $options = array('file' => $file);
633 632
 
634
-        $type = exif_imagetype( $file );
633
+        $type = exif_imagetype($file);
635 634
 
636
-        switch ( $type ) {
635
+        switch ($type) {
637 636
             case IMAGETYPE_GIF:
638
-                return $img->output( 'gif', $options );
637
+                return $img->output('gif', $options);
639 638
 
640 639
             case IMAGETYPE_PNG:
641
-                return $img->output( 'png', $options );
640
+                return $img->output('png', $options);
642 641
 
643 642
             default:
644
-                return $img->output( 'jpeg', array_merge( $options, array( 'quality' => $this->config['jpegQuality'] ) ) );
643
+                return $img->output('jpeg', array_merge($options, array('quality' => $this->config['jpegQuality'])));
645 644
         }
646 645
 
647 646
     }
648 647
 
649
-    protected function makeThumb($file, $overwrite=true) {
648
+    protected function makeThumb($file, $overwrite = true){
650 649
         $img = image::factory($this->imageDriver, $file);
651 650
 
652 651
         // Drop files which are not images
@@ -654,7 +653,7 @@  discard block
 block discarded – undo
654 653
             return true;
655 654
 
656 655
         $thumb = substr($file, strlen($this->config['uploadDir']));
657
-        $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb;
656
+        $thumb = $this->config['uploadDir']."/".$this->config['thumbsDir']."/".$thumb;
658 657
         $thumb = path::normalize($thumb);
659 658
         $thumbDir = dirname($thumb);
660 659
         if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true))
@@ -677,15 +676,15 @@  discard block
 block discarded – undo
677 676
         if (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight']))
678 677
             return false;
679 678
 
680
-        if ( $this->imageDriver == 'gd' ) {
681
-            $width  = imagesx( $img->image );
682
-            $height = imagesy( $img->image );
683
-            $back   = image::factory( $this->imageDriver, array( $width, $height ) );
684
-            $tile   = image::factory( $this->imageDriver, __DIR__ . '/../themes/' . $this->config['theme'] . '/img/bg_transparent.png' );
679
+        if ($this->imageDriver == 'gd') {
680
+            $width  = imagesx($img->image);
681
+            $height = imagesy($img->image);
682
+            $back   = image::factory($this->imageDriver, array($width, $height));
683
+            $tile   = image::factory($this->imageDriver, __DIR__.'/../themes/'.$this->config['theme'].'/img/bg_transparent.png');
685 684
 
686
-            imagesettile( $back->image, $tile->image );
687
-            imagefilledrectangle( $back->image, 0, 0, $width, $height, IMG_COLOR_TILED );
688
-            imagecopy( $back->image, $img->image, 0, 0, 0, 0, $width, $height );
685
+            imagesettile($back->image, $tile->image);
686
+            imagefilledrectangle($back->image, 0, 0, $width, $height, IMG_COLOR_TILED);
687
+            imagecopy($back->image, $img->image, 0, 0, 0, 0, $width, $height);
689 688
 
690 689
             $img = $back;
691 690
         }
@@ -697,7 +696,7 @@  discard block
 block discarded – undo
697 696
         ));
698 697
     }
699 698
 
700
-    protected function localize($langCode) {
699
+    protected function localize($langCode){
701 700
         require "lang/{$langCode}.php";
702 701
         setlocale(LC_ALL, $lang['_locale']);
703 702
         $this->charset = $lang['_charset'];
@@ -712,7 +711,7 @@  discard block
 block discarded – undo
712 711
         $this->labels = $lang;
713 712
     }
714 713
 
715
-    protected function label($string, array $data=null) {
714
+    protected function label($string, array $data = null){
716 715
         $return = isset($this->labels[$string]) ? $this->labels[$string] : $string;
717 716
         if (is_array($data))
718 717
             foreach ($data as $key => $val)
@@ -720,7 +719,7 @@  discard block
 block discarded – undo
720 719
         return $return;
721 720
     }
722 721
 
723
-    protected function backMsg($message, array $data=null) {
722
+    protected function backMsg($message, array $data = null){
724 723
         $message = $this->label($message, $data);
725 724
         if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name']))
726 725
             @unlink($this->file['tmp_name']);
@@ -728,7 +727,7 @@  discard block
 block discarded – undo
728 727
         die;
729 728
     }
730 729
 
731
-    protected function callBack($url, $message="") {
730
+    protected function callBack($url, $message = ""){
732 731
         $message = text::jsValue($message);
733 732
         $CKfuncNum = isset($this->opener['CKEditor']['funcNum'])
734 733
             ? $this->opener['CKEditor']['funcNum'] : 0;
@@ -769,7 +768,7 @@  discard block
 block discarded – undo
769 768
 
770 769
     }
771 770
 
772
-    protected function get_htaccess() {
771
+    protected function get_htaccess(){
773 772
         return "<IfModule mod_php4.c>
774 773
   php_value engine off
775 774
 </IfModule>
Please login to merge, or discard this patch.
Braces   +238 added lines, -149 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class uploader {
15
+class uploader
16
+{
16 17
 
17 18
 /** Release version */
18 19
     const VERSION = "2.54";
@@ -104,17 +105,21 @@  discard block
 block discarded – undo
104 105
 /** Magic method which allows read-only access to protected or private class properties
105 106
   * @param string $property
106 107
   * @return mixed */
107
-    public function __get($property) {
108
+    public function __get($property)
109
+    {
108 110
         return property_exists($this, $property) ? $this->$property : null;
109 111
     }
110 112
 
111
-    public function __construct($modx) {
113
+    public function __construct($modx)
114
+    {
112 115
 
113 116
         //MODX
114 117
         try {
115 118
             if ($modx instanceof DocumentParser) {
116 119
                 $this->modx = $modx;
117
-            } else throw new Exception('MODX should be instance of DocumentParser');
120
+            } else {
121
+                throw new Exception('MODX should be instance of DocumentParser');
122
+            }
118 123
         } catch (Exception $e) {
119 124
             die($e->getMessage());
120 125
         }
@@ -129,26 +134,34 @@  discard block
 block discarded – undo
129 134
         // SET CMS INTEGRATION ATTRIBUTE
130 135
         if (isset($this->get['cms']) &&
131 136
             in_array($this->get['cms'], array("drupal"))
132
-        )
133
-            $this->cms = $this->get['cms'];
137
+        ) {
138
+                    $this->cms = $this->get['cms'];
139
+        }
134 140
 
135 141
 		// LINKING UPLOADED FILE
136
-        if (count($_FILES))
137
-            $this->file = &$_FILES[key($_FILES)];
142
+        if (count($_FILES)) {
143
+                    $this->file = &$_FILES[key($_FILES)];
144
+        }
138 145
 
139 146
         // LOAD DEFAULT CONFIGURATION
140 147
         require "config.php";
141 148
 
142 149
         // SETTING UP SESSION
143
-        if (isset($_CONFIG['_sessionLifetime']))
144
-            ini_set('session.gc_maxlifetime', $_CONFIG['_sessionLifetime'] * 60);
145
-        if (isset($_CONFIG['_sessionDir']))
146
-            ini_set('session.save_path', $_CONFIG['_sessionDir']);
147
-        if (isset($_CONFIG['_sessionDomain']))
148
-            ini_set('session.cookie_domain', $_CONFIG['_sessionDomain']);
150
+        if (isset($_CONFIG['_sessionLifetime'])) {
151
+                    ini_set('session.gc_maxlifetime', $_CONFIG['_sessionLifetime'] * 60);
152
+        }
153
+        if (isset($_CONFIG['_sessionDir'])) {
154
+                    ini_set('session.save_path', $_CONFIG['_sessionDir']);
155
+        }
156
+        if (isset($_CONFIG['_sessionDomain'])) {
157
+                    ini_set('session.cookie_domain', $_CONFIG['_sessionDomain']);
158
+        }
149 159
         switch ($this->cms) {
150 160
             case "drupal": break;
151
-            default: if (!session_id()) session_start(); break;
161
+            default: if (!session_id()) {
162
+                session_start();
163
+            }
164
+            break;
152 165
         }
153 166
 
154 167
         // RELOAD DEFAULT CONFIGURATION
@@ -159,31 +172,37 @@  discard block
 block discarded – undo
159 172
         if (isset($_CONFIG['_sessionVar']) &&
160 173
             is_array($_CONFIG['_sessionVar'])
161 174
         ) {
162
-            foreach ($_CONFIG['_sessionVar'] as $key => $val)
163
-                if ((substr($key, 0, 1) != "_") && isset($_CONFIG[$key]))
175
+            foreach ($_CONFIG['_sessionVar'] as $key => $val) {
176
+                            if ((substr($key, 0, 1) != "_") && isset($_CONFIG[$key]))
164 177
                     $this->config[$key] = $val;
165
-            if (!isset($this->config['_sessionVar']['self']))
166
-                $this->config['_sessionVar']['self'] = array();
178
+            }
179
+            if (!isset($this->config['_sessionVar']['self'])) {
180
+                            $this->config['_sessionVar']['self'] = array();
181
+            }
167 182
             $this->session = &$this->config['_sessionVar']['self'];
168
-        } else
169
-            $this->session = &$_SESSION;
183
+        } else {
184
+                    $this->session = &$_SESSION;
185
+        }
170 186
 
171 187
         // IMAGE DRIVER INIT
172 188
         if (isset($this->config['imageDriversPriority'])) {
173 189
             $this->config['imageDriversPriority'] =
174 190
                 text::clearWhitespaces($this->config['imageDriversPriority']);
175 191
             $driver = image::getDriver(explode(' ', $this->config['imageDriversPriority']));
176
-            if ($driver !== false)
177
-                $this->imageDriver = $driver;
192
+            if ($driver !== false) {
193
+                            $this->imageDriver = $driver;
194
+            }
178 195
         }
179 196
         if ((!isset($driver) || ($driver === false)) &&
180 197
             (image::getDriver(array($this->imageDriver)) === false)
181
-        )
182
-            die("Cannot find any of the supported PHP image extensions!");
198
+        ) {
199
+                    die("Cannot find any of the supported PHP image extensions!");
200
+        }
183 201
 
184 202
         // WATERMARK INIT
185
-        if (isset($this->config['watermark']) && is_string($this->config['watermark']))
186
-            $this->config['watermark'] = array('file' => $this->config['watermark']);
203
+        if (isset($this->config['watermark']) && is_string($this->config['watermark'])) {
204
+                    $this->config['watermark'] = array('file' => $this->config['watermark']);
205
+        }
187 206
 
188 207
         // GET TYPE DIRECTORY
189 208
         $this->types = &$this->config['types'];
@@ -197,9 +216,10 @@  discard block
 block discarded – undo
197 216
 
198 217
         // LOAD TYPE DIRECTORY SPECIFIC CONFIGURATION IF EXISTS
199 218
         if (is_array($this->types[$this->type])) {
200
-            foreach ($this->types[$this->type] as $key => $val)
201
-                if (in_array($key, $this->typeSettings))
219
+            foreach ($this->types[$this->type] as $key => $val) {
220
+                            if (in_array($key, $this->typeSettings))
202 221
                     $this->config[$key] = $val;
222
+            }
203 223
             $this->types[$this->type] = isset($this->types[$this->type]['type'])
204 224
                 ? $this->types[$this->type]['type'] : "";
205 225
         }
@@ -209,12 +229,14 @@  discard block
 block discarded – undo
209 229
         $ip = '/^' . implode('\.', array($ip, $ip, $ip, $ip)) . '$/';
210 230
         if (preg_match($ip, $_SERVER['HTTP_HOST']) ||
211 231
             preg_match('/^[^\.]+$/', $_SERVER['HTTP_HOST'])
212
-        )
213
-            $this->config['cookieDomain'] = "";
214
-        elseif (!strlen($this->config['cookieDomain']))
215
-            $this->config['cookieDomain'] = $_SERVER['HTTP_HOST'];
216
-        if (!strlen($this->config['cookiePath']))
217
-            $this->config['cookiePath'] = "/";
232
+        ) {
233
+                    $this->config['cookieDomain'] = "";
234
+        } elseif (!strlen($this->config['cookieDomain'])) {
235
+                    $this->config['cookieDomain'] = $_SERVER['HTTP_HOST'];
236
+        }
237
+        if (!strlen($this->config['cookiePath'])) {
238
+                    $this->config['cookiePath'] = "/";
239
+        }
218 240
 
219 241
         // UPLOAD FOLDER INIT
220 242
 
@@ -250,26 +272,30 @@  discard block
 block discarded – undo
250 272
             $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
251 273
             $this->typeURL = "{$this->config['uploadURL']}/{$this->type}";
252 274
         }
253
-        if (!is_dir($this->config['uploadDir']))
254
-            @mkdir($this->config['uploadDir'], $this->config['dirPerms']);
275
+        if (!is_dir($this->config['uploadDir'])) {
276
+                    @mkdir($this->config['uploadDir'], $this->config['dirPerms']);
277
+        }
255 278
 
256 279
         // HOST APPLICATIONS INIT
257
-        if (isset($this->get['CKEditorFuncNum']))
258
-            $this->opener['CKEditor']['funcNum'] = $this->get['CKEditorFuncNum'];
280
+        if (isset($this->get['CKEditorFuncNum'])) {
281
+                    $this->opener['CKEditor']['funcNum'] = $this->get['CKEditorFuncNum'];
282
+        }
259 283
         if (isset($this->get['opener']) &&
260 284
             (strtolower($this->get['opener']) == "tinymce") &&
261 285
             isset($this->config['_tinyMCEPath']) &&
262 286
             strlen($this->config['_tinyMCEPath'])
263
-        )
264
-            $this->opener['TinyMCE'] = true;
287
+        ) {
288
+                    $this->opener['TinyMCE'] = true;
289
+        }
265 290
 
266 291
         // LOCALIZATION
267
-        foreach ($this->langInputNames as $key)
268
-            if (isset($this->get[$key]) &&
292
+        foreach ($this->langInputNames as $key) {
293
+                    if (isset($this->get[$key]) &&
269 294
                 preg_match('/^[a-z][a-z\._\-]*$/i', $this->get[$key]) &&
270 295
                 file_exists("lang/" . strtolower($this->get[$key]) . ".php")
271 296
             ) {
272 297
                 $this->lang = $this->get[$key];
298
+        }
273 299
                 break;
274 300
             }
275 301
         $this->localize($this->lang);
@@ -280,31 +306,39 @@  discard block
 block discarded – undo
280 306
         ) {
281 307
             $htaccess = "{$this->config['uploadDir']}/.htaccess";
282 308
             if (!file_exists($htaccess)) {
283
-                if (!@file_put_contents($htaccess, $this->get_htaccess()))
284
-                    $this->backMsg("Cannot write to upload folder. {$this->config['uploadDir']}");
309
+                if (!@file_put_contents($htaccess, $this->get_htaccess())) {
310
+                                    $this->backMsg("Cannot write to upload folder. {$this->config['uploadDir']}");
311
+                }
285 312
             } else {
286
-                if (false === ($data = @file_get_contents($htaccess)))
287
-                    $this->backMsg("Cannot read .htaccess");
288
-                if (($data != $this->get_htaccess()) && !@file_put_contents($htaccess, $data))
289
-                    $this->backMsg("Incorrect .htaccess file. Cannot rewrite it!");
313
+                if (false === ($data = @file_get_contents($htaccess))) {
314
+                                    $this->backMsg("Cannot read .htaccess");
315
+                }
316
+                if (($data != $this->get_htaccess()) && !@file_put_contents($htaccess, $data)) {
317
+                                    $this->backMsg("Incorrect .htaccess file. Cannot rewrite it!");
318
+                }
290 319
             }
291 320
         }
292 321
 
293 322
         // CHECK & CREATE UPLOAD FOLDER
294 323
         if (!is_dir($this->typeDir)) {
295
-            if (!mkdir($this->typeDir, $this->config['dirPerms']))
296
-                $this->backMsg("Cannot create {dir} folder.", array('dir' => $this->type));
297
-        } elseif (!is_readable($this->typeDir))
298
-            $this->backMsg("Cannot read upload folder.");
324
+            if (!mkdir($this->typeDir, $this->config['dirPerms'])) {
325
+                            $this->backMsg("Cannot create {dir} folder.", array('dir' => $this->type));
326
+            }
327
+        } elseif (!is_readable($this->typeDir)) {
328
+                    $this->backMsg("Cannot read upload folder.");
329
+        }
299 330
     }
300 331
 
301
-    public function upload() {
332
+    public function upload()
333
+    {
302 334
         $config = &$this->config;
303 335
         $file = &$this->file;
304 336
         $url = $message = "";
305 337
 
306 338
         if ($config['disabled'] || !$config['access']['files']['upload']) {
307
-            if (isset($file['tmp_name'])) @unlink($file['tmp_name']);
339
+            if (isset($file['tmp_name'])) {
340
+                @unlink($file['tmp_name']);
341
+            }
308 342
             $message = $this->label("You don't have permissions to upload files.");
309 343
 
310 344
         } elseif (true === ($message = $this->checkUploadedFile())) {
@@ -315,9 +349,9 @@  discard block
 block discarded – undo
315 349
                 (false !== ($gdir = $this->checkInputDir($this->get['dir'])))
316 350
             ) {
317 351
                 $udir = path::normalize("$dir$gdir");
318
-                if (substr($udir, 0, strlen($dir)) !== $dir)
319
-                    $message = $this->label("Unknown error.");
320
-                else {
352
+                if (substr($udir, 0, strlen($dir)) !== $dir) {
353
+                                    $message = $this->label("Unknown error.");
354
+                } else {
321 355
                     $l = strlen($dir);
322 356
                     $dir = "$udir/";
323 357
                     $udir = substr($udir, $l);
@@ -325,8 +359,9 @@  discard block
 block discarded – undo
325 359
             }
326 360
 
327 361
             if (!strlen($message)) {
328
-                if (!is_dir(path::normalize($dir)))
329
-                    @mkdir(path::normalize($dir), $this->config['dirPerms'], true);
362
+                if (!is_dir(path::normalize($dir))) {
363
+                                    @mkdir(path::normalize($dir), $this->config['dirPerms'], true);
364
+                }
330 365
 
331 366
                 $filename = $this->normalizeFilename($file['name']);
332 367
                 $target = file::getInexistantFilename($dir . $filename);
@@ -334,21 +369,25 @@  discard block
 block discarded – undo
334 369
                 if (!@move_uploaded_file($file['tmp_name'], $target) &&
335 370
                     !@rename($file['tmp_name'], $target) &&
336 371
                     !@copy($file['tmp_name'], $target)
337
-                )
338
-                    $message = $this->label("Cannot move uploaded file to target folder.");
339
-                else {
340
-                    if (function_exists('chmod'))
341
-                        @chmod($target, $this->config['filePerms']);
372
+                ) {
373
+                                    $message = $this->label("Cannot move uploaded file to target folder.");
374
+                } else {
375
+                    if (function_exists('chmod')) {
376
+                                            @chmod($target, $this->config['filePerms']);
377
+                    }
342 378
                     $this->makeThumb($target);
343 379
                     $url = $this->typeURL;
344
-                    if (isset($udir)) $url .= "/$udir";
380
+                    if (isset($udir)) {
381
+                        $url .= "/$udir";
382
+                    }
345 383
                     $url .= "/" . basename($target);
346 384
                     if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)$/', $url, $patt)) {
347 385
                         list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
348 386
                         $base = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/";
349 387
                         $url = $base . path::urlPathEncode($path);
350
-                    } else
351
-                        $url = path::urlPathEncode($url);
388
+                    } else {
389
+                                            $url = path::urlPathEncode($url);
390
+                    }
352 391
                 }
353 392
             }
354 393
         }
@@ -356,16 +395,19 @@  discard block
 block discarded – undo
356 395
         if (strlen($message) &&
357 396
             isset($this->file['tmp_name']) &&
358 397
             file_exists($this->file['tmp_name'])
359
-        )
360
-            @unlink($this->file['tmp_name']);
398
+        ) {
399
+                    @unlink($this->file['tmp_name']);
400
+        }
361 401
 
362
-        if (strlen($message) && method_exists($this, 'errorMsg'))
363
-            $this->errorMsg($message);
402
+        if (strlen($message) && method_exists($this, 'errorMsg')) {
403
+                    $this->errorMsg($message);
404
+        }
364 405
         $this->callBack($url, $message);
365 406
     }
366 407
 
367 408
 
368
-	protected function getTransaliasSettings() {
409
+	protected function getTransaliasSettings()
410
+	{
369 411
 		$modx = DocumentParser::getInstance();
370 412
 
371 413
 		// Cleaning uploaded filename?
@@ -385,7 +427,8 @@  discard block
 block discarded – undo
385 427
 	}
386 428
 
387 429
 
388
-	protected function normalizeFilename($filename) {
430
+	protected function normalizeFilename($filename)
431
+	{
389 432
 		if ($this->getTransaliasSettings()) {
390 433
         		$format = strrchr($filename, ".");
391 434
         		$filename = str_replace($format, "", $filename);
@@ -394,16 +437,19 @@  discard block
 block discarded – undo
394 437
         	return $filename;
395 438
 	}
396 439
 
397
-	protected function normalizeDirname($dirname) {
440
+	protected function normalizeDirname($dirname)
441
+	{
398 442
         return $this->modx->stripAlias($dirname);
399 443
     }
400 444
 
401
-    protected function checkUploadedFile(array $aFile=null) {
445
+    protected function checkUploadedFile(array $aFile=null)
446
+    {
402 447
         $config = &$this->config;
403 448
         $file = ($aFile === null) ? $this->file : $aFile;
404 449
 
405
-        if (!is_array($file) || !isset($file['name']))
406
-            return $this->label("Unknown error");
450
+        if (!is_array($file) || !isset($file['name'])) {
451
+                    return $this->label("Unknown error");
452
+        }
407 453
 
408 454
         if (is_array($file['name'])) {
409 455
             foreach ($file['name'] as $i => $name) {
@@ -412,8 +458,9 @@  discard block
 block discarded – undo
412 458
                     'tmp_name' => $file['tmp_name'][$i],
413 459
                     'error' => $file['error'][$i]
414 460
                 ));
415
-                if ($return !== true)
416
-                    return "$name: $return";
461
+                if ($return !== true) {
462
+                                    return "$name: $return";
463
+                }
417 464
             }
418 465
             return true;
419 466
         }
@@ -422,8 +469,8 @@  discard block
 block discarded – undo
422 469
         $typePatt = strtolower(text::clearWhitespaces($this->types[$this->type]));
423 470
 
424 471
         // CHECK FOR UPLOAD ERRORS
425
-        if ($file['error'])
426
-            return
472
+        if ($file['error']) {
473
+                    return
427 474
                 ($file['error'] == UPLOAD_ERR_INI_SIZE) ?
428 475
                     $this->label("The uploaded file exceeds {size} bytes.",
429 476
                         array('size' => ini_get('upload_max_filesize'))) : (
@@ -440,14 +487,17 @@  discard block
 block discarded – undo
440 487
                     $this->label("Failed to write file.") :
441 488
                     $this->label("Unknown error.")
442 489
             )))));
490
+        }
443 491
 
444 492
         // HIDDEN FILENAMES CHECK
445
-        elseif (substr($file['name'], 0, 1) == ".")
446
-            return $this->label("File name shouldn't begins with '.'");
493
+        elseif (substr($file['name'], 0, 1) == ".") {
494
+                    return $this->label("File name shouldn't begins with '.'");
495
+        }
447 496
 
448 497
         // EXTENSION CHECK
449
-        elseif (!$this->validateExtension($extension, $this->type))
450
-            return $this->label("Denied file extension.");
498
+        elseif (!$this->validateExtension($extension, $this->type)) {
499
+                    return $this->label("Denied file extension.");
500
+        }
451 501
 
452 502
         // SPECIAL DIRECTORY TYPES CHECK (e.g. *img)
453 503
         elseif (preg_match('/^\*([^ ]+)(.*)?$/s', $typePatt, $patt)) {
@@ -457,70 +507,84 @@  discard block
 block discarded – undo
457 507
                 $type = new $class();
458 508
                 $cfg = $config;
459 509
                 $cfg['filename'] = $file['name'];
460
-                if (strlen($params))
461
-                    $cfg['params'] = trim($params);
510
+                if (strlen($params)) {
511
+                                    $cfg['params'] = trim($params);
512
+                }
462 513
                 $response = $type->checkFile($file['tmp_name'], $cfg);
463
-                if ($response !== true)
464
-                    return $this->label($response);
465
-            } else
466
-                return $this->label("Non-existing directory type.");
514
+                if ($response !== true) {
515
+                                    return $this->label($response);
516
+                }
517
+            } else {
518
+                            return $this->label("Non-existing directory type.");
519
+            }
467 520
         }
468 521
 
469 522
         // IMAGE RESIZE
470 523
         $img = image::factory($this->imageDriver, $file['tmp_name']);
471
-        if (!$img->initError && !$this->imageResize($img, $file['tmp_name']))
472
-            return $this->label("The image is too big and/or cannot be resized.");
524
+        if (!$img->initError && !$this->imageResize($img, $file['tmp_name'])) {
525
+                    return $this->label("The image is too big and/or cannot be resized.");
526
+        }
473 527
 
474 528
 
475 529
 	// CHECK FOR MODX MAX FILE SIZE
476 530
 	$actualfilesize=filesize($file['tmp_name']);
477
-	if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478
-	    return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
531
+	if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize']) {
532
+		    return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
533
+	}
479 534
 
480 535
         return true;
481 536
     }
482 537
 
483
-    protected function checkInputDir($dir, $inclType=true, $existing=true) {
538
+    protected function checkInputDir($dir, $inclType=true, $existing=true)
539
+    {
484 540
         $dir = path::normalize($dir);
485
-        if (substr($dir, 0, 1) == "/")
486
-            $dir = substr($dir, 1);
541
+        if (substr($dir, 0, 1) == "/") {
542
+                    $dir = substr($dir, 1);
543
+        }
487 544
 
488
-        if ((substr($dir, 0, 1) == ".") || (substr(basename($dir), 0, 1) == "."))
489
-            return false;
545
+        if ((substr($dir, 0, 1) == ".") || (substr(basename($dir), 0, 1) == ".")) {
546
+                    return false;
547
+        }
490 548
 
491 549
         if ($inclType) {
492 550
             $first = explode("/", $dir);
493 551
             $first = $first[0];
494
-            if ($first != $this->type)
495
-                return false;
552
+            if ($first != $this->type) {
553
+                            return false;
554
+            }
496 555
             $return = $this->removeTypeFromPath($dir);
497 556
         } else {
498 557
             $return = $dir;
499 558
             $dir = "{$this->type}/$dir";
500 559
         }
501 560
 
502
-        if (!$existing)
503
-            return $return;
561
+        if (!$existing) {
562
+                    return $return;
563
+        }
504 564
 
505 565
         $path = "{$this->config['uploadDir']}/$dir";
506 566
         return (is_dir($path) && is_readable($path)) ? $return : false;
507 567
     }
508 568
 
509
-    protected function validateExtension($ext, $type) {
569
+    protected function validateExtension($ext, $type)
570
+    {
510 571
         $ext = trim(strtolower($ext));
511
-        if (!isset($this->types[$type]))
512
-            return false;
572
+        if (!isset($this->types[$type])) {
573
+                    return false;
574
+        }
513 575
 
514 576
         $exts = strtolower(text::clearWhitespaces($this->config['deniedExts']));
515 577
         if (strlen($exts)) {
516 578
             $exts = explode(" ", $exts);
517
-            if (in_array($ext, $exts))
518
-                return false;
579
+            if (in_array($ext, $exts)) {
580
+                            return false;
581
+            }
519 582
         }
520 583
 
521 584
         $exts = trim($this->types[$type]);
522
-        if (!strlen($exts) || substr($exts, 0, 1) == "*")
523
-            return true;
585
+        if (!strlen($exts) || substr($exts, 0, 1) == "*") {
586
+                    return true;
587
+        }
524 588
 
525 589
         if (substr($exts, 0, 1) == "!") {
526 590
             $exts = explode(" ", trim(strtolower(substr($exts, 1))));
@@ -531,26 +595,32 @@  discard block
 block discarded – undo
531 595
         return in_array($ext, $exts);
532 596
     }
533 597
 
534
-    protected function getTypeFromPath($path) {
598
+    protected function getTypeFromPath($path)
599
+    {
535 600
         return preg_match('/^([^\/]*)\/.*$/', $path, $patt)
536 601
             ? $patt[1] : $path;
537 602
     }
538 603
 
539
-    protected function removeTypeFromPath($path) {
604
+    protected function removeTypeFromPath($path)
605
+    {
540 606
         return preg_match('/^[^\/]*\/(.*)$/', $path, $patt)
541 607
             ? $patt[1] : "";
542 608
     }
543 609
 
544
-    protected function imageResize($image, $file=null) {
610
+    protected function imageResize($image, $file=null)
611
+    {
545 612
 
546 613
         if (!($image instanceof image)) {
547 614
             $img = image::factory($this->imageDriver, $image);
548
-            if ($img->initError) return false;
615
+            if ($img->initError) {
616
+                return false;
617
+            }
549 618
             $file = $image;
550
-        } elseif ($file === null)
551
-            return false;
552
-        else
553
-            $img = $image;
619
+        } elseif ($file === null) {
620
+                    return false;
621
+        } else {
622
+                    $img = $image;
623
+        }
554 624
 
555 625
         $orientation = 1;
556 626
         if (function_exists("exif_read_data")) {
@@ -572,8 +642,9 @@  discard block
 block discarded – undo
572 642
             )
573 643
             ) &&
574 644
             ($orientation == 1)
575
-        )
576
-            return true;
645
+        ) {
646
+                    return true;
647
+        }
577 648
 
578 649
 
579 650
         // PROPORTIONAL RESIZE
@@ -593,15 +664,17 @@  discard block
 block discarded – undo
593 664
                 $width = $img->getPropWidth($height);
594 665
             }
595 666
 
596
-            if (isset($width) && isset($height) && !$img->resize($width, $height))
597
-                return false;
667
+            if (isset($width) && isset($height) && !$img->resize($width, $height)) {
668
+                            return false;
669
+            }
598 670
 
599 671
         // RESIZE TO FIT
600 672
         } elseif (
601 673
             $this->config['maxImageWidth'] && $this->config['maxImageHeight'] &&
602 674
             !$img->resizeFit($this->config['maxImageWidth'], $this->config['maxImageHeight'])
603
-        )
604
-            return false;
675
+        ) {
676
+                    return false;
677
+        }
605 678
 
606 679
         // AUTO FLIP AND ROTATE FROM EXIF
607 680
         if ((($orientation == 2) && !$img->flipHorizontal()) ||
@@ -611,11 +684,13 @@  discard block
 block discarded – undo
611 684
             (($orientation == 6) && !$img->rotate(90)) ||
612 685
             (($orientation == 7) && (!$img->flipHorizontal() || !$img->rotate(90))) ||
613 686
             (($orientation == 8) && !$img->rotate(270))
614
-        )
615
-            return false;
616
-        if (($orientation >= 2) && ($orientation <= 8) && ($this->imageDriver == "imagick"))
617
-            try {
687
+        ) {
688
+                    return false;
689
+        }
690
+        if (($orientation >= 2) && ($orientation <= 8) && ($this->imageDriver == "imagick")) {
691
+                    try {
618 692
                 $img->image->setImageProperty('exif:Orientation', "1");
693
+        }
619 694
             } catch (Exception $e) {}
620 695
 
621 696
         // WATERMARK
@@ -646,22 +721,26 @@  discard block
 block discarded – undo
646 721
 
647 722
     }
648 723
 
649
-    protected function makeThumb($file, $overwrite=true) {
724
+    protected function makeThumb($file, $overwrite=true)
725
+    {
650 726
         $img = image::factory($this->imageDriver, $file);
651 727
 
652 728
         // Drop files which are not images
653
-        if ($img->initError)
654
-            return true;
729
+        if ($img->initError) {
730
+                    return true;
731
+        }
655 732
 
656 733
         $thumb = substr($file, strlen($this->config['uploadDir']));
657 734
         $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb;
658 735
         $thumb = path::normalize($thumb);
659 736
         $thumbDir = dirname($thumb);
660
-        if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true))
661
-            return false;
737
+        if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) {
738
+                    return false;
739
+        }
662 740
 
663
-        if (!$overwrite && is_file($thumb))
664
-            return true;
741
+        if (!$overwrite && is_file($thumb)) {
742
+                    return true;
743
+        }
665 744
 
666 745
         // Images with smaller resolutions than thumbnails
667 746
         /*if (($img->width <= $this->config['thumbWidth']) &&
@@ -674,8 +753,9 @@  discard block
 block discarded – undo
674 753
 
675 754
         // Resize image
676 755
         } else */
677
-        if (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight']))
678
-            return false;
756
+        if (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight'])) {
757
+                    return false;
758
+        }
679 759
 
680 760
         if ( $this->imageDriver == 'gd' ) {
681 761
             $width  = imagesx( $img->image );
@@ -697,7 +777,8 @@  discard block
 block discarded – undo
697 777
         ));
698 778
     }
699 779
 
700
-    protected function localize($langCode) {
780
+    protected function localize($langCode)
781
+    {
701 782
         require "lang/{$langCode}.php";
702 783
         setlocale(LC_ALL, $lang['_locale']);
703 784
         $this->charset = $lang['_charset'];
@@ -712,27 +793,34 @@  discard block
 block discarded – undo
712 793
         $this->labels = $lang;
713 794
     }
714 795
 
715
-    protected function label($string, array $data=null) {
796
+    protected function label($string, array $data=null)
797
+    {
716 798
         $return = isset($this->labels[$string]) ? $this->labels[$string] : $string;
717
-        if (is_array($data))
718
-            foreach ($data as $key => $val)
799
+        if (is_array($data)) {
800
+                    foreach ($data as $key => $val)
719 801
                 $return = str_replace("{{$key}}", $val, $return);
802
+        }
720 803
         return $return;
721 804
     }
722 805
 
723
-    protected function backMsg($message, array $data=null) {
806
+    protected function backMsg($message, array $data=null)
807
+    {
724 808
         $message = $this->label($message, $data);
725
-        if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name']))
726
-            @unlink($this->file['tmp_name']);
809
+        if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) {
810
+                    @unlink($this->file['tmp_name']);
811
+        }
727 812
         $this->callBack("", $message);
728 813
         die;
729 814
     }
730 815
 
731
-    protected function callBack($url, $message="") {
816
+    protected function callBack($url, $message="")
817
+    {
732 818
         $message = text::jsValue($message);
733 819
         $CKfuncNum = isset($this->opener['CKEditor']['funcNum'])
734 820
             ? $this->opener['CKEditor']['funcNum'] : 0;
735
-        if (!$CKfuncNum) $CKfuncNum = 0;
821
+        if (!$CKfuncNum) {
822
+            $CKfuncNum = 0;
823
+        }
736 824
         header("Content-Type: text/html; charset={$this->charset}");
737 825
 
738 826
 ?><html>
@@ -769,7 +857,8 @@  discard block
 block discarded – undo
769 857
 
770 858
     }
771 859
 
772
-    protected function get_htaccess() {
860
+    protected function get_htaccess()
861
+    {
773 862
         return "<IfModule mod_php4.c>
774 863
   php_value engine off
775 864
 </IfModule>
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/autoload.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 $modx = DocumentParser::getInstance();
27 27
 $modx->db->connect();
28 28
 startCMSSession();
29
-if(!isset($_SESSION['mgrValidated'])) {
29
+if (!isset($_SESSION['mgrValidated'])) {
30 30
         die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
31 31
 }
32 32
 define('IN_MANAGER_MODE', true);
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 $manager_language = $modx->config['manager_language'];
36 36
 // Pass language code from MODX to KCFinder
37
-if(!file_exists("../../../includes/lang/".$manager_language.".inc.php")) {
37
+if (!file_exists("../../../includes/lang/".$manager_language.".inc.php")) {
38 38
     $manager_language = "english"; // if not set, get the english language file.
39 39
 }
40 40
 include_once "../../../includes/lang/".$manager_language.".inc.php";
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 // PHP VERSION CHECK
44 44
 if (substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.')) < 5)
45
-    die("You are using PHP " . PHP_VERSION . " when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution.");
45
+    die("You are using PHP ".PHP_VERSION." when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution.");
46 46
 
47 47
 
48 48
 // SAFE MODE CHECK
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 
53 53
 // MAGIC AUTOLOAD CLASSES FUNCTION
54
-function autoloadda9d06472ccb71b84928677ce2a6ca89($class) {
54
+function autoloadda9d06472ccb71b84928677ce2a6ca89($class){
55 55
     static $classes = null;
56 56
     if ($classes === null) {
57 57
         $classes = array(
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         );
76 76
     }
77 77
     if (isset($classes[$class])) {
78
-        require dirname(__FILE__) . $classes[$class];
78
+        require dirname(__FILE__).$classes[$class];
79 79
     }
80 80
 }
81 81
 spl_autoload_register('autoloadda9d06472ccb71b84928677ce2a6ca89', true);
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 // json_encode() IMPLEMENTATION IF JSON EXTENSION IS MISSING
85 85
 if (!function_exists("json_encode")) {
86 86
 
87
-    function kcfinder_json_string_encode($string) {
88
-        return '"' .
87
+    function kcfinder_json_string_encode($string){
88
+        return '"'.
89 89
             str_replace('/', "\\/",
90 90
             str_replace("\t", "\\t",
91 91
             str_replace("\r", "\\r",
92 92
             str_replace("\n", "\\n",
93 93
             str_replace('"', "\\\"",
94 94
             str_replace("\\", "\\\\",
95
-        $string)))))) . '"';
95
+        $string)))))).'"';
96 96
     }
97 97
 
98
-    function json_encode($data) {
98
+    function json_encode($data){
99 99
 
100 100
         if (is_array($data)) {
101 101
             $ret = array();
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
             // OBJECT
104 104
             if (array_keys($data) !== range(0, count($data) - 1)) {
105 105
                 foreach ($data as $key => $val)
106
-                    $ret[] = kcfinder_json_string_encode($key) . ':' . json_encode($val);
107
-                return "{" . implode(",", $ret) . "}";
106
+                    $ret[] = kcfinder_json_string_encode($key).':'.json_encode($val);
107
+                return "{".implode(",", $ret)."}";
108 108
 
109 109
             // ARRAY
110 110
             } else {
111 111
                 foreach ($data as $val)
112 112
                     $ret[] = json_encode($val);
113
-                return "[" . implode(",", $ret) . "]";
113
+                return "[".implode(",", $ret)."]";
114 114
             }
115 115
 
116 116
         // BOOLEAN OR NULL
Please login to merge, or discard this patch.
manager/media/script/air-datepicker/datepicker.inc.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class DATEPICKER {
2
+class DATEPICKER{
3 3
     /**
4 4
      * @return string
5 5
      */
6
-    public function getDP() {
6
+    public function getDP(){
7 7
         $modx = DocumentParser::getInstance();
8 8
 
9 9
         $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl');
10
-        if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode();
10
+        if (!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode();
11 11
 		$modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy';
12 12
         return $modx->mergeSettingsContent($load_script);
13 13
     }
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
     /**
16 16
      * @return string
17 17
      */
18
-    public function getLangCode() {
18
+    public function getLangCode(){
19 19
         $modx = DocumentParser::getInstance(); global $modx_lang_attribute;
20 20
 
21
-        if(!$modx_lang_attribute) return 'en';
21
+        if (!$modx_lang_attribute) return 'en';
22 22
 
23 23
         $lc = $modx_lang_attribute;
24
-        if($lc === 'uk') return 'ru';
25
-        $dp_path = str_replace('\\','/',dirname(__FILE__));
24
+        if ($lc === 'uk') return 'ru';
25
+        $dp_path = str_replace('\\', '/', dirname(__FILE__));
26 26
 
27 27
         return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en';
28 28
     }
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,13 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class DATEPICKER {
2
+class DATEPICKER
3
+{
3 4
     /**
4 5
      * @return string
5 6
      */
6
-    public function getDP() {
7
+    public function getDP()
8
+    {
7 9
         $modx = DocumentParser::getInstance();
8 10
 
9 11
         $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl');
10
-        if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode();
12
+        if(!isset($modx->config['lang_code'])) {
13
+            $modx->config['lang_code'] = $this->getLangCode();
14
+        }
11 15
 		$modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy';
12 16
         return $modx->mergeSettingsContent($load_script);
13 17
     }
@@ -15,13 +19,18 @@  discard block
 block discarded – undo
15 19
     /**
16 20
      * @return string
17 21
      */
18
-    public function getLangCode() {
22
+    public function getLangCode()
23
+    {
19 24
         $modx = DocumentParser::getInstance(); global $modx_lang_attribute;
20 25
 
21
-        if(!$modx_lang_attribute) return 'en';
26
+        if(!$modx_lang_attribute) {
27
+            return 'en';
28
+        }
22 29
 
23 30
         $lc = $modx_lang_attribute;
24
-        if($lc === 'uk') return 'ru';
31
+        if($lc === 'uk') {
32
+            return 'ru';
33
+        }
25 34
         $dp_path = str_replace('\\','/',dirname(__FILE__));
26 35
 
27 36
         return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en';
Please login to merge, or discard this patch.