| Conditions | 58 |
| Paths | 0 |
| Total Lines | 347 |
| Code Lines | 250 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php declare(strict_types=1); |
||
| 132 | public function getForm($action = false) |
||
| 133 | { |
||
| 134 | $helper = Helper::getInstance(); |
||
| 135 | |||
| 136 | $categoryHandler = $helper->getHandler('Category'); |
||
| 137 | $permissionsHandler = $helper->getHandler('Permission'); |
||
| 138 | |||
| 139 | $utility = new Utility(); |
||
| 140 | |||
| 141 | if (!$action) { |
||
| 142 | $action = $_SERVER['REQUEST_URI']; |
||
| 143 | } |
||
| 144 | $isAdmin = false; |
||
| 145 | $userUid = 0; |
||
| 146 | $userEmail = ''; |
||
| 147 | $userName = ''; |
||
| 148 | if (\is_object($GLOBALS['xoopsUser'])) { |
||
| 149 | if (\is_object($GLOBALS['xoopsModule'])) { |
||
| 150 | $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
||
| 151 | } |
||
| 152 | $userUid = $GLOBALS['xoopsUser']->uid(); |
||
| 153 | $userEmail = $GLOBALS['xoopsUser']->email(); |
||
| 154 | $userName = ('' != (string)$GLOBALS['xoopsUser']->name()) ? $GLOBALS['xoopsUser']->name() : $GLOBALS['xoopsUser']->uname(); |
||
| 155 | } |
||
| 156 | |||
| 157 | $imgInfo = '<img class="wge-img-info" src="' . \WGEVENTS_ICONS_URL_24 . '/info.png" alt="img-info" title="%s">'; |
||
| 158 | |||
| 159 | // Title |
||
| 160 | $title = $this->isNew() ? \_MA_WGEVENTS_EVENT_ADD : \_MA_WGEVENTS_EVENT_EDIT; |
||
| 161 | if ($this->idSource > 0) { |
||
| 162 | $this->unsetNew(); |
||
| 163 | } |
||
| 164 | // Get Theme Form |
||
| 165 | \xoops_load('XoopsFormLoader'); |
||
| 166 | $form = new \XoopsThemeForm($title, 'formEvent', $action, 'post', true); |
||
| 167 | $form->setExtra('enctype="multipart/form-data"'); |
||
| 168 | // Form Text identifier |
||
| 169 | if (!$this->isNew()) { |
||
| 170 | if ($isAdmin) { |
||
| 171 | $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_IDENTIFIER, 'identifier', 50, 255, $this->getVar('identifier'))); |
||
| 172 | } else { |
||
| 173 | $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_EVENT_IDENTIFIER, $this->getVar('identifier'))); |
||
| 174 | $form->addElement(new \XoopsFormHidden('identifier', (string)$this->getVar('identifier'))); |
||
| 175 | } |
||
| 176 | } |
||
| 177 | // Form Table categories |
||
| 178 | $evCatidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_CATID, 'catid', $this->getVar('catid')); |
||
| 179 | $evCatidSelect->addOptionArray($categoryHandler->getAllCatsOnline(Constants::CATEGORY_TYPE_MAIN)); |
||
| 180 | $form->addElement($evCatidSelect); |
||
| 181 | // Form Table sub categories |
||
| 182 | // count sub categories |
||
| 183 | $catsSubOnline = $categoryHandler->getAllCatsOnline(Constants::CATEGORY_TYPE_SUB); |
||
| 184 | if (\count($catsSubOnline) > 0) { |
||
| 185 | $evSubCats = $this->isNew() ? [] : \unserialize($this->getVar('subcats')); |
||
| 186 | $evSubCatsSelect = new \XoopsFormCheckBox(\_MA_WGEVENTS_EVENT_SUBCATS, 'subcats', $evSubCats); |
||
| 187 | $evSubCatsSelect->addOptionArray($catsSubOnline); |
||
| 188 | $form->addElement($evSubCatsSelect); |
||
| 189 | } |
||
| 190 | // Form Text evName |
||
| 191 | $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_NAME, 'name', 50, 255, $this->getVar('name')), true); |
||
| 192 | // Form Editor DhtmlTextArea evDesc |
||
| 193 | $editorConfigs = []; |
||
| 194 | if ($isAdmin) { |
||
| 195 | $editor = $helper->getConfig('editor_admin'); |
||
| 196 | } else { |
||
| 197 | $editor = $helper->getConfig('editor_user'); |
||
| 198 | } |
||
| 199 | $editorConfigs['name'] = 'desc'; |
||
| 200 | $editorConfigs['value'] = $this->getVar('desc', 'e'); |
||
| 201 | $editorConfigs['rows'] = 5; |
||
| 202 | $editorConfigs['cols'] = 40; |
||
| 203 | $editorConfigs['width'] = '100%'; |
||
| 204 | $editorConfigs['height'] = '400px'; |
||
| 205 | $editorConfigs['editor'] = $editor; |
||
| 206 | $form->addElement(new \XoopsFormEditor(\_MA_WGEVENTS_EVENT_DESC, 'desc', $editorConfigs)); |
||
| 207 | // Form Image evLogo |
||
| 208 | // Form Image evLogo: Select Uploaded Image |
||
| 209 | $getEvLogo = $this->getVar('logo'); |
||
| 210 | $evLogo = $getEvLogo ?: 'blank.gif'; |
||
| 211 | $imageDirectory = '/uploads/wgevents/events/logos/' . $userUid; |
||
| 212 | $folderUid = \XOOPS_ROOT_PATH . $imageDirectory; |
||
| 213 | if (!\file_exists($folderUid)) { |
||
| 214 | $utility::createFolder($folderUid); |
||
| 215 | \chmod($folderUid, 0777); |
||
| 216 | $file = \WGEVENTS_PATH . '/assets/images/blank.gif'; |
||
| 217 | $dest = $folderUid . '/blank.gif'; |
||
| 218 | $utility::copyFile($file, $dest); |
||
| 219 | } |
||
| 220 | $imageTray = new Forms\FormElementTray(\_MA_WGEVENTS_EVENT_LOGO, '<br>'); |
||
| 221 | $imageSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_LOGO_UPLOADS, 'logo', $evLogo, 5); |
||
| 222 | $imageArray = \XoopsLists::getImgListAsArray(\XOOPS_ROOT_PATH . $imageDirectory); |
||
| 223 | foreach ($imageArray as $image1) { |
||
| 224 | $imageSelect->addOption(($image1), $image1); |
||
| 225 | } |
||
| 226 | $imageSelect->setExtra("onchange='showImgSelected(\"imglabel_logo\", \"logo\", \"" . $imageDirectory . '", "", "' . \XOOPS_URL . "\")'"); |
||
| 227 | $imageTray->addElement($imageSelect, false); |
||
| 228 | $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='" . \XOOPS_URL . '/' . $imageDirectory . '/' . $evLogo . "' id='imglabel_logo' alt='' style='max-width:100px' >")); |
||
| 229 | // Form Image evLogo: Upload new image |
||
| 230 | $maxsize = $helper->getConfig('maxsize_image'); |
||
| 231 | $imageTray->addElement(new \XoopsFormFile('<br>' . \_AM_WGEVENTS_FORM_UPLOAD_NEW, 'logo', $maxsize)); |
||
| 232 | $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . \_AM_WGEVENTS_FORM_UPLOAD_SIZE_MB)); |
||
| 233 | $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_IMG_WIDTH, $helper->getConfig('maxwidth_image') . ' px')); |
||
| 234 | $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_IMG_HEIGHT, $helper->getConfig('maxheight_image') . ' px')); |
||
| 235 | $form->addElement($imageTray); |
||
| 236 | // Form Tray Datefrom |
||
| 237 | $evDatefromTray = new Forms\FormElementTray(\_MA_WGEVENTS_EVENT_DATEFROM, ' '); |
||
| 238 | // Text Date Select evDatefrom |
||
| 239 | $evDatefrom = ($this->isNew() && 0 == (int)$this->getVar('datefrom')) ? \time() : $this->getVar('datefrom'); |
||
| 240 | $evDatefromTray->addElement(new \XoopsFormDateTime('', 'datefrom', '', $evDatefrom), true); |
||
| 241 | // Text Date Checkbox evAllday |
||
| 242 | $evAllday = $this->isNew() ? 0 : (int)$this->getVar('allday'); |
||
| 243 | $checkAllday = new \XoopsFormCheckBox('', 'allday', $evAllday); |
||
| 244 | $checkAllday->addOption(1, \_MA_WGEVENTS_EVENT_ALLDAY); |
||
| 245 | $checkAllday->setExtra(" onclick='toggleAllday()' "); |
||
| 246 | $evDatefromTray->addElement($checkAllday); |
||
| 247 | $form->addElement($evDatefromTray); |
||
| 248 | // Form Text Date Select evDateto |
||
| 249 | $evDateto = ($this->isNew() && 0 == (int)$this->getVar('dateto')) ? \time() : $this->getVar('dateto'); |
||
| 250 | $form->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_EVENT_DATETO, 'dateto', '', $evDateto)); |
||
| 251 | // Form Text evContact |
||
| 252 | $form->addElement(new \XoopsFormTextArea(\_MA_WGEVENTS_EVENT_CONTACT, 'contact', $this->getVar('contact', 'e'), 4, 30)); |
||
| 253 | // Form Text evEmail |
||
| 254 | $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_EMAIL, 'email', 50, 255, $this->getVar('email'))); |
||
| 255 | // Form Text evUrl |
||
| 256 | $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_URL, 'url', 50, 255, $this->getVar('url'))); |
||
| 257 | // Location |
||
| 258 | // Form Editor TextArea evLocation |
||
| 259 | $evLocation = $this->isNew() ? '' : $this->getVar('location', 'e'); |
||
| 260 | $form->addElement(new \XoopsFormTextArea(\_MA_WGEVENTS_EVENT_LOCATION, 'location', $evLocation, 4, 50)); |
||
| 261 | |||
| 262 | if ($helper->getConfig('use_gmaps')) { |
||
| 263 | $gmapsTray = new Forms\FormElementTray('', '<br>'); |
||
| 264 | // Form Text evLocgmlat |
||
| 265 | $evLocgmlat = $this->isNew() ? '0.00' : $this->getVar('locgmlat'); |
||
| 266 | $gmapsTray->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_LOCGMLAT, 'locgmlat', 20, 50, $evLocgmlat)); |
||
| 267 | // Form Text evLocgmlon |
||
| 268 | $evLocgmlon = $this->isNew() ? '0.00' : $this->getVar('locgmlon'); |
||
| 269 | $gmapsTray->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_LOCGMLON, 'locgmlon', 20, 50, $evLocgmlon)); |
||
| 270 | // Form Text evLocgmzoom |
||
| 271 | $evLocgmzoom = $this->isNew() ? '10' : $this->getVar('locgmzoom'); |
||
| 272 | $gmapsTray->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_LOCGMZOOM, 'locgmzoom', 5, 50, $evLocgmzoom)); |
||
| 273 | // Form label |
||
| 274 | $locLabel = '<div class="row"><div class="col-sm-6">'; |
||
| 275 | $locLabel .= $gmapsTray->render(); |
||
| 276 | $locLabel .= '</div>'; |
||
| 277 | $locLabel .= '<div class="col-sm-6">'; |
||
| 278 | $locLabel .= "<button id='btnGetCoords' type='button' class='btn btn-primary' data-toggle='modal' data-target='#modalCoordsPicker'>" . \_MA_WGEVENTS_EVENT_GM_GETCOORDS . '</button>'; |
||
| 279 | $locLabel .= '</div></div>'; |
||
| 280 | $form->addElement(new \XoopsFormLabel('', $locLabel)); |
||
| 281 | } |
||
| 282 | // Form Text evFee |
||
| 283 | $default0 = '0' . $helper->getConfig('sep_comma') . '00'; |
||
| 284 | $evFeeArr = []; |
||
| 285 | if ($this->isNew()) { |
||
| 286 | $evFeeArr = [[$default0, '', 'placeholder' => \_MA_WGEVENTS_EVENT_FEE_DESC_PH]]; |
||
| 287 | } else { |
||
| 288 | $evFee = \json_decode($this->getVar('fee'), true); |
||
| 289 | foreach($evFee as $fee) { |
||
| 290 | $evFeeArr[] = [Utility::FloatToString((float)$fee[0]), $fee[1], 'placeholder' => \_MA_WGEVENTS_EVENT_FEE_DESC_PH]; |
||
| 291 | } |
||
| 292 | if (0 === \count($evFeeArr)) { |
||
| 293 | $evFeeArr = [[$default0, '', 'placeholder' => \_MA_WGEVENTS_EVENT_FEE_DESC_PH]]; |
||
| 294 | } |
||
| 295 | } |
||
| 296 | $evFeeTray = new Forms\FormElementTray(\_MA_WGEVENTS_EVENT_FEE, '<br>'); |
||
| 297 | $evFeeGroup = new Forms\FormTextDouble('', 'fee', 0, 0, ''); |
||
| 298 | $evFeeGroup->setElements($evFeeArr); |
||
| 299 | $evFeeGroup->setPlaceholder1(\_MA_WGEVENTS_EVENT_FEE_VAL_PH); |
||
| 300 | $evFeeGroup->setPlaceholder2(\_MA_WGEVENTS_EVENT_FEE_DESC_PH); |
||
| 301 | $evFeeTray->addElement($evFeeGroup); |
||
| 302 | |||
| 303 | $form->addElement($evFeeTray); |
||
| 304 | // Form TextArea evPaymentinfo |
||
| 305 | $editorConfigs2 = []; |
||
| 306 | $editorConfigs2['name'] = 'paymentinfo'; |
||
| 307 | $editorConfigs2['value'] = $this->getVar('paymentinfo', 'e'); |
||
| 308 | $editorConfigs2['rows'] = 5; |
||
| 309 | $editorConfigs2['cols'] = 40; |
||
| 310 | $editorConfigs2['width'] = '100%'; |
||
| 311 | $editorConfigs2['height'] = '400px'; |
||
| 312 | $editorConfigs2['editor'] = $editor; |
||
| 313 | $form->addElement(new \XoopsFormEditor(\_MA_WGEVENTS_EVENT_PAYMENTINFO, 'paymentinfo', $editorConfigs2)); |
||
| 314 | |||
| 315 | // Start block registration options |
||
| 316 | if ($helper->getConfig('use_register')) { |
||
| 317 | // Form Radio Yes/No evRegister_use |
||
| 318 | $evRegister_use = $this->isNew() ? 0 : $this->getVar('register_use'); |
||
| 319 | $evRegisterUseRadio = new \XoopsFormRadioYN(\_MA_WGEVENTS_EVENT_REGISTER_USE, 'register_use', $evRegister_use); |
||
| 320 | $evRegisterUseRadio->setExtra(" onclick='toggleRegistrationOpts()' "); |
||
| 321 | $form->addElement($evRegisterUseRadio); |
||
| 322 | $evReservUseTray = new \XoopsFormElementTray('', '<br>'); //double element tray is necessary for proper toggle |
||
| 323 | $evRegisterOptsTray = new Forms\FormElementTray('', '<br>', 'registeropttray'); |
||
| 324 | $evRegisterOptsTray->setClass('col-xs-12 col-sm-5 col-lg-5'); |
||
| 325 | if (!$evRegister_use) { |
||
| 326 | $evRegisterOptsTray->setHidden(); |
||
| 327 | } |
||
| 328 | // Form Text Date Select evRegisterfrom |
||
| 329 | $evRegisterfrom = $this->isNew() ? \time() : $this->getVar('register_from'); |
||
| 330 | $evRegisterOptsTray->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_EVENT_REGISTER_FROM, 'register_from', '', $evRegisterfrom)); |
||
| 331 | // Form Text Date Select evRegisterto |
||
| 332 | $evRegisterto = $this->isNew() ? \time() : $this->getVar('register_to'); |
||
| 333 | $evRegisterOptsTray->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_EVENT_REGISTER_TO, 'register_to', '', $evRegisterto)); |
||
| 334 | // Form Text evRegisterMax |
||
| 335 | $evRegisterMax = $this->isNew() ? 0 : $this->getVar('register_max'); |
||
| 336 | $captionRegisterMax = \_MA_WGEVENTS_EVENT_REGISTER_MAX . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_MAX_DESC); |
||
| 337 | $evRegisterOptsTray->addElement(new \XoopsFormText($captionRegisterMax, 'register_max', 5, 50, $evRegisterMax)); |
||
| 338 | // Form Radio Yes/No evRegisterListwait |
||
| 339 | $evRegisterListwait = $this->isNew() ? 0 : $this->getVar('register_listwait'); |
||
| 340 | $captionRegisterListwait = \_MA_WGEVENTS_EVENT_REGISTER_LISTWAIT . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_LISTWAIT_DESC); |
||
| 341 | $evRegisterOptsTray->addElement(new \XoopsFormRadioYN($captionRegisterListwait, 'register_listwait', $evRegisterListwait)); |
||
| 342 | // Form Select User evRegisterAutoaccept |
||
| 343 | $evRegisterAutoaccept = $this->isNew() ? 0 : $this->getVar('register_autoaccept'); |
||
| 344 | $captionRegisterAutoaccept = \_MA_WGEVENTS_EVENT_REGISTER_AUTOACCEPT . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_AUTOACCEPT_DESC); |
||
| 345 | $evRegisterOptsTray->addElement(new \XoopsFormRadioYN($captionRegisterAutoaccept, 'register_autoaccept', $evRegisterAutoaccept)); |
||
| 346 | // Form Editor TextArea evRegisterNotify |
||
| 347 | $evRegisterNotify = $this->isNew() ? $userEmail : $this->getVar('register_notify', 'e'); |
||
| 348 | $captionRegisterNotify = \_MA_WGEVENTS_EVENT_REGISTER_NOTIFY . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_NOTIFY_DESC); |
||
| 349 | $evRegisterOptsTray->addElement(new \XoopsFormTextArea($captionRegisterNotify, 'register_notify', $evRegisterNotify, 4, 30)); |
||
| 350 | // Form Text evRegisterSendermail |
||
| 351 | $evRegisterSendermail = $this->isNew() ? $userEmail : $this->getVar('register_sendermail'); |
||
| 352 | $captionRegisterSendermail = \_MA_WGEVENTS_EVENT_REGISTER_SENDERMAIL . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_SENDERMAIL_DESC); |
||
| 353 | $evRegisterOptsTray->addElement(new \XoopsFormText($captionRegisterSendermail, 'register_sendermail', 35, 255, $evRegisterSendermail)); |
||
| 354 | // Form Text evRegisterSendername |
||
| 355 | $evRegisterSendername = $this->isNew() ? $userName : $this->getVar('register_sendername'); |
||
| 356 | $captionRegisterSendername = \_MA_WGEVENTS_EVENT_REGISTER_SENDERNAME . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_SENDERNAME_DESC); |
||
| 357 | $evRegisterOptsTray->addElement(new \XoopsFormText($captionRegisterSendername, 'register_sendername', 35, 255, $evRegisterSendername)); |
||
| 358 | // Form Editor TextArea evRegisterSignature |
||
| 359 | $evRegisterSignature = $this->isNew() ? '' : $this->getVar('register_signature', 'e'); |
||
| 360 | $captionRegisterSignature = \_MA_WGEVENTS_EVENT_REGISTER_SIGNATURE . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_SIGNATURE_DESC); |
||
| 361 | $evRegisterOptsTray->addElement(new \XoopsFormTextArea($captionRegisterSignature, 'register_signature', $evRegisterSignature, 4, 30)); |
||
| 362 | // Form Radio Yes/No evRegisterListwait |
||
| 363 | $evRegisterForceverif = $this->isNew() ? 1 : $this->getVar('register_forceverif'); |
||
| 364 | $captionRegisterForceverif = \_MA_WGEVENTS_EVENT_REGISTER_FORCEVERIF . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_FORCEVERIF_DESC); |
||
| 365 | $evRegisterOptsTray->addElement(new \XoopsFormRadioYN($captionRegisterForceverif, 'register_forceverif', $evRegisterForceverif)); |
||
| 366 | |||
| 367 | $evReservUseTray->addElement($evRegisterOptsTray); |
||
| 368 | $form->addElement($evReservUseTray); |
||
| 369 | //$form->addElement(new \XoopsFormLabel('', $evReservUseTray)); |
||
| 370 | // End block registration options |
||
| 371 | } |
||
| 372 | // Form Select evGalid |
||
| 373 | if ($helper->getConfig('use_wggallery')) { |
||
| 374 | /*TODO */ |
||
| 375 | /* |
||
| 376 | $evGalidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_GALID, 'galid', $this->getVar('galid')); |
||
| 377 | $evGalidSelect->addOption('Empty'); |
||
| 378 | $evGalidSelect->addOptionArray($albumHandler->getList()); |
||
| 379 | $form->addElement($evGalidSelect); |
||
| 380 | */ |
||
| 381 | } |
||
| 382 | // Form Select evGroups |
||
| 383 | if ($helper->getConfig('use_groups')) { |
||
| 384 | if ($this->isNew()) { |
||
| 385 | $groups = ['00000']; |
||
| 386 | } else { |
||
| 387 | $groups = \explode("|", $this->getVar('groups')); |
||
| 388 | } |
||
| 389 | $evGroupsSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_GROUPS, 'groups', $groups, 5, true); |
||
| 390 | $evGroupsSelect->addOption('00000', \_MA_WGEVENTS_EVENT_GROUPS_ALL); |
||
| 391 | // Get groups |
||
| 392 | $memberHandler = \xoops_getHandler('member'); |
||
| 393 | $xoopsGroups = $memberHandler->getGroupList(); |
||
| 394 | foreach ($xoopsGroups as $key => $group) { |
||
| 395 | if (3 !== (int)$key) { |
||
| 396 | $evGroupsSelect->addOption(substr('00000' . $key, -5), $group); |
||
| 397 | } |
||
| 398 | } |
||
| 399 | $form->addElement($evGroupsSelect, true); |
||
| 400 | } else { |
||
| 401 | $form->addElement(new \XoopsFormHidden('groups', '00000')); |
||
| 402 | } |
||
| 403 | // Form Select Status evStatus |
||
| 404 | // Form Text Date Select evDatecreated |
||
| 405 | // Form Select User evSubmitter |
||
| 406 | $permEventsApprove = $permissionsHandler->getPermEventsApprove(); |
||
| 407 | $permEventsApproveAuto = $permissionsHandler->getPermEventsApproveAuto(); |
||
| 408 | if ($this->isNew()) { |
||
| 409 | $evStatus = $permEventsApproveAuto ? Constants::STATUS_APPROVED : Constants::STATUS_SUBMITTED; |
||
| 410 | } else { |
||
| 411 | $evStatus = $this->getVar('status'); |
||
| 412 | } |
||
| 413 | $evDatecreated = $this->isNew() ? \time() : (int)$this->getVar('datecreated'); |
||
| 414 | $evSubmitter = $this->isNew() ? $userUid : (int)$this->getVar('submitter'); |
||
| 415 | if ($isAdmin) { |
||
| 416 | $evStatusSelect = new \XoopsFormSelect(\_MA_WGEVENTS_STATUS, 'status', $evStatus); |
||
| 417 | $evStatusSelect->addOption(Constants::STATUS_NONE, \_MA_WGEVENTS_STATUS_NONE); |
||
| 418 | $evStatusSelect->addOption(Constants::STATUS_OFFLINE, \_MA_WGEVENTS_STATUS_OFFLINE); |
||
| 419 | $evStatusSelect->addOption(Constants::STATUS_SUBMITTED, \_MA_WGEVENTS_STATUS_SUBMITTED); |
||
| 420 | $evStatusSelect->addOption(Constants::STATUS_APPROVED, \_MA_WGEVENTS_STATUS_APPROVED); |
||
| 421 | $evStatusSelect->addOption(Constants::STATUS_LOCKED, \_MA_WGEVENTS_STATUS_LOCKED); |
||
| 422 | $evStatusSelect->addOption(Constants::STATUS_CANCELED, \_MA_WGEVENTS_STATUS_CANCELED); |
||
| 423 | $form->addElement($evStatusSelect, true); |
||
| 424 | $form->addElement(new \XoopsFormTextDateSelect(\_MA_WGEVENTS_DATECREATED, 'datecreated', '', $evDatecreated)); |
||
| 425 | $form->addElement(new \XoopsFormSelectUser(\_MA_WGEVENTS_SUBMITTER, 'submitter', false, $evSubmitter)); |
||
| 426 | } else { |
||
| 427 | $form->addElement(new \XoopsFormHidden('status', $evStatus)); |
||
| 428 | $form->addElement(new \XoopsFormHidden('datecreated_int', $evDatecreated)); |
||
| 429 | $form->addElement(new \XoopsFormHidden('submitter', $evSubmitter)); |
||
| 430 | if (!$this->isNew() && $permEventsApprove) { |
||
| 431 | $evStatusSelect = new \XoopsFormSelect(\_MA_WGEVENTS_STATUS, 'status', $evStatus); |
||
| 432 | $evStatusSelect->addOption(Constants::STATUS_NONE, \_MA_WGEVENTS_STATUS_NONE); |
||
| 433 | $evStatusSelect->addOption(Constants::STATUS_OFFLINE, \_MA_WGEVENTS_STATUS_OFFLINE); |
||
| 434 | $evStatusSelect->addOption(Constants::STATUS_SUBMITTED, \_MA_WGEVENTS_STATUS_SUBMITTED); |
||
| 435 | $evStatusSelect->addOption(Constants::STATUS_APPROVED, \_MA_WGEVENTS_STATUS_APPROVED); |
||
| 436 | $form->addElement($evStatusSelect, true); |
||
| 437 | $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_DATECREATED, \formatTimestamp($evDatecreated, 's'))); |
||
| 438 | $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_SUBMITTER, \XoopsUser::getUnameFromId($evSubmitter))); |
||
| 439 | } |
||
| 440 | } |
||
| 441 | if ($this->idSource > 0 && $helper->getConfig('use_register')) { |
||
| 442 | $form->addElement(new \XoopsFormRadioYN(\_MA_WGEVENTS_EVENT_CLONE_QUESTION, 'clone_question', 1)); |
||
| 443 | $form->addElement(new \XoopsFormHidden('id_source', $this->idSource)); |
||
| 444 | } |
||
| 445 | if (!$this->isNew() && 0 === $this->idSource) { |
||
| 446 | $informModif = new \XoopsFormRadioYN(\_MA_WGEVENTS_EVENT_INFORM_MODIF, 'informModif', 0); |
||
| 447 | $informModif->setDescription(\_MA_WGEVENTS_EVENT_INFORM_MODIF_DESC); |
||
| 448 | $form->addElement($informModif); |
||
| 449 | } |
||
| 450 | // To Save |
||
| 451 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||
| 452 | $form->addElement(new \XoopsFormHidden('start', $this->start)); |
||
| 453 | $form->addElement(new \XoopsFormHidden('limit', $this->limit)); |
||
| 454 | $form->addElement(new \XoopsFormHidden('cats', $this->cats)); |
||
| 455 | // button tray |
||
| 456 | $buttonTray = new \XoopsFormElementTray(''); |
||
| 457 | $buttonBack = new Forms\FormButton('', 'confirm_back', \_CANCEL, 'button'); |
||
| 458 | $buttonBack->setExtra('onclick="history.go(-1);return true;"'); |
||
| 459 | $buttonBack->setClass('btn-danger'); |
||
| 460 | $buttonTray->addElement($buttonBack); |
||
| 461 | |||
| 462 | $buttonReset = new Forms\FormButton('', 'reset', \_RESET, 'reset'); |
||
| 463 | $buttonReset->setClass('btn-warning'); |
||
| 464 | $buttonTray->addElement($buttonReset); |
||
| 465 | |||
| 466 | $buttonSubmit = new Forms\FormButton('', '_submit', \_MA_WGEVENTS_SAVE, 'submit'); |
||
| 467 | $buttonSubmit->setClass('btn-primary'); |
||
| 468 | $buttonTray->addElement($buttonSubmit); |
||
| 469 | |||
| 470 | $buttonNext = new Forms\FormButton('', 'continue_questions', \_MA_WGEVENTS_CONTINUE_QUESTIONY, 'submit'); |
||
| 471 | $buttonNext->setClass('btn-primary'); |
||
| 472 | if (!$evRegister_use) { |
||
| 473 | $buttonNext->setHidden(); |
||
| 474 | } |
||
| 475 | $buttonTray->addElement($buttonNext); |
||
| 476 | $form->addElement($buttonTray); |
||
| 477 | |||
| 478 | return $form; |
||
| 479 | } |
||
| 723 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: