@@ -21,5 +21,5 @@ |
||
21 | 21 | if($ok) { |
22 | 22 | echo '{status:"ok"}'; |
23 | 23 | } else { |
24 | - echo '{status:"null"}'; |
|
24 | + echo '{status:"null"}'; |
|
25 | 25 | } |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | |
4 | 4 | // PROCESSOR FIRST |
5 | 5 | if($_SESSION['mgrRole'] == 1) { |
6 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
7 | - $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
|
8 | - if(!empty($current)) { |
|
9 | - $modx->manager->setSystemChecksum($current); |
|
10 | - $modx->clearCache('full'); |
|
11 | - $modx->config['sys_files_checksum'] = $current; |
|
12 | - }; |
|
13 | - } |
|
6 | + if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
7 | + $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
|
8 | + if(!empty($current)) { |
|
9 | + $modx->manager->setSystemChecksum($current); |
|
10 | + $modx->clearCache('full'); |
|
11 | + $modx->config['sys_files_checksum'] = $current; |
|
12 | + }; |
|
13 | + } |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | // NOW CHECK CONFIG |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | |
19 | 19 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
20 | 20 | if ($sysfiles_check!=='0'){ |
21 | - $warningspresent = 1; |
|
22 | - $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
|
21 | + $warningspresent = 1; |
|
22 | + $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if (is_writable("includes/config.inc.php")){ |
26 | 26 | // Warn if world writable |
27 | 27 | if(@fileperms('includes/config.inc.php') & 0x0002) { |
28 | - $warningspresent = 1; |
|
29 | - $warnings[] = array($_lang['configcheck_configinc']); |
|
28 | + $warningspresent = 1; |
|
29 | + $warnings[] = array($_lang['configcheck_configinc']); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | break; |
178 | 178 | case $_lang['configcheck_sysfiles_mod']: |
179 | 179 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
180 | - $warnings[$i][2] = '<ul><li>'. join('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
181 | - if($modx->hasPermission('settings')) { |
|
182 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
183 | - } |
|
180 | + $warnings[$i][2] = '<ul><li>'. join('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
181 | + if($modx->hasPermission('settings')) { |
|
182 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
183 | + } |
|
184 | 184 | if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".join(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
185 | 185 | break; |
186 | 186 | case $_lang['configcheck_lang_difference'] : |
@@ -9,178 +9,178 @@ |
||
9 | 9 | |
10 | 10 | Class TemplateParser { |
11 | 11 | |
12 | - function __construct() { |
|
13 | - } |
|
14 | - |
|
15 | - /** |
|
16 | - * @param array $config [action, tabs, toArray] |
|
17 | - * @param array $data |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function output($config = array(), $data = array()) { |
|
21 | - global $modx; |
|
22 | - |
|
23 | - $output = ''; |
|
24 | - $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
|
25 | - $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : ''; |
|
26 | - |
|
27 | - if($action) { |
|
28 | - $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name |
|
12 | + function __construct() { |
|
13 | + } |
|
14 | + |
|
15 | + /** |
|
16 | + * @param array $config [action, tabs, toArray] |
|
17 | + * @param array $data |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function output($config = array(), $data = array()) { |
|
21 | + global $modx; |
|
22 | + |
|
23 | + $output = ''; |
|
24 | + $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
|
25 | + $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : ''; |
|
26 | + |
|
27 | + if($action) { |
|
28 | + $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name |
|
29 | 29 | FROM ' . $modx->getFullTableName('system_templates') . ' AS t1 |
30 | 30 | INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category |
31 | 31 | WHERE t1.action IN(' . $action . ') ' . $tab . ' |
32 | 32 | ORDER BY t1.tab ASC, t1.rank ASC'); |
33 | 33 | |
34 | - if($modx->db->getRecordCount($sql)) { |
|
35 | - $tabs = array(); |
|
36 | - while($row = $modx->db->getRow($sql)) { |
|
37 | - if(!$row['value'] && !empty($data[$row['name']])) { |
|
38 | - $row['value'] = $data[$row['name']]; |
|
39 | - } |
|
40 | - $tabs[$row['tab']]['category_name'] = $row['category_name']; |
|
41 | - $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
|
42 | - } |
|
43 | - |
|
44 | - if(!empty($config['toArray'])) { |
|
45 | - $output = $tabs; |
|
46 | - } else { |
|
47 | - $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
48 | - $output .= ' |
|
34 | + if($modx->db->getRecordCount($sql)) { |
|
35 | + $tabs = array(); |
|
36 | + while($row = $modx->db->getRow($sql)) { |
|
37 | + if(!$row['value'] && !empty($data[$row['name']])) { |
|
38 | + $row['value'] = $data[$row['name']]; |
|
39 | + } |
|
40 | + $tabs[$row['tab']]['category_name'] = $row['category_name']; |
|
41 | + $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
|
42 | + } |
|
43 | + |
|
44 | + if(!empty($config['toArray'])) { |
|
45 | + $output = $tabs; |
|
46 | + } else { |
|
47 | + $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
48 | + $output .= ' |
|
49 | 49 | <script type="text/javascript"> |
50 | 50 | var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
51 | 51 | </script>'; |
52 | 52 | |
53 | - foreach($tabs as $idTab => $tab) { |
|
54 | - $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
55 | - $output .= ' |
|
53 | + foreach($tabs as $idTab => $tab) { |
|
54 | + $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
55 | + $output .= ' |
|
56 | 56 | <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2> |
57 | 57 | <script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>'; |
58 | - unset($tab['category_name']); |
|
59 | - foreach($tab as $item) { |
|
60 | - $output .= $item; |
|
61 | - } |
|
62 | - $output .= '</div>'; |
|
63 | - } |
|
64 | - $output .= '</div>'; |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - return $output; |
|
70 | - } |
|
71 | - |
|
72 | - private function render($data) { |
|
73 | - global $modx, $_lang, $_country_lang; |
|
74 | - |
|
75 | - $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
|
76 | - $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->htmlspecialchars($data['value']) : '')); |
|
77 | - $data['readonly'] = ($data['readonly'] ? ' readonly' : ''); |
|
78 | - |
|
79 | - $output = ''; |
|
80 | - $output .= '<div class="form-group row">'; |
|
81 | - |
|
82 | - switch($data['type']) { |
|
83 | - |
|
84 | - case 'text': |
|
85 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
58 | + unset($tab['category_name']); |
|
59 | + foreach($tab as $item) { |
|
60 | + $output .= $item; |
|
61 | + } |
|
62 | + $output .= '</div>'; |
|
63 | + } |
|
64 | + $output .= '</div>'; |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + return $output; |
|
70 | + } |
|
71 | + |
|
72 | + private function render($data) { |
|
73 | + global $modx, $_lang, $_country_lang; |
|
74 | + |
|
75 | + $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
|
76 | + $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->htmlspecialchars($data['value']) : '')); |
|
77 | + $data['readonly'] = ($data['readonly'] ? ' readonly' : ''); |
|
78 | + |
|
79 | + $output = ''; |
|
80 | + $output .= '<div class="form-group row">'; |
|
81 | + |
|
82 | + switch($data['type']) { |
|
83 | + |
|
84 | + case 'text': |
|
85 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
86 | 86 | <div class="col-sm-7"> |
87 | 87 | <input type="text" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
88 | - $output .= $data['content']; |
|
89 | - $output .= '</div>'; |
|
88 | + $output .= $data['content']; |
|
89 | + $output .= '</div>'; |
|
90 | 90 | |
91 | - break; |
|
91 | + break; |
|
92 | 92 | |
93 | - case 'textarea': |
|
94 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
93 | + case 'textarea': |
|
94 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
95 | 95 | <div class="col-sm-7"> |
96 | 96 | <textarea name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;"[+readonly+]>[+value+]</textarea>'; |
97 | - $output .= $data['content']; |
|
98 | - $output .= '</div>'; |
|
97 | + $output .= $data['content']; |
|
98 | + $output .= '</div>'; |
|
99 | 99 | |
100 | - break; |
|
100 | + break; |
|
101 | 101 | |
102 | - case 'date': |
|
103 | - $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : '')); |
|
104 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
102 | + case 'date': |
|
103 | + $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : '')); |
|
104 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
105 | 105 | <div class="col-sm-7"> |
106 | 106 | <input type="text" name="[+name+]" class="form-control DatePicker" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
107 | - $output .= $data['content']; |
|
108 | - $output .= '</div>'; |
|
109 | - |
|
110 | - break; |
|
111 | - |
|
112 | - case 'select': |
|
113 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
114 | - $output .= '<div class="col-sm-7">'; |
|
115 | - $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
|
116 | - if($data['name'] == 'country' && isset($_country_lang)) { |
|
117 | - $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
|
118 | - $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
119 | - foreach($_country_lang as $key => $value) { |
|
120 | - $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
121 | - } |
|
122 | - } else { |
|
123 | - if($data['elements']) { |
|
124 | - $elements = explode('||', $data['elements']); |
|
125 | - foreach($elements as $key => $value) { |
|
126 | - $value = explode('==', $value); |
|
127 | - $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
131 | - $output .= '</select>'; |
|
132 | - $output .= $data['content']; |
|
133 | - $output .= '</div>'; |
|
134 | - |
|
135 | - break; |
|
136 | - |
|
137 | - case 'checkbox': |
|
138 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
139 | - $output .= '<div class="col-sm-7">'; |
|
140 | - $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
141 | - if($data['elements']) { |
|
142 | - $elements = explode('||', $data['elements']); |
|
143 | - foreach($elements as $key => $value) { |
|
144 | - $value = explode('==', $value); |
|
145 | - $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
146 | - } |
|
147 | - } |
|
148 | - $output .= $data['content']; |
|
149 | - $output .= '</div>'; |
|
150 | - |
|
151 | - break; |
|
152 | - |
|
153 | - case 'radio': |
|
154 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
155 | - $output .= '<div class="col-sm-7">'; |
|
156 | - $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
157 | - if($data['elements']) { |
|
158 | - $elements = explode('||', $data['elements']); |
|
159 | - foreach($elements as $key => $value) { |
|
160 | - $value = explode('==', $value); |
|
161 | - $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
162 | - } |
|
163 | - } |
|
164 | - $output .= $data['content']; |
|
165 | - $output .= '</div>'; |
|
166 | - |
|
167 | - break; |
|
168 | - |
|
169 | - case 'custom': |
|
170 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
171 | - $output .= '<div class="col-sm-7">'; |
|
172 | - $output .= $data['content']; |
|
173 | - $output .= '</div>'; |
|
174 | - |
|
175 | - break; |
|
176 | - } |
|
177 | - |
|
178 | - $output .= '</div>'; |
|
179 | - |
|
180 | - $output = $modx->parseText($output, $data); |
|
181 | - |
|
182 | - return $output; |
|
183 | - } |
|
107 | + $output .= $data['content']; |
|
108 | + $output .= '</div>'; |
|
109 | + |
|
110 | + break; |
|
111 | + |
|
112 | + case 'select': |
|
113 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
114 | + $output .= '<div class="col-sm-7">'; |
|
115 | + $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
|
116 | + if($data['name'] == 'country' && isset($_country_lang)) { |
|
117 | + $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
|
118 | + $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
119 | + foreach($_country_lang as $key => $value) { |
|
120 | + $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
121 | + } |
|
122 | + } else { |
|
123 | + if($data['elements']) { |
|
124 | + $elements = explode('||', $data['elements']); |
|
125 | + foreach($elements as $key => $value) { |
|
126 | + $value = explode('==', $value); |
|
127 | + $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | + $output .= '</select>'; |
|
132 | + $output .= $data['content']; |
|
133 | + $output .= '</div>'; |
|
134 | + |
|
135 | + break; |
|
136 | + |
|
137 | + case 'checkbox': |
|
138 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
139 | + $output .= '<div class="col-sm-7">'; |
|
140 | + $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
141 | + if($data['elements']) { |
|
142 | + $elements = explode('||', $data['elements']); |
|
143 | + foreach($elements as $key => $value) { |
|
144 | + $value = explode('==', $value); |
|
145 | + $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
146 | + } |
|
147 | + } |
|
148 | + $output .= $data['content']; |
|
149 | + $output .= '</div>'; |
|
150 | + |
|
151 | + break; |
|
152 | + |
|
153 | + case 'radio': |
|
154 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
155 | + $output .= '<div class="col-sm-7">'; |
|
156 | + $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
157 | + if($data['elements']) { |
|
158 | + $elements = explode('||', $data['elements']); |
|
159 | + foreach($elements as $key => $value) { |
|
160 | + $value = explode('==', $value); |
|
161 | + $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
162 | + } |
|
163 | + } |
|
164 | + $output .= $data['content']; |
|
165 | + $output .= '</div>'; |
|
166 | + |
|
167 | + break; |
|
168 | + |
|
169 | + case 'custom': |
|
170 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
171 | + $output .= '<div class="col-sm-7">'; |
|
172 | + $output .= $data['content']; |
|
173 | + $output .= '</div>'; |
|
174 | + |
|
175 | + break; |
|
176 | + } |
|
177 | + |
|
178 | + $output .= '</div>'; |
|
179 | + |
|
180 | + $output = $modx->parseText($output, $data); |
|
181 | + |
|
182 | + return $output; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | } |
186 | 186 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | // show debug information |
5 | 5 | if(isset($enable_debug) && $enable_debug==true) { |
6 | - ?> |
|
6 | + ?> |
|
7 | 7 | <script language="javascript"> |
8 | 8 | //document.onload = removeDebug(); |
9 | 9 | |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | } |
34 | 34 | </style> |
35 | 35 | <?php |
36 | - $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $tend = $mtime; $totaltime = ($tend - $tstart); |
|
37 | - ?> |
|
36 | + $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $tend = $mtime; $totaltime = ($tend - $tstart); |
|
37 | + ?> |
|
38 | 38 | <div class='debug' id='debug' name='debug' onClick="removeDebugDiv();"> |
39 | 39 | <table border="0" cellspacing="0" cellpadding="0"> |
40 | 40 | <tr> |
@@ -4,59 +4,59 @@ |
||
4 | 4 | $ContextMenuCnt = 0; |
5 | 5 | |
6 | 6 | class ContextMenu { |
7 | - var $id; |
|
7 | + var $id; |
|
8 | 8 | |
9 | - function __construct($id = '', $width = 120, $visible = false) { |
|
10 | - global $ContextMenuCnt; |
|
11 | - $ContextMenuCnt++; |
|
12 | - $this->html = ""; |
|
13 | - $this->visible = $visible ? $visible : false; |
|
14 | - $this->width = is_numeric($width) ? intval($width) : 120; |
|
15 | - $this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt; // set id |
|
16 | - } |
|
9 | + function __construct($id = '', $width = 120, $visible = false) { |
|
10 | + global $ContextMenuCnt; |
|
11 | + $ContextMenuCnt++; |
|
12 | + $this->html = ""; |
|
13 | + $this->visible = $visible ? $visible : false; |
|
14 | + $this->width = is_numeric($width) ? intval($width) : 120; |
|
15 | + $this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt; // set id |
|
16 | + } |
|
17 | 17 | |
18 | - function addItem($text, $action = "", $img = "", $disabled = 0) { |
|
19 | - global $base_url, $_style; |
|
18 | + function addItem($text, $action = "", $img = "", $disabled = 0) { |
|
19 | + global $base_url, $_style; |
|
20 | 20 | if($disabled) { |
21 | 21 | return; |
22 | 22 | } |
23 | - if(!$img) { |
|
24 | - $img = $base_url . $_style['tx']; |
|
25 | - } |
|
26 | - if(substr($action, 0, 3) == "js:") { |
|
27 | - $action = substr($action, 3); |
|
28 | - } else if(substr($action, 0, 3) == "hl:") { |
|
29 | - $action = "window.location.href='" . substr($action, 3) . "'"; |
|
30 | - } else { |
|
31 | - $action = "window.location.href='" . $action . "'"; |
|
32 | - } |
|
33 | - $action = " onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('" . $this->id . "');\""; |
|
34 | - $this->html .= "<div class='" . ($disabled ? "cntxMnuItemDisabled" : "cntxMnuItem") . "' $action>"; |
|
23 | + if(!$img) { |
|
24 | + $img = $base_url . $_style['tx']; |
|
25 | + } |
|
26 | + if(substr($action, 0, 3) == "js:") { |
|
27 | + $action = substr($action, 3); |
|
28 | + } else if(substr($action, 0, 3) == "hl:") { |
|
29 | + $action = "window.location.href='" . substr($action, 3) . "'"; |
|
30 | + } else { |
|
31 | + $action = "window.location.href='" . $action . "'"; |
|
32 | + } |
|
33 | + $action = " onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('" . $this->id . "');\""; |
|
34 | + $this->html .= "<div class='" . ($disabled ? "cntxMnuItemDisabled" : "cntxMnuItem") . "' $action>"; |
|
35 | 35 | if(substr($img, 0, 5) == 'fa fa') { |
36 | 36 | $img = '<i class="' . $img . '"></i>'; |
37 | 37 | } else if(substr($img, 0, 1) != '<') { |
38 | 38 | $img = '<img src="' . $img . '" />'; |
39 | 39 | } |
40 | - $this->html .= $img . ' ' . $text . '</div>'; |
|
41 | - } |
|
40 | + $this->html .= $img . ' ' . $text . '</div>'; |
|
41 | + } |
|
42 | 42 | |
43 | - function addSeparator() { |
|
44 | - $this->html .= " |
|
43 | + function addSeparator() { |
|
44 | + $this->html .= " |
|
45 | 45 | <div class='cntxMnuSeparator'></div> |
46 | 46 | "; |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | - function render() { |
|
50 | - global $ContextMenuScript; |
|
49 | + function render() { |
|
50 | + global $ContextMenuScript; |
|
51 | 51 | |
52 | - $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>"; |
|
53 | - $ContextMenuScript = ""; // reset css |
|
54 | - return $html; |
|
55 | - } |
|
52 | + $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>"; |
|
53 | + $ContextMenuScript = ""; // reset css |
|
54 | + return $html; |
|
55 | + } |
|
56 | 56 | |
57 | - function getClientScriptObject() { |
|
58 | - return "getCntxMenu('" . $this->id . "')"; |
|
59 | - } |
|
57 | + function getClientScriptObject() { |
|
58 | + return "getCntxMenu('" . $this->id . "')"; |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $ContextMenuScript = <<<BLOCK |
@@ -12,280 +12,280 @@ |
||
12 | 12 | |
13 | 13 | class DataGrid { |
14 | 14 | |
15 | - var $ds; // datasource |
|
16 | - var $id; |
|
17 | - var $pageSize; // pager settings |
|
18 | - var $pageNumber; |
|
19 | - var $pager; |
|
20 | - var $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
21 | - |
|
22 | - var $cssStyle; |
|
23 | - var $cssClass; |
|
24 | - |
|
25 | - var $columnHeaderStyle; |
|
26 | - var $columnHeaderClass; |
|
27 | - var $itemStyle; |
|
28 | - var $itemClass; |
|
29 | - var $altItemStyle; |
|
30 | - var $altItemClass; |
|
31 | - |
|
32 | - var $fields; |
|
33 | - var $columns; |
|
34 | - var $colWidths; |
|
35 | - var $colAligns; |
|
36 | - var $colWraps; |
|
37 | - var $colColors; |
|
38 | - var $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
39 | - // data type: integer,float,currency,date |
|
40 | - |
|
41 | - var $header; |
|
42 | - var $footer; |
|
43 | - var $cellPadding; |
|
44 | - var $cellSpacing; |
|
45 | - |
|
46 | - var $rowAlign; // vertical alignment: top, middle, bottom |
|
47 | - var $rowIdField; |
|
48 | - |
|
49 | - var $pagerStyle; |
|
50 | - var $pagerClass; |
|
51 | - var $pageClass; |
|
52 | - var $selPageClass; |
|
53 | - var $noRecordMsg = "No records found."; |
|
54 | - |
|
55 | - function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
56 | - global $__DataGridCnt; |
|
57 | - |
|
58 | - // set id |
|
59 | - $__DataGridCnt++; |
|
60 | - $this->id = $this->id ? $id : "dg" . $__DataGridCnt; |
|
61 | - |
|
62 | - // set datasource |
|
63 | - $this->ds = $ds; |
|
64 | - |
|
65 | - // set pager |
|
66 | - $this->pageSize = $pageSize; |
|
67 | - $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
68 | - $this->pagerLocation = 'top-right'; |
|
69 | - } |
|
70 | - |
|
71 | - function setDataSource($ds) { |
|
72 | - $this->ds = $ds; |
|
73 | - } |
|
74 | - |
|
75 | - function render() { |
|
76 | - global $modx; |
|
77 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
78 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
79 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
80 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
81 | - |
|
82 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
83 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
84 | - |
|
85 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
86 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
87 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
88 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
89 | - |
|
90 | - $this->_alt = 0; |
|
91 | - $this->_total = 0; |
|
92 | - |
|
93 | - $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
|
94 | - |
|
95 | - if(!$cssStyle && !$cssClass) { |
|
96 | - $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
97 | - } |
|
98 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
99 | - $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
100 | - } |
|
101 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
102 | - $this->_itemStyle = "style='color:black;'"; |
|
103 | - } |
|
104 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
105 | - $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
106 | - } |
|
107 | - |
|
108 | - if($this->_isDataset && !$this->columns) { |
|
109 | - $cols = $modx->db->numFields($this->ds); |
|
110 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
111 | - } |
|
112 | - |
|
113 | - // start grid |
|
114 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
115 | - $tblEnd = "</table>"; |
|
116 | - |
|
117 | - // build column header |
|
118 | - $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
119 | - $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
120 | - $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
121 | - $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
122 | - $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
123 | - $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
124 | - $this->_colcount = count($this->_colnames); |
|
125 | - if(!$this->_isDataset) { |
|
126 | - $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
127 | - $this->ds = array_chunk($this->ds, $this->_colcount); |
|
128 | - } |
|
129 | - $tblColHdr = "<thead><tr>"; |
|
130 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
131 | - $name = $this->_colnames[$c]; |
|
132 | - $width = $this->_colwidths[$c]; |
|
133 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
134 | - } |
|
135 | - $tblColHdr .= "</tr></thead>\n"; |
|
136 | - |
|
137 | - // build rows |
|
138 | - $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
139 | - $this->_fieldnames = explode(",", $this->fields); |
|
140 | - if($rowcount == 0) { |
|
141 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
142 | - } else { |
|
143 | - // render grid items |
|
144 | - if($this->pageSize <= 0) { |
|
145 | - for($r = 0; $r < $rowcount; $r++) { |
|
146 | - $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
|
147 | - $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
148 | - } |
|
149 | - } else { |
|
150 | - if(!$this->pager) { |
|
151 | - include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
152 | - $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
153 | - $this->pager->setRenderRowFnc($this); // pass this object |
|
154 | - $this->pager->cssStyle = $pagerStyle; |
|
155 | - $this->pager->cssClass = $pagerClass; |
|
156 | - } else { |
|
157 | - $this->pager->pageSize = $this->pageSize; |
|
158 | - $this->pager->pageNumber = $this->pageNumber; |
|
159 | - } |
|
160 | - |
|
161 | - $this->pager->render(); |
|
162 | - $tblRows = $this->pager->getRenderedRows(); |
|
163 | - $tblPager = $this->pager->getRenderedPager(); |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - // setup header,pager and footer |
|
168 | - $o = $tblStart; |
|
169 | - $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
170 | - $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
171 | - if($this->header) { |
|
172 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
173 | - } |
|
174 | - if($tblPager && $ptop) { |
|
175 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
176 | - } |
|
177 | - $o .= $tblColHdr . $tblRows; |
|
178 | - if($tblPager && $pbot) { |
|
179 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
180 | - } |
|
181 | - if($this->footer) { |
|
182 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
183 | - } |
|
184 | - $o .= $tblEnd; |
|
185 | - return $o; |
|
186 | - } |
|
187 | - |
|
188 | - // format column values |
|
189 | - |
|
190 | - function RenderRowFnc($n, $row) { |
|
191 | - if($this->_alt == 0) { |
|
192 | - $Style = $this->_itemStyle; |
|
193 | - $Class = $this->_itemClass; |
|
194 | - $this->_alt = 1; |
|
195 | - } else { |
|
196 | - $Style = $this->_altItemStyle; |
|
197 | - $Class = $this->_altItemClass; |
|
198 | - $this->_alt = 0; |
|
199 | - } |
|
200 | - $o = "<tr>"; |
|
201 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
202 | - $colStyle = $Style; |
|
203 | - $fld = trim($this->_fieldnames[$c]); |
|
204 | - $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
|
205 | - $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null; |
|
206 | - $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null; |
|
207 | - $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
|
208 | - $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
|
209 | - $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
|
210 | - if($color && $Style) { |
|
211 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
212 | - } |
|
213 | - $value = $this->formatColumnValue($row, $value, $type, $align); |
|
214 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
215 | - } |
|
216 | - $o .= "</tr>\n"; |
|
217 | - return $o; |
|
218 | - } |
|
219 | - |
|
220 | - function formatColumnValue($row, $value, $type, &$align) { |
|
221 | - if(strpos($type, ":") !== false) { |
|
222 | - list($type, $type_format) = explode(":", $type, 2); |
|
223 | - } |
|
224 | - switch(strtolower($type)) { |
|
225 | - case "integer": |
|
226 | - if($align == "") { |
|
227 | - $align = "right"; |
|
228 | - } |
|
229 | - $value = number_format($value); |
|
230 | - break; |
|
231 | - |
|
232 | - case "float": |
|
233 | - if($align == "") { |
|
234 | - $align = "right"; |
|
235 | - } |
|
236 | - if(!$type_format) { |
|
237 | - $type_format = 2; |
|
238 | - } |
|
239 | - $value = number_format($value, $type_format); |
|
240 | - break; |
|
241 | - |
|
242 | - case "currency": |
|
243 | - if($align == "") { |
|
244 | - $align = "right"; |
|
245 | - } |
|
246 | - if(!$type_format) { |
|
247 | - $type_format = 2; |
|
248 | - } |
|
249 | - $value = "$" . number_format($value, $type_format); |
|
250 | - break; |
|
251 | - |
|
252 | - case "date": |
|
253 | - if($align == "") { |
|
254 | - $align = "right"; |
|
255 | - } |
|
256 | - if(!is_numeric($value)) { |
|
257 | - $value = strtotime($value); |
|
258 | - } |
|
259 | - if(!$type_format) { |
|
260 | - $type_format = "%A %d, %B %Y"; |
|
261 | - } |
|
262 | - $value = strftime($type_format, $value); |
|
263 | - break; |
|
264 | - |
|
265 | - case "boolean": |
|
266 | - if($align == '') { |
|
267 | - $align = "center"; |
|
268 | - } |
|
269 | - $value = number_format($value); |
|
270 | - if($value) { |
|
271 | - $value = '•'; |
|
272 | - } else { |
|
273 | - $value = ' '; |
|
274 | - } |
|
275 | - break; |
|
276 | - |
|
277 | - case "template": |
|
278 | - // replace [+value+] first |
|
279 | - $value = str_replace("[+value+]", $value, $type_format); |
|
280 | - // replace other [+fields+] |
|
281 | - if(strpos($value, "[+") !== false) { |
|
282 | - foreach($row as $k => $v) { |
|
283 | - $value = str_replace("[+$k+]", $v, $value); |
|
284 | - } |
|
285 | - } |
|
286 | - break; |
|
287 | - |
|
288 | - } |
|
289 | - return $value; |
|
290 | - } |
|
15 | + var $ds; // datasource |
|
16 | + var $id; |
|
17 | + var $pageSize; // pager settings |
|
18 | + var $pageNumber; |
|
19 | + var $pager; |
|
20 | + var $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
21 | + |
|
22 | + var $cssStyle; |
|
23 | + var $cssClass; |
|
24 | + |
|
25 | + var $columnHeaderStyle; |
|
26 | + var $columnHeaderClass; |
|
27 | + var $itemStyle; |
|
28 | + var $itemClass; |
|
29 | + var $altItemStyle; |
|
30 | + var $altItemClass; |
|
31 | + |
|
32 | + var $fields; |
|
33 | + var $columns; |
|
34 | + var $colWidths; |
|
35 | + var $colAligns; |
|
36 | + var $colWraps; |
|
37 | + var $colColors; |
|
38 | + var $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
39 | + // data type: integer,float,currency,date |
|
40 | + |
|
41 | + var $header; |
|
42 | + var $footer; |
|
43 | + var $cellPadding; |
|
44 | + var $cellSpacing; |
|
45 | + |
|
46 | + var $rowAlign; // vertical alignment: top, middle, bottom |
|
47 | + var $rowIdField; |
|
48 | + |
|
49 | + var $pagerStyle; |
|
50 | + var $pagerClass; |
|
51 | + var $pageClass; |
|
52 | + var $selPageClass; |
|
53 | + var $noRecordMsg = "No records found."; |
|
54 | + |
|
55 | + function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
56 | + global $__DataGridCnt; |
|
57 | + |
|
58 | + // set id |
|
59 | + $__DataGridCnt++; |
|
60 | + $this->id = $this->id ? $id : "dg" . $__DataGridCnt; |
|
61 | + |
|
62 | + // set datasource |
|
63 | + $this->ds = $ds; |
|
64 | + |
|
65 | + // set pager |
|
66 | + $this->pageSize = $pageSize; |
|
67 | + $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
68 | + $this->pagerLocation = 'top-right'; |
|
69 | + } |
|
70 | + |
|
71 | + function setDataSource($ds) { |
|
72 | + $this->ds = $ds; |
|
73 | + } |
|
74 | + |
|
75 | + function render() { |
|
76 | + global $modx; |
|
77 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
78 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
79 | + $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
80 | + $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
81 | + |
|
82 | + $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
83 | + $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
84 | + |
|
85 | + $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
86 | + $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
87 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
88 | + $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
89 | + |
|
90 | + $this->_alt = 0; |
|
91 | + $this->_total = 0; |
|
92 | + |
|
93 | + $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
|
94 | + |
|
95 | + if(!$cssStyle && !$cssClass) { |
|
96 | + $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
97 | + } |
|
98 | + if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
99 | + $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
100 | + } |
|
101 | + if(!$this->_itemStyle && !$this->_itemClass) { |
|
102 | + $this->_itemStyle = "style='color:black;'"; |
|
103 | + } |
|
104 | + if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
105 | + $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
106 | + } |
|
107 | + |
|
108 | + if($this->_isDataset && !$this->columns) { |
|
109 | + $cols = $modx->db->numFields($this->ds); |
|
110 | + for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
111 | + } |
|
112 | + |
|
113 | + // start grid |
|
114 | + $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
115 | + $tblEnd = "</table>"; |
|
116 | + |
|
117 | + // build column header |
|
118 | + $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
119 | + $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
120 | + $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
121 | + $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
122 | + $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
123 | + $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
124 | + $this->_colcount = count($this->_colnames); |
|
125 | + if(!$this->_isDataset) { |
|
126 | + $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
127 | + $this->ds = array_chunk($this->ds, $this->_colcount); |
|
128 | + } |
|
129 | + $tblColHdr = "<thead><tr>"; |
|
130 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
131 | + $name = $this->_colnames[$c]; |
|
132 | + $width = $this->_colwidths[$c]; |
|
133 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
134 | + } |
|
135 | + $tblColHdr .= "</tr></thead>\n"; |
|
136 | + |
|
137 | + // build rows |
|
138 | + $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
139 | + $this->_fieldnames = explode(",", $this->fields); |
|
140 | + if($rowcount == 0) { |
|
141 | + $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
142 | + } else { |
|
143 | + // render grid items |
|
144 | + if($this->pageSize <= 0) { |
|
145 | + for($r = 0; $r < $rowcount; $r++) { |
|
146 | + $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
|
147 | + $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
148 | + } |
|
149 | + } else { |
|
150 | + if(!$this->pager) { |
|
151 | + include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
152 | + $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
153 | + $this->pager->setRenderRowFnc($this); // pass this object |
|
154 | + $this->pager->cssStyle = $pagerStyle; |
|
155 | + $this->pager->cssClass = $pagerClass; |
|
156 | + } else { |
|
157 | + $this->pager->pageSize = $this->pageSize; |
|
158 | + $this->pager->pageNumber = $this->pageNumber; |
|
159 | + } |
|
160 | + |
|
161 | + $this->pager->render(); |
|
162 | + $tblRows = $this->pager->getRenderedRows(); |
|
163 | + $tblPager = $this->pager->getRenderedPager(); |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + // setup header,pager and footer |
|
168 | + $o = $tblStart; |
|
169 | + $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
170 | + $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
171 | + if($this->header) { |
|
172 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
173 | + } |
|
174 | + if($tblPager && $ptop) { |
|
175 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
176 | + } |
|
177 | + $o .= $tblColHdr . $tblRows; |
|
178 | + if($tblPager && $pbot) { |
|
179 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
180 | + } |
|
181 | + if($this->footer) { |
|
182 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
183 | + } |
|
184 | + $o .= $tblEnd; |
|
185 | + return $o; |
|
186 | + } |
|
187 | + |
|
188 | + // format column values |
|
189 | + |
|
190 | + function RenderRowFnc($n, $row) { |
|
191 | + if($this->_alt == 0) { |
|
192 | + $Style = $this->_itemStyle; |
|
193 | + $Class = $this->_itemClass; |
|
194 | + $this->_alt = 1; |
|
195 | + } else { |
|
196 | + $Style = $this->_altItemStyle; |
|
197 | + $Class = $this->_altItemClass; |
|
198 | + $this->_alt = 0; |
|
199 | + } |
|
200 | + $o = "<tr>"; |
|
201 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
202 | + $colStyle = $Style; |
|
203 | + $fld = trim($this->_fieldnames[$c]); |
|
204 | + $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
|
205 | + $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null; |
|
206 | + $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null; |
|
207 | + $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
|
208 | + $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
|
209 | + $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
|
210 | + if($color && $Style) { |
|
211 | + $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
212 | + } |
|
213 | + $value = $this->formatColumnValue($row, $value, $type, $align); |
|
214 | + $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
215 | + } |
|
216 | + $o .= "</tr>\n"; |
|
217 | + return $o; |
|
218 | + } |
|
219 | + |
|
220 | + function formatColumnValue($row, $value, $type, &$align) { |
|
221 | + if(strpos($type, ":") !== false) { |
|
222 | + list($type, $type_format) = explode(":", $type, 2); |
|
223 | + } |
|
224 | + switch(strtolower($type)) { |
|
225 | + case "integer": |
|
226 | + if($align == "") { |
|
227 | + $align = "right"; |
|
228 | + } |
|
229 | + $value = number_format($value); |
|
230 | + break; |
|
231 | + |
|
232 | + case "float": |
|
233 | + if($align == "") { |
|
234 | + $align = "right"; |
|
235 | + } |
|
236 | + if(!$type_format) { |
|
237 | + $type_format = 2; |
|
238 | + } |
|
239 | + $value = number_format($value, $type_format); |
|
240 | + break; |
|
241 | + |
|
242 | + case "currency": |
|
243 | + if($align == "") { |
|
244 | + $align = "right"; |
|
245 | + } |
|
246 | + if(!$type_format) { |
|
247 | + $type_format = 2; |
|
248 | + } |
|
249 | + $value = "$" . number_format($value, $type_format); |
|
250 | + break; |
|
251 | + |
|
252 | + case "date": |
|
253 | + if($align == "") { |
|
254 | + $align = "right"; |
|
255 | + } |
|
256 | + if(!is_numeric($value)) { |
|
257 | + $value = strtotime($value); |
|
258 | + } |
|
259 | + if(!$type_format) { |
|
260 | + $type_format = "%A %d, %B %Y"; |
|
261 | + } |
|
262 | + $value = strftime($type_format, $value); |
|
263 | + break; |
|
264 | + |
|
265 | + case "boolean": |
|
266 | + if($align == '') { |
|
267 | + $align = "center"; |
|
268 | + } |
|
269 | + $value = number_format($value); |
|
270 | + if($value) { |
|
271 | + $value = '•'; |
|
272 | + } else { |
|
273 | + $value = ' '; |
|
274 | + } |
|
275 | + break; |
|
276 | + |
|
277 | + case "template": |
|
278 | + // replace [+value+] first |
|
279 | + $value = str_replace("[+value+]", $value, $type_format); |
|
280 | + // replace other [+fields+] |
|
281 | + if(strpos($value, "[+") !== false) { |
|
282 | + foreach($row as $k => $v) { |
|
283 | + $value = str_replace("[+$k+]", $v, $value); |
|
284 | + } |
|
285 | + } |
|
286 | + break; |
|
287 | + |
|
288 | + } |
|
289 | + return $value; |
|
290 | + } |
|
291 | 291 | } |
@@ -12,181 +12,181 @@ |
||
12 | 12 | |
13 | 13 | class DataSetPager { |
14 | 14 | |
15 | - var $ds; // datasource |
|
16 | - var $pageSize; |
|
17 | - var $pageNumber; |
|
18 | - var $rows; |
|
19 | - var $pager; |
|
20 | - var $id; |
|
21 | - |
|
22 | - // normal page |
|
23 | - var $pageStyle; |
|
24 | - var $pageClass; |
|
25 | - |
|
26 | - // selected page |
|
27 | - var $selPageStyle; |
|
28 | - var $selPageClass; |
|
29 | - |
|
30 | - function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
31 | - global $_PAGE; // use view state object |
|
32 | - |
|
33 | - global $__DataSetPagerCnt; |
|
34 | - |
|
35 | - // set id |
|
36 | - $__DataSetPagerCnt++; |
|
37 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
38 | - |
|
39 | - // get pagenumber |
|
40 | - // by setting pager to -1 cause pager to load it's last page number |
|
41 | - if($pageNumber == -1) { |
|
42 | - $pageNumber = 1; |
|
43 | - if(isset($_GET["dpgn" . $this->id])) { |
|
44 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
45 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
46 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
47 | - } |
|
48 | - } |
|
49 | - if(!is_numeric($pageNumber)) { |
|
50 | - $pageNumber = 1; |
|
51 | - } |
|
52 | - |
|
53 | - $this->ds = $ds; // datasource |
|
54 | - $this->pageSize = $pageSize; |
|
55 | - $this->pageNumber = $pageNumber; |
|
56 | - $this->rows = ''; |
|
57 | - $this->pager = ''; |
|
58 | - } |
|
59 | - |
|
60 | - function getRenderedPager() { |
|
61 | - return $this->pager; |
|
62 | - } |
|
63 | - |
|
64 | - function getRenderedRows() { |
|
65 | - return $this->rows; |
|
66 | - } |
|
67 | - |
|
68 | - function setDataSource($ds) { |
|
69 | - $this->ds = $ds; |
|
70 | - } |
|
71 | - |
|
72 | - function setPageSize($ps) { |
|
73 | - $this->pageSize = $ps; |
|
74 | - } |
|
75 | - |
|
76 | - function setRenderRowFnc($fncName, $args = "") { |
|
77 | - $this->renderRowFnc = &$fncName; |
|
78 | - $this->renderRowFncArgs = $args; // extra agruments |
|
79 | - |
|
80 | - |
|
81 | - } |
|
82 | - |
|
83 | - function setRenderPagerFnc($fncName, $args = "") { |
|
84 | - $this->renderPagerFnc = $fncName; |
|
85 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
86 | - } |
|
87 | - |
|
88 | - function render() { |
|
89 | - global $modx, $_PAGE; |
|
90 | - |
|
91 | - $isDataset = $modx->db->isResult($this->ds); |
|
92 | - |
|
93 | - if(!$this->selPageStyle) { |
|
94 | - $this->selPageStyle = "font-weight:bold"; |
|
95 | - } |
|
96 | - |
|
97 | - // get total number of rows |
|
98 | - $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
99 | - |
|
100 | - // render: no records found |
|
101 | - if($tnr <= 0) { |
|
102 | - $fnc = $this->renderRowFnc; |
|
103 | - $args = $this->renderRowFncArgs; |
|
104 | - if(isset($fnc)) { |
|
105 | - if($args != "") { |
|
106 | - $this->rows .= $fnc(0, null, $args); |
|
107 | - } // if agrs was specified then we will pass three params |
|
108 | - else { |
|
109 | - $this->rows .= $fnc(0, null); |
|
110 | - } // otherwise two will be passed |
|
111 | - } |
|
112 | - return; |
|
113 | - } |
|
114 | - |
|
115 | - // get total pages |
|
116 | - $tp = ceil($tnr / $this->pageSize); |
|
117 | - if($this->pageNumber > $tp) { |
|
118 | - $this->pageNumber = 1; |
|
119 | - } |
|
120 | - |
|
121 | - // get page number |
|
122 | - $p = $this->pageNumber; |
|
123 | - |
|
124 | - // save page number to view state if available |
|
125 | - if(isset($_PAGE['vs'])) { |
|
126 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
127 | - } |
|
128 | - |
|
129 | - // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
130 | - if($tp > 1) { |
|
131 | - $fnc = $this->renderPagerFnc; |
|
132 | - $args = $this->renderPagerFncArgs; |
|
133 | - if(!isset($fnc)) { |
|
134 | - if($modx->isFrontend()) { |
|
135 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
136 | - } else { |
|
137 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
138 | - } |
|
139 | - $i = 0; |
|
140 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
141 | - $i++; |
|
142 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
143 | - } |
|
144 | - if($i >= 1) { |
|
145 | - $url .= "&"; |
|
146 | - } |
|
147 | - } |
|
148 | - for($i = 1; $i <= $tp; $i++) { |
|
149 | - if(isset($fnc)) { |
|
150 | - if($args != "") { |
|
151 | - $this->pager .= $fnc($p, $i, $args); |
|
152 | - } else { |
|
153 | - $this->pager .= $fnc($p, $i); |
|
154 | - } |
|
155 | - } else { |
|
156 | - $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> "; |
|
157 | - } |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
162 | - $fnc = $this->renderRowFnc; |
|
163 | - $args = $this->renderRowFncArgs; |
|
164 | - |
|
165 | - if(isset($fnc)) { |
|
166 | - $i = 1; |
|
167 | - $fncObject = is_object($fnc); |
|
168 | - $minitems = (($p - 1) * $this->pageSize) + 1; |
|
169 | - $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
170 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
171 | - if($i >= $minitems && $i <= $maxitems) { |
|
172 | - if($fncObject) { |
|
173 | - if($args != "") { |
|
174 | - $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
175 | - } else { |
|
176 | - $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
177 | - } |
|
178 | - } else { |
|
179 | - if($args != "") { |
|
180 | - $this->rows .= $fnc($i, $row, $args); |
|
181 | - } // if agrs was specified then we wil pass three params |
|
182 | - else { |
|
183 | - $this->rows .= $fnc($i, $row); |
|
184 | - } // otherwise two will be passed |
|
185 | - } |
|
186 | - |
|
187 | - } |
|
188 | - $i++; |
|
189 | - } |
|
190 | - } |
|
191 | - } |
|
15 | + var $ds; // datasource |
|
16 | + var $pageSize; |
|
17 | + var $pageNumber; |
|
18 | + var $rows; |
|
19 | + var $pager; |
|
20 | + var $id; |
|
21 | + |
|
22 | + // normal page |
|
23 | + var $pageStyle; |
|
24 | + var $pageClass; |
|
25 | + |
|
26 | + // selected page |
|
27 | + var $selPageStyle; |
|
28 | + var $selPageClass; |
|
29 | + |
|
30 | + function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
31 | + global $_PAGE; // use view state object |
|
32 | + |
|
33 | + global $__DataSetPagerCnt; |
|
34 | + |
|
35 | + // set id |
|
36 | + $__DataSetPagerCnt++; |
|
37 | + $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
38 | + |
|
39 | + // get pagenumber |
|
40 | + // by setting pager to -1 cause pager to load it's last page number |
|
41 | + if($pageNumber == -1) { |
|
42 | + $pageNumber = 1; |
|
43 | + if(isset($_GET["dpgn" . $this->id])) { |
|
44 | + $pageNumber = $_GET["dpgn" . $this->id]; |
|
45 | + } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
46 | + $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
47 | + } |
|
48 | + } |
|
49 | + if(!is_numeric($pageNumber)) { |
|
50 | + $pageNumber = 1; |
|
51 | + } |
|
52 | + |
|
53 | + $this->ds = $ds; // datasource |
|
54 | + $this->pageSize = $pageSize; |
|
55 | + $this->pageNumber = $pageNumber; |
|
56 | + $this->rows = ''; |
|
57 | + $this->pager = ''; |
|
58 | + } |
|
59 | + |
|
60 | + function getRenderedPager() { |
|
61 | + return $this->pager; |
|
62 | + } |
|
63 | + |
|
64 | + function getRenderedRows() { |
|
65 | + return $this->rows; |
|
66 | + } |
|
67 | + |
|
68 | + function setDataSource($ds) { |
|
69 | + $this->ds = $ds; |
|
70 | + } |
|
71 | + |
|
72 | + function setPageSize($ps) { |
|
73 | + $this->pageSize = $ps; |
|
74 | + } |
|
75 | + |
|
76 | + function setRenderRowFnc($fncName, $args = "") { |
|
77 | + $this->renderRowFnc = &$fncName; |
|
78 | + $this->renderRowFncArgs = $args; // extra agruments |
|
79 | + |
|
80 | + |
|
81 | + } |
|
82 | + |
|
83 | + function setRenderPagerFnc($fncName, $args = "") { |
|
84 | + $this->renderPagerFnc = $fncName; |
|
85 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
86 | + } |
|
87 | + |
|
88 | + function render() { |
|
89 | + global $modx, $_PAGE; |
|
90 | + |
|
91 | + $isDataset = $modx->db->isResult($this->ds); |
|
92 | + |
|
93 | + if(!$this->selPageStyle) { |
|
94 | + $this->selPageStyle = "font-weight:bold"; |
|
95 | + } |
|
96 | + |
|
97 | + // get total number of rows |
|
98 | + $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
99 | + |
|
100 | + // render: no records found |
|
101 | + if($tnr <= 0) { |
|
102 | + $fnc = $this->renderRowFnc; |
|
103 | + $args = $this->renderRowFncArgs; |
|
104 | + if(isset($fnc)) { |
|
105 | + if($args != "") { |
|
106 | + $this->rows .= $fnc(0, null, $args); |
|
107 | + } // if agrs was specified then we will pass three params |
|
108 | + else { |
|
109 | + $this->rows .= $fnc(0, null); |
|
110 | + } // otherwise two will be passed |
|
111 | + } |
|
112 | + return; |
|
113 | + } |
|
114 | + |
|
115 | + // get total pages |
|
116 | + $tp = ceil($tnr / $this->pageSize); |
|
117 | + if($this->pageNumber > $tp) { |
|
118 | + $this->pageNumber = 1; |
|
119 | + } |
|
120 | + |
|
121 | + // get page number |
|
122 | + $p = $this->pageNumber; |
|
123 | + |
|
124 | + // save page number to view state if available |
|
125 | + if(isset($_PAGE['vs'])) { |
|
126 | + $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
127 | + } |
|
128 | + |
|
129 | + // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
130 | + if($tp > 1) { |
|
131 | + $fnc = $this->renderPagerFnc; |
|
132 | + $args = $this->renderPagerFncArgs; |
|
133 | + if(!isset($fnc)) { |
|
134 | + if($modx->isFrontend()) { |
|
135 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
136 | + } else { |
|
137 | + $url = $_SERVER['PHP_SELF'] . '?'; |
|
138 | + } |
|
139 | + $i = 0; |
|
140 | + foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
141 | + $i++; |
|
142 | + $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
143 | + } |
|
144 | + if($i >= 1) { |
|
145 | + $url .= "&"; |
|
146 | + } |
|
147 | + } |
|
148 | + for($i = 1; $i <= $tp; $i++) { |
|
149 | + if(isset($fnc)) { |
|
150 | + if($args != "") { |
|
151 | + $this->pager .= $fnc($p, $i, $args); |
|
152 | + } else { |
|
153 | + $this->pager .= $fnc($p, $i); |
|
154 | + } |
|
155 | + } else { |
|
156 | + $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> "; |
|
157 | + } |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
162 | + $fnc = $this->renderRowFnc; |
|
163 | + $args = $this->renderRowFncArgs; |
|
164 | + |
|
165 | + if(isset($fnc)) { |
|
166 | + $i = 1; |
|
167 | + $fncObject = is_object($fnc); |
|
168 | + $minitems = (($p - 1) * $this->pageSize) + 1; |
|
169 | + $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
170 | + while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
171 | + if($i >= $minitems && $i <= $maxitems) { |
|
172 | + if($fncObject) { |
|
173 | + if($args != "") { |
|
174 | + $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
175 | + } else { |
|
176 | + $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
177 | + } |
|
178 | + } else { |
|
179 | + if($args != "") { |
|
180 | + $this->rows .= $fnc($i, $row, $args); |
|
181 | + } // if agrs was specified then we wil pass three params |
|
182 | + else { |
|
183 | + $this->rows .= $fnc($i, $row); |
|
184 | + } // otherwise two will be passed |
|
185 | + } |
|
186 | + |
|
187 | + } |
|
188 | + $i++; |
|
189 | + } |
|
190 | + } |
|
191 | + } |
|
192 | 192 | } |
@@ -5,10 +5,10 @@ |
||
5 | 5 | $settings = array(); |
6 | 6 | if ($modx && count($modx->config)>0) $settings = $modx->config; |
7 | 7 | else{ |
8 | - $rs = $modx->db->select('setting_name, setting_value', $modx->getFullTableName('system_settings')); |
|
9 | - while ($row = $modx->db->getRow($rs)) { |
|
10 | - $settings[$row['setting_name']] = $row['setting_value']; |
|
11 | - } |
|
8 | + $rs = $modx->db->select('setting_name, setting_value', $modx->getFullTableName('system_settings')); |
|
9 | + while ($row = $modx->db->getRow($rs)) { |
|
10 | + $settings[$row['setting_name']] = $row['setting_value']; |
|
11 | + } |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | extract($settings, EXTR_OVERWRITE); |
@@ -12,13 +12,13 @@ |
||
12 | 12 | $modx->invokeEvent('OnManagerPageInit'); |
13 | 13 | $ok = false; |
14 | 14 | if(isset($_SESSION['mgrToken']) && $_GET['tok'] == $_SESSION['mgrToken']) { |
15 | - $ok = true; |
|
16 | - $modx->updateValidatedUserSession(); |
|
15 | + $ok = true; |
|
16 | + $modx->updateValidatedUserSession(); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | header('Content-type: application/json'); |
20 | 20 | if($ok) { |
21 | 21 | echo '{"status":"ok"}'; |
22 | 22 | } else { |
23 | - echo '{"status":"null"}'; |
|
23 | + echo '{"status":"null"}'; |
|
24 | 24 | } |