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

TextBox::showField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace XoopsModules\Pedigree;
3
4
/*
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 */
13
14
/**
15
 * @package         XoopsModules\Pedigree
16
 * @copyright       {@link https://xoops.org/ XOOPS Project}
17
 * @license         {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
18
 * @author          XOOPS Module Dev Team
19
 */
20
use XoopsModules\Pedigree;
21
22
/**
23
 * Class Pedigree\SelectBox
24
 */
25
class TextBox extends Pedigree\HtmlInputAbstract
26
{
27
    // Define class variables
28
    private $fieldnumber;
29
    private $fieldname;
30
    private $value;
31
    private $defaultvalue;
32
    private $lookuptable;
33
    private $size = 50;
34
    private $maxsize = 50;
35
36
    /**
37
     * Constructor
38
     *
39
     * @todo move hard coded language strings to language file
40
     * @param $parentObject
41
     * @param $animalObject
42
     */
43
    public function __construct($parentObject, $animalObject)
44
    {
45
        $this->fieldnumber = $parentObject->getId();
46
        $this->fieldname = $parentObject->fieldname;
47
        $this->value = $animalObject->{'user' . $this->fieldnumber};
48
        $this->defaultvalue = $parentObject->defaultvalue;
49
        $this->lookuptable = $parentObject->lookuptable;
50
        if ('1' == $this->lookuptable) {
51
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber, get_class($this));
52
        }
53
        if ('1' == $parentObject->viewinadvanced) {
54
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this));
55
        }
56
        if ('1' == $parentObject->viewinpie) {
57
            xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this));
58
        }
59
    }
60
61
    /**
62
     * @return \XoopsFormText
63
     */
64
    public function editField()
65
    {
66
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $this->size, $this->maxsize, $value = $this->value);
67
68
        return $textbox;
69
    }
70
71
    /**
72
     * @param string $name
73
     *
74
     * @return \XoopsFormText
75
     */
76
    public function newField($name = '')
77
    {
78
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $this->size, $this->maxsize, $value = $this->defaultvalue);
79
80
        return $textbox;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getSearchString()
87
    {
88
        return '&amp;o=naam&amp;l=1';
89
    }
90
91
    /**
92
     * @return mixed|void
93
     */
94
    public function showValue()
95
    {
96
        return null;
97
    }
98
}
99