Example #1
0
        public virtual XVar buildUserFile(dynamic _param_file)
        {
            #region pass-by-value parameters
            dynamic file = XVar.Clone(_param_file);
            #endregion

            dynamic hasThumbnail = null, userFile = XVar.Array();
            userFile = XVar.Clone(XVar.Array());
            userFile.InitAndSetArrayItem(file["usrName"], "name");
            userFile.InitAndSetArrayItem(file["size"], "size");
            userFile.InitAndSetArrayItem(file["type"], "type");
            userFile.InitAndSetArrayItem(CommonFunctions.CheckImageExtension((XVar)(file["name"])) != false, "isImg");
            if (XVar.Pack(file["error"]))
            {
                userFile.InitAndSetArrayItem(file["error"], "error");
            }
            hasThumbnail = XVar.Clone(file["thumbnail"] != "");
            userFile.InitAndSetArrayItem(MVCFunctions.GetTableLink(new XVar("mfhandler"), new XVar(""), (XVar)(MVCFunctions.Concat("file=", MVCFunctions.RawUrlEncode((XVar)(userFile["name"])), "&table=", MVCFunctions.RawUrlEncode((XVar)(this.table)), "&field=", MVCFunctions.RawUrlEncode((XVar)(this.field)), "&pageType=", MVCFunctions.RawUrlEncode((XVar)(this.pageType)), (XVar.Pack(this.tkeys != "") ? XVar.Pack(this.tkeys) : XVar.Pack(MVCFunctions.Concat("&fkey=", this.formStamp)))))), "url");
            if (XVar.Pack(hasThumbnail))
            {
                userFile.InitAndSetArrayItem(MVCFunctions.Concat(userFile["url"], "&thumbnail=1"), "thumbnail_url");
            }
            else
            {
                userFile.InitAndSetArrayItem("", "thumbnail_url");
            }
            return(userFile);
        }
Example #2
0
        public override XVar readWebValue(dynamic avalues, dynamic blobfields, dynamic _param_legacy1, dynamic _param_legacy2, dynamic filename_values)
        {
            #region pass-by-value parameters
            dynamic legacy1 = XVar.Clone(_param_legacy1);
            dynamic legacy2 = XVar.Clone(_param_legacy2);
            #endregion

            getPostValueAndType();
            if (XVar.Pack(MVCFunctions.FieldSubmitted((XVar)(MVCFunctions.Concat(this.goodFieldName, "_", this.id)))))
            {
                dynamic fileNameForPrepareFunc = null;
                fileNameForPrepareFunc = XVar.Clone(CommonFunctions.securityCheckFileName((XVar)(MVCFunctions.postvalue((XVar)(MVCFunctions.Concat("filename_", this.goodFieldName, "_", this.id))))));
                if (this.pageObject.pageType != Constants.PAGE_EDIT)
                {
                    this.webValue = XVar.Clone(MVCFunctions.prepare_upload((XVar)(this.field), new XVar("upload2"), (XVar)(fileNameForPrepareFunc), (XVar)(fileNameForPrepareFunc), new XVar(""), (XVar)(this.id), (XVar)(this.pageObject)));
                }
                else
                {
                    if (MVCFunctions.substr((XVar)(this.webType), new XVar(0), new XVar(4)) == "file")
                    {
                        dynamic prepearedFile = XVar.Array();
                        prepearedFile = XVar.Clone(MVCFunctions.prepare_file((XVar)(this.webValue), (XVar)(this.field), (XVar)(this.webType), (XVar)(fileNameForPrepareFunc), (XVar)(this.id)));
                        if (!XVar.Equals(XVar.Pack(prepearedFile), XVar.Pack(false)))
                        {
                            dynamic filename = null;
                            this.webValue = XVar.Clone(prepearedFile["value"]);
                            filename      = XVar.Clone(prepearedFile["filename"]);
                        }
                        else
                        {
                            this.webValue = new XVar(false);
                        }
                    }
                    else
                    {
                        if (MVCFunctions.substr((XVar)(this.webType), new XVar(0), new XVar(6)) == "upload")
                        {
                            if (XVar.Pack(fileNameForPrepareFunc))
                            {
                                this.webValue = XVar.Clone(fileNameForPrepareFunc);
                            }
                            if (this.webType == "upload1")
                            {
                                dynamic oldValues = XVar.Array();
                                oldValues = XVar.Clone(this.pageObject.getOldRecordData());
                                fileNameForPrepareFunc = XVar.Clone(oldValues[this.field]);
                            }
                            this.webValue = XVar.Clone(MVCFunctions.prepare_upload((XVar)(this.field), (XVar)(this.webType), (XVar)(fileNameForPrepareFunc), (XVar)(this.webValue), new XVar(""), (XVar)(this.id), (XVar)(this.pageObject)));
                        }
                    }
                }
            }
            else
            {
                this.webValue = new XVar(false);
            }
            if (XVar.Pack(!(XVar)(XVar.Equals(XVar.Pack(this.webValue), XVar.Pack(false)))))
            {
                if ((XVar)(this.webValue) && (XVar)(this.pageObject.pSetEdit.getCreateThumbnail((XVar)(this.field))))
                {
                    dynamic contents = null, ext = null, thumb = null;
                    contents = XVar.Clone(MVCFunctions.GetUploadedFileContents((XVar)(MVCFunctions.Concat("value_", this.goodFieldName, "_", this.id))));
                    ext      = XVar.Clone(CommonFunctions.CheckImageExtension((XVar)(MVCFunctions.GetUploadedFileName((XVar)(MVCFunctions.Concat("value_", this.goodFieldName, "_", this.id))))));
                    thumb    = XVar.Clone(MVCFunctions.CreateThumbnail((XVar)(contents), (XVar)(this.pageObject.pSetEdit.getThumbnailSize((XVar)(this.field))), (XVar)(ext)));
                    this.pageObject.filesToSave.InitAndSetArrayItem(new SaveFile((XVar)(thumb), (XVar)(MVCFunctions.Concat(this.pageObject.pSetEdit.getStrThumbnail((XVar)(this.field)), this.webValue)), (XVar)(this.pageObject.pSetEdit.getUploadFolder((XVar)(this.field))), (XVar)(this.pageObject.pSetEdit.isAbsolute((XVar)(this.field)))), null);
                }
                avalues.InitAndSetArrayItem(this.webValue, this.field);
            }
            return(null);
        }
