Passed
Push — master ( 005d4f...8b5e26 )
by Michael
06:49
created

Animal::getNumOfFields()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
nc 4
nop 0
dl 0
loc 16
rs 9.9
c 1
b 0
f 0
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
use \XoopsModules\Pedigree;
13
14
/**
15
 * Class SystemMessage
16
 * @deprecated
17
 */
18
class SystemMessage
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
19
{
20
    /**
21
     * @param $message
22
     */
23
    public function __construct($message)
24
    {
25
        echo '<span style="color: #ff0000;"><h3>' . $message . '</h3></span>';
26
    }
27
}
28
29
/**
30
 * Class Animal
31
 * @deprecated
32
 */
33
class Animal
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
34
{
35
    /**
36
     * @param int $animalnumber * @internal param int $id animal ID
37
     */
38
    public function __construct($animalnumber = 0)
39
    {
40
        global $xoopsDB;
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...
41
        if (0 == $animalnumber) {
42
            $SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE id = '1'";
43
        } else {
44
            $SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE id = ' . $animalnumber;
45
        }
46
        $result = $GLOBALS['xoopsDB']->query($SQL);
47
        $row = $GLOBALS['xoopsDB']->fetchRow($result);
48
        $numfields = $GLOBALS['xoopsDB']->getFieldsNum($result);
49
        for ($i = 0; $i < $numfields; ++$i) {
50
            $key = mysqli_fetch_field_direct($result, $i)->name;
51
            $this->$key = $row[$i];
52
        }
53
    }
54
55
    /**
56
     * @return array
57
     */
58
    public function getFieldsIds()
59
    {
60
        global $xoopsDB;
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...
61
        $SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . ' ORDER BY `order`';
62
        $fields = [];
63
        $result = $GLOBALS['xoopsDB']->query($SQL);
64
        $count = 0;
65
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
66
            $fields[] = $row['id'];
67
            ++$count;
68
            $configValues[] = $row;
69
        }
70
        $this->configValues = isset($configValues) ? $configValues : '';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $configValues does not seem to be defined for all execution paths leading up to this point.
Loading history...
Bug Best Practice introduced by
The property configValues does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
71
72
        //print_r ($this->configValues); die();
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% 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
        return $fields;
74
    }
75
76
    /**
77
     * @return mixed
78
     */
79
    public function getConfig()
80
    {
81
        return $this->configValues;
82
    }
83
}
84
85
/**
86
 * Class Field
87
 */
