Passed
Push — master ( ba995b...aecde2 )
by Michael
32s queued 12s
created

include/class_field.php (2 issues)

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: #ff0000;"><h3>' . $message . '</h3></span>';
24
    }
25
}
26
27
/**
28
 * Class Animal
29
 * @deprecated
30
 */
31
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...
32
{
33
    /**
34
     * @param int $animalnumber * @internal param int $id animal ID
35
     */
36
    public function __construct($animalnumber = 0)
37
    {
38
        global $xoopsDB;
39
        if (0 == $animalnumber) {
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 = [];
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 : '';
69
70
        //print_r ($this->configValues); die();
71
        return $fields;
72
    }
73
74
    /**
75
     * @return mixed
76
     */
77
    public function getConfig()
78
    {
79
        return $this->configValues;
80
    }
81
}
82
83
/**
84
 * Class Field
85
 */
86
class Field
87
{
88
    protected $id;
89
90
    /**
91
     * @param $fieldnumber
92
     * @param $config
93
     */
94
    public function __construct($fieldnumber, $config)
95
    {
96
        //find key where ID = $fieldnumber;
97
        for ($x = 0, $xMax = count($config); $x < $xMax; ++$x) {
98
            if ($config[$x]['id'] = $fieldnumber) {
99
                foreach ($config[$x] as $key => $values) {
100
                    $this->$key = $values;
101
                }
102
            }
103
        }
104
        $this->id = $fieldnumber;
105
    }
106
107
    /**
108
     * @return bool
109
     */
110
    public function isActive()
111
    {
112
        $active = $this->getSetting('isActive');
113
        if ('1' == $active) {
114
            return true;
115
        }
116
117
        return false;
118
    }
119
120
    /**
121
     * @return bool
122
     */
123
    public function inAdvanced()
124
    {
125
        $active = $this->getSetting('ViewInAdvanced');
126
        // return ('1' == $active) ? true : false;
127
        if ('1' == $active) {
128
            return true;
129
        }
130
131
        return false;
132
    }
133
134
    /**
135
     * @return bool
136
     */
137
    public function isLocked()
138
    {
139
        $active = $this->getSetting('locked');
140
        if ('1' == $active) {
141
            return true;
142
        }
143
144
        return false;
145
    }
146
147
    /**
148
     * @return bool
149
     */
150
    public function hasSearch()
151
    {
152
        $active = $this->getSetting('HasSearch');
153
        if ('1' == $active) {
154
            return true;
155
        }
156
157
        return false;
158
    }
159
160
    /**
161
     * @return bool
162
     */
163
    public function addLitter()
164
    {
165
        $active = $this->getSetting('Litter');
166
        if ('1' == $active) {
167
            return true;
168
        }
169
170
        return false;
171
    }
172
173
    /**
174
     * @return bool
175
     */
176
    public function generalLitter()
177
    {
178
        $active = $this->getSetting('Generallitter');
179
        if ('1' == $active) {
180
            return true;
181
        }
182
183
        return false;
184
    }
185
186
    /**
187
     * @return bool
188
     */
189
    public function hasLookup()
190
    {
191
        $active = $this->getSetting('LookupTable');
192
        if ('1' == $active) {
193
            return true;
194
        }
195
196
        return false;
197
    }
198
199
    /**
200
     * @return string
201
     */
202
    public function getSearchString()
203
    {
204
        return '&amp;o=naam&amp;p';
205
    }
206
207
    /**
208
     * @return bool
209
     */
210
    public function inPie()
211
    {
212
        $active = $this->getSetting('ViewInPie');
213
        if ('1' == $active) {
214
            return true;
215
        }
216
217
        return false;
218
    }
219
220
    /**
221
     * @return bool
222
     */
223
    public function inPedigree()
224
    {
225
        $active = $this->getSetting('viewinpedigree');
226
        if ('1' == $active) {
227
            return true;
228
        }
229
230
        return false;
231
    }
232
233
    /**
234
     * @return bool
235
     */
236
    public function inList()
237
    {
238
        $active = $this->getSetting('ViewInList');
239
        if ('1' == $active) {
240
            return true;
241
        }
242
243
        return false;
244
    }
245
246
    public function getId()
247
    {
248
        return $this->id;
249
    }
250
251
    /**
252
     * @param $setting
253
     *
254
     * @return mixed
255
     */
256
    public function getSetting($setting)
257
    {
258
        return $this->{$setting};
259
    }
260
261
    /**
262
     * @param $fieldnumber
263
     *
264
     * @return array
265
     */
266
    public function lookupField($fieldnumber)
267
    {
268
        $ret = [];
269
        global $xoopsDB;
270
        $SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $fieldnumber) . " ORDER BY 'order'";
271
        $result = $GLOBALS['xoopsDB']->query($SQL);
272
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
273
            $ret[] = ['id' => $row['id'], 'value' => $row['value']];
274
        }
275
276
        //array_multisort($ret,SORT_ASC);
277
        return $ret;
278
    }
