@@ -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); |
@@ -280,13 +280,13 @@ discard block |
||
| 280 | 280 | $orderby = trim($orderby); |
| 281 | 281 | $limit = trim($limit); |
| 282 | 282 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 283 | - $where = "WHERE {$where}"; |
|
| 283 | + $where = "where {$where}"; |
|
| 284 | 284 | } |
| 285 | 285 | if ($orderby !== '' && stripos($orderby, 'ORDER BY') !== 0) { |
| 286 | 286 | $orderby = "ORDER BY {$orderby}"; |
| 287 | 287 | } |
| 288 | 288 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 289 | - $limit = "LIMIT {$limit}"; |
|
| 289 | + $limit = "limit {$limit}"; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | return $this->query("DELETE FROM {$from} {$where} {$orderby} {$limit}"); |
@@ -322,16 +322,16 @@ discard block |
||
| 322 | 322 | $orderby = trim($orderby); |
| 323 | 323 | $limit = trim($limit); |
| 324 | 324 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 325 | - $where = "WHERE {$where}"; |
|
| 325 | + $where = "where {$where}"; |
|
| 326 | 326 | } |
| 327 | 327 | if ($orderby !== '' && stripos($orderby, 'ORDER') !== 0) { |
| 328 | 328 | $orderby = "ORDER BY {$orderby}"; |
| 329 | 329 | } |
| 330 | 330 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 331 | - $limit = "LIMIT {$limit}"; |
|
| 331 | + $limit = "limit {$limit}"; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - return $this->query("SELECT {$fields} FROM {$from} {$where} {$orderby} {$limit}"); |
|
| 334 | + return $this->query("select {$fields} FROM {$from} {$where} {$orderby} {$limit}"); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -358,10 +358,10 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | $where = trim($where); |
| 360 | 360 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 361 | - $where = "WHERE {$where}"; |
|
| 361 | + $where = "where {$where}"; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - return $this->query("UPDATE {$table} SET {$fields} {$where}"); |
|
| 364 | + return $this->query("update {$table} SET {$fields} {$where}"); |
|
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | $where = trim($where); |
| 391 | 391 | $limit = trim($limit); |
| 392 | 392 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 393 | - $where = "WHERE {$where}"; |
|
| 393 | + $where = "where {$where}"; |
|
| 394 | 394 | } |
| 395 | 395 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 396 | - $limit = "LIMIT {$limit}"; |
|
| 396 | + $limit = "limit {$limit}"; |
|
| 397 | 397 | } |
| 398 | 398 | $rt = $this->query("INSERT INTO {$intotable} {$fields} SELECT {$fromfields} FROM {$fromtable} {$where} {$limit}"); |
| 399 | 399 | } else { |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | |
| 733 | 733 | public function truncate($table_name) |
| 734 | 734 | { |
| 735 | - $rs = $this->query("TRUNCATE {$table_name}"); |
|
| 735 | + $rs = $this->query("truncate {$table_name}"); |
|
| 736 | 736 | |
| 737 | 737 | return $rs; |
| 738 | 738 | } |
@@ -554,6 +554,7 @@ discard block |
||
| 554 | 554 | * @name: getColumn |
| 555 | 555 | * @desc: returns an array of the values found on colun $name |
| 556 | 556 | * @param: $dsq - dataset or query string |
| 557 | + * @param string $name |
|
| 557 | 558 | */ |
| 558 | 559 | public function getColumn($name, $dsq) |
| 559 | 560 | { |
@@ -720,6 +721,9 @@ discard block |
||
| 720 | 721 | return $result; |
| 721 | 722 | } |
| 722 | 723 | |
| 724 | + /** |
|
| 725 | + * @param string $table_name |
|
| 726 | + */ |
|
| 723 | 727 | public function optimize($table_name) |
| 724 | 728 | { |
| 725 | 729 | $rs = $this->query("OPTIMIZE TABLE {$table_name}"); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class DataGrid { |
| 14 | 14 | |
| 15 | - public $ds; // datasource |
|
| 15 | + public $ds; // datasource |
|
| 16 | 16 | public $id; |
| 17 | 17 | public $pageSize; // pager settings |
| 18 | 18 | public $pageNumber; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public $colWraps; |
| 37 | 37 | public $colColors; |
| 38 | 38 | public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
| 39 | - // data type: integer,float,currency,date |
|
| 39 | + // data type: integer,float,currency,date |
|
| 40 | 40 | |
| 41 | 41 | public $header; |
| 42 | 42 | public $footer; |
@@ -73,239 +73,239 @@ discard block |
||
| 73 | 73 | public $cdelim; |
| 74 | 74 | |
| 75 | 75 | public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
| 76 | - global $__DataGridCnt; |
|
| 76 | + global $__DataGridCnt; |
|
| 77 | 77 | |
| 78 | - // set id |
|
| 79 | - $__DataGridCnt++; |
|
| 80 | - $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt; |
|
| 78 | + // set id |
|
| 79 | + $__DataGridCnt++; |
|
| 80 | + $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt; |
|
| 81 | 81 | |
| 82 | - // set datasource |
|
| 83 | - $this->ds = $ds; |
|
| 82 | + // set datasource |
|
| 83 | + $this->ds = $ds; |
|
| 84 | 84 | |
| 85 | - // set pager |
|
| 86 | - $this->pageSize = $pageSize; |
|
| 87 | - $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
| 88 | - $this->pagerLocation = 'top-right'; |
|
| 89 | - } |
|
| 85 | + // set pager |
|
| 86 | + $this->pageSize = $pageSize; |
|
| 87 | + $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
| 88 | + $this->pagerLocation = 'top-right'; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | public function setDataSource($ds) { |
| 92 | - $this->ds = $ds; |
|
| 93 | - } |
|
| 92 | + $this->ds = $ds; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | public function render() { |
| 96 | - 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 . "'" : ''; |
|
| 101 | - |
|
| 102 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
| 103 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
| 104 | - |
|
| 105 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
| 106 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
| 107 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
| 108 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
| 109 | - |
|
| 110 | - $this->_alt = 0; |
|
| 111 | - $this->_total = 0; |
|
| 112 | - |
|
| 113 | - $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
|
| 114 | - |
|
| 115 | - if(!$cssStyle && !$cssClass) { |
|
| 116 | - $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
| 117 | - } |
|
| 118 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
| 119 | - $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
| 120 | - } |
|
| 121 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
| 122 | - $this->_itemStyle = "style='color:black;'"; |
|
| 123 | - } |
|
| 124 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
| 125 | - $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if($this->_isDataset && !$this->columns) { |
|
| 129 | - $cols = $modx->db->numFields($this->ds); |
|
| 130 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // start grid |
|
| 134 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
| 135 | - $tblEnd = "</table>"; |
|
| 136 | - |
|
| 137 | - // build column header |
|
| 138 | - $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
| 139 | - $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
| 140 | - $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
| 141 | - $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
| 142 | - $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
| 143 | - $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
| 144 | - $this->_colcount = count($this->_colnames); |
|
| 145 | - if(!$this->_isDataset) { |
|
| 146 | - $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
| 147 | - $this->ds = array_chunk($this->ds, $this->_colcount); |
|
| 148 | - } |
|
| 149 | - $tblColHdr = "<thead><tr>"; |
|
| 150 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
| 151 | - $name = $this->_colnames[$c]; |
|
| 152 | - $width = $this->_colwidths[$c]; |
|
| 153 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
| 154 | - } |
|
| 155 | - $tblColHdr .= "</tr></thead>\n"; |
|
| 156 | - |
|
| 157 | - // build rows |
|
| 158 | - $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 159 | - $this->_fieldnames = explode(",", $this->fields); |
|
| 160 | - if($rowcount == 0) { |
|
| 161 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
| 162 | - } else { |
|
| 163 | - // render grid items |
|
| 164 | - if($this->pageSize <= 0) { |
|
| 165 | - for($r = 0; $r < $rowcount; $r++) { |
|
| 166 | - $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
|
| 167 | - $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
| 168 | - } |
|
| 169 | - } else { |
|
| 170 | - if(!$this->pager) { |
|
| 171 | - include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
| 172 | - $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
| 173 | - $this->pager->setRenderRowFnc($this); // pass this object |
|
| 174 | - $this->pager->cssStyle = $pagerStyle; |
|
| 175 | - $this->pager->cssClass = $pagerClass; |
|
| 176 | - } else { |
|
| 177 | - $this->pager->pageSize = $this->pageSize; |
|
| 178 | - $this->pager->pageNumber = $this->pageNumber; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $this->pager->render(); |
|
| 182 | - $tblRows = $this->pager->getRenderedRows(); |
|
| 183 | - $tblPager = $this->pager->getRenderedPager(); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - // setup header,pager and footer |
|
| 188 | - $o = $tblStart; |
|
| 189 | - $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
| 190 | - $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
| 191 | - if($this->header) { |
|
| 192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
| 193 | - } |
|
| 194 | - if($tblPager && $ptop) { |
|
| 195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </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 . " </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 |
|
| 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 . "'" : ''; |
|
| 101 | + |
|
| 102 | + $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
| 103 | + $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
| 104 | + |
|
| 105 | + $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
| 106 | + $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
| 107 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
| 108 | + $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
| 109 | + |
|
| 110 | + $this->_alt = 0; |
|
| 111 | + $this->_total = 0; |
|
| 112 | + |
|
| 113 | + $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
|
| 114 | + |
|
| 115 | + if(!$cssStyle && !$cssClass) { |
|
| 116 | + $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
| 117 | + } |
|
| 118 | + if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
| 119 | + $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
| 120 | + } |
|
| 121 | + if(!$this->_itemStyle && !$this->_itemClass) { |
|
| 122 | + $this->_itemStyle = "style='color:black;'"; |
|
| 123 | + } |
|
| 124 | + if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
| 125 | + $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if($this->_isDataset && !$this->columns) { |
|
| 129 | + $cols = $modx->db->numFields($this->ds); |
|
| 130 | + for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // start grid |
|
| 134 | + $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
| 135 | + $tblEnd = "</table>"; |
|
| 136 | + |
|
| 137 | + // build column header |
|
| 138 | + $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
| 139 | + $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
| 140 | + $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
| 141 | + $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
| 142 | + $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
| 143 | + $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
| 144 | + $this->_colcount = count($this->_colnames); |
|
| 145 | + if(!$this->_isDataset) { |
|
| 146 | + $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
| 147 | + $this->ds = array_chunk($this->ds, $this->_colcount); |
|
| 148 | + } |
|
| 149 | + $tblColHdr = "<thead><tr>"; |
|
| 150 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
| 151 | + $name = $this->_colnames[$c]; |
|
| 152 | + $width = $this->_colwidths[$c]; |
|
| 153 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
| 154 | + } |
|
| 155 | + $tblColHdr .= "</tr></thead>\n"; |
|
| 156 | + |
|
| 157 | + // build rows |
|
| 158 | + $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 159 | + $this->_fieldnames = explode(",", $this->fields); |
|
| 160 | + if($rowcount == 0) { |
|
| 161 | + $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
| 162 | + } else { |
|
| 163 | + // render grid items |
|
| 164 | + if($this->pageSize <= 0) { |
|
| 165 | + for($r = 0; $r < $rowcount; $r++) { |
|
| 166 | + $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
|
| 167 | + $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
| 168 | + } |
|
| 169 | + } else { |
|
| 170 | + if(!$this->pager) { |
|
| 171 | + include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
| 172 | + $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
| 173 | + $this->pager->setRenderRowFnc($this); // pass this object |
|
| 174 | + $this->pager->cssStyle = $pagerStyle; |
|
| 175 | + $this->pager->cssClass = $pagerClass; |
|
| 176 | + } else { |
|
| 177 | + $this->pager->pageSize = $this->pageSize; |
|
| 178 | + $this->pager->pageNumber = $this->pageNumber; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $this->pager->render(); |
|
| 182 | + $tblRows = $this->pager->getRenderedRows(); |
|
| 183 | + $tblPager = $this->pager->getRenderedPager(); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + // setup header,pager and footer |
|
| 188 | + $o = $tblStart; |
|
| 189 | + $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
| 190 | + $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
| 191 | + if($this->header) { |
|
| 192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
| 193 | + } |
|
| 194 | + if($tblPager && $ptop) { |
|
| 195 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </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 . " </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 = '•'; |
|
| 292 | - } else { |
|
| 293 | - $value = ' '; |
|
| 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 = '•'; |
|
| 292 | + } else { |
|
| 293 | + $value = ' '; |
|
| 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 | } |
@@ -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 | } |
@@ -10,7 +10,8 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $__DataGridCnt = 0; |
| 12 | 12 | |
| 13 | -class DataGrid { |
|
| 13 | +class DataGrid |
|
| 14 | +{ |
|
| 14 | 15 | |
| 15 | 16 | public $ds; // datasource |
| 16 | 17 | public $id; |
@@ -72,7 +73,8 @@ discard block |
||
| 72 | 73 | */ |
| 73 | 74 | public $cdelim; |
| 74 | 75 | |
| 75 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
| 76 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) |
|
| 77 | + { |
|
| 76 | 78 | global $__DataGridCnt; |
| 77 | 79 | |
| 78 | 80 | // set id |
@@ -88,11 +90,13 @@ discard block |
||
| 88 | 90 | $this->pagerLocation = 'top-right'; |
| 89 | 91 | } |
| 90 | 92 | |
| 91 | - public function setDataSource($ds) { |
|
| 93 | + public function setDataSource($ds) |
|
| 94 | + { |
|
| 92 | 95 | $this->ds = $ds; |
| 93 | 96 | } |
| 94 | 97 | |
| 95 | - public function render() { |
|
| 98 | + public function render() |
|
| 99 | + { |
|
| 96 | 100 | global $modx; |
| 97 | 101 | $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
| 98 | 102 | $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
@@ -127,7 +131,9 @@ discard block |
||
| 127 | 131 | |
| 128 | 132 | if($this->_isDataset && !$this->columns) { |
| 129 | 133 | $cols = $modx->db->numFields($this->ds); |
| 130 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
| 134 | + for($i = 0; $i < $cols; $i++) { |
|
| 135 | + $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
| 136 | + } |
|
| 131 | 137 | } |
| 132 | 138 | |
| 133 | 139 | // start grid |
@@ -207,7 +213,8 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -72,6 +72,10 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public $cdelim; |
| 74 | 74 | |
| 75 | + /** |
|
| 76 | + * @param null|string $id |
|
| 77 | + * @param string $ds |
|
| 78 | + */ |
|
| 75 | 79 | public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
| 76 | 80 | global $__DataGridCnt; |
| 77 | 81 | |
@@ -207,6 +211,9 @@ discard block |
||
| 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; |
@@ -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 { |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | $countChild++; |
| 68 | 68 | $id = $value[0]; |
| 69 | 69 | $ph['id'] = $id; |
| 70 | - $ph['li_class'] = $this->get_li_class($id) . $value[10]; |
|
| 70 | + $ph['li_class'] = $this->get_li_class($id).$value[10]; |
|
| 71 | 71 | $ph['href'] = $value[3]; |
| 72 | 72 | $ph['alt'] = $value[4]; |
| 73 | 73 | $ph['target'] = $value[7]; |
| 74 | 74 | $ph['onclick'] = $value[5]; |
| 75 | 75 | $ph['a_class'] = $this->get_a_class($id); |
| 76 | 76 | $ph['LinkAttr'] = $this->getLinkAttr($id); |
| 77 | - $ph['itemName'] = $value[2] . $this->getItemName($id); |
|
| 77 | + $ph['itemName'] = $value[2].$this->getItemName($id); |
|
| 78 | 78 | |
| 79 | 79 | $ph['DrawSub'] = ''; |
| 80 | 80 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | public function get_li_class($id) |
| 114 | 114 | { |
| 115 | 115 | if (isset($this->menu[$id])) { |
| 116 | - return $this->defaults['parentClass'] . ' '; |
|
| 116 | + return $this->defaults['parentClass'].' '; |
|
| 117 | 117 | } else { |
| 118 | 118 | return ''; |
| 119 | 119 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | public function get_a_class($id) |
| 123 | 123 | { |
| 124 | 124 | if (isset($this->menu[$id])) { |
| 125 | - return ' class="' . $this->defaults['parentLinkClass'] . '"'; |
|
| 125 | + return ' class="'.$this->defaults['parentLinkClass'].'"'; |
|
| 126 | 126 | } else { |
| 127 | 127 | return ''; |
| 128 | 128 | } |
@@ -3,12 +3,12 @@ discard block |
||
| 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 | if(!$modx->hasPermission('delete_plugin')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Set the item name for logger |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | // invoke OnBeforePluginFormDelete event |
| 19 | 19 | $modx->invokeEvent("OnBeforePluginFormDelete", |
| 20 | - array( |
|
| 21 | - "id" => $id |
|
| 22 | - )); |
|
| 20 | + array( |
|
| 21 | + "id" => $id |
|
| 22 | + )); |
|
| 23 | 23 | |
| 24 | 24 | // delete the plugin. |
| 25 | 25 | $modx->db->delete($modx->getFullTableName('site_plugins'), "id='{$id}'"); |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | // invoke OnPluginFormDelete event |
| 31 | 31 | $modx->invokeEvent("OnPluginFormDelete", |
| 32 | - array( |
|
| 33 | - "id" => $id |
|
| 34 | - )); |
|
| 32 | + array( |
|
| 33 | + "id" => $id |
|
| 34 | + )); |
|
| 35 | 35 | |
| 36 | 36 | // empty cache |
| 37 | 37 | $modx->clearCache('full'); |
@@ -1,13 +1,13 @@ 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 | -if(!$modx->hasPermission('delete_plugin')) { |
|
| 5 | +if (!$modx->hasPermission('delete_plugin')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -37,5 +37,5 @@ discard block |
||
| 37 | 37 | $modx->clearCache('full'); |
| 38 | 38 | |
| 39 | 39 | // finished emptying cache - redirect |
| 40 | -$header="Location: index.php?a=76&r=2"; |
|
| 40 | +$header = "Location: index.php?a=76&r=2"; |
|
| 41 | 41 | header($header); |
@@ -3,12 +3,12 @@ discard block |
||
| 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 | if(!$modx->hasPermission('delete_snippet')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Set the item name for logger |
@@ -17,18 +17,18 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | // invoke OnBeforeChunkFormDelete event |
| 19 | 19 | $modx->invokeEvent("OnBeforeChunkFormDelete", |
| 20 | - array( |
|
| 21 | - "id" => $id |
|
| 22 | - )); |
|
| 20 | + array( |
|
| 21 | + "id" => $id |
|
| 22 | + )); |
|
| 23 | 23 | |
| 24 | 24 | // delete the chunk. |
| 25 | 25 | $modx->db->delete($modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); |
| 26 | 26 | |
| 27 | 27 | // invoke OnChunkFormDelete event |
| 28 | 28 | $modx->invokeEvent("OnChunkFormDelete", |
| 29 | - array( |
|
| 30 | - "id" => $id |
|
| 31 | - )); |
|
| 29 | + array( |
|
| 30 | + "id" => $id |
|
| 31 | + )); |
|
| 32 | 32 | |
| 33 | 33 | // empty cache |
| 34 | 34 | $modx->clearCache('full'); |
@@ -1,13 +1,13 @@ 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 | -if(!$modx->hasPermission('delete_snippet')) { |
|
| 5 | +if (!$modx->hasPermission('delete_snippet')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -34,5 +34,5 @@ discard block |
||
| 34 | 34 | $modx->clearCache('full'); |
| 35 | 35 | |
| 36 | 36 | // finished emptying cache - redirect |
| 37 | -$header="Location: index.php?a=76&r=2"; |
|
| 37 | +$header = "Location: index.php?a=76&r=2"; |
|
| 38 | 38 | header($header); |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('delete_template')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id == 0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // delete the template, but first check it doesn't have any documents using it |
| 15 | 15 | $rs = $modx->db->select('id, pagetitle,introtext', $modx->getFullTableName('site_content'), "template='{$id}' AND deleted=0"); |
| 16 | 16 | $limit = $modx->db->getRecordCount($rs); |
| 17 | 17 | if($limit > 0) { |
| 18 | - include "header.inc.php"; |
|
| 19 | - ?> |
|
| 18 | + include "header.inc.php"; |
|
| 19 | + ?> |
|
| 20 | 20 | |
| 21 | 21 | <h1><?php echo $_lang['manage_templates']; ?></h1> |
| 22 | 22 | |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | <p>Documents using this template:</p> |
| 29 | 29 | <ul> |
| 30 | 30 | <?php |
| 31 | - while($row = $modx->db->getRow($rs)) { |
|
| 32 | - echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['introtext'] != '' ? ' - ' . $row['introtext'] : '') . '</li>'; |
|
| 33 | - } |
|
| 34 | - ?> |
|
| 31 | + while($row = $modx->db->getRow($rs)) { |
|
| 32 | + echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['introtext'] != '' ? ' - ' . $row['introtext'] : '') . '</li>'; |
|
| 33 | + } |
|
| 34 | + ?> |
|
| 35 | 35 | </ul> |
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | <?php |
| 39 | - include_once "footer.inc.php"; |
|
| 40 | - exit; |
|
| 39 | + include_once "footer.inc.php"; |
|
| 40 | + exit; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | if($id == $default_template) { |
| 44 | - $modx->webAlertAndQuit("This template is set as the default template. Please choose a different default template in the MODX configuration before deleting this template."); |
|
| 44 | + $modx->webAlertAndQuit("This template is set as the default template. Please choose a different default template in the MODX configuration before deleting this template."); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Set the item name for logger |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | // invoke OnBeforeTempFormDelete event |
| 52 | 52 | $modx->invokeEvent("OnBeforeTempFormDelete", array( |
| 53 | - "id" => $id |
|
| 54 | - )); |
|
| 53 | + "id" => $id |
|
| 54 | + )); |
|
| 55 | 55 | |
| 56 | 56 | // delete the document. |
| 57 | 57 | $modx->db->delete($modx->getFullTableName('site_templates'), "id='{$id}'"); |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // invoke OnTempFormDelete event |
| 62 | 62 | $modx->invokeEvent("OnTempFormDelete", array( |
| 63 | - "id" => $id |
|
| 64 | - )); |
|
| 63 | + "id" => $id |
|
| 64 | + )); |
|
| 65 | 65 | |
| 66 | 66 | // empty cache |
| 67 | 67 | $modx->clearCache('full'); |
@@ -1,20 +1,20 @@ 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 | -if(!$modx->hasPermission('delete_template')) { |
|
| 5 | +if (!$modx->hasPermission('delete_template')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 10 | -if($id == 0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // delete the template, but first check it doesn't have any documents using it |
| 15 | 15 | $rs = $modx->db->select('id, pagetitle,introtext', $modx->getFullTableName('site_content'), "template='{$id}' AND deleted=0"); |
| 16 | 16 | $limit = $modx->db->getRecordCount($rs); |
| 17 | -if($limit > 0) { |
|
| 17 | +if ($limit > 0) { |
|
| 18 | 18 | include "header.inc.php"; |
| 19 | 19 | ?> |
| 20 | 20 | |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | <p>Documents using this template:</p> |
| 29 | 29 | <ul> |
| 30 | 30 | <?php |
| 31 | - while($row = $modx->db->getRow($rs)) { |
|
| 32 | - echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['introtext'] != '' ? ' - ' . $row['introtext'] : '') . '</li>'; |
|
| 31 | + while ($row = $modx->db->getRow($rs)) { |
|
| 32 | + echo '<li><span style="width: 200px"><a href="index.php?id='.$row['id'].'&a=27">'.$row['pagetitle'].'</a></span>'.($row['introtext'] != '' ? ' - '.$row['introtext'] : '').'</li>'; |
|
| 33 | 33 | } |
| 34 | 34 | ?> |
| 35 | 35 | </ul> |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | exit; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -if($id == $default_template) { |
|
| 43 | +if ($id == $default_template) { |
|
| 44 | 44 | $modx->webAlertAndQuit("This template is set as the default template. Please choose a different default template in the MODX configuration before deleting this template."); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -3,12 +3,12 @@ discard block |
||
| 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 | if(!$modx->hasPermission('delete_snippet')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Set the item name for logger |
@@ -17,18 +17,18 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | // invoke OnBeforeSnipFormDelete event |
| 19 | 19 | $modx->invokeEvent("OnBeforeSnipFormDelete", |
| 20 | - array( |
|
| 21 | - "id" => $id |
|
| 22 | - )); |
|
| 20 | + array( |
|
| 21 | + "id" => $id |
|
| 22 | + )); |
|
| 23 | 23 | |
| 24 | 24 | // delete the snippet. |
| 25 | 25 | $modx->db->delete($modx->getFullTableName('site_snippets'), "id='{$id}'"); |
| 26 | 26 | |
| 27 | 27 | // invoke OnSnipFormDelete event |
| 28 | 28 | $modx->invokeEvent("OnSnipFormDelete", |
| 29 | - array( |
|
| 30 | - "id" => $id |
|
| 31 | - )); |
|
| 29 | + array( |
|
| 30 | + "id" => $id |
|
| 31 | + )); |
|
| 32 | 32 | |
| 33 | 33 | // empty cache |
| 34 | 34 | $modx->clearCache('full'); |
@@ -1,13 +1,13 @@ 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 | -if(!$modx->hasPermission('delete_snippet')) { |
|
| 5 | +if (!$modx->hasPermission('delete_snippet')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -34,5 +34,5 @@ discard block |
||
| 34 | 34 | $modx->clearCache('full'); |
| 35 | 35 | |
| 36 | 36 | // finished emptying cache - redirect |
| 37 | -$header="Location: index.php?a=76&r=2"; |
|
| 37 | +$header = "Location: index.php?a=76&r=2"; |
|
| 38 | 38 | header($header); |
@@ -3,33 +3,33 @@ |
||
| 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 | if(!($modx->hasPermission('settings') && ($modx->hasPermission('logs')||$modx->hasPermission('bk_manager')))) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | if (isset($_REQUEST['t'])) { |
| 10 | 10 | |
| 11 | - if (empty($_REQUEST['t'])) { |
|
| 12 | - $modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]); |
|
| 13 | - } |
|
| 11 | + if (empty($_REQUEST['t'])) { |
|
| 12 | + $modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - // Set the item name for logger |
|
| 16 | - $_SESSION['itemname'] = $_REQUEST['t']; |
|
| 15 | + // Set the item name for logger |
|
| 16 | + $_SESSION['itemname'] = $_REQUEST['t']; |
|
| 17 | 17 | |
| 18 | - $modx->db->optimize($_REQUEST['t']); |
|
| 18 | + $modx->db->optimize($_REQUEST['t']); |
|
| 19 | 19 | |
| 20 | 20 | } elseif (isset($_REQUEST['u'])) { |
| 21 | 21 | |
| 22 | - if (empty($_REQUEST['u'])) { |
|
| 23 | - $modx->webAlertAndQuit($_lang["error_no_truncate_tablename"]); |
|
| 24 | - } |
|
| 22 | + if (empty($_REQUEST['u'])) { |
|
| 23 | + $modx->webAlertAndQuit($_lang["error_no_truncate_tablename"]); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - // Set the item name for logger |
|
| 27 | - $_SESSION['itemname'] = $_REQUEST['u']; |
|
| 26 | + // Set the item name for logger |
|
| 27 | + $_SESSION['itemname'] = $_REQUEST['u']; |
|
| 28 | 28 | |
| 29 | - $modx->db->truncate($_REQUEST['u']); |
|
| 29 | + $modx->db->truncate($_REQUEST['u']); |
|
| 30 | 30 | |
| 31 | 31 | } else { |
| 32 | - $modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]); |
|
| 32 | + $modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $mode = (int)$_REQUEST['mode']; |
@@ -1,8 +1,8 @@ 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 | -if(!($modx->hasPermission('settings') && ($modx->hasPermission('logs')||$modx->hasPermission('bk_manager')))) { |
|
| 5 | +if (!($modx->hasPermission('settings') && ($modx->hasPermission('logs') || $modx->hasPermission('bk_manager')))) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -32,6 +32,6 @@ discard block |
||
| 32 | 32 | $modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -$mode = (int)$_REQUEST['mode']; |
|
| 36 | -$header="Location: index.php?a={$mode}&s=4"; |
|
| 35 | +$mode = (int) $_REQUEST['mode']; |
|
| 36 | +$header = "Location: index.php?a={$mode}&s=4"; |
|
| 37 | 37 | header($header); |