Completed
Push — 1.11.x ( 78f130...f6f5c2 )
by José
50:40 queued 24:26
created
src/Chamilo/CoreBundle/Component/HTMLPurifier/Filter/AllowIframes.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $vimeoMatch = preg_match('#://player.vimeo.com/#i', $matches[1]);
62 62
         $googleMapsMatch = preg_match('#src="https://maps.google.com/#i', $matches[1]);
63 63
         $slideShare = preg_match('#src="(https?:)?//www.slideshare.net/#', $matches[1]);
64
-        $platformDomain = preg_match('#src="https?://(.+\.)?' . $hostName[1] . '#i', $matches[1]);
64
+        $platformDomain = preg_match('#src="https?://(.+\.)?'.$hostName[1].'#i', $matches[1]);
65 65
 
66 66
         if ($youTubeMatch || $vimeoMatch || $googleMapsMatch || $slideShare || $platformDomain) {
67 67
             $extra = ' frameborder="0"';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             } elseif ($vimeoMatch) {
71 71
                 $extra .= ' webkitAllowFullScreen mozallowfullscreen allowFullScreen';
72 72
             }
73
-            return '<iframe ' . $matches[1] . $extra . '></iframe>';
73
+            return '<iframe '.$matches[1].$extra.'></iframe>';
74 74
         } else {
75 75
             return '';
76 76
         }
Please login to merge, or discard this patch.
src/Chamilo/UserBundle/Entity/User.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1875,11 +1875,11 @@  discard block
 block discarded – undo
1875 1875
         return $this->locale;
1876 1876
     }
1877 1877
 
1878
-     /**
1879
-     * @param string $timezone
1880
-     *
1881
-     * @return User
1882
-     */
1878
+        /**
1879
+         * @param string $timezone
1880
+         *
1881
+         * @return User
1882
+         */
1883 1883
     public function setTimezone($timezone)
1884 1884
     {
1885 1885
         $this->timezone = $timezone;
@@ -2048,11 +2048,11 @@  discard block
 block discarded – undo
2048 2048
         return $this->plainPassword;
2049 2049
     }
2050 2050
 
2051
-      /**
2052
-     * Returns the user roles
2053
-     *
2054
-     * @return array The roles
2055
-     */
2051
+        /**
2052
+         * Returns the user roles
2053
+         *
2054
+         * @return array The roles
2055
+         */
2056 2056
     public function getRoles()
