1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits of |
4
|
|
|
supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit |
6
|
|
|
authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, but |
9
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: Pedigree |
15
|
|
|
* |
16
|
|
|
* @package XoopsModules\Pedigree |
17
|
|
|
* @author XOOPS Module Development Team |
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
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
use Xmf\Request; |
|
|
|
|
23
|
|
|
use XoopsModules\Pedigree; |
24
|
|
|
use XoopsModules\Pedigree\Constants; |
25
|
|
|
|
26
|
|
|
//require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
27
|
|
|
require_once __DIR__ . '/header.php'; |
28
|
|
|
|
29
|
|
|
$helper->loadLanguage('main'); |
30
|
|
|
// Include any common code for this module. |
31
|
|
|
require_once $helper->path('include/common.php'); |
32
|
|
|
|
33
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_adddog.tpl'; |
34
|
|
|
|
35
|
|
|
require XOOPS_ROOT_PATH . '/header.php'; |
36
|
|
|
|
37
|
|
|
$GLOBALS['xoopsTpl']->assign('page_title', _MA_PEDIGREE_ADD_OWNER_BREEDER); |
38
|
|
|
|
39
|
|
|
//check for access |
40
|
|
|
if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
41
|
|
|
redirect_header('javascript:history.go(-1)', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$f = Request::getString('f', '', 'POST'); |
45
|
|
|
if ('check' === $f) { |
46
|
|
|
//check for access |
47
|
|
|
$objVars = [ |
48
|
|
|
'firstname' => Request::getString('firstname', '', 'POST'), |
49
|
|
|
'lastname' => Request::getString('lastname', '', 'POST'), |
50
|
|
|
'emailadres' => Request::getEmail('email', '', 'POST'), |
51
|
|
|
'website' => Request::getUrl('website', '', 'POST'), |
52
|
|
|
'user' => Request::getString('user', '', 'POST'), |
53
|
|
|
]; |
54
|
|
|
|
55
|
|
|
$ownerHandler = $helper->getHandler('Owner'); |
56
|
|
|
$oObj = $ownerHandler->create(); |
57
|
|
|
$oObj->setVars($objVars); |
58
|
|
|
$ownerHandler->insert($oObj); |
59
|
|
|
|
60
|
|
|
$helper->redirect('', 3, _MA_PEDIGREE_ADDED_TO_DB); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
//create form |
64
|
|
|
require XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
65
|
|
|
$form = new \XoopsThemeForm(_MA_PEDIGREE_ADD_OWNER, 'breedername', 'add_breeder.php?f=check', 'post'); |
66
|
|
|
$form->addElement(new \XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = Constants::TOKEN_TIMEOUT)); |
67
|
|
|
$form->addElement(new \XoopsFormHidden('user', $GLOBALS['xoopsUser']->getVar('uid'))); |
68
|
|
|
//lastname |
69
|
|
|
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_LNAME . '</b>', 'lastname', $size = 30, $maxsize = 30, $value = '')); |
70
|
|
|
|
71
|
|
|
//firstname |
72
|
|
|
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_FNAME . '</b>', 'firstname', $size = 3050, $maxsize = 30, $value = '')); |
73
|
|
|
|
74
|
|
|
//email |
75
|
|
|
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_EMAIL . '</b>', 'email', $size = 30, $maxsize = 40, $value = '')); |
76
|
|
|
|
77
|
|
|
//website |
78
|
|
|
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_WEB . '</b>', 'website', $size = 30, $maxsize = 60, $value = '')); |
79
|
|
|
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, _MA_PEDIGREE_FLD_OWN_WEB_EX)); |
80
|
|
|
|
81
|
|
|
//submit button |
82
|
|
|
$form->addElement(new \XoopsFormButton('', 'button_id', _MA_PEDIGREE_ADD_OWNER, 'submit')); |
83
|
|
|
|
84
|
|
|
//add data (form) to smarty template |
85
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
86
|
|
|
|
87
|
|
|
//footer |
88
|
|
|
require XOOPS_ROOT_PATH . '/footer.php'; |
89
|
|
|
|
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: