Completed
Push — develop ( ef95a6...f399f2 )
by Maxim
06:16
created
index.php 3 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
 	include_once($autoloader);
51 51
 }
52 52
 
53
-if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
53
+if (!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
54 54
 
55
-$base_path = str_replace('\\','/',dirname(__FILE__)) . '/';
56
-if(is_file($base_path . 'assets/cache/siteManager.php'))
57
-    include_once($base_path . 'assets/cache/siteManager.php');
58
-if(!defined('MGR_DIR') && is_dir("{$base_path}manager"))
55
+$base_path = str_replace('\\', '/', dirname(__FILE__)).'/';
56
+if (is_file($base_path.'assets/cache/siteManager.php'))
57
+    include_once($base_path.'assets/cache/siteManager.php');
58
+if (!defined('MGR_DIR') && is_dir("{$base_path}manager"))
59 59
 	define('MGR_DIR', 'manager');
60
-if(is_file($base_path . 'assets/cache/siteHostnames.php'))
61
-    include_once($base_path . 'assets/cache/siteHostnames.php');
62
-if(!defined('MODX_SITE_HOSTNAMES'))
60
+if (is_file($base_path.'assets/cache/siteHostnames.php'))
61
+    include_once($base_path.'assets/cache/siteHostnames.php');
62
+if (!defined('MODX_SITE_HOSTNAMES'))
63 63
 	define('MODX_SITE_HOSTNAMES', '');
64 64
 
65 65
 // get start time
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 // set some settings, and address some IE issues
72 72
 @ini_set('url_rewriter.tags', '');
73 73
 @ini_set('session.use_trans_sid', 0);
74
-@ini_set('session.use_only_cookies',1);
74
+@ini_set('session.use_only_cookies', 1);
75 75
 session_cache_limiter('');
76 76
 header('P3P: CP="NOI NID ADMa OUR IND UNI COM NAV"'); // header for weird cookie stuff. Blame IE.
77 77
 header('Cache-Control: private, must-revalidate');
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  */
84 84
 
85 85
 define('IN_PARSER_MODE', true);
86
-if ( ! defined('IN_MANAGER_MODE')) {
86
+if (!defined('IN_MANAGER_MODE')) {
87 87
 	define('IN_MANAGER_MODE', false);
88 88
 }
89 89
 if (!defined('MODX_API_MODE')) {
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 }
92 92
 
93 93
 // get the required includes
94
-if(!isset($database_user) || $database_user=="") {
94
+if (!isset($database_user) || $database_user == "") {
95 95
 	$rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php');
96 96
 	// Be sure config.inc.php is there and that it contains some important values
97
-	if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
97
+	if (!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
98 98
 		readfile('install/not_installed.tpl');
99 99
 		exit;
100 100
 	}
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 $modx->stopOnNotice = false;
126 126
 
127 127
 // Don't show PHP errors to the public
128
-if(!isset($_SESSION['mgrValidated']) || !$_SESSION['mgrValidated']) {
129
-    @ini_set("display_errors","0");
128
+if (!isset($_SESSION['mgrValidated']) || !$_SESSION['mgrValidated']) {
129
+    @ini_set("display_errors", "0");
130 130
 }
131 131
 
132
-if(MODX_CLI){
132
+if (MODX_CLI) {
133 133
     @set_time_limit(0);
134
-    @ini_set('max_execution_time',0);
134
+    @ini_set('max_execution_time', 0);
135 135
 }
136 136
 
137 137
 // execute the parser if index.php was not included
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,17 +50,23 @@  discard block
 block discarded – undo
50 50
 	include_once($autoloader);
51 51
 }
52 52
 
53
-if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
53
+if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) {
54
+    $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
55
+}
54 56
 
55 57
 $base_path = str_replace('\\','/',dirname(__FILE__)) . '/';
56
-if(is_file($base_path . 'assets/cache/siteManager.php'))
58
+if(is_file($base_path . 'assets/cache/siteManager.php')) {
57 59
     include_once($base_path . 'assets/cache/siteManager.php');
58
-if(!defined('MGR_DIR') && is_dir("{$base_path}manager"))
60
+}
61
+if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) {
59 62
 	define('MGR_DIR', 'manager');
60
-if(is_file($base_path . 'assets/cache/siteHostnames.php'))
63
+}
64
+if(is_file($base_path . 'assets/cache/siteHostnames.php')) {
61 65
     include_once($base_path . 'assets/cache/siteHostnames.php');
62
-if(!defined('MODX_SITE_HOSTNAMES'))
66
+}
67
+if(!defined('MODX_SITE_HOSTNAMES')) {
63 68
 	define('MODX_SITE_HOSTNAMES', '');
69
+}
64 70
 
65 71
 // get start time
66 72
 $mstart = memory_get_usage();
@@ -129,7 +135,7 @@  discard block
 block discarded – undo
129 135
     @ini_set("display_errors","0");
130 136
 }
131 137
 
132
-if(MODX_CLI){
138
+if(MODX_CLI) {
133 139
     @set_time_limit(0);
134 140
     @ini_set('max_execution_time',0);
135 141
 }
Please login to merge, or discard this patch.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 $autoloader = __DIR__.'/vendor/autoload.php';
49 49
 if (file_exists($autoloader) && is_readable($autoloader)) {
50
-	include_once($autoloader);
50
+    include_once($autoloader);
51 51
 }
52 52
 
53 53
 if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 if(is_file($base_path . 'assets/cache/siteManager.php'))
57 57
     include_once($base_path . 'assets/cache/siteManager.php');
58 58
 if(!defined('MGR_DIR') && is_dir("{$base_path}manager"))
59
-	define('MGR_DIR', 'manager');
59
+    define('MGR_DIR', 'manager');
60 60
 if(is_file($base_path . 'assets/cache/siteHostnames.php'))
61 61
     include_once($base_path . 'assets/cache/siteHostnames.php');
62 62
 if(!defined('MODX_SITE_HOSTNAMES'))
63
-	define('MODX_SITE_HOSTNAMES', '');
63
+    define('MODX_SITE_HOSTNAMES', '');
64 64
 
65 65
 // get start time
66 66
 $mstart = memory_get_usage();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 define('IN_PARSER_MODE', true);
86 86
 if ( ! defined('IN_MANAGER_MODE')) {
87
-	define('IN_MANAGER_MODE', false);
87
+    define('IN_MANAGER_MODE', false);
88 88
 }
89 89
 if (!defined('MODX_API_MODE')) {
90 90
     define('MODX_API_MODE', false);
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 
93 93
 // get the required includes
94 94
 if(!isset($database_user) || $database_user=="") {
95
-	$rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php');
96
-	// Be sure config.inc.php is there and that it contains some important values
97
-	if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
98
-		readfile('install/not_installed.tpl');
99
-		exit;
100
-	}
95
+    $rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php');
96
+    // Be sure config.inc.php is there and that it contains some important values
97
+    if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
98
+        readfile('install/not_installed.tpl');
99
+        exit;
100
+    }
101 101
 }
102 102
 
103 103
 // start session
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 
106 106
 // initiate a new document parser
107 107
 if (isset($coreClass) && class_exists($coreClass)) {
108
-	$modx = new $coreClass;
108
+    $modx = new $coreClass;
109 109
 }
110 110
 if (!isset($modx) || !($modx instanceof \DocumentParser)) {
111
-	include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php');
112
-	$modx = DocumentParser::getInstance();
111
+    include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php');
112
+    $modx = DocumentParser::getInstance();
113 113
 }
114 114
 
115 115
 // set some parser options
Please login to merge, or discard this patch.
manager/frames/nodes.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@
 block discarded – undo
18 18
     exit('send some data');
19 19
 } //??
20 20
 
21
-$indent = (int)$_REQUEST['indent'];
22
-$parent = (int)$_REQUEST['parent'];
23
-$expandAll = (int)$_REQUEST['expandAll'];
21
+$indent = (int) $_REQUEST['indent'];
22
+$parent = (int) $_REQUEST['parent'];
23
+$expandAll = (int) $_REQUEST['expandAll'];
24 24
 $output = '';
25 25
 $hereid = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? $_REQUEST['id'] : '';
26 26
 
Please login to merge, or discard this patch.
manager/frames/nodes.functions.inc.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
         case 'publishedon':
39 39
         case 'pub_date':
40 40
         case 'unpub_date':
41
-            $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']);
41
+            $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.'.$_SESSION['tree_sortby'], 'sc.'.$_SESSION['tree_sortby']);
42 42
             break;
43 43
         default:
44
-            $sortby = 'sc.' . $_SESSION['tree_sortby'];
44
+            $sortby = 'sc.'.$_SESSION['tree_sortby'];
45 45
     };
46 46
 
47
-    $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']);
47
+    $orderby = $modx->db->escape($sortby.' '.$_SESSION['tree_sortdir']);
48 48
 
49 49
     // Folder sorting gets special setup ;) Add menuindex and pagetitle
50 50
     if ($_SESSION['tree_sortby'] == 'isfolder') {
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
     $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
59 59
     $showProtected = false;
60 60
     if (isset ($modx->config['tree_show_protected'])) {
61
-        $showProtected = (boolean)$modx->config['tree_show_protected'];
61
+        $showProtected = (boolean) $modx->config['tree_show_protected'];
62 62
     }
63
-    $mgrRole = (isset ($_SESSION['mgrRole']) && (string)$_SESSION['mgrRole'] === '1') ? '1' : '0';
63
+    $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0';
64 64
     if ($showProtected == false) {
65
-        $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))");
65
+        $access = "AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))");
66 66
     } else {
67 67
         $access = '';
68 68
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         }
99 99
 
100 100
         $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : '';
101
-        $pageIdDisplay = '<small>(' . ($modx_textdir ? '&rlm;' : '') . $row['id'] . ')</small>';
101
+        $pageIdDisplay = '<small>('.($modx_textdir ? '&rlm;' : '').$row['id'].')</small>';
102 102
 
103 103
         // Prepare displaying user-locks
104 104
         $lockedByUser = '';
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                     'element_type' => $_lang["lock_element_type_7"],
110 110
                     'lasthit_df' => $rowLock['lasthit_df']
111 111
                 ));
112
-                $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>';
112
+                $lockedByUser = '<span title="'.$title.'" class="editResource">'.$_style['tree_preview_resource'].'</span>';
113 113
             } else {
114 114
                 $title = $modx->parseText($_lang["lock_element_locked_by"], array(
115 115
                     'element_type' => $_lang["lock_element_type_7"],
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
                     'lasthit_df' => $rowLock['lasthit_df']
118 118
                 ));
119 119
                 if ($modx->hasPermission('remove_locks')) {
120
-                    $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>';
120
+                    $lockedByUser = '<span onclick="modx.tree.unlockElement(7, '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>';
121 121
                 } else {
122
-                    $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>';
122
+                    $lockedByUser = '<span title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>';
123 123
                 }
124 124
             }
125 125
         }
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 
129 129
         $title = '';
130 130
         if (isDateNode($nodeNameSource)) {
131
-            $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]';
131
+            $title = $_lang['pagetitle'].': '.$row['pagetitle'].'[+lf+]';
132 132
         }
133
-        $title .= $_lang['id'] . ': ' . $row['id'];
134
-        $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle'];
135
-        $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex'];
136
-        $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-');
137
-        $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename'];
138
-        $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']);
139
-        $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']);
140
-        $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']);
141
-        $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']);
142
-        $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']);
143
-        $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']);
144
-        $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']);
133
+        $title .= $_lang['id'].': '.$row['id'];
134
+        $title .= '[+lf+]'.$_lang['resource_opt_menu_title'].': '.$row['menutitle'];
135
+        $title .= '[+lf+]'.$_lang['resource_opt_menu_index'].': '.$row['menuindex'];
136
+        $title .= '[+lf+]'.$_lang['alias'].': '.(!empty($row['alias']) ? $row['alias'] : '-');
137
+        $title .= '[+lf+]'.$_lang['template'].': '.$row['templatename'];
138
+        $title .= '[+lf+]'.$_lang['publish_date'].': '.$modx->toDateFormat($row['pub_date']);
139
+        $title .= '[+lf+]'.$_lang['unpublish_date'].': '.$modx->toDateFormat($row['unpub_date']);
140
+        $title .= '[+lf+]'.$_lang['page_data_web_access'].': '.($row['privateweb'] ? $_lang['private'] : $_lang['public']);
141
+        $title .= '[+lf+]'.$_lang['page_data_mgr_access'].': '.($row['privatemgr'] ? $_lang['private'] : $_lang['public']);
142
+        $title .= '[+lf+]'.$_lang['resource_opt_richtext'].': '.($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']);
143
+        $title .= '[+lf+]'.$_lang['page_data_searchable'].': '.($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']);
144
+        $title .= '[+lf+]'.$_lang['page_data_cacheable'].': '.($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']);
145 145
         $title = $modx->htmlspecialchars($title);
146
-        $title = str_replace('[+lf+]', ' &#13;', $title);   // replace line-breaks with empty space as fall-back
146
+        $title = str_replace('[+lf+]', ' &#13;', $title); // replace line-breaks with empty space as fall-back
147 147
 
148 148
         $data = array(
149 149
             'id' => $row['id'],
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
             }
228 228
 
229 229
             if ($ph['contextmenu']) {
230
-                $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
230
+                $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
231 231
             }
232 232
 
233 233
             if ($_SESSION['tree_show_only_folders']) {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                     }
286 286
 
287 287
                     if ($ph['contextmenu']) {
288
-                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
288
+                        $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
289 289
                     }
290 290
 
291 291
                     $node .= $modx->parseText($tpl, $ph);
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                     }
324 324
 
325 325
                     if ($ph['contextmenu']) {
326
-                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
326
+                        $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
327 327
                     }
328 328
 
329 329
                     $node .= $modx->parseText($tpl, $ph);
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
                     }
375 375
 
376 376
                     if ($ph['contextmenu']) {
377
-                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
377
+                        $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
378 378
                     }
379 379
 
380 380
                     $node .= $modx->parseText($tpl, $ph);
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                     }
417 417
 
418 418
                     if ($ph['contextmenu']) {
419
-                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
419
+                        $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
420 420
                     }
421 421
 
422 422
                     $node .= $modx->parseText($tpl, $ph);
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
                     $nodetitle .= $modx->config['friendly_url_suffix'];
494 494
                 }
495 495
             }
496
-            $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle;
496
+            $nodetitle = $modx->config['friendly_url_prefix'].$nodetitle;
497 497
             break;
498 498
         case 'pagetitle':
499 499
             $nodetitle = $row['pagetitle'];
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 {
554 554
     $modx = evolutionCMS();
555 555
 
556
-    return (int)$modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' '));
556
+    return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM '.$modx->getFullTableName('site_content').' WHERE parent='.$parent.' AND isfolder='.$isfolder.' '));
557 557
 }
558 558
 
559 559
 /**
Please login to merge, or discard this patch.
manager/actions/mutate_content.dynamic.php 3 patches
Indentation   +411 added lines, -411 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
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
 /********************/
@@ -12,30 +12,30 @@  discard block
 block discarded – undo
12 12
 
13 13
 // check permissions
14 14
 switch($modx->manager->action) {
15
-	case 27:
16
-		if(!$modx->hasPermission('edit_document')) {
17
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
18
-		}
19
-		break;
20
-	case 85:
21
-	case 72:
22
-	case 4:
23
-		if(!$modx->hasPermission('new_document')) {
24
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
25
-		} elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
26
-			// check user has permissions for parent
27
-			include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
28
-			$udperms = new udperms();
29
-			$udperms->user = $modx->getLoginUserID();
30
-			$udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid'];
31
-			$udperms->role = $_SESSION['mgrRole'];
32
-			if(!$udperms->checkPermissions()) {
33
-				$modx->webAlertAndQuit($_lang["access_permission_denied"]);
34
-			}
35
-		}
36
-		break;
37
-	default:
38
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
+    case 27:
16
+        if(!$modx->hasPermission('edit_document')) {
17
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
18
+        }
19
+        break;
20
+    case 85:
21
+    case 72:
22
+    case 4:
23
+        if(!$modx->hasPermission('new_document')) {
24
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
25
+        } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
26
+            // check user has permissions for parent
27
+            include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
28
+            $udperms = new udperms();
29
+            $udperms->user = $modx->getLoginUserID();
30
+            $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid'];
31
+            $udperms->role = $_SESSION['mgrRole'];
32
+            if(!$udperms->checkPermissions()) {
33
+                $modx->webAlertAndQuit($_lang["access_permission_denied"]);
34
+            }
35
+        }
36
+        break;
37
+    default:
38
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
39 39
 }
40 40
 
41 41
 $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
 $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars');
55 55
 
56 56
 if($modx->manager->action == 27) {
57
-	//editing an existing document
58
-	// check permissions on the document
59
-	include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
60
-	$udperms = new udperms();
61
-	$udperms->user = $modx->getLoginUserID();
62
-	$udperms->document = $id;
63
-	$udperms->role = $_SESSION['mgrRole'];
64
-
65
-	if(!$udperms->checkPermissions()) {
66
-		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
67
-	}
57
+    //editing an existing document
58
+    // check permissions on the document
59
+    include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
60
+    $udperms = new udperms();
61
+    $udperms->user = $modx->getLoginUserID();
62
+    $udperms->document = $id;
63
+    $udperms->role = $_SESSION['mgrRole'];
64
+
65
+    if(!$udperms->checkPermissions()) {
66
+        $modx->webAlertAndQuit($_lang["access_permission_denied"]);
67
+    }
68 68
 }
69 69
 
70 70
 // check to see if resource isn't locked
71 71
 if($lockedEl = $modx->elementIsLocked(7, $id)) {
72
-	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource']));
72
+    $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource']));
73 73
 }
74 74
 // end check for lock
75 75
 
@@ -78,74 +78,74 @@  discard block
 block discarded – undo
78 78
 
79 79
 // get document groups for current user
80 80
 if($_SESSION['mgrDocgroups']) {
81
-	$docgrp = implode(',', $_SESSION['mgrDocgroups']);
81
+    $docgrp = implode(',', $_SESSION['mgrDocgroups']);
82 82
 }
83 83
 
84 84
 if(!empty ($id)) {
85
-	$access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']);
86
-	if($docgrp) {
87
-		$access .= " OR dg.document_group IN ({$docgrp})";
88
-	}
89
-	$rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})");
90
-	$content = array();
91
-	$content = $modx->db->getRow($rs);
92
-	$modx->documentObject = &$content;
93
-	if(!$content) {
94
-		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
95
-	}
96
-	$_SESSION['itemname'] = $content['pagetitle'];
85
+    $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']);
86
+    if($docgrp) {
87
+        $access .= " OR dg.document_group IN ({$docgrp})";
88
+    }
89
+    $rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})");
90
+    $content = array();
91
+    $content = $modx->db->getRow($rs);
92
+    $modx->documentObject = &$content;
93
+    if(!$content) {
94
+        $modx->webAlertAndQuit($_lang["access_permission_denied"]);
95
+    }
96
+    $_SESSION['itemname'] = $content['pagetitle'];
97 97
 } else {
98
-	$content = array();
98
+    $content = array();
99 99
 
100
-	if(isset($_REQUEST['newtemplate'])) {
101
-		$content['template'] = $_REQUEST['newtemplate'];
102
-	} else {
103
-		$content['template'] = getDefaultTemplate();
104
-	}
100
+    if(isset($_REQUEST['newtemplate'])) {
101
+        $content['template'] = $_REQUEST['newtemplate'];
102
+    } else {
103
+        $content['template'] = getDefaultTemplate();
104
+    }
105 105
 
106
-	$_SESSION['itemname'] = $_lang["new_resource"];
106
+    $_SESSION['itemname'] = $_lang["new_resource"];
107 107
 }
108 108
 
109 109
 // restore saved form
110 110
 $formRestored = $modx->manager->loadFormValues();
111 111
 if(isset($_REQUEST['newtemplate'])) {
112
-	$formRestored = true;
112
+    $formRestored = true;
113 113
 }