88
class Field
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
89
{
90
    protected $id;
91
92
    /**
93
     * @param $fieldnumber
94
     * @param $config
95
     */
96
    public function __construct($fieldnumber, $config)
97
    {
98
        //find key where ID = $fieldnumber;
99
        for ($x = 0, $xMax = count($config); $x < $xMax; ++$x) {
100
            if ($config[$x]['id'] = $fieldnumber) {
101
                foreach ($config[$x] as $key => $values) {
102
                    $this->$key = $values;
103
                }
104
            }
105
        }
106
        $this->id = $fieldnumber;
107
    }
108
109
    /**
110
     * @return bool
111
     */
112
    public function isActive()
113
    {
114
        $active = $this->getSetting('isactive');
115
        return '1' == $active;
116
    }
117
118
    /**
119
     * @return bool
120
     */
121
    public function inAdvanced()
122
    {
123
        $active = $this->getSetting('viewinadvanced');
124
        // return ('1' == $active) ? true : false;
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% 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...
125
        return '1' == $active;
126
    }
127
128
    /**
129
     * @return bool
130
     */
131
    public function isLocked()
132
    {
133
        $active = $this->getSetting('locked');
134
        return '1' == $active;
135
    }
136
137
    /**
138
     * @return bool
139
     */
140
    public function hasSearch()
141
    {
142
        $active = $this->getSetting('hassearch');
143
        return '1' == $active;
144
    }
145
146
    /**
147
     * @return bool
148
     */
149
    public function addLitter()
150
    {
151
        $active = $this->getSetting('litter');
152
        return '1' == $active;
153
    }
154
155
    /**
156
     * @return bool
157
     */
158
    public function generalLitter()
159
    {
160
        $active = $this->getSetting('generallitter');
161
        return '1' == $active;
162
    }
163
164
    /**
165
     * @return bool
166
     */
167
    public function hasLookup()
168
    {
169
        $active = $this->getSetting('lookuptable');
170
        return '1' == $active;
171
    }
172
173
    /**
174
     * @return string
175
     */
176
    public function getSearchString()
177
    {
178
        return '&amp;o=naam&amp;p';
179
    }
180
181
    /**
182
     * @return bool
183
     */
184
    public function inPie()
185
    {
186
        $active = $this->getSetting('viewinpie');
187
        return '1' == $active;
188
    }
189
190
    /**
191
     * @return bool
192
     */
193
    public function inPedigree()
194
    {
195
        $active = $this->getSetting('viewinpedigree');
196
        return '1' == $active;
197
    }
198
199
    /**
200
     * @return bool
201
     */
202
    public function inList()
203
    {
204
        $active = $this->getSetting('viewinlist');
205
        return '1' == $active;
206
    }
207
208
    public function getId()
209
    {
210
        return $this->id;
211
    }
212
213
    /**
214
     * @param $setting
215
     *
216
     * @return mixed
217
     */
218
    public function getSetting($setting)
219
    {
220
        return $this->{$setting};
221
    }
222
223
    /**
224
     * @param $fieldnumber
225
     *
226
     * @return array
227
     */
228
    public function lookupField($fieldnumber)
229
    {
230
        $ret = [];
231
        global $xoopsDB;
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...
232
        $SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $fieldnumber) . " ORDER BY 'order'";
233
        $result = $GLOBALS['xoopsDB']->query($SQL);
234
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
235
            $ret[] = ['id' => $row['id'], 'value' => $row['value']];
236
        }
237
238
        //array_multisort($ret,SORT_ASC);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% 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...
239
        return $ret;
240
    }
241
242
    /**
243
     * @return XoopsFormLabel
244
     */
245
    public function viewField()
246
    {
247
        $view = new \XoopsFormLabel($this->fieldname, $this->value);
248
249
        return $view;
250
    }
251
252
    /**
253
     * @return string
254
     */
255
    public function showField()
256
    {
257
        return $this->fieldname . ' : ' . $this->value;
258
    }
259
260
    /**
261
     * @return mixed|string
262
     */
263
    public function showValue()
264
    {
265
        global $myts;
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...
266
267
        return $myts->displayTarea($this->value);
268
        //return $this->value;
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...
269
    }
270
271
    /**
272
     * @return string
273
     */
274
    public function searchField()
275
    {
276
        return '<input type="text" name="query" size="20">';
277
    }
278
}
279
280
/**
281
 * Class RadioButton
282
 * @deprecated
283
 */
284
class RadioButton extends Field
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
285
{
286
    /**
287
     * @param Pedigree\Field  $parentObject
288
     * @param Pedigree\Animal $animalObject
289
     */
290
    public function __construct($parentObject, $animalObject)
291
    {
292
        $this->fieldnumber = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
293
294
        $this->fieldname = $parentObject->fieldname;
0 ignored issues
show
Bug introduced by
The property fieldname does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
295
        $this->value = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
296
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Bug introduced by
The property defaultvalue does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
297
        $this->lookuptable = $parentObject->lookuptable;
0 ignored issues
show
Bug Best Practice introduced by
The property lookuptable does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Bug introduced by
The property lookuptable does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
298
        if ('0' == $this->lookuptable) {
299
            new SystemMessage('A lookuptable must be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

299
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A lookuptable must be specified for userfield' . $this->fieldnumber);
Loading history...
300
        }
301
    }
302
303
    /**
304
     * @return XoopsFormRadio
305
     */
306
    public function editField()
307
    {
308
        $radio = new \XoopsFormRadio('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value);
309
        $lookupcontents = $this->lookupField($this->fieldnumber);
310
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
311
            $radio->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br>'));
312
        }
313
314
        return $radio;
315
    }
316
317
    /**
318
     * @param string $name
319
     *
320
     * @return XoopsFormRadio
321
     */
322
    public function newField($name = '')
323
    {
324
        $radio = new \XoopsFormRadio('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue);
325
        $lookupcontents = $this->lookupField($this->fieldnumber);
326
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
327
            $radio->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br>'));
328
        }
329
330
        return $radio;
331
    }
332
333
    /**
334
     * @return XoopsFormLabel
335
     */
336
    public function viewField()
337
    {
338
        $choosenvalue = '';
339
        $lookupcontents = $this->lookupField($this->fieldnumber);
340
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
341
            if ($lookupcontents[$i]['id'] == $this->value) {
342
                $choosenvalue = $lookupcontents[$i]['value'];
343
            }
344
        }
345
        $view = new \XoopsFormLabel($this->fieldname, $choosenvalue);
346
347
        return $view;
348
    }
349
350
    /**
351
     * @return string
352
     */
353
    public function showField()
354
    {
355
        $choosenvalue = '';
356
        $lookupcontents = $this->lookupField($this->fieldnumber);
357
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
358
            if ($lookupcontents[$i]['id'] == $this->value) {
359
                $choosenvalue = $lookupcontents[$i]['value'];
360
            }
361
        }
362
363
        return $this->fieldname . ' : ' . $choosenvalue;
364
    }
