예제 #1
0
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterScriptFile(this, @"~/CMSModules/Content/CMSDesk/View/Listing.js");

        currentSiteName = CMSContext.CurrentSiteName;
        currentUserInfo = CMSContext.CurrentUser;

        // Current Node ID
        nodeId = QueryHelper.GetInteger("nodeid", 0);

        // Setup page title text and image
        CurrentMaster.Title.TitleText  = GetString("Content.ListingTitle");
        CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Menu/Listing.png");

        CurrentMaster.Title.HelpName      = "helpTopic";
        CurrentMaster.Title.HelpTopicName = "list_tab";

        string[,] actions = new string[1, 6];
        actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1]     = GetString("Listing.ParentDirectory");
        actions[0, 5]     = GetImageUrl("CMSModules/CMS_Content/Listing/parent.png");
        CurrentMaster.HeaderActions.Actions = actions;

        if (nodeId > 0)
        {
            tree             = new TreeProvider(currentUserInfo);
            checkPermissions = tree.CheckDocumentUIPermissions(currentSiteName);
            node             = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
            // Set edited document
            EditedDocument = node;

            if (node != null)
            {
                if (currentUserInfo.IsAuthorizedPerDocument(node, NodePermissionsEnum.ExploreTree) != AuthorizationResultEnum.Allowed)
                {
                    RedirectToCMSDeskAccessDenied("CMS.Content", "exploretree");
                }

                aliasPath = node.NodeAliasPath;

                // Setup the link to the parent document
                if ((node.NodeClassName.ToLower() != "cms.root") && (currentUserInfo.UserStartingAliasPath.ToLower() != node.NodeAliasPath.ToLower()))
                {
                    CurrentMaster.HeaderActions.Actions[0, 3] = "javascript:SelectItem(" + node.NodeParentID + ");";
                }
                else
                {
                    CurrentMaster.HeaderActions.Visible = false;
                    CurrentMaster.PanelBody.FindControl("pnlActions").Visible = false;
                }
            }

            ScriptHelper.RegisterProgress(this);
            ScriptHelper.RegisterDialogScript(this);
            ScriptHelper.RegisterJQuery(this);

            InitDropdowLists();

            cultureElem.DropDownCultures.Width = 222;

            // Prepare JavaScript for actions
            StringBuilder actionScript = new StringBuilder();
            actionScript.Append(
                @"function PerformAction(selectionFunction, selectionField, dropId){
    var label = document.getElementById('" + lblInfo.ClientID + @"');
    var whatDrp = document.getElementById('" + drpWhat.ClientID + @"');
    var action = document.getElementById(dropId).value;
    var selectionFieldElem = document.getElementById(selectionField);
    var allSelected = " + (int)What.SelectedDocuments + @";
    if (action == '" + (int)Action.SelectAction + @"'){
        label.innerHTML = '" + GetString("massaction.selectsomeaction") + @"';
        return false;
    }
    if(whatDrp.value == '" + (int)What.AllDocuments + @"'){
        allSelected = " + (int)What.AllDocuments + @";
    }
    var items = selectionFieldElem.value;
    if(!eval(selectionFunction) || whatDrp.value == '" + (int)What.AllDocuments + @"'){
        var argument = '|' + allSelected + '|' + items;
        switch(action){
            case '" + (int)Action.Move + @"':
                argument = '" + Action.Move + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Copy + @"':
                argument = '" + Action.Copy + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Link + @"':
                argument = '" + Action.Link + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Delete + @"':
                argument = '" + Action.Delete + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "Redirect", string.Empty) + @";
                break;

            case '" + (int)Action.Publish + @"':
                argument = '" + Action.Publish + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "Redirect", string.Empty) + @";
                break;

            case '" + (int)Action.Archive + @"':
                argument = '" + Action.Archive + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "Redirect", string.Empty) + @";
                break;

            default:
                return false;
        }
    }
    else{
        label.innerHTML = '" + GetString("documents.selectdocuments") + @"';
    }
    return false;
}

function OpenModal(arg, context){
    modalDialog(arg,'actionDialog','90%', '85%');
}

function Redirect(arg, context){
    document.location.replace(arg);
}");

            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "actionScript", ScriptHelper.GetScript(actionScript.ToString()));

            // Add action to button
            btnOk.OnClientClick = "return PerformAction('" + gridDocuments.GetCheckSelectionScript() + "','" + gridDocuments.GetSelectionFieldClientID() + "','" + drpAction.ClientID + "');";

            // Initialize dropdown lists
            if (!RequestHelper.IsPostBack())
            {
                drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString()));
                drpAction.Items.Add(new ListItem(GetString("general." + Action.Move), Convert.ToInt32(Action.Move).ToString()));
                drpAction.Items.Add(new ListItem(GetString("general." + Action.Copy), Convert.ToInt32(Action.Copy).ToString()));
                drpAction.Items.Add(new ListItem(GetString("general." + Action.Link), Convert.ToInt32(Action.Link).ToString()));
                drpAction.Items.Add(new ListItem(GetString("general." + Action.Delete), Convert.ToInt32(Action.Delete).ToString()));
                if (currentUserInfo.IsGlobalAdministrator || currentUserInfo.IsAuthorizedPerResource("CMS.Content", "ManageWorkflow"))
                {
                    drpAction.Items.Add(new ListItem(GetString("general." + Action.Publish), Convert.ToInt32(Action.Publish).ToString()));
                    drpAction.Items.Add(new ListItem(GetString("general." + Action.Archive), Convert.ToInt32(Action.Archive).ToString()));
                }

                drpWhat.Items.Add(new ListItem(GetString("contentlisting." + What.SelectedDocuments), Convert.ToInt32(What.SelectedDocuments).ToString()));
                drpWhat.Items.Add(new ListItem(GetString("contentlisting." + What.AllDocuments), Convert.ToInt32(What.AllDocuments).ToString()));
            }

            // Setup the grid
            gridDocuments.OnExternalDataBound += gridDocuments_OnExternalDataBound;
            gridDocuments.OnBeforeDataReload  += gridDocuments_OnBeforeDataReload;
            gridDocuments.OnDataReload        += gridDocuments_OnDataReload;
            gridDocuments.ZeroRowsText         = GetString("content.nochilddocumentsfound");
            gridDocuments.ShowActionsMenu      = true;
            if (node != null)
            {
                gridDocuments.WhereCondition = "NodeParentID = " + node.NodeID + " AND NodeLevel = " + (node.NodeLevel + 1);
            }

            // Initialize columns
            string columns = @"DocumentLastVersionName, DocumentName, NodeParentID,
                    ClassDisplayName, DocumentModifiedWhen, Published, DocumentLastVersionNumber, DocumentMenuRedirectURL, DocumentLastVersionMenuRedirectUrl, DocumentIsArchived, DocumentCheckedOutByUserID,
                    DocumentPublishedVersionHistoryID, DocumentWorkflowStepID, DocumentCheckedOutVersionHistoryID, DocumentNamePath, DocumentPublishFrom, DocumentType, DocumentLastVersionType, NodeAliasPath";

            if (checkPermissions)
            {
                columns = SqlHelperClass.MergeColumns(columns, TreeProvider.SECURITYCHECK_REQUIRED_COLUMNS);
            }
            gridDocuments.Columns = columns;

            StringBuilder refreshScripts = new StringBuilder();
            refreshScripts.Append(
                @"function RefreshTree()
{
    if((parent != null) && (parent.parent != null) && (parent.parent.frames['contenttree'] != null) && (parent.parent.frames['contenttree'].RefreshNode != null))
    {
        parent.parent.frames['contenttree'].RefreshNode(", nodeId, @",", nodeId, @");
    }
}
function ClearSelection()
{ 
", gridDocuments.GetClearSelectionScript(), @"
}
function RefreshGrid()
{
    ClearSelection();
    RefreshTree();",
                ClientScript.GetPostBackEventReference(btnShow, "null"), @"
}");
            // Register refresh scripts
            string refreshScript = ScriptHelper.GetScript(refreshScripts.ToString());
            ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "refreshListing", refreshScript);

            // Get all possible columns to retrieve
            IDataClass   nodeClass = DataClassFactory.NewDataClass("CMS.Tree");
            DocumentInfo di        = new DocumentInfo();
            gridDocuments.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(di.ColumnNames.ToArray()), SqlHelperClass.MergeColumns(nodeClass.ColumnNames.ToArray()));
        }
    }