Example #3
0
        public virtual XVar handle_file_upload(dynamic _param_uploadedFile, dynamic _param_index)
        {
            #region pass-by-value parameters
            dynamic uploadedFile = XVar.Clone(_param_uploadedFile);
            dynamic index        = XVar.Clone(_param_index);
            #endregion

            dynamic file = XVar.Array(), fileInfo = null, name = null, path_parts = XVar.Array(), size = null, tmpName = null, uploadDir = null, uploadDirRelative = null, var_error = null, var_type = null;
            tmpName           = XVar.Clone(uploadedFile["tmp_name"]);
            name              = XVar.Clone(uploadedFile["name"]);
            size              = XVar.Clone(uploadedFile["size"]);
            var_type          = XVar.Clone(uploadedFile["type"]);
            var_error         = XVar.Clone(uploadedFile["error"]);
            fileInfo          = XVar.Clone(new XVar("name", name, "size", MVCFunctions.intval((XVar)(size)), "type", var_type, "isThumbnail", false));
            uploadDir         = XVar.Clone(this.pSet.getFinalUploadFolder((XVar)(this.field), (XVar)(fileInfo)));
            uploadDirRelative = XVar.Clone(this.pSet.getUploadFolder((XVar)(this.field), (XVar)(fileInfo)));
            file              = XVar.Clone(XVar.Array());
            file.InitAndSetArrayItem(false, "error");
            file.InitAndSetArrayItem(MVCFunctions.trim_file_name((XVar)(name), (XVar)(var_type), (XVar)(index), this), "name");
            file.InitAndSetArrayItem(file["name"], "usrName");
            file.InitAndSetArrayItem(MVCFunctions.intval((XVar)(size)), "size");
            switch (((XVar)var_type).ToString())
            {
            case "image/png":
            case "image/x-png":
                file.InitAndSetArrayItem("image/png", "type");
                break;

            case "image/jpeg":
            case "image/pjpeg":
                file.InitAndSetArrayItem("image/jpeg", "type");
                break;

            default:
                file.InitAndSetArrayItem(var_type, "type");
                break;
            }
            path_parts = XVar.Clone(pathinfo_local((XVar)(name)));
            if (file["type"] == "")
            {
                file.InitAndSetArrayItem(CommonFunctions.getContentTypeByExtension((XVar)(path_parts["extension"])), "type");
            }
            file.InitAndSetArrayItem(false, "isImg");
            file.InitAndSetArrayItem("", "thumbnail");
            if (XVar.Pack(this.pSet.isMakeDirectoryNeeded((XVar)(this.field))))
            {
                if (XVar.Pack(!(XVar)(MVCFunctions.makeSurePathExists((XVar)(uploadDir)))))
                {
                    file.InitAndSetArrayItem("No existe el envío de carpetas", "error");
                    return(file);
                }
            }
            else
            {
                if (XVar.Pack(!(XVar)(MVCFunctions.is_dir((XVar)(uploadDir)))))
                {
                    file.InitAndSetArrayItem("No existe el envío de carpetas", "error");
                    return(file);
                }
            }
            if (XVar.Pack(validate((XVar)(uploadedFile), (XVar)(file), (XVar)(var_error), (XVar)(size), (XVar)(index), (XVar)(uploadDir))))
            {
                dynamic file_path = null, file_size = null;
                file.InitAndSetArrayItem(CommonFunctions.CheckImageExtension((XVar)(tmpName)) != false, "isImg");
                handle_form_data((XVar)(file), (XVar)(index));
                file.InitAndSetArrayItem(tempnam_sfx((XVar)(uploadDir), (XVar)(path_parts["filename"]), (XVar)(path_parts["extension"])), "name");
                file_path = XVar.Clone(MVCFunctions.Concat(uploadDir, file["name"]));
                MVCFunctions.clearstatcache();
                MVCFunctions.upload_File((XVar)(uploadedFile), (XVar)(file_path));
                file_size = XVar.Clone(MVCFunctions.filesize((XVar)(file_path)));
                if (XVar.Pack(this.options["resizeOnUpload"]))
                {
                    dynamic new_file_name = null, tempOptions = null;
                    tempOptions   = XVar.Clone(new XVar("max_width", this.options["max_width"], "max_height", this.options["max_width"]));
                    new_file_name = XVar.Clone(tempnam_sfx((XVar)(uploadDir), (XVar)(path_parts["filename"]), (XVar)(path_parts["extension"])));
                    if (XVar.Pack(create_scaled_image((XVar)(MVCFunctions.Concat(uploadDir, file["name"])), (XVar)(uploadDir), (XVar)(new_file_name), (XVar)(tempOptions), (XVar)(file), new XVar(false), (XVar)(uploadDirRelative), (XVar)(uploadedFile))))
                    {
                        MVCFunctions.unlink((XVar)(file_path));
                        file.InitAndSetArrayItem(new_file_name, "name");
                        file_path = XVar.Clone(MVCFunctions.Concat(uploadDir, new_file_name));
                        file_size = XVar.Clone(MVCFunctions.filesize((XVar)(file_path)));
                    }
                }
                if (XVar.Equals(XVar.Pack(file_size), XVar.Pack(file["size"])))
                {
                    file.InitAndSetArrayItem(MVCFunctions.Concat(uploadDir, MVCFunctions.RawUrlEncode((XVar)(file["name"]))), "url");
                    foreach (KeyValuePair <XVar, dynamic> options in this.options["image_versions"].GetEnumerator())
                    {
                        dynamic fileInfoThimbnail = null, thumbUploadDir = null, thumbUploadDirRelative = null, thumbnail_name = null;
                        fileInfoThimbnail      = XVar.Clone(new XVar("name", name, "size", MVCFunctions.intval((XVar)(size)), "type", var_type, "isThumbnail", true));
                        thumbUploadDir         = XVar.Clone(this.pSet.getFinalUploadFolder((XVar)(this.field), (XVar)(fileInfoThimbnail)));
                        thumbUploadDirRelative = XVar.Clone(this.pSet.getUploadFolder((XVar)(this.field), (XVar)(fileInfoThimbnail)));
                        if (XVar.Pack(this.pSet.isMakeDirectoryNeeded((XVar)(this.field))))
                        {
                            if (XVar.Pack(!(XVar)(MVCFunctions.makeSurePathExists((XVar)(thumbUploadDir)))))
                            {
                                continue;
                            }
                        }
                        thumbnail_name = XVar.Clone(tempnam_sfx((XVar)(thumbUploadDir), (XVar)(MVCFunctions.Concat(options.Value["thumbnailPrefix"], path_parts["filename"])), (XVar)(path_parts["extension"])));
                        if (XVar.Pack(create_scaled_image((XVar)(MVCFunctions.Concat(uploadDir, file["name"])), (XVar)(thumbUploadDir), (XVar)(thumbnail_name), (XVar)(options.Value), (XVar)(file), new XVar(true), (XVar)(thumbUploadDirRelative), (XVar)(uploadedFile))))
                        {
                            MVCFunctions.clearstatcache();
                            file_size = XVar.Clone(MVCFunctions.filesize((XVar)(file_path)));
                        }
                    }
                }
                else
                {
                    MVCFunctions.unlink((XVar)(file_path));
                    file.InitAndSetArrayItem("abort", "error");
                }
                file.InitAndSetArrayItem(file_size, "size");
                file.InitAndSetArrayItem(MVCFunctions.Concat(uploadDirRelative, file["name"]), "name");
                set_file_delete_url((XVar)(file));
            }
            return(file);
        }
