@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $pre = null, |
20 | 20 | $charset = '', |
21 | 21 | $connection_method = 'SET CHARACTER SET' |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | $this->config['host'] = $host ? $host : $GLOBALS['database_server']; |
24 | 24 | $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase']; |
25 | 25 | $this->config['user'] = $uid ? $uid : $GLOBALS['database_user']; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $ua = $modx->htmlspecialchars($_SERVER['HTTP_USER_AGENT']); |
53 | 53 | $referer = $modx->htmlspecialchars($_SERVER['HTTP_REFERER']); |
54 | 54 | $modx->sendmail(array( |
55 | - 'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'], |
|
55 | + 'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'], |
|
56 | 56 | 'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}", |
57 | 57 | 'type' => 'text' |
58 | 58 | )); |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | $tend = $modx->getMicroTime(); |
71 | 71 | $totaltime = $tend - $tstart; |
72 | 72 | if ($modx->dumpSQL) { |
73 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", |
|
74 | - $totaltime) . "</fieldset><br />"; |
|
73 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", |
|
74 | + $totaltime)."</fieldset><br />"; |
|
75 | 75 | } |
76 | 76 | $this->conn->set_charset($this->config['charset']); |
77 | 77 | $this->isConnected = true; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | case 1091: |
139 | 139 | break; |
140 | 140 | default: |
141 | - $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql); |
|
141 | + $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql); |
|
142 | 142 | } |
143 | 143 | } else { |
144 | 144 | $tend = $modx->getMicroTime(); |
@@ -152,24 +152,24 @@ discard block |
||
152 | 152 | $debug_path[] = $line['function']; |
153 | 153 | } |
154 | 154 | $debug_path = implode(' > ', array_reverse($debug_path)); |
155 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", |
|
156 | - $totaltime * 1000) . "</legend>"; |
|
157 | - $modx->queryCode .= $sql . '<br><br>'; |
|
155 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", |
|
156 | + $totaltime * 1000)."</legend>"; |
|
157 | + $modx->queryCode .= $sql.'<br><br>'; |
|
158 | 158 | if ($modx->event->name) { |
159 | - $modx->queryCode .= 'Current Event => ' . $modx->event->name . '<br>'; |
|
159 | + $modx->queryCode .= 'Current Event => '.$modx->event->name.'<br>'; |
|
160 | 160 | } |
161 | 161 | if ($modx->event->activePlugin) { |
162 | - $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>'; |
|
162 | + $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>'; |
|
163 | 163 | } |
164 | 164 | if ($modx->currentSnippet) { |
165 | - $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>'; |
|
165 | + $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>'; |
|
166 | 166 | } |
167 | 167 | if (stripos($sql, 'select') === 0) { |
168 | - $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>'; |
|
168 | + $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>'; |
|
169 | 169 | } else { |
170 | - $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>'; |
|
170 | + $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>'; |
|
171 | 171 | } |
172 | - $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>'; |
|
172 | + $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>'; |
|
173 | 173 | $modx->queryCode .= "</fieldset><br />"; |
174 | 174 | } |
175 | 175 | $modx->executedQueries = $modx->executedQueries + 1; |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | if (is_null($value) || strtolower($value) === 'null') { |
253 | 253 | $flds = 'NULL'; |
254 | 254 | } else { |
255 | - $flds = "'" . $value . "'"; |
|
255 | + $flds = "'".$value."'"; |
|
256 | 256 | } |
257 | - $fields[$key] = "`{$key}` = " . $flds; |
|
257 | + $fields[$key] = "`{$key}` = ".$flds; |
|
258 | 258 | } |
259 | 259 | $fields = implode(",", $fields); |
260 | 260 | } |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | $this->query("INSERT INTO {$intotable} {$fields}"); |
279 | 279 | } else { |
280 | 280 | if (empty($fromtable)) { |
281 | - $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '", |
|
282 | - array_values($fields)) . "')"; |
|
281 | + $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '", |
|
282 | + array_values($fields))."')"; |
|
283 | 283 | $rt = $this->query("INSERT INTO {$intotable} {$fields}"); |
284 | 284 | } else { |
285 | 285 | $fromtable = $this->replaceFullTableName($fromtable); |
286 | - $fields = "(" . implode(",", array_keys($fields)) . ")"; |
|
286 | + $fields = "(".implode(",", array_keys($fields)).")"; |
|
287 | 287 | $where = trim($where); |
288 | 288 | $limit = trim($limit); |
289 | 289 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | public function getInsertId($conn = null) |
349 | 349 | { |
350 | 350 | if (!is_object($conn)) { |
351 | - $conn =& $this->conn; |
|
351 | + $conn = & $this->conn; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | return $conn->insert_id; |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | public function getAffectedRows($conn = null) |
358 | 358 | { |
359 | 359 | if (!is_object($conn)) { |
360 | - $conn =& $this->conn; |
|
360 | + $conn = & $this->conn; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | return $conn->affected_rows; |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | public function getLastError($conn = null) |
367 | 367 | { |
368 | 368 | if (!is_object($conn)) { |
369 | - $conn =& $this->conn; |
|
369 | + $conn = & $this->conn; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | return $conn->error; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | { |
387 | 387 | $out = false; |
388 | 388 | if (is_object($ds)) { |
389 | - switch($mode){ |
|
389 | + switch ($mode) { |
|
390 | 390 | case 'assoc': |
391 | 391 | $out = $ds->fetch_assoc(); |
392 | 392 | break; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | * @author Jason Coward <[email protected]> (MODX) |
10 | 10 | */ |
11 | -class MakeTable { |
|
11 | +class MakeTable{ |
|
12 | 12 | public $actionField; |
13 | 13 | public $cellAction; |
14 | 14 | public $linkAction; |
@@ -33,26 +33,26 @@ discard block |
||
33 | 33 | public $fieldHeaders; |
34 | 34 | public $extra; |
35 | 35 | |
36 | - public function __construct() { |
|
37 | - $this->fieldHeaders= array(); |
|
38 | - $this->excludeFields= array(); |
|
39 | - $this->actionField= ''; |
|
40 | - $this->cellAction= ''; |
|
41 | - $this->linkAction= ''; |
|
42 | - $this->tableWidth= ''; |
|
43 | - $this->tableClass= ''; |
|
44 | - $this->rowHeaderClass= ''; |
|
45 | - $this->columnHeaderClass= ''; |
|
46 | - $this->rowRegularClass= ''; |
|
47 | - $this->rowAlternateClass= 'alt'; |
|
48 | - $this->formName= 'tableForm'; |
|
49 | - $this->formAction= '[~[*id*]~]'; |
|
50 | - $this->formElementName= ''; |
|
51 | - $this->formElementType= ''; |
|
52 | - $this->rowAlternatingScheme= 'EVEN'; |
|
53 | - $this->allOption= 0; |
|
54 | - $this->selectedValues= array(); |
|
55 | - $this->extra= ''; |
|
36 | + public function __construct(){ |
|
37 | + $this->fieldHeaders = array(); |
|
38 | + $this->excludeFields = array(); |
|
39 | + $this->actionField = ''; |
|
40 | + $this->cellAction = ''; |
|
41 | + $this->linkAction = ''; |
|
42 | + $this->tableWidth = ''; |
|
43 | + $this->tableClass = ''; |
|
44 | + $this->rowHeaderClass = ''; |
|
45 | + $this->columnHeaderClass = ''; |
|
46 | + $this->rowRegularClass = ''; |
|
47 | + $this->rowAlternateClass = 'alt'; |
|
48 | + $this->formName = 'tableForm'; |
|
49 | + $this->formAction = '[~[*id*]~]'; |
|
50 | + $this->formElementName = ''; |
|
51 | + $this->formElementType = ''; |
|
52 | + $this->rowAlternatingScheme = 'EVEN'; |
|
53 | + $this->allOption = 0; |
|
54 | + $this->selectedValues = array(); |
|
55 | + $this->extra = ''; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param $value A URL to execute when table cells are clicked. |
62 | 62 | */ |
63 | - public function setCellAction($value) { |
|
64 | - $this->cellAction= $this->prepareLink($value); |
|
63 | + public function setCellAction($value){ |
|
64 | + $this->cellAction = $this->prepareLink($value); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @param $value A URL to execute when text within table cells are clicked. |
71 | 71 | */ |
72 | - public function setLinkAction($value) { |
|
73 | - $this->linkAction= $this->prepareLink($value); |
|
72 | + public function setLinkAction($value){ |
|
73 | + $this->linkAction = $this->prepareLink($value); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param $value A valid width attribute for the HTML TABLE tag |
80 | 80 | */ |
81 | - public function setTableWidth($value) { |
|
82 | - $this->tableWidth= $value; |
|
81 | + public function setTableWidth($value){ |
|
82 | + $this->tableWidth = $value; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @param $value A class for the main HTML TABLE. |
89 | 89 | */ |
90 | - public function setTableClass($value) { |
|
91 | - $this->tableClass= $value; |
|
90 | + public function setTableClass($value){ |
|
91 | + $this->tableClass = $value; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param $value A class for the main HTML TABLE. |
98 | 98 | */ |
99 | - public function setTableID($value) { |
|
100 | - $this->tableID= $value; |
|
99 | + public function setTableID($value){ |
|
100 | + $this->tableID = $value; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param $value A class for the table header row. |
107 | 107 | */ |
108 | - public function setRowHeaderClass($value) { |
|
109 | - $this->rowHeaderClass= $value; |
|
108 | + public function setRowHeaderClass($value){ |
|
109 | + $this->rowHeaderClass = $value; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param $value A class for the table header row. |
116 | 116 | */ |
117 | - public function setThHeaderClass($value) { |
|
118 | - $this->thClass= $value; |
|
117 | + public function setThHeaderClass($value){ |
|
118 | + $this->thClass = $value; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param $value A class for the column header row. |
125 | 125 | */ |
126 | - public function setColumnHeaderClass($value) { |
|
127 | - $this->columnHeaderClass= $value; |
|
126 | + public function setColumnHeaderClass($value){ |
|
127 | + $this->columnHeaderClass = $value; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @param $value A class for regular table rows. |
134 | 134 | */ |
135 | - public function setRowRegularClass($value) { |
|
136 | - $this->rowRegularClass= $value; |
|
135 | + public function setRowRegularClass($value){ |
|
136 | + $this->rowRegularClass = $value; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param $value A class for alternate table rows. |
143 | 143 | */ |
144 | - public function setRowAlternateClass($value) { |
|
145 | - $this->rowAlternateClass= $value; |
|
144 | + public function setRowAlternateClass($value){ |
|
145 | + $this->rowAlternateClass = $value; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @param $value Indicates the INPUT form element type attribute. |
152 | 152 | */ |
153 | - public function setFormElementType($value) { |
|
154 | - $this->formElementType= $value; |
|
153 | + public function setFormElementType($value){ |
|
154 | + $this->formElementType = $value; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @param $value Indicates the INPUT form element name attribute. |
161 | 161 | */ |
162 | - public function setFormElementName($value) { |
|
163 | - $this->formElementName= $value; |
|
162 | + public function setFormElementName($value){ |
|
163 | + $this->formElementName = $value; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @param $value Indicates the FORM name attribute. |
171 | 171 | */ |
172 | - public function setFormName($value) { |
|
173 | - $this->formName= $value; |
|
172 | + public function setFormName($value){ |
|
173 | + $this->formName = $value; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @param $value Indicates the FORM action attribute. |
180 | 180 | */ |
181 | - public function setFormAction($value) { |
|
182 | - $this->formAction= $value; |
|
181 | + public function setFormAction($value){ |
|
182 | + $this->formAction = $value; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param $value An Array of field keys to exclude from the table. |
189 | 189 | */ |
190 | - public function setExcludeFields($value) { |
|
191 | - $this->excludeFields= $value; |
|
190 | + public function setExcludeFields($value){ |
|
191 | + $this->excludeFields = $value; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @param $value 'ODD' or 'EVEN' to indicate the alternate row scheme. |
198 | 198 | */ |
199 | - public function setRowAlternatingScheme($value) { |
|
200 | - $this->rowAlternatingScheme= $value; |
|
199 | + public function setRowAlternatingScheme($value){ |
|
200 | + $this->rowAlternatingScheme = $value; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param $value The key of the field to add as a query string parameter. |
208 | 208 | */ |
209 | - public function setActionFieldName($value) { |
|
210 | - $this->actionField= $value; |
|
209 | + public function setActionFieldName($value){ |
|
210 | + $this->actionField = $value; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | * @param $value An Array of column widths in the order of the keys in the |
217 | 217 | * source table array. |
218 | 218 | */ |
219 | - public function setColumnWidths($widthArray) { |
|
220 | - $this->columnWidths= $widthArray; |
|
219 | + public function setColumnWidths($widthArray){ |
|
220 | + $this->columnWidths = $widthArray; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @param $value Indicates the INPUT form element type attribute. |
227 | 227 | */ |
228 | - public function setSelectedValues($valueArray) { |
|
229 | - $this->selectedValues= $valueArray; |
|
228 | + public function setSelectedValues($valueArray){ |
|
229 | + $this->selectedValues = $valueArray; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param $value A string of additional content. |
237 | 237 | */ |
238 | - public function setExtra($value) { |
|
239 | - $this->extra= $value; |
|
238 | + public function setExtra($value){ |
|
239 | + $this->extra = $value; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @param $columnPosition The index of the column to get the width for. |
246 | 246 | */ |
247 | - public function getColumnWidth($columnPosition) { |
|
248 | - $currentWidth= ''; |
|
247 | + public function getColumnWidth($columnPosition){ |
|
248 | + $currentWidth = ''; |
|
249 | 249 | if (is_array($this->columnWidths)) { |
250 | - $currentWidth= $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
|
250 | + $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
|
251 | 251 | } |
252 | 252 | return $currentWidth; |
253 | 253 | } |
@@ -257,19 +257,19 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @param $value The position of the current row being rendered. |
259 | 259 | */ |
260 | - public function determineRowClass($position) { |
|
260 | + public function determineRowClass($position){ |
|
261 | 261 | switch ($this->rowAlternatingScheme) { |
262 | 262 | case 'ODD' : |
263 | - $modRemainder= 1; |
|
263 | + $modRemainder = 1; |
|
264 | 264 | break; |
265 | 265 | case 'EVEN' : |
266 | - $modRemainder= 0; |
|
266 | + $modRemainder = 0; |
|
267 | 267 | break; |
268 | 268 | } |
269 | 269 | if ($position % 2 == $modRemainder) { |
270 | - $currentClass= $this->rowRegularClass; |
|
270 | + $currentClass = $this->rowRegularClass; |
|
271 | 271 | } else { |
272 | - $currentClass= $this->rowAlternateClass; |
|
272 | + $currentClass = $this->rowAlternateClass; |
|
273 | 273 | } |
274 | 274 | return ' class="'.$currentClass.'"'; |
275 | 275 | } |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @param $value Indicates the INPUT form element type attribute. |
282 | 282 | */ |
283 | - public function getCellAction($currentActionFieldValue) { |
|
283 | + public function getCellAction($currentActionFieldValue){ |
|
284 | 284 | if ($this->cellAction) { |
285 | - $cellAction= ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
|
285 | + $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
|
286 | 286 | } |
287 | 287 | return $cellAction; |
288 | 288 | } |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | * @param $currentActionFieldValue The value to be applied to the link action. |
294 | 294 | * @param $value The value of the cell. |
295 | 295 | */ |
296 | - public function createCellText($currentActionFieldValue, $value) { |
|
296 | + public function createCellText($currentActionFieldValue, $value){ |
|
297 | 297 | $cell .= $value; |
298 | 298 | if ($this->linkAction) { |
299 | - $cell= '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
|
299 | + $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
|
300 | 300 | } |
301 | 301 | return $cell; |
302 | 302 | } |
@@ -305,8 +305,8 @@ discard block |
||
305 | 305 | * Sets an option to generate a check all link when checkbox is indicated |
306 | 306 | * as the table formElementType. |
307 | 307 | */ |
308 | - public function setAllOption() { |
|
309 | - $this->allOption= 1; |
|
308 | + public function setAllOption(){ |
|
309 | + $this->allOption = 1; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @param $value Indicates the INPUT form element type attribute. |
316 | 316 | */ |
317 | - public function prepareLink($link) { |
|
317 | + public function prepareLink($link){ |
|
318 | 318 | if (strstr($link, '?')) { |
319 | - $end= '&'; |
|
319 | + $end = '&'; |
|
320 | 320 | } else { |
321 | - $end= '?'; |
|
321 | + $end = '?'; |
|
322 | 322 | } |
323 | 323 | return $link.$end; |
324 | 324 | } |
@@ -333,20 +333,20 @@ discard block |
||
333 | 333 | * the $fieldsArray where the values represent the alt heading content |
334 | 334 | * for each column. |
335 | 335 | */ |
336 | - public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="") { |
|
336 | + public function create($fieldsArray, $fieldHeadersArray = array(), $linkpage = ""){ |
|
337 | 337 | global $_lang; |
338 | 338 | if (is_array($fieldsArray)) { |
339 | - $i= 0; |
|
339 | + $i = 0; |
|
340 | 340 | foreach ($fieldsArray as $fieldName => $fieldValue) { |
341 | 341 | $table .= "\t<tr".$this->determineRowClass($i).">\n"; |
342 | - $currentActionFieldValue= $fieldValue[$this->actionField]; |
|
342 | + $currentActionFieldValue = $fieldValue[$this->actionField]; |
|
343 | 343 | if (is_array($this->selectedValues)) { |
344 | - $isChecked= array_search($currentActionFieldValue, $this->selectedValues)===false? 0 : 1; |
|
344 | + $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1; |
|
345 | 345 | } else { |
346 | - $isChecked= false; |
|
346 | + $isChecked = false; |
|
347 | 347 | } |
348 | 348 | $table .= $this->addFormField($currentActionFieldValue, $isChecked); |
349 | - $colPosition= 0; |
|
349 | + $colPosition = 0; |
|
350 | 350 | foreach ($fieldValue as $key => $value) { |
351 | 351 | if (!in_array($key, $this->excludeFields)) { |
352 | 352 | $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">"; |
@@ -354,20 +354,20 @@ discard block |
||
354 | 354 | $table .= "</td>\n"; |
355 | 355 | if ($i == 0) { |
356 | 356 | if (empty ($header) && $this->formElementType) { |
357 | - $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">". ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n"; |
|
357 | + $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n"; |
|
358 | 358 | } |
359 | - $headerText= array_key_exists($key, $fieldHeadersArray)? $fieldHeadersArray[$key]: $key; |
|
359 | + $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key; |
|
360 | 360 | $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n"; |
361 | 361 | } |
362 | - $colPosition ++; |
|
362 | + $colPosition++; |
|
363 | 363 | } |
364 | 364 | } |
365 | - $i ++; |
|
365 | + $i++; |
|
366 | 366 | $table .= "\t</tr>\n"; |
367 | 367 | } |
368 | - $table= "\n".'<table'. ($this->tableWidth ? ' width="'.$this->tableWidth.'"' : ''). ($this->tableClass ? ' class="'.$this->tableClass.'"' : ''). ($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n". ($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n"; |
|
368 | + $table = "\n".'<table'.($this->tableWidth ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n"; |
|
369 | 369 | if ($this->formElementType) { |
370 | - $table= "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
|
370 | + $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
|
371 | 371 | } |
372 | 372 | if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
373 | 373 | /* commented this part because of cookie |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | } |
403 | 403 | if ($this->formElementType) { |
404 | 404 | if ($this->extra) { |
405 | - $table.= "\n".$this->extra."\n"; |
|
405 | + $table .= "\n".$this->extra."\n"; |
|
406 | 406 | } |
407 | - $table.= "\n".'</form>'."\n"; |
|
407 | + $table .= "\n".'</form>'."\n"; |
|
408 | 408 | } |
409 | 409 | return $table; |
410 | 410 | } |
@@ -416,36 +416,36 @@ discard block |
||
416 | 416 | * @param $numRecords The number of records to show per page. |
417 | 417 | * @param $qs An optional query string to be appended to the paging links |
418 | 418 | */ |
419 | - public function createPagingNavigation($numRecords, $qs='') { |
|
419 | + public function createPagingNavigation($numRecords, $qs = ''){ |
|
420 | 420 | global $_lang; |
421 | - $currentPage= (is_numeric($_GET['page']) ? $_GET['page'] : 1); |
|
422 | - $numPages= ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
|
421 | + $currentPage = (is_numeric($_GET['page']) ? $_GET['page'] : 1); |
|
422 | + $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
|
423 | 423 | if ($numPages > 1) { |
424 | - $currentURL= empty($qs)? '': '?'.$qs; |
|
424 | + $currentURL = empty($qs) ? '' : '?'.$qs; |
|
425 | 425 | if ($currentPage > 6) { |
426 | 426 | $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]); |
427 | 427 | } |
428 | 428 | if ($currentPage != 1) { |
429 | - $nav .= $this->createPageLink($currentURL, $currentPage -1, '<<'); |
|
429 | + $nav .= $this->createPageLink($currentURL, $currentPage - 1, '<<'); |
|
430 | 430 | } |
431 | - $offset= -4 + ($currentPage < 5 ? (5 - $currentPage) : 0); |
|
432 | - $i= 1; |
|
431 | + $offset = -4 + ($currentPage < 5 ? (5 - $currentPage) : 0); |
|
432 | + $i = 1; |
|
433 | 433 | while ($i < 10 && ($currentPage + $offset <= $numPages)) { |
434 | 434 | if ($currentPage == $currentPage + $offset) |
435 | 435 | $nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true); |
436 | 436 | else |
437 | 437 | $nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset); |
438 | - $i ++; |
|
439 | - $offset ++; |
|
438 | + $i++; |
|
439 | + $offset++; |
|
440 | 440 | } |
441 | 441 | if ($currentPage < $numPages) { |
442 | - $nav .= $this->createPageLink($currentURL, $currentPage +1, '>>'); |
|
442 | + $nav .= $this->createPageLink($currentURL, $currentPage + 1, '>>'); |
|
443 | 443 | } |
444 | 444 | if ($currentPage != $numPages) { |
445 | 445 | $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]); |
446 | 446 | } |
447 | 447 | } |
448 | - $this->pageNav= ' '.$nav; |
|
448 | + $this->pageNav = ' '.$nav; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | * @param $currentPage Indicates if the link is to the current page. |
458 | 458 | * @param $qs And optional query string to be appended to the link. |
459 | 459 | */ |
460 | - public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='') { |
|
460 | + public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = ''){ |
|
461 | 461 | global $modx; |
462 | - $orderBy= !empty($_GET['orderby'])? '&orderby=' . $_GET['orderby']: ''; |
|
463 | - $orderDir= !empty($_GET['orderdir'])? '&orderdir=' . $_GET['orderdir']: ''; |
|
464 | - if (!empty($qs)) $qs= "?$qs"; |
|
465 | - $link= empty($link)? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs . "page=$pageNum$orderBy$orderDir"): $this->prepareLink($link) . "page=$pageNum"; |
|
466 | - $nav .= '<li'.($currentPage? ' class="currentPage"': '').'><a'.($currentPage? ' class="currentPage"': '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
|
462 | + $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : ''; |
|
463 | + $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : ''; |
|
464 | + if (!empty($qs)) $qs = "?$qs"; |
|
465 | + $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum"; |
|
466 | + $nav .= '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
|
467 | 467 | return $nav; |
468 | 468 | } |
469 | 469 | |
@@ -474,10 +474,10 @@ discard block |
||
474 | 474 | * @param $isChecked Indicates if the checked attribute should apply to the |
475 | 475 | * element. |
476 | 476 | */ |
477 | - public function addFormField($value, $isChecked) { |
|
477 | + public function addFormField($value, $isChecked){ |
|
478 | 478 | if ($this->formElementType) { |
479 | - $checked= $isChecked? "checked ": ""; |
|
480 | - $field= "\t\t".'<td><input type="'.$this->formElementType.'" name="'. ($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
|
479 | + $checked = $isChecked ? "checked " : ""; |
|
480 | + $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
|
481 | 481 | } |
482 | 482 | return $field; |
483 | 483 | } |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | * Generates the proper LIMIT clause for queries to retrieve paged results in |
487 | 487 | * a MakeTable $fieldsArray. |
488 | 488 | */ |
489 | - public function handlePaging() { |
|
490 | - $offset= (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
|
491 | - $limitClause= ' LIMIT '. ($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
|
489 | + public function handlePaging(){ |
|
490 | + $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
|
491 | + $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
|
492 | 492 | return $limitClause; |
493 | 493 | } |
494 | 494 | |
@@ -498,12 +498,12 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @param $natural_order If true, the results are returned in natural order. |
500 | 500 | */ |
501 | - public function handleSorting($natural_order=false) { |
|
502 | - $orderByClause= ''; |
|
501 | + public function handleSorting($natural_order = false){ |
|
502 | + $orderByClause = ''; |
|
503 | 503 | if (!$natural_order) { |
504 | - $orderby= !empty($_GET['orderby'])? $_GET['orderby']: "id"; |
|
505 | - $orderdir= !empty($_GET['orderdir'])? $_GET['orderdir']: "DESC"; |
|
506 | - $orderbyClause= !empty($orderby)? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ': ""; |
|
504 | + $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id"; |
|
505 | + $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC"; |
|
506 | + $orderbyClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : ""; |
|
507 | 507 | } |
508 | 508 | return $orderbyClause; |
509 | 509 | } |
@@ -516,15 +516,15 @@ discard block |
||
516 | 516 | * @param $text The text for the link (e.g. table column header). |
517 | 517 | * @param $qs An optional query string to append to the order by link. |
518 | 518 | */ |
519 | - public function prepareOrderByLink($key, $text, $qs='') { |
|
519 | + public function prepareOrderByLink($key, $text, $qs = ''){ |
|
520 | 520 | global $modx; |
521 | 521 | if (!empty($_GET['orderdir'])) { |
522 | - $orderDir= strtolower($_GET['orderdir'])=='desc'? '&orderdir=asc': '&orderdir=desc'; |
|
522 | + $orderDir = strtolower($_GET['orderdir']) == 'desc' ? '&orderdir=asc' : '&orderdir=desc'; |
|
523 | 523 | } else { |
524 | - $orderDir= '&orderdir=asc'; |
|
524 | + $orderDir = '&orderdir=asc'; |
|
525 | 525 | } |
526 | 526 | if (!empty($qs)) { |
527 | - if (!strrpos($qs, '&')==strlen($qs)-1) $qs.= '&'; |
|
527 | + if (!strrpos($qs, '&') == strlen($qs) - 1) $qs .= '&'; |
|
528 | 528 | } |
529 | 529 | return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>'; |
530 | 530 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -$userid = (int)$value; |
|
2 | +$userid = (int) $value; |
|
3 | 3 | if (!isset($modx->filter->cache['ui'][$userid])) { |
4 | 4 | if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid)); |
5 | 5 | else $user = $modx->getUserInfo($userid); |
@@ -1,43 +1,43 @@ |
||
1 | 1 | <?php |
2 | -if(strpos($opt,',')) list($limit,$delim) = explode(',', $opt); |
|
3 | -elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} |
|
4 | -else {$limit=124;$delim='';} |
|
2 | +if (strpos($opt, ',')) list($limit, $delim) = explode(',', $opt); |
|
3 | +elseif (preg_match('/^[1-9][0-9]*$/', $opt)) {$limit = $opt; $delim = ''; } |
|
4 | +else {$limit = 124; $delim = ''; } |
|
5 | 5 | |
6 | -if($delim==='') $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
7 | -$limit = (int)$limit; |
|
6 | +if ($delim === '') $delim = $modx->config['manager_language'] === 'japanese-utf8' ? '。' : '.'; |
|
7 | +$limit = (int) $limit; |
|
8 | 8 | |
9 | 9 | $content = $modx->filter->parseDocumentSource($value); |
10 | 10 | |
11 | 11 | $content = strip_tags($content); |
12 | 12 | |
13 | -$content = str_replace(array("\r\n","\r","\n","\t",' '),' ',$content); |
|
14 | -if(preg_match('/\s+/',$content)) |
|
15 | - $content = preg_replace('/\s+/',' ',$content); |
|
13 | +$content = str_replace(array("\r\n", "\r", "\n", "\t", ' '), ' ', $content); |
|
14 | +if (preg_match('/\s+/', $content)) |
|
15 | + $content = preg_replace('/\s+/', ' ', $content); |
|
16 | 16 | $content = trim($content); |
17 | 17 | |
18 | 18 | $pos = $modx->filter->strpos($content, $delim); |
19 | 19 | |
20 | -if($pos!==false && $pos<$limit) { |
|
20 | +if ($pos !== false && $pos < $limit) { |
|
21 | 21 | $_ = explode($delim, $content); |
22 | 22 | $text = ''; |
23 | - foreach($_ as $v) { |
|
24 | - if($limit <= $modx->filter->strlen($text.$v.$delim)) break; |
|
23 | + foreach ($_ as $v) { |
|
24 | + if ($limit <= $modx->filter->strlen($text.$v.$delim)) break; |
|
25 | 25 | $text .= $v.$delim; |
26 | 26 | } |
27 | - if($text) $content = $text; |
|
27 | + if ($text) $content = $text; |
|
28 | 28 | } |
29 | 29 | |
30 | -if($limit<$modx->filter->strlen($content) && strpos($content,' ')!==false) { |
|
30 | +if ($limit < $modx->filter->strlen($content) && strpos($content, ' ') !== false) { |
|
31 | 31 | $_ = explode(' ', $content); |
32 | 32 | $text = ''; |
33 | - foreach($_ as $v) { |
|
34 | - if($limit <= $modx->filter->strlen($text.$v.' ')) break; |
|
35 | - $text .= $v . ' '; |
|
33 | + foreach ($_ as $v) { |
|
34 | + if ($limit <= $modx->filter->strlen($text.$v.' ')) break; |
|
35 | + $text .= $v.' '; |
|
36 | 36 | } |
37 | - if($text!=='') $content = $text; |
|
37 | + if ($text !== '') $content = $text; |
|
38 | 38 | } |
39 | 39 | |
40 | -if($limit < $modx->filter->strlen($content)) $content = $modx->filter->substr($content, 0, $limit); |
|
41 | -if($modx->filter->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim; |
|
40 | +if ($limit < $modx->filter->strlen($content)) $content = $modx->filter->substr($content, 0, $limit); |
|
41 | +if ($modx->filter->substr($content, -1) == $delim) $content = rtrim($content, $delim).$delim; |
|
42 | 42 | |
43 | 43 | return $content; |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | use PHPMailer\PHPMailer\PHPMailer; |
12 | 12 | use PHPMailer\PHPMailer\Exception as PHPMailerException; |
13 | 13 | |
14 | -require MODX_MANAGER_PATH . 'includes/controls/phpmailer/Exception.php'; |
|
15 | -require MODX_MANAGER_PATH . 'includes/controls/phpmailer/PHPMailer.php'; |
|
16 | -require MODX_MANAGER_PATH . 'includes/controls/phpmailer/SMTP.php'; |
|
14 | +require MODX_MANAGER_PATH.'includes/controls/phpmailer/Exception.php'; |
|
15 | +require MODX_MANAGER_PATH.'includes/controls/phpmailer/PHPMailer.php'; |
|
16 | +require MODX_MANAGER_PATH.'includes/controls/phpmailer/SMTP.php'; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Class MODxMailer |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function init(DocumentParser $modx) |
36 | 36 | { |
37 | 37 | $this->modx = $modx; |
38 | - $this->PluginDir = MODX_MANAGER_PATH . 'includes/controls/phpmailer/'; |
|
38 | + $this->PluginDir = MODX_MANAGER_PATH.'includes/controls/phpmailer/'; |
|
39 | 39 | |
40 | 40 | switch ($modx->config['email_method']) { |
41 | 41 | case 'smtp': |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | mb_language($this->mb_language); |
100 | 100 | mb_internal_encoding($modx->config['modx_charset']); |
101 | 101 | } |
102 | - $exconf = MODX_MANAGER_PATH . 'includes/controls/phpmailer/config.inc.php'; |
|
102 | + $exconf = MODX_MANAGER_PATH.'includes/controls/phpmailer/config.inc.php'; |
|
103 | 103 | if (is_file($exconf)) { |
104 | 104 | include($exconf); |
105 | 105 | } |
@@ -167,12 +167,12 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | if ($this->modx->debug) { |
170 | - $debug_info = 'CharSet = ' . $this->CharSet . "\n"; |
|
171 | - $debug_info .= 'Encoding = ' . $this->Encoding . "\n"; |
|
172 | - $debug_info .= 'mb_language = ' . $this->mb_language . "\n"; |
|
173 | - $debug_info .= 'encode_header_method = ' . $this->encode_header_method . "\n"; |
|
170 | + $debug_info = 'CharSet = '.$this->CharSet."\n"; |
|
171 | + $debug_info .= 'Encoding = '.$this->Encoding."\n"; |
|
172 | + $debug_info .= 'mb_language = '.$this->mb_language."\n"; |
|
173 | + $debug_info .= 'encode_header_method = '.$this->encode_header_method."\n"; |
|
174 | 174 | $debug_info .= "send_mode = {$mode}\n"; |
175 | - $debug_info .= 'Subject = ' . $this->Subject . "\n"; |
|
175 | + $debug_info .= 'Subject = '.$this->Subject."\n"; |
|
176 | 176 | $log = "<pre>{$debug_info}\n{$header}\n{$org_body}</pre>"; |
177 | 177 | $this->modx->logEvent(1, 1, $log, 'MODxMailer debug information'); |
178 | 178 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | ini_set('sendmail_from', $old_from); |
237 | 237 | } |
238 | 238 | if (!$rt) { |
239 | - $msg = $this->Lang('instantiate') . "<br />\n"; |
|
239 | + $msg = $this->Lang('instantiate')."<br />\n"; |
|
240 | 240 | $msg .= "{$this->Subject}<br />\n"; |
241 | 241 | $msg .= "{$this->FromName}<{$this->From}><br />\n"; |
242 | 242 | $msg .= mb_convert_encoding($body, $this->modx->config['modx_charset'], $this->CharSet); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function SetError($msg) |
257 | 257 | { |
258 | - $msg .= '<pre>' . print_r(get_object_vars($this), true) . '</pre>'; |
|
258 | + $msg .= '<pre>'.print_r(get_object_vars($this), true).'</pre>'; |
|
259 | 259 | $this->modx->config['send_errormail'] = '0'; |
260 | 260 | $this->modx->logEvent(0, 3, $msg, 'phpmailer'); |
261 | 261 | |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | /** |
285 | 285 | * @return string |
286 | 286 | */ |
287 | - public function getMIMEHeader() { |
|
287 | + public function getMIMEHeader(){ |
|
288 | 288 | return $this->MIMEHeader; |
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
292 | 292 | * @return string |
293 | 293 | */ |
294 | - public function getMIMEBody() { |
|
294 | + public function getMIMEBody(){ |
|
295 | 295 | return $this->MIMEBody; |
296 | 296 | } |
297 | 297 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @return $this |
302 | 302 | */ |
303 | - public function setMIMEHeader($header = '') { |
|
303 | + public function setMIMEHeader($header = ''){ |
|
304 | 304 | $this->MIMEHeader = $header; |
305 | 305 | |
306 | 306 | return $this; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return $this |
313 | 313 | */ |
314 | - public function setMIMEBody($body = '') { |
|
314 | + public function setMIMEBody($body = ''){ |
|
315 | 315 | $this->MIMEBody = $body; |
316 | 316 | |
317 | 317 | return $this; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @return $this |
324 | 324 | */ |
325 | - public function setMailHeader($header = '') { |
|
325 | + public function setMailHeader($header = ''){ |
|
326 | 326 | $this->mailHeader = $header; |
327 | 327 | |
328 | 328 | return $this; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | /** |
332 | 332 | * @return string |
333 | 333 | */ |
334 | - public function getMessageID() { |
|
335 | - return trim($this->lastMessageID,'<>'); |
|
334 | + public function getMessageID(){ |
|
335 | + return trim($this->lastMessageID, '<>'); |
|
336 | 336 | } |
337 | 337 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $pre = null, |
31 | 31 | $charset = '', |
32 | 32 | $connection_method = 'SET CHARACTER SET' |
33 | - ) { |
|
33 | + ){ |
|
34 | 34 | $this->config['host'] = $host ? $host : $GLOBALS['database_server']; |
35 | 35 | $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase']; |
36 | 36 | $this->config['user'] = $uid ? $uid : $GLOBALS['database_user']; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $referer = $modx->htmlspecialchars($_SERVER['HTTP_REFERER']); |
121 | 121 | |
122 | 122 | $modx->sendmail(array( |
123 | - 'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'], |
|
123 | + 'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'], |
|
124 | 124 | 'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}", |
125 | 125 | 'type' => 'text' |
126 | 126 | ) |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | $dbase = trim($dbase, '`'); // remove the `` chars |
139 | 139 | if (!@ mysql_select_db($dbase, $this->conn)) { |
140 | - $modx->messageQuit("Failed to select the database '" . $dbase . "'!"); |
|
140 | + $modx->messageQuit("Failed to select the database '".$dbase."'!"); |
|
141 | 141 | exit; |
142 | 142 | } |
143 | 143 | @mysql_query("{$connection_method} {$charset}", $this->conn); |
144 | 144 | $tend = $modx->getMicroTime(); |
145 | 145 | $totaltime = $tend - $tstart; |
146 | 146 | if ($modx->dumpSQL) { |
147 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", |
|
148 | - $totaltime) . "</fieldset><br />"; |
|
147 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", |
|
148 | + $totaltime)."</fieldset><br />"; |
|
149 | 149 | } |
150 | 150 | if (function_exists('mysql_set_charset')) { |
151 | 151 | mysql_set_charset($this->config['charset']); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | case 1091: |
226 | 226 | break; |
227 | 227 | default: |
228 | - $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql); |
|
228 | + $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql); |
|
229 | 229 | } |
230 | 230 | } else { |
231 | 231 | $tend = $modx->getMicroTime(); |
@@ -239,24 +239,24 @@ discard block |
||
239 | 239 | $debug_path[] = $line['function']; |
240 | 240 | } |
241 | 241 | $debug_path = implode(' > ', array_reverse($debug_path)); |
242 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", |
|
243 | - $totaltime * 1000) . "</legend>"; |
|
244 | - $modx->queryCode .= $sql . '<br><br>'; |
|
242 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", |
|
243 | + $totaltime * 1000)."</legend>"; |
|
244 | + $modx->queryCode .= $sql.'<br><br>'; |
|
245 | 245 | if ($modx->event->name) { |
246 | - $modx->queryCode .= 'Current Event => ' . $modx->event->name . '<br>'; |
|
246 | + $modx->queryCode .= 'Current Event => '.$modx->event->name.'<br>'; |
|
247 | 247 | } |
248 | 248 | if ($modx->event->activePlugin) { |
249 | - $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>'; |
|
249 | + $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>'; |
|
250 | 250 | } |
251 | 251 | if ($modx->currentSnippet) { |
252 | - $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>'; |
|
252 | + $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>'; |
|
253 | 253 | } |
254 | 254 | if (stripos($sql, 'select') === 0) { |
255 | - $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>'; |
|
255 | + $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>'; |
|
256 | 256 | } else { |
257 | - $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>'; |
|
257 | + $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>'; |
|
258 | 258 | } |
259 | - $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>'; |
|
259 | + $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>'; |
|
260 | 260 | $modx->queryCode .= "</fieldset><br />"; |
261 | 261 | } |
262 | 262 | $modx->executedQueries = $modx->executedQueries + 1; |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | if (is_null($value) || strtolower($value) === 'null') { |
351 | 351 | $flds = 'NULL'; |
352 | 352 | } else { |
353 | - $flds = "'" . $value . "'"; |
|
353 | + $flds = "'".$value."'"; |
|
354 | 354 | } |
355 | - $fields[$key] = "`{$key}` = " . $flds; |
|
355 | + $fields[$key] = "`{$key}` = ".$flds; |
|
356 | 356 | } |
357 | 357 | $fields = implode(",", $fields); |
358 | 358 | } |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | $this->query("INSERT INTO {$intotable} {$fields}"); |
381 | 381 | } else { |
382 | 382 | if (empty($fromtable)) { |
383 | - $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '", |
|
384 | - array_values($fields)) . "')"; |
|
383 | + $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '", |
|
384 | + array_values($fields))."')"; |
|
385 | 385 | $rt = $this->query("INSERT INTO {$intotable} {$fields}"); |
386 | 386 | } else { |
387 | 387 | if (version_compare($this->getVersion(), "4.0.14") >= 0) { |
388 | 388 | $fromtable = $this->replaceFullTableName($fromtable); |
389 | - $fields = "(" . implode(",", array_keys($fields)) . ")"; |
|
389 | + $fields = "(".implode(",", array_keys($fields)).")"; |
|
390 | 390 | $where = trim($where); |
391 | 391 | $limit = trim($limit); |
392 | 392 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | } else { |
400 | 400 | $ds = $this->select($fromfields, $fromtable, $where, '', $limit); |
401 | 401 | while ($row = $this->getRow($ds)) { |
402 | - $fields = "(" . implode(",", array_keys($fields)) . ") VALUES('" . implode("', '", |
|
403 | - $row) . "')"; |
|
402 | + $fields = "(".implode(",", array_keys($fields)).") VALUES('".implode("', '", |
|
403 | + $row)."')"; |
|
404 | 404 | $rt = $this->query("INSERT INTO {$intotable} {$fields}"); |
405 | 405 | } |
406 | 406 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | public function getInsertId($conn = null) |
486 | 486 | { |
487 | 487 | if (!is_resource($conn)) { |
488 | - $conn =& $this->conn; |
|
488 | + $conn = & $this->conn; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | return mysql_insert_id($conn); |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | public function getAffectedRows($conn = null) |
499 | 499 | { |
500 | 500 | if (!is_resource($conn)) { |
501 | - $conn =& $this->conn; |
|
501 | + $conn = & $this->conn; |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | return mysql_affected_rows($conn); |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | public function getLastError($conn = null) |
512 | 512 | { |
513 | 513 | if (!is_resource($conn)) { |
514 | - $conn =& $this->conn; |
|
514 | + $conn = & $this->conn; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | return mysql_error($conn); |
@@ -1,43 +1,43 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | $this->old = new OldFunctions(); |
3 | -class OldFunctions { |
|
3 | +class OldFunctions{ |
|
4 | 4 | |
5 | - public function dbConnect() {global $modx; $modx->db->connect();$modx->rs = $modx->db->conn;} |
|
6 | - public function dbQuery($sql) {global $modx;return $modx->db->query($sql);} |
|
7 | - public function recordCount($rs) {global $modx;return $modx->db->getRecordCount($rs);} |
|
8 | - public function fetchRow($rs,$mode='assoc') {global $modx;return $modx->db->getRow($rs, $mode);} |
|
9 | - public function affectedRows($rs) {global $modx;return $modx->db->getAffectedRows($rs);} |
|
10 | - public function insertId($rs) {global $modx;return $modx->db->getInsertId($rs);} |
|
11 | - public function dbClose() {global $modx; $modx->db->disconnect();} |
|
5 | + public function dbConnect(){global $modx; $modx->db->connect(); $modx->rs = $modx->db->conn; } |
|
6 | + public function dbQuery($sql){global $modx; return $modx->db->query($sql); } |
|
7 | + public function recordCount($rs){global $modx; return $modx->db->getRecordCount($rs); } |
|
8 | + public function fetchRow($rs, $mode = 'assoc'){global $modx; return $modx->db->getRow($rs, $mode); } |
|
9 | + public function affectedRows($rs){global $modx; return $modx->db->getAffectedRows($rs); } |
|
10 | + public function insertId($rs){global $modx; return $modx->db->getInsertId($rs); } |
|
11 | + public function dbClose(){global $modx; $modx->db->disconnect(); } |
|
12 | 12 | |
13 | - public function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) { |
|
13 | + public function makeList($array, $ulroot = 'root', $ulprefix = 'sub_', $type = '', $ordered = false, $tablevel = 0){ |
|
14 | 14 | // first find out whether the value passed is an array |
15 | 15 | if (!is_array($array)) { |
16 | 16 | return "<ul><li>Bad list</li></ul>"; |
17 | 17 | } |
18 | 18 | if (!empty ($type)) { |
19 | - $typestr= " style='list-style-type: $type'"; |
|
19 | + $typestr = " style='list-style-type: $type'"; |
|
20 | 20 | } else { |
21 | - $typestr= ""; |
|
21 | + $typestr = ""; |
|
22 | 22 | } |
23 | - $tabs= ""; |
|
24 | - for ($i= 0; $i < $tablevel; $i++) { |
|
23 | + $tabs = ""; |
|
24 | + for ($i = 0; $i < $tablevel; $i++) { |
|
25 | 25 | $tabs .= "\t"; |
26 | 26 | } |
27 | - $listhtml= $ordered == true ? $tabs . "<ol class='$ulroot'$typestr>\n" : $tabs . "<ul class='$ulroot'$typestr>\n"; |
|
27 | + $listhtml = $ordered == true ? $tabs."<ol class='$ulroot'$typestr>\n" : $tabs."<ul class='$ulroot'$typestr>\n"; |
|
28 | 28 | foreach ($array as $key => $value) { |
29 | 29 | if (is_array($value)) { |
30 | - $listhtml .= $tabs . "\t<li>" . $key . "\n" . $this->makeList($value, $ulprefix . $ulroot, $ulprefix, $type, $ordered, $tablevel +2) . $tabs . "\t</li>\n"; |
|
30 | + $listhtml .= $tabs."\t<li>".$key."\n".$this->makeList($value, $ulprefix.$ulroot, $ulprefix, $type, $ordered, $tablevel + 2).$tabs."\t</li>\n"; |
|
31 | 31 | } else { |
32 | - $listhtml .= $tabs . "\t<li>" . $value . "</li>\n"; |
|
32 | + $listhtml .= $tabs."\t<li>".$value."</li>\n"; |
|
33 | 33 | } |
34 | 34 | } |
35 | - $listhtml .= $ordered == true ? $tabs . "</ol>\n" : $tabs . "</ul>\n"; |
|
35 | + $listhtml .= $ordered == true ? $tabs."</ol>\n" : $tabs."</ul>\n"; |
|
36 | 36 | return $listhtml; |
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | - public function getUserData() { |
|
40 | + public function getUserData(){ |
|
41 | 41 | $client['ip'] = $_SERVER['REMOTE_ADDR']; |
42 | 42 | $client['ua'] = $_SERVER['HTTP_USER_AGENT']; |
43 | 43 | return $client; |
@@ -45,80 +45,80 @@ discard block |
||
45 | 45 | |
46 | 46 | # Returns true, install or interact when inside manager |
47 | 47 | // deprecated |
48 | - public function insideManager() { |
|
49 | - $m= false; |
|
50 | - if( defined('IN_MANAGER_MODE') && IN_MANAGER_MODE === true) { |
|
51 | - $m= true; |
|
48 | + public function insideManager(){ |
|
49 | + $m = false; |
|
50 | + if (defined('IN_MANAGER_MODE') && IN_MANAGER_MODE === true) { |
|
51 | + $m = true; |
|
52 | 52 | if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true') |
53 | - $m= "interact"; |
|
53 | + $m = "interact"; |
|
54 | 54 | else |
55 | 55 | if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true') |
56 | - $m= "install"; |
|
56 | + $m = "install"; |
|
57 | 57 | } |
58 | 58 | return $m; |
59 | 59 | } |
60 | 60 | |
61 | 61 | // deprecated |
62 | - public function putChunk($chunkName) { // alias name >.< |
|
62 | + public function putChunk($chunkName){ // alias name >.< |
|
63 | 63 | global $modx; |
64 | 64 | return $modx->getChunk($chunkName); |
65 | 65 | } |
66 | 66 | |
67 | - public function getDocGroups() { |
|
67 | + public function getDocGroups(){ |
|
68 | 68 | global $modx; |
69 | 69 | return $modx->getUserDocGroups(); |
70 | 70 | } // deprecated |
71 | 71 | |
72 | - public function changePassword($o, $n) { |
|
72 | + public function changePassword($o, $n){ |
|
73 | 73 | return changeWebUserPassword($o, $n); |
74 | 74 | } // deprecated |
75 | 75 | |
76 | - public function userLoggedIn() { |
|
76 | + public function userLoggedIn(){ |
|
77 | 77 | global $modx; |
78 | - $userdetails= array (); |
|
78 | + $userdetails = array(); |
|
79 | 79 | if ($modx->isFrontend() && isset ($_SESSION['webValidated'])) { |
80 | 80 | // web user |
81 | - $userdetails['loggedIn']= true; |
|
82 | - $userdetails['id']= $_SESSION['webInternalKey']; |
|
83 | - $userdetails['username']= $_SESSION['webShortname']; |
|
84 | - $userdetails['usertype']= 'web'; // added by Raymond |
|
81 | + $userdetails['loggedIn'] = true; |
|
82 | + $userdetails['id'] = $_SESSION['webInternalKey']; |
|
83 | + $userdetails['username'] = $_SESSION['webShortname']; |
|
84 | + $userdetails['usertype'] = 'web'; // added by Raymond |
|
85 | 85 | return $userdetails; |
86 | 86 | } else |
87 | 87 | if ($modx->isBackend() && isset ($_SESSION['mgrValidated'])) { |
88 | 88 | // manager user |
89 | - $userdetails['loggedIn']= true; |
|
90 | - $userdetails['id']= $_SESSION['mgrInternalKey']; |
|
91 | - $userdetails['username']= $_SESSION['mgrShortname']; |
|
92 | - $userdetails['usertype']= 'manager'; // added by Raymond |
|
89 | + $userdetails['loggedIn'] = true; |
|
90 | + $userdetails['id'] = $_SESSION['mgrInternalKey']; |
|
91 | + $userdetails['username'] = $_SESSION['mgrShortname']; |
|
92 | + $userdetails['usertype'] = 'manager'; // added by Raymond |
|
93 | 93 | return $userdetails; |
94 | 94 | } else { |
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - public function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) { |
|
99 | + public function getFormVars($method = "", $prefix = "", $trim = "", $REQUEST_METHOD){ |
|
100 | 100 | // function to retrieve form results into an associative array |
101 | 101 | global $modx; |
102 | - $results= array (); |
|
103 | - $method= strtoupper($method); |
|
102 | + $results = array(); |
|
103 | + $method = strtoupper($method); |
|
104 | 104 | if ($method == "") |
105 | - $method= $REQUEST_METHOD; |
|
105 | + $method = $REQUEST_METHOD; |
|
106 | 106 | if ($method == "POST") |
107 | - $method= & $_POST; |
|
108 | - elseif ($method == "GET") $method= & $_GET; |
|
107 | + $method = & $_POST; |
|
108 | + elseif ($method == "GET") $method = & $_GET; |
|
109 | 109 | else |
110 | 110 | return false; |
111 | 111 | reset($method); |
112 | 112 | foreach ($method as $key => $value) { |
113 | 113 | if (($prefix != "") && (substr($key, 0, strlen($prefix)) == $prefix)) { |
114 | 114 | if ($trim) { |
115 | - $pieces= explode($prefix, $key, 2); |
|
116 | - $key= $pieces[1]; |
|
117 | - $results[$key]= $value; |
|
115 | + $pieces = explode($prefix, $key, 2); |
|
116 | + $key = $pieces[1]; |
|
117 | + $results[$key] = $value; |
|
118 | 118 | } else |
119 | - $results[$key]= $value; |
|
119 | + $results[$key] = $value; |
|
120 | 120 | } |
121 | - elseif ($prefix == "") $results[$key]= $value; |
|
121 | + elseif ($prefix == "") $results[$key] = $value; |
|
122 | 122 | } |
123 | 123 | return $results; |
124 | 124 | } |
@@ -129,16 +129,16 @@ discard block |
||
129 | 129 | * @param string $msg Message to show |
130 | 130 | * @param string $url URL to redirect to |
131 | 131 | */ |
132 | - public function webAlert($msg, $url= "") { |
|
132 | + public function webAlert($msg, $url = ""){ |
|
133 | 133 | global $modx; |
134 | - $msg= addslashes($modx->db->escape($msg)); |
|
134 | + $msg = addslashes($modx->db->escape($msg)); |
|
135 | 135 | if (substr(strtolower($url), 0, 11) == "javascript:") { |
136 | - $act= "__WebAlert();"; |
|
137 | - $fnc= "function __WebAlert(){" . substr($url, 11) . "};"; |
|
136 | + $act = "__WebAlert();"; |
|
137 | + $fnc = "function __WebAlert(){".substr($url, 11)."};"; |
|
138 | 138 | } else { |
139 | - $act= ($url ? "window.location.href='" . addslashes($url) . "';" : ""); |
|
139 | + $act = ($url ? "window.location.href='".addslashes($url)."';" : ""); |
|
140 | 140 | } |
141 | - $html= "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>"; |
|
141 | + $html = "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>"; |
|
142 | 142 | if ($modx->isFrontend()) |
143 | 143 | $modx->regClientScript($html); |
144 | 144 | else { |
@@ -16,18 +16,18 @@ discard block |
||
16 | 16 | { |
17 | 17 | global $modx; |
18 | 18 | |
19 | - if(!defined('MODX_BASE_PATH')) return false; |
|
19 | + if (!defined('MODX_BASE_PATH')) return false; |
|
20 | 20 | $this->exportstart = $this->get_mtime(); |
21 | 21 | $this->count = 0; |
22 | 22 | $this->setUrlMode(); |
23 | 23 | $this->generate_mode = 'crawl'; |
24 | - $this->targetDir = $modx->config['base_path'] . 'temp/export'; |
|
25 | - if(!isset($this->total)) $this->getTotal(); |
|
24 | + $this->targetDir = $modx->config['base_path'].'temp/export'; |
|
25 | + if (!isset($this->total)) $this->getTotal(); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function setExportDir($dir) |
29 | 29 | { |
30 | - $dir = str_replace('\\','/',$dir); |
|
30 | + $dir = str_replace('\\', '/', $dir); |
|
31 | 31 | $dir = rtrim($dir, '/'); |
32 | 32 | $this->targetDir = $dir; |
33 | 33 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | global $modx; |
46 | 46 | |
47 | - if($modx->config['friendly_urls']==0) |
|
47 | + if ($modx->config['friendly_urls'] == 0) |
|
48 | 48 | { |
49 | 49 | $modx->config['friendly_urls'] = 1; |
50 | 50 | $modx->config['use_alias_path'] = 1; |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | $modx->config['make_folders'] = '1'; |
54 | 54 | } |
55 | 55 | |
56 | - public function getTotal($ignore_ids='', $noncache='0') |
|
56 | + public function getTotal($ignore_ids = '', $noncache = '0') |
|
57 | 57 | { |
58 | 58 | global $modx; |
59 | 59 | $tbl_site_content = $modx->getFullTableName('site_content'); |
60 | 60 | |
61 | 61 | $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids))); |
62 | - if(count($ignore_ids)>0) |
|
62 | + if (count($ignore_ids) > 0) |
|
63 | 63 | { |
64 | 64 | $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')"; |
65 | 65 | } else { |
@@ -70,72 +70,72 @@ discard block |
||
70 | 70 | |
71 | 71 | $noncache = ($noncache == 1) ? '' : 'AND cacheable=1'; |
72 | 72 | $where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}"; |
73 | - $rs = $modx->db->select('count(id)',$tbl_site_content,$where); |
|
73 | + $rs = $modx->db->select('count(id)', $tbl_site_content, $where); |
|
74 | 74 | $this->total = $modx->db->getValue($rs); |
75 | 75 | return $this->total; |
76 | 76 | } |
77 | 77 | |
78 | - public function removeDirectoryAll($directory='') |
|
78 | + public function removeDirectoryAll($directory = '') |
|
79 | 79 | { |
80 | 80 | $rs = false; |
81 | - if(empty($directory)) $directory = $this->targetDir; |
|
82 | - $directory = rtrim($directory,'/'); |
|
81 | + if (empty($directory)) $directory = $this->targetDir; |
|
82 | + $directory = rtrim($directory, '/'); |
|
83 | 83 | // if the path is not valid or is not a directory ... |
84 | - if(empty($directory)) return false; |
|
85 | - if(strpos($directory,MODX_BASE_PATH)===false) return $rs; |
|
84 | + if (empty($directory)) return false; |
|
85 | + if (strpos($directory, MODX_BASE_PATH) === false) return $rs; |
|
86 | 86 | |
87 | - if(!is_dir($directory)) return $rs; |
|
88 | - elseif(!is_readable($directory)) return $rs; |
|
87 | + if (!is_dir($directory)) return $rs; |
|
88 | + elseif (!is_readable($directory)) return $rs; |
|
89 | 89 | else |
90 | 90 | { |
91 | - $files = glob($directory . '/*'); |
|
92 | - if(!empty($files)) |
|
91 | + $files = glob($directory.'/*'); |
|
92 | + if (!empty($files)) |
|
93 | 93 | { |
94 | - foreach($files as $path) |
|
94 | + foreach ($files as $path) |
|
95 | 95 | { |
96 | 96 | $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | - if($directory !== $this->targetDir) $rs = rmdir($directory); |
|
100 | + if ($directory !== $this->targetDir) $rs = rmdir($directory); |
|
101 | 101 | |
102 | 102 | return $rs; |
103 | 103 | } |
104 | 104 | |
105 | 105 | public function makeFile($docid, $filepath) |
106 | 106 | { |
107 | - global $modx,$_lang; |
|
107 | + global $modx, $_lang; |
|
108 | 108 | $file_permission = octdec($modx->config['new_file_permissions']); |
109 | - if($this->generate_mode==='direct') |
|
109 | + if ($this->generate_mode === 'direct') |
|
110 | 110 | { |
111 | 111 | $back_lang = $_lang; |
112 | 112 | $src = $modx->executeParser($docid); |
113 | 113 | |
114 | 114 | $_lang = $back_lang; |
115 | 115 | } |
116 | - else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}"); |
|
116 | + else $src = $this->curl_get_contents(MODX_SITE_URL."index.php?id={$docid}"); |
|
117 | 117 | |
118 | 118 | |
119 | - if($src !== false) |
|
119 | + if ($src !== false) |
|
120 | 120 | { |
121 | - if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src); |
|
122 | - $result = file_put_contents($filepath,$src); |
|
123 | - if($result!==false) @chmod($filepath, $file_permission); |
|
121 | + if ($this->repl_before !== $this->repl_after) $src = str_replace($this->repl_before, $this->repl_after, $src); |
|
122 | + $result = file_put_contents($filepath, $src); |
|
123 | + if ($result !== false) @chmod($filepath, $file_permission); |
|
124 | 124 | |
125 | - if($result !== false) return 'success'; |
|
125 | + if ($result !== false) return 'success'; |
|
126 | 126 | else return 'failed_no_write'; |
127 | 127 | } |
128 | 128 | else return 'failed_no_retrieve'; |
129 | 129 | } |
130 | 130 | |
131 | - public function getFileName($docid, $alias='', $prefix, $suffix) |
|
131 | + public function getFileName($docid, $alias = '', $prefix, $suffix) |
|
132 | 132 | { |
133 | 133 | global $modx; |
134 | 134 | |
135 | - if($alias==='') $filename = $prefix.$docid.$suffix; |
|
135 | + if ($alias === '') $filename = $prefix.$docid.$suffix; |
|
136 | 136 | else |
137 | 137 | { |
138 | - if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false) |
|
138 | + if ($modx->config['suffix_mode'] === '1' && strpos($alias, '.') !== false) |
|
139 | 139 | { |
140 | 140 | $suffix = ''; |
141 | 141 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | return $filename; |
145 | 145 | } |
146 | 146 | |
147 | - public function run($parent=0) |
|
147 | + public function run($parent = 0) |
|
148 | 148 | { |
149 | 149 | global $_lang; |
150 | 150 | global $modx; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $tbl_site_content = $modx->getFullTableName('site_content'); |
153 | 153 | |
154 | 154 | $ignore_ids = $this->ignore_ids; |
155 | - $dirpath = $this->targetDir . '/'; |
|
155 | + $dirpath = $this->targetDir.'/'; |
|
156 | 156 | |
157 | 157 | $prefix = $modx->config['friendly_url_prefix']; |
158 | 158 | $suffix = $modx->config['friendly_url_suffix']; |
@@ -162,36 +162,36 @@ discard block |
||
162 | 162 | |
163 | 163 | $ph['status'] = 'fail'; |
164 | 164 | $ph['msg1'] = $_lang['export_site_failed']; |
165 | - $ph['msg2'] = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath; |
|
166 | - $msg_failed_no_write = $this->parsePlaceholder($tpl,$ph); |
|
165 | + $ph['msg2'] = $_lang["export_site_failed_no_write"].' - '.$dirpath; |
|
166 | + $msg_failed_no_write = $this->parsePlaceholder($tpl, $ph); |
|
167 | 167 | |
168 | 168 | $ph['msg2'] = $_lang["export_site_failed_no_retrieve"]; |
169 | - $msg_failed_no_retrieve = $this->parsePlaceholder($tpl,$ph); |
|
169 | + $msg_failed_no_retrieve = $this->parsePlaceholder($tpl, $ph); |
|
170 | 170 | |
171 | 171 | $ph['status'] = 'success'; |
172 | 172 | $ph['msg1'] = $_lang['export_site_success']; |
173 | 173 | $ph['msg2'] = ''; |
174 | - $msg_success = $this->parsePlaceholder($tpl,$ph); |
|
174 | + $msg_success = $this->parsePlaceholder($tpl, $ph); |
|
175 | 175 | |
176 | 176 | $ph['msg2'] = $_lang['export_site_success_skip_doc']; |
177 | - $msg_success_skip_doc = $this->parsePlaceholder($tpl,$ph); |
|
177 | + $msg_success_skip_doc = $this->parsePlaceholder($tpl, $ph); |
|
178 | 178 | |
179 | 179 | $ph['msg2'] = $_lang['export_site_success_skip_dir']; |
180 | - $msg_success_skip_dir = $this->parsePlaceholder($tpl,$ph); |
|
180 | + $msg_success_skip_dir = $this->parsePlaceholder($tpl, $ph); |
|
181 | 181 | |
182 | 182 | $fields = "id, alias, pagetitle, isfolder, (content = '' AND template = 0) AS wasNull, published"; |
183 | - $noncache = $_POST['includenoncache']==1 ? '' : 'AND cacheable=1'; |
|
183 | + $noncache = $_POST['includenoncache'] == 1 ? '' : 'AND cacheable=1'; |
|
184 | 184 | $where = "parent = '{$parent}' AND deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}"; |
185 | - $rs = $modx->db->select($fields,$tbl_site_content,$where); |
|
185 | + $rs = $modx->db->select($fields, $tbl_site_content, $where); |
|
186 | 186 | |
187 | 187 | $ph = array(); |
188 | - $ph['total'] = $this->total; |
|
188 | + $ph['total'] = $this->total; |
|
189 | 189 | $folder_permission = octdec($modx->config['new_folder_permissions']); |
190 | - while($row = $modx->db->getRow($rs)) |
|
190 | + while ($row = $modx->db->getRow($rs)) |
|
191 | 191 | { |
192 | 192 | $this->count++; |
193 | 193 | $filename = ''; |
194 | - $row['count'] = $this->count; |
|
194 | + $row['count'] = $this->count; |
|
195 | 195 | $row['url'] = $modx->makeUrl($row['id']); |
196 | 196 | |
197 | 197 | if (!$row['wasNull']) |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | $filename = $dirpath.$docname; |
201 | 201 | if (!is_file($filename)) |
202 | 202 | { |
203 | - if($row['published']==='1') |
|
203 | + if ($row['published'] === '1') |
|
204 | 204 | { |
205 | 205 | $status = $this->makeFile($row['id'], $filename); |
206 | - switch($status) |
|
206 | + switch ($status) |
|
207 | 207 | { |
208 | 208 | case 'failed_no_write' : |
209 | 209 | $row['status'] = $msg_failed_no_write; |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | $row['status'] = $msg_success_skip_dir; |
226 | 226 | $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row); |
227 | 227 | } |
228 | - if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false)) |
|
228 | + if ($row['isfolder'] === '1' && ($modx->config['suffix_mode'] !== '1' || strpos($row['alias'], '.') === false)) |
|
229 | 229 | { // needs making a folder |
230 | - $end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id']; |
|
231 | - $dir_path = $dirpath . $end_dir; |
|
232 | - if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE; |
|
230 | + $end_dir = ($row['alias'] !== '') ? $row['alias'] : $row['id']; |
|
231 | + $dir_path = $dirpath.$end_dir; |
|
232 | + if (strpos($dir_path, MODX_BASE_PATH) === false) return FALSE; |
|
233 | 233 | if (!is_dir($dir_path)) |
234 | 234 | { |
235 | 235 | if (is_file($dir_path)) @unlink($dir_path); |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | |
242 | - if($modx->config['make_folders']==='1' && $row['published']==='1') |
|
242 | + if ($modx->config['make_folders'] === '1' && $row['published'] === '1') |
|
243 | 243 | { |
244 | - if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html'); |
|
244 | + if (!empty($filename) && is_file($filename)) rename($filename, $dir_path.'/index.html'); |
|
245 | 245 | } |
246 | 246 | $this->targetDir = $dir_path; |
247 | 247 | $this->run($row['id']); |
@@ -250,16 +250,16 @@ discard block |
||
250 | 250 | return implode("\n", $this->output); |
251 | 251 | } |
252 | 252 | |
253 | - public function curl_get_contents($url, $timeout = 30 ) |
|
253 | + public function curl_get_contents($url, $timeout = 30) |
|
254 | 254 | { |
255 | - if(!function_exists('curl_init')) return @file_get_contents($url); |
|
255 | + if (!function_exists('curl_init')) return @file_get_contents($url); |
|
256 | 256 | |
257 | 257 | $ch = curl_init(); |
258 | 258 | curl_setopt($ch, CURLOPT_URL, $url); |
259 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT |
|
260 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER |
|
259 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT |
|
260 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER |
|
261 | 261 | curl_setopt($ch, CURLOPT_HEADER, false); |
262 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); |
|
262 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
263 | 263 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
264 | 264 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
265 | 265 | $result = curl_exec($ch); |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | return $result; |
268 | 268 | } |
269 | 269 | |
270 | - public function parsePlaceholder($tpl,$ph=array()) |
|
270 | + public function parsePlaceholder($tpl, $ph = array()) |
|
271 | 271 | { |
272 | - foreach($ph as $k=>$v) |
|
272 | + foreach ($ph as $k=>$v) |
|
273 | 273 | { |
274 | 274 | $k = "[+{$k}+]"; |
275 | - $tpl = str_replace($k,$v,$tpl); |
|
275 | + $tpl = str_replace($k, $v, $tpl); |
|
276 | 276 | } |
277 | 277 | return $tpl; |
278 | 278 | } |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataGridCnt = 0; |
12 | 12 | |
13 | -class DataGrid { |
|
13 | +class DataGrid{ |
|
14 | 14 | |
15 | 15 | public $ds; // datasource |
16 | 16 | public $id; |
17 | - public $pageSize; // pager settings |
|
17 | + public $pageSize; // pager settings |
|
18 | 18 | public $pageNumber; |
19 | 19 | public $pager; |
20 | - public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
20 | + public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
21 | 21 | |
22 | 22 | public $cssStyle; |
23 | 23 | public $cssClass; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public $colAligns; |
36 | 36 | public $colWraps; |
37 | 37 | public $colColors; |
38 | - public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
38 | + public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
39 | 39 | // data type: integer,float,currency,date |
40 | 40 | |
41 | 41 | public $header; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public $cellPadding; |
44 | 44 | public $cellSpacing; |
45 | 45 | |
46 | - public $rowAlign; // vertical alignment: top, middle, bottom |
|
46 | + public $rowAlign; // vertical alignment: top, middle, bottom |
|
47 | 47 | public $rowIdField; |
48 | 48 | |
49 | 49 | public $pagerStyle; |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public $cdelim; |
74 | 74 | |
75 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
75 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){ |
|
76 | 76 | global $__DataGridCnt; |
77 | 77 | |
78 | 78 | // set id |
79 | 79 | $__DataGridCnt++; |
80 | - $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt; |
|
80 | + $this->id = $this->id ? empty($id) : "dg".$__DataGridCnt; |
|
81 | 81 | |
82 | 82 | // set datasource |
83 | 83 | $this->ds = $ds; |
@@ -88,50 +88,50 @@ discard block |
||
88 | 88 | $this->pagerLocation = 'top-right'; |
89 | 89 | } |
90 | 90 | |
91 | - public function setDataSource($ds) { |
|
91 | + public function setDataSource($ds){ |
|
92 | 92 | $this->ds = $ds; |
93 | 93 | } |
94 | 94 | |
95 | - public function render() { |
|
95 | + public function render(){ |
|
96 | 96 | global $modx; |
97 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
98 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
99 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
100 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
97 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : ''; |
|
98 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : ""; |
|
99 | + $cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : ''; |
|
100 | + $cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : ''; |
|
101 | 101 | |
102 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
103 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
102 | + $pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : ''; |
|
103 | + $pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'"; |
|
104 | 104 | |
105 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
106 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
107 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
108 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
105 | + $this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : ''; |
|
106 | + $this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : ''; |
|
107 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : ''; |
|
108 | + $this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : ''; |
|
109 | 109 | |
110 | 110 | $this->_alt = 0; |
111 | 111 | $this->_total = 0; |
112 | 112 | |
113 | 113 | $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
114 | 114 | |
115 | - if(!$cssStyle && !$cssClass) { |
|
115 | + if (!$cssStyle && !$cssClass) { |
|
116 | 116 | $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
117 | 117 | } |
118 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
118 | + if (!$columnHeaderStyle && !$columnHeaderClass) { |
|
119 | 119 | $columnHeaderStyle = "style='color:black;background-color:silver'"; |
120 | 120 | } |
121 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
121 | + if (!$this->_itemStyle && !$this->_itemClass) { |
|
122 | 122 | $this->_itemStyle = "style='color:black;'"; |
123 | 123 | } |
124 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
124 | + if (!$this->_altItemStyle && !$this->_altItemClass) { |
|
125 | 125 | $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
126 | 126 | } |
127 | 127 | |
128 | - if($this->_isDataset && !$this->columns) { |
|
128 | + if ($this->_isDataset && !$this->columns) { |
|
129 | 129 | $cols = $modx->db->numFields($this->ds); |
130 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
130 | + for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->db->fieldName($this->ds, $i); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // start grid |
134 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
134 | + $tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>"; |
|
135 | 135 | $tblEnd = "</table>"; |
136 | 136 | |
137 | 137 | // build column header |
@@ -142,33 +142,33 @@ discard block |
||
142 | 142 | $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
143 | 143 | $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
144 | 144 | $this->_colcount = count($this->_colnames); |
145 | - if(!$this->_isDataset) { |
|
145 | + if (!$this->_isDataset) { |
|
146 | 146 | $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
147 | 147 | $this->ds = array_chunk($this->ds, $this->_colcount); |
148 | 148 | } |
149 | 149 | $tblColHdr = "<thead><tr>"; |
150 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
150 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
151 | 151 | $name = $this->_colnames[$c]; |
152 | 152 | $width = $this->_colwidths[$c]; |
153 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
153 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>"; |
|
154 | 154 | } |
155 | 155 | $tblColHdr .= "</tr></thead>\n"; |
156 | 156 | |
157 | 157 | // build rows |
158 | 158 | $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
159 | 159 | $this->_fieldnames = explode(",", $this->fields); |
160 | - if($rowcount == 0) { |
|
161 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
160 | + if ($rowcount == 0) { |
|
161 | + $tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n"; |
|
162 | 162 | } else { |
163 | 163 | // render grid items |
164 | - if($this->pageSize <= 0) { |
|
165 | - for($r = 0; $r < $rowcount; $r++) { |
|
164 | + if ($this->pageSize <= 0) { |
|
165 | + for ($r = 0; $r < $rowcount; $r++) { |
|
166 | 166 | $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
167 | 167 | $tblRows .= $this->RenderRowFnc($r + 1, $row); |
168 | 168 | } |
169 | 169 | } else { |
170 | - if(!$this->pager) { |
|
171 | - include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
170 | + if (!$this->pager) { |
|
171 | + include_once dirname(__FILE__)."/datasetpager.class.php"; |
|
172 | 172 | $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
173 | 173 | $this->pager->setRenderRowFnc($this); // pass this object |
174 | 174 | $this->pager->cssStyle = $pagerStyle; |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | $o = $tblStart; |
189 | 189 | $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
190 | 190 | $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
191 | - if($this->header) { |
|
192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
191 | + if ($this->header) { |
|
192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>"; |
|
193 | 193 | } |
194 | - if($tblPager && $ptop) { |
|
195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
194 | + if ($tblPager && $ptop) { |
|
195 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
196 | 196 | } |
197 | - $o .= $tblColHdr . $tblRows; |
|
198 | - if($tblPager && $pbot) { |
|
199 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
197 | + $o .= $tblColHdr.$tblRows; |
|
198 | + if ($tblPager && $pbot) { |
|
199 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
200 | 200 | } |
201 | - if($this->footer) { |
|
202 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
201 | + if ($this->footer) { |
|
202 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>"; |
|
203 | 203 | } |
204 | 204 | $o .= $tblEnd; |
205 | 205 | return $o; |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | |
208 | 208 | // format column values |
209 | 209 | |
210 | - public function RenderRowFnc($n, $row) { |
|
211 | - if($this->_alt == 0) { |
|
210 | + public function RenderRowFnc($n, $row){ |
|
211 | + if ($this->_alt == 0) { |
|
212 | 212 | $Style = $this->_itemStyle; |
213 | 213 | $Class = $this->_itemClass; |
214 | 214 | $this->_alt = 1; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $this->_alt = 0; |
219 | 219 | } |
220 | 220 | $o = "<tr>"; |
221 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
221 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
222 | 222 | $colStyle = $Style; |
223 | 223 | $fld = trim($this->_fieldnames[$c]); |
224 | 224 | $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
@@ -227,67 +227,67 @@ discard block |
||
227 | 227 | $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
228 | 228 | $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
229 | 229 | $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
230 | - if($color && $Style) { |
|
231 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
230 | + if ($color && $Style) { |
|
231 | + $colStyle = substr($colStyle, 0, -1).";background-color:$color;'"; |
|
232 | 232 | } |
233 | 233 | $value = $this->formatColumnValue($row, $value, $type, $align); |
234 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
234 | + $o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>"; |
|
235 | 235 | } |
236 | 236 | $o .= "</tr>\n"; |
237 | 237 | return $o; |
238 | 238 | } |
239 | 239 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
241 | - if(strpos($type, ":") !== false) { |
|
240 | + public function formatColumnValue($row, $value, $type, &$align){ |
|
241 | + if (strpos($type, ":") !== false) { |
|
242 | 242 | list($type, $type_format) = explode(":", $type, 2); |
243 | 243 | } |
244 | - switch(strtolower($type)) { |
|
244 | + switch (strtolower($type)) { |
|
245 | 245 | case "integer": |
246 | - if($align == "") { |
|
246 | + if ($align == "") { |
|
247 | 247 | $align = "right"; |
248 | 248 | } |
249 | 249 | $value = number_format($value); |
250 | 250 | break; |
251 | 251 | |
252 | 252 | case "float": |
253 | - if($align == "") { |
|
253 | + if ($align == "") { |
|
254 | 254 | $align = "right"; |
255 | 255 | } |
256 | - if(!$type_format) { |
|
256 | + if (!$type_format) { |
|
257 | 257 | $type_format = 2; |
258 | 258 | } |
259 | 259 | $value = number_format($value, $type_format); |
260 | 260 | break; |
261 | 261 | |
262 | 262 | case "currency": |
263 | - if($align == "") { |
|
263 | + if ($align == "") { |
|
264 | 264 | $align = "right"; |
265 | 265 | } |
266 | - if(!$type_format) { |
|
266 | + if (!$type_format) { |
|
267 | 267 | $type_format = 2; |
268 | 268 | } |
269 | - $value = "$" . number_format($value, $type_format); |
|
269 | + $value = "$".number_format($value, $type_format); |
|
270 | 270 | break; |
271 | 271 | |
272 | 272 | case "date": |
273 | - if($align == "") { |
|
273 | + if ($align == "") { |
|
274 | 274 | $align = "right"; |
275 | 275 | } |
276 | - if(!is_numeric($value)) { |
|
276 | + if (!is_numeric($value)) { |
|
277 | 277 | $value = strtotime($value); |
278 | 278 | } |
279 | - if(!$type_format) { |
|
279 | + if (!$type_format) { |
|
280 | 280 | $type_format = "%A %d, %B %Y"; |
281 | 281 | } |
282 | 282 | $value = strftime($type_format, $value); |
283 | 283 | break; |
284 | 284 | |
285 | 285 | case "boolean": |
286 | - if($align == '') { |
|
286 | + if ($align == '') { |
|
287 | 287 | $align = "center"; |
288 | 288 | } |
289 | 289 | $value = number_format($value); |
290 | - if($value) { |
|
290 | + if ($value) { |
|
291 | 291 | $value = '•'; |
292 | 292 | } else { |
293 | 293 | $value = ' '; |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | // replace [+value+] first |
299 | 299 | $value = str_replace("[+value+]", $value, $type_format); |
300 | 300 | // replace other [+fields+] |
301 | - if(strpos($value, "[+") !== false) { |
|
302 | - foreach($row as $k => $v) { |
|
301 | + if (strpos($value, "[+") !== false) { |
|
302 | + foreach ($row as $k => $v) { |
|
303 | 303 | $value = str_replace("[+$k+]", $v, $value); |
304 | 304 | } |
305 | 305 | } |