예제 #2
0
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterScriptFile(this, @"~/CMSModules/Content/CMSDesk/View/Listing.js");

        currentSiteName = CMSContext.CurrentSiteName;
        currentUserInfo = CMSContext.CurrentUser;

        // Current Node ID
        nodeId = QueryHelper.GetInteger("nodeid", 0);

        // Setup page title text and image
        CurrentMaster.Title.TitleText = GetString("Content.ListingTitle");
        CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Menu/Listing.png");

        CurrentMaster.Title.HelpName = "helpTopic";
        CurrentMaster.Title.HelpTopicName = "list_tab";

        string[,] actions = new string[1, 6];
        actions[0, 0] = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1] = GetString("Listing.ParentDirectory");
        actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/Listing/parent.png");
        CurrentMaster.HeaderActions.Actions = actions;

        if (nodeId > 0)
        {
            tree = new TreeProvider(currentUserInfo);
            checkPermissions = tree.CheckDocumentUIPermissions(currentSiteName);
            node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
            // Set edited document
            EditedDocument = node;

            if (node != null)
            {
                if (currentUserInfo.IsAuthorizedPerDocument(node, NodePermissionsEnum.ExploreTree) != AuthorizationResultEnum.Allowed)
                {
                    RedirectToCMSDeskAccessDenied("CMS.Content", "exploretree");
                }

                aliasPath = node.NodeAliasPath;

                // Setup the link to the parent document
                if ((node.NodeClassName.ToLower() != "cms.root") && (currentUserInfo.UserStartingAliasPath.ToLower() != node.NodeAliasPath.ToLower()))
                {
                    CurrentMaster.HeaderActions.Actions[0, 3] = "javascript:SelectItem(" + node.NodeParentID + ");";
                }
                else
                {
                    CurrentMaster.HeaderActions.Visible = false;
                    CurrentMaster.PanelBody.FindControl("pnlActions").Visible = false;
                }
            }

            ScriptHelper.RegisterProgress(this);
            ScriptHelper.RegisterDialogScript(this);
            ScriptHelper.RegisterJQuery(this);

            InitDropdowLists();

            cultureElem.DropDownCultures.Width = 222;

            // Prepare JavaScript for actions
            StringBuilder actionScript = new StringBuilder();
            actionScript.Append(
        @"function PerformAction(selectionFunction, selectionField, dropId){
        var label = document.getElementById('" + lblInfo.ClientID + @"');
        var whatDrp = document.getElementById('" + drpWhat.ClientID + @"');
        var action = document.getElementById(dropId).value;
        var selectionFieldElem = document.getElementById(selectionField);
        var allSelected = " + (int)What.SelectedDocuments + @";
        if (action == '" + (int)Action.SelectAction + @"'){
        label.innerHTML = '" + GetString("massaction.selectsomeaction") + @"';
        return false;
        }
        if(whatDrp.value == '" + (int)What.AllDocuments + @"'){
        allSelected = " + (int)What.AllDocuments + @";
        }
        var items = selectionFieldElem.value;
        if(!eval(selectionFunction) || whatDrp.value == '" + (int)What.AllDocuments + @"'){
        var argument = '|' + allSelected + '|' + items;
        switch(action){
            case '" + (int)Action.Move + @"':
                argument = '" + Action.Move + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Copy + @"':
                argument = '" + Action.Copy + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Link + @"':
                argument = '" + Action.Link + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Delete + @"':
                argument = '" + Action.Delete + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "Redirect", string.Empty) + @";
                break;

            case '" + (int)Action.Publish + @"':
                argument = '" + Action.Publish + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "Redirect", string.Empty) + @";
                break;

            case '" + (int)Action.Archive + @"':
                argument = '" + Action.Archive + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "Redirect", string.Empty) + @";
                break;

            default:
                return false;
        }
        }
        else{
        label.innerHTML = '" + GetString("documents.selectdocuments") + @"';
        }
        return false;
        }

        function OpenModal(arg, context){
        modalDialog(arg,'actionDialog','90%', '85%');
        }

        function Redirect(arg, context){
        document.location.replace(arg);
        }");

            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "actionScript", ScriptHelper.GetScript(actionScript.ToString()));

            // Add action to button
            btnOk.OnClientClick = "return PerformAction('" + gridDocuments.GetCheckSelectionScript() + "','" + gridDocuments.GetSelectionFieldClientID() + "','" + drpAction.ClientID + "');";

            // Initialize dropdown lists
            if (!RequestHelper.IsPostBack())
            {
                drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString()));
                drpAction.Items.Add(new ListItem(GetString("general." + Action.Move), Convert.ToInt32(Action.Move).ToString()));
                drpAction.Items.Add(new ListItem(GetString("general." + Action.Copy), Convert.ToInt32(Action.Copy).ToString()));
                drpAction.Items.Add(new ListItem(GetString("general." + Action.Link), Convert.ToInt32(Action.Link).ToString()));
                drpAction.Items.Add(new ListItem(GetString("general." + Action.Delete), Convert.ToInt32(Action.Delete).ToString()));
                if (currentUserInfo.IsGlobalAdministrator || currentUserInfo.IsAuthorizedPerResource("CMS.Content", "ManageWorkflow"))
                {
                    drpAction.Items.Add(new ListItem(GetString("general." + Action.Publish), Convert.ToInt32(Action.Publish).ToString()));
                    drpAction.Items.Add(new ListItem(GetString("general." + Action.Archive), Convert.ToInt32(Action.Archive).ToString()));
                }

                drpWhat.Items.Add(new ListItem(GetString("contentlisting." + What.SelectedDocuments), Convert.ToInt32(What.SelectedDocuments).ToString()));
                drpWhat.Items.Add(new ListItem(GetString("contentlisting." + What.AllDocuments), Convert.ToInt32(What.AllDocuments).ToString()));
            }

            // Setup the grid
            gridDocuments.OnExternalDataBound += gridDocuments_OnExternalDataBound;
            gridDocuments.OnBeforeDataReload += gridDocuments_OnBeforeDataReload;
            gridDocuments.OnDataReload += gridDocuments_OnDataReload;
            gridDocuments.ZeroRowsText = GetString("content.nochilddocumentsfound");
            gridDocuments.ShowActionsMenu = true;
            if (node != null)
            {
                gridDocuments.WhereCondition = "NodeParentID = " + node.NodeID + " AND NodeLevel = " + (node.NodeLevel + 1);
            }

            // Initialize columns
            string columns = @"DocumentLastVersionName, DocumentName, NodeParentID,
                    ClassDisplayName, DocumentModifiedWhen, Published, DocumentLastVersionNumber, DocumentMenuRedirectURL, DocumentLastVersionMenuRedirectUrl, DocumentIsArchived, DocumentCheckedOutByUserID,
                    DocumentPublishedVersionHistoryID, DocumentWorkflowStepID, DocumentCheckedOutVersionHistoryID, DocumentNamePath, DocumentPublishFrom, DocumentType, DocumentLastVersionType, NodeAliasPath";

            if (checkPermissions)
            {
                columns = SqlHelperClass.MergeColumns(columns, TreeProvider.SECURITYCHECK_REQUIRED_COLUMNS);
            }
            gridDocuments.Columns = columns;

            StringBuilder refreshScripts = new StringBuilder();
            refreshScripts.Append(
        @"function RefreshTree()
        {
        if((parent != null) && (parent.parent != null) && (parent.parent.frames['contenttree'] != null) && (parent.parent.frames['contenttree'].RefreshNode != null))
        {
        parent.parent.frames['contenttree'].RefreshNode(", nodeId, @",", nodeId, @");
        }
        }
        function ClearSelection()
        {
        ", gridDocuments.GetClearSelectionScript(), @"
        }
        function RefreshGrid()
        {
        ClearSelection();
        RefreshTree();",
        ClientScript.GetPostBackEventReference(btnShow, "null"), @"
        }");
            // Register refresh scripts
            string refreshScript = ScriptHelper.GetScript(refreshScripts.ToString());
            ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "refreshListing", refreshScript);

            // Get all possible columns to retrieve
            IDataClass nodeClass = DataClassFactory.NewDataClass("CMS.Tree");
            DocumentInfo di = new DocumentInfo();
            gridDocuments.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(di.ColumnNames.ToArray()), SqlHelperClass.MergeColumns(nodeClass.ColumnNames.ToArray()));

        }
    }