Completed
Push — master ( a9decc...a21b67 )
by Michael
02:51
created

agenda_fnc.php ➔ getNavBarTabs()   F

Complexity

Conditions 25
Paths > 20000

Size

Total Lines 140
Code Lines 91

Duplication

Lines 80
Ratio 57.14 %

Importance

Changes 0
Metric Value
cc 25
eloc 91
nc 354294
nop 1
dl 80
loc 140
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 21.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * classGenerator
4
 * walls_watermarks.
5
 *
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 *
13
 *
14
 *
15
 * L'utilisation de ce formulaire d'adminitration suppose
16
 * que la classe correspondante de la table a été générées avec classGenerator
17
 **/
18
define('_EXTCAL_FORMAT_AGENDA_KEYD', 'Y-m-d');
19
define('_EXTCAL_FORMAT_AGENDA_KEYT', 'H:i');
20
21
require_once __DIR__ . '/constantes.php';
22
require_once __DIR__ . '/../class/utility.php';
23
24
$moduleDirName = basename(dirname(__DIR__));
25
xoops_loadLanguage('main', $moduleDirName);
26
27
/*******************************************************************
28
 *
29
 ******************************************************************
30
 * @param        $ts
31
 * @param        $hStart
32
 * @param        $hEnd
33
 * @param int    $mPlage
34
 * @param int    $nbJours
35
 * @param        $formatDate
36
 * @param string $formatJour
37
 *
38
 * @return array
39
 */
40
41
function agenda_getCanevas($ts, $hStart, $hEnd, $mPlage = 15, $nbJours = 1, $formatDate, $formatJour = 'H:i')
42
{
43
    global $xoopsModuleConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
44
    $jour = date('d', $ts);
45
    $mois = date('m', $ts);
46
    $an   = date('Y', $ts);
47
    if (!isset($formatDate)) {
48
        $formatDate = $xoopsModuleConfig['event_date_week'];
49
    }
50
51
    //echo "agenda_getCanevas : {$jour}-{$mois}-{$an}-{$ts}<br>";
52
    //$tsStart = mktime($heure, $minute, $seconde, $mois, $jour, $an);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
53
    $jName = array(
54
        _MD_EXTCAL_DAY_SUNDAY,
55
        _MD_EXTCAL_DAY_MONDAY,
56
        _MD_EXTCAL_DAY_TUESDAY,
57
        _MD_EXTCAL_DAY_WEDNESDAY,
58
        _MD_EXTCAL_DAY_THURSDAY,
59
        _MD_EXTCAL_DAY_FRIDAY,
60
        _MD_EXTCAL_DAY_SATURDAY
61
    );
62
63
    $tj = array();
64
    for ($j = 0; $j < $nbJours; ++$j) {
65
        $tsj                = mktime(0, 0, 0, $mois, $jour + $j, $an);
66
        $kj                 = date(_EXTCAL_FORMAT_AGENDA_KEYD, $tsj);
67
        $tj[$kj]['caption'] = date($formatDate, $tsj);
68
69
        $tj[$kj]['events'] = array();
70
71
        $tj[$kj]['dayWeek'] = date('w', $tsj);
72
        $tj[$kj]['jour']    = $jName[$tj[$kj]['dayWeek']]; //date('l', $tsj);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
73
        if ($tj[$kj]['dayWeek'] == 0) {
74
            $tj[$kj]['bg'] = "background='" . XOOPS_URL . "/modules/extcal/assets/images/trame.png'";
75
        } else {
76
            $tj[$kj]['bg'] = '';
77
        }
78
    }
79
80
    //echo "{$hStart}-{$hEnd}-{$mPlage}<br>";
81
    $sPlage  = $mPlage * _EXTCAL_TS_MINUTE; // en secondes
82
    $tsStart = mktime($hStart, 0, 0, 1, 1, 2000);
83
    $tsEnd   = mktime($hEnd + 1, 0, 0, 1, 1, 2000);
84
85
    $ta = array();
86 View Code Duplication
    if ($hStart > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
87
        $tsCurent          = mktime(0, 0, 0, 1, 1, 2000);
88
        $k                 = date(_EXTCAL_FORMAT_AGENDA_KEYT, $tsCurent);
89
        $ta[$k]['caption'] = date($formatJour, $tsCurent);
90
        $ta[$k]['jours']   = $tj;
91
        $ta[$k]['class']   = 'head';
92
    }
93
94
    $tsCurent = $tsStart;
95
    $h        = 0;
96
    while ($tsCurent < $tsEnd) {
97
        $k = date(_EXTCAL_FORMAT_AGENDA_KEYT, $tsCurent);
98
        //echo "{$k}-$tsCurent-";
99
        $ta[$k]['caption'] = date($formatJour, $tsCurent);
100
        $ta[$k]['jours']   = $tj;
101
        $ta[$k]['class']   = ((($h % 2) == 0) ? 'odd' : 'even');
102
103
        //----------------------------------------------
104
        ++$h;
105
        $tsCurent += $sPlage;
106
    }
107
108 View Code Duplication
    if ($hEnd < 23) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
109
        $tsCurent          = mktime($hEnd + 1, 0, 0, 1, 1, 2000);
110
        $k                 = date(_EXTCAL_FORMAT_AGENDA_KEYT, $tsCurent);
111
        $ta[$k]['caption'] = date($formatJour, $tsCurent);
112
        $ta[$k]['jours']   = $tj;
113
        $ta[$k]['class']   = 'foot';
114
    }
115
116
    return $ta;
117
}
118
119
/*******************************************************************
120
 *
121
 ******************************************************************
122
 * @param        $eventsArray
123
 * @param        $ts
124
 * @param        $hStart
125
 * @param        $hEnd
126
 * @param int    $mPlage
127
 * @param int    $nbJours
128
 * @param string $formatDate
129
 * @param string $formatJour
130
 * @return array
131
 */
132
function agenda_getEvents(
133
    $eventsArray,
134
    $ts,
135
    $hStart,
136
    $hEnd,
137
    $mPlage = 15,
138
    $nbJours = 1,
139
    $formatDate = 'd-m-Y',
140
    $formatJour = 'H:i'
141
) {
142
143
    //    $tAgenda = agenda_getCanevas($ts, 8, 20, $mPlage, $nbJours);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
144
    $tAgenda = agenda_getCanevas($ts, $hStart, $hEnd - 1, $mPlage, $nbJours, $formatDate, $formatJour);
145
    $tk      = array_keys($tAgenda);
146
    $tk0     = $tk[0];
147
    $tk1     = $tk[count($tk) - 1];
148
149
    foreach ($eventsArray as $e) {
150
        $ts     = $e['event_start'];
151
        $kd     = date(_EXTCAL_FORMAT_AGENDA_KEYD, $ts);
152
        $hour   = date('H', $ts);
153
        $minute = date('i', $ts);
154
        $m      = (int)($minute / $mPlage) * $mPlage;
155
        //      echo "--->{$minute} / {$mPlage} = {$m}<br>";
156
        $sMinute = (($m < 10) ? '0' . $m : $m);
157
        //$kt = date(_EXTCAL_FORMAT_AGENDA_KEYT, $ts);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
158
        if ($hour < $hStart) {
159
            $kt = $tk0;
160
        } elseif ($hour >= ($hEnd + 1)) {
161
            $kt = $tk1;
162
        } else {
163
            $kt = $hour . ':' . $sMinute;
164
        }
165
166
        $tAgenda[$kt]['jours'][$kd]['events'][] = $e;
167
    }
168
169
    return $tAgenda;
170
}
171
172
/*******************************************************************
173
 *
174
 *******************************************************************/
175
function test_getAgenda()
176
{
177
    $tsD1 = mktime(0, 0, 0, 01, 25, 1954);
178
    $t    = getAgenda($tsD1, 8, 21, 30, 7);
179
180
    $t['10:30']['jours']['1954-01-25']['events'][1]['lib'] = 'Jean';
181
    $t['10:30']['jours']['1954-01-25']['events'][1]['dsc'] = 'bobo';
182
183
    $t['10:30']['jours']['1954-01-25']['events'][7]['lib'] = 'polo';
184
    $t['10:30']['jours']['1954-01-25']['events'][7]['dsc'] = 'haribo';
185
186
    $t['11:30']['jours']['1954-01-28']['events'][5]['lib'] = 'Jean';
187
    $t['11:30']['jours']['1954-01-28']['events'][5]['dsc'] = 'bibi';
188
189
    $exp = print_r($t, true);
190
    echo "<pre>{$exp}</pre>";
191
}
192
193
/*******************************************************************
194
 *
195
 ******************************************************************
196
 * @param $event1
197
 * @param $event2
198
 * @return int
199
 */
