Completed
Push — 16.1 ( 44c9ff...55c5d1 )
by Nathan
23:26
created
api/src/Framework/Ajax.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @param string $template = '' name of the template
59 59
 	 */
60
-	function __construct($template=self::APP)
60
+	function __construct($template = self::APP)
61 61
 	{
62
-		parent::__construct($template);		// call the constructor of the extended class
62
+		parent::__construct($template); // call the constructor of the extended class
63 63
 
64
-		$this->template_dir = '/'.$template;		// we are packaged as an application
64
+		$this->template_dir = '/'.$template; // we are packaged as an application
65 65
 	}
66 66
 
67 67
 	/**
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
 	public static function app_from_url($url)
130 130
 	{
131 131
 		$matches = null;
132
-		if (preg_match('/menuaction=([a-z0-9_-]+)\./i',$url,$matches))
132
+		if (preg_match('/menuaction=([a-z0-9_-]+)\./i', $url, $matches))
133 133
 		{
134 134
 			return $matches[1];
135 135
 		}
136 136
 		if ($GLOBALS['egw_info']['server']['webserver_url'] &&
137
-			($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH)))
137
+			($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH)))
138 138
 		{
139
-			list(,$url) = explode($webserver_path, parse_url($url,PHP_URL_PATH),2);
139
+			list(,$url) = explode($webserver_path, parse_url($url, PHP_URL_PATH), 2);
140 140
 		}
141
-		if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/',$url,$matches))
141
+		if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/', $url, $matches))
142 142
 		{
143 143
 			return $matches[1];
144 144
 		}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @param string $link_app = null if appname or true, some templates generate a special link-handler url
155 155
 	 * @return string	The full url after processing
156 156
 	 */
