Passed
Push — 1.10.x ( 12c7e7...f34bae )
by Angel Fernando Quiroz
46:03
created
main/admin/configure_homepage.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 {
20 20
 	$post = strpos($file_logged_in, "_logged_in");
21 21
 	if ($post !== false) {
22
-		$file_logged_out = str_replace('_logged_in','', $file_logged_in);
22
+		$file_logged_out = str_replace('_logged_in', '', $file_logged_in);
23 23
 		//variables initialization
24 24
 		$data_logged_out = array();
25 25
 		$data_logged_in  = array();
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 		//we read the file with all links
28 28
 		$file = file($file_logged_in);
29 29
 		foreach ($file as $line) {
30
-			$line = str_replace("\n", '',$line);
30
+			$line = str_replace("\n", '', $line);
31 31
 			//not logged user only sees public links
32
-			if (!preg_match('/::private/',$line)) {
32
+			if (!preg_match('/::private/', $line)) {
33 33
 				$data_logged_out[] = $line;
34 34
 			}
35 35
 			//logged user only sees all links
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
75 75
 $tool_name = get_lang('ConfigureHomePage');
76 76
 $_languages = api_get_languages();
77
-$selfUrl =  api_get_self();
77
+$selfUrl = api_get_self();
78 78
 $interbreadcrumb[] = array(
79 79
 	'url' => 'index.php',
80 80
 	'name' => get_lang('PlatformAdmin')
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 				}
263 263
 
264 264
 				if (EventsMail::check_if_using_class('portal_homepage_edited')) {
265
-					EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
265
+					EventsDispatcher::events('portal_homepage_edited', array('about_user' => api_get_user_id()));
266 266
 				}
267 267
 				Event::addEvent(
268 268
 					LOG_HOMEPAGE_CHANGED,
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 				if ($link_url == 'http://' || $link_url == 'https://') {
395 395
 					$link_url = '';
396 396
 				} elseif (!empty($link_url) && !strstr($link_url, '://')) {
397
-					$link_url='http://'.$link_url;
397
+					$link_url = 'http://'.$link_url;
398 398
 				}
399
-				$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $mtloggedin : $menuf;
399
+				$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs') ? $mtloggedin : $menuf;
400 400
 
401 401
 				if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
402 402
 					$errorMsg = get_lang('HomePageFilesNotWritable');
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 					}
415 415
 					// If the typical language suffix is not found in the file name,
416 416
 					// replace the ".html" suffix by "_en.html" or the active menu language
417
-					if (!strstr($filename,'_'.$lang.$ext)) {
417
+					if (!strstr($filename, '_'.$lang.$ext)) {
418 418
 						$filename = str_replace($ext, '_'.$lang.$ext, $filename);
419 419
 					}
420 420
 					// Get the contents of home_menu_en.html (or active menu language
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 					//
437 437
 					// If the given link url is empty, then replace the link url by a link to the link file created
438 438
 
439
-					if (empty($link_url) || $link_url == 'http://' ||  $link_url == 'https://') {
439
+					if (empty($link_url) || $link_url == 'http://' || $link_url == 'https://') {
440 440
 						$link_url = api_get_path(WEB_PATH).'index.php?include='.urlencode($filename);
441 441
 						// If the file doesn't exist, then create it and
442 442
 						// fill it with default text
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 					}
456 456
 					// If the requested action is to edit a link, open the file and
457 457
 					// write to it (if the file doesn't exist, create it)
458
-					if (in_array($action, array('edit_link'))  && !empty($link_html)) {
458
+					if (in_array($action, array('edit_link')) && !empty($link_html)) {
459 459
 						$fp = @fopen($homep.$filename, 'w');
460 460
 						if ($fp) {
461 461
 							fputs($fp, $link_html);
@@ -482,10 +482,10 @@  discard block
 block discarded – undo
482 482
 								break;
483 483
 							}
484 484
 						}
485
-						$home_menu[$insert_where + 1] = '<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'. $link_name .'</a></li>';
485
+						$home_menu[$insert_where + 1] = '<li '.$class_add_in_tab.'><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'.$link_name.'</a></li>';
486 486
 					} else {
487 487
 						// If the request is about a link edition, change the link
488
-						$home_menu[$link_index]='<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'. $link_name .'</a></li>';
488
+						$home_menu[$link_index] = '<li '.$class_add_in_tab.'><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'.$link_name.'</a></li>';
489 489
 					}
490 490
 					// Re-build the file from the home_menu array
491 491
 					$home_menu = implode("\n", $home_menu);
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 				Event::addEvent(
540 540
 					LOG_HOMEPAGE_CHANGED,
541 541
 					$action,
542
-					cut($link_name . ':' . $link_url, 254),
542
+					cut($link_name.':'.$link_url, 254),
543 543
 					api_get_utc_datetime(),
544 544
 					api_get_user_id()
545 545
 				);
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 				// A link is deleted by getting the file into an array, removing the
563 563
 				// link and re-writing the array to the file
564 564
 				$link_index = intval($_GET['link_index']);
565
-				$menuf = ($action == 'delete_tabs')? $mtloggedin : $menuf;
565
+				$menuf = ($action == 'delete_tabs') ? $mtloggedin : $menuf;
566 566
 				$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
567 567
 				if (empty($home_menu)) {
568 568
 					$home_menu = array();
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 				fclose($fp);
584 584
 				if (file_exists($homep.$menuf.$ext)) {
585 585
 					if (is_writable($homep.$menuf.$ext)) {
586
-						$fpo = fopen($homep.$menuf.$ext,'w');
586
+						$fpo = fopen($homep.$menuf.$ext, 'w');
587 587
 						fputs($fpo, $home_menu);
588 588
 						home_tabs($homep.$menuf.$ext);
589 589
 						fclose($fpo);
@@ -596,9 +596,9 @@  discard block
 block discarded – undo
596 596
 				// This request is only the preparation for the update of the home_top
597 597
 				$home_top = '';
598 598
 				if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
599
-					$home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
599
+					$home_top = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext);
600 600
 				} elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
601
-					$home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
601
+					$home_top = @(string) file_get_contents($homep.$topf.$lang.$ext);
602 602
 				} else {
603 603
 					$errorMsg = get_lang('HomePageFilesNotReadable');
604 604
 				}
@@ -626,9 +626,9 @@  discard block
 block discarded – undo
626 626
 				// This request is the preparation for the update of the home_news page
627 627
 				$home_news = '';
628 628
 				if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
629
-					$home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
629
+					$home_news = @(string) file_get_contents($homep.$newsf.'_'.$lang.$ext);
630 630
 				} elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
631
-					$home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
631
+					$home_news = @(string) file_get_contents($homep.$newsf.$lang.$ext);
632 632
 				} else {
633 633
 					$errorMsg = get_lang('HomePageFilesNotReadable');
634 634
 				}
@@ -637,10 +637,10 @@  discard block
 block discarded – undo
637 637
 			case 'insert_link':
638 638
 				// This request is the preparation for the addition of an item in home_menu
639 639
 				$home_menu = '';
640
-				$menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
640
+				$menuf = ($action == 'edit_tabs') ? $mtloggedin : $menuf;
641 641
 				if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
642 642
 					$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
643
-				} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
643
+				} elseif (is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
644 644
 					$home_menu = @file($homep.$menuf.$lang.$ext);
645 645
 				} else {
646 646
 					$errorMsg = get_lang('HomePageFilesNotReadable');
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 			case 'edit_link':
682 682
 				// This request is the preparation for the edition of the links array
683 683
 				$home_menu = '';
684
-				$menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
684
+				$menuf = ($action == 'edit_tabs') ? $mtloggedin : $menuf;
685 685
 				if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
686 686
 					$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
687
-				} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
687
+				} elseif (is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
688 688
 					$home_menu = @file($homep.$menuf.$lang.$ext);
689 689
 				} else {
690 690
 					$errorMsg = get_lang('HomePageFilesNotReadable');
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 						$link_name = strip_tags($enreg);
748 748
 
749 749
 						// Get the contents of "href" attribute in $link_url
750
-						$enreg = explode('href="',$enreg);
750
+						$enreg = explode('href="', $enreg);
751 751
 						list($link_url) = explode('"', $enreg[sizeof($enreg) - 1]);
752 752
 
753 753
 						// If the link contains the web root of this portal, then strip
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 	case 'open_link':
786 786
 		if (!empty($link)) {
787 787
 			// $link is only set in case of action=open_link and is filtered
788
-			$open = @(string)file_get_contents($homep.$link);
788
+			$open = @(string) file_get_contents($homep.$link);
789 789
 			$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
790 790
 			echo $open;
791 791
 		}
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 		}
850 850
 		$default = array();
851 851
 		$form = new FormValidator('configure_homepage_'.$action, 'post', $selfUrl.'?action='.$action, '', array('style' => 'margin: 0px;'));
852
-		$renderer =& $form->defaultRenderer();
852
+		$renderer = & $form->defaultRenderer();
853 853
 
854 854
 		$form->addElement('header', '', $tool_name);
855 855
 		$form->addElement('hidden', 'formSent', '1');
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 
871 871
 		if ($action == 'insert_link' || $action == 'insert_tabs') {
872 872
 			$add_in_tab = 1;
873
-			if (is_array($home_menu)){
873
+			if (is_array($home_menu)) {
874 874
 				foreach ($home_menu as $key => $enreg) {
875 875
 					if (strlen($enreg = trim(strip_tags($enreg))) > 0) {
876 876
 						$options[$key] = get_lang('After').' &quot;'.$enreg.'&quot;';
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 				}
881 881
 			}
882 882
 			$default['insert_link'] = $selected;
883
-			$form->addElement('select', 'insert_where', get_lang('InsertThisLink') , $options);
883
+			$form->addElement('select', 'insert_where', get_lang('InsertThisLink'), $options);
884 884
 		}
885 885
 
886 886
 		$target_blank_checkbox = $form->addElement('checkbox', 'target_blank', null, get_lang('OpenInNewWindow'), 1);
@@ -895,15 +895,15 @@  discard block
 block discarded – undo
895 895
 		if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://' || $link_url == 'https://')) {
896 896
 			$default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : $link_html;
897 897
 			$form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
898
-            $form->addButtonSave(get_lang('Save'),'submit');
898
+            $form->addButtonSave(get_lang('Save'), 'submit');
899 899
 
900 900
 		} else {
901
-			if (in_array($action, array('edit_tabs','insert_tabs'))) {
901
+			if (in_array($action, array('edit_tabs', 'insert_tabs'))) {
902 902
 				$default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : (!empty($link_html) ? $link_html : '');
903 903
 				$form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
904 904
 			}
905 905
 			$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
906
-			$form->addElement('html','<table id="table_langs" style="margin-left:159px;"><tr>');
906
+			$form->addElement('html', '<table id="table_langs" style="margin-left:159px;"><tr>');
907 907
 			$i = 0;
908 908
 			foreach ($_languages['name'] as $key => $value) {
909 909
 				$i++;
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
 				}
917 917
 				$form->addElement('html', $html_langs);
918 918
 			}
919
-			$form->addElement('html','</tr></table><br/>');
920
-            $form->addButtonSave(get_lang('Save'),'submit');
919
+			$form->addElement('html', '</tr></table><br/>');
920
+            $form->addButtonSave(get_lang('Save'), 'submit');
921 921
 		}
922 922
 
923 923
 		$form->setDefaults($default);
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 			$open = $home_top;
932 932
 		} else {
933 933
 			$name = $newsf;
934
-			$open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
934
+			$open = @(string) file_get_contents($homep.$newsf.'_'.$lang.$ext);
935 935
 		}
936 936
 		$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
937 937
 
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 			'',
948 948
 			array('style' => 'margin: 0px;')
949 949
 		);
