Completed
Push — develop ( 49fa03...44ee86 )
by Dmytro
14s
created
manager/includes/controls/datasetpager.class.php 1 patch
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataSetPagerCnt = 0;
12 12
 
13
-class DataSetPager {
13
+class DataSetPager
14
+{
14 15
 
15 16
 	public $ds; // datasource
16 17
     public $pageSize;
@@ -31,7 +32,8 @@  discard block
 block discarded – undo
31 32
     public $renderPagerFnc;
32 33
     public $renderPagerFncArgs;
33 34
 
34
-    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35
+    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1)
36
+    {
35 37
 		global $_PAGE; // use view state object
36 38
 
37 39
 		global $__DataSetPagerCnt;
@@ -61,35 +63,42 @@  discard block
 block discarded – undo
61 63
 		$this->pager = '';
62 64
 	}
63 65
 
64
-    public function getRenderedPager() {
66
+    public function getRenderedPager()
67
+    {
65 68
 		return $this->pager;
66 69
 	}
67 70
 
68
-    public function getRenderedRows() {
71
+    public function getRenderedRows()
72
+    {
69 73
 		return $this->rows;
70 74
 	}
71 75
 
72
-    public function setDataSource($ds) {
76
+    public function setDataSource($ds)
77
+    {
73 78
 		$this->ds = $ds;
74 79
 	}
75 80
 
76
-    public function setPageSize($ps) {
81
+    public function setPageSize($ps)
82
+    {
77 83
 		$this->pageSize = $ps;
78 84
 	}
79 85
 
80
-    public function setRenderRowFnc($fncName, $args = "") {
86
+    public function setRenderRowFnc($fncName, $args = "")
87
+    {
81 88
 		$this->renderRowFnc = &$fncName;
82 89
 		$this->renderRowFncArgs = $args;    // extra agruments
83 90
 
84 91
 
85 92
 	}
86 93
 
87
-    public function setRenderPagerFnc($fncName, $args = "") {
94
+    public function setRenderPagerFnc($fncName, $args = "")
95
+    {
88 96
 		$this->renderPagerFnc = $fncName;
89 97
 		$this->renderPagerFncArgs = $args;    // extra agruments
90 98
 	}
91 99
 
92
-    public function render() {
100
+    public function render()
101
+    {
93 102
 		global $modx, $_PAGE;
94 103
 
95 104
 		$isDataset = $modx->db->isResult($this->ds);
@@ -142,8 +151,10 @@  discard block
 block discarded – undo
142 151
 					$url = $_SERVER['PHP_SELF'] . '?';
143 152
 				}
144 153
 				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
154
+				foreach($_GET as $n => $v) {
155
+				    if($n != 'dpgn' . $this->id) {
146 156
 					$i++;
157
+				}
147 158
 					$url .= (($i > 1) ? "&" : "") . "$n=$v";
148 159
 				}
149 160
 				if($i >= 1) {
Please login to merge, or discard this patch.
manager/processors/save_settings.processor.php 1 patch
Braces   +18 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,39 +9,27 @@  discard block
 block discarded – undo
9 9
 // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972
10 10
 unset($_POST);
11 11
 
12
-if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false)
13
-{
12
+if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) {
14 13
 	$htaccess        = $modx->config['base_path'] . '.htaccess';
15 14
 	$sample_htaccess = $modx->config['base_path'] . 'ht.access';
16 15
 	$dir = '/' . trim($modx->config['base_url'],'/');
17
-	if(is_file($htaccess))
18
-	{
16
+	if(is_file($htaccess)) {
19 17
 		$_ = file_get_contents($htaccess);
20
-		if(strpos($_,'RewriteBase')===false)
21
-		{
18
+		if(strpos($_,'RewriteBase')===false) {
22 19
 			$warnings[] = $_lang["settings_friendlyurls_alert2"];
23
-		}
24
-		elseif(is_writable($htaccess))
25
-		{
20
+		} elseif(is_writable($htaccess)) {
26 21
 			$_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_);
27
-			if(!@file_put_contents($htaccess,$_))
28
-			{
22
+			if(!@file_put_contents($htaccess,$_)) {
29 23
 				$warnings[] = $_lang["settings_friendlyurls_alert2"];
30 24
 			}
31 25
 		}
32
-	}
33
-	elseif(is_file($sample_htaccess))
34
-	{
35
-		if(!@rename($sample_htaccess,$htaccess))
36
-        {
26
+	} elseif(is_file($sample_htaccess)) {
27
+		if(!@rename($sample_htaccess,$htaccess)) {
37 28
         	$warnings[] = $_lang["settings_friendlyurls_alert"];
38
-		}
39
-		elseif($modx->config['base_url']!=='/')
40
-		{
29
+		} elseif($modx->config['base_url']!=='/') {
41 30
 			$_ = file_get_contents($htaccess);
42 31
 			$_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_);
43
-			if(!@file_put_contents($htaccess,$_))
44
-			{
32
+			if(!@file_put_contents($htaccess,$_)) {
45 33
 				$warnings[] = $_lang["settings_friendlyurls_alert2"];
46 34
 			}
47 35
 		}
@@ -70,7 +58,7 @@  discard block
 block discarded – undo
70 58
 	foreach ($data as $k => $v) {
71 59
 		switch ($k) {
72 60
             case 'settings_version':{
73
-                if($modx->getVersionData('version')!=$data['settings_version']){
61
+                if($modx->getVersionData('version')!=$data['settings_version']) {
74 62
                     $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version');
75 63
                     $v = $modx->getVersionData('version');
76 64
                 }
@@ -131,7 +119,9 @@  discard block
 block discarded – undo
131 119
 
132 120
 		$modx->config[$k] = $v;
133 121
 
134
-		if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')';
122
+		if(!empty($k)) {
123
+		    $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')';
124
+		}
135 125
 	}
136 126
 
137 127
 	// Run a single query to save all the values
@@ -145,8 +135,11 @@  discard block
 block discarded – undo
145 135
 		$oldtemplate = (int)$data['old_template'];
146 136
 		$tbl = $modx->getFullTableName('site_content');
147 137
 		$reset = $data['reset_template'];
148
-		if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'");
149
-		else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'");
138
+		if($reset==1) {
139
+		    $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'");
140
+		} else if($reset==2) {
141
+		    $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'");
142
+		}
150 143
 	}
151 144
 
152 145
 	// empty cache
Please login to merge, or discard this patch.
manager/processors/save_plugin.processor.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -177,7 +177,9 @@  discard block
 block discarded – undo
177 177
     // save selected system events
178 178
     $formEventList = array();
179 179
     foreach ($sysevents as $evtId) {
180
-        if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId);
180
+        if(!preg_match('@^[1-9][0-9]*$@',$evtId)) {
181
+            $evtId = getEventIdByName($evtId);
182
+        }
181 183
         if ($mode == '101') {
182 184
             $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'");
183 185
         } else {
@@ -203,10 +205,14 @@  discard block
 block discarded – undo
203 205
     $dbEventList = array();
204 206
     $del = array();
205 207
     while($row = $modx->db->getRow($rs)) {
206
-        if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid'];
208
+        if(!in_array($row['evtid'], $evtids)) {
209
+            $del[] = $row['evtid'];
210
+        }
207 211
     }
208 212
 
209
-    if(empty($del)) return;
213
+    if(empty($del)) {
214
+        return;
215
+    }
210 216
 
211 217
     foreach($del as $delid) {
212 218
         $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id));
@@ -218,7 +224,9 @@  discard block
 block discarded – undo
218 224
     global $modx;
219 225
     static $eventIds=array();
220 226
 
221
-    if(isset($eventIds[$name])) return $eventIds[$name];
227
+    if(isset($eventIds[$name])) {
228
+        return $eventIds[$name];
229
+    }
222 230
 
223 231
     $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames');
224 232
     while ($row = $modx->db->getRow($rs)) {
Please login to merge, or discard this patch.
manager/actions/welcome.static.php 1 patch
Braces   +77 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
4 4
 }
5 5
 
6 6
 unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
7 7
 
8
-if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
8
+if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
9 9
 	// seems to be a new install - send the user to the configuration page
10 10
 	exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
11 11
 }
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 $_SESSION['nrnewmessages'] = 0;
17 17
 
18 18
 // setup message info
19
-if($modx->hasPermission('messages')) {
19
+if($modx->hasPermission('messages')) {
20 20
 	include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
21 21
 	$_SESSION['nrtotalmessages'] = $nrtotalmessages;
22 22
 	$_SESSION['nrnewmessages'] = $nrnewmessages;
@@ -32,46 +32,46 @@  discard block
 block discarded – undo
32 32
 }
33 33
 
34 34
 // setup icons
35
-if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
35
+if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
36 36
 	$icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37 37
 	$ph['SecurityIcon'] = wrapIcon($icon, 75);
38 38
 }
39
-if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
39
+if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
40 40
 	$icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41 41
 	$ph['WebUserIcon'] = wrapIcon($icon, 99);
42 42
 }
43
-if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
43
+if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
44 44
 	$icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45 45
 	$ph['ModulesIcon'] = wrapIcon($icon, 106);
46 46
 }
47
-if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
47
+if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
48 48
 	$icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49 49
 	$ph['ResourcesIcon'] = wrapIcon($icon, 76);
50 50
 }
51
-if($modx->hasPermission('bk_manager')) {
51
+if($modx->hasPermission('bk_manager')) {
52 52
 	$icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53 53
 	$ph['BackupIcon'] = wrapIcon($icon, 93);
54 54
 }
55
-if($modx->hasPermission('help')) {
55
+if($modx->hasPermission('help')) {
56 56
 	$icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57 57
 	$ph['HelpIcon'] = wrapIcon($icon, 9);
58 58
 }
59 59
 // do some config checks
60
-if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
60
+if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
61 61
 	include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
62
-	if($config_check_results != $_lang['configcheck_ok']) {
62
+	if($config_check_results != $_lang['configcheck_ok']) {
63 63
 		$ph['config_check_results'] = $config_check_results;
64 64
 		$ph['config_display'] = 'block';
65
-	} else {
65
+	} else {
66 66
 		$ph['config_display'] = 'none';
67 67
 	}
68
-} else {
68
+} else {
69 69
 	$ph['config_display'] = 'none';
70 70
 }
71 71
 
72 72
 // Check logout-reminder
73
-if(isset($_SESSION['show_logout_reminder'])) {
74
-	switch($_SESSION['show_logout_reminder']['type']) {
73
+if(isset($_SESSION['show_logout_reminder'])) {
74
+	switch($_SESSION['show_logout_reminder']['type']) {
75 75
 		case 'logout_reminder':
76 76
 			$date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
77 77
 			$ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 	$ph['show_logout_reminder'] = 'block';
81 81
 	unset($_SESSION['show_logout_reminder']);
82
-} else {
82
+} else {
83 83
 	$ph['show_logout_reminder'] = 'none';
84 84
 }
85 85
 
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'";
141 141
 $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
142 142
 
143
-if($modx->db->getRecordCount($rs) < 1) {
143
+if($modx->db->getRecordCount($rs) < 1) {
144 144
 	$html = '<p>[%no_active_users_found%]</p>';
145
-} else {
145
+} else {
146 146
 	include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
147 147
 	$now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
148 148
 	$ph['now'] = strftime('%H:%M:%S', $now);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	$userList = array();
169 169
 	$userCount = array();
170 170
 	// Create userlist with session-count first before output
171
-	while($activeusers = $modx->db->getRow($rs)) {
171
+	while($activeusers = $modx->db->getRow($rs)) {
172 172
 		$userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
173 173
 
174 174
 		$idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			$currentaction
187 187
 		);
188 188
 	}
189
-	foreach($userList as $params) {
189
+	foreach($userList as $params) {
190 190
 		$params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
191 191
 		$html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
192 192
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 // invoke event OnManagerWelcomePrerender
233 233
 $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
234
-if(is_array($evtOut)) {
234
+if(is_array($evtOut)) {
235 235
 	$output = implode('', $evtOut);
236 236
 	$ph['OnManagerWelcomePrerender'] = $output;
237 237
 }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	'body' => '<div class="widget-stage">[+RecentInfo+]</div>',
341 341
 	'hide'=>'0'
342 342
 );
343
-if ($modx->config['rss_url_news']) {
343
+if ($modx->config['rss_url_news']) {
344 344
     $widgets['news'] = array(
345 345
         'menuindex' => '40',
346 346
         'id' => 'news',
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
         'hide'=>'0'
352 352
     );
353 353
 }
354
-if ($modx->config['rss_url_security']) {
354
+if ($modx->config['rss_url_security']) {
355 355
     $widgets['security'] = array(
356 356
         'menuindex' => '50',
357 357
         'id' => 'security',
@@ -365,29 +365,29 @@  discard block
 block discarded – undo
365 365
 
366 366
 // invoke OnManagerWelcomeHome event
367 367
 $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
368
-if(is_array($sitewidgets)) {
368
+if(is_array($sitewidgets)) {
369 369
 	$newwidgets = array();
370
-    foreach($sitewidgets as $widget){
370
+    foreach($sitewidgets as $widget) {
371 371
         $newwidgets = array_merge($newwidgets, unserialize($widget));
372 372
     }
373 373
     $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets;
374 374
 }
375 375
 
376
-usort($widgets, function ($a, $b) {
376
+usort($widgets, function ($a, $b){
377 377
 	return $a['menuindex'] - $b['menuindex'];
378 378
 });
379 379
 
380 380
 $tpl = getTplWidget();
381 381
 $output = '';
382
-foreach($widgets as $widget) {
383
-	if ($widget['hide'] != '1'){
382
+foreach($widgets as $widget) {
383
+	if ($widget['hide'] != '1') {
384 384
 		$output .= $modx->parseText($tpl, $widget);
385 385
 	}
386 386
 }
387 387
 $ph['widgets'] = $output;
388 388
 
389 389
 // load template
390
-if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
390
+if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
391 391
 	$modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
392 392
 }
393 393
 
@@ -395,26 +395,28 @@  discard block
 block discarded – undo
395 395
 $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target);
396 396
 $target = $modx->mergeSettingsContent($target);
397 397
 
398
-if(substr($target, 0, 1) === '@') {
399
-	if(substr($target, 0, 6) === '@CHUNK') {
398
+if(substr($target, 0, 1) === '@') {
399
+	if(substr($target, 0, 6) === '@CHUNK') {
400 400
 		$content = $modx->getChunk(trim(substr($target, 7)));
401
-	} elseif(substr($target, 0, 5) === '@FILE') {
401
+	} elseif(substr($target, 0, 5) === '@FILE') {
402 402
 		$content = file_get_contents(trim(substr($target, 6)));
403
-	} else {
403
+	} else {
404 404
 		$content = '';
405 405
 	}
406
-} else {
406
+} else {
407 407
 	$chunk = $modx->getChunk($target);
408
-	if($chunk !== false && !empty($chunk)) {
408
+	if($chunk !== false && !empty($chunk)) {
409 409
 		$content = $chunk;
410
-	} elseif(is_file(MODX_BASE_PATH . $target)) {
410
+	} elseif(is_file(MODX_BASE_PATH . $target)) {
411 411
 		$content = file_get_contents(MODX_BASE_PATH . $target);
412
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
412
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
413 413
 		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
414
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
414
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) {
415
+	    // ClipperCMS compatible
415 416
 	{
416
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
417
-	} else {
417
+		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
418
+	}
419
+	} else {
418 420
 		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
419 421
 	}
420 422
 }
@@ -423,7 +425,7 @@  discard block
 block discarded – undo
423 425
 $content = $modx->mergeConditionalTagsContent($content);
424 426
 $content = $modx->mergeSettingsContent($content);
425 427
 $content = $modx->parseText($content, $ph);
426
-if(strpos($content, '[+') !== false) {
428
+if(strpos($content, '[+') !== false) {
427 429
 	$modx->toPlaceholders($ph);
428 430
 	$content = $modx->mergePlaceholderContent($content);
429 431
 }
@@ -432,7 +434,7 @@  discard block
 block discarded – undo
432 434
 $content = $modx->parseText($content, $_style, '[&', '&]');
433 435
 $content = $modx->cleanUpMODXTags($content); //cleanup
434 436
 
435
-if($js = $modx->getRegisteredClientScripts()) {
437
+if($js = $modx->getRegisteredClientScripts()) {
436 438
 	$content .= $js;
437 439
 }
438 440
 
@@ -442,7 +444,9 @@  discard block
 block discarded – undo
442 444
 //	<a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a>
443 445
 //  <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a>
444 446
 //</span>
445
-function getTplWidget() { // recent document info
447
+function getTplWidget()
448
+{
449
+// recent document info
446 450
 	return '
447 451
 		<div class="[+cols+]" id="[+id+]">
448 452
 			<div class="card"[+cardAttr+]>
@@ -453,7 +457,9 @@  discard block
 block discarded – undo
453 457
 ';
454 458
 }
455 459
 
456
-function getRecentInfo() { // recent document info
460
+function getRecentInfo()
461
+{
462
+// recent document info
457 463
 	global $modx;
458 464
 
459 465
 	$modx->addSnippet('recentInfoList', 'getRecentInfoList');
@@ -479,12 +485,13 @@  discard block
 block discarded – undo
479 485
 	return $html;
480 486
 }
481 487
 
482
-function getRecentInfoList() {
488
+function getRecentInfoList()
489
+{
483 490
 	global $modx;
484 491
 
485 492
 	$rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
486 493
 
487
-	if($modx->db->getRecordCount($rs) < 1) {
494
+	if($modx->db->getRecordCount($rs) < 1) {
488 495
 		return '<tr><td>[%no_activity_message%]</td></tr>';
489 496
 	}
490 497
 
@@ -494,22 +501,22 @@  discard block
 block discarded – undo
494 501
 	$btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
495 502
 
496 503
 	$output = array();
497
-	while($ph = $modx->db->getRow($rs)) {
504
+	while($ph = $modx->db->getRow($rs)) {
498 505
 		$docid = $ph['id'];
499 506
 		$_ = $modx->getUserInfo($ph['editedby']);
500 507
 		$ph['username'] = $_['username'];
501 508
 
502
-		if($ph['deleted'] == 1) {
509
+		if($ph['deleted'] == 1) {
503 510
 			$ph['status'] = 'deleted text-danger';
504
-		} elseif($ph['published'] == 0) {
511
+		} elseif($ph['published'] == 0) {
505 512
 			$ph['status'] = 'unpublished font-italic text-muted';
506
-		} else {
513
+		} else {
507 514
 			$ph['status'] = 'published';
508 515
 		}
509 516
 
510
-		if($modx->hasPermission('edit_document')) {
517
+		if($modx->hasPermission('edit_document')) {
511 518
 			$ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
512
-		} else {
519
+		} else {
513 520
 			$ph['edit_btn'] = '';
514 521
 		}
515 522
 
@@ -522,40 +529,40 @@  discard block
 block discarded – undo
522 529
 			$preview_disabled
523 530
 		), $btntpl['preview_btn']);
524 531
 
525
-		if($modx->hasPermission('delete_document')) {
526
-			if($ph['deleted'] == 0) {
532
+		if($modx->hasPermission('delete_document')) {
533
+			if($ph['deleted'] == 0) {
527 534
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> ';
528
-			} else {
535
+			} else {
529 536
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
530 537
 			}
531 538
 			$ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
532
-		} else {
539
+		} else {
533 540
 			$ph['delete_btn'] = '';
534 541
 		}
535 542
 
536
-		if($ph['deleted'] == 1 && $ph['published'] == 0) {
543
+		if($ph['deleted'] == 1 && $ph['published'] == 0) {
537 544
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
538
-		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
545
+		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
539 546
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
540
-		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
547
+		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
541 548
 			$publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
542
-		} else {
549
+		} else {
543 550
 			$publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
544 551
 		}
545 552
 		$ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
546 553
 
547 554
 		$ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
548 555
 
549
-		if($ph['longtitle'] == '') {
556
+		if($ph['longtitle'] == '') {
550 557
 			$ph['longtitle'] = '(<i>[%not_set%]</i>)';
551 558
 		}
552
-		if($ph['description'] == '') {
559
+		if($ph['description'] == '') {
553 560
 			$ph['description'] = '(<i>[%not_set%]</i>)';
554 561
 		}
555
-		if($ph['introtext'] == '') {
562
+		if($ph['introtext'] == '') {
556 563
 			$ph['introtext'] = '(<i>[%not_set%]</i>)';
557 564
 		}
558
-		if($ph['alias'] == '') {
565
+		if($ph['alias'] == '') {
559 566
 			$ph['alias'] = '(<i>[%not_set%]</i>)';
560 567
 		}
561 568
 
@@ -564,7 +571,8 @@  discard block
 block discarded – undo
564 571
 	return implode("\n", $output);
565 572
 }
566 573
 
567
-function getRecentInfoRowTpl() {
574
+function getRecentInfoRowTpl()
575
+{
568 576
 	$tpl = '
569 577
 						<tr>
570 578
 							<td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td>
@@ -593,11 +601,13 @@  discard block
 block discarded – undo
593 601
 }
594 602
 
595 603
 // setup icons
596
-function wrapIcon($i, $action) {
604
+function wrapIcon($i, $action)
605
+{
597 606
 	return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
598 607
 }
599 608
 
600
-function getStartUpScript() {
609
+function getStartUpScript()
610
+{
601 611
 	$script = '
602 612
         <script type="text/javascript">
603 613
         function hideConfigCheckWarning(key) {
Please login to merge, or discard this patch.
manager/media/rss/rss_parse.inc 1 patch
Braces   +89 added lines, -115 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@  discard block
 block discarded – undo
31 31
 * see: rss_fetch.inc for a simpler interface with integrated caching support
32 32
 *
33 33
 */
34
-class MagpieRSS {
34
+class MagpieRSS
35
+{
35 36
     var $parser;
36 37
 
37 38
     var $current_item   = array();  // item currently being parsed
@@ -143,7 +144,8 @@  discard block
 block discarded – undo
143 144
         $this->normalize();
144 145
     }
145 146
 
146
-    function feed_start_element($p, $element, &$attrs) {
147
+    function feed_start_element($p, $element, &$attrs)
148
+    {
147 149
         $el = $element = strtolower($element);
148 150
         $attrs = array_change_key_case($attrs, CASE_LOWER);
149 151
 
@@ -163,12 +165,10 @@  discard block
 block discarded – undo
163 165
             if ( $el == 'rdf' ) {
164 166
                 $this->feed_type = RSS;
165 167
                 $this->feed_version = '1.0';
166
-            }
167
-            elseif ( $el == 'rss' ) {
168
+            } elseif ( $el == 'rss' ) {
168 169
                 $this->feed_type = RSS;
169 170
                 $this->feed_version = $attrs['version'];
170
-            }
171
-            elseif ( $el == 'feed' ) {
171
+            } elseif ( $el == 'feed' ) {
172 172
                 $this->feed_type = ATOM;
173 173
                 $this->feed_version = $attrs['version'];
174 174
                 $this->inchannel = true;
@@ -176,12 +176,9 @@  discard block
 block discarded – undo
176 176
             return;
177 177
         }
178 178
 
179
-        if ( $el == 'channel' )
180
-        {
179
+        if ( $el == 'channel' ) {
181 180
             $this->inchannel = true;
182
-        }
183
-        elseif ($el == 'item' or $el == 'entry' )
184
-        {
181
+        } elseif ($el == 'item' or $el == 'entry' ) {
185 182
             $this->initem = true;
186 183
             if ( isset($attrs['rdf:about']) ) {
187 184
                 $this->current_item['about'] = $attrs['rdf:about'];
@@ -193,22 +190,17 @@  discard block
 block discarded – undo
193 190
         elseif (
194 191
             $this->feed_type == RSS and
195 192
             $this->current_namespace == '' and
196
-            $el == 'textinput' )
197
-        {
193
+            $el == 'textinput' ) {
198 194
             $this->intextinput = true;
199
-        }
200
-
201
-        elseif (
195
+        } elseif (
202 196
             $this->feed_type == RSS and
203 197
             $this->current_namespace == '' and
204
-            $el == 'image' )
205
-        {
198
+            $el == 'image' ) {
206 199
             $this->inimage = true;
207 200
         }
208 201
 
209 202
         # handle atom content constructs
210
-        elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
211
-        {
203
+        elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) {
212 204
             // avoid clashing w/ RSS mod_content
213 205
             if ($el == 'content' ) {
214 206
                 $el = 'atom_content';
@@ -220,8 +212,7 @@  discard block
 block discarded – undo
220 212
         }
221 213
 
222 214
         // if inside an Atom content construct (e.g. content or summary) field treat tags as text
223
-        elseif ($this->feed_type == ATOM and $this->incontent )
224
-        {
215
+        elseif ($this->feed_type == ATOM and $this->incontent ) {
225 216
             // if tags are inlined, then flatten
226 217
             $attrs_str = implode(' ',
227 218
                     array_map('map_attrs',
@@ -237,13 +228,10 @@  discard block
 block discarded – undo
237 228
         // Magpie treats link elements of type rel='alternate'
238 229
         // as being equivalent to RSS's simple link element.
239 230
         //
240
-        elseif ($this->feed_type == ATOM and $el == 'link' )
241
-        {
242
-            if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
243
-            {
231
+        elseif ($this->feed_type == ATOM and $el == 'link' ) {
232
+            if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) {
244 233
                 $link_el = 'link';
245
-            }
246
-            else {
234
+            } else {
247 235
                 $link_el = 'link_' . $attrs['rel'];
248 236
             }
249 237
 
@@ -257,63 +245,51 @@  discard block
 block discarded – undo
257 245
 
258 246
 
259 247
 
260
-    function feed_cdata ($p, $text) {
261
-        if ($this->feed_type == ATOM and $this->incontent)
262
-        {
248
+    function feed_cdata ($p, $text)
249
+    {
250
+        if ($this->feed_type == ATOM and $this->incontent) {
263 251
             $this->append_content( $text );
264
-        }
265
-        else {
252
+        } else {
266 253
             $current_el = implode('_', array_reverse($this->stack));
267 254
             $this->append($current_el, $text);
268 255
         }
269 256
     }
270 257
 
271
-    function feed_end_element ($p, $el) {
258
+    function feed_end_element ($p, $el)
259
+    {
272 260
         $el = strtolower($el);
273 261
 
274
-        if ( $el == 'item' or $el == 'entry' )
275
-        {
262
+        if ( $el == 'item' or $el == 'entry' ) {
276 263
             $this->items[] = $this->current_item;
277 264
             $this->current_item = array();
278 265
             $this->initem = false;
279
-        }
280
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
281
-        {
266
+        } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) {
282 267
             $this->intextinput = false;
283
-        }
284
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
285
-        {
268
+        } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) {
286 269
             $this->inimage = false;
287
-        }
288
-        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
289
-        {
270
+        } elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) {
290 271
             $this->incontent = false;
291
-        }
292
-        elseif ($el == 'channel' or $el == 'feed' )
293
-        {
272
+        } elseif ($el == 'channel' or $el == 'feed' ) {
294 273
             $this->inchannel = false;
295
-        }
296
-        elseif ($this->feed_type == ATOM and $this->incontent  ) {
274
+        } elseif ($this->feed_type == ATOM and $this->incontent  ) {
297 275
             // balance tags properly
298 276
             // note:  i don't think this is actually neccessary
299
-            if ( $this->stack[0] == $el )
300
-            {
277
+            if ( $this->stack[0] == $el ) {
301 278
                 $this->append_content("</$el>");
302
-            }
303
-            else {
279
+            } else {
304 280
                 $this->append_content("<$el />");
305 281
             }
306 282
 
307 283
             array_shift( $this->stack );
308
-        }
309
-        else {
284
+        } else {
310 285
             array_shift( $this->stack );
311 286
         }
312 287
 
313 288
         $this->current_namespace = false;
314 289
     }
315 290
 
316
-    function concat (&$str1, $str2="") {
291
+    function concat (&$str1, $str2="")
292
+    {
317 293
         if (!isset($str1) ) {
318 294
             $str1="";
319 295
         }
@@ -322,53 +298,46 @@  discard block
 block discarded – undo
322 298
 
323 299
 
324 300
 
325
-    function append_content($text) {
301
+    function append_content($text)
302
+    {
326 303
         if ( $this->initem ) {
327 304
             $this->concat( $this->current_item[ $this->incontent ], $text );
328
-        }
329
-        elseif ( $this->inchannel ) {
305
+        } elseif ( $this->inchannel ) {
330 306
             $this->concat( $this->channel[ $this->incontent ], $text );
331 307
         }
332 308
     }
333 309
 
334 310
     // smart append - field and namespace aware
335
-    function append($el, $text) {
311
+    function append($el, $text)
312
+    {
336 313
         if (!$el) {
337 314
             return;
338 315
         }
339
-        if ( $this->current_namespace )
340
-        {
316
+        if ( $this->current_namespace ) {
341 317
             if ( $this->initem ) {
342 318
                 $this->concat(
343 319
                     $this->current_item[ $this->current_namespace ][ $el ], $text);
344
-            }
345
-            elseif ($this->inchannel) {
320
+            } elseif ($this->inchannel) {
346 321
                 $this->concat(
347 322
                     $this->channel[ $this->current_namespace][ $el ], $text );
348
-            }
349
-            elseif ($this->intextinput) {
323
+            } elseif ($this->intextinput) {
350 324
                 $this->concat(
351 325
                     $this->textinput[ $this->current_namespace][ $el ], $text );
352
-            }
353
-            elseif ($this->inimage) {
326
+            } elseif ($this->inimage) {
354 327
                 $this->concat(
355 328
                     $this->image[ $this->current_namespace ][ $el ], $text );
356 329
             }
357
-        }
358
-        else {
330
+        } else {
359 331
             if ( $this->initem ) {
360 332
                 $this->concat(
361 333
                     $this->current_item[ $el ], $text);
362
-            }
363
-            elseif ($this->intextinput) {
334
+            } elseif ($this->intextinput) {
364 335
                 $this->concat(
365 336
                     $this->textinput[ $el ], $text );
366
-            }
367
-            elseif ($this->inimage) {
337
+            } elseif ($this->inimage) {
368 338
                 $this->concat(
369 339
                     $this->image[ $el ], $text );
370
-            }
371
-            elseif ($this->inchannel) {
340
+            } elseif ($this->inchannel) {
372 341
                 $this->concat(
373 342
                     $this->channel[ $el ], $text );
374 343
             }
@@ -376,16 +345,19 @@  discard block
 block discarded – undo
376 345
         }
377 346
     }
378 347
 
379
-    function normalize () {
348
+    function normalize ()
349
+    {
380 350
         // if atom populate rss fields
381 351
         if ( $this->is_atom() ) {
382 352
             $this->channel['description'] = $this->channel['tagline'];
383 353
             for ( $i = 0; $i < count($this->items); $i++) {
384 354
                 $item = $this->items[$i];
385
-                if ( isset($item['summary']) )
386
-                    $item['description'] = $item['summary'];
387
-                if ( isset($item['atom_content']))
388
-                    $item['content']['encoded'] = $item['atom_content'];
355
+                if ( isset($item['summary']) ) {
356
+                                    $item['description'] = $item['summary'];
357
+                }
358
+                if ( isset($item['atom_content'])) {
359
+                                    $item['content']['encoded'] = $item['atom_content'];
360
+                }
389 361
 
390 362
                 $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified'];
391 363
                 if ( $atom_date ) {
@@ -397,23 +369,23 @@  discard block
 block discarded – undo
397 369
 
398 370
                 $this->items[$i] = $item;
399 371
             }
400
-        }
401
-        elseif ( $this->is_rss() ) {
372
+        } elseif ( $this->is_rss() ) {
402 373
             $this->channel['tagline'] = $this->channel['description'];
403 374
             for ( $i = 0; $i < count($this->items); $i++) {
404 375
                 $item = $this->items[$i];
405
-                if ( isset($item['description']))
406
-                    $item['summary'] = $item['description'];
407
-                if ( isset($item['content']['encoded'] ) )
408
-                    $item['atom_content'] = $item['content']['encoded'];
376
+                if ( isset($item['description'])) {
377
+                                    $item['summary'] = $item['description'];
378
+                }
379
+                if ( isset($item['content']['encoded'] ) ) {
380
+                                    $item['atom_content'] = $item['content']['encoded'];
381
+                }
409 382
 
410 383
                 if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) {
411 384
                     $epoch = @parse_w3cdtf($item['dc']['date']);
412 385
                     if ($epoch and $epoch > 0) {
413 386
                         $item['date_timestamp'] = $epoch;
414 387
                     }
415
-                }
416
-                elseif ( isset($item['pubdate']) ) {
388
+                } elseif ( isset($item['pubdate']) ) {
417 389
                     $epoch = @strtotime($item['pubdate']);
418 390
                     if ($epoch > 0) {
419 391
                         $item['date_timestamp'] = $epoch;
@@ -426,20 +398,20 @@  discard block
 block discarded – undo
426 398
     }
427 399
 
428 400
 
429
-    function is_rss () {
401
+    function is_rss ()
402
+    {
430 403
         if ( $this->feed_type == RSS ) {
431 404
             return $this->feed_version;
432
-        }
433
-        else {
405
+        } else {
434 406
             return false;
435 407
         }
436 408
     }
437 409
 
438
-    function is_atom() {
410
+    function is_atom()
411
+    {
439 412
         if ( $this->feed_type == ATOM ) {
440 413
             return $this->feed_version;
441
-        }
442
-        else {
414
+        } else {
443 415
             return false;
444 416
         }
445 417
     }
@@ -448,11 +420,11 @@  discard block
 block discarded – undo
448 420
     * return XML parser, and possibly re-encoded source
449 421
     *
450 422
     */
451
-    function create_parser($source, $out_enc, $in_enc, $detect) {
423
+    function create_parser($source, $out_enc, $in_enc, $detect)
424
+    {
452 425
         if ( substr(phpversion(),0,1) == 5) {
453 426
             $parser = $this->php5_create_parser($in_enc, $detect);
454
-        }
455
-        else {
427
+        } else {
456 428
             list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect);
457 429
         }
458 430
         if ($out_enc) {
@@ -472,12 +444,12 @@  discard block
 block discarded – undo
472 444
     * All hail libxml2!
473 445
     *
474 446
     */
475
-    function php5_create_parser($in_enc, $detect) {
447
+    function php5_create_parser($in_enc, $detect)
448
+    {
476 449
         // by default php5 does a fine job of detecting input encodings
477 450
         if(!$detect && $in_enc) {
478 451
             return xml_parser_create($in_enc);
479
-        }
480
-        else {
452
+        } else {
481 453
             return xml_parser_create('');
482 454
         }
483 455
     }
@@ -497,7 +469,8 @@  discard block
 block discarded – undo
497 469
     * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
498 470
     *
499 471
     */
500
-    function php4_create_parser($source, $in_enc, $detect) {
472
+    function php4_create_parser($source, $in_enc, $detect)
473
+    {
501 474
         if ( !$detect ) {
502 475
             return array(xml_parser_create($in_enc), $source);
503 476
         }
@@ -506,8 +479,7 @@  discard block
 block discarded – undo
506 479
             if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
507 480
                 $in_enc = strtoupper($m[1]);
508 481
                 $this->source_encoding = $in_enc;
509
-            }
510
-            else {
482
+            } else {
511 483
                 $in_enc = 'UTF-8';
512 484
             }
513 485
         }
@@ -522,7 +494,7 @@  discard block
 block discarded – undo
522 494
         // cast the XML to a known encoding
523 495
         // @see http://php.net/iconv
524 496
 
525
-        if (function_exists('iconv'))  {
497
+        if (function_exists('iconv')) {
526 498
             $encoded_source = iconv($in_enc,'UTF-8', $source);
527 499
             if ($encoded_source) {
528 500
                 return array(xml_parser_create('UTF-8'), $encoded_source);
@@ -546,25 +518,25 @@  discard block
 block discarded – undo
546 518
         return array(xml_parser_create(), $source);
547 519
     }
548 520
 
549
-    function known_encoding($enc) {
521
+    function known_encoding($enc)
522
+    {
550 523
         $enc = strtoupper($enc);
551 524
         if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) {
552 525
             return $enc;
553
-        }
554
-        else {
526
+        } else {
555 527
             return false;
556 528
         }
557 529
     }
558 530
 
559
-    function error ($errormsg, $lvl=E_USER_WARNING) {
531
+    function error ($errormsg, $lvl=E_USER_WARNING)
532
+    {
560 533
         // append PHP's error message if track_errors enabled
561 534
         if ( isset($php_errormsg) ) {
562 535
             $errormsg .= " ($php_errormsg)";
563 536
         }
564 537
         if ( MAGPIE_DEBUG ) {
565 538
             trigger_error( $errormsg, $lvl);
566
-        }
567
-        else {
539
+        } else {
568 540
             error_log( $errormsg, 0);
569 541
         }
570 542
 
@@ -579,7 +551,8 @@  discard block
 block discarded – undo
579 551
 
580 552
 } // end class RSS
581 553
 
582
-function map_attrs($k, $v) {
554
+function map_attrs($k, $v)
555
+{
583 556
     return "$k=\"$v\"";
584 557
 }
585 558
 
@@ -591,9 +564,10 @@  discard block
 block discarded – undo
591 564
 	define('CASE_LOWER', 0);
592 565
 
593 566
 
594
-	function array_change_key_case($array, $case=CASE_LOWER) {
567
+	function array_change_key_case($array, $case=CASE_LOWER)
568
+	{
595 569
         $output = array();
596
-        switch($case){
570
+        switch($case) {
597 571
            case CASE_LOWER:
598 572
                $cmd='strtolower';
599 573
                break;
Please login to merge, or discard this patch.
manager/media/rss/rss_cache.inc 1 patch
Braces   +26 added lines, -19 removed lines patch added patch discarded remove patch
@@ -16,12 +16,14 @@  discard block
 block discarded – undo
16 16
  *
17 17
  */
18 18
 
19
-class RSSCache {
19
+class RSSCache
20
+{
20 21
     var $BASE_CACHE = './cache';    // where the cache files are stored
21 22
     var $MAX_AGE    = 3600;         // when are files stale, default one hour
22 23
     var $ERROR      = "";           // accumulate error messages
23 24
 
24
-    function __construct($base='', $age='') {
25
+    function __construct($base='', $age='')
26
+    {
25 27
         if ( $base ) {
26 28
             $this->BASE_CACHE = $base;
27 29
         }
@@ -48,7 +50,8 @@  discard block
 block discarded – undo
48 50
     Input:      url from wich the rss file was fetched
49 51
     Output:     true on sucess
50 52
 \*=======================================================================*/
51
-    function set ($url, $rss) {
53
+    function set ($url, $rss)
54
+    {
52 55
         $this->ERROR = "";
53 56
         $cache_file = $this->file_name( $url );
54 57
         $fp = @fopen( $cache_file, 'w' );
@@ -74,7 +77,8 @@  discard block
 block discarded – undo
74 77
     Input:      url from wich the rss file was fetched
75 78
     Output:     cached object on HIT, false on MISS
76 79
 \*=======================================================================*/
77
-    function get ($url) {
80
+    function get ($url)
81
+    {
78 82
         $this->ERROR = "";
79 83
         $cache_file = $this->file_name( $url );
80 84
 
@@ -110,7 +114,8 @@  discard block
 block discarded – undo
110 114
     Input:      url from wich the rss file was fetched
111 115
     Output:     cached object on HIT, false on MISS
112 116
 \*=======================================================================*/
113
-    function check_cache ( $url ) {
117
+    function check_cache ( $url )
118
+    {
114 119
         $this->ERROR = "";
115 120
         $filename = $this->file_name( $url );
116 121
 
@@ -122,26 +127,24 @@  discard block
 block discarded – undo
122 127
             if ( $this->MAX_AGE > $age ) {
123 128
                 // object exists and is current
124 129
                 return 'HIT';
125
-            }
126
-            else {
130
+            } else {
127 131
                 // object exists but is old
128 132
                 return 'STALE';
129 133
             }
130
-        }
131
-        else {
134
+        } else {
132 135
             // object does not exist
133 136
             return 'MISS';
134 137
         }
135 138
     }
136 139
 
137
-	function cache_age( $cache_key ) {
140
+	function cache_age( $cache_key )
141
+	{
138 142
 		$filename = $this->file_name( $url );
139 143
 		if ( file_exists( $filename ) ) {
140 144
 			$mtime = filemtime( $filename );
141 145
             $age = time() - $mtime;
142 146
 			return $age;
143
-		}
144
-		else {
147
+		} else {
145 148
 			return -1;
146 149
 		}
147 150
 	}
@@ -149,14 +152,16 @@  discard block
 block discarded – undo
149 152
 /*=======================================================================*\
150 153
     Function:   serialize
151 154
 \*=======================================================================*/
152
-    function serialize ( $rss ) {
155
+    function serialize ( $rss )
156
+    {
153 157
         return serialize( $rss );
154 158
     }
155 159
 
156 160
 /*=======================================================================*\
157 161
     Function:   unserialize
158 162
 \*=======================================================================*/
159
-    function unserialize ( $data ) {
163
+    function unserialize ( $data )
164
+    {
160 165
         return unserialize( $data );
161 166
     }
162 167
 
@@ -166,7 +171,8 @@  discard block
 block discarded – undo
166 171
     Input:      url from wich the rss file was fetched
167 172
     Output:     a file name
168 173
 \*=======================================================================*/
169
-    function file_name ($url) {
174
+    function file_name ($url)
175
+    {
170 176
         $filename = md5( $url );
171 177
         return implode( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) );
172 178
     }
@@ -175,7 +181,8 @@  discard block
 block discarded – undo
175 181
     Function:   error
176 182
     Purpose:    register error
177 183
 \*=======================================================================*/
178
-    function error ($errormsg, $lvl=E_USER_WARNING) {
184
+    function error ($errormsg, $lvl=E_USER_WARNING)
185
+    {
179 186
         // append PHP's error message if track_errors enabled
180 187
         if ( isset($php_errormsg) ) {
181 188
             $errormsg .= " ($php_errormsg)";
@@ -183,13 +190,13 @@  discard block
 block discarded – undo
183 190
         $this->ERROR = $errormsg;
184 191
         if ( MAGPIE_DEBUG ) {
185 192
             trigger_error( $errormsg, $lvl);
186
-        }
187
-        else {
193
+        } else {
188 194
             error_log( $errormsg, 0);
189 195
         }
190 196
     }
191 197
 
192
-    function debug ($debugmsg, $lvl=E_USER_NOTICE) {
198
+    function debug ($debugmsg, $lvl=E_USER_NOTICE)
199
+    {
193 200
         if ( MAGPIE_DEBUG ) {
194 201
             $this->error("MagpieRSS [debug] $debugmsg", $lvl);
195 202
         }
Please login to merge, or discard this patch.
manager/includes/veriword.php 1 patch
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@  discard block
 block discarded – undo
41 41
 ## see sample.php for test and usage
42 42
 ## sample URL: http://www.program-ruti.org/veriword/
43 43
 ####
44
-class VeriWord {
44
+class VeriWord
45
+{
45 46
 
46 47
     /* path to font directory*/
47 48
     public $dir_font   = "ttf/";
@@ -52,7 +53,8 @@  discard block
 block discarded – undo
52 53
     public $im_height  = 0;
53 54
     public $im;
54 55
 
55
-    public function __construct($w=200, $h=80) {
56
+    public function __construct($w=200, $h=80)
57
+    {
56 58
         /* create session to set word for verification */
57 59
         $this->set_veriword();
58 60
         $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font;
@@ -60,21 +62,24 @@  discard block
 block discarded – undo
60 62
         $this->im_height        = $h;
61 63
     }
62 64
 
63
-    public function set_veriword() {
65
+    public function set_veriword()
66
+    {
64 67
         /* create session variable for verification,
65 68
            you may change the session variable name */
66 69
         $this->word             = $this->pick_word();
67 70
         $_SESSION['veriword']   = $this->word;
68 71
     }
69 72
 
70
-    public function output_image() {
73
+    public function output_image()
74
+    {
71 75
         /* output the image as jpeg */
72 76
         $this->draw_image();
73 77
         header("Content-type: image/jpeg");
74 78
         imagejpeg($this->im);
75 79
     }
76 80
 
77
-    public function pick_word() {
81
+    public function pick_word()
82
+    {
78 83
         global $modx;
79 84
         // set default words
80 85
         $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
@@ -85,7 +90,8 @@  discard block
 block discarded – undo
85 90
         return (string) $arr_words[array_rand($arr_words)].rand(10,999);
86 91
     }
87 92
 
88
-    public function draw_text() {
93
+    public function draw_text()
94
+    {
89 95
         $dir = dir($this->dir_font);
90 96
         $fontstmp = array();
91 97
         while (false !== ($file = $dir->read())) {
@@ -140,7 +146,8 @@  discard block
 block discarded – undo
140 146
     }
141 147
 
142 148
 
143
-    public function draw_image() {
149
+    public function draw_image()
150
+    {
144 151
 
145 152
         /* pick one background image randomly from image directory */
146 153
         $img_file       = $this->dir_noise."noise".rand(1,4).".jpg";
@@ -171,7 +178,8 @@  discard block
 block discarded – undo
171 178
         return $this->im;
172 179
     }
173 180
 
174
-    public function destroy_image() {
181
+    public function destroy_image()
182
+    {
175 183
 
176 184
         imagedestroy($this->im);
177 185
 
Please login to merge, or discard this patch.
install/instprocessor.php 1 patch
Braces   +61 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) {
3 3
     include_once(dirname(__FILE__)."/../assets/cache/siteManager.php");
4
-}else{
4
+} else {
5 5
     define('MGR_DIR', 'manager');
6 6
 }
7 7
 
@@ -58,13 +58,15 @@  discard block
 block discarded – undo
58 58
 
59 59
 // get base path and url
60 60
 $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"])));
61
-if (count($a) > 1)
61
+if (count($a) > 1) {
62 62
     array_pop($a);
63
+}
63 64
 $url = implode("install", $a);
64 65
 reset($a);
65 66
 $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__))));
66
-if (count($a) > 1)
67
+if (count($a) > 1) {
67 68
     array_pop($a);
69
+}
68 70
 $pth = implode("install", $a);
69 71
 unset ($a);
70 72
 $base_url = $url . (substr($url, -1) != "/" ? "/" : "");
@@ -85,7 +87,9 @@  discard block
 block discarded – undo
85 87
     echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>";
86 88
     $create = true;
87 89
 } else {
88
-	if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset);
90
+	if (function_exists('mysqli_set_charset')) {
91
+	    mysqli_set_charset($conn, $database_charset);
92
+	}
89 93
     mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}");
90 94
     echo '<span class="ok">'.$_lang['ok']."</span></p>";
91 95
 }
@@ -132,7 +136,8 @@  discard block
 block discarded – undo
132 136
      * @param string $propertyString
133 137
      * @return array
134 138
      */
135
-    function parseProperties($propertyString) {
139
+    function parseProperties($propertyString)
140
+    {
136 141
         $parameter= array ();
137 142
         if (!empty ($propertyString)) {
138 143
             $tmpParams= explode("&", $propertyString);
@@ -141,11 +146,14 @@  discard block
 block discarded – undo
141 146
                 if (strpos($tmpParams[$x], '=', 0)) {
142 147
                     $pTmp= explode("=", $tmpParams[$x]);
143 148
                     $pvTmp= explode(";", trim($pTmp[1]));
144
-                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
145
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
149
+                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "") {
150
+                                            $parameter[trim($pTmp[0])]= $pvTmp[3];
151
+                    }
152
+                    //list default
146 153
                     else
147
-                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
148
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
154
+                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "") {
155
+                                                    $parameter[trim($pTmp[0])]= $pvTmp[2];
156
+                        }
149 157
                 }
150 158
             }
151 159
         }
@@ -216,7 +224,7 @@  discard block
 block discarded – undo
216 224
 // custom or not
217 225
 if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) {
218 226
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
219
-}else{
227
+} else {
220 228
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
221 229
 }
222 230
 
@@ -352,7 +360,9 @@  discard block
 block discarded – undo
352 360
                         echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
353 361
                         return;
354 362
                     }
355
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
363
+                    if(!is_null($save_sql_id_as)) {
364
+                        $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
365
+                    }
356 366
                     echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
357 367
                 }
358 368
             }
@@ -446,9 +456,9 @@  discard block
 block discarded – undo
446 456
             $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]);
447 457
             $filecontent = $moduleChunk[2];
448 458
 
449
-            if (!file_exists($filecontent))
450
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
451
-            else {
459
+            if (!file_exists($filecontent)) {
460
+                            echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
461
+            } else {
452 462
 
453 463
                 // Create the category if it does not already exist
454 464
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -500,9 +510,9 @@  discard block
 block discarded – undo
500 510
             $guid = mysqli_real_escape_string($conn, $moduleModule[4]);
501 511
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
502 512
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
503
-            if (!file_exists($filecontent))
504
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
505
-            else {
513
+            if (!file_exists($filecontent)) {
514
+                            echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
515
+            } else {
506 516
 
507 517
                 // Create the category if it does not already exist
508 518
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -552,9 +562,9 @@  discard block
 block discarded – undo
552 562
                 // parse comma-separated legacy names and prepare them for sql IN clause
553 563
                 $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
554 564
             }
555
-            if (!file_exists($filecontent))
556
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
557
-            else {
565
+            if (!file_exists($filecontent)) {
566
+                            echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
567
+            } else {
558 568
 
559 569
                 // disable legacy versions based on legacy_names provided
560 570
                 if(!empty($leg_names)) {
@@ -573,7 +583,7 @@  discard block
 block discarded – undo
573 583
                     $insert = true;
574 584
                     while($row = mysqli_fetch_assoc($rs)) {
575 585
                         $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
576
-                        if($row['description'] == $desc){
586
+                        if($row['description'] == $desc) {
577 587
                             if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
578 588
                                 echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
579 589
                                 return;
@@ -631,9 +641,9 @@  discard block
 block discarded – undo
631 641
             $filecontent = $moduleSnippet[2];
632 642
             $properties = $moduleSnippet[3];
633 643
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
634
-            if (!file_exists($filecontent))
635
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
636
-            else {
644
+            if (!file_exists($filecontent)) {
645
+                            echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
646
+            } else {
637 647
 
638 648
                 // Create the category if it does not already exist
639 649
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -741,13 +751,16 @@  discard block
 block discarded – undo
741 751
 }
742 752
 
743 753
 // call back function
744
-if ($callBackFnc != "")
754
+if ($callBackFnc != "") {
745 755
     $callBackFnc ($sqlParser);
756
+}
746 757
 
747 758
 // Setup the MODX API -- needed for the cache processor
748 759
 define('MODX_API_MODE', true);
749 760
 define('MODX_BASE_PATH', $base_path);
750
-if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
761
+if (!defined('MODX_MANAGER_PATH')) {
762
+    define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
763
+}
751 764
 $database_type = 'mysqli';
752 765
 // initiate a new document parser
753 766
 include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php');
@@ -792,11 +805,12 @@  discard block
 block discarded – undo
792 805
  * @param string $old
793 806
  * @return string
794 807
  */
795
-function propUpdate($new,$old){
808
+function propUpdate($new,$old)
809
+{
796 810
     $newArr = parseProperties($new);
797 811
     $oldArr = parseProperties($old);
798
-    foreach ($oldArr as $k => $v){
799
-        if (isset($v['0']['options'])){
812
+    foreach ($oldArr as $k => $v) {
813
+        if (isset($v['0']['options'])) {
800 814
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
801 815
         }
802 816
     }
@@ -811,12 +825,17 @@  discard block
 block discarded – undo
811 825
  * @param bool|mixed $json
812 826
  * @return string
813 827
  */
814
-function parseProperties($propertyString, $json=false) {
828
+function parseProperties($propertyString, $json=false)
829
+{
815 830
     $propertyString = str_replace('{}', '', $propertyString );
816 831
     $propertyString = str_replace('} {', ',', $propertyString );
817 832
 
818
-    if(empty($propertyString)) return array();
819
-    if($propertyString=='{}' || $propertyString=='[]') return array();
833
+    if(empty($propertyString)) {
834
+        return array();
835
+    }
836
+    if($propertyString=='{}' || $propertyString=='[]') {
837
+        return array();
838
+    }
820 839
 
821 840
     $jsonFormat = isJson($propertyString, true);
822 841
     $property = array();
@@ -858,7 +877,7 @@  discard block
 block discarded – undo
858 877
 
859 878
         }
860 879
     // new json-format
861
-    } else if(!empty($jsonFormat)){
880
+    } else if(!empty($jsonFormat)) {
862 881
         $property = $jsonFormat;
863 882
     }
864 883
     if ($json) {
@@ -873,7 +892,8 @@  discard block
 block discarded – undo
873 892
  * @param bool $returnData
874 893
  * @return bool|mixed
875 894
  */
876
-function isJson($string, $returnData=false) {
895
+function isJson($string, $returnData=false)
896
+{
877 897
     $data = json_decode($string, true);
878 898
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
879 899
 }
@@ -883,7 +903,8 @@  discard block
 block discarded – undo
883 903
  * @param SqlParser $sqlParser
884 904
  * @return int
885 905
  */
886
-function getCreateDbCategory($category, $sqlParser) {
906
+function getCreateDbCategory($category, $sqlParser)
907
+{
887 908
     $dbase = $sqlParser->dbname;
888 909
     $dbase = '`' . trim($dbase,'`') . '`';
889 910
     $table_prefix = $sqlParser->prefix;
@@ -911,7 +932,8 @@  discard block
 block discarded – undo
911 932
  * @param string $type
912 933
  * @return string
913 934
  */
914
-function removeDocblock($code, $type) {
935
+function removeDocblock($code, $type)
936
+{
915 937
 
916 938
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
917 939
 
@@ -932,8 +954,9 @@  discard block
 block discarded – undo
932 954
         default:
933 955
             return $cleaned;
934 956
     };
935
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
936
-        return $cleaned;
957
+    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') {
958
+            return $cleaned;
959
+    }
937 960
 
938 961
     // fileBinding not found - return code incl docblock
939 962
     return $code;
Please login to merge, or discard this patch.
manager/actions/resources/functions.inc.php 1 patch
Braces   +32 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
  * @param array $ph
17 17
  * @return string
18 18
  */
19
-function parsePh($tpl, $ph) {
19
+function parsePh($tpl, $ph)
20
+{
20 21
 	global $modx, $_lang;
21 22
 	$tpl = $modx->parseText($tpl, $_lang, '[%', '%]');
22 23
 	return $modx->parseText($tpl, $ph);
@@ -26,7 +27,8 @@  discard block
 block discarded – undo
26 27
  * @param string|int $cssId
27 28
  * @return string
28 29
  */
29
-function renderViewSwitchButtons($cssId) {
30
+function renderViewSwitchButtons($cssId)
31
+{
30 32
 	global $modx, $_lang, $tpl;
31 33
 
32 34
 	return parsePh($tpl['viewForm'], array(
@@ -39,19 +41,20 @@  discard block
 block discarded – undo
39 41
  * @param mgrResources $resources
40 42
  * @return string
41 43
  */
42
-function createResourceList($resourceTable, $resources) {
44
+function createResourceList($resourceTable, $resources)
45
+{
43 46
 	global $modx, $_lang, $_style, $modx_textdir, $tpl;
44 47
 
45 48
 	$items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false;
46 49
 
47
-	if( ! is_array($items) || empty($items)) {
50
+	if( ! is_array($items) || empty($items)) {
48 51
 		return $_lang['no_results'];
49 52
 	}
50 53
 
51 54
 	// Prepare elements- and categories-list
52 55
 	$elements = array();
53 56
 	$categories = array();
54
-	foreach($items as $row) {
57
+	foreach($items as $row) {
55 58
 		$catid = $row['catid'] ? $row['catid'] : 0;
56 59
 		$categories[$catid] = array('name' => stripslashes($row['category']));
57 60
 		$elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources);
@@ -59,7 +62,7 @@  discard block
 block discarded – undo
59 62
 
60 63
 	// Now render categories / panel-collapse
61 64
 	$panelGroup = '';
62
-	foreach($elements as $catid => $elList) {
65
+	foreach($elements as $catid => $elList) {
63 66
 		// Add panel-heading / category-collapse to output
64 67
 		$panelGroup .= parsePh($tpl['panelHeading'], array(
65 68
 			'tab' => $resourceTable,
@@ -70,7 +73,7 @@  discard block
 block discarded – undo
70 73
 
71 74
 		// Prepare content for panel-collapse
72 75
 		$panelCollapse = '';
73
-		foreach($elList as $el) {
76
+		foreach($elList as $el) {
74 77
 			$panelCollapse .= parsePh($tpl['elementsRow'], $el);
75 78
 		}
76 79
 
@@ -92,14 +95,15 @@  discard block
 block discarded – undo
92 95
  * @param mgrResources $resources
93 96
  * @return string
94 97
  */
95
-function createCombinedView($resources) {
98
+function createCombinedView($resources)
99
+{
96 100
 	global $modx, $_lang, $_style, $modx_textdir;
97 101
 
98 102
 	$itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false;
99 103
 	$types = isset($resources->types) ? $resources->types : false;
100 104
 	$categories = isset($resources->categories) ? $resources->categories : false;
101 105
 
102
-	if(!$itemsPerCategory) {
106
+	if(!$itemsPerCategory) {
103 107
 		return $_lang['no_results'];
104 108
 	}
105 109
 
@@ -112,10 +116,10 @@  discard block
 block discarded – undo
112 116
 
113 117
 	// Easily loop through $itemsPerCategory-Array
114 118
 	$panelGroup = '';
115
-	foreach($categories as $catid => $category) {
119
+	foreach($categories as $catid => $category) {
116 120
 		// Prepare collapse content / elements-list
117 121
 		$panelCollapse = '';
118
-		foreach($itemsPerCategory[$catid] as $el) {
122
+		foreach($itemsPerCategory[$catid] as $el) {
119 123
 			$resourceTable = $el['type'];
120 124
 			$ph = prepareElementRowPh($el, $resourceTable, $resources);
121 125
 			$panelCollapse .= parsePh($tpl['elementsRow'], $ph);
@@ -149,14 +153,15 @@  discard block
 block discarded – undo
149 153
  * @param mgrResources $resources
150 154
  * @return array
151 155
  */
152
-function prepareElementRowPh($row, $resourceTable, $resources) {
156
+function prepareElementRowPh($row, $resourceTable, $resources)
157
+{
153 158
 	global $modx, $modx_textdir, $_style, $_lang;
154 159
 
155 160
 	$types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false;
156 161
 
157 162
 	$_lang["confirm_delete"] = $_lang["delete"];
158 163
 
159
-	switch($resourceTable){
164
+	switch($resourceTable) {
160 165
         case 'site_templates':
161 166
             $class = $row['selectable'] ? '' : 'disabledPlugin';
162 167
             $lockElementType = 1;
@@ -193,56 +198,56 @@  discard block
 block discarded – undo
193 198
 	// Prepare displaying user-locks
194 199
 	$lockedByUser = '';
195 200
 	$rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true);
196
-	if($rowLock && $modx->hasPermission('display_locks')) {
197
-		if($rowLock['sid'] == $modx->sid) {
201
+	if($rowLock && $modx->hasPermission('display_locks')) {
202
+		if($rowLock['sid'] == $modx->sid) {
198 203
 			$title = $modx->parseText($_lang["lock_element_editing"], array(
199 204
 				'element_type' => $_lang["lock_element_type_" . $lockElementType],
200 205
 				'lasthit_df' => $rowLock['lasthit_df']
201 206
 			));
202 207
 			$lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span>&nbsp;';
203
-		} else {
208
+		} else {
204 209
 			$title = $modx->parseText($_lang["lock_element_locked_by"], array(
205 210
 				'element_type' => $_lang["lock_element_type_" . $lockElementType],
206 211
 				'username' => $rowLock['username'],
207 212
 				'lasthit_df' => $rowLock['lasthit_df']
208 213
 			));
209
-			if($modx->hasPermission('remove_locks')) {
214
+			if($modx->hasPermission('remove_locks')) {
210 215
 				$lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
211
-			} else {
216
+			} else {
212 217
 				$lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>';
213 218
 			}
214 219
 		}
215 220
 	}
216
-	if($lockedByUser) {
221
+	if($lockedByUser) {
217 222
 		$lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>';
218 223
 	}
219 224
 
220 225
 	// Caption
221
-	if($resourceTable == 'site_tmplvars') {
226
+	if($resourceTable == 'site_tmplvars') {
222 227
 		$caption = !empty($row['description']) ? ' ' . $row['caption'] . ' &nbsp; <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
223
-	} else {
228
+	} else {
224 229
 		$caption = !empty($row['description']) ? ' ' . $row['description'] : '';
225 230
 	}
226 231
 
227 232
 	// Special marks
228 233
 	$tplInfo = array();
229
-	if($row['locked']) {
234
+	if($row['locked']) {
230 235
 		$tplInfo[] = $_lang['locked'];
231 236
 	}
232
-	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
237
+	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
233 238
 		$tplInfo[] = $_lang['defaulttemplate_title'];
234 239
 	}
235 240
 	$marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
236 241
 
237 242
 	/* row buttons */
238 243
 	$buttons = '';
239
-	if($modx->hasPermission($types['actions']['edit'][1])) {
244
+	if($modx->hasPermission($types['actions']['edit'][1])) {
240 245
 		$buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>';
241 246
 	}
242
-	if($modx->hasPermission($types['actions']['duplicate'][1])) {
247
+	if($modx->hasPermission($types['actions']['duplicate'][1])) {
243 248
 		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>';
244 249
 	}
245
-	if($modx->hasPermission($types['actions']['remove'][1])) {
250
+	if($modx->hasPermission($types['actions']['remove'][1])) {
246 251
 		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>';
247 252
 	}
248 253
 	$buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : '';
Please login to merge, or discard this patch.