Completed
Pull Request — master (#1)
by
unknown
03:00
created

PedigreeUrlField::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 17
Code Lines 12

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 12
nc 8
nop 2
dl 17
loc 17
rs 9.2
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 27 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
 * Pedigree module for XOOPS
13
 *
14
 * @copyright   {@link http://sourceforge.net/projects/thmod/ The TXMod XOOPS Project}
15
 * @copyright   {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}
16
 * @license     GPL 2.0 or later
17
 * @package     pedigree
18
 * @subpackage  class
19
 * @author      XOOPS Mod Development Team
20
 */
21
22
require_once __DIR__ . '/htmlinput.abstract.php';
23
24
/**
25
 * Class PedigreeSelectBox
26
 */
27
class PedigreeUrlField extends PedigreeHtmlInputAbstract
0 ignored issues
show
Bug introduced by
There is one abstract method searchField in this class; you could implement it, or declare this class as abstract.
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...
28
{
29
    // Define class variables
30
    private $fieldnumber;
31
    private $fieldname;
32
    private $value;
33
    private $defaultvalue;
34
    private $lookuptable;
35
36
    /**
37
     * Constructor
38
     *
39
     * @param Field $parentObject
40
     * @param PedigreeAnimal $animalObject
41
     */
42 View Code Duplication
    public function __construct($parentObject, $animalObject)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $this->fieldnumber  = $parentObject->getId();
45
        $this->fieldname    = $parentObject->fieldname;
0 ignored issues
show
Bug introduced by
The property fieldname does not seem to exist in Field.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
46
        $this->value        = $animalObject->{'user' . $this->fieldnumber};
47
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug introduced by
The property defaultvalue does not seem to exist in Field.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
48
        $this->lookuptable  = $parentObject->hasLookup();
49
        if ($this->lookuptable) {
50
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber, get_class($this));
51
        }
52
        if ($parentObject->inAdvanced()) {
53
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this));
54
        }
55
        if ($parentObject->inPie()) {
56
            xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this));
57
        }
58
    }
59
60
    /**
61
     * @return XoopsFormText
62
     */
63
    public function editField()
64
    {
65
        $textbox = new XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 50, $maxsize = 255, $value = $this->value);
66
67
        return $textbox;
68
    }
69
70
    /**
71
     * @param string $name
72
     *
73
     * @return XoopsFormText
74
     */
75
    public function newField($name = '')
76
    {
77
        $textbox = new XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 50, $maxsize = 255, $value = $this->defaultvalue);
78
79
        return $textbox;
80
    }
81
82
    /**
83
     * @return XoopsFormLabel
84
     */
85
    public function viewField()
86
    {
87
        $view = new XoopsFormLabel($this->fieldname, '<a href="' . $this->value . '" target=\"_new\">' . $this->value . '</a>');
88
89
        return $view;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function showField()
96
    {
97
        return $this->fieldname . " : <a href=\"" . $this->value . "\" target=\"_new\">" . $this->value . '</a>';
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function showValue()
104
    {
105
        return "<a href=\"" . $this->value . "\" target=\"_new\">" . $this->value . '</a>';
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getSearchString()
112
    {
113
        return '&amp;o=naam&amp;l=1';
114
    }
115
}
116