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 {
         $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 process()
 {
     try {
         if (array_key_exists("id", $this->form->getControls())) {
             $record = new InquiriesRecord($this->form->getControlByName("id")->getValue());
         } else {
             $record = new InquiriesRecord();
             $record->question = $this->form->getControlByName("question")->getValue();
         }
         $record->is_active = (int) $this->form->getControlByName("is_active")->isSelected();
         $record->store();
         if (!array_key_exists("id", $this->form->getControls())) {
             for ($i = 1; $i <= LBoxConfigManagerProperties::getPropertyContentByName("inquiries_answers_count"); $i++) {
                 if (strlen($this->form->getControlByName("answer-{$i}")->getValue()) < 1) {
                     continue;
                 }
                 $optionsRecords[$i] = new InquiriesOptionsRecord();
                 $optionsRecords[$i]->ref_inquiry = $record->id;
                 $optionsRecords[$i]->answer = $this->form->getControlByName("answer-{$i}")->getValue();
                 $optionsRecords[$i]->store();
             }
         }
         LBoxFront::reload(LBoxFront::getPage()->url . ":" . $record->id);
     } catch (Exception $e) {
         throw $e;
     }
 }
 public function process()
 {
     try {
         LBoxFront::reload(LBoxUtil::getURLWithParams(array("edit-" . $this->form->getName())));
     } catch (Exception $e) {
         throw $e;
     }
 }
 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;
     }
 }
示例#6
0
 /**
  * reloadne hlavni stranku adminu
  */
 protected function reloadAdminHome()
 {
     try {
         if (strlen($adminHomePageID = LBoxConfigManagerProperties::getPropertyContentByName("ref_page_xt_admin")) < 1) {
             throw new LBoxExceptionPage("Property ref_page_xt_admin not set!");
         }
         LBoxFront::reload(LBoxConfigManagerStructure::getPageById($adminHomePageID)->url);
     } catch (Exception $e) {
         throw $e;
     }
 }
示例#7
0
 public function executeInit()
 {
     try {
         parent::executeInit();
         if ($this->config->getChildNodesIterator()) {
             LBoxFront::reload($this->config->getChildNodesIterator()->current()->url);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
示例#8
0
 protected function executeStart()
 {
     try {
         if (strlen($this->getRecordURLParam()) > 0 && !$this->getRecord()) {
             LBoxFront::reload(LBoxUtil::getURLWithoutParams(array($this->getRecordURLParam())));
         }
         parent::executeStart();
     } catch (Exception $e) {
         throw $e;
     }
 }
 public function process()
 {
     try {
         $url = LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("rpe")->getValue())->url;
         if (strlen($this->form->getControlByName("pnpup")->getValue()) > 0) {
             $url .= ":" . str_replace("<url_param>", $this->form->getControlByName("id")->getValue(), LBoxConfigManagerProperties::gpcn($this->form->getControlByName("pnpup")->getValue()));
         } else {
             $url .= ":" . $this->form->getControlByName("id")->getValue();
         }
         LBoxFront::reload($url);
     } 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;
     }
 }
示例#11
0
 /**
  * @throws LBoxExceptionForm
  */
 public function process()
 {
     try {
         if (!$this->wasSent()) {
             return;
         }
         // zkontrolovat, jestli mame nastaven procesor
         if (!$this->isSubForm() && count($this->processors) < 1) {
             throw new LBoxExceptionForm(LBoxExceptionForm::MSG_FORM_PROCESSOR_DOESNOT_EXISTS, LBoxExceptionForm::CODE_FORM_PROCESSOR_DOESNOT_EXISTS);
         }
         if ($this->isAntiSpamSet()) {
             if (!$this->getSpamDefenseControl()->process()) {
                 return;
             }
         }
         // spustit checking controls
         $controlInvalid = false;
         foreach ($this->controls as $control) {
             if ($control->getName() == $this->getSpamDefenseControl()->getName()) {
                 continue;
             }
             if (!$control->process()) {
                 $controlInvalid = true;
             }
         }
         if ($controlInvalid) {
             return;
         }
         // spustit processory
         foreach ($this->processors as $processor) {
             $processor->process();
         }
         // oznamit controls uspesne dokonceny processing
         foreach ($this->controls as $control) {
             $control->commitProcessSuccess();
         }
         // nastavit do session uspesne odeslani a reloadovat stranku
         if (!$this->doNotReload) {
             if (strtolower($this->method) == "post") {
                 $this->sentSucces = true;
                 $_SESSION["LBox"]["Forms"][$this->getName()]["succes"] = true;
                 if (!$this->isSubForm()) {
                     LBoxFront::reload();
                 }
             }
         } else {
             //vynulovat pole a nastavit, ze byl uspesne proveden
             foreach ($this->controls as $control) {
                 $control->setValue("");
             }
             $this->sentSucces = true;
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
示例#12
0
 /**
  * reloaduje stranku
  * @param string $url
  */
 protected function reload($url = "")
 {
     LBoxFront::reload($url);
 }
 public function process()
 {
     try {
         $parent = NULL;
         if (strlen($this->fileNamesTemplatePagesTypesPattern) < 1) {
             throw new LBoxExceptionFormProcessor(LBoxExceptionFormProcessor::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxExceptionFormProcessor::CODE_BAD_INSTANCE_VAR);
         }
         if (strlen($this->form->getControlByName("id")->getValue()) > 0) {
             $configItem = LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("id")->getValue());
             // smazat cache pro existujici stranku na jeji puvodni URL jeste pred moznou zmenou!
             LBoxCacheManagerFront::getInstance()->cleanAllURLs(true);
             if ($parentID = $this->form->getControlByName("parent_id")->getValue()) {
                 $parent = LBoxConfigManagerStructure::getInstance()->getPageById($parentID);
             }
         } else {
             try {
                 if (LBoxConfigManagerStructure::getInstance()->getPageByUrl($this->form->getControlByName("url")->getValue())) {
                     throw new LBoxExceptionConfigStructure("URL: " . LBoxExceptionConfigStructure::MSG_ATTRIBUTE_UNIQUE_NOT_UNIQUE, LBoxExceptionConfigStructure::CODE_ATTRIBUTE_UNIQUE_NOT_UNIQUE);
                 }
             } catch (Exception $e) {
                 switch ($e->getCode()) {
                     case LBoxExceptionConfigStructure::CODE_NODE_BYURL_NOT_FOUND:
                         NULL;
                         break;
                     default:
                         throw $e;
                 }
             }
             if ($parentID = $this->form->getControlByName("parent_id")->getValue()) {
                 $parent = LBoxConfigManagerStructure::getInstance()->getPageById($parentID);
                 // zaridi parental vztah jen pri vytvareni (nutno kvuli odvozeni ID) - pro editaci je dodatecne prirazeni nize
                 $configItem = LBoxConfigStructure::getInstance()->getCreateChild($parent, $this->form->getControlByName("url")->getValue());
             } else {
                 $configItem = LBoxConfigStructure::getInstance()->getCreateItem($this->form->getControlByName("url")->getValue());
             }
         }
         foreach ($this->form->getControls() as $control) {
             if ($control instanceof LBoxFormControlMultiple) {
                 continue;
             }
             $name = $control->getName();
             switch ($name) {
                 case "id":
                 case "parent_id":
                 case "move_before":
                     NULL;
                     break;
                 case "type":
                     $configItem->template = str_replace("(.+)", $control->getValue(), $this->fileNamesTemplatePagesTypesPattern);
                     $configItem->template = preg_replace("/[^\\w_\\-\\.]/", "", $configItem->template);
                     break;
                 case "url":
                     if ($parent) {
                         $configItem->{$name} = "/" . $parent->url . "/" . $control->getValue() . "/";
                         $configItem->{$name} = preg_replace("/(\\/+)/", "/", $configItem->{$name});
                     } else {
                         $configItem->{$name} = "/" . $control->getValue() . "/";
                         $configItem->{$name} = preg_replace("/(\\/+)/", "/", $configItem->{$name});
                     }
                     break;
                 default:
                     $configItem->{$name} = $control->getValue();
             }
         }
         // move before a parent_id
         // - je treba dodatecne zajistit parental vztah, pri editaci horni logika to zajistuje pouze pri vytvareni, ale ne pri editaci
         switch (true) {
             // editace + parent puvodne nemel tohoto potomka
             case $this->form->getControlByName("id")->getValue() && $this->form->getControlByName("parent_id")->getValue() > 0 && !LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("parent_id")->getValue())->isParentOf($configItem):
                 LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("parent_id")->getValue())->appendChild($configItem);
                 break;
                 // parent neni nastaven, jde o editaci a predtim nastaven byl
             // parent neni nastaven, jde o editaci a predtim nastaven byl
             case !$this->form->getControlByName("parent_id")->getValue() && $configItem->hasParent():
                 // uprednostnit removeFromTree()
                 $configItem->removeFromTree();
                 break;
                 // editace + move before je nastaveno na jiny node nez bylo
             // editace + move before je nastaveno na jiny node nez bylo
             case $this->form->getControlByName("move_before")->getValue() && $this->form->getControlByName("id")->getValue() && (!$configItem->hasSiblingBefore() || $configItem->getSiblingBefore()->id != $this->form->getControlByName("move_before")->getValue()):
                 // vlozeni + moveBefore je nastaveno
             // vlozeni + moveBefore je nastaveno
             case $this->form->getControlByName("move_before")->getValue() && $this->form->getControlByName("id")->getValue():
                 // uprednostnit insertBefore()
                 LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("move_before")->getValue())->insertBefore($configItem);
                 break;
                 // parent je nastaven
             // parent je nastaven
             case $this->form->getControlByName("parent_id")->getValue():
                 // uprednostnit appendChild()
                 LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("parent_id")->getValue())->appendChild($configItem);
                 break;
             default:
                 $configItem->removeFromTree();
         }
         LBoxConfigStructure::getInstance()->store();
         // pro jistotu smazani front cache stranky na jeji potencialne zmenene URL (mohly by tam byt data z minulosti)
         LBoxCacheManagerFront::getInstance()->cleanAllURLs(true);
         //reload na nove ulozenou stranky
         LBoxFront::reload(LBoxConfigManagerStructure::getInstance()->getPageById($configItem->id)->url);
     } catch (Exception $e) {
         throw $e;
     }
 }
示例#14
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;
     }
 }
示例#15
0
 /**
  * posouva o jeden krok zpet, pokud predchozi krok existuje
  */
 protected function moveToPreviousStep()
 {
     try {
         if (!$this->subForms[$this->getStepCurrent() - 1] instanceof LBoxForm) {
             return;
         }
         $_SESSION["LBox"]["Forms"][$this->getName()]["step"] = $this->getStepCurrent() - 1;
         LBoxFront::reload();
     } catch (Exception $e) {
         throw $e;
     }
 }