|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
/** |
|
12
|
|
|
* animal module for xoops |
|
13
|
|
|
* |
|
14
|
|
|
* @copyright The TXMod XOOPS Project http://sourceforge.net/projects/thmod/ |
|
15
|
|
|
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
|
16
|
|
|
* @license GPL 2.0 or later |
|
17
|
|
|
* @package animal |
|
18
|
|
|
* @since 2.5.x |
|
19
|
|
|
* @author XOOPS Development Team ( [email protected] ) - ( http://xoops.org ) |
|
20
|
|
|
* @version $Id: const_entete.php 9860 2012-07-13 10:41:41Z txmodxoops $ |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
if (!defined("XOOPS_ROOT_PATH")) { |
|
24
|
|
|
die("XOOPS root path not defined"); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class PedigreeFields |
|
29
|
|
|
*/ |
|
30
|
|
|
class PedigreeFields extends XoopsObject |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
//Constructor |
|
33
|
|
|
/** |
|
34
|
|
|
* |
|
35
|
|
|
*/ |
|
36
|
|
|
function __construct() |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
parent::__construct(); |
|
39
|
|
|
$this->initVar("ID", XOBJ_DTYPE_INT, null, false, 2); |
|
40
|
|
|
$this->initVar("isActive", XOBJ_DTYPE_INT, null, false, 1); |
|
41
|
|
|
$this->initVar("FieldName", XOBJ_DTYPE_TXTBOX, null, false, 50); |
|
42
|
|
|
$this->initVar("FieldType", XOBJ_DTYPE_ENUM, null, false); |
|
43
|
|
|
$this->initVar("LookupTable", XOBJ_DTYPE_INT, null, false, 1); |
|
44
|
|
|
$this->initVar("DefaultValue", XOBJ_DTYPE_TXTBOX, null, false, 50); |
|
45
|
|
|
$this->initVar("FieldExplenation", XOBJ_DTYPE_TXTAREA, null, false); |
|
46
|
|
|
$this->initVar("HasSearch", XOBJ_DTYPE_INT, null, false, 1); |
|
47
|
|
|
$this->initVar("Litter", XOBJ_DTYPE_INT, null, false, 1); |
|
48
|
|
|
$this->initVar("Generallitter", XOBJ_DTYPE_INT, null, false, 1); |
|
49
|
|
|
$this->initVar("SearchName", XOBJ_DTYPE_TXTBOX, null, false, 50); |
|
50
|
|
|
$this->initVar("SearchExplenation", XOBJ_DTYPE_TXTAREA, null, false); |
|
51
|
|
|
$this->initVar("ViewInPedigree", XOBJ_DTYPE_INT, null, false, 1); |
|
52
|
|
|
$this->initVar("ViewInAdvanced", XOBJ_DTYPE_INT, null, false, 1); |
|
53
|
|
|
$this->initVar("ViewInPie", XOBJ_DTYPE_INT, null, false, 1); |
|
54
|
|
|
$this->initVar("ViewInList", XOBJ_DTYPE_INT, null, false, 1); |
|
55
|
|
|
$this->initVar("locked", XOBJ_DTYPE_INT, null, false, 1); |
|
56
|
|
|
$this->initVar("order", XOBJ_DTYPE_INT, null, false, 3); |
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param bool $action |
|
62
|
|
|
* |
|
63
|
|
|
* @return XoopsThemeForm |
|
64
|
|
|
*/ |
|
65
|
|
|
function getForm($action = false) |
|
|
|
|
|
|
66
|
|
|
{ |
|
67
|
|
|
global $xoopsDB, $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
if ($action === false) { |
|
70
|
|
|
$action = $_SERVER["REQUEST_URI"]; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$title = $this->isNew() ? sprintf(_AM_PEDIGREE_PEDIGREE_CONFIG_ADD) : sprintf(_AM_PEDIGREE_PEDIGREE_CONFIG_EDIT); |
|
74
|
|
|
|
|
75
|
|
|
include_once(XOOPS_ROOT_PATH . "/class/xoopsformloader.php"); |
|
76
|
|
|
|
|
77
|
|
|
$form = new XoopsThemeForm($title, "form", $action, "post", true); |
|
78
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
79
|
|
|
|
|
80
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_ISACTIVE, "isActive", 50, 255, $this->getVar("isActive")), false); |
|
81
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_FIELDNAME, "FieldName", 50, 255, $this->getVar("FieldName")), false); |
|
82
|
|
|
$form->addElement(new XoopsFormTextArea(_AM_PEDIGREE_PEDIGREE_CONFIG_FIELDTYPE, "FieldType", $this->getVar("FieldType"), 4, 47), false); |
|
83
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_LOOKUPTABLE, "LookupTable", 50, 255, $this->getVar("LookupTable")), false); |
|
84
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_DEFAULTVALUE, "DefaultValue", 50, 255, $this->getVar("DefaultValue")), false); |
|
85
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_FIELDEXPLENATION, "FieldExplenation", 50, 255, $this->getVar("FieldExplenation")), false); |
|
86
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_HASSEARCH, "HasSearch", 50, 255, $this->getVar("HasSearch")), false); |
|
87
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_LITTER, "Litter", 50, 255, $this->getVar("Litter")), false); |
|
88
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_GENERALLITTER, "Generallitter", 50, 255, $this->getVar("Generallitter")), false); |
|
89
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_SEARCHNAME, "SearchName", 50, 255, $this->getVar("SearchName")), false); |
|
90
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_SEARCHEXPLENATION, "SearchExplenation", 50, 255, $this->getVar("SearchExplenation")), false); |
|
91
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINPEDIGREE, "ViewInPedigree", 50, 255, $this->getVar("ViewInPedigree")), false); |
|
92
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINADVANCED, "ViewInAdvanced", 50, 255, $this->getVar("ViewInAdvanced")), false); |
|
93
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINPIE, "ViewInPie", 50, 255, $this->getVar("ViewInPie")), false); |
|
94
|
|
|
$form->addElement(new XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINLIST, "ViewInList", 50, 255, $this->getVar("ViewInList")), false); |
|
95
|
|
|
|
|
96
|
|
|
// include_once(XOOPS_ROOT_PATH."/class/tree.php"); |
|
|
|
|
|
|
97
|
|
|
// $Handler =& xoops_getModuleHandler("animal_", $xoopsModule->getVar("dirname")); |
|
98
|
|
|
// $criteria = new CriteriaCompo(); |
|
99
|
|
|
// $criteria->setSort('_id'); |
|
100
|
|
|
// $criteria->setOrder('ASC'); |
|
101
|
|
|
// $_arr = $Handler->getall(); |
|
102
|
|
|
// $mytree = new XoopsObjectTree($_arr, "_id", "_pid"); |
|
103
|
|
|
// $form->addElement(new XoopsFormLabel(_AM_PEDIGREE_PEDIGREE_CONFIG_LOCKED, $mytree->makeSelBox("_pid", "_title","--", $this->getVar("_pid"),false))); |
|
104
|
|
|
// |
|
105
|
|
|
// include_once(XOOPS_ROOT_PATH."/class/tree.php"); |
|
106
|
|
|
// $Handler =& xoops_getModuleHandler("animal_", $xoopsModule->getVar("dirname")); |
|
107
|
|
|
// $criteria = new CriteriaCompo(); |
|
108
|
|
|
// $criteria->setSort('_id'); |
|
109
|
|
|
// $criteria->setOrder('ASC'); |
|
110
|
|
|
// $_arr = $Handler->getall(); |
|
111
|
|
|
// $mytree = new XoopsObjectTree($_arr, "_id", "_pid"); |
|
112
|
|
|
// $form->addElement(new XoopsFormLabel(_AM_PEDIGREE_PEDIGREE_CONFIG_ORDER, $mytree->makeSelBox("_pid", "_title","--", $this->getVar("_pid"),false))); |
|
113
|
|
|
|
|
114
|
|
|
include_once(XOOPS_ROOT_PATH . "/class/tree.php"); |
|
115
|
|
|
// $Handler =& xoops_getModuleHandler("animal_", $xoopsModule->getVar("dirname")); |
|
|
|
|
|
|
116
|
|
|
$Handler =& xoops_getModuleHandler('fields', $xoopsModule->getVar("dirname")); |
|
117
|
|
|
// $Handler = & $pedigreeFieldsHandler; |
|
|
|
|
|
|
118
|
|
|
$criteria = new CriteriaCompo(); |
|
119
|
|
|
$criteria->setSort('_id'); |
|
120
|
|
|
$criteria->setOrder('ASC'); |
|
121
|
|
|
$_arr = $Handler->getall(); |
|
122
|
|
|
$mytree = new XoopsObjectTree($_arr, "_id", "_pid"); |
|
123
|
|
|
$form->addElement(new XoopsFormLabel(_AM_PEDIGREE_PEDIGREE_CONFIG_LOCKED, $mytree->makeSelBox("_pid", "_title", "--", $this->getVar("_pid"), false))); |
|
124
|
|
|
|
|
125
|
|
|
$form->addElement(new XoopsFormHidden("op", "save_pedigree_config")); |
|
126
|
|
|
|
|
127
|
|
|
//Submit buttons |
|
128
|
|
|
$button_tray = new XoopsFormElementTray("", ""); |
|
129
|
|
|
$submit_button = new XoopsFormButton("", "submit", _SUBMIT, "submit"); |
|
130
|
|
|
$button_tray->addElement($submit_button); |
|
131
|
|
|
|
|
132
|
|
|
$cancel_button = new XoopsFormButton("", "", _CANCEL, "cancel"); |
|
133
|
|
|
$cancel_button->setExtra('onclick="history.go(-1)"'); |
|
134
|
|
|
$button_tray->addElement($cancel_button); |
|
135
|
|
|
|
|
136
|
|
|
$form->addElement($button_tray); |
|
137
|
|
|
|
|
138
|
|
|
return $form; |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Class PedigreeFieldsHandler |
|
144
|
|
|
*/ |
|
145
|
|
|
class PedigreeFieldsHandler extends XoopsPersistableObjectHandler |
|
|
|
|
|
|
146
|
|
|
{ |
|
147
|
|
|
/** |
|
148
|
|
|
* @param null|object $db |
|
149
|
|
|
*/ |
|
150
|
|
|
function __construct(&$db) |
|
|
|
|
|
|
151
|
|
|
{ |
|
152
|
|
|
parent::__construct($db, "pedigree_fields", "PedigreeFields", "ID", "isActive"); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.