279
280
    /**
281
     * @return XoopsFormLabel
282
     */
283
    public function viewField()
284
    {
285
        $view = new \XoopsFormLabel($this->fieldname, $this->value);
286
287
        return $view;
288
    }
289
290
    /**
291
     * @return string
292
     */
293
    public function showField()
294
    {
295
        return $this->fieldname . ' : ' . $this->value;
296
    }
297
298
    /**
299
     * @return mixed|string
300
     */
301
    public function showValue()
302
    {
303
        global $myts;
304
305
        return $myts->displayTarea($this->value);
306
        //return $this->value;
307
    }
308
309
    /**
310
     * @return string
311
     */
312
    public function searchField()
313
    {
314
        return '<input type="text" name="query" size="20">';
315
    }
316
}
317
318
/**
319
 * Class RadioButton
320
 */
321
class RadioButton extends Field
322
{
323
    /**
324
     * @param \PedigreeField  $parentObject
325
     * @param \PedigreeAnimal $animalObject
326
     */
327
    public function __construct(PedigreeField $parentObject, PedigreeAnimal $animalObject)
328
    {
329
        $this->fieldnumber = $parentObject->getId();
330
331
        $this->fieldname = $parentObject->fieldname;
332
        $this->value = $animalObject->{'user' . $this->fieldnumber};
333
        $this->defaultvalue = $parentObject->defaultvalue;
334
        $this->lookuptable = $parentObject->lookuptable;
335
        if ('0' == $this->lookuptable) {
336
            new SystemMessage('A lookuptable must be specified for userfield' . $this->fieldnumber);
337
        }
338
    }
339
340
    /**
341
     * @return XoopsFormRadio
342
     */
343
    public function editField()
344
    {
345
        $radio = new \XoopsFormRadio('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value);
346
        $lookupcontents = $this->lookupField($this->fieldnumber);
347
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
348
            $radio->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br>'));
349
        }
350
351
        return $radio;
352
    }
353
354
    /**
355
     * @param string $name
356
     *
357
     * @return XoopsFormRadio
358
     */
359
    public function newField($name = '')
360
    {
361
        $radio = new \XoopsFormRadio('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue);
362
        $lookupcontents = $this->lookupField($this->fieldnumber);
363
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
364
            $radio->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br>'));
365
        }
366
367
        return $radio;
368
    }
369
370
    /**
371
     * @return XoopsFormLabel
372
     */
373
    public function viewField()
374
    {
375
        $choosenvalue = '';
376
        $lookupcontents = $this->lookupField($this->fieldnumber);
377
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
378
            if ($lookupcontents[$i]['id'] == $this->value) {
379
                $choosenvalue = $lookupcontents[$i]['value'];
380
            }
381
        }
382
        $view = new \XoopsFormLabel($this->fieldname, $choosenvalue);
383
384
        return $view;
385
    }
