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 store() { try { $this->params["type"] = "post"; parent::store(); } catch (Exception $e) { throw $e; } }
/** * getter na record * @return DiscussionsRecord */ public function getRecord() { try { if ($this->record instanceof DiscussionsRecord) { return $this->record; } $pageID = LBoxConfigManagerStructure::getInstance()->getPageByUrl(LBOX_REQUEST_URL_VIRTUAL)->id; $locationURL = $this->getLocationUrlParam(); $discussions = new DiscussionsRecords(array("pageId" => $pageID), array("lft" => 1), array(0, 1)); if ($discussions->count() < 1) { // pokud diskuze nebyla nalezena, vytvorime ji a vratime $discussion = new DiscussionsRecord(); $discussion->pageId = $pageID; $discussion->urlParam = $locationURL; $discussion->store(); } else { $discussion = $discussions->current(); } $discussion->setOutputFilter(new OutputFilterDiscussionRecord($discussion)); return $this->record = $discussion; } catch (Exception $e) { throw $e; } }