Ejemplo n.º 1
0
        private void NodeImageExplorer_RightButtonSingleClick(object sender, MouseManagerEventArgs e)
        {
            ParentSurface.Selector.Clear();
            ParentSurface.Selector.AddNode(this, false);
            var location = e.End.PositionInformation.GetPosition(ParentSurface);

            ContextMenuContainer.ShowContextMenu <ViewerNodeControlContextMenu>(location, this);
            ViewerNodeControlContextMenu.Rating.DataContext = ViewModelNode.NodeProperties;
        }
Ejemplo n.º 2
0
        private void NodeImage_RightButtonSingleClick(object sender, MouseManagerEventArgs e)
        {
            if (IoC.GetInstance <ArrowCreationManager>().InMotion)
            {
                IoC.GetInstance <ArrowCreationManager>().SetTo(this);
            }
            else
            {
                if (!ParentSurface.Selector.IsMultiSelect || !ViewModelNode.IsSelected)
                {
                    ParentSurface.Selector.Clear();
                    ParentSurface.Selector.AddNode(this);
                    Focus();
                }

                Point location;

                if (ParentSurface.Selector.IsMultiSelect)
                {
                    foreach (var control in ParentSurface.Selector.NodeControls)
                    {
                        if (control == this && !control.IsCollapsed)
                        {
                            location = e.End.PositionInformation.GetPosition(ParentSurface);
                            ContextMenuContainer.ShowContextMenu <MultiNodesContextMenu>(location);
                            return;
                        }
                    }
                }
                else
                {
                    location = e.End.PositionInformation.GetPosition(ParentSurface);
                    ContextMenuContainer.ShowContextMenu <AuthorNodeControlContextMenu>(location, this);
                }
            }
        }
    protected override void OnInit(EventArgs e)
    {
        if (!RequestHelper.IsCallback() && RequestHelper.IsPostBack())
        {
            NodeID = ValidationHelper.GetInteger(Param1, 0);
            if (Action.ToLowerCSafe() == "refresh")
            {
                ExpandNodeID = ValidationHelper.GetInteger(Param2, 0);
            }
        }

        // Set up the tree
        if ((NodeID > 0) && !RequestHelper.IsPostBack())
        {
            treeElem.SelectedNodeID = NodeID;
            // Setup the current node script
            AddScript(string.Format("currentNodeId = {0};", NodeID));
        }

        treeElem.ExpandNodeID = ExpandNodeID;
        treeElem.Culture = Culture;
        treeElem.NodeTextTemplate = string.Format("{0}<span class=\"ContentTreeItem\" onclick=\"{2} SelectNode(##NODEID##, this); return false;\">##ICON##<span class=\"Name\">##NODENAME##</span></span>{1}##STATUSICONS##", ContextMenuContainer.GetStartTag("nodeMenu", "##NODEID##", false, false), ContextMenuContainer.GetEndTag(false), BeforeSelectNodeScript);
        treeElem.SelectedNodeTextTemplate = string.Format("{0}<span id=\"treeSelectedNode\" class=\"ContentTreeSelectedItem\" onclick=\"{2} SelectNode(##NODEID##, this); return false;\">##ICON##<span class=\"Name\">##NODENAME##</span></span>{1}##STATUSICONS##", ContextMenuContainer.GetStartTag("nodeMenu", "##NODEID##", false, false), ContextMenuContainer.GetEndTag(false), BeforeSelectNodeScript);
        treeElem.MaxTreeNodeText = string.Format("<span class=\"ContentTreeItem\" onclick=\"Listing(##PARENTNODEID##, this); return false;\"><span class=\"Name\" >{0}</span></span>", GetString("general.SeeListing"));
        treeElem.SelectPublishedData = false;
        treeElem.IsProductTree = IsProductTree;

        if (IsProductTree)
        {
            menuCont.MenuControlPath = "~/CMSModules/Ecommerce/Controls/UI/ProductSectionsContextMenu.ascx";
            treeElem.RootNodeCreated += treeElem_RootNodeCreated;

            // Filter only product section nodes
            string where = "NodeClassID IN (SELECT ClassID FROM CMS_Class WHERE ClassIsProductSection = 1)";

            // Check if products are to be displayed in tree
            if (DisplayProductsInSectionsTree)
            {
                // Include product documents
                where = SqlHelper.AddWhereCondition(where, "(NodeSKUID IS NOT NULL)", "OR");
            }

            treeElem.MapProvider.WhereCondition = SqlHelper.AddWhereCondition(treeElem.MapProvider.WhereCondition, where);
        }
        else
        {
            menuCont.MenuControlPath = "~/CMSModules/Content/Controls/TreeContextMenu.ascx";
        }

        if (!string.IsNullOrEmpty(StartingAliasPath))
        {
            treeElem.Path = StartingAliasPath;
        }
        base.OnInit(e);
    }
    private void CreateActions(List<HeaderAction> actions, Control parent, int level, bool useTable, bool renderAsContextMenu)
    {
        int actionsCount = actions.Count;
        if (useTable)
        {
            parent.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\" class=\"_nodivs\"><tr>"));
        }

        // Sort actions by index to be sure the order is ensured for multiple actions
        if (actionsCount > 1)
        {
            // At least one action has index
            if (ActionsList.Exists(a => (a.Index != -1)))
            {
                // Sort the actions
                ActionsList.Sort((a1, a2) => a1.Index.CompareTo(a2.Index));
            }
        }

        // Generate the actions
        for (int i = 0; i < actionsCount; ++i)
        {
            var action = actions[i];

            // If the text is not specified or visibility is false, skip the action
            FormSubmitButton formButton = action.BaseButton as FormSubmitButton;
            if (!action.IsVisible() || ((action.BaseButton != null) && (!action.BaseButton.Visible || ((formButton != null) && !formButton.RegisterHeaderAction))))
            {
                // Skip empty action
                action.Visible = false;
                continue;
            }

            // Set live site flag for resource strings
            action.IsLiveSite = IsLiveSite;

            // Start tag of the table if more then one action is defined
            if (useTable)
            {
                if (action.GenerateSeparatorBeforeAction && (i > 0))
                {
                    parent.Controls.Add(new LiteralControl("<td class=\"PadSeparator\"><span></span></td>"));
                }
                parent.Controls.Add(new LiteralControl("<td>"));

            }

            // Context menu container
            ContextMenuContainer container = null;
            bool enabled = Enabled && action.Enabled;
            bool renderCtxMenu = (action.AlternativeActions.Count > 0);
            if (renderCtxMenu)
            {
                container = new ContextMenuContainer
                {
                    ID = "menuCont" + i,
                    MenuID = ClientID + "m_" + level + i,
                    ParentElementClientID = ClientID,
                    RenderAsTag = HtmlTextWriterTag.Div,
                    MouseButton = MouseButtonEnum.Both,
                    OffsetY = 1,
                    VerticalPosition = VerticalPositionEnum.Bottom,
                    HorizontalPosition = HorizontalPositionEnum.Left,
                    CssClass = "CtxContainer",
                    Enabled = enabled,
                    IsLiveSite = IsLiveSite
                };

                if (action.Inactive)
                {
                    parent.Controls.Add(container);
                }
            }

            // Get the action parameters
            string ctrlId = ID + "_HA_" + level + i;
            string cssClass = !string.IsNullOrEmpty(action.CssClass) ? action.CssClass : LinkCssClass;
            string commandName = !string.IsNullOrEmpty(action.CommandName) ? action.CommandName : action.EventName;
            string url = ResolveUrl(action.RedirectUrl);

            // Add HyperLink
            HyperLink link = new HyperLink();
            link.ID = ctrlId;
            link.ToolTip = action.Tooltip;
            link.CssClass = enabled ? cssClass : (cssClass + "Disabled");
            link.Enabled = enabled;
            link.Text = action.Text;

            // Add control to the panel
            AddControlToPanel(link, (action.Inactive && (container != null)) ? container : parent, renderAsContextMenu);

            if (enabled && !action.Inactive)
            {
                // Perform post-back
                if (!String.IsNullOrEmpty(commandName))
                {
                    string script = null;
                    // Register encapsulation function
                    if (!string.IsNullOrEmpty(action.OnClientClick))
                    {
                        link.Attributes.Add("onclick", action.OnClientClick);
                        if (action.RegisterShortcutScript)
                        {
                            script = "if(!PerfAction_" + ctrlId + "()) { return false; }";
                            string scriptFunction = "function PerfAction_" + ctrlId + "() { " + action.OnClientClick.TrimEnd(';') + "; return true; }";
                            ScriptHelper.RegisterStartupScript(Page, typeof(string), "PerfAction_" + ctrlId, scriptFunction, true);
                        }
                    }

                    string argument = string.Join(";", new string[] { commandName, action.CommandArgument });
                    PostBackOptions opt = new PostBackOptions(this, argument)
                    {
                        PerformValidation = true,
                        ValidationGroup = action.ValidationGroup
                    };

                    string postbackScript = ControlsHelper.GetPostBackEventReference(this, opt, false, !PerformFullPostBack);
                    link.NavigateUrl = "javascript:" + postbackScript;

                    // Register the CRTL+S shortcut
                    if (action.RegisterShortcutScript)
                    {
                        // Store action information for shortcut event validation registration
                        shortcutAction = new HeaderAction() { IsLiveSite = IsLiveSite, CommandArgument = argument, ValidationGroup = action.ValidationGroup };

                        // Prepare action script
                        string actionScript = script + " " + postbackScript + ";";

                        // SaveObject function will simply simulate clicking the control
                        string scriptSave = string.Format(@"function SaveObject() {{ {0} }}", actionScript);
                        ScriptHelper.RegisterShortcuts(Page);
                        ScriptHelper.RegisterStartupScript(Page, typeof(string), ScriptHelper.SAVE_DOCUMENT_SCRIPT_KEY, scriptSave, true);
                    }
                }
                else
                {
                    link.Attributes.Add("onclick", action.OnClientClick);

                    // Use URL only for standard link
                    if (!String.IsNullOrEmpty(action.RedirectUrl))
                    {
                        link.NavigateUrl = url;
                        link.Target = action.Target;
                    }

                    // Register the CRTL+S shortcut for empty command name
                    if (action.RegisterShortcutScript)
                    {
                        // SaveObject function will simply simulate clicking the control
                        string scriptSave = string.Format(@"function SaveObject() {{ {0} }}", action.OnClientClick);
                        ScriptHelper.RegisterShortcuts(Page);
                        ScriptHelper.RegisterStartupScript(Page, typeof(string), ScriptHelper.SAVE_DOCUMENT_SCRIPT_KEY, scriptSave, true);
                    }
                }

            }

            // Create image if URL is not empty
            Image img = null;
            string imageUrl = (UseSmallIcons && !string.IsNullOrEmpty(action.SmallImageUrl)) ? action.SmallImageUrl : action.ImageUrl;
            if (!string.IsNullOrEmpty(imageUrl))
            {
                if (action.UseImageButton)
                {
                    ImageButton imgButton = new ImageButton();
                    if (!action.Inactive && enabled)
                    {
                        imgButton.PostBackUrl = url;
                    }

                    img = imgButton;
                }
                else
                {
                    img = new Image();
                }

                // Set common properties
                img.ID = ID + "_HAI_" + level + i;
                img.ImageUrl = imageUrl;
                img.ToolTip = action.Tooltip;
                img.AlternateText = action.Text;
                img.CssClass = IconCssClass;
                img.Enabled = enabled;
            }

            // Add controls to the panel
            if (img != null)
            {
                link.Controls.Add(img);
            }

            if (!string.IsNullOrEmpty(action.Text))
            {
                link.Controls.Add(new Label { Text = action.Text, CssClass = "Text" });
            }

            // Alternative actions
            if (renderCtxMenu)
            {
                if (!action.Inactive)
                {
                    container.RenderAsTag = HtmlTextWriterTag.Span;
                    container.OffsetX = -1;
                    parent.Controls.Add(container);
                    container.Controls.Add(new LiteralControl("<span class=\"SepContextButton\"><span class=\"Arrow\"></span></span>"));
                }
                else
                {
                    link.Controls.Add(new LiteralControl("<span class=\"ContextButton\"><span class=\"Arrow\"></span></span>"));
                }

                // Context menu
                ContextMenu menu = new ContextMenu();
                container.MenuControl = menu;
                container.InitializeMenuControl(menu);

                if (!String.IsNullOrEmpty(ContextMenuCssClass))
                {
                    menu.OuterCssClass = this.ContextMenuCssClass;
                }
                menu.CssClass = "PortalContextMenu CMSEditMenu";

                CreateActions(action.AlternativeActions, menu, i, false, true);
            }

            // Do not insert padding for last item
            if (i < actionsCount - 1)
            {
                parent.Controls.Add(new LiteralControl("<span class=\"Pad\"></span>"));
            }

            // Add free separator cell in table if it's not the last action
            if (useTable)
            {
                parent.Controls.Add(new LiteralControl(((i < actionsCount - 1) && RenderSeparator ? "</td><td style=\"width:" + SeparatorWidth + "px; \" />" : "</td>")));
            }
        }

        // End tag of the table
        if (useTable)
        {
            parent.Controls.Add(new LiteralControl("</tr></table>"));
        }
    }
Ejemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     dManager    = FindObjectOfType <DialogueManager>();
     cMContainer = FindObjectOfType <ContextMenuContainer>();
     bInteractions.Add(new ButtonInteraction("Falar", Speak));
 }
Ejemplo n.º 6
0
    private void CreateActions(List <HeaderAction> actions, Control parent, int level, bool useTable, bool renderAsContextMenu)
    {
        int actionsCount = actions.Count;

        if (useTable)
        {
            parent.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\" class=\"_nodivs\"><tr>"));
        }

        // Sort actions by index to be sure the order is ensured for multiple actions
        if (actionsCount > 1)
        {
            // At least one action has index
            if (ActionsList.Exists(a => (a.Index != -1)))
            {
                // Sort the actions
                ActionsList.Sort((a1, a2) => a1.Index.CompareTo(a2.Index));
            }
        }

        // Generate the actions
        for (int i = 0; i < actionsCount; ++i)
        {
            var action = actions[i];

            // If the text is not specified or visibility is false, skip the action
            FormSubmitButton formButton = action.BaseButton as FormSubmitButton;
            if (!action.IsVisible() || ((action.BaseButton != null) && (!action.BaseButton.Visible || ((formButton != null) && !formButton.RegisterHeaderAction))))
            {
                // Skip empty action
                action.Visible = false;
                continue;
            }

            // Set live site flag for resource strings
            action.IsLiveSite = IsLiveSite;

            // Start tag of the table if more then one action is defined
            if (useTable)
            {
                if (action.GenerateSeparatorBeforeAction && (i > 0))
                {
                    parent.Controls.Add(new LiteralControl("<td class=\"PadSeparator\"><span></span></td>"));
                }
                parent.Controls.Add(new LiteralControl("<td>"));
            }

            // Context menu container
            ContextMenuContainer container = null;
            bool enabled       = Enabled && action.Enabled;
            bool renderCtxMenu = (action.AlternativeActions.Count > 0);
            if (renderCtxMenu)
            {
                container = new ContextMenuContainer
                {
                    ID     = "menuCont" + i,
                    MenuID = ClientID + "m_" + level + i,
                    ParentElementClientID = ClientID,
                    RenderAsTag           = HtmlTextWriterTag.Div,
                    MouseButton           = MouseButtonEnum.Both,
                    OffsetY            = 1,
                    VerticalPosition   = VerticalPositionEnum.Bottom,
                    HorizontalPosition = HorizontalPositionEnum.Left,
                    CssClass           = "CtxContainer",
                    Enabled            = enabled,
                    IsLiveSite         = IsLiveSite
                };

                if (action.Inactive)
                {
                    parent.Controls.Add(container);
                }
            }


            // Get the action parameters
            string ctrlId      = ID + "_HA_" + level + i;
            string cssClass    = !string.IsNullOrEmpty(action.CssClass) ? action.CssClass : LinkCssClass;
            string commandName = !string.IsNullOrEmpty(action.CommandName) ? action.CommandName : action.EventName;
            string url         = ResolveUrl(action.RedirectUrl);

            // Add HyperLink
            HyperLink link = new HyperLink();
            link.ID       = ctrlId;
            link.ToolTip  = action.Tooltip;
            link.CssClass = enabled ? cssClass : (cssClass + "Disabled");
            link.Enabled  = enabled;
            link.Text     = action.Text;

            // Add control to the panel
            AddControlToPanel(link, (action.Inactive && (container != null)) ? container : parent, renderAsContextMenu);

            if (enabled && !action.Inactive)
            {
                // Perform post-back
                if (!String.IsNullOrEmpty(commandName))
                {
                    string script = null;
                    // Register encapsulation function
                    if (!string.IsNullOrEmpty(action.OnClientClick))
                    {
                        link.Attributes.Add("onclick", action.OnClientClick);
                        if (action.RegisterShortcutScript)
                        {
                            script = "if(!PerfAction_" + ctrlId + "()) { return false; }";
                            string scriptFunction = "function PerfAction_" + ctrlId + "() { " + action.OnClientClick.TrimEnd(';') + "; return true; }";
                            ScriptHelper.RegisterStartupScript(Page, typeof(string), "PerfAction_" + ctrlId, scriptFunction, true);
                        }
                    }

                    string          argument = string.Join(";", new string[] { commandName, action.CommandArgument });
                    PostBackOptions opt      = new PostBackOptions(this, argument)
                    {
                        PerformValidation = true,
                        ValidationGroup   = action.ValidationGroup
                    };

                    string postbackScript = ControlsHelper.GetPostBackEventReference(this, opt, false, !PerformFullPostBack);
                    link.NavigateUrl = "javascript:" + postbackScript;

                    // Register the CRTL+S shortcut
                    if (action.RegisterShortcutScript)
                    {
                        // Store action information for shortcut event validation registration
                        shortcutAction = new HeaderAction()
                        {
                            IsLiveSite = IsLiveSite, CommandArgument = argument, ValidationGroup = action.ValidationGroup
                        };

                        // Prepare action script
                        string actionScript = script + " " + postbackScript + ";";

                        // SaveObject function will simply simulate clicking the control
                        string scriptSave = string.Format(@"function SaveObject() {{ {0} }}", actionScript);
                        ScriptHelper.RegisterShortcuts(Page);
                        ScriptHelper.RegisterStartupScript(Page, typeof(string), ScriptHelper.SAVE_DOCUMENT_SCRIPT_KEY, scriptSave, true);
                    }
                }
                else
                {
                    link.Attributes.Add("onclick", action.OnClientClick);

                    // Use URL only for standard link
                    if (!String.IsNullOrEmpty(action.RedirectUrl))
                    {
                        link.NavigateUrl = url;
                        link.Target      = action.Target;
                    }

                    // Register the CRTL+S shortcut for empty command name
                    if (action.RegisterShortcutScript)
                    {
                        // SaveObject function will simply simulate clicking the control
                        string scriptSave = string.Format(@"function SaveObject() {{ {0} }}", action.OnClientClick);
                        ScriptHelper.RegisterShortcuts(Page);
                        ScriptHelper.RegisterStartupScript(Page, typeof(string), ScriptHelper.SAVE_DOCUMENT_SCRIPT_KEY, scriptSave, true);
                    }
                }
            }

            // Create image if URL is not empty
            Image  img      = null;
            string imageUrl = (UseSmallIcons && !string.IsNullOrEmpty(action.SmallImageUrl)) ? action.SmallImageUrl : action.ImageUrl;
            if (!string.IsNullOrEmpty(imageUrl))
            {
                if (action.UseImageButton)
                {
                    ImageButton imgButton = new ImageButton();
                    if (!action.Inactive && enabled)
                    {
                        imgButton.PostBackUrl = url;
                    }

                    img = imgButton;
                }
                else
                {
                    img = new Image();
                }

                // Set common properties
                img.ID            = ID + "_HAI_" + level + i;
                img.ImageUrl      = imageUrl;
                img.ToolTip       = action.Tooltip;
                img.AlternateText = action.Text;
                img.CssClass      = IconCssClass;
                img.Enabled       = enabled;
            }

            // Add controls to the panel
            if (img != null)
            {
                link.Controls.Add(img);
            }

            if (!string.IsNullOrEmpty(action.Text))
            {
                link.Controls.Add(new Label {
                    Text = action.Text, CssClass = "Text"
                });
            }

            // Alternative actions
            if (renderCtxMenu)
            {
                if (!action.Inactive)
                {
                    container.RenderAsTag = HtmlTextWriterTag.Span;
                    container.OffsetX     = -1;
                    parent.Controls.Add(container);
                    container.Controls.Add(new LiteralControl("<span class=\"SepContextButton\"><span class=\"Arrow\"></span></span>"));
                }
                else
                {
                    link.Controls.Add(new LiteralControl("<span class=\"ContextButton\"><span class=\"Arrow\"></span></span>"));
                }

                // Context menu
                ContextMenu menu = new ContextMenu();
                container.MenuControl = menu;
                container.InitializeMenuControl(menu);

                if (!String.IsNullOrEmpty(ContextMenuCssClass))
                {
                    menu.OuterCssClass = this.ContextMenuCssClass;
                }
                menu.CssClass = "PortalContextMenu CMSEditMenu";

                CreateActions(action.AlternativeActions, menu, i, false, true);
            }

            // Do not insert padding for last item
            if (i < actionsCount - 1)
            {
                parent.Controls.Add(new LiteralControl("<span class=\"Pad\"></span>"));
            }

            // Add free separator cell in table if it's not the last action
            if (useTable)
            {
                parent.Controls.Add(new LiteralControl(((i < actionsCount - 1) && RenderSeparator ? "</td><td style=\"width:" + SeparatorWidth + "px; \" />" : "</td>")));
            }
        }

        // End tag of the table
        if (useTable)
        {
            parent.Controls.Add(new LiteralControl("</tr></table>"));
        }
    }
Ejemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register the dialog script
        ScriptHelper.RegisterScriptFile(this, @"~/CMSModules/Content/CMSDesk/tree.js");
        ScriptHelper.RegisterDialogScript(this);
        ScriptHelper.RegisterJQuery(Page);

        AddScript(string.Format("treeUrl = '{0}'; var contentDir = '{1}';\n",
                                ResolveUrl("~/CMSModules/Content/CMSDesk/Tree.aspx"),
                                ResolveUrl("~/CMSModules/Content/CMSDesk/")));

        treeContent.NodeTextTemplate         = string.Format("{0}<span class=\"ContentTreeItem\" onclick=\"SelectNode(##NODEID##, this); return false;\">##ICON##<span class=\"Name\">##NODENAME##</span></span>{1}", ContextMenuContainer.GetStartTag("nodeMenu", "##NODEID##", false, false), ContextMenuContainer.GetEndTag(false));
        treeContent.SelectedNodeTextTemplate = string.Format("{0}<span id=\"treeSelectedNode\" class=\"ContentTreeSelectedItem\" onclick=\"SelectNode(##NODEID##, this); return false;\">##ICON##<span class=\"Name\">##NODENAME##</span></span>{1}", ContextMenuContainer.GetStartTag("nodeMenu", "##NODEID##", false, false), ContextMenuContainer.GetEndTag(false));
        treeContent.MaxTreeNodeText          = string.Format("<span class=\"ContentTreeItem\" onclick=\"Listing(##PARENTNODEID##, this); return false;\"><span class=\"Name\" style=\"font-style: italic;\">{0}</span></span>", GetString("ContentTree.SeeListing"));
        treeContent.SelectPublishedData      = false;

        if (!string.IsNullOrEmpty(CMSContext.CurrentUser.UserStartingAliasPath))
        {
            treeContent.Path = CMSContext.CurrentUser.UserStartingAliasPath;
        }

        if (!Page.IsCallback)
        {
            // If nodeId set, init the list of the nodes to expand
            int expandNodeId = QueryHelper.GetInteger("expandnodeid", 0);
            int nodeId       = QueryHelper.GetInteger("nodeid", 0);

            if (RequestHelper.IsPostBack())
            {
                nodeId = ValidationHelper.GetInteger(Param1, 0);
                if (Action.ToLower() == "refresh")
                {
                    expandNodeId = ValidationHelper.GetInteger(Param2, 0);
                }
            }

            // Current Node ID
            treeContent.NodeID       = nodeId;
            treeContent.ExpandNodeID = expandNodeId;

            string script = null;

            // Setup the current node script
            if ((nodeId > 0) && !RequestHelper.IsPostBack())
            {
                script += string.Format("currentNodeId = {0};\n", nodeId);
            }

            script +=
                @"function ProcessRequest(action, param1, param2){
    var elm = jQuery('#" + pnlTreeArea.ClientID + @"');
    jQuery('#hdnScroll').val(elm.scrollTop());
    jQuery('#hdnAction').val(action); 
    jQuery('#hdnParam1').val(param1); 
    jQuery('#hdnParam2').val(param2);" +
                ClientScript.GetPostBackEventReference(this, null) + "}\n";

            AddScript(script);

            imgRefresh.ImageUrl      = GetImageUrl("CMSModules/CMS_Content/ContextMenu/Refresh.png");
            imgRefresh.AlternateText = GetString("general.refresh");
            imgRefresh.Attributes.Add("onclick", "RefreshTree(" + nodeId + ",null)");
            AddScript(string.Format("var refreshIconID = \"{0}\";", imgRefresh.ClientID));
        }
    }
