Passed
Branch master (465698)
by Michael
05:38
created

Field   A

Complexity

Total Complexity 33

Size/Duplication

Total Lines 224
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 224
rs 9.3999
c 0
b 0
f 0
wmc 33

19 Methods

Rating   Name   Duplication   Size   Complexity  
A inPie() 0 8 2
A inPedigree() 0 8 2
A lookupField() 0 11 2
A getSearchString() 0 3 1
A __construct() 0 12 4
A isLocked() 0 8 2
A hasLookup() 0 8 2
A inAdvanced() 0 5 2
A addLitter() 0 8 2
A getSetting() 0 3 1
A showField() 0 3 1
A searchField() 0 3 1
A hasSearch() 0 8 2
A isActive() 0 8 2
A inList() 0 8 2
A showValue() 0 5 1
A generalLitter() 0 8 2
A viewField() 0 5 1
A getId() 0 3 1
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
/**
13
 * Class SystemMessage
14
 * @deprecated
15
 */
16
class SystemMessage
17
{
18
    /**
19
     * @param $message
20
     */
21
    public function __construct($message)
22
    {
23
        echo '<span style="color: red;"><h3>' . $message . '</h3></span>';
24
    }
25
}
26
27
/**
28
 * Class Animal
29
 */
30
class Animal
31
{
32
    /**
33
     * @deprecated
34
     * @param int $animalnumber * @internal param int $id animal ID
35
     */
36
    public function __construct($animalnumber = 0)
37
    {
38
        global $xoopsDB;
39
        if ($animalnumber == 0) {
40
            $SQL = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE ID = '1'";
41
        } else {
42
            $SQL = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE ID = ' . $animalnumber;
43
        }
44
        $result    = $GLOBALS['xoopsDB']->query($SQL);
45
        $row       = $GLOBALS['xoopsDB']->fetchRow($result);
46
        $numfields = $GLOBALS['xoopsDB']->getFieldsNum($result);
47
        for ($i = 0; $i < $numfields; ++$i) {
48
            $key        = mysqli_fetch_field_direct($result, $i)->name;
49
            $this->$key = $row[$i];
50
        }
51
    }
52
53
    /**
54
     * @return array
55
     */
56
    public function getNumOfFields()
57
    {
58
        global $xoopsDB;
59
        $SQL    = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . ' ORDER BY `order`';
60
        $fields = array();
61
        $result = $GLOBALS['xoopsDB']->query($SQL);
62
        $count  = 0;
63
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
64
            $fields[] = $row['Id'];
65
            ++$count;
66
            $configValues[] = $row;
67
        }
68
        $this->configValues = isset($configValues) ? $configValues : '';
0 ignored issues
show
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...
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...
69
        //print_r ($this->configValues); die();
70
        return $fields;
71
    }
72
73
    /**
74
     * @return mixed
75
     */
76
    public function getConfig()
77
    {
78
        return $this->configValues;
79
    }
80
}
81
82
/**
83
 * Class Field
84
 */
