Esempio n. 1
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControlLoad()
    {
        // Handle filter change event
        if (DataSourceControl != null)
        {
            DataSourceControl.OnFilterChanged += DataSourceControl_OnFilterChanged;
        }

        MediaLibraryInfo mli = MediaLibraryInfoProvider.GetMediaLibraryInfo(MediaLibraryName, SiteContext.CurrentSiteName);

        if (mli != null)
        {
            mMediaLibraryRoot = MediaLibraryHelper.GetMediaRootFolderPath(SiteContext.CurrentSiteName) + mli.LibraryFolder;
            mMediaLibraryUrl  = URLHelper.GetAbsoluteUrl("~/" + SiteContext.CurrentSiteName + "/media/" + mli.LibraryFolder);
        }
        repItems.ItemDataBound += repItems_ItemDataBound;
    }
Esempio n. 2
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControlLoad()
    {
        // Handle filter change event
        if (this.DataSourceControl != null)
        {
            this.DataSourceControl.OnFilterChanged += new ActionEventHandler(DataSourceControl_OnFilterChanged);
        }

        MediaLibraryInfo mli = MediaLibraryInfoProvider.GetMediaLibraryInfo(this.MediaLibraryName, CMSContext.CurrentSiteName);

        if (mli != null)
        {
            this.mMediaLibraryRoot = MediaLibraryHelper.GetMediaRootFolderPath(CMSContext.CurrentSiteName) + mli.LibraryFolder;
            this.mMediaLibraryUrl  = URLHelper.GetAbsoluteUrl("~/" + CMSContext.CurrentSiteName + "/media/" + mli.LibraryFolder);
        }
        this.repItems.ItemDataBound += new RepeaterItemEventHandler(repItems_ItemDataBound);
    }
