@@ -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 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | global $ContextMenuCnt; |
4 | 4 | $ContextMenuCnt = 0; |
5 | 5 | |
6 | -class ContextMenu { |
|
6 | +class ContextMenu{ |
|
7 | 7 | public $id; |
8 | 8 | /** |
9 | 9 | * @var string |
@@ -18,56 +18,56 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public $width = 120; |
20 | 20 | |
21 | - public function __construct($id = '', $width = 120, $visible = false) { |
|
21 | + public function __construct($id = '', $width = 120, $visible = false){ |
|
22 | 22 | global $ContextMenuCnt; |
23 | 23 | $ContextMenuCnt++; |
24 | 24 | $this->html = ""; |
25 | 25 | $this->visible = $visible ? $visible : false; |
26 | - $this->width = is_numeric($width) ? (int)$width : 120; |
|
27 | - $this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt; // set id |
|
26 | + $this->width = is_numeric($width) ? (int) $width : 120; |
|
27 | + $this->id = $id ? $id : "cntxMnu".$ContextMenuCnt; // set id |
|
28 | 28 | } |
29 | 29 | |
30 | - public function addItem($text, $action = "", $img = "", $disabled = 0) { |
|
30 | + public function addItem($text, $action = "", $img = "", $disabled = 0){ |
|
31 | 31 | global $base_url, $_style; |
32 | - if($disabled) { |
|
32 | + if ($disabled) { |
|
33 | 33 | return; |
34 | 34 | } |
35 | - if(!$img) { |
|
36 | - $img = $base_url . $_style['tx']; |
|
35 | + if (!$img) { |
|
36 | + $img = $base_url.$_style['tx']; |
|
37 | 37 | } |
38 | - if(substr($action, 0, 3) == "js:") { |
|
38 | + if (substr($action, 0, 3) == "js:") { |
|
39 | 39 | $action = substr($action, 3); |
40 | - } else if(substr($action, 0, 3) == "hl:") { |
|
41 | - $action = "window.location.href='" . substr($action, 3) . "'"; |
|
40 | + } else if (substr($action, 0, 3) == "hl:") { |
|
41 | + $action = "window.location.href='".substr($action, 3)."'"; |
|
42 | 42 | } else { |
43 | - $action = "window.location.href='" . $action . "'"; |
|
43 | + $action = "window.location.href='".$action."'"; |
|
44 | 44 | } |
45 | - $action = " onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('" . $this->id . "');\""; |
|
46 | - $this->html .= "<div class='" . ($disabled ? "cntxMnuItemDisabled" : "cntxMnuItem") . "' $action>"; |
|
47 | - if(substr($img, 0, 5) == 'fa fa') { |
|
48 | - $img = '<i class="' . $img . '"></i>'; |
|
49 | - } else if(substr($img, 0, 1) != '<') { |
|
50 | - $img = '<img src="' . $img . '" />'; |
|
45 | + $action = " onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('".$this->id."');\""; |
|
46 | + $this->html .= "<div class='".($disabled ? "cntxMnuItemDisabled" : "cntxMnuItem")."' $action>"; |
|
47 | + if (substr($img, 0, 5) == 'fa fa') { |
|
48 | + $img = '<i class="'.$img.'"></i>'; |
|
49 | + } else if (substr($img, 0, 1) != '<') { |
|
50 | + $img = '<img src="'.$img.'" />'; |
|
51 | 51 | } |
52 | - $this->html .= $img . ' ' . $text . '</div>'; |
|
52 | + $this->html .= $img.' '.$text.'</div>'; |
|
53 | 53 | } |
54 | 54 | |
55 | - public function addSeparator() { |
|
55 | + public function addSeparator(){ |
|
56 | 56 | $this->html .= " |
57 | 57 | <div class='cntxMnuSeparator'></div> |
58 | 58 | "; |
59 | 59 | } |
60 | 60 | |
61 | - public function render() { |
|
61 | + public function render(){ |
|
62 | 62 | global $ContextMenuScript; |
63 | 63 | |
64 | - $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>"; |
|
64 | + $html = $ContextMenuScript."<div id='".$this->id."' class='contextMenu' style='width:".$this->width."px; visibility:".($this->visible ? 'visible' : 'hidden')."'>".$this->html."</div>"; |
|
65 | 65 | $ContextMenuScript = ""; // reset css |
66 | 66 | return $html; |
67 | 67 | } |
68 | 68 | |
69 | - public function getClientScriptObject() { |
|
70 | - return "getCntxMenu('" . $this->id . "')"; |
|
69 | + public function getClientScriptObject(){ |
|
70 | + return "getCntxMenu('".$this->id."')"; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataSetPagerCnt = 0; |
12 | 12 | |
13 | -class DataSetPager { |
|
13 | +class DataSetPager{ |
|
14 | 14 | |
15 | 15 | public $ds; // datasource |
16 | 16 | public $pageSize; |
@@ -31,26 +31,26 @@ discard block |
||
31 | 31 | public $renderPagerFnc; |
32 | 32 | public $renderPagerFncArgs; |
33 | 33 | |
34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
34 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){ |
|
35 | 35 | global $_PAGE; // use view state object |
36 | 36 | |
37 | 37 | global $__DataSetPagerCnt; |
38 | 38 | |
39 | 39 | // set id |
40 | 40 | $__DataSetPagerCnt++; |
41 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
41 | + $this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt; |
|
42 | 42 | |
43 | 43 | // get pagenumber |
44 | 44 | // by setting pager to -1 cause pager to load it's last page number |
45 | - if($pageNumber == -1) { |
|
45 | + if ($pageNumber == -1) { |
|
46 | 46 | $pageNumber = 1; |
47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
47 | + if (isset($_GET["dpgn".$this->id])) { |
|
48 | + $pageNumber = $_GET["dpgn".$this->id]; |
|
49 | + } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) { |
|
50 | + $pageNumber = $_PAGE['vs'][$id.'_dpgn']; |
|
51 | 51 | } |
52 | 52 | } |
53 | - if(!is_numeric($pageNumber)) { |
|
53 | + if (!is_numeric($pageNumber)) { |
|
54 | 54 | $pageNumber = 1; |
55 | 55 | } |
56 | 56 | |
@@ -61,40 +61,40 @@ discard block |
||
61 | 61 | $this->pager = ''; |
62 | 62 | } |
63 | 63 | |
64 | - public function getRenderedPager() { |
|
64 | + public function getRenderedPager(){ |
|
65 | 65 | return $this->pager; |
66 | 66 | } |
67 | 67 | |
68 | - public function getRenderedRows() { |
|
68 | + public function getRenderedRows(){ |
|
69 | 69 | return $this->rows; |
70 | 70 | } |
71 | 71 | |
72 | - public function setDataSource($ds) { |
|
72 | + public function setDataSource($ds){ |
|
73 | 73 | $this->ds = $ds; |
74 | 74 | } |
75 | 75 | |
76 | - public function setPageSize($ps) { |
|
76 | + public function setPageSize($ps){ |
|
77 | 77 | $this->pageSize = $ps; |
78 | 78 | } |
79 | 79 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
80 | + public function setRenderRowFnc($fncName, $args = ""){ |
|
81 | 81 | $this->renderRowFnc = &$fncName; |
82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
83 | 83 | |
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
87 | + public function setRenderPagerFnc($fncName, $args = ""){ |
|
88 | 88 | $this->renderPagerFnc = $fncName; |
89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | 90 | } |
91 | 91 | |
92 | - public function render() { |
|
92 | + public function render(){ |
|
93 | 93 | global $modx, $_PAGE; |
94 | 94 | |
95 | 95 | $isDataset = $modx->db->isResult($this->ds); |
96 | 96 | |
97 | - if(!$this->selPageStyle) { |
|
97 | + if (!$this->selPageStyle) { |
|
98 | 98 | $this->selPageStyle = "font-weight:bold"; |
99 | 99 | } |
100 | 100 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
103 | 103 | |
104 | 104 | // render: no records found |
105 | - if($tnr <= 0) { |
|
105 | + if ($tnr <= 0) { |
|
106 | 106 | $fnc = $this->renderRowFnc; |
107 | 107 | $args = $this->renderRowFncArgs; |
108 | - if(isset($fnc)) { |
|
109 | - if($args != "") { |
|
108 | + if (isset($fnc)) { |
|
109 | + if ($args != "") { |
|
110 | 110 | $this->rows .= $fnc(0, null, $args); |
111 | 111 | } // if agrs was specified then we will pass three params |
112 | 112 | else { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // get total pages |
120 | 120 | $tp = ceil($tnr / $this->pageSize); |
121 | - if($this->pageNumber > $tp) { |
|
121 | + if ($this->pageNumber > $tp) { |
|
122 | 122 | $this->pageNumber = 1; |
123 | 123 | } |
124 | 124 | |
@@ -126,39 +126,39 @@ discard block |
||
126 | 126 | $p = $this->pageNumber; |
127 | 127 | |
128 | 128 | // save page number to view state if available |
129 | - if(isset($_PAGE['vs'])) { |
|
130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
129 | + if (isset($_PAGE['vs'])) { |
|
130 | + $_PAGE['vs'][$this->id.'_dpgn'] = $p; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
134 | - if($tp > 1) { |
|
134 | + if ($tp > 1) { |
|
135 | 135 | $url = ''; |
136 | 136 | $fnc = $this->renderPagerFnc; |
137 | 137 | $args = $this->renderPagerFncArgs; |
138 | - if(!isset($fnc)) { |
|
139 | - if($modx->isFrontend()) { |
|
140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
138 | + if (!isset($fnc)) { |
|
139 | + if ($modx->isFrontend()) { |
|
140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?'; |
|
141 | 141 | } else { |
142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
142 | + $url = $_SERVER['PHP_SELF'].'?'; |
|
143 | 143 | } |
144 | 144 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
145 | + foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) { |
|
146 | 146 | $i++; |
147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
147 | + $url .= (($i > 1) ? "&" : "")."$n=$v"; |
|
148 | 148 | } |
149 | - if($i >= 1) { |
|
149 | + if ($i >= 1) { |
|
150 | 150 | $url .= "&"; |
151 | 151 | } |
152 | 152 | } |
153 | - for($i = 1; $i <= $tp; $i++) { |
|
154 | - if(isset($fnc)) { |
|
155 | - if($args != "") { |
|
153 | + for ($i = 1; $i <= $tp; $i++) { |
|
154 | + if (isset($fnc)) { |
|
155 | + if ($args != "") { |
|
156 | 156 | $this->pager .= $fnc($p, $i, $args); |
157 | 157 | } else { |
158 | 158 | $this->pager .= $fnc($p, $i); |
159 | 159 | } |
160 | 160 | } else { |
161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
161 | + $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> "; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | $fnc = $this->renderRowFnc; |
168 | 168 | $args = $this->renderRowFncArgs; |
169 | 169 | |
170 | - if(isset($fnc)) { |
|
170 | + if (isset($fnc)) { |
|
171 | 171 | $i = 1; |
172 | 172 | $fncObject = is_object($fnc); |
173 | 173 | $minitems = (($p - 1) * $this->pageSize) + 1; |
174 | 174 | $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | - if($i >= $minitems && $i <= $maxitems) { |
|
177 | - if($fncObject) { |
|
178 | - if($args != "") { |
|
175 | + while ($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | + if ($i >= $minitems && $i <= $maxitems) { |
|
177 | + if ($fncObject) { |
|
178 | + if ($args != "") { |
|
179 | 179 | $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
180 | 180 | } else { |
181 | 181 | $this->rows .= $fnc->RenderRowFnc($i, $row); |
182 | 182 | } |
183 | 183 | } else { |
184 | - if($args != "") { |
|
184 | + if ($args != "") { |
|
185 | 185 | $this->rows .= $fnc($i, $row, $args); |
186 | 186 | } // if agrs was specified then we wil pass three params |
187 | 187 | else { |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | -$lockElementId = (int)$lockElementId; |
|
6 | +$lockElementId = (int) $lockElementId; |
|
7 | 7 | |
8 | 8 | if ($lockElementId > 0) { |
9 | 9 | ?> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | var stay = document.getElementById('stay'); |
19 | 19 | // Trigger unlock |
20 | 20 | if ((stay && stay.value !== '2') || !form_save) { |
21 | - var url = '<?php echo MODX_MANAGER_URL; ?>?a=67&type=<?php echo $lockElementType;?>&id=<?php echo $lockElementId;?>&o=' + Math.random(); |
|
21 | + var url = '<?php echo MODX_MANAGER_URL; ?>?a=67&type=<?php echo $lockElementType; ?>&id=<?php echo $lockElementId; ?>&o=' + Math.random(); |
|
22 | 22 | if (navigator.sendBeacon) { |
23 | 23 | navigator.sendBeacon(url) |
24 | 24 | } else { |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public $errormessage; |
17 | 17 | |
18 | - public function __construct() { |
|
18 | + public function __construct(){ |
|
19 | 19 | |
20 | 20 | $_lang = $this->include_lang('errormsg'); |
21 | 21 | |
@@ -50,33 +50,33 @@ discard block |
||
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | - function include_lang($context='common') { |
|
53 | + function include_lang($context = 'common'){ |
|
54 | 54 | global $modx; |
55 | 55 | $_lang = array(); |
56 | 56 | |
57 | - $context = trim($context,'/'); |
|
58 | - if(strpos($context,'..')!==false) return; |
|
57 | + $context = trim($context, '/'); |
|
58 | + if (strpos($context, '..') !== false) return; |
|
59 | 59 | |
60 | - if($context === 'common') |
|
61 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/'; |
|
60 | + if ($context === 'common') |
|
61 | + $lang_path = MODX_MANAGER_PATH.'includes/lang/'; |
|
62 | 62 | else |
63 | - $lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/"; |
|
64 | - include_once($lang_path . 'english.inc.php'); |
|
63 | + $lang_path = MODX_MANAGER_PATH."includes/lang/{$context}/"; |
|
64 | + include_once($lang_path.'english.inc.php'); |
|
65 | 65 | $manager_language = $modx->config['manager_language']; |
66 | - if(is_file("{$lang_path}{$manager_language}.inc.php")) |
|
66 | + if (is_file("{$lang_path}{$manager_language}.inc.php")) |
|
67 | 67 | include_once("{$lang_path}{$manager_language}.inc.php"); |
68 | 68 | return $_lang; |
69 | 69 | } |
70 | 70 | |
71 | - function setError($errorcode, $custommessage=""){ |
|
72 | - $this->errorcode=$errorcode; |
|
73 | - $this->errormessage=$this->errors[$errorcode]; |
|
74 | - if($custommessage!="") { |
|
75 | - $this->errormessage=$custommessage; |
|
71 | + function setError($errorcode, $custommessage = ""){ |
|
72 | + $this->errorcode = $errorcode; |
|
73 | + $this->errormessage = $this->errors[$errorcode]; |
|
74 | + if ($custommessage != "") { |
|
75 | + $this->errormessage = $custommessage; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | - function getError() { |
|
79 | + function getError(){ |
|
80 | 80 | return $this->errorcode; |
81 | 81 | } |
82 | 82 |