85
class Field
86
{
87
    protected $id;
88
    /**
89
     * @param $fieldnumber
90
     * @param $config
91
     */
92
    public function __construct($fieldnumber, $config)
93
    {
94
        //find key where ID = $fieldnumber;
95
        $configCount = count($config);
96
        for ($x = 0; $x < $configCount; ++$x) {
97
            if ($config[$x]['Id'] = $fieldnumber) {
98
                foreach ($config[$x] as $key => $values) {
99
                    $this->$key = $values;
100
                }
101
            }
102
        }
103
        $this->id = $fieldnumber;
104
    }
105
106
    /**
107
     * @return bool
108
     */
109
    public function isActive()
110
    {
111
        $active = $this->getSetting('isActive');
112
        if ($active == '1') {
113
            return true;
114
        }
115
116
        return false;
117
    }
118
119
    /**
120
     * @return bool
121
     */
122
    public function inAdvanced()
123
    {
124
        $active = $this->getSetting('ViewInAdvanced');
125
126
        return ('1' == $active) ? true : false;
127
    }
128
129
    /**
130
     * @return bool
131
     */
132
    public function isLocked()
133
    {
134
        $active = $this->getSetting('locked');
135
        if ($active == '1') {
136
            return true;
137
        }
138
139
        return false;
140
    }
141
142
    /**
143
     * @return bool
144
     */
145
    public function hasSearch()
146
    {
147
        $active = $this->getSetting('HasSearch');
148
        if ($active == '1') {
149
            return true;
150
        }
151
152
        return false;
153
    }
154
155
    /**
156
     * @return bool
157
     */
158
    public function addLitter()
159
    {
160
        $active = $this->getSetting('Litter');
161
        if ($active == '1') {
162
            return true;
163
        }
164
165
        return false;
166
    }
167
168
    /**
169
     * @return bool
170
     */
171
    public function generalLitter()
172
    {
173
        $active = $this->getSetting('generalLitter');
174
        if ($active == '1') {
175
            return true;
176
        }
177
178
        return false;
179
    }
180
181
    /**
182
     * @return bool
183
     */
184
    public function hasLookup()
185
    {
186
        $active = $this->getSetting('LookupTable');
187
        if ($active == '1') {
188
            return true;
189
        }
190
191
        return false;
192
    }
193
194
    /**
195
     * @return string
196
     */
197
    public function getSearchString()
198
    {
199
        return '&amp;o=naam&amp;p';
200
    }
201
202
    /**
203
     * @return bool
204
     */
205
    public function inPie()
206
    {
207
        $active = $this->getSetting('ViewInPie');
208
        if ($active == '1') {
209
            return true;
210
        }
211
212
        return false;
213
    }
214
215
    /**
216
     * @return bool
217
     */
218
    public function inPedigree()
219
    {
220
        $active = $this->getSetting('ViewInPedigree');
221
        if ($active == '1') {
222
            return true;
223
        }
224
225
        return false;
226
    }
227
228
    /**
229
     * @return bool
230
     */
231
    public function inList()
232
    {
233
        $active = $this->getSetting('ViewInList');
234
        if ($active == '1') {
235
            return true;
236
        }
237
238
        return false;
239
    }
240
241
    public function getId()
242
    {
243
        return $this->id;
244
    }
245
246
    /**
247
     * @param $setting
248
     *
249
     * @return mixed
250
     */
251
    public function getSetting($setting)
252
    {
253
        return $this->{$setting};
254
    }
255
256
    /**
257
     * @param $fieldnumber
258
     *
259
     * @return array
260
     */
261
    public function lookupField($fieldnumber)
262
    {
263
        $ret = array();
264
        global $xoopsDB;
265
        $SQL    = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $fieldnumber) . " ORDER BY 'order'";
266
        $result = $GLOBALS['xoopsDB']->query($SQL);
267
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
268
            $ret[] = array('id' => $row['Id'], 'value' => $row['value']);
269
        }
270
        //array_multisort($ret,SORT_ASC);
271
        return $ret;
272
    }
273
274
    /**
275
     * @return XoopsFormLabel
276
     */
277
    public function viewField()
278
    {
279
        $view = new XoopsFormLabel($this->fieldname, $this->value);
280
281
        return $view;
282
    }
283
284
    /**
285
     * @return string
286
     */
287
    public function showField()
288
    {
289
        return $this->fieldname . ' : ' . $this->value;
290
    }
291
292
    /**
293
     * @return mixed|string
294
     */
295
    public function showValue()
296
    {
297
        global $myts;
298
299
        return $myts->displayTarea($this->value);
300
        //return $this->value;
301
    }
302
303
    /**
304
     * @return string
305
     */
306
    public function searchField()
307
    {
308
        return '<input type="text" name="query" size="20">';
309
    }
310
}
311
312
/**
313
 * Class RadioButton
314
 */