386
387
    /**
388
     * @return string
389
     */
390
    public function showField()
391
    {
392
        $choosenvalue = '';
393
        $lookupcontents = $this->lookupField($this->fieldnumber);
394
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
395
            if ($lookupcontents[$i]['id'] == $this->value) {
396
                $choosenvalue = $lookupcontents[$i]['value'];
397
            }
398
        }
399
400
        return $this->fieldname . ' : ' . $choosenvalue;
401
    }
402
403
    /**
404
     * @return mixed
405
     */
406
    public function showValue()
407
    {
408
        $choosenvalue = '';
409
        $lookupcontents = $this->lookupField($this->fieldnumber);
410
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
411
            if ($lookupcontents[$i]['id'] == $this->value) {
412
                $choosenvalue = $lookupcontents[$i]['value'];
413
            }
414
        }
415
416
        return $choosenvalue;
417
    }
418
419
    /**
420
     * @return string
421
     */
422
    public function searchField()
423
    {
424
        $select = '<select size="1" name="query" style="width: 140px;">';
425
        $lookupcontents = $this->lookupField($this->fieldnumber);
426
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
427
            $select .= '<option value="' . $lookupcontents[$i]['id'] . '">' . $lookupcontents[$i]['value'] . '</option>';
428
        }
429
        $select .= '</select>';
430
431
        return $select;
432
    }
433
}
434
435
/**
436
 * Class SelectBox
437
 */
438
class SelectBox extends Field
439
{
440
    /**
441
     * @param $parentObject
442
     * @param $animalObject
443
     */
444
    public function __construct($parentObject, $animalObject)
445
    {
446
        $this->fieldnumber = $parentObject->getId();
447
        $this->fieldname = $parentObject->fieldname;
448
        $this->value = $animalObject->{'user' . $this->fieldnumber};
449
        $this->defaultvalue = $parentObject->defaultvalue;
450
        $this->lookuptable = $parentObject->lookuptable;
451
        if ('0' == $this->lookuptable) {
452
            new SystemMessage('A lookuptable must be specified for userfield' . $this->fieldnumber);
453
        }
454
    }
455
456
    /**
457
     * @return XoopsFormSelect
458
     */
459
    public function editField()
460
    {
461
        $select = new \XoopsFormSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value, $size = 1, $multiple = false);
462
        $lookupcontents = $this->lookupField($this->fieldnumber);
463
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
464
            $select->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br>'));
465
        }
466
467
        return $select;
468
    }
469
470
    /**
471
     * @param string $name
472
     *
473
     * @return XoopsFormSelect
474
     */
475
    public function newField($name = '')
476
    {
477
        $select = new \XoopsFormSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue, $size = 1, $multiple = false);
478
        $lookupcontents = $this->lookupField($this->fieldnumber);
479
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
480
            $select->addOption($lookupcontents[$i]['id'], $name = ($lookupcontents[$i]['value'] . '<br>'));
481
        }
482
483
        return $select;
484
    }
485
486
    /**
487
     * @return XoopsFormLabel
488
     */
489
    public function viewField()
490
    {
491
        $choosenvalue = '';
492
        $lookupcontents = $this->lookupField($this->fieldnumber);
493
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
494
            if ($lookupcontents[$i]['id'] == $this->value) {
495
                $choosenvalue = $lookupcontents[$i]['value'];
496
            }
497
        }
498
        $view = new \XoopsFormLabel($this->fieldname, $choosenvalue);
499
500
        return $view;
501
    }
502
503
    /**
504
     * @return string
505
     */
506
    public function showField()
507
    {
508
        $choosenvalue = '';
509
        $lookupcontents = $this->lookupField($this->fieldnumber);
510
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
511
            if ($lookupcontents[$i]['id'] == $this->value) {
512
                $choosenvalue = $lookupcontents[$i]['value'];
513
            }
514
        }
