Completed
Push — develop ( 6a553b...48041c )
by Agel_Nash
06:37
created
manager/includes/src/Database.php 4 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -373,7 +373,8 @@  discard block
 block discarded – undo
373 373
      * @return bool|mixed|mysqli_result
374 374
      */
375 375
     public function save($fields, $table, $where = '')
376
-    { // This is similar to "replace into table".
376
+    {
377
+// This is similar to "replace into table".
377 378
 
378 379
         if ($where === '') {
379 380
             $mode = 'insert';
@@ -490,7 +491,7 @@  discard block
 block discarded – undo
490 491
     {
491 492
         $out = false;
492 493
         if ($ds instanceof mysqli_result) {
493
-            switch($mode){
494
+            switch($mode) {
494 495
                 case 'assoc':
495 496
                     $out = $ds->fetch_assoc();
496 497
                     break;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
             $orderBy = trim($orderBy);
226 226
             $limit = trim($limit);
227 227
             if ($where !== '' && stripos($where, 'WHERE') !== 0) {
228
-                $where = "WHERE {$where}";
228
+                $where = "where {$where}";
229 229
             }
230 230
             if ($orderBy !== '' && stripos($orderBy, 'ORDER BY') !== 0) {
231 231
                 $orderBy = "ORDER BY {$orderBy}";
232 232
             }
233 233
             if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) {
234
-                $limit = "LIMIT {$limit}";
234
+                $limit = "limit {$limit}";
235 235
             }
236 236
 
237 237
             $out = $this->query("DELETE FROM {$from} {$where} {$orderBy} {$limit}");
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
         $orderBy = trim($orderBy);
273 273
         $limit = trim($limit);
274 274
         if ($where !== '' && stripos($where, 'WHERE') !== 0) {
275
-            $where = "WHERE {$where}";
275
+            $where = "where {$where}";
276 276
         }
277 277
         if ($orderBy !== '' && stripos($orderBy, 'ORDER') !== 0) {
278 278
             $orderBy = "ORDER BY {$orderBy}";
279 279
         }
280 280
         if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) {
281
-            $limit = "LIMIT {$limit}";
281
+            $limit = "limit {$limit}";
282 282
         }
283 283
 
284
-        return $this->query("SELECT {$fields} FROM {$from} {$where} {$orderBy} {$limit}");
284
+        return $this->query("select {$fields} FROM {$from} {$where} {$orderBy} {$limit}");
285 285
     }
286 286
 
287 287
     /**
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
                     $where = trim($where);
350 350
                     $limit = trim($limit);
351 351
                     if ($where !== '' && stripos($where, 'WHERE') !== 0) {
352
-                        $where = "WHERE {$where}";
352
+                        $where = "where {$where}";
353 353
                     }
354 354
                     if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) {
355
-                        $limit = "LIMIT {$limit}";
355
+                        $limit = "limit {$limit}";
356 356
                     }
357 357
                     $this->query("INSERT INTO {$intotable} {$fields} SELECT {$fromfields} FROM {$fromtable} {$where} {$limit}");
358 358
                 }
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
     /**
373 373
      * @param $fields
374
-     * @param $table
374
+     * @param string $table
375 375
      * @param string $where
376 376
      * @return bool|mixed|mysqli_result
377 377
      */
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
     }
517 517
 
518 518
     /**
519
-     * @param $name
519
+     * @param string $name
520 520
      * @param mysqli_result|string $dsq
521 521
      * @return array
522 522
      */
@@ -650,6 +650,9 @@  discard block
 block discarded – undo
650 650
         return $this->conn->server_info;
651 651
     }
652 652
 
653
+    /**
654
+     * @param string $tbl
655
+     */
653 656
     public function getFullTableName($tbl)
654 657
     {
655 658
         return $this->config['dbase'] . ".`" . $this->config['table_prefix'] . $tbl . "`";
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $pre = null,
34 34
         $charset = '',
35 35
         $connection_method = 'SET CHARACTER SET'
36
-    ) {
36
+    ){
37 37
         $this->config['host'] = $host ? $host : $GLOBALS['database_server'];
38 38
         $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase'];
39 39
         $this->config['user'] = $uid ? $uid : $GLOBALS['database_user'];
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                         $ua = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_USER_AGENT']);
74 74
                         $referer = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_REFERER']);
75 75
                         $modx->sendmail(array(
76
-                            'subject' => 'Missing to create the database connection! from ' . $modx->getPhpCompat()->entities($modx->config['site_name']),
76
+                            'subject' => 'Missing to create the database connection! from '.$modx->getPhpCompat()->entities($modx->config['site_name']),
77 77
                             'body'    => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}",
78 78
                             'type'    => 'text'
79 79
                         ));
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $tend = $modx->getMicroTime();
89 89
             $totaltime = $tend - $tstart;
90 90
             if ($modx->dumpSQL) {
91
-                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s",
92
-                        $totaltime) . "</fieldset><br />";
91
+                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s",
92
+                        $totaltime)."</fieldset><br />";
93 93
             }
94 94
             $this->conn->set_charset($this->config['charset']);
95 95
             $this->isConnected = true;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         if (1000 < $safeCount) {
123 123
             exit("Too many loops '{$safeCount}'");
124 124
         }
125
-        if ( ! ($this->conn instanceof mysqli)) {
125
+        if (!($this->conn instanceof mysqli)) {
126 126
             $this->connect();
127 127
         }
128 128
         if (is_array($s)) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     public function query($sql, $watchError = true)
149 149
     {
150 150
         $modx = evolutionCMS();
151
-        if ( ! ($this->conn instanceof mysqli)) {
151
+        if (!($this->conn instanceof mysqli)) {
152 152
             $this->connect();
153 153
         }
154 154
         $tStart = $modx->getMicroTime();
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                 case 1091:
169 169
                     break;
170 170
                 default:
171
-                    $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql);
171
+                    $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql);
172 172
             }
173 173
         } else {
174 174
             $tend = $modx->getMicroTime();
@@ -182,24 +182,24 @@  discard block
 block discarded – undo
182 182
                     $debug_path[] = $line['function'];
183 183
                 }
184 184
                 $debug_path = implode(' > ', array_reverse($debug_path));