200
function orderEvents($event1, $event2)
0 ignored issues
show
Coding Style introduced by
orderEvents uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
201
{
202
    if ($event1['event_start'] == $event2['event_start']) {
203
        return 0;
204
    }
205
    if ($GLOBALS['xoopsModuleConfig']['sort_order'] === 'ASC') {
206
        $opt1 = -1;
207
        $opt2 = 1;
208
    } else {
209
        $opt1 = 1;
210
        $opt2 = -1;
211
    }
212
213
    return ($event1['event_start'] < $event2['event_start']) ? $opt1 : $opt2;
214
}
215
216
/*******************************************************************
217
 *
218
 ******************************************************************
219
 * @param        $year
220
 * @param int    $nbYearsBefore
221
 * @param int    $nbYearsAfter
222
 * @param bool   $addNone
223
 * @param string $name
224
 * @return \XoopsFormSelect
225
 */
226
function getListYears($year, $nbYearsBefore = 0, $nbYearsAfter = 5, $addNone = false, $name = 'year')
227
{
228
    // Year selectbox
229
    $select = new XoopsFormSelect('', $name, $year);
230
    if ($addNone) {
231
        $select->addOption(0, ' ');
232
    }
233
    if ($year == 0) {
234
        $year = date('Y');
235
    }
236
237
    for ($i = $year - $nbYearsBefore; $i < ($year + $nbYearsAfter); ++$i) {
238
        $select->addOption($i);
239
    }
240
241
    return $select;
242
}
243
244
/*******************************************************************
245
 *
246
 ******************************************************************
247
 * @param        $month
248
 * @param bool   $addNone
249
 * @param string $name
250
 * @return \XoopsFormSelect
251
 */
252
function getListMonths($month, $addNone = false, $name = 'month')
253
{
254
    // Month selectbox
255
    $extcalTimeHandler = ExtcalTime::getHandler();
256
257
    $select = new XoopsFormSelect('', $name, $month);
258
    if ($addNone) {
259
        $select->addOption(0, ' ');
260
    }
261
262
    for ($i = 1; $i < 13; ++$i) {
263
        $select->addOption($i, $extcalTimeHandler->getMonthName($i));
264
    }
265
266
    return $select;
267
}
268
269
/*******************************************************************
270
 *
271
 ******************************************************************
272
 * @param      $day
273
 * @param bool $addNone
274
 * @return \XoopsFormSelect
275
 */
276
function getListDays($day, $addNone = false)
277
{
278
    // Day selectbox
279
    $select = new XoopsFormSelect('', 'day', $day);
280
    if ($addNone) {
281
        $select->addOption(0, ' ');
282
    }
283
284
    for ($i = 1; $i < 32; ++$i) {
285
        $select->addOption($i);
286
    }
287
288
    return $select;
289
}
290
291
/*******************************************************************
292
 *
293
 ******************************************************************
294
 * @param $name
295
 * @return bool
0 ignored issues
show
Documentation introduced by
Should the return type not be false|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
296
 */
297
function ext_loadLanguage($name)
298
{
299
    global $xoopsConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
300
    $prefix = substr($name, 4);
301
    switch ($prefix) {
302
        case '_MI_':
303
            $f = '';
304
            break;
305
        case '_MD_':
306
            $f = '';
307
            break;
308
        default:
309
            return false;
310
    }
311
312
    $file   = XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/' . $f;
313
    $prefix = (defined($name) ? '_MI' : '_MD');
0 ignored issues
show
Unused Code introduced by
$prefix is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
314
    require_once $file;
315
}
316
317
/*******************************************************************
318
 *
319
 ******************************************************************
320
 * @param string $currentTab
321
 * @return array
322
 */
323
324
function getNavBarTabs($currentTab = '')
0 ignored issues
show
Coding Style introduced by
getNavBarTabs uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
325
{
326
    global $xoopsModuleConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
327
328
    ext_loadLanguage('_MD_');
329
330
    $visibleTabs = $xoopsModuleConfig['visible_tabs'];
331
    $tNavBar     = $ordre = array();
332
333
    $sep     = '=';
334
    $tabs    = str_replace("\n", $sep, $xoopsModuleConfig['weight_tabs']);
335
    $tabs    = str_replace("\r", '', $tabs);
336
    $tabs    = str_replace(' ', '', $tabs);
337
    $t       = explode($sep, $tabs);
338
    $tWeight = array_flip($t);
339
340
    //-----------------------------------------------------------------
341
    $view = _EXTCAL_NAV_CALMONTH;
342
    //   echo "{$view} - {$currentTab}<br>";
343
    //   echoArray($visibleTabs,true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
344 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
345
        $tNavBar[$view] = array(
346
            'href'    => _EXTCAL_FILE_CALMONTH,
347
            'name'    => _MD_EXTCAL_NAV_CALMONTH,
348
            'current' => ($view == $currentTab) ? 1 : 0,
349
            'weight'  => 110
350
        );
351
    }
352
353
    $view = _EXTCAL_NAV_CALWEEK;
