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
|
|
|
* Pedigree module for XOOPS |
17
|
|
|
* |
18
|
|
|
* @copyright Copyright (c) 2001-2019 {@link https://xoops.org XOOPS Project} |
19
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
20
|
|
|
* @package XoopsModules\Pedigree\Class |
21
|
|
|
* @since |
22
|
|
|
* @author XOOPS Module Dev Team (https://xoops.org) |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use XoopsModules\Pedigree\{ |
26
|
|
|
Helper |
|
|
|
|
27
|
|
|
}; |
28
|
|
|
|
29
|
|
|
\defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Class Pedigree\Owner |
33
|
|
|
*/ |
34
|
|
|
class Owner extends \XoopsObject |
35
|
|
|
{ |
36
|
|
|
//Constructor |
37
|
|
|
|
38
|
|
|
public function __construct() |
39
|
|
|
{ |
40
|
|
|
parent::__construct(); |
41
|
|
|
$this->initVar('id', \XOBJ_DTYPE_INT, null, false, 11); |
42
|
|
|
$this->initVar('firstname', \XOBJ_DTYPE_TXTBOX, null, false, 30); |
43
|
|
|
$this->initVar('lastname', \XOBJ_DTYPE_TXTBOX, null, false, 30); |
44
|
|
|
$this->initVar('postcode', \XOBJ_DTYPE_TXTBOX, null, false, 7); |
45
|
|
|
$this->initVar('city', \XOBJ_DTYPE_TXTBOX, null, false, 50); |
46
|
|
|
$this->initVar('streetname', \XOBJ_DTYPE_TXTBOX, null, false, 40); |
47
|
|
|
$this->initVar('housenumber', \XOBJ_DTYPE_TXTBOX, null, false, 6); |
48
|
|
|
$this->initVar('phonenumber', \XOBJ_DTYPE_TXTBOX, null, false, 14); |
49
|
|
|
$this->initVar('emailadres', \XOBJ_DTYPE_TXTBOX, null, false, 40); |
50
|
|
|
$this->initVar('website', \XOBJ_DTYPE_TXTBOX, null, false, 60); |
51
|
|
|
$this->initVar('user', \XOBJ_DTYPE_TXTBOX, null, false, 20); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* |
56
|
|
|
* @param bool $reverse true - "lastname, firstname" else "firstname lastname" |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function getFullName(bool $reverse = false) |
60
|
|
|
{ |
61
|
|
|
$name = $this->getVar('firstname') . ' ' . $this->getVar('lastname'); |
62
|
|
|
if ($reverse) { |
63
|
|
|
$name = $this->getVar('lastname') . ', ' . $this->getVar('firstname'); |
64
|
|
|
} |
65
|
|
|
return $name; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param bool $action |
70
|
|
|
* |
71
|
|
|
* @return \XoopsThemeForm |
72
|
|
|
*/ |
73
|
|
|
public function getForm($action = false) |
74
|
|
|
{ |
75
|
|
|
if (false === $action) { |
76
|
|
|
$action = $_SERVER['REQUEST_URI']; |
77
|
|
|
} |
78
|
|
|
/** @var \XoopsModules\Pedigree\Helper $helper */ |
79
|
|
|
$helper = Helper::getInstance(); |
80
|
|
|
$helper->loadLanguage('admin'); |
81
|
|
|
$title = $this->isNew() ? \sprintf(\_AM_PEDIGREE_OWNER_ADD) : \sprintf(\_AM_PEDIGREE_OWNER_EDIT); |
82
|
|
|
|
83
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
84
|
|
|
|
85
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
86
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
87
|
|
|
|
88
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_FIRSTNAME, 'firstname', 50, 255, $this->getVar('firstname')), false); |
|
|
|
|
89
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_LASTNAME, 'lastname', 50, 255, $this->getVar('lastname')), false); |
90
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_POSTCODE, 'postcode', 50, 255, $this->getVar('postcode')), false); |
91
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_CITY, 'city', 50, 255, $this->getVar('city')), false); |
92
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_STREETNAME, 'streetname', 50, 255, $this->getVar('streetname')), false); |
93
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_HOUSENUMBER, 'housenumber', 50, 255, $this->getVar('housenumber')), false); |
94
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_PHONENUMBER, 'phonenumber', 50, 255, $this->getVar('phonenumber')), false); |
95
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_EMAILADRES, 'emailadres', 50, 255, $this->getVar('emailadres')), false); |
96
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_WEBSITE, 'website', 50, 255, $this->getVar('website')), false); |
97
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_OWNER_USER, 'user', 50, 255, $this->getVar('user')), false); |
98
|
|
|
|
99
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save_owner')); |
100
|
|
|
|
101
|
|
|
// Submit tray |
102
|
|
|
$form->addElement(new \XoopsFormButtonTray('submit', _SUBMIT)); |
103
|
|
|
/* |
104
|
|
|
//Submit buttons |
105
|
|
|
$buttonTray = new \XoopsFormElementTray('', ''); |
106
|
|
|
$submit_button = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
107
|
|
|
$buttonTray->addElement($submit_button); |
108
|
|
|
|
109
|
|
|
$cancel_button = new \XoopsFormButton('', '', _CANCEL, 'cancel'); |
110
|
|
|
$cancel_button->setExtra('onclick="history.go(-1)"'); |
111
|
|
|
$buttonTray->addElement($cancel_button); |
112
|
|
|
|
113
|
|
|
$form->addElement($buttonTray); |
114
|
|
|
*/ |
115
|
|
|
|
116
|
|
|
return $form; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
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: