/** * 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 form pro forward na editaci clanku * @return LBoxForm * @throws LBoxException */ protected function getFormXTToEdit() { try { if (!constant('CLI')) { if (!LBoxXTProject::isLoggedAdmin()) { return ""; } } if ($this->formToEdit instanceof LBoxForm) { return $this->formToEdit; } if (strlen($this->propertyNameRefPageEdit) < 1) { throw new LBoxExceptionOutputFilter(get_class($this) . "::\$propertyNameRefPageEdit: " . LBoxExceptionOutputFilter::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxExceptionOutputFilter::CODE_BAD_INSTANCE_VAR); } $instanceType = get_class($this->instance); $idColName = eval("return {$instanceType}::\$idColName;"); $id = $this->instance->getParamDirect(strlen($this->editURLFilterColname) > 0 ? $this->editURLFilterColname : $idColName); $controlID = new LBoxFormControlFillHidden("id", "", $id); $controlRefPageEdit = new LBoxFormControlFillHidden("rpe", "", LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getPropertyContentByName($this->propertyNameRefPageEdit))->id); $controlPropertyNamePatternURLParam = new LBoxFormControlFillHidden("pnpup", "", $this->propertyNamePatternURLParam); $form = new LBoxForm("record_xt_to_edit_{$id}", "post", "", "editovat"); $form->setTemplateFileName("lbox_form_xt_btn_edit.html"); $form->addControl($controlID); $form->addControl($controlRefPageEdit); $form->addControl($controlPropertyNamePatternURLParam); $form->addProcessor(new ProcessorRecordToEdit()); return $this->formToEdit = $form; } 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; } }
/** * private recaptcha key getter * @return string */ protected function getKeyPrivate() { try { return strlen($this->keyPrivate) > 0 ? $this->keyPrivate : LBoxConfigManagerProperties::getPropertyContentByName("recaptcha_key_private"); } catch (Exception $e) { throw $e; } }
/** * 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; } }
public function process() { try { $data = array(); $data["from"] = LBoxConfigManagerProperties::getPropertyContentByName("registration_confirm_mail_from"); $data["to"] = $this->form->getControlByName("email")->getValue(); $data["subject"] = "Potvrzeni registrace"; $data["page_confirm"] = LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getPropertyContentByName("ref_page_registration_confirm")); $data["processor_save"] = $this->processorSaveProfile; $mail = new MailProductsRegistrationConfirm($data); $mail->init(); } catch (Exception $e) { throw $e; } }
/** * spousti celou akci * @param string $to * @throws Exception */ public function init() { try { $to = LBoxConfigManagerProperties::getPropertyContentByName("contact_form_addresses"); $this->MIMEMail = new HTMLMIMEMail5(); $this->MIMEMail->setFrom($this->getFrom()); $this->MIMEMail->setSubject($this->getSubject()); $this->MIMEMail->setHeadCharset("UTF-8"); $this->MIMEMail->setHTMLCharset("UTF-8"); $this->MIMEMail->setTextCharset("UTF-8"); $this->MIMEMail->setHTML($this->getHTML()); if (!$this->MIMEMail->send((array) $to)) { throw new LBoxExceptionPage("Cannot send to address '{$to}'"); } } catch (Exception $e) { throw $e; } }
/** * 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; } }
public function prepare($name = "", $value = NULL) { try { $classNameInstance = get_class($this->instance); $editURLFilterColname = strlen($this->editURLFilterColname) > 0 ? $this->editURLFilterColname : eval("return {$classNameInstance}::\$idColName;"); switch ($name) { case "url_detail": if (strlen($this->propertyNameRefPageDetail) < 1) { return $this->instance->getParamDirect($this->editURLFilterColname); } return LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getPropertyContentByName($this->propertyNameRefPageDetail))->url . ":" . $this->instance->getParamDirect($this->editURLFilterColname); break; default: return $value; } } catch (Exception $e) { throw $e; } }
/** * 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; } }
/** * pretizeno o dalsi kontroly vztahujici se pouze na metanodes * @return bool */ public function isToShow() { try { if (!parent::isToShow()) { return false; } $forbiddenXTRoles = explode(",", LBoxConfigManagerProperties::getPropertyContentByName("metanodes_forbidden_xtroles")); array_walk($forbiddenXTRoles, "trim"); foreach ($forbiddenXTRoles as $forbiddenXTRole) { if (LBoxXTDBFree::isLogged()) { if (trim($forbiddenXTRole) == LBoxXTDBFree::getUserXTRecord()->ref_xtrole) { return false; } } else { if (trim($forbiddenXTRole) == LBoxXTProject::getUserXTRoleRecord()->id) { return false; } } } return true; } catch (Exception $e) { throw $e; } }
/** * getter na prvni URL param * @return string */ public static function getURLParamByPatternProperty($propertyName = "") { try { if (strlen($propertyName) < 1) { throw new LBoxExceptionPage(LBoxExceptionPage::MSG_PARAM_STRING_NOTNULL, LBoxExceptionPage::CODE_BAD_PARAM); } $pattern = LBoxConfigManagerProperties::getPropertyContentByName($propertyName); $pattern = str_ireplace("<url_param>", "([\\w-_\\.\\/\\\\ěščřžýáíéůúřťňĚďŠČŘŽÝÁÍÉŮÚŘŤĎŇ]+)", $pattern); foreach (LBoxFront::getUrlParamsArray() as $param) { if (preg_match("/{$pattern}/", $param, $matches)) { return $matches[1]; } } } catch (Exception $e) { throw $e; } }
/** * getter na stranku s editaci * @return LBoxPage */ public function getPageEdit() { try { if ($this->pageEdit instanceof LBoxPage) { return $this->pageEdit; } if (strlen($this->propertyNameRefPageEdit) < 1) { return NULL; } $this->pageEdit = LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getPropertyContentByName($this->propertyNameRefPageEdit)); $this->pageEdit->setOutputFilter(new OutputFilterPage($this->pageEdit)); return $this->pageEdit; } catch (Exception $e) { throw $e; } }
/** * vraci cestu k adresari sablon emailu * @return string */ protected function getTemplatesPath() { try { $path = LBoxConfigManagerProperties::getPropertyContentByName("path_templates_pdml"); $path = str_ireplace("<project>", LBOX_PATH_PROJECT, $path); return $path; } catch (Exception $e) { throw $e; } }
/** * pridava TALu namespace lbox * @param string $src * @param bool $nothrow * @return string */ function phptal_tales_lbox($src, $nothrow = false) { try { $srcArr = explode(".", $src); switch (strtolower($srcArr[0])) { case "component": if (strlen($name = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_COMPONENT_NAME_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } return '$ctx->SELF->getComponentById("' . $name . '")->getContent()'; break; case "page": $pageParams = explode("/", $srcArr[1]); if (!is_numeric($pageID = $pageParams[0]) || $pageID < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_PAGE_ID_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } unset($pageParams[0]); if (count($pageParams) < 1 || strlen(current($pageParams)) < 1) { return 'LBoxConfigManagerStructure::getPageById("' . $pageID . '", "OutputFilterPage")'; } else { return 'LBoxConfigManagerStructure::getPageById("' . $pageID . '", "OutputFilterPage")->' . current($pageParams); } break; case "page_by_property": $pageParams = explode("/", $srcArr[1]); if (!is_numeric($pageID = LBoxConfigManagerProperties::getPropertyContentByName($propertyName = $pageParams[0])) || $pageID < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_PAGE_ID_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } unset($pageParams[0]); if (count($pageParams) < 1 || strlen(current($pageParams)) < 1) { return 'LBoxConfigManagerStructure::getPageById("' . $pageID . '", "OutputFilterPage")'; } else { return 'LBoxConfigManagerStructure::getPageById("' . $pageID . '", "OutputFilterPage")->' . current($pageParams); } break; case "property": if (strlen($name = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_PROPERTY_NAME_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } return 'LBoxConfigManagerProperties::getPropertyContentByName("' . $name . '")'; break; case "acces": return 'AccesRecord::getInstance()'; break; case "front": if (strlen($frontCalling = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_FRONT_CALL_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } return 'LBoxFront::' . $frontCalling . '()'; break; case "xt": if (strlen($frontCalling = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_FRONT_CALL_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } if (count($frontCallingXTParts = explode("/", $frontCalling)) == 2) { return 'LBoxXTProject::' . reset($frontCallingXTParts) . '()->' . end($frontCallingXTParts); } else { return 'LBoxXTProject::' . $frontCalling . '()'; } break; case "xt_dbfree": if (strlen($frontCalling = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_FRONT_CALL_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } if (count($frontCallingXTParts = explode("/", $frontCalling)) == 2) { return 'LBoxXTDBFree::' . reset($frontCallingXTParts) . '()->' . end($frontCallingXTParts); } else { return 'LBoxXTDBFree::' . $frontCalling . '()'; } break; case "i18n": if (strlen($srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_I18N_CONDITION_INVALID . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } if (count($langConditionArr = explode("/", $srcArr[1])) != 2) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_I18N_CONDITION_INVALID . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } switch ($langConditionArr[0]) { case 'isDisplayLanguageCurrent': return 'LBoxFront::isDisplayLanguageCurrent("' . $langConditionArr[1] . '")'; break; default: if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_I18N_CONDITION_INVALID . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } break; case "langdomain": if (strlen($frontCalling = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_FRONT_CALL_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } return 'LBoxConfigManagerLangdomains::getInstance()->getNodeByDomain()->' . $frontCalling . ''; break; case "request": if (strlen($name = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_REQUEST_PARAM_NAME_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } switch ($name) { case "url": return "LBOX_REQUEST_URL"; break; case "url_virtual": return "LBOX_REQUEST_URL_VIRTUAL"; break; case "url_params": return "LBOX_REQUEST_URL_PARAMS"; break; case "url_query": return "LBOX_REQUEST_URL_QUERY"; break; case "url_path": return "LBOX_REQUEST_URL_PATH"; break; case "url_scheme": return "LBOX_REQUEST_URL_SCHEME"; break; case "url_host": return "LBOX_REQUEST_URL_HOST"; break; case "ip": return "LBOX_REQUEST_IP"; break; case "ip_my": return "LBOX_REQUEST_IP_MY"; break; case "agent": return "LBOX_REQUEST_AGENT"; break; case "referer": return "LBOX_REQUEST_REFERER"; break; case "request_time": return "LBOX_REQUEST_REQUEST_TIME"; break; } break; case "slot": if (strlen($name = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_SLOT_NAME_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } $silent = array_key_exists(2, $srcArr) && $srcArr[2] == "silent" ? "true" : "false"; return '$ctx->SELF->templateGetSlot("' . $name . '", ' . $silent . ')'; break; case 'slot_start': return '$ctx->SELF->templateSlotContentBegin()'; break; case 'slot_end': if (strlen($name = $srcArr[1]) < 1) { if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_SLOT_NAME_EMPTY . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_BAD_KEY); } } return '$ctx->SELF->templateSlotContentEnd("' . $name . '")'; break; case 'metanode': return '$ctx->SELF->getMetanode("' . $srcArr[1] . '", "' . $srcArr[2] . '")'; break; default: if (!$nothrow) { throw new LBoxExceptionFront(LBoxExceptionFront::MSG_TPL_LBOX_NS_BAD_CALL . " Called like lbox:{$src}", LBoxExceptionFront::CODE_TPL_LBOX_NS_BAD_CALL); } } return ""; } catch (Exception $e) { throw $e; } }
/** * vraci adresar * @return string * @throws LBoxException */ public function getDirName() { try { if (strlen($this->pathsByTypes[get_class($this)]) > 0) { return $this->pathsByTypes[get_class($this)]; } $path = LBoxConfigManagerProperties::getPropertyContentByName($this->propertyNamePath); $path = str_ireplace("<project>", LBOX_PATH_PROJECT, $path); if ($this->getPhotogallery()) { $path = str_ireplace("<photogallery_name>", LBoxUtil::fixFileName($this->getPhotogallery()->name), $path); $path = str_ireplace("<photogallery_url>", LBoxUtil::fixFileName($this->getPhotogallery()->getParamDirect("url")), $path); } $path = str_ireplace("/", SLASH, $path); $path = str_ireplace("\\", SLASH, $path); $this->createDirByPath($path); return $this->pathsByTypes[get_class($this)] = $path; } catch (Exception $e) { throw $e; } }
public function store() { try { // v pripade, ze nepouzivame databazi, access se neuklada if (LBoxConfigManagerProperties::getPropertyContentByName("log_access") < 1) { return; } if (!array_key_exists("request_time", $this->params) || !$this->params["request_time"]) { $this->params["request_time"] = LBOX_REQUEST_REQUEST_TIME; } if (array_key_exists("ref_xtuser", $this->params) && !is_numeric($this->params["ref_xtuser"])) { $this->params["ref_xtuser"] = "******"; } $this->params["session_id"] = session_id(); // pro jistotu na 2 pokusy try { parent::store(); } catch (DbControlException $e) { try { $idColName = $this->getClassVar("idColName"); $this->params[$idColName] = $this->getMaxId() + 1; parent::store(); } catch (Exception $e) { throw $e; } } } catch (Exception $e) { throw $e; } }