Completed
Push — master ( 20dff3...12c298 )
by Hadi
33:00 queued 11:31
created
api/src/Framework.php 1 patch
Spacing   +111 added lines, -113 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			$GLOBALS['egw_info']['server']['template_set'] = 'jdots';
117 117
 		}
118 118
 		// eg. "default" is only used for login at the moment
119
-		if (!class_exists($class=$GLOBALS['egw_info']['server']['template_set'].'_framework'))
119
+		if (!class_exists($class = $GLOBALS['egw_info']['server']['template_set'].'_framework'))
120 120
 		{
121 121
 			$class = __CLASS__.'\\Minimal';
122 122
 		}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	{
136 136
 		return preg_match('/^[A-Z0-9_-]+$/i', $template) &&
137 137
 			file_exists(EGW_SERVER_ROOT.'/'.$template) &&
138
-			file_exists($file=EGW_SERVER_ROOT.'/'.$template.'/setup/setup.inc.php') &&
138
+			file_exists($file = EGW_SERVER_ROOT.'/'.$template.'/setup/setup.inc.php') &&
139 139
 			include_once($file) && !empty($GLOBALS['egw_info']['template'][$template]);
140 140
 	}
141 141
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		Header\ContentSecurityPolicy::send();
151 151
 
152 152
 		// allow client-side to detect first load aka just logged in
153
-		$reload_count =& Cache::getSession(__CLASS__, 'framework-reload');
153
+		$reload_count = & Cache::getSession(__CLASS__, 'framework-reload');
154 154
 		self::$extra['framework-reload'] = (int)(bool)$reload_count++;
155 155
 	}
156 156
 
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	 * @param string $link_app =null if appname or true, some templates generate a special link-handler url
181 181
 	 * @return string	The full url after processing
182 182
 	 */
183
-	static function link($url, $extravars = '', $link_app=null)
183
+	static function link($url, $extravars = '', $link_app = null)
184 184
 	{
185
-		unset($link_app);	// not used by required by function signature
185
+		unset($link_app); // not used by required by function signature
186 186
 		return $GLOBALS['egw']->session->link($url, $extravars);
187 187
 	}
188 188
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param string $url url to redirect to
205 205
 	 * @param string $link_app =null appname to redirect for, default currentapp
206 206
 	 */
