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
|
|
|
Animal, |
|
|
|
|
22
|
|
|
Field |
|
|
|
|
23
|
|
|
}; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class Pedigree\DateSelectBox |
27
|
|
|
*/ |
28
|
|
|
class DateSelect extends Pedigree\HtmlInputAbstract |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
// Define class variables |
31
|
|
|
private $fieldnumber; |
32
|
|
|
private $fieldname; |
33
|
|
|
private $value; |
34
|
|
|
private $defaultvalue; |
35
|
|
|
private $lookuptable; |
36
|
|
|
private $errs; |
37
|
|
|
private $size = 15; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Constructor |
41
|
|
|
* |
42
|
|
|
* @param Field $parentObject |
43
|
|
|
* @param Animal $animalObject |
44
|
|
|
* |
45
|
|
|
*/ |
46
|
|
|
public function __construct(Field $parentObject, Animal $animalObject) |
47
|
|
|
{ |
48
|
|
|
//@todo move language strings to language file |
49
|
|
|
$this->fieldnumber = $parentObject->getId(); |
50
|
|
|
$this->fieldname = $parentObject->getSetting('fieldname'); |
51
|
|
|
$this->value = $animalObject->{'user' . $this->fieldnumber}; |
52
|
|
|
$this->defaultvalue = $parentObject->getSetting('defaultvalue'); |
53
|
|
|
if ($parentObject->hasLookup()) { |
54
|
|
|
xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber, get_class($this)); |
55
|
|
|
} |
56
|
|
|
if ($parentObject->inAdvanced()) { |
57
|
|
|
xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this)); |
58
|
|
|
} |
59
|
|
|
if ($parentObject->inPie()) { |
60
|
|
|
xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this)); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return \XoopsFormTextDateSelect |
66
|
|
|
*/ |
67
|
|
|
public function editField(): \XoopsFormTextDateSelect |
68
|
|
|
{ |
69
|
|
|
return new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $this->size, $this->value); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $name |
74
|
|
|
* |
75
|
|
|
* @return \XoopsFormTextDateSelect |
76
|
|
|
*/ |
77
|
|
|
public function newField(?string $name = ''): \XoopsFormTextDateSelect |
78
|
|
|
{ |
79
|
|
|
return new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $this->size, $this->defaultvalue); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
public function getSearchString() |
86
|
|
|
{ |
87
|
|
|
return '&o=naam&l=1'; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Show the value - which is nothing for this data type |
92
|
|
|
*/ |
93
|
|
|
public function showValue() |
94
|
|
|
{ |
95
|
|
|
|
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/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 beforeOtherDir/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: