protected function getRecordsByControls(LBoxFormControlMultiple $control) { try { $filter = array(); foreach ($control->getControls() as $ctrlName => $control) { $filter[$ctrlName] = $control->getValue(); } return new XTUsersRecords($filter); } catch (Exception $e) { throw $e; } }
/** * getter na form * @return LBoxForm */ public function getForm() { try { if ($this->form instanceof LBoxForm) { return $this->form; } $ctrls["name"] = new LBoxFormControlFill("name", "jméno", "", LBoxConfigManagerProperties::getPropertyContentByName("form_max_length_name")); $ctrls["name"]->setTemplateFileName("lbox_form_control_first_name.html"); $ctrls["name"]->setRequired(); $ctrls["surname"] = new LBoxFormControlFill("surname", "příjmení", "", LBoxConfigManagerProperties::getPropertyContentByName("form_max_length_surname")); $ctrls["surname"]->setTemplateFileName("lbox_form_control_surname.html"); $ctrls["surname"]->setRequired(); $ctrls["company"] = new LBoxFormControlFill("company", "firma", "", LBoxConfigManagerProperties::getPropertyContentByName("form_max_length_company")); $ctrls["phone"] = new LBoxFormControlFill("phone", "telefon"); $ctrls["phone"]->setTemplateFileName("lbox_form_control_phone.html"); $ctrls["phone"]->addFilter(new LBoxFormFilterEraseSpaces()); $ctrls["phone"]->addFilter(new LBoxFormFilterPhoneNumberCS()); $ctrls["phone"]->addValidator(new LBoxFormValidatorPhone()); $ctrls["email"] = new LBoxFormControlFill("email", "email", "", LBoxConfigManagerProperties::getPropertyContentByName("form_max_length_email")); $ctrls["email"]->setTemplateFileName("lbox_form_control_email.html"); $ctrls["email"]->setRequired(); $ctrls["email"]->addValidator(new LBoxFormValidatorEmail()); $ctrls["message"] = new LBoxFormControlFill("message", "zpráva"); $ctrls["message"]->setTemplateFileName("lbox_form_control_message.html"); $ctrls["message"]->setRequired(); $ctrlGroup = new LBoxFormControlMultiple("contact-info"); foreach ($ctrls as $name => $ctrl) { if ($name == "message") { continue; } $ctrlGroup->addControl($ctrl); } $form = new LBoxForm("contact"); $form->setTemplateFileName("lbox_form_contact.html"); $form->addProcessor(new LBoxFormProcessorContact()); $form->addProcessor(new LBoxFormProcessorContactStoreToDB()); $form->addControl($ctrlGroup); $form->addControl($ctrls["message"]); return $this->form = $form; } catch (Exception $e) { throw $e; } }
/** * getter na form * @return LBoxForm */ public function getForm() { try { if (count($this->processors) < 1) { $this->processors[] = new ProcessorLogin(); } if (count($this->validators) < 1) { $this->validators[] = new LBoxFormValidatorLogin(); } $controlEmail = new LBoxFormControlFill("email", "e-mail", "", LBoxConfigManagerProperties::getPropertyContentByName("form_max_length_email")); $controlEmail->setTemplateFileName("lbox_form_control_email.html"); $controlEmail->setRequired(); $controlPassword = new LBoxFormControlPassword("password", "heslo", "", LBoxConfigManagerProperties::getPropertyContentByName("form_max_length_password")); $controlPassword->setRequired(); $controlsLogin = new LBoxFormControlMultiple("form", "controls"); $controlsLogin->setTemplateFileName("lbox_form_control_multi_login.html"); $controlsLogin->addControl($controlEmail); $controlsLogin->addControl($controlPassword); foreach ($this->validators as $validator) { $controlsLogin->addValidator($validator); } $form = new LBoxForm("login", "post", "Přihlášení uživatele", "přihlásit"); $form->setTemplateFileName("lbox_form_login.html"); $form->addControl($controlsLogin); $form->setAntiSpam(true); foreach ($this->processors as $processor) { $form->addProcessor($processor); } return $this->form = $form; } catch (Exception $e) { throw $e; } }
public function getForm() { try { if ($this->form instanceof LBoxForm) { return $this->form; } $rType = is_string($this->record) ? $this->record : get_class($this->record); $record = $this->record; $idColName = eval("return {$rType}::\$idColName;"); $formID = "metarecord-{$rType}-" . ($this->record->isInDatabase() ? $this->record->{$idColName} : ""); $subCtrls["type"] = new LBoxFormControlFillHidden("type", "", $rType); $subCtrls["type"]->setTemplateFileName("metarecord_hidden.html"); $subCtrls[$idColName] = new LBoxFormControlFillHidden($idColName, "", $this->record->isInDatabase() ? $this->record->{$idColName} : ""); $subCtrls[$idColName]->setTemplateFileName("metarecord_hidden.html"); $reloadOnComplete = false; //nasazet tam jednotlive record attributes foreach ($record->getAttributes() as $attribute) { if (array_key_exists("visibility", $attribute) && $attribute["visibility"] == "protected") { continue; } $attName = $attribute["name"]; $default = $attribute["default"]; $type = $attribute["type"]; $validatorType = "LBoxFormValidatorMetarecord" . ucfirst($type); $filterType = "LBoxFormFilterMetarecord" . ucfirst($type); if (array_key_exists("reference", $attribute)) { switch (true) { case strlen($recordRefType = $attribute["reference"]["type"]) < 1: throw new LBoxExceptionMetaRecords("type: " . LBoxExceptionMetaRecords::MSG_BAD_DEFINITION_REFERENCE, LBoxExceptionMetaRecords::CODE_BAD_DEFINITION_REFERENCE); break; case strlen($recordRefLabel = $attribute["reference"]["label"]) < 1: throw new LBoxExceptionMetaRecords("label: " . LBoxExceptionMetaRecords::MSG_BAD_DEFINITION_REFERENCE, LBoxExceptionMetaRecords::CODE_BAD_DEFINITION_REFERENCE); break; } $testR = new $recordRefType(); if ($testR instanceof AbstractRecords) { $recordRefType = eval("return {$recordRefType}::\$itemType;"); } $recordsRefType = eval("return {$recordRefType}::\$itemsType;"); $recordIDColName = eval("return {$recordRefType}::\$idColName;"); $testR = new $recordRefType(); switch (true) { // image reference case $testR instanceof PhotosRecord: $reloadOnComplete = true; if ($this->record->isInDatabase() && $this->record->{$attName}) { $recordsPhotoReference = new $recordsRefType(array($recordIDColName => $this->record->{$attName})); if ($recordsPhotoReference->count() < 1) { throw new LBoxExceptionMetaRecords(LBoxExceptionMetaRecords::MSG_BAD_DATA_REFERENCE_IMAGE, LBoxExceptionMetaRecords::CODE_BAD_DATA_REFERENCE_IMAGE); } $recordsPhotoReference->setOutputFilterItemsClass(array_key_exists("of", $attribute["reference"]) ? $attribute["reference"]["of"] : "OutputFilterPhoto"); $subCtrls[$attName] = new LBoxFormControlBool($attName, "delete {$attName}"); $subCtrls[$attName]->setTemplateFileName("metarecord_photo_delete.html"); $subCtrls[$attName]->photo = $recordsPhotoReference->current(); $subCtrls[$attName]->action = "image-remove"; } else { $subCtrls[$attName] = new LBoxFormControlFile($attName, $attName); $subCtrls[$attName]->setTemplateFilename("metarecord_photo.html"); $subCtrls[$attName]->addValidator(new LBoxFormValidatorFileImage()); $subCtrls[$attName]->action = "image-add"; } break; // other references // other references default: $records = new $recordsRefType(false, array($recordRefLabel => 1)); $recordsIDColName = eval("return {$recordRefType}::\$idColName;"); $optionsPrepend = $attribute["required"] ? array() : array(" " => " "); $subCtrls[$attName] = new LBoxFormControlChooseOneFromRecords($attName, $attName, $this->record->isInDatabase() ? $this->record->{$attName} : $default, $records, $colnameValue = $recordsIDColName, $recordRefLabel, $colnameTitle = "", $optionsPrepend); $subCtrls[$attName]->setTemplateFilename("metarecord_reference.html"); } } else { $subCtrls[$attName] = new LBoxFormControlFill($attName, $attName, $this->record->isInDatabase() ? $this->record->{$attName} : $default); $subCtrls[$attName]->setTemplateFilename("metarecord_" . $attribute["type"] . ".html"); } $subCtrls[$attName]->addFilter(new LBoxFormFilterTrim()); $subCtrls[$attName]->addFilter(new $filterType()); $subCtrls[$attName]->addValidator(new $validatorType()); if ($attribute["required"]) { $subCtrls[$attName]->setRequired(true); } } $subCtrls["action_reload_on_complete"] = new LBoxFormControlFillHidden("action_reload_on_complete", "", (int) $reloadOnComplete); // vlozime ho do dialog boxu pro JS GUI $ctrlDialog = new LBoxFormControlMultiple("dialog", ""); $ctrlDialog->setTemplateFileName("metarecord_dialog.html"); foreach ($subCtrls as $subCtrl) { $ctrlDialog->addControl($subCtrl); } $form = new LBoxForm($formID, "post", "", "editovat"); $form->setTemplateFileName("metarecord_xt_edit.html"); $form->action = LBoxConfigSystem::getInstance()->getParamByPath("metarecords/api/url"); $form->addControl($ctrlDialog); $form->addProcessor(new ProcessorMetaRecordEdit()); $form->className = "metarecord metarecord-{$rType}"; return $this->form = $form; } catch (Exception $e) { throw $e; } }
/** * getter na editacni form pro AJAX GUI * @return LBoxForm */ public function getForm() { try { if (!$this->isActive()) { return NULL; } if ($this->form instanceof LBoxForm) { return $this->form; } $type = get_class($this); $nodeType = eval("return {$type}::TYPE;"); $nodeControlClassName = eval("return {$type}::XT_FORM_CTRL_CLASSNAME;"); $nodeControlTemplate = eval("return {$type}::XT_FORM_CTRL_TEMPLATE_FILENAME;"); $seq = $this->seq; $callerID = $this->caller->id; $formID = "metanode-{$callerID}-{$seq}-{$nodeType}"; $ctrlType = new LBoxFormControlFillHidden("type", "", $nodeType); $ctrlType->setTemplateFileName("metanode_hidden.html"); $ctrlSeq = new LBoxFormControlFillHidden("seq", "", $seq); $ctrlSeq->setTemplateFileName("metanode_hidden.html"); $ctrlCallerID = new LBoxFormControlFillHidden("caller_id", "", $callerID); $ctrlCallerID->setTemplateFileName("metanode_hidden.html"); $ctrlCallerType = new LBoxFormControlFillHidden("caller_type", "", $this->caller instanceof LBoxPage || $this->caller instanceof PageList ? "page" : "component"); $ctrlCallerType->setTemplateFileName("metanode_hidden.html"); $ctrlLng = new LBoxFormControlFillHidden("lng", "", LBoxFront::getDisplayLanguage()); $ctrlLng->setTemplateFileName("metanode_hidden.html"); $ctrlContent = new $nodeControlClassName("content", "", $this->getContent()); $ctrlContent->setTemplateFileName($nodeControlTemplate); // vlozime ho do dialog boxu pro JS GUI $ctrlDialog = new LBoxFormControlMultiple("dialog", ""); $ctrlDialog->setTemplateFileName("metanode_dialog.html"); $ctrlDialog->addControl($ctrlContent); $this->form = new LBoxForm($formID, "post", "", "editovat"); $this->form->setTemplateFileName("metanode_xt_toedit.html"); $this->form->action = LBoxConfigSystem::getInstance()->getParamByPath("metanodes/api/url"); $this->form->addControl($ctrlDialog); $this->form->addProcessor(new ProcessorMetanodeXTToEdit()); $this->form->className = "metanode"; $this->form->addControl($ctrlType); $this->form->addControl($ctrlSeq); $this->form->addControl($ctrlCallerID); $this->form->addControl($ctrlCallerType); $this->form->addControl($ctrlLng); return $this->form; } catch (Exception $e) { throw $e; } }