2057 2057
     {
2058 2058
         $roles = $this->roles;
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
     /**
996 996
      * Get pictureUri
997 997
      *
998
-     * @return Media
998
+     * @return string
999 999
      */
1000 1000
     public function getPictureUri()
1001 1001
     {
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
     }
1304 1304
 
1305 1305
     /**
1306
-     * @return Media
1306
+     * @return string
1307 1307
      */
1308 1308
     public function getAvatar()
1309 1309
     {
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
       /**
2079 2079
      * Returns the user roles
2080 2080
      *
2081
-     * @return array The roles
2081
+     * @return string[] The roles
2082 2082
      */
2083 2083
     public function getRoles()
2084 2084
     {
@@ -2403,7 +2403,7 @@  discard block
 block discarded – undo
2403 2403
     /**
2404 2404
      * Check if the user has the skill
2405 2405
      * @param Skill $skill The skill
2406
-     * @return boolean
2406
+     * @return boolean|null
2407 2407
      */
2408 2408
     public function hasSkill(Skill $skill)
2409 2409
     {
Please login to merge, or discard this patch.
main/inc/ajax/course.ajax.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                         0, //howMany
75 75
                         1, //$orderby = 1
76 76
                         'ASC',
77
-                        -1,  //visibility
77
+                        -1, //visibility
78 78
                         $_GET['q'],
79 79
                         null, //$urlId
80 80
                         true //AlsoSearchCode
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
                 if (!empty($course['category_code'])) {
98 98
                     $parents = CourseCategory::getParentsToString($course['category_code']);
99
-                    $title = $parents . $course['title'];
99
+                    $title = $parents.$course['title'];
100 100
                 }
101 101
 
102 102
                 $results['items'][] = array(
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                     INNER JOIN $session_course_user r ON u.user_id = r.user_id
177 177
                     WHERE session_id = %d AND c_id =  '%s'
178 178
                     AND (u.firstname LIKE '%s' OR u.username LIKE '%s' OR u.lastname LIKE '%s')";
179
-            $needle = '%' . $_GET['q'] . '%';
179
+            $needle = '%'.$_GET['q'].'%';
180 180
             $sql_query = sprintf($sql, $_GET['session_id'], $course['real_id'], $needle, $needle, $needle);
181 181
 
182 182
             $result = Database::query($sql_query);
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
     case 'search_exercise_by_course':
196 196
         if (api_is_platform_admin()) {
197 197
             $course = api_get_course_info_by_id($_GET['course_id']);
198
-            $session_id = (!empty($_GET['session_id'])) ?  intval($_GET['session_id']) : 0 ;
198
+            $session_id = (!empty($_GET['session_id'])) ? intval($_GET['session_id']) : 0;
199 199
             $exercises = ExerciseLib::get_all_exercises($course, $session_id, false, $_GET['q'], true, 3);
200 200
 
201 201
             foreach ($exercises as $exercise) {
202
-                $data[] = array('id' => $exercise['id'], 'text' => html_entity_decode($exercise['title']) );
202
+                $data[] = array('id' => $exercise['id'], 'text' => html_entity_decode($exercise['title']));
203 203
             }
204 204
             if (!empty($data)) {
205 205
                 $data[] = array('id' => 'T', 'text' => 'TODOS');
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
                 $sql,
225 225
                 intval($_GET['course_id']),
226 226
                 intval($_GET['session_id']),
227
-                '%' . Database::escape_string($_GET['q']).'%'
227
+                '%'.Database::escape_string($_GET['q']).'%'
228 228
             );
229 229
             $result = Database::query($sql_query);
230 230
             while ($survey = Database::fetch_assoc($result)) {
231
-                $survey['title'] .= ($survey['anonymous'] == 1) ? ' (' . get_lang('Anonymous') . ')' : '';
231
+                $survey['title'] .= ($survey['anonymous'] == 1) ? ' ('.get_lang('Anonymous').')' : '';
232 232
                 $data[] = array(
233 233
                     'id' => $survey['id'],
234 234
                     'text' => strip_tags(html_entity_decode($survey['title']))
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -267,11 +267,11 @@
 block discarded – undo
267 267
                 $coachName = api_get_person_name($userResult['firstname'], $userResult['lastname']);
268 268
             }
269 269
 
270
-           $courses[] = array(
271
-               'id' => $courseId,
272
-               'name' => $course['title'],
273
-               'coachName' => $coachName,
274
-           );
270
+            $courses[] = array(
271
+                'id' => $courseId,
272
+                'name' => $course['title'],
273
+                'coachName' => $coachName,
274
+            );
275 275
         }
276 276
 
277 277
         echo json_encode($courses);
Please login to merge, or discard this patch.
src/Chamilo/PageBundle/Entity/User.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1875,11 +1875,11 @@  discard block
 block discarded – undo
1875 1875
         return $this->locale;
1876 1876
     }
1877 1877
 
1878
-     /**
1879
-     * @param string $timezone
1880
-     *
1881
-     * @return User
1882
-     */
1878
+        /**
1879
+         * @param string $timezone
1880
+         *
1881
+         * @return User
1882
+         */
1883 1883
     public function setTimezone($timezone)
1884 1884
     {
1885 1885
         $this->timezone = $timezone;
@@ -2048,11 +2048,11 @@  discard block
 block discarded – undo
2048 2048
         return $this->plainPassword;
2049 2049
     }
2050 2050
 
2051
-      /**
2052
-     * Returns the user roles
2053
-     *
2054
-     * @return array The roles
2055
-     */
2051
+        /**
2052
+         * Returns the user roles
2053
+         *
2054
+         * @return array The roles
2055
+         */
2056 2056
     public function getRoles()
2057 2057
     {
2058 2058
         $roles = $this->roles;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
     /**
908 908
      * Get pictureUri
909 909
      *
910
-     * @return Media
910
+     * @return string
911 911
      */
912 912
     public function getPictureUri()
913 913
     {
@@ -1284,7 +1284,7 @@  discard block
 block discarded – undo
1284 1284
     }
1285 1285
 
1286 1286
     /**
1287
-     * @return Media
1287
+     * @return string
1288 1288
      */
1289 1289
     public function getAvatar()
1290 1290
     {
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
       /**
2052 2052
      * Returns the user roles
2053 2053
      *
2054
-     * @return array The roles
2054
+     * @return string[] The roles
2055 2055
      */
2056 2056
     public function getRoles()
2057 2057
     {
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Element/SelectTheme.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@
 block discarded – undo
6 6
 */
7 7
 class SelectTheme extends HTML_QuickForm_select
8 8
 {
9
-	/**
10
-	 * Class constructor
11
-	 */
12
-	public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null)
13
-	{
14
-		parent::__construct($elementName, $elementLabel, $options, $attributes);
15
-		// Get all languages
16
-		$themes = api_get_themes();
17
-		$this->_options = array();
18
-		$this->_values = array();
19
-		$this->addOption('--',''); // no theme select
20
-		for ($i=0; $i< count($themes[0]); $i++) {
21
-			$this->addOption($themes[1][$i],$themes[0][$i]);
22
-		}
23
-	}
9
+    /**
10
+     * Class constructor
11
+     */
12
+    public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null)
13
+    {
14
+        parent::__construct($elementName, $elementLabel, $options, $attributes);
15
+        // Get all languages
16
+        $themes = api_get_themes();
17
+        $this->_options = array();
18
+        $this->_values = array();
19
+        $this->addOption('--',''); // no theme select
20
+        for ($i=0; $i< count($themes[0]); $i++) {
21
+            $this->addOption($themes[1][$i],$themes[0][$i]);
22
+        }
23
+    }
24 24
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@
 block discarded – undo
9 9
 	/**
10 10
 	 * Class constructor
11 11
 	 */
12
-	public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null)
12
+	public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
13 13
 	{
14 14
 		parent::__construct($elementName, $elementLabel, $options, $attributes);
15 15
 		// Get all languages
16 16
 		$themes = api_get_themes();
17 17
 		$this->_options = array();
18 18
 		$this->_values = array();
19
-		$this->addOption('--',''); // no theme select
20
-		for ($i=0; $i< count($themes[0]); $i++) {
21
-			$this->addOption($themes[1][$i],$themes[0][$i]);
19
+		$this->addOption('--', ''); // no theme select
20
+		for ($i = 0; $i < count($themes[0]); $i++) {
21
+			$this->addOption($themes[1][$i], $themes[0][$i]);
22 22
 		}
23 23
 	}
24 24
 }
Please login to merge, or discard this patch.
main/gradebook/lib/fe/scoredisplayform.class.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -14,28 +14,28 @@  discard block
 block discarded – undo
14 14
 	 * @param $form_name
15 15
 	 * @param null $action
16 16
 	 */
17
-	public function __construct($form_name, $action= null)
17
+	public function __construct($form_name, $action = null)
18 18
 	{
19 19
 		parent :: __construct($form_name, 'post', $action);
20 20
 		$displayscore = ScoreDisplay :: instance();
21 21
 		$customdisplays = $displayscore->get_custom_score_display_settings();
22 22
 
23
-		$nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1';
24
-		$this->setDefaults(array (
23
+		$nr_items = (count($customdisplays) != '0') ? count($customdisplays) : '1';
24
+		$this->setDefaults(array(
25 25
             'scorecolpercent' => $displayscore->get_color_split_value()
26 26
 		));
27 27
 
28 28
 		$this->addElement('hidden', 'maxvalue', '100');
29 29
 		$this->addElement('hidden', 'minvalue', '0');
30
-		$counter= 1;
30
+		$counter = 1;
31 31
 
32 32
 		//setting the default values
33 33
 
34
-		if(is_array($customdisplays)) {
34
+		if (is_array($customdisplays)) {
35 35
 			foreach ($customdisplays as $customdisplay) {
36
-				$this->setDefaults(array (
37
-					'endscore[' . $counter . ']' => $customdisplay['score'],
38
-					'displaytext[' . $counter . ']' => $customdisplay['display']
36
+				$this->setDefaults(array(
37
+					'endscore['.$counter.']' => $customdisplay['score'],
38
+					'displaytext['.$counter.']' => $customdisplay['display']
39 39
 				));
40 40
 				$counter++;
41 41
 			}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$this->addElement('header', get_lang('ScoreEdit'));
47 47
 
48 48
         if ($displayscore->is_coloring_enabled()) {
49
-            $this->addElement('html', '<b>' . get_lang('ScoreColor') . '</b>');
49
+            $this->addElement('html', '<b>'.get_lang('ScoreColor').'</b>');
50 50
             $this->addElement('text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array(
51 51
                 'size' => 5,
52 52
                 'maxlength' => 5,
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
             }
59 59
 
60 60
             $this->addRule('scorecolpercent', get_lang('OnlyNumbers'), 'numeric');
61
-            $this->addRule(array('scorecolpercent','maxvalue'), get_lang('Over100'), 'compare', '<=');
62
-            $this->addRule(array('scorecolpercent','minvalue'), get_lang('UnderMin'), 'compare', '>');
61
+            $this->addRule(array('scorecolpercent', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
62
+            $this->addRule(array('scorecolpercent', 'minvalue'), get_lang('UnderMin'), 'compare', '>');
63 63
         }
64 64
 
65 65
 		//Settings for the scoring system
66 66
 
67 67
 		if ($displayscore->is_custom()) {
68
-            $this->addElement('html', '<br /><b>' . get_lang('ScoringSystem') . '</b>');
68
+            $this->addElement('html', '<br /><b>'.get_lang('ScoringSystem').'</b>');
69 69
 			$this->addElement('static', null, null, get_lang('ScoreInfo'));
70 70
 			$this->setDefaults(array(
71 71
 				'beginscore' => '0'
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
 				'input-size' => 2
78 78
 			));
79 79
 
80
-			for ($counter= 1; $counter <= 20; $counter++) {
81
-				$renderer =& $this->defaultRenderer();
80
+			for ($counter = 1; $counter <= 20; $counter++) {
81
+				$renderer = & $this->defaultRenderer();
82 82
 				$elementTemplateTwoLabel =
83
-				'<div id=' . $counter . ' style="display: '.(($counter<=$nr_items)?'inline':'none').';">
83
+				'<div id='.$counter.' style="display: '.(($counter <= $nr_items) ? 'inline' : 'none').';">
84 84
 
85 85
 				<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
86 86
 
@@ -105,39 +105,39 @@  discard block
 block discarded – undo
105 105
 
106 106
 				';
107 107
 
108
-				$elementTemplateTwoLabel2 ='
108
+				$elementTemplateTwoLabel2 = '
109 109
 				<div class="col-sm-2">
110 110
 					<!-- BEGIN error --><span class="form_error">{error}</span>
111 111
 					<!-- END error -->
112 112
 					{element}
113 113
 				</div>
114 114
 				<div class="col-sm-1">
115
-                    <a href="javascript:plusItem(' . ($counter+1) . ')">
116
-                    <img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="plus-' . ($counter+1) . '" src="'.Display::returnIconPath('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'"></a>
117
-        			<a href="javascript:minItem(' . ($counter) . ')">
118
-        			<img style="display: '.(($counter>=$nr_items && $counter!=1)?'inline':'none').';" id="min-' . $counter . '" src="'.Display::returnIconPath('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></a>
115
+                    <a href="javascript:plusItem(' . ($counter + 1).')">
116
+                    <img style="display: '.(($counter >= $nr_items) ? 'inline' : 'none').';" id="plus-'.($counter + 1).'" src="'.Display::returnIconPath('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'"></a>
117
+        			<a href="javascript:minItem(' . ($counter).')">
118
+        			<img style="display: '.(($counter >= $nr_items && $counter != 1) ? 'inline' : 'none').';" id="min-'.$counter.'" src="'.Display::returnIconPath('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></a>
119 119
 				</div>
120 120
 				</div>
121 121
 				</div>';
122 122
 
123 123
 				$scorebetw = array();
124
-				$this->addElement('text', 'endscore[' . $counter . ']', null, array (
124
+				$this->addElement('text', 'endscore['.$counter.']', null, array(
125 125
 					'size' => 5,
126 126
 					'maxlength' => 5,
127 127
 					'id' => 'txta-'.$counter,
128 128
 					'input-size' => 2
129 129
 				));
130 130
 
131
-				$this->addElement('text', 'displaytext[' . $counter . ']', null,array (
131
+				$this->addElement('text', 'displaytext['.$counter.']', null, array(
132 132
 					'size' => 40,
133 133
 					'maxlength' => 40,
134 134
 					'id' => 'txtb-'.$counter
135 135
 				));
136
-				$renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore[' . $counter . ']');
137
-				$renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext[' . $counter . ']');
138
-				$this->addRule('endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric');
139
-				$this->addRule(array ('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
140
-				$this->addRule(array ('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>');
136
+				$renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore['.$counter.']');
137
+				$renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext['.$counter.']');
138
+				$this->addRule('endscore['.$counter.']', get_lang('OnlyNumbers'), 'numeric');
139
+				$this->addRule(array('endscore['.$counter.']', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
140
+				$this->addRule(array('endscore['.$counter.']', 'minvalue'), get_lang('UnderMin'), 'compare', '>');
141 141
 			}
142 142
 		}
143 143
 
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -10,47 +10,47 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class ScoreDisplayForm extends FormValidator
12 12
 {
13
-	/**
14
-	 * @param $form_name
15
-	 * @param null $action
16
-	 */
17
-	public function __construct($form_name, $action= null)
18
-	{
19
-		parent :: __construct($form_name, 'post', $action);
20
-		$displayscore = ScoreDisplay :: instance();
21
-		$customdisplays = $displayscore->get_custom_score_display_settings();
22
-
23
-		$nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1';
24
-		$this->setDefaults(array (
13
+    /**
14
+     * @param $form_name
15
+     * @param null $action
16
+     */
17
+    public function __construct($form_name, $action= null)
18
+    {
19
+        parent :: __construct($form_name, 'post', $action);
20
+        $displayscore = ScoreDisplay :: instance();
21
+        $customdisplays = $displayscore->get_custom_score_display_settings();
22
+
23
+        $nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1';
24
+        $this->setDefaults(array (
25 25
             'scorecolpercent' => $displayscore->get_color_split_value()
26
-		));
26
+        ));
27 27
 
28
-		$this->addElement('hidden', 'maxvalue', '100');
29
-		$this->addElement('hidden', 'minvalue', '0');
30
-		$counter= 1;
28
+        $this->addElement('hidden', 'maxvalue', '100');
29
+        $this->addElement('hidden', 'minvalue', '0');
30
+        $counter= 1;
31 31
 
32
-		//setting the default values
32
+        //setting the default values
33 33
 
34
-		if(is_array($customdisplays)) {
35
-			foreach ($customdisplays as $customdisplay) {
36
-				$this->setDefaults(array (
37
-					'endscore[' . $counter . ']' => $customdisplay['score'],
38
-					'displaytext[' . $counter . ']' => $customdisplay['display']
39
-				));
40
-				$counter++;
41
-			}
42
-		}
43
-		$scorecol = array();
34
+        if(is_array($customdisplays)) {
35
+            foreach ($customdisplays as $customdisplay) {
36
+                $this->setDefaults(array (
37
+                    'endscore[' . $counter . ']' => $customdisplay['score'],
38
+                    'displaytext[' . $counter . ']' => $customdisplay['display']
39
+                ));
40
+                $counter++;
41
+            }
42
+        }
43
+        $scorecol = array();
44 44
 
45
-		//settings for the colored score
46
-		$this->addElement('header', get_lang('ScoreEdit'));
45
+        //settings for the colored score
46
+        $this->addElement('header', get_lang('ScoreEdit'));
47 47
 
48 48
         if ($displayscore->is_coloring_enabled()) {
49 49
             $this->addElement('html', '<b>' . get_lang('ScoreColor') . '</b>');
50 50
             $this->addElement('text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array(
51 51
                 'size' => 5,
52 52
                 'maxlength' => 5,
53
-				'input-size' => 2
53
+                'input-size' => 2
54 54
             ));
55 55
 
56 56
             if (api_get_setting('teachers_can_change_score_settings') != 'true') {
@@ -62,25 +62,25 @@  discard block
 block discarded – undo
62 62
             $this->addRule(array('scorecolpercent','minvalue'), get_lang('UnderMin'), 'compare', '>');
63 63
         }
64 64
 
65
-		//Settings for the scoring system
65
+        //Settings for the scoring system
66 66
 
67
-		if ($displayscore->is_custom()) {
67
+        if ($displayscore->is_custom()) {
68 68
             $this->addElement('html', '<br /><b>' . get_lang('ScoringSystem') . '</b>');
69
-			$this->addElement('static', null, null, get_lang('ScoreInfo'));
70
-			$this->setDefaults(array(
71
-				'beginscore' => '0'
72
-			));
73
-			$this->addElement('text', 'beginscore', array(get_lang('Between'), null, '%'), array(
74
-				'size' => 5,
75
-				'maxlength' => 5,
76
-				'disabled' => 'disabled',
77
-				'input-size' => 2
78
-			));
79
-
80
-			for ($counter= 1; $counter <= 20; $counter++) {
81
-				$renderer =& $this->defaultRenderer();
82
-				$elementTemplateTwoLabel =
83
-				'<div id=' . $counter . ' style="display: '.(($counter<=$nr_items)?'inline':'none').';">
69
+            $this->addElement('static', null, null, get_lang('ScoreInfo'));
70
+            $this->setDefaults(array(
71
+                'beginscore' => '0'
72
+            ));
73
+            $this->addElement('text', 'beginscore', array(get_lang('Between'), null, '%'), array(
74
+                'size' => 5,
75
+                'maxlength' => 5,
76
+                'disabled' => 'disabled',
77
+                'input-size' => 2
78
+            ));
79
+
80
+            for ($counter= 1; $counter <= 20; $counter++) {
81
+                $renderer =& $this->defaultRenderer();
82
+                $elementTemplateTwoLabel =
83
+                '<div id=' . $counter . ' style="display: '.(($counter<=$nr_items)?'inline':'none').';">
84 84
 
85 85
 				<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
86 86
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
 				';
107 107
 
108
-				$elementTemplateTwoLabel2 ='
108
+                $elementTemplateTwoLabel2 ='
109 109
 				<div class="col-sm-2">
110 110
 					<!-- BEGIN error --><span class="form_error">{error}</span>
111 111
 					<!-- END error -->
@@ -120,34 +120,34 @@  discard block
 block discarded – undo
120 120
 				</div>
121 121
 				</div>';
122 122
 
123
-				$scorebetw = array();
124
-				$this->addElement('text', 'endscore[' . $counter . ']', null, array (
125
-					'size' => 5,
126
-					'maxlength' => 5,
127
-					'id' => 'txta-'.$counter,
128
-					'input-size' => 2
129
-				));
130
-
131
-				$this->addElement('text', 'displaytext[' . $counter . ']', null,array (
132
-					'size' => 40,
133
-					'maxlength' => 40,
134
-					'id' => 'txtb-'.$counter
135
-				));
136
-				$renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore[' . $counter . ']');
137
-				$renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext[' . $counter . ']');
138
-				$this->addRule('endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric');
139
-				$this->addRule(array ('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
140
-				$this->addRule(array ('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>');
141
-			}
142
-		}
123
+                $scorebetw = array();
124
+                $this->addElement('text', 'endscore[' . $counter . ']', null, array (
125
+                    'size' => 5,
126
+                    'maxlength' => 5,
127
+                    'id' => 'txta-'.$counter,
128
+                    'input-size' => 2
129
+                ));
130
+
131
+                $this->addElement('text', 'displaytext[' . $counter . ']', null,array (
132
+                    'size' => 40,
133
+                    'maxlength' => 40,
134
+                    'id' => 'txtb-'.$counter
135
+                ));
136
+                $renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore[' . $counter . ']');
137
+                $renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext[' . $counter . ']');
138
+                $this->addRule('endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric');
139
+                $this->addRule(array ('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
140
+                $this->addRule(array ('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>');
141
+            }
142
+        }
143 143
 
144 144
         if ($displayscore->is_custom()) {
145
-			$this->addButtonSave(get_lang('Ok'));
146
-		}
147
-	}
145
+            $this->addButtonSave(get_lang('Ok'));
146
+        }
147
+    }
148 148
 
149
-	public function validate()
149
+    public function validate()
150 150
     {
151
-		return parent :: validate();
152
-	}
151
+        return parent :: validate();
152
+    }
153 153
 }
Please login to merge, or discard this patch.
app/Resources/public/assets/ckeditor/samples/old/assets/posteddata.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,22 +27,22 @@
 block discarded – undo
27 27
 
28 28
 if (!empty($_POST))
29 29
 {
30
-	foreach ( $_POST as $key => $value )
31
-	{
32
-		if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
33
-			continue;
30
+    foreach ( $_POST as $key => $value )
31
+    {
32
+        if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
33
+            continue;
34 34
 
35
-		if ( get_magic_quotes_gpc() )
36
-			$value = htmlspecialchars( stripslashes((string)$value) );
37
-		else
38
-			$value = htmlspecialchars( (string)$value );
35
+        if ( get_magic_quotes_gpc() )
36
+            $value = htmlspecialchars( stripslashes((string)$value) );
37
+        else
38
+            $value = htmlspecialchars( (string)$value );
39 39
 ?>
40 40
 		<tr>
41 41
 			<th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th>
42 42
 			<td><pre class="samples"><?php echo $value; ?></pre></td>
43 43
 		</tr>
44 44
 	<?php
45
-	}
45
+    }
46 46
 }
47 47
 ?>
48 48
 	</table>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@
 block discarded – undo
27 27
 
28 28
 if (!empty($_POST))
29 29
 {
30
-	foreach ( $_POST as $key => $value )
30
+	foreach ($_POST as $key => $value)
31 31
 	{
32
-		if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
32
+		if ((!is_string($value) && !is_numeric($value)) || !is_string($key))
33 33
 			continue;
34 34
 
35
-		if ( get_magic_quotes_gpc() )
36
-			$value = htmlspecialchars( stripslashes((string)$value) );
35
+		if (get_magic_quotes_gpc())
36
+			$value = htmlspecialchars(stripslashes((string) $value));
37 37
 		else
38
-			$value = htmlspecialchars( (string)$value );
38
+			$value = htmlspecialchars((string) $value);
39 39
 ?>
40 40
 		<tr>
41
-			<th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th>
41
+			<th style="vertical-align: top"><?php echo htmlspecialchars((string) $key); ?></th>
42 42
 			<td><pre class="samples"><?php echo $value; ?></pre></td>
43 43
 		</tr>
44 44
 	<?php
Please login to merge, or discard this patch.
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,14 +29,16 @@
 block discarded – undo
29 29
 {
30 30
 	foreach ( $_POST as $key => $value )
31 31
 	{
32
-		if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
33
-			continue;
32
+		if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) ) {
33
+					continue;
34
+		}
34 35
 
35
-		if ( get_magic_quotes_gpc() )
36
-			$value = htmlspecialchars( stripslashes((string)$value) );
37
-		else
38
-			$value = htmlspecialchars( (string)$value );
39
-?>
36
+		if ( get_magic_quotes_gpc() ) {
37
+					$value = htmlspecialchars( stripslashes((string)$value) );
38
+		} else {
39
+					$value = htmlspecialchars( (string)$value );
40
+		}
41
+		?>
40 42
 		<tr>
41 43
 			<th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th>
42 44
 			<td><pre class="samples"><?php echo $value; ?></pre></td>
Please login to merge, or discard this patch.
main/admin/configure_homepage.php 2 patches
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.
Indentation   +849 added lines, -849 removed lines patch added patch discarded remove patch
@@ -17,35 +17,35 @@  discard block
 block discarded – undo
17 17
  */
18 18
 function home_tabs($file_logged_in)
19 19
 {
20
-	$post = strpos($file_logged_in, "_logged_in");
21
-	if ($post !== false) {
22
-		$file_logged_out = str_replace('_logged_in','', $file_logged_in);
23
-		//variables initialization
24
-		$data_logged_out = array();
25
-		$data_logged_in  = array();
26
-
27
-		//we read the file with all links
28
-		$file = file($file_logged_in);
29
-		foreach ($file as $line) {
30
-			$line = str_replace("\n", '',$line);
31
-			//not logged user only sees public links
32
-			if (!preg_match('/::private/',$line)) {
33
-				$data_logged_out[] = $line;
34
-			}
35
-			//logged user only sees all links
36
-			$data_logged_in[] = $line;
37
-		}
38
-		//tabs file for logged out users
39
-		if (file_exists($file_logged_out)) {
40
-			$fp = fopen($file_logged_out, 'w');
41
-			fputs($fp, implode("\n", $data_logged_out));
42
-			fclose($fp);
43
-		}
44
-		//tabs file for logged in users
45
-		$fp = fopen($file_logged_in, 'w');
46
-		fputs($fp, implode("\n", $data_logged_in));
47
-		fclose($fp);
48
-	}
20
+    $post = strpos($file_logged_in, "_logged_in");
21
+    if ($post !== false) {
22
+        $file_logged_out = str_replace('_logged_in','', $file_logged_in);
23
+        //variables initialization
24
+        $data_logged_out = array();
25
+        $data_logged_in  = array();
26
+
27
+        //we read the file with all links
28
+        $file = file($file_logged_in);
29
+        foreach ($file as $line) {
30
+            $line = str_replace("\n", '',$line);
31
+            //not logged user only sees public links
32
+            if (!preg_match('/::private/',$line)) {
33
+                $data_logged_out[] = $line;
34
+            }
35
+            //logged user only sees all links
36
+            $data_logged_in[] = $line;
37
+        }
38
+        //tabs file for logged out users
39
+        if (file_exists($file_logged_out)) {
40
+            $fp = fopen($file_logged_out, 'w');
41
+            fputs($fp, implode("\n", $data_logged_out));
42
+            fclose($fp);
43
+        }
44
+        //tabs file for logged in users
45
+        $fp = fopen($file_logged_in, 'w');
46
+        fputs($fp, implode("\n", $data_logged_in));
47
+        fclose($fp);
48
+    }
49 49
 }
50 50
 
51 51
 $cidReset = true;
@@ -76,39 +76,39 @@  discard block
 block discarded – undo
76 76
 $_languages = api_get_languages();
77 77
 $selfUrl =  api_get_self();
78 78
 $interbreadcrumb[] = array(
79
-	'url' => 'index.php',
80
-	'name' => get_lang('PlatformAdmin')
79
+    'url' => 'index.php',
80
+    'name' => get_lang('PlatformAdmin')
81 81
 );
82 82
 
83 83
 if (!empty($action)) {
84
-	$interbreadcrumb[] = array(
85
-		'url' => 'configure_homepage.php',
86
-		'name' => get_lang('ConfigureHomePage')
87
-	);
88
-
89
-	switch ($action) {
90
-		case 'edit_top':
91
-			$tool_name = get_lang('EditHomePage');
92
-			break;
93
-		case 'edit_news':
94
-			$tool_name = get_lang('EditNews');
95
-			break;
96
-		case 'edit_notice':
97
-			$tool_name = get_lang('EditNotice');
98
-			break;
99
-		case 'insert_link':
100
-			$tool_name = get_lang('InsertLink');
101
-			break;
102
-		case 'edit_link':
103
-			$tool_name = get_lang('EditLink');
104
-			break;
105
-		case 'insert_tabs':
106
-			$tool_name = get_lang('InsertTabs');
107
-			break;
108
-		case 'edit_tabs':
109
-			$tool_name = get_lang('EditTabs');
110
-			break;
111
-	}
84
+    $interbreadcrumb[] = array(
85
+        'url' => 'configure_homepage.php',
86
+        'name' => get_lang('ConfigureHomePage')
87
+    );
88
+
89
+    switch ($action) {
90
+        case 'edit_top':
91
+            $tool_name = get_lang('EditHomePage');
92
+            break;
93
+        case 'edit_news':
94
+            $tool_name = get_lang('EditNews');
95
+            break;
96
+        case 'edit_notice':
97
+            $tool_name = get_lang('EditNotice');
98
+            break;
99
+        case 'insert_link':
100
+            $tool_name = get_lang('InsertLink');
101
+            break;
102
+        case 'edit_link':
103
+            $tool_name = get_lang('EditLink');
104
+            break;
105
+        case 'insert_tabs':
106
+            $tool_name = get_lang('InsertTabs');
107
+            break;
108
+        case 'edit_tabs':
109
+            $tool_name = get_lang('EditTabs');
110
+            break;
111
+    }
112 112
 }
113 113
 
114 114
 // The global logic for language priorities should be:
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 
132 132
 $lang = ''; //el for "Edit Language"
133 133
 if (!empty($_SESSION['user_language_choice'])) {
134
-	$lang = $_SESSION['user_language_choice'];
134
+    $lang = $_SESSION['user_language_choice'];
135 135
 } elseif (!empty($_SESSION['_user']['language'])) {
136
-	$lang = $_SESSION['_user']['language'];
136
+    $lang = $_SESSION['_user']['language'];
137 137
 } else {
138
-	$lang = api_get_setting('platformLanguage');
138
+    $lang = api_get_setting('platformLanguage');
139 139
 }
140 140
 
141 141
 $languageGet = isset($_GET['language']) ? Security::remove_XSS($_GET['language']) : $lang;
@@ -144,25 +144,25 @@  discard block
 block discarded – undo
144 144
 $homePath = api_get_path(SYS_HOME_PATH);
145 145
 
146 146
 if (api_is_multiple_url_enabled()) {
147
-	$access_url_id = api_get_current_access_url_id();
148
-	if ($access_url_id != -1) {
149
-		$url_info = api_get_access_url($access_url_id);
150
-		$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
151
-		$clean_url = api_replace_dangerous_char($url);
152
-		$clean_url = str_replace('/', '-', $clean_url);
153
-		$clean_url .= '/';
154
-
155
-		$homep = $homePath; //homep for Home Path
156
-		$homep_new = $homePath.$clean_url; //homep for Home Path added the url
157
-		$new_url_dir = $homePath.$clean_url;
158
-		//we create the new dir for the new sites
159
-		if (!is_dir($new_url_dir)) {
160
-			mkdir($new_url_dir, api_get_permissions_for_new_directories());
161
-		}
162
-	}
147
+    $access_url_id = api_get_current_access_url_id();
148
+    if ($access_url_id != -1) {
149
+        $url_info = api_get_access_url($access_url_id);
150
+        $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
151
+        $clean_url = api_replace_dangerous_char($url);
152
+        $clean_url = str_replace('/', '-', $clean_url);
153
+        $clean_url .= '/';
154
+
155
+        $homep = $homePath; //homep for Home Path
156
+        $homep_new = $homePath.$clean_url; //homep for Home Path added the url
157
+        $new_url_dir = $homePath.$clean_url;
158
+        //we create the new dir for the new sites
159
+        if (!is_dir($new_url_dir)) {
160
+            mkdir($new_url_dir, api_get_permissions_for_new_directories());
161
+        }
162
+    }
163 163
 } else {
164
-	$homep_new = '';
165
-	$homep = $homePath; //homep for Home Path
164
+    $homep_new = '';
165
+    $homep = $homePath; //homep for Home Path
166 166
 }
167 167
 
168 168
 $menuf = 'home_menu'; //menuf for Menu File
@@ -177,25 +177,25 @@  discard block
 block discarded – undo
177 177
 
178 178
 // If language-specific file does not exist, create it by copying default file
179 179
 foreach ($homef as $my_file) {
180
-	if (api_is_multiple_url_enabled()) {
181
-		if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
182
-			if (!file_exists($homep.$my_file.$ext)) {
183
-				touch($homep.$my_file.$ext);
184
-			}
185
-			@copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
186
-		}
187
-	} else {
188
-		if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
189
-			if (!file_exists($homep.$my_file.$ext)) {
190
-				touch($homep.$my_file.$ext);
191
-			}
192
-			@copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext);
193
-		}
194
-	}
180
+    if (api_is_multiple_url_enabled()) {
181
+        if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
182
+            if (!file_exists($homep.$my_file.$ext)) {
183
+                touch($homep.$my_file.$ext);
184
+            }
185
+            @copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
186
+        }
187
+    } else {
188
+        if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
189
+            if (!file_exists($homep.$my_file.$ext)) {
190
+                touch($homep.$my_file.$ext);
191
+            }
192
+            @copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext);
193
+        }
194
+    }
195 195
 }
196 196
 
197 197
 if (api_is_multiple_url_enabled()) {
198
-	$homep = $homep_new;
198
+    $homep = $homep_new;
199 199
 }
200 200
 
201 201
 // Check WCAG settings and prepare edition using WCAG
@@ -204,578 +204,578 @@  discard block
 block discarded – undo
204 204
 // Filter link param
205 205
 $link = '';
206 206
 if (!empty($_GET['link'])) {
207
-	$link = $_GET['link'];
208
-	// If the link parameter is suspicious, empty it
209
-	if (strstr($link, '/') || !strstr($link, '.html') || strstr($link, '\\')) {
210
-		$link = '';
211
-		$action = '';
212
-	}
207
+    $link = $_GET['link'];
208
+    // If the link parameter is suspicious, empty it
209
+    if (strstr($link, '/') || !strstr($link, '.html') || strstr($link, '\\')) {
210
+        $link = '';
211
+        $action = '';
212
+    }
213 213
 }
214 214
 
215 215
 // Start analysing requested actions
216 216
 if (!empty($action)) {
217
-	if (!empty($_POST['formSent'])) {
218
-		// Variables used are $homep for home path, $menuf for menu file, $newsf
219
-		// for news file, $topf for top file, $noticef for noticefile,
220
-		// $ext for '.html'
221
-		switch ($action) {
222
-			case 'edit_top':
223
-				// Filter
224
-				$home_top = trim(stripslashes($_POST['home_top']));
225
-
226
-
227
-				// Write
228
-				if (is_writable($homep)) {
229
-					// Default
230
-					if (is_writable($homep.$topf.'_'.$lang.$ext)) {
231
-						$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
232
-						fputs($fp, $home_top);
233
-						fclose($fp);
234
-
235
-						// Language
236
-						foreach ($_languages['name'] as $key => $value) {
237
-							$lang_name = $_languages['folder'][$key];
238
-							if (isset($_POST[$lang_name])) {
239
-								$fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
240
-								fputs($fp, $home_top);
241
-								fclose($fp);
242
-							}
243
-						}
244
-					} else {
245
-						$errorMsg = get_lang('HomePageFilesNotWritable');
246
-					}
247
-				} else {
248
-					//File does not exist
249
-					$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
250
-					fputs($fp, $home_top);
251
-					fclose($fp);
252
-
253
-					foreach ($_languages['name'] as $key => $value) {
254
-						$lang_name = $_languages['folder'][$key];
255
-						if (isset($_POST[$lang_name])) {
256
-							if (file_exists($homep.$topf.'_'.$lang_name.$ext)) {
257
-								$fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
258
-								fputs($fp, $home_top);
259
-								fclose($fp);
260
-							}
261
-						}
262
-					}
263
-				}
264
-
265
-				if (EventsMail::check_if_using_class('portal_homepage_edited')) {
266
-					EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
267
-				}
268
-				Event::addEvent(
269
-					LOG_HOMEPAGE_CHANGED,
270
-					'edit_top',
271
-					cut(strip_tags($home_top), 254),
272
-					api_get_utc_datetime(),
273
-					api_get_user_id()
274
-				);
275
-				break;
276
-			case 'edit_notice':
277
-				// Filter
278
-				$notice_title = trim(strip_tags(stripslashes($_POST['notice_title'])));
279
-				$notice_text = trim(str_replace(array("\r", "\n"), array('', '<br />'), strip_tags(stripslashes($_POST['notice_text']), '<a>')));
280
-				if (empty($notice_title) || empty($notice_text)) {
281
-					$errorMsg = get_lang('NoticeWillBeNotDisplayed');
282
-				}
283
-				// Write
284
-				if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
285
-					if (is_writable($homep.$noticef.'_'.$lang.$ext)) {
286
-						$fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
287
-						if ($errorMsg == '') {
288
-							fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
289
-
290
-							foreach ($_languages['name'] as $key => $value) {
291
-								$lang_name = $_languages['folder'][$key];
292
-								if (isset($_POST[$lang_name])) {
293
-									if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
294
-										if (is_writable($homep.$noticef.'_'.$lang_name.$ext)) {
295
-											$fp = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
296
-											fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
297
-											fclose($fp);
298
-										}
299
-									}
300
-								}
301
-							}
302
-						} else {
303
-							fputs($fp, '');
304
-
305
-							foreach ($_languages['name'] as $key => $value) {
306
-								$lang_name = $_languages['folder'][$key];
307
-								if (isset($_POST[$lang_name])) {
308
-									if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
309
-										$fp1 = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
310
-										fputs($fp1, '');
311
-										fclose($fp1);
312
-									}
313
-								}
314
-							}
315
-						}
316
-						fclose($fp);
317
-					} else {
318
-						$errorMsg .= "<br/>\n".get_lang('HomePageFilesNotWritable');
319
-					}
320
-				} else {
321
-					//File does not exist
322
-					$fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
323
-					fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
324
-					fclose($fp);
325
-				}
326
-				Event::addEvent(
217
+    if (!empty($_POST['formSent'])) {
218
+        // Variables used are $homep for home path, $menuf for menu file, $newsf
219
+        // for news file, $topf for top file, $noticef for noticefile,
220
+        // $ext for '.html'
221
+        switch ($action) {
222
+            case 'edit_top':
223
+                // Filter
224
+                $home_top = trim(stripslashes($_POST['home_top']));
225
+
226
+
227
+                // Write
228
+                if (is_writable($homep)) {
229
+                    // Default
230
+                    if (is_writable($homep.$topf.'_'.$lang.$ext)) {
231
+                        $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
232
+                        fputs($fp, $home_top);
233
+                        fclose($fp);
234
+
235
+                        // Language
236
+                        foreach ($_languages['name'] as $key => $value) {
237
+                            $lang_name = $_languages['folder'][$key];
238
+                            if (isset($_POST[$lang_name])) {
239
+                                $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
240
+                                fputs($fp, $home_top);
241
+                                fclose($fp);
242
+                            }
243
+                        }
244
+                    } else {
245
+                        $errorMsg = get_lang('HomePageFilesNotWritable');
246
+                    }
247
+                } else {
248
+                    //File does not exist
249
+                    $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
250
+                    fputs($fp, $home_top);
251
+                    fclose($fp);
252
+
253
+                    foreach ($_languages['name'] as $key => $value) {
254
+                        $lang_name = $_languages['folder'][$key];
255
+                        if (isset($_POST[$lang_name])) {
256
+                            if (file_exists($homep.$topf.'_'.$lang_name.$ext)) {
257
+                                $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
258
+                                fputs($fp, $home_top);
259
+                                fclose($fp);
260
+                            }
261
+                        }
262
+                    }
263
+                }
264
+
265
+                if (EventsMail::check_if_using_class('portal_homepage_edited')) {
266
+                    EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
267
+                }
268
+                Event::addEvent(
269
+                    LOG_HOMEPAGE_CHANGED,
270
+                    'edit_top',
271
+                    cut(strip_tags($home_top), 254),
272
+                    api_get_utc_datetime(),
273
+                    api_get_user_id()
274
+                );
275
+                break;
276
+            case 'edit_notice':
277
+                // Filter
278
+                $notice_title = trim(strip_tags(stripslashes($_POST['notice_title'])));
279
+                $notice_text = trim(str_replace(array("\r", "\n"), array('', '<br />'), strip_tags(stripslashes($_POST['notice_text']), '<a>')));
280
+                if (empty($notice_title) || empty($notice_text)) {
281
+                    $errorMsg = get_lang('NoticeWillBeNotDisplayed');
282
+                }
283
+                // Write
284
+                if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
285
+                    if (is_writable($homep.$noticef.'_'.$lang.$ext)) {
286
+                        $fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
287
+                        if ($errorMsg == '') {
288
+                            fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
289
+
290
+                            foreach ($_languages['name'] as $key => $value) {
291
+                                $lang_name = $_languages['folder'][$key];
292
+                                if (isset($_POST[$lang_name])) {
293
+                                    if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
294
+                                        if (is_writable($homep.$noticef.'_'.$lang_name.$ext)) {
295
+                                            $fp = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
296
+                                            fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
297
+                                            fclose($fp);
298
+                                        }
299
+                                    }
300
+                                }
301
+                            }
302
+                        } else {
303
+                            fputs($fp, '');
304
+
305
+                            foreach ($_languages['name'] as $key => $value) {
306
+                                $lang_name = $_languages['folder'][$key];
307
+                                if (isset($_POST[$lang_name])) {
308
+                                    if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
309
+                                        $fp1 = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
310
+                                        fputs($fp1, '');
311
+                                        fclose($fp1);
312
+                                    }
313
+                                }
314
+                            }
315
+                        }
316
+                        fclose($fp);
317
+                    } else {
318
+                        $errorMsg .= "<br/>\n".get_lang('HomePageFilesNotWritable');
319
+                    }
320
+                } else {
321
+                    //File does not exist
322
+                    $fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
323
+                    fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
324
+                    fclose($fp);
325
+                }
326
+                Event::addEvent(
327 327
                     LOG_HOMEPAGE_CHANGED,
328 328
                     'edit_notice',
329 329
                     cut(strip_tags($notice_title), 254),
330 330
                     api_get_utc_datetime(),
331 331
                     api_get_user_id()
332 332
                 );
333
-				break;
334
-			case 'edit_news':
335
-				//Filter
336
-				$home_news = trim(stripslashes($_POST['home_news']));
337
-
338
-				//Write
339
-				if ($s_languages_news != 'all') {
340
-					if (file_exists($homep.$newsf.'_'.$s_languages_news.$ext)) {
341
-						if (is_writable($homep.$newsf.'_'.$s_languages_news.$ext)) {
342
-							$fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
343
-							fputs($fp, $home_news);
344
-							fclose($fp);
345
-						} else {
346
-							$errorMsg = get_lang('HomePageFilesNotWritable');
347
-						}
348
-					} else {
349
-						// File does not exist
350
-						$fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
351
-						fputs($fp, $home_news);
352
-						fclose($fp);
353
-					}
354
-				} else {
355
-					// We update all the news file
356
-					foreach ($_languages['name'] as $key => $value) {
357
-						$english_name = $_languages['folder'][$key];
358
-						if (file_exists($homep.$newsf.'_'.$english_name.$ext)) {
359
-							if (is_writable($homep.$newsf.'_'.$english_name.$ext)) {
360
-								$fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
361
-								fputs($fp, $home_news);
362
-								fclose($fp);
363
-							} else {
364
-								$errorMsg = get_lang('HomePageFilesNotWritable');
365
-							}
366
-						} else {
367
-							// File does not exist
368
-							$fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
369
-							fputs($fp, $home_news);
370
-							fclose($fp);
371
-						}
372
-					}
373
-				}
374
-				Event::addEvent(
333
+                break;
334
+            case 'edit_news':
335
+                //Filter
336
+                $home_news = trim(stripslashes($_POST['home_news']));
337
+
338
+                //Write
339
+                if ($s_languages_news != 'all') {
340
+                    if (file_exists($homep.$newsf.'_'.$s_languages_news.$ext)) {
341
+                        if (is_writable($homep.$newsf.'_'.$s_languages_news.$ext)) {
342
+                            $fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
343
+                            fputs($fp, $home_news);
344
+                            fclose($fp);
345
+                        } else {
346
+                            $errorMsg = get_lang('HomePageFilesNotWritable');
347
+                        }
348
+                    } else {
349
+                        // File does not exist
350
+                        $fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
351
+                        fputs($fp, $home_news);
352
+                        fclose($fp);
353
+                    }
354
+                } else {
355
+                    // We update all the news file
356
+                    foreach ($_languages['name'] as $key => $value) {
357
+                        $english_name = $_languages['folder'][$key];
358
+                        if (file_exists($homep.$newsf.'_'.$english_name.$ext)) {
359
+                            if (is_writable($homep.$newsf.'_'.$english_name.$ext)) {
360
+                                $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
361
+                                fputs($fp, $home_news);
362
+                                fclose($fp);
363
+                            } else {
364
+                                $errorMsg = get_lang('HomePageFilesNotWritable');
365
+                            }
366
+                        } else {
367
+                            // File does not exist
368
+                            $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
369
+                            fputs($fp, $home_news);
370
+                            fclose($fp);
371
+                        }
372
+                    }
373
+                }
374
+                Event::addEvent(
375 375
                     LOG_HOMEPAGE_CHANGED,
376 376
                     'edit_news',
377 377
                     strip_tags(cut($home_news, 254)),
378 378
                     api_get_utc_datetime(),
379 379
                     api_get_user_id()
380 380
                 );
381
-				break;
382
-			case 'insert_tabs':
383
-			case 'edit_tabs':
384
-			case 'insert_link':
385
-			case 'edit_link':
386
-				$link_index     = intval($_POST['link_index']);
387
-				$insert_where   = intval($_POST['insert_where']);
388
-				$link_name      = trim(stripslashes($_POST['link_name']));
389
-				$link_url       = trim(stripslashes($_POST['link_url']));
390
-				$add_in_tab     = intval($_POST['add_in_tab']);
391
-				$link_html = trim(stripslashes($_POST['link_html']));
392
-				$filename = trim(stripslashes($_POST['filename']));
393
-				$target_blank = $_POST['target_blank'] ? true : false;
394
-
395
-				if ($link_url == 'http://' || $link_url == 'https://') {
396
-					$link_url = '';
397
-				} elseif (!empty($link_url) && !strstr($link_url, '://')) {
398
-					$link_url='http://'.$link_url;
399
-				}
400
-				$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $mtloggedin : $menuf;
401
-
402
-				if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
403
-					$errorMsg = get_lang('HomePageFilesNotWritable');
404
-				} elseif (empty($link_name)) {
405
-					$errorMsg = get_lang('PleaseEnterLinkName');
406
-				} else {
407
-					// New links are added as new files in the home/ directory
408
-					if ($action == 'insert_link' || $action == 'insert_tabs' || empty($filename) || strstr($filename, '/') || !strstr($filename, '.html')) {
409
-						$filename = api_replace_dangerous_char($link_name).'.html';
410
-					}
411
-
412
-					// "home_" prefix for links are renamed to "user_" prefix (to avoid name clash with existing home page files)
413
-					if (!empty($filename)) {
414
-						$filename = str_replace('home_', 'user_', $filename);
415
-					}
416
-					// If the typical language suffix is not found in the file name,
417
-					// replace the ".html" suffix by "_en.html" or the active menu language
418
-					if (!strstr($filename,'_'.$lang.$ext)) {
419
-						$filename = str_replace($ext, '_'.$lang.$ext, $filename);
420
-					}
421
-					// Get the contents of home_menu_en.html (or active menu language
422
-					// version) into $home_menu as an array of one entry per line
423
-					$home_menu = file($homep.$menuf.'_'.$lang.$ext);
424
-					$home_menu = implode("\n", $home_menu);
425
-					$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
426
-					$home_menu = explode("\n", $home_menu);
427
-					$home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
428
-					// Prepare place to insert the new link into (default is end of file)
429
-					if ($insert_where < -1 || $insert_where > (sizeof($home_menu) - 1)) {
430
-						$insert_where = sizeof($home_menu) - 1;
431
-					}
432
-					//
433
-					// For each line of the file, remove trailing spaces and special chars
434
-					//foreach ($home_menu as $key => $enreg) {
435
-					//	$home_menu[$key] = trim($enreg);
436
-					//}
437
-					//
438
-					// If the given link url is empty, then replace the link url by a link to the link file created
439
-
440
-					if (empty($link_url) || $link_url == 'http://' ||  $link_url == 'https://') {
441
-						$link_url = api_get_path(WEB_PATH).'index.php?include='.urlencode($filename);
442
-						// If the file doesn't exist, then create it and
443
-						// fill it with default text
444
-
445
-						$fp = @fopen($homep.$filename, 'w');
446
-						if ($fp) {
447
-							if (empty($link_html)) {
448
-								fputs($fp, get_lang('MyTextHere'));
449
-								home_tabs($homep.$filename);
450
-							} else {
451
-								fputs($fp, $link_html);
452
-								home_tabs($homep.$filename);
453
-							}
454
-							fclose($fp);
455
-						}
456
-					}
457
-					// If the requested action is to edit a link, open the file and
458
-					// write to it (if the file doesn't exist, create it)
459
-					if (in_array($action, array('edit_link'))  && !empty($link_html)) {
460
-						$fp = @fopen($homep.$filename, 'w');
461
-						if ($fp) {
462
-							fputs($fp, $link_html);
463
-							home_tabs($homep.$filename);
464
-							fclose($fp);
465
-						}
466
-					}
381
+                break;
382
+            case 'insert_tabs':
383
+            case 'edit_tabs':
384
+            case 'insert_link':
385
+            case 'edit_link':
386
+                $link_index     = intval($_POST['link_index']);
387
+                $insert_where   = intval($_POST['insert_where']);
388
+                $link_name      = trim(stripslashes($_POST['link_name']));
389
+                $link_url       = trim(stripslashes($_POST['link_url']));
390
+                $add_in_tab     = intval($_POST['add_in_tab']);
391
+                $link_html = trim(stripslashes($_POST['link_html']));
392
+                $filename = trim(stripslashes($_POST['filename']));
393
+                $target_blank = $_POST['target_blank'] ? true : false;
394
+
395
+                if ($link_url == 'http://' || $link_url == 'https://') {
396
+                    $link_url = '';
397
+                } elseif (!empty($link_url) && !strstr($link_url, '://')) {
398
+                    $link_url='http://'.$link_url;
399
+                }
400
+                $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $mtloggedin : $menuf;
401
+
402
+                if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
403
+                    $errorMsg = get_lang('HomePageFilesNotWritable');
404
+                } elseif (empty($link_name)) {
405
+                    $errorMsg = get_lang('PleaseEnterLinkName');
406
+                } else {
407
+                    // New links are added as new files in the home/ directory
408
+                    if ($action == 'insert_link' || $action == 'insert_tabs' || empty($filename) || strstr($filename, '/') || !strstr($filename, '.html')) {
409
+                        $filename = api_replace_dangerous_char($link_name).'.html';
410
+                    }
411
+
412
+                    // "home_" prefix for links are renamed to "user_" prefix (to avoid name clash with existing home page files)
413
+                    if (!empty($filename)) {
414
+                        $filename = str_replace('home_', 'user_', $filename);
415
+                    }
416
+                    // If the typical language suffix is not found in the file name,
417
+                    // replace the ".html" suffix by "_en.html" or the active menu language
418
+                    if (!strstr($filename,'_'.$lang.$ext)) {
419
+                        $filename = str_replace($ext, '_'.$lang.$ext, $filename);
420
+                    }
421
+                    // Get the contents of home_menu_en.html (or active menu language
422
+                    // version) into $home_menu as an array of one entry per line
423
+                    $home_menu = file($homep.$menuf.'_'.$lang.$ext);
424
+                    $home_menu = implode("\n", $home_menu);
425
+                    $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
426
+                    $home_menu = explode("\n", $home_menu);
427
+                    $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
428
+                    // Prepare place to insert the new link into (default is end of file)
429
+                    if ($insert_where < -1 || $insert_where > (sizeof($home_menu) - 1)) {
430
+                        $insert_where = sizeof($home_menu) - 1;
431
+                    }
432
+                    //
433
+                    // For each line of the file, remove trailing spaces and special chars
434
+                    //foreach ($home_menu as $key => $enreg) {
435
+                    //	$home_menu[$key] = trim($enreg);
436
+                    //}
437
+                    //
438
+                    // If the given link url is empty, then replace the link url by a link to the link file created
439
+
440
+                    if (empty($link_url) || $link_url == 'http://' ||  $link_url == 'https://') {
441
+                        $link_url = api_get_path(WEB_PATH).'index.php?include='.urlencode($filename);
442
+                        // If the file doesn't exist, then create it and
443
+                        // fill it with default text
444
+
445
+                        $fp = @fopen($homep.$filename, 'w');
446
+                        if ($fp) {
447
+                            if (empty($link_html)) {
448
+                                fputs($fp, get_lang('MyTextHere'));
449
+                                home_tabs($homep.$filename);
450
+                            } else {
451
+                                fputs($fp, $link_html);
452
+                                home_tabs($homep.$filename);
453
+                            }
454
+                            fclose($fp);
455
+                        }
456
+                    }
457
+                    // If the requested action is to edit a link, open the file and
458
+                    // write to it (if the file doesn't exist, create it)
459
+                    if (in_array($action, array('edit_link'))  && !empty($link_html)) {
460
+                        $fp = @fopen($homep.$filename, 'w');
461
+                        if ($fp) {
462
+                            fputs($fp, $link_html);
463
+                            home_tabs($homep.$filename);
464
+                            fclose($fp);
465
+                        }
466
+                    }
467 467
 
468 468
                     $class_add_in_tab = 'class="show_menu"';
469 469
 
470
-					if (!$add_in_tab) {
471
-						$class_add_in_tab = 'class="hide_menu"';
472
-					}
473
-
474
-					// If the requested action is to create a link, make some room
475
-					// for the new link in the home_menu array at the requested place
476
-					// and insert the new link there
477
-
478
-					if ($action == 'insert_link' || $action == 'insert_tabs') {
479
-						for ($i = sizeof($home_menu); $i; $i--) {
480
-							if ($i > $insert_where) {
481
-								$home_menu[$i] = $home_menu[$i - 1];
482
-							} else {
483
-								break;
484
-							}
485
-						}
486
-						$home_menu[$insert_where + 1] = '<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'. $link_name .'</a></li>';
487
-					} else {
488
-						// If the request is about a link edition, change the link
489
-						$home_menu[$link_index]='<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'. $link_name .'</a></li>';
490
-					}
491
-					// Re-build the file from the home_menu array
492
-					$home_menu = implode("\n", $home_menu);
493
-					// Write
494
-					if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
495
-						if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
496
-							$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
497
-							fputs($fp, $home_menu);
498
-							home_tabs($homep.$menuf.'_'.$lang.$ext);
499
-							fclose($fp);
500
-
501
-							foreach ($_languages['name'] as $key => $value) {
502
-								$lang_name = $_languages['folder'][$key];
503
-								if (isset($_POST[$lang_name])) {
504
-									$fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
505
-									fputs($fp, $home_menu);
506
-									home_tabs($homep.$menuf.'_'.$lang_name.$ext);
507
-									fclose($fp);
508
-								}
509
-							}
510
-
511
-							if (file_exists($homep.$menuf.$ext)) {
512
-								if (is_writable($homep.$menuf.$ext)) {
513
-									$fpo = fopen($homep.$menuf.$ext, 'w');
514
-									fputs($fpo, $home_menu);
515
-									home_tabs($homep.$menuf.$ext);
516
-									fclose($fpo);
517
-								}
518
-							}
519
-						} else {
520
-							$errorMsg = get_lang('HomePageFilesNotWritable');
521
-						}
522
-					} else {
523
-						//File does not exist
524
-						$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
525
-						fputs($fp, $home_menu);
526
-						home_tabs($homep.$menuf.'_'.$lang.$ext);
527
-						fclose($fp);
528
-
529
-						foreach ($_languages['name'] as $key => $value) {
530
-							$lang_name = $_languages['folder'][$key];
531
-							if (isset($_POST[$lang_name])) {
532
-								$fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
533
-								fputs($fp, $home_menu);
534
-								home_tabs($homep.$menuf.'_'.$lang_name.$ext);
535
-								fclose($fp);
536
-							}
537
-						}
538
-					}
539
-				}
540
-				Event::addEvent(
541
-					LOG_HOMEPAGE_CHANGED,
542
-					$action,
543
-					cut($link_name . ':' . $link_url, 254),
544
-					api_get_utc_datetime(),
545
-					api_get_user_id()
546
-				);
547
-				break;
548
-		} //end of switch($action)
549
-
550
-		if (empty($errorMsg)) {
551
-			header('Location: '.$selfUrl.'?language='.$languageGet);
552
-			exit();
553
-		}
554
-	} else {
555
-		//if POST[formSent] is not set
556
-		switch ($action) {
557
-			case 'open_link':
558
-				// Previously, filtering of GET['link'] was done here but it left
559
-				// a security threat. Filtering has now been moved outside conditions
560
-				break;
561
-			case 'delete_tabs':
562
-			case 'delete_link':
563
-				// A link is deleted by getting the file into an array, removing the
564
-				// link and re-writing the array to the file
565
-				$link_index = intval($_GET['link_index']);
566
-				$menuf = ($action == 'delete_tabs')? $mtloggedin : $menuf;
567
-				$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
568
-				if (empty($home_menu)) {
569
-					$home_menu = array();
570
-				}
571
-				foreach ($home_menu as $key => $enreg) {
572
-					if ($key == $link_index) {
573
-						unset($home_menu[$key]);
574
-					} else {
575
-						$home_menu[$key] = trim($enreg);
576
-					}
577
-				}
578
-				$home_menu = implode("\n", $home_menu);
579
-				$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
580
-
581
-				$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
582
-				fputs($fp, $home_menu);
583
-				home_tabs($homep.$menuf.'_'.$lang.$ext);
584
-				fclose($fp);
585
-				if (file_exists($homep.$menuf.$ext)) {
586
-					if (is_writable($homep.$menuf.$ext)) {
587
-						$fpo = fopen($homep.$menuf.$ext,'w');
588
-						fputs($fpo, $home_menu);
589
-						home_tabs($homep.$menuf.$ext);
590
-						fclose($fpo);
591
-					}
592
-				}
593
-				header('Location: '.$selfUrl);
594
-				exit();
595
-				break;
596
-			case 'edit_top':
597
-				// This request is only the preparation for the update of the home_top
598
-				$home_top = '';
599
-				if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
600
-					$home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
601
-				} elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
602
-					$home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
603
-				} else {
604
-					$errorMsg = get_lang('HomePageFilesNotReadable');
605
-				}
606
-				$home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
607
-				break;
608
-			case 'edit_notice':
609
-				// This request is only the preparation for the update of the home_notice
610
-				$home_notice = '';
611
-				if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) {
612
-					$home_notice = @file($homep.$noticef.'_'.$lang.$ext);
613
-				} elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) {
614
-					$home_notice = @file($homep.$noticef.$lang.$ext);
615
-				} else {
616
-					$errorMsg = get_lang('HomePageFilesNotReadable');
617
-				}
618
-				if (empty($home_notice)) {
619
-					$home_notice = array();
620
-				}
621
-				$notice_title = strip_tags($home_notice[0]);
622
-				$notice_title = api_to_system_encoding($notice_title, api_detect_encoding($notice_title));
623
-				$notice_text = strip_tags(str_replace('<br />', "\n", $home_notice[1]), '<a>');
624
-				$notice_text = api_to_system_encoding($notice_text, api_detect_encoding(strip_tags($notice_text)));
625
-				break;
626
-			case 'edit_news':
627
-				// This request is the preparation for the update of the home_news page
628
-				$home_news = '';
629
-				if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
630
-					$home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
631
-				} elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
632
-					$home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
633
-				} else {
634
-					$errorMsg = get_lang('HomePageFilesNotReadable');
635
-				}
636
-				$home_news = api_to_system_encoding($home_news, api_detect_encoding(strip_tags($home_news)));
637
-				break;
638
-			case 'insert_link':
639
-				// This request is the preparation for the addition of an item in home_menu
640
-				$home_menu = '';
641
-				$menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
642
-				if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
643
-					$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
644
-				} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
645
-					$home_menu = @file($homep.$menuf.$lang.$ext);
646
-				} else {
647
-					$errorMsg = get_lang('HomePageFilesNotReadable');
648
-				}
649
-				if (empty($home_menu)) {
650
-					$home_menu = array();
651
-				}
652
-				if (!empty($home_menu)) {
653
-					$home_menu = implode("\n", $home_menu);
654
-					$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
655
-					$home_menu = explode("\n", $home_menu);
656
-				}
657
-				$home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
658
-				break;
659
-			case 'insert_tabs':
660
-				// This request is the preparation for the addition of an item in home_menu
661
-				$home_menu = '';
662
-				if (is_file($homep.$mtloggedin.'_'.$lang.$ext) && is_readable($homep.$mtloggedin.'_'.$lang.$ext)) {
663
-					$home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
664
-				} elseif (is_file($homep.$mtloggedin.$lang.$ext) && is_readable($homep.$mtloggedin.$lang.$ext)) {
665
-					$home_menu = @file($homep.$mtloggedin.$lang.$ext);
666
-				} elseif (touch($homep.$mtloggedin.'_'.$lang.$ext)) {
667
-					$home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
668
-				} else {
669
-					$errorMsg = get_lang('HomePageFilesNotReadable');
670
-				}
671
-				if (empty($home_menu)) {
672
-					$home_menu = array();
673
-				}
674
-				if (!empty($home_menu)) {
675
-					$home_menu = implode("\n", $home_menu);
676
-					$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
677
-					$home_menu = explode("\n", $home_menu);
678
-				}
679
-				$home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
680
-				break;
681
-			case 'edit_tabs':
682
-			case 'edit_link':
683
-				// This request is the preparation for the edition of the links array
684
-				$home_menu = '';
685
-				$menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
686
-				if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
687
-					$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
688
-				} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
689
-					$home_menu = @file($homep.$menuf.$lang.$ext);
690
-				} else {
691
-					$errorMsg = get_lang('HomePageFilesNotReadable');
692
-				}
693
-
694
-				if (empty($home_menu)) {
695
-					if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
696
-						$home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
697
-					}
698
-				}
699
-
700
-				if (empty($home_menu)) {
701
-					$home_menu = array();
702
-				}
703
-				if (!empty($home_menu)) {
704
-					$home_menu = implode("\n", $home_menu);
705
-					$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
706
-					$home_menu = explode("\n", $home_menu);
707
-				}
708
-
709
-				$link_index = intval($_GET['link_index']);
710
-
711
-				$target_blank = false;
712
-				$link_name = '';
713
-				$link_url = '';
714
-
715
-				//$home_menu_new = array();
716
-				//
717
-				//Cleaning array
718
-				//foreach ($home_menu as $item) {
719
-				//	if(!empty($item)) {
720
-				//		$home_menu_new[] = $item;
721
-				//	}
722
-				//}
723
-				//$home_menu = $home_menu_new;
724
-
725
-				// Cleaning the array
726
-				$home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
727
-
728
-				// For each line of the home_menu file
729
-				foreach ($home_menu as $key => $enreg) {
730
-
731
-					// Check if the current item is the one we want to update
732
-					if ($key == $link_index) {
733
-						// This is the link we want to update
734
-						// Check if the target should be "_blank"
735
-						if (strstr($enreg, 'target="_blank"')) {
736
-							$target_blank = true;
737
-						}
738
-
739
-						if (strstr($enreg, 'hide_menu')) {
740
-							$add_in_tab = false;
741
-						} else {
742
-							$add_in_tab = true;
743
-						}
744
-
745
-						// Remove dangerous HTML tags from the link itself (this is an
746
-						// additional measure in case a link previously contained
747
-						// unsecure tags)
748
-						$link_name = strip_tags($enreg);
749
-
750
-						// Get the contents of "href" attribute in $link_url
751
-						$enreg = explode('href="',$enreg);
752
-						list($link_url) = explode('"', $enreg[sizeof($enreg) - 1]);
753
-
754
-						// If the link contains the web root of this portal, then strip
755
-						// it off and keep only the name of the file that needs edition
756
-						if (strstr($link_url, '?include=')) {
757
-							$link_url = explode('?include=', $link_url);
758
-
759
-							$filename = $link_url[sizeof($link_url) - 1];
760
-
761
-							if (!strstr($filename, '/') && strstr($filename, '.html')) {
762
-								// Get oonly the contents of the link file
763
-								$link_html = @file($homep.$filename);
764
-								$link_html = implode('', $link_html);
765
-								$link_url = '';
766
-							} else {
767
-								$filename = '';
768
-							}
769
-						}
770
-						break;
771
-					}
772
-				}
773
-				break;
774
-		}//end of second switch($action) (when POST['formSent'] was not set, yet)
775
-	}// end of "else" in if($_POST['formSent']) condition
470
+                    if (!$add_in_tab) {
471
+                        $class_add_in_tab = 'class="hide_menu"';
472
+                    }
473
+
474
+                    // If the requested action is to create a link, make some room
475
+                    // for the new link in the home_menu array at the requested place
476
+                    // and insert the new link there
477
+
478
+                    if ($action == 'insert_link' || $action == 'insert_tabs') {
479
+                        for ($i = sizeof($home_menu); $i; $i--) {
480
+                            if ($i > $insert_where) {
481
+                                $home_menu[$i] = $home_menu[$i - 1];
482
+                            } else {
483
+                                break;
484
+                            }
485
+                        }
486
+                        $home_menu[$insert_where + 1] = '<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'. $link_name .'</a></li>';
487
+                    } else {
488
+                        // If the request is about a link edition, change the link
489
+                        $home_menu[$link_index]='<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'. $link_name .'</a></li>';
490
+                    }
491
+                    // Re-build the file from the home_menu array
492
+                    $home_menu = implode("\n", $home_menu);
493
+                    // Write
494
+                    if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
495
+                        if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
496
+                            $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
497
+                            fputs($fp, $home_menu);
498
+                            home_tabs($homep.$menuf.'_'.$lang.$ext);
499
+                            fclose($fp);
500
+
501
+                            foreach ($_languages['name'] as $key => $value) {
502
+                                $lang_name = $_languages['folder'][$key];
503
+                                if (isset($_POST[$lang_name])) {
504
+                                    $fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
505
+                                    fputs($fp, $home_menu);
506
+                                    home_tabs($homep.$menuf.'_'.$lang_name.$ext);
507
+                                    fclose($fp);
508
+                                }
509
+                            }
510
+
511
+                            if (file_exists($homep.$menuf.$ext)) {
512
+                                if (is_writable($homep.$menuf.$ext)) {
513
+                                    $fpo = fopen($homep.$menuf.$ext, 'w');
514
+                                    fputs($fpo, $home_menu);
515
+                                    home_tabs($homep.$menuf.$ext);
516
+                                    fclose($fpo);
517
+                                }
518
+                            }
519
+                        } else {
520
+                            $errorMsg = get_lang('HomePageFilesNotWritable');
521
+                        }
522
+                    } else {
523
+                        //File does not exist
524
+                        $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
525
+                        fputs($fp, $home_menu);
526
+                        home_tabs($homep.$menuf.'_'.$lang.$ext);
527
+                        fclose($fp);
528
+
529
+                        foreach ($_languages['name'] as $key => $value) {
530
+                            $lang_name = $_languages['folder'][$key];
531
+                            if (isset($_POST[$lang_name])) {
532
+                                $fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
533
+                                fputs($fp, $home_menu);
534
+                                home_tabs($homep.$menuf.'_'.$lang_name.$ext);
535
+                                fclose($fp);
536
+                            }
537
+                        }
538
+                    }
539
+                }
540
+                Event::addEvent(
541
+                    LOG_HOMEPAGE_CHANGED,
542
+                    $action,
543
+                    cut($link_name . ':' . $link_url, 254),
544
+                    api_get_utc_datetime(),
545
+                    api_get_user_id()
546
+                );
547
+                break;
548
+        } //end of switch($action)
549
+
550
+        if (empty($errorMsg)) {
551
+            header('Location: '.$selfUrl.'?language='.$languageGet);
552
+            exit();
553
+        }
554
+    } else {
555
+        //if POST[formSent] is not set
556
+        switch ($action) {
557
+            case 'open_link':
558
+                // Previously, filtering of GET['link'] was done here but it left
559
+                // a security threat. Filtering has now been moved outside conditions
560
+                break;
561
+            case 'delete_tabs':
562
+            case 'delete_link':
563
+                // A link is deleted by getting the file into an array, removing the
564
+                // link and re-writing the array to the file
565
+                $link_index = intval($_GET['link_index']);
566
+                $menuf = ($action == 'delete_tabs')? $mtloggedin : $menuf;
567
+                $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
568
+                if (empty($home_menu)) {
569
+                    $home_menu = array();
570
+                }
571
+                foreach ($home_menu as $key => $enreg) {
572
+                    if ($key == $link_index) {
573
+                        unset($home_menu[$key]);
574
+                    } else {
575
+                        $home_menu[$key] = trim($enreg);
576
+                    }
577
+                }
578
+                $home_menu = implode("\n", $home_menu);
579
+                $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
580
+
581
+                $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
582
+                fputs($fp, $home_menu);
583
+                home_tabs($homep.$menuf.'_'.$lang.$ext);
584
+                fclose($fp);
585
+                if (file_exists($homep.$menuf.$ext)) {
586
+                    if (is_writable($homep.$menuf.$ext)) {
587
+                        $fpo = fopen($homep.$menuf.$ext,'w');
588
+                        fputs($fpo, $home_menu);
589
+                        home_tabs($homep.$menuf.$ext);
590
+                        fclose($fpo);
591
+                    }
592
+                }
593
+                header('Location: '.$selfUrl);
594
+                exit();
595
+                break;
596
+            case 'edit_top':
597
+                // This request is only the preparation for the update of the home_top
598
+                $home_top = '';
599
+                if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
600
+                    $home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
601
+                } elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
602
+                    $home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
603
+                } else {
604
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
605
+                }
606
+                $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
607
+                break;
608
+            case 'edit_notice':
609
+                // This request is only the preparation for the update of the home_notice
610
+                $home_notice = '';
611
+                if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) {
612
+                    $home_notice = @file($homep.$noticef.'_'.$lang.$ext);
613
+                } elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) {
614
+                    $home_notice = @file($homep.$noticef.$lang.$ext);
615
+                } else {
616
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
617
+                }
618
+                if (empty($home_notice)) {
619
+                    $home_notice = array();
620
+                }
621
+                $notice_title = strip_tags($home_notice[0]);
622
+                $notice_title = api_to_system_encoding($notice_title, api_detect_encoding($notice_title));
623
+                $notice_text = strip_tags(str_replace('<br />', "\n", $home_notice[1]), '<a>');
624
+                $notice_text = api_to_system_encoding($notice_text, api_detect_encoding(strip_tags($notice_text)));
625
+                break;
626
+            case 'edit_news':
627
+                // This request is the preparation for the update of the home_news page
628
+                $home_news = '';
629
+                if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
630
+                    $home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
631
+                } elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
632
+                    $home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
633
+                } else {
634
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
635
+                }
636
+                $home_news = api_to_system_encoding($home_news, api_detect_encoding(strip_tags($home_news)));
637
+                break;
638
+            case 'insert_link':
639
+                // This request is the preparation for the addition of an item in home_menu
640
+                $home_menu = '';
641
+                $menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
642
+                if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
643
+                    $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
644
+                } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
645
+                    $home_menu = @file($homep.$menuf.$lang.$ext);
646
+                } else {
647
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
648
+                }
649
+                if (empty($home_menu)) {
650
+                    $home_menu = array();
651
+                }
652
+                if (!empty($home_menu)) {
653
+                    $home_menu = implode("\n", $home_menu);
654
+                    $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
655
+                    $home_menu = explode("\n", $home_menu);
656
+                }
657
+                $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
658
+                break;
659
+            case 'insert_tabs':
660
+                // This request is the preparation for the addition of an item in home_menu
661
+                $home_menu = '';
662
+                if (is_file($homep.$mtloggedin.'_'.$lang.$ext) && is_readable($homep.$mtloggedin.'_'.$lang.$ext)) {
663
+                    $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
664
+                } elseif (is_file($homep.$mtloggedin.$lang.$ext) && is_readable($homep.$mtloggedin.$lang.$ext)) {
665
+                    $home_menu = @file($homep.$mtloggedin.$lang.$ext);
666
+                } elseif (touch($homep.$mtloggedin.'_'.$lang.$ext)) {
667
+                    $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
668
+                } else {
669
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
670
+                }
671
+                if (empty($home_menu)) {
672
+                    $home_menu = array();
673
+                }
674
+                if (!empty($home_menu)) {
675
+                    $home_menu = implode("\n", $home_menu);
676
+                    $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
677
+                    $home_menu = explode("\n", $home_menu);
678
+                }
679
+                $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
680
+                break;
681
+            case 'edit_tabs':
682
+            case 'edit_link':
683
+                // This request is the preparation for the edition of the links array
684
+                $home_menu = '';
685
+                $menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
686
+                if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
687
+                    $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
688
+                } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
689
+                    $home_menu = @file($homep.$menuf.$lang.$ext);
690
+                } else {
691
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
692
+                }
693
+
694
+                if (empty($home_menu)) {
695
+                    if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
696
+                        $home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
697
+                    }
698
+                }
699
+
700
+                if (empty($home_menu)) {
701
+                    $home_menu = array();
702
+                }
703
+                if (!empty($home_menu)) {
704
+                    $home_menu = implode("\n", $home_menu);
705
+                    $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
706
+                    $home_menu = explode("\n", $home_menu);
707
+                }
708
+
709
+                $link_index = intval($_GET['link_index']);
710
+
711
+                $target_blank = false;
712
+                $link_name = '';
713
+                $link_url = '';
714
+
715
+                //$home_menu_new = array();
716
+                //
717
+                //Cleaning array
718
+                //foreach ($home_menu as $item) {
719
+                //	if(!empty($item)) {
720
+                //		$home_menu_new[] = $item;
721
+                //	}
722
+                //}
723
+                //$home_menu = $home_menu_new;
724
+
725
+                // Cleaning the array
726
+                $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
727
+
728
+                // For each line of the home_menu file
729
+                foreach ($home_menu as $key => $enreg) {
730
+
731
+                    // Check if the current item is the one we want to update
732
+                    if ($key == $link_index) {
733
+                        // This is the link we want to update
734
+                        // Check if the target should be "_blank"
735
+                        if (strstr($enreg, 'target="_blank"')) {
736
+                            $target_blank = true;
737
+                        }
738
+
739
+                        if (strstr($enreg, 'hide_menu')) {
740
+                            $add_in_tab = false;
741
+                        } else {
742
+                            $add_in_tab = true;
743
+                        }
744
+
745
+                        // Remove dangerous HTML tags from the link itself (this is an
746
+                        // additional measure in case a link previously contained
747
+                        // unsecure tags)
748
+                        $link_name = strip_tags($enreg);
749
+
750
+                        // Get the contents of "href" attribute in $link_url
751
+                        $enreg = explode('href="',$enreg);
752
+                        list($link_url) = explode('"', $enreg[sizeof($enreg) - 1]);
753
+
754
+                        // If the link contains the web root of this portal, then strip
755
+                        // it off and keep only the name of the file that needs edition
756
+                        if (strstr($link_url, '?include=')) {
757
+                            $link_url = explode('?include=', $link_url);
758
+
759
+                            $filename = $link_url[sizeof($link_url) - 1];
760
+
761
+                            if (!strstr($filename, '/') && strstr($filename, '.html')) {
762
+                                // Get oonly the contents of the link file
763
+                                $link_html = @file($homep.$filename);
764
+                                $link_html = implode('', $link_html);
765
+                                $link_url = '';
766
+                            } else {
767
+                                $filename = '';
768
+                            }
769
+                        }
770
+                        break;
771
+                    }
772
+                }
773
+                break;
774
+        }//end of second switch($action) (when POST['formSent'] was not set, yet)
775
+    }// end of "else" in if($_POST['formSent']) condition
776 776
 } else {
777
-	//if $action is empty, then prepare a list of the course categories to display (?)
778
-	$Categories = CourseCategory::getCategoriesToDisplayInHomePage();
777
+    //if $action is empty, then prepare a list of the course categories to display (?)
778
+    $Categories = CourseCategory::getCategoriesToDisplayInHomePage();
779 779
 }
