Completed
Push — master ( c8eead...62889a )
by Michael
04:13
created

include/class_field.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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