mambax7 /
pedigree
| 1 | <?php namespace XoopsModules\Pedigree; |
||||
| 2 | |||||
| 3 | /* |
||||
| 4 | You may not change or alter any portion of this comment or credits |
||||
| 5 | of supporting developers from this source code or any supporting source code |
||||
| 6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 7 | |||||
| 8 | This program is distributed in the hope that it will be useful, |
||||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 11 | */ |
||||
| 12 | /** |
||||
| 13 | * Pedigree module for XOOPS |
||||
| 14 | * |
||||
| 15 | * @copyright {@link https://xoops.org/ The XOOPS Project} |
||||
| 16 | * @license GPL 2.0 or later |
||||
| 17 | * @package pedigree |
||||
| 18 | * @author XOOPS Module Dev Team |
||||
| 19 | */ |
||||
| 20 | |||||
| 21 | use XoopsModules\Pedigree; |
||||
| 22 | |||||
| 23 | defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||||
| 24 | |||||
| 25 | /** |
||||
| 26 | * Class Pedigree\Fields |
||||
| 27 | */ |
||||
| 28 | class Fields extends \XoopsObject |
||||
| 29 | { |
||||
| 30 | /** |
||||
| 31 | * Constructor |
||||
| 32 | */ |
||||
| 33 | public function __construct() |
||||
| 34 | { |
||||
| 35 | parent::__construct(); |
||||
| 36 | $this->initVar('id', XOBJ_DTYPE_INT, null, false, 2); |
||||
| 37 | $this->initVar('isaActive', XOBJ_DTYPE_INT, 1, false, 1); |
||||
| 38 | $this->initVar('fieldName', XOBJ_DTYPE_TXTBOX, null, false, 50); |
||||
| 39 | $this->initVar('fieldType', XOBJ_DTYPE_ENUM, 'textbox', false); |
||||
| 40 | $this->initVar('lookupTable', XOBJ_DTYPE_INT, 0, false, 1); |
||||
| 41 | $this->initVar('defaultValue', XOBJ_DTYPE_TXTBOX, null, false, 50); |
||||
| 42 | $this->initVar('fieldExplanation', XOBJ_DTYPE_TXTAREA, null, false); |
||||
| 43 | $this->initVar('hasSearch', XOBJ_DTYPE_INT, 0, false, 1); |
||||
| 44 | $this->initVar('litter', XOBJ_DTYPE_INT, 0, false, 1); |
||||
| 45 | $this->initVar('generalLitter', XOBJ_DTYPE_INT, 1, false, 1); |
||||
| 46 | $this->initVar('searchName', XOBJ_DTYPE_TXTBOX, null, false, 50); |
||||
| 47 | $this->initVar('searchExplanation', XOBJ_DTYPE_TXTAREA, null, false); |
||||
| 48 | $this->initVar('viewInPedigree', XOBJ_DTYPE_INT, 1, false, 1); |
||||
| 49 | $this->initVar('viewInAdvanced', XOBJ_DTYPE_INT, 1, false, 1); |
||||
| 50 | $this->initVar('viewInPie', XOBJ_DTYPE_INT, 1, false, 1); |
||||
| 51 | $this->initVar('viewInList', XOBJ_DTYPE_INT, 1, false, 1); |
||||
| 52 | $this->initVar('locked', XOBJ_DTYPE_INT, 0, false, 1); |
||||
| 53 | $this->initVar('order', XOBJ_DTYPE_INT, 0, false, 3); |
||||
| 54 | } |
||||
| 55 | |||||
| 56 | /** |
||||
| 57 | * @param bool $action |
||||
| 58 | * |
||||
| 59 | * @todo refactor to eliminate XoopsObjectTree since it's not structured to |
||||
| 60 | * handle this type of object |
||||
| 61 | * |
||||
| 62 | * @return object {@see XoopsThemeForm} |
||||
| 63 | */ |
||||
| 64 | public function getForm($action = false) |
||||
| 65 | { |
||||
| 66 | if (false === $action) { |
||||
| 67 | $action = $_SERVER['REQUEST_URI']; |
||||
| 68 | } |
||||
| 69 | |||||
| 70 | $title = $this->isNew() ? sprintf(_AM_PEDIGREE_PEDIGREE_CONFIG_ADD) : sprintf(_AM_PEDIGREE_PEDIGREE_CONFIG_EDIT); |
||||
| 71 | |||||
| 72 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||||
| 73 | |||||
| 74 | $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
||||
| 75 | $form->setExtra('enctype="multipart/form-data"'); |
||||
| 76 | |||||
| 77 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_FIELDNAME, 'fieldName', 50, 255, $this->getVar('FieldName')), true); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 78 | $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_ISACTIVE, 'isActive', (int)$this->getVar('isActive')), false); |
||||
| 79 | $fieldTypes = new \XoopsFormSelect(_AM_PEDIGREE_PEDIGREE_CONFIG_FIELDTYPE, 'fieldType', $this->getVar('FieldType'), false); |
||||
|
0 ignored issues
–
show
false of type false is incompatible with the type integer expected by parameter $size of XoopsFormSelect::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 80 | $fieldTypes->addOptionArray([ |
||||
| 81 | 'DateSelect' => 'DateSelect', |
||||
| 82 | 'Picture' => 'Picture', |
||||
| 83 | 'radiobutton' => 'radiobutton', |
||||
| 84 | 'selectbox' => 'selectbox', |
||||
| 85 | 'textarea' => 'textarea', |
||||
| 86 | 'textbox' => 'textbox', |
||||
| 87 | 'urlfield' => 'urlfield' |
||||
| 88 | ]); |
||||
| 89 | $form->addElement($fieldTypes); |
||||
| 90 | // $form->addElement(new \XoopsFormTextArea(_AM_PEDIGREE_PEDIGREE_CONFIG_FIELDTYPE, "FieldType", $this->getVar("FieldType"), 4, 47), false); |
||||
| 91 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_LOOKUPTABLE, 'lookupTable', 50, 255, $this->getVar('LookupTable')), false); |
||||
| 92 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_DEFAULTVALUE, 'defaultValue', 50, 255, $this->getVar('DefaultValue')), false); |
||||
| 93 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_FIELDEXPLANATION, 'fieldExplanation', 50, 255, $this->getVar('FieldExplanation')), false); |
||||
| 94 | $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_HASSEARCH, 'hasSearch', (int)$this->getVar('HasSearch')), false); |
||||
| 95 | /* @todo: should be single select for either General Litter or Litter, can't have both */ |
||||
| 96 | $currentType = $this->getVar('litter') ? 'litter' : 'generallitter'; |
||||
| 97 | $litterRadio = new \XoopsFormRadio(_AM_PEDIGREE_PEDIGREE_CONFIG_LITTER_TYPE, 'litterType', $currentType); |
||||
| 98 | $litterRadio->addOptionArray([ |
||||
| 99 | 'litter' => _AM_PEDIGREE_PEDIGREE_CONFIG_LITTER, |
||||
| 100 | 'generallitter' => _AM_PEDIGREE_PEDIGREE_CONFIG_GENERALLITTER |
||||
| 101 | ]); |
||||
| 102 | $form->addElement($litterRadio, false); |
||||
| 103 | // $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_LITTER, "Litter", $this->getVar("Litter")), false); |
||||
| 104 | // $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_GENERALLITTER, "Generallitter", $this->getVar("Generallitter")), false); |
||||
| 105 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_SEARCHNAME, 'searchName', 50, 255, $this->getVar('SearchName')), false); |
||||
| 106 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_SEARCHEXPLANATION, 'searchExplanation', 50, 255, $this->getVar('SearchExplanation')), false); |
||||
| 107 | $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINPEDIGREE, 'viewInPedigree', (int)$this->getVar('viewinpedigree')), false); |
||||
| 108 | $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINADVANCED, 'viewInAdvanced', (int)$this->getVar('ViewInAdvanced')), false); |
||||
| 109 | $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINPIE, 'viewInPie', (int)$this->getVar('ViewInPie')), false); |
||||
| 110 | $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINLIST, 'viewInList', (int)$this->getVar('ViewInList')), false); |
||||
| 111 | $form->addElement(new \XoopsFormRadioYN(_AM_PEDIGREE_PEDIGREE_CONFIG_LOCKED, 'locked', (int)$this->getVar('locked')), false); |
||||
| 112 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_CONFIG_ORDER, 'order', 3, 8, (int)$this->getVar('order')), false); |
||||
| 113 | // include_once(XOOPS_ROOT_PATH."/class/tree.php"); |
||||
| 114 | // $Handler = xoops_getModuleHandler("animal_", $GLOBALS['xoopsDB']->getVar("dirname")); |
||||
| 115 | // $criteria = new \CriteriaCompo(); |
||||
| 116 | // $criteria->setSort('_id'); |
||||
| 117 | // $criteria->setOrder('ASC'); |
||||
| 118 | // $_arr = $Handler->getAll(); |
||||
| 119 | // $mytree = new \XoopsObjectTree($_arr, "_id", "_pid"); |
||||
| 120 | // $form->addElement(new \XoopsFormLabel(_AM_PEDIGREE_PEDIGREE_CONFIG_LOCKED, $mytree->makeSelBox("_pid", "_title","--", $this->getVar("_pid"),false))); |
||||
| 121 | // |
||||
| 122 | // include_once(XOOPS_ROOT_PATH."/class/tree.php"); |
||||
| 123 | // $Handler = xoops_getModuleHandler("animal_", $GLOBALS['xoopsModule']->getVar("dirname")); |
||||
| 124 | // $criteria = new \CriteriaCompo(); |
||||
| 125 | // $criteria->setSort('_id'); |
||||
| 126 | // $criteria->setOrder('ASC'); |
||||
| 127 | // $_arr = $Handler->getAll(); |
||||
| 128 | // $mytree = new \XoopsObjectTree($_arr, "_id", "_pid"); |
||||
| 129 | // $form->addElement(new \XoopsFormLabel(_AM_PEDIGREE_PEDIGREE_CONFIG_ORDER, $mytree->makeSelBox("_pid", "_title","--", $this->getVar("_pid"),false))); |
||||
| 130 | /* |
||||
| 131 | require_once $GLOBALS['xoops']->path("class/tree.php"); |
||||
| 132 | // $Handler = xoops_getModuleHandler("animal_", $GLOBALS['xoopsModule']->getVar("dirname")); |
||||
| 133 | $Handler = Pedigree\Helper::getInstance()->getHandler('Fields'); |
||||
| 134 | // $Handler = & $fieldsHandler; |
||||
| 135 | $criteria = new \CriteriaCompo(); |
||||
| 136 | $criteria->setSort('id'); |
||||
| 137 | $criteria->setOrder('ASC'); |
||||
| 138 | $_arr = $Handler->getAll(); |
||||
| 139 | $mytree = new \XoopsObjectTree($_arr, "ID", "_pid"); |
||||
| 140 | $form->addElement(new \XoopsFormLabel(_AM_PEDIGREE_PEDIGREE_CONFIG_LOCKED, $mytree->makeSelBox("_pid", "_title", "--", $this->getVar("_pid"), false))); |
||||
| 141 | */ |
||||
| 142 | $form->addElement(new \XoopsFormHidden('op', 'save_pedigree_config')); |
||||
| 143 | |||||
| 144 | //Submit buttons |
||||
| 145 | $form->addElement(new \XoopsFormButtonTray('fieldButtons', _SUBMIT, 'submit')); |
||||
| 146 | |||||
| 147 | /* |
||||
| 148 | $button_tray = new \XoopsFormElementTray("", ""); |
||||
| 149 | $submit_button = new \XoopsFormButton("", "submit", _SUBMIT, "submit"); |
||||
| 150 | $button_tray->addElement($submit_button); |
||||
| 151 | |||||
| 152 | $cancel_button = new \XoopsFormButton("", "", _CANCEL, "cancel"); |
||||
| 153 | $cancel_button->setExtra('onclick="history.go(-1)"'); |
||||
| 154 | $button_tray->addElement($cancel_button); |
||||
| 155 | |||||
| 156 | $form->addElement($button_tray); |
||||
| 157 | */ |
||||
| 158 | |||||
| 159 | return $form; |
||||
| 160 | } |
||||
| 161 | |||||
| 162 | /** |
||||
| 163 | * @return bool |
||||
| 164 | */ |
||||
| 165 | public function isActive() |
||||
| 166 | { |
||||
| 167 | return (1 == $this->getVar('isActive'));// ? true : false; |
||||
| 168 | } |
||||
| 169 | |||||
| 170 | /** |
||||
| 171 | * @return bool |
||||
| 172 | */ |
||||
| 173 | public function inAdvanced() |
||||
| 174 | { |
||||
| 175 | return (1 == $this->getVar('viewInAdvanced'));// ? true : false; |
||||
| 176 | } |
||||
| 177 | |||||
| 178 | /** |
||||
| 179 | * @return bool |
||||
| 180 | */ |
||||
| 181 | public function isLocked() |
||||
| 182 | { |
||||
| 183 | return (1 == $this->getVar('locked'));// ? true : false; |
||||
| 184 | } |
||||
| 185 | |||||
| 186 | /** |
||||
| 187 | * @return bool |
||||
| 188 | */ |
||||
| 189 | public function hasSearch() |
||||
| 190 | { |
||||
| 191 | return (1 == $this->getVar('hasSearch'));// ? true : false; |
||||
| 192 | } |
||||
| 193 | |||||
| 194 | /** |
||||
| 195 | * @return bool |
||||
| 196 | */ |
||||
| 197 | public function addLitter() |
||||
| 198 | { |
||||
| 199 | return (1 == $this->getVar('litter'));// ? true : false; |
||||
| 200 | } |
||||
| 201 | |||||
| 202 | /** |
||||
| 203 | * @return bool |
||||
| 204 | */ |
||||
| 205 | public function generalLitter() |
||||
| 206 | { |
||||
| 207 | return (1 == $this->getVar('generalLitter'));// ? true : false; |
||||
| 208 | } |
||||
| 209 | |||||
| 210 | /** |
||||
| 211 | * @return bool |
||||
| 212 | */ |
||||
| 213 | public function hasLookup() |
||||
| 214 | { |
||||
| 215 | return (1 == $this->getVar('lookupTable'));// ? true : false; |
||||
| 216 | } |
||||
| 217 | |||||
| 218 | /** |
||||
| 219 | * @return string |
||||
| 220 | */ |
||||
| 221 | public function getSearchString() |
||||
| 222 | { |
||||
| 223 | return '&o=naam&p'; |
||||
| 224 | } |
||||
| 225 | |||||
| 226 | /** |
||||
| 227 | * @return bool |
||||
| 228 | */ |
||||
| 229 | public function inPie() |
||||
| 230 | { |
||||
| 231 | return (1 == $this->getVar('viewInPie'));// ? true : false; |
||||
| 232 | } |
||||
| 233 | |||||
| 234 | /** |
||||
| 235 | * @return bool |
||||
| 236 | */ |
||||
| 237 | public function inPedigree() |
||||
| 238 | { |
||||
| 239 | return (1 == $this->getVar('viewInPedigree'));// ? true : false; |
||||
| 240 | } |
||||
| 241 | |||||
| 242 | /** |
||||
| 243 | * @return bool |
||||
| 244 | */ |
||||
| 245 | public function inList() |
||||
| 246 | { |
||||
| 247 | return (1 == $this->getVar('viewInList'));// ? true : false; |
||||
| 248 | } |
||||
| 249 | |||||
| 250 | /** |
||||
| 251 | * @return int|mixed |
||||
| 252 | */ |
||||
| 253 | public function getId() |
||||
| 254 | { |
||||
| 255 | $id = $this->getVar('id'); |
||||
| 256 | |||||
| 257 | return !empty($id) ? $id : 0; |
||||
| 258 | } |
||||
| 259 | |||||
| 260 | /** |
||||
| 261 | * @deprecated |
||||
| 262 | * @param $setting |
||||
| 263 | * |
||||
| 264 | * @return mixed |
||||
| 265 | */ |
||||
| 266 | public function getSetting($setting) |
||||
| 267 | { |
||||
| 268 | return isset($this->$setting) ? $this->setting : null; |
||||
|
0 ignored issues
–
show
|
|||||
| 269 | } |
||||
| 270 | } |
||||
| 271 |