515
516
        return $this->fieldname . ' : ' . $choosenvalue;
517
    }
518
519
    /**
520
     * @return mixed
521
     */
522
    public function showValue()
523
    {
524
        $choosenvalue = '';
525
        $lookupcontents = $this->lookupField($this->fieldnumber);
526
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
527
            if ($lookupcontents[$i]['id'] == $this->value) {
528
                $choosenvalue = $lookupcontents[$i]['value'];
529
            }
530
        }
531
532
        return $choosenvalue;
533
    }
534
535
    /**
536
     * @return string
537
     */
538
    public function searchField()
539
    {
540
        $select = '<select size="1" name="query" style="width: 140px;">';
541
        $lookupcontents = $this->lookupField($this->fieldnumber);
542
        for ($i = 0, $iMax = count($lookupcontents); $i < $iMax; ++$i) {
543
            $select .= '<option value="' . $lookupcontents[$i]['id'] . '">' . $lookupcontents[$i]['value'] . '</option>';
544
        }
545
        $select .= '</select>';
546
547
        return $select;
548
    }
549
}
550
551
/**
552
 * Class TextBox
553
 */
554
class TextBox extends Field
555
{
556
    /**
557
     * @param $parentObject
558
     * @param $animalObject
559
     */
560
    public function __construct($parentObject, $animalObject)
561
    {
562
        $this->fieldnumber = $parentObject->getId();
563
        $this->fieldname = $parentObject->fieldname;
564
        $this->value = $animalObject->{'user' . $this->fieldnumber};
565
        $this->defaultvalue = $parentObject->defaultvalue;
566
        $this->lookuptable = $parentObject->lookuptable;
567
        if ('1' == $this->lookuptable) {
568
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
569
        }
570
        if ('1' == $parentObject->ViewInAdvanced) {
571
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
572
        }
573
        if ('1' == $parentObject->ViewInPie) {
574
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
575
        }
576
    }
577
578
    /**
579
     * @return XoopsFormText
580
     */
581
    public function editField()
582
    {
583
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 50, $maxsize = 50, $value = $this->value);
584
585
        return $textbox;
586
    }
587
588
    /**
589
     * @param string $name
590
     *
591
     * @return XoopsFormText
592
     */
593
    public function newField($name = '')
594
    {
595
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 50, $maxsize = 50, $value = $this->defaultvalue);
596
597
        return $textbox;
598
    }
599
600
    /**
601
     * @return string
602
     */
603
    public function getSearchString()
604
    {
605
        return '&amp;o=naam&amp;l=1';
606
    }
607
}
608
609
/**
610
 * Class TextArea
611
 */
