/// <summary>
    /// Creates URL for editing.
    /// </summary>
    private String GetEditUrl()
    {
        String url = String.Empty;

        if (mUIEdit != null)
        {
            url = UIContextHelper.GetElementUrl(mUIEdit, UIContext);
            url = URLHelper.AppendQuery(url, "objectid={0}");

            // Ensures dialog parameters
            if (mEditInDialog)
            {
                url = URLHelper.UpdateParameterInUrl(url, "dialog", "true");
                url = URLHelper.UpdateParameterInUrl(url, "displaytitle", "true");
            }

            // Add specific ID for object. F.e. add ReportID={ID} to query
            String objectParameterID = ValidationHelper.GetString(UIContext["objectParameterID"], String.Empty);
            if (objectParameterID != String.Empty)
            {
                url += String.Format("&{0}={{0}}", objectParameterID);
            }

            url = UIContextHelper.AppendDialogHash(UIContext, url);
        }

        return(url);
    }
Exemple #2
0
    /// <summary>
    /// Handles the OnAfterSave event of the EditForm control.
    /// </summary>
    protected void EditForm_OnAfterSave(object sender, EventArgs ea)
    {
        String saveScript = AfterSaveScript;

        if (saveScript != String.Empty)
        {
            ScriptHelper.RegisterClientScriptBlock(this, typeof(String), "aftersavescript", ScriptHelper.GetScript(saveScript));
        }
        else
        {
            if (!String.IsNullOrEmpty(RedirectURL))
            {
                URLHelper.Redirect(RedirectURL);
            }

            if (newItem)
            {
                String url = RedirectURL;
                if (String.IsNullOrEmpty(RedirectURL))
                {
                    // Find element representing new object
                    UIElementInfo uiPar = UIElementInfoProvider.GetUIElementInfo(UIContext.UIElement.ElementParentID);
                    if (uiPar != null)
                    {
                        // Append parameters
                        url = UIContextHelper.GetElementUrl(uiPar.GetEditElement(), UIContext);
                        url = URLHelper.AppendQuery(url, "objectid=" + EditForm.EditedObject.Generalized.ObjectID + "&saved=1");

                        // Ensure that the redirected edit page will behave as a top dialog page (hide breadcrumbs, uses dialog page title...)
                        url = URLHelper.RemoveParameterFromUrl(url, "rootelementid");

                        // Append action edit parameter
                        url = URLHelper.AddParameterToUrl(url, "action", "edit");
                    }
                }

                // Ensure hash for dialog mode
                url = UIContextHelper.AppendDialogHash(UIContext, url);

                EditForm.RedirectUrlAfterSave = url;
            }
        }

        // Raise the javascript return handler function
        RaiseReturnHandler();

        if (itemChanged)
        {
            String refreshWopener = String.Empty;

            // Refresh opener for dialog page.
            if (IsDialog)
            {
                refreshWopener = "if(wopener!=null) {if (wopener.Refresh != null) {wopener.Refresh()} else if (wopener.RefreshPage != null) wopener.RefreshPage();}";
            }

            ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "RefreshParent", ScriptHelper.GetScript(refreshWopener + "if (parent.refreshPage) {parent.refreshPage()} else parent.location = parent.location;"));
        }
    }