315
class RadioButton extends Field
316
{
317
    /**
318
     * @param $parentObject
319
     * @param $animalObject
320
     */
321
    public function __construct($parentObject, $animalObject)
322
    {
323
        $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...
324
325
        $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...
326
        $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...
327
        $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...
328
        $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...
329
        if ($this->lookuptable == '0') {
330
            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

330
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A lookuptable must be specified for userfield' . $this->fieldnumber);
Loading history...
331
        }
332
    }
333
334
    /**
335
     * @return XoopsFormRadio
336
     */
337
    public function editField()
338
    {
339
        $radio          = new XoopsFormRadio('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value);
340
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

340
        /** @scrutinizer ignore-call */ 
341
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
341
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
342
            $radio->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br />'));
343
        }
344
345
        return $radio;
346
    }
347
348
    /**
349
     * @param string $name
350
     *
351
     * @return XoopsFormRadio
352
     */
353
    public function newField($name = '')
354
    {
355
        $radio          = new XoopsFormRadio('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue);
356
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

356
        /** @scrutinizer ignore-call */ 
357
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
357
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
358
            $radio->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br />'));
359
        }
360
361
        return $radio;
362
    }
363
364
    /**
365
     * @return XoopsFormLabel
366
     */
367
    public function viewField()
368
    {
369
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

369
        /** @scrutinizer ignore-call */ 
370
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
370
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
371
            if ($lookupcontents[$i]['id'] == $this->value) {
372
                $choosenvalue = $lookupcontents[$i]['value'];
373
            }
374
        }
375
        $view = new XoopsFormLabel($this->fieldname, $choosenvalue);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $choosenvalue does not seem to be defined for all execution paths leading up to this point.
Loading history...
376
377
        return $view;
378
    }
379
380
    /**
381
     * @return string
382
     */
383
    public function showField()
384
    {
385
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

385
        /** @scrutinizer ignore-call */ 
386
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
386
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
387
            if ($lookupcontents[$i]['id'] == $this->value) {
388
                $choosenvalue = $lookupcontents[$i]['value'];
389
            }
390
        }
391
392
        return $this->fieldname . ' : ' . $choosenvalue;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $choosenvalue does not seem to be defined for all execution paths leading up to this point.
Loading history...
393
    }
394
395
    /**
396
     * @return mixed
397
     */
398
    public function showValue()
399
    {
400
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

400
        /** @scrutinizer ignore-call */ 
401
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
401
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
402
            if ($lookupcontents[$i]['id'] == $this->value) {
403
                $choosenvalue = $lookupcontents[$i]['value'];
404
            }
405
        }
406
407
        return $choosenvalue;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $choosenvalue does not seem to be defined for all execution paths leading up to this point.
Loading history...
408
    }
409
410
    /**
411
     * @return string
412
     */
413
    public function searchField()
414
    {
415
        $select         = '<select size="1" name="query" style="width: 140px;">';
416
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

416
        /** @scrutinizer ignore-call */ 
417
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
417
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
418
            $select .= '<option value="' . $lookupcontents[$i]['id'] . '">' . $lookupcontents[$i]['value'] . '</option>';
419
        }
420
        $select .= '</select>';
421
422
        return $select;
423
    }
424
}
425
426
/**
427
 * Class SelectBox
428
 */
429
class SelectBox extends Field
430
{
431
    /**
432
     * @param $parentObject
433
     * @param $animalObject
434
     */
435
    public function __construct($parentObject, $animalObject)
436
    {
437
        $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...
438
        $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...
439
        $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...
440
        $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...
441
        $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...
442
        if ($this->lookuptable == '0') {
443
            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

443
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A lookuptable must be specified for userfield' . $this->fieldnumber);
Loading history...
444
        }
445
    }
446
447
    /**
448
     * @return XoopsFormSelect
449
     */
450
    public function editField()
451
    {
452
        $select         = new XoopsFormSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value, $size = 1, $multiple = false);
453
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

453
        /** @scrutinizer ignore-call */ 
454
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
454
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
455
            $select->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br />'));
456
        }
457
458
        return $select;
459
    }
460
461
    /**
462
     * @param string $name
463
     *
464
     * @return XoopsFormSelect
465
     */
466
    public function newField($name = '')
467
    {
468
        $select         = new XoopsFormSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue, $size = 1, $multiple = false);
469
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

469
        /** @scrutinizer ignore-call */ 
470
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
470
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
471
            $select->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br />'));
472
        }
473
474
        return $select;
475
    }
