@@ -2,4 +2,6 @@ |
||
2 | 2 | |
3 | 3 | use Exception; |
4 | 4 | |
5 | -class ServiceNotFoundException extends Exception{} |
|
5 | +class ServiceNotFoundException extends Exception |
|
6 | +{ |
|
7 | +} |
@@ -2,4 +2,6 @@ |
||
2 | 2 | |
3 | 3 | use Exception; |
4 | 4 | |
5 | -class ContainerException extends Exception{} |
|
5 | +class ContainerException extends Exception |
|
6 | +{ |
|
7 | +} |
@@ -1,3 +1,5 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Interfaces; |
2 | 2 | |
3 | -interface ManagerApiInterface{} |
|
3 | +interface ManagerApiInterface |
|
4 | +{ |
|
5 | +} |
@@ -1,3 +1,5 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Interfaces; |
2 | 2 | |
3 | -interface ServiceProviderInterface{} |
|
3 | +interface ServiceProviderInterface |
|
4 | +{ |
|
5 | +} |
@@ -1,3 +1,5 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Interfaces; |
2 | 2 | |
3 | -interface PasswordHashInterface{} |
|
3 | +interface PasswordHashInterface |
|
4 | +{ |
|
5 | +} |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | if (isset($this->aliases[$id])) { |
98 | 98 | if ($this->aliasVisible[$id] == 1) { |
99 | 99 | if ($path != '') { |
100 | - $path = $this->aliases[$id] . '/' . $path; |
|
100 | + $path = $this->aliases[$id].'/'.$path; |
|
101 | 101 | } else { |
102 | 102 | $path = $this->aliases[$id]; |
103 | 103 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $modx->messageQuit("Cache path not set."); |
122 | 122 | } |
123 | 123 | |
124 | - $files = glob(realpath($this->cachePath) . '/*.pageCache.php'); |
|
124 | + $files = glob(realpath($this->cachePath).'/*.pageCache.php'); |
|
125 | 125 | $filesincache = count($files); |
126 | 126 | $deletedfiles = array(); |
127 | 127 | while ($file = array_shift($files)) { |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | if (isset($opcache)) { |
157 | 157 | echo '<p>Opcache empty.</p>'; |
158 | 158 | } |
159 | - echo '<p>' . $_lang['cache_files_deleted'] . '</p><ul>'; |
|
159 | + echo '<p>'.$_lang['cache_files_deleted'].'</p><ul>'; |
|
160 | 160 | foreach ($deletedfiles as $deletedfile) { |
161 | - echo '<li>' . $deletedfile . '</li>'; |
|
161 | + echo '<li>'.$deletedfile.'</li>'; |
|
162 | 162 | } |
163 | 163 | echo '</ul>'; |
164 | 164 | } |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | |
178 | 178 | |
179 | 179 | // write the file |
180 | - $content = '<?php' . "\n"; |
|
181 | - $content .= '$recent_update=\'' . $this->request_time . '\';' . "\n"; |
|
182 | - $content .= '$cacheRefreshTime=\'' . $cacheRefreshTime . '\';' . "\n"; |
|
180 | + $content = '<?php'."\n"; |
|
181 | + $content .= '$recent_update=\''.$this->request_time.'\';'."\n"; |
|
182 | + $content .= '$cacheRefreshTime=\''.$cacheRefreshTime.'\';'."\n"; |
|
183 | 183 | |
184 | - $filename = $this->cachePath . '/sitePublishing.idx.php'; |
|
184 | + $filename = $this->cachePath.'/sitePublishing.idx.php'; |
|
185 | 185 | if (!$handle = fopen($filename, 'w')) { |
186 | 186 | exit("Cannot open file ({$filename}"); |
187 | 187 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $timesArr = array(); |
206 | 206 | |
207 | 207 | $result = $modx->getDatabase()->select('MIN(pub_date) AS minpub', '[+prefix+]site_content', |
208 | - 'pub_date>' . $this->request_time); |
|
208 | + 'pub_date>'.$this->request_time); |
|
209 | 209 | if (!$result) { |
210 | 210 | echo "Couldn't determine next publish event!"; |
211 | 211 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | $result = $modx->getDatabase()->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content', |
219 | - 'unpub_date>' . $this->request_time); |
|
219 | + 'unpub_date>'.$this->request_time); |
|
220 | 220 | if (!$result) { |
221 | 221 | echo "Couldn't determine next unpublish event!"; |
222 | 222 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $config = array(); |
256 | 256 | $content .= '$c=&$this->config;'; |
257 | 257 | while (list($key, $value) = $modx->getDatabase()->getRow($rs, 'num')) { |
258 | - $content .= '$c[\'' . $key . '\']="' . $this->escapeDoubleQuotes($value) . '";'; |
|
258 | + $content .= '$c[\''.$key.'\']="'.$this->escapeDoubleQuotes($value).'";'; |
|
259 | 259 | $config[$key] = $value; |
260 | 260 | } |
261 | 261 | |
@@ -293,23 +293,23 @@ discard block |
||
293 | 293 | $docid = $doc['id']; |
294 | 294 | if ($use_alias_path) { |
295 | 295 | $tmpPath = $this->getParents($doc['parent']); |
296 | - $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '') . $doc['alias']; |
|
296 | + $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '').$doc['alias']; |
|
297 | 297 | $key = $alias; |
298 | 298 | } else { |
299 | 299 | $key = $doc['alias']; |
300 | 300 | } |
301 | 301 | |
302 | 302 | $doc['path'] = $tmpPath; |
303 | - $content .= '$a[' . $docid . ']=array(\'id\'=>' . $docid . ',\'alias\'=>\'' . $doc['alias'] . '\',\'path\'=>\'' . $doc['path'] . '\',\'parent\'=>' . $doc['parent'] . ',\'isfolder\'=>' . $doc['isfolder'] . ',\'alias_visible\'=>' . $doc['alias_visible'] . ');'; |
|
304 | - $content .= '$d[\'' . $key . '\']=' . $docid . ';'; |
|
305 | - $content .= '$m[]=array(' . $doc['parent'] . '=>' . $docid . ');'; |
|
303 | + $content .= '$a['.$docid.']=array(\'id\'=>'.$docid.',\'alias\'=>\''.$doc['alias'].'\',\'path\'=>\''.$doc['path'].'\',\'parent\'=>'.$doc['parent'].',\'isfolder\'=>'.$doc['isfolder'].',\'alias_visible\'=>'.$doc['alias_visible'].');'; |
|
304 | + $content .= '$d[\''.$key.'\']='.$docid.';'; |
|
305 | + $content .= '$m[]=array('.$doc['parent'].'=>'.$docid.');'; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | // get content types |
309 | 309 | $rs = $modx->getDatabase()->select('id, contentType', '[+prefix+]site_content', "contentType!='text/html'"); |
310 | 310 | $content .= '$c=&$this->contentTypes;'; |
311 | 311 | while ($doc = $modx->getDatabase()->getRow($rs)) { |
312 | - $content .= '$c[\'' . $doc['id'] . '\']=\'' . $doc['contentType'] . '\';'; |
|
312 | + $content .= '$c[\''.$doc['id'].'\']=\''.$doc['contentType'].'\';'; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // WRITE Chunks to cache file |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | if ($modx->config['minifyphp_incache']) { |
320 | 320 | $doc['snippet'] = $this->php_strip_whitespace($doc['snippet']); |
321 | 321 | } |
322 | - $content .= '$c[\'' . $doc['name'] . '\']=\'' . ($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])) . '\';'; |
|
322 | + $content .= '$c[\''.$doc['name'].'\']=\''.($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])).'\';'; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | // WRITE snippets to cache file |
@@ -330,18 +330,18 @@ discard block |
||
330 | 330 | while ($row = $modx->getDatabase()->getRow($rs)) { |
331 | 331 | $key = $row['name']; |
332 | 332 | if ($row['disabled']) { |
333 | - $content .= '$s[\'' . $key . '\']=\'return false;\';'; |
|
333 | + $content .= '$s[\''.$key.'\']=\'return false;\';'; |
|
334 | 334 | } else { |
335 | 335 | $value = trim($row['snippet']); |
336 | 336 | if ($modx->config['minifyphp_incache']) { |
337 | 337 | $value = $this->php_strip_whitespace($value); |
338 | 338 | } |
339 | - $content .= '$s[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
339 | + $content .= '$s[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
340 | 340 | $properties = $modx->parseProperties($row['properties']); |
341 | 341 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
342 | 342 | $properties = array_merge($sharedproperties, $properties); |
343 | 343 | if (0 < count($properties)) { |
344 | - $content .= '$s[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
344 | + $content .= '$s[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | if ($modx->config['minifyphp_incache']) { |
360 | 360 | $value = $this->php_strip_whitespace($value); |
361 | 361 | } |
362 | - $content .= '$p[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
362 | + $content .= '$p[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
363 | 363 | if ($row['properties'] != '' || $row['sharedproperties'] != '') { |
364 | 364 | $properties = $modx->parseProperties($row['properties']); |
365 | 365 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
366 | 366 | $properties = array_merge($sharedproperties, $properties); |
367 | 367 | if (0 < count($properties)) { |
368 | - $content .= '$p[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
368 | + $content .= '$p[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | } |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | } |
389 | 389 | foreach ($events as $evtname => $pluginnames) { |
390 | 390 | $events[$evtname] = $pluginnames; |
391 | - $content .= '$e[\'' . $evtname . '\']=array(\'' . implode('\',\'', |
|
392 | - $this->escapeSingleQuotes($pluginnames)) . '\');'; |
|
391 | + $content .= '$e[\''.$evtname.'\']=array(\''.implode('\',\'', |
|
392 | + $this->escapeSingleQuotes($pluginnames)).'\');'; |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | $content .= "\n"; |
396 | 396 | |
397 | 397 | // close and write the file |
398 | - $filename = $this->cachePath . 'siteCache.idx.php'; |
|
398 | + $filename = $this->cachePath.'siteCache.idx.php'; |
|
399 | 399 | |
400 | 400 | // invoke OnBeforeCacheUpdate event |
401 | 401 | if ($modx) { |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | exit("Cannot write main MODX cache file! Make sure the assets/cache directory is writable!"); |
407 | 407 | } |
408 | 408 | |
409 | - if (!is_file($this->cachePath . '/.htaccess')) { |
|
410 | - file_put_contents($this->cachePath . '/.htaccess', "order deny,allow\ndeny from all\n"); |
|
409 | + if (!is_file($this->cachePath.'/.htaccess')) { |
|
410 | + file_put_contents($this->cachePath.'/.htaccess', "order deny,allow\ndeny from all\n"); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | // invoke OnCacheUpdate event |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | |
430 | 430 | $source = trim($source); |
431 | 431 | if (substr($source, 0, 5) !== '<?php') { |
432 | - $source = '<?php ' . $source; |
|
432 | + $source = '<?php '.$source; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | $tokens = token_get_all($source); |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | } |
488 | 488 | } |
489 | 489 | $source = preg_replace(array('@^<\?php@i', '|\s+|', '|<!--|', '|-->|', '|-->\s+<!--|'), |
490 | - array('', ' ', "\n" . '<!--', '-->' . "\n", '-->' . "\n" . '<!--'), $_); |
|
490 | + array('', ' ', "\n".'<!--', '-->'."\n", '-->'."\n".'<!--'), $_); |
|
491 | 491 | $source = trim($source); |
492 | 492 | |
493 | 493 | return $source; |
@@ -13,7 +13,7 @@ discard block |
||
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 |
||
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 |
||
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 . " </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 |
|
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 . " </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 | } |
@@ -15,10 +15,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -11,7 +11,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -75,6 +75,9 @@ discard block |
||
75 | 75 | |
76 | 76 | public static $dataGridCnt; |
77 | 77 | |
78 | + /** |
|
79 | + * @param string $ds |
|
80 | + */ |
|
78 | 81 | public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
79 | 82 | // set id |
80 | 83 | self::$dataGridCnt++; |
@@ -207,6 +210,9 @@ discard block |
||
207 | 210 | |
208 | 211 | // format column values |
209 | 212 | |
213 | + /** |
|
214 | + * @param integer $n |
|
215 | + */ |
|
210 | 216 | public function RenderRowFnc($n, $row) { |
211 | 217 | if($this->_alt == 0) { |
212 | 218 | $Style = $this->_itemStyle; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | // Set line feed |
75 | 75 | $lf = "\n"; |
76 | - $tempfile_path = $modx->config['base_path'] . 'assets/backup/temp.php'; |
|
76 | + $tempfile_path = $modx->config['base_path'].'assets/backup/temp.php'; |
|
77 | 77 | |
78 | 78 | $result = $modx->getDatabase()->query('SHOW TABLES'); |
79 | 79 | $tables = $this->result2Array(0, $result); |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | |
87 | 87 | // Set header |
88 | 88 | $output = "#{$lf}"; |
89 | - $output .= "# " . addslashes($modx->config['site_name']) . " Database Dump{$lf}"; |
|
89 | + $output .= "# ".addslashes($modx->config['site_name'])." Database Dump{$lf}"; |
|
90 | 90 | $output .= "# MODX Version:{$version['version']}{$lf}"; |
91 | 91 | $output .= "# {$lf}"; |
92 | 92 | $output .= "# Host: {$this->database_server}{$lf}"; |
93 | - $output .= "# Generation Time: " . $modx->toDateFormat(time()) . $lf; |
|
94 | - $output .= "# Server version: " . $modx->getDatabase()->getVersion() . $lf; |
|
95 | - $output .= "# PHP Version: " . phpversion() . $lf; |
|
93 | + $output .= "# Generation Time: ".$modx->toDateFormat(time()).$lf; |
|
94 | + $output .= "# Server version: ".$modx->getDatabase()->getVersion().$lf; |
|
95 | + $output .= "# PHP Version: ".phpversion().$lf; |
|
96 | 96 | $output .= "# Database: `{$this->dbname}`{$lf}"; |
97 | - $output .= "# Description: " . trim($_REQUEST['backup_title']) . "{$lf}"; |
|
97 | + $output .= "# Description: ".trim($_REQUEST['backup_title'])."{$lf}"; |
|
98 | 98 | $output .= "#"; |
99 | 99 | file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); |
100 | 100 | $output = ''; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | } |
115 | 115 | if ($callBack === 'snapshot') { |
116 | - if (!preg_match('@^' . $modx->getDatabase()->config['table_prefix'] . '@', $tblval)) { |
|
116 | + if (!preg_match('@^'.$modx->getDatabase()->config['table_prefix'].'@', $tblval)) { |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | } |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | ), '\\n', $value); |
151 | 151 | $value = "'{$value}'"; |
152 | 152 | } |
153 | - $insertdump .= $value . ','; |
|
153 | + $insertdump .= $value.','; |
|
154 | 154 | } |
155 | - $output .= rtrim($insertdump, ',') . ");\n"; |
|
155 | + $output .= rtrim($insertdump, ',').");\n"; |
|
156 | 156 | if (1048576 < strlen($output)) { |
157 | 157 | file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); |
158 | 158 | $output = ''; |
@@ -19,46 +19,46 @@ discard block |
||
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 . ' ' . $text . '</div>'; |
|
52 | + $this->html .= $img.' '.$text.'</div>'; |
|
53 | 53 | } |
54 | 54 | |
55 | - public function addSeparator() { |
|
55 | + public function addSeparator(){ |
|
56 | 56 | $this->html .= " |
57 | 57 | <div class='cntxMnuSeparator'></div> |
58 | 58 | "; |
59 | 59 | } |
60 | 60 | |
61 | - public function render() { |
|
61 | + public function render(){ |
|
62 | 62 | $ContextMenuScript = <<<BLOCK |
63 | 63 | <script> |
64 | 64 | function getCntxMenu(id) { |
@@ -71,12 +71,12 @@ discard block |
||
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 | } |
@@ -2,7 +2,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
52 | 55 | $this->html .= $img . ' ' . $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 |
||
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 | } |
@@ -69,7 +69,7 @@ |
||
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 |