365
366
    /**
367
     * @return mixed
368
     */
369
    public function showValue()
370
    {
371
        $choosenvalue = '';
372
        $lookupcontents = $this->lookupField($this->fieldnumber);
373
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
374
            if ($lookupcontents[$i]['id'] == $this->value) {
375
                $choosenvalue = $lookupcontents[$i]['value'];
376
            }
377
        }
378
379
        return $choosenvalue;
380
    }
381
382
    /**
383
     * @return string
384
     */
385
    public function searchField()
386
    {
387
        $select = '<select size="1" name="query" style="width: 140px;">';
388
        $lookupcontents = $this->lookupField($this->fieldnumber);
389
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
390
            $select .= '<option value="' . $lookupcontents[$i]['id'] . '">' . $lookupcontents[$i]['value'] . '</option>';
391
        }
392
        $select .= '</select>';
393
394
        return $select;
395
    }
396
}
397
398
/**
399
 * Class SelectBox
400
 * @deprecated
401
 */
402
class SelectBox extends Field
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
403
{
404
    /**
405
     * @param $parentObject
406
     * @param $animalObject
407
     */
408
    public function __construct($parentObject, $animalObject)
409
    {
410
        $this->fieldnumber = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
411
        $this->fieldname = $parentObject->fieldname;
0 ignored issues
show
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
412
        $this->value = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
413
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
414
        $this->lookuptable = $parentObject->lookuptable;
0 ignored issues
show
Bug Best Practice introduced by
The property lookuptable does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
415
        if ('0' == $this->lookuptable) {
416
            new SystemMessage('A lookuptable must be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

416
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A lookuptable must be specified for userfield' . $this->fieldnumber);
Loading history...
417
        }
418
    }
419
420
    /**
421
     * @return XoopsFormSelect
422
     */
423
    public function editField()
424
    {
425
        $select = new \XoopsFormSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value, $size = 1, $multiple = false);
426
        $lookupcontents = $this->lookupField($this->fieldnumber);
427
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
428
            $select->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br>'));
429
        }
430
431
        return $select;
432
    }
433
434
    /**
435
     * @param string $name
436
     *
437
     * @return XoopsFormSelect
438
     */
439
    public function newField($name = '')
440
    {
441
        $select = new \XoopsFormSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue, $size = 1, $multiple = false);
442
        $lookupcontents = $this->lookupField($this->fieldnumber);
443
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
444
            $select->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br>'));
445
        }
446
447
        return $select;
448
    }
449
450
    /**
451
     * @return XoopsFormLabel
452
     */
453
    public function viewField()
454
    {
455
        $choosenvalue = '';
456
        $lookupcontents = $this->lookupField($this->fieldnumber);
457
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
458
            if ($lookupcontents[$i]['id'] == $this->value) {
459
                $choosenvalue = $lookupcontents[$i]['value'];
460
            }
461
        }
462
        $view = new \XoopsFormLabel($this->fieldname, $choosenvalue);