207
-	static function redirect($url, $link_app=null)
207
+	static function redirect($url, $link_app = null)
208 208
 	{
209 209
 		// Determines whether the current output buffer should be flushed
210 210
 		$do_flush = true;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		else
227 227
 		{
228 228
 			$file = $line = null;
229
-			if (headers_sent($file,$line))
229
+			if (headers_sent($file, $line))
230 230
 			{
231 231
 				throw new Exception\AssertionFailed(__METHOD__."('".htmlspecialchars($url)."') can NOT redirect, output already started at $file line $line!");
232 232
 			}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @param string $link_app =null if appname or true, some templates generate a special link-handler url
262 262
 	 * @return string	The full url after processing
263 263
 	 */
264
-	static function redirect_link($url, $extravars='', $link_app=null)
264
+	static function redirect_link($url, $extravars = '', $link_app = null)
265 265
 	{
266 266
 		self::redirect(self::link($url, $extravars), $link_app);
267 267
 	}
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @param string $navbar =null show the navigation, default !$GLOBALS['egw_info']['flags']['nonavbar'], false gives a typical popu
277 277
 	 *
278 278
 	 */
279
-	function render($content,$app_header=null,$navbar=null)
279
+	function render($content, $app_header = null, $navbar = null)
280 280
 	{
281 281
 		if (!is_null($app_header)) $GLOBALS['egw_info']['flags']['app_header'] = $app_header;
282 282
 		if (!is_null($navbar)) $GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return string with Html
299 299
 	 */
300
-	abstract function header(array $extra=array());
300
+	abstract function header(array $extra = array());
301 301
 
302 302
 	/**
303 303
 	 * Returns the Html from the body-tag til the main application area (incl. opening div tag)
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @return boolean $consider_navbar_not_yet_called_as_true=true
318 318
 	 * @return boolean
319 319
 	 */
320
-	abstract function isTop($consider_navbar_not_yet_called_as_true=true);
320
+	abstract function isTop($consider_navbar_not_yet_called_as_true = true);
321 321
 
322 322
 	/**
323 323
 	 * Returns the content of one sidebox
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	 * @param array $file
328 328
 	 * @param string $type =null 'admin', 'preferences', 'favorites', ...
329 329
 	 */
330
-	abstract function sidebox($appname,$menu_title,$file,$type=null);
330
+	abstract function sidebox($appname, $menu_title, $file, $type = null);
331 331
 
332 332
 	/**
333 333
 	 * Returns the Html from the closing div of the main application area to the closing html-tag
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 * @param string $extra_vars for login url
343 343
 	 * @param string $change_passwd =null string with message to render input fields for password change
344 344
 	 */
345
-	function login_screen($extra_vars, $change_passwd=null)
345
+	function login_screen($extra_vars, $change_passwd = null)
346 346
 	{
347 347
 		(new Framework\Login($this))->screen($extra_vars, $change_passwd);
348 348
 	}
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
 	public function _get_footer()
381 381
 	{
382 382
 		$var = Array(
383
-			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
383
+			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images',
384 384
 			'version'        => $GLOBALS['egw_info']['server']['versions']['api']
385 385
 		);
386 386
 		$var['page_generation_time'] = '';
387
-		if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
387
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
388 388
 		{
389 389
 			$times = self::get_page_generation_time();
390 390
 
@@ -428,16 +428,16 @@  discard block
 block discarded – undo
428 428
 	static public function _get_body_attribs()
429 429
 	{
430 430
 		$js = '';
431
-		foreach(self::$body_tags as $what => $data)
431
+		foreach (self::$body_tags as $what => $data)
432 432
 		{
433 433
 			if (!empty($data))
434 434
 			{
435
-				if($what == 'onLoad')
435
+				if ($what == 'onLoad')
436 436
 				{
437
-					$js .= 'onLoad="egw_LAB.wait(function() {'. htmlspecialchars($data).'})"';
437
+					$js .= 'onLoad="egw_LAB.wait(function() {'.htmlspecialchars($data).'})"';
438 438
 					continue;
439 439
 				}
440
-				$js .= ' '.$what.'="' . htmlspecialchars($data) . '"';
440
+				$js .= ' '.$what.'="'.htmlspecialchars($data).'"';
441 441
 			}
442 442
 		}
443 443
 		return $js;
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	 * @param array $extra =array() extra attributes passed as data-attribute to egw.js
450 450
 	 * @return array
451 451
 	 */
452
-	protected function _get_header(array $extra=array())
452
+	protected function _get_header(array $extra = array())
453 453
 	{
454 454
 		// display password expires in N days message once per session
455 455
 		$message = null;
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 		}
461 461
 
462 462
 		// get used language code (with a little xss check, if someone tries to sneak something in)
463
-		if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$GLOBALS['egw_info']['user']['preferences']['common']['lang']))
463
+		if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $GLOBALS['egw_info']['user']['preferences']['common']['lang']))
464 464
 		{
465 465
 			$lang_code = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
466 466
 		}
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 		// send appheader to clientside
481 481
 		$extra['app-header'] = $app_header;
482 482
 
483
-		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots ='<meta name="robots" content="none" />';
483
+		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots = '<meta name="robots" content="none" />';
484 484
 
485 485
 		$var['favicon_file'] = self::get_login_logo_or_bg_url('favicon_file', 'favicon.ico');
486 486
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 			$include_wz_tooltip = '<script src="'.$GLOBALS['egw_info']['server']['webserver_url'].
491 491
 				$wz_tooltip.'?'.filemtime(EGW_SERVER_ROOT.$wz_tooltip).'" type="text/javascript"></script>';
492 492
 		}
493
-		return $this->_get_css()+array(
493
+		return $this->_get_css() + array(
494 494
 			'img_icon'			=> $var['favicon_file'],
495 495
 			'img_shortcut'		=> $var['favicon_file'],
496 496
 			'pngfix'        	=> $pngfix,
@@ -514,15 +514,15 @@  discard block
 block discarded – undo
514 514
 	 */
515 515
 	protected function _get_navbar($apps)
516 516
 	{
517
-		$var['img_root'] = $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$this->template.'/images';
517
+		$var['img_root'] = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/templates/'.$this->template.'/images';
518 518
 
519
-		if(isset($GLOBALS['egw_info']['flags']['app_header']))
519
+		if (isset($GLOBALS['egw_info']['flags']['app_header']))
520 520
 		{
521 521
 			$var['current_app_title'] = $GLOBALS['egw_info']['flags']['app_header'];
522 522
 		}
523 523
 		else
524 524
 		{
525
-			$var['current_app_title']=$apps[$GLOBALS['egw_info']['flags']['currentapp']]['title'];
525
+			$var['current_app_title'] = $apps[$GLOBALS['egw_info']['flags']['currentapp']]['title'];
526 526
 		}
527 527
 		$var['currentapp'] = $GLOBALS['egw_info']['flags']['currentapp'];
528 528
 
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
 
532 532
 		$var['user_info'] = $this->_user_time_info();
533 533
 
534
-		if($GLOBALS['egw_info']['user']['account_lastpwd_change'] == 0)
534
+		if ($GLOBALS['egw_info']['user']['account_lastpwd_change'] == 0)
535 535
 		{
536 536
 			$api_messages = lang('You are required to change your password during your first login').'<br />'.
537
-				lang('Click this image on the navbar: %1','<img src="'.Image::find('preferences','navbar.gif').'">');
537
+				lang('Click this image on the navbar: %1', '<img src="'.Image::find('preferences', 'navbar.gif').'">');
538 538
 		}
539
-		elseif($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] && $GLOBALS['egw_info']['user']['account_lastpwd_change'] < time() - (86400*$GLOBALS['egw_info']['server']['change_pwd_every_x_days']))
539
+		elseif ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] && $GLOBALS['egw_info']['user']['account_lastpwd_change'] < time() - (86400 * $GLOBALS['egw_info']['server']['change_pwd_every_x_days']))
540 540
 		{
541
-			$api_messages = lang('it has been more then %1 days since you changed your password',$GLOBALS['egw_info']['server']['change_pwd_every_x_days']);
541
+			$api_messages = lang('it has been more then %1 days since you changed your password', $GLOBALS['egw_info']['server']['change_pwd_every_x_days']);
542 542
 		}
543 543
 
544 544
 		$var['logo_header'] = $var['logo_file'] = self::get_login_logo_or_bg_url('login_logo_file', 'logo');
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
 			$var['logo_header'] = self::get_login_logo_or_bg_url('login_logo_header', 'logo');
549 549
 		}