476
477
    /**
478
     * @return XoopsFormLabel
479
     */
480
    public function viewField()
481
    {
482
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

482
        /** @scrutinizer ignore-call */ 
483
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
483
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
484
            if ($lookupcontents[$i]['id'] == $this->value) {
485
                $choosenvalue = $lookupcontents[$i]['value'];
486
            }
487
        }
488
        $view = new XoopsFormLabel($this->fieldname, $choosenvalue);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $choosenvalue does not seem to be defined for all execution paths leading up to this point.
Loading history...
489
490
        return $view;
491
    }
492
493
    /**
494
     * @return string
495
     */
496
    public function showField()
497
    {
498
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

498
        /** @scrutinizer ignore-call */ 
499
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
499
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
500
            if ($lookupcontents[$i]['id'] == $this->value) {
501
                $choosenvalue = $lookupcontents[$i]['value'];
502
            }
503
        }
504
505
        return $this->fieldname . ' : ' . $choosenvalue;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $choosenvalue does not seem to be defined for all execution paths leading up to this point.
Loading history...
506
    }
507
508
    /**
509
     * @return mixed
510
     */
511
    public function showValue()
512
    {
513
        $choosenvalue   = '';
514
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

514
        /** @scrutinizer ignore-call */ 
515
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
515
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
516
            if ($lookupcontents[$i]['id'] == $this->value) {
517
                $choosenvalue = $lookupcontents[$i]['value'];
518
            }
519
        }
520
521
        return $choosenvalue;
522
    }
523
524
    /**
525
     * @return string
526
     */
527
    public function searchField()
528
    {
529
        $select         = '<select size="1" name="query" style="width: 140px;">';
530
        $lookupcontents = Field::lookupField($this->fieldnumber);
0 ignored issues
show
Bug Best Practice introduced by
The method Field::lookupField() is not static, but was called statically. ( Ignorable by Annotation )

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

530
        /** @scrutinizer ignore-call */ 
531
        $lookupcontents = Field::lookupField($this->fieldnumber);
Loading history...
531
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
532
            $select .= '<option value="' . $lookupcontents[$i]['id'] . '">' . $lookupcontents[$i]['value'] . '</option>';
533
        }
534
        $select .= '</select>';
535
536
        return $select;
537
    }
538
}
539
540
/**
541
 * Class TextBox
542
 */
543
class TextBox extends Field
544
{
545
    /**
546
     * @param $parentObject
547
     * @param $animalObject
548
     */
549
    public function __construct($parentObject, $animalObject)
550
    {
551
        $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...
552
        $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...
553
        $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...
554
        $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...
555
        $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...
556
        if ($this->lookuptable == '1') {
557
            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

557
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
558
        }
559
        if ($parentObject->ViewInAdvanced == '1') {
560
            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

560
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
561
        }
562
        if ($parentObject->ViewInPie == '1') {
563
            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

563
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
564
        }
565
    }
566
567
    /**
568
     * @return XoopsFormText
569
     */
570
    public function editField()
571
    {
572
        $textbox = new XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 50, $maxsize = 50, $value = $this->value);
573
574
        return $textbox;
575
    }
576
577
    /**
578
     * @param string $name
579
     *
580
     * @return XoopsFormText
581
     */
582
    public function newField($name = '')
583
    {
584
        $textbox = new XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 50, $maxsize = 50, $value = $this->defaultvalue);
585
586
        return $textbox;
587
    }
588
589
    /**
590
     * @return string
591
     */
592
    public function getSearchString()
593
    {
594
        return '&amp;o=naam&amp;l=1';
595
    }
596
}
597
598
/**
599
 * Class TextArea
600
 */