612
class TextArea extends Field
613
{
614
    /**
615
     * @param $parentObject
616
     * @param $animalObject
617
     */
618
    public function __construct($parentObject, $animalObject)
619
    {
620
        $this->fieldnumber = $parentObject->getId();
621
        $this->fieldname = $parentObject->fieldname;
622
        $this->value = $animalObject->{'user' . $this->fieldnumber};
623
        $this->defaultvalue = $parentObject->defaultvalue;
624
        if ('1' == $parentObject->LookupTable) {
625
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
626
        }
627
        if ('1' == $parentObject->ViewInAdvanced) {
628
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
629
        }
630
        if ('1' == $parentObject->ViewInPie) {
631
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
632
        }
633
    }
634
635
    /**
636
     * @return XoopsFormTextArea
637
     */
638
    public function editField()
639
    {
640
        $textarea = new \XoopsFormTextArea('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $value = $this->value, $rows = 5, $cols = 50);
641
642
        return $textarea;
643
    }
644
645
    /**
646
     * @param string $name
647
     *
648
     * @return XoopsFormTextArea
649
     */
650
    public function newField($name = '')
651
    {
652
        $textarea = new \XoopsFormTextArea('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $value = $this->defaultvalue, $rows = 5, $cols = 50);
653
654
        return $textarea;
655
    }
656
657
    /**
658
     * @return string
659
     */
660
    public function getSearchString()
661
    {
662
        return '&amp;o=naam&amp;l=1';
663
    }
664
}
665
666
/**
667
 * Class DataSelect
668
 */
669
class DataSelect extends Field
670
{
671
    /**
672
     * @param $parentObject
673
     * @param $animalObject
674
     */
675
    public function __construct($parentObject, $animalObject)
676
    {
677
        $this->fieldnumber = $parentObject->getId();
678
        $this->fieldname = $parentObject->fieldname;
679
        $this->value = $animalObject->{'user' . $this->fieldnumber};
680
        $this->defaultvalue = $parentObject->defaultvalue;
681
        if ('1' == $parentObject->lookuptable) {
682
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
683
        }
684
        if ('1' == $parentObject->ViewInAdvanced) {
685
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
686
        }
687
        if ('1' == $parentObject->ViewInPie) {
688
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
689
        }
690
    }
691
692
    /**
693
     * @return XoopsFormTextDateSelect
694
     */
695
    public function editField()
696
    {
697
        //$textarea = new \XoopsFormFile("<b>".$this->fieldname."</b>", $this->fieldname, $maxfilesize = 2000);
698
        $textarea = new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 15, $this->value);
699
700
        return $textarea;
701
    }
702
703
    /**
704
     * @param string $name
705
     *
706
     * @return XoopsFormTextDateSelect
707
     */
708
    public function newField($name = '')
709
    {
710
        $textarea = new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 15, $this->defaultvalue);
711
712
        return $textarea;
713
    }
714
715
    /**
716
     * @return string
717
     */
718
    public function getSearchString()
719
    {
720
        return '&amp;o=naam&amp;l=1';
721
    }
722
}
723
724
/**
725
 * Class UrlField
726
 */
727
class UrlField extends Field
728
{
729
    /**
730
     * @param $parentObject
731
     * @param $animalObject
732
     */
733
    public function __construct($parentObject, $animalObject)
734
    {
735
        $this->fieldnumber = $parentObject->getId();
736
        $this->fieldname = $parentObject->fieldname;
737
        $this->value = $animalObject->{'user' . $this->fieldnumber};
738
        $this->defaultvalue = $parentObject->defaultvalue;
739
        $this->lookuptable = $parentObject->lookuptable;
740
        if ('1' == $this->lookuptable) {
741
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
742
        }
743
        if ('1' == $parentObject->ViewInAdvanced) {
744
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
745
        }
746
        if ('1' == $parentObject->ViewInPie) {
747
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
748
        }
749
    }
750
751
    /**
752
     * @return XoopsFormText
753
     */
754
    public function editField()
755
    {
756
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 50, $maxsize = 255, $value = $this->value);
757
758
        return $textbox;
759
    }
760
761
    /**
762
     * @param string $name
763
     *
764
     * @return XoopsFormText
765
     */
766
    public function newField($name = '')
767
    {
768
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 50, $maxsize = 255, $value = $this->defaultvalue);
769
770
        return $textbox;
771
    }
772
773
    /**
774
     * @return XoopsFormLabel
775
     */
776
    public function viewField()
777
    {
778
        $view = new \XoopsFormLabel($this->fieldname, '<a href="' . $this->value . '" target=\"_new\">' . $this->value . '</a>');
779
780
        return $view;
781
    }
782
783
    /**
784
     * @return string
785
     */
786
    public function showField()
787
    {
788
        return $this->fieldname . ' : <a href="' . $this->value . '" target="_new">' . $this->value . '</a>';
789
    }
790
791
    /**
792
     * @return string
793
     */
794
    public function showValue()
795
    {
796
        return '<a href="' . $this->value . '" target="_new">' . $this->value . '</a>';
797
    }
798
799
    /**
800
     * @return string
801
     */
802
    public function getSearchString()