550 550
 
551
-		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url']?$GLOBALS['egw_info']['server']['login_logo_url']:'http://www.egroupware.org';
551
+		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url'] ? $GLOBALS['egw_info']['server']['login_logo_url'] : 'http://www.egroupware.org';
552 552
 
553
-		if (substr($var['logo_url'],0,4) != 'http')
553
+		if (substr($var['logo_url'], 0, 4) != 'http')
554 554
 		{
555 555
 			$var['logo_url'] = 'http://'.$var['logo_url'];
556 556
 		}
557
-		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title']?$GLOBALS['egw_info']['server']['login_logo_title']:'www.egroupware.org';
557
+		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title'] ? $GLOBALS['egw_info']['server']['login_logo_title'] : 'www.egroupware.org';
558 558
 
559 559
 		return $var;
560 560
 	}
@@ -567,11 +567,10 @@  discard block
 block discarded – undo
567 567
 	 *
568 568
 	 * @return string returns full url of the image
569 569
 	 */
570
-	static function get_login_logo_or_bg_url ($type, $find_type)
570
+	static function get_login_logo_or_bg_url($type, $find_type)
571 571
 	{
572 572
 		$url = is_array($GLOBALS['egw_info']['server'][$type]) ?
573
-			$GLOBALS['egw_info']['server'][$type][0] :
574
-			$GLOBALS['egw_info']['server'][$type];
573
+			$GLOBALS['egw_info']['server'][$type][0] : $GLOBALS['egw_info']['server'][$type];
575 574
 
576 575
 		if (substr($url, 0, 4) == 'http' ||
577 576
 			$url[0] == '/')
@@ -580,7 +579,7 @@  discard block
 block discarded – undo
580 579
 		}
581 580
 		else
582 581
 		{
583
-			return Image::find('api',$url ? $url : $find_type, '', null);
582
+			return Image::find('api', $url ? $url : $find_type, '', null);
584 583
 		}
585 584
 	}
586 585
 
@@ -592,14 +591,14 @@  discard block
 block discarded – undo
592 591
 	protected static function _user_time_info()
593 592
 	{
594 593
 		$now = new DateTime();
595
-		$user_info = '<span>'.lang($now->format('l')) . ' ' . $now->format(true).'</span>';
594
+		$user_info = '<span>'.lang($now->format('l')).' '.$now->format(true).'</span>';
596 595
 
597 596
 		$user_tzs = DateTime::getUserTimezones();
598 597
 		if (count($user_tzs) > 1)
599 598
 		{
600 599
 			$tz = $GLOBALS['egw_info']['user']['preferences']['common']['tz'];
601
-			$user_info .= Html::form(Html::select('tz',$tz,$user_tzs,true),array(),
602
-				'/index.php','','tz_selection',' style="display: inline;"','GET');
600
+			$user_info .= Html::form(Html::select('tz', $tz, $user_tzs, true), array(),
601
+				'/index.php', '', 'tz_selection', ' style="display: inline;"', 'GET');
603 602
 		}
604 603
 		return $user_info;
605 604
 	}
@@ -647,12 +646,12 @@  discard block
 block discarded – undo
647 646
 	 */
648 647
 	protected static function _current_users()
649 648
 	{
650
-	   if( $GLOBALS['egw_info']['user']['apps']['admin'] && $GLOBALS['egw_info']['user']['preferences']['common']['show_currentusers'])
649
+	   if ($GLOBALS['egw_info']['user']['apps']['admin'] && $GLOBALS['egw_info']['user']['preferences']['common']['show_currentusers'])
651 650
 	   {
652 651
 		   return [
653 652
 			   'name' => 'current_user',
654 653
 			   'title' => lang('Current users').':'.$GLOBALS['egw']->session->session_count(),
655
-			   'url' => self::link('/index.php','menuaction=admin.admin_accesslog.sessions&ajax=true')
654
+			   'url' => self::link('/index.php', 'menuaction=admin.admin_accesslog.sessions&ajax=true')
656 655
 		   ];
657 656
 	   }
658 657
 	}
@@ -686,14 +685,14 @@  discard block
 block discarded – undo
686 685
 	 * @param array $opts =array() further params for http(s) context, eg. array('timeout' => 123)
687 686
 	 * @return resource|null context to use with file_get_context/fopen or null if no proxy configured
688 687
 	 */
