Completed
Push — develop ( 0132ab...e45b08 )
by Dmytro
13:40 queued 05:11
created
manager/processors/remove_installer.processor.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
  *
13 13
  */
14 14
 
15
-$msg ='';
15
+$msg = '';
16 16
 $pth = dirname(dirname(dirname(__FILE__)))."/install/";
17
-$pth = str_replace("\\","/",$pth);
18
-if(isset($_GET["rminstall"])) {
19
-	if(is_dir($pth)) {
20
-		if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder";
17
+$pth = str_replace("\\", "/", $pth);
18
+if (isset($_GET["rminstall"])) {
19
+	if (is_dir($pth)) {
20
+		if (!rmdirRecursive($pth)) $msg = "An error occured while attempting to remove the install folder";
21 21
 	}
22 22
 }
23
-if($msg) echo "<script>alert('".addslashes($msg)."');</script>";
23
+if ($msg) echo "<script>alert('".addslashes($msg)."');</script>";
24 24
 echo "<script>window.location='../index.php?a=2';</script>";
25 25
 
26 26
 /**
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
  * @param bool $followLinks
31 31
  * @return bool
32 32
  */
33
-function rmdirRecursive($path, $followLinks=false) {
34
-   $dir = opendir($path) ;
33
+function rmdirRecursive($path, $followLinks = false){
34
+   $dir = opendir($path);
35 35
    while ($entry = readdir($dir)) {
36 36
 	   if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) {
37
-		   @unlink( "$path/$entry" );
37
+		   @unlink("$path/$entry");
38 38
 	   }
39
-	   elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
39
+	   elseif (is_dir("$path/$entry") && $entry != '.' && $entry != '..') {
40 40
 		   rmdirRecursive("$path/$entry"); // recursive
41 41
 	   }
42 42
    }
Please login to merge, or discard this patch.
install/connection.collation.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
     foreach ($_ as $collation=>$selected) {
51 51
         $collation = htmlentities($collation);
52 52
         // if(substr($collation,0,4)!=='utf8') continue;
53
-        if (strpos($collation, 'sjis')===0) {
53
+        if (strpos($collation, 'sjis') === 0) {
54 54
             continue;
55 55
         }
56
-        if ($collation=='recommend') {
56
+        if ($collation == 'recommend') {
57 57
             $output .= '<optgroup label="recommend">';
58
-        } elseif ($collation=='unrecommend') {
58
+        } elseif ($collation == 'unrecommend') {
59 59
             $output .= '</optgroup><optgroup label="unrecommend">';
60 60
         } else {
61 61
             $output .= sprintf('<option value="%s" %s>%s</option>', $collation, $selected, $collation);
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
 echo $output;
68 68
 exit;
69 69
 
70
-function sortItem($array=array(), $order='utf8mb4,utf8')
70
+function sortItem($array = array(), $order = 'utf8mb4,utf8')
71 71
 {
72 72
     $rs = array('recommend'=>'');
73 73
     $order = explode(',', $order);
74 74
     foreach ($order as $v) {
75 75
         foreach ($array as $name=>$sel) {
76
-            if (strpos($name, $v)!==false) {
76
+            if (strpos($name, $v) !== false) {
77 77
                 $rs[$name] = $array[$name];
78 78
                 unset($array[$name]);
79 79
             }
80 80
         }
81 81
     }
82
-    $rs['unrecommend']='';
82
+    $rs['unrecommend'] = '';
83 83
     return $rs + $array;
84 84
 }
Please login to merge, or discard this patch.
index.php 1 patch
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.
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('&nbsp;%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/import_site.static.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  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
-if(!$modx->hasPermission('import_static')) {
5
+if (!$modx->hasPermission('import_static')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	<div class="tab-page">
44 44
 		<div class="container container-body">
45 45
 			<?php
46
-			if(!isset($_POST['import'])) {
47
-				echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
46
+			if (!isset($_POST['import'])) {
47
+				echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>";
48 48
 				?>
49 49
 				<form action="index.php" method="post" name="importFrm">
50 50
 					<input type="hidden" name="import" value="import" />
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 /**
105 105
  * @return string
106 106
  */
107
-function run() {
107
+function run(){
108 108
 	$modx = evolutionCMS(); global $_lang;
109 109
 
110 110
 	$tbl_site_content = $modx->getFullTableName('site_content');
111 111
 	$output = '';
112 112
 	$maxtime = $_POST['maxtime'];
113 113
 
114
-	if(!is_numeric($maxtime)) {
114
+	if (!is_numeric($maxtime)) {
115 115
 		$maxtime = 30;
116 116
 	}
117 117
 
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
 	$mtime = $mtime[1] + $mtime[0];
123 123
 	$importstart = $mtime;
124 124
 
125
-	if($_POST['reset'] == 'on') {
125
+	if ($_POST['reset'] == 'on') {
126 126
 		$modx->db->truncate($tbl_site_content);
127 127
 		$modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128 128
 	}
129 129
 
130
-	$parent = (int)$_POST['parent'];
130
+	$parent = (int) $_POST['parent'];
131 131
 
132
-	if(is_dir(MODX_BASE_PATH . 'temp/import')) {
133
-		$filedir = MODX_BASE_PATH . 'temp/import/';
134
-	} elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
135
-		$filedir = MODX_BASE_PATH . 'assets/import/';
132
+	if (is_dir(MODX_BASE_PATH.'temp/import')) {
133
+		$filedir = MODX_BASE_PATH.'temp/import/';
134
+	} elseif (is_dir(MODX_BASE_PATH.'assets/import')) {
135
+		$filedir = MODX_BASE_PATH.'assets/import/';
136 136
 	} else {
137 137
         $filedir = '';
138 138
     }
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 	$files = pop_index($files);
144 144
 
145 145
 	// no. of files to import
146
-	$output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
146
+	$output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound);
147 147
 
148 148
 	// import files
149
-	if(0 < count($files)) {
149
+	if (0 < count($files)) {
150 150
 		$modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
151 151
 		importFiles($parent, $filedir, $files, 'root');
152 152
 	}
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 	$mtime = $mtime[1] + $mtime[0];
157 157
 	$importend = $mtime;
158 158
 	$totaltime = ($importend - $importstart);
159
-	$output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
159
+	$output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3));
160 160
 
161
-	if($_POST['convert_link'] == 'on') {
161
+	if ($_POST['convert_link'] == 'on') {
162 162
 		convertLink();
163 163
 	}
164 164
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  * @param array $files
172 172
  * @param string $mode
173 173
  */
174
-function importFiles($parent, $filedir, $files, $mode) {
174
+function importFiles($parent, $filedir, $files, $mode){
175 175
 	$modx = evolutionCMS();
176 176
 	global $_lang, $allowedfiles;
177 177
 	global $search_default, $cache_default, $publish_default;
@@ -180,21 +180,21 @@  discard block
 block discarded – undo
180 180
 	$tbl_system_settings = $modx->getFullTableName('system_settings');
181 181
 
182 182
 	$createdby = $modx->getLoginUserID();
183
-	if(!is_array($files)) {
183
+	if (!is_array($files)) {
184 184
 		return;
185 185
 	}
186
-	if($_POST['object'] === 'all') {
186
+	if ($_POST['object'] === 'all') {
187 187
 		$modx->config['default_template'] = '0';
188 188
 		$richtext = '0';
189 189
 	} else {
190 190
 		$richtext = '1';
191 191
 	}
192 192
 
193
-	foreach($files as $id => $value) {
194
-		if(is_array($value)) {
193
+	foreach ($files as $id => $value) {
194
+		if (is_array($value)) {
195 195
 			// create folder
196 196
 			$alias = $id;
197
-			printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
197
+			printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias);
198 198
 			$field = array();
199 199
 			$field['type'] = 'document';
200 200
 			$field['contentType'] = 'text/html';
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 			$field['isfolder'] = 1;
210 210
 			$field['menuindex'] = 1;
211 211
 			$find = false;
212
-			foreach(array(
212
+			foreach (array(
213 213
 						'index.html',
214 214
 						'index.htm'
215 215
 					) as $filename) {
216
-				$filepath = $filedir . $alias . '/' . $filename;
217
-				if($find === false && file_exists($filepath)) {
216
+				$filepath = $filedir.$alias.'/'.$filename;
217
+				if ($find === false && file_exists($filepath)) {
218 218
 					$file = getFileContent($filepath);
219 219
 					list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
220 220
 
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 					$field['createdon'] = $date;
227 227
 					$field['editedon'] = $date;
228 228
 					$newid = $modx->db->insert($field, $tbl_site_content);
229
-					if($newid) {
229
+					if ($newid) {
230 230
 						$find = true;
231
-						echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
232
-						importFiles($newid, $filedir . $alias . '/', $value, 'sub');
231
+						echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
232
+						importFiles($newid, $filedir.$alias.'/', $value, 'sub');
233 233
 					} else {
234
-						echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
234
+						echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
235 235
 						exit;
236 236
 					}
237 237
 				}
238 238
 			}
239
-			if($find === false) {
239
+			if ($find === false) {
240 240
 				$date = time();
241 241
 				$field['pagetitle'] = '---';
242 242
 				$field['content'] = '';
@@ -244,30 +244,30 @@  discard block
 block discarded – undo
244 244
 				$field['editedon'] = $date;
245 245
 				$field['hidemenu'] = '1';
246 246
 				$newid = $modx->db->insert($field, $tbl_site_content);
247
-				if($newid) {
247
+				if ($newid) {
248 248
 					$find = true;
249
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
250
-					importFiles($newid, $filedir . $alias . '/', $value, 'sub');
249
+					echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
250
+					importFiles($newid, $filedir.$alias.'/', $value, 'sub');
251 251
 				} else {
252
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
252
+					echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
253 253
 					exit;
254 254
 				}
255 255
 			}
256 256
 		} else {
257 257
 			// create document
258
-			if($mode == 'sub' && $value == 'index.html') {
258
+			if ($mode == 'sub' && $value == 'index.html') {
259 259
 				continue;
260 260
 			}
261 261
 			$filename = $value;
262 262
 			$fparts = explode('.', $value);
263 263
 			$alias = $fparts[0];
264 264
 			$ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
265
-			printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
265
+			printf("<span>".$_lang['import_site_importing_document']."</span>", $filename);
266 266
 
267
-			if(!in_array($ext, $allowedfiles)) {
268
-				echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
267
+			if (!in_array($ext, $allowedfiles)) {
268
+				echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n";
269 269
 			} else {
270
-				$filepath = $filedir . $filename;
270
+				$filepath = $filedir.$filename;
271 271
 				$file = getFileContent($filepath);
272 272
 				list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
273 273
 
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 				$field['isfolder'] = 0;
293 293
 				$field['menuindex'] = ($alias == 'index') ? 0 : 2;
294 294
 				$newid = $modx->db->insert($field, $tbl_site_content);
295
-				if($newid) {
296
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
295
+				if ($newid) {
296
+					echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
297 297
 				} else {
298
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
298
+					echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
299 299
 					exit;
300 300
 				}
301 301
 
302 302
 				$is_site_start = false;
303
-				if($filename == 'index.html') {
303
+				if ($filename == 'index.html') {
304 304
 					$is_site_start = true;
305 305
 				}
306
-				if($is_site_start == true && $_POST['reset'] == 'on') {
306
+				if ($is_site_start == true && $_POST['reset'] == 'on') {
307 307
 					$modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
308 308
 					$modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
309 309
 				}
@@ -318,26 +318,26 @@  discard block
 block discarded – undo
318 318
  * @param int $count
319 319
  * @return array
320 320
  */
321
-function getFiles($directory, $listing = array(), $count = 0) {
321
+function getFiles($directory, $listing = array(), $count = 0){
322 322
 	global $_lang;
323 323
 	global $filesfound;
324 324
 	$dummy = $count;
325
-	if( ! empty($directory) && $files = scandir($directory)) {
326
-		foreach($files as $file) {
327
-			if($file == '.' || $file == '..') {
325
+	if (!empty($directory) && $files = scandir($directory)) {
326
+		foreach ($files as $file) {
327
+			if ($file == '.' || $file == '..') {
328 328
 				continue;
329
-			} elseif($h = @opendir($directory . $file . "/")) {
329
+			} elseif ($h = @opendir($directory.$file."/")) {
330 330
 				closedir($h);
331 331
 				$count = -1;
332
-				$listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
333
-			} elseif(strpos($file, '.htm') !== false) {
332
+				$listing[$file] = getFiles($directory.$file."/", array(), $count + 1);
333
+			} elseif (strpos($file, '.htm') !== false) {
334 334
 				$listing[$dummy] = $file;
335 335
 				$dummy = $dummy + 1;
336 336
 				$filesfound++;
337 337
 			}
338 338
 		}
339 339
 	} else {
340
-		echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
340
+		echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>";
341 341
 	}
342 342
 	return ($listing);
343 343
 }
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
  * @param string $filepath
347 347
  * @return bool|string
348 348
  */
349
-function getFileContent($filepath) {
349
+function getFileContent($filepath){
350 350
 	global $_lang;
351 351
 	// get the file
352
-	if(!$buffer = file_get_contents($filepath)) {
353
-		echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
352
+	if (!$buffer = file_get_contents($filepath)) {
353
+		echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>";
354 354
 	} else {
355 355
 		return $buffer;
356 356
 	}
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
  * @param array $array
361 361
  * @return array
362 362
  */
363
-function pop_index($array) {
363
+function pop_index($array){
364 364
 	$new_array = array();
365
-	foreach($array as $k => $v) {
366
-		if($v !== 'index.html' && $v !== 'index.htm') {
365
+	foreach ($array as $k => $v) {
366
+		if ($v !== 'index.html' && $v !== 'index.htm') {
367 367
 			$new_array[$k] = $v;
368 368
 		} else {
369 369
 			array_unshift($new_array, $v);
370 370
 		}
371 371
 	}
372
-	foreach($array as $k => $v) {
373
-		if(is_array($v)) {
372
+	foreach ($array as $k => $v) {
373
+		if (is_array($v)) {
374 374
 			$new_array[$k] = $v;
375 375
 		}
376 376
 	}
@@ -383,34 +383,34 @@  discard block
 block discarded – undo
383 383
  * @param string $alias
384 384
  * @return array
385 385
  */
386
-function treatContent($src, $filename, $alias) {
386
+function treatContent($src, $filename, $alias){
387 387
 	$modx = evolutionCMS();
388 388
 
389 389
 	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
390 390
 
391
-	if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
391
+	if (preg_match("@<title>(.*)</title>@i", $src, $matches)) {
392 392
 		$pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
393 393
 		$pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
394 394
 	} else {
395 395
 		$pagetitle = $alias;
396 396
 	}
397
-	if(!$pagetitle) {
397
+	if (!$pagetitle) {
398 398
 		$pagetitle = $alias;
399 399
 	}
400 400
 
401
-	if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
401
+	if (preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
402 402
 		$description = ($matches[1] !== '') ? $matches[1] : $filename;
403 403
 		$description = str_replace('[*description*]', '', $description);
404 404
 	} else {
405 405
 		$description = '';
406 406
 	}
407 407
 
408
-	if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
408
+	if ((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
409 409
 		$content = $matches[1];
410 410
 	} else {
411 411
 		$content = $src;
412 412
 		$s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
413
-		$r = '$1' . $modx->config['modx_charset'] . '$2';
413
+		$r = '$1'.$modx->config['modx_charset'].'$2';
414 414
 		$content = preg_replace($s, $r, $content);
415 415
 		$content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
416 416
 	}
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 /**
428 428
  * @return void
429 429
  */
430
-function convertLink() {
430
+function convertLink(){
431 431
 	$modx = evolutionCMS();
432 432
 	$tbl_site_content = $modx->getFullTableName('site_content');
433 433
 
@@ -435,33 +435,33 @@  discard block
 block discarded – undo
435 435
 	$p = array();
436 436
     $target = array();
437 437
 	$dir = '';
438
-	while($row = $modx->db->getRow($rs)) {
438
+	while ($row = $modx->db->getRow($rs)) {
439 439
 		$id = $row['id'];
440 440
 		$array = explode('<a href=', $row['content']);
441 441
 		$c = 0;
442
-		foreach($array as $v) {
443
-			if($v[0] === '"') {
442
+		foreach ($array as $v) {
443
+			if ($v[0] === '"') {
444 444
 				$v = substr($v, 1);
445 445
 				list($href, $v) = explode('"', $v, 2);
446 446
 				$_ = $href;
447
-				if(strpos($_, $modx->config['site_url']) !== false) {
448
-					$_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
447
+				if (strpos($_, $modx->config['site_url']) !== false) {
448
+					$_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_);
449 449
 				}
450
-				if($_[0] === '/') {
450
+				if ($_[0] === '/') {
451 451
 					$_ = substr($_, 1);
452 452
 				}
453 453
 				$_ = str_replace('/index.html', '.html', $_);
454 454
 				$level = substr_count($_, '../');
455
-				if(1 < $level) {
456
-					if(!isset($p[$id])) {
455
+				if (1 < $level) {
456
+					if (!isset($p[$id])) {
457 457
 						$p[$id] = $modx->getParentIds($id);
458 458
 					}
459 459
 					$k = array_keys($p[$id]);
460
-					while(0 < $level) {
460
+					while (0 < $level) {
461 461
 						$dir = array_shift($k);
462 462
 						$level--;
463 463
 					}
464
-					if($dir != '') {
464
+					if ($dir != '') {
465 465
 						$dir .= '/';
466 466
 					}
467 467
 				} else {
@@ -469,18 +469,18 @@  discard block
 block discarded – undo
469 469
 				}
470 470
 
471 471
 				$_ = trim($_, './');
472
-				if(strpos($_, '/') !== false) {
472
+				if (strpos($_, '/') !== false) {
473 473
 					$_ = substr($_, strrpos($_, '/'));
474 474
 				}
475
-				$_ = $dir . str_replace('.html', '', $_);
476
-				if(!isset($target[$_])) {
475
+				$_ = $dir.str_replace('.html', '', $_);
476
+				if (!isset($target[$_])) {
477 477
 					$target[$_] = $modx->getIdFromAlias($_);
478 478
 				}
479 479
 				$target[$_] = trim($target[$_]);
480
-				if(!empty($target[$_])) {
481
-					$href = '[~' . $target[$_] . '~]';
480
+				if (!empty($target[$_])) {
481
+					$href = '[~'.$target[$_].'~]';
482 482
 				}
483
-				$array[$c] = '<a href="' . $href . '"' . $v;
483
+				$array[$c] = '<a href="'.$href.'"'.$v;
484 484
 			}
485 485
 			$c++;
486 486
 		}
Please login to merge, or discard this patch.
manager/actions/mutate_content.dynamic.php 1 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.
manager/actions/resources/functions.inc.php 1 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.
manager/actions/resources/mgrResources.class.php 1 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.