601
class TextArea extends Field
602
{
603
    /**
604
     * @param $parentObject
605
     * @param $animalObject
606
     */
607
    public function __construct($parentObject, $animalObject)
608
    {
609
        $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...
610
        $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...
611
        $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...
612
        $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...
613
        if ($parentObject->LookupTable == '1') {
614
            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

614
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
615
        }
616
        if ($parentObject->ViewInAdvanced == '1') {
617
            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

617
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
618
        }
619
        if ($parentObject->ViewInPie == '1') {
620
            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

620
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
621
        }
622
    }
623
624
    /**
625
     * @return XoopsFormTextArea
626
     */
627
    public function editField()
628
    {
629
        $textarea = new XoopsFormTextArea('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value, $rows = 5, $cols = 50);
630
631
        return $textarea;
632
    }
633
634
    /**
635
     * @param string $name
636
     *
637
     * @return XoopsFormTextArea
638
     */
639
    public function newField($name = '')
640
    {
641
        $textarea = new XoopsFormTextArea('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue, $rows = 5, $cols = 50);
642
643
        return $textarea;
644
    }
645
646
    /**
647
     * @return string
648
     */
649
    public function getSearchString()
650
    {
651
        return '&amp;o=naam&amp;l=1';
652
    }
653
}
654
655
/**
656
 * Class DataSelect
657
 */
658
class DataSelect extends Field
659
{
660
    /**
661
     * @param $parentObject
662
     * @param $animalObject
663
     */
664
    public function __construct($parentObject, $animalObject)
665
    {
666
        $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...
667
        $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...
668
        $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...
669
        $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...
670
        if ($parentObject->lookuptable == '1') {
671
            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

671
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
672
        }
673
        if ($parentObject->ViewInAdvanced == '1') {
674
            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

674
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
675
        }
676
        if ($parentObject->ViewInPie == '1') {
677
            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

677
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
678
        }
679
    }
680
681
    /**
682
     * @return XoopsFormTextDateSelect
683
     */
684
    public function editField()
685
    {
686
        //$textarea = new XoopsFormFile("<b>".$this->fieldname."</b>", $this->fieldname, $maxfilesize = 2000);
687
        $textarea = new XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 15, $this->value);
688
689
        return $textarea;
690
    }
691
692
    /**
693
     * @param string $name
694
     *
695
     * @return XoopsFormTextDateSelect
696
     */
697
    public function newField($name = '')
698
    {
699
        $textarea = new XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 15, $this->defaultvalue);
700
701
        return $textarea;
702
    }
703
704
    /**
705
     * @return string
706
     */
707
    public function getSearchString()
708
    {
709
        return '&amp;o=naam&amp;l=1';
710
    }
711
}
712
713
/**
714
 * Class UrlField
715
 */
716
class UrlField extends Field
717
{
718
    /**
719
     * @param $parentObject
720
     * @param $animalObject
721
     */
722
    public function __construct($parentObject, $animalObject)
723
    {
724
        $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...
725
        $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...
726
        $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...
727
        $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...
728
        $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...
729
        if ($this->lookuptable == '1') {
730
            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

730
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
731
        }
732
        if ($parentObject->ViewInAdvanced == '1') {
733
            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

733
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
734
        }
735
        if ($parentObject->ViewInPie == '1') {
736
            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

736
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
737
        }
738
    }
739
740
    /**
741
     * @return XoopsFormText
742
     */
743
    public function editField()
744
    {
745
        $textbox = new XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 50, $maxsize = 255, $value = $this->value);
746
747
        return $textbox;
748
    }
749
750
    /**
751
     * @param string $name
752
     *
753
     * @return XoopsFormText
754
     */
755
    public function newField($name = '')
756
    {
757
        $textbox = new XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 50, $maxsize = 255, $value = $this->defaultvalue);
758
759
        return $textbox;
760
    }
761
762
    /**
763
     * @return XoopsFormLabel
764
     */
765
    public function viewField()
766
    {
767
        $view = new XoopsFormLabel($this->fieldname, '<a href="' . $this->value . '" target=\"_new\">' . $this->value . '</a>');
768
769
        return $view;
770
    }
771
772
    /**
773
     * @return string
774
     */
775
    public function showField()
776
    {
777
        return $this->fieldname . " : <a href=\"" . $this->value . "\" target=\"_new\">" . $this->value . '</a>';
778
    }
779
780
    /**
781
     * @return string
782
     */
783
    public function showValue()
784
    {
785
        return "<a href=\"" . $this->value . "\" target=\"_new\">" . $this->value . '</a>';
786
    }
787
788
    /**
789
     * @return string
790
     */
