Completed
Push — develop ( dd48c1...053968 )
by Maxim
06:38 queued 01:16
created
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
 
@@ -11,13 +11,15 @@  discard block
 block discarded – undo
11 11
 	'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl')
12 12
 );
13 13
 
14
-function parsePh($tpl, $ph) {
14
+function parsePh($tpl, $ph)
15
+{
15 16
 	global $modx, $_lang;
16 17
 	$tpl = $modx->parseText($tpl, $_lang, '[%', '%]');
17 18
 	return $modx->parseText($tpl, $ph);
18 19
 }
19 20
 
20
-function renderViewSwitchButtons($cssId) {
21
+function renderViewSwitchButtons($cssId)
22
+{
21 23
 	global $modx, $_lang, $tpl;
22 24
 
23 25
 	return parsePh($tpl['viewForm'], array(
@@ -25,19 +27,20 @@  discard block
 block discarded – undo
25 27
 	));
26 28
 }
27 29
 
28
-function createResourceList($resourceTable, $resources) {
30
+function createResourceList($resourceTable, $resources)
31
+{
29 32
 	global $modx, $_lang, $_style, $modx_textdir, $tpl;
30 33
 
31 34
 	$items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false;
32 35
 
33
-	if( ! is_array($items) || empty($items)) {
36
+	if( ! is_array($items) || empty($items)) {
34 37
 		return $_lang['no_results'];
35 38
 	}
36 39
 
37 40
 	// Prepare elements- and categories-list
38 41
 	$elements = array();
39 42
 	$categories = array();
40
-	foreach($items as $row) {
43
+	foreach($items as $row) {
41 44
 		$catid = $row['catid'] ? $row['catid'] : 0;
42 45
 		$categories[$catid] = array('name' => stripslashes($row['category']));
43 46
 		$elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources);
@@ -45,7 +48,7 @@  discard block
 block discarded – undo
45 48
 
46 49
 	// Now render categories / panel-collapse
47 50
 	$panelGroup = '';
48
-	foreach($elements as $catid => $elList) {
51
+	foreach($elements as $catid => $elList) {
49 52
 		// Add panel-heading / category-collapse to output
50 53
 		$panelGroup .= parsePh($tpl['panelHeading'], array(
51 54
 			'tab' => $resourceTable,
@@ -56,7 +59,7 @@  discard block
 block discarded – undo
56 59
 
57 60
 		// Prepare content for panel-collapse
58 61
 		$panelCollapse = '';
59
-		foreach($elList as $el) {
62
+		foreach($elList as $el) {
60 63
 			$panelCollapse .= parsePh($tpl['elementsRow'], $el);
61 64
 		}
62 65
 
@@ -74,14 +77,15 @@  discard block
 block discarded – undo
74 77
 	));
75 78
 }
76 79
 
77
-function createCombinedView($resources) {
80
+function createCombinedView($resources)
81
+{
78 82
 	global $modx, $_lang, $_style, $modx_textdir;
79 83
 
80 84
 	$itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false;
81 85
 	$types = isset($resources->types) ? $resources->types : false;
82 86
 	$categories = isset($resources->categories) ? $resources->categories : false;
83 87
 
84
-	if(!$itemsPerCategory) {
88
+	if(!$itemsPerCategory) {
85 89
 		return $_lang['no_results'];
86 90
 	}
87 91
 
@@ -94,10 +98,10 @@  discard block
 block discarded – undo
94 98
 
95 99
 	// Easily loop through $itemsPerCategory-Array
96 100
 	$panelGroup = '';
97
-	foreach($categories as $catid => $category) {
101
+	foreach($categories as $catid => $category) {
98 102
 		// Prepare collapse content / elements-list
99 103
 		$panelCollapse = '';
100
-		foreach($itemsPerCategory[$catid] as $el) {
104
+		foreach($itemsPerCategory[$catid] as $el) {
101 105
 			$resourceTable = $el['type'];
102 106
 			$ph = prepareElementRowPh($el, $resourceTable, $resources);
103 107
 			$panelCollapse .= parsePh($tpl['elementsRow'], $ph);
@@ -131,14 +135,15 @@  discard block
 block discarded – undo
131 135
  * @param $resources
132 136
  * @return array
133 137
  */
134
-function prepareElementRowPh($row, $resourceTable, $resources) {
138
+function prepareElementRowPh($row, $resourceTable, $resources)
139
+{
135 140
 	global $modx, $modx_textdir, $_style, $_lang;
136 141
 
137 142
 	$types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false;
138 143
 
139 144
 	$_lang["confirm_delete"] = $_lang["delete"];
140 145
 
141
-	switch($resourceTable){
146
+	switch($resourceTable) {
142 147
         case 'site_templates':
143 148
             $class = $row['selectable'] ? '' : 'disabledPlugin';
144 149
             $lockElementType = 1;
@@ -175,56 +180,56 @@  discard block
 block discarded – undo
175 180
 	// Prepare displaying user-locks
176 181
 	$lockedByUser = '';
177 182
 	$rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true);
178
-	if($rowLock && $modx->hasPermission('display_locks')) {
179
-		if($rowLock['sid'] == $modx->sid) {
183
+	if($rowLock && $modx->hasPermission('display_locks')) {
184
+		if($rowLock['sid'] == $modx->sid) {
180 185
 			$title = $modx->parseText($_lang["lock_element_editing"], array(
181 186
 				'element_type' => $_lang["lock_element_type_" . $lockElementType],
182 187
 				'lasthit_df' => $rowLock['lasthit_df']
183 188
 			));
184 189
 			$lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span>&nbsp;';
185
-		} else {
190
+		} else {
186 191
 			$title = $modx->parseText($_lang["lock_element_locked_by"], array(
187 192
 				'element_type' => $_lang["lock_element_type_" . $lockElementType],
188 193
 				'username' => $rowLock['username'],
189 194
 				'lasthit_df' => $rowLock['lasthit_df']
190 195
 			));
191
-			if($modx->hasPermission('remove_locks')) {
196
+			if($modx->hasPermission('remove_locks')) {
192 197
 				$lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
193
-			} else {
198
+			} else {
194 199
 				$lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>';
195 200
 			}
196 201
 		}
197 202
 	}
198
-	if($lockedByUser) {
203
+	if($lockedByUser) {
199 204
 		$lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>';
200 205
 	}
201 206
 
202 207
 	// Caption
203
-	if($resourceTable == 'site_tmplvars') {
208
+	if($resourceTable == 'site_tmplvars') {
204 209
 		$caption = !empty($row['description']) ? ' ' . $row['caption'] . ' &nbsp; <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
205
-	} else {
210
+	} else {
206 211
 		$caption = !empty($row['description']) ? ' ' . $row['description'] : '';
207 212
 	}
208 213
 
209 214
 	// Special marks
210 215
 	$tplInfo = array();
211
-	if($row['locked']) {
216
+	if($row['locked']) {
212 217
 		$tplInfo[] = $_lang['locked'];
213 218
 	}
214
-	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
219
+	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
215 220
 		$tplInfo[] = $_lang['defaulttemplate_title'];
216 221
 	}
217 222
 	$marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
218 223
 
219 224
 	/* row buttons */
220 225
 	$buttons = '';
221
-	if($modx->hasPermission($types['actions']['edit'][1])) {
226
+	if($modx->hasPermission($types['actions']['edit'][1])) {
222 227
 		$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>';
223 228
 	}
224
-	if($modx->hasPermission($types['actions']['duplicate'][1])) {
229
+	if($modx->hasPermission($types['actions']['duplicate'][1])) {
225 230
 		$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>';
226 231
 	}
227
-	if($modx->hasPermission($types['actions']['remove'][1])) {
232
+	if($modx->hasPermission($types['actions']['remove'][1])) {
228 233
 		$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>';
229 234
 	}
230 235
 	$buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : '';
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/includes/extenders/modifiers.class.inc.php 1 patch
Braces   +544 added lines, -282 removed lines patch added patch discarded remove patch
@@ -1,8 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
3
+if(!defined('MODX_CORE_PATH')) {
4
+    define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
5
+}
4 6
 
5
-class MODIFIERS {
7
+class MODIFIERS
8
+{
6 9
 
7 10
     public $placeholders = array();
8 11
     public $vars = array();
@@ -26,14 +29,18 @@  discard block
 block discarded – undo
26 29
     {
27 30
         global $modx;
28 31
 
29
-        if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']);
32
+        if (function_exists('mb_internal_encoding')) {
33
+            mb_internal_encoding($modx->config['modx_charset']);
34
+        }
30 35
         $this->condModifiers = '=,is,eq,equals,ne,neq,notequals,isnot,isnt,not,%,isempty,isnotempty,isntempty,>=,gte,eg,gte,greaterthan,>,gt,isgreaterthan,isgt,lowerthan,<,lt,<=,lte,islte,islowerthan,islt,el,find,in,inarray,in_array,fnmatch,wcard,wcard_match,wildcard,wildcard_match,is_file,is_dir,file_exists,is_readable,is_writable,is_image,regex,preg,preg_match,memberof,mo,isinrole,ir';
31 36
     }
32 37
 
33 38
     public function phxFilter($key,$value,$modifiers)
34 39
     {
35 40
         global $modx;
36
-        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value);
41
+        if(substr($modifiers,0,3)!=='id(') {
42
+            $value = $this->parseDocumentSource($value);
43
+        }
37 44
         $this->srcValue = $value;
38 45
         $modifiers = trim($modifiers);
39 46
         $modifiers = ':'.trim($modifiers,':');
@@ -51,63 +58,81 @@  discard block
 block discarded – undo
51 58
         return $value;
52 59
     }
53 60
 
54
-    public function _getDelim($mode,$modifiers) {
61
+    public function _getDelim($mode,$modifiers)
62
+    {
55 63
         $c = substr($modifiers,0,1);
56
-        if(!in_array($c, array('"', "'", '`')) ) return false;
64
+        if(!in_array($c, array('"', "'", '`')) ) {
65
+            return false;
66
+        }
57 67
 
58 68
         $modifiers = substr($modifiers,1);
59 69
         $closure = $mode=='(' ? "{$c})" : $c;
60
-        if(strpos($modifiers, $closure)===false) return false;
70
+        if(strpos($modifiers, $closure)===false) {
71
+            return false;
72
+        }
61 73
 
62 74
         return  $c;
63 75
     }
64 76
 
65
-    public function _getOpt($mode,$delim,$modifiers) {
77
+    public function _getOpt($mode,$delim,$modifiers)
78
+    {
66 79
         if($delim) {
67
-            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
80
+            if($mode=='(') {
81
+                return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
82
+            }
68 83
 
69 84
             return substr($modifiers,1,strpos($modifiers,$delim,1)-1);
70
-        }
71
-        else {
72
-            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') );
85
+        } else {
86
+            if($mode=='(') {
87
+                return substr($modifiers,0,strpos($modifiers, ')') );
88
+            }
73 89
 
74 90
             $chars = str_split($modifiers);
75 91
             $opt='';
76 92
             foreach($chars as $c) {
77
-                if($c==':' || $c==')') break;
93
+                if($c==':' || $c==')') {
94
+                    break;
95
+                }
78 96
                 $opt .=$c;
79 97
             }
80 98
             return $opt;
81 99
         }
82 100
     }
83
-    public function _getRemainModifiers($mode,$delim,$modifiers) {
101
+    public function _getRemainModifiers($mode,$delim,$modifiers)
102
+    {
84 103
         if($delim) {
85
-            if($mode=='(')
86
-                return $this->_fetchContent($modifiers, $delim . ')');
87
-            else {
104
+            if($mode=='(') {
105
+                            return $this->_fetchContent($modifiers, $delim . ')');
106
+            } else {
88 107
                 $modifiers = trim($modifiers);
89 108
                 $modifiers = substr($modifiers,1);
90 109
                 return $this->_fetchContent($modifiers, $delim);
91 110
             }
92
-        }
93
-        else {
94
-            if($mode=='(') return $this->_fetchContent($modifiers, ')');
111
+        } else {
112
+            if($mode=='(') {
113
+                return $this->_fetchContent($modifiers, ')');
114
+            }
95 115
             $chars = str_split($modifiers);
96 116
             foreach($chars as $c) {
97
-                if($c==':') return $modifiers;
98
-                else $modifiers = substr($modifiers,1);
117
+                if($c==':') {
118
+                    return $modifiers;
119
+                } else {
120
+                    $modifiers = substr($modifiers,1);
121
+                }
99 122
             }
100 123
             return $modifiers;
101 124
         }
102 125
     }
103 126
 
104
-    public function _fetchContent($string,$delim) {
127
+    public function _fetchContent($string,$delim)
128
+    {
105 129
         $len = strlen($delim);
106 130
         $string = $this->parseDocumentSource($string);
107 131
         return substr($string,strpos($string, $delim)+$len);
108 132
     }
109 133
 
110
-    public function splitEachModifiers($modifiers) {
134
+    public function splitEachModifiers($modifiers)
135
+    {
111 136
         global $modx;
112 137
 
113 138
         $cmd = '';
@@ -118,11 +143,15 @@  discard block
 block discarded – undo
118 143
             $c = substr($modifiers,0,1);
119 144
             $modifiers = substr($modifiers,1);
120 145
 
121
-            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
146
+            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) {
147
+// :=, :!=, :<=, :>=, :!<=, :!>=
122 148
                 $c = substr($modifiers,strlen($match[1]),1);
123 149
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
124
-                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1);
125
-                else         $modifiers = substr($modifiers,strlen($match[1]));
150
+                if($c==='(') {
151
+                    $modifiers = substr($modifiers,strlen($match[1])+1);
152
+                } else {
153
+                    $modifiers = substr($modifiers,strlen($match[1]));
154
+                }
126 155
 
127 156
                 $delim     = $this->_getDelim($c,$modifiers);
128 157
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -130,13 +159,12 @@  discard block
 block discarded – undo
130 159
 
131 160
                 $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
132 161
                 $cmd = '';
133
-            }
134
-            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
162
+            } elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) {
163
+// :+3, :-3, :*3 ...
135 164
                 $modifiers = substr($modifiers,strlen($match[0]));
136 165
                 $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]);
137 166
                 $cmd = '';
138
-            }
139
-            elseif($c==='(' || $c==='=') {
167
+            } elseif($c==='(' || $c==='=') {
140 168
                 $modifiers = $m1 = trim($modifiers);
141 169
                 $delim     = $this->_getDelim($c,$modifiers);
142 170
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -146,29 +174,29 @@  discard block
 block discarded – undo
146 174
                 $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
147 175
 
148 176
                 $cmd = '';
149
-            }
150
-            elseif($c==':') {
177
+            } elseif($c==':') {
151 178
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
152
-                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
179
+                if($cmd!=='') {
180
+                    $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
181
+                }
153 182
 
154 183
                 $cmd = '';
155
-            }
156
-            elseif(trim($modifiers)=='' && trim($cmd)!=='') {
184
+            } elseif(trim($modifiers)=='' && trim($cmd)!=='') {
157 185
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
158 186
                 $cmd .= $c;
159 187
                 $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
160 188
 
161 189
                 break;
162
-            }
163
-            else {
190
+            } else {
164 191
                 $cmd .= $c;
165 192
             }
166 193
         }
167 194
 
168
-        if(empty($result)) return array();
195
+        if(empty($result)) {
196
+            return array();
197
+        }
169 198
 
170
-        foreach($result as $i=>$a)
171
-        {
199
+        foreach($result as $i=>$a) {
172 200
             $a['opt'] = $this->parseDocumentSource($a['opt']);
173 201
             $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders);
174 202
         }
@@ -181,22 +209,23 @@  discard block
 block discarded – undo
181 209
         global $modx;
182 210
         $lastKey = '';
183 211
         $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true)));
184
-        if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
185
-        if(empty($modifiers)) return '';
212
+        if(isset($this->tmpCache[$cacheKey])) {
213
+            return $this->tmpCache[$cacheKey];
214
+        }
215
+        if(empty($modifiers)) {
216
+            return '';
217
+        }
186 218
 
187
-        foreach($modifiers as $m)
188
-        {
219
+        foreach($modifiers as $m) {
189 220
             $lastKey = strtolower($m['cmd']);
190 221
         }
191 222
         $_ = explode(',',$this->condModifiers);
192
-        if(in_array($lastKey,$_))
193
-        {
223
+        if(in_array($lastKey,$_)) {
194 224
             $modifiers[] = array('cmd'=>'then','opt'=>'1');
195 225
             $modifiers[] = array('cmd'=>'else','opt'=>'0');
196 226
         }
197 227
 
198
-        foreach($modifiers as $i=>$a)
199
-        {
228
+        foreach($modifiers as $i=>$a) {
200 229
             $value = $this->Filter($key,$value, $a['cmd'], $a['opt']);
201 230
         }
202 231
         $this->tmpCache[$cacheKey] = $value;
@@ -208,25 +237,32 @@  discard block
 block discarded – undo
208 237
     {
209 238
         global $modx;
210 239
 
211
-        if($key==='documentObject') $value = $modx->documentIdentifier;
240
+        if($key==='documentObject') {
241
+            $value = $modx->documentIdentifier;
242
+        }
212 243
         $cmd = $this->parseDocumentSource($cmd);
213
-        if(preg_match('@^[1-9][/0-9]*$@',$cmd))
214
-        {
215
-            if(strpos($cmd,'/')!==false)
216
-                $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
244
+        if(preg_match('@^[1-9][/0-9]*$@',$cmd)) {
245
+            if(strpos($cmd,'/')!==false) {
246
+                            $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
247
+            }
217 248
             $opt = $cmd;
218 249
             $cmd = 'id';
219 250
         }
220 251
 
221
-        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
222
-        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
223
-        else                                           $this->elmName = '';
252
+        if(isset($modx->snippetCache["phx:{$cmd}"])) {
253
+            $this->elmName = "phx:{$cmd}";
254
+        } elseif(isset($modx->chunkCache["phx:{$cmd}"])) {
255
+            $this->elmName = "phx:{$cmd}";
256
+        } else {
257
+            $this->elmName = '';
258
+        }
224 259
 
225 260
         $cmd = strtolower($cmd);
226
-        if($this->elmName!=='')
227
-            $value = $this->getValueFromElement($key, $value, $cmd, $opt);
228
-        else
229
-            $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
261
+        if($this->elmName!=='') {
262
+                    $value = $this->getValueFromElement($key, $value, $cmd, $opt);
263
+        } else {
264
+                    $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
265
+        }
230 266
 
231 267
         $value = str_replace('[+key+]', $key, $value);
232 268
 
@@ -235,29 +271,37 @@  discard block
 block discarded – undo
235 271
 
236 272
     public function isEmpty($cmd,$value)
237 273
     {
238
-        if($value!=='') return false;
274
+        if($value!=='') {
275
+            return false;
276
+        }
239 277
 
240 278
         $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
241
-        if(in_array($cmd,$_)) return false;
242
-        else                  return true;
279
+        if(in_array($cmd,$_)) {
280
+            return false;
281
+        } else {
282
+            return true;
283
+        }
243 284
     }
244 285
 
245 286
     public function getValueFromPreset($key, $value, $cmd, $opt)
246 287
     {
247 288
         global $modx;
248 289
 
249
-        if($this->isEmpty($cmd,$value)) return '';
290
+        if($this->isEmpty($cmd,$value)) {
291
+            return '';
292
+        }
250 293
 
251 294
         $this->key = $key;
252 295
         $this->value  = $value;
253 296
         $this->opt    = $opt;
254 297
 
255
-        switch ($cmd)
256
-        {
298
+        switch ($cmd) {
257 299
             #####  Conditional Modifiers
258 300
             case 'input':
259 301
             case 'if':
260
-                if(!$opt) return $value;
302
+                if(!$opt) {
303
+                    return $value;
304
+                }
261 305
                 return $opt;
262 306
             case '=':
263 307
             case 'eq':
@@ -318,14 +362,24 @@  discard block
 block discarded – undo
318 362
             case 'file_exists':
319 363
             case 'is_readable':
320 364
             case 'is_writable':
321
-                if(!$opt) $path = $value;
322
-                else      $path = $opt;
323
-                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path');
324
-                if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/');
365
+                if(!$opt) {
366
+                    $path = $value;
367
+                } else {
368
+                    $path = $opt;
369
+                }
370
+                if(strpos($path,MODX_MANAGER_PATH)!==false) {
371
+                    exit('Can not read core path');
372
+                }
373
+                if(strpos($path,$modx->config['base_path'])===false) {
374
+                    $path = ltrim($path,'/');
375
+                }
325 376
                 $this->condition[] = (int)($cmd($path)!==false);break;
326 377
             case 'is_image':
327
-                if(!$opt) $path = $value;
328
-                else      $path = $opt;
378
+                if(!$opt) {
379
+                    $path = $value;
380
+                } else {
381
+                    $path = $opt;
382
+                }
329 383
                 if(!is_file($path)) {$this->condition[]='0';break;}
330 384
                 $_ = getimagesize($path);
331 385
                 $this->condition[] = (int)($_[0]);break;
@@ -348,17 +402,23 @@  discard block
 block discarded – undo
348 402
             case 'this':
349 403
                 $conditional = implode(' ',$this->condition);
350 404
                 $isvalid = (int)(eval("return ({$conditional});"));
351
-                if ($isvalid) return $this->srcValue;
405
+                if ($isvalid) {
406
+                    return $this->srcValue;
407
+                }
352 408
                 return NULL;
353 409
             case 'then':
354 410
                 $conditional = implode(' ',$this->condition);
355 411
                 $isvalid = (int)eval("return ({$conditional});");
356
-                if ($isvalid)  return $opt;
412
+                if ($isvalid) {
413
+                    return $opt;
414
+                }
357 415
                 return null;
358 416
             case 'else':
359 417
                 $conditional = implode(' ',$this->condition);
360 418
                 $isvalid = (int)eval("return ({$conditional});");
361
-                if (!$isvalid) return $opt;
419
+                if (!$isvalid) {
420
+                    return $opt;
421
+                }
362 422
                 break;
363 423
             case 'select':
364 424
             case 'switch':
@@ -369,8 +429,11 @@  discard block
 block discarded – undo
369 429
                     $mi = explode('=',$raw[$m],2);
370 430
                     $map[$mi[0]] = $mi[1];
371 431
                 }
372
-                if(isset($map[$value])) return $map[$value];
373
-                else                    return '';
432
+                if(isset($map[$value])) {
433
+                    return $map[$value];
434
+                } else {
435
+                    return '';
436
+                }
374 437
             ##### End of Conditional Modifiers
375 438
 
376 439
             #####  Encode / Decode / Hash / Escape
@@ -396,24 +459,25 @@  discard block
 block discarded – undo
396 459
             case 'spam_protect':
397 460
                 return str_replace(array('@','.'),array('&#64;','&#46;'),$value);
398 461
             case 'strip':
399
-                if($opt==='') $opt = ' ';
462
+                if($opt==='') {
463
+                    $opt = ' ';
464
+                }
400 465
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
401 466
             case 'strip_linefeeds':
402 467
                 return str_replace(array("\n","\r"), '', $value);
403 468
             case 'notags':
404 469
             case 'strip_tags':
405 470
             case 'remove_html':
406
-                if($opt!=='')
407
-                {
471
+                if($opt!=='') {
408 472
                     $param = array();
409
-                    foreach(explode(',',$opt) as $v)
410
-                    {
473
+                    foreach(explode(',',$opt) as $v) {
411 474
                         $v = trim($v,'</> ');
412 475
                         $param[] = "<{$v}>";
413 476
                     }
414 477
                     $params = implode(',',$param);
478
+                } else {
479
+                    $params = '';
415 480
                 }
416
-                else $params = '';
417 481
                 if(!strpos($params,'<br>')===false) {
418 482
                     $value = preg_replace('@(<br[ /]*>)\n@','$1',$value);
419 483
                     $value = preg_replace('@<br[ /]*>@',"\n",$value);
@@ -424,8 +488,11 @@  discard block
 block discarded – undo
424 488
             case 'encode_url':
425 489
                 return urlencode($value);
426 490
             case 'base64_decode':
427
-                if($opt!=='false') $opt = true;
428
-                else               $opt = false;
491
+                if($opt!=='false') {
492
+                    $opt = true;
493
+                } else {
494
+                    $opt = false;
495
+                }
429 496
                 return base64_decode($value,$opt);
430 497
             case 'encode_sha1': $cmd = 'sha1';
431 498
             case 'addslashes':
@@ -451,16 +518,19 @@  discard block
 block discarded – undo
451 518
                 return $this->strtoupper($value);
452 519
             case 'capitalize':
453 520
                 $_ = explode(' ',$value);
454
-                foreach($_ as $i=>$v)
455
-                {
521
+                foreach($_ as $i=>$v) {
456 522
                     $_[$i] = ucfirst($v);
457 523
                 }
458 524
                 return implode(' ',$_);
459 525
             case 'zenhan':
460
-                if(empty($opt)) $opt='VKas';
526
+                if(empty($opt)) {
527
+                    $opt='VKas';
528
+                }
461 529
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
462 530
             case 'hanzen':
463
-                if(empty($opt)) $opt='VKAS';
531
+                if(empty($opt)) {
532
+                    $opt='VKAS';
533
+                }
464 534
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
465 535
             case 'str_shuffle':
466 536
             case 'shuffle':
@@ -485,13 +555,18 @@  discard block
 block discarded – undo
485 555
                 $value = preg_replace('/\r/', '', $value);
486 556
                 return count(preg_split('/\n+/',$value));
487 557
             case 'strpos':
488
-                if($opt!=0&&empty($opt)) return $value;
558
+                if($opt!=0&&empty($opt)) {
559
+                    return $value;
560
+                }
489 561
                 return $this->strpos($value,$opt);
490 562
             case 'wordwrap':
491 563
                 // default: 70
492 564
                   $wrapat = (int)$opt > 0 ? (int)$opt : 70;
493
-                if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap');
494
-                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
565
+                if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
566
+                    return $this->includeMdfFile('wordwrap');
567
+                } else {
568
+                    return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
569
+                }
495 570
             case 'wrap_text':
496 571
                 $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70;
497 572
                 if($modx->config['manager_language']==='japanese-utf8') {
@@ -507,30 +582,36 @@  discard block
 block discarded – undo
507 582
                         $value = $this->substr($value,$width);
508 583
                     }
509 584
                     return implode("\n",$chunk);
585
+                } else {
586
+                                    return wordwrap($value,$width,"\n",true);
510 587
                 }
511
-                else
512
-                    return wordwrap($value,$width,"\n",true);
513 588
             case 'substr':
514
-                if(empty($opt)) break;
589
+                if(empty($opt)) {
590
+                    break;
591
+                }
515 592
                 if(strpos($opt,',')!==false) {
516 593
                     list($b,$e) = explode(',',$opt,2);
517 594
                     return $this->substr($value,$b,(int)$e);
595
+                } else {
596
+                    return $this->substr($value,$opt);
518 597
                 }
519
-                else return $this->substr($value,$opt);
520 598
             case 'limit':
521 599
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
522
-                if(strpos($opt,'+')!==false)
523
-                    list($len,$str) = explode('+',$opt,2);
524
-                else {
600
+                if(strpos($opt,'+')!==false) {
601
+                                    list($len,$str) = explode('+',$opt,2);
602
+                } else {
525 603
                     $len = $opt;
526 604
                     $str = '';
527 605
                 }
528
-                if($len==='') $len = 100;
529
-                if(abs($len) > $this->strlen($value)) $str ='';
606
+                if($len==='') {
607
+                    $len = 100;
608
+                }
609
+                if(abs($len) > $this->strlen($value)) {
610
+                    $str ='';
611
+                }
530 612
                 if(preg_match('/^[1-9][0-9]*$/',$len)) {
531 613
                     return $this->substr($value,0,$len) . $str;
532
-                }
533
-                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
614
+                } elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
534 615
                     return $str . $this->substr($value,$len);
535 616
                 }
536 617
                 break;
@@ -540,18 +621,30 @@  discard block
 block discarded – undo
540 621
                 return $this->includeMdfFile('summary');
541 622
             case 'replace':
542 623
             case 'str_replace':
543
-                if(empty($opt) || strpos($opt,',')===false) break;
544
-                if    (substr_count($opt, ',') ==1) $delim = ',';
545
-                elseif(substr_count($opt, '|') ==1) $delim = '|';
546
-                elseif(substr_count($opt, '=>')==1) $delim = '=>';
547
-                elseif(substr_count($opt, '/') ==1) $delim = '/';
548
-                else break;
624
+                if(empty($opt) || strpos($opt,',')===false) {
625
+                    break;
626
+                }
627
+                if    (substr_count($opt, ',') ==1) {
628
+                    $delim = ',';
629
+                } elseif(substr_count($opt, '|') ==1) {
630
+                    $delim = '|';
631
+                } elseif(substr_count($opt, '=>')==1) {
632
+                    $delim = '=>';
633
+                } elseif(substr_count($opt, '/') ==1) {
634
+                    $delim = '/';
635
+                } else {
636
+                    break;
637
+                }
549 638
                 list($s,$r) = explode($delim,$opt);
550
-                if($value!=='') return str_replace($s,$r,$value);
639
+                if($value!=='') {
640
+                    return str_replace($s,$r,$value);
641
+                }
551 642
                 break;
552 643
             case 'replace_to':
553 644
             case 'tpl':
554
-                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
645
+                if($value!=='') {
646
+                    return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
647
+                }
555 648
                 break;
556 649
             case 'eachtpl':
557 650
                 $value = explode('||',$value);
@@ -562,59 +655,83 @@  discard block
 block discarded – undo
562 655
                 return implode("\n", $_);
563 656
             case 'array_pop':
564 657
             case 'array_shift':
565
-                if(strpos($value,'||')!==false) $delim = '||';
566
-                else                            $delim = ',';
658
+                if(strpos($value,'||')!==false) {
659
+                    $delim = '||';
660
+                } else {
661
+                    $delim = ',';
662
+                }
567 663
                 return $cmd(explode($delim,$value));
568 664
             case 'preg_replace':
569 665
             case 'regex_replace':
570
-                if(empty($opt) || strpos($opt,',')===false) break;
666
+                if(empty($opt) || strpos($opt,',')===false) {
667
+                    break;
668
+                }
571 669
                 list($s,$r) = explode(',',$opt,2);
572
-                if($value!=='') return preg_replace($s,$r,$value);
670
+                if($value!=='') {
671
+                    return preg_replace($s,$r,$value);
672
+                }
573 673
                 break;
574 674
             case 'cat':
575 675
             case 'concatenate':
576 676
             case '.':
577
-                if($value!=='') return $value . $opt;
677
+                if($value!=='') {
678
+                    return $value . $opt;
679
+                }
578 680
                 break;
579 681
             case 'sprintf':
580 682
             case 'string_format':
581
-                if($value!=='') return sprintf($opt,$value);
683
+                if($value!=='') {
684
+                    return sprintf($opt,$value);
685
+                }
582 686
                 break;
583 687
             case 'number_format':
584
-                    if($opt=='') $opt = 0;
688
+                    if($opt=='') {
689
+                        $opt = 0;
690
+                    }
585 691
                     return number_format($value,$opt);
586 692
             case 'money_format':
587 693
                     setlocale(LC_MONETARY,setlocale(LC_TIME,0));
588
-                    if($value!=='') return money_format($opt,(double)$value);
694
+                    if($value!=='') {
695
+                        return money_format($opt,(double)$value);
696
+                    }
589 697
                     break;
590 698
             case 'tobool':
591 699
                 return boolval($value);
592 700
             case 'nl2lf':
593
-                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value);
701
+                if($value!=='') {
702
+                    return str_replace(array("\r\n","\n", "\r"), '\n', $value);
703
+                }
594 704
                 break;
595 705
             case 'br2nl':
596 706
                 return preg_replace('@<br[\s/]*>@i', "\n", $value);
597 707
             case 'nl2br':
598
-                if (version_compare(PHP_VERSION, '5.3.0', '<'))
599
-                    return nl2br($value);
600
-                if($opt!=='')
601
-                {
708
+                if (version_compare(PHP_VERSION, '5.3.0', '<')) {
709
+                                    return nl2br($value);
710
+                }
711
+                if($opt!=='') {
602 712
                     $opt = trim($opt);
603 713
                     $opt = strtolower($opt);
604
-                    if($opt==='false') $opt = false;
605
-                    elseif($opt==='0') $opt = false;
606
-                    else               $opt = true;
714
+                    if($opt==='false') {
715
+                        $opt = false;
716
+                    } elseif($opt==='0') {
717
+                        $opt = false;
718
+                    } else {
719
+                        $opt = true;
720
+                    }
721
+                } elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') {
722
+                                                       $opt = false;
723
+                } else {
724
+                    $opt = true;
607 725
                 }
608
-                elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
609
-                                       $opt = false;
610
-                else                   $opt = true;
611 726
                 return nl2br($value,$opt);
612 727
             case 'ltrim':
613 728
             case 'rtrim':
614 729
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
615
-                if($opt==='')
616
-                    return $cmd($value);
617
-                else return $cmd($value,$opt);
730
+                if($opt==='') {
731
+                                    return $cmd($value);
732
+                } else {
733
+                    return $cmd($value,$opt);
734
+                }
618 735
             // These are all straight wrappers for PHP functions
619 736
             case 'ucfirst':
620 737
             case 'lcfirst':
@@ -625,15 +742,24 @@  discard block
 block discarded – undo
625 742
             case 'strftime':
626 743
             case 'date':
627 744
             case 'dateformat':
628
-                if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
629
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
630
-                if(strpos($opt,'%')!==false)
631
-                    return strftime($opt,0+$value);
632
-                else
633
-                    return date($opt,0+$value);
745
+                if(empty($opt)) {
746
+                    $opt = $modx->toDateFormat(null, 'formatOnly');
747
+                }
748
+                if(!preg_match('@^[0-9]+$@',$value)) {
749
+                    $value = strtotime($value);
750
+                }
751
+                if(strpos($opt,'%')!==false) {
752
+                                    return strftime($opt,0+$value);
753
+                } else {
754
+                                    return date($opt,0+$value);
755
+                }
634 756
             case 'time':
635
-                if(empty($opt)) $opt = '%H:%M';
636
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
757
+                if(empty($opt)) {
758
+                    $opt = '%H:%M';
759
+                }
760
+                if(!preg_match('@^[0-9]+$@',$value)) {
761
+                    $value = strtotime($value);
762
+                }
637 763
                 return strftime($opt,0+$value);
638 764
             case 'strtotime':
639 765
                 return strtotime($value);
@@ -643,7 +769,9 @@  discard block
 block discarded – undo
643 769
             case 'tofloat':
644 770
                 return floatval($value);
645 771
             case 'round':
646
-                if(!$opt) $opt = 0;
772
+                if(!$opt) {
773
+                    $opt = 0;
774
+                }
647 775
                 return $cmd($value,$opt);
648 776
             case 'max':
649 777
             case 'min':
@@ -655,28 +783,42 @@  discard block
 block discarded – undo
655 783
             case 'math':
656 784
             case 'calc':
657 785
                 $value = (int)$value;
658
-                if(empty($value)) $value = '0';
786
+                if(empty($value)) {
787
+                    $value = '0';
788
+                }
659 789
                 $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt);
660 790
                 $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter);
661
-                if(strpos($filter,'?')===false) $filter = "?{$filter}";
791
+                if(strpos($filter,'?')===false) {
792
+                    $filter = "?{$filter}";
793
+                }
662 794
                 $filter = str_replace('?',$value,$filter);
663 795
                 return eval("return {$filter};");
664 796
             case 'count':
665
-                if($value=='') return 0;
797
+                if($value=='') {
798
+                    return 0;
799
+                }
666 800
                 $value = explode(',',$value);
667 801
                 return count($value);
668 802
             case 'sort':
669 803
             case 'rsort':
670
-                if(strpos($value,"\n")!==false) $delim="\n";
671
-                else $delim = ',';
804
+                if(strpos($value,"\n")!==false) {
805
+                    $delim="\n";
806
+                } else {
807
+                    $delim = ',';
808
+                }
672 809
                 $swap = explode($delim,$value);
673
-                if(!$opt) $opt = SORT_REGULAR;
674
-                else      $opt = constant($opt);
810
+                if(!$opt) {
811
+                    $opt = SORT_REGULAR;
812
+                } else {
813
+                    $opt = constant($opt);
814
+                }
675 815
                 $cmd($swap,$opt);
676 816
                 return implode($delim,$swap);
677 817
             #####  Resource fields
678 818
             case 'id':
679
-                if($opt) return $this->getDocumentObject($opt,$key);
819
+                if($opt) {
820
+                    return $this->getDocumentObject($opt,$key);
821
+                }
680 822
                 break;
681 823
             case 'type':
682 824
             case 'contenttype':
@@ -713,7 +855,9 @@  discard block
 block discarded – undo
713 855
             case 'privatemgr':
714 856
             case 'content_dispo':
715 857
             case 'hidemenu':
716
-                if($cmd==='contenttype') $cmd = 'contentType';
858
+                if($cmd==='contenttype') {
859
+                    $cmd = 'contentType';
860
+                }
717 861
                 return $this->getDocumentObject($value,$cmd);
718 862
             case 'title':
719 863
                 $pagetitle = $this->getDocumentObject($value,'pagetitle');
@@ -728,13 +872,20 @@  discard block
 block discarded – undo
728 872
                 $templateName = $modx->db->getValue($rs);
729 873
                 return !$templateName ? '(blank)' : $templateName;
730 874
             case 'getfield':
731
-                if(!$opt) $opt = 'content';
875
+                if(!$opt) {
876
+                    $opt = 'content';
877
+                }
732 878
                 return $modx->getField($opt,$value);
733 879
             case 'children':
734 880
             case 'childids':
735
-                if($value=='') $value = 0; // 値がない場合はルートと見なす
881
+                if($value=='') {
882
+                    $value = 0;
883
+                }
884
+                // 値がない場合はルートと見なす
736 885
                 $published = 1;
737
-                if($opt=='') $opt = 'page';
886
+                if($opt=='') {
887
+                    $opt = 'page';
888
+                }
738 889
                 $_ = explode(',',$opt);
739 890
                 $where = array();
740 891
                 foreach($_ as $opt) {
@@ -750,29 +901,43 @@  discard block
 block discarded – undo
750 901
                 $where = implode(' AND ', $where);
751 902
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
752 903
                 $result = array();
753
-                foreach((array)$children as $child){
904
+                foreach((array)$children as $child) {
754 905
                     $result[] = $child['id'];
755 906
                 }
756 907
                 return implode(',', $result);
757 908
             case 'fullurl':
758
-                if(!is_numeric($value)) return $value;
909
+                if(!is_numeric($value)) {
910
+                    return $value;
911
+                }
759 912
                 return $modx->makeUrl($value);
760 913
             case 'makeurl':
761
-                if(!is_numeric($value)) return $value;
762
-                if(!$opt) $opt = 'full';
914
+                if(!is_numeric($value)) {
915
+                    return $value;
916
+                }
917
+                if(!$opt) {
918
+                    $opt = 'full';
919
+                }
763 920
                 return $modx->makeUrl($value,'','',$opt);
764 921
 
765 922
             #####  File system
766 923
             case 'getimageinfo':
767 924
             case 'imageinfo':
768
-                if(!is_file($value)) return '';
925
+                if(!is_file($value)) {
926
+                    return '';
927
+                }
769 928
                 $_ = getimagesize($value);
770
-                if(!$_[0]) return '';
929
+                if(!$_[0]) {
930
+                    return '';
931
+                }
771 932
                 $info['width']  = $_[0];
772 933
                 $info['height'] = $_[1];
773
-                if    ($_[0] > $_[1]) $info['aspect'] = 'landscape';
774
-                elseif($_[0] < $_[1]) $info['aspect'] = 'portrait';
775
-                else                  $info['aspect'] = 'square';
934
+                if    ($_[0] > $_[1]) {
935
+                    $info['aspect'] = 'landscape';
936
+                } elseif($_[0] < $_[1]) {
937
+                    $info['aspect'] = 'portrait';
938
+                } else {
939
+                    $info['aspect'] = 'square';
940
+                }
776 941
                 switch($_[2]) {
777 942
                     case IMAGETYPE_GIF  : $info['type'] = 'gif'; break;
778 943
                     case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break;
@@ -791,33 +956,47 @@  discard block
 block discarded – undo
791 956
 
792 957
             case 'file_get_contents':
793 958
             case 'readfile':
794
-                if(!is_file($value)) return $value;
959
+                if(!is_file($value)) {
960
+                    return $value;
961
+                }
795 962
                 $value = realpath($value);
796
-                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file');
963
+                if(strpos($value,MODX_MANAGER_PATH)!==false) {
964
+                    exit('Can not read core file');
965
+                }
797 966
                 $ext = strtolower(substr($value,-4));
798
-                if($ext==='.php') exit('Can not read php file');
799
-                if($ext==='.cgi') exit('Can not read cgi file');
967
+                if($ext==='.php') {
968
+                    exit('Can not read php file');
969
+                }
970
+                if($ext==='.cgi') {
971
+                    exit('Can not read cgi file');
972
+                }
800 973
                 return file_get_contents($value);
801 974
             case 'filesize':
802
-                if($value == '') return '';
975
+                if($value == '') {
976
+                    return '';
977
+                }
803 978
                 $filename = $value;
804 979
 
805 980
                 $site_url = $modx->config['site_url'];
806
-                if(strpos($filename,$site_url) === 0)
807
-                    $filename = substr($filename,0,strlen($site_url));
981
+                if(strpos($filename,$site_url) === 0) {
982
+                                    $filename = substr($filename,0,strlen($site_url));
983
+                }
808 984
                 $filename = trim($filename,'/');
809 985
 
810 986
                 $opt = trim($opt,'/');
811
-                if($opt!=='') $opt .= '/';
987
+                if($opt!=='') {
988
+                    $opt .= '/';
989
+                }
812 990
 
813 991
                 $filename = MODX_BASE_PATH.$opt.$filename;
814 992
 
815
-                if(is_file($filename)){
993
+                if(is_file($filename)) {
816 994
                     clearstatcache();
817 995
                     $size = filesize($filename);
818 996
                     return $size;
997
+                } else {
998
+                    return '';
819 999
                 }
820
-                else return '';
821 1000
             #####  User info
822 1001
             case 'username':
823 1002
             case 'fullname':
@@ -845,32 +1024,47 @@  discard block
 block discarded – undo
845 1024
                 $this->opt = $cmd;
846 1025
                 return $this->includeMdfFile('moduser');
847 1026
             case 'userinfo':
848
-                if(empty($opt)) $this->opt = 'username';
1027
+                if(empty($opt)) {
1028
+                    $this->opt = 'username';
1029
+                }
849 1030
                 return $this->includeMdfFile('moduser');
850 1031
             case 'webuserinfo':
851
-                if(empty($opt)) $this->opt = 'username';
1032
+                if(empty($opt)) {
1033
+                    $this->opt = 'username';
1034
+                }
852 1035
                 $this->value = -$value;
853 1036
                 return $this->includeMdfFile('moduser');
854 1037
             #####  Special functions
855 1038
             case 'ifempty':
856 1039
             case '_default':
857 1040
             case 'default':
858
-                if (empty($value)) return $opt; break;
1041
+                if (empty($value)) {
1042
+                    return $opt;
1043
+                }
1044
+                break;
859 1045
             case 'ifnotempty':
860
-                if (!empty($value)) return $opt; break;
1046
+                if (!empty($value)) {
1047
+                    return $opt;
1048
+                }
1049
+                break;
861 1050
             case 'datagrid':
862 1051
                 include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
863 1052
                 $grd = new DataGrid(null, trim($value));
864 1053
                 $grd->itemStyle = '';
865 1054
                 $grd->altItemStyle = '';
866 1055
                 $pos = strpos($value,"\n");
867
-                if($pos) $_ = substr($value,0,$pos);
868
-                else $_ = $pos;
1056
+                if($pos) {
1057
+                    $_ = substr($value,0,$pos);
1058
+                } else {
1059
+                    $_ = $pos;
1060
+                }
869 1061
                 $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ',';
870 1062
                 return $grd->render();
871 1063
             case 'rotate':
872 1064
             case 'evenodd':
873
-                if(strpos($opt,',')===false) $opt = 'odd,even';
1065
+                if(strpos($opt,',')===false) {
1066
+                    $opt = 'odd,even';
1067
+                }
874 1068
                 $_ = explode(',', $opt);
875 1069
                 $c = count($_);
876 1070
                 $i = $value + $c;
@@ -879,7 +1073,9 @@  discard block
 block discarded – undo
879 1073
             case 'takeval':
880 1074
                 $arr = explode(",",$opt);
881 1075
                 $idx = $value;
882
-                if(!is_numeric($idx)) return $value;
1076
+                if(!is_numeric($idx)) {
1077
+                    return $value;
1078
+                }
883 1079
                 return $arr[$idx];
884 1080
             case 'getimage':
885 1081
                 return $this->includeMdfFile('getimage');
@@ -887,14 +1083,18 @@  discard block
 block discarded – undo
887 1083
                     return $modx->nicesize($value);
888 1084
             case 'googlemap':
889 1085
             case 'googlemaps':
890
-                if(empty($opt)) $opt = 'border:none;width:500px;height:350px;';
1086
+                if(empty($opt)) {
1087
+                    $opt = 'border:none;width:500px;height:350px;';
1088
+                }
891 1089
                 $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>';
892 1090
                 $ph['style'] = $opt;
893 1091
                 $ph['value'] = $value;
894 1092
                 return $modx->parseText($tpl,$ph);
895 1093
             case 'youtube':
896 1094
             case 'youtube16x9':
897
-                if(empty($opt)) $opt = 560;
1095
+                if(empty($opt)) {
1096
+                    $opt = 560;
1097
+                }
898 1098
                 $h = round($opt*0.5625);
899 1099
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
900 1100
                 return sprintf($tpl,$opt,$h,$value);
@@ -927,7 +1127,8 @@  discard block
 block discarded – undo
927 1127
         return $value;
928 1128
     }
929 1129
 
930
-    public function includeMdfFile($cmd) {
1130
+    public function includeMdfFile($cmd)
1131
+    {
931 1132
         global $modx;
932 1133
         $key = $this->key;
933 1134
         $value  = $this->value;
@@ -938,55 +1139,65 @@  discard block
 block discarded – undo
938 1139
     public function getValueFromElement($key, $value, $cmd, $opt)
939 1140
     {
940 1141
         global $modx;
941
-        if( isset($modx->snippetCache[$this->elmName]) )
942
-        {
1142
+        if( isset($modx->snippetCache[$this->elmName]) ) {
943 1143
             $php = $modx->snippetCache[$this->elmName];
944
-        }
945
-        else
946
-        {
1144
+        } else {
947 1145
             $esc_elmName = $modx->db->escape($this->elmName);
948 1146
             $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
949 1147
             $total = $modx->db->getRecordCount($result);
950
-            if($total == 1)
951
-            {
1148
+            if($total == 1) {
952 1149
                 $row = $modx->db->getRow($result);
953 1150
                 $php = $row['snippet'];
954
-            }
955
-            elseif($total == 0)
956
-            {
1151
+            } elseif($total == 0) {
957 1152
                 $assets_path = MODX_BASE_PATH.'assets/';
958
-                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
959
-                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
960
-                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
961
-                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
962
-                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
963
-                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
964
-                else $modifiers_path = false;
1153
+                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) {
1154
+                                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1155
+                } elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) {
1156
+                                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1157
+                } elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) {
1158
+                                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1159
+                } else {
1160
+                    $modifiers_path = false;
1161
+                }
965 1162
 
966 1163
                 if($modifiers_path !== false) {
967 1164
                     $php = @file_get_contents($modifiers_path);
968 1165
                     $php = trim($php);
969
-                    if(substr($php,0,5)==='<?php') $php = substr($php,6);
970
-                    if(substr($php,0,2)==='<?')    $php = substr($php,3);
971
-                    if(substr($php,-2)==='?>')     $php = substr($php,0,-2);
972
-                    if($this->elmName!=='')
973
-                        $modx->snippetCache[$this->elmName.'Props'] = '';
974
-                }
975
-                else
976
-                    $php = false;
1166
+                    if(substr($php,0,5)==='<?php') {
1167
+                        $php = substr($php,6);
1168
+                    }
1169
+                    if(substr($php,0,2)==='<?') {
1170
+                        $php = substr($php,3);
1171
+                    }
1172
+                    if(substr($php,-2)==='?>') {
1173
+                        $php = substr($php,0,-2);
1174
+                    }
1175
+                    if($this->elmName!=='') {
1176
+                                            $modx->snippetCache[$this->elmName.'Props'] = '';
1177
+                    }
1178
+                } else {
1179
+                                    $php = false;
1180
+                }
1181
+            } else {
1182
+                $php = false;
1183
+            }
1184
+            if($this->elmName!=='') {
1185
+                $modx->snippetCache[$this->elmName]= $php;
977 1186
             }
978
-            else $php = false;
979
-            if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php;
980 1187
         }
981
-        if($php==='') $php=false;
1188
+        if($php==='') {
1189
+            $php=false;
1190
+        }
982 1191
 
983
-        if($php===false) $html = $modx->getChunk($this->elmName);
984
-        else             $html = false;
1192
+        if($php===false) {
1193
+            $html = $modx->getChunk($this->elmName);
1194
+        } else {
1195
+            $html = false;
1196
+        }
985 1197
 
986 1198
         $self = '[+output+]';
987 1199
 
988
-        if($php !== false)
989
-        {
1200
+        if($php !== false) {
990 1201
             ob_start();
991 1202
             $options = $opt;
992 1203
             $output = $value;
@@ -998,19 +1209,19 @@  discard block
 block discarded – undo
998 1209
             $this->vars['options'] = & $opt;
999 1210
             $custom = eval($php);
1000 1211
             $msg = ob_get_contents();
1001
-            if($value===$this->bt) $value = $msg . $custom;
1212
+            if($value===$this->bt) {
1213
+                $value = $msg . $custom;
1214
+            }
1002 1215
             ob_end_clean();
1003
-        }
1004
-        elseif($html!==false && isset($value) && $value!=='')
1005
-        {
1216
+        } elseif($html!==false && isset($value) && $value!=='') {
1006 1217
             $html = str_replace(array($self,'[+value+]'), $value, $html);
1007 1218
             $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1219
+        } else {
1220
+            return false;
1008 1221
         }
1009
-        else return false;
1010 1222
 
1011 1223
         if($php===false && $html===false && $value!==''
1012
-           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false))
1013
-        {
1224
+           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) {
1014 1225
             $value = str_replace(array('[+value+]',$self),$value,$cmd);
1015 1226
         }
1016 1227
         return $value;
@@ -1020,23 +1231,39 @@  discard block
 block discarded – undo
1020 1231
     {
1021 1232
         global $modx;
1022 1233
 
1023
-        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
1234
+        if(strpos($content,'[')===false && strpos($content,'{')===false) {
1235
+            return $content;
1236
+        }
1024 1237
 
1025
-        if(!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1238
+        if(!$modx->maxParserPasses) {
1239
+            $modx->maxParserPasses = 10;
1240
+        }
1026 1241
         $bt='';
1027 1242
         $i=0;
1028
-        while($bt!==$content)
1029
-        {
1243
+        while($bt!==$content) {
1030 1244
             $bt = $content;
1031
-            if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1032
-                                              $content = $modx->mergeDocumentContent($content);
1033
-            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1034
-            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1035
-            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1036
-            if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
1037
-
1038
-            if($content===$bt)              break;
1039
-            if($modx->maxParserPasses < $i) break;
1245
+            if(strpos($content,'[*')!==false && $modx->documentIdentifier) {
1246
+                                                          $content = $modx->mergeDocumentContent($content);
1247
+            }
1248
+            if(strpos($content,'[(')!==false) {
1249
+                $content = $modx->mergeSettingsContent($content);
1250
+            }
1251
+            if(strpos($content,'{{')!==false) {
1252
+                $content = $modx->mergeChunkContent($content);
1253
+            }
1254
+            if(strpos($content,'[!')!==false) {
1255
+                $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1256
+            }
1257
+            if(strpos($content,'[[')!==false) {
1258
+                $content = $modx->evalSnippets($content);
1259
+            }
1260
+
1261
+            if($content===$bt) {
1262
+                break;
1263
+            }
1264
+            if($modx->maxParserPasses < $i) {
1265
+                break;
1266
+            }
1040 1267
             $i++;
1041 1268
         }
1042 1269
         return $content;
@@ -1047,103 +1274,138 @@  discard block
 block discarded – undo
1047 1274
         global $modx;
1048 1275
 
1049 1276
         $target = trim($target);
1050
-        if(empty($target)) $target = $modx->config['site_start'];
1051
-        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id';
1052
-        else $method = 'alias';
1277
+        if(empty($target)) {
1278
+            $target = $modx->config['site_start'];
1279
+        }
1280
+        if(preg_match('@^[1-9][0-9]*$@',$target)) {
1281
+            $method='id';
1282
+        } else {
1283
+            $method = 'alias';
1284
+        }
1053 1285
 
1054
-        if(!isset($this->documentObject[$target]))
1055
-        {
1286
+        if(!isset($this->documentObject[$target])) {
1056 1287
             $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct');
1057 1288
         }
1058 1289
 
1059
-        if($this->documentObject[$target]['publishedon']==='0')
1060
-            return '';
1061
-        elseif(isset($this->documentObject[$target][$field]))
1062
-        {
1063
-            if(is_array($this->documentObject[$target][$field]))
1064
-            {
1290
+        if($this->documentObject[$target]['publishedon']==='0') {
1291
+                    return '';
1292
+        } elseif(isset($this->documentObject[$target][$field])) {
1293
+            if(is_array($this->documentObject[$target][$field])) {
1065 1294
                 $a = $modx->getTemplateVarOutput($field,$target);
1066 1295
                 $this->documentObject[$target][$field] = $a[$field];
1067 1296
             }
1297
+        } else {
1298
+            $this->documentObject[$target][$field] = false;
1068 1299
         }
1069
-        else $this->documentObject[$target][$field] = false;
1070 1300
 
1071 1301
         return $this->documentObject[$target][$field];
1072 1302
     }
1073 1303
 
1074
-    public function setPlaceholders($value = '', $key = '', $path = '') {
1075
-        if($path!=='') $key = "{$path}.{$key}";
1304
+    public function setPlaceholders($value = '', $key = '', $path = '')
1305
+    {
1306
+        if($path!=='') {
1307
+            $key = "{$path}.{$key}";
1308
+        }
1076 1309
         if (is_array($value)) {
1077 1310
             foreach ($value as $subkey => $subval) {
1078 1311
                 $this->setPlaceholders($subval, $subkey, $key);
1079 1312
             }
1313
+        } else {
1314
+            $this->setModifiersVariable($key, $value);
1080 1315
         }
1081
-        else $this->setModifiersVariable($key, $value);
1082 1316
     }
1083 1317
 
1084 1318
     // Sets a placeholder variable which can only be access by Modifiers
1085
-    public function setModifiersVariable($key, $value) {
1086
-        if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1319
+    public function setModifiersVariable($key, $value)
1320
+    {
1321
+        if ($key != 'phx' && $key != 'dummy') {
1322
+            $this->placeholders[$key] = $value;
1323
+        }
1087 1324
     }
1088 1325
 
1089 1326
     //mbstring
1090
-    public function substr($str, $s, $l = null) {
1327
+    public function substr($str, $s, $l = null)
1328
+    {
1091 1329
         global $modx;
1092
-        if(is_null($l)) $l = $this->strlen($str);
1093
-        if (function_exists('mb_substr'))
1094
-        {
1095
-            if(strpos($str,"\r")!==false)
1096
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1330
+        if(is_null($l)) {
1331
+            $l = $this->strlen($str);
1332
+        }
1333
+        if (function_exists('mb_substr')) {
1334
+            if(strpos($str,"\r")!==false) {
1335
+                            $str = str_replace(array("\r\n","\r"), "\n", $str);
1336
+            }
1097 1337
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1098 1338
         }
1099 1339
         return substr($str, $s, $l);
1100 1340
     }
1101
-    public function strpos($haystack,$needle,$offset=0) {
1341
+    public function strpos($haystack,$needle,$offset=0)
1342
+    {
1102 1343
         global $modx;
1103
-        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1344
+        if (function_exists('mb_strpos')) {
1345
+            return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1346
+        }
1104 1347
         return strpos($haystack,$needle,$offset);
1105 1348
     }
1106
-    public function strlen($str) {
1349
+    public function strlen($str)
1350
+    {
1107 1351
         global $modx;
1108
-        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1352
+        if (function_exists('mb_strlen')) {
1353
+            return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1354
+        }
1109 1355
         return strlen($str);
1110 1356
     }
1111
-    public function strtolower($str) {
1112
-        if (function_exists('mb_strtolower')) return mb_strtolower($str);
1357
+    public function strtolower($str)
1358
+    {
1359
+        if (function_exists('mb_strtolower')) {
1360
+            return mb_strtolower($str);
1361
+        }
1113 1362
         return strtolower($str);
1114 1363
     }
1115
-    public function strtoupper($str) {
1116
-        if (function_exists('mb_strtoupper')) return mb_strtoupper($str);
1364
+    public function strtoupper($str)
1365
+    {
1366
+        if (function_exists('mb_strtoupper')) {
1367
+            return mb_strtoupper($str);
1368
+        }
1117 1369
         return strtoupper($str);
1118 1370
     }
1119
-    public function ucfirst($str) {
1120
-        if (function_exists('mb_strtoupper'))
1121
-            return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1371
+    public function ucfirst($str)
1372
+    {
1373
+        if (function_exists('mb_strtoupper')) {
1374
+                    return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1375
+        }
1122 1376
         return ucfirst($str);
1123 1377
     }
1124
-    public function lcfirst($str) {
1125
-        if (function_exists('mb_strtolower'))
1126
-            return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1378
+    public function lcfirst($str)
1379
+    {
1380
+        if (function_exists('mb_strtolower')) {
1381
+                    return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1382
+        }
1127 1383
         return lcfirst($str);
1128 1384
     }
1129
-    public function ucwords($str) {
1130
-        if (function_exists('mb_convert_case'))
1131
-            return mb_convert_case($str, MB_CASE_TITLE);
1385
+    public function ucwords($str)
1386
+    {
1387
+        if (function_exists('mb_convert_case')) {
1388
+                    return mb_convert_case($str, MB_CASE_TITLE);
1389
+        }
1132 1390
         return ucwords($str);
1133 1391
     }
1134
-    public function strrev($str) {
1392
+    public function strrev($str)
1393
+    {
1135 1394
         preg_match_all('/./us', $str, $ar);
1136 1395
         return implode(array_reverse($ar[0]));
1137 1396
     }
1138
-    public function str_shuffle($str) {
1397
+    public function str_shuffle($str)
1398
+    {
1139 1399
         preg_match_all('/./us', $str, $ar);
1140 1400
         shuffle($ar[0]);
1141 1401
         return implode($ar[0]);
1142 1402
     }
1143
-    public function str_word_count($str) {
1403
+    public function str_word_count($str)
1404
+    {
1144 1405
         return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
1145 1406
     }
1146
-    public function strip_tags($value,$params='') {
1407
+    public function strip_tags($value,$params='')
1408
+    {
1147 1409
         global $modx;
1148 1410
 
1149 1411
         if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
Please login to merge, or discard this patch.
manager/includes/config_check.inc.php 1 patch
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 $warningspresent = 0;
20 20
 
21 21
 $sysfiles_check = $modx->manager->checkSystemChecksum();
22
-if ($sysfiles_check!=='0'){
22
+if ($sysfiles_check!=='0') {
23 23
       $warningspresent = 1;
24 24
       $warnings[] = array($_lang['configcheck_sysfiles_mod']);
25 25
 }
26 26
 
27
-if (is_writable("includes/config.inc.php")){
27
+if (is_writable("includes/config.inc.php")) {
28 28
     // Warn if world writable
29 29
     if(@fileperms('includes/config.inc.php') & 0x0002) {
30 30
       $warningspresent = 1;
@@ -117,7 +117,8 @@  discard block
 block discarded – undo
117 117
 }
118 118
 
119 119
 if (!function_exists('checkSiteCache')) {
120
-    function checkSiteCache() {
120
+    function checkSiteCache()
121
+    {
121 122
         global $modx;
122 123
         $checked= true;
123 124
         if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) {
@@ -156,26 +157,36 @@  discard block
 block discarded – undo
156 157
 
157 158
 if ($warningspresent==1) {
158 159
 
159
-if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3';
160
+if(!isset($modx->config['send_errormail'])) {
161
+    $modx->config['send_errormail']='3';
162
+}
160 163
 $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>";
161 164
 
162 165
 for ($i=0;$i<count($warnings);$i++) {
163 166
     switch ($warnings[$i][0]) {
164 167
         case $_lang['configcheck_configinc'];
165 168
             $warnings[$i][1] = $_lang['configcheck_configinc_msg'];
166
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
169
+            if(!$_SESSION["mgrConfigCheck"]) {
170
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
171
+            }
167 172
             break;
168 173
         case $_lang['configcheck_installer'] :
169 174
             $warnings[$i][1] = $_lang['configcheck_installer_msg'];
170
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
175
+            if(!$_SESSION["mgrConfigCheck"]) {
176
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
177
+            }
171 178
             break;
172 179
         case $_lang['configcheck_cache'] :
173 180
             $warnings[$i][1] = $_lang['configcheck_cache_msg'];
174
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
181
+            if(!$_SESSION["mgrConfigCheck"]) {
182
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
183
+            }
175 184
             break;
176 185
         case $_lang['configcheck_images'] :
177 186
             $warnings[$i][1] = $_lang['configcheck_images_msg'];
178
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
187
+            if(!$_SESSION["mgrConfigCheck"]) {
188
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
189
+            }
179 190
             break;
180 191
         case $_lang['configcheck_sysfiles_mod']:
181 192
             $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"];
@@ -183,7 +194,9 @@  discard block
 block discarded – undo
183 194
 			if($modx->hasPermission('settings')) {
184 195
 				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>';
185 196
 			}
186
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
197
+            if(!$_SESSION["mgrConfigCheck"]) {
198
+                $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
199
+            }
187 200
             break;
188 201
         case $_lang['configcheck_lang_difference'] :
189 202
             $warnings[$i][1] = $_lang['configcheck_lang_difference_msg'];
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.
manager/includes/preload.functions.inc.php 1 patch
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,13 +3,15 @@  discard block
 block discarded – undo
3 3
 global $site_sessionname;
4 4
 $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession
5 5
 
6
-function genEvoSessionName() {
6
+function genEvoSessionName()
7
+{
7 8
     $_ = crc32(__FILE__);
8 9
     $_ = sprintf('%u', $_);
9 10
     return 'evo' . base_convert($_,10,36);
10 11
 }
11 12
 
12
-function startCMSSession(){
13
+function startCMSSession()
14
+{
13 15
 
14 16
     global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain;
15 17
 
@@ -22,24 +24,27 @@  discard block
 block discarded – undo
22 24
     session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
23 25
     session_start();
24 26
     $key = "modx.mgr.session.cookie.lifetime";
25
-    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
27
+    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
26 28
         $cookieLifetime= (int)$_SESSION[$key];
27
-        if($cookieLifetime) $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime;
29
+        if($cookieLifetime) {
30
+            $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime;
31
+        }
28 32
         setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
29 33
     }
30
-    if (!isset($_SESSION['modx.session.created.time'])) {
34
+    if (!isset($_SESSION['modx.session.created.time'])) {
31 35
         $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME'];
32 36
     }
33 37
 }
34 38
 
35
-function removeInvalidCmsSessionFromStorage(&$storage, $session_name) {
36
-    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted'))
37
-    {
39
+function removeInvalidCmsSessionFromStorage(&$storage, $session_name)
40
+{
41
+    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
38 42
     unset($storage[$session_name]);
39 43
     }
40 44
 }
41 45
 
42
-function removeInvalidCmsSessionIds($session_name) {
46
+function removeInvalidCmsSessionIds($session_name)
47
+{
43 48
     // session ids is invalid iff it is empty string
44 49
     // storage priorioty can see in PHP source ext/session/session.c
45 50
     removeInvalidCmsSessionFromStorage($_COOKIE, $session_name);
Please login to merge, or discard this patch.