Example #4
0
        public virtual XVar getFileOrImageMarkup(dynamic _param_value, dynamic _param_fileName, dynamic _param_newUploaderWasUsed, dynamic _param_fileData)
        {
            #region pass-by-value parameters
            dynamic value              = XVar.Clone(_param_value);
            dynamic fileName           = XVar.Clone(_param_fileName);
            dynamic newUploaderWasUsed = XVar.Clone(_param_newUploaderWasUsed);
            dynamic fileData           = XVar.Clone(_param_fileData);
            #endregion

            dynamic altAttr = null, cachedValue = null, disp = null, filePath = null, finalFilePath = null, finalUploadFolder = null, imageValue = null, uploadFolder = null;
            cachedValue = XVar.Clone(value);
            if (XVar.Pack(newUploaderWasUsed))
            {
                finalFilePath = XVar.Clone(filePath = XVar.Clone(fileData["name"]));
            }
            else
            {
                uploadFolder      = XVar.Clone(this.pageObject.pSetEdit.getUploadFolder((XVar)(this.field)));
                filePath          = XVar.Clone(MVCFunctions.Concat(uploadFolder, value));
                finalUploadFolder = XVar.Clone(this.pageObject.pSetEdit.getFinalUploadFolder((XVar)(this.field)));
                finalFilePath     = XVar.Clone(MVCFunctions.Concat(finalUploadFolder, value));
            }
            if (XVar.Pack(!(XVar)(CommonFunctions.CheckImageExtension((XVar)(fileName)))))
            {
                return(MVCFunctions.Concat("<a target=\"_blank\" href=\"", MVCFunctions.GetRootPathForResources((XVar)(MVCFunctions.runner_htmlspecialchars((XVar)(filePath)))), "\">", MVCFunctions.runner_htmlspecialchars((XVar)(fileName)), "</a>"));
            }
            altAttr = XVar.Clone((XVar.Pack(this.is508) ? XVar.Pack(MVCFunctions.Concat(" alt=\"", MVCFunctions.runner_htmlspecialchars((XVar)(fileName)), "\"")) : XVar.Pack("")));
            if (XVar.Pack(!(XVar)(MVCFunctions.myfile_exists((XVar)(MVCFunctions.getabspath((XVar)(finalFilePath)))))))
            {
                filePath = new XVar("images/no_image.gif");
            }
            if (XVar.Pack(this.pageObject.pSetEdit.showThumbnail((XVar)(this.field))))
            {
                dynamic finalThumbPath = null, thumbPath = null;
                if (XVar.Pack(newUploaderWasUsed))
                {
                    finalThumbPath = XVar.Clone(thumbPath = XVar.Clone(fileData["thumbnail"]));
                }
                else
                {
                    dynamic thumbprefix = null;
                    thumbprefix    = XVar.Clone(this.pageObject.pSetEdit.getStrThumbnail((XVar)(this.field)));
                    thumbPath      = XVar.Clone(MVCFunctions.Concat(uploadFolder, thumbprefix, fileName));
                    finalThumbPath = XVar.Clone(MVCFunctions.Concat(finalUploadFolder, thumbprefix, fileName));
                }
                if (MVCFunctions.substr((XVar)(thumbPath), new XVar(0), new XVar(7)) != "http://")
                {
                    if (XVar.Pack(!(XVar)(MVCFunctions.myfile_exists((XVar)(MVCFunctions.getabspath((XVar)(finalThumbPath)))))))
                    {
                        thumbPath = XVar.Clone(filePath);
                    }
                }
                return(MVCFunctions.Concat("<a target=\"_blank\" href=\"", MVCFunctions.GetRootPathForResources((XVar)(MVCFunctions.runner_htmlspecialchars((XVar)(filePath)))), "\" class='zoombox zgallery'>", "<img", altAttr, " border=0 src=\"", MVCFunctions.GetRootPathForResources((XVar)(MVCFunctions.runner_htmlspecialchars((XVar)(thumbPath)))), "\"></a>"));
            }
            imageValue = XVar.Clone(filePath);
            if ((XVar)(filePath != "images/no_image.gif") && (XVar)(!(XVar)(newUploaderWasUsed)))
            {
                if (51200 < MVCFunctions.filesize((XVar)(MVCFunctions.Concat(finalUploadFolder, fileName))))
                {
                    imageValue = new XVar("images/icons/jpg.png");
                }
            }
            disp = XVar.Clone(MVCFunctions.Concat("<img ", altAttr, "src=\"", MVCFunctions.GetRootPathForResources((XVar)(MVCFunctions.runner_htmlspecialchars((XVar)(imageValue)))), "\" border=0>"));
            if (imageValue != "images/no_image.gif")
            {
                disp = XVar.Clone(MVCFunctions.Concat("<a target=\"_blank\" href=\"", MVCFunctions.GetRootPathForResources((XVar)(MVCFunctions.runner_htmlspecialchars((XVar)(filePath)))), "\">", disp, "</a>"));
            }
            return(disp);
        }
