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 {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
19
|
|
|
* @license GPL 2.0 or later |
20
|
|
|
* @package pedigree |
21
|
|
|
* @author XOOPS Module Dev Team (https://xoops.org) |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
use XoopsModules; |
25
|
|
|
|
26
|
|
|
\defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Class Pedigree\Tree |
30
|
|
|
*/ |
31
|
|
|
class Tree extends \XoopsObject |
32
|
|
|
{ |
33
|
|
|
//Constructor |
34
|
|
|
|
35
|
|
|
public function __construct() |
36
|
|
|
{ |
37
|
|
|
parent::__construct(); |
38
|
|
|
$this->initVar('id', \XOBJ_DTYPE_INT, null, false, 7); |
39
|
|
|
$this->initVar('pname', \XOBJ_DTYPE_TXTAREA, null, false); |
40
|
|
|
$this->initVar('id_owner', \XOBJ_DTYPE_INT, null, false, 5); |
41
|
|
|
$this->initVar('id_breeder', \XOBJ_DTYPE_INT, null, false, 5); |
42
|
|
|
$this->initVar('user', \XOBJ_DTYPE_TXTBOX, null, false, 25); |
43
|
|
|
$this->initVar('roft', \XOBJ_DTYPE_ENUM, null, false); |
44
|
|
|
$this->initVar('mother', \XOBJ_DTYPE_INT, null, false, 5); |
45
|
|
|
$this->initVar('father', \XOBJ_DTYPE_INT, null, false, 5); |
46
|
|
|
$this->initVar('foto', \XOBJ_DTYPE_TXTBOX, null, false, 255); |
47
|
|
|
$this->initVar('coi', \XOBJ_DTYPE_TXTBOX, null, false, 10); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function __toString() |
51
|
|
|
{ |
52
|
|
|
return $this->getVar('pname'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* |
57
|
|
|
* @return array containing parent info array['mother'=>['id', 'name'], 'father=>['id', 'name']; |
58
|
|
|
*/ |
59
|
|
|
public function getParents() |
60
|
|
|
{ |
61
|
|
|
$parents = ['mother' => ['id' => 0, 'name' => ''], 'father' => ['id' => 0, 'name' => '']]; //init the |
62
|
|
|
//get the Tree Handler and retrieve parent info |
63
|
|
|
$treeHandler = XoopsModules\Pedigree\Helper::getInstance()->getHandler('Tree'); |
64
|
|
|
if (!$this->getVar('mother')) { |
65
|
|
|
$motherObj = $treeHandler->get($this->getVar('mother')); |
66
|
|
|
if ($motherObj instanceof XoopsModules\Pedigree\Tree && !$motherObj->isNew()) { |
67
|
|
|
$parents['mother'] = ['id' => $motherObj->geVar('id'), 'name' => $motherObj->getVar('pname')]; |
|
|
|
|
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
if (!$this->getVar('father')) { |
71
|
|
|
$fatherObj = $treeHandler->get($this->getVar('father')); |
72
|
|
|
if ($fatherObj instanceof XoopsModules\Pedigree\Tree && !$fatherObj->isNew()) { |
73
|
|
|
$parents['father'] = ['id' => $fatherObj->geVar('id'), 'name' => $fatherObj->getVar('pname')]; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
return $parents; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param bool $action |
81
|
|
|
* |
82
|
|
|
* @return \XoopsThemeForm |
83
|
|
|
*/ |
84
|
|
|
public function getForm($action = false) |
85
|
|
|
{ |
86
|
|
|
//global $xoopsModuleConfig; |
87
|
|
|
|
88
|
|
|
if (false === $action) { |
89
|
|
|
$action = $_SERVER['REQUEST_URI']; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$title = $this->isNew() ? \sprintf(\_AM_PEDIGREE_PEDIGREE_ADD) : \sprintf(\_AM_PEDIGREE_PEDIGREE_EDIT); |
93
|
|
|
|
94
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
95
|
|
|
|
96
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
97
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
98
|
|
|
|
99
|
|
|
$form->addElement(new \XoopsFormTextArea(\_AM_PEDIGREE_PEDIGREE_PNAME, 'pname', $this->getVar('pname'), 4, 47), true); |
100
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_ID_OWNER, 'id_owner', 50, 255, $this->getVar('id_owner')), false); |
101
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_ID_BREEDER, 'id_breeder', 50, 255, $this->getVar('id_breeder')), false); |
102
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_USER, 'user', 50, 255, $this->getVar('user')), false); |
103
|
|
|
$form->addElement(new \XoopsFormTextArea(\_AM_PEDIGREE_PEDIGREE_ROFT, 'roft', $this->getVar('roft'), 4, 47), false); |
104
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_MOTHER, 'mother', 50, 255, $this->getVar('mother')), false); |
105
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_FATHER, 'father', 50, 255, $this->getVar('father')), false); |
106
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_FOTO, 'foto', 50, 255, $this->getVar('foto')), false); |
107
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_COI, 'coi', 50, 255, $this->getVar('coi')), false); |
108
|
|
|
|
109
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save_pedigree')); |
110
|
|
|
|
111
|
|
|
//Submit buttons |
112
|
|
|
$buttonTray = new \XoopsFormElementTray('', ''); |
113
|
|
|
$submit_button = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
114
|
|
|
$buttonTray->addElement($submit_button); |
115
|
|
|
|
116
|
|
|
$cancel_button = new \XoopsFormButton('', '', _CANCEL, 'cancel'); |
117
|
|
|
$cancel_button->setExtra('onclick="history.go(-1)"'); |
118
|
|
|
$buttonTray->addElement($cancel_button); |
119
|
|
|
|
120
|
|
|
$form->addElement($buttonTray); |
121
|
|
|
|
122
|
|
|
return $form; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.