public function process() { try { $parent = new DiscussionsRecord($this->form->getControlByName("pid")->getValue()); $record = new DiscussionsRecord(); $classNameRecord = get_class($record); foreach ($this->form->getControls() as $control) { if ($control instanceof LBoxFormControlMultiple) { continue; } if ($control instanceof LBoxFormControlSpamDefense) { continue; } if ($control->getName() == "pid") { continue; } if ($control->getName() == eval("return {$classNameRecord}::\$idColName;")) { continue; } $colName = $control->getName(); $record->{$colName} = strlen($control->getValue()) > 0 ? $control->getValue() : "<<NULL>>"; } $record->pageId = LBoxFront::getPage()->id; $record->store(); $parent->addChild($record); // u odpovedi reloadovat na hlavni vlakno if ($parent->hasParent()) { LBoxFront::reload(LBoxUtil::getURLWithoutParamsByPattern(array("/" . $this->patternURLParamReplyTo . "/"))); } } catch (Exception $e) { throw $e; } }
public function prepare($name = "", $value = NULL) { if (!$this->record instanceof AbstractRecord) { throw new LBoxExceptionOutputFilter(LBoxExceptionOutputFilter::MSG_INSTANCE_VAR_INSTANCE_CONCRETE_NOTNULL, LBoxExceptionOutputFilter::CODE_BAD_INSTANCE_VAR); } switch ($name) { case "rssURL": if ($this->instance->rss) { $rssPageUrl = LBoxConfigManagerStructure::getInstance()->getPageById($this->instance->rss)->url; $pageId = $this->instance->page->id; return "{$rssPageUrl}:{$pageId}/" . LBoxFront::getLocationUrlParam(); } break; case "getForm": $parentId = NULL; foreach (LBoxFront::getUrlParamsArray() as $param) { if (preg_match("/" . $this->patternURLParamReplyTo . "/", $param, $matches)) { $parentId = $matches[1]; } } if ($parentId) { $record = new DiscussionsRecord($parentId); if (!$record->isInDatabase()) { LBoxFront::reload(LBoxUtil::getURLWithoutParamsByPattern(array("/" . $this->patternURLParamReplyTo . "/"))); } $record->setOutputFilter(new OutputFilterDiscussionRecord($record)); return $record->getForm(); } else { return $this->record->getForm(); } break; default: return $value; } }
public function process() { try { $pid = $this->form->getControlByName("pid")->getValue(); LBoxFront::reload(LBoxUtil::getURLWithParams(array("replyto-{$pid}"), LBoxUtil::getURLWithoutParamsByPattern(array("/" . $this->patternURLParamReplyTo . "/"))) . "#frm-discussion-{$pid}-post"); } catch (Exception $e) { throw $e; } }
public function process() { try { if (count($this->patternPropertyNames) < 1) { throw new LBoxExceptionFormProcessor(LBoxExceptionFormProcessor::MSG_INSTANCE_VAR_ARRAY_NOTNULL, LBoxExceptionFormProcessor::CODE_BAD_INSTANCE_VAR); } if (count($this->patternPropertyNames) < 2) { $patternDefault = LBoxConfigManagerProperties::gpcn(current($this->patternPropertyNames)); } $patternPCRES = array(); foreach ($this->patternPropertyNames as $patternPropertyName) { $patternPCRES[] = "/" . str_ireplace("<url_param>", "([\\w-_\\.\\/\\\\ěščřžýáíéůúřťňĚďŠČŘŽÝÁÍÉŮÚŘŤĎŇ]+)", LBoxConfigManagerProperties::gpcn($patternPropertyName)) . "/"; } $reloadParams = array(); foreach ($this->form->getControls() as $control) { if (count($this->patternPropertyNames) > 1 && !array_key_exists($control->getName(), $this->patternPropertyNames)) { continue; } $pattern = ""; $pattern = $patternDefault ? $patternDefault : LBoxConfigManagerProperties::gpcn($this->patternPropertyNames[$control->getName()]); switch (true) { case $control instanceof LBoxFormControlMultiple: case $control instanceof LBoxFormControlSpamDefense: continue; break; default: if ($control->getValue() && strlen(trim($control->getValue())) > 0) { $reloadParams[] = str_replace("<url_param>", $control->getValue(), $pattern); } } } if (count($reloadParams) > 0) { LBoxFront::reload(LBoxUtil::getURLWithParams($reloadParams, LBoxUtil::getURLWithoutParamsByPattern($patternPCRES))); } else { LBoxFront::reload(LBoxUtil::getURLWithoutParamsByPattern($patternPCRES)); } } catch (Exception $e) { throw $e; } }
/** * 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; } }
public function getParamDirect($name = "") { try { if (strlen($this->params[$name]) < 1) { $value = NULL; switch ($name) { case "url": $URLParamPattern = LBoxConfigSystem::getInstance()->getParamByPath("paging/url_param_pattern"); $URLParamPattern = str_replace("<paging_id>", $this->paging->getPagingID(), $URLParamPattern); $URLParam = str_replace("<paging_page>", $this->number, $URLParamPattern); $URLParamPattern = str_replace("<paging_page>", "(\\d+)", $URLParamPattern); $URLParam = str_replace("/", "", $URLParam); $URLParam = str_replace("\\", "", $URLParam); if ($this->getNumber() > 1) { $value = LBoxUtil::getURLWithParams(array($URLParam), LBoxUtil::getURLWithoutParamsByPattern($URLParamPattern)); } else { $value = LBoxUtil::getURLWithoutParamsByPattern($URLParamPattern); } break; default: $value = NULL; } return $this->params[$name] = $value; } else { return $this->params[$name]; } } catch (Exception $e) { throw $e; } }