780 780
 
781 781
 // Display section
@@ -783,25 +783,25 @@  discard block
 block discarded – undo
783 783
 Display::display_header($tool_name);
784 784
 
785 785
 switch ($action) {
786
-	case 'open_link':
787
-		if (!empty($link)) {
788
-			// $link is only set in case of action=open_link and is filtered
789
-			$open = @(string)file_get_contents($homep.$link);
790
-			$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
791
-			echo $open;
792
-		}
793
-		break;
794
-	case 'edit_notice':
795
-		// Display for edit_notice case
796
-		?>
786
+    case 'open_link':
787
+        if (!empty($link)) {
788
+            // $link is only set in case of action=open_link and is filtered
789
+            $open = @(string)file_get_contents($homep.$link);
790
+            $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
791
+            echo $open;
792
+        }
793
+        break;
794
+    case 'edit_notice':
795
+        // Display for edit_notice case
796
+        ?>
797 797
 		<form action="<?php echo $selfUrl; ?>?action=<?php echo $action; ?>" method="post" class="form-horizontal">
798 798
 			<legend><?php echo $tool_name; ?></legend>
799 799
 			<input type="hidden" name="formSent" value="1"/>
800 800
 			<?php
801
-			if (!empty($errorMsg)) {
802
-				Display::display_normal_message($errorMsg);
803
-			}
804
-			?>
801
+            if (!empty($errorMsg)) {
802
+                Display::display_normal_message($errorMsg);
803
+            }
804
+            ?>
805 805
                         <div class="row">
806 806
                             <div class="col-md-12">
807 807
                                 <p><?php echo get_lang('LetThoseFieldsEmptyToHideTheNotice'); ?></p>
@@ -839,170 +839,170 @@  discard block
 block discarded – undo
839 839
                         </div>
840 840
 		</form>
841 841
 		<?php
842
-		break;
843
-	case 'insert_tabs':
844
-	case 'edit_tabs':
845
-	case 'insert_link':
846
-	case 'edit_link':
847
-		$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs') ? $mtloggedin : $menuf;
848
-		if (!empty($errorMsg)) {
849
-			Display::display_normal_message($errorMsg);
850
-		}
851
-		$default = array();
852
-		$form = new FormValidator('configure_homepage_'.$action, 'post', $selfUrl.'?action='.$action, '', array('style' => 'margin: 0px;'));
853
-		$renderer =& $form->defaultRenderer();
854
-
855
-		$form->addElement('header', '', $tool_name);
856
-		$form->addElement('hidden', 'formSent', '1');
857
-		$form->addElement('hidden', 'link_index', ($action == 'edit_link' || $action == 'edit_tabs') ? $link_index : '0');
858
-		$form->addElement('hidden', 'filename', ($action == 'edit_link' || $action == 'edit_tabs') ? (!empty($filename) ? $filename : '') : '');
859
-
860
-		$form->addElement('text', 'link_name', get_lang('LinkName'), array('size' => '30', 'maxlength' => '50'));
861
-		if (!empty($link_name)) {
862
-			$default['link_name'] = $link_name;
863
-		}
864
-		$default['link_url'] = empty($link_url) ? 'http://' : api_htmlentities($link_url, ENT_QUOTES);
865
-		$linkUrlComment = ($action == 'insert_tabs') ? get_lang('Optional').'<br />'.get_lang('GlobalLinkUseDoubleColumnPrivateToShowPrivately') : '';
866
-		$form->addElement('text', 'link_url', array(get_lang('LinkURL'), $linkUrlComment), array('size' => '30', 'maxlength' => '100', 'style' => 'width: 350px;'));
867
-
868
-		$options = array('-1' => get_lang('FirstPlace'));
869
-
870
-		$selected = '';
871
-
872
-		if ($action == 'insert_link' || $action == 'insert_tabs') {
873
-			$add_in_tab = 1;
874
-			if (is_array($home_menu)){
875
-				foreach ($home_menu as $key => $enreg) {
876
-					if (strlen($enreg = trim(strip_tags($enreg))) > 0) {
877
-						$options[$key] = get_lang('After').' &quot;'.$enreg.'&quot;';
878
-						$formSentCheck = (!empty($_POST['formSent']) ? true : false);
879
-						$selected = $formSentCheck && $insert_where == $key ? $key : '';
880
-					}
881
-				}
882
-			}
883
-			$default['insert_link'] = $selected;
884
-			$form->addElement('select', 'insert_where', get_lang('InsertThisLink') , $options);
885
-		}
886
-
887
-		$target_blank_checkbox = $form->addElement('checkbox', 'target_blank', null, get_lang('OpenInNewWindow'), 1);
888
-
889
-		if ($action == 'insert_tabs' || $action == 'edit_tabs') {
890
-			$form->addElement('checkbox', 'add_in_tab', null, get_lang('AddInMenu'), 1);
891
-			$default['add_in_tab'] = $add_in_tab;
892
-		}
893
-
894
-		if (!empty($target_blank)) { $target_blank_checkbox->setChecked(true); }
895
-
896
-		if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://' || $link_url == 'https://')) {
897
-			$default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : $link_html;
898
-			$form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
842
+        break;
843
+    case 'insert_tabs':
844
+    case 'edit_tabs':
845
+    case 'insert_link':
846
+    case 'edit_link':
847
+        $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs') ? $mtloggedin : $menuf;
848
+        if (!empty($errorMsg)) {
849
+            Display::display_normal_message($errorMsg);
850
+        }
851
+        $default = array();
852
+        $form = new FormValidator('configure_homepage_'.$action, 'post', $selfUrl.'?action='.$action, '', array('style' => 'margin: 0px;'));
853
+        $renderer =& $form->defaultRenderer();
854
+
855
+        $form->addElement('header', '', $tool_name);
856
+        $form->addElement('hidden', 'formSent', '1');
857
+        $form->addElement('hidden', 'link_index', ($action == 'edit_link' || $action == 'edit_tabs') ? $link_index : '0');
858
+        $form->addElement('hidden', 'filename', ($action == 'edit_link' || $action == 'edit_tabs') ? (!empty($filename) ? $filename : '') : '');
859
+
860
+        $form->addElement('text', 'link_name', get_lang('LinkName'), array('size' => '30', 'maxlength' => '50'));
861
+        if (!empty($link_name)) {
862
+            $default['link_name'] = $link_name;
863
+        }
864
+        $default['link_url'] = empty($link_url) ? 'http://' : api_htmlentities($link_url, ENT_QUOTES);
865
+        $linkUrlComment = ($action == 'insert_tabs') ? get_lang('Optional').'<br />'.get_lang('GlobalLinkUseDoubleColumnPrivateToShowPrivately') : '';
866
+        $form->addElement('text', 'link_url', array(get_lang('LinkURL'), $linkUrlComment), array('size' => '30', 'maxlength' => '100', 'style' => 'width: 350px;'));
867
+
868
+        $options = array('-1' => get_lang('FirstPlace'));
869
+
870
+        $selected = '';
871
+
872
+        if ($action == 'insert_link' || $action == 'insert_tabs') {
873
+            $add_in_tab = 1;
874
+            if (is_array($home_menu)){
875
+                foreach ($home_menu as $key => $enreg) {
876
+                    if (strlen($enreg = trim(strip_tags($enreg))) > 0) {
877
+                        $options[$key] = get_lang('After').' &quot;'.$enreg.'&quot;';
878
+                        $formSentCheck = (!empty($_POST['formSent']) ? true : false);
879
+                        $selected = $formSentCheck && $insert_where == $key ? $key : '';
880
+                    }
881
+                }
882
+            }
883
+            $default['insert_link'] = $selected;
884
+            $form->addElement('select', 'insert_where', get_lang('InsertThisLink') , $options);
885
+        }
886
+
887
+        $target_blank_checkbox = $form->addElement('checkbox', 'target_blank', null, get_lang('OpenInNewWindow'), 1);
888
+
889
+        if ($action == 'insert_tabs' || $action == 'edit_tabs') {
890
+            $form->addElement('checkbox', 'add_in_tab', null, get_lang('AddInMenu'), 1);
891
+            $default['add_in_tab'] = $add_in_tab;
892
+        }
893
+
894
+        if (!empty($target_blank)) { $target_blank_checkbox->setChecked(true); }
895
+
896
+        if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://' || $link_url == 'https://')) {
897
+            $default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : $link_html;
898
+            $form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
899 899
             $form->addButtonSave(get_lang('Save'),'submit');
900 900
 
901
-		} else {
902
-			if (in_array($action, array('edit_tabs','insert_tabs'))) {
903
-				$default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : (!empty($link_html) ? $link_html : '');
904
-				$form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
905
-			}
906
-			$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
907
-			$form->addElement('html','<table id="table_langs" style="margin-left:159px;"><tr>');
908
-			$i = 0;
909
-			foreach ($_languages['name'] as $key => $value) {
910
-				$i++;
911
-				$lang_name = $_languages['folder'][$key];
912
-				$html_langs = '<td width="300">';
913
-				$html_langs .= '<label><input type="checkbox" id="lang" name="'.$lang_name.'" />&nbsp;'.$lang_name.'<label/>';
914
-				$html_langs .= '</td>';
915
-				if ($i % 5 == 0) {
916
-					$html_langs .= '</tr><tr>';
917
-				}
918
-				$form->addElement('html', $html_langs);
919
-			}
920
-			$form->addElement('html','</tr></table><br/>');
901
+        } else {
902
+            if (in_array($action, array('edit_tabs','insert_tabs'))) {
903
+                $default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : (!empty($link_html) ? $link_html : '');
904
+                $form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
905
+            }
906
+            $form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
907
+            $form->addElement('html','<table id="table_langs" style="margin-left:159px;"><tr>');
908
+            $i = 0;
909
+            foreach ($_languages['name'] as $key => $value) {
910
+                $i++;
911
+                $lang_name = $_languages['folder'][$key];
912
+                $html_langs = '<td width="300">';
913
+                $html_langs .= '<label><input type="checkbox" id="lang" name="'.$lang_name.'" />&nbsp;'.$lang_name.'<label/>';
914
+                $html_langs .= '</td>';
915
+                if ($i % 5 == 0) {
916
+                    $html_langs .= '</tr><tr>';
917
+                }
918
+                $form->addElement('html', $html_langs);
919
+            }
920
+            $form->addElement('html','</tr></table><br/>');
921 921
             $form->addButtonSave(get_lang('Save'),'submit');
922
-		}
923
-
924
-		$form->setDefaults($default);
925
-		$form->display();
926
-
927
-		break;
928
-	case 'edit_top':
929
-	case 'edit_news':
930
-		if ($action == 'edit_top') {
931
-			$name = $topf;
932
-			$open = $home_top;
933
-		} else {
934
-			$name = $newsf;
935
-			$open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
936
-		}
937
-		$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
938
-
939
-		if (!empty($errorMsg)) {
940
-			Display::display_normal_message($errorMsg); //main API
941
-		}
942
-
943
-		$default = array();
944
-		$form = new FormValidator(
945
-			'configure_homepage_'.$action,
946
-			'post',
947
-			$selfUrl.'?action='.$action,
948
-			'',
949
-			array('style' => 'margin: 0px;')
950
-		);
951
-		$renderer =& $form->defaultRenderer();
952
-		$renderer->setHeaderTemplate('');
953
-		$renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
954
-		$renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>');
955
-		$renderer->setRequiredNoteTemplate('');
956
-		$form->addElement('hidden', 'formSent', '1');
957
-
958
-		if ($action == 'edit_news') {
959
-			$_languages = api_get_languages();
960
-			$html = '<tr><td>'.get_lang('ChooseNewsLanguage').' : ';
961
-			$html .= '<select name="news_languages">';
962
-			$html .= '<option value="all">'.get_lang('ApplyAllLanguages').'</option>';
963
-			foreach ($_languages['name'] as $key => $value) {
964
-				$english_name = $_languages['folder'][$key];
965
-				if ($language == $english_name) {
966
-					$html .= '<option value="'.$english_name.'" selected="selected">'.$value.'</option>';
967
-				} else {
968
-					$html .= '<option value="'.$english_name.'">'.$value.'</option>';
969
-				}
970
-			}
971
-			$html .= '</select></td></tr>';
972
-			$form->addElement('html', $html);
973
-		}
974
-
975
-		$default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open);
976
-		$form->addHtmlEditor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
977
-		$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'),array('id' => 'all_langs'));
978
-		$form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
979
-
980
-		$currentLanguage = api_get_interface_language();
981
-		$i = 0;
982
-		foreach ($_languages['name'] as $key => $value) {
983
-			$lang_name = $_languages['folder'][$key];
984
-			$i++;
985
-
986
-			$checked = null;
987
-			if ($languageGet == $lang_name)  {
988
-				$checked = "checked";
989
-			}
990
-			$html_langs = '<td width="300">';
991
-			$html_langs .= '<label><input type="checkbox" '.$checked.' id="lang" name="'.$lang_name.'" />&nbsp;'.$value.'<label/>';
992
-			$html_langs .= '</td>';
993
-			if ($i % 5 == 0) {
994
-				$html_langs .= '</tr><tr>';
995
-			}
996
-			$form->addElement('html', $html_langs);
997
-		}
998
-		$form->addElement('html','</tr></table><br/>');
999
-		$form->addButtonSave(get_lang('Save'));
1000
-		$form->setDefaults($default);
1001
-		$form->display();
1002
-
1003
-		break;
1004
-	default: // When no action applies, default page to update campus homepage
1005
-		?>
922
+        }
923
+
924
+        $form->setDefaults($default);
925
+        $form->display();
926
+
927
+        break;
928
+    case 'edit_top':
929
+    case 'edit_news':
930
+        if ($action == 'edit_top') {
931
+            $name = $topf;
932
+            $open = $home_top;
933
+        } else {
934
+            $name = $newsf;
935
+            $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
936
+        }
937
+        $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
938
+
939
+        if (!empty($errorMsg)) {
940
+            Display::display_normal_message($errorMsg); //main API
941
+        }
942
+
943
+        $default = array();
944
+        $form = new FormValidator(
945
+            'configure_homepage_'.$action,
946
+            'post',
947
+            $selfUrl.'?action='.$action,
948
+            '',
949
+            array('style' => 'margin: 0px;')
950
+        );
951
+        $renderer =& $form->defaultRenderer();
952
+        $renderer->setHeaderTemplate('');
953
+        $renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
954
+        $renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>');
955
+        $renderer->setRequiredNoteTemplate('');
956
+        $form->addElement('hidden', 'formSent', '1');
957
+
958
+        if ($action == 'edit_news') {
959
+            $_languages = api_get_languages();
960
+            $html = '<tr><td>'.get_lang('ChooseNewsLanguage').' : ';
961
+            $html .= '<select name="news_languages">';
962
+            $html .= '<option value="all">'.get_lang('ApplyAllLanguages').'</option>';
963
+            foreach ($_languages['name'] as $key => $value) {
964
+                $english_name = $_languages['folder'][$key];
965
+                if ($language == $english_name) {
966
+                    $html .= '<option value="'.$english_name.'" selected="selected">'.$value.'</option>';
967
+                } else {
968
+                    $html .= '<option value="'.$english_name.'">'.$value.'</option>';
969
+                }
970
+            }
971
+            $html .= '</select></td></tr>';
972
+            $form->addElement('html', $html);
973
+        }
974
+
975
+        $default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open);
976
+        $form->addHtmlEditor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
977
+        $form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'),array('id' => 'all_langs'));
978
+        $form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
979
+
980
+        $currentLanguage = api_get_interface_language();
981
+        $i = 0;
982
+        foreach ($_languages['name'] as $key => $value) {
983
+            $lang_name = $_languages['folder'][$key];
984
+            $i++;
985
+
986
+            $checked = null;
987
+            if ($languageGet == $lang_name)  {
988
+                $checked = "checked";
989
+            }
990
+            $html_langs = '<td width="300">';
991
+            $html_langs .= '<label><input type="checkbox" '.$checked.' id="lang" name="'.$lang_name.'" />&nbsp;'.$value.'<label/>';
992
+            $html_langs .= '</td>';
993
+            if ($i % 5 == 0) {
994
+                $html_langs .= '</tr><tr>';
995
+            }
996
+            $form->addElement('html', $html_langs);
997
+        }
998
+        $form->addElement('html','</tr></table><br/>');
999
+        $form->addButtonSave(get_lang('Save'));
1000
+        $form->setDefaults($default);
1001
+        $form->display();
1002
+
1003
+        break;
1004
+    default: // When no action applies, default page to update campus homepage
1005
+        ?>
1006 1006
 
