@@ -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 | 5 | |
6 | -if(!$modx->hasPermission('edit_module')) { |
|
6 | +if (!$modx->hasPermission('edit_module')) { |
|
7 | 7 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
8 | 8 | } |
9 | 9 | |
10 | -$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
10 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
11 | 11 | |
12 | 12 | // Get table names (alphabetical) |
13 | 13 | $tbl_active_users = $modx->getFullTableName('active_users'); |
@@ -24,41 +24,41 @@ discard block |
||
24 | 24 | $modx->manager->initPageViewState(); |
25 | 25 | |
26 | 26 | // check to see the editor isn't locked |
27 | -$rs = $modx->db->select('username', $tbl_active_users, "action=108 AND id='{$id}' AND internalKey!='" . $modx->getLoginUserID() . "'"); |
|
28 | -if($username = $modx->db->getValue($rs)) { |
|
27 | +$rs = $modx->db->select('username', $tbl_active_users, "action=108 AND id='{$id}' AND internalKey!='".$modx->getLoginUserID()."'"); |
|
28 | +if ($username = $modx->db->getValue($rs)) { |
|
29 | 29 | $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $username, 'module')); |
30 | 30 | } |
31 | 31 | // end check for lock |
32 | 32 | |
33 | 33 | // take action |
34 | -switch($_REQUEST['op']) { |
|
34 | +switch ($_REQUEST['op']) { |
|
35 | 35 | case 'add': |
36 | 36 | // convert ids to numbers |
37 | 37 | $opids = array_filter(array_map('intval', explode(',', $_REQUEST['newids']))); |
38 | 38 | |
39 | - if(count($opids) > 0) { |
|
39 | + if (count($opids) > 0) { |
|
40 | 40 | // 1-snips, 2-tpls, 3-tvs, 4-chunks, 5-plugins, 6-docs |
41 | 41 | $rt = strtolower($_REQUEST["rt"]); |
42 | - if($rt == 'chunk') { |
|
42 | + if ($rt == 'chunk') { |
|
43 | 43 | $type = 10; |
44 | 44 | } |
45 | - if($rt == 'doc') { |
|
45 | + if ($rt == 'doc') { |
|
46 | 46 | $type = 20; |
47 | 47 | } |
48 | - if($rt == 'plug') { |
|
48 | + if ($rt == 'plug') { |
|
49 | 49 | $type = 30; |
50 | 50 | } |
51 | - if($rt == 'snip') { |
|
51 | + if ($rt == 'snip') { |
|
52 | 52 | $type = 40; |
53 | 53 | } |
54 | - if($rt == 'tpl') { |
|
54 | + if ($rt == 'tpl') { |
|
55 | 55 | $type = 50; |
56 | 56 | } |
57 | - if($rt == 'tv') { |
|
57 | + if ($rt == 'tv') { |
|
58 | 58 | $type = 60; |
59 | 59 | } |
60 | - $modx->db->delete($tbl_site_module_depobj, "module='{$id}' AND resource IN (" . implode(',', $opids) . ") AND type='{$type}'"); |
|
61 | - foreach($opids as $opid) { |
|
60 | + $modx->db->delete($tbl_site_module_depobj, "module='{$id}' AND resource IN (".implode(',', $opids).") AND type='{$type}'"); |
|
61 | + foreach ($opids as $opid) { |
|
62 | 62 | $modx->db->insert(array( |
63 | 63 | 'module' => $id, |
64 | 64 | 'resource' => $opid, |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | $opids = array_filter(array_map('intval', $_REQUEST['depid'])); |
73 | 73 | |
74 | 74 | // get resources that needs to be removed |
75 | - $ds = $modx->db->select('*', $tbl_site_module_depobj, "id IN (" . implode(",", $opids) . ")"); |
|
75 | + $ds = $modx->db->select('*', $tbl_site_module_depobj, "id IN (".implode(",", $opids).")"); |
|
76 | 76 | // loop through resources and look for plugins and snippets |
77 | 77 | $plids = array(); |
78 | 78 | $snid = array(); |
79 | - while($row = $modx->db->getRow($ds)) { |
|
80 | - if($row['type'] == '30') { |
|
79 | + while ($row = $modx->db->getRow($ds)) { |
|
80 | + if ($row['type'] == '30') { |
|
81 | 81 | $plids[$i] = $row['resource']; |
82 | 82 | } |
83 | - if($row['type'] == '40') { |
|
83 | + if ($row['type'] == '40') { |
|
84 | 84 | $snids[$i] = $row['resource']; |
85 | 85 | } |
86 | 86 | } |
@@ -88,28 +88,28 @@ discard block |
||
88 | 88 | $ds = $modx->db->select('guid', $tbl_site_modules, "id='{$id}'"); |
89 | 89 | $guid = $modx->db->getValue($ds); |
90 | 90 | // reset moduleguid for deleted resources |
91 | - if(($cp = count($plids)) || ($cs = count($snids))) { |
|
92 | - if($cp) { |
|
93 | - $modx->db->update(array('moduleguid' => ''), $tbl_site_plugins, "id IN (" . implode(',', $plids) . ") AND moduleguid='{$guid}'"); |
|
91 | + if (($cp = count($plids)) || ($cs = count($snids))) { |
|
92 | + if ($cp) { |
|
93 | + $modx->db->update(array('moduleguid' => ''), $tbl_site_plugins, "id IN (".implode(',', $plids).") AND moduleguid='{$guid}'"); |
|
94 | 94 | } |
95 | - if($cs) { |
|
96 | - $modx->db->update(array('moduleguid' => ''), $tbl_site_plugins, "id IN (" . implode(',', $snids) . ") AND moduleguid='{$guid}'"); |
|
95 | + if ($cs) { |
|
96 | + $modx->db->update(array('moduleguid' => ''), $tbl_site_plugins, "id IN (".implode(',', $snids).") AND moduleguid='{$guid}'"); |
|
97 | 97 | } |
98 | 98 | // reset cache |
99 | 99 | $modx->clearCache('full'); |
100 | 100 | } |
101 | - $modx->db->delete($tbl_site_module_depobj, "id IN (" . implode(',', $opids) . ")"); |
|
101 | + $modx->db->delete($tbl_site_module_depobj, "id IN (".implode(',', $opids).")"); |
|
102 | 102 | break; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // load record |
106 | 106 | $rs = $modx->db->select('*', $tbl_site_modules, "id = '{$id}'"); |
107 | 107 | $content = $modx->db->getRow($rs); |
108 | -if(!$content) { |
|
108 | +if (!$content) { |
|
109 | 109 | $modx->webAlertAndQuit("Module not found for id '{$id}'."); |
110 | 110 | } |
111 | 111 | $_SESSION['itemname'] = $content['name']; |
112 | -if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) { |
|
112 | +if ($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) { |
|
113 | 113 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
114 | 114 | } |
115 | 115 | |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | <input type="hidden" name="id" value="<?php echo $content['id']; ?>" /> |
189 | 189 | |
190 | 190 | <h1> |
191 | - <i class="fa fa-cogs"></i><?= ($content['name'] ? $content['name'] . '<small>(' . $content['id'] . ')</small>' : $_lang['module_resource_title']) ?> |
|
191 | + <i class="fa fa-cogs"></i><?= ($content['name'] ? $content['name'].'<small>('.$content['id'].')</small>' : $_lang['module_resource_title']) ?> |
|
192 | 192 | </h1> |
193 | 193 | |
194 | 194 | <?php echo $_style['actionbuttons']['dynamic']['close'] ?> |
195 | 195 | |
196 | 196 | <div class="section"> |
197 | - <div class="sectionHeader"><?php echo $content["name"] . " - " . $_lang['module_resource_title']; ?></div> |
|
197 | + <div class="sectionHeader"><?php echo $content["name"]." - ".$_lang['module_resource_title']; ?></div> |
|
198 | 198 | <div class="sectionBody"> |
199 | 199 | <p><?php echo $_lang['module_resource_msg']; ?></p> |
200 | 200 | <br /> |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | LEFT JOIN {$tbl_site_snippets} AS ss ON ss.id = smd.resource AND smd.type = '40' |
219 | 219 | LEFT JOIN {$tbl_site_templates} AS st ON st.id = smd.resource AND smd.type = '50' |
220 | 220 | LEFT JOIN {$tbl_site_tmplvars} AS sv ON sv.id = smd.resource AND smd.type = '60'", "smd.module={$id}", "smd.type,name"); |
221 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
221 | + include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; |
|
222 | 222 | $grd = new DataGrid('', $ds, 0); // set page size to 0 t show all items |
223 | 223 | $grd->noRecordMsg = $_lang["no_records_found"]; |
224 | 224 | $grd->cssClass = "grid"; |
225 | 225 | $grd->columnHeaderClass = "gridHeader"; |
226 | 226 | $grd->itemClass = "gridItem"; |
227 | 227 | $grd->altItemClass = "gridAltItem"; |
228 | - $grd->columns = $_lang["element_name"] . " ," . $_lang["type"]; |
|
228 | + $grd->columns = $_lang["element_name"]." ,".$_lang["type"]; |
|
229 | 229 | $grd->colTypes = "template:<input type='checkbox' name='depid[]' value='[+id+]'> [+value+]"; |
230 | 230 | $grd->fields = "name,type"; |
231 | 231 | echo $grd->render(); |
@@ -1,5 +1,5 @@ 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 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
19 | 19 | } |
20 | 20 | |
21 | -$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
21 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
22 | 22 | |
23 | 23 | // Get table Names (alphabetical) |
24 | 24 | $tbl_site_module_depobj = $modx->getFullTableName('site_module_depobj'); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $rs = $modx->db->select('*', $tbl_site_snippets, "id='{$id}'"); |
40 | 40 | $content = $modx->db->getRow($rs); |
41 | 41 | if (!$content) { |
42 | - header("Location: " . MODX_SITE_URL . "index.php?id=" . $site_start); |
|
42 | + header("Location: ".MODX_SITE_URL."index.php?id=".$site_start); |
|
43 | 43 | } |
44 | 44 | $_SESSION['itemname'] = $content['name']; |
45 | 45 | if ($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $content['name'] = $_REQUEST['itemname']; |
51 | 51 | } else { |
52 | 52 | $_SESSION['itemname'] = $_lang["new_snippet"]; |
53 | - $content['category'] = (int)$_REQUEST['catid']; |
|
53 | + $content['category'] = (int) $_REQUEST['catid']; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($modx->manager->hasFormValues()) { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // Add lock-element JS-Script |
63 | 63 | $lockElementId = $id; |
64 | 64 | $lockElementType = 4; |
65 | -require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); |
|
65 | +require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php'); |
|
66 | 66 | ?> |
67 | 67 | <script type="text/javascript"> |
68 | 68 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | <input type="hidden" name="mode" value="<?= $modx->manager->action ?>"> |
432 | 432 | |
433 | 433 | <h1 class="pagetitle"> |
434 | - <i class="fa fa-code"></i><?= ($content['name'] ? $content['name'] . '<small>(' . $content['id'] . ')</small>' : $_lang['new_snippet']) ?><i class="fa fa-question-circle help"></i> |
|
434 | + <i class="fa fa-code"></i><?= ($content['name'] ? $content['name'].'<small>('.$content['id'].')</small>' : $_lang['new_snippet']) ?><i class="fa fa-question-circle help"></i> |
|
435 | 435 | </h1> |
436 | 436 | |
437 | 437 | <?= $_style['actionbuttons']['dynamic']['element'] ?> |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | <div class="form-control-name clearfix"> |
458 | 458 | <input name="name" type="text" maxlength="100" value="<?= $modx->htmlspecialchars($content['name']) ?>" class="form-control form-control-lg" onchange="documentDirty=true;" /> |
459 | 459 | <?php if ($modx->hasPermission('save_role')): ?> |
460 | - <label class="custom-control" title="<?= $_lang['lock_snippet'] . "\n" . $_lang['lock_snippet_msg'] ?>" tooltip> |
|
460 | + <label class="custom-control" title="<?= $_lang['lock_snippet']."\n".$_lang['lock_snippet_msg'] ?>" tooltip> |
|
461 | 461 | <input name="locked" type="checkbox"<?= ($content['locked'] == 1 ? ' checked="checked"' : '') ?> /> |
462 | 462 | <i class="fa fa-lock"></i> |
463 | 463 | </label> |
@@ -481,9 +481,9 @@ discard block |
||
481 | 481 | <select name="categoryid" class="form-control" onchange="documentDirty=true;"> |
482 | 482 | <option> </option> |
483 | 483 | <?php |
484 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
484 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
485 | 485 | foreach (getCategories() as $n => $v) { |
486 | - echo '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . '</option>'; |
|
486 | + echo '<option value="'.$v['id'].'"'.($content['category'] == $v['id'] ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($v['category']).'</option>'; |
|
487 | 487 | } |
488 | 488 | ?> |
489 | 489 | </select> |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | <div class="form-group"> |
501 | 501 | <?php if ($_SESSION['mgrRole'] == 1): ?> |
502 | 502 | <div class="form-row"> |
503 | - <label><input name="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> /> <?= ($content['disabled'] == 1 ? "<span class='text-danger'>" . $_lang['disabled'] . "</span>" : $_lang['disabled']) ?></label> |
|
503 | + <label><input name="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> /> <?= ($content['disabled'] == 1 ? "<span class='text-danger'>".$_lang['disabled']."</span>" : $_lang['disabled']) ?></label> |
|
504 | 504 | </div> |
505 | 505 | <?php endif; ?> |
506 | 506 | <div class="form-row"> |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | <span><?= $_lang['snippet_code'] ?></span> |
518 | 518 | </div> |
519 | 519 | <div class="section-editor clearfix"> |
520 | - <textarea dir="ltr" name="post" class="phptextarea" rows="20" wrap="soft" onchange="documentDirty=true;"><?= (isset($content['post']) ? trim($modx->htmlspecialchars($content['post'])) : "<?php" . "\n" . trim($modx->htmlspecialchars($content['snippet'])) . "\n") ?></textarea> |
|
520 | + <textarea dir="ltr" name="post" class="phptextarea" rows="20" wrap="soft" onchange="documentDirty=true;"><?= (isset($content['post']) ? trim($modx->htmlspecialchars($content['post'])) : "<?php"."\n".trim($modx->htmlspecialchars($content['snippet']))."\n") ?></textarea> |
|
521 | 521 | </div> |
522 | 522 | <!-- PHP text editor end --> |
523 | 523 | </div> |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | INNER JOIN {$tbl_site_module_depobj} AS smd ON smd.module=sm.id AND smd.type=40 |
553 | 553 | INNER JOIN {$tbl_site_snippets} AS ss ON ss.id=smd.resource", "smd.resource='{$id}' AND sm.enable_sharedparams=1", 'sm.name'); |
554 | 554 | while ($row = $modx->db->getRow($ds)) { |
555 | - echo "<option value='" . $row['guid'] . "'" . ($content['moduleguid'] == $row['guid'] ? " selected='selected'" : "") . ">" . $modx->htmlspecialchars($row['name']) . "</option>"; |
|
555 | + echo "<option value='".$row['guid']."'".($content['moduleguid'] == $row['guid'] ? " selected='selected'" : "").">".$modx->htmlspecialchars($row['name'])."</option>"; |
|
556 | 556 | } |
557 | 557 | ?> |
558 | 558 | </select> |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -$userid = (int)$value; |
|
2 | +$userid = (int) $value; |
|
3 | 3 | if (!isset($modx->filter->cache['ui'][$userid])) { |
4 | 4 | if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid)); |
5 | 5 | else $user = $modx->getUserInfo($userid); |
@@ -1,43 +1,43 @@ |
||
1 | 1 | <?php |
2 | -if(strpos($opt,',')) list($limit,$delim) = explode(',', $opt); |
|
3 | -elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} |
|
4 | -else {$limit=124;$delim='';} |
|
2 | +if (strpos($opt, ',')) list($limit, $delim) = explode(',', $opt); |
|
3 | +elseif (preg_match('/^[1-9][0-9]*$/', $opt)) {$limit = $opt; $delim = ''; } |
|
4 | +else {$limit = 124; $delim = ''; } |
|
5 | 5 | |
6 | -if($delim==='') $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
7 | -$limit = (int)$limit; |
|
6 | +if ($delim === '') $delim = $modx->config['manager_language'] === 'japanese-utf8' ? '。' : '.'; |
|
7 | +$limit = (int) $limit; |
|
8 | 8 | |
9 | 9 | $content = $modx->filter->parseDocumentSource($value); |
10 | 10 | |
11 | 11 | $content = strip_tags($content); |
12 | 12 | |
13 | -$content = str_replace(array("\r\n","\r","\n","\t",' '),' ',$content); |
|
14 | -if(preg_match('/\s+/',$content)) |
|
15 | - $content = preg_replace('/\s+/',' ',$content); |
|
13 | +$content = str_replace(array("\r\n", "\r", "\n", "\t", ' '), ' ', $content); |
|
14 | +if (preg_match('/\s+/', $content)) |
|
15 | + $content = preg_replace('/\s+/', ' ', $content); |
|
16 | 16 | $content = trim($content); |
17 | 17 | |
18 | 18 | $pos = $modx->filter->strpos($content, $delim); |
19 | 19 | |
20 | -if($pos!==false && $pos<$limit) { |
|
20 | +if ($pos !== false && $pos < $limit) { |
|
21 | 21 | $_ = explode($delim, $content); |
22 | 22 | $text = ''; |
23 | - foreach($_ as $v) { |
|
24 | - if($limit <= $modx->filter->strlen($text.$v.$delim)) break; |
|
23 | + foreach ($_ as $v) { |
|
24 | + if ($limit <= $modx->filter->strlen($text.$v.$delim)) break; |
|
25 | 25 | $text .= $v.$delim; |
26 | 26 | } |
27 | - if($text) $content = $text; |
|
27 | + if ($text) $content = $text; |
|
28 | 28 | } |
29 | 29 | |
30 | -if($limit<$modx->filter->strlen($content) && strpos($content,' ')!==false) { |
|
30 | +if ($limit < $modx->filter->strlen($content) && strpos($content, ' ') !== false) { |
|
31 | 31 | $_ = explode(' ', $content); |
32 | 32 | $text = ''; |
33 | - foreach($_ as $v) { |
|
34 | - if($limit <= $modx->filter->strlen($text.$v.' ')) break; |
|
35 | - $text .= $v . ' '; |
|
33 | + foreach ($_ as $v) { |
|
34 | + if ($limit <= $modx->filter->strlen($text.$v.' ')) break; |
|
35 | + $text .= $v.' '; |
|
36 | 36 | } |
37 | - if($text!=='') $content = $text; |
|
37 | + if ($text !== '') $content = $text; |
|
38 | 38 | } |
39 | 39 | |
40 | -if($limit < $modx->filter->strlen($content)) $content = $modx->filter->substr($content, 0, $limit); |
|
41 | -if($modx->filter->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim; |
|
40 | +if ($limit < $modx->filter->strlen($content)) $content = $modx->filter->substr($content, 0, $limit); |
|
41 | +if ($modx->filter->substr($content, -1) == $delim) $content = rtrim($content, $delim).$delim; |
|
42 | 42 | |
43 | 43 | return $content; |
@@ -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); |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataGridCnt = 0; |
12 | 12 | |
13 | -class DataGrid { |
|
13 | +class DataGrid{ |
|
14 | 14 | |
15 | 15 | public $ds; // datasource |
16 | 16 | public $id; |
17 | - public $pageSize; // pager settings |
|
17 | + public $pageSize; // pager settings |
|
18 | 18 | public $pageNumber; |
19 | 19 | public $pager; |
20 | - public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
20 | + public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
21 | 21 | |
22 | 22 | public $cssStyle; |
23 | 23 | public $cssClass; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public $colAligns; |
36 | 36 | public $colWraps; |
37 | 37 | public $colColors; |
38 | - public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
38 | + public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
39 | 39 | // data type: integer,float,currency,date |
40 | 40 | |
41 | 41 | public $header; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public $cellPadding; |
44 | 44 | public $cellSpacing; |
45 | 45 | |
46 | - public $rowAlign; // vertical alignment: top, middle, bottom |
|
46 | + public $rowAlign; // vertical alignment: top, middle, bottom |
|
47 | 47 | public $rowIdField; |
48 | 48 | |
49 | 49 | public $pagerStyle; |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public $cdelim; |
74 | 74 | |
75 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
75 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){ |
|
76 | 76 | global $__DataGridCnt; |
77 | 77 | |
78 | 78 | // set id |
79 | 79 | $__DataGridCnt++; |
80 | - $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt; |
|
80 | + $this->id = $this->id ? empty($id) : "dg".$__DataGridCnt; |
|
81 | 81 | |
82 | 82 | // set datasource |
83 | 83 | $this->ds = $ds; |
@@ -88,50 +88,50 @@ discard block |
||
88 | 88 | $this->pagerLocation = 'top-right'; |
89 | 89 | } |
90 | 90 | |
91 | - public function setDataSource($ds) { |
|
91 | + public function setDataSource($ds){ |
|
92 | 92 | $this->ds = $ds; |
93 | 93 | } |
94 | 94 | |
95 | - public function render() { |
|
95 | + public function render(){ |
|
96 | 96 | global $modx; |
97 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
98 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
99 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
100 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
97 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : ''; |
|
98 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : ""; |
|
99 | + $cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : ''; |
|
100 | + $cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : ''; |
|
101 | 101 | |
102 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
103 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
102 | + $pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : ''; |
|
103 | + $pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'"; |
|
104 | 104 | |
105 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
106 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
107 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
108 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
105 | + $this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : ''; |
|
106 | + $this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : ''; |
|
107 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : ''; |
|
108 | + $this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : ''; |
|
109 | 109 | |
110 | 110 | $this->_alt = 0; |
111 | 111 | $this->_total = 0; |
112 | 112 | |
113 | 113 | $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
114 | 114 | |
115 | - if(!$cssStyle && !$cssClass) { |
|
115 | + if (!$cssStyle && !$cssClass) { |
|
116 | 116 | $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
117 | 117 | } |
118 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
118 | + if (!$columnHeaderStyle && !$columnHeaderClass) { |
|
119 | 119 | $columnHeaderStyle = "style='color:black;background-color:silver'"; |
120 | 120 | } |
121 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
121 | + if (!$this->_itemStyle && !$this->_itemClass) { |
|
122 | 122 | $this->_itemStyle = "style='color:black;'"; |
123 | 123 | } |
124 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
124 | + if (!$this->_altItemStyle && !$this->_altItemClass) { |
|
125 | 125 | $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
126 | 126 | } |
127 | 127 | |
128 | - if($this->_isDataset && !$this->columns) { |
|
128 | + if ($this->_isDataset && !$this->columns) { |
|
129 | 129 | $cols = $modx->db->numFields($this->ds); |
130 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
130 | + for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->db->fieldName($this->ds, $i); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // start grid |
134 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
134 | + $tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>"; |
|
135 | 135 | $tblEnd = "</table>"; |
136 | 136 | |
137 | 137 | // build column header |
@@ -142,33 +142,33 @@ discard block |
||
142 | 142 | $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
143 | 143 | $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
144 | 144 | $this->_colcount = count($this->_colnames); |
145 | - if(!$this->_isDataset) { |
|
145 | + if (!$this->_isDataset) { |
|
146 | 146 | $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
147 | 147 | $this->ds = array_chunk($this->ds, $this->_colcount); |
148 | 148 | } |
149 | 149 | $tblColHdr = "<thead><tr>"; |
150 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
150 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
151 | 151 | $name = $this->_colnames[$c]; |
152 | 152 | $width = $this->_colwidths[$c]; |
153 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
153 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>"; |
|
154 | 154 | } |
155 | 155 | $tblColHdr .= "</tr></thead>\n"; |
156 | 156 | |
157 | 157 | // build rows |
158 | 158 | $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
159 | 159 | $this->_fieldnames = explode(",", $this->fields); |
160 | - if($rowcount == 0) { |
|
161 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
160 | + if ($rowcount == 0) { |
|
161 | + $tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n"; |
|
162 | 162 | } else { |
163 | 163 | // render grid items |
164 | - if($this->pageSize <= 0) { |
|
165 | - for($r = 0; $r < $rowcount; $r++) { |
|
164 | + if ($this->pageSize <= 0) { |
|
165 | + for ($r = 0; $r < $rowcount; $r++) { |
|
166 | 166 | $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
167 | 167 | $tblRows .= $this->RenderRowFnc($r + 1, $row); |
168 | 168 | } |
169 | 169 | } else { |
170 | - if(!$this->pager) { |
|
171 | - include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
170 | + if (!$this->pager) { |
|
171 | + include_once dirname(__FILE__)."/datasetpager.class.php"; |
|
172 | 172 | $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
173 | 173 | $this->pager->setRenderRowFnc($this); // pass this object |
174 | 174 | $this->pager->cssStyle = $pagerStyle; |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | $o = $tblStart; |
189 | 189 | $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
190 | 190 | $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
191 | - if($this->header) { |
|
192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
191 | + if ($this->header) { |
|
192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>"; |
|
193 | 193 | } |
194 | - if($tblPager && $ptop) { |
|
195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
194 | + if ($tblPager && $ptop) { |
|
195 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
196 | 196 | } |
197 | - $o .= $tblColHdr . $tblRows; |
|
198 | - if($tblPager && $pbot) { |
|
199 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
197 | + $o .= $tblColHdr.$tblRows; |
|
198 | + if ($tblPager && $pbot) { |
|
199 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
200 | 200 | } |
201 | - if($this->footer) { |
|
202 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
201 | + if ($this->footer) { |
|
202 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>"; |
|
203 | 203 | } |
204 | 204 | $o .= $tblEnd; |
205 | 205 | return $o; |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | |
208 | 208 | // format column values |
209 | 209 | |
210 | - public function RenderRowFnc($n, $row) { |
|
211 | - if($this->_alt == 0) { |
|
210 | + public function RenderRowFnc($n, $row){ |
|
211 | + if ($this->_alt == 0) { |
|
212 | 212 | $Style = $this->_itemStyle; |
213 | 213 | $Class = $this->_itemClass; |
214 | 214 | $this->_alt = 1; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $this->_alt = 0; |
219 | 219 | } |
220 | 220 | $o = "<tr>"; |
221 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
221 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
222 | 222 | $colStyle = $Style; |
223 | 223 | $fld = trim($this->_fieldnames[$c]); |
224 | 224 | $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
@@ -227,67 +227,67 @@ discard block |
||
227 | 227 | $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
228 | 228 | $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
229 | 229 | $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
230 | - if($color && $Style) { |
|
231 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
230 | + if ($color && $Style) { |
|
231 | + $colStyle = substr($colStyle, 0, -1).";background-color:$color;'"; |
|
232 | 232 | } |
233 | 233 | $value = $this->formatColumnValue($row, $value, $type, $align); |
234 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
234 | + $o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>"; |
|
235 | 235 | } |
236 | 236 | $o .= "</tr>\n"; |
237 | 237 | return $o; |
238 | 238 | } |
239 | 239 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
241 | - if(strpos($type, ":") !== false) { |
|
240 | + public function formatColumnValue($row, $value, $type, &$align){ |
|
241 | + if (strpos($type, ":") !== false) { |
|
242 | 242 | list($type, $type_format) = explode(":", $type, 2); |
243 | 243 | } |
244 | - switch(strtolower($type)) { |
|
244 | + switch (strtolower($type)) { |
|
245 | 245 | case "integer": |
246 | - if($align == "") { |
|
246 | + if ($align == "") { |
|
247 | 247 | $align = "right"; |
248 | 248 | } |
249 | 249 | $value = number_format($value); |
250 | 250 | break; |
251 | 251 | |
252 | 252 | case "float": |
253 | - if($align == "") { |
|
253 | + if ($align == "") { |
|
254 | 254 | $align = "right"; |
255 | 255 | } |
256 | - if(!$type_format) { |
|
256 | + if (!$type_format) { |
|
257 | 257 | $type_format = 2; |
258 | 258 | } |
259 | 259 | $value = number_format($value, $type_format); |
260 | 260 | break; |
261 | 261 | |
262 | 262 | case "currency": |
263 | - if($align == "") { |
|
263 | + if ($align == "") { |
|
264 | 264 | $align = "right"; |
265 | 265 | } |
266 | - if(!$type_format) { |
|
266 | + if (!$type_format) { |
|
267 | 267 | $type_format = 2; |
268 | 268 | } |
269 | - $value = "$" . number_format($value, $type_format); |
|
269 | + $value = "$".number_format($value, $type_format); |
|
270 | 270 | break; |
271 | 271 | |
272 | 272 | case "date": |
273 | - if($align == "") { |
|
273 | + if ($align == "") { |
|
274 | 274 | $align = "right"; |
275 | 275 | } |
276 | - if(!is_numeric($value)) { |
|
276 | + if (!is_numeric($value)) { |
|
277 | 277 | $value = strtotime($value); |
278 | 278 | } |
279 | - if(!$type_format) { |
|
279 | + if (!$type_format) { |
|
280 | 280 | $type_format = "%A %d, %B %Y"; |
281 | 281 | } |
282 | 282 | $value = strftime($type_format, $value); |
283 | 283 | break; |
284 | 284 | |
285 | 285 | case "boolean": |
286 | - if($align == '') { |
|
286 | + if ($align == '') { |
|
287 | 287 | $align = "center"; |
288 | 288 | } |
289 | 289 | $value = number_format($value); |
290 | - if($value) { |
|
290 | + if ($value) { |
|
291 | 291 | $value = '•'; |
292 | 292 | } else { |
293 | 293 | $value = ' '; |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | // replace [+value+] first |
299 | 299 | $value = str_replace("[+value+]", $value, $type_format); |
300 | 300 | // replace other [+fields+] |
301 | - if(strpos($value, "[+") !== false) { |
|
302 | - foreach($row as $k => $v) { |
|
301 | + if (strpos($value, "[+") !== false) { |
|
302 | + foreach ($row as $k => $v) { |
|
303 | 303 | $value = str_replace("[+$k+]", $v, $value); |
304 | 304 | } |
305 | 305 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | global $ContextMenuCnt; |
4 | 4 | $ContextMenuCnt = 0; |
5 | 5 | |
6 | -class ContextMenu { |
|
6 | +class ContextMenu{ |
|
7 | 7 | public $id; |
8 | 8 | /** |
9 | 9 | * @var string |
@@ -18,56 +18,56 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public $width = 120; |
20 | 20 | |
21 | - public function __construct($id = '', $width = 120, $visible = false) { |
|
21 | + public function __construct($id = '', $width = 120, $visible = false){ |
|
22 | 22 | global $ContextMenuCnt; |
23 | 23 | $ContextMenuCnt++; |
24 | 24 | $this->html = ""; |
25 | 25 | $this->visible = $visible ? $visible : false; |
26 | - $this->width = is_numeric($width) ? (int)$width : 120; |
|
27 | - $this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt; // set id |
|
26 | + $this->width = is_numeric($width) ? (int) $width : 120; |
|
27 | + $this->id = $id ? $id : "cntxMnu".$ContextMenuCnt; // set id |
|
28 | 28 | } |
29 | 29 | |
30 | - public function addItem($text, $action = "", $img = "", $disabled = 0) { |
|
30 | + public function addItem($text, $action = "", $img = "", $disabled = 0){ |
|
31 | 31 | global $base_url, $_style; |
32 | - if($disabled) { |
|
32 | + if ($disabled) { |
|
33 | 33 | return; |
34 | 34 | } |
35 | - if(!$img) { |
|
36 | - $img = $base_url . $_style['tx']; |
|
35 | + if (!$img) { |
|
36 | + $img = $base_url.$_style['tx']; |
|
37 | 37 | } |
38 | - if(substr($action, 0, 3) == "js:") { |
|
38 | + if (substr($action, 0, 3) == "js:") { |
|
39 | 39 | $action = substr($action, 3); |
40 | - } else if(substr($action, 0, 3) == "hl:") { |
|
41 | - $action = "window.location.href='" . substr($action, 3) . "'"; |
|
40 | + } else if (substr($action, 0, 3) == "hl:") { |
|
41 | + $action = "window.location.href='".substr($action, 3)."'"; |
|
42 | 42 | } else { |
43 | - $action = "window.location.href='" . $action . "'"; |
|
43 | + $action = "window.location.href='".$action."'"; |
|
44 | 44 | } |
45 | - $action = " onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('" . $this->id . "');\""; |
|
46 | - $this->html .= "<div class='" . ($disabled ? "cntxMnuItemDisabled" : "cntxMnuItem") . "' $action>"; |
|
47 | - if(substr($img, 0, 5) == 'fa fa') { |
|
48 | - $img = '<i class="' . $img . '"></i>'; |
|
49 | - } else if(substr($img, 0, 1) != '<') { |
|
50 | - $img = '<img src="' . $img . '" />'; |
|
45 | + $action = " onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('".$this->id."');\""; |
|
46 | + $this->html .= "<div class='".($disabled ? "cntxMnuItemDisabled" : "cntxMnuItem")."' $action>"; |
|
47 | + if (substr($img, 0, 5) == 'fa fa') { |
|
48 | + $img = '<i class="'.$img.'"></i>'; |
|
49 | + } else if (substr($img, 0, 1) != '<') { |
|
50 | + $img = '<img src="'.$img.'" />'; |
|
51 | 51 | } |
52 | - $this->html .= $img . ' ' . $text . '</div>'; |
|
52 | + $this->html .= $img.' '.$text.'</div>'; |
|
53 | 53 | } |
54 | 54 | |
55 | - public function addSeparator() { |
|
55 | + public function addSeparator(){ |
|
56 | 56 | $this->html .= " |
57 | 57 | <div class='cntxMnuSeparator'></div> |
58 | 58 | "; |
59 | 59 | } |
60 | 60 | |
61 | - public function render() { |
|
61 | + public function render(){ |
|
62 | 62 | global $ContextMenuScript; |
63 | 63 | |
64 | - $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>"; |
|
64 | + $html = $ContextMenuScript."<div id='".$this->id."' class='contextMenu' style='width:".$this->width."px; visibility:".($this->visible ? 'visible' : 'hidden')."'>".$this->html."</div>"; |
|
65 | 65 | $ContextMenuScript = ""; // reset css |
66 | 66 | return $html; |
67 | 67 | } |
68 | 68 | |
69 | - public function getClientScriptObject() { |
|
70 | - return "getCntxMenu('" . $this->id . "')"; |
|
69 | + public function getClientScriptObject(){ |
|
70 | + return "getCntxMenu('".$this->id."')"; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataSetPagerCnt = 0; |
12 | 12 | |
13 | -class DataSetPager { |
|
13 | +class DataSetPager{ |
|
14 | 14 | |
15 | 15 | public $ds; // datasource |
16 | 16 | public $pageSize; |
@@ -31,26 +31,26 @@ discard block |
||
31 | 31 | public $renderPagerFnc; |
32 | 32 | public $renderPagerFncArgs; |
33 | 33 | |
34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
34 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){ |
|
35 | 35 | global $_PAGE; // use view state object |
36 | 36 | |
37 | 37 | global $__DataSetPagerCnt; |
38 | 38 | |
39 | 39 | // set id |
40 | 40 | $__DataSetPagerCnt++; |
41 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
41 | + $this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt; |
|
42 | 42 | |
43 | 43 | // get pagenumber |
44 | 44 | // by setting pager to -1 cause pager to load it's last page number |
45 | - if($pageNumber == -1) { |
|
45 | + if ($pageNumber == -1) { |
|
46 | 46 | $pageNumber = 1; |
47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
47 | + if (isset($_GET["dpgn".$this->id])) { |
|
48 | + $pageNumber = $_GET["dpgn".$this->id]; |
|
49 | + } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) { |
|
50 | + $pageNumber = $_PAGE['vs'][$id.'_dpgn']; |
|
51 | 51 | } |
52 | 52 | } |
53 | - if(!is_numeric($pageNumber)) { |
|
53 | + if (!is_numeric($pageNumber)) { |
|
54 | 54 | $pageNumber = 1; |
55 | 55 | } |
56 | 56 | |
@@ -61,40 +61,40 @@ discard block |
||
61 | 61 | $this->pager = ''; |
62 | 62 | } |
63 | 63 | |
64 | - public function getRenderedPager() { |
|
64 | + public function getRenderedPager(){ |
|
65 | 65 | return $this->pager; |
66 | 66 | } |
67 | 67 | |
68 | - public function getRenderedRows() { |
|
68 | + public function getRenderedRows(){ |
|
69 | 69 | return $this->rows; |
70 | 70 | } |
71 | 71 | |
72 | - public function setDataSource($ds) { |
|
72 | + public function setDataSource($ds){ |
|
73 | 73 | $this->ds = $ds; |
74 | 74 | } |
75 | 75 | |
76 | - public function setPageSize($ps) { |
|
76 | + public function setPageSize($ps){ |
|
77 | 77 | $this->pageSize = $ps; |
78 | 78 | } |
79 | 79 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
80 | + public function setRenderRowFnc($fncName, $args = ""){ |
|
81 | 81 | $this->renderRowFnc = &$fncName; |
82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
83 | 83 | |
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
87 | + public function setRenderPagerFnc($fncName, $args = ""){ |
|
88 | 88 | $this->renderPagerFnc = $fncName; |
89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | 90 | } |
91 | 91 | |
92 | - public function render() { |
|
92 | + public function render(){ |
|
93 | 93 | global $modx, $_PAGE; |
94 | 94 | |
95 | 95 | $isDataset = $modx->db->isResult($this->ds); |
96 | 96 | |
97 | - if(!$this->selPageStyle) { |
|
97 | + if (!$this->selPageStyle) { |
|
98 | 98 | $this->selPageStyle = "font-weight:bold"; |
99 | 99 | } |
100 | 100 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
103 | 103 | |
104 | 104 | // render: no records found |
105 | - if($tnr <= 0) { |
|
105 | + if ($tnr <= 0) { |
|
106 | 106 | $fnc = $this->renderRowFnc; |
107 | 107 | $args = $this->renderRowFncArgs; |
108 | - if(isset($fnc)) { |
|
109 | - if($args != "") { |
|
108 | + if (isset($fnc)) { |
|
109 | + if ($args != "") { |
|
110 | 110 | $this->rows .= $fnc(0, null, $args); |
111 | 111 | } // if agrs was specified then we will pass three params |
112 | 112 | else { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // get total pages |
120 | 120 | $tp = ceil($tnr / $this->pageSize); |
121 | - if($this->pageNumber > $tp) { |
|
121 | + if ($this->pageNumber > $tp) { |
|
122 | 122 | $this->pageNumber = 1; |
123 | 123 | } |
124 | 124 | |
@@ -126,39 +126,39 @@ discard block |
||
126 | 126 | $p = $this->pageNumber; |
127 | 127 | |
128 | 128 | // save page number to view state if available |
129 | - if(isset($_PAGE['vs'])) { |
|
130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
129 | + if (isset($_PAGE['vs'])) { |
|
130 | + $_PAGE['vs'][$this->id.'_dpgn'] = $p; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
134 | - if($tp > 1) { |
|
134 | + if ($tp > 1) { |
|
135 | 135 | $url = ''; |
136 | 136 | $fnc = $this->renderPagerFnc; |
137 | 137 | $args = $this->renderPagerFncArgs; |
138 | - if(!isset($fnc)) { |
|
139 | - if($modx->isFrontend()) { |
|
140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
138 | + if (!isset($fnc)) { |
|
139 | + if ($modx->isFrontend()) { |
|
140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?'; |
|
141 | 141 | } else { |
142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
142 | + $url = $_SERVER['PHP_SELF'].'?'; |
|
143 | 143 | } |
144 | 144 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
145 | + foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) { |
|
146 | 146 | $i++; |
147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
147 | + $url .= (($i > 1) ? "&" : "")."$n=$v"; |
|
148 | 148 | } |
149 | - if($i >= 1) { |
|
149 | + if ($i >= 1) { |
|
150 | 150 | $url .= "&"; |
151 | 151 | } |
152 | 152 | } |
153 | - for($i = 1; $i <= $tp; $i++) { |
|
154 | - if(isset($fnc)) { |
|
155 | - if($args != "") { |
|
153 | + for ($i = 1; $i <= $tp; $i++) { |
|
154 | + if (isset($fnc)) { |
|
155 | + if ($args != "") { |
|
156 | 156 | $this->pager .= $fnc($p, $i, $args); |
157 | 157 | } else { |
158 | 158 | $this->pager .= $fnc($p, $i); |
159 | 159 | } |
160 | 160 | } else { |
161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
161 | + $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> "; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | $fnc = $this->renderRowFnc; |
168 | 168 | $args = $this->renderRowFncArgs; |
169 | 169 | |
170 | - if(isset($fnc)) { |
|
170 | + if (isset($fnc)) { |
|
171 | 171 | $i = 1; |
172 | 172 | $fncObject = is_object($fnc); |
173 | 173 | $minitems = (($p - 1) * $this->pageSize) + 1; |
174 | 174 | $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | - if($i >= $minitems && $i <= $maxitems) { |
|
177 | - if($fncObject) { |
|
178 | - if($args != "") { |
|
175 | + while ($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | + if ($i >= $minitems && $i <= $maxitems) { |
|
177 | + if ($fncObject) { |
|
178 | + if ($args != "") { |
|
179 | 179 | $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
180 | 180 | } else { |
181 | 181 | $this->rows .= $fnc->RenderRowFnc($i, $row); |
182 | 182 | } |
183 | 183 | } else { |
184 | - if($args != "") { |
|
184 | + if ($args != "") { |
|
185 | 185 | $this->rows .= $fnc($i, $row, $args); |
186 | 186 | } // if agrs was specified then we wil pass three params |
187 | 187 | else { |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | -$lockElementId = (int)$lockElementId; |
|
6 | +$lockElementId = (int) $lockElementId; |
|
7 | 7 | |
8 | 8 | if ($lockElementId > 0) { |
9 | 9 | ?> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | var stay = document.getElementById('stay'); |
19 | 19 | // Trigger unlock |
20 | 20 | if ((stay && stay.value !== '2') || !form_save) { |
21 | - var url = '<?php echo MODX_MANAGER_URL; ?>?a=67&type=<?php echo $lockElementType;?>&id=<?php echo $lockElementId;?>&o=' + Math.random(); |
|
21 | + var url = '<?php echo MODX_MANAGER_URL; ?>?a=67&type=<?php echo $lockElementType; ?>&id=<?php echo $lockElementId; ?>&o=' + Math.random(); |
|
22 | 22 | if (navigator.sendBeacon) { |
23 | 23 | navigator.sendBeacon(url) |
24 | 24 | } else { |