Esempio n. 3
0
    private void InitializeInnerControls()
    {
        if (MediaLibrary != null)
        {
            // If the control was hidden because there were no data on init, show the control and process it
            if (hidden)
            {
                Visible                       = true;
                StopProcessing                = false;
                folderTree.StopProcessing     = false;
                fileDataSource.StopProcessing = false;
            }

            if (string.IsNullOrEmpty(MediaLibraryPath))
            {
                // If there is no path set
                folderTree.RootFolderPath     = MediaLibraryHelper.GetMediaRootFolderPath(CMSContext.CurrentSiteName);
                folderTree.MediaLibraryFolder = MediaLibrary.LibraryFolder;
            }
            else
            {
                // Set root folder with library path
                folderTree.RootFolderPath     = MediaLibraryHelper.GetMediaRootFolderPath(CMSContext.CurrentSiteName) + MediaLibrary.LibraryFolder;
                folderTree.MediaLibraryFolder = Path.GetFileName(MediaLibraryPath);
                folderTree.MediaLibraryPath   = MediaLibraryHelper.EnsurePath(MediaLibraryPath);
            }

            folderTree.FileIDQueryStringKey  = FileIDQueryStringKey;
            folderTree.PathQueryStringKey    = PathQueryStringKey;
            folderTree.FilterMethod          = FilterMethod;
            folderTree.ShowSubfoldersContent = ShowSubfoldersContent;
            folderTree.DisplayFileCount      = DisplayFileCount;

            // Get media file id from query
            mMediaFileID = QueryHelper.GetInteger(FileIDQueryStringKey, 0);

            // Media library sort
            mediaLibrarySort.OnFilterChanged     += FilterChanged;
            mediaLibrarySort.FileIDQueryStringKey = FileIDQueryStringKey;
            mediaLibrarySort.SortQueryStringKey   = SortQueryStringKey;
            mediaLibrarySort.FilterMethod         = FilterMethod;

            // File upload properties
            fileUploader.Visible             = AllowUpload;
            fileUploader.EnableUploadPreview = AllowUploadPreview;
            fileUploader.PreviewSuffix       = PreviewSuffix;
            fileUploader.LibraryID           = MediaLibrary.LibraryID;
            fileUploader.DestinationPath     = folderTree.SelectedPath;
            fileUploader.OnNotAllowed       += fileUploader_OnNotAllowed;
            fileUploader.OnAfterFileUpload  += fileUploader_OnAfterFileUpload;

            // Data properties
            fileDataSource.TopN     = SelectTopN;
            fileDataSource.SiteName = CMSContext.CurrentSiteName;
            fileDataSource.GroupID  = MediaLibrary.LibraryGroupID;

            // UniPager properties
            UniPagerControl.PageSize       = PageSize;
            UniPagerControl.GroupSize      = GroupSize;
            UniPagerControl.QueryStringKey = QueryStringKey;
            UniPagerControl.DisplayFirstLastAutomatically    = DisplayFirstLastAutomatically;
            UniPagerControl.DisplayPreviousNextAutomatically = DisplayPreviousNextAutomatically;
            UniPagerControl.HidePagerForSinglePage           = HidePagerForSinglePage;
            UniPagerControl.PagerMode = PagerMode;

            mMediaLibraryRoot = MediaLibraryHelper.GetMediaRootFolderPath(CMSContext.CurrentSiteName) + MediaLibrary.LibraryFolder;
            mMediaLibraryUrl  = URLHelper.GetAbsoluteUrl("~/" + CMSContext.CurrentSiteName + "/media/" + MediaLibrary.LibraryFolder);

            // List properties
            fileList.HideControlForZeroRows = HideControlForZeroRows;
            fileList.ZeroRowsText           = ZeroRowsText;
            fileList.ItemDataBound         += fileList_ItemDataBound;

            // Initialize templates for FileList and UniPager
            InitTemplates();
        }

        // Append filter changed event if folder is hidden or path query string id is set
        if (!HideFolderTree || !String.IsNullOrEmpty(PathQueryStringKey))
        {
            folderTree.OnFilterChanged += FilterChanged;
        }

        // Folder tree
        if (!HideFolderTree)
        {
            if (CultureHelper.IsPreferredCultureRTL())
            {
                folderTree.ImageFolderPath = GetImageUrl("RTL/Design/Controls/Tree", IsLiveSite, true);
            }
            else
            {
                folderTree.ImageFolderPath = GetImageUrl("Design/Controls/Tree", IsLiveSite, true);
            }
        }
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!QueryHelper.ValidateHash("hash"))
        {
            return;
        }

        // Check if hashtable containing dialog parameters is not empty
        if ((Parameters == null) || (Parameters.Count == 0))
        {
            return;
        }

        // Initialize events
        ctlAsync.OnFinished   += ctlAsync_OnFinished;
        ctlAsync.OnError      += ctlAsync_OnError;
        ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
        ctlAsync.OnCancel     += ctlAsync_OnCancel;

        // Get the sorce node
        MediaLibraryID = ValidationHelper.GetInteger(Parameters["libraryid"], 0);
        Action         = ValidationHelper.GetString(Parameters["action"], string.Empty);
        FolderPath     = ValidationHelper.GetString(Parameters["folderpath"], "").Replace("/", "\\");
        Files          = ValidationHelper.GetString(Parameters["files"], "").Trim('|');
        RootFolder     = MediaLibraryHelper.GetMediaRootFolderPath(CMSContext.CurrentSiteName);
        AllFiles       = ValidationHelper.GetBoolean(Parameters["allFiles"], false);
        NewPath        = ValidationHelper.GetString(Parameters["newpath"], "").Replace("/", "\\");

        btnCancel.Text = GetString("general.cancel");
        btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");

        // Target folder
        string tarFolder = NewPath;

        if (string.IsNullOrEmpty(tarFolder) && (LibraryInfo != null))
        {
            tarFolder = LibraryInfo.LibraryFolder + " (root)";
        }
        lblFolder.Text = tarFolder;

        if (!IsLoad)
        {
            if (AllFiles || String.IsNullOrEmpty(Files))
            {
                if (AllFiles)
                {
                    lblFilesToCopy.ResourceString = "media.folder.filestoall" + Action.ToLower();
                }
                else
                {
                    lblFilesToCopy.ResourceString = "media.folder.folderto" + Action.ToLower();
                }

                // Source folder
                string srcFolder = FolderPath;
                if (string.IsNullOrEmpty(srcFolder) && (LibraryInfo != null))
                {
                    srcFolder = LibraryInfo.LibraryFolder + "&nbsp;(root)";
                }
                lblFileList.Text = HTMLHelper.HTMLEncode(srcFolder);
            }
            else
            {
                lblFilesToCopy.ResourceString = "media.folder.filesto" + Action.ToLower();
                string[] fileList = Files.Split('|');
                foreach (string file in fileList)
                {
                    lblFileList.Text += HTMLHelper.HTMLEncode(DirectoryHelper.CombinePath(FolderPath.TrimEnd('\\'), file)) + "<br />";
                }
            }

            if (!Page.IsCallback && !URLHelper.IsPostback())
            {
                bool performAction = ValidationHelper.GetBoolean(Parameters["performaction"], false);
                if (performAction)
                {
                    // Perform Move or Copy
                    PerformAction();
                }
            }

            pnlInfo.Visible  = true;
            pnlEmpty.Visible = false;
        }
        else
        {
            pnlInfo.Visible  = false;
            pnlEmpty.Visible = true;
            lblEmpty.Text    = GetString("media.copymove.select");

            // Disable New folder button
            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "DisableNewFolderOnLoad", ScriptHelper.GetScript("if ((window.parent != null) && window.parent.DisableNewFolderBtn) { window.parent.DisableNewFolderBtn(); }"));
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        MediaLibraryInfo mli = MediaLibraryInfoProvider.GetMediaLibraryInfo(MediaLibraryName, SiteContext.CurrentSiteName);

        if (mli != null)
        {
            // If dont have 'Manage' permission
            if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(mli, "read"))
            {
                // Check 'File create' permission
                if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(mli, "libraryaccess"))
                {
                    folderTree.StopProcessing  = true;
                    folderTree.Visible         = false;
                    messageElem.ErrorMessage   = MediaLibraryHelper.GetAccessDeniedMessage("libraryaccess");
                    messageElem.DisplayMessage = true;
                    return;
                }
            }

            // Tree
            if (string.IsNullOrEmpty(MediaLibraryPath))
            {
                folderTree.RootFolderPath     = MediaLibraryHelper.GetMediaRootFolderPath(SiteContext.CurrentSiteName);
                folderTree.MediaLibraryFolder = mli.LibraryFolder;
            }
            else
            {
                folderTree.RootFolderPath = MediaLibraryHelper.GetMediaRootFolderPath(SiteContext.CurrentSiteName) + mli.LibraryFolder;
                int index = MediaLibraryPath.LastIndexOfCSafe('/');
                if ((index > -1) && (MediaLibraryPath.Length > (index + 1)))
                {
                    folderTree.MediaLibraryFolder = MediaLibraryPath.Substring(index + 1);
                }
                else
                {
                    folderTree.MediaLibraryFolder = MediaLibraryPath;
                }
                folderTree.MediaLibraryPath = Path.EnsureBackslashes(MediaLibraryPath);
            }

            // Set images path
            if (CultureHelper.IsPreferredCultureRTL())
            {
                folderTree.ImageFolderPath = GetImageUrl("RTL/Design/Controls/Tree", true, true);
            }
            else
            {
                folderTree.ImageFolderPath = GetImageUrl("Design/Controls/Tree", true, true);
            }

            folderTree.SourceFilterName     = FilterName;
            folderTree.FileIDQueryStringKey = FileIDQueryStringKey;
            folderTree.PathQueryStringKey   = PathQueryStringKey;
            folderTree.DisplayFileCount     = DisplayFileCount;

            // Add tree to the filter collection
            CMSControlsHelper.SetFilter(ValidationHelper.GetString(GetValue("WebPartControlID"), ID), folderTree);
        }
        else
        {
            folderTree.StopProcessing = true;
            folderTree.Visible        = false;
        }
    }