Exemplo n.º 1
0
    private void SetFolderActions(string path)
    {
        var isZipped = StorageHelper.IsZippedFilePath(path);

        folderActions.EnableDeleteFolder = !FullStartingPath.EqualsCSafe(path, true) && !isZipped;
        folderActions.EnableAddFolder    = !isZipped;
    }
    /// <summary>
    /// Handles actions occurring when tree refresh is requested.
    /// </summary>
    /// <param name="argument">Argument holding information on requested item</param>
    private void HandleTreeRefreshAction(string argument)
    {
        InitializeFileSystemTree();

        // Fill with new info
        NodeID = argument;

        treeFileSystem.DefaultPath       = NodeID;
        treeFileSystem.ExpandDefaultPath = true;

        treeFileSystem.ReloadData();
        pnlUpdateTree.Update();
        pnlUpdateMenu.Update();

        // Reload the file system view
        fileSystemView.StartingPath = NodeID;
        fileSystemView.Reload();

        pnlUpdateView.Update();

        InitializeMenuElem();
        folderActions.EnableDeleteFolder = !FullStartingPath.EqualsCSafe(NodeID, true);
        folderActions.Update();
        menuElem.UpdateActionsMenu();


        // Forget recent action
        ClearActionElems();
    }
    /// <summary>
    /// Handles actions related to the folders.
    /// </summary>
    /// <param name="argument">Argument related to the folder action</param>
    /// <param name="forceReload">Indicates if load should be forced</param>
    private void HandleFolderAction(string argument, bool forceReload)
    {
        NodeID = ValidationHelper.GetString(argument, string.Empty);

        // Reload content tree if necessary
        if (forceReload)
        {
            InitializeFileSystemTree();

            // Fill with new info
            treeFileSystem.DefaultPath       = NodeID;
            treeFileSystem.ExpandDefaultPath = true;

            treeFileSystem.ReloadData();
            pnlUpdateTree.Update();

            ScriptManager.RegisterStartupScript(Page, typeof(Page), "EnsureTopWindow", "if (self.focus) { self.focus(); }", true);
        }

        ColorizeLastSelectedRow();

        // Get parent node ID info
        string parentId = string.Empty;

        if (FullStartingPath.ToLowerCSafe() != NodeID.ToLowerCSafe())
        {
            try
            {
                parentId = (DirectoryInfo.New(NodeID)).Parent.FullName;
            }
            // Access denied to parent
            catch (SecurityException)
            {
            }
        }

        menuElem.ShowParentButton = !String.IsNullOrEmpty(parentId);
        menuElem.NodeParentID     = parentId;

        fileSystemView.Config = Config;

        // Load new data
        if ((Config.ShowFolders) && (NodeID.LastIndexOfCSafe('\\') != -1))
        {
            fileSystemView.StartingPath = NodeID.Substring(0, argument.LastIndexOfCSafe('\\') + 1);
        }

        fileSystemView.StartingPath = NodeID;

        // Reload view control's content
        fileSystemView.Reload();
        pnlUpdateView.Update();

        InitializeMenuElem();
        menuElem.UpdateActionsMenu();
        folderActions.Update();
        pnlUpdateMenu.Update();

        ClearActionElems();
    }
    /// <summary>
    /// Pre render.
    /// </summary>
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        // High-light item being edited
        if (ItemToColorize != String.Empty)
        {
            ColorizeRow(ItemToColorize);
        }

        // Display info on listing more content
        if (IsDisplayMore && !Config.ShowFolders) //curently selected more object && (TreeNodeObj != null))
        {
            string closeLink   = String.Format("<span class=\"ListingClose\" style=\"cursor: pointer;\" onclick=\"SetAction('closelisting', ''); RaiseHiddenPostBack(); return false;\">{0}</span>", GetString("general.close"));
            string currentPath = "<span class=\"ListingPath\">";

            // Display relative paths with tilda
            if (Config.StartingPath.StartsWithCSafe("~"))
            {
                string serverPath = Server.MapPath(Config.StartingPath).TrimEnd('\\');
                currentPath += NodeID.Replace(serverPath.Substring(0, serverPath.LastIndexOfCSafe('\\') + 1), string.Empty);
            }
            else
            {
                currentPath += NodeID.Replace(NodeID.Substring(0, Config.StartingPath.TrimEnd('\\').LastIndexOfCSafe('\\') + 1), string.Empty);
            }
            currentPath += "</span>";

            string listingMsg = string.Format(GetString("dialogs.filesystem.listinginfo"), currentPath, closeLink);
            fileSystemView.DisplayListingInfo(listingMsg);
        }

        folderActions.EnableDeleteFolder = !FullStartingPath.EqualsCSafe(NodeID, true);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Check if folder is allowed and not excluded.
    /// </summary>
    /// <param name="info">DiretoryInfo to check</param>
    /// <returns>True if folder isallowed and not excluded otherwise false</returns>
    private bool IsAllowedAndNotExcludedFolder(DirectoryInfo info)
    {
        bool   isAllowed  = false;
        bool   isExcluded = false;
        string startPath  = DirectoryHelper.EnsurePathBackSlash(FullStartingPath.ToLower());
        string folderName = info.FullName.ToLower();

        // Check if folder is allowed
        if (String.IsNullOrEmpty(Configuration.AllowedFolders))
        {
            isAllowed = true;
        }
        else
        {
            foreach (string path in Configuration.AllowedFolders.ToLower().Split(';'))
            {
                if (folderName.StartsWith(startPath + path))
                {
                    isAllowed = true;
                }
            }
        }

        // Check if folder isn't excluded
        if (!String.IsNullOrEmpty(Configuration.ExcludedFolders))
        {
            foreach (string path in Configuration.ExcludedFolders.ToLower().Split(';'))
            {
                if (folderName.StartsWith(startPath + path))
                {
                    isExcluded = true;
                }
            }
        }
        return((isAllowed) && (!isExcluded));
    }