Example #5
0
        public virtual XVar showDBValue(dynamic _param_value, dynamic _param_keyLink)
        {
            #region pass-by-value parameters
            dynamic value   = XVar.Clone(_param_value);
            dynamic keyLink = XVar.Clone(_param_keyLink);
            #endregion

            dynamic filesArray = XVar.Array(), imageValue = null, keylink = null;
            imageValue = new XVar("");
            initUploadHandler();
            this.upload_handler.tkeys = XVar.Clone(keylink);
            filesArray = XVar.Clone(MVCFunctions.my_json_decode((XVar)(value)));
            if ((XVar)(!(XVar)(MVCFunctions.is_array((XVar)(filesArray)))) || (XVar)(MVCFunctions.count(filesArray) == 0))
            {
                if (value == XVar.Pack(""))
                {
                    filesArray = XVar.Clone(XVar.Array());
                }
                else
                {
                    dynamic uploadedFile = null;
                    uploadedFile = XVar.Clone(this.upload_handler.get_file_object((XVar)(value)));
                    if (XVar.Pack(uploadedFile == null))
                    {
                        filesArray = XVar.Clone(XVar.Array());
                    }
                    else
                    {
                        filesArray = XVar.Clone(new XVar(0, uploadedFile));
                    }
                }
            }
            foreach (KeyValuePair <XVar, dynamic> imageFile in filesArray.GetEnumerator())
            {
                dynamic userFile = XVar.Array();
                userFile = XVar.Clone(this.upload_handler.buildUserFile((XVar)(imageFile.Value)));
                if (this.pageObject.pSetEdit.getViewFormat((XVar)(this.field)) == Constants.FORMAT_FILE)
                {
                    imageValue = MVCFunctions.Concat(imageValue, (XVar.Pack(imageValue != XVar.Pack("")) ? XVar.Pack("<br>") : XVar.Pack("")));
                    imageValue = MVCFunctions.Concat(imageValue, "<a href=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\">", MVCFunctions.runner_htmlspecialchars((XVar)((XVar.Pack(imageFile.Value["usrName"] != "") ? XVar.Pack(imageFile.Value["usrName"]) : XVar.Pack(imageFile.Value["name"])))), "</a>");
                }
                else
                {
                    if (XVar.Pack(CommonFunctions.CheckImageExtension((XVar)(imageFile.Value["name"]))))
                    {
                        dynamic imgHeight = null, imgWidth = null;
                        imageValue = MVCFunctions.Concat(imageValue, (XVar.Pack(imageValue != XVar.Pack("")) ? XVar.Pack("<br>") : XVar.Pack("")));
                        if (XVar.Pack(this.pageObject.pSetEdit.showThumbnail((XVar)(this.field))))
                        {
                            dynamic thumbname = null;
                            thumbname  = XVar.Clone(userFile["thumbnail_url"]);
                            imageValue = MVCFunctions.Concat(imageValue, "<a target=_blank");
                            imageValue = MVCFunctions.Concat(imageValue, " href=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\" class='zoombox'>");
                            imageValue = MVCFunctions.Concat(imageValue, "<img");
                            if ((XVar)(thumbname == XVar.Pack("")) || (XVar)(imageFile.Value["name"] == imageFile.Value["thumbnail"]))
                            {
                                imgWidth   = XVar.Clone(this.pageObject.pSetEdit.getImageWidth((XVar)(this.field)));
                                imageValue = MVCFunctions.Concat(imageValue, (XVar.Pack(imgWidth) ? XVar.Pack(MVCFunctions.Concat(" width=", imgWidth)) : XVar.Pack("")));
                                imgHeight  = XVar.Clone(this.pageObject.pSetEdit.getImageHeight((XVar)(this.field)));
                                imageValue = MVCFunctions.Concat(imageValue, (XVar.Pack(imgHeight) ? XVar.Pack(MVCFunctions.Concat(" height=", imgHeight)) : XVar.Pack("")));
                            }
                            imageValue = MVCFunctions.Concat(imageValue, " border=0");
                            if (XVar.Pack(this.is508))
                            {
                                imageValue = MVCFunctions.Concat(imageValue, " alt=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["name"])), "\"");
                            }
                            imageValue = MVCFunctions.Concat(imageValue, " src=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["thumbnail_url"])), "\"></a>");
                        }
                        else
                        {
                            imageValue = MVCFunctions.Concat(imageValue, "<img");
                            imgWidth   = XVar.Clone(this.pageObject.pSetEdit.getImageWidth((XVar)(this.field)));
                            imageValue = MVCFunctions.Concat(imageValue, (XVar.Pack(imgWidth) ? XVar.Pack(MVCFunctions.Concat(" width=", imgWidth)) : XVar.Pack("")));
                            imgHeight  = XVar.Clone(this.pageObject.pSetEdit.getImageHeight((XVar)(this.field)));
                            imageValue = MVCFunctions.Concat(imageValue, (XVar.Pack(imgHeight) ? XVar.Pack(MVCFunctions.Concat(" height=", imgHeight)) : XVar.Pack("")));
                            imageValue = MVCFunctions.Concat(imageValue, " border=0");
                            if (XVar.Pack(this.is508))
                            {
                                imageValue = MVCFunctions.Concat(imageValue, " alt=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["name"])), "\"");
                            }
                            imageValue = MVCFunctions.Concat(imageValue, " src=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\">");
                        }
                    }
                }
            }
            return(imageValue);
        }