Exemple #3
0
 /// <summary>
 /// Appends additional query parameters.
 /// </summary>
 protected void Control_OnTabCreated(object sender, TabCreatedEventArgs e)
 {
     if ((e.Tab != null) && !String.IsNullOrEmpty(deviceName))
     {
         e.Tab.RedirectUrl = URLHelper.AddParameterToUrl(e.Tab.RedirectUrl, "devicename", deviceName);
         e.Tab.RedirectUrl = UIContextHelper.AppendDialogHash(e.Tab.RedirectUrl);
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        String text    = String.Empty;
        String url     = TargetUrl;
        bool   enabled = true;
        String onClick = String.Empty;

        // If new element is set, load it directly, otherwise use first element with prefix 'new' in its name.
        UIElementInfo uiNew = String.IsNullOrEmpty(NewElement) ? UIContext.UIElement.GetNewElement() :
                              UIElementInfoProvider.GetUIElementInfo(UIContext.UIElement.ElementResourceID, NewElement);

        bool   openInDialog = false;
        String dialogWidth  = null;
        String dialogHeight = null;

        if (uiNew != null)
        {
            UIContextData data = new UIContextData();
            data.LoadData(uiNew.ElementProperties);
            text    = UIElementInfoProvider.GetElementCaption(uiNew);
            enabled = UIContextHelper.CheckElementVisibilityCondition(uiNew);
            url     = ContextResolver.ResolveMacros(UIContextHelper.GetElementUrl(uiNew, UIContext));

            openInDialog = data["OpenInDialog"].ToBoolean(false);
            dialogWidth  = data["DialogWidth"].ToString(null);
            dialogHeight = data["DialogHeight"].ToString(null);

            // Set on-click for JavaScript type
            if (uiNew.ElementType == UIElementTypeEnum.Javascript)
            {
                onClick = url;
                url     = String.Empty;
            }
            else
            {
                // For URL append dialog hash if needed
                url = UIContextHelper.AppendDialogHash(UIContext, url);
            }
        }

        // If url is non empty add action
        if (((url != String.Empty) || (onClick != String.Empty)) && (HeaderActions != null))
        {
            HeaderActions.AddAction(new HeaderAction()
            {
                Text          = GetString(text),
                RedirectUrl   = url,
                Enabled       = enabled,
                OnClientClick = onClick,
                OpenInDialog  = openInDialog,
                DialogWidth   = dialogWidth,
                DialogHeight  = dialogHeight
            });
        }
    }
Exemple #5
0
    /// <summary>
    /// Sets url for redirect after creating abtest.
    /// </summary>
    private void SetRedirectUrlAfterCreate()
    {
        string url = UIContextHelper.GetElementUrl("CMS.MVTest", "Detail");

        url = URLHelper.AddParameterToUrl(url, "objectID", "{%EditedObject.ID%}");
        url = URLHelper.AddParameterToUrl(url, "saved", "1");

        url = URLHelper.PropagateUrlParameters(url, "aliaspath", "nodeid", "displayTitle", "dialog");

        url = UIContextHelper.AppendDialogHash(url);

        form.RedirectUrlAfterCreate = url;
    }
Exemple #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Setup help
        object options = new
        {
            helpName = "lnkProductEditHelp",
            helpUrl  = UIContextHelper.GetDocumentationTopicUrl(HELP_TOPIC_LINK)
        };

        ScriptHelper.RegisterModule(this, "CMS/DialogContextHelpChange", options);

        if (ProductID > 0)
        {
            sku = SKUInfoProvider.GetSKUInfo(ProductID);

            EditedObject = sku;

            if (sku != null)
            {
                // Check site ID
                CheckEditedObjectSiteID(sku.SKUSiteID);

                ucOptions.ProductID = ProductID;

                // Add new category button in HeaderAction
                CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
                {
                    Text          = GetString("com.productoptions.select"),
                    OnClientClick = ucOptions.GetAddCategoryJavaScript(),
                    Enabled       = ECommerceContext.IsUserAuthorizedToModifySKU(sku.IsGlobal)
                });

                // New button is active in editing of global product only if global option categories are allowed and user has GlobalModifyPermission permission
                bool enabledButton = (sku.IsGlobal) ? ECommerceSettings.AllowGlobalProductOptions(CurrentSiteName) && ECommerceContext.IsUserAuthorizedToModifyOptionCategory(true)
                    : ECommerceContext.IsUserAuthorizedToModifyOptionCategory(false);

                // Create new enabled/disabled category button in HeaderAction
                var dialogUrl = URLHelper.ResolveUrl("~/CMSModules/Ecommerce/Pages/Tools/ProductOptions/OptionCategory_New.aspx?ProductID=" + sku.SKUID + "&dialog=1");
                dialogUrl = UIContextHelper.AppendDialogHash(dialogUrl);

                CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
                {
                    Text          = GetString("com.productoptions.new"),
                    Enabled       = enabledButton,
                    ButtonStyle   = ButtonStyle.Default,
                    OnClientClick = "modalDialog('" + dialogUrl + "','NewOptionCategoryDialog', 1000, 800);"
                });
            }
        }
    }
    /// <summary>
    /// Occurs when new transformation is saved.
    /// </summary>
    protected void ucTransf_OnSaved(object sender, EventArgs e)
    {
        //Transfer to transformation list
        var query = String.Format("?objectid={0}&classid={1}", ucTransf.TransInfo.TransformationID, ucTransf.DocumentTypeID);

        var url = UIContextHelper.GetElementUrl("CMS.DocumentEngine", "EditTransformation");

        url = URLHelper.AppendQuery(url, RequestContext.CurrentQueryString);
        url = URLHelper.AppendQuery(url, query);

        if (editOnlyCode)
        {
            // Add hash for dialog URL, dialog=1 is added by CurrentQueryString append.
            url = UIContextHelper.AppendDialogHash(url);
        }

        URLHelper.Redirect(url);
    }