114 114
 
115 115
 // retain form values if template was changed
116 116
 // edited to convert pub_date and unpub_date
117 117
 // sottwell 02-09-2006
118 118
 if($formRestored == true) {
119
-	$content = array_merge($content, $_POST);
120
-	$content['content'] = $_POST['ta'];
121
-	if(empty ($content['pub_date'])) {
122
-		unset ($content['pub_date']);
123
-	} else {
124
-		$content['pub_date'] = $modx->toTimeStamp($content['pub_date']);
125
-	}
126
-	if(empty ($content['unpub_date'])) {
127
-		unset ($content['unpub_date']);
128
-	} else {
129
-		$content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']);
130
-	}
119
+    $content = array_merge($content, $_POST);
120
+    $content['content'] = $_POST['ta'];
121
+    if(empty ($content['pub_date'])) {
122
+        unset ($content['pub_date']);
123
+    } else {
124
+        $content['pub_date'] = $modx->toTimeStamp($content['pub_date']);
125
+    }
126
+    if(empty ($content['unpub_date'])) {
127
+        unset ($content['unpub_date']);
128
+    } else {
129
+        $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']);
130
+    }
131 131
 }
132 132
 
133 133
 // increase menu index if this is a new document
134 134
 if(!isset ($_REQUEST['id'])) {
135
-	if(!isset ($modx->config['auto_menuindex'])) {
136
-		$modx->config['auto_menuindex'] = 1;
137
-	}
138
-	if($modx->config['auto_menuindex']) {
139
-		$pid = (int)$_REQUEST['pid'];
140
-		$rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'");
141
-		$content['menuindex'] = $modx->db->getValue($rs);
142
-	} else {
143
-		$content['menuindex'] = 0;
144
-	}
135
+    if(!isset ($modx->config['auto_menuindex'])) {
136
+        $modx->config['auto_menuindex'] = 1;
137
+    }
138
+    if($modx->config['auto_menuindex']) {
139
+        $pid = (int)$_REQUEST['pid'];
140
+        $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'");
141
+        $content['menuindex'] = $modx->db->getValue($rs);
142
+    } else {
143
+        $content['menuindex'] = 0;
144
+    }
145 145
 }
146 146
 
147 147
 if(isset ($_POST['which_editor'])) {
148
-	$modx->config['which_editor'] = $_POST['which_editor'];
148
+    $modx->config['which_editor'] = $_POST['which_editor'];
149 149
 }
150 150
 
151 151
 // Add lock-element JS-Script
@@ -545,23 +545,23 @@  discard block
 block discarded – undo
545 545
 
546 546
 	<form name="mutate" id="mutate" class="content" method="post" enctype="multipart/form-data" action="index.php" onsubmit="documentDirty=false;">
547 547
 		<?php
548
-		// invoke OnDocFormPrerender event
549
-		$evtOut = $modx->invokeEvent('OnDocFormPrerender', array(
550
-			'id' => $id,
551
-			'template' => $content['template']
552
-		));
553
-
554
-		if(is_array($evtOut)) {
555
-			echo implode('', $evtOut);
556
-		}
557
-
558
-		/*************************/
559
-		$dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : '';
560
-		$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon';
561
-		$page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : '';
562
-		/*************************/
563
-
564
-		?>
548
+        // invoke OnDocFormPrerender event
549
+        $evtOut = $modx->invokeEvent('OnDocFormPrerender', array(
550
+            'id' => $id,
551
+            'template' => $content['template']
552
+        ));
553
+
554
+        if(is_array($evtOut)) {
555
+            echo implode('', $evtOut);
556
+        }
557
+
558
+        /*************************/
559
+        $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : '';
560
+        $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon';
561
+        $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : '';
562
+        /*************************/
563
+
564
+        ?>
565 565
 		<input type="hidden" name="a" value="5" />
566 566
 		<input type="hidden" name="id" value="<?= $content['id'] ?>" />
567 567
 		<input type="hidden" name="mode" value="<?= $modx->manager->action ?>" />
@@ -576,54 +576,54 @@  discard block
 block discarded – undo
576 576
 
577 577
 			<h1>
578 578
 				<i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) {
579
-					echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>';
580
-				} else {
581
-				    if ($modx->manager->action == '4') {
579
+                    echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>';
580
+                } else {
581
+                    if ($modx->manager->action == '4') {
582 582
                         echo $_lang['add_resource'];
583 583
                     } else if ($modx->manager->action == '72') {
584 584
                         echo $_lang['add_weblink'];
585 585
                     } else {
586 586
                         echo $_lang['create_resource_title'];
587 587
                     }
588
-				} ?>
588
+                } ?>
589 589
 			</h1>
590 590
 
591 591
 			<?= $_style['actionbuttons']['dynamic']['document'] ?>
592 592
 
593 593
 			<?php
594
-			// breadcrumbs
595
-			if($modx->config['use_breadcrumbs']) {
596
-				$temp = array();
597
-				$title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title'];
598
-
599
-				if(isset($_REQUEST['id']) && $content['parent'] != 0) {
600
-					$bID = (int) $_REQUEST['id'];
601
-					$temp = $modx->getParentIds($bID);
602
-				} else if(isset($_REQUEST['pid'])) {
603
-					$bID = (int) $_REQUEST['pid'];
604
-					$temp = $modx->getParentIds($bID);
605
-					array_unshift($temp, $bID);
606
-				}
607
-
608
-				if($temp) {
609
-					$parents = implode(',', $temp);
610
-
611
-					if(!empty($parents)) {
612
-						$where = "FIND_IN_SET(id,'{$parents}') DESC";
613
-						$rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where);
614
-						while($row = $modx->db->getRow($rs)) {
615
-							$out .= '<li class="breadcrumbs__li">
594
+            // breadcrumbs
595
+            if($modx->config['use_breadcrumbs']) {
596
+                $temp = array();
597
+                $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title'];
598
+
599
+                if(isset($_REQUEST['id']) && $content['parent'] != 0) {
600
+                    $bID = (int) $_REQUEST['id'];
601
+                    $temp = $modx->getParentIds($bID);
602
+                } else if(isset($_REQUEST['pid'])) {
603
+                    $bID = (int) $_REQUEST['pid'];
604
+                    $temp = $modx->getParentIds($bID);
605
+                    array_unshift($temp, $bID);
606
+                }
607
+
608
+                if($temp) {
609
+                    $parents = implode(',', $temp);
610
+
611
+                    if(!empty($parents)) {
612
+                        $where = "FIND_IN_SET(id,'{$parents}') DESC";
613
+                        $rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where);
614
+                        while($row = $modx->db->getRow($rs)) {
615
+                            $out .= '<li class="breadcrumbs__li">
616 616
                                 <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a>
617 617
                                 <span class="breadcrumbs__sep">&gt;</span>
618 618
                             </li>';
619
-						}
620
-					}
621
-				}
619
+                        }
620
+                    }
621
+                }
622 622
 
623
-				$out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>';
624
-				echo '<ul class="breadcrumbs">' . $out . '</ul>';
625
-			}
626
-			?>
623
+                $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>';
624
+                echo '<ul class="breadcrumbs">' . $out . '</ul>';
625
+            }
626
+            ?>
627 627
 
628 628
 			<!-- start main wrapper -->
629 629
 			<div class="sectionBody">
@@ -635,13 +635,13 @@  discard block
 block discarded – undo
635 635
 
636 636
 					<!-- General -->
637 637
 					<?php
638
-					$evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array(
639
-						'id' => $id
640
-					));
641
-					if(is_array($evtOut)) {
642
-						echo implode('', $evtOut);
643
-					} else {
644
-						?>
638
+                    $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array(
639
+                        'id' => $id
640
+                    ));
641
+                    if(is_array($evtOut)) {
642
+                        echo implode('', $evtOut);
643
+                    } else {
644
+                        ?>
645 645
 						<div class="tab-page" id="tabGeneral">
646 646
 							<h2 class="tab"><?= $_lang['settings_general'] ?></h2>
647 647
 							<script type="text/javascript">tpSettings.addTabPage(document.getElementById("tabGeneral"));</script>
@@ -726,36 +726,36 @@  discard block
 block discarded – undo
726 726
 										<select id="template" name="template" class="inputBox" onchange="templateWarning();">
727 727
 											<option value="0">(blank)</option>
728 728
 											<?php
729
-											$field = "t.templatename, t.selectable, t.id, c.category";
730
-											$from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id";
731
-											$rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC');
732
-											$currentCategory = '';
733
-											while($row = $modx->db->getRow($rs)) {
734
-												if($row['selectable'] != 1 && $row['id'] != $content['template']) {
735
-													continue;
736
-												};
737
-												// Skip if not selectable but show if selected!
738
-												$thisCategory = $row['category'];
739
-												if($thisCategory == null) {
740
-													$thisCategory = $_lang["no_category"];
741
-												}
742
-												if($thisCategory != $currentCategory) {
743
-													if($closeOptGroup) {
744
-														echo "\t\t\t\t\t</optgroup>\n";
745
-													}
746
-													echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n";
747
-													$closeOptGroup = true;
748
-												}
729
+                                            $field = "t.templatename, t.selectable, t.id, c.category";
730
+                                            $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id";
731
+                                            $rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC');
732
+                                            $currentCategory = '';
733
+                                            while($row = $modx->db->getRow($rs)) {
734
+                                                if($row['selectable'] != 1 && $row['id'] != $content['template']) {
735
+                                                    continue;
736
+                                                };
737
+                                                // Skip if not selectable but show if selected!
738
+                                                $thisCategory = $row['category'];
739
+                                                if($thisCategory == null) {
740
+                                                    $thisCategory = $_lang["no_category"];
741
+                                                }
742
+                                                if($thisCategory != $currentCategory) {
743
+                                                    if($closeOptGroup) {
744
+                                                        echo "\t\t\t\t\t</optgroup>\n";
745
+                                                    }
746
+                                                    echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n";
747
+                                                    $closeOptGroup = true;
748
+                                                }
749 749
 
750
-												$selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : '';
750
+                                                $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : '';
751 751
 
752
-												echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n";
753
-												$currentCategory = $thisCategory;
754
-											}
755
-											if($thisCategory != '') {
756
-												echo "\t\t\t\t\t</optgroup>\n";
757
-											}
758
-											?>
752
+                                                echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n";
753
+                                                $currentCategory = $thisCategory;
754
+                                            }
755
+                                            if($thisCategory != '') {
756
+                                                echo "\t\t\t\t\t</optgroup>\n";
757
+                                            }
758
+                                            ?>
759 759
 										</select>
760 760
 									</td>
761 761
 								</tr>
@@ -795,37 +795,37 @@  discard block
 block discarded – undo
795 795
 									</td>
796 796
 									<td valign="top">
797 797
 										<?php
798
-										$parentlookup = false;
799
-										if(isset ($_REQUEST['id'])) {
800
-											if($content['parent'] == 0) {
801
-												$parentname = $site_name;
802
-											} else {
803
-												$parentlookup = $content['parent'];
804
-											}
805
-										} elseif(isset ($_REQUEST['pid'])) {
806
-											if($_REQUEST['pid'] == 0) {
807
-												$parentname = $site_name;
808
-											} else {
809
-												$parentlookup = $_REQUEST['pid'];
810
-											}
811
-										} elseif(isset($_POST['parent'])) {
812
-											if($_POST['parent'] == 0) {
813
-												$parentname = $site_name;
814
-											} else {
815
-												$parentlookup = $_POST['parent'];
816
-											}
817
-										} else {
818
-											$parentname = $site_name;
819
-											$content['parent'] = 0;
820
-										}
821
-										if($parentlookup !== false && is_numeric($parentlookup)) {
822
-											$rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'");
823
-											$parentname = $modx->db->getValue($rs);
824
-											if(!$parentname) {
825
-												$modx->webAlertAndQuit($_lang["error_no_parent"]);
826
-											}
827
-										}
828
-										?>
798
+                                        $parentlookup = false;
799
+                                        if(isset ($_REQUEST['id'])) {
800
+                                            if($content['parent'] == 0) {
801
+                                                $parentname = $site_name;
802
+                                            } else {
803
+                                                $parentlookup = $content['parent'];
804
+                                            }
805
+                                        } elseif(isset ($_REQUEST['pid'])) {
806
+                                            if($_REQUEST['pid'] == 0) {
807
+                                                $parentname = $site_name;
808
+                                            } else {
809
+                                                $parentlookup = $_REQUEST['pid'];
810
+                                            }
811
+                                        } elseif(isset($_POST['parent'])) {
812
+                                            if($_POST['parent'] == 0) {
813
+                                                $parentname = $site_name;
814
+                                            } else {
815
+                                                $parentlookup = $_POST['parent'];
816
+                                            }
817
+                                        } else {
818
+                                            $parentname = $site_name;
819
+                                            $content['parent'] = 0;
820
+                                        }
821
+                                        if($parentlookup !== false && is_numeric($parentlookup)) {
822
+                                            $rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'");
823
+                                            $parentname = $modx->db->getValue($rs);
824
+                                            if(!$parentname) {
825
+                                                $modx->webAlertAndQuit($_lang["error_no_parent"]);
826
+                                            }
827
+                                        }
828
+                                        ?>
829 829
 										<i id="plock" class="<?= $_style["actions_folder"] ?>" onclick="enableParentSelection(!allowParentSelection);"></i>
830 830
 										<b><span id="parentName"><?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?> (<?= $parentname ?>)</span></b>
831 831
 										<input type="hidden" name="parent" value="<?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?>" onchange="documentDirty=true;" />
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 								</tr>
834 834
 								<tr></tr>
835 835
 								<?php
836
-								/*
836
+                                /*
837 837
 								if($content['type'] == 'reference' || $modx->manager->action == '72') {
838 838
 									?>
839 839
 									<tr>
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 									</tr>
862 862
 									<?php
863 863
 								}*/
864
-								?>
864
+                                ?>
865 865
 
866 866
 								<?php if($content['type'] == 'document' || $modx->manager->action == '4') { ?>
867 867
 									<tr>
@@ -874,36 +874,36 @@  discard block
 block discarded – undo
874 874
 													<select id="which_editor" class="form-control form-control-sm" size="1" name="which_editor" onchange="changeRTE();">
875 875
 													<option value="none"><?= $_lang['none'] ?></option>
876 876
 														<?php
877
-														// invoke OnRichTextEditorRegister event
878
-														$evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
879
-														if(is_array($evtOut)) {
880
-															for($i = 0; $i < count($evtOut); $i++) {
881
-																$editor = $evtOut[$i];
882
-																echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n";
883
-															}
884
-														}
885
-														?>
877
+                                                        // invoke OnRichTextEditorRegister event
878
+                                                        $evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
879
+                                                        if(is_array($evtOut)) {
880
+                                                            for($i = 0; $i < count($evtOut); $i++) {
881
+                                                                $editor = $evtOut[$i];
882
+                                                                echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n";
883
+                                                            }
884
+                                                        }
885
+                                                        ?>
886 886
 													</select>
887 887
 												</label>
888 888
 											</div>
889 889
 											<div id="content_body">
890 890
 												<?php
891
-												if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) {
892
-													$htmlContent = $content['content'];
893
-													?>
891
+                                                if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) {
892
+                                                    $htmlContent = $content['content'];
893
+                                                    ?>
894 894
 													<div class="section-editor clearfix">
895 895
 														<textarea id="ta" name="ta" onchange="documentDirty=true;"><?= $modx->htmlspecialchars($htmlContent) ?></textarea>
896 896
 													</div>
897 897
 													<?php
898
-													// Richtext-[*content*]
899
-													$richtexteditorIds = array();
900
-													$richtexteditorOptions = array();
901
-													$richtexteditorIds[$modx->config['which_editor']][] = 'ta';
902
-													$richtexteditorOptions[$modx->config['which_editor']]['ta'] = '';
903
-												} else {
904
-													echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n";
905
-												}
906
-												?>
898
+                                                    // Richtext-[*content*]
899
+                                                    $richtexteditorIds = array();
900
+                                                    $richtexteditorOptions = array();
901
+                                                    $richtexteditorIds[$modx->config['which_editor']][] = 'ta';
902
+                                                    $richtexteditorOptions[$modx->config['which_editor']]['ta'] = '';
903
+                                                } else {
904
+                                                    echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n";
905
+                                                }
906
+                                                ?>
907 907
 											</div>
908 908
 										</td>
909 909
 									</tr>
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 								<?php
1192 1192
 
1193
-								if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1194
-									?>
1193
+                                if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1194
+                                    ?>
1195 1195
 									<tr>
1196 1196
 										<td>
1197 1197
 											<span class="warning"><?= $_lang['resource_type'] ?></span>
@@ -1213,15 +1213,15 @@  discard block
 block discarded – undo
1213 1213
 										<td>
1214 1214
 											<select name="contentType" class="inputBox" onchange="documentDirty=true;">
1215 1215
 												<?php
1216
-												if(!$content['contentType']) {
1217
-													$content['contentType'] = 'text/html';
1218
-												}
1219
-												$custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml");
1220
-												$ct = explode(",", $custom_contenttype);
1221
-												for($i = 0; $i < count($ct); $i++) {
1222
-													echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n";
1223
-												}
1224
-												?>
1216
+                                                if(!$content['contentType']) {
1217
+                                                    $content['contentType'] = 'text/html';
1218
+                                                }
1219
+                                                $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml");
1220
+                                                $ct = explode(",", $custom_contenttype);
1221
+                                                for($i = 0; $i < count($ct); $i++) {
1222
+                                                    echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n";
1223
+                                                }
1224
+                                                ?>
1225 1225
 											</select>
1226 1226
 										</td>
1227 1227
 									</tr>
@@ -1244,23 +1244,23 @@  discard block
 block discarded – undo
1244 1244
 										</td>
1245 1245
 									</tr>
1246 1246
 									<?php
1247
-								} else {
1248
-									if($content['type'] != 'reference' && $modx->manager->action != '72') {
1249
-										// non-admin managers creating or editing a document resource
1250
-										?>
1247
+                                } else {
1248
+                                    if($content['type'] != 'reference' && $modx->manager->action != '72') {
1249
+                                        // non-admin managers creating or editing a document resource
1250
+                                        ?>
1251 1251
 										<input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" />
1252 1252
 										<input type="hidden" name="type" value="document" />
1253 1253
 										<input type="hidden" name="content_dispo" value="<?= (isset($content['content_dispo']) ? $content['content_dispo'] : '0') ?>" />
1254 1254
 										<?php
1255
-									} else {
1256
-										// non-admin managers creating or editing a reference (weblink) resource
1257
-										?>
1255
+                                    } else {
1256
+                                        // non-admin managers creating or editing a reference (weblink) resource
1257
+                                        ?>
1258 1258
 										<input type="hidden" name="type" value="reference" />
1259 1259
 										<input type="hidden" name="contentType" value="text/html" />
1260 1260
 										<?php
1261
-									}
1262
-								}//if mgrRole
1263
-								?>
1261
+                                    }
1262
+                                }//if mgrRole
1263
+                                ?>
1264 1264
 
1265 1265
 								<tr>
1266 1266
 									<td>
@@ -1343,112 +1343,112 @@  discard block
 block discarded – undo
1343 1343
                     ?>
1344 1344
 
1345 1345
 						<?php
1346
-					/*******************************
1346
+                    /*******************************
1347 1347
 					 * Document Access Permissions */