Ejemplo n.º 8
0
    protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        sourceName = sourceName.ToLowerCSafe();
        DataRowView drv = null;
        bool        modifyPermission = true;
        string      documentCulture  = null;

        switch (sourceName)
        {
        case "documentname":
            drv = parameter as DataRowView;
            string documentName        = null;
            string encodedDocumentName = null;
            string documentType        = null;
            documentCulture = ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty);
            string alias           = ValidationHelper.GetString(drv.Row["NodeAlias"], string.Empty);
            int    nodeId          = ValidationHelper.GetInteger(drv.Row["NodeID"], 0);
            int    documentId      = ValidationHelper.GetInteger(drv.Row["DocumentID"], 0);
            bool   isLinked        = (ValidationHelper.GetInteger(drv["NodeLinkedNodeID"], 0) != 0);
            Guid   nodeGuid        = ValidationHelper.GetGuid(drv.Row["NodeGUID"], Guid.Empty);
            string fileDescription = ValidationHelper.GetString(drv.Row["FileDescription"], string.Empty);
            Guid   fileAttachment  = ValidationHelper.GetGuid(drv.Row["FileAttachment"], Guid.Empty);

            // Get permissions flags
            modifyPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, documentCulture);
            bool modifyCulturePermission     = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, PreferredCultureCode);
            bool deletePermission            = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Delete, documentCulture);
            bool modifyPermissionsPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.ModifyPermissions, documentCulture);
            bool readPermission = !CheckPermissions || TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Read, documentCulture);

            if (modifyPermission)
            {
                documentName = ValidationHelper.GetString(drv.Row["DocumentName"], string.Empty);
                documentType = ValidationHelper.GetString(drv.Row["DocumentType"], string.Empty);
            }
            else
            {
                documentName = ValidationHelper.GetString(drv.Row["PublishedDocumentName"], string.Empty);
                documentType = ValidationHelper.GetString(drv.Row["PublishedDocumentType"], string.Empty);
            }

            encodedDocumentName = HTMLHelper.HTMLEncode(documentName);

            string fileTypeIcon = UIHelper.GetFileIcon(Page, documentType, tooltip: HTMLHelper.HTMLEncode(documentType));
            string flagIcon     = null;
            if (documentCulture.ToLowerCSafe() != PreferredCultureCode.ToLowerCSafe())
            {
                flagIcon = "<img class=\"Icon\" src=\"" + GetFlagIconUrl(documentCulture, "16x16") + "\" alt=\"" + HTMLHelper.HTMLEncode(documentCulture) + "\" />";
            }

            string menuParameter = ScriptHelper.GetString(nodeId + "|" + documentCulture);

            string attachmentName = encodedDocumentName;

            string toolTip = UIHelper.GetTooltipAttributes(null, 0, 0, null, null, null, fileDescription, null, 300);

            // Generate link to open document
            if (fileAttachment != Guid.Empty)
            {
                // Get document URL
                string attachmentUrl = AuthenticationHelper.ResolveUIUrl(AttachmentURLProvider.GetPermanentAttachmentUrl(nodeGuid, alias));
                if (modifyPermission)
                {
                    attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "latestfordocid", ValidationHelper.GetString(documentId, string.Empty));
                    attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "hash", ValidationHelper.GetHashString("d" + documentId));
                }
                attachmentUrl = URLHelper.UpdateParameterInUrl(attachmentUrl, "chset", Guid.NewGuid().ToString());

                if (!string.IsNullOrEmpty(attachmentUrl))
                {
                    attachmentName = "<a href=\"" + HTMLHelper.EncodeForHtmlAttribute(attachmentUrl) + "\" " + toolTip + ">" + encodedDocumentName + "</a> ";
                }
            }
            else
            {
                attachmentName = "<span" + toolTip + ">" + encodedDocumentName + "</span>";
            }

            // Add linked flag
            if (isLinked)
            {
                attachmentName += DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
            }

            bool showContextMenu = readPermission && (modifyPermission || modifyPermissionsPermission || deletePermission || (IsAuthorizedToCreate && modifyCulturePermission));
            // Generate row with icons, hover action and context menu
            StringBuilder contextMenuString = new StringBuilder();
            contextMenuString.Append("<table>");
            contextMenuString.Append("<tr>");

            if (showContextMenu)
            {
                contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + arrowContextMenu.ClientID, menuParameter, false, HtmlTextWriterTag.Td, "ArrowIcon", null));
                contextMenuString.Append("<a class=\"btn-unigrid-action\"><i class=\"icon-ellipsis\"></i></a>");
                contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td));
            }
            else
            {
                contextMenuString.Append("<td class=\"NoIcon\">&nbsp;</td>");
            }

            if (showContextMenu)
            {
                contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "FileTypeIcon", null));
            }
            else
            {
                contextMenuString.Append("<td class=\"FileTypeIcon\">");
            }
            contextMenuString.Append(fileTypeIcon);
            contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td));

            if (showContextMenu)
            {
                contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "RowContent", "width: 100%;"));
            }
            else
            {
                contextMenuString.Append("<td class=\"RowContent\" style=\"width: 100%;\">");
            }
            contextMenuString.Append(attachmentName);
            contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td));

            if (!string.IsNullOrEmpty(flagIcon))
            {
                contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "FlagIcon", null));
                contextMenuString.Append(flagIcon);
                contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td));
            }
            contextMenuString.Append("  </tr>");
            contextMenuString.Append("</table>");
            return(contextMenuString.ToString());

        case "modifiedwhen":
        case "modifiedwhentooltip":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                return(string.Empty);
            }
            else
            {
                // Handle time zones
                DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);

                if (sourceName == "modifiedwhen")
                {
                    if (IsLiveSite)
                    {
                        return(TimeZoneMethods.ConvertDateTime(modifiedWhen, this));
                    }
                    else
                    {
                        return(TimeZoneHelper.GetCurrentTimeZoneDateTimeString(modifiedWhen, CurrentUser, CurrentSite, out usedTimeZone));
                    }
                }
                else
                {
                    if (!IsLiveSite)
                    {
                        if (TimeZoneHelper.TimeZonesEnabled && (usedTimeZone == null))
                        {
                            TimeZoneHelper.GetCurrentTimeZoneDateTimeString(modifiedWhen, CurrentUser, CurrentSite, out usedTimeZone);
                        }
                        return(TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

        case "status":
            string stepName = string.Empty;
            string toReturn = string.Empty;

            // Extract datarow
            drv      = parameter as DataRowView;
            stepName = GetString("general.dash");
            TreeNode node = DocumentHelper.GetDocument(ValidationHelper.GetInteger(drv["DocumentID"], 0), TreeProvider);
            if (node != null)
            {
                var step = node.WorkflowStep;
                if (step != null)
                {
                    stepName = step.StepDisplayName;
                }
            }
            // Gain desired values from datarow view
            int checkedOutByUserId = ValidationHelper.GetInteger(drv["DocumentCheckedOutByUserID"], 0);
            documentCulture  = ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty);
            modifyPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, documentCulture);

            // Add 'checked out' icon
            if ((checkedOutByUserId > 0) && modifyPermission)
            {
                toReturn = " " + DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.CheckedOut);
            }

            toReturn = stepName + toReturn;
            return(toReturn);
        }
        return(parameter);
    }