185
-                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms",
186
-                        $totalTime * 1000) . "</legend>";
187
-                $modx->queryCode .= $sql . '<br><br>';
185
+                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms",
186
+                        $totalTime * 1000)."</legend>";
187
+                $modx->queryCode .= $sql.'<br><br>';
188 188
                 if ($modx->event->name) {
189
-                    $modx->queryCode .= 'Current Event  => ' . $modx->event->name . '<br>';
189
+                    $modx->queryCode .= 'Current Event  => '.$modx->event->name.'<br>';
190 190
                 }
191 191
                 if ($modx->event->activePlugin) {
192
-                    $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>';
192
+                    $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>';
193 193
                 }
194 194
                 if ($modx->currentSnippet) {
195
-                    $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>';
195
+                    $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>';
196 196
                 }
197 197
                 if (stripos($sql, 'select') === 0) {
198
-                    $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>';
198
+                    $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>';
199 199
                 } else {
200
-                    $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>';
200
+                    $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>';
201 201
                 }
202
-                $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>';
202
+                $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>';
203 203
                 $modx->queryCode .= "</fieldset><br />";
204 204
             }
205 205
             $modx->executedQueries++;
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
                     if ($value === null || strtolower($value) === 'null') {
307 307
                         $f = 'NULL';
308 308
                     } else {
309
-                        $f = "'" . $value . "'";
309
+                        $f = "'".$value."'";
310 310
                     }
311
-                    $fields[$key] = "`{$key}` = " . $f;
311
+                    $fields[$key] = "`{$key}` = ".$f;
312 312
                 }
313 313
                 $fields = implode(',', $fields);
314 314
             }
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
                 $this->query("INSERT INTO {$intotable} {$fields}");
344 344
             } else {
345 345
                 if (empty($fromtable)) {
346
-                    $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '",
347
-                            array_values($fields)) . "')";
346
+                    $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '",
347
+                            array_values($fields))."')";
348 348
                     $this->query("INSERT INTO {$intotable} {$fields}");
