Passed
Push — master ( b847d6...d6d54c )
by Michael
09:34 queued 05:00
created

DateSelect::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 namespace XoopsModules\Pedigree;
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
/**
13
 * Pedigree module for XOOPS
14
 *
15
 * @copyright   {@link http://sourceforge.net/projects/thmod/ The TXMod XOOPS Project}
16
 * @copyright   {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}
17
 * @license     GPL 2.0 or later
18
 * @package     pedigree
19
 * @subpackage  class
20
 * @author      XOOPS Mod Development Team
21
 */
22
23
use XoopsModules\Pedigree;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsModules\Pedigree\Pedigree. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
24
25
26
/**
27
 * Class Pedigree\DateSelectBox
28
 */
29
class DateSelect extends Pedigree\HtmlInputAbstract
30
{
31
    // Define class variables
32
    private $fieldnumber;
33
    private $fieldname;
34
    private $value;
35
    private $defaultvalue;
36
    private $lookuptable;
37
    private $errs;
38
39
    /**
40
     * Constructor
41
     *
42
     * @param Pedigree\Fields $parentObject
43
     * @param                $animalObject
44
     */
45
    public function __construct($parentObject, $animalObject)
46
    {
47
        //@todo move language strings to language file
48
        $this->fieldnumber  = $parentObject->getId();
49
        $this->fieldname    = $parentObject->fieldname;
0 ignored issues
show
Bug introduced by
The property fieldname does not seem to exist on XoopsModules\Pedigree\Fields.
Loading history...
50
        $this->value        = $animalObject->{'user' . $this->fieldnumber};
51
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug introduced by
The property defaultvalue does not seem to exist on XoopsModules\Pedigree\Fields.
Loading history...
52
        if ($parentObject->hasLookup()) {
53
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber, get_class($this));
54
        }
55
        if ($parentObject->inAdvanced()) {
56
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this));
57
        }
58
        if ($parentObject->inPie()) {
59
            xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this));
60
        }
61
    }
62
63
    /**
64
     * @return \XoopsFormTextDateSelect
65
     */
66
    public function editField()
67
    {
68
        $textarea = new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 15, $this->value);
69
70
        return $textarea;
71
    }
72
73
    /**
74
     * @param string $name
75
     *
76
     * @return \XoopsFormTextDateSelect
77
     */
78
    public function newField($name = '')
79
    {
80
        $textarea = new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 15, $this->defaultvalue);
81
82
        return $textarea;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getSearchString()
89
    {
90
        return '&amp;o=naam&amp;l=1';
91
    }
92
93
    /**
94
     * @return mixed|void
95
     */
96
    public function searchField()
97
    {
98
        return null;
99
    }
100
101
    /**
102
     * @return mixed|void
103
     */
104
    public function showField()
105
    {
106
        return null;
107
    }
108
109
    /**
110
     * @return mixed|void
111
     */
112
    public function viewField()
113
    {
114
        return null;
115
    }
116
117
    /**
118
     * @return mixed|void
119
     */
120
    public function showValue()
121
    {
122
        return null;
123
    }
124
}
125