Ejemplo n.º 1
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;
     }
 }
 /**
  * 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.º 3
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;
     }
 }