950
-		$renderer =& $form->defaultRenderer();
950
+		$renderer = & $form->defaultRenderer();
951 951
 		$renderer->setHeaderTemplate('');
952 952
 		$renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
953 953
 		$renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>');
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
 
974 974
 		$default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open);
975 975
 		$form->addHtmlEditor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
976
-		$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'),array('id' => 'all_langs'));
977
-		$form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
976
+		$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
977
+		$form->addElement('html', '<table id="table_langs" style="margin-left:5px;"><tr>');
978 978
 
979 979
 		$currentLanguage = api_get_interface_language();
980 980
 		$i = 0;
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 			$i++;
984 984
 
985 985
 			$checked = null;
986
-			if ($languageGet == $lang_name)  {
986
+			if ($languageGet == $lang_name) {
987 987
 				$checked = "checked";
988 988
 			}
989 989
 			$html_langs = '<td width="300">';
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 			}
995 995
 			$form->addElement('html', $html_langs);
996 996
 		}
997
-		$form->addElement('html','</tr></table><br/>');
997
+		$form->addElement('html', '</tr></table><br/>');
998 998
 		$form->addButtonSave(get_lang('Save'));
999 999
 		$form->setDefaults($default);
1000 1000
 		$form->display();
@@ -1047,9 +1047,9 @@  discard block
 block discarded – undo