1007 1007
 <section id="page-home">
1008 1008
     <div class="row">
@@ -1158,53 +1158,53 @@  discard block
 block discarded – undo
1158 1158
             ?>
1159 1159
 
1160 1160
             <?php
1161
-		if (file_exists($homep.$newsf.'_'.$lang.$ext)) {
1161
+        if (file_exists($homep.$newsf.'_'.$lang.$ext)) {
1162 1162
                     $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
1163 1163
                     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
1164 1164
                     echo $open;
1165
-		} else {
1165
+        } else {
1166 1166
                     $open = @(string)file_get_contents($homep.$newsf.$ext);
1167 1167
                     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
1168 1168
                     echo $open;
1169
-		}
1169
+        }
1170 1170
             ?>
1171 1171
 
1172 1172
             <?php
1173 1173
                 // Add new page
1174
-		$home_menu = '';
1175
-		if (file_exists($homep.$mtloggedin.'_'.$lang.$ext)) {
1174
+        $home_menu = '';
1175
+        if (file_exists($homep.$mtloggedin.'_'.$lang.$ext)) {
1176 1176
                     $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
1177
-		} else {
1177
+        } else {
1178 1178
                     $home_menu = @file($homep.$mtloggedin.$ext);
1179
-		}
1180
-		if (empty($home_menu)) {
1179
+        }
1180
+        if (empty($home_menu)) {
1181 1181
                     if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
1182
-			$home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
1182
+            $home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
1183 1183
                     }
1184
-		}
1185
-		if (empty($home_menu)) {
1184
+        }
1185
+        if (empty($home_menu)) {
1186 1186
                     $home_menu = array();
1187
-		}
1188
-		if (!empty($home_menu)) {
1187
+        }
1188
+        if (!empty($home_menu)) {
1189 1189
                     $home_menu = implode("\n", $home_menu);
1190 1190
                     $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
1191 1191
                     $home_menu = explode("\n", $home_menu);
1192
-		}
1193
-		$link_list = '';
1194
-		$tab_counter = 0;
1192
+        }
1193
+        $link_list = '';
1194
+        $tab_counter = 0;
1195 1195
                     foreach ($home_menu as $enreg) {
1196 1196
                     $enreg = trim($enreg);
1197
-			if (!empty($enreg)) {
1197
+            if (!empty($enreg)) {
1198 1198
                             $edit_link   = ' <a href="'.$selfUrl.'?action=edit_tabs&amp;link_index='.$tab_counter.'" ><span>'.Display::return_icon('edit.png', get_lang('Edit')).'</span></a>';
1199 1199
                             $delete_link = ' <a href="'.$selfUrl.'?action=delete_tabs&amp;link_index='.$tab_counter.'"  onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;"><span>'.Display::return_icon('delete.png', get_lang('Delete')).'</span></a>';
1200 1200
                             $tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=', '</li>'),
1201 1201
                                 array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename($selfUrl).'?action=open_link&link=', $edit_link.$delete_link.'</li>'),
1202
-				$enreg);
1202
+                $enreg);
1203 1203
                             $tab_string = str_replace(array('<li>', '</li>','class="hide_menu"', 'hide_menu'), '', $tab_string);