Example #6
0
        public override XVar showDBValue(dynamic data, dynamic _param_keylink)
        {
            #region pass-by-value parameters
            dynamic keylink = XVar.Clone(_param_keylink);
            #endregion

            dynamic filesArray = XVar.Array(), isExport = null, showThumbnails = null, value = null, zoomboxRand = null;
            value = new XVar("");
            this.upload_handler.tkeys = XVar.Clone(keylink);
            filesArray     = XVar.Clone(getFilesArray((XVar)(data[this.field])));
            showThumbnails = XVar.Clone(this.container.pSet.showThumbnail((XVar)(this.field)));
            isExport       = XVar.Clone((XVar)(this.container.pageType == Constants.PAGE_EXPORT) || (XVar)(this.container.forExport != ""));
            if (XVar.Pack(showThumbnails))
            {
                zoomboxRand = XVar.Clone(MVCFunctions.rand(new XVar(11111), new XVar(99999)));
            }
            foreach (KeyValuePair <XVar, dynamic> file in filesArray.GetEnumerator())
            {
                dynamic userFile = XVar.Array();
                userFile = XVar.Clone(this.upload_handler.buildUserFile((XVar)(file.Value)));
                if (XVar.Pack(!(XVar)(isExport)))
                {
                    value = MVCFunctions.Concat(value, (XVar.Pack(value != XVar.Pack("")) ? XVar.Pack("<br>") : XVar.Pack("")));
                    if ((XVar)((XVar)(showThumbnails) && (XVar)(userFile["thumbnail_url"] != "")) && (XVar)(CommonFunctions.CheckImageExtension((XVar)(file.Value["name"]))))
                    {
                        value = MVCFunctions.Concat(value, "<a target=_blank href=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\" class='zoombox zgallery", zoomboxRand, "'><img  border='0'");
                        if (XVar.Pack(this.is508))
                        {
                            value = MVCFunctions.Concat(value, " alt=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["name"])), "\"");
                        }
                        value = MVCFunctions.Concat(value, " src=\"", MVCFunctions.runner_htmlspecialchars((XVar)(MVCFunctions.GetRootPathForResources((XVar)(userFile["thumbnail_url"])))), "\" /></a>");
                    }
                    else
                    {
                        if (XVar.Pack(this.container.pSet.showIcon((XVar)(this.field))))
                        {
                            value = MVCFunctions.Concat(value, "<a href=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\"><img style=\"vertical-align: middle;\" src=\"", MVCFunctions.GetRootPathForResources((XVar)(MVCFunctions.Concat("images/icons/", getFileIconByType((XVar)(file.Value["name"]), (XVar)(file.Value["type"]))))), "\" /></a>");
                        }
                    }
                }
                if (XVar.Pack(this.container.pSet.showCustomExpr((XVar)(this.field))))
                {
                    value = MVCFunctions.Concat(value, MVCFunctions.fileCustomExpression((XVar)(file.Value), (XVar)(data), (XVar)(this.field), (XVar)(this.container.pageType)));
                }
                else
                {
                    if (XVar.Pack(isExport))
                    {
                        value = MVCFunctions.Concat(value, (XVar.Pack(value != XVar.Pack("")) ? XVar.Pack(", ") : XVar.Pack("")), file.Value["usrName"]);
                    }
                    else
                    {
                        dynamic label = null;
                        if ((XVar)((XVar)((XVar)(showThumbnails) && (XVar)(userFile["thumbnail_url"] != "")) && (XVar)(CommonFunctions.CheckImageExtension((XVar)(file.Value["name"])))) && (XVar)(value != XVar.Pack("")))
                        {
                            value = MVCFunctions.Concat(value, "<br />");
                        }
                        label = XVar.Clone(MVCFunctions.runner_htmlspecialchars((XVar)((XVar.Pack(file.Value["usrName"] != "") ? XVar.Pack(file.Value["usrName"]) : XVar.Pack(file.Value["name"])))));
                        if (XVar.Pack(this.searchHighlight))
                        {
                            label = XVar.Clone(highlightSearchWord((XVar)(label), new XVar(true), new XVar("")));
                        }
                        value = MVCFunctions.Concat(value, "<a dir=\"LTR\" href=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\">", label, "</a>");
                    }
                }
                if (XVar.Pack(this.container.pSet.showFileSize((XVar)(this.field))))
                {
                    dynamic fileSizeAndUnit = XVar.Array();
                    fileSizeAndUnit = XVar.Clone(getFileSizeAndUnits((XVar)(file.Value["size"])));
                    value           = MVCFunctions.Concat(value, " ", CommonFunctions.str_format_number((XVar)((XVar)Math.Round((double)(fileSizeAndUnit["size"]), 2))), " ", this.sizeUnits[fileSizeAndUnit["unitIndex"]]);
                }
            }
            return(value);
        }