Exemple #8
0
    /// <summary>
    /// Actions handler.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        if (e.CommandName.ToLowerInvariant() == "save")
        {
            if (editElem.Save())
            {
                string url = UIContextHelper.GetElementUrl(ModuleName.NEWSLETTER, "EditIssueProperties");
                url = URLHelper.AddParameterToUrl(url, "tabname", "Newsletter.Issue.Content");
                url = URLHelper.AddParameterToUrl(url, "objectid", editElem.IssueID.ToString());
                url = URLHelper.PropagateUrlParameters(url, "parentobjectid");
                url = UIContextHelper.AppendDialogHash(url);
                URLHelper.Redirect(url);
            }
            else
            {
                MessagesPlaceHolder.ShowError(editElem.ErrorMessage);

                // Refresh content of editable regions in the issue body
                editElem.RefreshEditableRegions();
            }
        }
    }
    private void ProcessDialog(WebPartContainerInfo webPartContainer, bool closeOnSave)
    {
        WebPartContainerSiteInfoProvider.AddContainerToSite(webPartContainer, SiteContext.CurrentSite);

        ScriptHelper.RegisterWOpenerScript(this);
        string returnHandler = ScriptHelper.GetString(QueryHelper.GetString("returnhandler", String.Empty), false);
        string script        = "if (wopener && wopener." + returnHandler + ") { wopener." + returnHandler + "('" + webPartContainer.ContainerName + "'); }";

        // Redirects to edit window or simply closes the current window
        if (closeOnSave)
        {
            script += "CloseDialog();";
        }
        else
        {
            UIElementInfo ui = UIElementInfoProvider.GetUIElementInfo("cms.Design", "EditWebPartContainer");
            if (ui != null)
            {
                // Create base URL for element
                String url = UIContextHelper.GetElementUrl(ui, UIContext);

                // Append object ID
                url = URLHelper.AddParameterToUrl(url, "objectid", webPartContainer.ContainerID.ToString());

                // Append actual query string parameters
                url = URLHelper.AddParameterToUrl(url, "returnhandler", QueryHelper.GetString("returnhandler", String.Empty));
                url = URLHelper.AddParameterToUrl(url, "dialog", "1");
                url = URLHelper.AddParameterToUrl(url, "aliaspath", QueryHelper.GetString("aliaspath", String.Empty));
                url = URLHelper.AddParameterToUrl(url, "instanceguid", QueryHelper.GetString("instanceguid", String.Empty));

                // Append dialog hash
                url = UIContextHelper.AppendDialogHash(url);

                script += "window.location.replace('" + ResolveUrl(url) + "');";
            }
        }

        ScriptHelper.RegisterStartupScript(this, GetType(), "UpdateSelector", script, true);
    }