1204
-				$link_list .= Display::tag('li', $tab_string, array('class' => 'list-group-item'));
1205
-				$tab_counter++;
1206
-			}
1207
-		}
1204
+                $link_list .= Display::tag('li', $tab_string, array('class' => 'list-group-item'));
1205
+                $tab_counter++;
1206
+            }
1207
+        }
1208 1208
             ?>
1209 1209
             <div class="actions">
1210 1210
 		<a href="<?php echo $selfUrl; ?>?action=insert_tabs">
@@ -1212,9 +1212,9 @@  discard block
 block discarded – undo
1212 1212
                 </a>
1213 1213
             </div>
1214 1214
             <?php
1215
-		echo '<ul id="list-hiperlink" class="list-group">';
1216
-		echo $link_list;
1217
-		echo '</ul>';
1215
+        echo '<ul id="list-hiperlink" class="list-group">';
1216
+        echo $link_list;
1217
+        echo '</ul>';
1218 1218
             ?>
1219 1219
         </div>
1220 1220
     </div>
Please login to merge, or discard this patch.
plugin/vchamilo/cli/clilib.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
  * @param string $prompt text prompt, should include possible options
192 192
  * @param string $default default value when enter pressed
193 193
  * @param array $options list of allowed options, empty means any text
194
- * @param bool $casesensitive true if options are case sensitive
194
+ * @param bool $casesensitiveoptions true if options are case sensitive
195 195
  * @return string entered text