Example #7
0
        public override XVar getPdfValue(dynamic data, dynamic _param_keylink = null)
        {
            #region default values
            if (_param_keylink as Object == null)
            {
                _param_keylink = new XVar("");
            }
            #endregion

            #region pass-by-value parameters
            dynamic keylink = XVar.Clone(_param_keylink);
            #endregion

            dynamic defWidth = null, filesArray = XVar.Array(), resultValues = XVar.Array(), thumbWidth = null, width = null;
            if (XVar.Pack(!(XVar)(data[this.field])))
            {
                return("\"\"");
            }
            defWidth = new XVar(100);
            if (XVar.Equals(XVar.Pack(this.container.pageType), XVar.Pack(Constants.PAGE_VIEW)))
            {
                defWidth = new XVar(300);
            }
            width      = XVar.Clone((XVar.Pack(this.imageWidth) ? XVar.Pack(this.imageWidth) : XVar.Pack(defWidth)));
            thumbWidth = XVar.Clone((XVar.Pack(this.thumbWidth) ? XVar.Pack(this.thumbWidth) : XVar.Pack(72)));
            if (XVar.Pack(this.isImageURL))
            {
                return(MVCFunctions.Concat("{ \r\n\t\t\t\timage:\"", data[this.field], "\",\r\n\t\t\t\twidth: ", width, ", \r\n\t\t\t\theight: ", this.imageHeight, " \t\t\t\r\n\t\t\t}"));
            }
            this.upload_handler.tkeys = XVar.Clone(keylink);
            resultValues = XVar.Clone(XVar.Array());
            filesArray   = XVar.Clone(getFilesArray((XVar)(data[this.field])));
            foreach (KeyValuePair <XVar, dynamic> imageFile in filesArray.GetEnumerator())
            {
                dynamic content = null, hasBigImage = null, hasThumbnail = null, imagePath = null, imageType = null, thumbPath = null, userFile = null;
                userFile = XVar.Clone(this.upload_handler.buildUserFile((XVar)(imageFile.Value)));
                if (XVar.Pack(!(XVar)(CommonFunctions.CheckImageExtension((XVar)(imageFile.Value["name"])))))
                {
                    resultValues.InitAndSetArrayItem("\"\"", null);
                    continue;
                }
                imagePath   = XVar.Clone(getImagePath((XVar)(imageFile.Value["name"])));
                hasBigImage = XVar.Clone(MVCFunctions.myfile_exists((XVar)(imagePath)));
                if (XVar.Pack(!(XVar)(hasBigImage)))
                {
                    continue;
                }
                if (XVar.Pack(!(XVar)(this.showThumbnails)))
                {
                    content   = XVar.Clone(MVCFunctions.myfile_get_contents((XVar)(imagePath)));
                    imageType = XVar.Clone(MVCFunctions.SupposeImageType((XVar)(content)));
                    if ((XVar)(imageType == "image/jpeg") || (XVar)(imageType == "image/png"))
                    {
                        resultValues.InitAndSetArrayItem(MVCFunctions.Concat("{ \r\n\t\t\t\t\t\timage: \"", CommonFunctions.jsreplace((XVar)(MVCFunctions.Concat("data:", imageType, ";base64,", MVCFunctions.base64_encode((XVar)(content))))), "\",\r\n\t\t\t\t\t\twidth: ", width, ", \r\n\t\t\t\t\t\theight: ", this.imageHeight, " \r\n\t\t\t\t\t}"), null);
                    }
                    continue;
                }
                thumbPath    = XVar.Clone(getImagePath((XVar)(imageFile.Value["thumbnail"])));
                hasThumbnail = XVar.Clone(MVCFunctions.myfile_exists((XVar)(thumbPath)));
                if (XVar.Pack(hasThumbnail))
                {
                    content   = XVar.Clone(MVCFunctions.myfile_get_contents((XVar)(thumbPath)));
                    imageType = XVar.Clone(MVCFunctions.SupposeImageType((XVar)(content)));
                    if ((XVar)(imageType == "image/jpeg") || (XVar)(imageType == "image/png"))
                    {
                        resultValues.InitAndSetArrayItem(MVCFunctions.Concat("{ \r\n\t\t\t\t\t\timage: \"", CommonFunctions.jsreplace((XVar)(MVCFunctions.Concat("data:", imageType, ";base64,", MVCFunctions.base64_encode((XVar)(content))))), "\",\r\n\t\t\t\t\t\twidth: ", thumbWidth, ", \r\n\t\t\t\t\t\theight: ", this.thumbHeight, " \r\n\t\t\t\t\t}"), null);
                    }
                }
                else
                {
                    content   = XVar.Clone(MVCFunctions.myfile_get_contents((XVar)(imagePath)));
                    imageType = XVar.Clone(MVCFunctions.SupposeImageType((XVar)(content)));
                    if ((XVar)(imageType == "image/jpeg") || (XVar)(imageType == "image/png"))
                    {
                        resultValues.InitAndSetArrayItem(MVCFunctions.Concat("{ \r\n\t\t\t\t\t\timage: \"", CommonFunctions.jsreplace((XVar)(MVCFunctions.Concat("data:", imageType, ";base64,", MVCFunctions.base64_encode((XVar)(content))))), "\",\r\n\t\t\t\t\t\twidth: ", thumbWidth, ", \r\n\t\t\t\t\t\theight: ", this.thumbHeight, " \r\n\t\t\t\t\t}"), null);
                    }
                }
            }
            if (0 < MVCFunctions.count(resultValues))
            {
                return(MVCFunctions.Concat("[", MVCFunctions.implode(new XVar(","), (XVar)(resultValues)), "]"));
            }
            return("\"\"");
        }
