Ejemplo n.º 1
0
 protected function executePrepend(PHPTAL $TAL)
 {
     //DbControl::$debug = true;
     try {
         parent::executePrepend($TAL);
         // controls
         $default = "";
         $control1_1 = new LBoxFormControlFill($name = "control-1-1", $label = "", $default);
         $control1_2 = new LBoxFormControlFill($name = "control-1-2", $label = "", $default);
         $control2_1 = new LBoxFormControlFill($name = "control-2-1", $label = "", $default);
         $control2_2 = new LBoxFormControlFill($name = "control-2-2", $label = "", $default);
         $control1_1->setTemplateFileName("lbox_form_control_fill_dev.html");
         $control1_2->setTemplateFileName("lbox_form_control_fill_dev.html");
         $control2_1->setTemplateFileName("lbox_form_control_fill_dev.html");
         $control2_2->setTemplateFileName("lbox_form_control_fill_dev.html");
         // sub forms
         $formStep1 = new LBoxForm("form-step-1");
         $formStep2 = new LBoxForm("form-step-2");
         $formStep1->addControl($control1_1);
         $formStep1->addControl($control1_2);
         $formStep2->addControl($control2_1);
         $formStep2->addControl($control2_2);
         // global form
         $form = new LBoxFormMultistep("form-multistep");
         $form->addProcessor(new LBoxFormProcessorDevMultiple());
         $form->addForm($formStep1);
         $form->addForm($formStep2);
         /*$formStep1	->setDoNotReload();
         		$formStep2	->setDoNotReload();
         		$form		->setDoNotReload();*/
         $TAL->form = $form;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 2
0
 /**
  * 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;
     }
 }
Ejemplo n.º 3
0
 /**
  * preneseni commit success z formu na validatory
  */
 public function commitProcessSuccess()
 {
     try {
         foreach ($this->validators as $validator) {
             $validator->commitProcessSuccess();
         }
         // uchovat hodnotu pro pripadnou persistenci
         $_SESSION["LBox"]["Forms"][$this->form->getName()]["Controls"][$this->getName()]["value"][LBoxFront::getPage()->url] = $this->getValue();
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 4
0
 /**
  * @return LBoxForm
  */
 public function getForm()
 {
     try {
         if ($this->form instanceof LBoxForm) {
             return $this->form;
         }
         $controls["text"] = new LBoxFormControlFill("text", "text");
         $controls["text"]->addFilter(new LBoxFormFilterTrim());
         $controls["text"]->addValidator(new ValidatorURLParam());
         $controls["leaveempty"] = new LBoxFormControlFill("leaveempty", "leave empty");
         $controls["leaveempty"]->setRequired();
         $this->form = new LBoxForm("test");
         foreach ($controls as $control) {
             $this->form->addControl($control);
         }
         $this->form->addProcessor(new LBoxFormProcessorDev());
         return $this->form;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 5
0
 /**
  * getter na form editace ankety
  * @return LBoxForm
  */
 public function getForm()
 {
     try {
         if ($this->form instanceof LBoxForm) {
             return $this->form;
         }
         $controls["is_active"] = new LBoxFormControlBool("is_active", "Aktivní", $this->getInquiry() ? $this->getInquiry()->is_active : 0);
         $controls["question"] = new LBoxFormControlFill("question", "Otázka", $this->getInquiry() ? $this->getInquiry()->question : "");
         $controls["question"]->setTemplateFileName("lbox_form_control_admin_inquiry_question.html");
         $controls["question"]->addFilter(new LBoxFormFilterTrim());
         $controls["question"]->setRequired();
         $controls["question"]->setDisabled((bool) $this->getInquiry());
         $inquiryOptions = $this->getInquiryOptions();
         for ($i = 1; $i <= LBoxConfigManagerProperties::getPropertyContentByName("inquiries_answers_count"); $i++) {
             $controlsAnswers["answer-{$i}"] = new LBoxFormControlFill("answer-{$i}", "Odpověď {$i}", $inquiryOptions[$i]);
             $controlsAnswers["answer-{$i}"]->addFilter(new LBoxFormFilterTrim());
             $controlsAnswers["answer-{$i}"]->setDisabled((bool) $this->getInquiry());
         }
         $controls["answers"] = new LBoxFormControlMultiple("answers", NULL);
         foreach ($controlsAnswers as $controlAnswer) {
             $controls["answers"]->addControl($controlAnswer);
         }
         $controls["answers"]->setTemplateFileName("lbox_form_control_admin_inquiries_answers.html");
         $controls["answers"]->addValidator(new LBoxFormValidatorInquiriesAnswers());
         if ($this->getInquiry()) {
             $controls["id"] = new LBoxFormControlFillHidden("id", "", $this->getInquiry()->id);
         }
         $form = new LBoxForm("edit-inquiry", "post", "editace ankety", "ulož");
         foreach ($controls as $control) {
             $form->addControl($control);
         }
         $form->addProcessor(new LBoxFormProcessorAdminInquiryEdit());
         return $this->form = $form;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 6
0
 /**
  * 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;
     }
 }
 /**
  * vraci instanci formu pro hlasovani
  * @return LBoxForm
  */
 protected function getForm()
 {
     try {
         $control = new LBoxFormControlFillHidden("ref_option", "", $this->getID());
         $control->addValidator(new LBoxFormValidatorInquiryOptionValidOnlyLastInquiry());
         $form = new LBoxForm("inquiry-option-" . $this->getID(), "post", "", "hlasovat");
         $form->setTemplateFileName("lbox_form_inquiries_votefor.html");
         $form->addControl($control);
         $form->addProcessor(new LBoxFormProcessorInquiryVoteFor());
         $form->setAntiSpam(true);
         return $form;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 8
0
 /**
  * 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;
     }
 }
Ejemplo n.º 9
0
 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;
     }
 }
Ejemplo n.º 10
0
 /**
  * vrati true, pokud byl na teto strance aktualne odeslan formular - pouzivano pri zjitovani jestli se ma tato URL nacist z cache
  * @return bool
  */
 public function wasFormSentNow()
 {
     try {
         $url = substr(LBOX_REQUEST_URL, -1) == "/" ? LBOX_REQUEST_URL : LBOX_REQUEST_URL . "/";
         $url = str_replace("?/", "/", $url);
         $url = str_replace("//", "/", $url);
         foreach ((array) $this->recordTypes[$url]["forms"] as $formName) {
             if (LBoxForm::wasFormSentByName($formName)) {
                 return true;
             }
             //LBoxFirePHP::error("$formName nebyl odeslan!");
         }
         return false;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 11
0
 /**
  * getter na form pro vlozeni prispevku
  * Pokud je zavolan na record diskuze, vrati form pro vlozeni noveho prispevku
  * POkud je zavolan na record prispevku, vrati form pro vlozeni odpovedi na nej
  * @return LBoxForm
  */
 public function getForm()
 {
     try {
         if ($this->form instanceof LBoxForm) {
             return $this->form;
         }
         if (!$this->isInDatabase()) {
             LBoxFront::reload(LBoxUtil::getURLWithoutParamsByPattern(array("/" . $this->patternURLParamReplyTo . "/")));
         }
         if ($this->hasParent()) {
             $title = $this->title;
             switch (true) {
                 case preg_match("/^re( *)(\\d+)(.*)/i", $title, $regs):
                     $num = $regs[2] + 1;
                     $title = "RE{$num}" . trim($regs[3]);
                     break;
                 case preg_match("/^re(.*)/i", $title, $regs):
                     $title = "RE2" . $regs[1];
                     break;
                 default:
                     $title = "RE: {$title}";
             }
         } else {
             $title = "";
         }
         $id = $this->params[self::$idColName];
         $controls["pid"] = new LBoxFormControlFillHidden("pid", "", $id);
         $controls["pid"]->setDisabled();
         $controls["title"] = new LBoxFormControlFill("title", "titulek", $title, LBoxConfigManagerProperties::gpcn("form_max_length_discussion_title"));
         $controls["title"]->setRequired();
         $controls["title"]->setTemplateFilename("discussion_title.html");
         $controls["nick"] = new LBoxFormControlFill("nick", "nick", LBoxXT::isLogged() ? LBoxXT::getUserXTRecord()->nick : "", LBoxConfigManagerProperties::gpcn("form_max_length_nick"));
         if (LBoxXT::isLogged() && strlen(LBoxXT::getUserXTRecord()->nick) > 0) {
             $controls["nick"]->setDisabled();
         }
         $controls["nick"]->setTemplateFilename("lbox_form_control_nick.html");
         $validatorNick = new ValidatorAdminRecordNotExists(LBoxXT::isLogged() ? LBoxXT::getUserXTRecord()->id : NULL);
         $validatorNick->setRecordClassName("XTUsersRecord");
         $validatorNick->setFilterColName("nick");
         $controls["nick"]->addValidator($validatorNick);
         $controls["nick"]->setRequired();
         $controls["email"] = new LBoxFormControlFill("email", "email", LBoxXT::isLogged() ? LBoxXT::getUserXTRecord()->email : "", LBoxConfigManagerProperties::gpcn("form_max_length_email"));
         if (LBoxXT::isLogged() && strlen(LBoxXT::getUserXTRecord()->email) > 0) {
             $controls["email"]->setDisabled();
         }
         $controls["email"]->setTemplateFilename("lbox_form_control_email.html");
         $controls["email"]->addValidator(new LBoxFormValidatorEmail());
         $validatorEmail = new ValidatorAdminRecordNotExists(LBoxXT::isLogged() ? LBoxXT::getUserXTRecord()->id : NULL);
         $validatorEmail->setRecordClassName("XTUsersRecord");
         $validatorEmail->setFilterColName("email");
         $controls["email"]->addValidator($validatorEmail);
         $controls["www"] = new LBoxFormControlFill("www", "www", LBoxXT::isLogged() ? LBoxXT::getUserXTRecord()->www : "", LBoxConfigManagerProperties::gpcn("form_max_length_www"));
         if (LBoxXT::isLogged() && strlen(LBoxXT::getUserXTRecord()->www) > 0) {
             $controls["www"]->setDisabled();
         }
         $controls["www"]->setTemplateFilename("lbox_form_control_www.html");
         $controls["www"]->addValidator(new LBoxFormValidatorURLHTTPHTTPS());
         $controls["body"] = new LBoxFormControlFill("body", "body", "", 1);
         $controls["body"]->setTemplateFilename("discussion_body.html");
         $controls["body"]->addValidator(new LBoxFormValidatorDiscussionBody());
         $controls["body"]->setRequired();
         if (LBoxConfigManagerProperties::gpcn("discussion_recaptcha")) {
             $controls["recaptcha"] = new LBoxFormControlReCaptcha();
         }
         $this->form = new LBoxForm("discussion-{$id}-post", "post", $this->hasParent() ? "Odpověď na příspěvek \"" . $this->getParamDirect("title") . "\"" : "Nový příspěvek", "odeslat");
         //$this->form			->addProcessor(new LBoxFormProcessorDev);
         $this->form->addProcessor(new ProcessorDiscussionPost());
         $this->form->setAntiSpam((bool) LBoxConfigManagerProperties::gpcn("discussion_antispam"));
         foreach ($controls as $control) {
             $control->addFilter(new LBoxFormFilterTrim());
             $this->form->addControl($control);
         }
         return $this->form;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 12
0
 /**
  * getter na form editace stranky struktury
  * @return LBoxForm
  */
 public function getForm()
 {
     try {
         if ($this->form instanceof LBoxForm) {
             return $this->form;
         }
         if ($this->getPage() && $this->getPage()->config->isHomePage()) {
             return NULL;
         }
         $controls["id"] = new LBoxFormControlFillHidden("id", "", $this->getPage() ? $this->getPage()->config->getParamDirect("id") : NULL);
         $controls["id"]->setDisabled();
         $subControls["base"]["heading"] = new LBoxFormControlFill("heading", "heading", $this->getPage() ? $this->getPage()->config->getParamDirect("heading") : LBoxUtil::getNameByURLString($this->getURLPartCurrentLast()));
         $subControls["base"]["heading"]->setRequired();
         $subControls["base"]["heading"]->setTemplateFileName("webui_structure_heading.html");
         $subControls["base"]["title"] = new LBoxFormControlFill("title", "title", $this->getPage() ? $this->getPage()->config->getParamDirect("title") : NULL);
         $subControls["base"]["url"] = new LBoxFormControlFill("url", "url", preg_replace("/(\\/+)/", "", $this->getURLPartCurrentLast()));
         $subControls["base"]["url"]->setRequired();
         $subControls["base"]["url"]->addFilter(new LBoxFormFilterTrim());
         $subControls["base"]["url"]->addFilter(new LBoxFormFilterURLStringFromName());
         $filterURLFromHeading = new LBoxFormFilterURLFromName($subControls["base"]["url"]);
         $filterURLFromHeading->setControlName($subControls["base"]["heading"]);
         $subControls["base"]["url"]->addFilter($filterURLFromHeading);
         $subControls["base"]["url"]->setTemplateFileName("webui_structure_url.html");
         $subControls["base"]["url"]->addValidator(new WebUIFormControlValidatorStructureItemURL());
         $validatorPageExistsByURL = new WebUIFormControlValidatorStructurePageExistsByURL($this->getPage() ? $this->getPage()->config->getParamDirect("id") : NULL);
         $subControls["base"]["url"]->addValidator($validatorPageExistsByURL);
         if (!$this->getPage() || preg_match("/" . $this->fileNamesTemplatePagesTypesPattern . "/", $this->getPage()->config->template)) {
             $subControls["base"]["type"] = new LBoxFormControlChooseOne("type", "typ", $this->getPageTypeCurrent());
             $subControls["base"]["type"]->setRequired();
             foreach ($this->getPagesTypes() as $type) {
                 $subControls["base"]["type"]->addOption(new LBoxFormControlOption($type, $type));
             }
         }
         $subControls["structure"]["in_menu"] = new LBoxFormControlChooseOne("in_menu", "v menu", $this->getPage() ? $this->getPage()->config->getParamDirect("in_menu") : 0);
         $subControls["structure"]["in_menu"]->setRequired();
         foreach ($this->getOptionsInMenu() as $k => $option) {
             $subControls["structure"]["in_menu"]->addOption(new LBoxFormControlOption($k, $option));
         }
         if (count($this->getOptionsInMenu()) < 3) {
             $subControls["structure"]["in_menu"]->setTemplateFileName("lbox_form_control_choose_one_radio.html");
         } else {
             $subControls["structure"]["in_menu"]->setTemplateFileName("lbox_form_control_choose_one_select.html");
         }
         $subControls["structure"]["parent_id"] = new LBoxFormControlChooseOne("parent_id", "parent", $this->getPage() && $this->getPage()->config->hasParent() ? $this->getPage()->config->getParent()->id : NULL);
         $subControls["structure"]["parent_id"]->setTemplateFileName("lbox_form_control_choose_one_select.html");
         $this->fillControlChooseParentID($subControls["structure"]["parent_id"]);
         $subControls["structure"]["move_before"] = new LBoxFormControlChooseOne("move_before", "přesunout před", $this->getPage() ? $this->getValueCurrentMoveBefore() : NULL);
         $subControls["structure"]["move_before"]->setTemplateFileName("lbox_form_control_choose_one_select.html");
         $this->fillControlChooseMoveBefore($subControls["structure"]["move_before"]);
         $subControls["seo"]["keywords"] = new LBoxFormControlFill("keywords", "keywords", $this->getPage() ? $this->getPage()->config->getParamDirect("keywords") : NULL);
         $subControls["seo"]["keywords"]->setTemplateFileName("webui_structure_keywords.html");
         $subControls["seo"]["description"] = new LBoxFormControlFill("description", "description", $this->getPage() ? $this->getPage()->config->getParamDirect("description") : NULL);
         $subControls["seo"]["description"]->setTemplateFileName("webui_structure_description.html");
         $validatorPageExistsByURL->setControlParentID($subControls["structure"]["parent_id"]);
         foreach ($subControls as $themeName => $theme) {
             foreach ($theme as $subControl) {
                 if (!array_key_exists($themeName, $controls) || !$controls[$themeName] instanceof LBoxFormControlMultiple) {
                     $controls[$themeName] = new LBoxFormControlMultiple($themeName);
                     $controls[$themeName]->setTemplateFileName("webui_structure_multi.html");
                 }
                 $controls[$themeName]->addControl($subControl);
             }
         }
         $this->form = new LBoxForm("webui-structure-item-" . LBoxFront::getPage()->id, "post", "upravit stranku", "uložit");
         $processor = new WebUIFormProcessorStructureItem();
         $processor->setFileNamesTemplatePagesTypesPattern($this->fileNamesTemplatePagesTypesPattern);
         //$this->form ->addProcessor(new LBoxFormProcessorDev());
         $this->form->addProcessor($processor);
         foreach ($controls as $control) {
             $this->form->addControl($control);
         }
         return $this->form;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 13
0
 /**
  * vraci form pro editaci profilu
  * @return LBoxForm
  */
 public function getForm()
 {
     try {
         if ($this->form instanceof LBoxForm) {
             return $this->form;
         }
         $controls["id"] = new LBoxFormControlFillHidden("id", "", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->id : "");
         $controls["id"]->addFilter(new LBoxFormFilterTrim());
         $controls["id"]->addValidator(new ValidatorProfileNotExists(LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->id : ""));
         $controls["nick"] = new LBoxFormControlFill("nick", "přezdívka", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->nick : "", 255);
         $controls["nick"]->addFilter(new LBoxFormFilterTrim());
         $controls["nick"]->addValidator(new ValidatorProfileNotExistsByNick(LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->id : "", 255));
         $controls["nick"]->setTemplateFilename("lbox_form_control_nick.html");
         $controls["nick"]->setRequired();
         $controls["email"] = new LBoxFormControlFill("email", "e-mail", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->email : "", 255);
         $controls["email"]->addFilter(new LBoxFormFilterTrim());
         $controls["email"]->addValidator(new ValidatorProfileNotExistsByEmail(LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->id : ""));
         $controls["email"]->addValidator(new LBoxFormValidatorEmail());
         $controls["email"]->setTemplateFilename("lbox_form_control_email.html");
         $controls["email"]->setRequired();
         $subControls["passwords"]["password1"] = new LBoxFormControlPassword("password1", "Heslo", "", 30);
         $subControls["passwords"]["password1"]->setTemplateFilename("lbox_form_control_password.html");
         $subControls["passwords"]["password1"]->setRequired();
         $subControls["passwords"]["password2"] = new LBoxFormControlPassword("password2", "Heslo podruhé", "", 30);
         $subControls["passwords"]["password2"]->setTemplateFilename("lbox_form_control_password.html");
         $subControls["passwords"]["password2"]->setRequired();
         $controls["passwords"] = new LBoxFormControlMultiple("passwords");
         foreach ($subControls["passwords"] as $subControl) {
             $controls["passwords"]->addControl($subControl);
         }
         $controls["passwords"]->addValidator(new LBoxFormValidatorPasswords());
         $controls["passwords"]->setTemplateFilename("lbox_form_control_multi_passwords.html");
         $controls["name"] = new LBoxFormControlFill("name", "jméno", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->name : "", 255);
         $controls["name"]->addFilter(new LBoxFormFilterTrim());
         $controls["name"]->setTemplateFilename("lbox_form_control_name.html");
         $controls["name"]->setRequired();
         $controls["surname"] = new LBoxFormControlFill("surname", "příjmení", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->surname : "", 255);
         $controls["surname"]->addFilter(new LBoxFormFilterTrim());
         $controls["surname"]->setTemplateFilename("lbox_form_control_surname.html");
         $controls["surname"]->setRequired();
         $controls["phone"] = new LBoxFormControlFill("phone", "telefon", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->phone : "", 12);
         $controls["phone"]->addFilter(new LBoxFormFilterTrim());
         $controls["phone"]->addFilter(new LBoxFormFilterPhoneNumberCSWithPreselection());
         $controls["phone"]->addValidator(new ValidatorProfileNotExistsByPhone(LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->id : ""));
         $controls["phone"]->addValidator(new LBoxFormValidatorPhone());
         $controls["phone"]->setTemplateFilename("lbox_form_control_phone.html");
         $controls["phone"]->setRequired();
         $controls["street"] = new LBoxFormControlFill("street", "Ulice", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->street : "", 255);
         $controls["street"]->addFilter(new LBoxFormFilterTrim());
         $controls["street"]->setTemplateFilename("lbox_form_control_street.html");
         $controls["street"]->setRequired();
         $controls["street_number"] = new LBoxFormControlFill("street_number", "Číslo domu", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->street_number : "", 11);
         $controls["street_number"]->addFilter(new LBoxFormFilterTrim());
         $controls["street_number"]->setTemplateFilename("lbox_form_control_streetnumber.html");
         $controls["street_number"]->setRequired();
         $controls["city"] = new LBoxFormControlFill("city", "město", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->city : "", 255);
         $controls["city"]->addFilter(new LBoxFormFilterTrim());
         $controls["city"]->setTemplateFilename("lbox_form_control_city.html");
         $controls["city"]->setRequired();
         $controls["zip"] = new LBoxFormControlFill("zip", "PSČ", LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord()->zip : "", 5);
         $controls["zip"]->addFilter(new LBoxFormFilterEraseSpaces());
         $controls["zip"]->addValidator(new LBoxFormValidatorZIPCS());
         $controls["zip"]->setTemplateFilename("lbox_form_control_zip.html");
         $controls["zip"]->setRequired();
         $this->form = new LBoxForm("profile", "post", LBoxXTProject::isLogged() ? "Úprava profilu" : "Vytvořit profil", "Uložit");
         $this->form->addProcessor($processorSaveProfile = new ProcessorSaveProfile());
         $this->form->addProcessor(new ProcessorRegistrationSendConfirmMail($processorSaveProfile));
         foreach ($controls as $control) {
             $this->form->addControl($control);
         }
         return $this->form;
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * vraci formular - button na odpoved na prispevek
  * @return LBoxForm
  */
 protected function getFormToReply()
 {
     try {
         $classNameInstance = get_class($this->instance);
         $idColName = eval("return {$classNameInstance}::\$idColName;");
         if (array_key_exists($this->instance->{$idColName}, self::$formsByIDs) && self::$formsByIDs[$this->instance->{$idColName}] instanceof LBoxForm) {
             return self::$formsByIDs[$this->instance->{$idColName}];
         }
         $controls["id"] = new LBoxFormControlFillHidden("pid", "", $this->instance->{$idColName});
         $controls["id"]->setDisabled();
         $form = new LBoxForm($this->instance->{$idColName} . "-to-reply", "post", "", "Odpovědět");
         $form->setTemplateFileName("lbox_form_discussion_to_reply.html");
         //$form	->addProcessor(new LBoxFormProcessorDev);
         $form->addProcessor(new ProcessorDiscussionToReply());
         foreach ($controls as $control) {
             $form->addControl($control);
         }
         return self::$formsByIDs[$this->instance->{$idColName}] = $form;
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * vraci form pro delete clanku
  * @return LBoxForm
  * @throws LBoxException
  */
 protected function getFormXTDelete()
 {
     try {
         if (!constant('CLI')) {
             if (!LBoxXTProject::isLoggedAdmin()) {
                 return "";
             }
         }
         if ($this->formDelete instanceof LBoxForm) {
             return $this->formDelete;
         }
         $instanceType = get_class($this->instance);
         $idColName = eval("return {$instanceType}::\$idColName;");
         $id = $this->instance->getParamDirect($idColName);
         $controlID = new LBoxFormControlFillHidden("id", "", $id);
         foreach ($this->formDeleteValidators as $validatorDeleteID) {
             $controlID->addValidator($validatorDeleteID);
         }
         if (strlen($this->formDeleteTemplateControlID) > 0) {
             $controlID->setTemplateFileName($this->formDeleteTemplateControlID);
         }
         $controlType = new LBoxFormControlFillHidden("type", "", $instanceType);
         $form = new LBoxForm("record_xt_delete_{$id}", "post", "", "delete");
         $form->setTemplateFileName("lbox_form_xt_btn_delete.html");
         $form->addControl($controlID);
         $form->addControl($controlType);
         $form->addProcessor(new ProcessorRecordDelete());
         $form->item_name = strlen($this->instance->name) > 0 ? $this->instance->name : $this->instance->{$idColName};
         return $this->formDelete = $form;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 16
0
 /**
  * vraci formularova data konkretniho kroku podle predaneho formu
  * @param LBoxForm $form
  * @return array
  */
 public function getFormsDataStepByForm(LBoxForm $form)
 {
     try {
         $step = NULL;
         foreach ($this->subForms as $stepSubform => $subForm) {
             if ($form->getName() == $subForm->getName()) {
                 $step = $stepSubform;
             }
         }
         if (!is_int($step)) {
             throw new LBoxExceptionForm(LBoxExceptionForm::MSG_FORM_FORM_SUB_NOT_SET, LBoxExceptionForm::CODE_FORM_FORM_SUB_NOT_SET);
         }
         $formsData = $this->getFormsData();
         return $formsData[$step];
     } catch (Exception $e) {
         throw $e;
     }
 }