/**
  * prida photo podle predaneho controlu
  * @param LBoxFormControlBool $control
  */
 protected function addPhotoByControl(LBoxFormControlFile $control)
 {
     try {
         if (!$this->record instanceof AbstractRecord) {
             throw new LBoxExceptionFormProcessor("Cannot find stored record!", LBoxExceptionFormProcessor::CODE_BAD_INSTANCE_VAR);
         }
         $attributeName = $control->getName();
         $attribute = $this->getAttributeByName($attributeName);
         $imageType = $attribute["reference"]["type"];
         $testRI = new $imageType();
         if ($testRI instanceof AbstractRecords) {
             $imageType = eval("return {$imageType}::\$itemType;");
         }
         $imageIDColName = eval("return {$imageType}::\$idColName;");
         $dataFilesimage = $control->getValueFiles();
         if ($dataFilesimage["size"] < 1) {
             return;
         }
         if ($dataFilesimage["size"] > 0) {
             $image = new $imageType();
         }
         if (!$image instanceof PhotosRecord) {
             throw new LBoxExceptionFormProcessor("Image record of wrong type '" . get_class($image) . "'!");
         }
         $image->saveUploadedFile($dataFilesimage["tmp_name"], $dataFilesimage["name"], $dataFilesimage["size"]);
         if (array_key_exists("size_resize", $attribute["reference"])) {
             if (!array_key_exists("x", $attribute["reference"]["size_resize"])) {
                 throw new LBoxExceptionMetaRecords(LBoxExceptionMetaRecords::MSG_BAD_DEFINITION_REFERENCE_IMAGE_RESIZE, LBoxExceptionMetaRecords::CODE_BAD_DEFINITION_REFERENCE_IMAGE_RESIZE);
             }
             $image->resize($attribute["reference"]["size_resize"]["x"], $attribute["reference"]["size_resize"]["y"], (bool) $attribute["reference"]["size_resize"]["proportions"]);
         }
         if (array_key_exists("size_limit", $attribute["reference"])) {
             if (!array_key_exists("longer", $attribute["reference"]["size_limit"])) {
                 throw new LBoxExceptionMetaRecords(LBoxExceptionMetaRecords::MSG_BAD_DEFINITION_REFERENCE_IMAGE_LIMIT, LBoxExceptionMetaRecords::CODE_BAD_DEFINITION_REFERENCE_IMAGE_LIMIT);
             }
             $image->limitSize($attribute["reference"]["size_limit"]["longer"]);
         }
         $image->store();
         $this->record->{$attributeName} = $image->{$imageIDColName};
         $this->record->store();
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * 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;
     }
 }