1047 1047
                                 <?php
1048 1048
                                     $home_notice = '';
1049 1049
                                     if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
1050
-                                        $home_notice = @(string)file_get_contents($homep.$noticef.'_'.$lang.$ext);
1050
+                                        $home_notice = @(string) file_get_contents($homep.$noticef.'_'.$lang.$ext);
1051 1051
                                     } else {
1052
-                                        $home_notice = @(string)file_get_contents($homep.$noticef.$ext);
1052
+                                        $home_notice = @(string) file_get_contents($homep.$noticef.$ext);
1053 1053
                                     }
1054 1054
                                     $home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
1055 1055
                                     echo '<div class="homepage_notice">';
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
                     </div>
1075 1075
                     <div id="links-list" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
1076 1076
                         <div class="panel-body">
1077
-                            <a href="<?php echo $selfUrl; ?>?action=insert_link"><?php echo Display::return_icon('add.png', get_lang('InsertLink')).'&nbsp;'. get_lang('InsertLink'); ?>
1077
+                            <a href="<?php echo $selfUrl; ?>?action=insert_link"><?php echo Display::return_icon('add.png', get_lang('InsertLink')).'&nbsp;'.get_lang('InsertLink'); ?>
1078 1078
                             </a>
1079 1079
                             <ul class="menulist">
