public function prepare($name = "", $value = NULL) { try { switch ($name) { case "url": $pageItem = LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::gpcn($this->configVarNameArticleRefPage)); return LBoxUtil::getURLWithParams(array($this->instance->getParamDirect("url")), $pageItem->url); break; case "url_param": return $this->instance->getParamDirect("url"); break; case "urlAbsolute": return LBOX_REQUEST_URL_SCHEME . "://" . LBOX_REQUEST_URL_HOST . $this->prepare("url"); break; case "headingEntities": return htmlentities($this->prepare("heading")); break; case "publishedDate": return date("j.n. Y", $this->instance->time_published); break; case "published2": return date("j.n.Y | H:i:s", $this->instance->time_published); break; case "perex_raw": return strip_tags($this->instance->perex); break; default: return parent::prepare($name, $value); } } 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 { $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; } }
/** * Vrati kompletni logout URL * @return string * @throws Exception */ public function getURLLogout() { try { return LBoxUtil::getURLWithParams(array(LBoxFront::getURLParamNameLogout()), LBoxUtil::getURLWithoutParams(array(LBoxFront::getURLParamNameLogout()))); } 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 filter(LBoxFormControl $control = NULL) { try { return LBoxUtil::getURLByNameString(trim($control->getValue())); } catch (Exception $e) { throw $e; } }
/** * Vrati kompletni logout URL * @return string * @throws Exception */ public function getURLLogout() { try { return LBoxUtil::getURLWithParams(array("logout-dbfree"), LBoxUtil::getURLWithoutParams(array("logout-dbfree"))); } 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; } }
/** * combines code from defined "document root relative" paths and returns path to destination file * @param array files */ public function combine($files = array()) { try { if (strlen(LBoxJSCombine) < 1) { throw new LBoxException("\$extOut: " . LBoxException::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxException::CODE_BAD_CLASS_VAR); } if (count($files) < 1) { throw new LBoxException(LBoxException::MSG_PARAM_ARRAY_NOTNULL, LBoxException::CODE_BAD_PARAM); } $sDocRoot = $_SERVER['DOCUMENT_ROOT']; $destination = $this->getPathDestination(); LBoxUtil::createDirByPath($destination); // get and merge code $sCode = ""; $aLastModifieds = array(); foreach ($files as $file) { $file = LBOX_PATH_PROJECT . $file; $file = str_ireplace('project/project/', 'project/', $file); if (!file_exists($file)) { throw new LBoxExceptionFilesystem("{$file}: " . LBoxExceptionFilesystem::MSG_FILE_NOT_EXISTS, LBoxExceptionFilesystem::CODE_FILE_NOT_EXISTS); } $aLastModifieds[] = filemtime($file); $sCode .= file_get_contents($file) . "\n"; } // sort dates, newest first rsort($aLastModifieds); $fileName = md5($aLastModifieds[0]) . ".js"; $destinationFile = "{$destination}/{$fileName}"; // cache the data if (!file_exists($destinationFile)) { //LBoxFirePHP::warn("$destinationFile zatim NEexistuje - vytvarim novy"); switch (LBoxConfigSystem::getInstance()->getParamByPath("output/js_compress")) { case 1: $sCode = $this->compress($sCode); break; case -1: if (LBOX_REQUEST_IP != "127.0.0.1") { $sCode = $this->compress($sCode); } break; } $sCode = "/*merged from files: " . implode($files, ",\n") . "*/" . $sCode; $fo = fopen($destinationFile, "w"); fwrite($fo, $sCode); fclose($fo); } else { //LBoxFirePHP::log("$destinationFile uz existuje"); } return str_replace(LBOX_PATH_PROJECT, "", $destinationFile); } catch (Exception $e) { throw $e; } }
/** * pretizeno o automaticke vytvareni sablony z defaultni * @return string */ protected function getTemplatePath() { try { $pathTemplate = parent::getTemplatePath(); if (!file_exists($pathTemplate)) { $srcPath = LBoxConfigSystem::getInstance()->getParamByPath("pages/templates/path") . SLASH . LBoxConfigSystem::getInstance()->getParamByPath("pages/templates/default"); LBoxUtil::copyFile($srcPath, $pathTemplate); } return $pathTemplate; } catch (Exception $e) { throw $e; } }
protected function getPath() { try { $pathGallery = LBoxConfigManagerProperties::gpcn("path_photos_photogalleries"); $pathGallery = str_replace("<project>", LBOX_PATH_PROJECT, $pathGallery); $pathGallery = str_replace("<photogallery_name>", $this->getPhotogallery()->name, $pathGallery); $pathGallery = str_replace("<photogallery_url>", $this->getPhotogallery()->getParamDirect("url"), $pathGallery); $fileName = $this->instance->getParamDirect("filename"); $ext = $this->instance->getParamDirect("ext"); return LBoxUtil::fixPathSlashes("{$pathGallery}/{$fileName}.{$ext}"); } catch (Exception $e) { throw $e; } }
/** * getter na file path * @return string */ protected function getFilePath() { try { if (strlen($this->pathDataSave) < 1) { throw new LBoxExceptionFormProcessor(LBoxExceptionFormProcessor::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxExceptionFormProcessor::CODE_BAD_INSTANCE_VAR); } $path = $this->pathDataSave; $path = str_replace("<project>", LBOX_PATH_PROJECT, $path); $path = LBoxUtil::fixPathSlashes($path); LBoxUtil::createDirByPath(dirname($path)); return $path; } catch (Exception $e) { throw $e; } }
public function filter(LBoxFormControl $control = NULL) { try { if (!$this->controlName instanceof LBoxFormControl) { throw new LBoxExceptionFormFilter("Bad instance var", LBoxExceptionFormFilter::CODE_BAD_INSTANCE_VAR); } if (strlen($control->getValue()) < 1) { return LBoxUtil::getURLByNameString(trim($this->controlName->getValue())); } else { return $control->getValue(); } } catch (Exception $e) { throw $e; } }
public function store() { try { if (strlen($this->params["url_cs"]) < 1) { $this->params["url_cs"] = LBoxUtil::getURLByNameString($this->params["name_cs"]); } if (strlen($this->params["url_sk"]) < 1) { $this->params["url_sk"] = LBoxUtil::getURLByNameString($this->params["name_sk"]); } if (strlen($this->params["url_en"]) < 1) { $this->params["url_en"] = LBoxUtil::getURLByNameString($this->params["name_en"]); } parent::store(); } catch (Exception $e) { throw $e; } }
public function store() { try { if (!$this->params["time_published"] || strtolower($this->params["time_published"]) == "<<null>>") { $this->params["time_published"] = time(); } if (strlen($this->params["url_cs"]) < 1 || $this->params["url_cs"] == "<<NULL>>") { $this->params["url_cs"] = LBoxUtil::getURLByNameString($this->params["heading_cs"]); } if (strlen($this->params["url_sk"]) < 1 || $this->params["url_sk"] == "<<NULL>>") { $this->params["url_sk"] = LBoxUtil::getURLByNameString($this->params["heading_sk"]); } $this->params["ref_access"] = AccesRecord::getInstance()->id; parent::store(); } catch (Exception $e) { throw $e; } }
/** * @param string $value * @return LBoxConfigItemStructure */ protected function getExistingRelevantRecord($value = "") { try { if (strlen($value) < 1) { throw new LBoxExceptionFormValidator(LBoxExceptionFormValidator::MSG_PARAM_STRING_NOTNULL, LBoxExceptionFormValidator::CODE_BAD_PARAM); } if (!$this->controlParentID instanceof LBoxFormControl) { throw new LBoxExceptionFormValidator(LBoxExceptionFormValidator::MSG_INSTANCE_VAR_INSTANCE_CONCRETE_NOTNULL, LBoxExceptionFormValidator::CODE_BAD_INSTANCE_VAR); } try { if ($parentID = $this->controlParentID->getValue()) { $parent = LBoxConfigManagerStructure::getInstance()->getPageById($parentID); $urlParts = explode("/", $value); foreach ($urlParts as $part) { if (strlen(trim($part)) > 0) { $out = $part; } } $urlPart = LBoxUtil::getURLByNameString($out); $value = $parent->url . "/" . $urlPart . "/"; } else { $value = "/{$value}/"; } $value = preg_replace("/(\\/+)/", "/", $value); if ($page = LBoxConfigManagerStructure::getInstance()->getPageByUrl($value)) { return $page; } } catch (Exception $e) { switch ($e->getCode()) { case LBoxExceptionConfigStructure::CODE_NODE_BYURL_NOT_FOUND: NULL; break; default: throw $e; } } } 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; } }
protected function getURLParamByPatterProperty($propertyName = "") { try { return LBoxUtil::getURLParamByPatternProperty($propertyName); } catch (Exception $e) { throw $e; } }
/** * getter na cestu k sablone * @return string */ protected function getTemplatePath() { try { return LBoxUtil::fixPathSlashes($this->templatePath . "/" . $this->getTemplateFileName()); } catch (Exception $e) { throw $e; } }
/** * vraci celou cestu k sablone control (ovlivnenou atributem filenameTemplate instance control) * @return string */ protected function getPathTemplate() { try { $pathTemplatesForms = LBoxConfigSystem::getInstance()->getParamByPath("metarecords/templates/path"); return LBoxUtil::fixPathSlashes("{$pathTemplatesForms}/" . $this->filenameTemplate); } catch (Exception $e) { throw $e; } }
/** * runs all defined tests * if tests directory contains coverage folder, it will generate coverage results there */ function run_tests() { global $argv; // read test directory and run all tests $path = dirname(__FILE__) . '/tests'; $dir = dir($path); $lime_output = new lime_output(); $coverage = $coveragePath = ''; $tests = array(); while (($entry = $dir->read()) !== false) { if ($entry == '.' || $entry == '..') { continue; } if (is_dir("{$path}/{$entry}")) { if ($entry == 'coverage') { $coveragePath = $path . '/' . $entry; } continue; } if (is_test($entry)) { $tests[getTestNameByPath("{$path}/{$entry}")] = "{$path}/{$entry}"; } } // run concrete test if (($testName = $argv[1]) && can_param_be_test($testName)) { $testName .= 'Test'; if (!array_key_exists($testName, $tests)) { $lime_output->error("cannot find test " . $argv[1] . ' in ' . $path); return; } if ($coveragePath) { $coveragePathConcrete = $coveragePath . '/' . $testName; LBoxUtil::createDirByPath($coveragePathConcrete); $coverage = '--coverage-html ' . $coveragePathConcrete . ' '; //$coverage .= ' --coverage-clover '. $coveragePathConcrete . '/clover.xml '; } $path = $tests[$testName]; $call = "phpunit {$coverage} {$path}"; //$lime_output->info($call); $out = getCallReturn($call); if (preg_match('/OK \\((\\d+) test(s?)\\, (\\d+) assertion(s?)\\)/', $out, $matchAll)) { $lime_output->green_bar($testName); } else { $lime_output->red_bar($testName); } echo $out; if (strlen($coverage) > 0) { if (!doesContainErrorNotification($out)) { $lime_output->info("coverage results in {$coveragePath}"); } } return; } // run all loaded tests if (count($tests) < 1) { $lime_output->comment('no test found in ' . $path); return; } $assertionsCountAtomic = 0; $testsCountAtomic = 0; foreach ($tests as $name => $path) { if ($coveragePath) { $coveragePathConcrete = $coveragePath . '/' . $name; LBoxUtil::createDirByPath($coveragePathConcrete); $coverage = '--coverage-html ' . $coveragePathConcrete . ' '; //$coverage .= ' --coverage-clover '. $coveragePathConcrete . '/clover.xml '; } $call = "phpunit {$coverage} {$path}"; //$lime_output->info($call); $out = getCallReturn($call); $space = ''; if (preg_match('/OK \\((\\d+) test(s?)\\, (\\d+) assertion(s?)\\)/', $out, $matchAll)) { $i = 1; foreach ($matchAll as $k => $v) { if (is_numeric($v)) { $match[$i] = $v; $i++; } } $assertionsCountAtomic += $match[2]; $testsCountAtomic += $match[1]; $outPartName = $name . ' (' . $match[1] . ' tests, ' . $match[2] . ' assertions)'; for ($i = 0; $i < 68 - strlen($outPartName); $i++) { $space .= ' '; } $lime_output->green_bar($outPartName . $space . 'OK '); } else { for ($i = 0; $i < 64 - strlen($name); $i++) { $space .= ' '; } $lime_output->red_bar($name . $space . 'FAILED '); echo $out; } } $lime_output->echoln("{$testsCountAtomic} tests, {$assertionsCountAtomic} assertions done", array('fg' => 'green')); if (strlen($coverage) > 0) { if (!doesContainErrorNotification($out)) { $lime_output->info("coverage results in {$coveragePath}"); } } $dir->close(); }
/** * getter na cestu k fotkam * @return string */ protected function getPathPhotos() { try { $pathGallery = LBoxConfigManagerProperties::gpcn("path_photos_photogalleries"); $pathGallery = str_replace("<project>", LBOX_PATH_PROJECT, $pathGallery); $pathGallery = str_replace("<photogallery_name>", $this->get("name"), $pathGallery); return LBoxUtil::fixPathSlashes($pathGallery); } catch (Exception $e) { throw $e; } }
public function process() { try { if (strlen($classNameRecord = $this->classNameRecord) < 1) { throw new LBoxExceptionPage(LBoxExceptionPage::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxExceptionPage::CODE_BAD_INSTANCE_VAR); } $record = $this->getRecord(); foreach ($this->form->getControls() as $control) { if ($control instanceof LBoxFormControlMultiple) { continue; } if ($control instanceof LBoxFormControlSpamDefense) { continue; } if ($control->getName() == eval("return {$classNameRecord}::\$idColName;")) { continue; } if ($control->getName() == "filter_by") { continue; } if (is_numeric(array_search($control->getName(), $this->controlsIgnore))) { continue; } if ($control instanceof LBoxFormControlChooseMore) { $colNamesChooseMoreChecked[$control->getName()] = array(); // choose more pocita s defaultnim schematem sloupcu odvozenych od options values podle LBoxFormProcessorSQLCreateTable foreach ($control->getValue() as $value) { $colNamesChooseMoreChecked[$control->getName()][] = $colName = strtolower($control->getName()) . "_" . strtolower(LBoxUtil::getURLByNameString($value)); $record->{$colName} = 1; } // zpetna kontrola options, ktere nebyly zaskrtle a tim by mely byt vynulovany foreach ($record as $colName => $value) { if (preg_match('/^' . strtolower($control->getName()) . '_' . '(.+)$/', $colName, $matches) && $value) { if (!is_numeric(array_search($colName, $colNamesChooseMoreChecked[$control->getName()]))) { $record->{$colName} = 0; } } } continue; } if ($control->getName() == "photo_delete") { if ($control->getValue()) { $record->deletePhoto(); } continue; } if ($control->getName() == "photo") { if ($control instanceof LBoxFormControlFile && $control->getValueFiles()) { $record->ref_photo = $this->getUploadedImageByControl($control)->id; } continue; } $colName = $control->getName(); $record->{$colName} = strlen($control->getValue()) > 0 ? $control->getValue() : "<<NULL>>"; } //DbControl::$debug=true; $record->store(); } catch (Exception $e) { throw $e; } }
/** * vraci posledni cast aktualni URL * @return string */ protected function getURLPartCurrentLast() { try { $urlParts = explode("/", LBOX_REQUEST_URL_VIRTUAL); foreach ($urlParts as $part) { if (strlen(trim($part)) > 0) { $out = $part; } } return LBoxUtil::getURLByNameString($out); } catch (Exception $e) { throw $e; } }
/** * * @return PHPTAL */ protected function getTAL() { try { if (!$this->TAL instanceof PHPTAL) { $this->TAL = new PHPTAL($this->getPathTemplate()); } $translator = new LBoxTranslator($this->getPathTemplate()); // zajistit existenci ciloveho adresare PHP kodu pro TAL: $phptalPhpCodeDestination = LBoxUtil::fixPathSlashes(LBoxConfigSystem::getInstance()->getParamByPath("output/tal/PHPTAL_PHP_CODE_DESTINATION")); LBoxUtil::createDirByPath($phptalPhpCodeDestination); $this->TAL->setTranslator($translator); $this->TAL->setForceReparse(LBoxConfigSystem::getInstance()->getParamByPath("output/tal/PHPTAL_FORCE_REPARSE")); $this->TAL->setPhpCodeDestination($phptalPhpCodeDestination); $this->TAL->SELF = $this; return $this->TAL; } catch (Exception $e) { throw $e; } }
/** * vraci cesty k lang souborum podle jazyka a sablony, ktera instanci obsluhuje * @return array */ protected function getLanguageFilePaths() { try { $lang = LBoxFront::getDisplayLanguage(); $out = array(); $out[] = LBoxUtil::fixPathSlashes($this->templatePath . ".{$lang}.xml"); $out[] = LBoxUtil::fixPathSlashes(LBOX_PATH_FILES_I18N . "/project.{$lang}.xml"); return $out; } catch (Exception $e) { throw $e; } }
/** * getter na instanci komponenty starajici se o samotne cachovani * @return Cache_Lite */ protected function getCache() { try { if ($this->cache instanceof Cache_Lite) { return $this->cache; } $dir = LBoxUtil::fixPathSlashes($this->getDir()); $dir = substr($dir, -1) == SLASH ? $dir : $dir . SLASH; self::createDirByPath($dir); $cacheOptions = array("cacheDir" => $dir, "lifeTime" => $this->lifeTime, "hashedDirectoryLevel" => $this->hashedDirectoryLevel); if (WIN) { $cacheOptions["fileLocking"] = false; $cacheOptions["writeControl"] = false; $cacheOptions["readControl"] = false; $cacheOptions["hashedDirectoryLevel"] = 0; } $this->cache = new Cache_Lite($cacheOptions); $this->cache->_hashedDirectoryUmask = self::$_hashedDirectoryUmask; return $this->cache; } 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; } }
/** * 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; } }
die; } // firePHP debug //LBoxFirePHP::log(LBoxConfigSystem::getInstance()->getParamByPath("metanodes/images/path")); //LBoxFirePHP::table($_FILES['image'], "uploaded image data"); try { ////////////////////////////////////////////////////////////////////// // saving data ////////////////////////////////////////////////////////////////////// if (strlen($tmpPath = $_FILES['image']['tmp_name']) > 0) { $imgName = $_FILES["image"]["name"]; $userRecord = LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord() : LBoxXTDBFree::getUserXTRecord(); $dirTarget = LBoxUtil::fixPathSlashes(LBoxConfigSystem::getInstance()->getParamByPath("metanodes/images/path") . SLASH . $userRecord->nick . SLASH . date("Ym")); $imgNameTarget = date("YmdHis") . "." . LBoxUtil::getExtByFilename($imgName); $imageURL = str_replace('\\', '/', LBoxUtil::fixPathSlashes(str_replace(LBOX_PATH_PROJECT, "", "{$dirTarget}/{$imgNameTarget}"))); LBoxUtil::createDirByPath($dirTarget); if (!move_uploaded_file($tmpPath, "{$dirTarget}" . SLASH . "{$imgNameTarget}")) { throw new LBoxExceptionFilesystem(LBoxExceptionFilesystem::MSG_FILE_UPLOAD_ERROR, LBoxExceptionFilesystem::CODE_FILE_UPLOAD_ERROR); } $ret = new stdclass(); // PHP base class $ret->status = "UPLOADED"; $ret->image_url = $imageURL; header("HTTP/1.1 200 OK"); header("content-type: text/html"); die(json_encode($ret)); } } catch (Exception $e) { throwExceptionToFirePHP($e); $ret = new stdclass(); // PHP base class