463
464
        return $view;
465
    }
466
467
    /**
468
     * @return string
469
     */
470
    public function showField()
471
    {
472
        $choosenvalue = '';
473
        $lookupcontents = $this->lookupField($this->fieldnumber);
474
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
475
            if ($lookupcontents[$i]['id'] == $this->value) {
476
                $choosenvalue = $lookupcontents[$i]['value'];
477
            }
478
        }
479
480
        return $this->fieldname . ' : ' . $choosenvalue;
481
    }
482
483
    /**
484
     * @return mixed
485
     */
486
    public function showValue()
487
    {
488
        $choosenvalue = '';
489
        $lookupcontents = $this->lookupField($this->fieldnumber);
490
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
491
            if ($lookupcontents[$i]['id'] == $this->value) {
492
                $choosenvalue = $lookupcontents[$i]['value'];
493
            }
494
        }
495
496
        return $choosenvalue;
497
    }
498
499
    /**
500
     * @return string
501
     */
502
    public function searchField()
503
    {
504
        $select = '<select size="1" name="query" style="width: 140px;">';
505
        $lookupcontents = $this->lookupField($this->fieldnumber);
506
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
507
            $select .= '<option value="' . $lookupcontents[$i]['id'] . '">' . $lookupcontents[$i]['value'] . '</option>';
508
        }
509
        $select .= '</select>';
510
511
        return $select;
512
    }
513
}
514
515
/**
516
 * Class TextBox
517
 * @deprecated
518
 */
519
class TextBox extends Field
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
520
{
521
    /**
522
     * @param $parentObject
523
     * @param $animalObject
524
     */
525
    public function __construct($parentObject, $animalObject)
526
    {
527
        $this->fieldnumber = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
528
        $this->fieldname = $parentObject->fieldname;
0 ignored issues
show
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
529
        $this->value = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
530
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
531
        $this->lookuptable = $parentObject->lookuptable;
0 ignored issues
show
Bug Best Practice introduced by
The property lookuptable does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
532
        if ('1' == $this->lookuptable) {
533
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

533
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
534
        }
535
        if ('1' == $parentObject->viewinadvanced) {
536
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

536
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
537
        }
538
        if ('1' == $parentObject->viewinpie) {
539
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

539
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
540
        }
541
    }
542
543
    /**
544
     * @return XoopsFormText
545
     */
546
    public function editField()
547
    {
548
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 50, $maxsize = 50, $value = $this->value);
549
550
        return $textbox;
551
    }
552
553
    /**
554
     * @param string $name
555
     *
556
     * @return XoopsFormText
557
     */
558
    public function newField($name = '')
559
    {
560
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 50, $maxsize = 50, $value = $this->defaultvalue);
561
562
        return $textbox;
563
    }
564
565
    /**
566
     * @return string
567
     */
568
    public function getSearchString()
569
    {
570
        return '&amp;o=naam&amp;l=1';
571
    }
572
}
573
574
/**
575
 * Class TextArea
576
 * @deprecated
577
 */