354 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
355
        $tNavBar[$view] = array(
356
            'href'    => _EXTCAL_FILE_CALWEEK,
357
            'name'    => _MD_EXTCAL_NAV_CALWEEK,
358
            'current' => ($view == $currentTab) ? 1 : 0,
359
            'weight'  => 120
360
        );
361
    }
362
363
    $view = _EXTCAL_NAV_YEAR;
364 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
365
        $tNavBar[$view] = array(
366
            'href'    => _EXTCAL_FILE_YEAR,
367
            'name'    => _MD_EXTCAL_NAV_YEAR,
368
            'current' => ($view == $currentTab) ? 1 : 0,
369
            'weight'  => 130
370
        );
371
    }
372
373
    $view = _EXTCAL_NAV_MONTH;
374 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
375
        $tNavBar[$view] = array(
376
            'href'    => _EXTCAL_FILE_MONTH,
377
            'name'    => _MD_EXTCAL_NAV_MONTH,
378
            'current' => ($view == $currentTab) ? 1 : 0,
379
            'weight'  => 140
380
        );
381
    }
382
383
    $view = _EXTCAL_NAV_WEEK;
384 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
385
        $tNavBar[$view] = array(
386
            'href'    => _EXTCAL_FILE_WEEK,
387
            'name'    => _MD_EXTCAL_NAV_WEEK,
388
            'current' => ($view == $currentTab) ? 1 : 0,
389
            'weight'  => 150
390
        );
391
    }
392
393
    $view = _EXTCAL_NAV_DAY;
394 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
395
        $tNavBar[$view] = array(
396
            'href'    => _EXTCAL_FILE_DAY,
397
            'name'    => _MD_EXTCAL_NAV_DAY,
398
            'current' => ($view == $currentTab) ? 1 : 0,
399
            'weight'  => 160
400
        );
401
    }
402
403
    $view = _EXTCAL_NAV_AGENDA_WEEK;
404 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
405
        $tNavBar[$view] = array(
406
            'href'    => _EXTCAL_FILE_AGENDA_WEEK,
407
            'name'    => _MD_EXTCAL_NAV_AGENDA_WEEK,
408
            'current' => ($view == $currentTab) ? 1 : 0,
409
            'weight'  => 170
410
        );
411
    }
412
413
    $view = _EXTCAL_NAV_AGENDA_DAY;
414 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
415
        $tNavBar[$view] = array(
416
            'href'    => _EXTCAL_FILE_AGENDA_DAY,
417
            'name'    => _MD_EXTCAL_NAV_AGENDA_DAY,
418
            'current' => ($view == $currentTab) ? 1 : 0,
419
            'weight'  => 180
420
        );
421
    }
422
423
    $view = _EXTCAL_NAV_SEARCH;
424 View Code Duplication
    if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
425
        $tNavBar[$view] = array(
426
            'href'    => _EXTCAL_FILE_SEARCH,
427
            'name'    => _MD_EXTCAL_NAV_SEARCH,
428
            'current' => ($view == $currentTab) ? 1 : 0,
429
            'weight'  => 200
430
        );
431
    }
432
433
    $user = isset($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser'] : null;
434
    /** @var ExtcalCatHandler $catHandler */
435
    $catHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
436
    if ($catHandler->haveSubmitRight($user)) {
437
        $view = _EXTCAL_NAV_NEW_EVENT;
438 View Code Duplication
        if (in_array($view, $visibleTabs)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
439
            $tNavBar[$view] = array(
440
                'href'    => _EXTCAL_FILE_NEW_EVENT,
441
                'name'    => _MD_EXTCAL_NAV_NEW_EVENT,
442
                'current' => ($view == $currentTab) ? 1 : 0,
443
                'weight'  => 100
444
            );
445
        }
446
    }
447
    //----------------------------------------------------------------
448
    //    $ordre = array();
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
449
    //    while (list($k, $v) = each($tNavBar)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
450
    foreach ($tNavBar as $k => $v) {
451
        if (isset($tWeight[$k])) {
452
            $ordre[] = (int)$tWeight[$k]; //ordre defini dans les option du module
453
        } else {
454
            $ordre[] = $v['weight']; // ordre par defaut ddefini dans le tableau $tNavBar
455
        }
456
    }
457
458
    array_multisort($tNavBar, SORT_ASC, SORT_NUMERIC, $ordre, SORT_ASC, SORT_NUMERIC);
459
460
    //    ext_echoArray($tNavBar);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
461
    //    ext_echoArray($ordre);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
462
    return $tNavBar;
463
}
464
465
/*----------------------------------------------------------------------*/
466