Completed
Pull Request — develop (#530)
by
unknown
05:43
created
manager/frames/1.php 1 patch
Braces   +35 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 header("X-XSS-Protection: 0");
@@ -11,22 +11,22 @@  discard block
 block discarded – undo
11 11
 
12 12
 $mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en';
13 13
 
14
-if (!isset($modx->config['manager_menu_height'])) {
14
+if (!isset($modx->config['manager_menu_height'])) {
15 15
     $modx->config['manager_menu_height'] = 2.2; // rem
16 16
 }
17 17
 
18
-if (!isset($modx->config['manager_tree_width'])) {
18
+if (!isset($modx->config['manager_tree_width'])) {
19 19
     $modx->config['manager_tree_width'] = 20; // rem
20 20
 }
21 21
 
22
-if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) {
22
+if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) {
23 23
     $initMainframeAction = $_SESSION['onLoginForwardToAction'];
24 24
     unset($_SESSION['onLoginForwardToAction']);
25
-} else {
25
+} else {
26 26
     $initMainframeAction = 2; // welcome.static
27 27
 }
28 28
 
29
-if (!isset($_SESSION['tree_show_only_folders'])) {
29
+if (!isset($_SESSION['tree_show_only_folders'])) {
30 30
     $_SESSION['tree_show_only_folders'] = 0;
31 31
 }
32 32
 
@@ -35,21 +35,21 @@  discard block
 block discarded – undo
35 35
 $tree_width = $modx->config['manager_tree_width'];
36 36
 $tree_min_width = 0;
37 37
 
38
-if (isset($_COOKIE['MODX_widthSideBar'])) {
38
+if (isset($_COOKIE['MODX_widthSideBar'])) {
39 39
     $MODX_widthSideBar = $_COOKIE['MODX_widthSideBar'];
40
-} else {
40
+} else {
41 41
     $MODX_widthSideBar = $tree_width;
42 42
 }
43 43
 
44
-if (!$MODX_widthSideBar) {
44
+if (!$MODX_widthSideBar) {
45 45
     $body_class .= 'sidebar-closed';
46 46
 }
47 47
 
48
-if (isset($_COOKIE['MODX_themeColor'])) {
48
+if (isset($_COOKIE['MODX_themeColor'])) {
49 49
     $body_class .= ' ' . $_COOKIE['MODX_themeColor'];
50 50
 }
51 51
 
52
-if (isset($modx->pluginCache['ElementsInTree'])) {
52
+if (isset($modx->pluginCache['ElementsInTree'])) {
53 53
     $body_class .= ' ElementsInTree';
54 54
 }
55 55
 
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
     'type8' => $_lang["lock_element_type_8"]
66 66
 );
67 67
 
68
-foreach ($unlockTranslations as $key => $value) {
68
+foreach ($unlockTranslations as $key => $value) {
69 69
     $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value);
70 70
 }
71 71
 
72 72
 $user = $modx->getUserInfo($modx->getLoginUserID());
73
-if ($user['which_browser'] == 'default') {
73
+if ($user['which_browser'] == 'default') {
74 74
     $user['which_browser'] = $modx->config['which_browser'];
75 75
 }
76 76
 
77 77
 $css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime;
78 78
 
79
-if ($modx->config['manager_theme'] == 'default') {
80
-    if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
79
+if ($modx->config['manager_theme'] == 'default') {
80
+    if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
81 81
         require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php';
82 82
         $minifier = new Formatter\CSSMinify();
83 83
         $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css');
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $css = $minifier->minify();
95 95
         file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css);
96 96
     }
97
-    if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
97
+    if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
98 98
         $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime;
99 99
     }
100 100
 }
@@ -237,8 +237,12 @@  discard block
 block discarded – undo
237 237
       <?php
238 238
       $opened = array_filter(array_map('intval', explode('|', $_SESSION['openedArray'])));
239 239
       echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n		modx.openedArray[", $opened) . '] = 1;') . "\n";
240
-      if(filemtime(MODX_MANAGER_PATH.'media/style/'.$modx->config["manager_theme"].'/js/modx.js') > filemtime(MODX_MANAGER_PATH.'media/style/'.$modx->config["manager_theme"].'/js/modx.min.js')) $modxJs = 'modx.js';
241
-      else $modxJs = 'modx.min.js'; // For easier development
240
+      if(filemtime(MODX_MANAGER_PATH.'media/style/'.$modx->config["manager_theme"].'/js/modx.js') > filemtime(MODX_MANAGER_PATH.'media/style/'.$modx->config["manager_theme"].'/js/modx.min.js')) {
241
+          $modxJs = 'modx.js';
242
+      } else {
243
+          $modxJs = 'modx.min.js';
244
+      }
245
+      // For easier development
242 246
       ?>
243 247
     </script>
244 248
     <script src="media/style/<?= $modx->config['manager_theme'] ?>/js/<?= $modxJs ?>?v=<?= $lastInstallTime ?>"></script>
@@ -250,7 +254,7 @@  discard block
 block discarded – undo
250 254
     <?php
251 255
     // invoke OnManagerTopPrerender event
252 256
     $evtOut = $modx->invokeEvent('OnManagerTopPrerender', $_REQUEST);
253
-    if (is_array($evtOut)) {
257
+    if (is_array($evtOut)) {
254 258
         echo implode("\n", $evtOut);
255 259
     }
256 260
     ?>
@@ -421,9 +425,12 @@  discard block
 block discarded – undo
421 425
             <div id="evo-tab-page-home" class="evo-tab-page show">
422 426
                 <iframe id="mainframe" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe>
423 427
             </div>
424
-        <?php else: ?>
428
+        <?php else {
429
+    : ?>
425 430
             <iframe id="mainframe" name="main" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe>
426
-        <?php endif; ?>
431
+        <?php endif;
432
+}
433
+?>
427 434
         <div id="mainloader"></div>
428 435
     </div>
429 436
     <div id="resizer"></div>
@@ -436,11 +443,11 @@  discard block
 block discarded – undo
436 443
             'tree_sortdir',
437 444
             'tree_nodename'
438 445
         );
439
-        foreach ($sortParams as $param) {
440
-            if (isset($_REQUEST[$param])) {
446
+        foreach ($sortParams as $param) {
447
+            if (isset($_REQUEST[$param])) {
441 448
                 $modx->manager->saveLastUserSetting($param, $_REQUEST[$param]);
442 449
                 $_SESSION[$param] = $_REQUEST[$param];
443
-            } else if (!isset($_SESSION[$param])) {
450
+            } else if (!isset($_SESSION[$param])) {
444 451
                 $_SESSION[$param] = $modx->manager->getLastUserSetting($param);
445 452
             }
446 453
         }
@@ -520,9 +527,9 @@  discard block
 block discarded – undo
520 527
     </div>
521 528
 
522 529
     <?php
523
-    function constructLink($action, $img, $text, $allowed)
524
-    {
525
-        if ($allowed == 1) {
530
+    function constructLink($action, $img, $text, $allowed)
531
+    {
532
+        if ($allowed == 1) {
526 533
             echo sprintf('<div class="menuLink" id="item%s" onclick="modx.tree.menuHandler(%s);">', $action, $action);
527 534
             echo sprintf('<i class="%s"></i> %s</div>', $img, $text);
528 535
         }
@@ -627,7 +634,7 @@  discard block
 block discarded – undo
627 634
     ?>
628 635
 
629 636
 </div>
630
-<?php if ($modx->config['show_picker'] != "0") {
637
+<?php if ($modx->config['show_picker'] != "0") {
631 638
     include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php');
632 639
 } ?>
633 640
 </body>
Please login to merge, or discard this patch.
manager/actions/welcome.static.php 1 patch
Braces   +77 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
4 4
 }
5 5
 
6 6
 unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
7 7
 
8
-if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
8
+if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
9 9
 	// seems to be a new install - send the user to the configuration page
10 10
 	exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
11 11
 }
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 $_SESSION['nrnewmessages'] = 0;
17 17
 
18 18
 // setup message info
19
-if($modx->hasPermission('messages')) {
19
+if($modx->hasPermission('messages')) {
20 20
 	include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
21 21
 	$_SESSION['nrtotalmessages'] = $nrtotalmessages;
22 22
 	$_SESSION['nrnewmessages'] = $nrnewmessages;
@@ -32,46 +32,46 @@  discard block
 block discarded – undo
32 32
 }
33 33
 
34 34
 // setup icons
35
-if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
35
+if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
36 36
 	$icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37 37
 	$ph['SecurityIcon'] = wrapIcon($icon, 75);
38 38
 }
39
-if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
39
+if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
40 40
 	$icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41 41
 	$ph['WebUserIcon'] = wrapIcon($icon, 99);
42 42
 }
43
-if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
43
+if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
44 44
 	$icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45 45
 	$ph['ModulesIcon'] = wrapIcon($icon, 106);
46 46
 }
47
-if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
47
+if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
48 48
 	$icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49 49
 	$ph['ResourcesIcon'] = wrapIcon($icon, 76);
50 50
 }
51
-if($modx->hasPermission('bk_manager')) {
51
+if($modx->hasPermission('bk_manager')) {
52 52
 	$icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53 53
 	$ph['BackupIcon'] = wrapIcon($icon, 93);
54 54
 }
55
-if($modx->hasPermission('help')) {
55
+if($modx->hasPermission('help')) {
56 56
 	$icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57 57
 	$ph['HelpIcon'] = wrapIcon($icon, 9);
58 58
 }
59 59
 // do some config checks
60
-if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
60
+if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
61 61
 	include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
62
-	if($config_check_results != $_lang['configcheck_ok']) {
62
+	if($config_check_results != $_lang['configcheck_ok']) {
63 63
 		$ph['config_check_results'] = $config_check_results;
64 64
 		$ph['config_display'] = 'block';
65
-	} else {
65
+	} else {
66 66
 		$ph['config_display'] = 'none';
67 67
 	}
68
-} else {
68
+} else {
69 69
 	$ph['config_display'] = 'none';
70 70
 }
71 71
 
72 72
 // Check logout-reminder
73
-if(isset($_SESSION['show_logout_reminder'])) {
74
-	switch($_SESSION['show_logout_reminder']['type']) {
73
+if(isset($_SESSION['show_logout_reminder'])) {
74
+	switch($_SESSION['show_logout_reminder']['type']) {
75 75
 		case 'logout_reminder':
76 76
 			$date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
77 77
 			$ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 	$ph['show_logout_reminder'] = 'block';
81 81
 	unset($_SESSION['show_logout_reminder']);
82
-} else {
82
+} else {
83 83
 	$ph['show_logout_reminder'] = 'none';
84 84
 }
85 85
 
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'";
141 141
 $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
142 142
 
143
-if($modx->db->getRecordCount($rs) < 1) {
143
+if($modx->db->getRecordCount($rs) < 1) {
144 144
 	$html = '<p>[%no_active_users_found%]</p>';
145
-} else {
145
+} else {
146 146
 	include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
147 147
 	$now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
148 148
 	$ph['now'] = strftime('%H:%M:%S', $now);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	$userList = array();
169 169
 	$userCount = array();
170 170
 	// Create userlist with session-count first before output
171
-	while($activeusers = $modx->db->getRow($rs)) {
171
+	while($activeusers = $modx->db->getRow($rs)) {
172 172
 		$userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
173 173
 
174 174
 		$idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			$currentaction
187 187
 		);
188 188
 	}
189
-	foreach($userList as $params) {
189
+	foreach($userList as $params) {
190 190
 		$params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
191 191
 		$html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
192 192
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 // invoke event OnManagerWelcomePrerender
233 233
 $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
234
-if(is_array($evtOut)) {
234
+if(is_array($evtOut)) {
235 235
 	$output = implode('', $evtOut);
236 236
 	$ph['OnManagerWelcomePrerender'] = $output;
237 237
 }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	'body' => '<div class="widget-stage">[+RecentInfo+]</div>',
341 341
 	'hide'=>'0'
342 342
 );
343
-if ($modx->config['rss_url_news']) {
343
+if ($modx->config['rss_url_news']) {
344 344
     $widgets['news'] = array(
345 345
         'menuindex' => '40',
346 346
         'id' => 'news',
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
         'hide'=>'0'
352 352
     );
353 353
 }
354
-if ($modx->config['rss_url_security']) {
354
+if ($modx->config['rss_url_security']) {
355 355
     $widgets['security'] = array(
356 356
         'menuindex' => '50',
357 357
         'id' => 'security',
@@ -365,29 +365,29 @@  discard block
 block discarded – undo
365 365
 
366 366
 // invoke OnManagerWelcomeHome event
367 367
 $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
368
-if(is_array($sitewidgets)) {
368
+if(is_array($sitewidgets)) {
369 369
 	$newwidgets = array();
370
-    foreach($sitewidgets as $widget){
370
+    foreach($sitewidgets as $widget) {
371 371
         $newwidgets = array_merge($newwidgets, unserialize($widget));
372 372
     }
373 373
     $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets;
374 374
 }
375 375
 
376
-usort($widgets, function ($a, $b) {
376
+usort($widgets, function ($a, $b){
377 377
 	return $a['menuindex'] - $b['menuindex'];
378 378
 });
379 379
 
380 380
 $tpl = getTplWidget();
381 381
 $output = '';
382
-foreach($widgets as $widget) {
383
-	if ($widget['hide'] != '1'){
382
+foreach($widgets as $widget) {
383
+	if ($widget['hide'] != '1') {
384 384
 		$output .= $modx->parseText($tpl, $widget);
385 385
 	}
386 386
 }
387 387
 $ph['widgets'] = $output;
388 388
 
389 389
 // load template
390
-if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
390
+if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
391 391
 	$modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
392 392
 }
393 393
 
@@ -395,26 +395,28 @@  discard block
 block discarded – undo
395 395
 $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target);
396 396
 $target = $modx->mergeSettingsContent($target);
397 397
 
398
-if(substr($target, 0, 1) === '@') {
399
-	if(substr($target, 0, 6) === '@CHUNK') {
398
+if(substr($target, 0, 1) === '@') {
399
+	if(substr($target, 0, 6) === '@CHUNK') {
400 400
 		$content = $modx->getChunk(trim(substr($target, 7)));
401
-	} elseif(substr($target, 0, 5) === '@FILE') {
401
+	} elseif(substr($target, 0, 5) === '@FILE') {
402 402
 		$content = file_get_contents(trim(substr($target, 6)));
403
-	} else {
403
+	} else {
404 404
 		$content = '';
405 405
 	}
406
-} else {
406
+} else {
407 407
 	$chunk = $modx->getChunk($target);
408
-	if($chunk !== false && !empty($chunk)) {
408
+	if($chunk !== false && !empty($chunk)) {
409 409
 		$content = $chunk;
410
-	} elseif(is_file(MODX_BASE_PATH . $target)) {
410
+	} elseif(is_file(MODX_BASE_PATH . $target)) {
411 411
 		$content = file_get_contents(MODX_BASE_PATH . $target);
412
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
412
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
413 413
 		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
414
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
414
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) {
415
+	    // ClipperCMS compatible
415 416
 	{
416
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
417
-	} else {
417
+		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
418
+	}
419
+	} else {
418 420
 		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
419 421
 	}
420 422
 }
@@ -423,7 +425,7 @@  discard block
 block discarded – undo
423 425
 $content = $modx->mergeConditionalTagsContent($content);
424 426
 $content = $modx->mergeSettingsContent($content);
425 427
 $content = $modx->parseText($content, $ph);
426
-if(strpos($content, '[+') !== false) {
428
+if(strpos($content, '[+') !== false) {
427 429
 	$modx->toPlaceholders($ph);
428 430
 	$content = $modx->mergePlaceholderContent($content);
429 431
 }
@@ -432,7 +434,7 @@  discard block
 block discarded – undo
432 434
 $content = $modx->parseText($content, $_style, '[&', '&]');
433 435
 $content = $modx->cleanUpMODXTags($content); //cleanup
434 436
 
435
-if($js = $modx->getRegisteredClientScripts()) {
437
+if($js = $modx->getRegisteredClientScripts()) {
436 438
 	$content .= $js;
437 439
 }
438 440
 
@@ -442,7 +444,9 @@  discard block
 block discarded – undo
442 444
 //	<a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a>
443 445
 //  <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a>
444 446
 //</span>
445
-function getTplWidget() { // recent document info
447
+function getTplWidget()
448
+{
449
+// recent document info
446 450
 	return '
447 451
 		<div class="[+cols+]" id="[+id+]">
448 452
 			<div class="card"[+cardAttr+]>
@@ -453,7 +457,9 @@  discard block
 block discarded – undo
453 457
 ';
454 458
 }
455 459
 
456
-function getRecentInfo() { // recent document info
460
+function getRecentInfo()
461
+{
462
+// recent document info
457 463
 	global $modx;
458 464
 
459 465
 	$modx->addSnippet('recentInfoList', 'getRecentInfoList');
@@ -479,12 +485,13 @@  discard block
 block discarded – undo
479 485
 	return $html;
480 486
 }
481 487
 
482
-function getRecentInfoList() {
488
+function getRecentInfoList()
489
+{
483 490
 	global $modx;
484 491
 
485 492
 	$rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
486 493
 
487
-	if($modx->db->getRecordCount($rs) < 1) {
494
+	if($modx->db->getRecordCount($rs) < 1) {
488 495
 		return '<tr><td>[%no_activity_message%]</td></tr>';
489 496
 	}
490 497
 
@@ -494,22 +501,22 @@  discard block
 block discarded – undo
494 501
 	$btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
495 502
 
496 503
 	$output = array();
497
-	while($ph = $modx->db->getRow($rs)) {
504
+	while($ph = $modx->db->getRow($rs)) {
498 505
 		$docid = $ph['id'];
499 506
 		$_ = $modx->getUserInfo($ph['editedby']);
500 507
 		$ph['username'] = $_['username'];
501 508
 
502
-		if($ph['deleted'] == 1) {
509
+		if($ph['deleted'] == 1) {
503 510
 			$ph['status'] = 'deleted text-danger';
504
-		} elseif($ph['published'] == 0) {
511
+		} elseif($ph['published'] == 0) {
505 512
 			$ph['status'] = 'unpublished font-italic text-muted';
506
-		} else {
513
+		} else {
507 514
 			$ph['status'] = 'published';
508 515
 		}
509 516
 
510
-		if($modx->hasPermission('edit_document')) {
517
+		if($modx->hasPermission('edit_document')) {
511 518
 			$ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
512
-		} else {
519
+		} else {
513 520
 			$ph['edit_btn'] = '';
514 521
 		}
515 522
 
@@ -522,40 +529,40 @@  discard block
 block discarded – undo
522 529
 			$preview_disabled
523 530
 		), $btntpl['preview_btn']);
524 531
 
525
-		if($modx->hasPermission('delete_document')) {
526
-			if($ph['deleted'] == 0) {
532
+		if($modx->hasPermission('delete_document')) {
533
+			if($ph['deleted'] == 0) {
527 534
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main" data-ajaxaction="delete.res" data-id="[+id+]" data-element="row[+id+]"><i class="fa fa-trash fa-fw"></i></a> ';
528
-			} else {
535
+			} else {
529 536
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main" data-ajaxaction="delete.res" data-id="[+id+]" data-element="row[+id+]"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
530 537
 			}
531 538
 			$ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
532
-		} else {
539
+		} else {
533 540
 			$ph['delete_btn'] = '';
534 541
 		}
535 542
 
536
-		if($ph['deleted'] == 1 && $ph['published'] == 0) {
543
+		if($ph['deleted'] == 1 && $ph['published'] == 0) {
537 544
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main" data-ajaxaction="publish.res" data-id="[+id+]" data-element="row[+id+]"><i class="fa fa-arrow-up fa-fw"></i></a> ';
538
-		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
545
+		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
539 546
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main" data-ajaxaction="publish.res" data-id="[+id+]" data-element="row[+id+]"><i class="fa fa-arrow-down fa-fw"></i></a> ';
540
-		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
547
+		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
541 548
 			$publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main" data-ajaxaction="publish.res" data-id="[+id+]" data-element="row[+id+]"><i class="fa fa-arrow-up fa-fw"></i></a> ';
542
-		} else {
549
+		} else {
543 550
 			$publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main" data-ajaxaction="publish.res" data-id="[+id+]" data-element="row[+id+]"><i class="fa fa-arrow-down fa-fw"></i></a> ';
544 551
 		}
545 552
 		$ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
546 553
 
547 554
 		$ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
548 555
 
549
-		if($ph['longtitle'] == '') {
556
+		if($ph['longtitle'] == '') {
550 557
 			$ph['longtitle'] = '(<i>[%not_set%]</i>)';
551 558
 		}
552
-		if($ph['description'] == '') {
559
+		if($ph['description'] == '') {
553 560
 			$ph['description'] = '(<i>[%not_set%]</i>)';
554 561
 		}
555
-		if($ph['introtext'] == '') {
562
+		if($ph['introtext'] == '') {
556 563
 			$ph['introtext'] = '(<i>[%not_set%]</i>)';
557 564
 		}
558
-		if($ph['alias'] == '') {
565
+		if($ph['alias'] == '') {
559 566
 			$ph['alias'] = '(<i>[%not_set%]</i>)';
560 567
 		}
561 568
 
@@ -564,7 +571,8 @@  discard block
 block discarded – undo
564 571
 	return join("\n", $output);
565 572
 }
566 573
 
567
-function getRecentInfoRowTpl() {
574
+function getRecentInfoRowTpl()
575
+{
568 576
 	$tpl = '
569 577
 						<tr id="row[+id+]">
570 578
 							<td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td>
@@ -593,11 +601,13 @@  discard block
 block discarded – undo
593 601
 }
594 602
 
595 603
 // setup icons
596
-function wrapIcon($i, $action) {
604
+function wrapIcon($i, $action)
605
+{
597 606
 	return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
598 607
 }
599 608
 
600
-function getStartUpScript() {
609
+function getStartUpScript()
610
+{
601 611
 	$script = '
602 612
         <script type="text/javascript">
603 613
         function hideConfigCheckWarning(key) {
Please login to merge, or discard this patch.
manager/includes/document.parser.class.inc.php 1 patch
Braces   +62 added lines, -29 removed lines patch added patch discarded remove patch
@@ -696,13 +696,15 @@  discard block
 block discarded – undo
696 696
             $this->virtualDir = '';
697 697
         }
698 698
 
699
-        if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */
699
+        if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) {
700
+/* we got an ID returned, check to make sure it's not an alias */
700 701
             /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */
701 702
             if ($this->config['use_alias_path'] == 1) {
702 703
                 if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
703 704
                     $this->documentMethod = 'id';
704 705
                     return $q;
705
-                } else { /* not a valid id in terms of virtualDir, treat as alias */
706
+                } else {
707
+/* not a valid id in terms of virtualDir, treat as alias */
706 708
                     $this->documentMethod = 'alias';
707 709
                     return $q;
708 710
                 }
@@ -710,7 +712,8 @@  discard block
 block discarded – undo
710 712
                 $this->documentMethod = 'id';
711 713
                 return $q;
712 714
             }
713
-        } else { /* we didn't get an ID back, so instead we assume it's an alias */
715
+        } else {
716
+/* we didn't get an ID back, so instead we assume it's an alias */
714 717
             if ($this->config['friendly_alias_urls'] != 1) {
715 718
                 $q = $qOrig;
716 719
             }
@@ -740,13 +743,14 @@  discard block
 block discarded – undo
740 743
      * @param $id
741 744
      * @return array|mixed|null|string
742 745
      */
743
-    public function makePageCacheKey($id){
746
+    public function makePageCacheKey($id)
747
+    {
744 748
         $hash = $id;
745 749
         $tmp = null;
746 750
         $params = array();
747
-        if(!empty($this->systemCacheKey)){
751
+        if(!empty($this->systemCacheKey)) {
748 752
             $hash = $this->systemCacheKey;
749
-        }else {
753
+        } else {
750 754
             if (!empty($_GET)) {
751 755
                 // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID.
752 756
                 $params = $_GET;
@@ -755,7 +759,7 @@  discard block
 block discarded – undo
755 759
             }
756 760
         }
757 761
         $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params));
758
-        if (is_array($evtOut) && count($evtOut) > 0){
762
+        if (is_array($evtOut) && count($evtOut) > 0) {
759 763
             $tmp = array_pop($evtOut);
760 764
         }
761 765
         return empty($tmp) ? $hash : $tmp;
@@ -1166,10 +1170,18 @@  discard block
 block discarded – undo
1166 1170
             return array();
1167 1171
         }
1168 1172
         $spacer = md5('<<<EVO>>>');
1169
-        if($left==='{{' && strpos($content,';}}')!==false)  $content = str_replace(';}}', sprintf(';}%s}',   $spacer),$content);
1170
-        if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content);
1171
-        if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]',  $spacer),$content);
1172
-        if($left==='[[' && strpos($content,']]]')!==false)  $content = str_replace(']]]', sprintf(']%s]]',   $spacer),$content);
1173
+        if($left==='{{' && strpos($content,';}}')!==false) {
1174
+            $content = str_replace(';}}', sprintf(';}%s}',   $spacer),$content);
1175
+        }
1176
+        if($left==='{{' && strpos($content,'{{}}')!==false) {
1177
+            $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content);
1178
+        }
1179
+        if($left==='[[' && strpos($content,']]]]')!==false) {
1180
+            $content = str_replace(']]]]',sprintf(']]%s]]',  $spacer),$content);
1181
+        }
1182
+        if($left==='[[' && strpos($content,']]]')!==false) {
1183
+            $content = str_replace(']]]', sprintf(']%s]]',   $spacer),$content);
1184
+        }
1173 1185
 
1174 1186
         $pos['<![CDATA['] = strpos($content, '<![CDATA[');
1175 1187
         $pos[']]>'] = strpos($content, ']]>');
@@ -1222,7 +1234,8 @@  discard block
 block discarded – undo
1222 1234
                         }
1223 1235
                     }
1224 1236
 
1225
-                    if (!in_array($fetch, $tags)) {  // Avoid double Matches
1237
+                    if (!in_array($fetch, $tags)) {
1238
+// Avoid double Matches
1226 1239
                         $tags[] = $fetch; // Fetch
1227 1240
                     };
1228 1241
                     $fetch = ''; // and reset
@@ -1240,7 +1253,9 @@  discard block
 block discarded – undo
1240 1253
             }
1241 1254
         }
1242 1255
         foreach($tags as $i=>$tag) {
1243
-            if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag);
1256
+            if(strpos($tag,$spacer)!==false) {
1257
+                $tags[$i] = str_replace($spacer, '', $tag);
1258
+            }
1244 1259
         }
1245 1260
         return $tags;
1246 1261
     }
@@ -1280,7 +1295,10 @@  discard block
 block discarded – undo
1280 1295
         }
1281 1296
 
1282 1297
         foreach ($matches[1] as $i => $key) {
1283
-            if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1298
+            if(strpos($key,'[+')!==false) {
1299
+                continue;
1300
+            }
1301
+            // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1284 1302
             if (substr($key, 0, 1) == '#') {
1285 1303
                 $key = substr($key, 1);
1286 1304
             } // remove # for QuickEdit format
@@ -2005,7 +2023,8 @@  discard block
 block discarded – undo
2005 2023
      * @return mixed|string
2006 2024
      */
2007 2025
     public function _getSGVar($value)
2008
-    { // Get super globals
2026
+    {
2027
+// Get super globals
2009 2028
         $key = $value;
2010 2029
         $_ = $this->config['enable_filter'];
2011 2030
         $this->config['enable_filter'] = 1;
@@ -2410,7 +2429,8 @@  discard block
 block discarded – undo
2410 2429
         if ($this->config['friendly_urls'] == 1) {
2411 2430
             $aliases = array();
2412 2431
             if (is_array($this->documentListing)) {
2413
-                foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site!
2432
+                foreach ($this->documentListing as $path => $docid) {
2433
+// This is big Loop on large site!
2414 2434
                     $aliases[$docid] = $path;
2415 2435
                     $isfolder[$docid] = $this->aliasListing[$docid]['isfolder'];
2416 2436
                 }
@@ -2443,7 +2463,7 @@  discard block
 block discarded – undo
2443 2463
             $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
2444 2464
             $pref = $this->config['friendly_url_prefix'];
2445 2465
             $suff = $this->config['friendly_url_suffix'];
2446
-            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) {
2466
+            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){
2447 2467
                 global $modx;
2448 2468
                 $thealias = $aliases[$m[1]];
2449 2469
                 $thefolder = $isfolder[$m[1]];
@@ -3120,7 +3140,9 @@  discard block
 block discarded – undo
3120 3140
     public function webAlertAndQuit($msg, $url = "")
3121 3141
     {
3122 3142
         global $modx_manager_charset;
3123
-        if($this->ajaxMode === true) $this->jsonResponse(array('error'=>$msg));
3143
+        if($this->ajaxMode === true) {
3144
+            $this->jsonResponse(array('error'=>$msg));
3145
+        }
3124 3146
         if (substr(strtolower($url), 0, 11) == "javascript:") {
3125 3147
             $fnc = substr($url, 11);
3126 3148
         } elseif ($url) {
@@ -4216,7 +4238,8 @@  discard block
 block discarded – undo
4216 4238
         if (isset ($this->snippetCache[$snippetName])) {
4217 4239
             $snippet = $this->snippetCache[$snippetName];
4218 4240
             $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : '';
4219
-        } else { // not in cache so let's check the db
4241
+        } else {
4242
+// not in cache so let's check the db
4220 4243
             $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "'  AND ss.disabled=0;";
4221 4244
             $result = $this->db->query($sql);
4222 4245
             if ($this->db->getRecordCount($result) == 1) {
@@ -4720,7 +4743,7 @@  discard block
 block discarded – undo
4720 4743
             $result = $this->db->makeArray($rs);
4721 4744
 
4722 4745
             // get default/built-in template variables
4723
-            if(is_array($docRow)){
4746
+            if(is_array($docRow)) {
4724 4747
                 ksort($docRow);
4725 4748
 
4726 4749
                 foreach ($docRow as $key => $value) {
@@ -5199,12 +5222,16 @@  discard block
 block discarded – undo
5199 5222
             return '';
5200 5223
         } // nothing to register
5201 5224
         if (!is_array($options)) {
5202
-            if (is_bool($options))  // backward compatibility with old plaintext parameter
5225
+            if (is_bool($options)) {
5226
+                // backward compatibility with old plaintext parameter
5203 5227
             {
5204 5228
                 $options = array('plaintext' => $options);
5205
-            } elseif (is_string($options)) // Also allow script name as 2nd param
5229
+            }
5230
+            } elseif (is_string($options)) {
5231
+                // Also allow script name as 2nd param
5206 5232
             {
5207 5233
                 $options = array('name' => $options);
5234
+            }
5208 5235
             } else {
5209 5236
                 $options = array();
5210 5237
             }
@@ -5216,7 +5243,8 @@  discard block
 block discarded – undo
5216 5243
         unset($overwritepos); // probably unnecessary--just making sure
5217 5244
 
5218 5245
         $useThisVer = true;
5219
-        if (isset($this->loadedjscripts[$key])) { // a matching script was found
5246
+        if (isset($this->loadedjscripts[$key])) {
5247
+// a matching script was found
5220 5248
             // if existing script is a startup script, make sure the candidate is also a startup script
5221 5249
             if ($this->loadedjscripts[$key]['startup']) {
5222 5250
                 $startup = true;
@@ -5236,7 +5264,8 @@  discard block
 block discarded – undo
5236 5264
                     // overwrite the old script (the position may be important for dependent scripts)
5237 5265
                     $overwritepos = $this->loadedjscripts[$key]['pos'];
5238 5266
                 }
5239
-            } else { // Use the original version
5267
+            } else {
5268
+// Use the original version
5240 5269
                 if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) {
5241 5270
                     // need to move the exisiting script to the head
5242 5271
                     $version = $this->loadedjscripts[$key][$version];
@@ -5360,7 +5389,8 @@  discard block
 block discarded – undo
5360 5389
         }
5361 5390
 
5362 5391
         $results = null;
5363
-        foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop
5392
+        foreach ($this->pluginEvent[$evtName] as $pluginName) {
5393
+// start for loop
5364 5394
             if ($this->dumpPlugins) {
5365 5395
                 $eventtime = $this->getMicroTime();
5366 5396
             }
@@ -5908,7 +5938,8 @@  discard block
 block discarded – undo
5908 5938
      * @return bool
5909 5939
      */
5910 5940
     public function isSafeCode($phpcode = '', $safe_functions = '')
5911
-    { // return true or false
5941
+    {
5942
+// return true or false
5912 5943
         if ($safe_functions == '') {
5913 5944
             return false;
5914 5945
         }
@@ -6324,7 +6355,7 @@  discard block
 block discarded – undo
6324 6355
             $args = array_pad(array(), $_, '$var');
6325 6356
             $args = implode(", ", $args);
6326 6357
             $modx = &$this;
6327
-            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) {
6358
+            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){
6328 6359
                 $arg = $val['args'][$tmp - 1];
6329 6360
                 switch (true) {
6330 6361
                     case is_null($arg): {
@@ -6565,7 +6596,8 @@  discard block
 block discarded – undo
6565 6596
      *
6566 6597
      * @param boolean $state State of ajaxMode
6567 6598
      */
6568
-    function setAjaxMode($state) {
6599
+    function setAjaxMode($state)
6600
+    {
6569 6601
         $this->ajaxMode = $state === true ? true : false;
6570 6602
     }
6571 6603
 
@@ -6574,7 +6606,8 @@  discard block
 block discarded – undo
6574 6606
      *
6575 6607
      * @param array $array Array to convert
6576 6608
      */
6577
-    function jsonResponse($array) {
6609
+    function jsonResponse($array)
6610
+    {
6578 6611
         header('content-type: application/json');
6579 6612
         exit(json_encode($array, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE));
6580 6613
     }
Please login to merge, or discard this patch.
manager/media/style/default/ajax.php 1 patch
Braces   +86 added lines, -81 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
 
8 8
 $modx->db->connect();
9 9
 
10
-if (empty ($modx->config)) {
10
+if (empty ($modx->config)) {
11 11
     $modx->getSettings();
12 12
 }
13 13
 
14
-if (!isset($_SESSION['mgrValidated']) || !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
14
+if (!isset($_SESSION['mgrValidated']) || !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
15 15
     $modx->sendErrorPage();
16 16
 }
17 17
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 $_lang = array();
23 23
 include_once MODX_MANAGER_PATH . '/includes/lang/english.inc.php';
24
-if ($modx->config['manager_language'] != 'english') {
24
+if ($modx->config['manager_language'] != 'english') {
25 25
     include_once MODX_MANAGER_PATH . '/includes/lang/' . $modx->config['manager_language'] . '.inc.php';
26 26
 }
27 27
 include_once MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/style.php';
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 
37 37
 $json = array();
38 38
 
39
-if (isset($action)) {
40
-    switch ($action) {
39
+if (isset($action)) {
40
+    switch ($action) {
41 41
 
42 42
         case '1': {
43 43
 
44
-            switch ($frame) {
44
+            switch ($frame) {
45 45
                 case 'nodes':
46 46
                     include_once MODX_MANAGER_PATH . '/frames/nodes.php';
47 47
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
             $elements = isset($_REQUEST['elements']) && is_scalar($_REQUEST['elements']) ? htmlentities($_REQUEST['elements']) : '';
57 57
 
58
-            if ($elements) {
58
+            if ($elements) {
59 59
                 $output = '';
60 60
                 $items = '';
61 61
                 $sql = '';
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                 $sqlLike = $filter ? 'WHERE t1.name LIKE "' . $modx->db->escape($filter) . '%"' : '';
65 65
                 $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
66 66
 
67
-                switch ($elements) {
67
+                switch ($elements) {
68 68
                     case 'element_templates':
69 69
                         $a = 16;
70 70
                         $sqlLike = $filter ? 'WHERE t1.templatename LIKE "' . $modx->db->escape($filter) . '%"' : '';
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                         ORDER BY t1.templatename ASC
75 75
                         ' . $sqlLimit);
76 76
 
77
-                        if ($modx->hasPermission('new_template')) {
77
+                        if ($modx->hasPermission('new_template')) {
78 78
                             $output .= '<li><a id="a_19" href="index.php?a=19" target="main"><i class="fa fa-plus"></i>' . $_lang['new_template'] . '</a></li>';
79 79
                         }
80 80
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                         ORDER BY t1.name ASC
91 91
                         ' . $sqlLimit);
92 92
 
93
-                        if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
93
+                        if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
94 94
                             $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>' . $_lang['new_tmplvars'] . '</a></li>';
95 95
                         }
96 96
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                         ORDER BY t1.name ASC
105 105
                         ' . $sqlLimit);
106 106
 
107
-                        if ($modx->hasPermission('new_chunk')) {
107
+                        if ($modx->hasPermission('new_chunk')) {
108 108
                             $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>' . $_lang['new_htmlsnippet'] . '</a></li>';
109 109
                         }
110 110
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                         ORDER BY t1.name ASC
119 119
                         ' . $sqlLimit);
120 120
 
121
-                        if ($modx->hasPermission('new_snippet')) {
121
+                        if ($modx->hasPermission('new_snippet')) {
122 122
                             $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>' . $_lang['new_snippet'] . '</a></li>';
123 123
                         }
124 124
 
@@ -132,19 +132,19 @@  discard block
 block discarded – undo
132 132
                         ORDER BY t1.name ASC
133 133
                         ' . $sqlLimit);
134 134
 
135
-                        if ($modx->hasPermission('new_plugin')) {
135
+                        if ($modx->hasPermission('new_plugin')) {
136 136
                             $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>' . $_lang['new_plugin'] . '</a></li>';
137 137
                         }
138 138
 
139 139
                         break;
140 140
                 }
141 141
 
142
-                if ($count = $modx->db->getRecordCount($sql)) {
143
-                    if ($count == $limit) {
142
+                if ($count = $modx->db->getRecordCount($sql)) {
143
+                    if ($count == $limit) {
144 144
                         $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
145 145
                     }
146
-                    while ($row = $modx->db->getRow($sql)) {
147
-                        if (($row['disabled'] || $row['locked']) && $role != 1) {
146
+                    while ($row = $modx->db->getRow($sql)) {
147
+                        if (($row['disabled'] || $row['locked']) && $role != 1) {
148 148
                             continue;
149 149
                         }
150 150
 
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
                     }
153 153
                 }
154 154
 
155
-                if (isset($_REQUEST['filter'])) {
155
+                if (isset($_REQUEST['filter'])) {
156 156
                     $output = $items;
157
-                } else {
157
+                } else {
158 158
                     $output .= $items;
159 159
                 }
160 160
 
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
 				ORDER BY t1.username ASC
180 180
 				' . $sqlLimit);
181 181
 
182
-            if ($modx->hasPermission('new_user')) {
182
+            if ($modx->hasPermission('new_user')) {
183 183
                 $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>' . $_lang['new_user'] . '</a></li>';
184 184
             }
185 185
 
186
-            if ($count = $modx->db->getRecordCount($sql)) {
187
-                if ($count == $limit) {
186
+            if ($count = $modx->db->getRecordCount($sql)) {
187
+                if ($count == $limit) {
188 188
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
189 189
                 }
190
-                while ($row = $modx->db->getRow($sql)) {
190
+                while ($row = $modx->db->getRow($sql)) {
191 191
                     $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
192 192
                 }
193 193
             }
194 194
 
195
-            if (isset($_REQUEST['filter'])) {
195
+            if (isset($_REQUEST['filter'])) {
196 196
                 $output = $items;
197
-            } else {
197
+            } else {
198 198
                 $output .= $items;
199 199
             }
200 200
 
@@ -218,22 +218,22 @@  discard block
 block discarded – undo
218 218
 				ORDER BY t1.username ASC
219 219
 				' . $sqlLimit);
220 220
 
221
-            if ($modx->hasPermission('new_web_user')) {
221
+            if ($modx->hasPermission('new_web_user')) {
222 222
                 $output .= '<li><a id="a_87" href="index.php?a=87" target="main"><i class="fa fa-plus"></i>' . $_lang['new_web_user'] . '</a></li>';
223 223
             }
224 224
 
225
-            if ($count = $modx->db->getRecordCount($sql)) {
226
-                if ($count == $limit) {
225
+            if ($count = $modx->db->getRecordCount($sql)) {
226
+                if ($count == $limit) {
227 227
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
228 228
                 }
229
-                while ($row = $modx->db->getRow($sql)) {
229
+                while ($row = $modx->db->getRow($sql)) {
230 230
                     $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
231 231
                 }
232 232
             }
233 233
 
234
-            if (isset($_REQUEST['filter'])) {
234
+            if (isset($_REQUEST['filter'])) {
235 235
                 $output = $items;
236
-            } else {
236
+            } else {
237 237
                 $output .= $items;
238 238
             }
239 239
 
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
             $type = isset($_REQUEST['type']) && is_scalar($_REQUEST['type']) ? $modx->db->escape($_REQUEST['type']) : false;
248 248
             $contextmenu = '';
249 249
 
250
-            if ($role && $name && $type) {
251
-                switch ($type) {
250
+            if ($role && $name && $type) {
251
+                switch ($type) {
252 252
                     case 'Snippet':
253 253
                     case 'SnippetNoCache': {
254 254
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 						WHERE name="' . $name . '"
258 258
 						LIMIT 1');
259 259
 
260
-                        if ($modx->db->getRecordCount($sql)) {
260
+                        if ($modx->db->getRecordCount($sql)) {
261 261
                             $row = $modx->db->getRow($sql);
262 262
                             $contextmenu = array(
263 263
                                 'header' => array(
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
                                     'url' => "index.php?a=22&id=" . $row['id']
269 269
                                 )
270 270
                             );
271
-                            if (!empty($row['description'])) {
271
+                            if (!empty($row['description'])) {
272 272
                                 $contextmenu['seperator'] = '';
273 273
                                 $contextmenu['description'] = array(
274 274
                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
275 275
                                 );
276 276
                             }
277
-                        } else {
277
+                        } else {
278 278
                             $contextmenu = array(
279 279
                                 'header' => array(
280 280
                                     'innerHTML' => '<i class="fa fa-code"></i> ' . $name
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 						WHERE name="' . $name . '"
296 296
 						LIMIT 1');
297 297
 
298
-                        if ($modx->db->getRecordCount($sql)) {
298
+                        if ($modx->db->getRecordCount($sql)) {
299 299
                             $row = $modx->db->getRow($sql);
300 300
                             $contextmenu = array(
301 301
                                 'header' => array(
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
                                     'url' => "index.php?a=78&id=" . $row['id']
307 307
                                 )
308 308
                             );
309
-                            if (!empty($row['description'])) {
309
+                            if (!empty($row['description'])) {
310 310
                                 $contextmenu['seperator'] = '';
311 311
                                 $contextmenu['description'] = array(
312 312
                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
313 313
                                 );
314 314
                             }
315
-                        } else {
315
+                        } else {
316 316
                             $contextmenu = array(
317 317
                                 'header' => array(
318 318
                                     'innerHTML' => '<i class="fa fa-th-large"></i> ' . $name
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 						WHERE name="' . $name . '"
333 333
 						LIMIT 1');
334 334
 
335
-                        if ($modx->db->getRecordCount($sql)) {
335
+                        if ($modx->db->getRecordCount($sql)) {
336 336
                             $row = $modx->db->getRow($sql);
337 337
                             $contextmenu = array(
338 338
                                 'header' => array(
@@ -343,20 +343,20 @@  discard block
 block discarded – undo
343 343
                                     'url' => "index.php?a=78&id=" . $row['id']
344 344
                                 )
345 345
                             );
346
-                            if (!empty($row['description'])) {
346
+                            if (!empty($row['description'])) {
347 347
                                 $contextmenu['seperator'] = '';
348 348
                                 $contextmenu['description'] = array(
349 349
                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
350 350
                                 );
351 351
                             }
352
-                        } else {
352
+                        } else {
353 353
 
354 354
                             $sql = $modx->db->query('SELECT *
355 355
 							FROM ' . $modx->getFullTableName('site_snippets') . '
356 356
 							WHERE name="' . $name . '"
357 357
 							LIMIT 1');
358 358
 
359
-                            if ($modx->db->getRecordCount($sql)) {
359
+                            if ($modx->db->getRecordCount($sql)) {
360 360
                                 $row = $modx->db->getRow($sql);
361 361
                                 $contextmenu = array(
362 362
                                     'header' => array(
@@ -367,13 +367,13 @@  discard block
 block discarded – undo
367 367
                                         'url' => "index.php?a=22&id=" . $row['id']
368 368
                                     )
369 369
                                 );
370
-                                if (!empty($row['description'])) {
370
+                                if (!empty($row['description'])) {
371 371
                                     $contextmenu['seperator'] = '';
372 372
                                     $contextmenu['description'] = array(
373 373
                                         'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
374 374
                                     );
375 375
                                 }
376
-                            } else {
376
+                            } else {
377 377
                                 $contextmenu = array(
378 378
                                     'header' => array(
379 379
                                         'innerHTML' => '<i class="fa fa-code"></i> ' . $name
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
                             'alias_visible'
436 436
                         );
437 437
 
438
-                        if (in_array($name, $default_field)) {
438
+                        if (in_array($name, $default_field)) {
439 439
                             return;
440 440
                         }
441 441
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 						WHERE name="' . $name . '"
445 445
 						LIMIT 1');
446 446
 
447
-                        if ($modx->db->getRecordCount($sql)) {
447
+                        if ($modx->db->getRecordCount($sql)) {
448 448
                             $row = $modx->db->getRow($sql);
449 449
                             $contextmenu = array(
450 450
                                 'header' => array(
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
                                     'url' => "index.php?a=301&id=" . $row['id']
456 456
                                 )
457 457
                             );
458
-                            if (!empty($row['description'])) {
458
+                            if (!empty($row['description'])) {
459 459
                                 $contextmenu['seperator'] = '';
460 460
                                 $contextmenu['description'] = array(
461 461
                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
462 462
                                 );
463 463
                             }
464
-                        } else {
464
+                        } else {
465 465
                             $contextmenu = array(
466 466
                                 'header' => array(
467 467
                                     'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $name
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
         }
485 485
 
486 486
         case 'movedocument' : {
487
-            if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
487
+            if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
488 488
                 $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : '';
489 489
                 $parent = isset($_REQUEST['parent']) ? (int)$_REQUEST['parent'] : 0;
490 490
                 $menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0;
491 491
 
492 492
                 // set parent
493
-                if ($id && $parent >= 0) {
493
+                if ($id && $parent >= 0) {
494 494
 
495 495
                     // find older parent
496 496
                     $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id=' . $id));
@@ -501,31 +501,31 @@  discard block
 block discarded – undo
501 501
                         'new_parent'  => $parent,
502 502
                     ]);
503 503
 
504
-                    if (is_array($eventOut) && count($eventOut) > 0) {
504
+                    if (is_array($eventOut) && count($eventOut) > 0) {
505 505
                         $eventParent = array_pop($eventOut);
506 506
 
507
-                        if ($eventParent == $parentOld) {
507
+                        if ($eventParent == $parentOld) {
508 508
                             $json['errors'] = $_lang['error_movedocument2'];
509
-                        } else {
509
+                        } else {
510 510
                             $parent = $eventParent;
511 511
                         }
512 512
                     }
513 513
 
514
-                    if (empty($json['errors'])) {
514
+                    if (empty($json['errors'])) {
515 515
                         // check privileges user for move docs
516
-                        if (!empty($modx->config['tree_show_protected']) && $role != 1) {
516
+                        if (!empty($modx->config['tree_show_protected']) && $role != 1) {
517 517
                             $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN(' . $id . ',' . $parent . ',' . $parentOld . ')');
518
-                            if ($modx->db->getRecordCount($sql)) {
518
+                            if ($modx->db->getRecordCount($sql)) {
519 519
                                 $document_groups = array();
520
-                                while ($row = $modx->db->getRow($sql)) {
520
+                                while ($row = $modx->db->getRow($sql)) {
521 521
                                     $document_groups[$row['document']]['groups'][] = $row['document_group'];
522 522
                                 }
523
-                                foreach ($document_groups as $key => $value) {
524
-                                    if (($key == $parent || $key == $parentOld || $key == $id) && !in_array($role, $value['groups'])) {
523
+                                foreach ($document_groups as $key => $value) {
524
+                                    if (($key == $parent || $key == $parentOld || $key == $id) && !in_array($role, $value['groups'])) {
525 525
                                         $json['errors'] = $_lang["error_no_privileges"];
526 526
                                     }
527 527
                                 }
528
-                                if ($json['errors']) {
528
+                                if ($json['errors']) {
529 529
                                     header('content-type: application/json');
530 530
                                     echo json_encode($json, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);
531 531
                                     break;
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
                             }
534 534
                         }
535 535
 
536
-                        if ($parent == 0 && $parent != $parentOld && !$modx->config['udperms_allowroot'] && $role != 1) {
536
+                        if ($parent == 0 && $parent != $parentOld && !$modx->config['udperms_allowroot'] && $role != 1) {
537 537
                             $json['errors'] = $_lang["error_no_privileges"];
538
-                        } else {
538
+                        } else {
539 539
                             // set new parent
540 540
                             $modx->db->update(array(
541 541
                                 'parent' => $parent
@@ -545,13 +545,13 @@  discard block
 block discarded – undo
545 545
                                 'isfolder' => 1
546 546
                             ), $modx->getFullTableName('site_content'), 'id=' . $parent);
547 547
 
548
-                            if ($parent != $parentOld) {
548
+                            if ($parent != $parentOld) {
549 549
                                 // check children docs and set parent isfolder
550
-                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
550
+                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
551 551
                                     $modx->db->update(array(
552 552
                                         'isfolder' => 1
553 553
                                     ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
554
-                                } else {
554
+                                } else {
555 555
                                     $modx->db->update(array(
556 556
                                         'isfolder' => 0
557 557
                                     ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
@@ -559,16 +559,16 @@  discard block
 block discarded – undo
559 559
                             }
560 560
 
561 561
                             // set menuindex
562
-                            if (!empty($menuindex)) {
562
+                            if (!empty($menuindex)) {
563 563
                                 $menuindex = explode(',', $menuindex);
564
-                                foreach ($menuindex as $key => $value) {
564
+                                foreach ($menuindex as $key => $value) {
565 565
                                     $modx->db->query('UPDATE ' . $modx->getFullTableName('site_content') . ' SET menuindex=' . $key . ' WHERE id=' . $value);
566 566
                                 }
567
-                            } else {
567
+                            } else {
568 568
                                 // TODO: max(*) menuindex
569 569
                             }
570 570
 
571
-                            if (!$json['errors']) {
571
+                            if (!$json['errors']) {
572 572
                                 $json['success'] = $_lang["actioncomplete"];
573 573
 
574 574
                                 $modx->invokeEvent('onAfterMoveDocument', [
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
                         }
581 581
                     }
582 582
                 }
583
-            } else {
583
+            } else {
584 584
                 $json['errors'] = $_lang["error_no_privileges"];
585 585
             }
586 586
 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 
596 596
             $output = !!$modx->elementIsLocked($type, $id, true);
597 597
 
598
-            if (!$output) {
598
+            if (!$output) {
599 599
                 $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
600 600
                 $docgrp_cond = $docgrp ? ' OR dg.document_group IN (' . $docgrp . ')' : '';
601 601
                 $sql = '
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
                     LEFT JOIN ' . $modx->getFullTableName('document_groups') . ' dg ON dg.document=sc.id
605 605
                     WHERE sc.id=' . $id . ' GROUP BY sc.id';
606 606
                 $sql = $modx->db->query($sql);
607
-                if ($modx->db->getRecordCount($sql)) {
607
+                if ($modx->db->getRecordCount($sql)) {
608 608
                     $row = $modx->db->getRow($sql);
609 609
                     $output = !!$row['locked'];
610 610
                 }
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
 	    case 'publish.res': {
620 620
 		    $published = getDocumentTv('published');
621 621
 		    $state = $published == 0 ? 1 : 0;
622
-		    if($state) {
622
+		    if($state) {
623 623
 			    require_once('../../../processors/publish_content.processor.php');
624
-		    } else {
624
+		    } else {
625 625
 			    require_once('../../../processors/unpublish_content.processor.php');
626 626
 		    }
627 627
 		    $json['result'] = $state == 1 ? 'publish' : 'unpublish';
@@ -630,22 +630,27 @@  discard block
 block discarded – undo
630 630
 	    case 'delete.res': {
631 631
 		    $deleted = getDocumentTv('deleted');
632 632
 		    $state = $deleted == 0 ? 1 : 0;
633
-		    if($state) {
633
+		    if($state) {
634 634
 			    require_once('../../../processors/delete_content.processor.php');
635
-		    } else {
635
+		    } else {
636 636
 			    require_once('../../../processors/undelete_content.processor.php');
637 637
 		    }
638 638
 		    $json['result'] = $state == 1 ? 'delete' : 'undelete';
639 639
 			break;
640 640
 		}
641 641
     }
642
-    if(!empty($json)) $modx->jsonResponse($json);
643
-}
642
+    if(!empty($json)) {
643
+        $modx->jsonResponse($json);
644
+    }
645
+    }
644 646
 
645
-function getDocumentTv($tv) {
647
+function getDocumentTv($tv)
648
+{
646 649
 	global $modx, $_lang;
647 650
 	$modx->setAjaxMode(true);
648 651
 	$id = isset($_REQUEST['id'])? intval($_REQUEST['id']) : 0;
649
-	if($id==0) $modx->webAlertAndQuit($_lang["error_no_id"]);
652
+	if($id==0) {
653
+	    $modx->webAlertAndQuit($_lang["error_no_id"]);
654
+	}
650 655
 	return $modx->db->getValue($modx->db->select($tv, $modx->getFullTableName('site_content'), 'id=' . $id));
651 656
 }
652 657
\ No newline at end of file
Please login to merge, or discard this patch.