Esempio n. 1
0
    /// <summary>
    /// Displays new file form.
    /// </summary>
    /// <param name="file">File the form is displayed for</param>
    public void DisplayForm(FileInfo file)
    {
        if (file != null)
        {
            string ext = file.Extension;

            if (!MediaLibraryHelper.IsExtensionAllowed(ext.TrimStart('.')))
            {
                String errorMsg = String.Format(GetString("attach.notallowedextension"), ext, MediaLibraryHelper.GetAllowedExtensions(SiteContext.CurrentSiteName).TrimEnd(';').Replace(";", ", "));

                plcMessInfo.ClearLabels();
                plcMessInfo.ShowError(errorMsg);
                SetFormVisible(false);
            }
            else
            {
                // If is not in DB fill new file form and show it
                SetFormVisible(true);
                txtNewDescripotion.Text = "";
                txtNewFileTitle.Text    = Path.GetFileNameWithoutExtension(file.Name);
                txtNewFileName.Text     = URLHelper.GetSafeFileName(Path.GetFileNameWithoutExtension(file.Name), SiteContext.CurrentSiteName, false);
            }
        }
    }
    /// <summary>
    /// Displays new file form.
    /// </summary>
    /// <param name="file">File the form is displayed for</param>
    public void DisplayForm(FileInfo file)
    {
        if (file != null)
        {
            string ext = file.Extension;

            if (!MediaLibraryHelper.IsExtensionAllowed(ext.TrimStart('.')))
            {
                String errorMsg = String.Format(GetString("attach.notallowedextension"), ext, MediaLibraryHelper.GetAllowedExtensions(SiteContext.CurrentSiteName).TrimEnd(';').Replace(";", ", "));

                plcMessInfo.ClearLabels();
                plcMessInfo.ShowError(errorMsg);
                SetFormVisible(false);
            }
            else
            {
                // If is not in DB fill new file form and show it
                SetFormVisible(true);
                txtNewDescripotion.Text = "";
                txtNewFileTitle.Text = Path.GetFileNameWithoutExtension(file.Name);
                txtNewFileName.Text = URLHelper.GetSafeFileName(Path.GetFileNameWithoutExtension(file.Name), SiteContext.CurrentSiteName, false);
            }
        }
    }