Exemple #10
0
    private CMSButtonAction GetControlAction(HeaderAction headerAction)
    {
        var controlAction = new CMSButtonAction();

        controlAction.Text    = headerAction.Text;
        controlAction.Enabled = headerAction.Enabled && Enabled;
        controlAction.ToolTip = headerAction.Tooltip;

        // Register script only when action is active
        if (Enabled && headerAction.Enabled && !headerAction.Inactive)
        {
            // Wrap script from OnClick property into anonymous function so it won't cancel the following script in case this property scipt returns true.
            // The execution of following script is canceled only when anonymous function returns false.
            if (!String.IsNullOrEmpty(headerAction.OnClientClick))
            {
                string onClickScript = "var onClickWrapper = function(sender) { " + headerAction.OnClientClick + "}; if (onClickWrapper(this) === false) { return false; }";
                controlAction.OnClientClick = onClickScript;
            }

            string commandName = !string.IsNullOrEmpty(headerAction.CommandName) ? headerAction.CommandName : headerAction.EventName;

            // Perform post-back
            if (!String.IsNullOrEmpty(commandName) || !String.IsNullOrEmpty(headerAction.CommandArgument))
            {
                string argument = string.Join(";", new[]
                {
                    commandName,
                    headerAction.CommandArgument
                });

                var opt = new PostBackOptions(this, argument)
                {
                    PerformValidation = true,
                    ValidationGroup   = headerAction.ValidationGroup
                };

                string postbackScript = ControlsHelper.GetPostBackEventReference(this, opt, false, !PerformFullPostBack);
                controlAction.OnClientClick += postbackScript + ";";
            }
            else
            {
                // Use URL only for standard link
                if (!String.IsNullOrEmpty(headerAction.RedirectUrl))
                {
                    var target = headerAction.Target ?? "_self";

                    var url = ScriptHelper.ResolveUrl(headerAction.RedirectUrl);

                    if (headerAction.OpenInDialog)
                    {
                        url = URLHelper.AddParameterToUrl(url, "dialog", "1");
                        url = UIContextHelper.AppendDialogHash(url);

                        ScriptHelper.RegisterDialogScript(Page);

                        controlAction.OnClientClick = ScriptHelper.GetModalDialogScript(url, "action" + headerAction.Index, headerAction.DialogWidth, headerAction.DialogHeight, false);
                    }
                    else
                    {
                        controlAction.OnClientClick += "window.open('" + url + "','" + target + "');";
                    }
                }
            }

            // Stop automatic postback rendered by asp button
            controlAction.OnClientClick += " return false;";
        }

        return(controlAction);
    }
    /// <summary>
    /// Handles the OnAfterSave event of the EditForm control.
    /// </summary>
    protected void EditForm_OnAfterSave(object sender, EventArgs ea)
    {
        String saveScript = AfterSaveScript;

        if (saveScript != String.Empty)
        {
            ScriptHelper.RegisterClientScriptBlock(this, typeof(String), "aftersavescript", ScriptHelper.GetScript(saveScript));
        }
        else
        {
            if (!String.IsNullOrEmpty(RedirectURL))
            {
                EditForm.RedirectUrlAfterSave = RedirectURL;
            }
            // If there is some redirect URL already set in the UI form, do not override this value with the URL taken
            // from the UI element, or with the generated one.
            // Existing value can only be set from the extender and therefore has higher priority.
            else if (newItem && String.IsNullOrEmpty(EditForm.RedirectUrlAfterSave))
            {
                // Find element representing new object
                UIElementInfo uiPar = UIElementInfoProvider.GetUIElementInfo(UIContext.UIElement.ElementParentID);
                if (uiPar != null)
                {
                    // Append parameters
                    string url = UIContextHelper.GetElementUrl(uiPar.GetEditElement(), UIContext);
                    url = URLHelper.AppendQuery(url, $"objectid={EditForm.EditedObject.Generalized.ObjectID}&saved=1");

                    // Ensure that the redirected edit page will behave as a top dialog page (hide breadcrumbs, uses dialog page title...)
                    url = URLHelper.RemoveParameterFromUrl(url, "rootelementid");

                    // Ensure hash for dialog mode
                    url = UIContextHelper.AppendDialogHash(UIContext, url);
                    EditForm.RedirectUrlAfterSave = url;
                }
            }
        }

        // Raise the javascript return handler function
        RaiseReturnHandler();

        if (itemChanged)
        {
            String refreshWopener = String.Empty;

            // Refresh opener for dialog page.
            if (IsDialog)
            {
                refreshWopener = @"
if(wopener) {
    if (wopener.Refresh) { 
        wopener.Refresh()
    } else if (wopener.RefreshPage) {
        wopener.RefreshPage();
    }
    else {
        wopener.location.reload(true);
    }
} else ";
            }

            refreshWopener += @"
if (parent.refreshPage) { 
    parent.refreshPage()
} else {
    parent.location.reload(true);
}
";

            ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "RefreshParent", ScriptHelper.GetScript(refreshWopener));
        }
    }
    /// <summary>
    /// Sets buttons actions.
    /// </summary>
    protected void Initialize()
    {
        ScriptHelper.RegisterDialogScript(Page);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "GetSelectedItem" + ItemType, ScriptHelper.GetScript(@"
            function getSelectedItem_" + ItemType + @"() { 
				if (document.getElementById('"                 + brsItems.UniSelectorClientID + @"') != null) {
					return document.getElementById('"                     + brsItems.UniSelectorClientID + @"').value;
				}
				return 0;
			}

            function DeleteItem_" + ItemType + @"() {
				if ((document.getElementById('"                 + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) {
					if (confirm("                     + ScriptHelper.GetLocalizedString("general.confirmdelete") + @")) {
						document.getElementById('"                         + hdnItemId.ClientID + @"').value = getSelectedItem_" + ItemType + @"(); 
						"                         + Page.ClientScript.GetPostBackEventReference(btnHdnDelete, null) + @" 
					}
				} else { 
					alert("                     + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); 
				}
			}

            function InserMacro_" + ItemType + @"() {
				if ((document.getElementById('"                 + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) {
					PageMethods.GetReportItemName('"                     + ReportInfoProvider.ReportItemTypeToString(ItemType) + "',getSelectedItem_" + ItemType + "(),OnComplete_" + ItemType + @");
				} else { 
					alert("                     + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); 
				}
            }

			function OnComplete_"             + ItemType + @"(result, response, context) {
				InsertHTML('%%control:Report"                 + ItemType + "?" + Report.ReportName + @".' + result +'%%');
            }

            function CloneItem_" + ItemType + @"(id) {
				if ((document.getElementById('"                 + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) { 
					modalDialog('"                     + URLHelper.ResolveUrl("~/CMSModules/Objects/Dialogs/CloneObjectDialog.aspx?objectType=" + GetObjectType() + @"&objectId=' + id") + @", 'CloneObject', 750, 470);
				} else { 
					alert("                     + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); 
				}
            }"));


        const string MODAL_HEIGHT = "760";
        const string MODAL_WIDTH  = "1050";


        if (Report != null)
        {
            string baseUrl = URLHelper.AddParameterToUrl(ResolveUrl(EditUrl), "reportId", Report.ReportID.ToString());
            string fullUrl = UIContextHelper.AppendDialogHash(baseUrl);

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "modalDialog('" + fullUrl + "','ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + ");return false;",
                Text          = GetString("general.new")
            });

            fullUrl = URLHelper.AddParameterToUrl(baseUrl, "preview", "true");
            fullUrl = UIContextHelper.AppendDialogHash(fullUrl);

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "if (getSelectedItem_" + ItemType + "() != '0') { modalDialog('" + fullUrl + "&objectid='+ getSelectedItem_" + ItemType + "(),'ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + "); } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + ");} return false;",
                Text          = GetString("general.preview")
            });

            fullUrl = UIContextHelper.AppendDialogHash(baseUrl);

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "if (getSelectedItem_" + ItemType + "() != '0') { modalDialog('" + fullUrl + "&objectid='+ getSelectedItem_" + ItemType + "(),'ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + "); } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + ");} return false;",
                Text          = GetString("general.edit")
            });

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "DeleteItem_" + ItemType + "(); return false;",
                Text          = GetString("general.delete")
            });

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "CloneItem_" + ItemType + @"(getSelectedItem_" + ItemType + "()); return false;",
                Text          = GetString("general.clone")
            });

            btnInsert.OnClientClick = "InserMacro_" + ItemType + "(); return false;";
        }
    }