GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#1814)
by
unknown
11:57
created
modules/widget/widget.controller.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -696,6 +696,9 @@
 block discarded – undo
696 696
 		return $GLOBALS['_xe_loaded_widgets_'][$widget];
697 697
 	}
698 698
 
699
+	/**
700
+	 * @param boolean $javascript_mode
701
+	 */
699 702
 	function compileWidgetStyle($widgetStyle,$widget,$widget_content_body, $args, $javascript_mode)
700 703
 	{
701 704
 		if(!$widgetStyle) return $widget_content_body;
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 /**
4
- * @class  widgetController
5
- * @author NAVER ([email protected])
6
- * @brief Controller class for widget modules
7
- */
4
+	 * @class  widgetController
5
+	 * @author NAVER ([email protected])
6
+	 * @brief Controller class for widget modules
7
+	 */
8 8
 class widgetController extends widget
9 9
 {
10 10
 	// The results are not widget modify/delete and where to use the flag for
Please login to merge, or discard this patch.
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
 		$oModuleModel = getModel('module');
35 35
 		$skin_info = $oModuleModel->loadSkinInfo($path, $skin);
36 36
 
37
-		for($i=0;$i<count($skin_info->colorset);$i++)
37
+		for ($i = 0; $i < count($skin_info->colorset); $i++)
38 38
 		{
39 39
 			$colorset = sprintf('%s|@|%s', $skin_info->colorset[$i]->name, $skin_info->colorset[$i]->title);
40 40
 			$colorset_list[] = $colorset;
41 41
 		}
42 42
 
43
-		if(count($colorset_list)) $colorsets = implode("\n", $colorset_list);
43
+		if (count($colorset_list)) $colorsets = implode("\n", $colorset_list);
44 44
 		$this->add('colorset_list', $colorsets);
45 45
 	}
46 46
 
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 	function procWidgetGenerateCode()
51 51
 	{
52 52
 		$widget = Context::get('selected_widget');
53
-		if(!$widget) return new Object(-1,'msg_invalid_request');
54
-		if(!Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null'));
53
+		if (!$widget) return new Object(-1, 'msg_invalid_request');
54
+		if (!Context::get('skin')) return new Object(-1, Context::getLang('msg_widget_skin_is_null'));
55 55
 
56 56
 		$attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
57 57
 
58
-		$widget_code = sprintf('<img class="zbxe_widget_output" widget="%s" %s />', $widget, implode(' ',$attribute));
58
+		$widget_code = sprintf('<img class="zbxe_widget_output" widget="%s" %s />', $widget, implode(' ', $attribute));
59 59
 		// Code output
60 60
 		$this->add('widget_code', $widget_code);
61 61
 	}
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	function procWidgetGenerateCodeInPage()
67 67
 	{
68 68
 		$widget = Context::get('selected_widget');
69
-		if(!$widget) return new Object(-1,'msg_invalid_request');
69
+		if (!$widget) return new Object(-1, 'msg_invalid_request');
70 70
 
71
-		if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null'));
71
+		if (!in_array($widget, array('widgetBox', 'widgetContent')) && !Context::get('skin')) return new Object(-1, Context::getLang('msg_widget_skin_is_null'));
72 72
 
73 73
 		$attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
74 74
 		// Wanted results
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 		$this->setLayoutPath('./common/tpl');
91 91
 		$this->setLayoutFile('default_layout.html');
92
-		$this->setTemplatePath($this->module_path.'tpl');
92
+		$this->setTemplatePath($this->module_path . 'tpl');
93 93
 		$this->setTemplateFile("top_refresh.html");
94 94
 	}
95 95
 
@@ -107,28 +107,28 @@  discard block
 block discarded – undo
107 107
 		$err = 0;
108 108
 		$oLayoutModel = getModel('layout');
109 109
 		$layout_info = $oLayoutModel->getLayout($module_srl);
110
-		if(!$layout_info || $layout_info->type != 'faceoff') $err++;
110
+		if (!$layout_info || $layout_info->type != 'faceoff') $err++;
111 111
 		// Destination Information Wanted page module
112 112
 		$oModuleModel = getModel('module');
113 113
 		$columnList = array('module_srl', 'module');
114 114
 		$page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
115
-		if(!$page_info->module_srl || $page_info->module != 'page') $err++;
115
+		if (!$page_info->module_srl || $page_info->module != 'page') $err++;
116 116
 
117
-		if($err > 1) return new Object(-1,'msg_invalid_request');
117
+		if ($err > 1) return new Object(-1, 'msg_invalid_request');
118 118
 		// Check permissions
119 119
 		$is_logged = Context::get('is_logged');
120 120
 		$logged_info = Context::get('logged_info');
121 121
 		$user_group = $logged_info->group_list;
122 122
 		$is_admin = false;
123
-		if(count($user_group)&&count($page_info->grants['manager']))
123
+		if (count($user_group) && count($page_info->grants['manager']))
124 124
 		{
125 125
 			$manager_group = $page_info->grants['manager'];
126
-			foreach($user_group as $group_srl => $group_info)
126
+			foreach ($user_group as $group_srl => $group_info)
127 127
 			{
128
-				if(in_array($group_srl, $manager_group)) $is_admin = true;
128
+				if (in_array($group_srl, $manager_group)) $is_admin = true;
129 129
 			}
130 130
 		}
131
-		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted');
131
+		if (!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1, 'msg_not_permitted');
132 132
 		// Enter post
133 133
 		$oDocumentModel = getModel('document');
134 134
 		$oDocumentController = getController('document');
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		$obj->document_srl = $document_srl;
140 140
 
141 141
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl, true);
142
-		if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
142
+		if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
143 143
 		{
144 144
 			$output = $oDocumentController->updateDocument($oDocument, $obj);
145 145
 		}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			$obj->document_srl = $output->get('document_srl');
150 150
 		}
151 151
 		// Stop when an error occurs
152
-		if(!$output->toBool()) return $output;
152
+		if (!$output->toBool()) return $output;
153 153
 		// Return results
154 154
 		$this->add('document_srl', $obj->document_srl);
155 155
 	}
@@ -167,30 +167,30 @@  discard block
 block discarded – undo
167 167
 		$oDocumentAdminController = getAdminController('document');
168 168
 
169 169
 		$oDocument = $oDocumentModel->getDocument($document_srl, true);
170
-		if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request');
170
+		if (!$oDocument->isExists()) return new Object(-1, 'msg_invalid_request');
171 171
 		$module_srl = $oDocument->get('module_srl');
172 172
 		// Destination Information Wanted page module
173 173
 		$oModuleModel = getModel('module');
174 174
 		$columnList = array('module_srl', 'module');
175 175
 		$page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
176
-		if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request');
176
+		if (!$page_info->module_srl || $page_info->module != 'page') return new Object(-1, 'msg_invalid_request');
177 177
 		// Check permissions
178 178
 		$is_logged = Context::get('is_logged');
179 179
 		$logged_info = Context::get('logged_info');
180 180
 		$user_group = $logged_info->group_list;
181 181
 		$is_admin = false;
182
-		if(count($user_group)&&count($page_info->grants['manager']))
182
+		if (count($user_group) && count($page_info->grants['manager']))
183 183
 		{
184 184
 			$manager_group = $page_info->grants['manager'];
185
-			foreach($user_group as $group_srl => $group_info)
185
+			foreach ($user_group as $group_srl => $group_info)
186 186
 			{
187
-				if(in_array($group_srl, $manager_group)) $is_admin = true;
187
+				if (in_array($group_srl, $manager_group)) $is_admin = true;
188 188
 			}
189 189
 		}
190
-		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted');
190
+		if (!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1, 'msg_not_permitted');
191 191
 
192
-		$output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get('document_srl')), $oDocument->get('module_srl'),0);
193
-		if(!$output->toBool()) return $output;
192
+		$output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get('document_srl')), $oDocument->get('module_srl'), 0);
193
+		if (!$output->toBool()) return $output;
194 194
 		// Return results
195 195
 		$copied_srls = $output->get('copied_srls');
196 196
 		$this->add('document_srl', $copied_srls[$oDocument->get('document_srl')]);
@@ -208,29 +208,29 @@  discard block
 block discarded – undo
208 208
 		$oDocumentController = getController('document');
209 209
 
210 210
 		$oDocument = $oDocumentModel->getDocument($document_srl, true);
211
-		if(!$oDocument->isExists()) return new Object();
211
+		if (!$oDocument->isExists()) return new Object();
212 212
 		$module_srl = $oDocument->get('module_srl');
213 213
 		// Destination Information Wanted page module
214 214
 		$oModuleModel = getModel('module');
215 215
 		$page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
216
-		if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request');
216
+		if (!$page_info->module_srl || $page_info->module != 'page') return new Object(-1, 'msg_invalid_request');
217 217
 		// Check permissions
218 218
 		$is_logged = Context::get('is_logged');
219 219
 		$logged_info = Context::get('logged_info');
220 220
 		$user_group = $logged_info->group_list;
221 221
 		$is_admin = false;
222
-		if(count($user_group)&&count($page_info->grants['manager']))
222
+		if (count($user_group) && count($page_info->grants['manager']))
223 223
 		{
224 224
 			$manager_group = $page_info->grants['manager'];
225
-			foreach($user_group as $group_srl => $group_info)
225
+			foreach ($user_group as $group_srl => $group_info)
226 226
 			{
227
-				if(in_array($group_srl, $manager_group)) $is_admin = true;
227
+				if (in_array($group_srl, $manager_group)) $is_admin = true;
228 228
 			}
229 229
 		}
230
-		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted');
230
+		if (!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1, 'msg_not_permitted');
231 231
 
232 232
 		$output = $oDocumentController->deleteDocument($oDocument->get('document_srl'), true);
233
-		if(!$output->toBool()) return $output;
233
+		if (!$output->toBool()) return $output;
234 234
 	}
235 235
 
236 236
 	/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	function triggerWidgetCompile(&$content)
249 249
 	{
250
-		if(Context::getResponseMethod()!='HTML') return new Object();
250
+		if (Context::getResponseMethod() != 'HTML') return new Object();
251 251
 		$content = $this->transWidgetCode($content, $this->layout_javascript_mode);
252 252
 		return new Object();
253 253
 	}
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 		// Check whether to include information about editing
264 264
 		$this->javascript_mode = $javascript_mode;
265 265
 		// Widget code box change
266
-		$content = preg_replace_callback('!<div([^\>]*)widget=([^\>]*?)\><div><div>((<img.*?>)*)!is', array($this,'transWidgetBox'), $content);
266
+		$content = preg_replace_callback('!<div([^\>]*)widget=([^\>]*?)\><div><div>((<img.*?>)*)!is', array($this, 'transWidgetBox'), $content);
267 267
 		// Widget code information byeogyeong
268
-		$content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this,'transWidget'), $content);
268
+		$content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this, 'transWidget'), $content);
269 269
 
270 270
 		return $content;
271 271
 	}
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
 		$oXmlParser = new XmlParser();
281 281
 		$xml_doc = $oXmlParser->parse(trim($buff));
282 282
 
283
-		if($xml_doc->img) $vars = $xml_doc->img->attrs;
283
+		if ($xml_doc->img) $vars = $xml_doc->img->attrs;
284 284
 		else $vars = $xml_doc->attrs;
285 285
 
286 286
 		$widget = $vars->widget;
287
-		if(!$widget) return $matches[0];
287
+		if (!$widget) return $matches[0];
288 288
 		unset($vars->widget);
289 289
 
290 290
 		return $this->execute($widget, $vars, $this->javascript_mode);
@@ -295,13 +295,13 @@  discard block
 block discarded – undo
295 295
 	 */
296 296
 	function transWidgetBox($matches)
297 297
 	{
298
-		$buff = preg_replace('/<div><div>(.*)$/i','</div>',$matches[0]);
298
+		$buff = preg_replace('/<div><div>(.*)$/i', '</div>', $matches[0]);
299 299
 		$oXmlParser = new XmlParser();
300 300
 		$xml_doc = $oXmlParser->parse($buff);
301 301
 
302 302
 		$vars = $xml_doc->div->attrs;
303 303
 		$widget = $vars->widget;
304
-		if(!$widget) return $matches[0];
304
+		if (!$widget) return $matches[0];
305 305
 		unset($vars->widget);
306 306
 
307 307
 		$vars->widgetbox_content = $matches[3];
@@ -322,28 +322,28 @@  discard block
 block discarded – undo
322 322
 		$oXmlParser = new XmlParser();
323 323
 
324 324
 		$cnt = count($matches[1]);
325
-		for($i=0;$i<$cnt;$i++)
325
+		for ($i = 0; $i < $cnt; $i++)
326 326
 		{
327 327
 			$buff = $matches[0][$i];
328 328
 			$xml_doc = $oXmlParser->parse(trim($buff));
329 329
 
330 330
 			$args = $xml_doc->img->attrs;
331
-			if(!$args) continue;
331
+			if (!$args) continue;
332 332
 			// If you are not caching path
333 333
 			$widget = $args->widget;
334 334
 			$sequence = $args->widget_sequence;
335 335
 			$cache = $args->widget_cache;
336
-			if(!$sequence || !$cache) continue;
336
+			if (!$sequence || !$cache) continue;
337 337
 
338
-			if(count($args))
338
+			if (count($args))
339 339
 			{
340
-				foreach($args as $k => $v) $args->{$k} = urldecode($v);
340
+				foreach ($args as $k => $v) $args->{$k} = urldecode($v);
341 341
 			}
342 342
 			// If the cache file for each language widget regeneration
343
-			foreach($lang_list as $lang_type => $val)
343
+			foreach ($lang_list as $lang_type => $val)
344 344
 			{
345 345
 				$cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $sequence, $lang_type);
346
-				if(!file_exists($cache_file)) continue;
346
+				if (!file_exists($cache_file)) continue;
347 347
 				$this->getCache($widget, $args, $lang_type, true);
348 348
 			}
349 349
 		}
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	function getCache($widget, $args, $lang_type = null, $ignore_cache = false)
356 356
 	{
357 357
 		// If the specified language specifies the current language
358
-		if(!$lang_type) $lang_type = Context::getLangType();
358
+		if (!$lang_type) $lang_type = Context::getLangType();
359 359
 		// widget, the cache number and cache values are set
360 360
 		$widget_sequence = $args->widget_sequence;
361 361
 		$widget_cache = $args->widget_cache;
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
 		/**
364 364
 		 * Even if the cache number and value of the cache and return it to extract data
365 365
 		 */
366
-		if(!$ignore_cache && (!$widget_cache || !$widget_sequence))
366
+		if (!$ignore_cache && (!$widget_cache || !$widget_sequence))
367 367
 		{
368 368
 			$oWidget = $this->getWidgetObject($widget);
369
-			if(!$oWidget || !method_exists($oWidget, 'proc')) return;
369
+			if (!$oWidget || !method_exists($oWidget, 'proc')) return;
370 370
 
371 371
 			$widget_content = $oWidget->proc($args);
372 372
 			$oModuleController = getController('module');
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 		}
376 376
 
377 377
 		$oCacheHandler = CacheHandler::getInstance('template');
378
-		if($oCacheHandler->isSupport())
378
+		if ($oCacheHandler->isSupport())
379 379
 		{
380 380
 			$key = 'widget_cache:' . $widget_sequence;
381 381
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 			$cache_body = preg_replace('@<\!--#Meta:@', '<!--Meta:', $cache_body);
384 384
 		}
385 385
 
386
-		if($cache_body)
386
+		if ($cache_body)
387 387
 		{
388 388
 			return $cache_body;
389 389
 		}
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
 			// Wanted cache file
397 397
 			$cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type);
398 398
 			// If the file exists in the cache, the file validation
399
-			if(!$ignore_cache && file_exists($cache_file))
399
+			if (!$ignore_cache && file_exists($cache_file))
400 400
 			{
401 401
 				$filemtime = filemtime($cache_file);
402 402
 				// Should be modified compared to the time of the cache or in the future if creating more than widget.controller.php file a return value of the cache
403
-				if($filemtime + $widget_cache * 60 > $_SERVER['REQUEST_TIME'] && $filemtime > filemtime(_XE_PATH_.'modules/widget/widget.controller.php'))
403
+				if ($filemtime + $widget_cache * 60 > $_SERVER['REQUEST_TIME'] && $filemtime > filemtime(_XE_PATH_ . 'modules/widget/widget.controller.php'))
404 404
 				{
405 405
 					$cache_body = FileHandler::readFile($cache_file);
406 406
 					$cache_body = preg_replace('@<\!--#Meta:@', '<!--Meta:', $cache_body);
@@ -409,18 +409,18 @@  discard block
 block discarded – undo
409 409
 				}
410 410
 			}
411 411
 			// cache update and cache renewal of the file mtime
412
-			if(!$oCacheHandler->isSupport())
412
+			if (!$oCacheHandler->isSupport())
413 413
 			{
414 414
 			touch($cache_file);
415 415
 			}
416 416
 
417 417
 			$oWidget = $this->getWidgetObject($widget);
418
-			if(!$oWidget || !method_exists($oWidget,'proc')) return;
418
+			if (!$oWidget || !method_exists($oWidget, 'proc')) return;
419 419
 
420 420
 			$widget_content = $oWidget->proc($args);
421 421
 			$oModuleController = getController('module');
422 422
 			$oModuleController->replaceDefinedLangCode($widget_content);
423
-			if($oCacheHandler->isSupport())
423
+			if ($oCacheHandler->isSupport())
424 424
 			{
425 425
 				$oCacheHandler->put($key, $widget_content, $widget_cache * 60);
426 426
 			}
@@ -442,16 +442,16 @@  discard block
 block discarded – undo
442 442
 	function execute($widget, $args, $javascript_mode = false, $escaped = true)
443 443
 	{
444 444
 		// Save for debug run-time widget
445
-		if(__DEBUG__==3) $start = getMicroTime();
445
+		if (__DEBUG__ == 3) $start = getMicroTime();
446 446
 		$before = microtime(true);
447 447
 		// urldecode the value of args haejum
448 448
 		$object_vars = get_object_vars($args);
449
-		if(count($object_vars))
449
+		if (count($object_vars))
450 450
 		{
451
-			foreach($object_vars as $key => $val)
451
+			foreach ($object_vars as $key => $val)
452 452
 			{
453
-				if(in_array($key, array('widgetbox_content','body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right','widgetstyle','document_srl'))) continue;
454
-				if($escaped) $args->{$key} = utf8RawUrlDecode($val);
453
+				if (in_array($key, array('widgetbox_content', 'body', 'class', 'style', 'widget_sequence', 'widget', 'widget_padding_left', 'widget_padding_top', 'widget_padding_bottom', 'widget_padding_right', 'widgetstyle', 'document_srl'))) continue;
454
+				if ($escaped) $args->{$key} = utf8RawUrlDecode($val);
455 455
 			}
456 456
 		}
457 457
 
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
 		 * Widgets widgetContent/widgetBox Wanted If you are not content
461 461
 		 */
462 462
 		$widget_content = '';
463
-		if($widget != 'widgetContent' && $widget != 'widgetBox')
463
+		if ($widget != 'widgetContent' && $widget != 'widgetBox')
464 464
 		{
465
-			if(!is_dir(sprintf(_XE_PATH_.'widgets/%s/',$widget))) return;
465
+			if (!is_dir(sprintf(_XE_PATH_ . 'widgets/%s/', $widget))) return;
466 466
 			// Hold the contents of the widget parameter
467 467
 			$widget_content = $this->getCache($widget, $args);
468 468
 		}
469 469
 
470
-		if($widget == 'widgetBox')
470
+		if ($widget == 'widgetBox')
471 471
 		{
472 472
 			$widgetbox_content = $args->widgetbox_content;
473 473
 		}
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		 * Wanted specified by the administrator of the widget style
477 477
 		 */
478 478
 		// Sometimes the wrong code, background-image: url (none) can be heard but none in this case, the request for the url so unconditionally Removed
479
-		$style = preg_replace('/url\((.+)(\/?)none\)/is','', $args->style);
479
+		$style = preg_replace('/url\((.+)(\/?)none\)/is', '', $args->style);
480 480
 		// Find a style statement that based on the internal margin dropping pre-change
481 481
 		$widget_padding_left = $args->widget_padding_left;
482 482
 		$widget_padding_right = $args->widget_padding_right;
@@ -492,18 +492,18 @@  discard block
 block discarded – undo
492 492
 		$widget_content_body = '';
493 493
 		$widget_content_footer = '';
494 494
 		// If general call is given on page styles should return immediately dreamin '
495
-		if(!$javascript_mode)
495
+		if (!$javascript_mode)
496 496
 		{
497
-			if($args->id) $args->id = ' id="'.$args->id.'" ';
498
-			switch($widget)
497
+			if ($args->id) $args->id = ' id="' . $args->id . '" ';
498
+			switch ($widget)
499 499
 			{
500 500
 				// If a direct orthogonal addition information
501 501
 				case 'widgetContent' :
502
-					if($args->document_srl)
502
+					if ($args->document_srl)
503 503
 					{
504 504
 						$oDocumentModel = getModel('document');
505 505
 						$oDocument = $oDocumentModel->getDocument($args->document_srl);
506
-						$body = $oDocument->getContent(false,false,false, false);
506
+						$body = $oDocument->getContent(false, false, false, false);
507 507
 					}
508 508
 					else
509 509
 					{
@@ -513,21 +513,21 @@  discard block
 block discarded – undo
513 513
 					$oEditorController = getController('editor');
514 514
 					$body = $oEditorController->transComponent($body);
515 515
 
516
-					$widget_content_header = sprintf('<div class="xe_content xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s"><div style="%s">', $args->id, $style,  $inner_style);
516
+					$widget_content_header = sprintf('<div class="xe_content xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s"><div style="%s">', $args->id, $style, $inner_style);
517 517
 					$widget_content_body = $body;
518 518
 					$widget_content_footer = '</div></div>';
519 519
 
520 520
 					break;
521 521
 					// If the widget box; it could
522 522
 				case 'widgetBox' :
523
-					$widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s;"><div style="%s"><div>', $args->id, $style,  $inner_style);
523
+					$widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s;"><div style="%s"><div>', $args->id, $style, $inner_style);
524 524
 					$widget_content_body = $widgetbox_content;
525 525
 
526 526
 					break;
527 527
 					// If the General wijetil
528 528
 				default :
529
-					$widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s">',$args->id,$style);
530
-					$widget_content_body = sprintf('<div style="*zoom:1;%s">%s</div>', $inner_style,$widget_content);
529
+					$widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s">', $args->id, $style);
530
+					$widget_content_body = sprintf('<div style="*zoom:1;%s">%s</div>', $inner_style, $widget_content);
531 531
 					$widget_content_footer = '</div>';
532 532
 					break;
533 533
 			}
@@ -535,15 +535,15 @@  discard block
 block discarded – undo
535 535
 		}
536 536
 		else
537 537
 		{
538
-			switch($widget)
538
+			switch ($widget)
539 539
 			{
540 540
 				// If a direct orthogonal addition information
541 541
 				case 'widgetContent' :
542
-					if($args->document_srl)
542
+					if ($args->document_srl)
543 543
 					{
544 544
 						$oDocumentModel = getModel('document');
545 545
 						$oDocument = $oDocumentModel->getDocument($args->document_srl);
546
-						$body = $oDocument->getContent(false,false,false);
546
+						$body = $oDocument->getContent(false, false, false);
547 547
 					}
548 548
 					else
549 549
 					{
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
 					}
552 552
 					// by args
553 553
 					$attribute = array();
554
-					if($args)
554
+					if ($args)
555 555
 					{
556
-						foreach($args as $key => $val)
556
+						foreach ($args as $key => $val)
557 557
 						{
558
-							if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue;
559
-							if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val);
558
+							if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) continue;
559
+							if (strpos($val, '|@|') > 0) $val = str_replace('|@|', ',', $val);
560 560
 							$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
561 561
 						}
562 562
 					}
@@ -564,44 +564,44 @@  discard block
 block discarded – undo
564 564
 					$oWidgetController = getController('widget');
565 565
 
566 566
 					$widget_content_header = sprintf(
567
-						'<div class="xe_content widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>'.
568
-						'<div class="widgetResize"></div>'.
569
-						'<div class="widgetResizeLeft"></div>'.
570
-						'<div class="widgetBorder">'.
571
-						'<div style="%s">',$args->widgetstyle,
567
+						'<div class="xe_content widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>' .
568
+						'<div class="widgetResize"></div>' .
569
+						'<div class="widgetResizeLeft"></div>' .
570
+						'<div class="widgetBorder">' .
571
+						'<div style="%s">', $args->widgetstyle,
572 572
 						$style,
573 573
 						$args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom,
574 574
 						$args->document_srl,
575
-						implode(' ',$attribute),
575
+						implode(' ', $attribute),
576 576
 						$inner_style);
577 577
 
578 578
 					$widget_content_body = $body;
579
-					$widget_content_footer = sprintf('</div>'.
580
-						'</div>'.
581
-						'<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>'.
582
-						'</div>',base64_encode($body));
579
+					$widget_content_footer = sprintf('</div>' .
580
+						'</div>' .
581
+						'<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>' .
582
+						'</div>', base64_encode($body));
583 583
 
584 584
 					break;
585 585
 					// If the widget box; it could
586 586
 				case 'widgetBox' :
587 587
 					// by args
588 588
 					$attribute = array();
589
-					if($args)
589
+					if ($args)
590 590
 					{
591
-						foreach($args as $key => $val)
591
+						foreach ($args as $key => $val)
592 592
 						{
593
-							if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue;
594
-							if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) continue;
595
-							if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val);
593
+							if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) continue;
594
+							if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) continue;
595
+							if (strpos($val, '|@|') > 0) $val = str_replace('|@|', ',', $val);
596 596
 							$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
597 597
 						}
598 598
 					}
599 599
 
600 600
 					$widget_content_header = sprintf(
601
-						'<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >'.
602
-						'<div class="widgetBoxResize"></div>'.
603
-						'<div class="widgetBoxResizeLeft"></div>'.
604
-						'<div class="widgetBoxBorder"><div class="nullWidget" style="%s">',$args->widgetstyle,$style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left,implode(' ',$attribute),$inner_style);
601
+						'<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >' .
602
+						'<div class="widgetBoxResize"></div>' .
603
+						'<div class="widgetBoxResizeLeft"></div>' .
604
+						'<div class="widgetBoxBorder"><div class="nullWidget" style="%s">', $args->widgetstyle, $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, implode(' ', $attribute), $inner_style);
605 605
 
606 606
 					$widget_content_body = $widgetbox_content;
607 607
 
@@ -610,26 +610,26 @@  discard block
 block discarded – undo
610 610
 				default :
611 611
 					// by args
612 612
 					$attribute = array();
613
-					if($args)
613
+					if ($args)
614 614
 					{
615
-						$allowed_key = array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget');
616
-						foreach($args as $key => $val)
615
+						$allowed_key = array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget');
616
+						foreach ($args as $key => $val)
617 617
 						{
618
-							if(in_array($key, $allowed_key)) continue;
619
-							if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) continue;
620
-							if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val);
618
+							if (in_array($key, $allowed_key)) continue;
619
+							if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) continue;
620
+							if (strpos($val, '|@|') > 0) $val = str_replace('|@|', ',', $val);
621 621
 							$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
622 622
 						}
623 623
 					}
624 624
 
625
-					$widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >'.
626
-						'<div class="widgetResize"></div>'.
627
-						'<div class="widgetResizeLeft"></div>'.
628
-						'<div class="widgetBorder">',$args->widgetstyle,$style,
625
+					$widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >' .
626
+						'<div class="widgetResize"></div>' .
627
+						'<div class="widgetResizeLeft"></div>' .
628
+						'<div class="widgetBorder">', $args->widgetstyle, $style,
629 629
 						$widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left,
630
-						$widget, implode(' ',$attribute));
630
+						$widget, implode(' ', $attribute));
631 631
 
632
-					$widget_content_body = sprintf('<div style="%s">%s</div>',$inner_style, $widget_content);
632
+					$widget_content_body = sprintf('<div style="%s">%s</div>', $inner_style, $widget_content);
633 633
 
634 634
 					$widget_content_footer = '</div></div>';
635 635
 
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
 			}
638 638
 		}
639 639
 		// Compile the widget style.
640
-		if($args->widgetstyle) $widget_content_body = $this->compileWidgetStyle($args->widgetstyle,$widget, $widget_content_body, $args, $javascript_mode);
640
+		if ($args->widgetstyle) $widget_content_body = $this->compileWidgetStyle($args->widgetstyle, $widget, $widget_content_body, $args, $javascript_mode);
641 641
 
642 642
 		$output = $widget_content_header . $widget_content_body . $widget_content_footer;
643 643
 		// Debug widget creation time information added to the results
644
-		if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
644
+		if (__DEBUG__ == 3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
645 645
 
646 646
 		$after = microtime(true);
647 647
 
@@ -662,32 +662,32 @@  discard block
 block discarded – undo
662 662
 	 */
663 663
 	function getWidgetObject($widget)
664 664
 	{
665
-		if(!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $widget))
665
+		if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $widget))
666 666
 		{
667 667
 			return Context::getLang('msg_invalid_request');
668 668
 		}
669 669
 
670
-		if(!$GLOBALS['_xe_loaded_widgets_'][$widget])
670
+		if (!$GLOBALS['_xe_loaded_widgets_'][$widget])
671 671
 		{
672 672
 			// Finding the location of a widget
673 673
 			$oWidgetModel = getModel('widget');
674 674
 			$path = $oWidgetModel->getWidgetPath($widget);
675 675
 			// If you do not find the class file error output widget (html output)
676 676
 			$class_file = sprintf('%s%s.class.php', $path, $widget);
677
-			if(!file_exists($class_file)) return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget);
677
+			if (!file_exists($class_file)) return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget);
678 678
 			// Widget classes include
679 679
 			require_once($class_file);
680 680
 
681 681
 			// Creating Objects
682
-			if(!class_exists($widget, false))
682
+			if (!class_exists($widget, false))
683 683
 			{
684 684
 				return sprintf(Context::getLang('msg_widget_object_is_null'), $widget);
685 685
 			}
686 686
 
687 687
 			$oWidget = new $widget();
688
-			if(!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget);
688
+			if (!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget);
689 689
 
690
-			if(!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget);
690
+			if (!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget);
691 691
 
692 692
 			$oWidget->widget_path = $path;
693 693
 
@@ -696,31 +696,31 @@  discard block
 block discarded – undo
696 696
 		return $GLOBALS['_xe_loaded_widgets_'][$widget];
697 697
 	}
698 698
 