1348
-					if($use_udperms == 1) {
1349
-						$groupsarray = array();
1350
-						$sql = '';
1351
-
1352
-						$documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']));
1353
-						if($documentId > 0) {
1354
-							// Load up, the permissions from the parent (if new document) or existing document
1355
-							$rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1356
-							while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1357
-
1358
-							// Load up the current permissions and names
1359
-							$vs = array(
1360
-								$tbl_document_group_names,
1361
-								$tbl_document_groups,
1362
-								$documentId
1363
-							);
1364
-							$from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs);
1365
-							$rs = $modx->db->select('dgn.*, groups.id AS link_id', $from, '', 'name');
1366
-						} else {
1367
-							// Just load up the names, we're starting clean
1368
-							$rs = $modx->db->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name');
1369
-						}
1370
-
1371
-						// retain selected doc groups between post
1372
-						if(isset($_POST['docgroups'])) {
1373
-							$groupsarray = array_merge($groupsarray, $_POST['docgroups']);
1374
-						}
1348
+                    if($use_udperms == 1) {
1349
+                        $groupsarray = array();
1350
+                        $sql = '';
1351
+
1352
+                        $documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']));
1353
+                        if($documentId > 0) {
1354
+                            // Load up, the permissions from the parent (if new document) or existing document
1355
+                            $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1356
+                            while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1357
+
1358
+                            // Load up the current permissions and names
1359
+                            $vs = array(
1360
+                                $tbl_document_group_names,
1361
+                                $tbl_document_groups,
1362
+                                $documentId
1363
+                            );
1364
+                            $from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs);
1365
+                            $rs = $modx->db->select('dgn.*, groups.id AS link_id', $from, '', 'name');
1366
+                        } else {
1367
+                            // Just load up the names, we're starting clean
1368
+                            $rs = $modx->db->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name');
1369
+                        }
1370
+
1371
+                        // retain selected doc groups between post
1372
+                        if(isset($_POST['docgroups'])) {
1373
+                            $groupsarray = array_merge($groupsarray, $_POST['docgroups']);
1374
+                        }
1375
+
1376
+                        $isManager = $modx->hasPermission('access_permissions');
1377
+                        $isWeb = $modx->hasPermission('web_access_permissions');
1378
+
1379
+                        // Setup Basic attributes for each Input box
1380
+                        $inputAttributes = array(
1381
+                            'type' => 'checkbox',
1382
+                            'class' => 'checkbox',
1383
+                            'name' => 'docgroups[]',
1384
+                            'onclick' => 'makePublic(false);',
1385
+                        );
1386
+                        $permissions = array(); // New Permissions array list (this contains the HTML)
1387
+                        $permissions_yes = 0; // count permissions the current mgr user has
1388
+                        $permissions_no = 0; // count permissions the current mgr user doesn't have
1389
+
1390
+                        // Loop through the permissions list
1391
+                        while($row = $modx->db->getRow($rs)) {
1392
+
1393
+                            // Create an inputValue pair (group ID and group link (if it exists))
1394
+                            $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new');
1395
+                            $inputId = 'group-' . $row['id'];
1396
+
1397
+                            $checked = in_array($inputValue, $groupsarray);
1398
+                            if($checked) {
1399
+                                $notPublic = true;
1400
+                            } // Mark as private access (either web or manager)
1401
+
1402
+                            // Skip the access permission if the user doesn't have access...
1403
+                            if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1404
+                                continue;
1405
+                            }
1375 1406
 
1376
-						$isManager = $modx->hasPermission('access_permissions');
1377
-						$isWeb = $modx->hasPermission('web_access_permissions');
1378
-
1379
-						// Setup Basic attributes for each Input box
1380
-						$inputAttributes = array(
1381
-							'type' => 'checkbox',
1382
-							'class' => 'checkbox',
1383
-							'name' => 'docgroups[]',
1384
-							'onclick' => 'makePublic(false);',
1385
-						);
1386
-						$permissions = array(); // New Permissions array list (this contains the HTML)
1387
-						$permissions_yes = 0; // count permissions the current mgr user has
1388
-						$permissions_no = 0; // count permissions the current mgr user doesn't have
1389
-
1390
-						// Loop through the permissions list
1391
-						while($row = $modx->db->getRow($rs)) {
1392
-
1393
-							// Create an inputValue pair (group ID and group link (if it exists))
1394
-							$inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new');
1395
-							$inputId = 'group-' . $row['id'];
1396
-
1397
-							$checked = in_array($inputValue, $groupsarray);
1398
-							if($checked) {
1399
-								$notPublic = true;
1400
-							} // Mark as private access (either web or manager)
1401
-
1402
-							// Skip the access permission if the user doesn't have access...
1403
-							if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1404
-								continue;
1405
-							}
1406
-
1407
-							// Setup attributes for this Input box
1408
-							$inputAttributes['id'] = $inputId;
1409
-							$inputAttributes['value'] = $inputValue;
1410
-							if($checked) {
1411
-								$inputAttributes['checked'] = 'checked';
1412
-							} else {
1413
-								unset($inputAttributes['checked']);
1414
-							}
1415
-
1416
-							// Create attribute string list
1417
-							$inputString = array();
1418
-							foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1419
-
1420
-							// Make the <input> HTML
1421
-							$inputHTML = '<input ' . implode(' ', $inputString) . ' />';
1422
-
1423
-							// does user have this permission?
1424
-							$from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg";
1425
-							$vs = array(
1426
-								$row['id'],
1427
-								$_SESSION['mgrInternalKey']
1428
-							);
1429
-							$where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs);
1430
-							$rsp = $modx->db->select('COUNT(mg.id)', $from, $where);
1431
-							$count = $modx->db->getValue($rsp);
1432
-							if($count > 0) {
1433
-								++$permissions_yes;
1434
-							} else {
1435
-								++$permissions_no;
1436
-							}
1437
-							$permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>';
1438
-						}
1439
-						// if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public
1440
-						if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1441
-							$permissions = array();
1442
-						}
1407
+                            // Setup attributes for this Input box
1408
+                            $inputAttributes['id'] = $inputId;
1409
+                            $inputAttributes['value'] = $inputValue;
1410
+                            if($checked) {
1411
+                                $inputAttributes['checked'] = 'checked';
1412
+                            } else {
1413
+                                unset($inputAttributes['checked']);
1414
+                            }
1443 1415
 
1444
-						// See if the Access Permissions section is worth displaying...
1445
-						if(!empty($permissions)) {
1446
-							// Add the "All Document Groups" item if we have rights in both contexts
1447
-							if($isManager && $isWeb) {
1448
-								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>');
1449
-							}
1450
-							// Output the permissions list...
1451
-							?>
1416
+                            // Create attribute string list
1417
+                            $inputString = array();
1418
+                            foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1419
+
1420
+                            // Make the <input> HTML
1421
+                            $inputHTML = '<input ' . implode(' ', $inputString) . ' />';
1422
+
1423
+                            // does user have this permission?
1424
+                            $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg";
1425
+                            $vs = array(
1426
+                                $row['id'],
1427
+                                $_SESSION['mgrInternalKey']
1428
+                            );
1429
+                            $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs);
1430
+                            $rsp = $modx->db->select('COUNT(mg.id)', $from, $where);
1431
+                            $count = $modx->db->getValue($rsp);
1432
+                            if($count > 0) {
1433
+                                ++$permissions_yes;
1434
+                            } else {
1435
+                                ++$permissions_no;
1436
+                            }
1437
+                            $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>';
1438
+                        }
1439
+                        // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public
1440
+                        if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1441
+                            $permissions = array();
1442
+                        }
1443
+
1444
+                        // See if the Access Permissions section is worth displaying...
1445
+                        if(!empty($permissions)) {
1446
+                            // Add the "All Document Groups" item if we have rights in both contexts
1447
+                            if($isManager && $isWeb) {
1448
+                                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>');
1449
+                            }
1450
+                            // Output the permissions list...
1451
+                            ?>
1452 1452
 							<!-- Access Permissions -->
1453 1453
 							<div class="tab-page" id="tabAccess">
1454 1454
 								<h2 class="tab" id="tab_access_header"><?= $_lang['access_permissions'] ?></h2>
@@ -1482,31 +1482,31 @@  discard block
 block discarded – undo
1482 1482
 								</ul>
1483 1483
 							</div><!--div class="tab-page" id="tabAccess"-->
1484 1484
 							<?php
1485
-						} // !empty($permissions)
1486
-						elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1487
-							?>
1485
+                        } // !empty($permissions)
1486
+                        elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1487
+                            ?>
1488 1488
 							<p><?= $_lang["access_permissions_docs_collision"] ?></p>
1489 1489
 							<?php
1490 1490
 
1491
-						}
1492
-					}
1493
-					/* End Document Access Permissions *
1491
+                        }
1492
+                    }
1493
+                    /* End Document Access Permissions *
1494 1494
 					 ***********************************/
1495
-					?>
1495
+                    ?>
1496 1496
 
1497 1497
 					<input type="submit" name="save" style="display:none" />
1498 1498
 					<?php
1499 1499
 
1500
-					// invoke OnDocFormRender event
1501
-					$evtOut = $modx->invokeEvent('OnDocFormRender', array(
1502
-						'id' => $id,
1503
-						'template' => $content['template']
1504
-					));
1500
+                    // invoke OnDocFormRender event
1501
+                    $evtOut = $modx->invokeEvent('OnDocFormRender', array(
1502
+                        'id' => $id,
1503
+                        'template' => $content['template']
1504
+                    ));
1505 1505
 
1506
-					if(is_array($evtOut)) {
1507
-						echo implode('', $evtOut);
1508
-					}
1509
-					?>
1506
+                    if(is_array($evtOut)) {
1507
+                        echo implode('', $evtOut);
1508
+                    }
1509
+                    ?>
1510 1510
 				</div><!--div class="tab-pane" id="documentPane"-->
1511 1511
 			</div><!--div class="sectionBody"-->
1512 1512
 		</fieldset>
@@ -1517,63 +1517,63 @@  discard block
 block discarded – undo
1517 1517
 	</script>
1518 1518
 <?php
1519 1519
 if(($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) {
1520
-	if(is_array($richtexteditorIds)) {
1521
-		foreach($richtexteditorIds as $editor => $elements) {
1522
-			// invoke OnRichTextEditorInit event
1523
-			$evtOut = $modx->invokeEvent('OnRichTextEditorInit', array(
1524
-				'editor' => $editor,
1525
-				'elements' => $elements,
1526
-				'options' => $richtexteditorOptions[$editor]
1527
-			));
1528
-			if(is_array($evtOut)) {
1529
-				echo implode('', $evtOut);
1530
-			}
1531
-		}
1532
-	}
1520
+    if(is_array($richtexteditorIds)) {
1521
+        foreach($richtexteditorIds as $editor => $elements) {
1522
+            // invoke OnRichTextEditorInit event
1523
+            $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array(
1524
+                'editor' => $editor,
1525
+                'elements' => $elements,
1526
+                'options' => $richtexteditorOptions[$editor]
1527
+            ));
1528
+            if(is_array($evtOut)) {
1529
+                echo implode('', $evtOut);
1530
+            }
1531
+        }
1532
+    }
1533 1533
 }
1534 1534
 
1535 1535
 /**
1536 1536
  * @return string
1537 1537
  */
1538 1538
 function getDefaultTemplate() {
1539
-	$modx = evolutionCMS();
1539
+    $modx = evolutionCMS();
1540 1540
 
1541 1541
     $default_template = '';
1542
-	switch($modx->config['auto_template_logic']) {
1543
-		case 'sibling':
1544
-			if(!isset($_GET['pid']) || empty($_GET['pid'])) {
1545
-				$site_start = $modx->config['site_start'];
1546
-				$where = "sc.isfolder=0 AND sc.id!='{$site_start}'";
1547
-				$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1);
1548
-				if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1549
-					$default_template = $sibl[0]['template'];
1550
-				}
1551
-			} else {
1552
-				$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1553
-				if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1554
-					$default_template = $sibl[0]['template'];
1555
-				} else {
1556
-					$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1557
-					if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1558
-						$default_template = $sibl[0]['template'];
1559
-					}
1560
-				}
1561
-			}
1562
-			if(isset($default_template)) {
1563
-				break;
1564
-			} // If $default_template could not be determined, fall back / through to "parent"-mode
1565
-		case 'parent':
1566
-			if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) {
1567
-				$parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template');
1568
-				if(isset($parent['template'])) {
1569
-					$default_template = $parent['template'];
1570
-				}
1571
-			}
1572
-			break;
1573
-		case 'system':
1574
-		default: // default_template is already set
1575
-			$default_template = $modx->config['default_template'];
1576
-	}
1577
-
1578
-	return empty($default_template) ? $modx->config['default_template'] : $default_template;
1542
+    switch($modx->config['auto_template_logic']) {
1543
+        case 'sibling':
1544
+            if(!isset($_GET['pid']) || empty($_GET['pid'])) {
1545
+                $site_start = $modx->config['site_start'];
1546
+                $where = "sc.isfolder=0 AND sc.id!='{$site_start}'";
1547
+                $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1);
1548
+                if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1549
+                    $default_template = $sibl[0]['template'];
1550
+                }
1551
+            } else {
1552
+                $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1553
+                if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1554
+                    $default_template = $sibl[0]['template'];
1555
+                } else {
1556
+                    $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1557
+                    if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1558
+                        $default_template = $sibl[0]['template'];
1559
+                    }
1560
+                }
1561
+            }
1562
+            if(isset($default_template)) {
1563
+                break;
1564
+            } // If $default_template could not be determined, fall back / through to "parent"-mode
1565
+        case 'parent':
1566
+            if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) {
1567
+                $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template');
1568
+                if(isset($parent['template'])) {
1569
+                    $default_template = $parent['template'];
1570
+                }
1571
+            }
1572
+            break;
1573
+        case 'system':
1574
+        default: // default_template is already set
1575
+            $default_template = $modx->config['default_template'];
1576
+    }
1577
+
1578
+    return empty($default_template) ? $modx->config['default_template'] : $default_template;
1579 1579
 }
Please login to merge, or discard this patch.
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,35 +1,35 @@  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
 /********************/
7
-$sd = isset($_REQUEST['dir']) ? '&dir=' . $_REQUEST['dir'] : '&dir=DESC';
8
-$sb = isset($_REQUEST['sort']) ? '&sort=' . $_REQUEST['sort'] : '&sort=createdon';
9
-$pg = isset($_REQUEST['page']) ? '&page=' . (int) $_REQUEST['page'] : '';
10
-$add_path = $sd . $sb . $pg;
7
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
8
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
9
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
10
+$add_path = $sd.$sb.$pg;
11 11
 /*******************/
12 12
 
13 13
 // check permissions