Example #8
0
        public override XVar showDBValue(dynamic data, dynamic _param_keylink, dynamic _param_html = null)
        {
            #region default values
            if (_param_html as Object == null)
            {
                _param_html = new XVar(true);
            }
            #endregion

            #region pass-by-value parameters
            dynamic keylink = XVar.Clone(_param_keylink);
            dynamic html    = XVar.Clone(_param_html);
            #endregion

            if (data[this.field] == "")
            {
                return("");
            }
            if (XVar.Pack(!(XVar)(this.isImageURL)))
            {
                dynamic arBigThumbnails = XVar.Array(), divBigThumbnailsSize = null, divSize = null, filesArray = XVar.Array(), resultValues = XVar.Array(), zoomboxRand = null;
                this.upload_handler.tkeys = XVar.Clone(keylink);
                resultValues    = XVar.Clone(XVar.Array());
                arBigThumbnails = XVar.Clone(XVar.Array());
                zoomboxRand     = XVar.Clone(MVCFunctions.rand(new XVar(11111), new XVar(99999)));
                filesArray      = XVar.Clone(getFilesArray((XVar)(data[this.field])));
                foreach (KeyValuePair <XVar, dynamic> imageFile in filesArray.GetEnumerator())
                {
                    dynamic hasBigImage = null, hasThumbnail = null, imagePath = null, imageValue = null, userFile = XVar.Array();
                    userFile = XVar.Clone(this.upload_handler.buildUserFile((XVar)(imageFile.Value)));
                    if ((XVar)(this.container.pageType == Constants.PAGE_EXPORT) || (XVar)(this.container.forExport != ""))
                    {
                        resultValues.InitAndSetArrayItem(userFile["name"], null);
                        continue;
                    }
                    if (XVar.Pack(!(XVar)(CommonFunctions.CheckImageExtension((XVar)(imageFile.Value["name"])))))
                    {
                        resultValues.InitAndSetArrayItem(MVCFunctions.Concat("<a href=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\">", userFile["name"], "</a>"), null);
                        continue;
                    }
                    userFile["url"] = MVCFunctions.Concat(userFile["url"], "&nodisp=1");
                    if (userFile["thumbnail_url"] != "")
                    {
                        userFile["thumbnail_url"] = MVCFunctions.Concat(userFile["thumbnail_url"], "&nodisp=1");
                    }
                    imageValue           = new XVar("");
                    divSize              = new XVar("");
                    divBigThumbnailsSize = new XVar("");
                    hasThumbnail         = new XVar(false);
                    imagePath            = XVar.Clone(getImagePath((XVar)(imageFile.Value["name"])));
                    hasBigImage          = XVar.Clone(MVCFunctions.myfile_exists((XVar)(imagePath)));
                    if (XVar.Pack(this.showThumbnails))
                    {
                        dynamic thumbPath = null;
                        thumbPath    = XVar.Clone(getImagePath((XVar)(imageFile.Value["thumbnail"])));
                        hasThumbnail = XVar.Clone(MVCFunctions.myfile_exists((XVar)(thumbPath)));
                    }
                    if (XVar.Pack(this.showThumbnails))
                    {
                        if (XVar.Pack(hasThumbnail))
                        {
                            dynamic src = null;
                            imageValue = MVCFunctions.Concat(imageValue, "<img class=\"bs-dbimage\" border=\"0\"");
                            if (XVar.Pack(this.is508))
                            {
                                imageValue = MVCFunctions.Concat(imageValue, " alt=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["name"])), "\"");
                            }
                            src = XVar.Clone((XVar.Pack(userFile["thumbnail_url"] != "") ? XVar.Pack(userFile["thumbnail_url"]) : XVar.Pack(userFile["url"])));
                            if ((XVar)(this.thumbWidth) || (XVar)(this.thumbHeight))
                            {
                                imageValue = MVCFunctions.Concat(imageValue, getSmallThumbnailStyle());
                            }
                            imageValue = MVCFunctions.Concat(imageValue, " src=\"", MVCFunctions.runner_htmlspecialchars((XVar)(src)), "\" />");
                        }
                        else
                        {
                            if (XVar.Pack(hasBigImage))
                            {
                                imageValue = MVCFunctions.Concat(imageValue, "<img class=\"bs-dbimage\" ", getImageSizeStyle(new XVar(true)), " border=\"0\"");
                                if (XVar.Pack(this.is508))
                                {
                                    imageValue = MVCFunctions.Concat(imageValue, " alt=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["name"])), "\"");
                                }
                                imageValue = MVCFunctions.Concat(imageValue, " src=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\">");
                            }
                        }
                        if ((XVar)(hasBigImage) && (XVar)(imageValue != XVar.Pack("")))
                        {
                            dynamic href = null, linkClass = null, smallThumbnailStyle = null;
                            href = XVar.Clone(MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])));
                            smallThumbnailStyle = new XVar("");
                            linkClass           = XVar.Clone((XVar.Pack(!(XVar)(this.setOfThumbnails)) ? XVar.Pack(MVCFunctions.Concat("zoombox zgallery", zoomboxRand)) : XVar.Pack("")));
                            if ((XVar)(this.thumbWidth) && (XVar)(this.thumbHeight))
                            {
                                dynamic thumbFileUrl = null;
                                thumbFileUrl        = XVar.Clone((XVar.Pack(hasThumbnail) ? XVar.Pack(userFile["thumbnail_url"]) : XVar.Pack(userFile["url"])));
                                smallThumbnailStyle = XVar.Clone(getSmallThumbnailStyle((XVar)(thumbFileUrl), (XVar)(hasThumbnail)));
                                linkClass           = MVCFunctions.Concat(linkClass, " background-picture");
                            }
                            if (XVar.Pack(linkClass))
                            {
                                linkClass = XVar.Clone(MVCFunctions.Concat("class='", linkClass, "'"));
                            }
                            imageValue = XVar.Clone(MVCFunctions.Concat("<a target=\"_blank\" href=\"", href, "\"", linkClass, smallThumbnailStyle, ">", imageValue, "</a>"));
                            if (XVar.Pack(this.setOfThumbnails))
                            {
                                dynamic bigThumbnailLink = null, bigThumbnailLinkStyle = null;
                                bigThumbnailLinkStyle = XVar.Clone(getBigThumbnailSizeStyles());
                                bigThumbnailLink      = XVar.Clone(MVCFunctions.Concat("<a style=\"display: none;\" href=\"", href, "\" ", (XVar.Pack(bigThumbnailLinkStyle) ? XVar.Pack("class=\"zoombox\"") : XVar.Pack("")), ">"));
                                bigThumbnailLink      = MVCFunctions.Concat(bigThumbnailLink, "<img src=\"", href, "\" border=\"0\"");
                                bigThumbnailLink      = MVCFunctions.Concat(bigThumbnailLink, getImageSizeStyle(new XVar(true)));
                                bigThumbnailLink      = MVCFunctions.Concat(bigThumbnailLink, "/></a>");
                                if (XVar.Pack(!(XVar)(divBigThumbnailsSize)))
                                {
                                    divBigThumbnailsSize = XVar.Clone(MVCFunctions.Concat("style=\"", bigThumbnailLinkStyle, "\""));
                                }
                                arBigThumbnails.InitAndSetArrayItem(bigThumbnailLink, null);
                            }
                        }
                    }
                    else
                    {
                        if (XVar.Pack(hasBigImage))
                        {
                            imageValue = MVCFunctions.Concat(imageValue, "<img");
                            if (XVar.Pack(this.imageWidth))
                            {
                                divSize = XVar.Clone(MVCFunctions.Concat("width: ", this.imageWidth, "px;"));
                            }
                            if (XVar.Pack(this.imageHeight))
                            {
                                divSize = MVCFunctions.Concat(divSize, "height: ", this.imageHeight, "px;");
                            }
                            if (divSize != XVar.Pack(""))
                            {
                                divSize = XVar.Clone(MVCFunctions.Concat("style=\"", divSize, "\""));
                            }
                            imageValue = MVCFunctions.Concat(imageValue, " border=0");
                            if (XVar.Pack(this.is508))
                            {
                                imageValue = MVCFunctions.Concat(imageValue, " alt=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["name"])), "\"");
                            }
                            imageValue = MVCFunctions.Concat(imageValue, getImageSizeStyle(new XVar(true)), " src=\"", MVCFunctions.runner_htmlspecialchars((XVar)(userFile["url"])), "\">");
                        }
                    }
                    if (imageValue != XVar.Pack(""))
                    {
                        resultValues.InitAndSetArrayItem(imageValue, null);
                    }
                }
                if ((XVar)(1 < MVCFunctions.count(resultValues)) || (XVar)((XVar)(MVCFunctions.count(resultValues) == 1) && (XVar)(this.setOfThumbnails)))
                {
                    dynamic divBigThumbnails = null, hiddenFields = null, i = null, presudoSlider = null;
                    if ((XVar)(this.container.pageType == Constants.PAGE_EXPORT) || (XVar)(this.container.forExport != ""))
                    {
                        return(MVCFunctions.implode(new XVar(", "), (XVar)(resultValues)));
                    }
                    if ((XVar)(this.container.pageType == Constants.PAGE_PRINT) || (XVar)(this.container.pageType == Constants.PAGE_RPRINT))
                    {
                        return(MVCFunctions.implode(new XVar("<br />"), (XVar)(resultValues)));
                    }
                    i = new XVar(0);
                    for (; i < MVCFunctions.count(resultValues); i++)
                    {
                        if (i == XVar.Pack(0))
                        {
                            resultValues.InitAndSetArrayItem(MVCFunctions.Concat("<li>", resultValues[i], "</li>"), i);
                        }
                        else
                        {
                            resultValues.InitAndSetArrayItem(MVCFunctions.Concat("<li style=\"display:none;\">", resultValues[i], "</li>"), i);
                        }
                    }
                    divBigThumbnails = new XVar("");
                    if (XVar.Pack(MVCFunctions.count(arBigThumbnails)))
                    {
                        divBigThumbnails = XVar.Clone(MVCFunctions.Concat("<div class=\"big-thumbnails\" ", divBigThumbnailsSize, ">", MVCFunctions.implode(new XVar(""), (XVar)(arBigThumbnails)), "</div>"));
                    }
                    if ((XVar)(!(XVar)(divSize)) && (XVar)(!(XVar)(this.setOfThumbnails)))
                    {
                        divSize = XVar.Clone(MVCFunctions.Concat("style=\"", getBigThumbnailSizeStyles(new XVar(true)), "\""));
                    }
                    presudoSlider = XVar.Clone(MVCFunctions.Concat("<div class=\"presudoslider\" ", divSize, ">", divBigThumbnails, "<ul class=\"viewimage-thumblist\" style=\"list-style: none;\">", MVCFunctions.implode(new XVar(""), (XVar)(resultValues)), "</ul>", hiddenFields, "</div>"));
                    return(MVCFunctions.Concat("<div style=\"position:relative;\" class=\"viewImage\">", presudoSlider, "</div>"));
                }
                if (MVCFunctions.count(resultValues) == 1)
                {
                    return(resultValues[0]);
                }
                return(MVCFunctions.Concat("<img src=\"", MVCFunctions.GetRootPathForResources(new XVar("images/no_image.gif")), "\" />"));
            }
            else
            {
                if (0 < MVCFunctions.strlen((XVar)(data[this.field])))
                {
                    dynamic value = null;
                    value = new XVar("<img class=\"bs-dbimage\"");
                    value = MVCFunctions.Concat(value, " border=0");
                    value = MVCFunctions.Concat(value, getImageSizeStyle(new XVar(true)), " src='", data[this.field], "'>");
                    return(value);
                }
            }
            return("");
        }