Пример #1
0
 public function store()
 {
     try {
         parent::store();
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #2
0
 /**
  * pretizeno o mazani titulni fotky
  */
 public function delete()
 {
     try {
         $this->deletePhoto();
         parent::delete();
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #3
0
 public function store()
 {
     try {
         if (!$this->isInDatabase()) {
             $this->params["created"] = date("Y-m-d H:i:s");
         }
         parent::store();
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #4
0
 /**
  * pretizeno o mazani fotek
  */
 public function delete()
 {
     try {
         foreach ($this->getPhotos() as $photo) {
             $photo->delete();
         }
         @rmdir($this->getPathPhotos());
         parent::delete();
     } 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;
     }
 }
Пример #6
0
 public function store()
 {
     try {
         if (!$this->params["created"]) {
             $this->params["created"] = date("Y-m-d H:i:s");
         }
         if (!$this->params["ref_xtRole"]) {
             $this->params["ref_xtRole"] = LBoxXT::getRoleRecordByName(LBoxXT::XT_ROLE_NAME_USER)->id;
         }
         if (!$this->isInDatabase()) {
             $this->params["hash"] = md5($this->get("nick") . $this->hashString . $this->get("password"));
         }
         parent::store();
         // vygenerovani hashe
         if (strlen(trim($this->params["hash"])) < 1) {
             $hashString = "kiou5s" . (string) rand(1, 9999) . $this->params[self::$idColName];
             $this->__set("hash", md5((string) $hashString));
         }
         parent::store();
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #7
0
 public function getForm()
 {
     try {
         if ($this->form instanceof LBoxForm) {
             return $this->form;
         }
         $rType = is_string($this->record) ? $this->record : get_class($this->record);
         $record = $this->record;
         $idColName = eval("return {$rType}::\$idColName;");
         $formID = "metarecord-{$rType}-" . ($this->record->isInDatabase() ? $this->record->{$idColName} : "");
         $subCtrls["type"] = new LBoxFormControlFillHidden("type", "", $rType);
         $subCtrls["type"]->setTemplateFileName("metarecord_hidden.html");
         $subCtrls[$idColName] = new LBoxFormControlFillHidden($idColName, "", $this->record->isInDatabase() ? $this->record->{$idColName} : "");
         $subCtrls[$idColName]->setTemplateFileName("metarecord_hidden.html");
         $reloadOnComplete = false;
         //nasazet tam jednotlive record attributes
         foreach ($record->getAttributes() as $attribute) {
             if (array_key_exists("visibility", $attribute) && $attribute["visibility"] == "protected") {
                 continue;
             }
             $attName = $attribute["name"];
             $default = $attribute["default"];
             $type = $attribute["type"];
             $validatorType = "LBoxFormValidatorMetarecord" . ucfirst($type);
             $filterType = "LBoxFormFilterMetarecord" . ucfirst($type);
             if (array_key_exists("reference", $attribute)) {
                 switch (true) {
                     case strlen($recordRefType = $attribute["reference"]["type"]) < 1:
                         throw new LBoxExceptionMetaRecords("type: " . LBoxExceptionMetaRecords::MSG_BAD_DEFINITION_REFERENCE, LBoxExceptionMetaRecords::CODE_BAD_DEFINITION_REFERENCE);
                         break;
                     case strlen($recordRefLabel = $attribute["reference"]["label"]) < 1:
                         throw new LBoxExceptionMetaRecords("label: " . LBoxExceptionMetaRecords::MSG_BAD_DEFINITION_REFERENCE, LBoxExceptionMetaRecords::CODE_BAD_DEFINITION_REFERENCE);
                         break;
                 }
                 $testR = new $recordRefType();
                 if ($testR instanceof AbstractRecords) {
                     $recordRefType = eval("return {$recordRefType}::\$itemType;");
                 }
                 $recordsRefType = eval("return {$recordRefType}::\$itemsType;");
                 $recordIDColName = eval("return {$recordRefType}::\$idColName;");
                 $testR = new $recordRefType();
                 switch (true) {
                     // image reference
                     case $testR instanceof PhotosRecord:
                         $reloadOnComplete = true;
                         if ($this->record->isInDatabase() && $this->record->{$attName}) {
                             $recordsPhotoReference = new $recordsRefType(array($recordIDColName => $this->record->{$attName}));
                             if ($recordsPhotoReference->count() < 1) {
                                 throw new LBoxExceptionMetaRecords(LBoxExceptionMetaRecords::MSG_BAD_DATA_REFERENCE_IMAGE, LBoxExceptionMetaRecords::CODE_BAD_DATA_REFERENCE_IMAGE);
                             }
                             $recordsPhotoReference->setOutputFilterItemsClass(array_key_exists("of", $attribute["reference"]) ? $attribute["reference"]["of"] : "OutputFilterPhoto");
                             $subCtrls[$attName] = new LBoxFormControlBool($attName, "delete {$attName}");
                             $subCtrls[$attName]->setTemplateFileName("metarecord_photo_delete.html");
                             $subCtrls[$attName]->photo = $recordsPhotoReference->current();
                             $subCtrls[$attName]->action = "image-remove";
                         } else {
                             $subCtrls[$attName] = new LBoxFormControlFile($attName, $attName);
                             $subCtrls[$attName]->setTemplateFilename("metarecord_photo.html");
                             $subCtrls[$attName]->addValidator(new LBoxFormValidatorFileImage());
                             $subCtrls[$attName]->action = "image-add";
                         }
                         break;
                         // other references
                     // other references
                     default:
                         $records = new $recordsRefType(false, array($recordRefLabel => 1));
                         $recordsIDColName = eval("return {$recordRefType}::\$idColName;");
                         $optionsPrepend = $attribute["required"] ? array() : array(" " => " ");
                         $subCtrls[$attName] = new LBoxFormControlChooseOneFromRecords($attName, $attName, $this->record->isInDatabase() ? $this->record->{$attName} : $default, $records, $colnameValue = $recordsIDColName, $recordRefLabel, $colnameTitle = "", $optionsPrepend);
                         $subCtrls[$attName]->setTemplateFilename("metarecord_reference.html");
                 }
             } else {
                 $subCtrls[$attName] = new LBoxFormControlFill($attName, $attName, $this->record->isInDatabase() ? $this->record->{$attName} : $default);
                 $subCtrls[$attName]->setTemplateFilename("metarecord_" . $attribute["type"] . ".html");
             }
             $subCtrls[$attName]->addFilter(new LBoxFormFilterTrim());
             $subCtrls[$attName]->addFilter(new $filterType());
             $subCtrls[$attName]->addValidator(new $validatorType());
             if ($attribute["required"]) {
                 $subCtrls[$attName]->setRequired(true);
             }
         }
         $subCtrls["action_reload_on_complete"] = new LBoxFormControlFillHidden("action_reload_on_complete", "", (int) $reloadOnComplete);
         // vlozime ho do dialog boxu pro JS GUI
         $ctrlDialog = new LBoxFormControlMultiple("dialog", "");
         $ctrlDialog->setTemplateFileName("metarecord_dialog.html");
         foreach ($subCtrls as $subCtrl) {
             $ctrlDialog->addControl($subCtrl);
         }
         $form = new LBoxForm($formID, "post", "", "editovat");
         $form->setTemplateFileName("metarecord_xt_edit.html");
         $form->action = LBoxConfigSystem::getInstance()->getParamByPath("metarecords/api/url");
         $form->addControl($ctrlDialog);
         $form->addProcessor(new ProcessorMetaRecordEdit());
         $form->className = "metarecord metarecord-{$rType}";
         return $this->form = $form;
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #8
0
 /**
  * pretizeno o cachovani
  * @see lBox/dbi/AbstractPaterns/AbstractRecord::hasParent()
  */
 public function getParent()
 {
     try {
         if ($this->parent) {
             return $this->parent;
         }
         return $this->parent = parent::getParent();
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #9
0
 public function delete()
 {
     try {
         @unlink($this->getFilePath(true));
         parent::delete();
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #10
0
 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;
     }
 }