803
    {
804
        return '&amp;o=naam&amp;l=1';
805
    }
806
}
807
808
/**
809
 * Class Picture
810
 */
811
class Picture extends Field
812
{
813
    /**
814
     * @param $parentObject
815
     * @param $animalObject
816
     */
817
    public function __construct($parentObject, $animalObject)
818
    {
819
        $this->fieldnumber = $parentObject->getId();
820
        $this->fieldname = $parentObject->fieldname;
821
        $this->value = $animalObject->{'user' . $this->fieldnumber};
822
        $this->defaultvalue = $parentObject->defaultvalue;
823
        $this->lookuptable = $parentObject->lookuptable;
824
        if ('1' == $this->lookuptable) {
825
            new SystemMessage('No lookuptable may be specified for userfield' . $this->fieldnumber);
826
        }
827
        if ('1' == $parentObject->ViewInAdvanced) {
828
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be shown in advanced info');
829
        }
830
        if ('1' == $parentObject->ViewInPie) {
831
            new SystemMessage('A Pie-chart cannot be specified for userfield' . $this->fieldnumber);
832
        }
833
        if ('1' == $parentObject->ViewInList) {
834
            new SystemMessage('userfield' . $this->fieldnumber . ' cannot be included in listview');
835
        }
836
        if ('1' == $parentObject->HasSearch) {
837
            new SystemMessage('Search cannot be defined for userfield' . $this->fieldnumber);
838
        }
839
    }
840
841
    /**
842
     * @return XoopsFormFile
843
     */
844
    public function editField()
845
    {
846
        $pictureField = new \XoopsFormFile($this->fieldname, 'user' . $this->fieldnumber, 1024000);
847
        $pictureField->setExtra("size ='50'");
848
849
        return $pictureField;
850
    }
851
852
    /**
853
     * @param string $name
854
     *
855
     * @return XoopsFormFile
856
     */
857
    public function newField($name = '')
858
    {
859
        $pictureField = new \XoopsFormFile($this->fieldname, $name . 'user' . $this->fieldnumber, 1024000);
860
        $pictureField->setExtra("size ='50'");
861
862
        return $pictureField;
863
    }
864
865
    /**
866
     * @return XoopsFormLabel
867
     */
868
    public function viewField()
869
    {
870
        $view = new \XoopsFormLabel($this->fieldname, '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">');
871
872
        return $view;
873
    }
874
875
    /**
876
     * @return string
877
     */
878
    public function showField()
879
    {
880
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_150.jpeg">';
881
    }
882
883
    /**
884
     * @return string
885
     */
886
    public function showValue()
887
    {
888
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">';
889
    }
890
}
891
892
/**
893
 * Class SISContext
894
 */
895
class SISContext
896
{
897
    private $contexts;
898
    private $depth;
899
900
    /**
901
     * SISContext constructor.
902
     */
903
    public function __construct()
904
    {
905
        $this->contexts = [];
906
        $this->depth = 0;
907
    }
908
909
    /**
910
     * @param $url
911
     * @param $name
912
     */
913
    public function myGoto($url, $name)
914
    {
915
        $keys = array_keys($this->contexts);
916
        for ($i = 0; $i < $this->depth; ++$i) {
917
            if ($keys[$i] == $name) {
918
                $this->contexts[$name] = $url; // the url might be slightly different
919
                $this->depth = $i + 1;
920
921
                for ($x = count($this->contexts); $x > $i + 1; $x--) {
922
                    array_pop($this->contexts);
923
                }
924
925
                return;
926
            }
927
        }
928
929
        $this->contexts[$name] = $url;
930
        $this->depth++;
931
    }
932
933
    /**
934
     * @return array
935
     */
936
    public function getAllContexts()
937
    {
938
        return $this->contexts;
939
    }
940
941
    /**
942
     * @return array
943
     */
944
    public function getAllContextNames()
945
    {
946
        return array_keys($this->contexts);
947
    }
948
}
949