This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /********************/ |
||
3 | $sd = isset($_REQUEST['dir']) ? '&dir=' . $_REQUEST['dir'] : '&dir=DESC'; |
||
4 | $sb = isset($_REQUEST['sort']) ? '&sort=' . $_REQUEST['sort'] : '&sort=createdon'; |
||
5 | $pg = isset($_REQUEST['page']) ? '&page=' . (int) $_REQUEST['page'] : ''; |
||
6 | $add_path = $sd . $sb . $pg; |
||
7 | /*******************/ |
||
8 | |||
9 | // check permissions |
||
10 | switch($modx->getManagerApi()->action) { |
||
11 | case 27: |
||
12 | if(!$modx->hasPermission('edit_document')) { |
||
13 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
||
14 | } |
||
15 | break; |
||
16 | case 85: |
||
17 | case 72: |
||
18 | case 4: |
||
19 | if(!$modx->hasPermission('new_document')) { |
||
20 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
||
21 | } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
||
22 | // check user has permissions for parent |
||
23 | $udperms = new EvolutionCMS\Legacy\Permissions(); |
||
24 | $udperms->user = $modx->getLoginUserID(); |
||
25 | $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid']; |
||
26 | $udperms->role = $_SESSION['mgrRole']; |
||
27 | if(!$udperms->checkPermissions()) { |
||
28 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
||
29 | } |
||
30 | } |
||
31 | break; |
||
32 | default: |
||
33 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
||
34 | } |
||
35 | |||
36 | $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
||
37 | |||
38 | // Get table names (alphabetical) |
||
39 | $tbl_categories = $modx->getDatabase()->getFullTableName('categories'); |
||
40 | $tbl_document_group_names = $modx->getDatabase()->getFullTableName('documentgroup_names'); |
||
41 | $tbl_member_groups = $modx->getDatabase()->getFullTableName('member_groups'); |
||
42 | $tbl_membergroup_access = $modx->getDatabase()->getFullTableName('membergroup_access'); |
||
43 | $tbl_document_groups = $modx->getDatabase()->getFullTableName('document_groups'); |
||
44 | $tbl_site_content = $modx->getDatabase()->getFullTableName('site_content'); |
||
45 | $tbl_site_templates = $modx->getDatabase()->getFullTableName('site_templates'); |
||
46 | $tbl_site_tmplvar_access = $modx->getDatabase()->getFullTableName('site_tmplvar_access'); |
||
47 | $tbl_site_tmplvar_contentvalues = $modx->getDatabase()->getFullTableName('site_tmplvar_contentvalues'); |
||
48 | $tbl_site_tmplvar_templates = $modx->getDatabase()->getFullTableName('site_tmplvar_templates'); |
||
49 | $tbl_site_tmplvars = $modx->getDatabase()->getFullTableName('site_tmplvars'); |
||
50 | |||
51 | if($modx->getManagerApi()->action == 27) { |
||
52 | //editing an existing document |
||
53 | // check permissions on the document |
||
54 | $udperms = new EvolutionCMS\Legacy\Permissions(); |
||
55 | $udperms->user = $modx->getLoginUserID(); |
||
56 | $udperms->document = $id; |
||
57 | $udperms->role = $_SESSION['mgrRole']; |
||
58 | |||
59 | if(!$udperms->checkPermissions()) { |
||
60 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | // check to see if resource isn't locked |
||
65 | View Code Duplication | if($lockedEl = $modx->elementIsLocked(7, $id)) { |
|
66 | $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource'])); |
||
67 | } |
||
68 | // end check for lock |
||
69 | |||
70 | // Lock resource for other users to edit |
||
71 | $modx->lockElement(7, $id); |
||
72 | |||
73 | // get document groups for current user |
||
74 | if($_SESSION['mgrDocgroups']) { |
||
75 | $docgrp = implode(',', $_SESSION['mgrDocgroups']); |
||
76 | } |
||
77 | |||
78 | if(!empty ($id)) { |
||
79 | $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']); |
||
80 | if($docgrp) { |
||
81 | $access .= " OR dg.document_group IN ({$docgrp})"; |
||
82 | } |
||
83 | $rs = $modx->getDatabase()->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})"); |
||
84 | $content = array(); |
||
85 | $content = $modx->getDatabase()->getRow($rs); |
||
86 | $modx->documentObject = &$content; |
||
87 | if(!$content) { |
||
88 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
||
89 | } |
||
90 | $_SESSION['itemname'] = $content['pagetitle']; |
||
91 | } else { |
||
92 | $content = array(); |
||
93 | |||
94 | View Code Duplication | if(isset($_REQUEST['newtemplate'])) { |
|
95 | $content['template'] = $_REQUEST['newtemplate']; |
||
96 | } else { |
||
97 | $content['template'] = getDefaultTemplate(); |
||
98 | } |
||
99 | |||
100 | $_SESSION['itemname'] = $_lang["new_resource"]; |
||
101 | } |
||
102 | |||
103 | // restore saved form |
||
104 | $formRestored = $modx->getManagerApi()->loadFormValues(); |
||
105 | if(isset($_REQUEST['newtemplate'])) { |
||
106 | $formRestored = true; |
||
107 | } |
||
108 | |||
109 | // retain form values if template was changed |
||
110 | // edited to convert pub_date and unpub_date |
||
111 | // sottwell 02-09-2006 |
||
112 | if($formRestored == true) { |
||
113 | $content = array_merge($content, $_POST); |
||
114 | $content['content'] = $_POST['ta']; |
||
115 | if(empty ($content['pub_date'])) { |
||
116 | unset ($content['pub_date']); |
||
117 | } else { |
||
118 | $content['pub_date'] = $modx->toTimeStamp($content['pub_date']); |
||
119 | } |
||
120 | if(empty ($content['unpub_date'])) { |
||
121 | unset ($content['unpub_date']); |
||
122 | } else { |
||
123 | $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']); |
||
124 | } |
||
125 | } |
||
126 | |||
127 | // increase menu index if this is a new document |
||
128 | if(!isset ($_REQUEST['id'])) { |
||
129 | if(!isset ($modx->config['auto_menuindex'])) { |
||
130 | $modx->config['auto_menuindex'] = 1; |
||
131 | } |
||
132 | if($modx->config['auto_menuindex']) { |
||
133 | $pid = (int)$_REQUEST['pid']; |
||
134 | $rs = $modx->getDatabase()->select('count(*)', $tbl_site_content, "parent='{$pid}'"); |
||
135 | $content['menuindex'] = $modx->getDatabase()->getValue($rs); |
||
136 | } else { |
||
137 | $content['menuindex'] = 0; |
||
138 | } |
||
139 | } |
||
140 | |||
141 | if(isset ($_POST['which_editor'])) { |
||
142 | $modx->config['which_editor'] = $_POST['which_editor']; |
||
143 | } |
||
144 | |||
145 | // Add lock-element JS-Script |
||
146 | $lockElementId = $id; |
||
147 | $lockElementType = 7; |
||
148 | require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); |
||
149 | ?> |
||
150 | <script type="text/javascript"> |
||
151 | /* <![CDATA[ */ |
||
152 | |||
153 | // save tree folder state |
||
154 | if(parent.tree) parent.tree.saveFolderState(); |
||
155 | |||
156 | function changestate(el) { |
||
157 | if(parseInt(el.value) === 1) { |
||
158 | el.value = 0; |
||
159 | } else { |
||
160 | el.value = 1; |
||
161 | } |
||
162 | documentDirty = true; |
||
163 | } |
||
164 | |||
165 | var actions = { |
||
166 | save: function() { |
||
167 | documentDirty = false; |
||
168 | form_save = true; |
||
169 | document.mutate.save.click(); |
||
170 | }, |
||
171 | delete: function() { |
||
172 | if(confirm("<?= $_lang['confirm_delete_resource']?>") === true) { |
||
173 | document.location.href = "index.php?id=" + document.mutate.id.value + "&a=6<?= $add_path ?>"; |
||
174 | } |
||
175 | }, |
||
176 | cancel: function() { |
||
177 | documentDirty = false; |
||
178 | document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id=' . $id . $add_path) ?>'; |
||
179 | }, |
||
180 | duplicate: function() { |
||
181 | if(confirm("<?= $_lang['confirm_resource_duplicate']?>") === true) { |
||
182 | document.location.href = "index.php?id=<?= $_REQUEST['id'] ?>&a=94<?= $add_path ?>"; |
||
183 | } |
||
184 | }, |
||
185 | view: function() { |
||
186 | window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : MODX_SITE_URL . 'index.php?id=' . $id ?>', 'previeWin'); |
||
187 | } |
||
188 | }; |
||
189 | |||
190 | var allowParentSelection = false; |
||
191 | var allowLinkSelection = false; |
||
192 | |||
193 | function enableLinkSelection(b) { |
||
194 | var llock = document.getElementById('llock'); |
||
195 | if(b) { |
||
196 | parent.tree.ca = "link"; |
||
197 | llock.className = "<?= $_style["actions_chain_broken"] ?>"; |
||
198 | allowLinkSelection = true; |
||
199 | } |
||
200 | else { |
||
201 | parent.tree.ca = "open"; |
||
202 | llock.className = "<?= $_style["actions_chain"] ?>"; |
||
203 | allowLinkSelection = false; |
||
204 | } |
||
205 | } |
||
206 | |||
207 | function setLink(lId) { |
||
208 | if(!allowLinkSelection) { |
||
209 | window.location.href = "index.php?a=3&id=" + lId + "<?= $add_path ?>"; |
||
210 | } |
||
211 | else { |
||
212 | documentDirty = true; |
||
213 | document.mutate.ta.value = lId; |
||
214 | } |
||
215 | } |
||
216 | |||
217 | function enableParentSelection(b) { |
||
218 | var plock = document.getElementById('plock'); |
||
219 | if(b) { |
||
220 | parent.tree.ca = "parent"; |
||
221 | plock.className = "<?= $_style["actions_folder_open"] ?>"; |
||
222 | allowParentSelection = true; |
||
223 | } |
||
224 | else { |
||
225 | parent.tree.ca = "open"; |
||
226 | plock.className = "<?= $_style["actions_folder"] ?>"; |
||
227 | allowParentSelection = false; |
||
228 | } |
||
229 | } |
||
230 | |||
231 | function setParent(pId, pName) { |
||
232 | if(!allowParentSelection) { |
||
233 | window.location.href = "index.php?a=3&id=" + pId + "<?= $add_path ?>"; |
||
234 | } |
||
235 | else { |
||
236 | if(pId === 0 || checkParentChildRelation(pId, pName)) { |
||
237 | documentDirty = true; |
||
238 | document.mutate.parent.value = pId; |
||
239 | var elm = document.getElementById('parentName'); |
||
240 | if(elm) { |
||
241 | elm.innerHTML = (pId + " (" + pName + ")"); |
||
242 | } |
||
243 | } |
||
244 | } |
||
245 | } |
||
246 | |||
247 | // check if the selected parent is a child of this document |
||
248 | function checkParentChildRelation(pId, pName) { |
||
249 | var sp; |
||
250 | var id = document.mutate.id.value; |
||
251 | var tdoc = parent.tree.document; |
||
252 | var pn = (tdoc.getElementById) ? tdoc.getElementById("node" + pId) : tdoc.all["node" + pId]; |
||
253 | if(!pn) return; |
||
254 | if(pn.id.substr(4) === id) { |
||
255 | alert("<?= $_lang['illegal_parent_self']?>"); |
||
256 | return; |
||
257 | } |
||
258 | else { |
||
259 | while(pn.getAttribute("p") > 0) { |
||
260 | pId = pn.getAttribute("p"); |
||
261 | pn = (tdoc.getElementById) ? tdoc.getElementById("node" + pId) : tdoc.all["node" + pId]; |
||
262 | if(pn.id.substr(4) === id) { |
||
263 | alert("<?= $_lang['illegal_parent_child']?>"); |
||
264 | return; |
||
265 | } |
||
266 | } |
||
267 | } |
||
268 | return true; |
||
269 | } |
||
270 | |||
271 | var curTemplate = -1; |
||
272 | var curTemplateIndex = 0; |
||
273 | |||
274 | function storeCurTemplate() { |
||
275 | var dropTemplate = document.getElementById('template'); |
||
276 | if(dropTemplate) { |
||
277 | for(var i = 0; i < dropTemplate.length; i++) { |
||
278 | if(dropTemplate[i].selected) { |
||
279 | curTemplate = dropTemplate[i].value; |
||
280 | curTemplateIndex = i; |
||
281 | } |
||
282 | } |
||
283 | } |
||
284 | } |
||
285 | |||
286 | var newTemplate; |
||
287 | |||
288 | function templateWarning() { |
||
289 | var dropTemplate = document.getElementById('template'); |
||
290 | if(dropTemplate) { |
||
291 | for(var i = 0; i < dropTemplate.length; i++) { |
||
292 | if(dropTemplate[i].selected) { |
||
293 | newTemplate = dropTemplate[i].value; |
||
294 | break; |
||
295 | } |
||
296 | } |
||
297 | } |
||
298 | if(curTemplate === newTemplate) { |
||
299 | return; |
||
300 | } |
||
301 | |||
302 | if(documentDirty === true) { |
||
303 | if(confirm('<?= $_lang['tmplvar_change_template_msg']?>')) { |
||
304 | documentDirty = false; |
||
305 | document.mutate.a.value = <?= $modx->getManagerApi()->action ?>; |
||
306 | document.mutate.newtemplate.value = newTemplate; |
||
307 | document.mutate.submit(); |
||
308 | } else { |
||
309 | dropTemplate[curTemplateIndex].selected = true; |
||
310 | } |
||
311 | } |
||
312 | else { |
||
313 | document.mutate.a.value = <?= $modx->getManagerApi()->action ?>; |
||
314 | document.mutate.newtemplate.value = newTemplate; |
||
315 | document.mutate.submit(); |
||
316 | } |
||
317 | } |
||
318 | |||
319 | // Added for RTE selection |
||
320 | function changeRTE() { |
||
321 | var whichEditor = document.getElementById('which_editor'), |
||
322 | newEditor, |
||
323 | i; |
||
324 | if(whichEditor) { |
||
325 | for(i = 0; i < whichEditor.length; i++) { |
||
326 | if(whichEditor[i].selected) { |
||
327 | newEditor = whichEditor[i].value; |
||
328 | break; |
||
329 | } |
||
330 | } |
||
331 | } |
||
332 | var dropTemplate = document.getElementById('template'); |
||
333 | if(dropTemplate) { |
||
334 | for(i = 0; i < dropTemplate.length; i++) { |
||
335 | if(dropTemplate[i].selected) { |
||
336 | newTemplate = dropTemplate[i].value; |
||
337 | break; |
||
338 | } |
||
339 | } |
||
340 | } |
||
341 | |||
342 | documentDirty = false; |
||
343 | document.mutate.a.value = <?= $modx->getManagerApi()->action ?>; |
||
344 | document.mutate.newtemplate.value = newTemplate; |
||
345 | document.mutate.which_editor.value = newEditor; |
||
346 | document.mutate.submit(); |
||
347 | } |
||
348 | |||
349 | /** |
||
350 | * Snippet properties |
||
351 | */ |
||
352 | |||
353 | var snippetParams = {}; // Snippet Params |
||
354 | var currentParams = {}; // Current Params |
||
355 | var lastsp, lastmod = {}; |
||
356 | |||
357 | function showParameters(ctrl) { |
||
358 | var c, p, df, cp, ar, desc, value, key, dt, f; |
||
359 | |||
360 | cp = {}; |
||
361 | currentParams = {}; // reset; |
||
362 | |||
363 | if(ctrl && ctrl.form) { |
||
364 | f = ctrl.form; |
||
365 | } else { |
||
366 | f = document.forms['mutate']; |
||
367 | ctrl = f.snippetlist; |
||
368 | } |
||
369 | |||
370 | // get display format |
||
371 | df = "";//lastsp = ctrl.options[ctrl.selectedIndex].value; |
||
372 | |||
373 | // load last modified param values |
||
374 | if(lastmod[df]) cp = lastmod[df].split("&"); |
||
375 | for(p = 0; p < cp.length; p++) { |
||
376 | cp[p] = (cp[p] + '').replace(/^\s|\s$/, ""); // trim |
||
377 | ar = cp[p].split("="); |
||
378 | currentParams[ar[0]] = ar[1]; |
||
379 | } |
||
380 | |||
381 | // setup parameters |
||
382 | var t, dp = (snippetParams[df]) ? snippetParams[df].split("&") : [""]; |
||
383 | if(dp) { |
||
384 | t = '<table width="100%" class="displayparams"><thead><tr><td width="50%"><?= $_lang['parameter']?><\/td><td width="50%"><?= $_lang['value']?><\/td><\/tr><\/thead>'; |
||
385 | for(p = 0; p < dp.length; p++) { |
||
386 | dp[p] = (dp[p] + '').replace(/^\s|\s$/, ""); // trim |
||
387 | ar = dp[p].split("="); |
||
388 | key = ar[0]; // param |
||
389 | ar = (ar[1] + '').split(";"); |
||
390 | desc = ar[0]; // description |
||
391 | dt = ar[1]; // data type |
||
392 | value = decode((currentParams[key]) ? currentParams[key] : (dt == 'list') ? ar[3] : (ar[2]) ? ar[2] : ''); |
||
393 | if(value !== currentParams[key]) currentParams[key] = value; |
||
394 | value = (value + '').replace(/^\s|\s$/, ""); // trim |
||
395 | if(dt) { |
||
396 | switch(dt) { |
||
397 | case 'int': |
||
398 | c = '<input type="text" name="prop_' + key + '" value="' + value + '" size="30" onchange="setParameter(\'' + key + '\',\'' + dt + '\',this)" \/>'; |
||
399 | break; |
||
400 | case 'list': |
||
401 | c = '<select name="prop_' + key + '" height="1" style="width:168px" onchange="setParameter(\'' + key + '\',\'' + dt + '\',this)">'; |
||
402 | var ls = (ar[2] + '').split(","); |
||
403 | if(currentParams[key] === ar[2]) currentParams[key] = ls[0]; // use first list item as default |
||
404 | for(var i = 0; i < ls.length; i++) { |
||
405 | c += '<option value="' + ls[i] + '"' + ((ls[i] === value) ? ' selected="selected"' : '') + '>' + ls[i] + '<\/option>'; |
||
406 | } |
||
407 | c += '<\/select>'; |
||
408 | break; |
||
409 | default: // string |
||
410 | c = '<input type="text" name="prop_' + key + '" value="' + value + '" size="30" onchange="setParameter(\'' + key + '\',\'' + dt + '\',this)" \/>'; |
||
411 | break; |
||
412 | |||
413 | } |
||
414 | t += '<tr><td bgcolor="#FFFFFF" width="50%">' + desc + '<\/td><td bgcolor="#FFFFFF" width="50%">' + c + '<\/td><\/tr>'; |
||
415 | } |
||
416 | } |
||
417 | t += '<\/table>'; |
||
418 | var td = (document.getElementById) ? document.getElementById('snippetparams') : document.all['snippetparams']; |
||
419 | td.innerHTML = t; |
||
420 | } |
||
421 | implodeParameters(); |
||
422 | } |
||
423 | |||
424 | function setParameter(key, dt, ctrl) { |
||
425 | var v; |
||
426 | if(!ctrl) return null; |
||
427 | switch(dt) { |
||
428 | case 'int': |
||
429 | ctrl.value = parseInt(ctrl.value); |
||
430 | if(isNaN(ctrl.value)) ctrl.value = 0; |
||
431 | v = ctrl.value; |
||
432 | break; |
||
433 | case 'list': |
||
434 | v = ctrl.options[ctrl.selectedIndex].value; |
||
435 | break; |
||
436 | default: |
||
437 | v = ctrl.value + ''; |
||
438 | break; |
||
439 | } |
||
440 | currentParams[key] = v; |
||
441 | implodeParameters(); |
||
442 | } |
||
443 | |||
444 | function resetParameters() { |
||
445 | document.mutate.params.value = ""; |
||
446 | lastmod[lastsp] = ""; |
||
447 | showParameters(); |
||
448 | } |
||
449 | |||
450 | // implode parameters |
||
451 | function implodeParameters() { |
||
452 | var v, p, s = ''; |
||
453 | for(p in currentParams) { |
||
454 | v = currentParams[p]; |
||
455 | if(v) s += '&' + p + '=' + encode(v); |
||
456 | } |
||
457 | //document.forms['mutate'].params.value = s; |
||
458 | if(lastsp) lastmod[lastsp] = s; |
||
459 | } |
||
460 | |||
461 | function encode(s) { |
||
462 | s = s + ''; |
||
463 | s = s.replace(/\=/g, '%3D'); // = |
||
464 | s = s.replace(/\&/g, '%26'); // & |
||
465 | return s; |
||
466 | } |
||
467 | |||
468 | function decode(s) { |
||
469 | s = s + ''; |
||
470 | s = s.replace(/\%3D/g, '='); // = |
||
471 | s = s.replace(/\%26/g, '&'); // & |
||
472 | return s; |
||
473 | } |
||
474 | |||
475 | <?php if ($content['type'] == 'reference' || $modx->getManagerApi()->action == '72') { // Web Link specific ?> |
||
476 | var lastImageCtrl; |
||
477 | var lastFileCtrl; |
||
478 | |||
479 | function OpenServerBrowser(url, width, height) { |
||
480 | var iLeft = (screen.width - width) / 2; |
||
481 | var iTop = (screen.height - height) / 2; |
||
482 | |||
483 | var sOptions = 'toolbar=no,status=no,resizable=yes,dependent=yes'; |
||
484 | sOptions += ',width=' + width; |
||
485 | sOptions += ',height=' + height; |
||
486 | sOptions += ',left=' + iLeft; |
||
487 | sOptions += ',top=' + iTop; |
||
488 | |||
489 | var oWindow = window.open(url, 'FCKBrowseWindow', sOptions); |
||
490 | } |
||
491 | |||
492 | function BrowseServer(ctrl) { |
||
493 | lastImageCtrl = ctrl; |
||
494 | var w = screen.width * 0.5; |
||
495 | var h = screen.height * 0.5; |
||
496 | OpenServerBrowser('<?= MODX_MANAGER_URL ?>media/browser/<?= $which_browser ?>/browser.php?Type=images', w, h); |
||
497 | } |
||
498 | |||
499 | function BrowseFileServer(ctrl) { |
||
500 | lastFileCtrl = ctrl; |
||
501 | var w = screen.width * 0.5; |
||
502 | var h = screen.height * 0.5; |
||
503 | OpenServerBrowser('<?= MODX_MANAGER_URL ?>media/browser/<?= $which_browser ?>/browser.php?Type=files', w, h); |
||
504 | } |
||
505 | |||
506 | function SetUrlChange(el) { |
||
507 | if('createEvent' in document) { |
||
508 | var evt = document.createEvent('HTMLEvents'); |
||
509 | evt.initEvent('change', false, true); |
||
510 | el.dispatchEvent(evt); |
||
511 | } else { |
||
512 | el.fireEvent('onchange'); |
||
513 | } |
||
514 | } |
||
515 | |||
516 | function SetUrl(url, width, height, alt) { |
||
517 | if(lastFileCtrl) { |
||
518 | var c = document.getElementById(lastFileCtrl); |
||
519 | if(c && c.value !== url) { |
||
520 | c.value = url; |
||
521 | SetUrlChange(c); |
||
522 | } |
||
523 | lastFileCtrl = ''; |
||
524 | } else if(lastImageCtrl) { |
||
525 | var c = document.getElementById(lastImageCtrl); |
||
526 | if(c && c.value !== url) { |
||
527 | c.value = url; |
||
528 | SetUrlChange(c); |
||
529 | } |
||
530 | lastImageCtrl = ''; |
||
531 | } else { |
||
532 | |||
533 | } |
||
534 | } |
||
535 | |||
536 | <?php $ResourceManagerLoaded = true; } ?> |
||
537 | /* ]]> */ |
||
538 | </script> |
||
539 | |||
540 | <form name="mutate" id="mutate" class="content" method="post" enctype="multipart/form-data" action="index.php" onsubmit="documentDirty=false;"> |
||
541 | <?php |
||
542 | // invoke OnDocFormPrerender event |
||
543 | $evtOut = $modx->invokeEvent('OnDocFormPrerender', array( |
||
544 | 'id' => $id, |
||
545 | 'template' => $content['template'] |
||
546 | )); |
||
547 | |||
548 | if(is_array($evtOut)) { |
||
549 | echo implode('', $evtOut); |
||
550 | } |
||
551 | |||
552 | /*************************/ |
||
553 | $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : ''; |
||
554 | $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon'; |
||
555 | $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : ''; |
||
556 | /*************************/ |
||
557 | |||
558 | ?> |
||
559 | <input type="hidden" name="a" value="5" /> |
||
560 | <input type="hidden" name="id" value="<?= $content['id'] ?>" /> |
||
561 | <input type="hidden" name="mode" value="<?= $modx->getManagerApi()->action ?>" /> |
||
562 | <input type="hidden" name="MAX_FILE_SIZE" value="<?= (isset($modx->config['upload_maxsize']) ? $modx->config['upload_maxsize'] : 1048576) ?>" /> |
||
563 | <input type="hidden" name="refresh_preview" value="0" /> |
||
564 | <input type="hidden" name="newtemplate" value="" /> |
||
565 | <input type="hidden" name="dir" value="<?= entities($dir, $modx->getConfig('modx_charset')) ?>" /> |
||
566 | <input type="hidden" name="sort" value="<?= entities($sort, $modx->getConfig('modx_charset')) ?>" /> |
||
567 | <input type="hidden" name="page" value="<?= $page ?>" /> |
||
568 | |||
569 | <fieldset id="create_edit"> |
||
570 | |||
571 | <h1> |
||
572 | <i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) { |
||
573 | echo entities(iconv_substr($content['pagetitle'], 0, 50, $modx->getConfig('modx_charset')), $modx->getConfig('modx_charset')) . (iconv_strlen($content['pagetitle'], $modx->getConfig('modx_charset')) > 50 ? '...' : '') . '<small>(' . (int)$_REQUEST['id'] . ')</small>'; |
||
574 | } else { |
||
575 | if ($modx->getManagerApi()->action == '4') { |
||
576 | echo $_lang['add_resource']; |
||
577 | } else if ($modx->getManagerApi()->action == '72') { |
||
578 | echo $_lang['add_weblink']; |
||
579 | } else { |
||
580 | echo $_lang['create_resource_title']; |
||
581 | } |
||
582 | } ?> |
||
583 | </h1> |
||
584 | |||
585 | <?= ManagerTheme::getStyle('actionbuttons.dynamic.document') ?> |
||
586 | |||
587 | <?php |
||
588 | // breadcrumbs |
||
589 | if($modx->config['use_breadcrumbs']) { |
||
590 | $temp = array(); |
||
591 | $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title']; |
||
592 | |||
593 | if(isset($_REQUEST['id']) && $content['parent'] != 0) { |
||
594 | $bID = (int) $_REQUEST['id']; |
||
595 | $temp = $modx->getParentIds($bID); |
||
596 | } else if(isset($_REQUEST['pid'])) { |
||
597 | $bID = (int) $_REQUEST['pid']; |
||
598 | $temp = $modx->getParentIds($bID); |
||
599 | array_unshift($temp, $bID); |
||
600 | } |
||
601 | |||
602 | if($temp) { |
||
603 | $parents = implode(',', $temp); |
||
604 | |||
605 | if(!empty($parents)) { |
||
606 | $where = "FIND_IN_SET(id,'{$parents}') DESC"; |
||
607 | $rs = $modx->getDatabase()->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where); |
||
608 | while($row = $modx->getDatabase()->getRow($rs)) { |
||
609 | $out .= '<li class="breadcrumbs__li"> |
||
610 | <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->getConfig('modx_charset')) . '</a> |
||
611 | <span class="breadcrumbs__sep">></span> |
||
612 | </li>'; |
||
613 | } |
||
614 | } |
||
615 | } |
||
616 | |||
617 | $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>'; |
||
618 | echo '<ul class="breadcrumbs">' . $out . '</ul>'; |
||
619 | } |
||
620 | ?> |
||
621 | |||
622 | <!-- start main wrapper --> |
||
623 | <div class="sectionBody"> |
||
624 | |||
625 | <div class="tab-pane" id="documentPane"> |
||
626 | <script type="text/javascript"> |
||
627 | var tpSettings = new WebFXTabPane(document.getElementById("documentPane"), <?= ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') ?> ); |
||
628 | </script> |
||
629 | |||
630 | <!-- General --> |
||
631 | <?php |
||
632 | $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array( |
||
633 | 'id' => $id |
||
634 | )); |
||
635 | if(is_array($evtOut)) { |
||
636 | echo implode('', $evtOut); |
||
637 | } else { |
||
638 | ?> |
||
639 | <div class="tab-page" id="tabGeneral"> |
||
640 | <h2 class="tab"><?=ManagerTheme::getLexicon('settings_general');?></h2> |
||
641 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById("tabGeneral"));</script> |
||
642 | |||
643 | <table> |
||
644 | <tr> |
||
645 | <td> |
||
646 | <span class="warning"><?=ManagerTheme::getLexicon('resource_title');?></span> |
||
647 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_title_help');?>"></i> |
||
648 | </td> |
||
649 | <td> |
||
650 | <input name="pagetitle" type="text" maxlength="255" value="<?= $modx->getPhpCompat()->htmlspecialchars(stripslashes($content['pagetitle'])) ?>" class="inputBox" onchange="documentDirty=true;" spellcheck="true" /> |
||
651 | <script>document.getElementsByName("pagetitle")[0].focus();</script> |
||
652 | </td> |
||
653 | </tr> |
||
654 | <tr> |
||
655 | <td> |
||
656 | <span class="warning"><?=ManagerTheme::getLexicon('long_title');?></span> |
||
657 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_long_title_help');?>"></i> |
||
658 | </td> |
||
659 | <td> |
||
660 | <input name="longtitle" type="text" maxlength="255" value="<?= $modx->getPhpCompat()->htmlspecialchars(stripslashes($content['longtitle'])) ?>" class="inputBox" onchange="documentDirty=true;" spellcheck="true" /> |
||
661 | </td> |
||
662 | </tr> |
||
663 | <tr> |
||
664 | <td> |
||
665 | <span class="warning"><?=ManagerTheme::getLexicon('resource_description');?></span> |
||
666 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_description_help');?>"></i> |
||
667 | </td> |
||
668 | <td> |
||
669 | <input name="description" type="text" maxlength="255" value="<?= $modx->getPhpCompat()->htmlspecialchars(stripslashes($content['description'])) ?>" class="inputBox" onchange="documentDirty=true;" spellcheck="true" /> |
||
670 | </td> |
||
671 | </tr> |
||
672 | <tr> |
||
673 | <td> |
||
674 | <span class="warning"><?=ManagerTheme::getLexicon('resource_alias');?></span> |
||
675 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_alias_help');?>"></i> |
||
676 | </td> |
||
677 | <td> |
||
678 | <input name="alias" type="text" maxlength="100" value="<?= stripslashes($content['alias']) ?>" class="inputBox" onchange="documentDirty=true;" /> |
||
679 | </td> |
||
680 | </tr> |
||
681 | <tr> |
||
682 | <td> |
||
683 | <span class="warning"><?=ManagerTheme::getLexicon('link_attributes');?></span> |
||
684 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('link_attributes_help');?>"></i> |
||
685 | </td> |
||
686 | <td> |
||
687 | <input name="link_attributes" type="text" maxlength="255" value="<?= $modx->getPhpCompat()->htmlspecialchars(stripslashes($content['link_attributes'])) ?>" class="inputBox" onchange="documentDirty=true;" /> |
||
688 | </td> |
||
689 | </tr> |
||
690 | |||
691 | <?php if($content['type'] == 'reference' || $modx->getManagerApi()->action == '72') { // Web Link specific ?> |
||
692 | |||
693 | <tr> |
||
694 | <td><span class="warning"><?=ManagerTheme::getLexicon('weblink');?></span> |
||
695 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_weblink_help');?>"></i> |
||
696 | </td> |
||
697 | <td> |
||
698 | <i id="llock" class="<?= $_style["actions_chain"] ?>" onclick="enableLinkSelection(!allowLinkSelection);"></i> |
||
699 | <input name="ta" id="ta" type="text" maxlength="255" value="<?= (!empty($content['content']) ? entities(stripslashes($content['content']), $modx->getConfig('modx_charset')) : 'http://') ?>" class="inputBox" onchange="documentDirty=true;" /><input type="button" value="<?=ManagerTheme::getLexicon('insert');?>" onclick="BrowseFileServer('ta')" /> |
||
700 | </td> |
||
701 | </tr> |
||
702 | |||
703 | <?php } ?> |
||
704 | |||
705 | <tr> |
||
706 | <td valign="top"> |
||
707 | <span class="warning"><?=ManagerTheme::getLexicon('resource_summary');?></span> |
||
708 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_summary_help');?>" spellcheck="true"></i> |
||
709 | </td> |
||
710 | <td valign="top"> |
||
711 | <textarea id="introtext" name="introtext" class="inputBox" rows="3" cols="" onchange="documentDirty=true;"><?= $modx->getPhpCompat()->htmlspecialchars(stripslashes($content['introtext'])) ?></textarea> |
||
712 | </td> |
||
713 | </tr> |
||
714 | <tr> |
||
715 | <td> |
||
716 | <span class="warning"><?=ManagerTheme::getLexicon('page_data_template');?></span> |
||
717 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('page_data_template_help');?>"></i> |
||
718 | </td> |
||
719 | <td> |
||
720 | <select id="template" name="template" class="inputBox" onchange="templateWarning();"> |
||
721 | <option value="0">(blank)</option> |
||
722 | <?php |
||
723 | $field = "t.templatename, t.selectable, t.id, c.category"; |
||
724 | $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id"; |
||
725 | $rs = $modx->getDatabase()->select($field, $from, '', 'c.category, t.templatename ASC'); |
||
726 | $currentCategory = ''; |
||
727 | while($row = $modx->getDatabase()->getRow($rs)) { |
||
728 | if($row['selectable'] != 1 && $row['id'] != $content['template']) { |
||
729 | continue; |
||
730 | }; |
||
731 | // Skip if not selectable but show if selected! |
||
732 | $thisCategory = $row['category']; |
||
733 | if($thisCategory == null) { |
||
734 | $thisCategory = $_lang["no_category"]; |
||
735 | } |
||
736 | if($thisCategory != $currentCategory) { |
||
737 | if($closeOptGroup) { |
||
738 | echo "\t\t\t\t\t</optgroup>\n"; |
||
739 | } |
||
740 | echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n"; |
||
741 | $closeOptGroup = true; |
||
742 | } |
||
743 | |||
744 | $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : ''; |
||
745 | |||
746 | echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n"; |
||
747 | $currentCategory = $thisCategory; |
||
748 | } |
||
749 | if($thisCategory != '') { |
||
750 | echo "\t\t\t\t\t</optgroup>\n"; |
||
751 | } |
||
752 | ?> |
||
753 | </select> |
||
754 | </td> |
||
755 | </tr> |
||
756 | <tr> |
||
757 | <td> |
||
758 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_menu_title');?></span> |
||
759 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_menu_title_help');?>"></i> |
||
760 | </td> |
||
761 | <td> |
||
762 | <input name="menutitle" type="text" maxlength="255" value="<?= $modx->getPhpCompat()->htmlspecialchars(stripslashes($content['menutitle'])) ?>" class="inputBox" onchange="documentDirty=true;" /> |
||
763 | </td> |
||
764 | </tr> |
||
765 | <tr> |
||
766 | <td> |
||
767 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_menu_index');?></span> |
||
768 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_menu_index_help');?>"></i> |
||
769 | </td> |
||
770 | <td> |
||
771 | <input name="menuindex" type="text" maxlength="6" value="<?= $content['menuindex'] ?>" class="inputBox" onchange="documentDirty=true;" /> |
||
772 | <a href="javascript:;" class="btn btn-secondary" onclick="var elm = document.mutate.menuindex;var v=parseInt(elm.value+'')-1;elm.value=v>0? v:0;elm.focus();documentDirty=true;return false;"><i class="<?= $_style['actions_angle_left'] ?>"></i></a> |
||
773 | <a href="javascript:;" class="btn btn-secondary" onclick="var elm = document.mutate.menuindex;var v=parseInt(elm.value+'')+1;elm.value=v>0? v:0;elm.focus();documentDirty=true;return false;"><i class="<?= $_style['actions_angle_right'] ?>"></i></a> |
||
774 | </td> |
||
775 | </tr> |
||
776 | <tr> |
||
777 | <td> |
||
778 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_show_menu');?></span> |
||
779 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_show_menu_help');?>"></i> |
||
780 | </td> |
||
781 | <td> |
||
782 | <input name="hidemenucheck" type="checkbox" class="checkbox" <?= ($content['hidemenu'] != 1 ? 'checked="checked"' : '') ?> onclick="changestate(document.mutate.hidemenu);" /><input type="hidden" name="hidemenu" class="hidden" value="<?= ($content['hidemenu'] == 1 ? 1 : 0) ?>" /> |
||
783 | </td> |
||
784 | </tr> |
||
785 | <tr> |
||
786 | <td valign="top"> |
||
787 | <span class="warning"><?=ManagerTheme::getLexicon('resource_parent');?></span> |
||
788 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_parent_help');?>"></i> |
||
789 | </td> |
||
790 | <td valign="top"> |
||
791 | <?php |
||
792 | $parentlookup = false; |
||
793 | if(isset ($_REQUEST['id'])) { |
||
794 | View Code Duplication | if($content['parent'] == 0) { |
|
795 | $parentname = $modx->getConfig('site_name'); |
||
796 | } else { |
||
797 | $parentlookup = $content['parent']; |
||
798 | } |
||
799 | } elseif(isset ($_REQUEST['pid'])) { |
||
800 | if($_REQUEST['pid'] == 0) { |
||
801 | $parentname = $modx->getConfig('site_name'); |
||
802 | } else { |
||
803 | $parentlookup = $_REQUEST['pid']; |
||
804 | } |
||
805 | } elseif(isset($_POST['parent'])) { |
||
806 | View Code Duplication | if($_POST['parent'] == 0) { |
|
807 | $parentname = $modx->getConfig('site_name'); |
||
808 | } else { |
||
809 | $parentlookup = $_POST['parent']; |
||
810 | } |
||
811 | } else { |
||
812 | $parentname = $modx->getConfig('site_name'); |
||
813 | $content['parent'] = 0; |
||
814 | } |
||
815 | if($parentlookup !== false && is_numeric($parentlookup)) { |
||
816 | $rs = $modx->getDatabase()->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'"); |
||
817 | $parentname = $modx->getDatabase()->getValue($rs); |
||
818 | if(!$parentname) { |
||
819 | $modx->webAlertAndQuit($_lang["error_no_parent"]); |
||
820 | } |
||
821 | } |
||
822 | ?> |
||
823 | <i id="plock" class="<?= $_style["actions_folder"] ?>" onclick="enableParentSelection(!allowParentSelection);"></i> |
||
824 | <b><span id="parentName"><?= (isset($_REQUEST['pid']) ? entities($_REQUEST['pid']) : $content['parent']) ?> (<?= entities($parentname) ?>)</span></b> |
||
825 | <input type="hidden" name="parent" value="<?= (isset($_REQUEST['pid']) ? entities($_REQUEST['pid']) : $content['parent']) ?>" onchange="documentDirty=true;" /> |
||
826 | </td> |
||
827 | </tr> |
||
828 | <tr></tr> |
||
829 | <?php |
||
830 | /* |
||
0 ignored issues
–
show
|
|||
831 | if($content['type'] == 'reference' || $modx->getManagerApi()->action == '72') { |
||
832 | ?> |
||
833 | <tr> |
||
834 | <td colspan="2"> |
||
835 | <div class="split"></div> |
||
836 | </td> |
||
837 | </tr> |
||
838 | <tr> |
||
839 | <td> |
||
840 | <span class="warning"><?=ManagerTheme::getLexicon('which_editor_title');?></span></td> |
||
841 | <td> |
||
842 | <select id="which_editor" name="which_editor" onchange="changeRTE();"> |
||
843 | <?php |
||
844 | // invoke OnRichTextEditorRegister event |
||
845 | $evtOut = $modx->invokeEvent("OnRichTextEditorRegister"); |
||
846 | if(is_array($evtOut)) { |
||
847 | for($i = 0; $i < count($evtOut); $i++) { |
||
848 | $editor = $evtOut[$i]; |
||
849 | echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n"; |
||
850 | } |
||
851 | } |
||
852 | ?> |
||
853 | </select> |
||
854 | </td> |
||
855 | </tr> |
||
856 | <?php |
||
857 | }*/ |
||
858 | ?> |
||
859 | |||
860 | <?php if($content['type'] == 'document' || $modx->getManagerApi()->action == '4') { ?> |
||
861 | <tr> |
||
862 | <td colspan="2"> |
||
863 | <hr> |
||
864 | <!-- Content --> |
||
865 | <div class="clearfix"> |
||
866 | <span id="content_header"><?=ManagerTheme::getLexicon('resource_content');?></span> |
||
867 | <label class="float-xs-right"><?=ManagerTheme::getLexicon('which_editor_title');?> |
||
868 | <select id="which_editor" class="form-control form-control-sm" size="1" name="which_editor" onchange="changeRTE();"> |
||
869 | <option value="none"><?=ManagerTheme::getLexicon('none');?></option> |
||
870 | <?php |
||
871 | // invoke OnRichTextEditorRegister event |
||
872 | $evtOut = $modx->invokeEvent("OnRichTextEditorRegister"); |
||
873 | if(is_array($evtOut)) { |
||
874 | for($i = 0; $i < count($evtOut); $i++) { |
||
875 | $editor = $evtOut[$i]; |
||
876 | echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n"; |
||
877 | } |
||
878 | } |
||
879 | ?> |
||
880 | </select> |
||
881 | </label> |
||
882 | </div> |
||
883 | <div id="content_body"> |
||
884 | <?php |
||
885 | if(($content['richtext'] == 1 || $modx->getManagerApi()->action == '4') && $use_editor == 1) { |
||
886 | $htmlContent = $content['content']; |
||
887 | ?> |
||
888 | <div class="section-editor clearfix"> |
||
889 | <textarea id="ta" name="ta" onchange="documentDirty=true;"><?= $modx->getPhpCompat()->htmlspecialchars($htmlContent) ?></textarea> |
||
890 | </div> |
||
891 | <?php |
||
892 | // Richtext-[*content*] |
||
893 | $richtexteditorIds = array(); |
||
894 | $richtexteditorOptions = array(); |
||
895 | $richtexteditorIds[$modx->config['which_editor']][] = 'ta'; |
||
896 | $richtexteditorOptions[$modx->config['which_editor']]['ta'] = ''; |
||
897 | } else { |
||
898 | echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->getPhpCompat()->htmlspecialchars($content['content']), '</textarea></div>' . "\n"; |
||
899 | } |
||
900 | ?> |
||
901 | </div> |
||
902 | </td> |
||
903 | </tr> |
||
904 | <!-- end .sectionBody --> |
||
905 | <?php } ?> |
||
906 | </table> |
||
907 | |||
908 | <?php |
||
909 | |||
910 | $templateVariables = ''; |
||
911 | $templateVariablesOutput = ''; |
||
912 | |||
913 | if (($content['type'] == 'document' || $modx->getManagerApi()->action == '4') || ($content['type'] == 'reference' || $modx->getManagerApi()->action == 72)) { |
||
914 | $template = $default_template; |
||
915 | $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int)$modx->config['group_tvs']; |
||
916 | View Code Duplication | if (isset ($_REQUEST['newtemplate'])) { |
|
917 | $template = $_REQUEST['newtemplate']; |
||
918 | } else { |
||
919 | if (isset ($content['template'])) { |
||
920 | $template = $content['template']; |
||
921 | } |
||
922 | } |
||
923 | |||
924 | $field = "DISTINCT tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value, tvtpl.rank as tvrank"; |
||
925 | $vs = array( |
||
926 | $tbl_site_tmplvars, |
||
927 | $tbl_site_tmplvar_templates, |
||
928 | $tbl_site_tmplvar_contentvalues, |
||
929 | $id, |
||
930 | $tbl_site_tmplvar_access |
||
931 | ); |
||
932 | $from = vsprintf("%s AS tv INNER JOIN %s AS tvtpl ON tvtpl.tmplvarid = tv.id |
||
933 | LEFT JOIN %s AS tvc ON tvc.tmplvarid=tv.id AND tvc.contentid='%s' |
||
934 | LEFT JOIN %s AS tva ON tva.tmplvarid=tv.id", $vs); |
||
935 | $dgs = $docgrp ? " OR tva.documentgroup IN ({$docgrp})" : ''; |
||
936 | $vs = array( |
||
937 | $template, |
||
938 | $_SESSION['mgrRole'], |
||
939 | $dgs |
||
940 | ); |
||
941 | $sort = 'tvtpl.rank,tv.rank, tv.id'; |
||
942 | if ($group_tvs) { |
||
943 | $field .= ', IFNULL(cat.id,0) AS category_id, IFNULL(cat.category,"' . $_lang['no_category'] . '") AS category, IFNULL(cat.rank,0) AS category_rank'; |
||
944 | $from .= ' |
||
945 | LEFT JOIN ' . $tbl_categories . ' AS cat ON cat.id=tv.category'; |
||
946 | $sort = 'category_rank,category_id,' . $sort; |
||
947 | } |
||
948 | $where = vsprintf("tvtpl.templateid='%s' AND (1='%s' OR ISNULL(tva.documentgroup) %s)", $vs); |
||
949 | $rs = $modx->getDatabase()->select($field, $from, $where, $sort); |
||
950 | if ($modx->getDatabase()->getRecordCount($rs)) { |
||
951 | $tvsArray = $modx->getDatabase()->makeArray($rs, 'name'); |
||
952 | $templateVariablesOutput = ''; |
||
953 | $templateVariablesGeneral = ''; |
||
954 | |||
955 | $i = $ii = 0; |
||
956 | $tab = ''; |
||
957 | foreach ($tvsArray as $row) { |
||
958 | if ($group_tvs && $row['category_id'] != 0) { |
||
959 | $ii = 0; |
||
960 | if ($tab !== $row['category_id']) { |
||
961 | if ($group_tvs == 1 || $group_tvs == 3) { |
||
962 | if ($i === 0) { |
||
963 | $templateVariablesOutput .= ' |
||
964 | <div class="tab-section" id="tabTV_' . $row['category_id'] . '"> |
||
965 | <div class="tab-header">' . $row['category'] . '</div> |
||
966 | <div class="tab-body tmplvars"> |
||
967 | <table>' . "\n"; |
||
968 | } else { |
||
969 | $templateVariablesOutput .= ' |
||
970 | </table> |
||
971 | </div> |
||
972 | </div> |
||
973 | |||
974 | <div class="tab-section" id="tabTV_' . $row['category_id'] . '"> |
||
975 | <div class="tab-header">' . $row['category'] . '</div> |
||
976 | <div class="tab-body tmplvars"> |
||
977 | <table>'; |
||
978 | } |
||
979 | } else if ($group_tvs == 2 || $group_tvs == 4) { |
||
980 | View Code Duplication | if ($i === 0) { |
|
981 | $templateVariablesOutput .= ' |
||
982 | <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
||
983 | <h2 class="tab">' . $row['category'] . '</h2> |
||
984 | <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
||
985 | |||
986 | <div class="tab-body tmplvars"> |
||
987 | <table>'; |
||
988 | } else { |
||
989 | $templateVariablesOutput .= ' |
||
990 | </table> |
||
991 | </div> |
||
992 | </div> |
||
993 | |||
994 | <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
||
995 | <h2 class="tab">' . $row['category'] . '</h2> |
||
996 | <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
||
997 | |||
998 | <div class="tab-body tmplvars"> |
||
999 | <table>'; |
||
1000 | } |
||
1001 | View Code Duplication | } else if ($group_tvs == 5) { |
|
1002 | if ($i === 0) { |
||
1003 | $templateVariablesOutput .= ' |
||
1004 | <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
||
1005 | <h2 class="tab">' . $row['category'] . '</h2> |
||
1006 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
||
1007 | <table>'; |
||
1008 | } else { |
||
1009 | $templateVariablesOutput .= ' |
||
1010 | </table> |
||
1011 | </div> |
||
1012 | |||
1013 | <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
||
1014 | <h2 class="tab">' . $row['category'] . '</h2> |
||
1015 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
||
1016 | |||
1017 | <table>'; |
||
1018 | } |
||
1019 | } |
||
1020 | $split = 0; |
||
1021 | } else { |
||
1022 | $split = 1; |
||
1023 | } |
||
1024 | } |
||
1025 | |||
1026 | // Go through and display all Template Variables |
||
1027 | if ($row['type'] == 'richtext' || $row['type'] == 'htmlarea') { |
||
1028 | // determine TV-options |
||
1029 | $tvOptions = $modx->parseProperties($row['elements']); |
||
1030 | if (!empty($tvOptions)) { |
||
1031 | // Allow different Editor with TV-option {"editor":"CKEditor4"} or &editor=Editor;text;CKEditor4 |
||
1032 | $editor = isset($tvOptions['editor']) ? $tvOptions['editor'] : $modx->config['which_editor']; |
||
1033 | }; |
||
1034 | // Add richtext editor to the list |
||
1035 | $richtexteditorIds[$editor][] = "tv" . $row['id']; |
||
1036 | $richtexteditorOptions[$editor]["tv" . $row['id']] = $tvOptions; |
||
1037 | } |
||
1038 | |||
1039 | $templateVariablesTmp = ''; |
||
1040 | |||
1041 | // splitter |
||
1042 | if ($group_tvs) { |
||
1043 | if (($split && $i) || $ii) { |
||
1044 | $templateVariablesTmp .= ' |
||
1045 | <tr><td colspan="2"><div class="split"></div></td></tr>' . "\n"; |
||
1046 | } |
||
1047 | } else if ($i) { |
||
1048 | $templateVariablesTmp .= ' |
||
1049 | <tr><td colspan="2"><div class="split"></div></td></tr>' . "\n"; |
||
1050 | } |
||
1051 | |||
1052 | // post back value |
||
1053 | if (array_key_exists('tv' . $row['id'], $_POST)) { |
||
1054 | if (is_array($_POST['tv' . $row['id']])) { |
||
1055 | $tvPBV = implode('||', $_POST['tv' . $row['id']]); |
||
1056 | } else { |
||
1057 | $tvPBV = $_POST['tv' . $row['id']]; |
||
1058 | } |
||
1059 | } else { |
||
1060 | $tvPBV = $row['value']; |
||
1061 | } |
||
1062 | |||
1063 | $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">' . $row['description'] . '</span>' : ''; |
||
1064 | $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">(' . $_lang['tmplvars_inherited'] . ')</span>' : ''; |
||
1065 | $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*' . $row['name'] . '*]</small>' : ''; |
||
1066 | |||
1067 | $templateVariablesTmp .= ' |
||
1068 | <tr> |
||
1069 | <td><span class="warning">' . $row['caption'] . $tvName . '</span>' . $tvDescription . $tvInherited . '</td> |
||
1070 | <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '') . '">' . renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray) . '</div></td> |
||
1071 | </tr>'; |
||
1072 | |||
1073 | if ($group_tvs && $row['category_id'] == 0) { |
||
1074 | $templateVariablesGeneral .= $templateVariablesTmp; |
||
1075 | $ii++; |
||
1076 | } else { |
||
1077 | $templateVariablesOutput .= $templateVariablesTmp; |
||
1078 | $tab = $row['category_id']; |
||
1079 | $i++; |
||
1080 | } |
||
1081 | } |
||
1082 | |||
1083 | if ($templateVariablesGeneral) { |
||
1084 | echo '<table id="tabTV_0" class="tmplvars"><tbody>' . $templateVariablesGeneral . '</tbody></table>'; |
||
1085 | } |
||
1086 | |||
1087 | $templateVariables .= ' |
||
1088 | <!-- Template Variables -->' . "\n"; |
||
1089 | if (!$group_tvs) { |
||
1090 | $templateVariables .= ' |
||
1091 | <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'] . '</div> |
||
1092 | <div class="sectionBody tmplvars"> |
||
1093 | <table>'; |
||
1094 | } else if ($group_tvs == 2) { |
||
1095 | $templateVariables .= ' |
||
1096 | <div class="tab-section"> |
||
1097 | <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'] . '</div> |
||
1098 | <div class="tab-pane" id="paneTemplateVariables"> |
||
1099 | <script type="text/javascript"> |
||
1100 | tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
||
1101 | </script>'; |
||
1102 | } else if ($group_tvs == 3) { |
||
1103 | $templateVariables .= ' |
||
1104 | <div id="templateVariables" class="tab-page tmplvars"> |
||
1105 | <h2 class="tab">' . $_lang['settings_templvars'] . '</h2> |
||
1106 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script>'; |
||
1107 | } else if ($group_tvs == 4) { |
||
1108 | $templateVariables .= ' |
||
1109 | <div id="templateVariables" class="tab-page tmplvars"> |
||
1110 | <h2 class="tab">' . $_lang['settings_templvars'] . '</h2> |
||
1111 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script> |
||
1112 | <div class="tab-pane" id="paneTemplateVariables"> |
||
1113 | <script type="text/javascript"> |
||
1114 | tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
||
1115 | </script>'; |
||
1116 | } |
||
1117 | if ($templateVariablesOutput) { |
||
1118 | $templateVariables .= $templateVariablesOutput; |
||
1119 | $templateVariables .= ' |
||
1120 | </table> |
||
1121 | </div>' . "\n"; |
||
1122 | if ($group_tvs == 1) { |
||
1123 | $templateVariables .= ' |
||
1124 | </div>' . "\n"; |
||
1125 | } else if ($group_tvs == 2 || $group_tvs == 4) { |
||
1126 | $templateVariables .= ' |
||
1127 | </div> |
||
1128 | </div> |
||
1129 | </div>' . "\n"; |
||
1130 | } else if ($group_tvs == 3) { |
||
1131 | $templateVariables .= ' |
||
1132 | </div> |
||
1133 | </div>' . "\n"; |
||
1134 | } |
||
1135 | } |
||
1136 | $templateVariables .= ' |
||
1137 | <!-- end Template Variables -->' . "\n"; |
||
1138 | } |
||
1139 | } |
||
1140 | |||
1141 | // Template Variables |
||
1142 | if ($group_tvs < 3 && $templateVariablesOutput) { |
||
1143 | echo $templateVariables; |
||
1144 | } |
||
1145 | ?> |
||
1146 | |||
1147 | </div> |
||
1148 | <!-- end #tabGeneral --> |
||
1149 | |||
1150 | <!-- Settings --> |
||
1151 | <div class="tab-page" id="tabSettings"> |
||
1152 | <h2 class="tab"><?=ManagerTheme::getLexicon('settings_page_settings');?></h2> |
||
1153 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById("tabSettings"));</script> |
||
1154 | |||
1155 | <table> |
||
1156 | <?php $mx_can_pub = $modx->hasPermission('publish_document') ? '' : 'disabled="disabled" ' ?> |
||
1157 | <tr> |
||
1158 | <td> |
||
1159 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_published');?></span> |
||
1160 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_published_help');?>"></i> |
||
1161 | </td> |
||
1162 | <td> |
||
1163 | <input <?= $mx_can_pub ?>name="publishedcheck" type="checkbox" class="checkbox" <?= (isset($content['published']) && $content['published'] == 1) || (!isset($content['published']) && $publish_default == 1) ? "checked" : '' ?> onclick="changestate(document.mutate.published);" /> |
||
1164 | <input type="hidden" name="published" value="<?= (isset($content['published']) && $content['published'] == 1) || (!isset($content['published']) && $publish_default == 1) ? 1 : 0 ?>" /> |
||
1165 | </td> |
||
1166 | </tr> |
||
1167 | <tr> |
||
1168 | <td> |
||
1169 | <span class="warning"><?=ManagerTheme::getLexicon('page_data_publishdate');?></span> |
||
1170 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('page_data_publishdate_help');?>"></i> |
||
1171 | </td> |
||
1172 | <td> |
||
1173 | <input type="text" id="pub_date" <?= $mx_can_pub ?>name="pub_date" class="DatePicker" value="<?= ($content['pub_date'] == "0" || !isset($content['pub_date']) ? '' : $modx->toDateFormat($content['pub_date'])) ?>" onblur="documentDirty=true;" /> |
||
1174 | <a href="javascript:" onclick="document.mutate.pub_date.value=''; return true;" onmouseover="window.status='<?=ManagerTheme::getLexicon('remove_date');?>'; return true;" onmouseout="window.status=''; return true;"> |
||
1175 | <i class="<?= $_style["actions_calendar_delete"] ?>" title="<?=ManagerTheme::getLexicon('remove_date');?>"></i></a> |
||
1176 | </td> |
||
1177 | </tr> |
||
1178 | <tr> |
||
1179 | <td></td> |
||
1180 | <td> |
||
1181 | <em> <?= $modx->config['datetime_format'] ?> HH:MM:SS</em></td> |
||
1182 | </tr> |
||
1183 | <tr> |
||
1184 | <td> |
||
1185 | <span class="warning"><?=ManagerTheme::getLexicon('page_data_unpublishdate');?></span> |
||
1186 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('page_data_unpublishdate_help');?>"></i> |
||
1187 | </td> |
||
1188 | <td> |
||
1189 | <input type="text" id="unpub_date" <?= $mx_can_pub ?>name="unpub_date" class="DatePicker" value="<?= ($content['unpub_date'] == "0" || !isset($content['unpub_date']) ? '' : $modx->toDateFormat($content['unpub_date'])) ?>" onblur="documentDirty=true;" /> |
||
1190 | <a href="javascript:" onclick="document.mutate.unpub_date.value=''; return true;" onmouseover="window.status='<?=ManagerTheme::getLexicon('remove_date');?>'; return true;" onmouseout="window.status=''; return true;"> |
||
1191 | <i class="<?= $_style["actions_calendar_delete"] ?>" title="<?=ManagerTheme::getLexicon('remove_date');?>"></i></a> |
||
1192 | </td> |
||
1193 | </tr> |
||
1194 | <tr> |
||
1195 | <td></td> |
||
1196 | <td> |
||
1197 | <em> <?= $modx->config['datetime_format'] ?> HH:MM:SS</em> |
||
1198 | </td> |
||
1199 | </tr> |
||
1200 | <tr> |
||
1201 | <td colspan="2"> |
||
1202 | <div class='split'></div> |
||
1203 | </td> |
||
1204 | </tr> |
||
1205 | |||
1206 | <?php |
||
1207 | |||
1208 | if($_SESSION['mgrRole'] == 1 || $modx->getManagerApi()->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
||
1209 | ?> |
||
1210 | <tr> |
||
1211 | <td> |
||
1212 | <span class="warning"><?=ManagerTheme::getLexicon('resource_type');?></span> |
||
1213 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_type_message');?>"></i> |
||
1214 | </td> |
||
1215 | <td> |
||
1216 | <select name="type" class="inputBox" onchange="documentDirty=true;"> |
||
1217 | <option value="document"<?= (($content['type'] == "document" || $modx->getManagerApi()->action == '85' || $modx->getManagerApi()->action == '4') ? ' selected="selected"' : "") ?> ><?=ManagerTheme::getLexicon('resource_type_webpage');?></option> |
||
1218 | <option value="reference"<?= (($content['type'] == "reference" || $modx->getManagerApi()->action == '72') ? ' selected="selected"' : "") ?> ><?=ManagerTheme::getLexicon('resource_type_weblink');?></option> |
||
1219 | </select> |
||
1220 | </td> |
||
1221 | </tr> |
||
1222 | |||
1223 | <tr> |
||
1224 | <td> |
||
1225 | <span class="warning"><?=ManagerTheme::getLexicon('page_data_contentType');?></span> |
||
1226 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('page_data_contentType_help');?>"></i> |
||
1227 | </td> |
||
1228 | <td> |
||
1229 | <select name="contentType" class="inputBox" onchange="documentDirty=true;"> |
||
1230 | <?php |
||
1231 | if(!$content['contentType']) { |
||
1232 | $content['contentType'] = 'text/html'; |
||
1233 | } |
||
1234 | $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml"); |
||
1235 | $ct = explode(",", $custom_contenttype); |
||
1236 | for($i = 0; $i < count($ct); $i++) { |
||
1237 | echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n"; |
||
1238 | } |
||
1239 | ?> |
||
1240 | </select> |
||
1241 | </td> |
||
1242 | </tr> |
||
1243 | <tr> |
||
1244 | <td> |
||
1245 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_contentdispo');?></span> |
||
1246 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_contentdispo_help');?>"></i> |
||
1247 | </td> |
||
1248 | <td> |
||
1249 | <select name="content_dispo" class="inputBox" size="1" onchange="documentDirty=true;"> |
||
1250 | <option value="0"<?= (!$content['content_dispo'] ? ' selected="selected"' : '') ?>><?=ManagerTheme::getLexicon('inline');?></option> |
||
1251 | <option value="1"<?= ($content['content_dispo'] == 1 ? ' selected="selected"' : '') ?>><?=ManagerTheme::getLexicon('attachment');?></option> |
||
1252 | </select> |
||
1253 | </td> |
||
1254 | </tr> |
||
1255 | |||
1256 | <tr> |
||
1257 | <td colspan="2"> |
||
1258 | <div class='split'></div> |
||
1259 | </td> |
||
1260 | </tr> |
||
1261 | <?php |
||
1262 | } else { |
||
1263 | if($content['type'] != 'reference' && $modx->getManagerApi()->action != '72') { |
||
1264 | // non-admin managers creating or editing a document resource |
||
1265 | ?> |
||
1266 | <input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" /> |
||
1267 | <input type="hidden" name="type" value="document" /> |
||
1268 | <input type="hidden" name="content_dispo" value="<?= (isset($content['content_dispo']) ? $content['content_dispo'] : '0') ?>" /> |
||
1269 | <?php |
||
1270 | } else { |
||
1271 | // non-admin managers creating or editing a reference (weblink) resource |
||
1272 | ?> |
||
1273 | <input type="hidden" name="type" value="reference" /> |
||
1274 | <input type="hidden" name="contentType" value="text/html" /> |
||
1275 | <?php |
||
1276 | } |
||
1277 | }//if mgrRole |
||
1278 | ?> |
||
1279 | |||
1280 | <tr> |
||
1281 | <td> |
||
1282 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_folder');?></span> |
||
1283 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_folder_help');?>"></i> |
||
1284 | </td> |
||
1285 | <td> |
||
1286 | <input name="isfoldercheck" type="checkbox" class="checkbox" <?= (($content['isfolder'] == 1 || $modx->getManagerApi()->action == '85') ? "checked" : '') ?> onclick="changestate(document.mutate.isfolder);" /> |
||
1287 | <input type="hidden" name="isfolder" value="<?= (($content['isfolder'] == 1 || $modx->getManagerApi()->action == '85') ? 1 : 0) ?>" onchange="documentDirty=true;" /> |
||
1288 | </td> |
||
1289 | </tr> |
||
1290 | |||
1291 | <tr> |
||
1292 | <td> |
||
1293 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_alvisibled');?></span> |
||
1294 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_alvisibled_help');?>"></i> |
||
1295 | </td> |
||
1296 | <td> |
||
1297 | <input name="alias_visible_check" type="checkbox" class="checkbox" <?= ((!isset($content['alias_visible']) || $content['alias_visible'] == 1) ? "checked" : '') ?> onclick="changestate(document.mutate.alias_visible);" /><input type="hidden" name="alias_visible" value="<?= ((!isset($content['alias_visible']) || $content['alias_visible'] == 1) ? 1 : 0) ?>" /> |
||
1298 | </td> |
||
1299 | </tr> |
||
1300 | |||
1301 | <tr> |
||
1302 | <td> |
||
1303 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_richtext');?></span> |
||
1304 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_richtext_help');?>"></i> |
||
1305 | </td> |
||
1306 | <td> |
||
1307 | <input name="richtextcheck" type="checkbox" class="checkbox" <?= ($content['richtext'] == 0 && $modx->getManagerApi()->action == '27' ? '' : "checked") ?> onclick="changestate(document.mutate.richtext);" /> |
||
1308 | <input type="hidden" name="richtext" value="<?= ($content['richtext'] == 0 && $modx->getManagerApi()->action == '27' ? 0 : 1) ?>" onchange="documentDirty=true;" /> |
||
1309 | </td> |
||
1310 | </tr> |
||
1311 | <tr> |
||
1312 | <td> |
||
1313 | <span class="warning"><?=ManagerTheme::getLexicon('track_visitors_title');?></span> |
||
1314 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_trackvisit_help');?>"></i> |
||
1315 | </td> |
||
1316 | <td> |
||
1317 | <input name="donthitcheck" type="checkbox" class="checkbox" <?= ($content['donthit'] != 1 ? 'checked="checked"' : '') ?> onclick="changestate(document.mutate.donthit);" /><input type="hidden" name="donthit" value="<?= ($content['donthit'] == 1 ? 1 : 0) ?>" onchange="documentDirty=true;" /> |
||
1318 | </td> |
||
1319 | </tr> |
||
1320 | <tr> |
||
1321 | <td> |
||
1322 | <span class="warning"><?=ManagerTheme::getLexicon('page_data_searchable');?></span> |
||
1323 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('page_data_searchable_help');?>"></i> |
||
1324 | </td> |
||
1325 | <td> |
||
1326 | <input name="searchablecheck" type="checkbox" class="checkbox" <?= (isset($content['searchable']) && $content['searchable'] == 1) || (!isset($content['searchable']) && $search_default == 1) ? "checked" : '' ?> onclick="changestate(document.mutate.searchable);" /><input type="hidden" name="searchable" value="<?= ((isset($content['searchable']) && $content['searchable'] == 1) || (!isset($content['searchable']) && $search_default == 1) ? 1 : 0) ?>" onchange="documentDirty=true;" /> |
||
1327 | </td> |
||
1328 | </tr> |
||
1329 | <tr> |
||
1330 | <td> |
||
1331 | <span class="warning"><?=ManagerTheme::getLexicon('page_data_cacheable');?></span> |
||
1332 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('page_data_cacheable_help');?>"></i> |
||
1333 | </td> |
||
1334 | <td> |
||
1335 | <input name="cacheablecheck" type="checkbox" class="checkbox" <?= ((isset($content['cacheable']) && $content['cacheable'] == 1) || (!isset($content['cacheable']) && $cache_default == 1) ? "checked" : '') ?> onclick="changestate(document.mutate.cacheable);" /> |
||
1336 | <input type="hidden" name="cacheable" value="<?= ((isset($content['cacheable']) && $content['cacheable'] == 1) || (!isset($content['cacheable']) && $cache_default == 1) ? 1 : 0) ?>" onchange="documentDirty=true;" /> |
||
1337 | </td> |
||
1338 | </tr> |
||
1339 | <tr> |
||
1340 | <td> |
||
1341 | <span class="warning"><?=ManagerTheme::getLexicon('resource_opt_emptycache');?></span> |
||
1342 | <input type="hidden" name="syncsite" value="1" /> |
||
1343 | <i class="<?= $_style["icons_tooltip"] ?>" data-tooltip="<?=ManagerTheme::getLexicon('resource_opt_emptycache_help');?>"></i> |
||
1344 | </td> |
||
1345 | <td> |
||
1346 | <input name="syncsitecheck" type="checkbox" class="checkbox" checked="checked" onclick="changestate(document.mutate.syncsite);" /> |
||
1347 | </td> |
||
1348 | </tr> |
||
1349 | </table> |
||
1350 | </div><!-- end #tabSettings --> |
||
1351 | <?php } ?> |
||
1352 | |||
1353 | <?php |
||
1354 | //Template Variables |
||
1355 | if ($modx->getConfig('group_tvs') > 2 && $templateVariablesOutput) { |
||
1356 | echo $templateVariables; |
||
1357 | } |
||
1358 | ?> |
||
1359 | |||
1360 | <?php |
||
1361 | /******************************* |
||
1362 | * Document Access Permissions */ |
||
1363 | if($modx->getConfig('use_udperms')) { |
||
1364 | $groupsarray = array(); |
||
1365 | $sql = ''; |
||
1366 | |||
1367 | $documentId = ($modx->getManagerApi()->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent'])); |
||
1368 | if($documentId > 0) { |
||
1369 | // Load up, the permissions from the parent (if new document) or existing document |
||
1370 | $rs = $modx->getDatabase()->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
||
1371 | while($currentgroup = $modx->getDatabase()->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
||
1372 | |||
1373 | // Load up the current permissions and names |
||
1374 | $vs = array( |
||
1375 | $tbl_document_group_names, |
||
1376 | $tbl_document_groups, |
||
1377 | $documentId |
||
1378 | ); |
||
1379 | $from = vsprintf("%s AS dgn LEFT JOIN %s AS groups_resource ON groups_resource.document_group=dgn.id AND groups_resource.document='%s'", $vs); |
||
1380 | $rs = $modx->db->select('dgn.*, groups_resource.id AS link_id', $from, '', 'name'); |
||
1381 | } else { |
||
1382 | // Just load up the names, we're starting clean |
||
1383 | $rs = $modx->getDatabase()->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name'); |
||
1384 | } |
||
1385 | |||
1386 | // retain selected doc groups between post |
||
1387 | if(isset($_POST['docgroups'])) { |
||
1388 | $groupsarray = array_merge($groupsarray, $_POST['docgroups']); |
||
1389 | } |
||
1390 | |||
1391 | $isManager = $modx->hasPermission('access_permissions'); |
||
1392 | $isWeb = $modx->hasPermission('web_access_permissions'); |
||
1393 | |||
1394 | // Setup Basic attributes for each Input box |
||
1395 | $inputAttributes = array( |
||
1396 | 'type' => 'checkbox', |
||
1397 | 'class' => 'checkbox', |
||
1398 | 'name' => 'docgroups[]', |
||
1399 | 'onclick' => 'makePublic(false);', |
||
1400 | ); |
||
1401 | $permissions = array(); // New Permissions array list (this contains the HTML) |
||
1402 | $permissions_yes = 0; // count permissions the current mgr user has |
||
1403 | $permissions_no = 0; // count permissions the current mgr user doesn't have |
||
1404 | |||
1405 | // Loop through the permissions list |
||
1406 | while($row = $modx->getDatabase()->getRow($rs)) { |
||
1407 | |||
1408 | // Create an inputValue pair (group ID and group link (if it exists)) |
||
1409 | $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new'); |
||
1410 | $inputId = 'group-' . $row['id']; |
||
1411 | |||
1412 | $checked = in_array($inputValue, $groupsarray); |
||
1413 | if($checked) { |
||
1414 | $notPublic = true; |
||
1415 | } // Mark as private access (either web or manager) |
||
1416 | |||
1417 | // Skip the access permission if the user doesn't have access... |
||
1418 | if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
||
1419 | continue; |
||
1420 | } |
||
1421 | |||
1422 | // Setup attributes for this Input box |
||
1423 | $inputAttributes['id'] = $inputId; |
||
1424 | $inputAttributes['value'] = $inputValue; |
||
1425 | if($checked) { |
||
1426 | $inputAttributes['checked'] = 'checked'; |
||
1427 | } else { |
||
1428 | unset($inputAttributes['checked']); |
||
1429 | } |
||
1430 | |||
1431 | // Create attribute string list |
||
1432 | $inputString = array(); |
||
1433 | foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
||
1434 | |||
1435 | // Make the <input> HTML |
||
1436 | $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
||
1437 | |||
1438 | // does user have this permission? |
||
1439 | $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg"; |
||
1440 | $vs = array( |
||
1441 | $row['id'], |
||
1442 | $_SESSION['mgrInternalKey'] |
||
1443 | ); |
||
1444 | $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs); |
||
1445 | $rsp = $modx->getDatabase()->select('COUNT(mg.id)', $from, $where); |
||
1446 | $count = $modx->getDatabase()->getValue($rsp); |
||
1447 | if($count > 0) { |
||
1448 | ++$permissions_yes; |
||
1449 | } else { |
||
1450 | ++$permissions_no; |
||
1451 | } |
||
1452 | $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>'; |
||
1453 | } |
||
1454 | // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public |
||
1455 | if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
||
1456 | $permissions = array(); |
||
1457 | } |
||
1458 | |||
1459 | // See if the Access Permissions section is worth displaying... |
||
1460 | if(!empty($permissions)) { |
||
1461 | // Add the "All Document Groups" item if we have rights in both contexts |
||
1462 | if($isManager && $isWeb) { |
||
1463 | array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>'); |
||
1464 | } |
||
1465 | // Output the permissions list... |
||
1466 | ?> |
||
1467 | <!-- Access Permissions --> |
||
1468 | <div class="tab-page" id="tabAccess"> |
||
1469 | <h2 class="tab" id="tab_access_header"><?=ManagerTheme::getLexicon('access_permissions');?></h2> |
||
1470 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById("tabAccess"));</script> |
||
1471 | <script type="text/javascript"> |
||
1472 | /* <![CDATA[ */ |
||
1473 | function makePublic(b) { |
||
1474 | var notPublic = false; |
||
1475 | var f = document.forms['mutate']; |
||
1476 | var chkpub = f['chkalldocs']; |
||
1477 | var chks = f['docgroups[]']; |
||
1478 | if(!chks && chkpub) { |
||
1479 | chkpub.checked = true; |
||
1480 | return false; |
||
1481 | } else if(!b && chkpub) { |
||
1482 | if(!chks.length) notPublic = chks.checked; |
||
1483 | else for(var i = 0; i < chks.length; i++) if(chks[i].checked) notPublic = true; |
||
1484 | chkpub.checked = !notPublic; |
||
1485 | } else { |
||
1486 | if(!chks.length) chks.checked = (b) ? false : chks.checked; |
||
1487 | else for(var i = 0; i < chks.length; i++) if(b) chks[i].checked = false; |
||
1488 | chkpub.checked = true; |
||
1489 | } |
||
1490 | } |
||
1491 | |||
1492 | /* ]]> */ |
||
1493 | </script> |
||
1494 | <p><?=ManagerTheme::getLexicon('access_permissions_docs_message');?></p> |
||
1495 | <ul> |
||
1496 | <?= implode("\n", $permissions) . "\n" ?> |
||
1497 | </ul> |
||
1498 | </div><!--div class="tab-page" id="tabAccess"--> |
||
1499 | <?php |
||
1500 | } // !empty($permissions) |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
84% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
1501 | elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
||
1502 | ?> |
||
1503 | <p><?=ManagerTheme::getLexicon('access_permissions_docs_collision');?></p> |
||
1504 | <?php |
||
1505 | |||
1506 | } |
||
1507 | } |
||
1508 | /* End Document Access Permissions * |
||
1509 | ***********************************/ |
||
1510 | ?> |
||
1511 | |||
1512 | <input type="submit" name="save" style="display:none" /> |
||
1513 | <?php |
||
1514 | |||
1515 | // invoke OnDocFormRender event |
||
1516 | $evtOut = $modx->invokeEvent('OnDocFormRender', array( |
||
1517 | 'id' => $id, |
||
1518 | 'template' => $content['template'] |
||
1519 | )); |
||
1520 | |||
1521 | if(is_array($evtOut)) { |
||
1522 | echo implode('', $evtOut); |
||
1523 | } |
||
1524 | ?> |
||
1525 | </div><!--div class="tab-pane" id="documentPane"--> |
||
1526 | </div><!--div class="sectionBody"--> |
||
1527 | </fieldset> |
||
1528 | </form> |
||
1529 | |||
1530 | <script type="text/javascript"> |
||
1531 | storeCurTemplate(); |
||
1532 | </script> |
||
1533 | <?php |
||
1534 | if(($content['richtext'] == 1 || $modx->getManagerApi()->action == '4' || $modx->getManagerApi()->action == '72') && $use_editor == 1) { |
||
1535 | if(is_array($richtexteditorIds)) { |
||
1536 | foreach($richtexteditorIds as $editor => $elements) { |
||
1537 | // invoke OnRichTextEditorInit event |
||
1538 | $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array( |
||
1539 | 'editor' => $editor, |
||
1540 | 'elements' => $elements, |
||
1541 | 'options' => $richtexteditorOptions[$editor] |
||
1542 | )); |
||
1543 | if(is_array($evtOut)) { |
||
1544 | echo implode('', $evtOut); |
||
1545 | } |
||
1546 | } |
||
1547 | } |
||
1548 | } |
||
1549 | ?> |
||
1550 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.