1080 1080
                                 <?php
@@ -1113,16 +1113,16 @@  discard block
 block discarded – undo
1113 1113
         <div class="col-md-9">
1114 1114
             <div class="actions">
1115 1115
 		<a href="<?php echo $selfUrl; ?>?action=edit_top&language=<?php echo $languageGet; ?>">
1116
-                    <?php echo Display::return_icon('edit.png', get_lang('EditHomePage'),null,ICON_SIZE_SMALL).'&nbsp;'. get_lang('EditHomePage'); ?>
1116
+                    <?php echo Display::return_icon('edit.png', get_lang('EditHomePage'), null, ICON_SIZE_SMALL).'&nbsp;'.get_lang('EditHomePage'); ?>
1117 1117
 		</a>
1118 1118
             </div>
1119 1119
             <section id="homepage-home">
1120 1120
                 <?php
1121 1121
                 //print home_top contents
1122 1122
                 if (file_exists($homep.$topf.'_'.$lang.$ext)) {
1123
-                    $home_top_temp = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
1123
+                    $home_top_temp = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext);
1124 1124
                 } else {
1125
-                    $home_top_temp = @(string)file_get_contents($homep.$topf.$ext);
1125
+                    $home_top_temp = @(string) file_get_contents($homep.$topf.$ext);
1126 1126
                 }
1127 1127
                 $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
1128 1128
                 $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
@@ -1158,11 +1158,11 @@  discard block
 block discarded – undo
1158 1158
 
1159 1159
             <?php
1160 1160
 		if (file_exists($homep.$newsf.'_'.$lang.$ext)) {
1161
-                    $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
1161
+                    $open = @(string) file_get_contents($homep.$newsf.'_'.$lang.$ext);
1162 1162
                     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
1163 1163
                     echo $open;
1164 1164
 		} else {
1165
-                    $open = @(string)file_get_contents($homep.$newsf.$ext);
1165
+                    $open = @(string) file_get_contents($homep.$newsf.$ext);
1166 1166
                     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
1167 1167
                     echo $open;
1168 1168
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
                             $tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=', '</li>'),
1200 1200
                                 array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename($selfUrl).'?action=open_link&link=', $edit_link.$delete_link.'</li>'),
1201 1201
 				$enreg);
1202
-                            $tab_string = str_replace(array('<li>', '</li>','class="hide_menu"', 'hide_menu'), '', $tab_string);
1202
+                            $tab_string = str_replace(array('<li>', '</li>', 'class="hide_menu"', 'hide_menu'), '', $tab_string);
1203 1203
 				$link_list .= Display::tag('li', $tab_string, array('class' => 'list-group-item'));
1204 1204
 				$tab_counter++;
1205 1205
 			}
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
             ?>
1208 1208
             <div class="actions">
1209 1209
 		<a href="<?php echo $selfUrl; ?>?action=insert_tabs">
1210
-                    <?php echo Display::return_icon('add.png', get_lang('InsertLink')) .'&nbsp;'. get_lang('InsertLink'); ?>
1210
+                    <?php echo Display::return_icon('add.png', get_lang('InsertLink')).'&nbsp;'.get_lang('InsertLink'); ?>
1211 1211
                 </a>
1212 1212
             </div>
1213 1213
             <?php
Please login to merge, or discard this patch.