157
-	static function link($url = '', $extravars = '', $link_app=null)
157
+	static function link($url = '', $extravars = '', $link_app = null)
158 158
 	{
159 159
 		if (is_null($link_app)) $link_app = self::$link_app;
160 160
 		$link = parent::link($url, $extravars);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 			// Link gets handled in JS, so quotes need slashes as well as url-encoded
166 166
 			// encoded ampersands in get parameters (%26) need to be encoded twise,
167 167
 			// so they are still encoded when assigned to window.location
168
-			$link_with_slashes = str_replace(array('%27','%26'), array('\%27','%2526'), $link);
168
+			$link_with_slashes = str_replace(array('%27', '%26'), array('\%27', '%2526'), $link);
169 169
 
170 170
 			//$link = "javascript:window.egw_link_handler?egw_link_handler('$link','$link_app'):parent.egw_link_handler('$link','$link_app');";
171 171
 			$link = "javascript:egw_link_handler('$link_with_slashes','$link_app')";
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	protected function _get_csp_frame_src()
184 184
 	{
185 185
 		$srcs = array();
186
-		foreach(Api\Hooks::process('csp-frame-src') as $src)
186
+		foreach (Api\Hooks::process('csp-frame-src') as $src)
187 187
 		{
188 188
 			if ($src) $srcs = array_merge($srcs, $src);
189 189
 		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * @param array $extra = array() extra attributes passed as data-attribute to egw.js
197 197
 	 * @return string with Api\Html
198 198
 	 */
199
-	function header(array $extra=array())
199
+	function header(array $extra = array())
200 200
 	{
201 201
 		// make sure header is output only once
202 202
 		if (self::$header_done) return '';
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 		{
222 222
 			$this->tpl->set_file(array('_head' => 'head.tpl'));
223 223
 		}
224
-		$this->tpl->set_block('_head','head');
225
-		$this->tpl->set_block('_head','framework');
224
+		$this->tpl->set_block('_head', 'head');
225
+		$this->tpl->set_block('_head', 'framework');
226 226
 
227 227
 		// should we draw the framework, or just a header
228 228
 		$do_framework = isset($_GET['cd']) && $_GET['cd'] === 'yes';
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 			{
248 248
 				self::includeJS('.', 'fw_'.static::APP, static::JS_INCLUDE_APP);
249 249
 			}
250
-			Api\Cache::unsetSession(__CLASS__,'sidebox_md5');	// sideboxes need to be send again
250
+			Api\Cache::unsetSession(__CLASS__, 'sidebox_md5'); // sideboxes need to be send again
251 251
 
252 252
 			$extra['navbar-apps'] = $this->get_navbar_apps($_SERVER['REQUEST_URI']);
253 253
 		}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		// - if not we need to check if we have an opener (are a popup window)
257 257
 		// - as popups can open further popups, we need to decend all the way down until we find a framework
258 258
 		// - only if we cant find a framework in all openers, we redirect to create a new framework
259
-		if(!$do_framework)
259
+		if (!$do_framework)
260 260
 		{
261 261
 			// fetch sidebox from application and set it in extra data, if we are no popup
262 262
 			if (!$GLOBALS['egw_info']['flags']['nonavbar'])
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 			// for remote manual never check/create framework
267 267
 			if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr')))
268 268
 			{
269
-				if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']='';
269
+				if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script'] = '';
270 270
 				$extra['check-framework'] = $_GET['cd'] !== 'no';
271 271
 			}
272 272
 		}
273 273
 		$this->tpl->set_var($this->_get_header($extra));
274
-		$content = $this->tpl->fp('out','head').$content;
274
+		$content = $this->tpl->fp('out', 'head').$content;
275 275
 
276 276
 		if (!$do_framework)
277 277
 		{
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 
281 281
 		// topmenu
282 282
 		$vars = $this->_get_navbar($apps = $this->_get_navbar_apps());
283
-		$this->tpl->set_var($this->topmenu($vars,$apps));
283
+		$this->tpl->set_var($this->topmenu($vars, $apps));
284 284
 
285 285
 		// hook after_navbar (eg. notifications)
286
-		$this->tpl->set_var('hook_after_navbar',$this->_get_after_navbar());
286
+		$this->tpl->set_var('hook_after_navbar', $this->_get_after_navbar());
287 287
 
288 288
 		//Global sidebar width
289 289
 		$this->tpl->set_var('sidebox_width', self::get_global_sidebar_width());
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
 		// add framework div's
302 302
 		$this->tpl->set_var($this->_get_footer());
303
-		$content .= $this->tpl->fp('out','framework');
303
+		$content .= $this->tpl->fp('out', 'framework');
304 304
 		$content .= self::footer(false);
305 305
 
306 306
 		echo $content;
@@ -319,14 +319,14 @@  discard block
 block discarded – undo
319 319
 	 * @param array $apps
320 320
 	 * @return array
321 321
 	 */
322
-	function topmenu(array $vars,array $apps)
322
+	function topmenu(array $vars, array $apps)
323 323
 	{
324 324
 		$this->topmenu_items = $this->topmenu_info_items = array();
325 325
 
326
-		parent::topmenu($vars,$apps);
327
-		$vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>",$this->topmenu_items)."</li>\n</ul>";
326
+		parent::topmenu($vars, $apps);
327
+		$vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>", $this->topmenu_items)."</li>\n</ul>";
328 328
 		$vars['topmenu_info_items'] = '';
329
-		foreach($this->topmenu_info_items as $id => $item)
329
+		foreach ($this->topmenu_info_items as $id => $item)
330 330
 		{
331 331
 			$vars['topmenu_info_items'] .= '<div class="topmenu_info_item"'.
332 332
 				(is_numeric($id) ? '' : ' id="topmenu_info_'.$id.'"').'>'.$item."</div>\n";
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 	* @todo implement in a reasonable way for jdots
348 348
 	* @return void
349 349
 	*/
350
-	function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
350
+	function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null)
351 351
 	{
352
-		unset($id,$icon_src,$iconlink,$blink,$tooltip);	// not used
352
+		unset($id, $icon_src, $iconlink, $blink, $tooltip); // not used
353 353
 		// not yet implemented, only used in admin/inc/hook_topmenu_info.inc.php to notify about pending updates
354 354
 	}
355 355
 
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	* @access protected
363 363
 	* @return void
364 364
 	*/
365
-	function _add_topmenu_item(array $app_data,$alt_label=null)
365
+	function _add_topmenu_item(array $app_data, $alt_label = null)
366 366
 	{
367
-		switch($app_data['name'])
367
+		switch ($app_data['name'])
368 368
 		{
369 369
 			case 'logout':
370 370
 				if (Api\Header\UserAgent::mobile() || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile')
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 				}
374 374
 				else
375 375
 				{
376
-					return;	// no need for logout in topmenu on jdots
376
+					return; // no need for logout in topmenu on jdots
377 377
 				}
378 378
 				break;
379 379
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 				break;
383 383
 
384 384
 			default:
385
-				if (strpos($app_data['url'],'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:')
385
+				if (strpos($app_data['url'], 'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:')
386 386
 				{
387 387
 					$app_data['url'] = "javascript:egw_link_handler('".$app_data['url']."','".
388 388
 						(isset($GLOBALS['egw_info']['user']['apps'][$app_data['name']]) ?
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 				}
391 391
 		}
392 392
 		$id = $app_data['id'] ? $app_data['id'] : ($app_data['name'] ? $app_data['name'] : $app_data['title']);
393
-		$title =  htmlspecialchars($alt_label ? $alt_label : $app_data['title']);
394
-		$this->topmenu_items[] = '<a id="topmenu_' . $id . '" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>';
393
+		$title = htmlspecialchars($alt_label ? $alt_label : $app_data['title']);
394
+		$this->topmenu_items[] = '<a id="topmenu_'.$id.'" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>';
395 395
 	}
396 396
 
397 397
 	/**
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 	 * @access protected
403 403
 	 * @return void
404 404
 	 */
405
-	function _add_topmenu_info_item($content, $id=null)
405
+	function _add_topmenu_info_item($content, $id = null)
406 406
 	{
407
-		if(strpos($content,'menuaction=admin.admin_accesslog.sessions') !== false)
407
+		if (strpos($content, 'menuaction=admin.admin_accesslog.sessions') !== false)
408 408
 		{
409
-			$content = preg_replace('/href="([^"]+)"/',"href=\"javascript:egw_link_handler('\\1','admin')\"",$content);
409
+			$content = preg_replace('/href="([^"]+)"/', "href=\"javascript:egw_link_handler('\\1','admin')\"", $content);
410 410
 		}
411 411
 		if ($id)
412 412
 		{
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
 	 */
426 426
 	static function ajax_tz_selection($tz)
427 427
 	{
428
-		Api\DateTime::setUserPrefs($tz);	// throws exception, if tz is invalid
428
+		Api\DateTime::setUserPrefs($tz); // throws exception, if tz is invalid
429 429
 
430 430
 		$GLOBALS['egw']->preferences->read_repository();
431
-		$GLOBALS['egw']->preferences->add('common','tz',$tz);
431
+		$GLOBALS['egw']->preferences->add('common', 'tz', $tz);
432 432
 		$GLOBALS['egw']->preferences->save_repository();
433 433
 	}
434 434
 
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 		// only send admin sidebox, for admin index url (when clicked on admin),
481 481
 		// not for other admin pages, called eg. from sidebox menu of other apps
482 482
 		// --> that way we always stay in the app, and NOT open admin sidebox for an app tab!!!
483
-		if ($app == 'admin' && substr($_SERVER['PHP_SELF'],-16) != '/admin/index.php' &&
483
+		if ($app == 'admin' && substr($_SERVER['PHP_SELF'], -16) != '/admin/index.php' &&
484 484
 			$_GET['menuaction'] != 'admin.admin_ui.index')
485 485
 		{
486 486
 			//error_log(__METHOD__."() app=$app, menuaction=$_GET[menuaction], PHP_SELF=$_SERVER[PHP_SELF] --> sidebox request ignored");
487 487
 			return;
488 488
 		}
489
-		$md5_session =& Api\Cache::getSession(__CLASS__,'sidebox_md5');
489
+		$md5_session = & Api\Cache::getSession(__CLASS__, 'sidebox_md5');
490 490
 
491 491
 		//Set the sidebox content
492 492
 		$sidebox = $this->get_sidebox($app);
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		if ($md5_session[$app] !== $md5)
496 496
 		{
497 497
 			//error_log(__METHOD__."() header changed md5_session[$app]!=='$md5' --> setting it on self::\$extra[setSidebox]");
498
-			$md5_session[$app] = $md5;	// update md5 in session
498
+			$md5_session[$app] = $md5; // update md5 in session
499 499
 			self::$extra['setSidebox'] = array($app, $sidebox, $md5);
500 500
 		}
501 501
 		//else error_log(__METHOD__."() md5_session[$app]==='$md5' --> nothing to do");
@@ -509,9 +509,9 @@  discard block
 block discarded – undo
509 509
 	 * @return boolean $consider_navbar_not_yet_called_as_true=true ignored by jdots, we only care for cd=yes GET param
510 510
 	 * @return boolean
511 511
 	 */
512
-	public function isTop($consider_navbar_not_yet_called_as_true=true)
512
+	public function isTop($consider_navbar_not_yet_called_as_true = true)
513 513
 	{
514
-		unset($consider_navbar_not_yet_called_as_true);	// not used
514
+		unset($consider_navbar_not_yet_called_as_true); // not used
515 515
 		return isset($_GET['cd']) && $_GET['cd'] === 'yes';
516 516
 	}
517 517
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	 * @param array $file
538 538
 	 * @param string $type = null 'admin', 'preferences', 'favorites', ...
539 539
 	 */
540
-	public function sidebox($appname,$menu_title,$file,$type=null)
540
+	public function sidebox($appname, $menu_title, $file, $type = null)
541 541
 	{
542 542
 		if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened;
543 543
 		//error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened");
@@ -546,11 +546,11 @@  discard block
 block discarded – undo
546 546
 		// fix app admin menus to use admin.admin_ui.index loader
547 547
 		if (($type == 'admin' || $menu_title == lang('Admin')) && $appname != 'admin')
548 548
 		{
549
-			foreach($file as &$link)
549
+			foreach ($file as &$link)
550 550
 			{
551 551
 				preg_match('/ajax=(true|false)/', $link, $ajax);
552 552
 				$link = preg_replace("/^(javascript:egw_link_handler\(')(.*)menuaction=([^&]+)(.*)(','[^']+'\))$/",
553
-					'$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax=' . ($ajax[1] ? $ajax[1] : 'true') .'\',\'admin\')', $file_was=$link);
553
+					'$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax='.($ajax[1] ? $ajax[1] : 'true').'\',\'admin\')', $file_was = $link);
554 554
 			}
555 555
 
556 556
 		}
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
 			self::$link_app = $appname;
588 588
 			// allow other apps to hook into sidebox menu of an app, hook-name: sidebox_$appname
589 589
 			$this->sidebox_menu_opened = true;
590
-			Api\Hooks::process('sidebox_'.$appname,array($appname),true);	// true = call independent of app-permissions
590
+			Api\Hooks::process('sidebox_'.$appname, array($appname), true); // true = call independent of app-permissions
591 591
 
592 592
 			// calling the old hook
593 593
 			$this->sidebox_menu_opened = true;
594
-			Api\Hooks::single('sidebox_menu',$appname);
594
+			Api\Hooks::single('sidebox_menu', $appname);
595 595
 			self::$link_app = null;
596 596
 
597 597
 			// allow other apps to hook into sidebox menu of every app: sidebox_all
598
-			Api\Hooks::process('sidebox_all',array($GLOBALS['egw_info']['flags']['currentapp']),true);
598
+			Api\Hooks::process('sidebox_all', array($GLOBALS['egw_info']['flags']['currentapp']), true);
599 599
 		}
600 600
 		//If there still is no sidebox content, return null here
601 601
 		if (!isset($this->sideboxes[$appname]))
@@ -605,17 +605,17 @@  discard block
 block discarded – undo
605 605
 
606 606
 		$data = array();
607 607
 		$sendToBottom = array();
608
-		foreach($this->sideboxes[$appname] as $menu_name => &$file)
608
+		foreach ($this->sideboxes[$appname] as $menu_name => &$file)
609 609
 		{
610 610
 			$current_menu = array(
611
-				'menu_name' => md5($menu_name),	// can contain Api\Html tags and javascript!
611
+				'menu_name' => md5($menu_name), // can contain Api\Html tags and javascript!
612 612
 				'title' => $menu_name,
613 613
 				'entries' => array(),
614 614
 				'opened' => (boolean)$file['menuOpened'],
615 615
 			);
616
-			foreach($file as $item_text => $item_link)
616
+			foreach ($file as $item_text => $item_link)
617 617
 			{
618
-				if ($item_text === 'menuOpened' || $item_text === 'sendToBottom' ||// flag, not menu entry
618
+				if ($item_text === 'menuOpened' || $item_text === 'sendToBottom' || // flag, not menu entry
619 619
 					$item_text === '_NewLine_' || $item_link === '_NewLine_')
620 620
 				{
621 621
 					continue;
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
 				}
627 627
 
628 628
 				$var = array();
629
-				$var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images/bullet.png';
629
+				$var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images/bullet.png';
630 630
 				$var['target'] = '';
631
-				if(is_array($item_link))
631
+				if (is_array($item_link))
632 632
 				{
633
-					if(isset($item_link['icon']))
633
+					if (isset($item_link['icon']))
634 634
 					{
635 635
 						$app = isset($item_link['app']) ? $item_link['app'] : $appname;
636
-						$var['icon_or_star'] = $item_link['icon'] ? Api\Image::find($app,$item_link['icon']) : False;
636
+						$var['icon_or_star'] = $item_link['icon'] ? Api\Image::find($app, $item_link['icon']) : False;
637 637
 					}
638 638
 					$var['lang_item'] = isset($item_link['no_lang']) && $item_link['no_lang'] ? $item_link['text'] : lang($item_link['text']);
639 639
 					$var['item_link'] = $item_link['link'];
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 	public static function ajax_tab_changed_state($tablist)
678 678
 	{
679 679
 		$tabs = array();
680
-		foreach($tablist as $data)
680
+		foreach ($tablist as $data)
681 681
 		{
682 682
 			$tabs[] = $data['appName'];
683 683
 			if ($data['active']) $active = $data['appName'];
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 		// used eg. in phpFreeChat to leave the chat
687 687
 		if (($old_tabs = Api\Cache::getSession(__CLASS__, 'open_tabs')))
688 688
 		{
689
-			foreach(array_diff(explode(',',$old_tabs),$tabs) as $app)
689
+			foreach (array_diff(explode(',', $old_tabs), $tabs) as $app)
690 690
 			{
691 691
 				//error_log("Tab '$app' closed, old_tabs=$old_tabs");
692 692
 				Api\Hooks::single(array(
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 				), $app);
696 696
 			}
697 697
 		}
698
-		$open = implode(',',$tabs);
698
+		$open = implode(',', $tabs);
699 699
 
700 700
 		if ($open != $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs'] ||
701 701
 			$active != $GLOBALS['egw_info']['user']['preferences']['common']['active_tab'])
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 		$i = 0;
766 766
 
767 767
 		//Parse the "$apps" array for valid content (security)
768
-		foreach($apps as $app)
768
+		foreach ($apps as $app)
769 769
 		{
770 770
 			//Check whether the app really exists and add it to the $app_arr var
771 771
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
@@ -796,17 +796,17 @@  discard block
 block discarded – undo
796 796
 	 */
797 797
 	public function navbar_apps()
798 798
 	{
799
-		$apps = parent::_get_navbar_apps(Api\Image::svg_usable());	// use svg if usable in browser
799
+		$apps = parent::_get_navbar_apps(Api\Image::svg_usable()); // use svg if usable in browser
800 800
 
801 801
 		//Add its sidebox width to each app
802 802
 		foreach ($apps as $app => &$data)
803 803
 		{
804 804
 			$data['sideboxwidth'] = self::get_sidebar_width($app);
805 805
 			// overwrite icon with svg, if supported by browser
806
-			unset($data['icon_hover']);	// not used in jdots
806
+			unset($data['icon_hover']); // not used in jdots
807 807
 		}
808 808
 
809
-		unset($apps['logout']);	// never display it
809
+		unset($apps['logout']); // never display it
810 810
 		if (isset($apps['about'])) $apps['about']['noNavbar'] = true;
811 811
 		if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true;
812 812
 		if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true;
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		}
857 857
 
858 858
 		// check if user called a specific url --> open it as active tab
859
-		$last_direct_url =& Api\Cache::getSession(__CLASS__, 'last_direct_url');
859
+		$last_direct_url = & Api\Cache::getSession(__CLASS__, 'last_direct_url');
860 860
 		if ($last_direct_url)
861 861
 		{
862 862
 			$url = $last_direct_url;
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 		{
867 867
 			// Coming in with a specific URL, save it and redirect to index.php
868 868
 			// so reloads work nicely, but strip cd=yes or we'll get the framework again
869
-			$last_direct_url = preg_replace('/[&?]cd=yes/','',$url);
869
+			$last_direct_url = preg_replace('/[&?]cd=yes/', '', $url);
870 870
 			Api\Framework::redirect_link('/index.php?cd=yes');
871 871
 		}
872 872
 		else
@@ -881,11 +881,11 @@  discard block
 block discarded – undo
881 881
 		if ($active_tab && array_key_exists($active_tab, $apps))
882 882
 		{
883 883
 			// Do not remove cd=yes if it's an ajax=true app
884
-			if (strpos( $apps[$active_tab]['url'],'ajax=true') !== False)
884
+			if (strpos($apps[$active_tab]['url'], 'ajax=true') !== False)
885 885
 			{
886
-				$url = preg_replace('/[&?]cd=yes/','',$url);
886
+				$url = preg_replace('/[&?]cd=yes/', '', $url);
887 887
 			}
888
-			if($last_direct_url)
888
+			if ($last_direct_url)
889 889
 			{
890 890
 				$apps[$active_tab]['openOnce'] = $url;
891 891
 			}
@@ -897,8 +897,8 @@  discard block
 block discarded – undo
897 897
 		{
898 898
 			$open_tabs = $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs'];
899 899
 		}
900
-		$open_tabs = $open_tabs ? explode(',',$open_tabs) : array();
901
-		if ($active_tab && !in_array($active_tab,$open_tabs))
900
+		$open_tabs = $open_tabs ? explode(',', $open_tabs) : array();
901
+		if ($active_tab && !in_array($active_tab, $open_tabs))
902 902
 		{
903 903
 			$open_tabs[] = $active_tab;
904 904
 			$store_prefs = true;
@@ -906,14 +906,14 @@  discard block
 block discarded – undo
906 906
 		if ($store_prefs)
907 907
 		{
908 908
 			$GLOBALS['egw']->preferences->read_repository();
909
-			$GLOBALS['egw']->preferences->add('common', 'open_tabs', implode(',',$open_tabs));
909
+			$GLOBALS['egw']->preferences->add('common', 'open_tabs', implode(',', $open_tabs));
910 910
 			$GLOBALS['egw']->preferences->add('common', 'active_tab', $active_tab);
911 911
 			$GLOBALS['egw']->preferences->save_repository(true);
912 912
 		}
913 913
 
914 914
 		//error_log(__METHOD__."('$url') url_tab='$url_tab', active_tab=$active_tab, open_tabs=".array2string($open_tabs));
915 915
 		// Restore Tabs
916
-		foreach($open_tabs as $n => $app)
916
+		foreach ($open_tabs as $n => $app)
917 917
 		{
918 918
 			if (isset($apps[$app]))		// user might no longer have app rights
919 919
 			{
@@ -940,10 +940,10 @@  discard block
 block discarded – undo
940 940
 	 * @param boolean $no_framework = true
941 941
 	 * @return string
942 942
 	 */
943
-	function footer($no_framework=true)
943
+	function footer($no_framework = true)
944 944
 	{
945 945
 		//error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace());
946
-		if (self::$footer_done) return;	// prevent (multiple) footers
946
+		if (self::$footer_done) return; // prevent (multiple) footers
947 947
 		self::$footer_done = true;
948 948
 
949 949
 		if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter'])
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 			}
956 956
 		}
957 957
 		return $footer.
958
-			$GLOBALS['egw_info']['flags']['need_footer']."\n".	// eg. javascript, which need to be at the end of the page
958
+			$GLOBALS['egw_info']['flags']['need_footer']."\n".// eg. javascript, which need to be at the end of the page
959 959
 			"</body>\n</html>\n";
960 960
 	}
961 961
 
@@ -993,8 +993,8 @@  discard block
 block discarded – undo
993 993
 		if ($parts['query'])
994 994
 		{
995 995
 			$_SERVER['REQUEST_URI'] = '?'.$parts['query'];
996
-			parse_str($parts['query'],$_GET);
997
-			$_REQUEST = $_GET;	// some apps use $_REQUEST to check $_GET or $_POST
996
+			parse_str($parts['query'], $_GET);
997
+			$_REQUEST = $_GET; // some apps use $_REQUEST to check $_GET or $_POST
998 998
 		}
999 999
 
1000 1000
 		if (!isset($_GET['menuaction']))
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 		// set session action
1005 1005
 		$GLOBALS['egw']->session->set_action('Ajax: '.$_GET['menuaction']);
1006 1006
 
1007
-		list($app,$class,$method) = explode('.',$_GET['menuaction']);
1007
+		list($app, $class, $method) = explode('.', $_GET['menuaction']);
1008 1008
 
1009 1009
 		if (!isset($GLOBALS['egw_info']['user']['apps'][$app]))
1010 1010
 		{
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 
1017 1017
 		$GLOBALS[$class] = $obj = CreateObject($app.'.'.$class);
1018 1018
 
1019
-		if(!is_array($obj->public_functions) || !$obj->public_functions[$method])
1019
+		if (!is_array($obj->public_functions) || !$obj->public_functions[$method])
1020 1020
 		{
1021 1021
 			throw new Api\Exception\NoPermission("Bad menuaction {$_GET['menuaction']}, not listed in public_functions!");
1022 1022
 		}
Please login to merge, or discard this patch.