14
-switch($modx->manager->action) {
14
+switch ($modx->manager->action) {
15 15
 	case 27:
16
-		if(!$modx->hasPermission('edit_document')) {
16
+		if (!$modx->hasPermission('edit_document')) {
17 17
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
18 18
 		}
19 19
 		break;
20 20
 	case 85:
21 21
 	case 72:
22 22
 	case 4:
23
-		if(!$modx->hasPermission('new_document')) {
23
+		if (!$modx->hasPermission('new_document')) {
24 24
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
25
-		} elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
25
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
26 26
 			// check user has permissions for parent
27
-			include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
27
+			include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php');
28 28
 			$udperms = new udperms();
29 29
 			$udperms->user = $modx->getLoginUserID();
30 30
 			$udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid'];
31 31
 			$udperms->role = $_SESSION['mgrRole'];
32
-			if(!$udperms->checkPermissions()) {
32
+			if (!$udperms->checkPermissions()) {
33 33
 				$modx->webAlertAndQuit($_lang["access_permission_denied"]);
34 34
 			}
35 35
 		}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
39 39
 }
40 40
 
41
-$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
41
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
42 42
 
43 43
 // Get table names (alphabetical)
44 44
 $tbl_categories = $modx->getFullTableName('categories');
@@ -53,22 +53,22 @@  discard block
 block discarded – undo
53 53
 $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_templates');
54 54
 $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars');
55 55
 
56
-if($modx->manager->action == 27) {
56
+if ($modx->manager->action == 27) {
57 57
 	//editing an existing document
58 58
 	// check permissions on the document
59
-	include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
59
+	include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php');
60 60
 	$udperms = new udperms();
61 61
 	$udperms->user = $modx->getLoginUserID();
62 62
 	$udperms->document = $id;
63 63
 	$udperms->role = $_SESSION['mgrRole'];
64 64
 
65
-	if(!$udperms->checkPermissions()) {
65
+	if (!$udperms->checkPermissions()) {
66 66
 		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
67 67
 	}
68 68
 }
69 69
 
70 70
 // check to see if resource isn't locked
71
-if($lockedEl = $modx->elementIsLocked(7, $id)) {
71
+if ($lockedEl = $modx->elementIsLocked(7, $id)) {
72 72
 	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource']));
73 73
 }
74 74
 // end check for lock
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
 $modx->lockElement(7, $id);
78 78
 
79 79
 // get document groups for current user
80
-if($_SESSION['mgrDocgroups']) {
80
+if ($_SESSION['mgrDocgroups']) {
81 81
 	$docgrp = implode(',', $_SESSION['mgrDocgroups']);
82 82
 }
83 83
 
84
-if(!empty ($id)) {
84
+if (!empty ($id)) {
85 85
 	$access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']);
86
-	if($docgrp) {
86
+	if ($docgrp) {
87 87
 		$access .= " OR dg.document_group IN ({$docgrp})";
88 88
 	}
89 89
 	$rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})");
90 90
 	$content = array();
91 91
 	$content = $modx->db->getRow($rs);
92 92
 	$modx->documentObject = &$content;
93
-	if(!$content) {
93
+	if (!$content) {
94 94
 		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
95 95
 	}
96 96
 	$_SESSION['itemname'] = $content['pagetitle'];
97 97
 } else {
98 98
 	$content = array();
99 99
 
100
-	if(isset($_REQUEST['newtemplate'])) {
100
+	if (isset($_REQUEST['newtemplate'])) {
101 101
 		$content['template'] = $_REQUEST['newtemplate'];
102 102
 	} else {
103 103
 		$content['template'] = getDefaultTemplate();
@@ -108,22 +108,22 @@  discard block
 block discarded – undo
108 108
 
109 109
 // restore saved form
110 110
 $formRestored = $modx->manager->loadFormValues();
111
-if(isset($_REQUEST['newtemplate'])) {
111
+if (isset($_REQUEST['newtemplate'])) {
112 112
 	$formRestored = true;
113 113
 }
114 114
 
115 115
 // retain form values if template was changed
116 116
 // edited to convert pub_date and unpub_date
117 117
 // sottwell 02-09-2006
118
-if($formRestored == true) {
118
+if ($formRestored == true) {
119 119
 	$content = array_merge($content, $_POST);
120 120
 	$content['content'] = $_POST['ta'];
121
-	if(empty ($content['pub_date'])) {
121
+	if (empty ($content['pub_date'])) {
122 122
 		unset ($content['pub_date']);
123 123
 	} else {
124 124
 		$content['pub_date'] = $modx->toTimeStamp($content['pub_date']);
125 125
 	}
126
-	if(empty ($content['unpub_date'])) {
126
+	if (empty ($content['unpub_date'])) {
127 127
 		unset ($content['unpub_date']);
128 128
 	} else {
129 129
 		$content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']);
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 }
132 132
 
133 133
 // increase menu index if this is a new document
134
-if(!isset ($_REQUEST['id'])) {
135
-	if(!isset ($modx->config['auto_menuindex'])) {
134
+if (!isset ($_REQUEST['id'])) {
135
+	if (!isset ($modx->config['auto_menuindex'])) {
136 136
 		$modx->config['auto_menuindex'] = 1;
137 137
 	}
138
-	if($modx->config['auto_menuindex']) {
139
-		$pid = (int)$_REQUEST['pid'];
138
+	if ($modx->config['auto_menuindex']) {
139
+		$pid = (int) $_REQUEST['pid'];
140 140
 		$rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'");
141 141
 		$content['menuindex'] = $modx->db->getValue($rs);
142 142
 	} else {
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 }
146 146
 
147
-if(isset ($_POST['which_editor'])) {
147
+if (isset ($_POST['which_editor'])) {
148 148
 	$modx->config['which_editor'] = $_POST['which_editor'];
149 149
 }
150 150
 
151 151
 // Add lock-element JS-Script
152 152
 $lockElementId = $id;
153 153
 $lockElementType = 7;
154
-require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php');
154
+require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php');
155 155
 ?>
156 156
 	<script type="text/javascript">
157 157
 		/* <![CDATA[ */
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			},
182 182
 			cancel: function() {
183 183
 				documentDirty = false;
184
-				document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id=' . $id . $add_path) ?>';
184
+				document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id='.$id.$add_path) ?>';
185 185
 			},
186 186
 			duplicate: function() {
187 187
 				if(confirm("<?= $_lang['confirm_resource_duplicate']?>") === true) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				}
190 190
 			},
191 191
 			view: function() {
192
-				window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : $modx->config['site_url'] . 'index.php?id=' . $id ?>', 'previeWin');
192
+				window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : $modx->config['site_url'].'index.php?id='.$id ?>', 'previeWin');
193 193
 			}
194 194
 		};
195 195
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 			'template' => $content['template']
552 552
 		));
553 553
 
554
-		if(is_array($evtOut)) {
554
+		if (is_array($evtOut)) {
555 555
 			echo implode('', $evtOut);
556 556
 		}
557 557
 
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
 		<fieldset id="create_edit">
576 576
 
577 577
 			<h1>
578
-				<i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) {
579
-					echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>';
578
+				<i class="fa fa-pencil-square-o"></i><?php if (isset($_REQUEST['id'])) {
579
+					echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']).(iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '').'<small>('.$_REQUEST['id'].')</small>';
580 580
 				} else {
581 581
 				    if ($modx->manager->action == '4') {
582 582
                         echo $_lang['add_resource'];
@@ -592,36 +592,36 @@  discard block
 block discarded – undo
592 592
 
593 593
 			<?php
594 594
 			// breadcrumbs
595
-			if($modx->config['use_breadcrumbs']) {
595
+			if ($modx->config['use_breadcrumbs']) {
596 596
 				$temp = array();
597 597
 				$title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title'];
598 598
 
599
-				if(isset($_REQUEST['id']) && $content['parent'] != 0) {
599
+				if (isset($_REQUEST['id']) && $content['parent'] != 0) {
600 600
 					$bID = (int) $_REQUEST['id'];
601 601
 					$temp = $modx->getParentIds($bID);
602
-				} else if(isset($_REQUEST['pid'])) {
602
+				} else if (isset($_REQUEST['pid'])) {
603 603
 					$bID = (int) $_REQUEST['pid'];
604 604
 					$temp = $modx->getParentIds($bID);
605 605
 					array_unshift($temp, $bID);
606 606
 				}
607 607
 
608
-				if($temp) {
608
+				if ($temp) {
609 609
 					$parents = implode(',', $temp);
610 610
 
611
-					if(!empty($parents)) {
611
+					if (!empty($parents)) {
612 612
 						$where = "FIND_IN_SET(id,'{$parents}') DESC";
613 613
 						$rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where);
614
-						while($row = $modx->db->getRow($rs)) {
614
+						while ($row = $modx->db->getRow($rs)) {
615 615
 							$out .= '<li class="breadcrumbs__li">
616
-                                <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a>
616
+                                <a href="index.php?a=27&id=' . $row['id'].'" class="breadcrumbs__a">'.htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']).'</a>
617 617
                                 <span class="breadcrumbs__sep">&gt;</span>
618 618
                             </li>';
619 619
 						}
620 620
 					}
621 621
 				}
622 622
 
623
-				$out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>';
624
-				echo '<ul class="breadcrumbs">' . $out . '</ul>';
623
+				$out .= '<li class="breadcrumbs__li breadcrumbs__li_current">'.$title.'</li>';
624
+				echo '<ul class="breadcrumbs">'.$out.'</ul>';
625 625
 			}
626 626
 			?>
627 627
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 					$evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array(
639 639
 						'id' => $id
640 640
 					));
641
-					if(is_array($evtOut)) {
641
+					if (is_array($evtOut)) {
642 642
 						echo implode('', $evtOut);
643 643
 					} else {
644 644
 						?>
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 									</td>
695 695
 								</tr>
696 696
 
697
-								<?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?>
697
+								<?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?>
698 698
 
699 699
 									<tr>
700 700
 										<td><span class="warning"><?= $_lang['weblink'] ?></span>
@@ -730,17 +730,17 @@  discard block
 block discarded – undo
730 730
 											$from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id";
731 731
 											$rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC');
732 732
 											$currentCategory = '';
733
-											while($row = $modx->db->getRow($rs)) {
734
-												if($row['selectable'] != 1 && $row['id'] != $content['template']) {
733
+											while ($row = $modx->db->getRow($rs)) {
734
+												if ($row['selectable'] != 1 && $row['id'] != $content['template']) {
735 735
 													continue;
736 736
 												};
737 737
 												// Skip if not selectable but show if selected!
738 738
 												$thisCategory = $row['category'];
739
-												if($thisCategory == null) {
739
+												if ($thisCategory == null) {
740 740
 													$thisCategory = $_lang["no_category"];
741 741
 												}
742
-												if($thisCategory != $currentCategory) {
743
-													if($closeOptGroup) {
742
+												if ($thisCategory != $currentCategory) {
743
+													if ($closeOptGroup) {
744 744
 														echo "\t\t\t\t\t</optgroup>\n";
745 745
 													}
746 746
 													echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n";
@@ -749,10 +749,10 @@  discard block
 block discarded – undo
749 749
 
750 750
 												$selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : '';
751 751
 
752
-												echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n";
752
+												echo "\t\t\t\t\t".'<option value="'.$row['id'].'"'.$selectedtext.'>'.$row['templatename']."</option>\n";
753 753
 												$currentCategory = $thisCategory;
754 754
 											}
755
-											if($thisCategory != '') {
755
+											if ($thisCategory != '') {
756 756
 												echo "\t\t\t\t\t</optgroup>\n";
757 757
 											}
758 758
 											?>
@@ -796,20 +796,20 @@  discard block
 block discarded – undo
796 796
 									<td valign="top">
797 797
 										<?php
798 798
 										$parentlookup = false;
799
-										if(isset ($_REQUEST['id'])) {
800
-											if($content['parent'] == 0) {
799
+										if (isset ($_REQUEST['id'])) {
800
+											if ($content['parent'] == 0) {
801 801
 												$parentname = $site_name;
802 802
 											} else {
803 803
 												$parentlookup = $content['parent'];
804 804
 											}
805
-										} elseif(isset ($_REQUEST['pid'])) {
806
-											if($_REQUEST['pid'] == 0) {
805
+										} elseif (isset ($_REQUEST['pid'])) {
806
+											if ($_REQUEST['pid'] == 0) {
807 807
 												$parentname = $site_name;
808 808
 											} else {
809 809
 												$parentlookup = $_REQUEST['pid'];
810 810
 											}
811
-										} elseif(isset($_POST['parent'])) {
812
-											if($_POST['parent'] == 0) {
811
+										} elseif (isset($_POST['parent'])) {
812
+											if ($_POST['parent'] == 0) {
813 813
 												$parentname = $site_name;
814 814
 											} else {
815 815
 												$parentlookup = $_POST['parent'];
@@ -818,10 +818,10 @@  discard block
 block discarded – undo
818 818
 											$parentname = $site_name;
819 819
 											$content['parent'] = 0;
820 820
 										}
821
-										if($parentlookup !== false && is_numeric($parentlookup)) {
821
+										if ($parentlookup !== false && is_numeric($parentlookup)) {
822 822
 											$rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'");
823 823
 											$parentname = $modx->db->getValue($rs);
824
-											if(!$parentname) {
824
+											if (!$parentname) {
825 825
 												$modx->webAlertAndQuit($_lang["error_no_parent"]);
826 826
 											}
827 827
 										}
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 								}*/
864 864
 								?>
865 865
 
866
-								<?php if($content['type'] == 'document' || $modx->manager->action == '4') { ?>
866
+								<?php if ($content['type'] == 'document' || $modx->manager->action == '4') { ?>
867 867
 									<tr>
868 868
 										<td colspan="2">
869 869
 											<hr>
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 														<?php
877 877
 														// invoke OnRichTextEditorRegister event
878 878
 														$evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
879
-														if(is_array($evtOut)) {
880
-															for($i = 0; $i < count($evtOut); $i++) {
879
+														if (is_array($evtOut)) {
880
+															for ($i = 0; $i < count($evtOut); $i++) {
881 881
 																$editor = $evtOut[$i];
882 882
 																echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n";
883 883
 															}
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 											</div>
889 889
 											<div id="content_body">
890 890
 												<?php
891
-												if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) {
891
+												if (($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) {
892 892
 													$htmlContent = $content['content'];
893 893
 													?>
894 894
 													<div class="section-editor clearfix">
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 													$richtexteditorIds[$modx->config['which_editor']][] = 'ta';
902 902
 													$richtexteditorOptions[$modx->config['which_editor']]['ta'] = '';
903 903
 												} else {
904
-													echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n";
904
+													echo "\t".'<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>'."\n";
905 905
 												}
906 906
 												?>
907 907
 											</div>
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 
918 918
                             if (($content['type'] == 'document' || $modx->manager->action == '4') || ($content['type'] == 'reference' || $modx->manager->action == 72)) {
919 919
                                 $template = $default_template;
920
-                                $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int)$modx->config['group_tvs'];
920
+                                $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int) $modx->config['group_tvs'];
921 921
                                 if (isset ($_REQUEST['newtemplate'])) {
922 922
                                     $template = $_REQUEST['newtemplate'];
923 923
                                 } else {
@@ -945,10 +945,10 @@  discard block
 block discarded – undo
945 945
                                 );
946 946
                                 $sort = 'tvtpl.rank,tv.rank, tv.id';
947 947
                                 if ($group_tvs) {
948
-                                    $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"' . $_lang['no_category'] . '") AS category, IFNULL(cat.rank,0) AS category_rank';
948
+                                    $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"'.$_lang['no_category'].'") AS category, IFNULL(cat.rank,0) AS category_rank';
949 949
                                     $from .= '
950
-                                    LEFT JOIN ' . $tbl_categories . ' AS cat ON cat.id=tv.category';
951
-                                    $sort = 'cat.rank,cat.id,' . $sort;
950
+                                    LEFT JOIN ' . $tbl_categories.' AS cat ON cat.id=tv.category';
951
+                                    $sort = 'cat.rank,cat.id,'.$sort;
952 952
                                 }
953 953
                                 $where = vsprintf("tvtpl.templateid='%s' AND (1='%s' OR ISNULL(tva.documentgroup) %s)", $vs);
954 954
                                 $rs = $modx->db->select($field, $from, $where, $sort);
@@ -957,37 +957,37 @@  discard block
 block discarded – undo
957 957
                         <!-- Template Variables -->' . "\n";
958 958
                                     if (!$group_tvs) {
959 959
                                         $templateVariables .= '
960
-                                    <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'] . '</div>
960
+                                    <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'].'</div>
961 961
                                         <div class="sectionBody tmplvars">
962 962
                                             <table>';
963 963
                                     } else if ($group_tvs == 2) {
964 964
                                         $templateVariables .= '
965 965
                     <div class="tab-section">
966
-                        <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'] . '</div>
966
+                        <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'].'</div>
967 967
                         <div class="tab-pane" id="paneTemplateVariables">
968 968
                             <script type="text/javascript">
969
-                                tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
969
+                                tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').');
970 970
                             </script>';
971 971
                                     } else if ($group_tvs == 3) {
972 972
                                         $templateVariables .= '
973 973
                         <div id="templateVariables" class="tab-page tmplvars">
974
-                            <h2 class="tab">' . $_lang['settings_templvars'] . '</h2>
974
+                            <h2 class="tab">' . $_lang['settings_templvars'].'</h2>
975 975
                             <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script>';
976 976
                                     } else if ($group_tvs == 4) {
977 977
                                         $templateVariables .= '
978 978
                     <div id="templateVariables" class="tab-page tmplvars">
979
-                        <h2 class="tab">' . $_lang['settings_templvars'] . '</h2>
979
+                        <h2 class="tab">' . $_lang['settings_templvars'].'</h2>
980 980
                         <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script>
981 981
                         
982 982
                         <div class="tab-pane" id="paneTemplateVariables">
983 983
                             <script type="text/javascript">
984
-                                tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
984
+                                tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').');
985 985
                             </script>';
986 986
                                     }
987 987
 
988 988
                                     $tvsArray = $modx->db->makeArray($rs, 'name');
989
-                                    require_once(MODX_MANAGER_PATH . 'includes/tmplvars.inc.php');
990
-                                    require_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php');
989
+                                    require_once(MODX_MANAGER_PATH.'includes/tmplvars.inc.php');
990
+                                    require_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php');
991 991
                                     $i = 0;
992 992
                                     $tab = '';
993 993
                                     foreach ($tvsArray as $row) {
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
                                             if ($group_tvs == 1 || $group_tvs == 3) {
996 996
                                                 if ($i === 0) {
997 997
                                                     $templateVariables .= '
998
-                            <div class="tab-section" id="tabTV_' . $row['category_id'] . '">
999
-                                <div class="tab-header">' . $row['category'] . '</div>
998
+                            <div class="tab-section" id="tabTV_' . $row['category_id'].'">
999
+                                <div class="tab-header">' . $row['category'].'</div>
1000 1000
                                 <div class="tab-body tmplvars">
1001 1001
                                     <table>' . "\n";
1002 1002
                                                 } else {
@@ -1005,17 +1005,17 @@  discard block
 block discarded – undo
1005 1005
                                 </div>
1006 1006
                             </div>
1007 1007
                             
1008
-                            <div class="tab-section" id="tabTV_' . $row['category_id'] . '">
1009
-                                <div class="tab-header">' . $row['category'] . '</div>
1008
+                            <div class="tab-section" id="tabTV_' . $row['category_id'].'">
1009
+                                <div class="tab-header">' . $row['category'].'</div>
1010 1010
                                 <div class="tab-body tmplvars">
1011 1011
                                     <table>';
1012 1012
                                                 }
1013 1013
                                             } else if ($group_tvs == 2 || $group_tvs == 4) {
1014 1014
                                                 if ($i === 0) {
1015 1015
                                                     $templateVariables .= '
1016
-                            <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars">
1017
-                                <h2 class="tab">' . $row['category'] . '</h2>
1018
-                                <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script>
1016
+                            <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars">
1017
+                                <h2 class="tab">' . $row['category'].'</h2>
1018
+                                <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script>
1019 1019
                                 
1020 1020
                                 <div class="tab-body tmplvars">
1021 1021
                                     <table>';
@@ -1025,9 +1025,9 @@  discard block
 block discarded – undo
1025 1025
                                 </div>
1026 1026
                             </div>
1027 1027
                             
1028
-                            <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars">
1029
-                                <h2 class="tab">' . $row['category'] . '</h2>
1030
-                                <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script>
1028
+                            <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars">
1029
+                                <h2 class="tab">' . $row['category'].'</h2>
1030
+                                <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script>
1031 1031
                                 
1032 1032
                                 <div class="tab-body tmplvars">
1033 1033
                                     <table>';
@@ -1035,18 +1035,18 @@  discard block
 block discarded – undo
1035 1035
                                             } else if ($group_tvs == 5) {
1036 1036
                                                 if ($i === 0) {
1037 1037
                                                     $templateVariables .= '
1038
-                                <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars">
1039
-                                    <h2 class="tab">' . $row['category'] . '</h2>
1040
-                                    <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script>
1038
+                                <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars">
1039
+                                    <h2 class="tab">' . $row['category'].'</h2>
1040
+                                    <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script>
1041 1041
                                     <table>';
1042 1042
                                                 } else {
1043 1043
                                                     $templateVariables .= '
1044 1044
                                     </table>
1045 1045
                                 </div>
1046 1046
                                 
1047
-                                <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars">
1048
-                                    <h2 class="tab">' . $row['category'] . '</h2>
1049
-                                    <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script>
1047
+                                <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars">
1048
+                                    <h2 class="tab">' . $row['category'].'</h2>
1049
+                                    <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script>
1050 1050
                                     
1051 1051
                                     <table>';
1052 1052
                                                 }
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
                                                 $editor = isset($tvOptions['editor']) ? $tvOptions['editor'] : $modx->config['which_editor'];
1065 1065
                                             };
1066 1066
                                             // Add richtext editor to the list
1067
-                                            $richtexteditorIds[$editor][] = "tv" . $row['id'];
1068
-                                            $richtexteditorOptions[$editor]["tv" . $row['id']] = $tvOptions;
1067
+                                            $richtexteditorIds[$editor][] = "tv".$row['id'];
1068
+                                            $richtexteditorOptions[$editor]["tv".$row['id']] = $tvOptions;
1069 1069
                                         }
1070 1070
                                         // splitter
1071 1071
                                         if ($group_tvs) {
@@ -1079,24 +1079,24 @@  discard block
 block discarded – undo
1079 1079
                                         }
1080 1080
 
1081 1081
                                         // post back value
1082
-                                        if (array_key_exists('tv' . $row['id'], $_POST)) {
1083
-                                            if (is_array($_POST['tv' . $row['id']])) {
1084
-                                                $tvPBV = implode('||', $_POST['tv' . $row['id']]);
1082
+                                        if (array_key_exists('tv'.$row['id'], $_POST)) {
1083
+                                            if (is_array($_POST['tv'.$row['id']])) {
1084
+                                                $tvPBV = implode('||', $_POST['tv'.$row['id']]);
1085 1085
                                             } else {
1086
-                                                $tvPBV = $_POST['tv' . $row['id']];
1086
+                                                $tvPBV = $_POST['tv'.$row['id']];
1087 1087
                                             }
1088 1088
                                         } else {
1089 1089
                                             $tvPBV = $row['value'];
1090 1090
                                         }
1091 1091
 
1092
-                                        $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">' . $row['description'] . '</span>' : '';
1093
-                                        $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">(' . $_lang['tmplvars_inherited'] . ')</span>' : '';
1094
-                                        $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*' . $row['name'] . '*]</small>' : '';
1092
+                                        $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">'.$row['description'].'</span>' : '';
1093
+                                        $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">('.$_lang['tmplvars_inherited'].')</span>' : '';
1094
+                                        $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*'.$row['name'].'*]</small>' : '';
1095 1095
 
1096 1096
                                         $templateVariables .= '
1097 1097
                                         <tr>
1098
-                                            <td><span class="warning">' . $row['caption'] . $tvName . '</span>' . $tvDescription . $tvInherited . '</td>
1099
-                                            <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '') . '">' . renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray) . '</div></td>
1098
+                                            <td><span class="warning">' . $row['caption'].$tvName.'</span>'.$tvDescription.$tvInherited.'</td>
1099
+                                            <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '').'">'.renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray).'</div></td>
1100 1100
                                         </tr>';
1101 1101
 
1102 1102
                                         $tab = $row['category_id'];
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 								<?php
1192 1192
 
1193
-								if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1193
+								if ($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1194 1194
 									?>
1195 1195
 									<tr>
1196 1196
 										<td>
@@ -1213,13 +1213,13 @@  discard block
 block discarded – undo
1213 1213
 										<td>
1214 1214
 											<select name="contentType" class="inputBox" onchange="documentDirty=true;">
1215 1215
 												<?php
1216
-												if(!$content['contentType']) {
1216
+												if (!$content['contentType']) {
1217 1217
 													$content['contentType'] = 'text/html';
1218 1218
 												}
1219 1219
 												$custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml");
1220 1220
 												$ct = explode(",", $custom_contenttype);
1221
-												for($i = 0; $i < count($ct); $i++) {
1222
-													echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n";
1221
+												for ($i = 0; $i < count($ct); $i++) {
1222
+													echo "\t\t\t\t\t".'<option value="'.$ct[$i].'"'.($content['contentType'] == $ct[$i] ? ' selected="selected"' : '').'>'.$ct[$i]."</option>\n";
1223 1223
 												}
1224 1224
 												?>
1225 1225
 											</select>
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 									</tr>
1246 1246
 									<?php
1247 1247
 								} else {
1248
-									if($content['type'] != 'reference' && $modx->manager->action != '72') {
1248
+									if ($content['type'] != 'reference' && $modx->manager->action != '72') {
1249 1249
 										// non-admin managers creating or editing a document resource
1250 1250
 										?>
1251 1251
 										<input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" />
@@ -1345,15 +1345,15 @@  discard block
 block discarded – undo
1345 1345
 						<?php
1346 1346
 					/*******************************
1347 1347
 					 * Document Access Permissions */
1348
-					if($use_udperms == 1) {
1348
+					if ($use_udperms == 1) {
1349 1349
 						$groupsarray = array();
1350 1350
 						$sql = '';
1351 1351
 
1352 1352
 						$documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']));
1353
-						if($documentId > 0) {
1353
+						if ($documentId > 0) {
1354 1354
 							// Load up, the permissions from the parent (if new document) or existing document
1355 1355
 							$rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1356
-							while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1356
+							while ($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'].','.$currentgroup['id'];
1357 1357
 
1358 1358
 							// Load up the current permissions and names
1359 1359
 							$vs = array(
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
 						}
1370 1370
 
1371 1371
 						// retain selected doc groups between post
1372
-						if(isset($_POST['docgroups'])) {
1372
+						if (isset($_POST['docgroups'])) {
1373 1373
 							$groupsarray = array_merge($groupsarray, $_POST['docgroups']);
1374 1374
 						}
1375 1375
 
@@ -1388,26 +1388,26 @@  discard block
 block discarded – undo
1388 1388
 						$permissions_no = 0; // count permissions the current mgr user doesn't have
1389 1389
 
1390 1390
 						// Loop through the permissions list
1391
-						while($row = $modx->db->getRow($rs)) {
1391
+						while ($row = $modx->db->getRow($rs)) {
1392 1392
 
1393 1393
 							// Create an inputValue pair (group ID and group link (if it exists))
1394
-							$inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new');
1395
-							$inputId = 'group-' . $row['id'];
1394
+							$inputValue = $row['id'].','.($row['link_id'] ? $row['link_id'] : 'new');
1395
+							$inputId = 'group-'.$row['id'];
1396 1396
 
1397 1397
 							$checked = in_array($inputValue, $groupsarray);
1398
-							if($checked) {
1398
+							if ($checked) {
1399 1399
 								$notPublic = true;
1400 1400
 							} // Mark as private access (either web or manager)
1401 1401
 
1402 1402
 							// Skip the access permission if the user doesn't have access...
1403
-							if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1403
+							if ((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1404 1404
 								continue;
1405 1405
 							}
1406 1406
 
1407 1407
 							// Setup attributes for this Input box
1408 1408
 							$inputAttributes['id'] = $inputId;
1409 1409
 							$inputAttributes['value'] = $inputValue;
1410
-							if($checked) {
1410
+							if ($checked) {
1411 1411
 								$inputAttributes['checked'] = 'checked';
1412 1412
 							} else {
1413 1413
 								unset($inputAttributes['checked']);
@@ -1415,10 +1415,10 @@  discard block
 block discarded – undo
1415 1415
 
1416 1416
 							// Create attribute string list
1417 1417
 							$inputString = array();
1418
-							foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1418
+							foreach ($inputAttributes as $k => $v) $inputString[] = $k.'="'.$v.'"';
1419 1419
 
1420 1420
 							// Make the <input> HTML
1421
-							$inputHTML = '<input ' . implode(' ', $inputString) . ' />';
1421
+							$inputHTML = '<input '.implode(' ', $inputString).' />';
1422 1422
 
1423 1423
 							// does user have this permission?
1424 1424
 							$from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg";
@@ -1429,23 +1429,23 @@  discard block
 block discarded – undo
1429 1429
 							$where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs);
1430 1430
 							$rsp = $modx->db->select('COUNT(mg.id)', $from, $where);
1431 1431
 							$count = $modx->db->getValue($rsp);
1432
-							if($count > 0) {
1432
+							if ($count > 0) {
1433 1433
 								++$permissions_yes;
1434 1434
 							} else {
1435 1435
 								++$permissions_no;
1436 1436
 							}
1437
-							$permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>';
1437
+							$permissions[] = "\t\t".'<li>'.$inputHTML.'<label for="'.$inputId.'">'.$row['name'].'</label></li>';
1438 1438
 						}
1439 1439
 						// if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public
1440
-						if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1440
+						if ($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1441 1441
 							$permissions = array();
1442 1442
 						}
1443 1443
 
1444 1444
 						// See if the Access Permissions section is worth displaying...
1445
-						if(!empty($permissions)) {
1445
+						if (!empty($permissions)) {
1446 1446
 							// Add the "All Document Groups" item if we have rights in both contexts
1447
-							if($isManager && $isWeb) {
1448
-								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>');
1447
+							if ($isManager && $isWeb) {
1448
+								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>');
1449 1449
 							}
1450 1450
 							// Output the permissions list...
1451 1451
 							?>
@@ -1478,12 +1478,12 @@  discard block
 block discarded – undo
1478 1478
 								</script>
1479 1479
 								<p><?= $_lang['access_permissions_docs_message'] ?></p>
1480 1480
 								<ul>
1481
-									<?= implode("\n", $permissions) . "\n" ?>
1481
+									<?= implode("\n", $permissions)."\n" ?>
1482 1482
 								</ul>
1483 1483
 							</div><!--div class="tab-page" id="tabAccess"-->
1484 1484
 							<?php
1485 1485
 						} // !empty($permissions)
1486
-						elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1486
+						elseif ($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1487 1487
 							?>
1488 1488
 							<p><?= $_lang["access_permissions_docs_collision"] ?></p>
1489 1489
 							<?php
@@ -1503,7 +1503,7 @@  discard block
 block discarded – undo
1503 1503
 						'template' => $content['template']
1504 1504
 					));
1505 1505
 
1506
-					if(is_array($evtOut)) {
1506
+					if (is_array($evtOut)) {
1507 1507
 						echo implode('', $evtOut);
1508 1508
 					}
1509 1509
 					?>
@@ -1516,16 +1516,16 @@  discard block
 block discarded – undo
1516 1516
 		storeCurTemplate();
1517 1517
 	</script>
1518 1518
 <?php
1519
-if(($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) {
1520
-	if(is_array($richtexteditorIds)) {
1521
-		foreach($richtexteditorIds as $editor => $elements) {
1519
+if (($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) {
1520
+	if (is_array($richtexteditorIds)) {
1521
+		foreach ($richtexteditorIds as $editor => $elements) {
1522 1522
 			// invoke OnRichTextEditorInit event
1523 1523
 			$evtOut = $modx->invokeEvent('OnRichTextEditorInit', array(
1524 1524
 				'editor' => $editor,
1525 1525
 				'elements' => $elements,
1526 1526
 				'options' => $richtexteditorOptions[$editor]
1527 1527
 			));
1528
-			if(is_array($evtOut)) {
1528
+			if (is_array($evtOut)) {
1529 1529
 				echo implode('', $evtOut);
1530 1530
 			}
1531 1531
 		}
@@ -1535,37 +1535,37 @@  discard block
 block discarded – undo
1535 1535
 /**
1536 1536
  * @return string
1537 1537
  */
1538
-function getDefaultTemplate() {
1538
+function getDefaultTemplate(){
1539 1539
 	$modx = evolutionCMS();
1540 1540
 
1541 1541
     $default_template = '';
1542
-	switch($modx->config['auto_template_logic']) {
1542
+	switch ($modx->config['auto_template_logic']) {
1543 1543
 		case 'sibling':
1544
-			if(!isset($_GET['pid']) || empty($_GET['pid'])) {
1544
+			if (!isset($_GET['pid']) || empty($_GET['pid'])) {
1545 1545
 				$site_start = $modx->config['site_start'];
1546 1546
 				$where = "sc.isfolder=0 AND sc.id!='{$site_start}'";
1547 1547
 				$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1);
1548
-				if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1548
+				if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1549 1549
 					$default_template = $sibl[0]['template'];
1550 1550
 				}
1551 1551
 			} else {
1552 1552
 				$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1553
-				if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1553
+				if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1554 1554
 					$default_template = $sibl[0]['template'];
1555 1555
 				} else {
1556 1556
 					$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1557
-					if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1557
+					if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1558 1558
 						$default_template = $sibl[0]['template'];
1559 1559
 					}
1560 1560
 				}
1561 1561
 			}
1562
-			if(isset($default_template)) {
1562
+			if (isset($default_template)) {
1563 1563
 				break;
1564 1564
 			} // If $default_template could not be determined, fall back / through to "parent"-mode
1565 1565
 		case 'parent':
1566
-			if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) {
1566
+			if (isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) {
1567 1567
 				$parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template');
1568
-				if(isset($parent['template'])) {
1568
+				if (isset($parent['template'])) {
1569 1569
 					$default_template = $parent['template'];
1570 1570
 				}
1571 1571
 			}
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -478,7 +478,8 @@  discard block
 block discarded – undo
478 478
 			return s;
479 479
 		}
480 480
 
481
-		<?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?>
481
+		<?php if ($content['type'] == 'reference' || $modx->manager->action == '72') {
482
+// Web Link specific ?>
482 483
 		var lastImageCtrl;
483 484
 		var lastFileCtrl;
484 485
 
@@ -694,7 +695,8 @@  discard block
 block discarded – undo
694 695
 									</td>
695 696
 								</tr>
696 697
 
697
-								<?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?>
698
+								<?php if($content['type'] == 'reference' || $modx->manager->action == '72') {
699
+// Web Link specific ?>
698 700
 
699 701
 									<tr>
700 702
 										<td><span class="warning"><?= $_lang['weblink'] ?></span>
@@ -1353,7 +1355,9 @@  discard block
 block discarded – undo
1353 1355
 						if($documentId > 0) {
1354 1356
 							// Load up, the permissions from the parent (if new document) or existing document
1355 1357
 							$rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1356
-							while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1358
+							while($currentgroup = $modx->db->getRow($rs)) {
1359
+							    $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1360
+							}
1357 1361
 
1358 1362
 							// Load up the current permissions and names
1359 1363
 							$vs = array(
@@ -1415,7 +1419,9 @@  discard block
 block discarded – undo
1415 1419
 
1416 1420
 							// Create attribute string list
1417 1421
 							$inputString = array();
1418
-							foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1422
+							foreach($inputAttributes as $k => $v) {
1423
+							    $inputString[] = $k . '="' . $v . '"';
1424
+							}
1419 1425
 
1420 1426
 							// Make the <input> HTML
1421 1427
 							$inputHTML = '<input ' . implode(' ', $inputString) . ' />';
@@ -1535,7 +1541,8 @@  discard block
 block discarded – undo
1535 1541
 /**
1536 1542
  * @return string
1537 1543
  */
1538
-function getDefaultTemplate() {
1544
+function getDefaultTemplate()
1545
+{
1539 1546
 	$modx = evolutionCMS();
1540 1547
 
1541 1548
     $default_template = '';
Please login to merge, or discard this patch.
manager/actions/resources/functions.inc.php 3 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
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
 $tpl = array(
7
-	'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'),
8
-	'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'),
9
-	'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'),
10
-	'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'),
11
-	'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl')
7
+    'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'),
8
+    'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'),
9
+    'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'),
10
+    'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'),
11
+    'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl')
12 12
 );
13 13
 
14 14
 /**
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
  * @return string
18 18
  */
19 19
 function parsePh($tpl, $ph) {
20
-	$modx = evolutionCMS(); global $_lang;
21
-	$tpl = $modx->parseText($tpl, $_lang, '[%', '%]');
22
-	return $modx->parseText($tpl, $ph);
20
+    $modx = evolutionCMS(); global $_lang;
21
+    $tpl = $modx->parseText($tpl, $_lang, '[%', '%]');
22
+    return $modx->parseText($tpl, $ph);
23 23
 }
24 24
 
25 25
 /**
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
  * @return string
28 28
  */
29 29
 function renderViewSwitchButtons($cssId) {
30
-	$modx = evolutionCMS(); global $_lang, $tpl;
30
+    $modx = evolutionCMS(); global $_lang, $tpl;
31 31
 
32
-	return parsePh($tpl['viewForm'], array(
33
-		'cssId' => $cssId
34
-	));
32
+    return parsePh($tpl['viewForm'], array(
33
+        'cssId' => $cssId
34
+    ));
35 35
 }
36 36
 
37 37
 /**
@@ -40,52 +40,52 @@  discard block
 block discarded – undo
40 40
  * @return string
41 41
  */
42 42
 function createResourceList($resourceTable, $resources) {
43
-	$modx = evolutionCMS(); global $_lang, $_style, $modx_textdir, $tpl;
43
+    $modx = evolutionCMS(); global $_lang, $_style, $modx_textdir, $tpl;
44 44
 
45
-	$items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false;
45
+    $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false;
46 46
 
47
-	if( ! is_array($items) || empty($items)) {
48
-		return $_lang['no_results'];
49
-	}
47
+    if( ! is_array($items) || empty($items)) {
48
+        return $_lang['no_results'];
49
+    }
50 50
 
51
-	// Prepare elements- and categories-list
52
-	$elements = array();
53
-	$categories = array();
54
-	foreach($items as $row) {
55
-		$catid = $row['catid'] ? $row['catid'] : 0;
56
-		$categories[$catid] = array('name' => stripslashes($row['category']));
57
-		$elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources);
58
-	}
51
+    // Prepare elements- and categories-list
52
+    $elements = array();
53
+    $categories = array();
54
+    foreach($items as $row) {
55
+        $catid = $row['catid'] ? $row['catid'] : 0;
56
+        $categories[$catid] = array('name' => stripslashes($row['category']));
57
+        $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources);
58
+    }
59 59
 
60
-	// Now render categories / panel-collapse
61
-	$panelGroup = '';
62
-	foreach($elements as $catid => $elList) {
63
-		// Add panel-heading / category-collapse to output
64
-		$panelGroup .= parsePh($tpl['panelHeading'], array(
65
-			'tab' => $resourceTable,
66
-			'category' => $categories[$catid]['name'],
67
-			'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
68
-			'catid' => $catid,
69
-		));
60
+    // Now render categories / panel-collapse
61
+    $panelGroup = '';
62
+    foreach($elements as $catid => $elList) {
63
+        // Add panel-heading / category-collapse to output
64
+        $panelGroup .= parsePh($tpl['panelHeading'], array(
65
+            'tab' => $resourceTable,
66
+            'category' => $categories[$catid]['name'],
67
+            'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
68
+            'catid' => $catid,
69
+        ));
70 70
 
71
-		// Prepare content for panel-collapse
72
-		$panelCollapse = '';
73
-		foreach($elList as $el) {
74
-			$panelCollapse .= parsePh($tpl['elementsRow'], $el);
75
-		}
71
+        // Prepare content for panel-collapse
72
+        $panelCollapse = '';
73
+        foreach($elList as $el) {
74
+            $panelCollapse .= parsePh($tpl['elementsRow'], $el);
75
+        }
76 76
 
77
-		// Add panel-collapse with elements to output
78
-		$panelGroup .= parsePh($tpl['panelCollapse'], array(
79
-			'tab' => $resourceTable,
80
-			'catid' => $catid,
81
-			'wrapper' => $panelCollapse,
82
-		));
83
-	}
77
+        // Add panel-collapse with elements to output
78
+        $panelGroup .= parsePh($tpl['panelCollapse'], array(
79
+            'tab' => $resourceTable,
80
+            'catid' => $catid,
81
+            'wrapper' => $panelCollapse,
82
+        ));
83
+    }
84 84
 
85
-	return parsePh($tpl['panelGroup'], array(
86
-		'resourceTable' => $resourceTable,
87
-		'wrapper' => $panelGroup
88
-	));
85
+    return parsePh($tpl['panelGroup'], array(
86
+        'resourceTable' => $resourceTable,
87
+        'wrapper' => $panelGroup
88
+    ));
89 89
 }
90 90
 
91 91
 /**
@@ -93,54 +93,54 @@  discard block
 block discarded – undo
93 93
  * @return string
94 94
  */
95 95
 function createCombinedView($resources) {
96
-	$modx = evolutionCMS(); global $_lang, $_style, $modx_textdir;
96
+    $modx = evolutionCMS(); global $_lang, $_style, $modx_textdir;
97 97
 
98
-	$itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false;
99
-	$types = isset($resources->types) ? $resources->types : false;
100
-	$categories = isset($resources->categories) ? $resources->categories : false;
98
+    $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false;
99
+    $types = isset($resources->types) ? $resources->types : false;
100
+    $categories = isset($resources->categories) ? $resources->categories : false;
101 101
 
102
-	if(!$itemsPerCategory) {
103
-		return $_lang['no_results'];
104
-	}
102
+    if(!$itemsPerCategory) {
103
+        return $_lang['no_results'];
104
+    }
105 105
 
106
-	$tpl = array(
107
-		'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'),
108
-		'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'),
109
-		'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'),
110
-		'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'),
111
-	);
106
+    $tpl = array(
107
+        'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'),
108
+        'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'),
109
+        'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'),
110
+        'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'),
111
+    );
112 112
 
113
-	// Easily loop through $itemsPerCategory-Array
114
-	$panelGroup = '';
115
-	foreach($categories as $catid => $category) {
116
-		// Prepare collapse content / elements-list
117
-		$panelCollapse = '';
118
-		foreach($itemsPerCategory[$catid] as $el) {
119
-			$resourceTable = $el['type'];
120
-			$ph = prepareElementRowPh($el, $resourceTable, $resources);
121
-			$panelCollapse .= parsePh($tpl['elementsRow'], $ph);
122
-		}
113
+    // Easily loop through $itemsPerCategory-Array
114
+    $panelGroup = '';
115
+    foreach($categories as $catid => $category) {
116
+        // Prepare collapse content / elements-list
117
+        $panelCollapse = '';
118
+        foreach($itemsPerCategory[$catid] as $el) {
119
+            $resourceTable = $el['type'];
120
+            $ph = prepareElementRowPh($el, $resourceTable, $resources);
121
+            $panelCollapse .= parsePh($tpl['elementsRow'], $ph);
122
+        }
123 123
 
124
-		// Add panel-heading / button
125
-		$panelGroup .= parsePh($tpl['panelHeading'], array(
126
-			'tab' => 'categories_list',
127
-			'category' => $categories[$catid],
128
-			'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
129
-			'catid' => $catid,
130
-		));
124
+        // Add panel-heading / button
125
+        $panelGroup .= parsePh($tpl['panelHeading'], array(
126
+            'tab' => 'categories_list',
127
+            'category' => $categories[$catid],
128
+            'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
129
+            'catid' => $catid,
130
+        ));
131 131
 
132
-		// Add panel
133
-		$panelGroup .= parsePh($tpl['panelCollapse'], array(
134
-			'tab' => 'categories_list',
135
-			'catid' => $catid,
136
-			'wrapper' => $panelCollapse,
137
-		));
138
-	}
132
+        // Add panel
133
+        $panelGroup .= parsePh($tpl['panelCollapse'], array(
134
+            'tab' => 'categories_list',
135
+            'catid' => $catid,
136
+            'wrapper' => $panelCollapse,
137
+        ));
138
+    }
139 139
 
140
-	return parsePh($tpl['panelGroup'], array(
141
-		'resourceTable' => 'categories_list',
142
-		'wrapper' => $panelGroup
143
-	));
140
+    return parsePh($tpl['panelGroup'], array(
141
+        'resourceTable' => 'categories_list',
142
+        'wrapper' => $panelGroup
143
+    ));
144 144
 }
145 145
 
146 146
 /**
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
  * @return array
151 151
  */
152 152
 function prepareElementRowPh($row, $resourceTable, $resources) {
153
-	$modx = evolutionCMS(); global $modx_textdir, $_style, $_lang;
153
+    $modx = evolutionCMS(); global $modx_textdir, $_style, $_lang;
154 154
 
155
-	$types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false;
155
+    $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false;
156 156
 
157
-	$_lang["confirm_delete"] = $_lang["delete"];
157
+    $_lang["confirm_delete"] = $_lang["delete"];
158 158
 
159
-	switch($resourceTable){
159
+    switch($resourceTable){
160 160
         case 'site_templates':
161 161
             $class = $row['selectable'] ? '' : 'disabledPlugin';
162 162
             $lockElementType = 1;
@@ -190,77 +190,77 @@  discard block
 block discarded – undo
190 190
             return array();
191 191
     }
192 192
 
193
-	// Prepare displaying user-locks
194
-	$lockedByUser = '';
195
-	$rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true);
196
-	if($rowLock && $modx->hasPermission('display_locks')) {
197
-		if($rowLock['sid'] == $modx->sid) {
198
-			$title = $modx->parseText($_lang["lock_element_editing"], array(
199
-				'element_type' => $_lang["lock_element_type_" . $lockElementType],
200
-				'lasthit_df' => $rowLock['lasthit_df']
201
-			));
202
-			$lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span>&nbsp;';
203
-		} else {
204
-			$title = $modx->parseText($_lang["lock_element_locked_by"], array(
205
-				'element_type' => $_lang["lock_element_type_" . $lockElementType],
206
-				'username' => $rowLock['username'],
207
-				'lasthit_df' => $rowLock['lasthit_df']
208
-			));
209
-			if($modx->hasPermission('remove_locks')) {
210
-				$lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
211
-			} else {
212
-				$lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>';
213
-			}
214
-		}
215
-	}
216
-	if($lockedByUser) {
217
-		$lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>';
218
-	}
193
+    // Prepare displaying user-locks
194
+    $lockedByUser = '';
195
+    $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true);
196
+    if($rowLock && $modx->hasPermission('display_locks')) {
197
+        if($rowLock['sid'] == $modx->sid) {
198
+            $title = $modx->parseText($_lang["lock_element_editing"], array(
199
+                'element_type' => $_lang["lock_element_type_" . $lockElementType],
200
+                'lasthit_df' => $rowLock['lasthit_df']
201
+            ));
202
+            $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span>&nbsp;';
203
+        } else {
204
+            $title = $modx->parseText($_lang["lock_element_locked_by"], array(
205
+                'element_type' => $_lang["lock_element_type_" . $lockElementType],
206
+                'username' => $rowLock['username'],
207
+                'lasthit_df' => $rowLock['lasthit_df']
208
+            ));
209
+            if($modx->hasPermission('remove_locks')) {
210
+                $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
211
+            } else {
212
+                $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>';
213
+            }
214
+        }
215
+    }
216
+    if($lockedByUser) {
217
+        $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>';
218
+    }
219 219
 
220
-	// Caption
221
-	if($resourceTable == 'site_tmplvars') {
222
-		$caption = !empty($row['description']) ? ' ' . $row['caption'] . ' &nbsp; <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
223
-	} else {
224
-		$caption = !empty($row['description']) ? ' ' . $row['description'] : '';
225
-	}
220
+    // Caption
221
+    if($resourceTable == 'site_tmplvars') {
222
+        $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' &nbsp; <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
223
+    } else {
224
+        $caption = !empty($row['description']) ? ' ' . $row['description'] : '';
225
+    }
226 226
 
227
-	// Special marks
228
-	$tplInfo = array();
229
-	if($row['locked']) {
230
-		$tplInfo[] = $_lang['locked'];
231
-	}
232
-	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
233
-		$tplInfo[] = $_lang['defaulttemplate_title'];
234
-	}
235
-	$marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
227
+    // Special marks
228
+    $tplInfo = array();
229
+    if($row['locked']) {
230
+        $tplInfo[] = $_lang['locked'];
231
+    }
232
+    if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
233
+        $tplInfo[] = $_lang['defaulttemplate_title'];
234
+    }
235
+    $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
236 236
 
237
-	/* row buttons */
238
-	$buttons = '';
239
-	if($modx->hasPermission($types['actions']['edit'][1])) {
240
-		$buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>';
241
-	}
242
-	if($modx->hasPermission($types['actions']['duplicate'][1])) {
243
-		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>';
244
-	}
245
-	if($modx->hasPermission($types['actions']['remove'][1])) {
246
-		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>';
247
-	}
248
-	$buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : '';
237
+    /* row buttons */
238
+    $buttons = '';
239
+    if($modx->hasPermission($types['actions']['edit'][1])) {
240
+        $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>';
241
+    }
242
+    if($modx->hasPermission($types['actions']['duplicate'][1])) {
243
+        $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>';
244
+    }
245
+    if($modx->hasPermission($types['actions']['remove'][1])) {
246
+        $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>';
247
+    }
248
+    $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : '';
249 249
 
250
-	$catid = $row['catid'] ? $row['catid'] : 0;
250
+    $catid = $row['catid'] ? $row['catid'] : 0;
251 251
 
252
-	// Placeholders for elements-row
253
-	return array(
254
-		'class' => $class ? ' class="' . $class . '"' : '',
255
-		'lockedByUser' => $lockedByUser,
256
-		'name' => $row['name'],
257
-		'caption' => $caption,
258
-		'buttons' => $buttons,
259
-		'marks' => $marks,
260
-		'id' => $row['id'],
261
-		'resourceTable' => $resourceTable,
262
-		'actionEdit' => $types['actions']['edit'][0],
263
-		'catid' => $catid,
264
-		'textdir' => $modx_textdir ? '&rlm;' : '',
265
-	);
252
+    // Placeholders for elements-row
253
+    return array(
254
+        'class' => $class ? ' class="' . $class . '"' : '',
255
+        'lockedByUser' => $lockedByUser,
256
+        'name' => $row['name'],
257
+        'caption' => $caption,
258
+        'buttons' => $buttons,
259
+        'marks' => $marks,
260
+        'id' => $row['id'],
261
+        'resourceTable' => $resourceTable,
262
+        'actionEdit' => $types['actions']['edit'][0],
263
+        'catid' => $catid,
264
+        'textdir' => $modx_textdir ? '&rlm;' : '',
265
+    );
266 266
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  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
 $tpl = array(
7
-	'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'),
8
-	'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'),
9
-	'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'),
10
-	'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'),
11
-	'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl')
7
+	'viewForm' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_viewForm.tpl'),
8
+	'panelGroup' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelGroup.tpl'),
9
+	'panelHeading' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelHeading.tpl'),
10
+	'panelCollapse' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelCollapse.tpl'),
11
+	'elementsRow' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_elementsRow.tpl')
12 12
 );
13 13
 
14 14
 /**
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @param array $ph
17 17
  * @return string
18 18
  */
19
-function parsePh($tpl, $ph) {
19
+function parsePh($tpl, $ph){
20 20
 	$modx = evolutionCMS(); global $_lang;
21 21
 	$tpl = $modx->parseText($tpl, $_lang, '[%', '%]');
22 22
 	return $modx->parseText($tpl, $ph);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @param string|int $cssId
27 27
  * @return string
28 28
  */
29
-function renderViewSwitchButtons($cssId) {
29
+function renderViewSwitchButtons($cssId){
30 30
 	$modx = evolutionCMS(); global $_lang, $tpl;
31 31
 
32 32
 	return parsePh($tpl['viewForm'], array(
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
  * @param mgrResources $resources
40 40
  * @return string
41 41
  */
42
-function createResourceList($resourceTable, $resources) {
42
+function createResourceList($resourceTable, $resources){
43 43
 	$modx = evolutionCMS(); global $_lang, $_style, $modx_textdir, $tpl;
44 44
 
45 45
 	$items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false;
46 46
 
47
-	if( ! is_array($items) || empty($items)) {
47
+	if (!is_array($items) || empty($items)) {
48 48
 		return $_lang['no_results'];
49 49
 	}
50 50
 
51 51
 	// Prepare elements- and categories-list
52 52
 	$elements = array();
53 53
 	$categories = array();
54
-	foreach($items as $row) {
54
+	foreach ($items as $row) {
55 55
 		$catid = $row['catid'] ? $row['catid'] : 0;
56 56
 		$categories[$catid] = array('name' => stripslashes($row['category']));
57 57
 		$elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources);
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
 
60 60
 	// Now render categories / panel-collapse
61 61
 	$panelGroup = '';
62
-	foreach($elements as $catid => $elList) {
62
+	foreach ($elements as $catid => $elList) {
63 63
 		// Add panel-heading / category-collapse to output
64 64
 		$panelGroup .= parsePh($tpl['panelHeading'], array(
65 65
 			'tab' => $resourceTable,
66 66
 			'category' => $categories[$catid]['name'],
67
-			'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
67
+			'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '',
68 68
 			'catid' => $catid,
69 69
 		));
70 70
 
71 71
 		// Prepare content for panel-collapse
72 72
 		$panelCollapse = '';
73
-		foreach($elList as $el) {
73
+		foreach ($elList as $el) {
74 74
 			$panelCollapse .= parsePh($tpl['elementsRow'], $el);
75 75
 		}
76 76
 
@@ -92,30 +92,30 @@  discard block
 block discarded – undo
92 92
  * @param mgrResources $resources
93 93
  * @return string
94 94
  */
95
-function createCombinedView($resources) {
95
+function createCombinedView($resources){
96 96
 	$modx = evolutionCMS(); global $_lang, $_style, $modx_textdir;
97 97
 
98 98
 	$itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false;
99 99
 	$types = isset($resources->types) ? $resources->types : false;
100 100
 	$categories = isset($resources->categories) ? $resources->categories : false;
101 101
 
102
-	if(!$itemsPerCategory) {
102
+	if (!$itemsPerCategory) {
103 103
 		return $_lang['no_results'];
104 104
 	}
105 105
 
106 106
 	$tpl = array(
107
-		'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'),
108
-		'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'),
109
-		'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'),
110
-		'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'),
107
+		'panelGroup' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelGroup.tpl'),
108
+		'panelHeading' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelHeading.tpl'),
109
+		'panelCollapse' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelCollapse.tpl'),
110
+		'elementsRow' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_elementsRow.tpl'),
111 111
 	);
112 112
 
113 113
 	// Easily loop through $itemsPerCategory-Array
114 114
 	$panelGroup = '';
115
-	foreach($categories as $catid => $category) {
115
+	foreach ($categories as $catid => $category) {
116 116
 		// Prepare collapse content / elements-list
117 117
 		$panelCollapse = '';
118
-		foreach($itemsPerCategory[$catid] as $el) {
118
+		foreach ($itemsPerCategory[$catid] as $el) {
119 119
 			$resourceTable = $el['type'];
120 120
 			$ph = prepareElementRowPh($el, $resourceTable, $resources);
121 121
 			$panelCollapse .= parsePh($tpl['elementsRow'], $ph);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		$panelGroup .= parsePh($tpl['panelHeading'], array(
126 126
 			'tab' => 'categories_list',
127 127
 			'category' => $categories[$catid],
128
-			'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
128
+			'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '',
129 129
 			'catid' => $catid,
130 130
 		));
131 131
 
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
  * @param mgrResources $resources
150 150
  * @return array
151 151
  */
152
-function prepareElementRowPh($row, $resourceTable, $resources) {
152
+function prepareElementRowPh($row, $resourceTable, $resources){
153 153
 	$modx = evolutionCMS(); global $modx_textdir, $_style, $_lang;
154 154
 
155 155
 	$types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false;
156 156
 
157 157
 	$_lang["confirm_delete"] = $_lang["delete"];
158 158
 
159
-	switch($resourceTable){
159
+	switch ($resourceTable) {
160 160
         case 'site_templates':
161 161
             $class = $row['selectable'] ? '' : 'disabledPlugin';
162 162
             $lockElementType = 1;
@@ -193,65 +193,65 @@  discard block
 block discarded – undo
193 193
 	// Prepare displaying user-locks
194 194
 	$lockedByUser = '';
195 195
 	$rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true);
196
-	if($rowLock && $modx->hasPermission('display_locks')) {
197
-		if($rowLock['sid'] == $modx->sid) {
196
+	if ($rowLock && $modx->hasPermission('display_locks')) {
197
+		if ($rowLock['sid'] == $modx->sid) {
198 198
 			$title = $modx->parseText($_lang["lock_element_editing"], array(
199
-				'element_type' => $_lang["lock_element_type_" . $lockElementType],
199
+				'element_type' => $_lang["lock_element_type_".$lockElementType],
200 200
 				'lasthit_df' => $rowLock['lasthit_df']
201 201
 			));
202
-			$lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span>&nbsp;';
202
+			$lockedByUser = '<span title="'.$title.'" class="editResource" style="cursor:context-menu;">'.$_style['tree_preview_resource'].'</span>&nbsp;';
203 203
 		} else {
204 204
 			$title = $modx->parseText($_lang["lock_element_locked_by"], array(
205
-				'element_type' => $_lang["lock_element_type_" . $lockElementType],
205
+				'element_type' => $_lang["lock_element_type_".$lockElementType],
206 206
 				'username' => $rowLock['username'],
207 207
 				'lasthit_df' => $rowLock['lasthit_df']
208 208
 			));
209
-			if($modx->hasPermission('remove_locks')) {
210
-				$lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
209
+			if ($modx->hasPermission('remove_locks')) {
210
+				$lockedByUser = '<a href="javascript:;" onclick="unlockElement('.$lockElementType.', '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource"><i class="'.$_style['icons_secured'].'"></i></a>';
211 211
 			} else {
212
-				$lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>';
212
+				$lockedByUser = '<span title="'.$title.'" class="lockedResource" style="cursor:context-menu;"><i class="'.$_style['icons_secured'].'"></i></span>';
213 213
 			}
214 214
 		}
215 215
 	}
216
-	if($lockedByUser) {
217
-		$lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>';
216
+	if ($lockedByUser) {
217
+		$lockedByUser = '<div class="lockCell">'.$lockedByUser.'</div>';
218 218
 	}
219 219
 
220 220
 	// Caption
221
-	if($resourceTable == 'site_tmplvars') {
222
-		$caption = !empty($row['description']) ? ' ' . $row['caption'] . ' &nbsp; <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
221
+	if ($resourceTable == 'site_tmplvars') {
222
+		$caption = !empty($row['description']) ? ' '.$row['caption'].' &nbsp; <small>('.$row['description'].')</small>' : ' '.$row['caption'];
223 223
 	} else {
224
-		$caption = !empty($row['description']) ? ' ' . $row['description'] : '';
224
+		$caption = !empty($row['description']) ? ' '.$row['description'] : '';
225 225
 	}
226 226
 
227 227
 	// Special marks
228 228
 	$tplInfo = array();
229
-	if($row['locked']) {
229
+	if ($row['locked']) {
230 230
 		$tplInfo[] = $_lang['locked'];
231 231
 	}
232
-	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
232
+	if ($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
233 233
 		$tplInfo[] = $_lang['defaulttemplate_title'];
234 234
 	}
235
-	$marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
235
+	$marks = !empty($tplInfo) ? ' <em>('.implode(', ', $tplInfo).')</em>' : '';
236 236
 
237 237
 	/* row buttons */
238 238
 	$buttons = '';
239
-	if($modx->hasPermission($types['actions']['edit'][1])) {
240
-		$buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>';
239
+	if ($modx->hasPermission($types['actions']['edit'][1])) {
240
+		$buttons .= '<li><a title="'.$_lang["edit_resource"].'" href="index.php?a='.$types['actions']['edit'][0].'&amp;id='.$row['id'].'"><i class="fa fa-edit fa-fw"></i></a></li>';
241 241
 	}
242
-	if($modx->hasPermission($types['actions']['duplicate'][1])) {
243
-		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>';
242
+	if ($modx->hasPermission($types['actions']['duplicate'][1])) {
243
+		$buttons .= '<li><a onclick="return confirm(\''.$_lang["confirm_duplicate_record"].'\')" title="'.$_lang["resource_duplicate"].'" href="index.php?a='.$types['actions']['duplicate'][0].'&amp;id='.$row['id'].'"><i class="fa fa-clone fa-fw"></i></a></li>';
244 244
 	}
245
-	if($modx->hasPermission($types['actions']['remove'][1])) {
246
-		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>';
245
+	if ($modx->hasPermission($types['actions']['remove'][1])) {
246
+		$buttons .= '<li><a onclick="return confirm(\''.$_lang["confirm_delete"].'\')" title="'.$_lang["delete"].'" href="index.php?a='.$types['actions']['remove'][0].'&amp;id='.$row['id'].'"><i class="fa fa-trash fa-fw"></i></a></li>';
247 247
 	}
248
-	$buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : '';
248
+	$buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">'.$buttons.'</ul></div>' : '';
249 249
 
250 250
 	$catid = $row['catid'] ? $row['catid'] : 0;
251 251
 
252 252
 	// Placeholders for elements-row
253 253
 	return array(
254
-		'class' => $class ? ' class="' . $class . '"' : '',
254
+		'class' => $class ? ' class="'.$class.'"' : '',
255 255
 		'lockedByUser' => $lockedByUser,
256 256
 		'name' => $row['name'],
257 257
 		'caption' => $caption,
Please login to merge, or discard this patch.
Braces   +32 added lines, -27 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
 
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
  * @param array $ph
17 17
  * @return string
18 18
  */
19
-function parsePh($tpl, $ph) {
19
+function parsePh($tpl, $ph)
20
+{
20 21
 	$modx = evolutionCMS(); global $_lang;
21 22
 	$tpl = $modx->parseText($tpl, $_lang, '[%', '%]');
22 23
 	return $modx->parseText($tpl, $ph);
@@ -26,7 +27,8 @@  discard block
 block discarded – undo
26 27
  * @param string|int $cssId
27 28
  * @return string
28 29
  */
29
-function renderViewSwitchButtons($cssId) {
30
+function renderViewSwitchButtons($cssId)
31
+{
30 32
 	$modx = evolutionCMS(); global $_lang, $tpl;
31 33
 
32 34
 	return parsePh($tpl['viewForm'], array(
@@ -39,19 +41,20 @@  discard block
 block discarded – undo
39 41
  * @param mgrResources $resources
40 42
  * @return string
41 43
  */
42
-function createResourceList($resourceTable, $resources) {
44
+function createResourceList($resourceTable, $resources)
45
+{
43 46
 	$modx = evolutionCMS(); global $_lang, $_style, $modx_textdir, $tpl;
44 47
 
45 48
 	$items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false;
46 49
 
47
-	if( ! is_array($items) || empty($items)) {
50
+	if( ! is_array($items) || empty($items)) {
48 51
 		return $_lang['no_results'];
49 52
 	}
50 53
 
51 54
 	// Prepare elements- and categories-list
52 55
 	$elements = array();
53 56
 	$categories = array();
54
-	foreach($items as $row) {
57
+	foreach($items as $row) {
55 58
 		$catid = $row['catid'] ? $row['catid'] : 0;
56 59
 		$categories[$catid] = array('name' => stripslashes($row['category']));
57 60
 		$elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources);
@@ -59,7 +62,7 @@  discard block
 block discarded – undo
59 62
 
60 63
 	// Now render categories / panel-collapse
61 64
 	$panelGroup = '';
62
-	foreach($elements as $catid => $elList) {
65
+	foreach($elements as $catid => $elList) {
63 66
 		// Add panel-heading / category-collapse to output
64 67
 		$panelGroup .= parsePh($tpl['panelHeading'], array(
65 68
 			'tab' => $resourceTable,
@@ -70,7 +73,7 @@  discard block
 block discarded – undo
70 73
 
71 74
 		// Prepare content for panel-collapse
72 75
 		$panelCollapse = '';
73
-		foreach($elList as $el) {
76
+		foreach($elList as $el) {
74 77
 			$panelCollapse .= parsePh($tpl['elementsRow'], $el);
75 78
 		}
76 79
 
@@ -92,14 +95,15 @@  discard block
 block discarded – undo
92 95
  * @param mgrResources $resources
93 96
  * @return string
94 97
  */
95
-function createCombinedView($resources) {
98
+function createCombinedView($resources)
99
+{
96 100
 	$modx = evolutionCMS(); global $_lang, $_style, $modx_textdir;
97 101
 
98 102
 	$itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false;
99 103
 	$types = isset($resources->types) ? $resources->types : false;
100 104
 	$categories = isset($resources->categories) ? $resources->categories : false;
101 105
 
102
-	if(!$itemsPerCategory) {
106
+	if(!$itemsPerCategory) {
103 107
 		return $_lang['no_results'];
104 108
 	}
105 109
 
@@ -112,10 +116,10 @@  discard block
 block discarded – undo
112 116
 
113 117
 	// Easily loop through $itemsPerCategory-Array
114 118
 	$panelGroup = '';
115
-	foreach($categories as $catid => $category) {
119
+	foreach($categories as $catid => $category) {
116 120
 		// Prepare collapse content / elements-list
117 121
 		$panelCollapse = '';
118
-		foreach($itemsPerCategory[$catid] as $el) {
122
+		foreach($itemsPerCategory[$catid] as $el) {
119 123
 			$resourceTable = $el['type'];
120 124
 			$ph = prepareElementRowPh($el, $resourceTable, $resources);
121 125
 			$panelCollapse .= parsePh($tpl['elementsRow'], $ph);
@@ -149,14 +153,15 @@  discard block
 block discarded – undo
149 153
  * @param mgrResources $resources
150 154
  * @return array
151 155
  */
152
-function prepareElementRowPh($row, $resourceTable, $resources) {
156
+function prepareElementRowPh($row, $resourceTable, $resources)
157
+{
153 158
 	$modx = evolutionCMS(); global $modx_textdir, $_style, $_lang;
154 159
 
155 160
 	$types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false;
156 161
 
157 162
 	$_lang["confirm_delete"] = $_lang["delete"];
158 163
 
159
-	switch($resourceTable){
164
+	switch($resourceTable) {
160 165
         case 'site_templates':
161 166
             $class = $row['selectable'] ? '' : 'disabledPlugin';
162 167
             $lockElementType = 1;
@@ -193,56 +198,56 @@  discard block
 block discarded – undo
193 198
 	// Prepare displaying user-locks
194 199
 	$lockedByUser = '';
195 200
 	$rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true);
196
-	if($rowLock && $modx->hasPermission('display_locks')) {
197
-		if($rowLock['sid'] == $modx->sid) {
201
+	if($rowLock && $modx->hasPermission('display_locks')) {
202
+		if($rowLock['sid'] == $modx->sid) {
198 203
 			$title = $modx->parseText($_lang["lock_element_editing"], array(
199 204
 				'element_type' => $_lang["lock_element_type_" . $lockElementType],
200 205
 				'lasthit_df' => $rowLock['lasthit_df']
201 206
 			));
202 207
 			$lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span>&nbsp;';
203
-		} else {
208
+		} else {
204 209
 			$title = $modx->parseText($_lang["lock_element_locked_by"], array(
205 210
 				'element_type' => $_lang["lock_element_type_" . $lockElementType],
206 211
 				'username' => $rowLock['username'],
207 212
 				'lasthit_df' => $rowLock['lasthit_df']
208 213
 			));
209
-			if($modx->hasPermission('remove_locks')) {
214
+			if($modx->hasPermission('remove_locks')) {
210 215
 				$lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
211
-			} else {
216
+			} else {
212 217
 				$lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>';
213 218
 			}
214 219
 		}
215 220
 	}
216
-	if($lockedByUser) {
221
+	if($lockedByUser) {
217 222
 		$lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>';
218 223
 	}
219 224
 
220 225
 	// Caption
221
-	if($resourceTable == 'site_tmplvars') {
226
+	if($resourceTable == 'site_tmplvars') {
222 227
 		$caption = !empty($row['description']) ? ' ' . $row['caption'] . ' &nbsp; <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
223
-	} else {
228
+	} else {
224 229
 		$caption = !empty($row['description']) ? ' ' . $row['description'] : '';
225 230
 	}
226 231
 
227 232
 	// Special marks
228 233
 	$tplInfo = array();
229
-	if($row['locked']) {
234
+	if($row['locked']) {
230 235
 		$tplInfo[] = $_lang['locked'];
231 236
 	}
232
-	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
237
+	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
233 238
 		$tplInfo[] = $_lang['defaulttemplate_title'];
234 239
 	}
235 240
 	$marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
236 241
 
237 242
 	/* row buttons */
238 243
 	$buttons = '';
239
-	if($modx->hasPermission($types['actions']['edit'][1])) {
244
+	if($modx->hasPermission($types['actions']['edit'][1])) {
240 245
 		$buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>';
241 246
 	}
242
-	if($modx->hasPermission($types['actions']['duplicate'][1])) {
247
+	if($modx->hasPermission($types['actions']['duplicate'][1])) {
243 248
 		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>';
244 249
 	}
245
-	if($modx->hasPermission($types['actions']['remove'][1])) {
250
+	if($modx->hasPermission($types['actions']['remove'][1])) {
246 251
 		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>';
247 252
 	}
248 253
 	$buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : '';
Please login to merge, or discard this patch.
manager/actions/resources/mgrResources.class.php 3 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
     /**
8 8
      * @var array
9 9
      */
10
-	public $types = array();
10
+    public $types = array();
11 11
     /**
12 12
      * @var array
13 13
      */
@@ -25,73 +25,73 @@  discard block
 block discarded – undo
25 25
      * mgrResources constructor.
26 26
      */
27 27
     public function __construct() {
28
-		$this->setTypes();
29
-		$this->queryItemsFromDB();
30
-		$this->prepareCategoryArrays();
31
-	}
28
+        $this->setTypes();
29
+        $this->queryItemsFromDB();
30
+        $this->prepareCategoryArrays();
31
+    }
32 32
 
33 33
     /**
34 34
      * @return void
35 35
      */
36 36
     public function setTypes() {
37
-		global $_lang;
38
-		$this->types['site_templates']    = array(
39
-			'title'=>$_lang["manage_templates"],
40
-			'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ),
41
-			'permissions'=>array('new_template','edit_template'),
42
-			'name'=>'templatename'
43
-		);
44
-		$this->types['site_tmplvars']     = array(
45
-			'title'=>$_lang["tmplvars"],
46
-			'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')),
47
-			'permissions'=>array('new_template','edit_template'),
48
-		);
49
-		$this->types['site_htmlsnippets'] = array(
50
-			'title'=>$_lang["manage_htmlsnippets"],
51
-			'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')),
52
-			'permissions'=>array('new_chunk','edit_chunk'),
53
-		);
54
-		$this->types['site_snippets']     = array(
55
-			'title'=>$_lang["manage_snippets"],
56
-			'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')),
57
-			'permissions'=>array('new_snippet','edit_snippet'),
58
-		);
59
-		$this->types['site_plugins']      = array(
60
-			'title'=>$_lang["manage_plugins"],
61
-			'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')),
62
-			'permissions'=>array('new_plugin','edit_plugin'),
63
-		);
64
-		$this->types['site_modules']      = array(
65
-			'title'=>$_lang["manage_modules"],
66
-			'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')),
67
-			'permissions'=>array('new_module','edit_module'),
68
-		);
69
-	}
37
+        global $_lang;
38
+        $this->types['site_templates']    = array(
39
+            'title'=>$_lang["manage_templates"],
40
+            'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ),
41
+            'permissions'=>array('new_template','edit_template'),
42
+            'name'=>'templatename'
43
+        );
44
+        $this->types['site_tmplvars']     = array(
45
+            'title'=>$_lang["tmplvars"],
46
+            'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')),
47
+            'permissions'=>array('new_template','edit_template'),
48
+        );
49
+        $this->types['site_htmlsnippets'] = array(
50
+            'title'=>$_lang["manage_htmlsnippets"],
51
+            'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')),
52
+            'permissions'=>array('new_chunk','edit_chunk'),
53
+        );
54
+        $this->types['site_snippets']     = array(
55
+            'title'=>$_lang["manage_snippets"],
56
+            'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')),
57
+            'permissions'=>array('new_snippet','edit_snippet'),
58
+        );
59
+        $this->types['site_plugins']      = array(
60
+            'title'=>$_lang["manage_plugins"],
61
+            'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')),
62
+            'permissions'=>array('new_plugin','edit_plugin'),
63
+        );
64
+        $this->types['site_modules']      = array(
65
+            'title'=>$_lang["manage_modules"],
66
+            'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')),
67
+            'permissions'=>array('new_module','edit_module'),
68
+        );
69
+    }
70 70
 
71 71
     /**
72 72
      * @return void
73 73
      */
74 74
     public function queryItemsFromDB() {
75
-		foreach($this->types as $resourceTable=>$type) {
76
-			if($this->hasAnyPermissions($type['permissions'])) {
77
-				$nameField = isset($type['name']) ? $type['name'] : 'name';
78
-				$this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField);
79
-		   }
80
-		 }
81
-	}
75
+        foreach($this->types as $resourceTable=>$type) {
76
+            if($this->hasAnyPermissions($type['permissions'])) {
77
+                $nameField = isset($type['name']) ? $type['name'] : 'name';
78
+                $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField);
79
+            }
80
+            }
81
+    }
82 82
 
83 83
     /**
84 84
      * @param array $permissions
85 85
      * @return bool
86 86
      */
87 87
     public function hasAnyPermissions($permissions) {
88
-		$modx = evolutionCMS();
88
+        $modx = evolutionCMS();
89 89
 
90
-		foreach($permissions as $p)
91
-			if($modx->hasPermission($p)) return true;
90
+        foreach($permissions as $p)
91
+            if($modx->hasPermission($p)) return true;
92 92
 
93
-		return false;
94
-	}
93
+        return false;
94
+    }
95 95
 
96 96
     /**
97 97
      * @param string $resourceTable
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      * @return array|bool
100 100
      */
101 101
     public function queryResources($resourceTable, $nameField = 'name') {
102
-		$modx = evolutionCMS(); global $_lang;
102
+        $modx = evolutionCMS(); global $_lang;
103 103
 
104 104
         $allowed = array(
105 105
             'site_htmlsnippets',
@@ -107,59 +107,59 @@  discard block
 block discarded – undo
107 107
             'site_plugins',
108 108
             'site_modules'
109 109
         );
110
-		$pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : '';
111
-
112
-		$tvsql  = '';
113
-		$tvjoin = '';
114
-		if ($resourceTable === 'site_tmplvars') {
115
-			$tvsql    = 'site_tmplvars.caption, ';
116
-			$tvjoin   = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates'));
117
-			$sttfield = 'IF(stt.templateid,1,0) AS reltpl,';
118
-		}
119
-		else $sttfield = '';
120
-
121
-		$selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : "";
122
-
123
-		$rs = $modx->db->select(
124
-			"{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid",
125
-			$modx->getFullTableName($resourceTable) . " AS {$resourceTable}
110
+        $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : '';
111
+
112
+        $tvsql  = '';
113
+        $tvjoin = '';
114
+        if ($resourceTable === 'site_tmplvars') {
115
+            $tvsql    = 'site_tmplvars.caption, ';
116
+            $tvjoin   = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates'));
117
+            $sttfield = 'IF(stt.templateid,1,0) AS reltpl,';
118
+        }
119
+        else $sttfield = '';
120
+
121
+        $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : "";
122
+
123
+        $rs = $modx->db->select(
124
+            "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid",
125
+            $modx->getFullTableName($resourceTable) . " AS {$resourceTable}
126 126
 	            LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}",
127
-			"",
128
-			"category,name"
129
-		);
130
-		$limit = $modx->db->getRecordCount($rs);
127
+            "",
128
+            "category,name"
129
+        );
130
+        $limit = $modx->db->getRecordCount($rs);
131 131
 
132
-		if($limit < 1) return false;
132
+        if($limit < 1) return false;
133 133
 
134
-		$result = array();
135
-		while ($row = $modx->db->getRow($rs)) {
136
-			$result[] = $row;
137
-		}
138
-		return $result;
139
-	}
134
+        $result = array();
135
+        while ($row = $modx->db->getRow($rs)) {
136
+            $result[] = $row;
137
+        }
138
+        return $result;
139
+    }
140 140
 
141 141
     /**
142 142
      * @return void
143 143
      */
144 144
     public function prepareCategoryArrays() {
145
-		foreach($this->items as $type=>$items) {
146
-			foreach((array)$items as $item) {
147
-				$catid = $item['catid'] ? $item['catid'] : 0;
148
-				$this->categories[$catid] = $item['category'];
149
-
150
-				$item['type'] = $type;
151
-				$this->itemsPerCategory[$catid][] = $item;
152
-			}
153
-		}
154
-
155
-		// Sort categories by name
156
-		natcasesort($this->categories);
157
-
158
-		// Now sort by name
159
-		foreach($this->itemsPerCategory as $catid=>$items) {
160
-			usort($this->itemsPerCategory[$catid], function ($a, $b) {
161
-				return strcasecmp($a['name'], $b['name']);
162
-			});
163
-		}
164
-	}
145
+        foreach($this->items as $type=>$items) {
146
+            foreach((array)$items as $item) {
147
+                $catid = $item['catid'] ? $item['catid'] : 0;
148
+                $this->categories[$catid] = $item['category'];
149
+
150
+                $item['type'] = $type;
151
+                $this->itemsPerCategory[$catid][] = $item;
152
+            }
153
+        }
154
+
155
+        // Sort categories by name
156
+        natcasesort($this->categories);
157
+
158
+        // Now sort by name
159
+        foreach($this->itemsPerCategory as $catid=>$items) {
160
+            usort($this->itemsPerCategory[$catid], function ($a, $b) {
161
+                return strcasecmp($a['name'], $b['name']);
162
+            });
163
+        }
164
+    }
165 165
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  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
-class mgrResources {
6
+class mgrResources{
7 7
     /**
8 8
      * @var array
9 9
      */
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * mgrResources constructor.
26 26
      */
27
-    public function __construct() {
27
+    public function __construct(){
28 28
 		$this->setTypes();
29 29
 		$this->queryItemsFromDB();
30 30
 		$this->prepareCategoryArrays();
@@ -33,47 +33,47 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * @return void
35 35
      */
36
-    public function setTypes() {
36
+    public function setTypes(){
37 37
 		global $_lang;
38
-		$this->types['site_templates']    = array(
38
+		$this->types['site_templates'] = array(
39 39
 			'title'=>$_lang["manage_templates"],
40
-			'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ),
41
-			'permissions'=>array('new_template','edit_template'),
40
+			'actions'=>array('edit'=>array(16, 'edit_template'), 'duplicate'=>array(96, 'new_template'), 'remove'=>array(21, 'delete_template')),
41
+			'permissions'=>array('new_template', 'edit_template'),
42 42
 			'name'=>'templatename'
43 43
 		);
44
-		$this->types['site_tmplvars']     = array(
44
+		$this->types['site_tmplvars'] = array(
45 45
 			'title'=>$_lang["tmplvars"],
46
-			'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')),
47
-			'permissions'=>array('new_template','edit_template'),
46
+			'actions'=>array('edit'=>array(301, 'edit_template'), 'duplicate'=>array(304, 'edit_template'), 'remove'=>array(303, 'edit_template')),
47
+			'permissions'=>array('new_template', 'edit_template'),
48 48
 		);
49 49
 		$this->types['site_htmlsnippets'] = array(
50 50
 			'title'=>$_lang["manage_htmlsnippets"],
51
-			'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')),
52
-			'permissions'=>array('new_chunk','edit_chunk'),
51
+			'actions'=>array('edit'=>array(78, 'edit_chunk'), 'duplicate'=>array(97, 'new_chunk'), 'remove'=>array(80, 'delete_chunk')),
52
+			'permissions'=>array('new_chunk', 'edit_chunk'),
53 53
 		);
54
-		$this->types['site_snippets']     = array(
54
+		$this->types['site_snippets'] = array(
55 55
 			'title'=>$_lang["manage_snippets"],
56
-			'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')),
57
-			'permissions'=>array('new_snippet','edit_snippet'),
56
+			'actions'=>array('edit'=>array(22, 'edit_snippet'), 'duplicate'=>array(98, 'new_snippet'), 'remove'=>array(25, 'delete_snippet')),
57
+			'permissions'=>array('new_snippet', 'edit_snippet'),
58 58
 		);
59
-		$this->types['site_plugins']      = array(
59
+		$this->types['site_plugins'] = array(
60 60
 			'title'=>$_lang["manage_plugins"],
61
-			'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')),
62
-			'permissions'=>array('new_plugin','edit_plugin'),
61
+			'actions'=>array('edit'=>array(102, 'edit_plugin'), 'duplicate'=>array(105, 'new_plugin'), 'remove'=>array(104, 'delete_plugin')),
62
+			'permissions'=>array('new_plugin', 'edit_plugin'),
63 63
 		);
64
-		$this->types['site_modules']      = array(
64
+		$this->types['site_modules'] = array(
65 65
 			'title'=>$_lang["manage_modules"],
66
-			'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')),
67
-			'permissions'=>array('new_module','edit_module'),
66
+			'actions'=>array('edit'=>array(108, 'edit_module'), 'duplicate'=>array(111, 'new_module'), 'remove'=>array(110, 'delete_module')),
67
+			'permissions'=>array('new_module', 'edit_module'),
68 68
 		);
69 69
 	}
70 70
 
71 71
     /**
72 72
      * @return void
73 73
      */
74
-    public function queryItemsFromDB() {
75
-		foreach($this->types as $resourceTable=>$type) {
76
-			if($this->hasAnyPermissions($type['permissions'])) {
74
+    public function queryItemsFromDB(){
75
+		foreach ($this->types as $resourceTable=>$type) {
76
+			if ($this->hasAnyPermissions($type['permissions'])) {
77 77
 				$nameField = isset($type['name']) ? $type['name'] : 'name';
78 78
 				$this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField);
79 79
 		   }
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
      * @param array $permissions
85 85
      * @return bool
86 86
      */
87
-    public function hasAnyPermissions($permissions) {
87
+    public function hasAnyPermissions($permissions){
88 88
 		$modx = evolutionCMS();
89 89
 
90
-		foreach($permissions as $p)
91
-			if($modx->hasPermission($p)) return true;
90
+		foreach ($permissions as $p)
91
+			if ($modx->hasPermission($p)) return true;
92 92
 
93 93
 		return false;
94 94
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @param string $nameField
99 99
      * @return array|bool
100 100
      */
101
-    public function queryResources($resourceTable, $nameField = 'name') {
101
+    public function queryResources($resourceTable, $nameField = 'name'){
102 102
 		$modx = evolutionCMS(); global $_lang;
103 103
 
104 104
         $allowed = array(
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             'site_plugins',
108 108
             'site_modules'
109 109
         );
110
-		$pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : '';
110
+		$pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable.'.disabled, ' : '';
111 111
 
112 112
 		$tvsql  = '';
113 113
 		$tvjoin = '';
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 
123 123
 		$rs = $modx->db->select(
124 124
 			"{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid",
125
-			$modx->getFullTableName($resourceTable) . " AS {$resourceTable}
126
-	            LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}",
125
+			$modx->getFullTableName($resourceTable)." AS {$resourceTable}
126
+	            LEFT JOIN ".$modx->getFullTableName('categories')." AS categories ON {$resourceTable}.category = categories.id {$tvjoin}",
127 127
 			"",
128 128
 			"category,name"
129 129
 		);
130 130
 		$limit = $modx->db->getRecordCount($rs);
131 131
 
132
-		if($limit < 1) return false;
132
+		if ($limit < 1) return false;
133 133
 
134 134
 		$result = array();
135 135
 		while ($row = $modx->db->getRow($rs)) {
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
     /**
142 142
      * @return void
143 143
      */
144
-    public function prepareCategoryArrays() {
145
-		foreach($this->items as $type=>$items) {
146
-			foreach((array)$items as $item) {
144
+    public function prepareCategoryArrays(){
145
+		foreach ($this->items as $type=>$items) {
146
+			foreach ((array) $items as $item) {
147 147
 				$catid = $item['catid'] ? $item['catid'] : 0;
148 148
 				$this->categories[$catid] = $item['category'];
149 149
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 		natcasesort($this->categories);
157 157
 
158 158
 		// Now sort by name
159
-		foreach($this->itemsPerCategory as $catid=>$items) {
160
-			usort($this->itemsPerCategory[$catid], function ($a, $b) {
159
+		foreach ($this->itemsPerCategory as $catid=>$items) {
160
+			usort($this->itemsPerCategory[$catid], function($a, $b){
161 161
 				return strcasecmp($a['name'], $b['name']);
162 162
 			});
163 163
 		}
Please login to merge, or discard this patch.
Braces   +23 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,7 +3,8 @@  discard block
 block discarded – undo
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
-class mgrResources {
6
+class mgrResources
7
+{
7 8
     /**
8 9
      * @var array
9 10
      */
@@ -24,7 +25,8 @@  discard block
 block discarded – undo
24 25
     /**
25 26
      * mgrResources constructor.
26 27
      */
27
-    public function __construct() {
28
+    public function __construct()
29
+    {
28 30
 		$this->setTypes();
29 31
 		$this->queryItemsFromDB();
30 32
 		$this->prepareCategoryArrays();
@@ -33,7 +35,8 @@  discard block
 block discarded – undo
33 35
     /**
34 36
      * @return void
35 37
      */
36
-    public function setTypes() {
38
+    public function setTypes()
39
+    {
37 40
 		global $_lang;
38 41
 		$this->types['site_templates']    = array(
39 42
 			'title'=>$_lang["manage_templates"],
@@ -71,7 +74,8 @@  discard block
 block discarded – undo
71 74
     /**
72 75
      * @return void
73 76
      */
74
-    public function queryItemsFromDB() {
77
+    public function queryItemsFromDB()
78
+    {
75 79
 		foreach($this->types as $resourceTable=>$type) {
76 80
 			if($this->hasAnyPermissions($type['permissions'])) {
77 81
 				$nameField = isset($type['name']) ? $type['name'] : 'name';
@@ -84,11 +88,13 @@  discard block
 block discarded – undo
84 88
      * @param array $permissions
85 89
      * @return bool
86 90
      */
87
-    public function hasAnyPermissions($permissions) {
91
+    public function hasAnyPermissions($permissions)
92
+    {
88 93
 		$modx = evolutionCMS();
89 94
 
90
-		foreach($permissions as $p)
91
-			if($modx->hasPermission($p)) return true;
95
+		foreach($permissions as $p) {
96
+					if($modx->hasPermission($p)) return true;
97
+		}
92 98
 
93 99
 		return false;
94 100
 	}
@@ -98,7 +104,8 @@  discard block
 block discarded – undo
98 104
      * @param string $nameField
99 105
      * @return array|bool
100 106
      */
101
-    public function queryResources($resourceTable, $nameField = 'name') {
107
+    public function queryResources($resourceTable, $nameField = 'name')
108
+    {
102 109
 		$modx = evolutionCMS(); global $_lang;
103 110
 
104 111
         $allowed = array(
@@ -115,8 +122,9 @@  discard block
 block discarded – undo
115 122
 			$tvsql    = 'site_tmplvars.caption, ';
116 123
 			$tvjoin   = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates'));
117 124
 			$sttfield = 'IF(stt.templateid,1,0) AS reltpl,';
125
+		} else {
126
+		    $sttfield = '';
118 127
 		}
119
-		else $sttfield = '';
120 128
 
121 129
 		$selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : "";
122 130
 
@@ -129,7 +137,9 @@  discard block
 block discarded – undo
129 137
 		);
130 138
 		$limit = $modx->db->getRecordCount($rs);
131 139
 
132
-		if($limit < 1) return false;
140
+		if($limit < 1) {
141
+		    return false;
142
+		}
133 143
 
134 144
 		$result = array();
135 145
 		while ($row = $modx->db->getRow($rs)) {
@@ -141,7 +151,8 @@  discard block
 block discarded – undo
141 151
     /**
142 152
      * @return void
143 153
      */
144
-    public function prepareCategoryArrays() {
154
+    public function prepareCategoryArrays()
155
+    {
145 156
 		foreach($this->items as $type=>$items) {
146 157
 			foreach((array)$items as $item) {
147 158
 				$catid = $item['catid'] ? $item['catid'] : 0;
@@ -157,7 +168,7 @@  discard block
 block discarded – undo
157 168
 
158 169
 		// Now sort by name
159 170
 		foreach($this->itemsPerCategory as $catid=>$items) {
160
-			usort($this->itemsPerCategory[$catid], function ($a, $b) {
171
+			usort($this->itemsPerCategory[$catid], function ($a, $b){
161 172
 				return strcasecmp($a['name'], $b['name']);
162 173
 			});
163 174
 		}
Please login to merge, or discard this patch.
manager/includes/veriword.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $modx->getSettings();
6 6
 $modx->invokeEvent('OnWebPageInit');
7 7
 
8
-$vword = new VeriWord(148,60);
8
+$vword = new VeriWord(148, 60);
9 9
 $vword->output_image();
10 10
 $vword->destroy_image();
11 11
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 ## see sample.php for test and usage
42 42
 ## sample URL: http://www.program-ruti.org/veriword/
43 43
 ####
44
-class VeriWord {
44
+class VeriWord{
45 45
 
46 46
     /* path to font directory*/
47 47
     public $dir_font   = "ttf/";
@@ -52,44 +52,44 @@  discard block
 block discarded – undo
52 52
     public $im_height  = 0;
53 53
     public $im;
54 54
 
55
-    public function __construct($w=200, $h=80) {
55
+    public function __construct($w = 200, $h = 80){
56 56
         /* create session to set word for verification */
57 57
         $this->set_veriword();
58
-        $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font;
58
+        $this->dir_font = dirname(__FILE__).'/'.$this->dir_font;
59 59
         $this->im_width         = $w;
60 60
         $this->im_height        = $h;
61 61
     }
62 62
 
63
-    public function set_veriword() {
63
+    public function set_veriword(){
64 64
         /* create session variable for verification,
65 65
            you may change the session variable name */
66 66
         $this->word             = $this->pick_word();
67 67
         $_SESSION['veriword']   = $this->word;
68 68
     }
69 69
 
70
-    public function output_image() {
70
+    public function output_image(){
71 71
         /* output the image as jpeg */
72 72
         $this->draw_image();
73 73
         header("Content-type: image/jpeg");
74 74
         imagejpeg($this->im);
75 75
     }
76 76
 
77
-    public function pick_word() {
77
+    public function pick_word(){
78 78
         $modx = evolutionCMS();
79 79
         // set default words
80
-        $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
80
+        $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
81 81
         $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words;
82 82
         $arr_words = array_filter(array_map('trim', explode(',', $words)));
83 83
 
84 84
         /* pick one randomly for text verification */
85
-        return (string) $arr_words[array_rand($arr_words)].rand(10,999);
85
+        return (string) $arr_words[array_rand($arr_words)].rand(10, 999);
86 86
     }
87 87
 
88
-    public function draw_text() {
88
+    public function draw_text(){
89 89
         $dir = dir($this->dir_font);
90 90
         $fontstmp = array();
91 91
         while (false !== ($file = $dir->read())) {
92
-            if(substr($file, -4) == '.ttf') {
92
+            if (substr($file, -4) == '.ttf') {
93 93
                 $fontstmp[] = $this->dir_font.$file;
94 94
             }
95 95
         }
@@ -97,35 +97,35 @@  discard block
 block discarded – undo
97 97
         $text_font = (string) $fontstmp[array_rand($fontstmp)];
98 98
 
99 99
         /* angle for text inclination */
100
-        $text_angle = rand(-9,9);
100
+        $text_angle = rand(-9, 9);
101 101
         /* initial text size */
102 102
         $text_size  = 30;
103 103
         /* calculate text width and height */
104
-        $box        = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);
105
-        $text_width = $box[2]-$box[0]; //text width
106
-        $text_height= $box[5]-$box[3]; //text height
104
+        $box        = imagettfbbox($text_size, $text_angle, $text_font, $this->word);
105
+        $text_width = $box[2] - $box[0]; //text width
106
+        $text_height = $box[5] - $box[3]; //text height
107 107
 
108 108
         /* adjust text size */
109
-        $text_size  = round((20 * $this->im_width)/$text_width);
109
+        $text_size  = round((20 * $this->im_width) / $text_width);
110 110
 
111 111
         /* recalculate text width and height */
112
-        $box        = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);
113
-        $text_width = $box[2]-$box[0]; //text width
114
-        $text_height= $box[5]-$box[3]; //text height
112
+        $box        = imagettfbbox($text_size, $text_angle, $text_font, $this->word);
113
+        $text_width = $box[2] - $box[0]; //text width
114
+        $text_height = $box[5] - $box[3]; //text height
115 115
 
116 116
         /* calculate center position of text */
117
-        $text_x         = ($this->im_width - $text_width)/2;
118
-        $text_y         = ($this->im_height - $text_height)/2;
117
+        $text_x         = ($this->im_width - $text_width) / 2;
118
+        $text_y         = ($this->im_height - $text_height) / 2;
119 119
 
120 120
         /* create canvas for text drawing */
121
-        $im_text        = imagecreate ($this->im_width, $this->im_height);
122
-        $bg_color       = imagecolorallocate ($im_text, 255, 255, 255);
121
+        $im_text        = imagecreate($this->im_width, $this->im_height);
122
+        $bg_color       = imagecolorallocate($im_text, 255, 255, 255);
123 123
 
124 124
         /* pick color for text */
125
-        $text_color     = imagecolorallocate ($im_text, 0, 51, 153);
125
+        $text_color     = imagecolorallocate($im_text, 0, 51, 153);
126 126
 
127 127
         /* draw text into canvas */
128
-        imagettftext    (   $im_text,
128
+        imagettftext($im_text,
129 129
             $text_size,
130 130
             $text_angle,
131 131
             $text_x,
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
     }
141 141
 
142 142
 
143
-    public function draw_image() {
143
+    public function draw_image(){
144 144
 
145 145
         /* pick one background image randomly from image directory */
146
-        $img_file       = $this->dir_noise."noise".rand(1,4).".jpg";
146
+        $img_file       = $this->dir_noise."noise".rand(1, 4).".jpg";
147 147
 
148 148
         /* create "noise" background image from your image stock*/
149
-        $noise_img      = @imagecreatefromjpeg ($img_file);
149
+        $noise_img      = @imagecreatefromjpeg($img_file);
150 150
         $noise_width    = imagesx($noise_img);
151 151
         $noise_height   = imagesy($noise_img);
152 152
 
153 153
         /* resize the background image to fit the size of image output */
154
-        $this->im       = imagecreatetruecolor($this->im_width,$this->im_height);
155
-        imagecopyresampled ($this->im,
154
+        $this->im       = imagecreatetruecolor($this->im_width, $this->im_height);
155
+        imagecopyresampled($this->im,
156 156
             $noise_img,
157 157
             0, 0, 0, 0,
158 158
             $this->im_width,
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
             $noise_height);
162 162
 
163 163
         /* put text image into background image */
164
-        imagecopymerge (    $this->im,
164
+        imagecopymerge($this->im,
165 165
             $this->draw_text(),
166 166
             0, 0, 0, 0,
167 167
             $this->im_width,
168 168
             $this->im_height,
169
-            70 );
169
+            70);
170 170
 
171 171
         return $this->im;
172 172
     }
173 173
 
174
-    public function destroy_image() {
174
+    public function destroy_image(){
175 175
 
176 176
         imagedestroy($this->im);
177 177
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@  discard block
 block discarded – undo
41 41
 ## see sample.php for test and usage
42 42
 ## sample URL: http://www.program-ruti.org/veriword/
43 43
 ####
44
-class VeriWord {
44
+class VeriWord
45
+{
45 46
 
46 47
     /* path to font directory*/
47 48
     public $dir_font   = "ttf/";
@@ -52,7 +53,8 @@  discard block
 block discarded – undo
52 53
     public $im_height  = 0;
53 54
     public $im;
54 55
 
55
-    public function __construct($w=200, $h=80) {
56
+    public function __construct($w=200, $h=80)
57
+    {
56 58
         /* create session to set word for verification */
57 59
         $this->set_veriword();
58 60
         $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font;
@@ -60,21 +62,24 @@  discard block
 block discarded – undo
60 62
         $this->im_height        = $h;
61 63
     }
62 64
 
63
-    public function set_veriword() {
65
+    public function set_veriword()
66
+    {
64 67
         /* create session variable for verification,
65 68
            you may change the session variable name */
66 69
         $this->word             = $this->pick_word();
67 70
         $_SESSION['veriword']   = $this->word;
68 71
     }
69 72
 
70
-    public function output_image() {
73
+    public function output_image()
74
+    {
71 75
         /* output the image as jpeg */
72 76
         $this->draw_image();
73 77
         header("Content-type: image/jpeg");
74 78
         imagejpeg($this->im);
75 79
     }
76 80
 
77
-    public function pick_word() {
81
+    public function pick_word()
82
+    {
78 83
         $modx = evolutionCMS();
79 84
         // set default words
80 85
         $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
@@ -85,7 +90,8 @@  discard block
 block discarded – undo
85 90
         return (string) $arr_words[array_rand($arr_words)].rand(10,999);
86 91
     }
87 92
 
88
-    public function draw_text() {
93
+    public function draw_text()
94
+    {
89 95
         $dir = dir($this->dir_font);
90 96
         $fontstmp = array();
91 97
         while (false !== ($file = $dir->read())) {
@@ -140,7 +146,8 @@  discard block
 block discarded – undo
140 146
     }
141 147
 
142 148
 
143
-    public function draw_image() {
149
+    public function draw_image()
150
+    {
144 151
 
145 152
         /* pick one background image randomly from image directory */
146 153
         $img_file       = $this->dir_noise."noise".rand(1,4).".jpg";
@@ -171,7 +178,8 @@  discard block
 block discarded – undo
171 178
         return $this->im;
172 179
     }
173 180
 
174
-    public function destroy_image() {
181
+    public function destroy_image()
182
+    {
175 183
 
176 184
         imagedestroy($this->im);
177 185
 
Please login to merge, or discard this patch.
manager/includes/extenders/manager.api.class.inc.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -144,33 +144,33 @@  discard block
 block discarded – undo
144 144
             $algorithm = 'UNCRYPT';
145 145
         }
146 146
 
147
-        $salt = md5($password . $seed);
147
+        $salt = md5($password.$seed);
148 148
 
149 149
         switch ($algorithm) {
150 150
             case 'BLOWFISH_Y':
151
-                $salt = '$2y$07$' . substr($salt, 0, 22);
151
+                $salt = '$2y$07$'.substr($salt, 0, 22);
152 152
                 break;
153 153
             case 'BLOWFISH_A':
154
-                $salt = '$2a$07$' . substr($salt, 0, 22);
154
+                $salt = '$2a$07$'.substr($salt, 0, 22);
155 155
                 break;
156 156
             case 'SHA512':
157
-                $salt = '$6$' . substr($salt, 0, 16);
157
+                $salt = '$6$'.substr($salt, 0, 16);
158 158
                 break;
159 159
             case 'SHA256':
160
-                $salt = '$5$' . substr($salt, 0, 16);
160
+                $salt = '$5$'.substr($salt, 0, 16);
161 161
                 break;
162 162
             case 'MD5':
163
-                $salt = '$1$' . substr($salt, 0, 8);
163
+                $salt = '$1$'.substr($salt, 0, 8);
164 164
                 break;
165 165
         }
166 166
 
167 167
         if ($algorithm !== 'UNCRYPT') {
168
-            $password = sha1($password) . crypt($password, $salt);
168
+            $password = sha1($password).crypt($password, $salt);
169 169
         } else {
170
-            $password = sha1($salt . $password);
170
+            $password = sha1($salt.$password);
171 171
         }
172 172
 
173
-        $result = strtolower($algorithm) . '>' . md5($salt . $password) . substr(md5($salt), 0, 8);
173
+        $result = strtolower($algorithm).'>'.md5($salt.$password).substr(md5($salt), 0, 8);
174 174
 
175 175
         return $result;
176 176
     }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $check_files = explode("\n", $check_files);
253 253
         foreach ($check_files as $file) {
254 254
             $file = trim($file);
255
-            $file = MODX_BASE_PATH . $file;
255
+            $file = MODX_BASE_PATH.$file;
256 256
             if (!is_file($file)) {
257 257
                 continue;
258 258
             }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         $checksum = unserialize($checksum);
276 276
         foreach ($check_files as $file) {
277 277
             $file = trim($file);
278
-            $filePath = MODX_BASE_PATH . $file;
278
+            $filePath = MODX_BASE_PATH.$file;
279 279
             if (!is_file($filePath)) {
280 280
                 continue;
281 281
             }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     {
295 295
         $modx = evolutionCMS();
296 296
         $tbl_system_settings = $modx->getFullTableName('system_settings');
297
-        $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')";
297
+        $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','".$modx->db->escape($checksum)."')";
298 298
         $modx->db->query($sql);
299 299
     }
300 300
 
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
             foreach ($settings as $key => $val) {
372 372
                 $f = array();
373 373
                 $f['user'] = $_SESSION['mgrInternalKey'];
374
-                $f['setting_name'] = '_LAST_' . $key;
374
+                $f['setting_name'] = '_LAST_'.$key;
375 375
                 $f['setting_value'] = $val;
376 376
                 $f = $modx->db->escape($f);
377
-                $f = "(`" . implode("`, `", array_keys($f)) . "`) VALUES('" . implode("', '", array_values($f)) . "')";
377
+                $f = "(`".implode("`, `", array_keys($f))."`) VALUES('".implode("', '", array_values($f))."')";
378 378
                 $f .= " ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)";
379 379
                 $modx->db->insert($f, $modx->getFullTableName('user_settings'));
380 380
             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -116,7 +116,8 @@  discard block
 block discarded – undo
116 116
      * @return string
117 117
      */
118 118
     public function getHashType($db_value = '')
119
-    { // md5 | v1 | phpass
119
+    {
120
+// md5 | v1 | phpass
120 121
         $c = substr($db_value, 0, 1);
121 122
         if ($c === '$') {
122 123
             return 'phpass';
@@ -135,7 +136,8 @@  discard block
 block discarded – undo
135 136
      * @return string
136 137
      */
137 138
     public function genV1Hash($password, $seed = '1')
138
-    { // $seed is user_id basically
139
+    {
140
+// $seed is user_id basically
139 141
         $modx = evolutionCMS();
140 142
 
141 143
         if (isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) {
Please login to merge, or discard this patch.
manager/media/calendar/datepicker.inc.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DATEPICKER {
4
-	function __construct() {
5
-	}
4
+    function __construct() {
5
+    }
6 6
 
7
-	function getDP() {
8
-		$modx = evolutionCMS(); global $_lang;
7
+    function getDP() {
8
+        $modx = evolutionCMS(); global $_lang;
9 9
 
10
-		$tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
11
-		return $modx->parseText($tpl, $_lang, '[%', '%]');
12
-	}
10
+        $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
11
+        return $modx->parseText($tpl, $_lang, '[%', '%]');
12
+    }
13 13
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-class DATEPICKER {
4
-	function __construct() {
3
+class DATEPICKER{
4
+	function __construct(){
5 5
 	}
6 6
 
7
-	function getDP() {
7
+	function getDP(){
8 8
 		$modx = evolutionCMS(); global $_lang;
9 9
 
10
-		$tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
10
+		$tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl');
11 11
 		return $modx->parseText($tpl, $_lang, '[%', '%]');
12 12
 	}
13 13
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-class DATEPICKER {
4
-	function __construct() {
3
+class DATEPICKER
4
+{
5
+	function __construct()
6
+	{
5 7
 	}
6 8
 
7
-	function getDP() {
9
+	function getDP()
10
+	{
8 11
 		$modx = evolutionCMS(); global $_lang;
9 12
 
10 13
 		$tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
Please login to merge, or discard this patch.