Esempio n. 1
0
 public function store()
 {
     try {
         if (!$this->isInDatabase()) {
             $this->params["ref_access"] = AccesRecord::getInstance()->id;
         }
         if (strlen($this->params["time_published"]) < 1) {
             $this->params["time_published"] = time();
         }
         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"]);
         }
         if (strlen($this->params["name_sk"]) < 1 && strlen($this->params["name_cs"]) > 0) {
             $this->params["name_sk"] = $this->params["name_cs"];
         }
         if (strlen($this->params["name_en"]) < 1 && strlen($this->params["name_cs"]) > 0) {
             $this->params["name_en"] = $this->params["name_cs"];
         }
         if (strlen($this->params["url_sk"]) < 1 && strlen($this->params["url_cs"]) > 0) {
             $this->params["url_sk"] = $this->params["url_cs"];
         }
         if (strlen($this->params["url_en"]) < 1 && strlen($this->params["url_cs"]) > 0) {
             $this->params["url_en"] = $this->params["url_cs"];
         }
         parent::store();
     } catch (Exception $e) {
         throw $e;
     }
 }
 public function filter(LBoxFormControl $control = NULL)
 {
     try {
         return LBoxUtil::getURLByNameString(trim($control->getValue()));
     } 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;
     }
 }
Esempio n. 5
0
 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 (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;
     }
 }
Esempio n. 8
0
 /**
  * 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;
     }
 }