578
class TextArea extends Field
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
579
{
580
    /**
581
     * @param $parentObject
582
     * @param $animalObject
583
     */
584
    public function __construct($parentObject, $animalObject)
585
    {
586
        $this->fieldnumber = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
587
        $this->fieldname = $parentObject->fieldname;
0 ignored issues
show
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
588
        $this->value = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
589
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
590
        if ('1' == $parentObject->lookuptable) {
591
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

591
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
592
        }
593
        if ('1' == $parentObject->viewinadvanced) {
594
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

594
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
595
        }
596
        if ('1' == $parentObject->viewinpie) {
597
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

597
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
598
        }
599
    }
600
601
    /**
602
     * @return XoopsFormTextArea
603
     */
604
    public function editField()
605
    {
606
        $textarea = new \XoopsFormTextArea('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value, $rows = 5, $cols = 50);
607
608
        return $textarea;
609
    }
610
611
    /**
612
     * @param string $name
613
     *
614
     * @return XoopsFormTextArea
615
     */
616
    public function newField($name = '')
617
    {
618
        $textarea = new \XoopsFormTextArea('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue, $rows = 5, $cols = 50);
619
620
        return $textarea;
621
    }
622
623
    /**
624
     * @return string
625
     */
626
    public function getSearchString()
627
    {
628
        return '&amp;o=naam&amp;l=1';
629
    }
630
}
631
632
/**
633
 * Class DataSelect
634
 * @deprecated
635
 */
636
class DataSelect extends Field
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
637
{
638
    /**
639
     * @param $parentObject
640
     * @param $animalObject
641
     */
642
    public function __construct($parentObject, $animalObject)
643
    {
644
        $this->fieldnumber = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
645
        $this->fieldname = $parentObject->fieldname;
0 ignored issues
show
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
646
        $this->value = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
647
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
648
        if ('1' == $parentObject->lookuptable) {
649
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

649
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
650
        }
651
        if ('1' == $parentObject->viewinadvanced) {
652
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

652
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
653
        }
654
        if ('1' == $parentObject->viewinpie) {
655
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

655
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
656
        }
657
    }
658
659
    /**
660
     * @return XoopsFormTextDateSelect
661
     */
662
    public function editField()
663
    {
664
        //$textarea = new \XoopsFormFile("<b>".$this->fieldname."</b>", $this->fieldname, $maxfilesize = 2000);
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% 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...
665
        $textarea = new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 15, $this->value);
666
667
        return $textarea;
668
    }
669
670
    /**
671
     * @param string $name
672
     *
673
     * @return XoopsFormTextDateSelect
674
     */
675
    public function newField($name = '')
676
    {
677
        $textarea = new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 15, $this->defaultvalue);
678
679
        return $textarea;
680
    }
681
682
    /**
683
     * @return string
684
     */
685
    public function getSearchString()
686
    {
687
        return '&amp;o=naam&amp;l=1';
688
    }
689
}
690
691
/**
692
 * Class UrlField
693
 * @deprecated
694
 */
695
class UrlField extends Field
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
696
{
697
    /**
698
     * @param $parentObject
699
     * @param $animalObject
700
     */
701
    public function __construct($parentObject, $animalObject)
702
    {
703
        $this->fieldnumber = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
704
        $this->fieldname = $parentObject->fieldname;
0 ignored issues
show
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
705
        $this->value = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
706
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
707
        $this->lookuptable = $parentObject->lookuptable;
0 ignored issues
show
Bug Best Practice introduced by
The property lookuptable does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
708
        if ('1' == $this->lookuptable) {
709
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

709
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
710
        }
711
        if ('1' == $parentObject->viewinadvanced) {
712
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

712
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
713
        }
714
        if ('1' == $parentObject->viewinpie) {
715
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

715
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
716
        }
717
    }
718
719
    /**
720
     * @return XoopsFormText
721
     */
722
    public function editField()
723
    {
724
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 50, $maxsize = 255, $value = $this->value);
725
726
        return $textbox;
727
    }
728
729
    /**
730
     * @param string $name
731
     *
732
     * @return XoopsFormText
733
     */
734
    public function newField($name = '')
735
    {
736
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 50, $maxsize = 255, $value = $this->defaultvalue);
737
738
        return $textbox;
739
    }
740
741
    /**
742
     * @return XoopsFormLabel
743
     */
744
    public function viewField()
745
    {
746
        $view = new \XoopsFormLabel($this->fieldname, '<a href="' . $this->value . '" target=\"_new\">' . $this->value . '</a>');
747
748
        return $view;
749
    }
750
751
    /**
752
     * @return string
753
     */
754
    public function showField()
755
    {
756
        return $this->fieldname . ' : <a href="' . $this->value . '" target="_new">' . $this->value . '</a>';
757
    }
758
759
    /**
760
     * @return string
761
     */
762
    public function showValue()
763
    {
764
        return '<a href="' . $this->value . '" target="_new">' . $this->value . '</a>';
765
    }
766
767
    /**
768
     * @return string
769
     */
770
    public function getSearchString()
771
    {
772
        return '&amp;o=naam&amp;l=1';
773
    }
774
}
775
776
/**
777
 * Class Picture
778
 * @deprecated
779
 */