689
-	public static function proxy_context($username=null, $password=null, array $opts = array())
688
+	public static function proxy_context($username = null, $password = null, array $opts = array())
690 689
 	{
691 690
 		$opts += array(
692 691
 			'method' => 'GET',
693 692
 		);
694 693
 		if (!empty($GLOBALS['egw_info']['server']['httpproxy_server']))
695 694
 		{
696
-			$opts += array (
695
+			$opts += array(
697 696
 				'proxy'  => 'tcp://'.$GLOBALS['egw_info']['server']['httpproxy_server'].':'.
698 697
 					($GLOBALS['egw_info']['server']['httpproxy_port'] ? $GLOBALS['egw_info']['server']['httpproxy_port'] : 8080),
699 698
 				'request_fulluri' => true,
@@ -722,7 +721,7 @@  discard block
 block discarded – undo
722 721
 	 * @param string &$changelog on return path to changelog
723 722
 	 * @return string
724 723
 	 */
725
-	public static function api_version(&$changelog=null)
724
+	public static function api_version(&$changelog = null)
726 725
 	{
727 726
 		return Framework\Updates::api_version($changelog);
728 727
 	}
@@ -735,7 +734,7 @@  discard block
 block discarded – undo
735 734
 	 */
736 735
 	public static function index($app)
737 736
 	{
738
-		$data =& $GLOBALS['egw_info']['user']['apps'][$app];
737
+		$data = & $GLOBALS['egw_info']['user']['apps'][$app];
739 738
 		if (!isset($data))
740 739
 		{
741 740
 			throw new Exception\WrongParameter("'$app' not a valid app for this user!");
@@ -752,7 +751,7 @@  discard block
 block discarded – undo
752 751
 				$index = '/index.php?menuaction='.$data['index'];
753 752
 			}
754 753
 		}
755
-		return self::link($index,$GLOBALS['egw_info']['flags']['params'][$app]);
754
+		return self::link($index, $GLOBALS['egw_info']['flags']['params'][$app]);
756 755
 	}
757 756
 
758 757
 	/**
@@ -794,12 +793,12 @@  discard block
 block discarded – undo
794 793
 	protected static function _get_navbar_apps()
795 794
 	{
796 795
 		$first = key($GLOBALS['egw_info']['user']['apps']);
797
-		if(is_array($GLOBALS['egw_info']['user']['apps']['admin']) && $first != 'admin')
796
+		if (is_array($GLOBALS['egw_info']['user']['apps']['admin']) && $first != 'admin')
798 797
 		{
799 798
 			$newarray['admin'] = $GLOBALS['egw_info']['user']['apps']['admin'];
800
-			foreach($GLOBALS['egw_info']['user']['apps'] as $index => $value)
799
+			foreach ($GLOBALS['egw_info']['user']['apps'] as $index => $value)
801 800
 			{
802
-				if($index != 'admin')
801
+				if ($index != 'admin')
803 802
 				{
804 803
 					$newarray[$index] = $value;
805 804
 				}
@@ -812,7 +811,7 @@  discard block
 block discarded – undo
812 811
 		unset($newarray);
813 812
 
814 813
 		$apps = array();
815
-		foreach($GLOBALS['egw_info']['user']['apps'] as $app => $data)
814
+		foreach ($GLOBALS['egw_info']['user']['apps'] as $app => $data)
816 815
 		{
817 816
 			if (is_long($app))
818 817
 			{
@@ -829,12 +828,12 @@  discard block
 block discarded – undo
829 828
 				if ($data['status'] == 4)
830 829
 				{
831 830
 					$apps[$app]['target'] = ' target="'.$app.'" onClick="'."if (this != '') { window.open(this+'".
832
-						(strpos($apps[$app]['url'],'?') !== false ? '&' : '?').
831
+						(strpos($apps[$app]['url'], '?') !== false ? '&' : '?').
833 832
 						"referer='+encodeURIComponent(location),this.target,'width=800,height=600,scrollbars=yes,resizable=yes'); return false; } else { return true; }".'"';
834 833
 				}
835
-				elseif(isset($GLOBALS['egw_info']['flags']['navbar_target']) && $GLOBALS['egw_info']['flags']['navbar_target'])
834
+				elseif (isset($GLOBALS['egw_info']['flags']['navbar_target']) && $GLOBALS['egw_info']['flags']['navbar_target'])
836 835
 				{
837
-					$apps[$app]['target'] = 'target="' . $GLOBALS['egw_info']['flags']['navbar_target'] . '"';
836
+					$apps[$app]['target'] = 'target="'.$GLOBALS['egw_info']['flags']['navbar_target'].'"';
838 837
 				}
839 838
 				else
840 839
 				{
@@ -845,9 +844,9 @@  discard block
 block discarded – undo
845 844
 				// for instance: applications with status 5 will run in background
846 845
 				$apps[$app]['status'] = $data['status'];
847 846
 
848
-				$icon = isset($data['icon']) ?  $data['icon'] : 'navbar';
847
+				$icon = isset($data['icon']) ? $data['icon'] : 'navbar';
849 848
 				$icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app;
850
-				$apps[$app]['icon']  = $apps[$app]['icon_hover']  = Image::find($icon_app,Array($icon,'nonav'),'');
849
+				$apps[$app]['icon'] = $apps[$app]['icon_hover'] = Image::find($icon_app, Array($icon, 'nonav'), '');
851 850
 			}
852 851
 		}
853 852
 
@@ -880,13 +879,13 @@  discard block
 block discarded – undo
880 879
 		// We handle this here because its special
881 880
 		$apps['about']['title'] = 'EGroupware';
882 881
 		$apps['about']['url']   = self::link('/about.php');
883
-		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api',Array('about','nonav'));
882
+		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api', Array('about', 'nonav'));
884 883
 		$apps['about']['name']  = 'about';
885 884
 
886 885
 		$apps['logout']['title'] = lang('Logout');
887 886
 		$apps['logout']['name']  = 'logout';
888 887
 		$apps['logout']['url']   = self::link('/logout.php');
889
-		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api',Array('logout','nonav'));
888
+		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api', Array('logout', 'nonav'));
890 889
 
891 890
 		return $apps;
892 891
 	}
@@ -921,7 +920,7 @@  discard block
 block discarded – undo
921 920
 			}
922 921
 			$themes_to_check[] = $this->template_dir.'/css/'.$GLOBALS['egw_info']['user']['preferences']['common']['theme'].'.css';
923 922
 			$themes_to_check[] = $this->template_dir.'/css/'.$this->template.'.css';
924
-			foreach($themes_to_check as $theme_css)
923
+			foreach ($themes_to_check as $theme_css)
925 924
 			{
926 925
 				if (file_exists(EGW_SERVER_ROOT.$theme_css)) break;
927 926
 			}
@@ -961,7 +960,7 @@  discard block
 block discarded – undo
961 960
 
962 961
 				// sending print css last, so it can overwrite anything
963 962
 				$print_css = $this->template_dir.'/print.css';
964
-				if(!file_exists(EGW_SERVER_ROOT.$print_css))
963
+				if (!file_exists(EGW_SERVER_ROOT.$print_css))
965 964
 				{
966 965
 					$print_css = '/api/templates/default/print.css';
967 966
 				}
@@ -987,7 +986,7 @@  discard block
 block discarded – undo
987 986
 	 * @param array $extra =array() extra data to pass to egw.js as data-parameter
988 987
 	 * @return string the javascript to be included
989 988
 	 */
990
-	public static function _get_js(array $extra=array())
989
+	public static function _get_js(array $extra = array())
991 990
 	{
992 991
 		$java_script = '';
993 992
 
@@ -995,7 +994,7 @@  discard block
 block discarded – undo
995 994
 		Think of conf vars etc...  ([email protected]) */
996 995
 		if (isset($GLOBALS['egw_info']['flags']['java_script_thirst']))
997 996
 		{
998
-			$java_script .= $GLOBALS['egw_info']['flags']['java_script_thirst'] . "\n";
997
+			$java_script .= $GLOBALS['egw_info']['flags']['java_script_thirst']."\n";
999 998
 		}
1000 999
 		// add configuration, link-registry, images, user-data and -perferences for non-popup windows
1001 1000
 		// specifying etag in url to force reload, as we send expires header
@@ -1018,7 +1017,7 @@  discard block
 block discarded – undo
1018 1017
 		}
1019 1018
 
1020 1019
 		$extra['url'] = $GLOBALS['egw_info']['server']['webserver_url'];
1021
-		$extra['include'] = array_map(function($str){return substr($str,1);}, self::get_script_links(true), array(1));
1020
+		$extra['include'] = array_map(function($str) {return substr($str, 1); }, self::get_script_links(true), array(1));
1022 1021
 		$extra['app'] = $GLOBALS['egw_info']['flags']['currentapp'];
1023 1022
 
1024 1023
 		// Load LABjs ONCE here
@@ -1028,18 +1027,18 @@  discard block
 block discarded – undo
1028 1027
 				'/api/js/jsapi/egw.js?'.filemtime(EGW_SERVER_ROOT.'/api/js/jsapi/egw.js').'" id="egw_script_id"';
1029 1028
 
1030 1029
 		// add values of extra parameter and class var as data attributes to script tag of egw.js
1031
-		foreach($extra+self::$extra as $name => $value)
1030
+		foreach ($extra + self::$extra as $name => $value)
1032 1031
 		{
1033 1032
 			if (is_array($value)) $value = json_encode($value);
1034 1033
 			// we need to double encode (Html::htmlspecialchars( , TRUE)), as otherwise we get invalid json, eg. for quotes
1035
-			$java_script .= ' data-'.$name."=\"". Html::htmlspecialchars($value, true)."\"";
1034
+			$java_script .= ' data-'.$name."=\"".Html::htmlspecialchars($value, true)."\"";
1036 1035
 		}
1037 1036
 		$java_script .= "></script>\n";
1038 1037
 
1039
-		if(@isset($_GET['menuaction']))
1038
+		if (@isset($_GET['menuaction']))
1040 1039
 		{
1041
-			list(, $class) = explode('.',$_GET['menuaction']);
1042
-			if(is_array($GLOBALS[$class]->public_functions) &&
1040
+			list(, $class) = explode('.', $_GET['menuaction']);
1041
+			if (is_array($GLOBALS[$class]->public_functions) &&
1043 1042
 				$GLOBALS[$class]->public_functions['java_script'])
1044 1043
 			{
1045 1044
 				$java_script .= $GLOBALS[$class]->java_script();
@@ -1048,10 +1047,10 @@  discard block
 block discarded – undo
1048 1047
 		if (isset($GLOBALS['egw_info']['flags']['java_script']))
1049 1048
 		{
1050 1049
 			// Strip out any script tags, this needs to be executed as anonymous function
1051
-			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is','/<\/script>/'),array('$2',''),$GLOBALS['egw_info']['flags']['java_script']);
1052
-			if(trim($GLOBALS['egw_info']['flags']['java_script']) != '')
1050
+			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is', '/<\/script>/'), array('$2', ''), $GLOBALS['egw_info']['flags']['java_script']);
1051
+			if (trim($GLOBALS['egw_info']['flags']['java_script']) != '')
1053 1052
 			{
1054
-				$java_script .= '<script type="text/javascript">window.egw_LAB.wait(function() {'.$GLOBALS['egw_info']['flags']['java_script'] . "});</script>\n";
1053
+				$java_script .= '<script type="text/javascript">window.egw_LAB.wait(function() {'.$GLOBALS['egw_info']['flags']['java_script']."});</script>\n";
1055 1054
 			}
1056 1055
 		}
1057 1056
 
@@ -1068,7 +1067,7 @@  discard block
 block discarded – undo
1068 1067
 	function list_themes()
1069 1068
 	{
1070 1069
 		$list = array();
1071
-		if (file_exists($file=EGW_SERVER_ROOT.$this->template_dir.'/setup/setup.inc.php') &&
1070
+		if (file_exists($file = EGW_SERVER_ROOT.$this->template_dir.'/setup/setup.inc.php') &&
1072 1071
 			(include $file) && isset($GLOBALS['egw_info']['template'][$this->template]['themes']))
1073 1072
 		{
1074 1073
 			$list = $GLOBALS['egw_info']['template'][$this->template]['themes'];
@@ -1079,8 +1078,8 @@  discard block
 block discarded – undo
1079 1078
 			{
1080 1079
 				if (preg_match('/'."\.css$".'/i', $file))
1081 1080
 				{
1082
-					list($name) = explode('.',$file);
1083
-					if (!isset($list[$name])) $list[$name] = ucfirst ($name);
1081
+					list($name) = explode('.', $file);
1082
+					if (!isset($list[$name])) $list[$name] = ucfirst($name);
1084 1083
 				}
1085 1084
 			}
1086 1085
 			closedir($dh);
@@ -1094,21 +1093,20 @@  discard block
 block discarded – undo
1094 1093
 	 * @param boolean $full_data =false true: value is array with values for keys 'name', 'title', ...
1095 1094
 	 * @returns array alphabetically sorted list of templates
1096 1095
 	 */
1097
-	static function list_templates($full_data=false)
1096
+	static function list_templates($full_data = false)
1098 1097
 	{
1099 1098
 		$list = array('pixelegg'=>null);
1100 1099
 		// templates packaged like apps in own directories (containing as setup/setup.inc.php file!)
1101 1100
 		$dr = dir(EGW_SERVER_ROOT);
1102
-		while (($entry=$dr->read()))
1101
+		while (($entry = $dr->read()))
1103 1102
 		{
1104 1103
 			if ($entry != '..' && !isset($GLOBALS['egw_info']['apps'][$entry]) && is_dir(EGW_SERVER_ROOT.'/'.$entry) &&
1105
-				file_exists($f = EGW_SERVER_ROOT . '/' . $entry .'/setup/setup.inc.php'))
1104
+				file_exists($f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php'))
1106 1105
 			{
1107 1106
 				include($f);
1108 1107
 				if (isset($GLOBALS['egw_info']['template'][$entry]))
1109 1108
 				{
1110
-					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] :
1111
-						$GLOBALS['egw_info']['template'][$entry]['title'];
1109
+					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] : $GLOBALS['egw_info']['template'][$entry]['title'];
1112 1110
 				}
1113 1111
 			}
1114 1112
 		}
@@ -1125,7 +1123,7 @@  discard block
 block discarded – undo
1125 1123
 	* @param array $vars
1126 1124
 	* @param array $apps
1127 1125
 	*/
1128
-	function topmenu(array $vars,array $apps)
1126
+	function topmenu(array $vars, array $apps)
1129 1127
 	{
1130 1128
 		// array of topmenu info items (orders of the items matter)
1131 1129
 		$topmenu_info_items = [
@@ -1143,7 +1141,7 @@  discard block
 block discarded – undo
1143 1141
 		];
1144 1142
 
1145 1143
 		// Home should be at the top before preferences
1146
-		if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
1144
+		if ($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
1147 1145
 		{
1148 1146
 			$this->_add_topmenu_item($apps['home']);
1149 1147
 		}
@@ -1152,7 +1150,7 @@  discard block
 block discarded – undo
1152 1150
 		$topmenu_preferences = ['prefs', 'acl', 'cats', 'security'];
1153 1151
 
1154 1152
 		// set topmenu preferences items
1155
-		if($GLOBALS['egw_info']['user']['apps']['preferences'])
1153
+		if ($GLOBALS['egw_info']['user']['apps']['preferences'])
1156 1154
 		{
1157 1155
 			foreach ($topmenu_preferences as $prefs)
1158 1156
 			{
@@ -1161,10 +1159,10 @@  discard block
 block discarded – undo
1161 1159
 		}
1162 1160
 
1163 1161
 		// call topmenu info items hooks
1164
-		Hooks::process('topmenu_info',array(),true);
1162
+		Hooks::process('topmenu_info', array(), true);
1165 1163
 
1166 1164
 		// Add extra items added by hooks
1167
-		foreach(self::$top_menu_extra as $extra_item) {
1165
+		foreach (self::$top_menu_extra as $extra_item) {
1168 1166
 			if ($extra_item['name'] == 'search')
1169 1167
 			{
1170 1168
 				$topmenu_info_items['search'] = '<a href="'.$extra_item['url'].'" title="'.$extra_item['title'].'"></a>';
@@ -1196,9 +1194,9 @@  discard block
 block discarded – undo
1196 1194
 	/**
1197 1195
 	 * Add Preferences link to topmenu using settings-hook to know if an app supports Preferences
1198 1196
 	 */
1199
-	protected function add_preferences_topmenu($type='prefs')
1197
+	protected function add_preferences_topmenu($type = 'prefs')
1200 1198
 	{
1201
-		static $memberships=null;
1199
+		static $memberships = null;
1202 1200
 		if (!isset($memberships)) $memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1203 1201
 		static $types = array(
1204 1202
 			'prefs' => array(
@@ -1212,7 +1210,7 @@  discard block
 block discarded – undo
1212 1210
 			'cats' => array(
1213 1211
 				'title' => 'Categories',
1214 1212
 				'hook' => 'categories',
1215
-				'run_hook' => true,	// acturally run hook, not just look it's implemented
1213
+				'run_hook' => true, // acturally run hook, not just look it's implemented
1216 1214
 			),
1217 1215
 			'security' => array(
1218 1216
 				'title' => 'Security & Password',
@@ -1223,13 +1221,13 @@  discard block
 block discarded – undo
1223 1221
 			array_intersect($memberships, (array)$GLOBALS['egw_info']['server']['deny_'.$type]) &&
1224 1222
 			!$GLOBALS['egw_info']['user']['apps']['admin'])
1225 1223
 		{
1226
-			return;	// user has no access to Preferences app
1224
+			return; // user has no access to Preferences app
1227 1225
 		}
1228 1226
 		if (isset($types[$type]['run_hook']))
1229 1227
 		{
1230 1228
 			$apps = Hooks::process($types[$type]['hook']);
1231 1229
 			// as all apps answer, we need to remove none-true responses
1232
-			foreach($apps as $app => $val)
1230
+			foreach ($apps as $app => $val)
1233 1231
 			{
1234 1232
 				if (!$val) unset($apps[$app]);
1235 1233
 			}
@@ -1274,7 +1272,7 @@  discard block
 block discarded – undo
1274 1272
 	* @access protected
1275 1273
 	* @return void
1276 1274
 	*/
1277
-	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1275
+	abstract function _add_topmenu_item(array $app_data, $alt_label = null);
1278 1276
 
1279 1277
 	/**
1280 1278
 	* Add info items to the topmenu template class to be displayed
@@ -1284,7 +1282,7 @@  discard block
 block discarded – undo
1284 1282
 	* @access protected
1285 1283
 	* @return void
1286 1284
 	*/
1287
-	abstract function _add_topmenu_info_item($content, $id=null);
1285
+	abstract function _add_topmenu_info_item($content, $id = null);
1288 1286
 
1289 1287
 	static $top_menu_extra = array();
1290 1288
 
@@ -1299,7 +1297,7 @@  discard block
 block discarded – undo
1299 1297
 	* @access public
1300 1298
 	* @return void
1301 1299
 	*/
1302
-	public static function add_topmenu_item($id,$url,$title,$target = '')
1300
+	public static function add_topmenu_item($id, $url, $title, $target = '')
1303 1301
 	{
1304 1302
 		$entry['name'] = $id;
1305 1303
 		$entry['url'] = $url;
@@ -1320,7 +1318,7 @@  discard block
 block discarded – undo
1320 1318
 	* @access public
1321 1319
 	* @return void
1322 1320
 	*/
1323
-	abstract function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null);
1321
+	abstract function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null);
1324 1322
 
1325 1323
 	/**
1326 1324
 	 * Call and return content of 'after_navbar' hook
@@ -1330,7 +1328,7 @@  discard block
 block discarded – undo
1330 1328
 	protected function _get_after_navbar()
1331 1329
 	{
1332 1330
 		ob_start();
1333
-		Hooks::process('after_navbar',null,true);
1331
+		Hooks::process('after_navbar', null, true);
1334 1332
 		$content = ob_get_contents();
1335 1333
 		ob_end_clean();
1336 1334
 
@@ -1367,7 +1365,7 @@  discard block
 block discarded – undo
1367 1365
 	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1368 1366
 	* @param boolean $append =true should the file be added
1369 1367
 	*/
1370
-	static function includeJS($package, $file=null, $app='phpgwapi', $append=true)
1368
+	static function includeJS($package, $file = null, $app = 'phpgwapi', $append = true)
1371 1369
 	{
1372 1370
 		self::$js_include_mgr->include_js_file($package, $file, $app, $append);
1373 1371
 	}
@@ -1379,7 +1377,7 @@  discard block
 block discarded – undo
1379 1377
 	 * @param boolean $clear_files =false true clear files after returning them
1380 1378
 	 * @return array with pathes relative to EGW_SERVER_ROOT
1381 1379
 	 */
1382
-	static function js_files(array $files=null, $clear_files=false)
1380
+	static function js_files(array $files = null, $clear_files = false)
1383 1381
 	{
1384 1382
 		if (isset($files) && is_array($files))
1385 1383
 		{
@@ -1398,7 +1396,7 @@  discard block
 block discarded – undo
1398 1396
 	 * @param boolean $clear_files =false true clear files after returning them
1399 1397
 	 * @return string|array see $return_pathes parameter
1400 1398
 	 */
1401
-	static public function get_script_links($return_pathes=false, $clear_files=false)
1399
+	static public function get_script_links($return_pathes = false, $clear_files = false)
1402 1400
 	{
1403 1401
 		$to_include = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files($clear_files));
1404 1402
 
@@ -1406,7 +1404,7 @@  discard block
 block discarded – undo
1406 1404
 		{
1407 1405
 			return $to_include;
1408 1406
 		}
1409
-		$start = '<script type="text/javascript" src="'. $GLOBALS['egw_info']['server']['webserver_url'];
1407
+		$start = '<script type="text/javascript" src="'.$GLOBALS['egw_info']['server']['webserver_url'];
1410 1408
 		$end = '">'."</script>\n";
1411 1409
 		return "\n".$start.implode($end.$start, $to_include).$end;
1412 1410
 	}
@@ -1426,7 +1424,7 @@  discard block
 block discarded – undo
1426 1424
 	 * @param boolean $no_default_css =false true do NOT load any default css, only what app explicitly includes
1427 1425
 	 * @return boolean false: css file not found, true: file found
1428 1426
 	 */
1429
-	public static function includeCSS($app, $name=null, $append=true, $no_default_css=false)
1427
+	public static function includeCSS($app, $name = null, $append = true, $no_default_css = false)
1430 1428
 	{
1431 1429
 		if ($no_default_css)
1432 1430
 		{
@@ -1446,16 +1444,16 @@  discard block
 block discarded – undo
1446 1444
 
1447 1445
 		// try to add app specific css file
1448 1446
 		self::includeCSS($app, 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
1449
-			self::includeCSS($app,'app');
1447
+			self::includeCSS($app, 'app');
1450 1448
 
1451 1449
 		// add all css files from Framework::includeCSS()
1452 1450
 		$query = null;
1453 1451
 		//error_log(__METHOD__."() Framework\CssIncludes::get()=".array2string(Framework\CssIncludes::get()));
1454
-		foreach(Framework\CssIncludes::get() as $path)
1452
+		foreach (Framework\CssIncludes::get() as $path)
1455 1453
 		{
1456 1454
 			unset($query);
1457
-			list($path,$query) = explode('?',$path,2);
1458
-			$path .= '?'. ($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
1455
+			list($path, $query) = explode('?', $path, 2);
1456
+			$path .= '?'.($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
1459 1457
 			$response->includeCSS($GLOBALS['egw_info']['server']['webserver_url'].$path);
1460 1458
 		}
1461 1459
 
@@ -1464,7 +1462,7 @@  discard block
 block discarded – undo
1464 1462
 
1465 1463
 		// add all js files from Framework::includeJS()
1466 1464
 		$files = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files());
1467
-		foreach($files as $path)
1465
+		foreach ($files as $path)
1468 1466
 		{
1469 1467
 			$response->includeScript($GLOBALS['egw_info']['server']['webserver_url'].$path);
1470 1468
 		}
@@ -1543,18 +1541,18 @@  discard block
 block discarded – undo
1543 1541
 	 */
1544 1542
 	public static function ajax_user_list()
1545 1543
 	{
1546
-		$list = array('accounts' => array(),'groups' => array(), 'owngroups' => array());
1547
-		if($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'primary_group')
1544
+		$list = array('accounts' => array(), 'groups' => array(), 'owngroups' => array());
1545
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'primary_group')
1548 1546
 		{
1549 1547
 			$list['accounts']['filter']['group'] = $GLOBALS['egw_info']['user']['account_primary_group'];
1550 1548
 		}
1551 1549
 		$contact_obj = new Contacts();
1552
-		foreach($list as $type => &$accounts)
1550
+		foreach ($list as $type => &$accounts)
1553 1551
 		{
1554 1552
 			$options = array('account_type' => $type) + $accounts;
1555
-			$key_pair = Accounts::link_query('',$options);
1553
+			$key_pair = Accounts::link_query('', $options);
1556 1554
 			$accounts = array();
1557
-			foreach($key_pair as $account_id => $name)
1555
+			foreach ($key_pair as $account_id => $name)
1558 1556
 			{
1559 1557
 				$contact = $contact_obj->read('account:'.$account_id, true);
1560 1558
 				$accounts[] = array('value' => $account_id, 'label' => $name, 'icon' => self::link('/api/avatar.php', array(
@@ -1576,16 +1574,16 @@  discard block
 block discarded – undo
1576 1574
 	 * @param boolean $_resolve_groups =false true: return attribute for all members, false return attribute for group itself
1577 1575
 	 * @return array account_id => data pairs
1578 1576
 	 */
1579
-	public static function ajax_account_data($_account_ids, $_field, $_resolve_groups=false)
1577
+	public static function ajax_account_data($_account_ids, $_field, $_resolve_groups = false)
1580 1578
 	{
1581 1579
 		$list = array();
1582
-		foreach((array)$_account_ids as $account_id)
1580
+		foreach ((array)$_account_ids as $account_id)
1583 1581
 		{
1584
-			foreach($account_id < 0 && $_resolve_groups ?
1582
+			foreach ($account_id < 0 && $_resolve_groups ?
1585 1583
 				$GLOBALS['egw']->accounts->members($account_id, true) : array($account_id) as $account_id)
1586 1584
 			{
1587 1585
 				// Make sure name is formatted according to preference
1588
-				if($_field == 'account_fullname')
1586
+				if ($_field == 'account_fullname')
1589 1587
 				{
1590 1588
 					$list[$account_id] = Accounts::format_username(
1591 1589
 						$GLOBALS['egw']->accounts->id2name($account_id, 'account_lid'),
Please login to merge, or discard this patch.