699
-	function compileWidgetStyle($widgetStyle,$widget,$widget_content_body, $args, $javascript_mode)
699
+	function compileWidgetStyle($widgetStyle, $widget, $widget_content_body, $args, $javascript_mode)
700 700
 	{
701
-		if(!$widgetStyle) return $widget_content_body;
701
+		if (!$widgetStyle) return $widget_content_body;
702 702
 
703 703
 		$oWidgetModel = getModel('widget');
704 704
 		// Bring extra_var widget style tie
705 705
 		$widgetstyle_info = $oWidgetModel->getWidgetStyleInfo($widgetStyle);
706
-		if(!$widgetstyle_info) return $widget_content_body;
706
+		if (!$widgetstyle_info) return $widget_content_body;
707 707
 
708 708
 		$widgetstyle_extra_var = new stdClass();
709 709
 		$widgetstyle_extra_var_key = get_object_vars($widgetstyle_info);
710
-		if(count($widgetstyle_extra_var_key['extra_var']))
710
+		if (count($widgetstyle_extra_var_key['extra_var']))
711 711
 		{
712
-			foreach($widgetstyle_extra_var_key['extra_var'] as $key => $val)
712
+			foreach ($widgetstyle_extra_var_key['extra_var'] as $key => $val)
713 713
 			{
714
-				$widgetstyle_extra_var->{$key} =  $args->{$key};
714
+				$widgetstyle_extra_var->{$key} = $args->{$key};
715 715
 			}
716 716
 		}
717 717
 		Context::set('widgetstyle_extra_var', $widgetstyle_extra_var);
718 718
 		// #18994272 오타를 수정했으나 하위 호환성을 위해 남겨둠 - deprecated
719 719
 		Context::set('widgetstyle_extar_var', $widgetstyle_extra_var);
720 720
 
721
-		if($javascript_mode && $widget=='widgetBox')
721
+		if ($javascript_mode && $widget == 'widgetBox')
722 722
 		{
723
-			Context::set('widget_content', '<div class="widget_inner">'.$widget_content_body.'</div>');
723
+			Context::set('widget_content', '<div class="widget_inner">' . $widget_content_body . '</div>');
724 724
 		}
725 725
 		else
726 726
 		{
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 		$oWidgetModel = getModel('widget');
743 743
 		$widget_info = $oWidgetModel->getWidgetInfo($widget);
744 744
 
745
-		if(!$vars)
745
+		if (!$vars)
746 746
 		{
747 747
 			$vars = new stdClass();
748 748
 		}
@@ -753,31 +753,31 @@  discard block
 block discarded – undo
753 753
 
754 754
 		$vars->skin = trim($request_vars->skin);
755 755
 		$vars->colorset = trim($request_vars->colorset);
756
-		$vars->widget_sequence = (int)($request_vars->widget_sequence);
757
-		$vars->widget_cache = (int)($request_vars->widget_cache);
756
+		$vars->widget_sequence = (int) ($request_vars->widget_sequence);
757
+		$vars->widget_cache = (int) ($request_vars->widget_cache);
758 758
 		$vars->style = trim($request_vars->style);
759 759
 		$vars->widget_padding_left = trim($request_vars->widget_padding_left);
760 760
 		$vars->widget_padding_right = trim($request_vars->widget_padding_right);
761 761
 		$vars->widget_padding_top = trim($request_vars->widget_padding_top);
762 762
 		$vars->widget_padding_bottom = trim($request_vars->widget_padding_bottom);
763
-		$vars->document_srl= trim($request_vars->document_srl);
763
+		$vars->document_srl = trim($request_vars->document_srl);
764 764
 
765
-		if(count($widget_info->extra_var))
765
+		if (count($widget_info->extra_var))
766 766
 		{
767
-			foreach($widget_info->extra_var as $key=>$val)
767
+			foreach ($widget_info->extra_var as $key=>$val)
768 768
 			{
769 769
 				$vars->{$key} = trim($request_vars->{$key});
770 770
 			}
771 771
 		}
772 772
 		// If the widget style
773
-		if($request_vars->widgetstyle)
773
+		if ($request_vars->widgetstyle)
774 774
 		{
775 775
 			$widgetStyle_info = $oWidgetModel->getWidgetStyleInfo($request_vars->widgetstyle);
776
-			if(count($widgetStyle_info->extra_var))
776
+			if (count($widgetStyle_info->extra_var))
777 777
 			{
778
-				foreach($widgetStyle_info->extra_var as $key=>$val)
778
+				foreach ($widgetStyle_info->extra_var as $key=>$val)
779 779
 				{
780
-					if($val->type =='color' || $val->type =='text' || $val->type =='select' || $val->type =='filebox' || $val->type == 'textarea')
780
+					if ($val->type == 'color' || $val->type == 'text' || $val->type == 'select' || $val->type == 'filebox' || $val->type == 'textarea')
781 781
 					{
782 782
 						$vars->{$key} = trim($request_vars->{$key});
783 783
 					}
@@ -785,23 +785,23 @@  discard block
 block discarded – undo
785 785
 			}
786 786
 		}
787 787
 
788
-		if($vars->widget_sequence)
788
+		if ($vars->widget_sequence)
789 789
 		{
790 790
 			$cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $vars->widget_sequence, Context::getLangType());
791 791
 			FileHandler::removeFile($cache_file);
792 792
 		}
793 793
 
794
-		if($vars->widget_cache>0) $vars->widget_sequence = getNextSequence();
794
+		if ($vars->widget_cache > 0) $vars->widget_sequence = getNextSequence();
795 795
 
796 796
 		$attribute = array();
797
-		foreach($vars as $key => $val)
797
+		foreach ($vars as $key => $val)
798 798
 		{
799
-			if(!$val)
799
+			if (!$val)
800 800
 			{
801 801
 				unset($vars->{$key});
802 802
 				continue;
803 803
 			}
804
-			if(strpos($val,'|@|') > 0) $val = str_replace('|@|', ',', $val);
804
+			if (strpos($val, '|@|') > 0) $val = str_replace('|@|', ',', $val);
805 805
 			$vars->{$key} = Context::convertEncodingStr($val);
806 806
 			$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars(Context::convertEncodingStr($val), ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
807 807
 		}
Please login to merge, or discard this patch.
Braces   +171 added lines, -69 removed lines patch added patch discarded remove patch
@@ -40,7 +40,9 @@  discard block
 block discarded – undo
40 40
 			$colorset_list[] = $colorset;
41 41
 		}
42 42
 
43
-		if(count($colorset_list)) $colorsets = implode("\n", $colorset_list);
43
+		if(count($colorset_list)) {
44
+			$colorsets = implode("\n", $colorset_list);
45
+		}
44 46
 		$this->add('colorset_list', $colorsets);
45 47
 	}
46 48
 
@@ -50,8 +52,12 @@  discard block
 block discarded – undo
50 52
 	function procWidgetGenerateCode()
51 53
 	{
52 54
 		$widget = Context::get('selected_widget');
53
-		if(!$widget) return new Object(-1,'msg_invalid_request');
54
-		if(!Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null'));
55
+		if(!$widget) {
56
+			return new Object(-1,'msg_invalid_request');
57
+		}
58
+		if(!Context::get('skin')) {
59
+			return new Object(-1,Context::getLang('msg_widget_skin_is_null'));
60
+		}
55 61
 
56 62
 		$attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
57 63
 
@@ -66,9 +72,13 @@  discard block
 block discarded – undo
66 72
 	function procWidgetGenerateCodeInPage()
67 73
 	{
68 74
 		$widget = Context::get('selected_widget');
69
-		if(!$widget) return new Object(-1,'msg_invalid_request');
75
+		if(!$widget) {
76
+			return new Object(-1,'msg_invalid_request');
77
+		}
70 78
 
71
-		if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null'));
79
+		if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) {
80
+			return new Object(-1,Context::getLang('msg_widget_skin_is_null'));
81
+		}
72 82
 
73 83
 		$attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
74 84
 		// Wanted results
@@ -107,14 +117,20 @@  discard block
 block discarded – undo
107 117
 		$err = 0;
108 118
 		$oLayoutModel = getModel('layout');
109 119
 		$layout_info = $oLayoutModel->getLayout($module_srl);
110
-		if(!$layout_info || $layout_info->type != 'faceoff') $err++;
120
+		if(!$layout_info || $layout_info->type != 'faceoff') {
121
+			$err++;
122
+		}
111 123
 		// Destination Information Wanted page module
112 124
 		$oModuleModel = getModel('module');
113 125
 		$columnList = array('module_srl', 'module');
114 126
 		$page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
115
-		if(!$page_info->module_srl || $page_info->module != 'page') $err++;
127
+		if(!$page_info->module_srl || $page_info->module != 'page') {
128
+			$err++;
129
+		}
116 130
 
117
-		if($err > 1) return new Object(-1,'msg_invalid_request');
131
+		if($err > 1) {
132
+			return new Object(-1,'msg_invalid_request');
133
+		}
118 134
 		// Check permissions
119 135
 		$is_logged = Context::get('is_logged');
120 136
 		$logged_info = Context::get('logged_info');
@@ -125,10 +141,14 @@  discard block
 block discarded – undo
125 141
 			$manager_group = $page_info->grants['manager'];
126 142
 			foreach($user_group as $group_srl => $group_info)
127 143
 			{
128
-				if(in_array($group_srl, $manager_group)) $is_admin = true;
144
+				if(in_array($group_srl, $manager_group)) {
145
+					$is_admin = true;
146
+				}
129 147
 			}
130 148
 		}
131
-		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted');
149
+		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) {
150
+			return new Object(-1,'msg_not_permitted');
151
+		}
132 152
 		// Enter post
133 153
 		$oDocumentModel = getModel('document');
134 154
 		$oDocumentController = getController('document');
@@ -142,14 +162,15 @@  discard block
 block discarded – undo
142 162
 		if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
143 163
 		{
144 164
 			$output = $oDocumentController->updateDocument($oDocument, $obj);
145
-		}
146
-		else
165
+		} else
147 166
 		{
148 167
 			$output = $oDocumentController->insertDocument($obj);
149 168
 			$obj->document_srl = $output->get('document_srl');
150 169
 		}
151 170
 		// Stop when an error occurs
152
-		if(!$output->toBool()) return $output;
171
+		if(!$output->toBool()) {
172
+			return $output;
173
+		}
153 174
 		// Return results
154 175
 		$this->add('document_srl', $obj->document_srl);
155 176
 	}
@@ -167,13 +188,17 @@  discard block
 block discarded – undo
167 188
 		$oDocumentAdminController = getAdminController('document');
168 189
 
169 190
 		$oDocument = $oDocumentModel->getDocument($document_srl, true);
170
-		if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request');
191
+		if(!$oDocument->isExists()) {
192
+			return new Object(-1,'msg_invalid_request');
193
+		}
171 194
 		$module_srl = $oDocument->get('module_srl');
172 195
 		// Destination Information Wanted page module
173 196
 		$oModuleModel = getModel('module');
174 197
 		$columnList = array('module_srl', 'module');
175 198
 		$page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
176
-		if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request');
199
+		if(!$page_info->module_srl || $page_info->module != 'page') {
200
+			return new Object(-1,'msg_invalid_request');
201
+		}
177 202
 		// Check permissions
178 203
 		$is_logged = Context::get('is_logged');
179 204
 		$logged_info = Context::get('logged_info');
@@ -184,13 +209,19 @@  discard block
 block discarded – undo
184 209
 			$manager_group = $page_info->grants['manager'];
185 210
 			foreach($user_group as $group_srl => $group_info)
186 211
 			{
187
-				if(in_array($group_srl, $manager_group)) $is_admin = true;
212
+				if(in_array($group_srl, $manager_group)) {
213
+					$is_admin = true;
214
+				}
188 215
 			}
189 216
 		}
190
-		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted');
217
+		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) {
218
+			return new Object(-1,'msg_not_permitted');
219
+		}
191 220
 
192 221
 		$output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get('document_srl')), $oDocument->get('module_srl'),0);
193
-		if(!$output->toBool()) return $output;
222
+		if(!$output->toBool()) {
223
+			return $output;
224
+		}
194 225
 		// Return results
195 226
 		$copied_srls = $output->get('copied_srls');
196 227
 		$this->add('document_srl', $copied_srls[$oDocument->get('document_srl')]);
@@ -208,12 +239,16 @@  discard block
 block discarded – undo
208 239
 		$oDocumentController = getController('document');
209 240
 
210 241
 		$oDocument = $oDocumentModel->getDocument($document_srl, true);
211
-		if(!$oDocument->isExists()) return new Object();
242
+		if(!$oDocument->isExists()) {
243
+			return new Object();
244
+		}
212 245
 		$module_srl = $oDocument->get('module_srl');
213 246
 		// Destination Information Wanted page module
214 247
 		$oModuleModel = getModel('module');
215 248
 		$page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
216
-		if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request');
249
+		if(!$page_info->module_srl || $page_info->module != 'page') {
250
+			return new Object(-1,'msg_invalid_request');
251
+		}
217 252
 		// Check permissions
218 253
 		$is_logged = Context::get('is_logged');
219 254
 		$logged_info = Context::get('logged_info');
@@ -224,13 +259,19 @@  discard block
 block discarded – undo
224 259
 			$manager_group = $page_info->grants['manager'];
225 260
 			foreach($user_group as $group_srl => $group_info)
226 261
 			{
227
-				if(in_array($group_srl, $manager_group)) $is_admin = true;
262
+				if(in_array($group_srl, $manager_group)) {
263
+					$is_admin = true;
264
+				}
228 265
 			}
229 266
 		}
230
-		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted');
267
+		if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) {
268
+			return new Object(-1,'msg_not_permitted');
269
+		}
231 270
 
232 271
 		$output = $oDocumentController->deleteDocument($oDocument->get('document_srl'), true);
233
-		if(!$output->toBool()) return $output;
272
+		if(!$output->toBool()) {
273
+			return $output;
274
+		}
234 275
 	}
235 276
 
236 277
 	/**
@@ -247,7 +288,9 @@  discard block
 block discarded – undo
247 288
 	 */
248 289
 	function triggerWidgetCompile(&$content)
249 290
 	{
250
-		if(Context::getResponseMethod()!='HTML') return new Object();
291
+		if(Context::getResponseMethod()!='HTML') {
292
+			return new Object();
293
+		}
251 294
 		$content = $this->transWidgetCode($content, $this->layout_javascript_mode);
252 295
 		return new Object();
253 296
 	}
@@ -280,11 +323,16 @@  discard block
 block discarded – undo
280 323
 		$oXmlParser = new XmlParser();
281 324
 		$xml_doc = $oXmlParser->parse(trim($buff));
282 325
 
283
-		if($xml_doc->img) $vars = $xml_doc->img->attrs;
284
-		else $vars = $xml_doc->attrs;
326
+		if($xml_doc->img) {
327
+			$vars = $xml_doc->img->attrs;
328
+		} else {
329
+			$vars = $xml_doc->attrs;
330
+		}
285 331
 
286 332
 		$widget = $vars->widget;
287
-		if(!$widget) return $matches[0];
333
+		if(!$widget) {
334
+			return $matches[0];
335
+		}
288 336
 		unset($vars->widget);
289 337
 
290 338
 		return $this->execute($widget, $vars, $this->javascript_mode);
@@ -301,7 +349,9 @@  discard block
 block discarded – undo
301 349
 
302 350
 		$vars = $xml_doc->div->attrs;
303 351
 		$widget = $vars->widget;
304
-		if(!$widget) return $matches[0];
352
+		if(!$widget) {
353
+			return $matches[0];
354
+		}
305 355
 		unset($vars->widget);
306 356
 
307 357
 		$vars->widgetbox_content = $matches[3];
@@ -328,22 +378,30 @@  discard block
 block discarded – undo
328 378
 			$xml_doc = $oXmlParser->parse(trim($buff));
329 379
 
330 380
 			$args = $xml_doc->img->attrs;
331
-			if(!$args) continue;
381
+			if(!$args) {
382
+				continue;
383
+			}
332 384
 			// If you are not caching path
333 385
 			$widget = $args->widget;
334 386
 			$sequence = $args->widget_sequence;
335 387
 			$cache = $args->widget_cache;
336
-			if(!$sequence || !$cache) continue;
388
+			if(!$sequence || !$cache) {
389
+				continue;
390
+			}
337 391
 
338 392
 			if(count($args))
339 393
 			{
340
-				foreach($args as $k => $v) $args->{$k} = urldecode($v);
394
+				foreach($args as $k => $v) {
395
+					$args->{$k} = urldecode($v);
396
+				}
341 397
 			}
342 398
 			// If the cache file for each language widget regeneration
343 399
 			foreach($lang_list as $lang_type => $val)
344 400
 			{
345 401
 				$cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $sequence, $lang_type);
346
-				if(!file_exists($cache_file)) continue;
402
+				if(!file_exists($cache_file)) {
403
+					continue;
404
+				}
347 405
 				$this->getCache($widget, $args, $lang_type, true);
348 406
 			}
349 407
 		}
@@ -355,7 +413,9 @@  discard block
 block discarded – undo
355 413
 	function getCache($widget, $args, $lang_type = null, $ignore_cache = false)
356 414
 	{
357 415
 		// If the specified language specifies the current language
358
-		if(!$lang_type) $lang_type = Context::getLangType();
416
+		if(!$lang_type) {
417
+			$lang_type = Context::getLangType();
418
+		}
359 419
 		// widget, the cache number and cache values are set
360 420
 		$widget_sequence = $args->widget_sequence;
361 421
 		$widget_cache = $args->widget_cache;
@@ -366,7 +426,9 @@  discard block
 block discarded – undo
366 426
 		if(!$ignore_cache && (!$widget_cache || !$widget_sequence))
367 427
 		{
368 428
 			$oWidget = $this->getWidgetObject($widget);
369
-			if(!$oWidget || !method_exists($oWidget, 'proc')) return;
429
+			if(!$oWidget || !method_exists($oWidget, 'proc')) {
430
+				return;
431
+			}
370 432
 
371 433
 			$widget_content = $oWidget->proc($args);
372 434
 			$oModuleController = getController('module');
@@ -386,8 +448,7 @@  discard block
 block discarded – undo
386 448
 		if($cache_body)
387 449
 		{
388 450
 			return $cache_body;
389
-		}
390
-		else
451
+		} else
391 452
 		{
392 453
 			/**
393 454
 			 * Cache number and cache values are set so that the cache file should call
@@ -415,7 +476,9 @@  discard block
 block discarded – undo
415 476
 			}
416 477
 
417 478
 			$oWidget = $this->getWidgetObject($widget);
418
-			if(!$oWidget || !method_exists($oWidget,'proc')) return;
479
+			if(!$oWidget || !method_exists($oWidget,'proc')) {
480
+				return;
481
+			}
419 482
 
420 483
 			$widget_content = $oWidget->proc($args);
421 484
 			$oModuleController = getController('module');
@@ -423,8 +486,7 @@  discard block
 block discarded – undo
423 486
 			if($oCacheHandler->isSupport())
424 487
 			{
425 488
 				$oCacheHandler->put($key, $widget_content, $widget_cache * 60);
426
-			}
427
-			else
489
+			} else
428 490
 			{
429 491
 				FileHandler::writeFile($cache_file, $widget_content);
430 492
 			}
@@ -442,7 +504,9 @@  discard block
 block discarded – undo
442 504
 	function execute($widget, $args, $javascript_mode = false, $escaped = true)
443 505
 	{
444 506
 		// Save for debug run-time widget
445
-		if(__DEBUG__==3) $start = getMicroTime();
507
+		if(__DEBUG__==3) {
508
+			$start = getMicroTime();
509
+		}
446 510
 		$before = microtime(true);
447 511
 		// urldecode the value of args haejum
448 512
 		$object_vars = get_object_vars($args);
@@ -450,8 +514,12 @@  discard block
 block discarded – undo
450 514
 		{
451 515
 			foreach($object_vars as $key => $val)
452 516
 			{
453
-				if(in_array($key, array('widgetbox_content','body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right','widgetstyle','document_srl'))) continue;
454
-				if($escaped) $args->{$key} = utf8RawUrlDecode($val);
517
+				if(in_array($key, array('widgetbox_content','body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right','widgetstyle','document_srl'))) {
518
+					continue;
519
+				}
520
+				if($escaped) {
521
+					$args->{$key} = utf8RawUrlDecode($val);
522
+				}
455 523
 			}
456 524
 		}
457 525
 
@@ -462,7 +530,9 @@  discard block
 block discarded – undo
462 530
 		$widget_content = '';
463 531
 		if($widget != 'widgetContent' && $widget != 'widgetBox')
464 532
 		{
465
-			if(!is_dir(sprintf(_XE_PATH_.'widgets/%s/',$widget))) return;
533
+			if(!is_dir(sprintf(_XE_PATH_.'widgets/%s/',$widget))) {
534
+				return;
535
+			}
466 536
 			// Hold the contents of the widget parameter
467 537
 			$widget_content = $this->getCache($widget, $args);
468 538
 		}
@@ -494,7 +564,9 @@  discard block
 block discarded – undo
494 564
 		// If general call is given on page styles should return immediately dreamin '
495 565
 		if(!$javascript_mode)
496 566
 		{
497
-			if($args->id) $args->id = ' id="'.$args->id.'" ';
567
+			if($args->id) {
568
+				$args->id = ' id="'.$args->id.'" ';
569
+			}
498 570
 			switch($widget)
499 571
 			{
500 572
 				// If a direct orthogonal addition information
@@ -504,8 +576,7 @@  discard block
 block discarded – undo
504 576
 						$oDocumentModel = getModel('document');
505 577
 						$oDocument = $oDocumentModel->getDocument($args->document_srl);
506 578
 						$body = $oDocument->getContent(false,false,false, false);
507
-					}
508
-					else
579
+					} else
509 580
 					{
510 581
 						$body = base64_decode($args->body);
511 582
 					}
@@ -532,8 +603,7 @@  discard block
 block discarded – undo
532 603
 					break;
533 604
 			}
534 605
 			// Edit page is called when a widget if you add the code for handling
535
-		}
536
-		else
606
+		} else
537 607
 		{
538 608
 			switch($widget)
539 609
 			{
@@ -544,8 +614,7 @@  discard block
 block discarded – undo
544 614
 						$oDocumentModel = getModel('document');
545 615
 						$oDocument = $oDocumentModel->getDocument($args->document_srl);
546 616
 						$body = $oDocument->getContent(false,false,false);
547
-					}
548
-					else
617
+					} else
549 618
 					{
550 619
 						$body = base64_decode($args->body);
551 620
 					}
@@ -555,8 +624,12 @@  discard block
 block discarded – undo
555 624
 					{
556 625
 						foreach($args as $key => $val)
557 626
 						{
558
-							if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue;
559
-							if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val);
627
+							if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) {
628
+								continue;
629
+							}
630
+							if(strpos($val,'|@|')>0) {
631
+								$val = str_replace('|@|',',',$val);
632
+							}
560 633
 							$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
561 634
 						}
562 635
 					}
@@ -590,9 +663,15 @@  discard block
 block discarded – undo
590 663
 					{
591 664
 						foreach($args as $key => $val)
592 665
 						{
593
-							if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue;
594
-							if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) continue;
595
-							if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val);
666
+							if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) {
667
+								continue;
668
+							}
669
+							if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) {
670
+								continue;
671
+							}
672
+							if(strpos($val,'|@|')>0) {
673
+								$val = str_replace('|@|',',',$val);
674
+							}
596 675
 							$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
597 676
 						}
598 677
 					}
@@ -615,9 +694,15 @@  discard block
 block discarded – undo
615 694
 						$allowed_key = array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget');
616 695
 						foreach($args as $key => $val)
617 696
 						{
618
-							if(in_array($key, $allowed_key)) continue;
619
-							if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) continue;
620
-							if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val);
697
+							if(in_array($key, $allowed_key)) {
698
+								continue;
699
+							}
700
+							if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) {
701
+								continue;
702
+							}
703
+							if(strpos($val,'|@|')>0) {
704
+								$val = str_replace('|@|',',',$val);
705
+							}
621 706
 							$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
622 707
 						}
623 708
 					}
@@ -637,11 +722,15 @@  discard block
 block discarded – undo
637 722
 			}
638 723
 		}
639 724
 		// Compile the widget style.
640
-		if($args->widgetstyle) $widget_content_body = $this->compileWidgetStyle($args->widgetstyle,$widget, $widget_content_body, $args, $javascript_mode);
725
+		if($args->widgetstyle) {
726
+			$widget_content_body = $this->compileWidgetStyle($args->widgetstyle,$widget, $widget_content_body, $args, $javascript_mode);
727
+		}
641 728
 
642 729
 		$output = $widget_content_header . $widget_content_body . $widget_content_footer;
643 730
 		// Debug widget creation time information added to the results
644
-		if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
731
+		if(__DEBUG__==3) {
732
+			$GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
733
+		}
645 734
 
646 735
 		$after = microtime(true);
647 736
 
@@ -674,7 +763,9 @@  discard block
 block discarded – undo
674 763
 			$path = $oWidgetModel->getWidgetPath($widget);
675 764
 			// If you do not find the class file error output widget (html output)
676 765
 			$class_file = sprintf('%s%s.class.php', $path, $widget);
677
-			if(!file_exists($class_file)) return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget);
766
+			if(!file_exists($class_file)) {
767
+				return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget);
768
+			}
678 769
 			// Widget classes include
679 770
 			require_once($class_file);
680 771
 
@@ -685,9 +776,13 @@  discard block
 block discarded – undo
685 776
 			}
686 777
 
687 778
 			$oWidget = new $widget();
688
-			if(!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget);
779
+			if(!is_object($oWidget)) {
780
+				return sprintf(Context::getLang('msg_widget_object_is_null'), $widget);
781
+			}
689 782
 
690
-			if(!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget);
783
+			if(!method_exists($oWidget, 'proc')) {
784
+				return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget);
785
+			}
691 786
 
692 787
 			$oWidget->widget_path = $path;
693 788
 
@@ -698,12 +793,16 @@  discard block
 block discarded – undo
698 793
 
699 794
 	function compileWidgetStyle($widgetStyle,$widget,$widget_content_body, $args, $javascript_mode)
700 795
 	{
701
-		if(!$widgetStyle) return $widget_content_body;
796
+		if(!$widgetStyle) {
797
+			return $widget_content_body;
798
+		}
702 799
 
703 800
 		$oWidgetModel = getModel('widget');
704 801
 		// Bring extra_var widget style tie
705 802
 		$widgetstyle_info = $oWidgetModel->getWidgetStyleInfo($widgetStyle);
706
-		if(!$widgetstyle_info) return $widget_content_body;
803
+		if(!$widgetstyle_info) {
804
+			return $widget_content_body;
805
+		}
707 806
 
708 807
 		$widgetstyle_extra_var = new stdClass();
709 808
 		$widgetstyle_extra_var_key = get_object_vars($widgetstyle_info);
@@ -721,8 +820,7 @@  discard block
 block discarded – undo
721 820
 		if($javascript_mode && $widget=='widgetBox')
722 821
 		{
723 822
 			Context::set('widget_content', '<div class="widget_inner">'.$widget_content_body.'</div>');
724
-		}
725
-		else
823
+		} else
726 824
 		{
727 825
 			Context::set('widget_content', $widget_content_body);
728 826
 		}
@@ -791,7 +889,9 @@  discard block
 block discarded – undo
791 889
 			FileHandler::removeFile($cache_file);
792 890
 		}
793 891
 
794
-		if($vars->widget_cache>0) $vars->widget_sequence = getNextSequence();
892
+		if($vars->widget_cache>0) {
893
+			$vars->widget_sequence = getNextSequence();
894
+		}
795 895
 
796 896
 		$attribute = array();
797 897
 		foreach($vars as $key => $val)
@@ -801,7 +901,9 @@  discard block
 block discarded – undo
801 901
 				unset($vars->{$key});
802 902
 				continue;
803 903
 			}
804
-			if(strpos($val,'|@|') > 0) $val = str_replace('|@|', ',', $val);
904
+			if(strpos($val,'|@|') > 0) {
905
+				$val = str_replace('|@|', ',', $val);
906
+			}
805 907
 			$vars->{$key} = Context::convertEncodingStr($val);
806 908
 			$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars(Context::convertEncodingStr($val), ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
807 909
 		}
Please login to merge, or discard this patch.
tools/dbxml_validator/tests/xmlQueriesTest.php 4 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -27,6 +27,11 @@  discard block
 block discarded – undo
27 27
  
28 28
     // recursive glob
29 29
     // On Windows glob() is case-sensitive.
30
+
31
+    /**
32
+     * @param string $sDir
33
+     * @param integer $nFlags
34
+     */
30 35
     public function globr($sDir, $sPattern, $nFlags = NULL) 
31 36
     { 
32 37
 	// Get the list of all matching files currently in the 
@@ -129,6 +134,9 @@  discard block
 block discarded – undo
129 134
 	$this->markTestIncomplete('XML Schema Language files should be fixed first.');
130 135
     }
131 136
 
137
+    /**
138
+     * @param integer $err_code
139
+     */
132 140
     public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
133 141
     {
134 142
 	$cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename);
@@ -166,6 +174,9 @@  discard block
 block discarded – undo
166 174
 	return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS);
167 175
     }
168 176
 
177
+    /**
178
+     * @param string $dir_name
179
+     */
169 180
     public function getDirFilesList($dir_name)
170 181
     {
171 182
 	$output = array();
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -2,33 +2,33 @@  discard block
 block discarded – undo
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4 4
 if (!defined('__DIR__'))
5
-    define('__DIR__', realpath(dirname(__FILE__))); 
5
+	define('__DIR__', realpath(dirname(__FILE__))); 
6 6
 
7 7
 /** The tests here are meant only for the built-in checks in validator.php, 
8 8
     and not for the entire syntax expressed by the .xsd files. */
9 9
 class XmlQueriesTest extends PHPUnit_Framework_TestCase
10 10
 {
11
-    // taken from validator.php
11
+	// taken from validator.php
12 12
 
13
-    const RETCODE_VALIDATOR_INTERNAL = 60;
14
-    const RETCODE_GENERIC_XML_SYNTAX = 50;
15
-    const RETCODE_QUERY_ELEMENT = 40;
16
-    const RETCODE_XSD_VALIDATION = 30;
17
-    const RETCODE_BUILTIN_CHECKS =    20;
18
-    const RETCODE_DB_SCHEMA_MATCH =10;	// no schema match is currently implemented.
19
-    const RETCODE_SUCCESS = 0;
13
+	const RETCODE_VALIDATOR_INTERNAL = 60;
14
+	const RETCODE_GENERIC_XML_SYNTAX = 50;
15
+	const RETCODE_QUERY_ELEMENT = 40;
16
+	const RETCODE_XSD_VALIDATION = 30;
17
+	const RETCODE_BUILTIN_CHECKS =    20;
18
+	const RETCODE_DB_SCHEMA_MATCH =10;	// no schema match is currently implemented.
19
+	const RETCODE_SUCCESS = 0;
20 20
 
21
-    public $validator_cmd;
21
+	public $validator_cmd;
22 22
 
23
-    public function setUp()
24
-    {
23
+	public function setUp()
24
+	{
25 25
 	 $this->validator_cmd = "php " . escapeshellarg(__DIR__ . '/../validate.php') . " ";
26
-    }
26
+	}
27 27
  
28
-    // recursive glob
29
-    // On Windows glob() is case-sensitive.
30
-    public function globr($sDir, $sPattern, $nFlags = NULL) 
31
-    { 
28
+	// recursive glob
29
+	// On Windows glob() is case-sensitive.
30
+	public function globr($sDir, $sPattern, $nFlags = NULL) 
31
+	{ 
32 32
 	// Get the list of all matching files currently in the 
33 33
 	// directory. 
34 34
 
@@ -41,25 +41,25 @@  discard block
 block discarded – undo
41 41
 
42 42
 	foreach ($aDirs as $sSubDir) 
43 43
 	{ 
44
-	    if ($sSubDir != '.' && $sSubDir != '..')
45
-	    {
44
+		if ($sSubDir != '.' && $sSubDir != '..')
45
+		{
46 46
 		$aSubFiles = $this->globr($sSubDir, $sPattern, $nFlags); 
47 47
 		$aFiles = array_merge($aFiles, $aSubFiles); 
48
-	    }
48
+		}
49 49
 	} 
50 50
 
51 51
 	// return merged array with all (recursive) files
52 52
 	return $aFiles; 
53
-    } 
53
+	} 
54 54
 
55
-    /** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */
56
-    public function invoke_testReleasedXMLLangFiles
55
+	/** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */
56
+	public function invoke_testReleasedXMLLangFiles
57 57
 	(
58
-	    $released_files,
59
-	    $expected_return_code,
60
-	    $validator_args = ''
58
+		$released_files,
59
+		$expected_return_code,
60
+		$validator_args = ''
61 61
 	)
62
-    {
62
+	{
63 63
 	// this file is in tools/dbxml_validator/tests
64 64
 	$xe_dir = __DIR__ . '/../../..';
65 65
 
@@ -70,67 +70,67 @@  discard block
 block discarded – undo
70 70
 	$xml_files = array();
71 71
 
72 72
 	foreach ($released_files as $released_file_mask)
73
-	    $xml_files =
73
+		$xml_files =
74 74
 		array_merge
75 75
 		(
76
-		    $xml_files,
77
-		    $this->globr
76
+			$xml_files,
77
+			$this->globr
78 78
 			(
79
-			    $xe_dir,
80
-			    $released_file_mask,
81
-			    GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
79
+				$xe_dir,
80
+				$released_file_mask,
81
+				GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
82 82
 			)
83 83
 		);
84 84
 
85 85
 	while ($cnt < count($xml_files))
86 86
 	{
87
-	    $cmd = $this->validator_cmd . $validator_args;
87
+		$cmd = $this->validator_cmd . $validator_args;
88 88
 
89
-	    // Validate 50 files at once
90
-	    foreach (array_slice($xml_files, $cnt, 50) as $xml_file)
89
+		// Validate 50 files at once
90
+		foreach (array_slice($xml_files, $cnt, 50) as $xml_file)
91 91
 		$cmd .= " " . escapeshellarg($xml_file);
92 92
 
93
-	    exec($cmd . ' 2>&1', $validator_output, $return_code);
93
+		exec($cmd . ' 2>&1', $validator_output, $return_code);
94 94
 
95
-	    $output_text = trim(trim(implode("\n", $validator_output)), "\n");
95
+		$output_text = trim(trim(implode("\n", $validator_output)), "\n");
96 96
 
97
-	    // Validator should not crash/exit-with-an-error.
98
-	    $this->assertLessThanOrEqual
97
+		// Validator should not crash/exit-with-an-error.
98
+		$this->assertLessThanOrEqual
99 99
 		(
100
-		    $expected_return_code,
101
-		    $return_code,
102
-		    "{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}."
100
+			$expected_return_code,
101
+			$return_code,
102
+			"{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}."
103 103
 		);
104 104
 
105
-	    $cnt += 50;
105
+		$cnt += 50;
106
+	}
106 107
 	}
107
-    }
108 108
 
109
-    public function testReleasedXMLQueryLangFiles()
110
-    {
109
+	public function testReleasedXMLQueryLangFiles()
110
+	{
111 111
 	$this->invoke_testReleasedXMLLangFiles
112
-	    (
112
+		(
113 113
 		array('queries/*.xml', 'xml_query/*.xml'),
114 114
 		self::RETCODE_QUERY_ELEMENT
115
-	    );
115
+		);
116 116
 
117 117
 	$this->markTestIncomplete('XML Query Language files should be fixed first.');
118
-    }
118
+	}
119 119
 
120
-    public function testReleasedXMLSchemaLangFiles()
121
-    {
120
+	public function testReleasedXMLSchemaLangFiles()
121
+	{
122 122
 	$this->invoke_testReleasedXMLLangFiles
123
-	    (
123
+		(
124 124
 		array('schemas/*.xml'),
125 125
 		self::RETCODE_BUILTIN_CHECKS,
126 126
 		' --schema-language'
127
-	    );
127
+		);
128 128
 
129 129
 	$this->markTestIncomplete('XML Schema Language files should be fixed first.');
130
-    }
130
+	}
131 131
 
132
-    public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
133
-    {
132
+	public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
133
+	{
134 134
 	$cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename);
135 135
 	$validator_output = array();
136 136
 	$return_code = 0;
@@ -141,88 +141,88 @@  discard block
 block discarded – undo
141 141
 
142 142
 	// Validator should not crash/exit-with-an-error.
143 143
 	$this->assertEquals
144
-	    (
144
+		(
145 145
 		$err_code,
146 146
 		$return_code,
147 147
 		"{$cmd}\n{$output_text}\nValidator returned code {$return_code}."
148
-	    );
148
+		);
149 149
 
150 150
 	// Validator should output some error on the test files
151 151
 	$basefilename = basename($filename);
152 152
 	$this->assertNotEmpty($output_text, "Error reporting failed for {$basefilename} validation.");
153 153
 
154
-    }
154
+	}
155 155
 
156
-    public function testInvalidQueryId()
157
-    {
156
+	public function testInvalidQueryId()
157
+	{
158 158
 	return $this->invoke_testInvalidXmlFiles(__DIR__.'/data/wrongQueryId.xml', self::RETCODE_QUERY_ELEMENT);
159
-    }
159
+	}
160 160
 
161
-    /**
162
-     * @dataProvider getFilesList
163
-     */
164
-    public function testInvalidXMLQueryFiles($filename)
165
-    {
161
+	/**
162
+	 * @dataProvider getFilesList
163
+	 */
164
+	public function testInvalidXMLQueryFiles($filename)
165
+	{
166 166
 	return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS);
167
-    }
167
+	}
168 168
 