349 349
                 } else {
350 350
                     $fromtable = $this->replaceFullTableName($fromtable);
351
-                    $fields = "(" . implode(",", array_keys($fields)) . ")";
351
+                    $fields = "(".implode(",", array_keys($fields)).")";
352 352
                     $where = trim($where);
353 353
                     $limit = trim($limit);
354 354
                     if ($where !== '' && stripos($where, 'WHERE') !== 0) {
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
      */
443 443
     public function getInsertId($conn = null)
444 444
     {
445
-        if (! ($conn instanceof mysqli)) {
446
-            $conn =& $this->conn;
445
+        if (!($conn instanceof mysqli)) {
446
+            $conn = & $this->conn;
447 447
         }
448 448
 
449 449
         return $conn->insert_id;
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
      */
456 456
     public function getAffectedRows($conn = null)
457 457
     {
458
-        if (! ($conn instanceof mysqli)) {
459
-            $conn =& $this->conn;
458
+        if (!($conn instanceof mysqli)) {
459
+            $conn = & $this->conn;
460 460
         }
461 461
 
462 462
         return $conn->affected_rows;
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
      */
469 469
     public function getLastError($conn = null)
470 470
     {
471
-        if (! ($conn instanceof mysqli)) {
472
-            $conn =& $this->conn;
471
+        if (!($conn instanceof mysqli)) {
472
+            $conn = & $this->conn;
473 473
         }
474 474
 
475 475
         return $conn->error;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
     {
494 494
         $out = false;
495 495
         if ($ds instanceof mysqli_result) {
496
-            switch($mode){
496
+            switch ($mode) {
497 497
                 case 'assoc':
498 498
                     $out = $ds->fetch_assoc();
499 499
                     break;
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
     public function getColumn($name, $dsq)
524 524
     {
525 525
         $col = array();
526
-        if ( ! ($dsq instanceof mysqli_result)) {
526
+        if (!($dsq instanceof mysqli_result)) {
527 527
             $dsq = $this->query($dsq);
528 528
         }
529 529
         if ($dsq) {
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
     public function getColumnNames($dsq)
543 543
     {
544 544
         $names = array();
545
-        if ( ! ($dsq instanceof mysqli_result)) {
545
+        if (!($dsq instanceof mysqli_result)) {
546 546
             $dsq = $this->query($dsq);
547 547
         }
548 548
         if ($dsq) {
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
     public function getValue($dsq)
563 563
     {
564 564
         $out = false;
565
-        if ( ! ($dsq instanceof mysqli_result)) {
565
+        if (!($dsq instanceof mysqli_result)) {
566 566
             $dsq = $this->query($dsq);
567 567
         }
568 568
         if ($dsq) {
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 
653 653
     public function getFullTableName($tbl)
654 654
     {
655
-        return $this->config['dbase'] . ".`" . $this->config['table_prefix'] . $tbl . "`";
655
+        return $this->config['dbase'].".`".$this->config['table_prefix'].$tbl."`";
656 656
     }
657 657
 
658 658
     /**
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
         $tableName = trim($tableName);
666 666
         $dbase = trim($this->config['dbase'], '`');
667 667
         $prefix = $this->config['table_prefix'];
668
-        if ((bool)$force === true) {
668
+        if ((bool) $force === true) {
669 669
             $result = "`{$dbase}`.`{$prefix}{$tableName}`";
670 670
         } elseif (strpos($tableName, '[+prefix+]') !== false) {
671 671
             $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName);
Please login to merge, or discard this patch.
manager/includes/src/Interfaces/ManagerApiInterface.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,5 @@
 block discarded – undo
1 1
 <?php namespace EvolutionCMS\Interfaces;
2 2
 
3
-interface ManagerApiInterface{}
3
+interface ManagerApiInterface
4
+{
5
+}
Please login to merge, or discard this patch.
manager/includes/src/Interfaces/ServiceProviderInterface.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,5 @@
 block discarded – undo
1 1
 <?php namespace EvolutionCMS\Interfaces;
2 2
 
3
-interface ServiceProviderInterface{}
3
+interface ServiceProviderInterface
4
+{
5
+}
Please login to merge, or discard this patch.
manager/includes/src/Interfaces/PasswordHashInterface.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,5 @@
 block discarded – undo
1 1
 <?php namespace EvolutionCMS\Interfaces;
2 2
 
3
-interface PasswordHashInterface{}
3
+interface PasswordHashInterface
4
+{
5
+}
Please login to merge, or discard this patch.
manager/includes/src/Support/DataGrid.php 4 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 class DataGrid implements DataGridInterface{
15 15
 
16
-	public $ds; // datasource
16
+    public $ds; // datasource
17 17
     public $id;
18 18
     public $pageSize;            // pager settings
19 19
     public $pageNumber;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     public $colWraps;
38 38
     public $colColors;
39 39
     public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
40
-	// data type: integer,float,currency,date
40
+    // data type: integer,float,currency,date
41 41
 
42 42
     public $header;
43 43
     public $footer;
@@ -76,236 +76,236 @@  discard block
 block discarded – undo
76 76
     public static $dataGridCnt;
77 77
 
78 78
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
79
-		// set id
80
-		self::$dataGridCnt++;
81
-		$this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt;
79
+        // set id
80
+        self::$dataGridCnt++;
81
+        $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt;
82 82
 
83
-		// set datasource
84
-		$this->ds = $ds;
83
+        // set datasource
84
+        $this->ds = $ds;
85 85
 
86
-		// set pager
87
-		$this->pageSize = $pageSize;
88
-		$this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number
89
-		$this->pagerLocation = 'top-right';
90
-	}
86
+        // set pager
87
+        $this->pageSize = $pageSize;
88
+        $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number
89
+        $this->pagerLocation = 'top-right';
90
+    }
91 91
 
92 92
     public function setDataSource($ds) {
93
-		$this->ds = $ds;
94
-	}
93
+        $this->ds = $ds;
94
+    }
95 95
 
96 96
     public function render() {
97 97
         $modx = evolutionCMS();
98
-		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
99
-		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
100
-		$cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
101
-		$cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
102
-
103
-		$pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
104
-		$pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
105
-
106
-		$this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
107
-		$this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
108
-		$this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
109
-		$this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
110
-
111
-		$this->_alt = 0;
112
-		$this->_total = 0;
113
-
114
-		$this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array
115
-
116
-		if(!$cssStyle && !$cssClass) {
117
-			$cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
118
-		}
119
-		if(!$columnHeaderStyle && !$columnHeaderClass) {
120
-			$columnHeaderStyle = "style='color:black;background-color:silver'";
121
-		}
122
-		if(!$this->_itemStyle && !$this->_itemClass) {
123
-			$this->_itemStyle = "style='color:black;'";
124
-		}
125
-		if(!$this->_altItemStyle && !$this->_altItemClass) {
126
-			$this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
127
-		}
128
-
129
-		if($this->_isDataset && !$this->columns) {
130
-			$cols = $modx->getDatabase()->numFields($this->ds);
131
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i);
132
-		}
133
-
134
-		// start grid
135
-		$tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
136
-		$tblEnd = "</table>";
137
-
138
-		// build column header
139
-		$this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
140
-		$this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
141
-		$this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
142
-		$this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
143
-		$this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
144
-		$this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
145
-		$this->_colcount = count($this->_colnames);
146
-		if(!$this->_isDataset) {
147
-			$this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
148
-			$this->ds = array_chunk($this->ds, $this->_colcount);
149
-		}
150
-		$tblColHdr = "<thead><tr>";
151
-		for($c = 0; $c < $this->_colcount; $c++) {
152
-			$name = $this->_colnames[$c];
153
-			$width = $this->_colwidths[$c];
154
-			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
155
-		}
156
-		$tblColHdr .= "</tr></thead>\n";
157
-
158
-		// build rows
159
-		$rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds);
160
-		$this->_fieldnames = explode(",", $this->fields);
161
-		if($rowcount == 0) {
162
-			$tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
163
-		} else {
164
-			// render grid items
165
-			if($this->pageSize <= 0) {
166
-				for($r = 0; $r < $rowcount; $r++) {
167
-					$row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r];
168
-					$tblRows .= $this->RenderRowFnc($r + 1, $row);
169
-				}
170
-			} else {
171
-				if(!$this->pager) {
172
-					$this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173
-					$this->pager->setRenderRowFnc($this); // pass this object
174
-					$this->pager->cssStyle = $pagerStyle;
175
-					$this->pager->cssClass = $pagerClass;
176
-				} else {
177
-					$this->pager->pageSize = $this->pageSize;
178
-					$this->pager->pageNumber = $this->pageNumber;
179
-				}
180
-
181
-				$this->pager->render();
182
-				$tblRows = $this->pager->getRenderedRows();
183
-				$tblPager = $this->pager->getRenderedPager();
184
-			}
185
-		}
186
-
187
-		// setup header,pager and footer
188
-		$o = $tblStart;
189
-		$ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190
-		$pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
-		if($this->header) {
192
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
193
-		}
194
-		if($tblPager && $ptop) {
195
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
196
-		}
197
-		$o .= $tblColHdr . $tblRows;
198
-		if($tblPager && $pbot) {
199
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
-		}
201
-		if($this->footer) {
202
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
203
-		}
204
-		$o .= $tblEnd;
205
-		return $o;
206
-	}
207
-
208
-	// format column values
98
+        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
99
+        $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
100
+        $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
101
+        $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
102
+
103
+        $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
104
+        $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
105
+
106
+        $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
107
+        $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
108
+        $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
109
+        $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
110
+
111
+        $this->_alt = 0;
112
+        $this->_total = 0;
113
+
114
+        $this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array
115
+
116
+        if(!$cssStyle && !$cssClass) {
117
+            $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
118
+        }
119
+        if(!$columnHeaderStyle && !$columnHeaderClass) {
120
+            $columnHeaderStyle = "style='color:black;background-color:silver'";
121
+        }
122
+        if(!$this->_itemStyle && !$this->_itemClass) {
123
+            $this->_itemStyle = "style='color:black;'";
124
+        }
125
+        if(!$this->_altItemStyle && !$this->_altItemClass) {
126
+            $this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
127
+        }
128
+
129
+        if($this->_isDataset && !$this->columns) {
130
+            $cols = $modx->getDatabase()->numFields($this->ds);
131
+            for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i);
132
+        }
133
+
134
+        // start grid
135
+        $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
136
+        $tblEnd = "</table>";
137
+
138
+        // build column header
139
+        $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
140
+        $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
141
+        $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
142
+        $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
143
+        $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
144
+        $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
145
+        $this->_colcount = count($this->_colnames);
146
+        if(!$this->_isDataset) {
147
+            $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
148
+            $this->ds = array_chunk($this->ds, $this->_colcount);
149
+        }
150
+        $tblColHdr = "<thead><tr>";
151
+        for($c = 0; $c < $this->_colcount; $c++) {
152
+            $name = $this->_colnames[$c];
153
+            $width = $this->_colwidths[$c];
154
+            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
155
+        }
156
+        $tblColHdr .= "</tr></thead>\n";
157
+
158
+        // build rows
159
+        $rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds);
160
+        $this->_fieldnames = explode(",", $this->fields);
161
+        if($rowcount == 0) {
162
+            $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
163
+        } else {
164
+            // render grid items
165
+            if($this->pageSize <= 0) {
166
+                for($r = 0; $r < $rowcount; $r++) {
167
+                    $row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r];
168
+                    $tblRows .= $this->RenderRowFnc($r + 1, $row);
169
+                }
170
+            } else {
171
+                if(!$this->pager) {
172
+                    $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173
+                    $this->pager->setRenderRowFnc($this); // pass this object
174
+                    $this->pager->cssStyle = $pagerStyle;
175
+                    $this->pager->cssClass = $pagerClass;
176
+                } else {
177
+                    $this->pager->pageSize = $this->pageSize;
178
+                    $this->pager->pageNumber = $this->pageNumber;
179
+                }
180
+
181
+                $this->pager->render();
182
+                $tblRows = $this->pager->getRenderedRows();
183
+                $tblPager = $this->pager->getRenderedPager();
184
+            }
185
+        }
186
+
187
+        // setup header,pager and footer
188
+        $o = $tblStart;
189
+        $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190
+        $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
+        if($this->header) {
192
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
193
+        }
194
+        if($tblPager && $ptop) {
195
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
196
+        }
197
+        $o .= $tblColHdr . $tblRows;
198
+        if($tblPager && $pbot) {
199
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
+        }
201
+        if($this->footer) {
202
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
203
+        }
204
+        $o .= $tblEnd;
205
+        return $o;
206
+    }
207
+
208
+    // format column values
209 209
 
210 210
     public function RenderRowFnc($n, $row) {
211
-		if($this->_alt == 0) {
212
-			$Style = $this->_itemStyle;
213
-			$Class = $this->_itemClass;
214
-			$this->_alt = 1;
215
-		} else {
216
-			$Style = $this->_altItemStyle;
217
-			$Class = $this->_altItemClass;
218
-			$this->_alt = 0;
219
-		}
220
-		$o = "<tr>";
221
-		for($c = 0; $c < $this->_colcount; $c++) {
222
-			$colStyle = $Style;
223
-			$fld = trim($this->_fieldnames[$c]);
224
-			$width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
225
-			$align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
226
-			$color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
227
-			$type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228
-			$nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229
-			$value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
-			if($color && $Style) {
231
-				$colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
232
-			}
233
-			$value = $this->formatColumnValue($row, $value, $type, $align);
234
-			$o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
235
-		}
236
-		$o .= "</tr>\n";
237
-		return $o;
238
-	}
211
+        if($this->_alt == 0) {
212
+            $Style = $this->_itemStyle;
213
+            $Class = $this->_itemClass;
214
+            $this->_alt = 1;
215
+        } else {
216
+            $Style = $this->_altItemStyle;
217
+            $Class = $this->_altItemClass;
218
+            $this->_alt = 0;
219
+        }
220
+        $o = "<tr>";
221
+        for($c = 0; $c < $this->_colcount; $c++) {
222
+            $colStyle = $Style;
223
+            $fld = trim($this->_fieldnames[$c]);
224
+            $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
225
+            $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
226
+            $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
227
+            $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228
+            $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229
+            $value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
+            if($color && $Style) {
231
+                $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
232
+            }
233
+            $value = $this->formatColumnValue($row, $value, $type, $align);
234
+            $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
235
+        }
236
+        $o .= "</tr>\n";
237
+        return $o;
238
+    }
239 239
 
240 240
     public function formatColumnValue($row, $value, $type, &$align) {
241
-		if(strpos($type, ":") !== false) {
242
-			list($type, $type_format) = explode(":", $type, 2);
243
-		}
244
-		switch(strtolower($type)) {
245
-			case "integer":
246
-				if($align == "") {
247
-					$align = "right";
248
-				}
249
-				$value = number_format($value);
250
-				break;
251
-
252
-			case "float":
253
-				if($align == "") {
254
-					$align = "right";
255
-				}
256
-				if(!$type_format) {
257
-					$type_format = 2;
258
-				}
259
-				$value = number_format($value, $type_format);
260
-				break;
261
-
262
-			case "currency":
263
-				if($align == "") {
264
-					$align = "right";
265
-				}
266
-				if(!$type_format) {
267
-					$type_format = 2;
268
-				}
269
-				$value = "$" . number_format($value, $type_format);
270
-				break;
271
-
272
-			case "date":
273
-				if($align == "") {
274
-					$align = "right";
275
-				}
276
-				if(!is_numeric($value)) {
277
-					$value = strtotime($value);
278
-				}
279
-				if(!$type_format) {
280
-					$type_format = "%A %d, %B %Y";
281
-				}
282
-				$value = strftime($type_format, $value);
283
-				break;
284
-
285
-			case "boolean":
286
-				if($align == '') {
287
-					$align = "center";
288
-				}
289
-				$value = number_format($value);
290
-				if($value) {
291
-					$value = '&bull;';
292
-				} else {
293
-					$value = '&nbsp;';
294
-				}
295
-				break;
296
-
297
-			case "template":
298
-				// replace [+value+] first
299
-				$value = str_replace("[+value+]", $value, $type_format);
300
-				// replace other [+fields+]
301
-				if(strpos($value, "[+") !== false) {
302
-					foreach($row as $k => $v) {
303
-						$value = str_replace("[+$k+]", $v, $value);
304
-					}
305
-				}
306
-				break;
307
-
308
-		}
309
-		return $value;
310
-	}
241
+        if(strpos($type, ":") !== false) {
242
+            list($type, $type_format) = explode(":", $type, 2);
243
+        }
244
+        switch(strtolower($type)) {
245
+            case "integer":
246
+                if($align == "") {
247
+                    $align = "right";
248
+                }
249
+                $value = number_format($value);
250
+                break;
251
+
252
+            case "float":
253
+                if($align == "") {
254
+                    $align = "right";
255
+                }
256
+                if(!$type_format) {
257
+                    $type_format = 2;
258
+                }
259
+                $value = number_format($value, $type_format);
260
+                break;
261
+
262
+            case "currency":
263
+                if($align == "") {
264
+                    $align = "right";
265
+                }
266
+                if(!$type_format) {
267
+                    $type_format = 2;
268
+                }
269
+                $value = "$" . number_format($value, $type_format);
270
+                break;
271
+
272
+            case "date":
273
+                if($align == "") {
274
+                    $align = "right";
275
+                }
276
+                if(!is_numeric($value)) {
277
+                    $value = strtotime($value);
278
+                }
279
+                if(!$type_format) {
280
+                    $type_format = "%A %d, %B %Y";
281
+                }
282
+                $value = strftime($type_format, $value);
283
+                break;
284
+
285
+            case "boolean":
286
+                if($align == '') {
287
+                    $align = "center";
288
+                }
289
+                $value = number_format($value);
290
+                if($value) {
291
+                    $value = '&bull;';
292
+                } else {
293
+                    $value = '&nbsp;';
294
+                }
295
+                break;
296
+
297
+            case "template":
298
+                // replace [+value+] first
299
+                $value = str_replace("[+value+]", $value, $type_format);
300
+                // replace other [+fields+]
301
+                if(strpos($value, "[+") !== false) {
302
+                    foreach($row as $k => $v) {
303
+                        $value = str_replace("[+$k+]", $v, $value);
304
+                    }
305
+                }
306
+                break;
307
+
308
+        }
309
+        return $value;
310
+    }
311 311
 }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 
16 16
 	public $ds; // datasource
17 17
     public $id;
18
-    public $pageSize;            // pager settings
18
+    public $pageSize; // pager settings
19 19
     public $pageNumber;
20 20
     public $pager;
21
-    public $pagerLocation;        // top-right, top-left, bottom-left, bottom-right, both-left, both-right
21
+    public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right
22 22
 
23 23
     public $cssStyle;
24 24
     public $cssClass;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public $colAligns;
37 37
     public $colWraps;
38 38
     public $colColors;
39
-    public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39
+    public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
40 40
 	// data type: integer,float,currency,date
41 41
 
42 42
     public $header;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     public $cellPadding;
45 45
     public $cellSpacing;
46 46
 
47
-    public $rowAlign;            // vertical alignment: top, middle, bottom
47
+    public $rowAlign; // vertical alignment: top, middle, bottom
48 48
     public $rowIdField;
49 49
 
50 50
     public $pagerStyle;
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 
76 76
     public static $dataGridCnt;
77 77
 
78
-    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
78
+    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){
79 79
 		// set id
80 80
 		self::$dataGridCnt++;
81
-		$this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt;
81
+		$this->id = $this->id ? empty($id) : "dg".self::$dataGridCnt;
82 82
 
83 83
 		// set datasource
84 84
 		$this->ds = $ds;
@@ -89,50 +89,50 @@  discard block
 block discarded – undo
89 89
 		$this->pagerLocation = 'top-right';
90 90
 	}
91 91
 
92
-    public function setDataSource($ds) {
92
+    public function setDataSource($ds){
93 93
 		$this->ds = $ds;
94 94
 	}
95 95
 
96
-    public function render() {
96
+    public function render(){
97 97
         $modx = evolutionCMS();
98
-		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
99
-		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
100
-		$cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
101
-		$cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
98
+		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : '';
99
+		$columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : "";
100
+		$cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : '';
101
+		$cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : '';
102 102
 
103
-		$pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
104
-		$pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
103
+		$pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : '';
104
+		$pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'";
105 105
 
106
-		$this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
107
-		$this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
108
-		$this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
109
-		$this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
106
+		$this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : '';
107
+		$this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : '';
108
+		$this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : '';
109
+		$this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : '';
110 110
 
111 111
 		$this->_alt = 0;
112 112
 		$this->_total = 0;
113 113
 
114 114
 		$this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array
115 115
 
116
-		if(!$cssStyle && !$cssClass) {
116
+		if (!$cssStyle && !$cssClass) {
117 117
 			$cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
118 118
 		}
119
-		if(!$columnHeaderStyle && !$columnHeaderClass) {
119
+		if (!$columnHeaderStyle && !$columnHeaderClass) {
120 120
 			$columnHeaderStyle = "style='color:black;background-color:silver'";
121 121
 		}
122
-		if(!$this->_itemStyle && !$this->_itemClass) {
122
+		if (!$this->_itemStyle && !$this->_itemClass) {
123 123
 			$this->_itemStyle = "style='color:black;'";
124 124
 		}
125
-		if(!$this->_altItemStyle && !$this->_altItemClass) {
125
+		if (!$this->_altItemStyle && !$this->_altItemClass) {
126 126
 			$this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
127 127
 		}
128 128
 
129
-		if($this->_isDataset && !$this->columns) {
129
+		if ($this->_isDataset && !$this->columns) {
130 130
 			$cols = $modx->getDatabase()->numFields($this->ds);
131
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i);
131
+			for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->getDatabase()->fieldName($this->ds, $i);
132 132
 		}
133 133
 
134 134
 		// start grid
135
-		$tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
135
+		$tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>";
136 136
 		$tblEnd = "</table>";
137 137
 
138 138
 		// build column header
@@ -143,32 +143,32 @@  discard block
 block discarded – undo
143 143
 		$this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
144 144
 		$this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
145 145
 		$this->_colcount = count($this->_colnames);
146
-		if(!$this->_isDataset) {
146
+		if (!$this->_isDataset) {
147 147
 			$this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
148 148
 			$this->ds = array_chunk($this->ds, $this->_colcount);
149 149
 		}
150 150
 		$tblColHdr = "<thead><tr>";
151
-		for($c = 0; $c < $this->_colcount; $c++) {
151
+		for ($c = 0; $c < $this->_colcount; $c++) {
152 152
 			$name = $this->_colnames[$c];
153 153
 			$width = $this->_colwidths[$c];
154
-			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
154
+			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>";
155 155
 		}
156 156
 		$tblColHdr .= "</tr></thead>\n";
157 157
 
158 158
 		// build rows
159 159
 		$rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds);
160 160
 		$this->_fieldnames = explode(",", $this->fields);
161
-		if($rowcount == 0) {
162
-			$tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
161
+		if ($rowcount == 0) {
162
+			$tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n";
163 163
 		} else {
164 164
 			// render grid items
165
-			if($this->pageSize <= 0) {
166
-				for($r = 0; $r < $rowcount; $r++) {
165
+			if ($this->pageSize <= 0) {
166
+				for ($r = 0; $r < $rowcount; $r++) {
167 167
 					$row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r];
168 168
 					$tblRows .= $this->RenderRowFnc($r + 1, $row);
169 169
 				}
170 170
 			} else {
171
-				if(!$this->pager) {
171
+				if (!$this->pager) {
172 172
 					$this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173 173
 					$this->pager->setRenderRowFnc($this); // pass this object
174 174
 					$this->pager->cssStyle = $pagerStyle;
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
 		$o = $tblStart;
189 189
 		$ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190 190
 		$pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
-		if($this->header) {
192
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
191
+		if ($this->header) {
192
+			$o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>";
193 193
 		}
194
-		if($tblPager && $ptop) {
195
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
194
+		if ($tblPager && $ptop) {
195
+			$o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
196 196
 		}
197
-		$o .= $tblColHdr . $tblRows;
198
-		if($tblPager && $pbot) {
199
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
197
+		$o .= $tblColHdr.$tblRows;
198
+		if ($tblPager && $pbot) {
199
+			$o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
200 200
 		}
201
-		if($this->footer) {
202
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
201
+		if ($this->footer) {
202
+			$o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>";
203 203
 		}
204 204
 		$o .= $tblEnd;
205 205
 		return $o;
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 
208 208
 	// format column values
209 209
 
210
-    public function RenderRowFnc($n, $row) {
211
-		if($this->_alt == 0) {
210
+    public function RenderRowFnc($n, $row){
211
+		if ($this->_alt == 0) {
212 212
 			$Style = $this->_itemStyle;
213 213
 			$Class = $this->_itemClass;
214 214
 			$this->_alt = 1;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 			$this->_alt = 0;
219 219
 		}
220 220
 		$o = "<tr>";
221
-		for($c = 0; $c < $this->_colcount; $c++) {
221
+		for ($c = 0; $c < $this->_colcount; $c++) {
222 222
 			$colStyle = $Style;
223 223
 			$fld = trim($this->_fieldnames[$c]);
224 224
 			$width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
@@ -227,67 +227,67 @@  discard block
 block discarded – undo
227 227
 			$type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228 228
 			$nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229 229
 			$value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
-			if($color && $Style) {
231
-				$colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
230
+			if ($color && $Style) {
231
+				$colStyle = substr($colStyle, 0, -1).";background-color:$color;'";
232 232
 			}
233 233
 			$value = $this->formatColumnValue($row, $value, $type, $align);
234
-			$o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
234
+			$o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>";
235 235
 		}
236 236
 		$o .= "</tr>\n";
237 237
 		return $o;
238 238
 	}
239 239
 
240
-    public function formatColumnValue($row, $value, $type, &$align) {
241
-		if(strpos($type, ":") !== false) {
240
+    public function formatColumnValue($row, $value, $type, &$align){
241
+		if (strpos($type, ":") !== false) {
242 242
 			list($type, $type_format) = explode(":", $type, 2);
243 243
 		}
244
-		switch(strtolower($type)) {
244
+		switch (strtolower($type)) {
245 245
 			case "integer":
246
-				if($align == "") {
246
+				if ($align == "") {
247 247
 					$align = "right";
248 248
 				}
249 249
 				$value = number_format($value);
250 250
 				break;
251 251
 
252 252
 			case "float":
253
-				if($align == "") {
253
+				if ($align == "") {
254 254
 					$align = "right";
255 255
 				}
256
-				if(!$type_format) {
256
+				if (!$type_format) {
257 257
 					$type_format = 2;
258 258
 				}
259 259
 				$value = number_format($value, $type_format);
260 260
 				break;
261 261
 
262 262
 			case "currency":
263
-				if($align == "") {
263
+				if ($align == "") {
264 264
 					$align = "right";
265 265
 				}
266
-				if(!$type_format) {
266
+				if (!$type_format) {
267 267
 					$type_format = 2;
268 268
 				}
269
-				$value = "$" . number_format($value, $type_format);
269
+				$value = "$".number_format($value, $type_format);
270 270
 				break;
271 271
 
272 272
 			case "date":
273
-				if($align == "") {
273
+				if ($align == "") {
274 274
 					$align = "right";
275 275
 				}
276
-				if(!is_numeric($value)) {
276
+				if (!is_numeric($value)) {
277 277
 					$value = strtotime($value);
278 278
 				}
279
-				if(!$type_format) {
279
+				if (!$type_format) {
280 280
 					$type_format = "%A %d, %B %Y";
281 281
 				}
282 282
 				$value = strftime($type_format, $value);
283 283
 				break;
284 284
 
285 285
 			case "boolean":
286
-				if($align == '') {
286
+				if ($align == '') {
287 287
 					$align = "center";
288 288
 				}
289 289
 				$value = number_format($value);
290
-				if($value) {
290
+				if ($value) {
291 291
 					$value = '&bull;';
292 292
 				} else {
293 293
 					$value = '&nbsp;';
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 				// replace [+value+] first
299 299
 				$value = str_replace("[+value+]", $value, $type_format);
300 300
 				// replace other [+fields+]
301
-				if(strpos($value, "[+") !== false) {
302
-					foreach($row as $k => $v) {
301
+				if (strpos($value, "[+") !== false) {
302
+					foreach ($row as $k => $v) {
303 303
 						$value = str_replace("[+$k+]", $v, $value);
304 304
 					}
305 305
 				}
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,7 +11,8 @@  discard block
 block discarded – undo
11 11
 # -----------------------------------------
12 12
 #
13 13
 
14
-class DataGrid implements DataGridInterface{
14
+class DataGrid implements DataGridInterface
15
+{
15 16
 
16 17
 	public $ds; // datasource
17 18
     public $id;
@@ -75,7 +76,8 @@  discard block
 block discarded – undo
75 76
 
76 77
     public static $dataGridCnt;
77 78
 
78
-    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
79
+    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1)
80
+    {
79 81
 		// set id
80 82
 		self::$dataGridCnt++;
81 83
 		$this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt;
@@ -89,11 +91,13 @@  discard block
 block discarded – undo
89 91
 		$this->pagerLocation = 'top-right';
90 92
 	}
91 93
 
92
-    public function setDataSource($ds) {
94
+    public function setDataSource($ds)
95
+    {
93 96
 		$this->ds = $ds;
94 97
 	}
95 98
 
96
-    public function render() {
99
+    public function render()
100
+    {
97 101
         $modx = evolutionCMS();
98 102
 		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
99 103
 		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
@@ -128,7 +132,9 @@  discard block
 block discarded – undo
128 132
 
129 133
 		if($this->_isDataset && !$this->columns) {
130 134
 			$cols = $modx->getDatabase()->numFields($this->ds);
131
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i);
135
+			for($i = 0; $i < $cols; $i++) {
136
+			    $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i);
137
+			}
132 138
 		}
133 139
 
134 140
 		// start grid
@@ -207,7 +213,8 @@  discard block
 block discarded – undo
207 213
 
208 214
 	// format column values
209 215
 
210
-    public function RenderRowFnc($n, $row) {
216
+    public function RenderRowFnc($n, $row)
217
+    {
211 218
 		if($this->_alt == 0) {
212 219
 			$Style = $this->_itemStyle;
213 220
 			$Class = $this->_itemClass;
@@ -237,7 +244,8 @@  discard block
 block discarded – undo
237 244
 		return $o;
238 245
 	}
239 246
 
240
-    public function formatColumnValue($row, $value, $type, &$align) {
247
+    public function formatColumnValue($row, $value, $type, &$align)
248
+    {
241 249
 		if(strpos($type, ":") !== false) {
242 250
 			list($type, $type_format) = explode(":", $type, 2);
243 251
 		}
Please login to merge, or discard this patch.
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -75,6 +75,10 @@  discard block
 block discarded – undo
75 75
 
76 76
     public static $dataGridCnt;
77 77
 
78
+    /**
79
+     * @param null|string $id
80
+     * @param string $ds
81
+     */
78 82
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
79 83
 		// set id
80 84
 		self::$dataGridCnt++;
@@ -207,6 +211,9 @@  discard block
 block discarded – undo
207 211
 
208 212
 	// format column values
209 213
 
214
+    /**
215
+     * @param integer $n
216
+     */
210 217
     public function RenderRowFnc($n, $row) {
211 218
 		if($this->_alt == 0) {
212 219
 			$Style = $this->_itemStyle;
Please login to merge, or discard this patch.
manager/includes/src/Support/ContextMenu.php 3 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -19,46 +19,46 @@  discard block
 block discarded – undo
19 19
 
20 20
     public static $cnt;
21 21
 
22
-    public function __construct($id = '', $width = 120, $visible = false) {
22
+    public function __construct($id = '', $width = 120, $visible = false){
23 23
         self::$cnt++;
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" . self::$cnt;    // set id
26
+        $this->width = is_numeric($width) ? (int) $width : 120;
27
+        $this->id = $id ? $id : "cntxMnu".self::$cnt; // 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 . '&nbsp;' . $text . '</div>';
52
+        $this->html .= $img.'&nbsp;'.$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
         $ContextMenuScript = <<<BLOCK
63 63
 <script>
64 64
 	function getCntxMenu(id) {
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 </script>
72 72
 BLOCK;
73 73
 
74
-        $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>";
74
+        $html = $ContextMenuScript."<div id='".$this->id."' class='contextMenu' style='width:".$this->width."px; visibility:".($this->visible ? 'visible' : 'hidden')."'>".$this->html."</div>";
75 75
         $ContextMenuScript = ""; // reset css
76 76
         return $html;
77 77
     }
78 78
 
79
-    public function getClientScriptObject() {
80
-        return "getCntxMenu('" . $this->id . "')";
79
+    public function getClientScriptObject(){
80
+        return "getCntxMenu('".$this->id."')";
81 81
     }
82 82
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,7 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 use EvolutionCMS\Interfaces\ContextMenuInterface;
4 4
 
5
-class ContextMenu implements ContextMenuInterface{
5
+class ContextMenu implements ContextMenuInterface
6
+{
6 7
     public $id;
7 8
     /**
8 9
      * @var string
@@ -19,7 +20,8 @@  discard block
 block discarded – undo
19 20
 
20 21
     public static $cnt;
21 22
 
22
-    public function __construct($id = '', $width = 120, $visible = false) {
23
+    public function __construct($id = '', $width = 120, $visible = false)
24
+    {
23 25
         self::$cnt++;
24 26
         $this->html = "";
25 27
         $this->visible = $visible ? $visible : false;
@@ -27,7 +29,8 @@  discard block
 block discarded – undo
27 29
         $this->id = $id ? $id : "cntxMnu" . self::$cnt;    // set id
28 30
     }
29 31
 
30
-    public function addItem($text, $action = "", $img = "", $disabled = 0) {
32
+    public function addItem($text, $action = "", $img = "", $disabled = 0)
33
+    {
31 34
         global $base_url, $_style;
32 35
         if($disabled) {
33 36
             return;
@@ -52,13 +55,15 @@  discard block
 block discarded – undo
52 55
         $this->html .= $img . '&nbsp;' . $text . '</div>';
53 56
     }
54 57
 
55
-    public function addSeparator() {
58
+    public function addSeparator()
59
+    {
56 60
         $this->html .= "
57 61
 			<div class='cntxMnuSeparator'></div>
58 62
 		";
59 63
     }
60 64
 
61
-    public function render() {
65
+    public function render()
66
+    {
62 67
         $ContextMenuScript = <<<BLOCK
63 68
 <script>
64 69
 	function getCntxMenu(id) {
@@ -76,7 +81,8 @@  discard block
 block discarded – undo
76 81
         return $html;
77 82
     }
78 83
 
79
-    public function getClientScriptObject() {
84
+    public function getClientScriptObject()
85
+    {
80 86
         return "getCntxMenu('" . $this->id . "')";
81 87
     }
82 88
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 		cm.style.visibility = 'hidden';
70 70
 	}
71 71
 </script>
72
-BLOCK;
72
+block;
73 73
 
74 74
         $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>";
75 75
         $ContextMenuScript = ""; // reset css
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers/mdf_moduser.inc.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-$userid = (int)$value;
2
+$userid = (int) $value;
3 3
 if (!isset($modx->getModifiers()->cache['ui'][$userid])) {
4 4
     if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid));
5 5
     else             $user = $modx->getUserInfo($userid);
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 $userid = (int)$value;
3 3
 if (!isset($modx->getModifiers()->cache['ui'][$userid])) {
4
-    if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid));
5
-    else             $user = $modx->getUserInfo($userid);
4
+    if ($userid < 0) {
5
+        $user = $modx->getWebUserInfo(abs($userid));
6
+    } else {
7
+        $user = $modx->getUserInfo($userid);
8
+    }
6 9
     $modx->getModifiers()->cache['ui'][$userid] = $user;
7 10
 } else {
8 11
     $user = $modx->getModifiers()->cache['ui'][$userid];
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers/mdf_summary.inc.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,43 +1,43 @@
 block discarded – undo
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->getModifiers()->parseDocumentSource($value);
10 10
 
11 11
 $content = strip_tags($content);
12 12
 
13
-$content = str_replace(array("\r\n","\r","\n","\t",'&nbsp;'),' ',$content);
14
-if(preg_match('/\s+/',$content))
15
-    $content = preg_replace('/\s+/',' ',$content);
13
+$content = str_replace(array("\r\n", "\r", "\n", "\t", '&nbsp;'), ' ', $content);
14
+if (preg_match('/\s+/', $content))
15
+    $content = preg_replace('/\s+/', ' ', $content);
16 16
 $content = trim($content);
17 17
 
18 18
 $pos = $modx->getModifiers()->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->getModifiers()->strlen($text.$v.$delim)) break;
23
+    foreach ($_ as $v) {
24
+        if ($limit <= $modx->getModifiers()->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->getModifiers()->strlen($content) && strpos($content,' ')!==false) {
30
+if ($limit < $modx->getModifiers()->strlen($content) && strpos($content, ' ') !== false) {
31 31
     $_ = explode(' ', $content);
32 32
     $text = '';
33
-    foreach($_ as $v) {
34
-        if($limit <= $modx->getModifiers()->strlen($text.$v.' ')) break;
35
-        $text .= $v . ' ';
33
+    foreach ($_ as $v) {
34
+        if ($limit <= $modx->getModifiers()->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->getModifiers()->strlen($content)) $content = $modx->getModifiers()->substr($content, 0, $limit);
41
-if($modx->getModifiers()->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim;
40
+if ($limit < $modx->getModifiers()->strlen($content)) $content = $modx->getModifiers()->substr($content, 0, $limit);
41
+if ($modx->getModifiers()->substr($content, -1) == $delim) $content = rtrim($content, $delim).$delim;
42 42
 
43 43
 return $content;
Please login to merge, or discard this patch.
Braces   +28 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,9 +1,11 @@  discard block
 block discarded – undo
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,',')) {
3
+    list($limit,$delim) = explode(',', $opt);
4
+} elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} else {$limit=124;$delim='';}
5 5
 
6
-if($delim==='') $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.';
6
+if($delim==='') {
7
+    $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.';
8
+}
7 9
 $limit = (int)$limit;
8 10
 
9 11
 $content = $modx->getModifiers()->parseDocumentSource($value);
@@ -11,8 +13,9 @@  discard block
 block discarded – undo
11 13
 $content = strip_tags($content);
12 14
 
13 15
 $content = str_replace(array("\r\n","\r","\n","\t",'&nbsp;'),' ',$content);
14
-if(preg_match('/\s+/',$content))
16
+if(preg_match('/\s+/',$content)) {
15 17
     $content = preg_replace('/\s+/',' ',$content);
18
+}
16 19
 $content = trim($content);
17 20
 
18 21
 $pos = $modx->getModifiers()->strpos($content, $delim);
@@ -21,23 +24,35 @@  discard block
 block discarded – undo
21 24
     $_ = explode($delim, $content);
22 25
     $text = '';
23 26
     foreach($_ as $v) {
24
-        if($limit <= $modx->getModifiers()->strlen($text.$v.$delim)) break;
27
+        if($limit <= $modx->getModifiers()->strlen($text.$v.$delim)) {
28
+            break;
29
+        }
25 30
         $text .= $v.$delim;
26 31
     }
27
-    if($text) $content = $text;
28
-}
32
+    if($text) {
33
+        $content = $text;
34
+    }
35
+    }
29 36
 
30 37
 if($limit<$modx->getModifiers()->strlen($content) && strpos($content,' ')!==false) {
31 38
     $_ = explode(' ', $content);
32 39
     $text = '';
33 40
     foreach($_ as $v) {
34
-        if($limit <= $modx->getModifiers()->strlen($text.$v.' ')) break;
41
+        if($limit <= $modx->getModifiers()->strlen($text.$v.' ')) {
42
+            break;
43
+        }
35 44
         $text .= $v . ' ';
36 45
     }
37
-    if($text!=='') $content = $text;
38
-}
46
+    if($text!=='') {
47
+        $content = $text;
48
+    }
49
+    }
39 50
 
40
-if($limit < $modx->getModifiers()->strlen($content)) $content = $modx->getModifiers()->substr($content, 0, $limit);
41
-if($modx->getModifiers()->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim;
51
+if($limit < $modx->getModifiers()->strlen($content)) {
52
+    $content = $modx->getModifiers()->substr($content, 0, $limit);
53
+}
54
+if($modx->getModifiers()->substr($content,-1)==$delim) {
55
+    $content = rtrim($content,$delim) . $delim;
56
+}
42 57
 
43 58
 return $content;
Please login to merge, or discard this patch.
manager/includes/bootstrap.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * @see https://github.com/theseer/Autoload
4 4
  */
5 5
 spl_autoload_register(
6
-    function($class) {
6
+    function($class){
7 7
         static $classes = null;
8 8
         if ($classes === null) {
9 9
             $classes = array(
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         }
67 67
         $cn = strtolower($class);
68 68
         if (isset($classes[$cn])) {
69
-            require __DIR__ . $classes[$cn];
69
+            require __DIR__.$classes[$cn];
70 70
         }
71 71
     },
72 72
     true,
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
  * @see https://github.com/theseer/Autoload
4 4
  */
5 5
 spl_autoload_register(
6
-    function($class) {
6
+    function($class){
7 7
         static $classes = null;
8 8
         if ($classes === null) {
9 9
             $classes = array(
Please login to merge, or discard this patch.