780
class Picture extends Field
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
781
{
782
    /**
783
     * @param $parentObject
784
     * @param $animalObject
785
     */
786
    public function __construct($parentObject, $animalObject)
787
    {
788
        $this->fieldnumber = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
789
        $this->fieldname = $parentObject->fieldname;
0 ignored issues
show
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
790
        $this->value = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
791
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
792
        $this->lookuptable = $parentObject->lookuptable;
0 ignored issues
show
Bug Best Practice introduced by
The property lookuptable does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
793
        if ('1' == $this->lookuptable) {
794
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

794
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
795
        }
796
        if ('1' == $parentObject->viewinadvanced) {
797
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

797
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
798
        }
799
        if ('1' == $parentObject->viewinpie) {
800
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

800
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
801
        }
802
        if ('1' == $parentObject->viewinlist) {
803
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be included in listview');
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

803
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be included in listview');
Loading history...
804
        }
805
        if ('1' == $parentObject->hassearch) {
806
            new SystemMessage('Search cannot be defined for userfield' . $this->fieldnumber);
0 ignored issues
show
Deprecated Code introduced by
The class SystemMessage has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

806
            /** @scrutinizer ignore-deprecated */ new SystemMessage('Search cannot be defined for userfield' . $this->fieldnumber);
Loading history...
807
        }
808
    }
809
810
    /**
811
     * @return XoopsFormFile
812
     */
813
    public function editField()
814
    {
815
        $pictureField = new \XoopsFormFile($this->fieldname, 'user' . $this->fieldnumber, 1024000);
816
        $pictureField->setExtra("size ='50'");
817
818
        return $pictureField;
819
    }
820
821
    /**
822
     * @param string $name
823
     *
824
     * @return XoopsFormFile
825
     */
826
    public function newField($name = '')
827
    {
828
        $pictureField = new \XoopsFormFile($this->fieldname, $name . 'user' . $this->fieldnumber, 1024000);
829
        $pictureField->setExtra("size ='50'");
830
831
        return $pictureField;
832
    }
833
834
    /**
835
     * @return XoopsFormLabel
836
     */
837
    public function viewField()
838
    {
839
        $view = new \XoopsFormLabel($this->fieldname, '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">');
0 ignored issues
show
Bug introduced by
The constant PEDIGREE_UPLOAD_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
840
841
        return $view;
842
    }
843
844
    /**
845
     * @return string
846
     */
847
    public function showField()
848
    {
849
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_150.jpeg">';
0 ignored issues
show
Bug introduced by
The constant PEDIGREE_UPLOAD_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
850
    }
851
852
    /**
853
     * @return string
854
     */
855
    public function showValue()
856
    {
857
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">';
0 ignored issues
show
Bug introduced by
The constant PEDIGREE_UPLOAD_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
858
    }
859
}
860
861
/**
862
 * Class SISContext
863
 * @deprecated
864
 */
865
class SISContext
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
866
{
867
    private $contexts;
868
    private $depth;
869
870
    /**
871
     * SISContext constructor.
872
     */
873
    public function __construct()
874
    {
875
        $this->contexts = [];
876
        $this->depth = 0;
877
    }
878
879
    /**
880
     * @param $url
881
     * @param $name
882
     */
883
    public function myGoto($url, $name)
884
    {
885
        $keys = array_keys($this->contexts);
886
        for ($i = 0; $i < $this->depth; ++$i) {
887
            if ($keys[$i] == $name) {
888
                $this->contexts[$name] = $url; // the url might be slightly different
889
                $this->depth = $i + 1;
890
891
                for ($x = count($this->contexts); $x > $i + 1; $x--) {
892
                    array_pop($this->contexts);
893
                }
894
895
                return;
896
            }
897
        }
898
899
        $this->contexts[$name] = $url;
900
        $this->depth++;
901
    }
902
903
    /**
904
     * @return array
905
     */
906
    public function getAllContexts()
907
    {
908
        return $this->contexts;
909
    }
910
911
    /**
912
     * @return array
913
     */
914
    public function getAllContextNames()
915
    {
916
        return array_keys($this->contexts);
917
    }
918
}
919