Ejemplo n.º 1
0
 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 validate(LBoxFormControl $control = NULL)
 {
     try {
         if (strlen($control->getValue()) > LBoxConfigManagerProperties::gpcn("form_max_length_discussion_text")) {
             throw new LBoxExceptionFormValidator(LBoxExceptionFormValidator::MSG_FORM_VALIDATION_CONTROL_TOO_LONG, LBoxExceptionFormValidator::CODE_FORM_VALIDATION_CONTROL_TOO_LONG);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 3
0
 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;
     }
 }
 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;
     }
 }
 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;
     }
 }
Ejemplo n.º 6
0
 /**
  * vytvori a vrati photos record podle predaneho file controlu
  * @param LBoxFormControlFile $control
  * @return PhotosRecord
  */
 protected function getUploadedImageByControl(LBoxFormControlFile $control)
 {
     try {
         $classNamePhotosRecord = $this->classNamePhotosRecord;
         $dataFilesPhoto = $control->getValueFiles();
         if ($dataFilesPhoto["size"] > 0) {
             $photo = new $classNamePhotosRecord();
             if (!$photo instanceof PhotosRecord) {
                 throw new LBoxExceptionFormProcessor("Image record of wrong type!");
             }
             $photo->saveUploadedFile($dataFilesPhoto["tmp_name"], $dataFilesPhoto["name"], $dataFilesPhoto["size"]);
             if (LBoxConfigManagerProperties::gpcn($this->propertyNameUploadedPhotoSizeX) > 0 && LBoxConfigManagerProperties::gpcn($this->propertyNameUploadedPhotoSizeY)) {
                 switch ($this->uploadedPhotoResizeType) {
                     case "resize":
                         $photo->resize(LBoxConfigManagerProperties::gpcn($this->propertyNameUploadedPhotoSizeX), LBoxConfigManagerProperties::gpcn($this->propertyNameUploadedPhotoSizeY), $this->uploadedPhotoResizeKeepProportions);
                         break;
                     case "limit":
                         $photo->limitSize(LBoxConfigManagerProperties::gpcn($this->propertyNameUploadedPhotoSizeX) > LBoxConfigManagerProperties::gpcn($this->propertyNameUploadedPhotoSizeY) ? LBoxConfigManagerProperties::gpcn($this->propertyNameUploadedPhotoSizeX) : LBoxConfigManagerProperties::gpcn($this->propertyNameUploadedPhotoSizeY));
                         break;
                 }
             }
             $photo->store();
             return $photo;
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 7
0
 /**
  * vraci, jestli je cache na aktualni strance zapnuta
  * @return bool
  */
 public function isCacheON()
 {
     try {
         switch (true) {
             case !LBoxConfigManagerProperties::gpcn("cache_front"):
             case LBoxFront::getPage()->cache_off:
             case LBoxFront::getPage()->cache_only_notlogged && LBoxXTProject::isLogged():
                 return false;
                 break;
             default:
                 return true;
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 8
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;
     }
 }
Ejemplo n.º 9
0
 /**
  * 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;
     }
 }
Ejemplo n.º 10
0
 public function testGetPropertyContent()
 {
     $content = "testovaci obsah";
     $this->assertType("LBoxConfigItemProperty", $property = LBoxConfigProperties::getInstance()->getCreateItem("phpunit_test", $content));
     LBoxConfigProperties::getInstance()->store();
     $this->assertSame($content, LBoxConfigManagerProperties::gpcn("phpunit_test"));
     $this->assertType("LBoxConfigItemProperty", $property = LBoxConfigManagerProperties::getInstance()->getPropertyByName("phpunit_test"));
     $property->delete();
     LBoxConfigProperties::getInstance()->store();
 }
Ejemplo n.º 11
0
 /**
  * getter na file path
  * @return string
  */
 protected function getFilePath()
 {
     try {
         if (strlen($this->propertyNamePathData) < 1) {
             throw new LBoxExceptionFormProcessor(LBoxExceptionFormProcessor::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxExceptionFormProcessor::CODE_BAD_INSTANCE_VAR);
         }
         $path = LBoxConfigManagerProperties::gpcn($this->propertyNamePathData);
         $path = str_replace("<project>", LBOX_PATH_PROJECT, $path);
         $path = LBoxUtil::fixPathSlashes($path);
         return $path;
     } catch (Exception $e) {
         throw $e;
     }
 }