196 196
  */
197 197
 function cli_input($prompt, $default='', array $options=null, $casesensitiveoptions=false) {
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 /**
289 289
  * Print or return section separator string
290 290
  * @param bool $return false means print, true return as string
291
- * @return mixed void or string
291
+ * @return string|null void or string
292 292
  */
293 293
 function cli_separator($return=false) {
294 294
     $separator = str_repeat('-', 79)."\n";
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
 * @param string $location 
6 6
 *
7 7
 */
8
-function vchamilo_parse_csv_nodelist($nodelistlocation = '', $plugin = null){
8
+function vchamilo_parse_csv_nodelist($nodelistlocation = '', $plugin = null) {
9 9
     global $_configuration;
10 10
     
11 11
     $vnodes = array();
12 12
     
13
-    if (empty($nodelistlocation)){
13
+    if (empty($nodelistlocation)) {
14 14
         $nodelistlocation = $_configuratioh['root_sys'].'/plugin/vchamilo/nodelist.csv';
15 15
     }
16 16
     
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     // Jump any empty or comment line
69 69
     $text = fgets($fp, 1024);
70 70
     $i = 0;
71
-    while(vchamilo_is_empty_line_or_format($text, $i == 0)){
71
+    while (vchamilo_is_empty_line_or_format($text, $i == 0)) {
72 72
         $text = fgets($fp, 1024);
73 73
         $i++;
74 74
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     // Check for valid field names
79 79
     foreach ($headers as $h) {
80 80
         $header[] = trim($h); 
81
-        $patternized = implode('|', $patterns) . "\\d+";
81
+        $patternized = implode('|', $patterns)."\\d+";
82 82
         $metapattern = implode('|', $metas);
83 83
         if (!(isset($required[$h]) ||
84 84
                 isset($optionalDefaults[$h]) ||
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     $linenum = 2; // Since header is line 1.
108 108
 
109 109
     // Take some from admin profile, other fixed by hardcoded defaults.
110
-    while (!feof ($fp)) {
110
+    while (!feof($fp)) {
111 111
 
112 112
         // Make a new base record.
113 113
         $vnode = new StdClass();
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
  * @param bool $casesensitive true if options are case sensitive
195 195
  * @return string entered text
196 196
  */
197
-function cli_input($prompt, $default='', array $options=null, $casesensitiveoptions=false) {
197
+function cli_input($prompt, $default = '', array $options = null, $casesensitiveoptions = false) {
198 198
     echo $prompt;
199 199
     echo "\n: ";
200 200
     $input = fread(STDIN, 2048);
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
  * @param array $shortmapping array describing mapping of short to long style options ex:('h'=>'help', 'v'=>'verbose')
221 221
  * @return array array of arrays, options, unrecognised as optionlongname=>value
222 222
  */
223
-function cli_get_params(array $longoptions, array $shortmapping=null) {
224
-    $shortmapping = (array)$shortmapping;
223
+function cli_get_params(array $longoptions, array $shortmapping = null) {
224
+    $shortmapping = (array) $shortmapping;
225 225
     $options      = array();
226 226
     $unrecognized = array();
227 227
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
  * @param bool $return false means print, true return as string
291 291
  * @return mixed void or string
292 292
  */
293
-function cli_separator($return=false) {
293
+function cli_separator($return = false) {
294 294
     $separator = str_repeat('-', 79)."\n";
295 295
     if ($return) {
296 296
         return $separator;
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
  * @param bool $return false means print, true return as string
306 306
  * @return mixed void or string
307 307
  */
308
-function cli_heading($string, $return=false) {
308
+function cli_heading($string, $return = false) {
309 309
     $string = "== $string ==\n";
310 310
     if ($return) {
311 311
         return $string;
Please login to merge, or discard this patch.
Braces   +10 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,7 +133,9 @@  discard block
 block discarded – undo
133 133
             $key = $headers[$f];
134 134
             if (preg_match('/\|/', $key)) {
135 135
                 list($plugin, $variable) = explode('|', str_replace('plugin_', '', $key));
136
-                if (empty($variable)) die("Key error in CSV : $key ");
136
+                if (empty($variable)) {
137
+                    die("Key error in CSV : $key ");
138
+                }
137 139
                 if (!isset($vnode->$plugin)) {
138 140
                     $vnode->$plugin = new StdClass();
139 141
                 }
@@ -170,8 +172,13 @@  discard block
 block discarded – undo
170 172
     static $first = true;
171 173
 
172 174
     // We may have a risk the BOM is present on first line
173
-    if ($resetfirst) $first = true;
174
-    if (!isset($textlib)) $textlib = new textlib(); // Singleton
175
+    if ($resetfirst) {
176
+        $first = true;
177
+    }
178
+    if (!isset($textlib)) {
179
+        $textlib = new textlib();
180
+    }
181
+    // Singleton
175 182
     $text = $textlib->trim_utf8_bom($text);
176 183
     $first = false;
177 184
 
Please login to merge, or discard this patch.