169
-    public function getDirFilesList($dir_name)
170
-    {
169
+	public function getDirFilesList($dir_name)
170
+	{
171 171
 	$output = array();
172 172
 
173 173
 	$dir = opendir(__DIR__ . '/' . $dir_name);
174 174
 
175 175
 	if ($dir)
176 176
 	{
177
-	    $entry = readdir($dir);
177
+		$entry = readdir($dir);
178 178
 
179
-	    while ($entry !== FALSE)
180
-	    {
179
+		while ($entry !== FALSE)
180
+		{
181 181
 		$fname = __DIR__ . '/' . $dir_name .'/' . $entry;
182 182
 
183 183
 		if (!is_dir($fname)&& $entry != 'wrongQueryId.xml')
184
-		    $output[] = array($fname);
184
+			$output[] = array($fname);
185 185
 
186 186
 		$entry = readdir($dir);
187
-	    }
187
+		}
188 188
 
189
-	    closedir($dir);
189
+		closedir($dir);
190 190
 	}
191 191
 	else
192
-	    $this->assertFalse(TRUE);
192
+		$this->assertFalse(TRUE);
193 193
 
194
-        return $output;
195
-    }
194
+		return $output;
195
+	}
196 196
 
197
-    public function getFilesList()
198
-    {
197
+	public function getFilesList()
198
+	{
199 199
 	return $this->getDirFilesList('data');
200
-    }
200
+	}
201 201
 
202
-    public function getSchemaFilesList()
203
-    {
202
+	public function getSchemaFilesList()
203
+	{
204 204
 	return $this->getDirFilesList('data/schema');
205
-    }
205
+	}
206 206
 
207
-    public function getSchemaWarningFilesList()
208
-    {
207
+	public function getSchemaWarningFilesList()
208
+	{
209 209
 	return $this->getDirFilesList('data/schema/warnings');
210
-    }
210
+	}
211 211
 
212
-    /**
213
-     * @dataProvider getSchemaFilesList
214
-     */
215
-    public function testInvalidXMLSchemaFiles($filename)
216
-    {
212
+	/**
213
+	 * @dataProvider getSchemaFilesList
214
+	 */
215
+	public function testInvalidXMLSchemaFiles($filename)
216
+	{
217 217
 	return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS, '--schema-language');
218
-    }
218
+	}
219 219
 
220
-    /**
221
-     * @dataProvider getSchemaWarningFilesList
222
-     */
223
-    public function testWarningXMLSchemaFiles($filename)
224
-    {
220
+	/**
221
+	 * @dataProvider getSchemaWarningFilesList
222
+	 */
223
+	public function testWarningXMLSchemaFiles($filename)
224
+	{
225 225
 	return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_SUCCESS, '--schema-language');
226
-    }
226
+	}
227 227
 }
228 228
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -20 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
     const RETCODE_GENERIC_XML_SYNTAX = 50;
15 15
     const RETCODE_QUERY_ELEMENT = 40;
16 16
     const RETCODE_XSD_VALIDATION = 30;
17
-    const RETCODE_BUILTIN_CHECKS =    20;
18
-    const RETCODE_DB_SCHEMA_MATCH =10;	// no schema match is currently implemented.
17
+    const RETCODE_BUILTIN_CHECKS = 20;
18
+    const RETCODE_DB_SCHEMA_MATCH = 10; // no schema match is currently implemented.
19 19
     const RETCODE_SUCCESS = 0;
20 20
 
21 21
     public $validator_cmd;
@@ -53,8 +53,7 @@  discard block
 block discarded – undo
53 53
     } 
54 54
 
55 55
     /** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */
56
-    public function invoke_testReleasedXMLLangFiles
57
-	(
56
+    public function invoke_testReleasedXMLLangFiles(
58 57
 	    $released_files,
59 58
 	    $expected_return_code,
60 59
 	    $validator_args = ''
@@ -71,11 +70,9 @@  discard block
 block discarded – undo
71 70
 
72 71
 	foreach ($released_files as $released_file_mask)
73 72
 	    $xml_files =
74
-		array_merge
75
-		(
73
+		array_merge(
76 74
 		    $xml_files,
77
-		    $this->globr
78
-			(
75
+		    $this->globr(
79 76
 			    $xe_dir,
80 77
 			    $released_file_mask,
81 78
 			    GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
@@ -95,8 +92,7 @@  discard block
 block discarded – undo
95 92
 	    $output_text = trim(trim(implode("\n", $validator_output)), "\n");
96 93
 
97 94
 	    // Validator should not crash/exit-with-an-error.
98
-	    $this->assertLessThanOrEqual
99
-		(
95
+	    $this->assertLessThanOrEqual(
100 96
 		    $expected_return_code,
101 97
 		    $return_code,
102 98
 		    "{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}."
@@ -108,8 +104,7 @@  discard block
 block discarded – undo
108 104
 
109 105
     public function testReleasedXMLQueryLangFiles()
110 106
     {
111
-	$this->invoke_testReleasedXMLLangFiles
112
-	    (
107
+	$this->invoke_testReleasedXMLLangFiles(
113 108
 		array('queries/*.xml', 'xml_query/*.xml'),
114 109
 		self::RETCODE_QUERY_ELEMENT
115 110
 	    );
@@ -119,8 +114,7 @@  discard block
 block discarded – undo
119 114
 
120 115
     public function testReleasedXMLSchemaLangFiles()
121 116
     {
122
-	$this->invoke_testReleasedXMLLangFiles
123
-	    (
117
+	$this->invoke_testReleasedXMLLangFiles(
124 118
 		array('schemas/*.xml'),
125 119
 		self::RETCODE_BUILTIN_CHECKS,
126 120
 		' --schema-language'
@@ -131,7 +125,7 @@  discard block
 block discarded – undo
131 125
 
132 126
     public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
133 127
     {
134
-	$cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename);
128
+	$cmd = $this->validator_cmd . ' ' . $args . ' ' . escapeshellarg($filename);
135 129
 	$validator_output = array();
136 130
 	$return_code = 0;
137 131
 
@@ -140,8 +134,7 @@  discard block
 block discarded – undo
140 134
 	$output_text = trim(trim(implode("\n", $validator_output)), "\n");
141 135
 
142 136
 	// Validator should not crash/exit-with-an-error.
143
-	$this->assertEquals
144
-	    (
137
+	$this->assertEquals(
145 138
 		$err_code,
146 139
 		$return_code,
147 140
 		"{$cmd}\n{$output_text}\nValidator returned code {$return_code}."
@@ -155,7 +148,7 @@  discard block
 block discarded – undo
155 148
 
156 149
     public function testInvalidQueryId()
157 150
     {
158
-	return $this->invoke_testInvalidXmlFiles(__DIR__.'/data/wrongQueryId.xml', self::RETCODE_QUERY_ELEMENT);
151
+	return $this->invoke_testInvalidXmlFiles(__DIR__ . '/data/wrongQueryId.xml', self::RETCODE_QUERY_ELEMENT);
159 152
     }
160 153
 
161 154
     /**
@@ -178,9 +171,9 @@  discard block
 block discarded – undo
178 171
 
179 172
 	    while ($entry !== FALSE)
180 173
 	    {
181
-		$fname = __DIR__ . '/' . $dir_name .'/' . $entry;
174
+		$fname = __DIR__ . '/' . $dir_name . '/' . $entry;
182 175
 
183
-		if (!is_dir($fname)&& $entry != 'wrongQueryId.xml')
176
+		if (!is_dir($fname) && $entry != 'wrongQueryId.xml')
184 177
 		    $output[] = array($fname);
185 178
 
186 179
 		$entry = readdir($dir);
Please login to merge, or discard this patch.
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,8 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if (!defined('__DIR__'))
5
-    define('__DIR__', realpath(dirname(__FILE__))); 
4
+if (!defined('__DIR__')) {
5
+    define('__DIR__', realpath(dirname(__FILE__)));
6
+}
6 7
 
7 8
 /** The tests here are meant only for the built-in checks in validator.php, 
8 9
     and not for the entire syntax expressed by the .xsd files. */
@@ -69,8 +70,8 @@  discard block
 block discarded – undo
69 70
 	$cmd = $this->validator_cmd;
70 71
 	$xml_files = array();
71 72
 
72
-	foreach ($released_files as $released_file_mask)
73
-	    $xml_files =
73
+	foreach ($released_files as $released_file_mask) {
74
+		    $xml_files =
74 75
 		array_merge
75 76
 		(
76 77
 		    $xml_files,
@@ -80,15 +81,17 @@  discard block
 block discarded – undo
80 81
 			    $released_file_mask,
81 82
 			    GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
82 83
 			)
83
-		);
84
+		);
85
+	}
84 86
 
85 87
 	while ($cnt < count($xml_files))
86 88
 	{
87 89
 	    $cmd = $this->validator_cmd . $validator_args;
88 90
 
89 91
 	    // Validate 50 files at once
90
-	    foreach (array_slice($xml_files, $cnt, 50) as $xml_file)
91
-		$cmd .= " " . escapeshellarg($xml_file);
92
+	    foreach (array_slice($xml_files, $cnt, 50) as $xml_file) {
93
+	    		$cmd .= " " . escapeshellarg($xml_file);
94
+	    }
92 95
 
93 96
 	    exec($cmd . ' 2>&1', $validator_output, $return_code);
94 97
 
@@ -180,16 +183,17 @@  discard block
 block discarded – undo
180 183
 	    {
181 184
 		$fname = __DIR__ . '/' . $dir_name .'/' . $entry;
182 185
 
183
-		if (!is_dir($fname)&& $entry != 'wrongQueryId.xml')
184
-		    $output[] = array($fname);
186
+		if (!is_dir($fname)&& $entry != 'wrongQueryId.xml') {
187
+				    $output[] = array($fname);
188
+		}
185 189
 
186 190
 		$entry = readdir($dir);
187 191
 	    }
188 192
 
189 193
 	    closedir($dir);
190
-	}
191
-	else
192
-	    $this->assertFalse(TRUE);
194
+	} else {
195
+		    $this->assertFalse(TRUE);
196
+	}
193 197
 
194 198
         return $output;
195 199
     }
Please login to merge, or discard this patch.
tools/dbxml_validator/validate.php 4 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
  @return
174 174
  @param $xml_file
175 175
  @param $node
176
- @param $child_tag
176
+ @param string $child_tag
177 177
  */
178 178
 function checkDuplicateDescendants($xml_file, $node, $child_tag)
179 179
 {
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 	messages.
200 200
  @param $node
201 201
 	The XML node with the children to be checked.
202
- @param $child_tags
202
+ @param string[] $child_tags
203 203
 	Array with tag names for the children elements
204
- @param $attr_tags
204
+ @param string[] $attr_tags
205 205
 	Array with names of attributes to be checked. If multiple attributes
206 206
 	are given, than the first one that is present on a child is included
207 207
 	in the check.
208
- @param $key
208
+ @param boolean $key
209 209
 	True if child elements are required to expose at least one of the 
210 210
 	attribute. False if only the child nodes with some of the
211 211
 	attributes present are to be checked.
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 	@return
490 490
 	@param $xml_file
491 491
 	@param $container_element
492
-	@param $child_tag
492
+	@param string $child_tag
493 493
 */
494 494
 function checkVarContentsValidation
495 495
 	(
Please login to merge, or discard this patch.
Indentation   +28 added lines, -29 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		@param $line_no
91 91
 		@param $message
92 92
 		@access
93
-	*/
93
+	 */
94 94
 	public function __construct($file, $line_no, $message)
95 95
 	{
96 96
 		parent::__construct("{$file}({$line_no}):\n\t$message");
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	@developer
113 113
 	@return
114 114
 	@access
115
-	*/
115
+	 */
116 116
 	public function __destruct()
117 117
 	{
118 118
 		libxml_clear_errors();
@@ -834,8 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
 	@brief
836 836
 	@developer
837
-
838
-	*/
837
+	 */
839 838
 	class RestoreWorkDir
840 839
 	{
841 840
 		protected $dirname;
@@ -845,7 +844,7 @@  discard block
 block discarded – undo
845 844
 			@developer
846 845
 			@return
847 846
 			@access
848
-			*/
847
+		 */
849 848
 		public function __destruct()
850 849
 		{
851 850
 			try
@@ -868,7 +867,7 @@  discard block
 block discarded – undo
868 867
 			@developer
869 868
 			@return
870 869
 			@access
871
-			*/
870
+		 */
872 871
 		public function __construct()
873 872
 		{
874 873
 			$this->dirname = getcwd();
@@ -1113,7 +1112,7 @@  discard block
 block discarded – undo
1113 1112
 		@return
1114 1113
 		@access
1115 1114
 		@param $val
1116
-	*/
1115
+	 */
1117 1116
 	public function code($val = -1)
1118 1117
 	{
1119 1118
 		if($val == -1)
@@ -1135,7 +1134,7 @@  discard block
 block discarded – undo
1135 1134
 		@return
1136 1135
 		@access
1137 1136
 		@param $val
1138
-	*/
1137
+	 */
1139 1138
 	public function push($val)
1140 1139
 	{
1141 1140
 		$this->save = $this->exit_code;
@@ -1147,7 +1146,7 @@  discard block
 block discarded – undo
1147 1146
 		@developer
1148 1147
 		@access
1149 1148
 		@return
1150
-	*/
1149
+	 */
1151 1150
 	public function pop()
1152 1151
 	{
1153 1152
 		$this->exit_code = $this->save;
@@ -1160,7 +1159,7 @@  discard block
 block discarded – undo
1160 1159
 		@return
1161 1160
 		@access
1162 1161
 		@param $val
1163
-	*/
1162
+	 */
1164 1163
 	public function __construct($val = 0)
1165 1164
 	{
1166 1165
 		$this->save = self::RETCODE_VALIDATOR_INTERNAL;
@@ -1181,7 +1180,7 @@  discard block
 block discarded – undo
1181 1180
 		@developer
1182 1181
 		@access
1183 1182
 		@return
1184
-	*/
1183
+	 */
1185 1184
 	public function __destruct()
1186 1185
 	{
1187 1186
 		if($this->file_name)
@@ -1196,7 +1195,7 @@  discard block
 block discarded – undo
1196 1195
 		@access
1197 1196
 		@return
1198 1197
 		@param $file_name
1199
-	*/
1198
+	 */
1200 1199
 	public function __construct($file_name)
1201 1200
 	{
1202 1201
 		$this->file_name = $file_name;
@@ -1439,7 +1438,7 @@  discard block
 block discarded – undo
1439 1438
 
1440 1439
 			@brief
1441 1440
 			@developer
1442
-		*/
1441
+		 */
1443 1442
 		class Context
1444 1443
 		{
1445 1444
 			protected static $db_info = NULL;
@@ -1449,7 +1448,7 @@  discard block
 block discarded – undo
1449 1448
 				@developer
1450 1449
 				@return
1451 1450
 				@access
1452
-			*/
1451
+			 */
1453 1452
 			public static function isInstalled()
1454 1453
 			{
1455 1454
 				return TRUE;
@@ -1460,7 +1459,7 @@  discard block
 block discarded – undo
1460 1459
 				@developer
1461 1460
 				@return
1462 1461
 				@access
1463
-			*/
1462
+			 */
1464 1463
 			public static function getLangType()
1465 1464
 			{
1466 1465
 				return 'en';
@@ -1471,7 +1470,7 @@  discard block
 block discarded – undo
1471 1470
 				@developer
1472 1471
 				@return
1473 1472
 				@access
1474
-			*/
1473
+			 */
1475 1474
 			public static function getLang()
1476 1475
 			{
1477 1476
 				return 'en';
@@ -1482,7 +1481,7 @@  discard block
 block discarded – undo
1482 1481
 				@developer
1483 1482
 				@return
1484 1483
 				@access
1485
-			*/
1484
+			 */
1486 1485
 			public static function getDBType()
1487 1486
 			{
1488 1487
 				if(self::$db_info)
@@ -1501,7 +1500,7 @@  discard block
 block discarded – undo
1501 1500
 				@return
1502 1501
 				@access
1503 1502
 				@param $db_info
1504
-			*/
1503
+			 */
1505 1504
 			public static function setDBInfo($db_info)
1506 1505
 			{
1507 1506
 				self::$db_info = $db_info;
@@ -1512,7 +1511,7 @@  discard block
 block discarded – undo
1512 1511
 				@developer
1513 1512
 				@return
1514 1513
 				@access
1515
-			*/
1514
+			 */
1516 1515
 			public static function getDBInfo()
1517 1516
 			{
1518 1517
 				return self::$db_info;
@@ -1524,7 +1523,7 @@  discard block
 block discarded – undo
1524 1523
 				@return
1525 1524
 				@access
1526 1525
 				@param $str
1527
-			*/
1526
+			 */
1528 1527
 			public static function convertEncodingStr($str)
1529 1528
 			{
1530 1529
 				return $str;
@@ -1535,7 +1534,7 @@  discard block
 block discarded – undo
1535 1534
 				@developer
1536 1535
 				@return
1537 1536
 				@access
1538
-			*/
1537
+			 */
1539 1538
 			public static function setNoDBInfo()
1540 1539
 			{
1541 1540
 				$db_info = (object)NULL;
@@ -1562,7 +1561,7 @@  discard block
 block discarded – undo
1562 1561
 				@developer
1563 1562
 				@access
1564 1563
 				@return
1565
-			*/
1564
+			 */
1566 1565
 			public static function setMysqlDBInfo()
1567 1566
 			{
1568 1567
 				$db_info = (object)NULL;
@@ -1604,7 +1603,7 @@  discard block
 block discarded – undo
1604 1603
 				@developer
1605 1604
 				@return
1606 1605
 				@access
1607
-			*/
1606
+			 */
1608 1607
 			public static function setMysqliDBInfo()
1609 1608
 			{
1610 1609
 				$db_info = (object)NULL;
@@ -1646,7 +1645,7 @@  discard block
 block discarded – undo
1646 1645
 				@developer
1647 1646
 				@return
1648 1647
 				@access
1649
-			*/
1648
+			 */
1650 1649
 			public static function setCubridDBInfo()
1651 1650
 			{
1652 1651
 				$db_info = (object)NULL;
@@ -1688,7 +1687,7 @@  discard block
 block discarded – undo
1688 1687
 				@developer
1689 1688
 				@return
1690 1689
 				@access
1691
-			*/
1690
+			 */
1692 1691
 			public static function setMssqlDBInfo()
1693 1692
 			{
1694 1693
 				$db_info = (object)NULL;
@@ -1729,7 +1728,7 @@  discard block
 block discarded – undo
1729 1728
 		/**
1730 1729
 			@brief
1731 1730
 			@developer
1732
-		*/
1731
+		 */
1733 1732
 		class Any_prop_obj_base
1734 1733
 		{
1735 1734
 			/**
@@ -1738,7 +1737,7 @@  discard block
 block discarded – undo
1738 1737
 				@return
1739 1738
 				@param $property
1740 1739
 				@access
1741
-			*/
1740
+			 */
1742 1741
 			public function __get($property)
1743 1742
 			{
1744 1743
 				return NULL;
@@ -1748,7 +1747,7 @@  discard block
 block discarded – undo
1748 1747
 		/**
1749 1748
 			@brief
1750 1749
 			@developer
1751
-			*/
1750
+		 */
1752 1751
 		class LangArgFilterErrorMessage
1753 1752
 		{
1754 1753
 			/**
@@ -1757,7 +1756,7 @@  discard block
 block discarded – undo
1757 1756
 				@return
1758 1757
 				@param $property
1759 1758
 				@access
1760
-			*/
1759
+			 */
1761 1760
 			public function __get($property)
1762 1761
 			{
1763 1762
 				return 'Argument filter error';
Please login to merge, or discard this patch.
Spacing   +186 added lines, -205 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	{
96 96
 		parent::__construct("{$file}({$line_no}):\n\t$message");
97 97
 
98
-		$this->xml_file	= $file;
98
+		$this->xml_file = $file;
99 99
 		$this->xml_line_no = $line_no;
100 100
 		$this->xml_message = $message;
101 101
 	}
@@ -133,21 +133,21 @@  discard block
 block discarded – undo
133 133
 
134 134
 	$libXmlErrors = libxml_get_errors();
135 135
 
136
-	if(count($libXmlErrors))
136
+	if (count($libXmlErrors))
137 137
 	{
138
-		if(!$filename)
138
+		if (!$filename)
139 139
 		{
140 140
 			$filename = $libXmlErrors[0]->file;
141 141
 		}
142 142
 
143 143
 		$msg = '';
144 144
 
145
-		foreach($libXmlErrors as $libXmlError)
145
+		foreach ($libXmlErrors as $libXmlError)
146 146
 		{
147 147
 			$msg .= "{$libXmlError->file}({$libXmlError->line}):\n\t {$libXmlError->message}";
148 148
 		}
149 149
 
150
-		if($throw_error)
150
+		if ($throw_error)
151 151
 		{
152 152
 			throw new ErrorMessage($msg);
153 153
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	}
159 159
 	else
160 160
 	{
161
-		if($throw_error)
161
+		if ($throw_error)
162 162
 		{
163 163
 			throw new ErrorMessage('Schema validation failed.');
164 164
 		}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 {
180 180
 	$children = $node->getElementsByTagName($child_tag);
181 181
 
182
-	if($children->length > 1)
182
+	if ($children->length > 1)
183 183
 	{
184 184
 		throw 
185 185
 			new XmlSchemaError(
@@ -217,21 +217,21 @@  discard block
 block discarded – undo
217 217
 {
218 218
 	$key_values = array();
219 219
 
220
-	foreach($node->childNodes as $child_node)
220
+	foreach ($node->childNodes as $child_node)
221 221
 	{
222
-		if($child_node->nodeType == XML_ELEMENT_NODE
222
+		if ($child_node->nodeType == XML_ELEMENT_NODE
223 223
 					&&
224 224
 				in_array($child_node->tagName, $child_tags))
225 225
 		{
226 226
 			$key_value = NULL;
227 227
 
228
-			foreach($attr_tags as $attr_tag)
228
+			foreach ($attr_tags as $attr_tag)
229 229
 			{
230
-				if($child_node->hasAttribute($attr_tag))
230
+				if ($child_node->hasAttribute($attr_tag))
231 231
 				{
232 232
 					$key_value = $child_node->getAttribute($attr_tag);
233 233
 
234
-					if(array_key_exists($key_value, $key_values))
234
+					if (array_key_exists($key_value, $key_values))
235 235
 					{
236 236
 						throw
237 237
 							new XmlSchemaError(
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 				}
247 247
 			}
248 248
 
249
-			if(!$key_value && $key)
249
+			if (!$key_value && $key)
250 250
 			{
251 251
 				throw
252 252
 					new XmlSchemaError(
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
 	$table_name = NULL;
283 283
 	$join_type = NULL;
284 284
 
285
-	if($table_element->hasAttribute('name'))
285
+	if ($table_element->hasAttribute('name'))
286 286
 	{
287 287
 		$table_name = $table_element->getAttribute('name');
288 288
 	}
289 289
 
290
-	if($table_element->hasAttribute('type'))
290
+	if ($table_element->hasAttribute('type'))
291 291
 	{
292 292
 		$join_type = $table_element->getAttribute('type');
293 293
 	}
294 294
 
295
-	if($table_element->getAttribute('query') == 'true')
295
+	if ($table_element->getAttribute('query') == 'true')
296 296
 	{
297
-		if($table_name !== NULL)
297
+		if ($table_name !== NULL)
298 298
 		{
299 299
 			throw
300 300
 				new XmlSchemaError(
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 				);
305 305
 		}
306 306
 
307
-		if($join_type !== NULL)
307
+		if ($join_type !== NULL)
308 308
 		{
309 309
 			throw
310 310
 				new XmlSchemaError(
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 		// check contents for a select list or a table-specification
323 323
 		$has_query_clauses = FALSE;
324 324
 
325
-		foreach($table_element->childNodes as $query_clause)
325
+		foreach ($table_element->childNodes as $query_clause)
326 326
 		{
327
-			if($query_clause->nodeType == XML_ELEMENT_NODE
327
+			if ($query_clause->nodeType == XML_ELEMENT_NODE
328 328
 						&&
329 329
 					(
330 330
 						$query_clause->tagName == 'columns' 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 			}
336 336
 		}
337 337
 
338
-		if(!$has_query_clauses)
338
+		if (!$has_query_clauses)
339 339
 		{
340 340
 			throw
341 341
 				new XmlSchemaError(
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 	{
352 352
 		// base table or view
353 353
 
354
-		if($join_type !== NULL)
354
+		if ($join_type !== NULL)
355 355
 		{
356 356
 			$has_conditions_element = FALSE;
357 357
 
358
-			foreach($table_element->childNodes as $child_node)
358
+			foreach ($table_element->childNodes as $child_node)
359 359
 			{
360
-				if($child_node->nodeType == XML_ELEMENT_NODE)
360
+				if ($child_node->nodeType == XML_ELEMENT_NODE)
361 361
 				{
362
-					if($child_node->tagName == 'conditions')
362
+					if ($child_node->tagName == 'conditions')
363 363
 					{
364
-						if($has_conditions_element)
364
+						if ($has_conditions_element)
365 365
 						{
366 366
 							throw
367 367
 								new XmlSchemaError(
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 				}
388 388
 			}
389 389
 
390
-			if(!$has_conditions_element)
390
+			if (!$has_conditions_element)
391 391
 			{
392 392
 				throw
393 393
 					new XmlSchemaError(
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 		}
400 400
 		else
401 401
 		{
402
-			foreach($table_element->childNodes as $child_node)
402
+			foreach ($table_element->childNodes as $child_node)
403 403
 			{
404
-				if($child_node->nodeType == XML_ELEMENT_NODE)
404
+				if ($child_node->nodeType == XML_ELEMENT_NODE)
405 405
 				{
406 406
 					throw
407 407
 						new XmlSchemaError(
@@ -429,26 +429,25 @@  discard block
 block discarded – undo
429 429
  */
430 430
 function checkTablesClause($xml_file, $tables_element)
431 431
 {
432
-	checkUniqueKey
433
-		(
432
+	checkUniqueKey(
434 433
 			$xml_file,
435 434
 			$tables_element,
436
-			array('table'),				// child elements to be checked
437
-			array('alias', 'name'),		// attributes to be checked
435
+			array('table'), // child elements to be checked
436
+			array('alias', 'name'), // attributes to be checked
438 437
 			TRUE						// attributes are required
439 438
 		);
440 439
 
441
-	foreach($tables_element->childNodes as $table)
440
+	foreach ($tables_element->childNodes as $table)
442 441
 	{
443
-		if($table->nodeType == XML_ELEMENT_NODE
442
+		if ($table->nodeType == XML_ELEMENT_NODE
444 443
 					&&
445 444
 				$table->tagName == 'table')
446 445
 		{
447 446
 			checkTableExpression($xml_file, $table);
448 447
 
449
-			if($table->getAttribute('query') == 'true')
448
+			if ($table->getAttribute('query') == 'true')
450 449
 			{
451
-				validate_select_query($xml_file, $table);		// recursive call
450
+				validate_select_query($xml_file, $table); // recursive call
452 451
 			}
453 452
 		}
454 453
 	}
@@ -470,12 +469,11 @@  discard block
 block discarded – undo
470 469
  */
471 470
 function checkSelectListClause($xml_file, $columns_element)
472 471
 {
473
-	checkUniqueKey
474
-		(
472
+	checkUniqueKey(
475 473
 			$xml_file,
476 474
 			$columns_element,
477
-			array('column', 'query'),	// child elements
478
-			array('alias', 'name'),		// attributes
475
+			array('column', 'query'), // child elements
476
+			array('alias', 'name'), // attributes
479 477
 			FALSE						// ignore if no attributes present
480 478
 		);
481 479
 }
@@ -491,8 +489,7 @@  discard block
 block discarded – undo
491 489
 	@param $container_element
492 490
 	@param $child_tag
493 491
 */
494
-function checkVarContentsValidation
495
-	(
492
+function checkVarContentsValidation(
496 493
 		$xml_file,
497 494
 		$container_element,
498 495
 		$child_tag
@@ -503,23 +500,22 @@  discard block
 block discarded – undo
503 500
 
504 501
 	static
505 502
 		$var_attrs =
506
-			array
507
-			(
503
+			array(
508 504
 				'filter', 'notnull', 'minlength',
509 505
 				'maxlength'
510 506
 			);
511 507
 
512
-	foreach($container_element->childNodes as $child_node)
508
+	foreach ($container_element->childNodes as $child_node)
513 509
 	{
514
-		if($child_node->nodeType == XML_ELEMENT_NODE
510
+		if ($child_node->nodeType == XML_ELEMENT_NODE
515 511
 					&&
516 512
 				$child_node->tagName == $child_tag)
517 513
 		{
518
-			if(!$child_node->hasAttribute($key_attr))
514
+			if (!$child_node->hasAttribute($key_attr))
519 515
 			{
520
-				foreach($var_attrs as $var_attr)
516
+				foreach ($var_attrs as $var_attr)
521 517
 				{
522
-					if($child_node->hasAttribute($var_attr))
518
+					if ($child_node->hasAttribute($var_attr))
523 519
 					{
524 520
 						throw
525 521
 							new XmlSchemaError(
@@ -551,9 +547,9 @@  discard block
 block discarded – undo
551 547
 	$has_var_attribute = $condition->hasAttribute('var') || $condition->hasAttribute('default');
552 548
 	$query_line_no = -1;
553 549
 
554
-	foreach($condition->childNodes as $query_node)
550
+	foreach ($condition->childNodes as $query_node)
555 551
 	{
556
-		if($query_node->nodeType == XML_ELEMENT_NODE
552
+		if ($query_node->nodeType == XML_ELEMENT_NODE
557 553
 					&&
558 554
 				$query_node->tagName == 'query')
559 555
 		{
@@ -564,7 +560,7 @@  discard block
 block discarded – undo
564 560
 		}
565 561
 	}
566 562
 
567
-	if($child_query_node && $has_var_attribute)
563
+	if ($child_query_node && $has_var_attribute)
568 564
 	{
569 565
 		throw 
570 566
 			new XmlSchemaError(
@@ -574,7 +570,7 @@  discard block
 block discarded – undo
574 570
 			);
575 571
 	}
576 572
 
577
-	if(!($child_query_node || $has_var_attribute))
573
+	if (!($child_query_node || $has_var_attribute))
578 574
 	{
579 575
 		throw
580 576
 			new XmlSchemaError(
@@ -601,18 +597,18 @@  discard block
 block discarded – undo
601 597
 {
602 598
 	$first_child = TRUE;
603 599
 
604
-	foreach($conditions->childNodes as $child_node)
600
+	foreach ($conditions->childNodes as $child_node)
605 601
 	{
606
-		if($child_node->nodeType == XML_ELEMENT_NODE)
602
+		if ($child_node->nodeType == XML_ELEMENT_NODE)
607 603
 		{
608 604
 			// check for 'pipe' attribute
609
-			if($first_child)
605
+			if ($first_child)
610 606
 			{
611 607
 				$first_child = FALSE;
612 608
 			}
613 609
 			else
614 610
 			{
615
-				if(!$child_node->hasAttribute('pipe'))
611
+				if (!$child_node->hasAttribute('pipe'))
616 612
 				{
617 613
 					throw
618 614
 						new XmlSchemaError(
@@ -626,19 +622,19 @@  discard block
 block discarded – undo
626 622
 			}
627 623
 
628 624
 			// recurse in condition groups/queries
629
-			if($child_node->tagName == 'group')
625
+			if ($child_node->tagName == 'group')
630 626
 			{
631 627
 				checkConditionsGroup($xml_file, $child_node);
632 628
 			}
633 629
 			else
634 630
 			{
635
-				if($child_node->tagName == 'query')
631
+				if ($child_node->tagName == 'query')
636 632
 				{
637 633
 					validate_select_query($xml_file, $child_node);
638 634
 				}
639 635
 				else
640 636
 				{
641
-					if($child_node->tagName == 'condition')
637
+					if ($child_node->tagName == 'condition')
642 638
 					{
643 639
 						checkConditionElement($xml_file, $child_node);
644 640
 					}
@@ -664,12 +660,11 @@  discard block
 block discarded – undo
664 660
  */
665 661
 function checkNavigationClauses($xml_file, $navigation_element)
666 662
 {
667
-	foreach(array('list_count', 'page_count', 'page')
663
+	foreach (array('list_count', 'page_count', 'page')
668 664
 				as
669 665
 			$navigation_el)
670 666
 	{
671
-		checkDuplicateDescendants
672
-			(
667
+		checkDuplicateDescendants(
673 668
 				$xml_file,
674 669
 				$navigation_element,
675 670
 				$navigation_el
@@ -693,11 +688,11 @@  discard block
 block discarded – undo
693 688
  */
694 689
 function validate_select_query($xml_file, $query_element)
695 690
 {
696
-	foreach($query_element->childNodes as $select_clause)
691
+	foreach ($query_element->childNodes as $select_clause)
697 692
 	{
698
-		if($select_clause->nodeType == XML_ELEMENT_NODE)
693
+		if ($select_clause->nodeType == XML_ELEMENT_NODE)
699 694
 		{
700
-			switch($select_clause->tagName)
695
+			switch ($select_clause->tagName)
701 696
 			{
702 697
 				case 'columns':
703 698
 					checkSelectListClause($xml_file, $select_clause);
@@ -728,11 +723,11 @@  discard block
 block discarded – undo
728 723
  */
729 724
 function validate_update_query($xml_file, $query_element)
730 725
 {
731
-	foreach($query_element->childNodes as $update_clause)
726
+	foreach ($query_element->childNodes as $update_clause)
732 727
 	{
733
-		if($update_clause->nodeType == XML_ELEMENT_NODE)
728
+		if ($update_clause->nodeType == XML_ELEMENT_NODE)
734 729
 		{
735
-			switch($update_clause->tagName)
730
+			switch ($update_clause->tagName)
736 731
 			{
737 732
 				case 'tables':
738 733
 					checkTablesClause($xml_file, $update_clause);
@@ -755,11 +750,11 @@  discard block
 block discarded – undo
755 750
  */
756 751
 function validate_delete_query($xml_file, $query_element)
757 752
 {
758
-	foreach($query_element->childNodes as $delete_clause)
753
+	foreach ($query_element->childNodes as $delete_clause)
759 754
 	{
760
-		if($delete_clause->nodeType == XML_ELEMENT_NODE)
755
+		if ($delete_clause->nodeType == XML_ELEMENT_NODE)
761 756
 		{
762
-			switch($delete_clause->tagName)
757
+			switch ($delete_clause->tagName)
763 758
 			{
764 759
 				case 'conditions':
765 760
 					checkConditionsGroup($xml_file, $delete_clause);
@@ -778,11 +773,11 @@  discard block
 block discarded – undo
778 773
  */
779 774
 function validate_insert_select_query($xml_file, $query_element)
780 775
 {
781
-	foreach($query_element->childNodes as $statement_clause)
776
+	foreach ($query_element->childNodes as $statement_clause)
782 777
 	{
783
-		if($statement_clause->nodeType == XML_ELEMENT_NODE)
778
+		if ($statement_clause->nodeType == XML_ELEMENT_NODE)
784 779
 		{
785
-			switch($statement_clause->tagName)
780
+			switch ($statement_clause->tagName)
786 781
 			{
787 782
 				case 'query':
788 783
 					validate_select_query($xml_file, $statement_clause);
@@ -793,8 +788,7 @@  discard block
 block discarded – undo
793 788
 }
794 789
 
795 790
 $validate_query_type = 
796
-	array
797
-		(
791
+	array(
798 792
 			// 'insert' =>		
799 793
 							// there is currently nothing special to check
800 794
 							// for a plain insert, all the needed checks
@@ -818,13 +812,13 @@  discard block
 block discarded – undo
818 812
 
819 813
 	$action = $query_element->getAttribute('action');
820 814
 
821
-	if(array_key_exists($action, $validate_query_type))
815
+	if (array_key_exists($action, $validate_query_type))
822 816
 	{
823 817
 		$validate_query_type[$action]($xml_file, $query_element);
824 818
 	}
825 819
 }
826 820
 
827
-if(strpos(PHP_SAPI, 'cli') !== FALSE
821
+if (strpos(PHP_SAPI, 'cli') !== FALSE
828 822
 			|| 
829 823
 		strpos(PHP_SAPI, 'cgi') !== FALSE)
830 824
 {
@@ -857,7 +851,7 @@  discard block
 block discarded – undo
857 851
 				print "Failed to restore working dir {$this->dirname}.";
858 852
 			}
859 853
 
860
-			if(!$success)
854
+			if (!$success)
861 855
 			{
862 856
 				print "Failed to restore working dir {$this->dirname}.";
863 857
 			}
@@ -873,7 +867,7 @@  discard block
 block discarded – undo
873 867
 		{
874 868
 			$this->dirname = getcwd();
875 869
 
876
-			if(!$this->dirname)
870
+			if (!$this->dirname)
877 871
 			{
878 872
 				throw new ErrorMessage("Failed to get current directory.");
879 873
 			}
@@ -903,7 +897,7 @@  discard block
 block discarded – undo
903 897
 	$lowercase_name = strtolower($xml_path_info['basename']);
904 898
 	$uppercase_name = strtoupper($xml_path_info['basename']);
905 899
 
906
-	if(strlen($lowercase_name) != $filename_len
900
+	if (strlen($lowercase_name) != $filename_len
907 901
 				||
908 902
 			strlen($uppercase_name) != $filename_len)
909 903
 	{
@@ -916,9 +910,9 @@  discard block
 block discarded – undo
916 910
 
917 911
 	$varing_case_filename = '';
918 912
 
919
-	for($i = 0; $i < $filename_len; $i++)
913
+	for ($i = 0; $i < $filename_len; $i++)
920 914
 	{
921
-		if($lowercase_name[$i] != $uppercase_name[$i])
915
+		if ($lowercase_name[$i] != $uppercase_name[$i])
922 916
 		{
923 917
 			$varing_case_filename .= "[{$lowercase_name[$i]}{$uppercase_name[$i]}]";
924 918
 		}
@@ -932,13 +926,13 @@  discard block
 block discarded – undo
932 926
 
933 927
 	$restoreWorkDir = new RestoreWorkDir();
934 928
 
935
-	if($glob_pattern)
929
+	if ($glob_pattern)
936 930
 	{
937 931
 		// change current dir to the xml file directory to keep
938 932
 		// glob pattern shorter (maximum 260 chars).
939 933
 		$success = chdir($glob_pattern);
940 934
 
941
-		if(!$success)
935
+		if (!$success)
942 936
 		{
943 937
 			throw new ErrorMessage("Failed to change work dir to {$glob_pattern}.");
944 938
 		}
@@ -950,14 +944,14 @@  discard block
 block discarded – undo
950 944
 	// realpath() would have the same effect, but it is not documented as such
951 945
 	$matched_files = glob($glob_pattern, GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR);
952 946
 
953
-	unset($RestoreWorkDir);		// restore work dir after call to glob()
947
+	unset($RestoreWorkDir); // restore work dir after call to glob()
954 948
 
955
-	if($matched_files === FALSE || !is_array($matched_files))
949
+	if ($matched_files === FALSE || !is_array($matched_files))
956 950
 	{
957 951
 		throw new ErrorMessage("Directory listing for $xml_file failed.");
958 952
 	}
959 953
 
960
-	switch(count($matched_files))
954
+	switch (count($matched_files))
961 955
 	{
962 956
 		case 0:
963 957
 			throw new ErrorMessage("Directory listing for $xml_file failed.");
@@ -968,9 +962,9 @@  discard block
 block discarded – undo
968 962
 		default:
969 963
 			// more than one files with the same name and different case
970 964
 			// case-sensitive file system
971
-			foreach($mached_files as $matched_file)
965
+			foreach ($mached_files as $matched_file)
972 966
 			{
973
-				if(pathinfo($matched_file, PATHINFO_BASENAME) == $xml_path_info['basename'])
967
+				if (pathinfo($matched_file, PATHINFO_BASENAME) == $xml_path_info['basename'])
974 968
 				{
975 969
 					return ($xml_path_info['filename'] == $query_id);
976 970
 				}
@@ -979,7 +973,7 @@  discard block
 block discarded – undo
979 973
 
980 974
 	}
981 975
 
982
-	throw new ErrorMessage("Internal application error.");  // unreachable
976
+	throw new ErrorMessage("Internal application error."); // unreachable
983 977
 }
984 978
 
985 979
 /**
@@ -1000,9 +994,9 @@  discard block
 block discarded – undo
1000 994
 */
1001 995
 function validate_schema_doc($xml_file, $table_element)
1002 996
 {
1003
-	foreach($table_element->childNodes as $col_node)
997
+	foreach ($table_element->childNodes as $col_node)
1004 998
 	{
1005
-		if($col_node->nodeType == XML_ELEMENT_NODE
999
+		if ($col_node->nodeType == XML_ELEMENT_NODE
1006 1000
 					&&
1007 1001
 				$col_node->tagName == 'column')
1008 1002
 		{
@@ -1010,10 +1004,9 @@  discard block
 block discarded – undo
1010 1004
 			$col_size = NULL;
1011 1005
 
1012 1006
 			// check auto-increment column
1013
-			if($col_node->hasAttribute('auto_increment'))
1007
+			if ($col_node->hasAttribute('auto_increment'))
1014 1008
 			{
1015
-				fwrite
1016
-					(
1009
+				fwrite(
1017 1010
 						fopen('php://stdout', 'wt'), 
1018 1011
 						$xml_file . '(' . $col_node->getLineNo() . ")\n\t"
1019 1012
 							.
@@ -1023,7 +1016,7 @@  discard block
 block discarded – undo
1023 1016
 				static
1024 1017
 					$autoinc_types = array('number', 'bignumber');
1025 1018
 
1026
-				if(!in_array($col_type, $autoinc_types))
1019
+				if (!in_array($col_type, $autoinc_types))
1027 1020
 				{
1028 1021
 					throw
1029 1022
 						new XmlSchemaError(
@@ -1037,10 +1030,9 @@  discard block
 block discarded – undo
1037 1030
 			}
1038 1031
 
1039 1032
 			// check tinytext
1040
-			if($col_type == 'tinytext')
1033
+			if ($col_type == 'tinytext')
1041 1034
 			{
1042
-				fwrite
1043
-					(
1035
+				fwrite(
1044 1036
 						fopen('php://stdout', 'wt'), 
1045 1037
 						$xml_file . '(' . $col_node->getLineNo() . ")\n\t"
1046 1038
 							.
@@ -1049,12 +1041,12 @@  discard block
 block discarded – undo
1049 1041
 			}
1050 1042
 
1051 1043
 			// check size attribute
1052
-			if($col_node->hasAttribute('size'))
1044
+			if ($col_node->hasAttribute('size'))
1053 1045
 			{
1054 1046
 				$col_size = $col_node->getAttribute('size');
1055 1047
 			}
1056 1048
 
1057
-			if($col_type == 'varchar' && $col_size === NULL)
1049
+			if ($col_type == 'varchar' && $col_size === NULL)
1058 1050
 			{
1059 1051
 				throw 
1060 1052
 					new XmlSchemaError(
@@ -1068,7 +1060,7 @@  discard block
 block discarded – undo
1068 1060
 				$varsize_types = array('char', 'varchar', 'float');
1069 1061
 					
1070 1062
 
1071
-			if($col_size !== NULL  && !in_array($col_type, $varsize_types))
1063
+			if ($col_size !== NULL && !in_array($col_type, $varsize_types))
1072 1064
 			{
1073 1065
 				throw 
1074 1066
 					new XmlSchemaError(
@@ -1102,8 +1094,8 @@  discard block
 block discarded – undo
1102 1094
 	const RETCODE_GENERIC_XML_SYNTAX = 50;
1103 1095
 	const RETCODE_QUERY_ELEMENT = 40;
1104 1096
 	const RETCODE_XSD_VALIDATION = 30;
1105
-	const RETCODE_BUILTIN_CHECKS =	20;
1106
-	const RETCODE_DB_SCHEMA_MATCH = 10;	// no schema match is currently implemented.
1097
+	const RETCODE_BUILTIN_CHECKS = 20;
1098
+	const RETCODE_DB_SCHEMA_MATCH = 10; // no schema match is currently implemented.
1107 1099
 	const RETCODE_SUCCESS = 0;
1108 1100
 
1109 1101
 
@@ -1116,13 +1108,13 @@  discard block
 block discarded – undo
1116 1108
 	*/
1117 1109
 	public function code($val = -1)
1118 1110
 	{
1119
-		if($val == -1)
1111
+		if ($val == -1)
1120 1112
 		{
1121 1113
 			return $this->exit_code;
1122 1114
 		}
1123 1115
 		else
1124 1116
 		{
1125
-			if($this->exit_code < $val)
1117
+			if ($this->exit_code < $val)
1126 1118
 			{
1127 1119
 				$this->exit_code = $val;
1128 1120
 			}
@@ -1184,7 +1176,7 @@  discard block
 block discarded – undo
1184 1176
 	*/
1185 1177
 	public function __destruct()
1186 1178
 	{
1187
-		if($this->file_name)
1179
+		if ($this->file_name)
1188 1180
 		{
1189 1181
 			unlink($this->file_name);
1190 1182
 			$this->file_name = NULL;
@@ -1214,12 +1206,12 @@  discard block
 block discarded – undo
1214 1206
 	$cmdname = CMD_NAME;
1215 1207
 
1216 1208
 	// php manual says resources should not normally be declared constant
1217
-	if(!defined('STDERR'))
1209
+	if (!defined('STDERR'))
1218 1210
 	{
1219 1211
 		define('STDERR', fopen('php://stderr', 'wt'));
1220 1212
 	}
1221 1213
 
1222
-	if(!defined('__DIR__'))
1214
+	if (!defined('__DIR__'))
1223 1215
 	{
1224 1216
 		define('__DIR__', dirname(__FILE__)); 
1225 1217
 	}
@@ -1234,7 +1226,7 @@  discard block
 block discarded – undo
1234 1226
 	$query_args = NULL;
1235 1227
 	$query_args_file = NULL;
1236 1228
 
1237
-	while($argc >= 2 && $argv[1][0] == '-')
1229
+	while ($argc >= 2 && $argv[1][0] == '-')
1238 1230
 	{
1239 1231
 		$option = $argv[1];
1240 1232
 
@@ -1242,17 +1234,17 @@  discard block
 block discarded – undo
1242 1234
 		$argv = array_values($argv);
1243 1235
 		$argc = count($argv);
1244 1236
 
1245
-		switch($option)
1237
+		switch ($option)
1246 1238
 		{
1247 1239
 			case '-s':
1248 1240
 			case '--schema':
1249 1241
 			case '--schema-language':
1250
-				if($query_args !== NULL)
1242
+				if ($query_args !== NULL)
1251 1243
 				{
1252 1244
 					throw new SyntaxError("Both --args-string and --schema-language options given.");
1253 1245
 				}
1254 1246
 
1255
-				if($query_args_file !== NULL)
1247
+				if ($query_args_file !== NULL)
1256 1248
 				{
1257 1249
 					throw new SyntaxError("Both --args-file and --schema-language options given.");
1258 1250
 				}
@@ -1272,7 +1264,7 @@  discard block
 block discarded – undo
1272 1264
 
1273 1265
 			case '--xe-path':
1274 1266
 			case '--xe':
1275
-				if($argc < 2)
1267
+				if ($argc < 2)
1276 1268
 				{
1277 1269
 					throw
1278 1270
 						new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`");
@@ -1290,17 +1282,17 @@  discard block
 block discarded – undo
1290 1282
 			case '--args-string':
1291 1283
 			case '--arguments':
1292 1284
 			case '--args':
1293
-				if($schema_language !== NULL)
1285
+				if ($schema_language !== NULL)
1294 1286
 				{
1295 1287
 					throw new SyntaxError("Both --schema-language and --args-string options given.");
1296 1288
 				}
1297 1289
 
1298
-				if($query_args_file !== NULL)
1290
+				if ($query_args_file !== NULL)
1299 1291
 				{
1300 1292
 					throw new SyntaxError("Both --args-string and --args-file options given.");
1301 1293
 				}
1302 1294
 
1303
-				if($argc < 2)
1295
+				if ($argc < 2)
1304 1296
 				{
1305 1297
 					throw
1306 1298
 						new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`");
@@ -1316,17 +1308,17 @@  discard block
 block discarded – undo
1316 1308
 
1317 1309
 			case '--arguments-file':
1318 1310
 			case '--args-file':
1319
-				if($schema_language !== NULL)
1311
+				if ($schema_language !== NULL)
1320 1312
 				{
1321 1313
 					throw new SyntaxError("Both --schema-language and --args-file options given.");
1322 1314
 				}
1323 1315
 
1324
-				if($query_args !== NULL)
1316
+				if ($query_args !== NULL)
1325 1317
 				{
1326 1318
 					throw new SyntaxError("Both --args-string and --args-file options given.");
1327 1319
 				}
1328 1320
 
1329
-				if($argc < 2)
1321
+				if ($argc < 2)
1330 1322
 				{
1331 1323
 					throw
1332 1324
 						new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`");
@@ -1357,7 +1349,7 @@  discard block
 block discarded – undo
1357 1349
 		}
1358 1350
 	}
1359 1351
 
1360
-	if($argc < 2 ||
1352
+	if ($argc < 2 ||
1361 1353
 			(
1362 1354
 				$argc == 2
1363 1355
 					&&
@@ -1415,21 +1407,21 @@  discard block
 block discarded – undo
1415 1407
 	$query_user_args = array();
1416 1408
 
1417 1409
 	// check $xe_path, $query_args
1418
-	if(!$validate_only)
1410
+	if (!$validate_only)
1419 1411
 	{
1420
-		if($xe_path == NULL)
1412
+		if ($xe_path == NULL)
1421 1413
 		{
1422 1414
 			// assume validator.php is in directory .../xe/tools/dbxml_validator/ in an XE installation
1423 1415
 			$xe_path = dirname(dirname(realpath(__DIR__)));
1424 1416
 		}
1425 1417
 
1426
-		if(!file_exists($xe_path . '/index.php'))
1418
+		if (!file_exists($xe_path . '/index.php'))
1427 1419
 		{
1428 1420
 			throw
1429 1421
 				new ErrorMessage("File index.php not found in {$xe_path}.");
1430 1422
 		}
1431 1423
 
1432
-		if(!defined('_XE_PATH_'))
1424
+		if (!defined('_XE_PATH_'))
1433 1425
 		{
1434 1426
 			define('_XE_PATH_', $xe_path . '/');
1435 1427
 		}
@@ -1485,7 +1477,7 @@  discard block
 block discarded – undo
1485 1477
 			*/
1486 1478
 			public static function getDBType()
1487 1479
 			{
1488
-				if(self::$db_info)
1480
+				if (self::$db_info)
1489 1481
 				{
1490 1482
 					return self::$db_info->master_db['db_type'];
1491 1483
 				}
@@ -1538,10 +1530,9 @@  discard block
 block discarded – undo
1538 1530
 			*/
1539 1531
 			public static function setNoDBInfo()
1540 1532
 			{
1541
-				$db_info = (object)NULL;
1533
+				$db_info = (object) NULL;
1542 1534
 				$db_info->master_db =
1543
-					array
1544
-						(
1535
+					array(
1545 1536
 							'db_type' => NULL,
1546 1537
 							'db_hostname' => NULL,
1547 1538
 							'db_port' => NULL,
@@ -1565,10 +1556,9 @@  discard block
 block discarded – undo
1565 1556
 			*/
1566 1557
 			public static function setMysqlDBInfo()
1567 1558
 			{
1568
-				$db_info = (object)NULL;
1559
+				$db_info = (object) NULL;
1569 1560
 				$db_info->master_db =
1570
-					array
1571
-						(
1561
+					array(
1572 1562
 							'db_type' => 'mysql',
1573 1563
 							'db_hostname' => NULL,
1574 1564
 							'db_port' => NULL,
@@ -1584,7 +1574,7 @@  discard block
 block discarded – undo
1584 1574
 
1585 1575
 				self::setDBInfo($db_info);
1586 1576
 
1587
-				if(array_key_exists('__DB__', $GLOBALS)
1577
+				if (array_key_exists('__DB__', $GLOBALS)
1588 1578
 							&&
1589 1579
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1590 1580
 				{
@@ -1607,10 +1597,9 @@  discard block
 block discarded – undo
1607 1597
 			*/
1608 1598
 			public static function setMysqliDBInfo()
1609 1599
 			{
1610
-				$db_info = (object)NULL;
1600
+				$db_info = (object) NULL;
1611 1601
 				$db_info->master_db =
1612
-					array
1613
-						(
1602
+					array(
1614 1603
 							'db_type' => 'mysqli',
1615 1604
 							'db_hostname' => NULL,
1616 1605
 							'db_port' => NULL,
@@ -1626,7 +1615,7 @@  discard block
 block discarded – undo
1626 1615
 
1627 1616
 				self::setDBInfo($db_info);
1628 1617
 
1629
-				if(array_key_exists('__DB__', $GLOBALS)
1618
+				if (array_key_exists('__DB__', $GLOBALS)
1630 1619
 							&&
1631 1620
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1632 1621
 				{
@@ -1649,10 +1638,9 @@  discard block
 block discarded – undo
1649 1638
 			*/
1650 1639
 			public static function setCubridDBInfo()
1651 1640
 			{
1652
-				$db_info = (object)NULL;
1641
+				$db_info = (object) NULL;
1653 1642
 				$db_info->master_db =
1654
-					array
1655
-						(
1643
+					array(
1656 1644
 							'db_type' => 'cubrid',
1657 1645
 							'db_hostname' => NULL,
1658 1646
 							'db_port' => NULL,
@@ -1668,7 +1656,7 @@  discard block
 block discarded – undo
1668 1656
 
1669 1657
 				self::setDBInfo($db_info);
1670 1658
 
1671
-				if(array_key_exists('__DB__', $GLOBALS)
1659
+				if (array_key_exists('__DB__', $GLOBALS)
1672 1660
 							&&
1673 1661
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1674 1662
 				{
@@ -1691,10 +1679,9 @@  discard block
 block discarded – undo
1691 1679
 			*/
1692 1680
 			public static function setMssqlDBInfo()
1693 1681
 			{
1694
-				$db_info = (object)NULL;
1682
+				$db_info = (object) NULL;
1695 1683
 				$db_info->master_db =
1696
-					array
1697
-						(
1684
+					array(
1698 1685
 							'db_type' => 'mssql',
1699 1686
 							'db_hostname' => NULL,
1700 1687
 							'db_port' => NULL,
@@ -1710,7 +1697,7 @@  discard block
 block discarded – undo
1710 1697
 
1711 1698
 				self::setDBInfo($db_info);
1712 1699
 
1713
-				if(array_key_exists('__DB__', $GLOBALS)
1700
+				if (array_key_exists('__DB__', $GLOBALS)
1714 1701
 							&&
1715 1702
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1716 1703
 				{
@@ -1765,25 +1752,25 @@  discard block
 block discarded – undo
1765 1752
 		}
1766 1753
 
1767 1754
 		global $lang;
1768
-		$lang = new Any_prop_obj_base();	// to return NULL on non-existent properties
1755
+		$lang = new Any_prop_obj_base(); // to return NULL on non-existent properties
1769 1756
 		$lang->filter = New LangArgFilterErrorMessage();
1770 1757
 
1771
-		if(!defined('__XE__'))
1758
+		if (!defined('__XE__'))
1772 1759
 		{
1773 1760
 			define('__XE__', TRUE);
1774 1761
 		}
1775 1762
 
1776
-		if(!defined('__ZBXE__'))
1763
+		if (!defined('__ZBXE__'))
1777 1764
 		{
1778 1765
 			define('__ZBXE__', TRUE);
1779 1766
 		}
1780 1767
 
1781
-		if(!defined('__DEBUG__'))
1768
+		if (!defined('__DEBUG__'))
1782 1769
 		{
1783 1770
 			define('__DEBUG__', 0);
1784 1771
 		}
1785 1772
 
1786
-		if(!defined('__DEBUG_QUERY__'))
1773
+		if (!defined('__DEBUG_QUERY__'))
1787 1774
 		{
1788 1775
 			define('__DEBUG_QUERY__', 0);
1789 1776
 		}
@@ -1807,7 +1794,7 @@  discard block
 block discarded – undo
1807 1794
 		require_once(__DIR__ . '/connect_wrapper.php');
1808 1795
 
1809 1796
 		// check $query_args, $query_args_file
1810
-		if($query_args_file)
1797
+		if ($query_args_file)
1811 1798
 		{
1812 1799
 			try
1813 1800
 			{
@@ -1821,7 +1808,7 @@  discard block
 block discarded – undo
1821 1808
 		}
1822 1809
 		else
1823 1810
 		{
1824
-			if($query_args)
1811
+			if ($query_args)
1825 1812
 			{
1826 1813
 				try
1827 1814
 				{
@@ -1841,8 +1828,7 @@  discard block
 block discarded – undo
1841 1828
 
1842 1829
 	$schema_file = NULL;
1843 1830
 	$schemas_set =
1844
-		array
1845
-			(
1831
+		array(
1846 1832
 				'delete' => __DIR__ . '/xml_delete.xsd',
1847 1833
 				'update' => __DIR__ . '/xml_update.xsd',
1848 1834
 				'select' => __DIR__ . '/xml_select.xsd',
@@ -1855,12 +1841,12 @@  discard block
 block discarded – undo
1855 1841
 
1856 1842
 	$i = 1;
1857 1843
 
1858
-	if(pathinfo($argv[1], PATHINFO_EXTENSION) == 'xsd')
1844
+	if (pathinfo($argv[1], PATHINFO_EXTENSION) == 'xsd')
1859 1845
 	{
1860 1846
 		$schema_file = $argv[$i++];
1861 1847
 	}
1862 1848
 	
1863
-	for(; $i < count($argv); $i++)
1849
+	for (; $i < count($argv); $i++)
1864 1850
 	{
1865 1851
 		try
1866 1852
 		{
@@ -1869,7 +1855,7 @@  discard block
 block discarded – undo
1869 1855
 			$use_schema_language = $schema_language;
1870 1856
 
1871 1857
 			$retcode->push(ReturnCode::RETCODE_GENERIC_XML_SYNTAX);
1872
-			if($domDocument->load($argv[$i]))
1858
+			if ($domDocument->load($argv[$i]))
1873 1859
 			{
1874 1860
 				$retcode->pop();
1875 1861
 
@@ -1883,7 +1869,7 @@  discard block
 block discarded – undo
1883 1869
 					}
1884 1870
 				}
1885 1871
 
1886
-				if(!$schema_file && !$use_schema_language
1872
+				if (!$schema_file && !$use_schema_language
1887 1873
 							&&
1888 1874
 						(
1889 1875
 							$queryElement->tagName != 'query'
@@ -1903,7 +1889,7 @@  discard block
 block discarded – undo
1903 1889
 							);
1904 1890
 				}
1905 1891
 
1906
-				if(!$schema_file && !$use_schema_language && !$skip_query_id
1892
+				if (!$schema_file && !$use_schema_language && !$skip_query_id
1907 1893
 							&&
1908 1894
 						!validate_query_id($argv[$i], $queryElement->getAttribute('id')))
1909 1895
 				{
@@ -1916,24 +1902,24 @@  discard block
 block discarded – undo
1916 1902
 						);
1917 1903
 				}
1918 1904
 
1919
-				if($use_schema_language)
1905
+				if ($use_schema_language)
1920 1906
 				{
1921 1907
 					$document_schema = $table_schema;
1922 1908
 				}
1923 1909
 				else
1924 1910
 				{
1925
-					if(!$document_schema)
1911
+					if (!$document_schema)
1926 1912
 					{
1927 1913
 						$document_schema = $schemas_set[$queryElement->getAttribute('action')];
1928 1914
 					}
1929 1915
 				}
1930 1916
 
1931 1917
 				$retcode->push(ReturnCode::RETCODE_XSD_VALIDATION);
1932
-				if($domDocument->schemaValidate($document_schema))
1918
+				if ($domDocument->schemaValidate($document_schema))
1933 1919
 				{
1934 1920
 					$retcode->pop();
1935 1921
 
1936
-					if($use_schema_language)
1922
+					if ($use_schema_language)
1937 1923
 					{
1938 1924
 						validate_schema_doc($argv[$i], $domDocument->documentElement);
1939 1925
 					}
@@ -1944,22 +1930,22 @@  discard block
 block discarded – undo
1944 1930
 					$success = TRUE;
1945 1931
 				}
1946 1932
 
1947
-				if(!$validate_only)
1933
+				if (!$validate_only)
1948 1934
 				{
1949 1935
 					// Generate SQL with the db provider back-ends
1950 1936
 
1951
-					if(function_exists('sys_get_temp_dir'))
1937
+					if (function_exists('sys_get_temp_dir'))
1952 1938
 					{
1953 1939
 						$tmpdir = sys_get_temp_dir();
1954 1940
 					}
1955 1941
 					else
1956 1942
 					{
1957 1943
 						$tmpdir = getenv('TEMP');
1958
-						if(!$tmpdir)
1944
+						if (!$tmpdir)
1959 1945
 						{
1960 1946
 							$tmpdir = getenv('TMP');
1961 1947
 						}
1962
-						if(!$tmpdir)
1948
+						if (!$tmpdir)
1963 1949
 						{
1964 1950
 							$tmpdir = '/tmp';
1965 1951
 						}
@@ -1968,30 +1954,29 @@  discard block
 block discarded – undo
1968 1954
 
1969 1955
 					global $_SERVER;
1970 1956
 
1971
-					if(!is_array($_SERVER))
1957
+					if (!is_array($_SERVER))
1972 1958
 					{
1973 1959
 						$_SERVER = array();
1974 1960
 					}
1975 1961
 
1976
-					if(!array_key_exists('REMOTE_ADDR', $_SERVER))
1962
+					if (!array_key_exists('REMOTE_ADDR', $_SERVER))
1977 1963
 					{
1978 1964
 						$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
1979 1965
 					}
1980 1966
 
1981 1967
 					$set_db_info_methods =
1982
-						array
1983
-							(
1968
+						array(
1984 1969
 								'mysql'		=> 'setMysqlDBInfo',
1985 1970
 								'mysqli'	=> 'setMysqliDBInfo',
1986 1971
 								'cubrid'	=> 'setCubridDBInfo',
1987 1972
 								'mssql'		=> 'setMssqlDBInfo'
1988 1973
 							);
1989 1974
 
1990
-					foreach($set_db_info_methods as $db_type => $set_info_method)
1975
+					foreach ($set_db_info_methods as $db_type => $set_info_method)
1991 1976
 					{
1992 1977
 						Context::$set_info_method(); // calls setMysqlDBInfo()/setCubridDBInfo()/...
1993 1978
 
1994
-						if($use_schema_language)
1979
+						if ($use_schema_language)
1995 1980
 						{
1996 1981
 							$GLOBALS['__DB__'][$db_type]->queries = '';
1997 1982
 							$GLOBALS['__DB__'][$db_type]->createTableByXmlFile($argv[$i]);
@@ -2010,26 +1995,25 @@  discard block
 block discarded – undo
2010 1995
 							// copied from classes/db/DB.class.php
2011 1996
 							$oParser = new XmlQueryParser();
2012 1997
 							$args_array =
2013
-								$oParser->parse_xml_query
2014
-									(
1998
+								$oParser->parse_xml_query(
2015 1999
 										pathinfo($argv[$i], PATHINFO_FILENAME), // query id
2016
-										$argv[$i],								// xml file
2000
+										$argv[$i], // xml file
2017 2001
 										$unlink_tmpfile->file_name				// cache file
2018 2002
 									);
2019 2003
 							$args_array = $args_array->queryTag->getArguments();
2020 2004
 
2021 2005
 							$GLOBALS['__DB__'][$db_type]->queries = '';
2022 2006
 							$k = 1;
2023
-							foreach($args_array as $arg)
2007
+							foreach ($args_array as $arg)
2024 2008
 							{
2025
-								if(// why would there be a query arg without a var name ?
2009
+								if (// why would there be a query arg without a var name ?
2026 2010
 										isset($arg->variable_name)
2027 2011
 											&&
2028 2012
 										!array_key_exists($arg->variable_name, $query_user_args))
2029 2013
 								{
2030
-									if(isset($arg->argument_validator))
2014
+									if (isset($arg->argument_validator))
2031 2015
 									{
2032
-										if(FALSE	// some default values are to be parsed by php, some are not...
2016
+										if (FALSE	// some default values are to be parsed by php, some are not...
2033 2017
 													&&
2034 2018
 												isset($arg->argument_validator->default_value)
2035 2019
 													&&
@@ -2040,9 +2024,9 @@  discard block
 block discarded – undo
2040 2024
 										}
2041 2025
 										else
2042 2026
 										{
2043
-											if($arg->argument_validator->filter)
2027
+											if ($arg->argument_validator->filter)
2044 2028
 											{
2045
-												switch($arg->argument_validator->filter)
2029
+												switch ($arg->argument_validator->filter)
2046 2030
 												{
2047 2031
 													case 'email':
2048 2032
 													case 'email_address':
@@ -2081,18 +2065,17 @@  discard block
 block discarded – undo
2081 2065
 										}
2082 2066
 									}
2083 2067
 
2084
-									if(!array_key_exists($arg->variable_name, $query_user_args))
2068
+									if (!array_key_exists($arg->variable_name, $query_user_args))
2085 2069
 									{
2086 2070
 										$query_user_args[$arg->variable_name] = sprintf('%06d', $k);
2087 2071
 									}
2088 2072
 
2089
-									if(isset($arg->argument_validator))
2073
+									if (isset($arg->argument_validator))
2090 2074
 									{
2091
-										if(isset($arg->argument_validator->min_length))
2075
+										if (isset($arg->argument_validator->min_length))
2092 2076
 										{
2093 2077
 											$query_user_args[$arg->variable_name] =
2094
-												str_pad
2095
-													(
2078
+												str_pad(
2096 2079
 														$query_user_args[$arg->variable_name],
2097 2080
 														$arg->argument_validator->min_length,
2098 2081
 														isset($arg->argument_validator->filter) &&
@@ -2105,11 +2088,10 @@  discard block
 block discarded – undo
2105 2088
 													);
2106 2089
 										}
2107 2090
 
2108
-										if(isset($arg->argument_validator->max_length))
2091
+										if (isset($arg->argument_validator->max_length))
2109 2092
 										{
2110 2093
 											$query_user_args[$arg->variable_name] =
2111
-												substr
2112
-													(
2094
+												substr(
2113 2095
 														$query_user_args[$arg->variable_name],
2114 2096
 														0, 
2115 2097
 														$arg->argument_validator->max_length
@@ -2122,15 +2104,14 @@  discard block
 block discarded – undo
2122 2104
 							}
2123 2105
 
2124 2106
 							$resultset = 
2125
-								$GLOBALS['__DB__'][$db_type]->_executeQuery
2126
-									(
2127
-										$unlink_tmpfile->file_name,		// cache_file
2128
-										(object)$query_user_args,		// source_args
2129
-										basename($argv[$i]),			// query_id
2107
+								$GLOBALS['__DB__'][$db_type]->_executeQuery(
2108
+										$unlink_tmpfile->file_name, // cache_file
2109
+										(object) $query_user_args, // source_args
2110
+										basename($argv[$i]), // query_id
2130 2111
 										array()							// arg_columns
2131 2112
 									);
2132 2113
 
2133
-							if(is_a($resultset, 'Object') && !$resultset->toBool())
2114
+							if (is_a($resultset, 'Object') && !$resultset->toBool())
2134 2115
 							{
2135 2116
 								throw new XmlSchemaError($argv[$i], -1, 'mysql SQL query generation failed');
2136 2117
 							}
@@ -2147,7 +2128,7 @@  discard block
 block discarded – undo
2147 2128
 				}
2148 2129
 			}
2149 2130
 
2150
-			if(!$success)
2131
+			if (!$success)
2151 2132
 			{
2152 2133
 				libXmlDisplayError($argv[$i], TRUE);
2153 2134
 			}
@@ -2160,7 +2141,7 @@  discard block
 block discarded – undo
2160 2141
 		}
2161 2142
 		catch (ErrorMessage $exc)
2162 2143
 		{
2163
-			if($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2144
+			if ($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2164 2145
 			{
2165 2146
 				$retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL);
2166 2147
 			}
@@ -2170,7 +2151,7 @@  discard block
 block discarded – undo
2170 2151
 		}
2171 2152
 		catch (ErrorException $exc)
2172 2153
 		{
2173
-			if($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2154
+			if ($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2174 2155
 			{
2175 2156
 				$retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL);
2176 2157
 			}
@@ -2194,21 +2175,21 @@  discard block
 block discarded – undo
2194 2175
 catch (SyntaxError $syntax)
2195 2176
 {
2196 2177
 	fwrite(STDERR, $syntax->getMessage() . "\n");
2197
-	exit(254);	// wrong command line
2178
+	exit(254); // wrong command line
2198 2179
 				// 255 is reserved by php (for parse errors, etc.)
2199 2180
 }
2200 2181
 catch (ErrorMessage $exc)
2201 2182
 {
2202 2183
 	fwrite(STDERR, $exc->getMessage() . "\n");
2203 2184
 	libXmlDisplayError();
2204
-	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL);		// internal validator error
2185
+	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error
2205 2186
 }
2206 2187
 catch (Exception $exc)
2207 2188
 {
2208 2189
 	fwrite(STDERR, $exc->getFile() . '(' . $exc->getLine() . ")\n\t" . $exc->getMessage() . "\n");
2209 2190
 	fwrite(STDERR, $exc->getTraceAsString());
2210 2191
 	libXmlDisplayError();
2211
-	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL);		// internal validator error
2192
+	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error
2212 2193
 }
2213 2194
 
2214 2195
 /* End of file validate.php */
Please login to merge, or discard this patch.
Braces   +33 added lines, -66 removed lines patch added patch discarded remove patch
@@ -150,13 +150,11 @@  discard block
 block discarded – undo
150 150
 		if($throw_error)
151 151
 		{
152 152
 			throw new ErrorMessage($msg);
153
-		}
154
-		else
153
+		} else
155 154
 		{
156 155
 			fwrite(STDERR, $msg . "\n");
157 156
 		}
158
-	}
159
-	else
157
+	} else
160 158
 	{
161 159
 		if($throw_error)
162 160
 		{
@@ -346,8 +344,7 @@  discard block
 block discarded – undo
346 344
 					"\nANSI SQL-99 declares the table specification as required."
347 345
 				);
348 346
 		}
349
-	}
350
-	else
347
+	} else
351 348
 	{
352 349
 		// base table or view
353 350
 
@@ -369,13 +366,11 @@  discard block
 block discarded – undo
369 366
 									$child_node->getLineNo(),
370 367
 									'Duplicate <conditions> elements.'
371 368
 								);
372
-						}
373
-						else
369
+						} else
374 370
 						{
375 371
 							$has_conditions_element = TRUE;
376 372
 						}
377
-					}
378
-					else
373
+					} else
379 374
 					{
380 375
 						throw
381 376
 							new XmlSchemaError(
@@ -396,8 +391,7 @@  discard block
 block discarded – undo
396 391
 						'Expected <conditions> element as content.'
397 392
 					);
398 393
 			}
399
-		}
400
-		else
394
+		} else
401 395
 		{
402 396
 			foreach($table_element->childNodes as $child_node)
403 397
 			{
@@ -609,8 +603,7 @@  discard block
 block discarded – undo
609 603
 			if($first_child)
610 604
 			{
611 605
 				$first_child = FALSE;
612
-			}
613
-			else
606
+			} else
614 607
 			{
615 608
 				if(!$child_node->hasAttribute('pipe'))
616 609
 				{
@@ -629,14 +622,12 @@  discard block
 block discarded – undo
629 622
 			if($child_node->tagName == 'group')
630 623
 			{
631 624
 				checkConditionsGroup($xml_file, $child_node);
632
-			}
633
-			else
625
+			} else
634 626
 			{
635 627
 				if($child_node->tagName == 'query')
636 628
 				{
637 629
 					validate_select_query($xml_file, $child_node);
638
-				}
639
-				else
630
+				} else
640 631
 				{
641 632
 					if($child_node->tagName == 'condition')
642 633
 					{
@@ -851,8 +842,7 @@  discard block
 block discarded – undo
851 842
 			try
852 843
 			{
853 844
 				$success = chdir($this->dirname);
854
-			}
855
-			catch (Exception $e)
845
+			} catch (Exception $e)
856 846
 			{
857 847
 				print "Failed to restore working dir {$this->dirname}.";
858 848
 			}
@@ -921,8 +911,7 @@  discard block
 block discarded – undo
921 911
 		if($lowercase_name[$i] != $uppercase_name[$i])
922 912
 		{
923 913
 			$varing_case_filename .= "[{$lowercase_name[$i]}{$uppercase_name[$i]}]";
924
-		}
925
-		else
914
+		} else
926 915
 		{
927 916
 			$varing_case_filename .= $lowercase_name[$i];
928 917
 		}
@@ -1119,8 +1108,7 @@  discard block
 block discarded – undo
1119 1108
 		if($val == -1)
1120 1109
 		{
1121 1110
 			return $this->exit_code;
1122
-		}
1123
-		else
1111
+		} else
1124 1112
 		{
1125 1113
 			if($this->exit_code < $val)
1126 1114
 			{
@@ -1488,8 +1476,7 @@  discard block
 block discarded – undo
1488 1476
 				if(self::$db_info)
1489 1477
 				{
1490 1478
 					return self::$db_info->master_db['db_type'];
1491
-				}
1492
-				else
1479
+				} else
1493 1480
 				{
1494 1481
 					return NULL;
1495 1482
 				}
@@ -1588,8 +1575,7 @@  discard block
 block discarded – undo
1588 1575
 							&&
1589 1576
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1590 1577
 				{
1591
-				}
1592
-				else
1578
+				} else
1593 1579
 				{
1594 1580
 					$GLOBALS['__DB__'][$db_info->master_db['db_type']] =
1595 1581
 						new DBMysqlConnectWrapper();
@@ -1630,8 +1616,7 @@  discard block
 block discarded – undo
1630 1616
 							&&
1631 1617
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1632 1618
 				{
1633
-				}
1634
-				else
1619
+				} else
1635 1620
 				{
1636 1621
 					$GLOBALS['__DB__'][$db_info->master_db['db_type']] =
1637 1622
 						new DBMysqliConnectWrapper();
@@ -1672,8 +1657,7 @@  discard block
 block discarded – undo
1672 1657
 							&&
1673 1658
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1674 1659
 				{
1675
-				}
1676
-				else
1660
+				} else
1677 1661
 				{
1678 1662
 					$GLOBALS['__DB__'][$db_info->master_db['db_type']] =
1679 1663
 						new DBCubridConnectWrapper();
@@ -1714,8 +1698,7 @@  discard block
 block discarded – undo
1714 1698
 							&&
1715 1699
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1716 1700
 				{
1717
-				}
1718
-				else
1701
+				} else
1719 1702
 				{
1720 1703
 					$GLOBALS['__DB__'][$db_info->master_db['db_type']] =
1721 1704
 						new DBMssqlConnectWrapper();
@@ -1812,22 +1795,19 @@  discard block
 block discarded – undo
1812 1795
 			try
1813 1796
 			{
1814 1797
 				$query_user_args = require($query_args_file);
1815
-			}
1816
-			catch (Exception $exc)
1798
+			} catch (Exception $exc)
1817 1799
 			{
1818 1800
 				fwrite(STDERR, "Error in arguments file.\n");
1819 1801
 				throw $exc;
1820 1802
 			}
1821
-		}
1822
-		else
1803
+		} else
1823 1804
 		{
1824 1805
 			if($query_args)
1825 1806
 			{
1826 1807
 				try
1827 1808
 				{
1828 1809
 					eval('$query_user_args = array(' . $query_args . ');');
1829
-				}
1830
-				catch (Exception $exc)
1810
+				} catch (Exception $exc)
1831 1811
 				{
1832 1812
 					fwrite(STDERR, "Error in arguments string.\n");
1833 1813
 					throw $exc;
@@ -1919,8 +1899,7 @@  discard block
 block discarded – undo
1919 1899
 				if($use_schema_language)
1920 1900
 				{
1921 1901
 					$document_schema = $table_schema;
1922
-				}
1923
-				else
1902
+				} else
1924 1903
 				{
1925 1904
 					if(!$document_schema)
1926 1905
 					{
@@ -1936,8 +1915,7 @@  discard block
 block discarded – undo
1936 1915
 					if($use_schema_language)
1937 1916
 					{
1938 1917
 						validate_schema_doc($argv[$i], $domDocument->documentElement);
1939
-					}
1940
-					else
1918
+					} else
1941 1919
 					{
1942 1920
 						validate_xml_query($argv[$i], $domDocument->documentElement);
1943 1921
 					}
@@ -1951,8 +1929,7 @@  discard block
 block discarded – undo
1951 1929
 					if(function_exists('sys_get_temp_dir'))
1952 1930
 					{
1953 1931
 						$tmpdir = sys_get_temp_dir();
1954
-					}
1955
-					else
1932
+					} else
1956 1933
 					{
1957 1934
 						$tmpdir = getenv('TEMP');
1958 1935
 						if(!$tmpdir)
@@ -2001,8 +1978,7 @@  discard block
 block discarded – undo
2001 1978
 							print " {$db_type} query:\n";
2002 1979
 							print $GLOBALS['__DB__'][$db_type]->queries;
2003 1980
 							print "\n";
2004
-						}
2005
-						else
1981
+						} else
2006 1982
 						{
2007 1983
 							$unlink_tmpfile =
2008 1984
 								new UnlinkFile(tempnam($tmpdir, 'xe_'));
@@ -2037,8 +2013,7 @@  discard block
 block discarded – undo
2037 2013
 										{
2038 2014
 											$query_user_args[$arg->variable_name] =
2039 2015
 												eval('return ' . $arg->argument_validator->default_value->toString() . ';');
2040
-										}
2041
-										else
2016
+										} else
2042 2017
 										{
2043 2018
 											if($arg->argument_validator->filter)
2044 2019
 											{
@@ -2133,8 +2108,7 @@  discard block
 block discarded – undo
2133 2108
 							if(is_a($resultset, 'Object') && !$resultset->toBool())
2134 2109
 							{
2135 2110
 								throw new XmlSchemaError($argv[$i], -1, 'mysql SQL query generation failed');
2136
-							}
2137
-							else
2111
+							} else
2138 2112
 							{
2139 2113
 								print "\n";
2140 2114
 								print pathinfo($argv[$i], PATHINFO_FILENAME);
@@ -2151,14 +2125,12 @@  discard block
 block discarded – undo
2151 2125
 			{
2152 2126
 				libXmlDisplayError($argv[$i], TRUE);
2153 2127
 			}
2154
-		}
2155
-		catch (XmlSchemaError $exc)
2128
+		} catch (XmlSchemaError $exc)
2156 2129
 		{
2157 2130
 			$retcode->code(ReturnCode::RETCODE_BUILTIN_CHECKS);
2158 2131
 
2159 2132
 			fwrite(STDERR, $exc->getMessage() . "\n");
2160
-		}
2161
-		catch (ErrorMessage $exc)
2133
+		} catch (ErrorMessage $exc)
2162 2134
 		{
2163 2135
 			if($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2164 2136
 			{
@@ -2167,8 +2139,7 @@  discard block
 block discarded – undo
2167 2139
 
2168 2140
 			fwrite(STDERR, $exc->getMessage() . "\n");
2169 2141
 			libXmlDisplayError($argv[$i]);
2170
-		}
2171
-		catch (ErrorException $exc)
2142
+		} catch (ErrorException $exc)
2172 2143
 		{
2173 2144
 			if($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2174 2145
 			{
@@ -2178,8 +2149,7 @@  discard block
 block discarded – undo
2178 2149
 			fwrite(STDERR, "{$exc->getFile()}({$exc->getLine()}):\n\t{$exc->getMessage()}.\n");
2179 2150
 			fwrite(STDERR, $exc->getTraceAsString());
2180 2151
 			libXmlDisplayError($argv[$i]);
2181
-		}
2182
-		catch (Exception $exc)
2152
+		} catch (Exception $exc)
2183 2153
 		{
2184 2154
 			$retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL);
2185 2155
 
@@ -2190,20 +2160,17 @@  discard block
 block discarded – undo
2190 2160
 	}
2191 2161
 
2192 2162
 	exit($retcode->code());
2193
-}
2194
-catch (SyntaxError $syntax)
2163
+} catch (SyntaxError $syntax)
2195 2164
 {
2196 2165
 	fwrite(STDERR, $syntax->getMessage() . "\n");
2197 2166
 	exit(254);	// wrong command line
2198 2167
 				// 255 is reserved by php (for parse errors, etc.)
2199
-}
2200
-catch (ErrorMessage $exc)
2168
+} catch (ErrorMessage $exc)
2201 2169
 {
2202 2170
 	fwrite(STDERR, $exc->getMessage() . "\n");
2203 2171
 	libXmlDisplayError();
2204 2172
 	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL);		// internal validator error
2205
-}
2206
-catch (Exception $exc)
2173
+} catch (Exception $exc)
2207 2174
 {
2208 2175
 	fwrite(STDERR, $exc->getFile() . '(' . $exc->getLine() . ")\n\t" . $exc->getMessage() . "\n");
2209 2176
 	fwrite(STDERR, $exc->getTraceAsString());
Please login to merge, or discard this patch.
tools/minify/cssmin/CSSmin.php 3 patches
Doc Comments   +11 added lines, -2 removed lines patch added patch discarded remove patch
@@ -606,6 +606,11 @@  discard block
 block discarded – undo
606 606
  * ---------------------------------------------------------------------------------------------
607 607
  */
608 608
 
609
+/**
610
+ * @param double $v1
611
+ * @param double $v2
612
+ * @param integer $vh
613
+ */
609 614
 private function hue_to_rgb($v1, $v2, $vh)
610 615
 {
611 616
 	$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
@@ -620,6 +625,10 @@  discard block
 block discarded – undo
620 625
 	return intval(floor(floatval($n) + 0.5), 10);
621 626
 }
622 627
 
628
+/**
629
+ * @param integer $min
630
+ * @param integer $max
631
+ */
623 632
 private function clamp_number($n, $min, $max)
624 633
 {
625 634
 	return min(max($n, $min), $max);
@@ -648,7 +657,7 @@  discard block
 block discarded – undo
648 657
  *
649 658
  * @param string   $str
650 659
  * @param int      $from index
651
- * @param int|bool $to index (optional)
660
+ * @param integer $to index (optional)
652 661
  * @return string
653 662
  */
654 663
 private function substring($str, $from = 0, $to = FALSE)
@@ -680,7 +689,7 @@  discard block
 block discarded – undo
680 689
  *
681 690
  * @param string   $str
682 691
  * @param int      $start index
683
- * @param int|bool $end index (optional)
692
+ * @param integer $end index (optional)
684 693
  * @return string
685 694
  */
686 695
 private function str_slice($str, $start = 0, $end = FALSE)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$this->memory_limit = 128 * 1048576; // 128MB in bytes
48 48
 		$this->max_execution_time = 60; // 1 min
49 49
 		$this->pcre_backtrack_limit = 1000 * 1000;
50
-		$this->pcre_recursion_limit =  500 * 1000;
50
+		$this->pcre_recursion_limit = 500 * 1000;
51 51
 
52 52
 		$this->raise_php_limits = (bool) $raise_php_limits;
53 53
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	}
92 92
 
93 93
 	// preserve strings so their content doesn't get accidentally minified
94
-	$css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|'."(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css);
94
+	$css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|' . "(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css);
95 95
 
96 96
 	// Let's divide css code in chunks of 25.000 chars aprox.
97 97
 	// Reason: PHP's PCRE functions like preg_replace have a "backtrack limit"
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 			$token_tring = self::TOKEN . (count($this->preserved_tokens) - 1) . '___';
230 230
 			$css = preg_replace($placeholder, $token_tring, $css, 1);
231 231
 			// Preserve new lines for /*! important comments
232
-			$css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'. $token_tring .')/S', self::NL.'$1', $css);
233
-			$css = preg_replace('/('. $token_tring .'\*\/)\s*[\n\r\f]+\s*/S', '$1'.self::NL, $css);
232
+			$css = preg_replace('/\s*[\n\r\f]+\s*(\/\*' . $token_tring . ')/S', self::NL . '$1', $css);
233
+			$css = preg_replace('/(' . $token_tring . '\*\/)\s*[\n\r\f]+\s*/S', '$1' . self::NL, $css);
234 234
 			continue;
235 235
 		}
236 236
 
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 		// shorten that to /*\*/ and the next one to /**/
239 239
 		if (substr($token, (strlen($token) - 1), 1) === '\\') {
240 240
 			$this->preserved_tokens[] = '\\';
241
-			$css = preg_replace($placeholder,  self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
241
+			$css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
242 242
 			$i = $i + 1; // attn: advancing the loop
243 243
 			$this->preserved_tokens[] = '';
244
-			$css = preg_replace('/' . self::COMMENT . $i . '___/',  self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
244
+			$css = preg_replace('/' . self::COMMENT . $i . '___/', self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
245 245
 			continue;
246 246
 		}
247 247
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			if ($start_index > 2) {
253 253
 				if (substr($css, $start_index - 3, 1) === '>') {
254 254
 					$this->preserved_tokens[] = '';
255
-					$css = preg_replace($placeholder,  self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
255
+					$css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
256 256
 				}
257 257
 			}
258 258
 		}
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 					$css = preg_replace('/;;+/', ';', $css);
367 367
 
368 368
 					// Restore new lines for /*! important comments
369
-					$css = preg_replace('/'. self::NL .'/', "\n", $css);
369
+					$css = preg_replace('/' . self::NL . '/', "\n", $css);
370 370
 
371 371
 					// restore preserved comments and strings
372 372
 					for ($i = 0, $max = count($this->preserved_tokens); $i < $max; $i++) {
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 			$terminator = ')';
411 411
 		}
412 412
 
413
-		while ($found_terminator === FALSE && $end_index+1 <= $max_index) {
413
+		while ($found_terminator === FALSE && $end_index + 1 <= $max_index) {
414 414
 			$end_index = $this->index_of($css, $terminator, $end_index + 1);
415 415
 
416 416
 			// endIndex == 0 doesn't really apply here
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 			private function rgb_to_hex($matches)
555 555
 			{
556 556
 			// Support for percentage values rgb(100%, 0%, 45%);
557
-			if ($this->index_of($matches[1], '%') >= 0){
557
+			if ($this->index_of($matches[1], '%') >= 0) {
558 558
 				$rgbcolors = explode(',', str_replace('%', '', $matches[1]));
559 559
 				for ($i = 0; $i < count($rgbcolors); $i++) {
560 560
 					$rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55);
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 			}
571 571
 
572 572
 			// Fix for issue #2528093
573
-			if (!preg_match('/[\s\,\);\}]/', $matches[2])){
573
+			if (!preg_match('/[\s\,\);\}]/', $matches[2])) {
574 574
 				$matches[2] = ' ' . $matches[2];
575 575
 			}
576 576
 
@@ -594,12 +594,12 @@  discard block
 block discarded – undo
594 594
 	} else {
595 595
 		$v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l);
596 596
 		$v1 = (2 * $l) - $v2;
597
-		$r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1/3)));
597
+		$r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1 / 3)));
598 598
 		$g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h));
599
-		$b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1/3)));
599
+		$b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1 / 3)));
600 600
 	}
601 601
 
602
-	return $this->rgb_to_hex(array('', $r.','.$g.','.$b, $matches[2]));
602
+	return $this->rgb_to_hex(array('', $r . ',' . $g . ',' . $b, $matches[2]));
603 603
 }
604 604
 
605 605
 /* HELPERS
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
612 612
 	if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh;
613 613
 	if ($vh * 2 < 1) return $v2;
614
-	if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
614
+	if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2 / 3) - $vh) * 6;
615 615
 	return $v1;
616 616
 }
617 617
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -609,9 +609,15 @@
 block discarded – undo
609 609
 private function hue_to_rgb($v1, $v2, $vh)
610 610
 {
611 611
 	$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
612
-	if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh;
613
-	if ($vh * 2 < 1) return $v2;
614
-	if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
612
+	if ($vh * 6 < 1) {
613
+		return $v1 + ($v2 - $v1) * 6 * $vh;
614
+	}
615
+	if ($vh * 2 < 1) {
616
+		return $v2;
617
+	}
618
+	if ($vh * 3 < 2) {
619
+		return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
620
+	}
615 621
 	return $v1;
616 622
 }
617 623
 
Please login to merge, or discard this patch.
tools/minify/jsminplus/jsminplus.php 4 patches
Doc Comments   +35 added lines patch added patch discarded remove patch
@@ -114,6 +114,9 @@  discard block
 block discarded – undo
114 114
 		$this->parser = new JSParser();
115 115
 	}
116 116
 
117
+	/**
118
+	 * @return string
119
+	 */
117 120
 	public static function minify($js, $filename='')
118 121
 	{
119 122
 		static $instance;
@@ -125,6 +128,9 @@  discard block
 block discarded – undo
125 128
 		return $instance->min($js, $filename);
126 129
 	}
127 130
 
131
+	/**
132
+	 * @param string $filename
133
+	 */
128 134
 	private function min($js, $filename)
129 135
 	{
130 136
 		try
@@ -140,6 +146,9 @@  discard block
 block discarded – undo
140 146
 		return false;
141 147
 	}
142 148
 
149
+	/**
150
+	 * @param JSNode $n
151
+	 */
143 152
 	private function parseTree($n, $noBlockGrouping = false)
144 153
 	{
145 154
 		$s = '';
@@ -545,6 +554,9 @@  discard block
 block discarded – undo
545 554
 		return $s;
546 555
 	}
547 556
 
557
+	/**
558
+	 * @param string $string
559
+	 */
548 560
 	private function isValidIdentifier($string)
549 561
 	{
550 562
 		return preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $string) && !in_array($string, $this->reserved);
@@ -608,6 +620,9 @@  discard block
 block discarded – undo
608 620
 		$this->t = new JSTokenizer();
609 621
 	}
610 622
 
623
+	/**
624
+	 * @param integer $l
625
+	 */
611 626
 	public function parse($s, $f, $l)
612 627
 	{
613 628
 		// initialize tokenizer
@@ -621,6 +636,9 @@  discard block
 block discarded – undo
621 636
 		return $n;
622 637
 	}
623 638
 
639
+	/**
640
+	 * @param JSCompilerContext $x
641
+	 */
624 642
 	private function Script($x)
625 643
 	{
626 644
 		$n = $this->Statements($x);
@@ -971,6 +989,10 @@  discard block
 block discarded – undo
971 989
 		return $n;
972 990
 	}
973 991
 
992
+	/**
993
+	 * @param boolean $requireName
994
+	 * @param integer $functionForm
995
+	 */
974 996
 	private function FunctionDefinition($x, $requireName, $functionForm)
975 997
 	{
976 998
 		$f = new JSNode($this->t);
@@ -1437,6 +1459,10 @@  discard block
 block discarded – undo
1437 1459
 	}
1438 1460
 
1439 1461
 	// Statement stack and nested statement handler.
1462
+
1463
+	/**
1464
+	 * @param JSNode $node
1465
+	 */
1440 1466
 	private function nest($x, $node, $end = false)
1441 1467
 	{
1442 1468
 		array_push($x->stmtStack, $node);
@@ -1501,6 +1527,9 @@  discard block
 block discarded – undo
1501 1527
 	public $funDecls = array();
1502 1528
 	public $varDecls = array();
1503 1529
 
1530
+	/**
1531
+	 * @param boolean $inFunction
1532
+	 */
1504 1533
 	public function __construct($inFunction)
1505 1534
 	{
1506 1535
 		$this->inFunction = $inFunction;
@@ -1519,6 +1548,9 @@  discard block
 block discarded – undo
1519 1548
 	public $funDecls = array();
1520 1549
 	public $varDecls = array();
1521 1550
 
1551
+	/**
1552
+	 * @param JSTokenizer $t
1553
+	 */
1522 1554
 	public function __construct($t, $type=0)
1523 1555
 	{
1524 1556
 		if ($token = $t->currentToken())
@@ -1673,6 +1705,9 @@  discard block
 block discarded – undo
1673 1705
 		$this->scanOperand = true;
1674 1706
 	}
1675 1707
 
1708
+	/**
1709
+	 * @param integer|null $chunksize
1710
+	 */
1676 1711
 	public function getInput($chunksize)
1677 1712
 	{
1678 1713
 		if ($chunksize)
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -786,10 +786,10 @@  discard block
 block discarded – undo
786 786
 			return $n;
787 787
 
788 788
 			case KEYWORD_WHILE:
789
-			        $n = new JSNode($this->t);
790
-			        $n->isLoop = true;
791
-			        $n->condition = $this->ParenExpression($x);
792
-			        $n->body = $this->nest($x, $n);
789
+					$n = new JSNode($this->t);
790
+					$n->isLoop = true;
791
+					$n->condition = $this->ParenExpression($x);
792
+					$n->body = $this->nest($x, $n);
793 793
 			return $n;
794 794
 
795 795
 			case KEYWORD_DO:
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 
910 910
 			case KEYWORD_VAR:
911 911
 			case KEYWORD_CONST:
912
-			        $n = $this->Variables($x);
912
+					$n = $this->Variables($x);
913 913
 			break;
914 914
 
915 915
 			case TOKEN_CONDCOMMENT_START:
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
 
1694 1694
 	public function mustMatch($tt)
1695 1695
 	{
1696
-	        if (!$this->match($tt))
1696
+			if (!$this->match($tt))
1697 1697
 			throw $this->newSyntaxError('Unexpected token; token ' . $tt . ' expected');
1698 1698
 
1699 1699
 		return $this->currentToken();
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 		$this->parser = new JSParser();
115 115
 	}
116 116
 
117
-	public static function minify($js, $filename='')
117
+	public static function minify($js, $filename = '')
118 118
 	{
119 119
 		static $instance;
120 120
 
121 121
 		// this is a singleton
122
-		if(!$instance)
122
+		if (!$instance)
123 123
 			$instance = new JSMinPlus();
124 124
 
125 125
 		return $instance->min($js, $filename);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			$n = $this->parser->parse($js, $filename, 1);
133 133
 			return $this->parseTree($n);
134 134
 		}
135
-		catch(Exception $e)
135
+		catch (Exception $e)
136 136
 		{
137 137
 			echo $e->getMessage() . "\n";
138 138
 		}
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 					$t = $this->parseTree($n->value);
319 319
 					if (strlen($t))
320 320
 					{
321
-						if (	$t[0] != '(' && $t[0] != '[' && $t[0] != '{' &&
321
+						if ($t[0] != '(' && $t[0] != '[' && $t[0] != '{' &&
322 322
 							$t[0] != '"' && $t[0] != "'" && $t[0] != '/'
323 323
 						)
324 324
 							$s .= ' ';
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 			case JS_INDEX:
463 463
 				$s = $this->parseTree($n->treeNodes[0]);
464 464
 				// See if we can replace named index with a dot saving 3 bytes
465
-				if (	$n->treeNodes[0]->type == TOKEN_IDENTIFIER &&
465
+				if ($n->treeNodes[0]->type == TOKEN_IDENTIFIER &&
466 466
 					$n->treeNodes[1]->type == TOKEN_STRING &&
467 467
 					$this->isValidIdentifier(substr($n->treeNodes[1]->value, 1, -1))
468 468
 				)
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 					if ($t->type == JS_PROPERTY_INIT)
508 508
 					{
509 509
 						// Ditch the quotes when the index is a valid identifier
510
-						if (	$t->treeNodes[0]->type == TOKEN_STRING &&
510
+						if ($t->treeNodes[0]->type == TOKEN_STRING &&
511 511
 							$this->isValidIdentifier(substr($t->treeNodes[0]->value, 1, -1))
512 512
 						)
513 513
 							$s .= substr($t->treeNodes[0]->value, 1, -1);
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		return $n;
1042 1042
 	}
1043 1043
 
1044
-	private function Expression($x, $stop=false)
1044
+	private function Expression($x, $stop = false)
1045 1045
 	{
1046 1046
 		$operators = array();
1047 1047
 		$operands = array();
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 					if ($this->t->scanOperand)
1077 1077
 						break 2;
1078 1078
 
1079
-					while (	!empty($operators) &&
1079
+					while (!empty($operators) &&
1080 1080
 						$this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]
1081 1081
 					)
1082 1082
 						$this->reduce($operators, $operands);
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 						break 2;
1107 1107
 
1108 1108
 					// Use >, not >=, for right-associative ASSIGN
1109
-					while (	!empty($operators) &&
1109
+					while (!empty($operators) &&
1110 1110
 						$this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]
1111 1111
 					)
1112 1112
 						$this->reduce($operators, $operands);
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 					if ($this->t->scanOperand)
1153 1153
 						break 2;
1154 1154
 
1155
-					while (	!empty($operators) &&
1155
+					while (!empty($operators) &&
1156 1156
 						$this->opPrecedence[end($operators)->type] >= $this->opPrecedence[$tt]
1157 1157
 					)
1158 1158
 						$this->reduce($operators, $operands);
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 				case OP_INCREMENT: case OP_DECREMENT:
1182 1182
 					if ($this->t->scanOperand)
1183 1183
 					{
1184
-						array_push($operators, new JSNode($this->t));  // prefix increment or decrement
1184
+						array_push($operators, new JSNode($this->t)); // prefix increment or decrement
1185 1185
 					}
1186 1186
 					else
1187 1187
 					{
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 					}
1339 1339
 					else
1340 1340
 					{
1341
-						while (	!empty($operators) &&
1341
+						while (!empty($operators) &&
1342 1342
 							$this->opPrecedence[end($operators)->type] > $this->opPrecedence[KEYWORD_NEW]
1343 1343
 						)
1344 1344
 							$this->reduce($operators, $operands);
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
 	public $funDecls = array();
1520 1520
 	public $varDecls = array();
1521 1521
 
1522
-	public function __construct($t, $type=0)
1522
+	public function __construct($t, $type = 0)
1523 1523
 	{
1524 1524
 		if ($token = $t->currentToken())
1525 1525
 		{
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
 
1538 1538
 		if (($numargs = func_num_args()) > 2)
1539 1539
 		{
1540
-			$args = func_get_args();;
1540
+			$args = func_get_args(); ;
1541 1541
 			for ($i = 2; $i < $numargs; $i++)
1542 1542
 				$this->addNode($args[$i]);
1543 1543
 		}
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
 
1736 1736
 	public function get($chunksize = 1000)
1737 1737
 	{
1738
-		while($this->lookahead)
1738
+		while ($this->lookahead)
1739 1739
 		{
1740 1740
 			$this->lookahead--;
1741 1741
 			$this->tokenIndex = ($this->tokenIndex + 1) & 3;
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
 		$conditional_comment = false;
1748 1748
 
1749 1749
 		// strip whitespace and comments
1750
-		while(true)
1750
+		while (true)
1751 1751
 		{
1752 1752
 			$input = $this->getInput($chunksize);
1753 1753
 
Please login to merge, or discard this patch.
Braces   +350 added lines, -274 removed lines patch added patch discarded remove patch
@@ -119,8 +119,9 @@  discard block
 block discarded – undo
119 119
 		static $instance;
120 120
 
121 121
 		// this is a singleton
122
-		if(!$instance)
123
-			$instance = new JSMinPlus();
122
+		if(!$instance) {
123
+					$instance = new JSMinPlus();
124
+		}
124 125
 
125 126
 		return $instance->min($js, $filename);
126 127
 	}
@@ -131,8 +132,7 @@  discard block
 block discarded – undo
131 132
 		{
132 133
 			$n = $this->parser->parse($js, $filename, 1);
133 134
 			return $this->parseTree($n);
134
-		}
135
-		catch(Exception $e)
135
+		} catch(Exception $e)
136 136
 		{
137 137
 			echo $e->getMessage() . "\n";
138 138
 		}
@@ -149,8 +149,9 @@  discard block
 block discarded – undo
149 149
 			case KEYWORD_FUNCTION:
150 150
 				$s .= 'function' . ($n->name ? ' ' . $n->name : '') . '(';
151 151
 				$params = $n->params;
152
-				for ($i = 0, $j = count($params); $i < $j; $i++)
153
-					$s .= ($i ? ',' : '') . $params[$i];
152
+				for ($i = 0, $j = count($params); $i < $j; $i++) {
153
+									$s .= ($i ? ',' : '') . $params[$i];
154
+				}
154 155
 				$s .= '){' . $this->parseTree($n->body, true) . '}';
155 156
 			break;
156 157
 
@@ -176,13 +177,11 @@  discard block
 block discarded – undo
176 177
 							{
177 178
 								// put declared functions on a new line
178 179
 								$s .= "\n";
179
-							}
180
-							elseif ($type == KEYWORD_VAR && $type == $lastType)
180
+							} elseif ($type == KEYWORD_VAR && $type == $lastType)
181 181
 							{
182 182
 								// mutiple var-statements can go into one
183 183
 								$t = ',' . substr($t, 4);
184
-							}
185
-							else
184
+							} else
186 185
 							{
187 186
 								// add terminator
188 187
 								$s .= ';';
@@ -208,24 +207,26 @@  discard block
 block discarded – undo
208 207
 				$elsePart = $n->elsePart ? $this->parseTree($n->elsePart) : null;
209 208
 
210 209
 				// empty if-statement
211
-				if ($thenPart == '')
212
-					$thenPart = ';';
210
+				if ($thenPart == '') {
211
+									$thenPart = ';';
212
+				}
213 213
 
214 214
 				if ($elsePart)
215 215
 				{
216 216
 					// be carefull and always make a block out of the thenPart; could be more optimized but is a lot of trouble
217
-					if ($thenPart != ';' && $thenPart[0] != '{')
218
-						$thenPart = '{' . $thenPart . '}';
217
+					if ($thenPart != ';' && $thenPart[0] != '{') {
218
+											$thenPart = '{' . $thenPart . '}';
219
+					}
219 220
 
220 221
 					$s .= $thenPart . 'else';
221 222
 
222 223
 					// we could check for more, but that hardly ever applies so go for performance
223
-					if ($elsePart[0] != '{')
224
-						$s .= ' ';
224
+					if ($elsePart[0] != '{') {
225
+											$s .= ' ';
226
+					}
225 227
 
226 228
 					$s .= $elsePart;
227
-				}
228
-				else
229
+				} else
229 230
 				{
230 231
 					$s .= $thenPart;
231 232
 				}
@@ -237,18 +238,20 @@  discard block
 block discarded – undo
237 238
 				for ($i = 0, $j = count($cases); $i < $j; $i++)
238 239
 				{
239 240
 					$case = $cases[$i];
240
-					if ($case->type == KEYWORD_CASE)
241
-						$s .= 'case' . ($case->caseLabel->type != TOKEN_STRING ? ' ' : '') . $this->parseTree($case->caseLabel) . ':';
242
-					else
243
-						$s .= 'default:';
241
+					if ($case->type == KEYWORD_CASE) {
242
+											$s .= 'case' . ($case->caseLabel->type != TOKEN_STRING ? ' ' : '') . $this->parseTree($case->caseLabel) . ':';
243
+					} else {
244
+											$s .= 'default:';
245
+					}
244 246
 
245 247
 					$statement = $this->parseTree($case->statements, true);
246 248
 					if ($statement)
247 249
 					{
248 250
 						$s .= $statement;
249 251
 						// no terminator for last statement
250
-						if ($i + 1 < $j)
251
-							$s .= ';';
252
+						if ($i + 1 < $j) {
253
+													$s .= ';';
254
+						}
252 255
 					}
253 256
 				}
254 257
 				$s .= '}';
@@ -260,8 +263,9 @@  discard block
 block discarded – undo
260 263
 					. ';' . ($n->update ? $this->parseTree($n->update) : '') . ')';
261 264
 
262 265
 				$body  = $this->parseTree($n->body);
263
-				if ($body == '')
264
-					$body = ';';
266
+				if ($body == '') {
267
+									$body = ';';
268
+				}
265 269
 
266 270
 				$s .= $body;
267 271
 			break;
@@ -270,8 +274,9 @@  discard block
 block discarded – undo
270 274
 				$s = 'while(' . $this->parseTree($n->condition) . ')';
271 275
 
272 276
 				$body  = $this->parseTree($n->body);
273
-				if ($body == '')
274
-					$body = ';';
277
+				if ($body == '') {
278
+									$body = ';';
279
+				}
275 280
 
276 281
 				$s .= $body;
277 282
 			break;
@@ -280,8 +285,9 @@  discard block
 block discarded – undo
280 285
 				$s = 'for(' . ($n->varDecl ? $this->parseTree($n->varDecl) : $this->parseTree($n->iterator)) . ' in ' . $this->parseTree($n->object) . ')';
281 286
 
282 287
 				$body  = $this->parseTree($n->body);
283
-				if ($body == '')
284
-					$body = ';';
288
+				if ($body == '') {
289
+									$body = ';';
290
+				}
285 291
 
286 292
 				$s .= $body;
287 293
 			break;
@@ -303,8 +309,9 @@  discard block
 block discarded – undo
303 309
 					$t = $catchClauses[$i];
304 310
 					$s .= 'catch(' . $t->varName . ($t->guard ? ' if ' . $this->parseTree($t->guard) : '') . '){' . $this->parseTree($t->block, true) . '}';
305 311
 				}
306
-				if ($n->finallyBlock)
307
-					$s .= 'finally{' . $this->parseTree($n->finallyBlock, true) . '}';
312
+				if ($n->finallyBlock) {
313
+									$s .= 'finally{' . $this->parseTree($n->finallyBlock, true) . '}';
314
+				}
308 315
 			break;
309 316
 
310 317
 			case KEYWORD_THROW:
@@ -320,8 +327,9 @@  discard block
 block discarded – undo
320 327
 					{
321 328
 						if (	$t[0] != '(' && $t[0] != '[' && $t[0] != '{' &&
322 329
 							$t[0] != '"' && $t[0] != "'" && $t[0] != '/'
323
-						)
324
-							$s .= ' ';
330
+						) {
331
+													$s .= ' ';
332
+						}
325 333
 
326 334
 						$s .= $t;
327 335
 					}
@@ -341,8 +349,9 @@  discard block
 block discarded – undo
341 349
 					$t = $childs[$i];
342 350
 					$s .= ($i ? ',' : '') . $t->name;
343 351
 					$u = $t->initializer;
344
-					if ($u)
345
-						$s .= '=' . $this->parseTree($u);
352
+					if ($u) {
353
+											$s .= '=' . $this->parseTree($u);
354
+					}
346 355
 				}
347 356
 			break;
348 357
 
@@ -354,13 +363,15 @@  discard block
 block discarded – undo
354 363
 			case TOKEN_CONDCOMMENT_END:
355 364
 				$s = $n->value . ($n->type == TOKEN_CONDCOMMENT_START ? ' ' : '');
356 365
 				$childs = $n->treeNodes;
357
-				for ($i = 0, $j = count($childs); $i < $j; $i++)
358
-					$s .= $this->parseTree($childs[$i]);
366
+				for ($i = 0, $j = count($childs); $i < $j; $i++) {
367
+									$s .= $this->parseTree($childs[$i]);
368
+				}
359 369
 			break;
360 370
 
361 371
 			case OP_SEMICOLON:
362
-				if ($expression = $n->expression)
363
-					$s = $this->parseTree($expression);
372
+				if ($expression = $n->expression) {
373
+									$s = $this->parseTree($expression);
374
+				}
364 375
 			break;
365 376
 
366 377
 			case JS_LABEL:
@@ -369,8 +380,9 @@  discard block
 block discarded – undo
369 380
 
370 381
 			case OP_COMMA:
371 382
 				$childs = $n->treeNodes;
372
-				for ($i = 0, $j = count($childs); $i < $j; $i++)
373
-					$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
383
+				for ($i = 0, $j = count($childs); $i < $j; $i++) {
384
+									$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
385
+				}
374 386
 			break;
375 387
 
376 388
 			case OP_ASSIGN:
@@ -449,10 +461,11 @@  discard block
 block discarded – undo
449 461
 
450 462
 			case OP_INCREMENT:
451 463
 			case OP_DECREMENT:
452
-				if ($n->postfix)
453
-					$s = $this->parseTree($n->treeNodes[0]) . $n->value;
454
-				else
455
-					$s = $n->value . $this->parseTree($n->treeNodes[0]);
464
+				if ($n->postfix) {
465
+									$s = $this->parseTree($n->treeNodes[0]) . $n->value;
466
+				} else {
467
+									$s = $n->value . $this->parseTree($n->treeNodes[0]);
468
+				}
456 469
 			break;
457 470
 
458 471
 			case OP_DOT:
@@ -465,16 +478,18 @@  discard block
 block discarded – undo
465 478
 				if (	$n->treeNodes[0]->type == TOKEN_IDENTIFIER &&
466 479
 					$n->treeNodes[1]->type == TOKEN_STRING &&
467 480
 					$this->isValidIdentifier(substr($n->treeNodes[1]->value, 1, -1))
468
-				)
469
-					$s .= '.' . substr($n->treeNodes[1]->value, 1, -1);
470
-				else
471
-					$s .= '[' . $this->parseTree($n->treeNodes[1]) . ']';
481
+				) {
482
+									$s .= '.' . substr($n->treeNodes[1]->value, 1, -1);
483
+				} else {
484
+									$s .= '[' . $this->parseTree($n->treeNodes[1]) . ']';
485
+				}
472 486
 			break;
473 487
 
474 488
 			case JS_LIST:
475 489
 				$childs = $n->treeNodes;
476
-				for ($i = 0, $j = count($childs); $i < $j; $i++)
477
-					$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
490
+				for ($i = 0, $j = count($childs); $i < $j; $i++) {
491
+									$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
492
+				}
478 493
 			break;
479 494
 
480 495
 			case JS_CALL:
@@ -502,27 +517,29 @@  discard block
 block discarded – undo
502 517
 				for ($i = 0, $j = count($childs); $i < $j; $i++)
503 518
 				{
504 519
 					$t = $childs[$i];
505
-					if ($i)
506
-						$s .= ',';
520
+					if ($i) {
521
+											$s .= ',';
522
+					}
507 523
 					if ($t->type == JS_PROPERTY_INIT)
508 524
 					{
509 525
 						// Ditch the quotes when the index is a valid identifier
510 526
 						if (	$t->treeNodes[0]->type == TOKEN_STRING &&
511 527
 							$this->isValidIdentifier(substr($t->treeNodes[0]->value, 1, -1))
512
-						)
513
-							$s .= substr($t->treeNodes[0]->value, 1, -1);
514
-						else
515
-							$s .= $t->treeNodes[0]->value;
528
+						) {
529
+													$s .= substr($t->treeNodes[0]->value, 1, -1);
530
+						} else {
531
+													$s .= $t->treeNodes[0]->value;
532
+						}
516 533
 
517 534
 						$s .= ':' . $this->parseTree($t->treeNodes[1]);
518
-					}
519
-					else
535
+					} else
520 536
 					{
521 537
 						$s .= $t->type == JS_GETTER ? 'get' : 'set';
522 538
 						$s .= ' ' . $t->name . '(';
523 539
 						$params = $t->params;
524
-						for ($i = 0, $j = count($params); $i < $j; $i++)
525
-							$s .= ($i ? ',' : '') . $params[$i];
540
+						for ($i = 0, $j = count($params); $i < $j; $i++) {
541
+													$s .= ($i ? ',' : '') . $params[$i];
542
+						}
526 543
 						$s .= '){' . $this->parseTree($t->body, true) . '}';
527 544
 					}
528 545
 				}
@@ -615,8 +632,9 @@  discard block
 block discarded – undo
615 632
 
616 633
 		$x = new JSCompilerContext(false);
617 634
 		$n = $this->Script($x);
618
-		if (!$this->t->isDone())
619
-			throw $this->t->newSyntaxError('Syntax error');
635
+		if (!$this->t->isDone()) {
636
+					throw $this->t->newSyntaxError('Syntax error');
637
+		}
620 638
 
621 639
 		return $n;
622 640
 	}
@@ -636,8 +654,9 @@  discard block
 block discarded – undo
636 654
 		$n = new JSNode($this->t, JS_BLOCK);
637 655
 		array_push($x->stmtStack, $n);
638 656
 
639
-		while (!$this->t->isDone() && $this->t->peek() != OP_RIGHT_CURLY)
640
-			$n->addNode($this->Statement($x));
657
+		while (!$this->t->isDone() && $this->t->peek() != OP_RIGHT_CURLY) {
658
+					$n->addNode($this->Statement($x));
659
+		}
641 660
 
642 661
 		array_pop($x->stmtStack);
643 662
 
@@ -701,15 +720,17 @@  discard block
 block discarded – undo
701 720
 					switch ($tt)
702 721
 					{
703 722
 						case KEYWORD_DEFAULT:
704
-							if ($n->defaultIndex >= 0)
705
-								throw $this->t->newSyntaxError('More than one switch default');
723
+							if ($n->defaultIndex >= 0) {
724
+															throw $this->t->newSyntaxError('More than one switch default');
725
+							}
706 726
 							// FALL THROUGH
707 727
 						case KEYWORD_CASE:
708 728
 							$n2 = new JSNode($this->t);
709
-							if ($tt == KEYWORD_DEFAULT)
710
-								$n->defaultIndex = count($n->cases);
711
-							else
712
-								$n2->caseLabel = $this->Expression($x, OP_COLON);
729
+							if ($tt == KEYWORD_DEFAULT) {
730
+															$n->defaultIndex = count($n->cases);
731
+							} else {
732
+															$n2->caseLabel = $this->Expression($x, OP_COLON);
733
+							}
713 734
 								break;
714 735
 						default:
715 736
 							throw $this->t->newSyntaxError('Invalid switch case');
@@ -717,8 +738,9 @@  discard block
 block discarded – undo
717 738
 
718 739
 					$this->t->mustMatch(OP_COLON);
719 740
 					$n2->statements = new JSNode($this->t, JS_BLOCK);
720
-					while (($tt = $this->t->peek()) != KEYWORD_CASE && $tt != KEYWORD_DEFAULT && $tt != OP_RIGHT_CURLY)
721
-						$n2->statements->addNode($this->Statement($x));
741
+					while (($tt = $this->t->peek()) != KEYWORD_CASE && $tt != KEYWORD_DEFAULT && $tt != OP_RIGHT_CURLY) {
742
+											$n2->statements->addNode($this->Statement($x));
743
+					}
722 744
 
723 745
 					array_push($n->cases, $n2);
724 746
 				}
@@ -738,8 +760,7 @@  discard block
 block discarded – undo
738 760
 					{
739 761
 						$this->t->get();
740 762
 						$n2 = $this->Variables($x);
741
-					}
742
-					else
763
+					} else
743 764
 					{
744 765
 						$n2 = $this->Expression($x);
745 766
 					}
@@ -763,16 +784,14 @@  discard block
 block discarded – undo
763 784
 						// NB: n2[0].type == IDENTIFIER and n2[0].value == n2[0].name.
764 785
 						$n->iterator = $n2->treeNodes[0];
765 786
 						$n->varDecl = $n2;
766
-					}
767
-					else
787
+					} else
768 788
 					{
769 789
 						$n->iterator = $n2;
770 790
 						$n->varDecl = null;
771 791
 					}
772 792
 
773 793
 					$n->object = $this->Expression($x);
774
-				}
775
-				else
794
+				} else
776 795
 				{
777 796
 					$n->setup = $n2 ? $n2 : null;
778 797
 					$this->t->mustMatch(OP_SEMICOLON);
@@ -824,17 +843,18 @@  discard block
 block discarded – undo
824 843
 				{
825 844
 					do
826 845
 					{
827
-						if (--$i < 0)
828
-							throw $this->t->newSyntaxError('Label not found');
846
+						if (--$i < 0) {
847
+													throw $this->t->newSyntaxError('Label not found');
848
+						}
829 849
 					}
830 850
 					while ($ss[$i]->label != $label);
831
-				}
832
-				else
851
+				} else
833 852
 				{
834 853
 					do
835 854
 					{
836
-						if (--$i < 0)
837
-							throw $this->t->newSyntaxError('Invalid ' . $tt);
855
+						if (--$i < 0) {
856
+													throw $this->t->newSyntaxError('Invalid ' . $tt);
857
+						}
838 858
 					}
839 859
 					while (!$ss[$i]->isLoop && ($tt != KEYWORD_BREAK || $ss[$i]->type != KEYWORD_SWITCH));
840 860
 				}
@@ -855,15 +875,16 @@  discard block
 block discarded – undo
855 875
 
856 876
 					if ($this->t->match(KEYWORD_IF))
857 877
 					{
858
-						if ($x->ecmaStrictMode)
859
-							throw $this->t->newSyntaxError('Illegal catch guard');
878
+						if ($x->ecmaStrictMode) {
879
+													throw $this->t->newSyntaxError('Illegal catch guard');
880
+						}
860 881
 
861
-						if (count($n->catchClauses) && !end($n->catchClauses)->guard)
862
-							throw $this->t->newSyntaxError('Guarded catch after unguarded');
882
+						if (count($n->catchClauses) && !end($n->catchClauses)->guard) {
883
+													throw $this->t->newSyntaxError('Guarded catch after unguarded');
884
+						}
863 885
 
864 886
 						$n2->guard = $this->Expression($x);
865
-					}
866
-					else
887
+					} else
867 888
 					{
868 889
 						$n2->guard = null;
869 890
 					}
@@ -873,11 +894,13 @@  discard block
 block discarded – undo
873 894
 					array_push($n->catchClauses, $n2);
874 895
 				}
875 896
 
876
-				if ($this->t->match(KEYWORD_FINALLY))
877
-					$n->finallyBlock = $this->Block($x);
897
+				if ($this->t->match(KEYWORD_FINALLY)) {
898
+									$n->finallyBlock = $this->Block($x);
899
+				}
878 900
 
879
-				if (!count($n->catchClauses) && !$n->finallyBlock)
880
-					throw $this->t->newSyntaxError('Invalid try statement');
901
+				if (!count($n->catchClauses) && !$n->finallyBlock) {
902
+									throw $this->t->newSyntaxError('Invalid try statement');
903
+				}
881 904
 			return $n;
882 905
 
883 906
 			case KEYWORD_CATCH:
@@ -890,15 +913,17 @@  discard block
 block discarded – undo
890 913
 			break;
891 914
 
892 915
 			case KEYWORD_RETURN:
893
-				if (!$x->inFunction)
894
-					throw $this->t->newSyntaxError('Invalid return');
916
+				if (!$x->inFunction) {
917
+									throw $this->t->newSyntaxError('Invalid return');
918
+				}
895 919
 
896 920
 				$n = new JSNode($this->t);
897 921
 				$tt = $this->t->peekOnSameLine();
898
-				if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY)
899
-					$n->value = $this->Expression($x);
900
-				else
901
-					$n->value = null;
922
+				if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY) {
923
+									$n->value = $this->Expression($x);
924
+				} else {
925
+									$n->value = null;
926
+				}
902 927
 			break;
903 928
 
904 929
 			case KEYWORD_WITH:
@@ -939,8 +964,9 @@  discard block
 block discarded – undo
939 964
 						$ss = $x->stmtStack;
940 965
 						for ($i = count($ss) - 1; $i >= 0; --$i)
941 966
 						{
942
-							if ($ss[$i]->label == $label)
943
-								throw $this->t->newSyntaxError('Duplicate label');
967
+							if ($ss[$i]->label == $label) {
968
+															throw $this->t->newSyntaxError('Duplicate label');
969
+							}
944 970
 						}
945 971
 
946 972
 						$this->t->get();
@@ -962,8 +988,9 @@  discard block
 block discarded – undo
962 988
 		if ($this->t->lineno == $this->t->currentToken()->lineno)
963 989
 		{
964 990
 			$tt = $this->t->peekOnSameLine();
965
-			if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY)
966
-				throw $this->t->newSyntaxError('Missing ; before statement');
991
+			if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY) {
992
+							throw $this->t->newSyntaxError('Missing ; before statement');
993
+			}
967 994
 		}
968 995
 
969 996
 		$this->t->match(OP_SEMICOLON);
@@ -975,26 +1002,30 @@  discard block
 block discarded – undo
975 1002
 	{
976 1003
 		$f = new JSNode($this->t);
977 1004
 
978
-		if ($f->type != KEYWORD_FUNCTION)
979
-			$f->type = ($f->value == 'get') ? JS_GETTER : JS_SETTER;
1005
+		if ($f->type != KEYWORD_FUNCTION) {
1006
+					$f->type = ($f->value == 'get') ? JS_GETTER : JS_SETTER;
1007
+		}
980 1008
 
981
-		if ($this->t->match(TOKEN_IDENTIFIER))
982
-			$f->name = $this->t->currentToken()->value;
983
-		elseif ($requireName)
984
-			throw $this->t->newSyntaxError('Missing function identifier');
1009
+		if ($this->t->match(TOKEN_IDENTIFIER)) {
1010
+					$f->name = $this->t->currentToken()->value;
1011
+		} elseif ($requireName) {
1012
+					throw $this->t->newSyntaxError('Missing function identifier');
1013
+		}
985 1014
 
986 1015
 		$this->t->mustMatch(OP_LEFT_PAREN);
987 1016
 			$f->params = array();
988 1017
 
989 1018
 		while (($tt = $this->t->get()) != OP_RIGHT_PAREN)
990 1019
 		{
991
-			if ($tt != TOKEN_IDENTIFIER)
992
-				throw $this->t->newSyntaxError('Missing formal parameter');
1020
+			if ($tt != TOKEN_IDENTIFIER) {
1021
+							throw $this->t->newSyntaxError('Missing formal parameter');
1022
+			}
993 1023
 
994 1024
 			array_push($f->params, $this->t->currentToken()->value);
995 1025
 
996
-			if ($this->t->peek() != OP_RIGHT_PAREN)
997
-				$this->t->mustMatch(OP_COMMA);
1026
+			if ($this->t->peek() != OP_RIGHT_PAREN) {
1027
+							$this->t->mustMatch(OP_COMMA);
1028
+			}
998 1029
 		}
999 1030
 
1000 1031
 		$this->t->mustMatch(OP_LEFT_CURLY);
@@ -1006,8 +1037,9 @@  discard block
 block discarded – undo
1006 1037
 		$f->end = $this->t->currentToken()->end;
1007 1038
 
1008 1039
 		$f->functionForm = $functionForm;
1009
-		if ($functionForm == DECLARED_FORM)
1010
-			array_push($x->funDecls, $f);
1040
+		if ($functionForm == DECLARED_FORM) {
1041
+					array_push($x->funDecls, $f);
1042
+		}
1011 1043
 
1012 1044
 		return $f;
1013 1045
 	}
@@ -1025,8 +1057,9 @@  discard block
 block discarded – undo
1025 1057
 
1026 1058
 			if ($this->t->match(OP_ASSIGN))
1027 1059
 			{
1028
-				if ($this->t->currentToken()->assignOp)
1029
-					throw $this->t->newSyntaxError('Invalid variable initialization');
1060
+				if ($this->t->currentToken()->assignOp) {
1061
+									throw $this->t->newSyntaxError('Invalid variable initialization');
1062
+				}
1030 1063
 
1031 1064
 				$n2->initializer = $this->Expression($x, OP_COMMA);
1032 1065
 			}
@@ -1073,13 +1106,15 @@  discard block
 block discarded – undo
1073 1106
 					break 2;
1074 1107
 
1075 1108
 				case OP_HOOK:
1076
-					if ($this->t->scanOperand)
1077
-						break 2;
1109
+					if ($this->t->scanOperand) {
1110
+											break 2;
1111
+					}
1078 1112
 
1079 1113
 					while (	!empty($operators) &&
1080 1114
 						$this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]
1081
-					)
1082
-						$this->reduce($operators, $operands);
1115
+					) {
1116
+											$this->reduce($operators, $operands);
1117
+					}
1083 1118
 
1084 1119
 					array_push($operators, new JSNode($this->t));
1085 1120
 
@@ -1087,29 +1122,33 @@  discard block
 block discarded – undo
1087 1122
 					$this->t->scanOperand = true;
1088 1123
 					$n = $this->Expression($x);
1089 1124
 
1090
-					if (!$this->t->match(OP_COLON))
1091
-						break 2;
1125
+					if (!$this->t->match(OP_COLON)) {
1126
+											break 2;
1127
+					}
1092 1128
 
1093 1129
 					--$x->hookLevel;
1094 1130
 					array_push($operands, $n);
1095 1131
 				break;
1096 1132
 
1097 1133
 				case OP_COLON:
1098
-					if ($x->hookLevel)
1099
-						break 2;
1134
+					if ($x->hookLevel) {
1135
+											break 2;
1136
+					}
1100 1137
 
1101 1138
 					throw $this->t->newSyntaxError('Invalid label');
1102 1139
 				break;
1103 1140
 
1104 1141
 				case OP_ASSIGN:
1105
-					if ($this->t->scanOperand)
1106
-						break 2;
1142
+					if ($this->t->scanOperand) {
1143
+											break 2;
1144
+					}
1107 1145
 
1108 1146
 					// Use >, not >=, for right-associative ASSIGN
1109 1147
 					while (	!empty($operators) &&
1110 1148
 						$this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]
1111
-					)
1112
-						$this->reduce($operators, $operands);
1149
+					) {
1150
+											$this->reduce($operators, $operands);
1151
+					}
1113 1152
 
1114 1153
 					array_push($operators, new JSNode($this->t));
1115 1154
 					end($operands)->assignOp = $this->t->currentToken()->assignOp;
@@ -1123,8 +1162,9 @@  discard block
 block discarded – undo
1123 1162
 					if ($x->inForLoopInit && !$x->hookLevel &&
1124 1163
 						!$x->bracketLevel && !$x->curlyLevel &&
1125 1164
 						!$x->parenLevel
1126
-					)
1127
-						break 2;
1165
+					) {
1166
+											break 2;
1167
+					}
1128 1168
 				// FALL THROUGH
1129 1169
 				case OP_COMMA:
1130 1170
 					// A comma operator should not be parsed if we're parsing the then part
@@ -1132,8 +1172,9 @@  discard block
 block discarded – undo
1132 1172
 					if ($tt == OP_COMMA && $x->hookLevel &&
1133 1173
 						!$x->bracketLevel && !$x->curlyLevel &&
1134 1174
 						!$x->parenLevel
1135
-					)
1136
-						break 2;
1175
+					) {
1176
+											break 2;
1177
+					}
1137 1178
 				// Treat comma as left-associative so reduce can fold left-heavy
1138 1179
 				// COMMA trees into a single array.
1139 1180
 				// FALL THROUGH
@@ -1149,20 +1190,21 @@  discard block
 block discarded – undo
1149 1190
 				case OP_PLUS: case OP_MINUS:
1150 1191
 				case OP_MUL: case OP_DIV: case OP_MOD:
1151 1192
 				case OP_DOT:
1152
-					if ($this->t->scanOperand)
1153
-						break 2;
1193
+					if ($this->t->scanOperand) {
1194
+											break 2;
1195
+					}
1154 1196
 
1155 1197
 					while (	!empty($operators) &&
1156 1198
 						$this->opPrecedence[end($operators)->type] >= $this->opPrecedence[$tt]
1157
-					)
1158
-						$this->reduce($operators, $operands);
1199
+					) {
1200
+											$this->reduce($operators, $operands);
1201
+					}
1159 1202
 
1160 1203
 					if ($tt == OP_DOT)
1161 1204
 					{
1162 1205
 						$this->t->mustMatch(TOKEN_IDENTIFIER);
1163 1206
 						array_push($operands, new JSNode($this->t, OP_DOT, array_pop($operands), new JSNode($this->t)));
1164
-					}
1165
-					else
1207
+					} else
1166 1208
 					{
1167 1209
 						array_push($operators, new JSNode($this->t));
1168 1210
 						$this->t->scanOperand = true;
@@ -1172,8 +1214,9 @@  discard block
 block discarded – undo
1172 1214
 				case KEYWORD_DELETE: case KEYWORD_VOID: case KEYWORD_TYPEOF:
1173 1215
 				case OP_NOT: case OP_BITWISE_NOT: case OP_UNARY_PLUS: case OP_UNARY_MINUS:
1174 1216
 				case KEYWORD_NEW:
1175
-					if (!$this->t->scanOperand)
1176
-						break 2;
1217
+					if (!$this->t->scanOperand) {
1218
+											break 2;
1219
+					}
1177 1220
 
1178 1221
 					array_push($operators, new JSNode($this->t));
1179 1222
 				break;
@@ -1182,19 +1225,20 @@  discard block
 block discarded – undo
1182 1225
 					if ($this->t->scanOperand)
1183 1226
 					{
1184 1227
 						array_push($operators, new JSNode($this->t));  // prefix increment or decrement
1185
-					}
1186
-					else
1228
+					} else
1187 1229
 					{
1188 1230
 						// Don't cross a line boundary for postfix {in,de}crement.
1189 1231
 						$t = $this->t->tokens[($this->t->tokenIndex + $this->t->lookahead - 1) & 3];
1190
-						if ($t && $t->lineno != $this->t->lineno)
1191
-							break 2;
1232
+						if ($t && $t->lineno != $this->t->lineno) {
1233
+													break 2;
1234
+						}
1192 1235
 
1193 1236
 						if (!empty($operators))
1194 1237
 						{
1195 1238
 							// Use >, not >=, so postfix has higher precedence than prefix.
1196
-							while ($this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt])
1197
-								$this->reduce($operators, $operands);
1239
+							while ($this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]) {
1240
+															$this->reduce($operators, $operands);
1241
+							}
1198 1242
 						}
1199 1243
 
1200 1244
 						$n = new JSNode($this->t, $tt, array_pop($operands));
@@ -1204,8 +1248,9 @@  discard block
 block discarded – undo
1204 1248
 				break;
1205 1249
 
1206 1250
 				case KEYWORD_FUNCTION:
1207
-					if (!$this->t->scanOperand)
1208
-						break 2;
1251
+					if (!$this->t->scanOperand) {
1252
+											break 2;
1253
+					}
1209 1254
 
1210 1255
 					array_push($operands, $this->FunctionDefinition($x, false, EXPRESSED_FORM));
1211 1256
 					$this->t->scanOperand = false;
@@ -1213,8 +1258,9 @@  discard block
 block discarded – undo
1213 1258
 
1214 1259
 				case KEYWORD_NULL: case KEYWORD_THIS: case KEYWORD_TRUE: case KEYWORD_FALSE:
1215 1260
 				case TOKEN_IDENTIFIER: case TOKEN_NUMBER: case TOKEN_STRING: case TOKEN_REGEXP:
1216
-					if (!$this->t->scanOperand)
1217
-						break 2;
1261
+					if (!$this->t->scanOperand) {
1262
+											break 2;
1263
+					}
1218 1264
 
1219 1265
 					array_push($operands, new JSNode($this->t));
1220 1266
 					$this->t->scanOperand = false;
@@ -1222,10 +1268,11 @@  discard block
 block discarded – undo
1222 1268
 
1223 1269
 				case TOKEN_CONDCOMMENT_START:
1224 1270
 				case TOKEN_CONDCOMMENT_END:
1225
-					if ($this->t->scanOperand)
1226
-						array_push($operators, new JSNode($this->t));
1227
-					else
1228
-						array_push($operands, new JSNode($this->t));
1271
+					if ($this->t->scanOperand) {
1272
+											array_push($operators, new JSNode($this->t));
1273
+					} else {
1274
+											array_push($operands, new JSNode($this->t));
1275
+					}
1229 1276
 				break;
1230 1277
 
1231 1278
 				case OP_LEFT_BRACKET:
@@ -1244,15 +1291,15 @@  discard block
 block discarded – undo
1244 1291
 							}
1245 1292
 
1246 1293
 							$n->addNode($this->Expression($x, OP_COMMA));
1247
-							if (!$this->t->match(OP_COMMA))
1248
-								break;
1294
+							if (!$this->t->match(OP_COMMA)) {
1295
+															break;
1296
+							}
1249 1297
 						}
1250 1298
 
1251 1299
 						$this->t->mustMatch(OP_RIGHT_BRACKET);
1252 1300
 						array_push($operands, $n);
1253 1301
 						$this->t->scanOperand = false;
1254
-					}
1255
-					else
1302
+					} else
1256 1303
 					{
1257 1304
 						// Property indexing operator.
1258 1305
 						array_push($operators, new JSNode($this->t, JS_INDEX));
@@ -1262,18 +1309,21 @@  discard block
 block discarded – undo
1262 1309
 				break;
1263 1310
 
1264 1311
 				case OP_RIGHT_BRACKET:
1265
-					if ($this->t->scanOperand || $x->bracketLevel == $bl)
1266
-						break 2;
1312
+					if ($this->t->scanOperand || $x->bracketLevel == $bl) {
1313
+											break 2;
1314
+					}
1267 1315
 
1268
-					while ($this->reduce($operators, $operands)->type != JS_INDEX)
1269
-						continue;
1316
+					while ($this->reduce($operators, $operands)->type != JS_INDEX) {
1317
+											continue;
1318
+					}
1270 1319
 
1271 1320
 					--$x->bracketLevel;
1272 1321
 				break;
1273 1322
 
1274 1323
 				case OP_LEFT_CURLY:
1275
-					if (!$this->t->scanOperand)
1276
-						break 2;
1324
+					if (!$this->t->scanOperand) {
1325
+											break 2;
1326
+					}
1277 1327
 
1278 1328
 					// Object initialiser.  As for array initialisers (see above),
1279 1329
 					// parse using recursive descent.
@@ -1287,12 +1337,12 @@  discard block
 block discarded – undo
1287 1337
 							$tv = $this->t->currentToken()->value;
1288 1338
 							if (($tv == 'get' || $tv == 'set') && $this->t->peek() == TOKEN_IDENTIFIER)
1289 1339
 							{
1290
-								if ($x->ecmaStrictMode)
1291
-									throw $this->t->newSyntaxError('Illegal property accessor');
1340
+								if ($x->ecmaStrictMode) {
1341
+																	throw $this->t->newSyntaxError('Illegal property accessor');
1342
+								}
1292 1343
 
1293 1344
 								$n->addNode($this->FunctionDefinition($x, true, EXPRESSED_FORM));
1294
-							}
1295
-							else
1345
+							} else
1296 1346
 							{
1297 1347
 								switch ($tt)
1298 1348
 								{
@@ -1303,8 +1353,9 @@  discard block
 block discarded – undo
1303 1353
 									break;
1304 1354
 
1305 1355
 									case OP_RIGHT_CURLY:
1306
-										if ($x->ecmaStrictMode)
1307
-											throw $this->t->newSyntaxError('Illegal trailing ,');
1356
+										if ($x->ecmaStrictMode) {
1357
+																					throw $this->t->newSyntaxError('Illegal trailing ,');
1358
+										}
1308 1359
 									break 3;
1309 1360
 
1310 1361
 									default:
@@ -1327,21 +1378,22 @@  discard block
 block discarded – undo
1327 1378
 				break;
1328 1379
 
1329 1380
 				case OP_RIGHT_CURLY:
1330
-					if (!$this->t->scanOperand && $x->curlyLevel != $cl)
1331
-						throw new Exception('PANIC: right curly botch');
1381
+					if (!$this->t->scanOperand && $x->curlyLevel != $cl) {
1382
+											throw new Exception('PANIC: right curly botch');
1383
+					}
1332 1384
 				break 2;
1333 1385
 
1334 1386
 				case OP_LEFT_PAREN:
1335 1387
 					if ($this->t->scanOperand)
1336 1388
 					{
1337 1389
 						array_push($operators, new JSNode($this->t, JS_GROUP));
1338
-					}
1339
-					else
1390
+					} else
1340 1391
 					{
1341 1392
 						while (	!empty($operators) &&
1342 1393
 							$this->opPrecedence[end($operators)->type] > $this->opPrecedence[KEYWORD_NEW]
1343
-						)
1344
-							$this->reduce($operators, $operands);
1394
+						) {
1395
+													$this->reduce($operators, $operands);
1396
+						}
1345 1397
 
1346 1398
 						// Handle () now, to regularize the n-ary case for n > 0.
1347 1399
 						// We must set scanOperand in case there are arguments and
@@ -1354,8 +1406,7 @@  discard block
 block discarded – undo
1354 1406
 							{
1355 1407
 								array_pop($operators);
1356 1408
 								$n->addNode(array_pop($operands));
1357
-							}
1358
-							else
1409
+							} else
1359 1410
 							{
1360 1411
 								$n = new JSNode($this->t, JS_CALL, array_pop($operands), new JSNode($this->t, JS_LIST));
1361 1412
 							}
@@ -1365,18 +1416,20 @@  discard block
 block discarded – undo
1365 1416
 							break;
1366 1417
 						}
1367 1418
 
1368
-						if ($n && $n->type == KEYWORD_NEW)
1369
-							$n->type = JS_NEW_WITH_ARGS;
1370
-						else
1371
-							array_push($operators, new JSNode($this->t, JS_CALL));
1419
+						if ($n && $n->type == KEYWORD_NEW) {
1420
+													$n->type = JS_NEW_WITH_ARGS;
1421
+						} else {
1422
+													array_push($operators, new JSNode($this->t, JS_CALL));
1423
+						}
1372 1424
 					}
1373 1425
 
1374 1426
 					++$x->parenLevel;
1375 1427
 				break;
1376 1428
 
1377 1429
 				case OP_RIGHT_PAREN:
1378
-					if ($this->t->scanOperand || $x->parenLevel == $pl)
1379
-						break 2;
1430
+					if ($this->t->scanOperand || $x->parenLevel == $pl) {
1431
+											break 2;
1432
+					}
1380 1433
 
1381 1434
 					while (($tt = $this->reduce($operators, $operands)->type) != JS_GROUP &&
1382 1435
 						$tt != JS_CALL && $tt != JS_NEW_WITH_ARGS
@@ -1388,10 +1441,11 @@  discard block
 block discarded – undo
1388 1441
 					if ($tt != JS_GROUP)
1389 1442
 					{
1390 1443
 						$n = end($operands);
1391
-						if ($n->treeNodes[1]->type != OP_COMMA)
1392
-							$n->treeNodes[1] = new JSNode($this->t, JS_LIST, $n->treeNodes[1]);
1393
-						else
1394
-							$n->treeNodes[1]->type = JS_LIST;
1444
+						if ($n->treeNodes[1]->type != OP_COMMA) {
1445
+													$n->treeNodes[1] = new JSNode($this->t, JS_LIST, $n->treeNodes[1]);
1446
+						} else {
1447
+													$n->treeNodes[1]->type = JS_LIST;
1448
+						}
1395 1449
 					}
1396 1450
 
1397 1451
 					--$x->parenLevel;
@@ -1405,24 +1459,29 @@  discard block
 block discarded – undo
1405 1459
 			}
1406 1460
 		}
1407 1461
 
1408
-		if ($x->hookLevel != $hl)
1409
-			throw $this->t->newSyntaxError('Missing : in conditional expression');
1462
+		if ($x->hookLevel != $hl) {
1463
+					throw $this->t->newSyntaxError('Missing : in conditional expression');
1464
+		}
1410 1465
 
1411
-		if ($x->parenLevel != $pl)
1412
-			throw $this->t->newSyntaxError('Missing ) in parenthetical');
1466
+		if ($x->parenLevel != $pl) {
1467
+					throw $this->t->newSyntaxError('Missing ) in parenthetical');
1468
+		}
1413 1469
 
1414
-		if ($x->bracketLevel != $bl)
1415
-			throw $this->t->newSyntaxError('Missing ] in index expression');
1470
+		if ($x->bracketLevel != $bl) {
1471
+					throw $this->t->newSyntaxError('Missing ] in index expression');
1472
+		}
1416 1473
 
1417
-		if ($this->t->scanOperand)
1418
-			throw $this->t->newSyntaxError('Missing operand');
1474
+		if ($this->t->scanOperand) {
1475
+					throw $this->t->newSyntaxError('Missing operand');
1476
+		}
1419 1477
 
1420 1478
 		// Resume default mode, scanning for operands, not operators.
1421 1479
 		$this->t->scanOperand = true;
1422 1480
 		$this->t->unget();
1423 1481
 
1424
-		while (count($operators))
1425
-			$this->reduce($operators, $operands);
1482
+		while (count($operators)) {
1483
+					$this->reduce($operators, $operands);
1484
+		}
1426 1485
 
1427 1486
 		return array_pop($operands);
1428 1487
 	}
@@ -1443,8 +1502,9 @@  discard block
 block discarded – undo
1443 1502
 		$n = $this->statement($x);
1444 1503
 		array_pop($x->stmtStack);
1445 1504
 
1446
-		if ($end)
1447
-			$this->t->mustMatch($end);
1505
+		if ($end) {
1506
+					$this->t->mustMatch($end);
1507
+		}
1448 1508
 
1449 1509
 		return $n;
1450 1510
 	}
@@ -1473,13 +1533,15 @@  discard block
 block discarded – undo
1473 1533
 
1474 1534
 		// Always use push to add operands to n, to update start and end
1475 1535
 		$a = array_splice($operands, $c - $arity);
1476
-		for ($i = 0; $i < $arity; $i++)
1477
-			$n->addNode($a[$i]);
1536
+		for ($i = 0; $i < $arity; $i++) {
1537
+					$n->addNode($a[$i]);
1538
+		}
1478 1539
 
1479 1540
 		// Include closing bracket or postfix operator in [start,end]
1480 1541
 		$te = $this->t->currentToken()->end;
1481
-		if ($n->end < $te)
1482
-			$n->end = $te;
1542
+		if ($n->end < $te) {
1543
+					$n->end = $te;
1544
+		}
1483 1545
 
1484 1546
 		array_push($operands, $n);
1485 1547
 
@@ -1528,8 +1590,7 @@  discard block
 block discarded – undo
1528 1590
 			$this->lineno = $token->lineno;
1529 1591
 			$this->start = $token->start;
1530 1592
 			$this->end = $token->end;
1531
-		}
1532
-		else
1593
+		} else
1533 1594
 		{
1534 1595
 			$this->type = $type;
1535 1596
 			$this->lineno = $t->lineno;
@@ -1538,8 +1599,9 @@  discard block
 block discarded – undo
1538 1599
 		if (($numargs = func_num_args()) > 2)
1539 1600
 		{
1540 1601
 			$args = func_get_args();;
1541
-			for ($i = 2; $i < $numargs; $i++)
1542
-				$this->addNode($args[$i]);
1602
+			for ($i = 2; $i < $numargs; $i++) {
1603
+							$this->addNode($args[$i]);
1604
+			}
1543 1605
 		}
1544 1606
 	}
1545 1607
 
@@ -1551,8 +1613,9 @@  discard block
 block discarded – undo
1551 1613
 
1552 1614
 	public function __get($name)
1553 1615
 	{
1554
-		if (isset($this->$name))
1555
-			return $this->$name;
1616
+		if (isset($this->$name)) {
1617
+					return $this->$name;
1618
+		}
1556 1619
 
1557 1620
 		return null;
1558 1621
 	}
@@ -1561,10 +1624,12 @@  discard block
 block discarded – undo
1561 1624
 	{
1562 1625
 		if ($node !== null)
1563 1626
 		{
1564
-			if ($node->start < $this->start)
1565
-				$this->start = $node->start;
1566
-			if ($this->end < $node->end)
1567
-				$this->end = $node->end;
1627
+			if ($node->start < $this->start) {
1628
+							$this->start = $node->start;
1629
+			}
1630
+			if ($this->end < $node->end) {
1631
+							$this->end = $node->end;
1632
+			}
1568 1633
 		}
1569 1634
 
1570 1635
 		$this->treeNodes[] = $node;
@@ -1649,14 +1714,16 @@  discard block
 block discarded – undo
1649 1714
 		$this->opRegExp = '#^(' . implode('|', array_map('preg_quote', array_keys($this->opTypeNames))) . ')#';
1650 1715
 
1651 1716
 		// this is quite a hidden yet convenient place to create the defines for operators and keywords
1652
-		foreach ($this->opTypeNames as $operand => $name)
1653
-			define('OP_' . $name, $operand);
1717
+		foreach ($this->opTypeNames as $operand => $name) {
1718
+					define('OP_' . $name, $operand);
1719
+		}
1654 1720
 
1655 1721
 		define('OP_UNARY_PLUS', 'U+');
1656 1722
 		define('OP_UNARY_MINUS', 'U-');
1657 1723
 
1658
-		foreach ($this->keywords as $keyword)
1659
-			define('KEYWORD_' . strtoupper($keyword), $keyword);
1724
+		foreach ($this->keywords as $keyword) {
1725
+					define('KEYWORD_' . strtoupper($keyword), $keyword);
1726
+		}
1660 1727
 	}
1661 1728
 
1662 1729
 	public function init($source, $filename = '', $lineno = 1)
@@ -1675,8 +1742,9 @@  discard block
 block discarded – undo
1675 1742
 
1676 1743
 	public function getInput($chunksize)
1677 1744
 	{
1678
-		if ($chunksize)
1679
-			return substr($this->source, $this->cursor, $chunksize);
1745
+		if ($chunksize) {
1746
+					return substr($this->source, $this->cursor, $chunksize);
1747
+		}
1680 1748
 
1681 1749
 		return substr($this->source, $this->cursor);
1682 1750
 	}
@@ -1693,8 +1761,9 @@  discard block
 block discarded – undo
1693 1761
 
1694 1762
 	public function mustMatch($tt)
1695 1763
 	{
1696
-	        if (!$this->match($tt))
1697
-			throw $this->newSyntaxError('Unexpected token; token ' . $tt . ' expected');
1764
+	        if (!$this->match($tt)) {
1765
+	        			throw $this->newSyntaxError('Unexpected token; token ' . $tt . ' expected');
1766
+	        }
1698 1767
 
1699 1768
 		return $this->currentToken();
1700 1769
 	}
@@ -1704,12 +1773,12 @@  discard block
 block discarded – undo
1704 1773
 		if ($this->lookahead)
1705 1774
 		{
1706 1775
 			$next = $this->tokens[($this->tokenIndex + $this->lookahead) & 3];
1707
-			if ($this->scanNewlines && $next->lineno != $this->lineno)
1708
-				$tt = TOKEN_NEWLINE;
1709
-			else
1710
-				$tt = $next->type;
1711
-		}
1712
-		else
1776
+			if ($this->scanNewlines && $next->lineno != $this->lineno) {
1777
+							$tt = TOKEN_NEWLINE;
1778
+			} else {
1779
+							$tt = $next->type;
1780
+			}
1781
+		} else
1713 1782
 		{
1714 1783
 			$tt = $this->get();
1715 1784
 			$this->unget();
@@ -1729,8 +1798,9 @@  discard block
 block discarded – undo
1729 1798
 
1730 1799
 	public function currentToken()
1731 1800
 	{
1732
-		if (!empty($this->tokens))
1733
-			return $this->tokens[$this->tokenIndex];
1801
+		if (!empty($this->tokens)) {
1802
+					return $this->tokens[$this->tokenIndex];
1803
+		}
1734 1804
 	}
1735 1805
 
1736 1806
 	public function get($chunksize = 1000)
@@ -1740,8 +1810,9 @@  discard block
 block discarded – undo
1740 1810
 			$this->lookahead--;
1741 1811
 			$this->tokenIndex = ($this->tokenIndex + 1) & 3;
1742 1812
 			$token = $this->tokens[$this->tokenIndex];
1743
-			if ($token->type != TOKEN_NEWLINE || $this->scanNewlines)
1744
-				return $token->type;
1813
+			if ($token->type != TOKEN_NEWLINE || $this->scanNewlines) {
1814
+							return $token->type;
1815
+			}
1745 1816
 		}
1746 1817
 
1747 1818
 		$conditional_comment = false;
@@ -1758,22 +1829,27 @@  discard block
 block discarded – undo
1758 1829
 				$spaces = $match[0];
1759 1830
 				$spacelen = strlen($spaces);
1760 1831
 				$this->cursor += $spacelen;
1761
-				if (!$this->scanNewlines)
1762
-					$this->lineno += substr_count($spaces, "\n");
1832
+				if (!$this->scanNewlines) {
1833
+									$this->lineno += substr_count($spaces, "\n");
1834
+				}
1763 1835
 
1764
-				if ($spacelen == $chunksize)
1765
-					continue; // complete chunk contained whitespace
1836
+				if ($spacelen == $chunksize) {
1837
+									continue;
1838
+				}
1839
+				// complete chunk contained whitespace
1766 1840
 
1767 1841
 				$input = $this->getInput($chunksize);
1768
-				if ($input == '' || $input[0] != '/')
1769
-					break;
1842
+				if ($input == '' || $input[0] != '/') {
1843
+									break;
1844
+				}
1770 1845
 			}
1771 1846
 
1772 1847
 			// Comments
1773 1848
 			if (!preg_match('/^\/(?:\*(@(?:cc_on|if|elif|else|end))?.*?\*\/|\/[^\n]*)/s', $input, $match))
1774 1849
 			{
1775
-				if (!$chunksize)
1776
-					break;
1850
+				if (!$chunksize) {
1851
+									break;
1852
+				}
1777 1853
 
1778 1854
 				// retry with a full chunk fetch; this also prevents breakage of long regular expressions (which will never match a comment)
1779 1855
 				$chunksize = null;
@@ -1786,8 +1862,7 @@  discard block
 block discarded – undo
1786 1862
 				$match[0] = '/*' . $match[1];
1787 1863
 				$conditional_comment = true;
1788 1864
 				break;
1789
-			}
1790
-			else
1865
+			} else
1791 1866
 			{
1792 1867
 				$this->cursor += strlen($match[0]);
1793 1868
 				$this->lineno += substr_count($match[0], "\n");
@@ -1798,12 +1873,10 @@  discard block
 block discarded – undo
1798 1873
 		{
1799 1874
 			$tt = TOKEN_END;
1800 1875
 			$match = array('');
1801
-		}
1802
-		elseif ($conditional_comment)
1876
+		} elseif ($conditional_comment)
1803 1877
 		{
1804 1878
 			$tt = TOKEN_CONDCOMMENT_START;
1805
-		}
1806
-		else
1879
+		} else
1807 1880
 		{
1808 1881
 			switch ($input[0])
1809 1882
 			{
@@ -1812,8 +1885,7 @@  discard block
 block discarded – undo
1812 1885
 					if (preg_match('/^\d+\.\d*(?:[eE][-+]?\d+)?|^\d+(?:\.\d*)?[eE][-+]?\d+/', $input, $match))
1813 1886
 					{
1814 1887
 						$tt = TOKEN_NUMBER;
1815
-					}
1816
-					else if (preg_match('/^0[xX][\da-fA-F]+|^0[0-7]*|^\d+/', $input, $match))
1888
+					} else if (preg_match('/^0[xX][\da-fA-F]+|^0[0-7]*|^\d+/', $input, $match))
1817 1889
 					{
1818 1890
 						// this should always match because of \d+
1819 1891
 						$tt = TOKEN_NUMBER;
@@ -1825,11 +1897,12 @@  discard block
 block discarded – undo
1825 1897
 					if (preg_match('/^"(?:\\\\(?:.|\r?\n)|[^\\\\"\r\n]+)*"|^\'(?:\\\\(?:.|\r?\n)|[^\\\\\'\r\n]+)*\'/', $input, $match))
1826 1898
 					{
1827 1899
 						$tt = TOKEN_STRING;
1828
-					}
1829
-					else
1900
+					} else
1830 1901
 					{
1831
-						if ($chunksize)
1832
-							return $this->get(null); // retry with a full chunk fetch
1902
+						if ($chunksize) {
1903
+													return $this->get(null);
1904
+						}
1905
+						// retry with a full chunk fetch
1833 1906
 
1834 1907
 						throw $this->newSyntaxError('Unterminated string literal');
1835 1908
 					}
@@ -1861,16 +1934,16 @@  discard block
 block discarded – undo
1861 1934
 					{
1862 1935
 						$tt = OP_ASSIGN;
1863 1936
 						$match[0] .= '=';
1864
-					}
1865
-					else
1937
+					} else
1866 1938
 					{
1867 1939
 						$tt = $op;
1868 1940
 						if ($this->scanOperand)
1869 1941
 						{
1870
-							if ($op == OP_PLUS)
1871
-								$tt = OP_UNARY_PLUS;
1872
-							elseif ($op == OP_MINUS)
1873
-								$tt = OP_UNARY_MINUS;
1942
+							if ($op == OP_PLUS) {
1943
+															$tt = OP_UNARY_PLUS;
1944
+							} elseif ($op == OP_MINUS) {
1945
+															$tt = OP_UNARY_MINUS;
1946
+							}
1874 1947
 						}
1875 1948
 						$op = null;
1876 1949
 					}
@@ -1906,9 +1979,9 @@  discard block
 block discarded – undo
1906 1979
 					{
1907 1980
 						$match = array('@*/');
1908 1981
 						$tt = TOKEN_CONDCOMMENT_END;
1982
+					} else {
1983
+											throw $this->newSyntaxError('Illegal token');
1909 1984
 					}
1910
-					else
1911
-						throw $this->newSyntaxError('Illegal token');
1912 1985
 				break;
1913 1986
 
1914 1987
 				case "\n":
@@ -1916,9 +1989,9 @@  discard block
 block discarded – undo
1916 1989
 					{
1917 1990
 						$match = array("\n");
1918 1991
 						$tt = TOKEN_NEWLINE;
1992
+					} else {
1993
+											throw $this->newSyntaxError('Illegal token');
1919 1994
 					}
1920
-					else
1921
-						throw $this->newSyntaxError('Illegal token');
1922 1995
 				break;
1923 1996
 
1924 1997
 				default:
@@ -1926,22 +1999,24 @@  discard block
 block discarded – undo
1926 1999
 					if (preg_match('/^[$\w]+/', $input, $match))
1927 2000
 					{
1928 2001
 						$tt = in_array($match[0], $this->keywords) ? $match[0] : TOKEN_IDENTIFIER;
2002
+					} else {
2003
+											throw $this->newSyntaxError('Illegal token');
1929 2004
 					}
1930
-					else
1931
-						throw $this->newSyntaxError('Illegal token');
1932 2005
 			}
1933 2006
 		}
1934 2007
 
1935 2008
 		$this->tokenIndex = ($this->tokenIndex + 1) & 3;
1936 2009
 
1937
-		if (!isset($this->tokens[$this->tokenIndex]))
1938
-			$this->tokens[$this->tokenIndex] = new JSToken();
2010
+		if (!isset($this->tokens[$this->tokenIndex])) {
2011
+					$this->tokens[$this->tokenIndex] = new JSToken();
2012
+		}
1939 2013
 
1940 2014
 		$token = $this->tokens[$this->tokenIndex];
1941 2015
 		$token->type = $tt;
1942 2016
 
1943
-		if ($tt == OP_ASSIGN)
1944
-			$token->assignOp = $op;
2017
+		if ($tt == OP_ASSIGN) {
2018
+					$token->assignOp = $op;
2019
+		}
1945 2020
 
1946 2021
 		$token->start = $this->cursor;
1947 2022
 
@@ -1956,8 +2031,9 @@  discard block
 block discarded – undo
1956 2031
 
1957 2032
 	public function unget()
1958 2033
 	{
1959
-		if (++$this->lookahead == 4)
1960
-			throw $this->newSyntaxError('PANIC: too much lookahead!');
2034
+		if (++$this->lookahead == 4) {
2035
+					throw $this->newSyntaxError('PANIC: too much lookahead!');
2036
+		}
1961 2037
 
1962 2038
 		$this->tokenIndex = ($this->tokenIndex - 1) & 3;
1963 2039
 	}
Please login to merge, or discard this patch.
tools/minify/minify.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -172,6 +172,9 @@  discard block
 block discarded – undo
172 172
 	}
173 173
 }
174 174
 
175
+/**
176
+ * @param string $ext
177
+ */
175 178
 function get_target_files($ext, $dir, $files_to_skip) {
176 179
 	$files = glob("{$dir}*.{$ext}");
177 180
 	$skips = glob("{$dir}*.min.{$ext}");
@@ -181,6 +184,9 @@  discard block
 block discarded – undo
181 184
 	return $files;
182 185
 }
183 186
 
187
+/**
188
+ * @param string $content
189
+ */
184 190
 function closure_compile($content) {
185 191
 	require_once dirname(__FILE__).'/../../classes/httprequest/XEHttpRequest.class.php';
186 192
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author NAVER([email protected])
12 12
  */
13 13
 
14
-if(version_compare(PHP_VERSION, '5.3.0', '<')) {
14
+if (version_compare(PHP_VERSION, '5.3.0', '<')) {
15 15
 	echo "PHP 5.3.0 or above version is required.";
16 16
 	exit(1);
17 17
 }
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	$argc = $_SERVER['argc'];
22 22
 
23 23
 	// get target directories
24
-	if($argc < 1) exit;
25
-	elseif($argc < 2) $dirs = array($_SERVER['PWD']);
24
+	if ($argc < 1) exit;
25
+	elseif ($argc < 2) $dirs = array($_SERVER['PWD']);
26 26
 	else $dirs = array_slice($argv, 1);
27 27
 
28 28
 	$dirs = array_map('realpath', $dirs);
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 // add directory separator
35 35
 function add_dirsep($path) {
36
-	if(substr($path,-1) != DIRECTORY_SEPARATOR) $path .= DIRECTORY_SEPARATOR;
36
+	if (substr($path, -1) != DIRECTORY_SEPARATOR) $path .= DIRECTORY_SEPARATOR;
37 37
 	return $path;
38 38
 }
39 39
 
@@ -46,38 +46,38 @@  discard block
 block discarded – undo
46 46
 	echo " Done\n";
47 47
 
48 48
 	// merge
49
-	foreach($config['merge'] as $target=>$files) {
49
+	foreach ($config['merge'] as $target=>$files) {
50 50
 		merge($files, $target, $dir);
51 51
 	}
52 52
 
53 53
 	// files to skip
54 54
 	$files_to_skip = $config['skip'];
55
-	foreach($files_to_skip as $idx=>$file) {
56
-		if($file) $files_to_skip[$idx] = realpath($dir.trim($file));
55
+	foreach ($files_to_skip as $idx=>$file) {
56
+		if ($file) $files_to_skip[$idx] = realpath($dir . trim($file));
57 57
 	}
58 58
 
59 59
 	echo "  Minifying JavaScript files...";
60 60
 	$js_files = get_target_files('js', $dir, $files_to_skip);
61 61
 
62
-	if(count($js_files) && !class_exists('JSMinPlus')) {
63
-		require dirname(__FILE__).'/jsminplus/jsminplus.php';
62
+	if (count($js_files) && !class_exists('JSMinPlus')) {
63
+		require dirname(__FILE__) . '/jsminplus/jsminplus.php';
64 64
 	}
65
-	foreach($js_files as $file) {
66
-		if(!is_readable($file)) continue;
65
+	foreach ($js_files as $file) {
66
+		if (!is_readable($file)) continue;
67 67
 
68 68
 		$target  = preg_replace('@\.js$@', '.min.js', $file);
69 69
 		$content = file_get_contents($file);
70 70
 
71 71
 		// save copyright to preserve it
72
-		if(preg_match('@^[ \t]*(/\*\*.+?\*/)@s', $content, $matches)) {
73
-			$copyright = $matches[1]."\n";
72
+		if (preg_match('@^[ \t]*(/\*\*.+?\*/)@s', $content, $matches)) {
73
+			$copyright = $matches[1] . "\n";
74 74
 		} else {
75 75
 			$copyright = '';
76 76
 		}
77 77
 
78
-		if($config['use_closure_compiler']) {
78
+		if ($config['use_closure_compiler']) {
79 79
 			$content = closure_compile($content);
80
-			if(!$content) {
80
+			if (!$content) {
81 81
 				echo "   CANNOT compile the js file with closure compiler.\n";
82 82
 				echo "   Trying again with JSMinPlus.\n";
83 83
 				$content = JSMinPlus::minify($content);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			$content = JSMinPlus::minify($content);
87 87
 		}
88 88
 
89
-		file_put_contents($target, $copyright.$content, LOCK_EX);
89
+		file_put_contents($target, $copyright . $content, LOCK_EX);
90 90
 
91 91
 		echo '.';
92 92
 	}
@@ -95,19 +95,19 @@  discard block
 block discarded – undo
95 95
 	echo "  Minifying CSS files...";
96 96
 	$css_files = get_target_files('css', $dir, $files_to_skip);
97 97
 
98
-	if(count($css_files) && !class_exists('CSSmin')) {
99
-		require dirname(__FILE__).'/cssmin/CSSmin.php';
98
+	if (count($css_files) && !class_exists('CSSmin')) {
99
+		require dirname(__FILE__) . '/cssmin/CSSmin.php';
100 100
 	}
101 101
 
102 102
 	$oCSSmin = new CSSmin();
103 103
 
104
-	foreach($css_files as $file) {
105
-		if(!is_readable($file)) continue;
104
+	foreach ($css_files as $file) {
105
+		if (!is_readable($file)) continue;
106 106
 
107 107
 		$target  = preg_replace('@\.css$@', '.min.css', $file);
108 108
 		$content = file_get_contents($file);
109 109
 
110
-		file_put_contents($target, $copyright.$oCSSmin->run($content), LOCK_EX);
110
+		file_put_contents($target, $copyright . $oCSSmin->run($content), LOCK_EX);
111 111
 		echo '.';
112 112
 	}
113 113
 	echo " Done\n";
@@ -115,59 +115,59 @@  discard block
 block discarded – undo
115 115
 
116 116
 function read_config($dir) {
117 117
 	$default = array('option'=>array(), 'skip'=>array(), 'merge'=>array());
118
-	$file    = $dir.'minify.ini';
118
+	$file    = $dir . 'minify.ini';
119 119
 
120
-	if(!is_readable($file)) return $default;
120
+	if (!is_readable($file)) return $default;
121 121
 
122 122
 	$config_str = file_get_contents($file);
123 123
 	$config_str = preg_replace_callback('/(\[(?:skip|merge *>> *.+?)\])([\s\S]+?)(?=\[|$)/', 'transform_config_str', $config_str);
124 124
 
125 125
 	$config = parse_ini_string($config_str, 1);
126
-	if($config === false) return $default;
126
+	if ($config === false) return $default;
127 127
 
128
-	if(is_array($config['skip'])) $config['skip'] = array_keys($config['skip']);
128
+	if (is_array($config['skip'])) $config['skip'] = array_keys($config['skip']);
129 129
 
130
-	foreach($config as $section=>$value) {
131
-		if(preg_match('/merge *>> *(.+)/', $section, $match)) {
132
-			if(!is_array($config['merge'])) $config['merge'] = array();
130
+	foreach ($config as $section=>$value) {
131
+		if (preg_match('/merge *>> *(.+)/', $section, $match)) {
132
+			if (!is_array($config['merge'])) $config['merge'] = array();
133 133
 			$config['merge'][trim($match[1])] = array_keys($value);
134 134
 
135 135
 			unset($config[$section]);
136 136
 		}
137 137
 	}
138 138
 
139
-	if(is_array($config['option'])) $config = array_merge($config['option'], $config);
139
+	if (is_array($config['option'])) $config = array_merge($config['option'], $config);
140 140
 	$config = array_merge($default, $config);
141 141
 
142 142
 	return $config;
143 143
 }
144 144
 
145 145
 function transform_config_str($matches) {
146
-	if(!$matches[2]) return $matches[0];
146
+	if (!$matches[2]) return $matches[0];
147 147
 	$values = preg_replace('/$/m', '=', trim($matches[2]));
148 148
 
149 149
 	return "{$matches[1]}\n{$values}\n\n";
150 150
 }
151 151
 
152 152
 function merge($files, $target, $base_dir) {
153
-	if(!is_array($files)) return false;
153
+	if (!is_array($files)) return false;
154 154
 
155 155
 	$body   = '';
156 156
 	$is_css = !!preg_match('/\.css$/', $target);
157 157
 
158
-	foreach($files as $file) {
159
-		$file = $base_dir.trim($file);
160
-		if(!is_readable($file)) continue;
158
+	foreach ($files as $file) {
159
+		$file = $base_dir . trim($file);
160
+		if (!is_readable($file)) continue;
161 161
 
162 162
 		$content = trim(file_get_contents($file));
163
-		if($is_css && $body) $content = preg_replace('/^@.+?;/m', '', $content);
164
-		if($content) $body .= $content."\n";
163
+		if ($is_css && $body) $content = preg_replace('/^@.+?;/m', '', $content);
164
+		if ($content) $body .= $content . "\n";
165 165
 	}
166 166
 
167 167
 	if ($body) {
168 168
 		$file_count = count($files);
169 169
 		echo "  Merging {$file_count} files to create {$target} file...";
170
-		file_put_contents($base_dir.$target, $body, LOCK_EX);
170
+		file_put_contents($base_dir . $target, $body, LOCK_EX);
171 171
 		echo " Done\n";
172 172
 	}
173 173
 }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 }
183 183
 
184 184
 function closure_compile($content) {
185
-	require_once dirname(__FILE__).'/../../classes/httprequest/XEHttpRequest.class.php';
185
+	require_once dirname(__FILE__) . '/../../classes/httprequest/XEHttpRequest.class.php';
186 186
 
187 187
 	$req = new XEHttpRequest('closure-compiler.appspot.com', 80);
188 188
 	$ret = $req->send('/compile', 'POST', 5, array(
Please login to merge, or discard this patch.
Braces   +49 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,9 +21,13 @@  discard block
 block discarded – undo
21 21
 	$argc = $_SERVER['argc'];
22 22
 
23 23
 	// get target directories
24
-	if($argc < 1) exit;
25
-	elseif($argc < 2) $dirs = array($_SERVER['PWD']);
26
-	else $dirs = array_slice($argv, 1);
24
+	if($argc < 1) {
25
+		exit;
26
+	} elseif($argc < 2) {
27
+		$dirs = array($_SERVER['PWD']);
28
+	} else {
29
+		$dirs = array_slice($argv, 1);
30
+	}
27 31
 
28 32
 	$dirs = array_map('realpath', $dirs);
29 33
 	$dirs = array_map('add_dirsep', $dirs);
@@ -33,7 +37,9 @@  discard block
 block discarded – undo
33 37
 
34 38
 // add directory separator
35 39
 function add_dirsep($path) {
36
-	if(substr($path,-1) != DIRECTORY_SEPARATOR) $path .= DIRECTORY_SEPARATOR;
40
+	if(substr($path,-1) != DIRECTORY_SEPARATOR) {
41
+		$path .= DIRECTORY_SEPARATOR;
42
+	}
37 43
 	return $path;
38 44
 }
39 45
 
@@ -53,7 +59,9 @@  discard block
 block discarded – undo
53 59
 	// files to skip
54 60
 	$files_to_skip = $config['skip'];
55 61
 	foreach($files_to_skip as $idx=>$file) {
56
-		if($file) $files_to_skip[$idx] = realpath($dir.trim($file));
62
+		if($file) {
63
+			$files_to_skip[$idx] = realpath($dir.trim($file));
64
+		}
57 65
 	}
58 66
 
59 67
 	echo "  Minifying JavaScript files...";
@@ -63,7 +71,9 @@  discard block
 block discarded – undo
63 71
 		require dirname(__FILE__).'/jsminplus/jsminplus.php';
64 72
 	}
65 73
 	foreach($js_files as $file) {
66
-		if(!is_readable($file)) continue;
74
+		if(!is_readable($file)) {
75
+			continue;
76
+		}
67 77
 
68 78
 		$target  = preg_replace('@\.js$@', '.min.js', $file);
69 79
 		$content = file_get_contents($file);
@@ -102,7 +112,9 @@  discard block
 block discarded – undo
102 112
 	$oCSSmin = new CSSmin();
103 113
 
104 114
 	foreach($css_files as $file) {
105
-		if(!is_readable($file)) continue;
115
+		if(!is_readable($file)) {
116
+			continue;
117
+		}
106 118
 
107 119
 		$target  = preg_replace('@\.css$@', '.min.css', $file);
108 120
 		$content = file_get_contents($file);
@@ -117,51 +129,71 @@  discard block
 block discarded – undo
117 129
 	$default = array('option'=>array(), 'skip'=>array(), 'merge'=>array());
118 130
 	$file    = $dir.'minify.ini';
119 131
 
120
-	if(!is_readable($file)) return $default;
132
+	if(!is_readable($file)) {
133
+		return $default;
134
+	}
121 135
 
122 136
 	$config_str = file_get_contents($file);
123 137
 	$config_str = preg_replace_callback('/(\[(?:skip|merge *>> *.+?)\])([\s\S]+?)(?=\[|$)/', 'transform_config_str', $config_str);
124 138
 
125 139
 	$config = parse_ini_string($config_str, 1);
126
-	if($config === false) return $default;
140
+	if($config === false) {
141
+		return $default;
142
+	}
127 143
 
128
-	if(is_array($config['skip'])) $config['skip'] = array_keys($config['skip']);
144
+	if(is_array($config['skip'])) {
145
+		$config['skip'] = array_keys($config['skip']);
146
+	}
129 147
 
130 148
 	foreach($config as $section=>$value) {
131 149
 		if(preg_match('/merge *>> *(.+)/', $section, $match)) {
132
-			if(!is_array($config['merge'])) $config['merge'] = array();
150
+			if(!is_array($config['merge'])) {
151
+				$config['merge'] = array();
152
+			}
133 153
 			$config['merge'][trim($match[1])] = array_keys($value);
134 154
 
135 155
 			unset($config[$section]);
136 156
 		}
137 157
 	}
138 158
 
139
-	if(is_array($config['option'])) $config = array_merge($config['option'], $config);
159
+	if(is_array($config['option'])) {
160
+		$config = array_merge($config['option'], $config);
161
+	}
140 162
 	$config = array_merge($default, $config);
141 163
 
142 164
 	return $config;
143 165
 }
144 166
 
145 167
 function transform_config_str($matches) {
146
-	if(!$matches[2]) return $matches[0];
168
+	if(!$matches[2]) {
169
+		return $matches[0];
170
+	}
147 171
 	$values = preg_replace('/$/m', '=', trim($matches[2]));
148 172
 
149 173
 	return "{$matches[1]}\n{$values}\n\n";
150 174
 }
151 175
 
152 176
 function merge($files, $target, $base_dir) {
153
-	if(!is_array($files)) return false;
177
+	if(!is_array($files)) {
178
+		return false;
179
+	}
154 180
 
155 181
 	$body   = '';
156 182
 	$is_css = !!preg_match('/\.css$/', $target);
157 183
 
158 184
 	foreach($files as $file) {
159 185
 		$file = $base_dir.trim($file);
160
-		if(!is_readable($file)) continue;
186
+		if(!is_readable($file)) {
187
+			continue;
188
+		}
161 189
 
162 190
 		$content = trim(file_get_contents($file));
163
-		if($is_css && $body) $content = preg_replace('/^@.+?;/m', '', $content);
164
-		if($content) $body .= $content."\n";
191
+		if($is_css && $body) {
192
+			$content = preg_replace('/^@.+?;/m', '', $content);
193
+		}
194
+		if($content) {
195
+			$body .= $content."\n";
196
+		}
165 197
 	}
166 198
 
167 199
 	if ($body) {
Please login to merge, or discard this patch.
addons/adminlogging/adminlogging.addon.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if(!defined('__XE__'))
4
+if (!defined('__XE__'))
5 5
 	exit();
6 6
 
7 7
 /**
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @brief admin log
11 11
  */
12 12
 $logged_info = Context::get('logged_info');
13
-if($logged_info && $logged_info->is_admin == 'Y' && stripos(Context::get('act'), 'admin') !== false && $called_position == 'before_module_proc')
13
+if ($logged_info && $logged_info->is_admin == 'Y' && stripos(Context::get('act'), 'admin') !== false && $called_position == 'before_module_proc')
14 14
 {
15 15
 	$oAdminloggingController = getController('adminlogging');
16 16
 	$oAdminloggingController->insertLog($this->module, $this->act);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,8 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if(!defined('__XE__'))
4
+if(!defined('__XE__')) {
5 5
 	exit();
6
+}
6 7
 
7 8
 /**
8 9
  * @file point.addon.php
Please login to merge, or discard this patch.
addons/autolink/autolink.addon.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if(!defined('__XE__'))
4
+if (!defined('__XE__'))
5 5
 	exit();
6 6
 
7 7
 /**
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
  * @author NAVER ([email protected])
10 10
  * @brief Automatic link add-on
11 11
  */
12
-if($called_position == 'after_module_proc' && Context::getResponseMethod() == "HTML")
12
+if ($called_position == 'after_module_proc' && Context::getResponseMethod() == "HTML")
13 13
 {
14
-	if(Mobile::isFromMobilePhone())
14
+	if (Mobile::isFromMobilePhone())
15 15
 	{
16 16
 		Context::addJsFile('./common/js/jquery.min.js', false, '', -1000000);
17 17
 		Context::addJsFile('./common/js/xe.min.js', false, '', -1000000);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,8 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if(!defined('__XE__'))
4
+if(!defined('__XE__')) {
5 5
 	exit();
6
+}
6 7
 
7 8
 /**
8 9
  * @file point.addon.php
Please login to merge, or discard this patch.
addons/blogapi/blogapi.addon.php 2 patches
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if(!defined('__XE__'))
4
+if (!defined('__XE__'))
5 5
 	exit();
6 6
 
7 7
 /**
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * It should be called before executing the module(before_module_proc). If not, it is forced to shut down.
14 14
  * */
15 15
 // Insert a rsd tag when called_position is after_module_proc
16
-if($called_position == 'after_module_proc')
16
+if ($called_position == 'after_module_proc')
17 17
 {
18 18
 	// Create rsd address of the current module
19 19
 	$site_module_info = Context::get('site_module_info');
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	Context::addHtmlHeader("    " . '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . $rsd_url . '" />');
23 23
 }
24 24
 // If act isnot api, just return
25
-if($_REQUEST['act'] != 'api')
25
+if ($_REQUEST['act'] != 'api')
26 26
 {
27 27
 	return;
28 28
 }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
34 34
 
35 35
 // If HTTP_RAW_POST_DATA is NULL, Print error message
36
-if(!$xml)
36
+if (!$xml)
37 37
 {
38 38
 	$content = getXmlRpcFailure(1, 'Invalid Method Call');
39 39
 	printContent($content);
@@ -41,38 +41,38 @@  discard block
 block discarded – undo
41 41
 
42 42
 // xmlprc parsing
43 43
 // Parse the requested xmlrpc
44
-if(Security::detectingXEE($xml))
44
+if (Security::detectingXEE($xml))
45 45
 {
46 46
 	header("HTTP/1.0 400 Bad Request");
47 47
 	exit;
48 48
 }
49 49
 
50
-if(version_compare(PHP_VERSION, '5.2.11', '<=')) libxml_disable_entity_loader(true);
50
+if (version_compare(PHP_VERSION, '5.2.11', '<=')) libxml_disable_entity_loader(true);
51 51
 $xml = new SimpleXMLElement($xml, LIBXML_NONET | LIBXML_NOENT);
52 52
 
53
-$method_name = (string)$xml->methodName;
53
+$method_name = (string) $xml->methodName;
54 54
 $params = $xml->params->param;
55 55
 
56 56
 // Compatible with some of methodname
57
-if(in_array($method_name, array('metaWeblog.deletePost', 'metaWeblog.getUsersBlogs', 'metaWeblog.getUserInfo')))
57
+if (in_array($method_name, array('metaWeblog.deletePost', 'metaWeblog.getUsersBlogs', 'metaWeblog.getUserInfo')))
58 58
 {
59 59
 	$method_name = str_replace('metaWeblog.', 'blogger.', $method_name);
60 60
 }
61 61
 
62 62
 // Get user_id, password and attempt log-in
63
-$user_id = trim((string)$params[1]->value->string);
64
-$password = trim((string)$params[2]->value->string);
63
+$user_id = trim((string) $params[1]->value->string);
64
+$password = trim((string) $params[2]->value->string);
65 65
 
66 66
 // Before executing the module, authentication is processed.
67
-if($called_position == 'before_module_init')
67
+if ($called_position == 'before_module_init')
68 68
 {
69 69
 	// Attempt log-in by using member controller
70
-	if($user_id && $password)
70
+	if ($user_id && $password)
71 71
 	{
72 72
 		$oMemberController = getController('member');
73 73
 		$output = $oMemberController->doLogin($user_id, $password);
74 74
 		// If login fails, an error message appears
75
-		if(!$output->toBool())
75
+		if (!$output->toBool())
76 76
 		{
77 77
 			$content = getXmlRpcFailure(1, $output->getMessage());
78 78
 			printContent($content);
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 }
87 87
 
88 88
 // Before module processing, handle requests from blogapi tool and then terminate.
89
-if($called_position == 'before_module_proc')
89
+if ($called_position == 'before_module_proc')
90 90
 {
91 91
 	// Check writing permission 
92
-	if(!$this->grant->write_document)
92
+	if (!$this->grant->write_document)
93 93
 	{
94 94
 		printContent(getXmlRpcFailure(1, 'no permission'));
95 95
 	}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	$tmp_uploaded_path = sprintf(_XE_PATH_ . 'files/cache/blogapi/%s/%s/', $this->mid, $user_id);
103 103
 	$uploaded_target_path = sprintf(_XE_PATH_ . 'files/cache/blogapi/%s/%s/', $this->mid, $user_id);
104 104
 
105
-	switch($method_name)
105
+	switch ($method_name)
106 106
 	{
107 107
 		// Blog information
108 108
 		case 'blogger.getUsersBlogs' :
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 		// Return a list of categories
120 120
 		case 'metaWeblog.getCategories' :
121 121
 			$category_obj_list = array();
122
-			if($category_list)
122
+			if ($category_list)
123 123
 			{
124
-				foreach($category_list as $category_srl => $category_info)
124
+				foreach ($category_list as $category_srl => $category_info)
125 125
 				{
126 126
 					$obj = new stdClass();
127 127
 					$obj->description = $category_info->title;
@@ -142,35 +142,35 @@  discard block
 block discarded – undo
142 142
 			// Check a file upload permission
143 143
 			$oFileModel = getModel('file');
144 144
 			$file_module_config = $oFileModel->getFileModuleConfig($this->module_srl);
145
-			if(is_array($file_module_config->download_grant) && count($file_module_config->download_grant) > 0)
145
+			if (is_array($file_module_config->download_grant) && count($file_module_config->download_grant) > 0)
146 146
 			{
147 147
 				$logged_info = Context::get('logged_info');
148
-				if($logged_info->is_admin != 'Y')
148
+				if ($logged_info->is_admin != 'Y')
149 149
 				{
150 150
 					$is_permitted = false;
151
-					for($i = 0; $i < count($file_module_config->download_grant); $i++)
151
+					for ($i = 0; $i < count($file_module_config->download_grant); $i++)
152 152
 					{
153 153
 						$group_srl = $file_module_config->download_grant[$i];
154
-						if($logged_info->group_list[$group_srl])
154
+						if ($logged_info->group_list[$group_srl])
155 155
 						{
156 156
 							$is_permitted = true;
157 157
 							break;
158 158
 						}
159 159
 					}
160
-					if(!$is_permitted){
160
+					if (!$is_permitted) {
161 161
 						printContent(getXmlRpcFailure(1, 'no permission'));
162 162
 					}
163 163
 				}
164 164
 			}
165 165
 
166 166
 			$fileinfo = $params[3]->value->struct->member;
167
-			foreach($fileinfo as $key => $val)
167
+			foreach ($fileinfo as $key => $val)
168 168
 			{
169
-				$nodename = (string)$val->name;
170
-				if($nodename == 'bits')
171
-					$filedata = base64_decode((string)$val->value->base64);
172
-				elseif($nodename == 'name')
173
-					$filename = (string)$val->value->string;
169
+				$nodename = (string) $val->name;
170
+				if ($nodename == 'bits')
171
+					$filedata = base64_decode((string) $val->value->base64);
172
+				elseif ($nodename == 'name')
173
+					$filename = (string) $val->value->string;
174 174
 			}
175 175
 
176 176
 			$tmp_arr = explode('/', $filename);
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 			break;
189 189
 		// Get posts
190 190
 		case 'metaWeblog.getPost' :
191
-			$document_srl = (string)$params[0]->value->string;
192
-			if(!$document_srl)
191
+			$document_srl = (string) $params[0]->value->string;
192
+			if (!$document_srl)
193 193
 			{
194 194
 				printContent(getXmlRpcFailure(1, 'no permission'));
195 195
 			}
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 			{
198 198
 				$oDocumentModel = getModel('document');
199 199
 				$oDocument = $oDocumentModel->getDocument($document_srl);
200
-				if(!$oDocument->isExists() || !$oDocument->isGranted())
200
+				if (!$oDocument->isExists() || !$oDocument->isGranted())
201 201
 				{
202 202
 					printContent(getXmlRpcFailure(1, 'no permission'));
203 203
 				}
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 				{
206 206
 					// Get a list of categories and set Context
207 207
 					$category = "";
208
-					if($oDocument->get('category_srl'))
208
+					if ($oDocument->get('category_srl'))
209 209
 					{
210 210
 						$oDocumentModel = getModel('document');
211 211
 						$category_list = $oDocumentModel->getCategoryList($oDocument->get('module_srl'));
212
-						if($category_list[$oDocument->get('category_srl')])
212
+						if ($category_list[$oDocument->get('category_srl')])
213 213
 						{
214 214
 							$category = $category_list[$oDocument->get('category_srl')]->title;
215 215
 						}
@@ -251,35 +251,35 @@  discard block
 block discarded – undo
251 251
 			$obj = new stdClass();
252 252
 			$info = $params[3];
253 253
 			// Get information of post, title, and category
254
-			foreach($info->value->struct->member as $val)
254
+			foreach ($info->value->struct->member as $val)
255 255
 			{
256
-				switch((string)$val->name)
256
+				switch ((string) $val->name)
257 257
 				{
258 258
 					case 'title' :
259
-						$obj->title = (string)$val->value->string;
259
+						$obj->title = (string) $val->value->string;
260 260
 						break;
261 261
 					case 'description' :
262
-						$obj->content = (string)$val->value->string;
262
+						$obj->content = (string) $val->value->string;
263 263
 						break;
264 264
 					case 'categories' :
265 265
 						$categories = $val->value->array->data->value;
266
-						$category = (string)$categories[0]->string;
267
-						if($category && $category_list)
266
+						$category = (string) $categories[0]->string;
267
+						if ($category && $category_list)
268 268
 						{
269
-							foreach($category_list as $category_srl => $category_info)
269
+							foreach ($category_list as $category_srl => $category_info)
270 270
 							{
271
-								if($category_info->title == $category)
271
+								if ($category_info->title == $category)
272 272
 									$obj->category_srl = $category_srl;
273 273
 							}
274 274
 						}
275 275
 						break;
276 276
 					case 'tagwords' :
277 277
 						$tags = $val->value->array->data->value;
278
-						foreach($tags as $tag)
278
+						foreach ($tags as $tag)
279 279
 						{
280
-							$tag_list[] = (string)$tag->string;
280
+							$tag_list[] = (string) $tag->string;
281 281
 						}
282
-						if(count($tag_list))
282
+						if (count($tag_list))
283 283
 							$obj->tags = implode(',', $tag_list);
284 284
 						break;
285 285
 				}
@@ -291,14 +291,14 @@  discard block
 block discarded – undo
291 291
 			$obj->module_srl = $this->module_srl;
292 292
 
293 293
 			// Attachment
294
-			if(is_dir($tmp_uploaded_path))
294
+			if (is_dir($tmp_uploaded_path))
295 295
 			{
296 296
 				$file_list = FileHandler::readDir($tmp_uploaded_path);
297 297
 				$file_count = count($file_list);
298
-				if($file_count)
298
+				if ($file_count)
299 299
 				{
300 300
 					$oFileController = getController('file');
301
-					for($i = 0; $i < $file_count; $i++)
301
+					for ($i = 0; $i < $file_count; $i++)
302 302
 					{
303 303
 						$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
304 304
 						$file_info['name'] = $file_list[$i];
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			$obj->homepage = $logged_info->homepage;
325 325
 			$output = $oDocumentController->insertDocument($obj, TRUE);
326 326
 
327
-			if(!$output->toBool())
327
+			if (!$output->toBool())
328 328
 			{
329 329
 				$content = getXmlRpcFailure(1, $output->getMessage());
330 330
 			}
@@ -339,17 +339,17 @@  discard block
 block discarded – undo
339 339
 
340 340
 		// Edit post
341 341
 		case 'metaWeblog.editPost' :
342
-			$tmp_val = (string)$params[0]->value->string;
343
-			if(!$tmp_val)
344
-				$tmp_val = (string)$params[0]->value->i4;
345
-			if(!$tmp_val)
342
+			$tmp_val = (string) $params[0]->value->string;
343
+			if (!$tmp_val)
344
+				$tmp_val = (string) $params[0]->value->i4;
345
+			if (!$tmp_val)
346 346
 			{
347 347
 				$content = getXmlRpcFailure(1, 'no permission');
348 348
 				break;
349 349
 			}
350 350
 			$tmp_arr = explode('/', $tmp_val);
351 351
 			$document_srl = array_pop($tmp_arr);
352
-			if(!$document_srl)
352
+			if (!$document_srl)
353 353
 			{
354 354
 				$content = getXmlRpcFailure(1, 'no permission');
355 355
 				break;
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			$oDocumentModel = getModel('document');
359 359
 			$oDocument = $oDocumentModel->getDocument($document_srl);
360 360
 			// Check if a permission to modify a document is granted
361
-			if(!$oDocument->isGranted())
361
+			if (!$oDocument->isGranted())
362 362
 			{
363 363
 				$content = getXmlRpcFailure(1, 'no permission');
364 364
 				break;
@@ -368,35 +368,35 @@  discard block
 block discarded – undo
368 368
 
369 369
 			$info = $params[3];
370 370
 			// Get information of post, title, and category
371
-			foreach($info->value->struct->member as $val)
371
+			foreach ($info->value->struct->member as $val)
372 372
 			{
373
-				switch((string)$val->name)
373
+				switch ((string) $val->name)
374 374
 				{
375 375
 					case 'title' :
376
-						$obj->title = (string)$val->value->string;
376
+						$obj->title = (string) $val->value->string;
377 377
 						break;
378 378
 					case 'description' :
379
-						$obj->content = (string)$val->value->string;
379
+						$obj->content = (string) $val->value->string;
380 380
 						break;
381 381
 					case 'categories' :
382 382
 						$categories = $val->value->array->data->value;
383
-						$category = (string)$categories[0]->string;
384
-						if($category && $category_list)
383
+						$category = (string) $categories[0]->string;
384
+						if ($category && $category_list)
385 385
 						{
386
-							foreach($category_list as $category_srl => $category_info)
386
+							foreach ($category_list as $category_srl => $category_info)
387 387
 							{
388
-								if($category_info->title == $category)
388
+								if ($category_info->title == $category)
389 389
 									$obj->category_srl = $category_srl;
390 390
 							}
391 391
 						}
392 392
 						break;
393 393
 					case 'tagwords' :
394 394
 						$tags = $val->value->array->data->value;
395
-						foreach($tags as $tag)
395
+						foreach ($tags as $tag)
396 396
 						{
397
-							$tag_list[] = (string)$tag->string;
397
+							$tag_list[] = (string) $tag->string;
398 398
 						}
399
-						if(count($tag_list))
399
+						if (count($tag_list))
400 400
 							$obj->tags = implode(',', $tag_list);
401 401
 						break;
402 402
 				}
@@ -405,20 +405,20 @@  discard block
 block discarded – undo
405 405
 			$obj->document_srl = $document_srl;
406 406
 			$obj->module_srl = $this->module_srl;
407 407
 			// Attachment
408
-			if(is_dir($tmp_uploaded_path))
408
+			if (is_dir($tmp_uploaded_path))
409 409
 			{
410 410
 				$file_list = FileHandler::readDir($tmp_uploaded_path);
411 411
 				$file_count = count($file_list);
412
-				if($file_count)
412
+				if ($file_count)
413 413
 				{
414 414
 					$oFileController = getController('file');
415
-					for($i = 0; $i < $file_count; $i++)
415
+					for ($i = 0; $i < $file_count; $i++)
416 416
 					{
417 417
 						$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
418 418
 						$file_info['name'] = $file_list[$i];
419 419
 
420 420
 						$moved_filename = sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $file_info['name']);
421
-						if(file_exists($moved_filename))
421
+						if (file_exists($moved_filename))
422 422
 							continue;
423 423
 
424 424
 						$fileOutput = $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 			$oDocumentController = getController('document');
434 434
 			$output = $oDocumentController->updateDocument($oDocument, $obj, TRUE);
435 435
 
436
-			if(!$output->toBool())
436
+			if (!$output->toBool())
437 437
 			{
438 438
 				$content = getXmlRpcFailure(1, $output->getMessage());
439 439
 			}
@@ -447,19 +447,19 @@  discard block
 block discarded – undo
447 447
 			break;
448 448
 		// Delete the post
449 449
 		case 'blogger.deletePost' :
450
-			$tmp_val = (string)$params[1]->value->string;
450
+			$tmp_val = (string) $params[1]->value->string;
451 451
 			$tmp_arr = explode('/', $tmp_val);
452 452
 			$document_srl = array_pop($tmp_arr);
453 453
 			// Get a document
454 454
 			$oDocumentModel = getModel('document');
455 455
 			$oDocument = $oDocumentModel->getDocument($document_srl);
456 456
 			// If the document exists
457
-			if(!$oDocument->isExists())
457
+			if (!$oDocument->isExists())
458 458
 			{
459 459
 				$content = getXmlRpcFailure(1, 'not exists');
460 460
 				// Check if a permission to delete a document is granted
461 461
 			}
462
-			elseif(!$oDocument->isGranted())
462
+			elseif (!$oDocument->isGranted())
463 463
 			{
464 464
 				$content = getXmlRpcFailure(1, 'no permission');
465 465
 				break;
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 			{
470 470
 				$oDocumentController = getController('document');
471 471
 				$output = $oDocumentController->deleteDocument($document_srl);
472
-				if(!$output->toBool())
472
+				if (!$output->toBool())
473 473
 					$content = getXmlRpcFailure(1, $output->getMessage());
474 474
 				else
475 475
 					$content = getXmlRpcResponse(true);
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 			$args->search_target = 'member_srl';
490 490
 			$args->search_keyword = $logged_info->member_srl;
491 491
 			$output = $oDocumentModel->getDocumentList($args);
492
-			if(!$output->toBool() || !$output->data)
492
+			if (!$output->toBool() || !$output->data)
493 493
 			{
494 494
 				$content = getXmlRpcFailure(1, 'post not founded');
495 495
 			}
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
 				$oEditorController = getController('editor');
499 499
 
500 500
 				$posts = array();
501
-				foreach($output->data as $key => $oDocument)
501
+				foreach ($output->data as $key => $oDocument)
502 502
 				{
503 503
 					$post = new stdClass();
504 504
 					$post->categories = array();
505 505
 					$post->dateCreated = date("Ymd", $oDocument->getRegdateTime()) . 'T' . date("H:i:s", $oDocument->getRegdateTime());
506
-					$post->description = sprintf('<![CDATA[%s]]>',$oEditorController->transComponent($oDocument->getContent(false, false, true, false)));
506
+					$post->description = sprintf('<![CDATA[%s]]>', $oEditorController->transComponent($oDocument->getContent(false, false, true, false)));
507 507
 					$post->link = $post->permaLink = getFullUrl('', 'document_srl', $oDocument->document_srl);
508 508
 					$post->postid = $oDocument->document_srl;
509 509
 					$post->title = htmlspecialchars($oDocument->get('title'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
Please login to merge, or discard this patch.
Braces   +41 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,8 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if(!defined('__XE__'))
4
+if(!defined('__XE__')) {
5 5
 	exit();
6
+}
6 7
 
7 8
 /**
8 9
  * @file blogapicounter.addon.php
@@ -47,7 +48,9 @@  discard block
 block discarded – undo
47 48
 	exit;
48 49
 }
49 50
 
50
-if(version_compare(PHP_VERSION, '5.2.11', '<=')) libxml_disable_entity_loader(true);
51
+if(version_compare(PHP_VERSION, '5.2.11', '<=')) {
52
+	libxml_disable_entity_loader(true);
53
+}
51 54
 $xml = new SimpleXMLElement($xml, LIBXML_NONET | LIBXML_NOENT);
52 55
 
53 56
 $method_name = (string)$xml->methodName;
@@ -77,8 +80,7 @@  discard block
 block discarded – undo
77 80
 			$content = getXmlRpcFailure(1, $output->getMessage());
78 81
 			printContent($content);
79 82
 		}
80
-	}
81
-	else
83
+	} else
82 84
 	{
83 85
 		$content = getXmlRpcFailure(1, 'not logged');
84 86
 		printContent($content);
@@ -167,10 +169,11 @@  discard block
 block discarded – undo
167 169
 			foreach($fileinfo as $key => $val)
168 170
 			{
169 171
 				$nodename = (string)$val->name;
170
-				if($nodename == 'bits')
171
-					$filedata = base64_decode((string)$val->value->base64);
172
-				elseif($nodename == 'name')
173
-					$filename = (string)$val->value->string;
172
+				if($nodename == 'bits') {
173
+									$filedata = base64_decode((string)$val->value->base64);
174
+				} elseif($nodename == 'name') {
175
+									$filename = (string)$val->value->string;
176
+				}
174 177
 			}
175 178
 
176 179
 			$tmp_arr = explode('/', $filename);
@@ -192,16 +195,14 @@  discard block
 block discarded – undo
192 195
 			if(!$document_srl)
193 196
 			{
194 197
 				printContent(getXmlRpcFailure(1, 'no permission'));
195
-			}
196
-			else
198
+			} else
197 199
 			{
198 200
 				$oDocumentModel = getModel('document');
199 201
 				$oDocument = $oDocumentModel->getDocument($document_srl);
200 202
 				if(!$oDocument->isExists() || !$oDocument->isGranted())
201 203
 				{
202 204
 					printContent(getXmlRpcFailure(1, 'no permission'));
203
-				}
204
-				else
205
+				} else
205 206
 				{
206 207
 					// Get a list of categories and set Context
207 208
 					$category = "";
@@ -268,8 +269,9 @@  discard block
 block discarded – undo
268 269
 						{
269 270
 							foreach($category_list as $category_srl => $category_info)
270 271
 							{
271
-								if($category_info->title == $category)
272
-									$obj->category_srl = $category_srl;
272
+								if($category_info->title == $category) {
273
+																	$obj->category_srl = $category_srl;
274
+								}
273 275
 							}
274 276
 						}
275 277
 						break;
@@ -279,8 +281,9 @@  discard block
 block discarded – undo
279 281
 						{
280 282
 							$tag_list[] = (string)$tag->string;
281 283
 						}
282
-						if(count($tag_list))
283
-							$obj->tags = implode(',', $tag_list);
284
+						if(count($tag_list)) {
285
+													$obj->tags = implode(',', $tag_list);
286
+						}
284 287
 						break;
285 288
 				}
286 289
 			}
@@ -327,8 +330,7 @@  discard block
 block discarded – undo
327 330
 			if(!$output->toBool())
328 331
 			{
329 332
 				$content = getXmlRpcFailure(1, $output->getMessage());
330
-			}
331
-			else
333
+			} else
332 334
 			{
333 335
 				$content = getXmlRpcResponse(strval($document_srl));
334 336
 			}
@@ -340,8 +342,9 @@  discard block
 block discarded – undo
340 342
 		// Edit post
341 343
 		case 'metaWeblog.editPost' :
342 344
 			$tmp_val = (string)$params[0]->value->string;
343
-			if(!$tmp_val)
344
-				$tmp_val = (string)$params[0]->value->i4;
345
+			if(!$tmp_val) {
346
+							$tmp_val = (string)$params[0]->value->i4;
347
+			}
345 348
 			if(!$tmp_val)
346 349
 			{
347 350
 				$content = getXmlRpcFailure(1, 'no permission');
@@ -385,8 +388,9 @@  discard block
 block discarded – undo
385 388
 						{
386 389
 							foreach($category_list as $category_srl => $category_info)
387 390
 							{
388
-								if($category_info->title == $category)
389
-									$obj->category_srl = $category_srl;
391
+								if($category_info->title == $category) {
392
+																	$obj->category_srl = $category_srl;
393
+								}
390 394
 							}
391 395
 						}
392 396
 						break;
@@ -396,8 +400,9 @@  discard block
 block discarded – undo
396 400
 						{
397 401
 							$tag_list[] = (string)$tag->string;
398 402
 						}
399
-						if(count($tag_list))
400
-							$obj->tags = implode(',', $tag_list);
403
+						if(count($tag_list)) {
404
+													$obj->tags = implode(',', $tag_list);
405
+						}
401 406
 						break;
402 407
 				}
403 408
 			}
@@ -418,8 +423,9 @@  discard block
 block discarded – undo
418 423
 						$file_info['name'] = $file_list[$i];
419 424
 
420 425
 						$moved_filename = sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $file_info['name']);
421
-						if(file_exists($moved_filename))
422
-							continue;
426
+						if(file_exists($moved_filename)) {
427
+													continue;
428
+						}
423 429
 
424 430
 						$fileOutput = $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
425 431
 						$uploaded_filename = $fileOutput->get('uploaded_filename');
@@ -436,8 +442,7 @@  discard block
 block discarded – undo
436 442
 			if(!$output->toBool())
437 443
 			{
438 444
 				$content = getXmlRpcFailure(1, $output->getMessage());
439
-			}
440
-			else
445
+			} else
441 446
 			{
442 447
 				$content = getXmlRpcResponse(true);
443 448
 				FileHandler::removeDir($tmp_uploaded_path);
@@ -458,21 +463,20 @@  discard block
 block discarded – undo
458 463
 			{
459 464
 				$content = getXmlRpcFailure(1, 'not exists');
460 465
 				// Check if a permission to delete a document is granted
461
-			}
462
-			elseif(!$oDocument->isGranted())
466
+			} elseif(!$oDocument->isGranted())
463 467
 			{
464 468
 				$content = getXmlRpcFailure(1, 'no permission');
465 469
 				break;
466 470
 				// Delete
467
-			}
468
-			else
471
+			} else
469 472
 			{
470 473
 				$oDocumentController = getController('document');
471 474
 				$output = $oDocumentController->deleteDocument($document_srl);
472
-				if(!$output->toBool())
473
-					$content = getXmlRpcFailure(1, $output->getMessage());
474
-				else
475
-					$content = getXmlRpcResponse(true);
475
+				if(!$output->toBool()) {
476
+									$content = getXmlRpcFailure(1, $output->getMessage());
477
+				} else {
478
+									$content = getXmlRpcResponse(true);
479
+				}
476 480
 			}
477 481
 
478 482
 			printContent($content);
@@ -492,8 +496,7 @@  discard block
 block discarded – undo
492 496
 			if(!$output->toBool() || !$output->data)
493 497
 			{
494 498
 				$content = getXmlRpcFailure(1, 'post not founded');
495
-			}
496
-			else
499
+			} else
497 500
 			{
498 501
 				$oEditorController = getController('editor');
499 502
 
Please login to merge, or discard this patch.