UrlField   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 28
dl 0
loc 90
rs 10
c 5
b 0
f 0
wmc 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 4
A viewField() 0 5 1
A getSearchString() 0 3 1
A showField() 0 3 1
A editField() 0 5 1
A newField() 0 5 1
A showValue() 0 3 1
1
<?php
2
3
namespace XoopsModules\Pedigree;
4
5
/*
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * @package         XoopsModules\Pedigree
17
 * @copyright       {@link https://xoops.org/ XOOPS Project}
18
 * @license         {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
19
 * @author          XOOPS Module Dev Team
20
 */
21
22
23
/**
24
 * Class Pedigree\SelectBox
25
 */
26
class UrlField extends HtmlInputAbstract
27
{
28
    // Define class variables
29
    private $fieldnumber;
30
    private $fieldname;
31
    private $value;
32
    private $defaultvalue;
33
    private $lookuptable;
34
    private $size    = 50;
35
    private $maxsize = 255;
36
37
    /**
38
     * Constructor
39
     *
40
     * @param Field           $parentObject
41
     * @param Pedigree\Animal $animalObject
0 ignored issues
show
Bug introduced by
The type XoopsModules\Pedigree\Pedigree\Animal was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
42
     * @todo move hard coded language strings to language file
43
     */
44
    public function __construct($parentObject, $animalObject)
45
    {
46
        $this->fieldnumber  = $parentObject->getId();
47
        $this->fieldname    = $parentObject->fieldname;
0 ignored issues
show
Bug introduced by
The property fieldname does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
48
        $this->value        = $animalObject->{'user' . $this->fieldnumber};
49
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug introduced by
The property defaultvalue does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
50
        $this->lookuptable  = $parentObject->hasLookup();
51
        if ($this->lookuptable) {
52
            \xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber, \get_class($this));
53
        }
54
        if ($parentObject->inAdvanced()) {
55
            \xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', \get_class($this));
56
        }
57
        if ($parentObject->inPie()) {
58
            \xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, \get_class($this));
59
        }
60
    }
61
62
    /**
63
     * @return \XoopsFormText
64
     */
65
    public function editField()
66
    {
67
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $this->size, $this->maxsize, $value = $this->value);
68
69
        return $textbox;
70
    }
71
72
    /**
73
     * @param string $name
74
     *
75
     * @return \XoopsFormText
76
     */
77
    public function newField($name = '')
78
    {
79
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $this->size, $this->maxsize, $value = $this->defaultvalue);
80
81
        return $textbox;
82
    }
83
84
    /**
85
     * @return \XoopsFormLabel
86
     */
87
    public function viewField()
88
    {
89
        $view = new \XoopsFormLabel($this->fieldname, '<a href="' . $this->value . '" target=\"_new\">' . $this->value . '</a>');
90
91
        return $view;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function showField()
98
    {
99
        return $this->fieldname . ' : <a href="' . $this->value . '" target="_new">' . $this->value . '</a>';
100
    }
101
102
    /**
103
     * @return string
104
     */
105
    public function showValue()
106
    {
107
        return '<a href="' . $this->value . '" target="_new">' . $this->value . '</a>';
108
    }
109
110
    /**
111
     * @return string
112
     */
113
    public function getSearchString()
114
    {
115
        return '&amp;o=pname&amp;l=1';
116
    }
117
}
118