791
    public function getSearchString()
792
    {
793
        return '&amp;o=naam&amp;l=1';
794
    }
795
}
796
797
/**
798
 * Class Picture
799
 */
800
class Picture extends Field
801
{
802
    /**
803
     * @param $parentObject
804
     * @param $animalObject
805
     */
806
    public function __construct($parentObject, $animalObject)
807
    {
808
        $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...
809
        $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...
810
        $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...
811
        $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...
812
        $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...
813
        if ($this->lookuptable == '1') {
814
            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

814
            /** @scrutinizer ignore-deprecated */ new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
Loading history...
815
        }
816
        if ($parentObject->ViewInAdvanced == '1') {
817
            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

817
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
Loading history...
818
        }
819
        if ($parentObject->ViewInPie == '1') {
820
            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

820
            /** @scrutinizer ignore-deprecated */ new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
Loading history...
821
        }
822
        if ($parentObject->ViewInList == '1') {
823
            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

823
            /** @scrutinizer ignore-deprecated */ new SystemMessage('userfield' . $this->fieldnumber . ' cannot be included in listview');
Loading history...
824
        }
825
        if ($parentObject->HasSearch == '1') {
826
            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

826
            /** @scrutinizer ignore-deprecated */ new SystemMessage('Search cannot be defined for userfield' . $this->fieldnumber);
Loading history...
827
        }
828
    }
829
830
    /**
831
     * @return XoopsFormFile
832
     */
833
    public function editField()
834
    {
835
        $picturefield = new XoopsFormFile($this->fieldname, 'user' . $this->fieldnumber, 1024000);
836
        $picturefield->setExtra("size ='50'");
837
838
        return $picturefield;
839
    }
840
841
    /**
842
     * @param string $name
843
     *
844
     * @return XoopsFormFile
845
     */
846
    public function newField($name = '')
847
    {
848
        $picturefield = new XoopsFormFile($this->fieldname, $name . 'user' . $this->fieldnumber, 1024000);
849
        $picturefield->setExtra("size ='50'");
850
851
        return $picturefield;
852
    }
853
854
    /**
855
     * @return XoopsFormLabel
856
     */
857
    public function viewField()
858
    {
859
        $view = new XoopsFormLabel($this->fieldname, "<img src=\"assets/images/thumbnails/" . $this->value . "_400.jpeg\">");
860
861
        return $view;
862
    }
863
864
    /**
865
     * @return string
866
     */
867
    public function showField()
868
    {
869
        return "<img src=\"assets/images/thumbnails/" . $this->value . "_150.jpeg\">";
870
    }
871
872
    /**
873
     * @return string
874
     */
875
    public function showValue()
876
    {
877
        return "<img src=\"assets/images/thumbnails/" . $this->value . "_400.jpeg\">";
878
    }
879
}
880
881
/**
882
 * Class SISContext
883
 */
884
class SISContext
885
{
886
    private $contexts;
887
    private $depth;
888
889
    /**
890
     * SISContext constructor.
891
     */
892
    public function __construct()
893
    {
894
        $this->contexts = array();
895
        $this->depth    = 0;
896
    }
897
898
    /**
899
     * @param $url
900
     * @param $name
901
     */
902
    public function myGoto($url, $name)
903
    {
904
        $keys = array_keys($this->contexts);
905
        for ($i = 0; $i < $this->depth; ++$i) {
906
            if ($keys[$i] == $name) {
907
                $this->contexts[$name] = $url; // the url might be slightly different
908
                $this->depth           = $i + 1;
909
910
                for ($x = count($this->contexts); $x > $i + 1; $x--) {
911
                    array_pop($this->contexts);
912
                }
913
914
                return;
915
            }
916
        }
917
918
        $this->contexts[$name] = $url;
919
        $this->depth++;
920
    }
921
922
    /**
923
     * @return array
924
     */
925
    public function getAllContexts()
926
    {
927
        return $this->contexts;
928
    }
929
930
    /**
931
     * @return array
932
     */
933
    public function getAllContextNames()
934
    {
935
        return array_keys($this->contexts);
936
    }
937
}
938