Exemple #1
0
    /// <summary>
    /// Page load event handler
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        pnlButtons.Visible = ShowTemplateButtons;
        btnClear.Visible   = DisplayClearButton;

        // Tooltips
        btnClone.ToolTip = GetString("pagetemplateselector.clone");
        btnEditTemplateProperties.ToolTip = GetString("pagetemplateselector.edit");
        btnSave.ToolTip = GetString("pagetemplateselector.save");


        if (PageTemplateInfo != null)
        {
            int templateId = PageTemplateInfo.PageTemplateId;

            plcUIClone.Visible = PageTemplateInfo.IsReusable;

            if (Enabled)
            {
                // Add root category filter
                String root = !String.IsNullOrEmpty(RootCategoryName) ? "&startingpath=" + RootCategoryName : "";

                // Set buttons
                btnSave.OnClientClick = String.Format(
                    "modalDialog('{0}?selectorid={1}{2}&templateId={3}&siteid={4}', 'SaveNewTemplate', 700, 400); return false;",
                    ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/SaveNewPageTemplate.aspx"),
                    ClientID,
                    root,
                    templateId,
                    SiteContext.CurrentSiteID
                    );

                // Edit button
                string url = UIContextHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", templateId);

                btnEditTemplateProperties.OnClientClick = String.Format("modalDialog('{0}', 'Template edit', '95%', '95%'); return false;", url);

                btnClone.OnClientClick = String.Format(
                    "if (confirm({0})) {1};return false;",
                    ScriptHelper.GetString(GetString("pageselector.cloneasadhoc")),
                    Page.ClientScript.GetPostBackEventReference(btnFullPostback, null)
                    );
            }
        }
        else
        {
            pnlButtons.Visible = false;
        }

        WindowHelper.Add("ShowOnlySiteTemplates", ShowOnlySiteTemplates);
        SetButtonsOnClick();

        btnSelect.Text = GetString("general.select");
        btnClear.Text  = GetString("general.clear");

        if (RequestHelper.IsPostBack() && (hdnSelected.Value == ""))
        {
            hdnSelected.Value = Request.Form[hdnSelected.UniqueID];
        }
    }
    /// <summary>
    /// Creates URL for editing.
    /// </summary>
    /// <param name="resourceName">Resource name</param>
    /// <param name="elementName">Element name</param>
    /// <param name="transformation">Transformation object info</param>
    private String GetEditUrl(string resourceName, string elementName, TransformationInfo transformation)
    {
        var uiChild = UIElementInfoProvider.GetUIElementInfo(resourceName, elementName);

        if (uiChild != null)
        {
            string url   = String.Empty;
            string query = RequestContext.CurrentQueryString;

            if (!DialogMode)
            {
                url = UIContextHelper.GetElementUrl(uiChild, UIContext);
                url = URLHelper.AppendQuery(url, query);
            }
            else
            {
                url = UIContextHelper.GetElementDialogUrl(uiChild, 0, query);
            }


            return(URLHelper.AppendQuery(url, "objectid=" + transformation.TransformationID));
        }

        return(String.Empty);
    }
Exemple #3
0
    /// <summary>
    /// Sets visibility of buttons that are connected to merged contact - split button and link to his parent.
    /// </summary>
    private void SetButtonsVisibility()
    {
        // Find out if current contact is merged into another site or global contact
        bool mergedIntoSite   = ValidationHelper.GetInteger(EditForm.Data["ContactMergedWithContactID"], 0) != 0;
        bool mergedIntoGlobal = ValidationHelper.GetInteger(EditForm.Data["ContactGlobalContactID"], 0) != 0 &&
                                ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false);
        bool globalContactsVisible = SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSCMGlobalContacts") || CurrentUser.IsGlobalAdministrator;

        if (mergedIntoSite || (mergedIntoGlobal && globalContactsVisible))
        {
            if (mergedIntoSite)
            {
                parentContact = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(EditForm.Data["ContactMergedWithContactID"], 0));
                headingMergedInto.ResourceString = "om.contact.mergedintosite";
            }
            else
            {
                parentContact = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(EditForm.Data["ContactGlobalContactID"], 0));
                headingMergedInto.ResourceString = "om.contact.mergedintoglobal";
            }

            lblMergedIntoContactName.Text = HTMLHelper.HTMLEncode(ContactInfoProvider.GetContactFullName(parentContact));

            string contactDetailDialogURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", parentContact.ContactID);
            string openDialogScript       = ScriptHelper.GetModalDialogScript(contactDetailDialogURL, "ContactDetail");

            btnMergedContact.IconCssClass  = "icon-edit";
            btnMergedContact.OnClientClick = openDialogScript;
            btnMergedContact.ToolTip       = GetString("om.contact.viewdetail");
        }
        else
        {
            panelMergedContactDetails.Visible = btnSplit.Visible = false;
        }
    }
    /// <summary>
    /// UniGrid external databound.
    /// </summary>
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSGridActionButton btn = null;

        switch (sourceName.ToLowerCSafe())
        {
        case "edit":
            btn = ((CMSGridActionButton)sender);
            // Ensure accountID parameter value;
            var objectID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            // Account detail URL
            string accountURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditAccount", objectID, "isSiteManager=" + ContactHelper.IsSiteManager);
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(accountURL, "AccountDetail");
            break;

        // Display delete button
        case "remove":
            btn = (CMSGridActionButton)sender;

            // Display delete button only for users with appropriate permission
            btn.Enabled = siteID > 0 ? modifySiteCG : modifyGlobalCG;
            break;
        }
        return(null);
    }
    /// <summary>
    /// Returns order item edit action HTML.
    /// </summary>
    protected string GetOrderItemEditAction(object value)
    {
        var  editOrderItemElemHtml = "";
        Guid itemGuid = ValidationHelper.GetGuid(value, Guid.Empty);

        if (itemGuid != Guid.Empty)
        {
            var item = ShoppingCart.GetShoppingCartItem(itemGuid);

            // Hide edit link for attribute product option
            if (item.IsAttributeOption)
            {
                return(null);
            }

            var query       = "itemguid=" + itemGuid + GetCMSDeskShoppingCartSessionNameQuery();
            var editItemUrl = UIContextHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.OrderItemProperties", 0, query);

            var priceDetailButton = new CMSGridActionButton
            {
                IconCssClass  = "icon-edit",
                IconStyle     = GridIconStyle.Allow,
                ToolTip       = GetString("shoppingcart.editorderitem"),
                OnClientClick = ScriptHelper.GetModalDialogScript(editItemUrl, "OrderItemEdit", 720, 420)
            };

            editOrderItemElemHtml = priceDetailButton.GetRenderedHTML();
        }

        return(editOrderItemElemHtml);
    }
Exemple #6
0
    /// <summary>
    /// Gets a clickable click links counter based on the values from datasource.
    /// </summary>
    /// <param name="clicks">Number of unique clicks</param>
    /// <param name="issueId">Issue ID</param>
    private string GetUniqueClicks(int clicks, int issueId)
    {
        if (clicks > 0)
        {
            var url = UIContextHelper.GetElementDialogUrl(ModuleName.NEWSLETTER, "Newsletter.Issue.Reports.Clicks", issueId);
            return(string.Format(@"<a href=""#"" onclick=""modalDialog('{0}', 'NewsletterTrackedLinks', '1000px', '700px'); return false;"">{1}</a>", url, clicks));
        }

        return("0");
    }
Exemple #7
0
    /// <summary>
    /// Registers scripts for displaying modal dialog containing Contact details and postback logic.
    /// </summary>
    private void RegisterScripts()
    {
        // Ensure Dialog script is loaded
        ScriptHelper.RegisterDialogScript(Control.Page);

        // File with JavaScript logic related to this class
        ScriptHelper.RegisterScriptFile(Control.Page, "~/CMSModules/Personas/Scripts/PersonaContactsList.js");

        // prepare script for setting contact details dialog url which is later rendered into the page, so it can be used by JS. Url is not hardcoded into JS, so proper hash string can be generated.
        string dialogUrl = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact");
        string script    = string.Format("CMS.Personas.PersonaContactsList.setContactDetailDialogBaseUrl({0});", ScriptHelper.GetString(dialogUrl));

        ScriptHelper.RegisterStartupScript(Control, typeof(string), "CMS.setContactDetailDialogBaseUrl", script, true);
    }
    /// <summary>
    /// Puts JavaScript functions to page.
    /// </summary>
    private void RegisterScripts()
    {
        ScriptHelper.RegisterDialogScript(Page);

        string scriptBlock = string.Format(@"
            function ViewDetails(id) {{ modalDialog('{0}&objectid=' + id, 'ScoreDetails', '1050px', '700px'); }}
            function Refresh()
            {{
                __doPostBack('" + pnlUpdate.ClientID + @"', '');
            }}",
                                           UIContextHelper.GetElementDialogUrl("CMS.Scoring", "ScoringProperties"));

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Actions", scriptBlock, true);
    }
Exemple #9
0
    protected object listElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSGridActionButton btn;

        switch (sourceName.ToLowerCSafe())
        {
        // Delete action
        case "delete":
            int siteId = SiteID;

            if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD)
            {
                DataRowView drv           = (parameter as GridViewRow).DataItem as DataRowView;
                int         contactSiteId = ValidationHelper.GetInteger(drv["StateSiteID"], 0);
                if (contactSiteId > 0)
                {
                    siteId = contactSiteId;
                }
            }

            btn = (CMSGridActionButton)sender;
            btn.OnClientClick = "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), HTMLHelper.HTMLEncode(TypeHelper.GetNiceObjectTypeName(ContactInfo.OBJECT_TYPE).ToLowerCSafe()))) + ")) { return false; }" + btn.OnClientClick;
            if (!WorkflowStepInfoProvider.CanUserRemoveAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(siteId)))
            {
                if (btn != null)
                {
                    btn.Enabled = false;
                }
            }
            break;

        case "view":
            btn = (CMSGridActionButton)sender;
            // Ensure accountID parameter value;
            var objectID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            // Contact detail URL
            string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", objectID, "isSiteManager=" + ContactHelper.IsSiteManager);
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
            break;

        // Process status column
        case "statestatus":
            return(AutomationHelper.GetProcessStatus((ProcessStatusEnum)ValidationHelper.GetInteger(parameter, 0)));
        }

        return(null);
    }
Exemple #10
0
    /// <summary>
    /// Modify contact button.
    /// </summary>
    private object ModifyContactButton(object sender, object parameter)
    {
        var button    = ((CMSGridActionButton)sender);
        int contactID = ValidationHelper.GetInteger(((DataRowView)((GridViewRow)parameter).DataItem).Row["SessionContactID"], 0);

        if ((contactID > 0) && OnlineMarketingEnabled)
        {
            string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", contactID);
            button.OnClientClick = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
        }
        else
        {
            button.Visible = false;
        }
        return("");
    }
Exemple #11
0
    /// <summary>
    /// Gets a clickable opened emails counter based on the values from datasource.
    /// </summary>
    /// <param name="rowView">A <see cref="DataRowView" /> that represents one row from UniGrid's source</param>
    private string GetOpenedEmails(DataRowView rowView)
    {
        // Get issue ID
        int issueId = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(rowView, "IssueID"), 0);

        // Get opened emails count from issue record
        int openedEmails = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(rowView, "IssueOpenedEmails"), 0);

        if (openedEmails > 0)
        {
            var url = UIContextHelper.GetElementDialogUrl(ModuleName.NEWSLETTER, "Newsletter.Issue.Reports.Opens", issueId);
            return(string.Format(@"<a href=""#"" onclick=""modalDialog('{0}', 'NewsletterOpenedEmails', '1000px', '700px'); return false;"">{1}</a>", url, openedEmails));
        }

        return("0");
    }
    /// <summary>
    /// On external databound.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="sourceName">Source name</param>
    /// <param name="parameter">Parameter</param>
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSGridActionButton btn;
        ContactInfo         ci;

        switch (sourceName.ToLowerCSafe())
        {
        case "edit":
            btn = (CMSGridActionButton)sender;
            // Ensure accountID parameter value;
            var objectID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            // Contact detail URL
            string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", objectID);
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
            break;

        case "view":
            btn = (CMSGridActionButton)sender;
            btn.OnClientClick = "ViewScoreDetail(" + btn.CommandArgument + "); return false;";
            break;

        case "#contactfullname":
            ci = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(parameter, 0));
            if (ci != null)
            {
                string fullName = TextHelper.MergeIfNotEmpty(" ", ci.ContactFirstName, ci.ContactMiddleName, ci.ContactLastName);
                return(HTMLHelper.HTMLEncode(fullName));
            }
            return(String.Empty);

        case "#statusdisplayname":
            ci = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(parameter, 0));
            if (ci != null)
            {
                ContactStatusInfo statusInfo = ContactStatusInfoProvider.GetContactStatusInfo(ci.ContactStatusID);
                if (statusInfo != null)
                {
                    return(HTMLHelper.HTMLEncode(statusInfo.ContactStatusDisplayName));
                }
            }
            return(String.Empty);
        }

        return(null);
    }
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName)
        {
        case "edit":
            var btn = (CMSGridActionButton)sender;
            // Ensure accountID parameter value;
            var objectID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            // Contact detail URL
            string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", objectID, "isSiteManager=" + ContactHelper.IsSiteManager);
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
            break;
        }

        return(null);
    }
Exemple #14
0
    /// <summary>
    /// Unigrid external databoud event handler.
    /// </summary>
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSGridActionButton btn;

        switch (sourceName.ToLowerCSafe())
        {
        case "edit":
            btn = ((CMSGridActionButton)sender);
            // Ensure accountID parameter value;
            var objectID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            // Account detail URL
            string accountURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditAccount", objectID, "isSiteManager=" + ContactHelper.IsSiteManager);
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(accountURL, "AccountDetail");
            break;

        case "selectrole":
            btn = (CMSGridActionButton)sender;
            if ((mContactInfo.ContactMergedWithContactID == 0) && mModifyAccountContact)
            {
                btn.OnClientClick = string.Format("dialogParams_{0} = '{1}';{2};return false;",
                                                  ClientID,
                                                  btn.CommandArgument,
                                                  Page.ClientScript.GetCallbackEventReference(this, "dialogParams_" + ClientID, "SelectRole", null));
            }
            else
            {
                btn.Enabled = false;
            }
            break;

        case "remove":
            if ((mContactInfo.ContactMergedWithContactID != 0) || !mModifyAccountContact)
            {
                btn         = (CMSGridActionButton)sender;
                btn.Enabled = false;
            }
            break;
        }
        return(null);
    }
Exemple #15
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        CurrentMaster.PanelContent.AddCssClass("dialog-content");

        // Filter templates for current layout
        gridTemplates.WhereCondition       = "ObjectID IN (SELECT PageTemplateID FROM CMS_PageTemplate WHERE PageTemplateLayoutID = " + QueryHelper.GetInteger("layoutid", 0) + ") OR ObjectID IN (SELECT PageTemplateID FROM CMS_TemplateDeviceLayout WHERE LayoutID = " + QueryHelper.GetInteger("layoutid", 0) + ")";
        gridTemplates.ZeroRowsText         = GetString("layout.notemplates");
        gridTemplates.FilteredZeroRowsText = GetString("layout.notemplates");

        // Register edit script
        String url    = UIContextHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate");
        string script = @"
function EditPageTemplate(id){
     modalDialog('" + url + @"&objectid=' + id, 'TemplateSelection', 1024, 768, false);
}";

        ScriptHelper.RegisterDialogScript(this.Page);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "EditPageTemplate", ScriptHelper.GetScript(script));
    }
    /// <summary>
    /// Uni-grid external data bound event handler.
    /// </summary>
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSGridActionButton btn = sender as CMSGridActionButton;

        if (btn != null)
        {
            switch (sourceName.ToLowerCSafe())
            {
            case "edit":
                string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", btn.CommandArgument.ToInteger(0), "isSiteManager=" + ContactHelper.IsSiteManager);
                // Add modal dialog script to onClick action
                btn.OnClientClick = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
                break;

            case "selectrole":
                if ((ai.AccountMergedWithAccountID != 0) || !modifyAccountContact)
                {
                    btn.Enabled = false;
                }
                else
                {
                    btn.OnClientClick = string.Format("dialogParams_{0} = '{1}';{2};return false;",
                                                      ClientID,
                                                      btn.CommandArgument,
                                                      Page.ClientScript.GetCallbackEventReference(this, "dialogParams_" + ClientID, "SelectRole", null));
                }
                break;

            case "remove":
                if ((ai.AccountMergedWithAccountID != 0) || !modifyAccountContact)
                {
                    btn.Enabled = false;
                }
                break;
            }
        }

        return(null);
    }
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "edit":
            CMSGridActionButton btn = ((CMSGridActionButton)sender);
            string contactURL       = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", btn.CommandArgument.ToInteger(0));
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
            break;

        case "website":
            string url = ValidationHelper.GetString(parameter, null);
            if (url != null)
            {
                return("<a target=\"_blank\" href=\"" + URLHelper.URLEncode(url) + "\" \">" + HTMLHelper.HTMLEncode(url) + "</a>");
            }

            return(GetString("general.na"));
        }
        return(parameter);
    }
    /// <summary>
    /// Returns price detail link.
    /// </summary>
    protected string GetPriceDetailLink(object value)
    {
        var priceDetailElemHtml = "";

        if ((ShoppingCartControl.EnableProductPriceDetail) && (ShoppingCart.ContentTable != null))
        {
            Guid cartItemGuid = ValidationHelper.GetGuid(value, Guid.Empty);
            if (cartItemGuid != Guid.Empty)
            {
                var query = "itemguid=" + cartItemGuid + GetCMSDeskShoppingCartSessionNameQuery();

                if (IsLiveSite)
                {
                    string liveSiteUrl = URLHelper.ResolveUrl("~/CMSModules/Ecommerce/CMSPages/ShoppingCartSKUPriceDetail.aspx?" + query);

                    priceDetailElemHtml = string.Format("<img src=\"{0}\" onclick=\"{1}\" alt=\"{2}\" class=\"ProductPriceDetailImage\" style=\"cursor:pointer;\" />",
                                                        GetImageUrl("Design/Controls/UniGrid/Actions/detail.png"),
                                                        ScriptHelper.GetModalDialogScript(liveSiteUrl, "ProductPriceDetail", 750, 570),
                                                        GetString("shoppingcart.productpricedetail"));
                }
                else
                {
                    string adminUrl = UIContextHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.productpricedetail", 0, query);

                    var priceDetailButton = new CMSGridActionButton
                    {
                        IconCssClass  = "icon-eye",
                        ToolTip       = GetString("shoppingcart.productpricedetail"),
                        OnClientClick = ScriptHelper.GetModalDialogScript(adminUrl, "ProductPriceDetail", 750, 570)
                    };

                    priceDetailElemHtml = priceDetailButton.GetRenderedHTML();
                }
            }
        }

        return(priceDetailElemHtml);
    }
    /// <summary>
    /// Returns SKU edit action HTML.
    /// </summary>
    protected string GetSKUEditAction(object skuId, object skuSiteId, object skuParentSkuId, object isProductOption, object isBundleItem)
    {
        var editSKUElemHtml = "";

        if (!ValidationHelper.GetBoolean(isProductOption, false) && !ValidationHelper.GetBoolean(isBundleItem, false) && ShoppingCartControl.IsInternalOrder)
        {
            // Do not render product detail link, when not authorized
            if (!CanReadProducts)
            {
                return(editSKUElemHtml);
            }

            // Show variants tab for product variant, otherwise general tab
            int    parentSkuId    = ValidationHelper.GetInteger(skuParentSkuId, 0);
            string productIdParam = (parentSkuId == 0) ? skuId.ToString() : parentSkuId.ToString();
            string tabParam       = (parentSkuId == 0) ? "Products.General" : "Products.Variants";

            var query = URLHelper.AddParameterToUrl("", "productid", productIdParam);
            query = URLHelper.AddParameterToUrl(query, "tabName", tabParam);
            query = URLHelper.AddParameterToUrl(query, "siteid", skuSiteId.ToString());
            query = URLHelper.AddParameterToUrl(query, "dialog", "1");
            var url = UIContextHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "Products.Properties", additionalQuery: query);

            // Different tooltip for product than for product variant
            string tooltip = (parentSkuId == 0) ? GetString("shoppingcart.editproduct") : GetString("shoppingcart.editproductvariant");

            var priceDetailButton = new CMSGridActionButton
            {
                IconCssClass  = "icon-box",
                ToolTip       = tooltip,
                OnClientClick = ScriptHelper.GetModalDialogScript(url, "SKUEdit", "95%", "95%"),
            };

            editSKUElemHtml = priceDetailButton.GetRenderedHTML();
        }

        return(editSKUElemHtml);
    }
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "edit":
            var btn = ((CMSGridActionButton)sender);
            // Ensure accountID parameter value;
            var objectID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            // Account detail URL
            string accountURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditAccount", objectID, "isSiteManager=" + ContactHelper.IsSiteManager);
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(accountURL, "AccountDetail");
            break;

        case "primary":
            DataRowView drv       = (DataRowView)parameter;
            int         contactId = ValidationHelper.GetInteger(drv["AccountPrimaryContactID"], 0);
            string      fullName  = ValidationHelper.GetString(drv["PrimaryContactFullName"], null);

            string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", contactId);
            // Add modal dialog script to onClick action
            var script = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
            return("<a href=\"#\" onclick=\"" + script + "\">" + HTMLHelper.HTMLEncode(fullName) + "</a>");

        case "website":
            string url = ValidationHelper.GetString(parameter, null);
            if (url != null)
            {
                return("<a target=\"_blank\" href=\"" + HTMLHelper.HTMLEncode(url) + "\" \">" + HTMLHelper.HTMLEncode(url) + "</a>");
            }

            return(GetString("general.na"));
        }

        return(parameter);
    }
    /// <summary>
    /// Loads data of specific activity.
    /// </summary>
    protected void LoadData()
    {
        if (activityId <= 0)
        {
            return;
        }

        // Load and check if object exists
        ActivityInfo ai = ActivityInfoProvider.GetActivityInfo(activityId);

        EditedObject = ai;

        ActivityTypeInfo ati = ActivityTypeInfoProvider.GetActivityTypeInfo(ai.ActivityType);

        plcActivityValue.Visible = (ati == null) || ati.ActivityTypeIsCustom || (ati.ActivityTypeName == PredefinedActivityType.PAGE_VISIT) && !String.IsNullOrEmpty(ai.ActivityValue);

        string dispName = (ati != null ? ati.ActivityTypeDisplayName : GetString("general.na"));

        lblTypeVal.Text    = String.Format("{0}", HTMLHelper.HTMLEncode(dispName));
        lblContactVal.Text = HTMLHelper.HTMLEncode(ContactInfoProvider.GetContactFullName(ai.ActivityActiveContactID));

        // Init contact detail link
        string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", ai.ActivityActiveContactID, "isSiteManager=" + ContactHelper.IsSiteManager);

        btnContact.Attributes.Add("onClick", ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail"));
        btnContact.ToolTip = GetString("general.edit");

        lblDateVal.Text = (ai.ActivityCreated == DateTimeHelper.ZERO_TIME ? GetString("general.na") : HTMLHelper.HTMLEncode(ai.ActivityCreated.ToString()));

        // Get site display name
        string siteName = SiteInfoProvider.GetSiteName(ai.ActivitySiteID);

        if (String.IsNullOrEmpty(siteName))
        {
            siteName = GetString("general.na");
        }
        else
        {
            // Retrieve site info and its display name
            SiteInfo si = SiteInfoProvider.GetSiteInfo(siteName);
            if (si != null)
            {
                siteName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(si.DisplayName));
            }
            else
            {
                siteName = GetString("general.na");
            }
        }
        lblSiteVal.Text = siteName;

        string url = ai.ActivityURL;

        plcCampaign.Visible = !String.IsNullOrEmpty(ai.ActivityCampaign);
        lblCampaignVal.Text = HTMLHelper.HTMLEncode(ai.ActivityCampaign);
        lblValue.Text       = HTMLHelper.HTMLEncode(String.IsNullOrEmpty(ai.ActivityValue) ? GetString("general.na") : ai.ActivityValue);

        // Init textboxes only for the first time
        if (!RequestHelper.IsPostBack())
        {
            txtComment.Value = ai.ActivityComment;
            txtTitle.Text    = ai.ActivityTitle;
            txtURLRef.Text   = ai.ActivityURLReferrer;
            if (ai.ActivityType != PredefinedActivityType.NEWSLETTER_CLICKTHROUGH)
            {
                txtURL.Text = url;
            }
        }

        cDetails.ActivityID = activityId;

        // Init link button URL
        if (ai.ActivitySiteID > 0)
        {
            SiteInfo si = SiteInfoProvider.GetSiteInfo(ai.ActivitySiteID);
            if (si != null)
            {
                // Hide view button if URL is blank
                string activityUrl = ai.ActivityURL;
                if ((activityUrl != null) && !String.IsNullOrEmpty(activityUrl.Trim()))
                {
                    string appUrl = URLHelper.GetApplicationUrl(si.DomainName);
                    url                 = URLHelper.GetAbsoluteUrl(activityUrl, appUrl, appUrl, "");
                    url                 = URLHelper.AddParameterToUrl(url, URLHelper.SYSTEM_QUERY_PARAMETER, "1");
                    btnView.ToolTip     = GetString("general.view");
                    btnView.NavigateUrl = url;
                    btnView.Visible     = true;
                }
                else
                {
                    btnView.Visible = false;
                }
            }
        }
    }
Exemple #22
0
    /// <summary>
    /// UniGrid data bound.
    /// </summary>
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSAccessibleButton btn = null;

        DataRowView drv = parameter as DataRowView;

        switch (sourceName.ToLowerCSafe())
        {
        // Display delete button
        case "delete":
            btn = (CMSGridActionButton)sender;
            btn.OnClientClick = string.Format("dialogParams_{0} = '{1}';{2};return false;",
                                              ClientID,
                                              btn.CommandArgument,
                                              Page.ClientScript.GetCallbackEventReference(this, "dialogParams_" + ClientID, "Delete", null));

            // Display delete button only for users with appropriate permission
            if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD)
            {
                drv = ((GridViewRow)parameter).DataItem as DataRowView;
                if (ValidationHelper.GetInteger(drv["AccountSiteID"], 0) > 0)
                {
                    btn.Enabled = modifySite;
                }
                else
                {
                    btn.Enabled = modifyGlobal;
                }
            }
            else
            {
                btn.Enabled = modifyPermission;
            }
            if (!btn.Enabled)
            {
                btn.Enabled = false;
            }
            break;

        // Display information if account is merged
        case "accountmergedwithaccountid":
            int mergedIntoSite   = ValidationHelper.GetInteger(drv["AccountMergedWithAccountID"], 0);
            int mergedIntoGlobal = ValidationHelper.GetInteger(drv["AccountGlobalAccountID"], 0);
            int siteID           = ValidationHelper.GetInteger(drv["AccountSiteID"], 0);
            if (((siteID > 0) && (mergedIntoSite > 0)) || ((siteID == 0) && (mergedIntoGlobal > 0)))
            {
                return(GetString("general.yes"));
            }
            return(null);

        case "primarycontactname":
            string name = ValidationHelper.GetString(drv["PrimaryContactFullName"], "");
            if (!string.IsNullOrEmpty(name.Trim()))
            {
                string contactDetailsDialogURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", ValidationHelper.GetInteger(drv["AccountPrimaryContactID"], 0));

                var placeholder = new PlaceHolder();
                placeholder.Controls.Add(new Label
                {
                    Text     = HTMLHelper.HTMLEncode(name),
                    CssClass = "contactmanagement-accountlist-primarycontact"
                });

                placeholder.Controls.Add(new CMSGridActionButton
                {
                    IconCssClass  = "icon-edit",
                    OnClientClick = ScriptHelper.GetModalDialogScript(contactDetailsDialogURL, "ContactDetail"),
                    ToolTip       = GetString("om.contact.viewdetail")
                });

                return(placeholder);
            }
            return(null);
        }
        return(null);
    }
    protected void editOptionCategory_OnAfterSave(object sender, EventArgs e)
    {
        if (EditedCategory == null)
        {
            EditedObject = null;
            return;
        }

        // New option category
        if (!Editing)
        {
            // For new TEXT option category create text option
            if (SelectedCategoryType == OptionCategoryTypeEnum.Text)
            {
                CreateTextOption();
            }

            // Assign option category to product
            if (ParentProduct != null)
            {
                SKUOptionCategoryInfoProvider.AddOptionCategoryToSKU(EditedCategory.CategoryID, ParentProduct.SKUID);
            }

            // Redirect from new form dialog to option category edit.
            string query = QueryHelper.BuildQuery("saved", "1", "productid", ProductID.ToString(), "siteid", CategorySiteID.ToString());
            if (ParentProduct == null)
            {
                URLHelper.Redirect(UIContextHelper.GetElementUrl("CMS.Ecommerce", "EditOptionCategory", false, EditedCategory.CategoryID, query));
            }
            else
            {
                URLHelper.Redirect(UIContextHelper.GetElementDialogUrl("CMS.Ecommerce", "EditProductOptionCategory", EditedCategory.CategoryID, query));
            }
        }

        if (Editing)
        {
            // Refresh breadcrumbs
            var append = EditedCategory.IsGlobal ? " " + GetString("general.global") : "";
            ScriptHelper.RefreshTabHeader(Page, EditedCategory.CategoryDisplayName + append);

            // Category options
            DataSet options = SKUInfoProvider.GetSKUOptions(EditedCategory.CategoryID, false);

            // Option category type may be changed during editing and additional action is required
            switch (SelectedAdditionalAction)
            {
            case AdditionalActionEnum.DeleteOptionsAndCreateTextOption:
                DeleteOptions(options);
                CreateTextOption();

                break;

            case AdditionalActionEnum.DeleteTextOption:
                DeleteOptions(options);
                CategoryHasOptions = false;

                break;

            case AdditionalActionEnum.ConvertAttributeToProduct:
                ChangeAttributeToProduct(options);

                break;

            case AdditionalActionEnum.ConvertProductToAttribute:
                ChangeProductToAttribute(options);

                break;

            case AdditionalActionEnum.None:

                break;
            }

            editOptionCategory.SubmitButton.OnClientClick = "";
        }
    }
    object categoryGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        OptionCategoryInfo category;

        // Formatting columns
        switch (sourceName.ToLowerCSafe())
        {
        case "categorydisplayname":
            category = OptionCategoryInfoProvider.GetOptionCategoryInfo(ValidationHelper.GetInteger(parameter, 0));
            return(HTMLHelper.HTMLEncode(category.CategoryFullName));

        case "categorytype":
            return(ValidationHelper.GetString(parameter, "").ToEnum <OptionCategoryTypeEnum>().ToLocalizedString("com.optioncategorytype"));

        case "optionscounts":
            category = OptionCategoryInfoProvider.GetOptionCategoryInfo(ValidationHelper.GetInteger(parameter, 0));

            if (category.CategoryType != OptionCategoryTypeEnum.Text)
            {
                var tr = new ObjectTransformation("OptionsCounts", category.CategoryID)
                {
                    DataProvider         = countsDataProvider,
                    Transformation       = "{% if(AllowAllOptions) { GetResourceString(\"general.all\") } else { FormatString(GetResourceString(\"com.ProductOptions.availableXOfY\"), SelectedOptions, AllOptions) } %}",
                    NoDataTransformation = "{$com.productoptions.nooptions$}",
                    EncodeOutput         = false
                };

                return(tr);
            }

            return("");

        case "edititem":
            category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row);

            CMSGridActionButton btn = sender as CMSGridActionButton;

            // Disable edit button if category is global and global categories are NOT allowed
            if (btn != null)
            {
                if (!allowedGlobalCat && category.IsGlobal)
                {
                    btn.Enabled = false;
                }

                var    query       = QueryHelper.BuildQuery("siteId", category.CategorySiteID.ToString(), "productId", ProductID.ToString());
                string redirectUrl = UIContextHelper.GetElementDialogUrl("CMS.Ecommerce", "EditProductOptionCategory", category.CategoryID, query);
                btn.OnClientClick = "modalDialog('" + redirectUrl + "','categoryEdit', '1000', '800');";
            }
            break;

        case "selectoptions":
            category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row);

            CMSGridActionButton btnSelect = sender as CMSGridActionButton;

            if (btnSelect != null)
            {
                // Disable select button if category is type of Text
                if (category.CategoryType == OptionCategoryTypeEnum.Text)
                {
                    btnSelect.Enabled = false;
                }
                else
                {
                    var query = QueryHelper.BuildQuery("productId", ProductID.ToString());
                    // URL of allowed option selector pop-up
                    string urlSelect = UIContextHelper.GetElementDialogUrl("CMS.Ecommerce", "ProductOptions.SelectOptions", category.CategoryID, query);

                    // Open allowed options selection dialog
                    btnSelect.OnClientClick = ScriptHelper.GetModalDialogScript(urlSelect, "selectoptions", 1000, 650);
                }
            }
            break;
        }

        return(parameter);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        previewState = GetPreviewStateFromCookies(MASTERPAGE);

        // Keep current user
        user = MembershipContext.AuthenticatedUser;

        // Get document node
        tree = new TreeProvider(user);
        node = UIContext.EditedObject as TreeNode;

        // Register the dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Register save changes
        ScriptHelper.RegisterSaveChanges(Page);

        // Save changes support
        bool   confirmChanges = SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSConfirmChanges");
        string script         = string.Empty;

        if (confirmChanges)
        {
            script  = "CMSContentManager.confirmLeave=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode), true, false) + "; \n";
            script += "CMSContentManager.confirmLeaveShort=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeaveShort", user.PreferredUICultureCode), true, false) + "; \n";
        }
        else
        {
            script += "CMSContentManager.confirmChanges = false;";
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", script, true);

        try
        {
            if (node != null)
            {
                DocumentContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(node.NodeSiteName, node.NodeAliasPath, node.DocumentCulture, null, node.NodeID, false);

                // Title
                string title = DocumentContext.CurrentTitle;
                if (!string.IsNullOrEmpty(title))
                {
                    title = "<title>" + title + "</title>";
                }

                // Body class
                string bodyCss = DocumentContext.CurrentBodyClass;
                // Remove bootstrap default class
                bodyCss = bodyCss.Replace(" cms-bootstrap", String.Empty);

                if (bodyCss != null && bodyCss.Trim() != "")
                {
                    bodyCss = "class=\"" + bodyCss + "\"";
                }
                else
                {
                    bodyCss = "";
                }

                // Metadata
                string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />";

                string description = DocumentContext.CurrentDescription;
                if (description != "")
                {
                    meta += "<meta name=\"description\" content=\"" + description + "\" />";
                }

                string keywords = DocumentContext.CurrentKeyWords;
                if (keywords != "")
                {
                    meta += "<meta name=\"keywords\"  content=\"" + keywords + "\" />";
                }

                // Site style sheet
                string cssSiteSheet = "";

                int stylesheetId = DocumentContext.CurrentPageInfo.DocumentStylesheetID;

                CssStylesheetInfo cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : SiteContext.CurrentSite.SiteDefaultStylesheetID);

                if (cssInfo != null)
                {
                    cssSiteSheet = CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(cssInfo.StylesheetName));
                }

                // Theme CSS files
                string themeCssFiles = "";
                if (cssInfo != null)
                {
                    try
                    {
                        string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName));
                        if (Directory.Exists(directory))
                        {
                            foreach (string file in Directory.GetFiles(directory, "*.css"))
                            {
                                themeCssFiles += CSSHelper.GetCSSFileLink(CSSHelper.GetPhysicalCSSUrl(cssInfo.StylesheetName, Path.GetFileName(file)));
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                // Add values to page
                mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2);
                mBody = bodyCss;
            }
        }
        catch
        {
            ShowError(GetString("MasterPage.PageEditErr"));
        }

        LoadData();

        // Add save action
        SaveAction save = new SaveAction();

        save.CommandArgument = ComponentEvents.SAVE_DATA;
        save.CommandName     = ComponentEvents.SAVE_DATA;

        headerActions.ActionsList.Add(save);

        if (pti != null)
        {
            // Disable buttons for no-template
            bool actionsEnabled = (pti.PageTemplateId > 0);

            // Edit layout
            HeaderAction action = new HeaderAction
            {
                Text          = GetString("content.ui.pagelayout"),
                Tooltip       = GetString("pageplaceholder.editlayouttooltip"),
                OnClientClick = "EditLayout();return false;",
                Enabled       = actionsEnabled
            };
            headerActions.ActionsList.Add(action);

            string elemUrl = UIContextHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", pti.PageTemplateId);

            // Edit page properties action
            action = new HeaderAction
            {
                Text          = GetString("PageProperties.EditTemplateProperties"),
                Tooltip       = GetString("PageProperties.EditTemplateProperties"),
                OnClientClick = "modalDialog('" + elemUrl + "', 'TemplateSelection', '85%', '85%', false);return false;",
                Enabled       = actionsEnabled
            };

            CMSPagePlaceholder.RegisterEditLayoutScript(this, pti.PageTemplateId, node.NodeAliasPath, null);
            headerActions.ActionsList.Add(action);

            // Preview
            HeaderAction preview = new HeaderAction
            {
                Text          = GetString("general.preview"),
                OnClientClick = "performToolbarAction('split');return false;",
                Visible       = ((previewState == 0) && !UIContext.DisplaySplitMode),
                Tooltip       = GetString("preview.tooltip")
            };
            headerActions.ActionsList.Add(preview);

            headerActions.ActionPerformed += headerActions_ActionPerformed;
        }

        RegisterInitScripts(pnlBody.ClientID, pnlMenu.ClientID, false);
    }
Exemple #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Use UI culture for strings
        string culture = MembershipContext.AuthenticatedUser.PreferredUICultureCode;

        // Register dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Prepare script to display versions dialog
        StringBuilder script = new StringBuilder();

        script.Append(
            @"
function ShowVersionsDialog(objectType, objectId, objectName) {
  modalDialog('", ResolveUrl("~/CMSModules/Objects/Dialogs/ObjectVersionDialog.aspx"), @"' + '?objecttype=' + objectType + '&objectid=' + objectId + '&objectname=' + objectName,'VersionsDialog','800','600');
}"
            );

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

        // Check if template is ASPX one and initialize PageTemplateInfo variable
        bool isAspx = false;

        PageTemplateInfo pti = null;

        if (mPagePlaceholder != null)
        {
            pi = mPagePlaceholder.PageInfo;
        }

        if (pi != null)
        {
            pti = pi.UsedPageTemplateInfo;
            if (pti != null)
            {
                isAspx = pti.IsAspx;
            }
        }

        bool documentExists = ((pi != null) && (pi.DocumentID > 0));

        if ((mPagePlaceholder != null) && (mPagePlaceholder.ViewMode == ViewModeEnum.DesignDisabled))
        {
            // Hide edit layout and edit template if design mode is disabled
            iLayout.Visible   = false;
            iTemplate.Visible = false;
        }
        else
        {
            if ((mPagePlaceholder != null) && (mPagePlaceholder.LayoutTemplate == null))
            {
                // Edit layout
                iLayout.Text = ResHelper.GetString("PlaceholderMenu.IconLayout", culture);
                iLayout.Attributes.Add("onclick", "EditLayout();");

                if ((pti != null) && (pti.LayoutID > 0))
                {
                    LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID);

                    // Display layout versions sub-menu
                    if ((li != null) && ObjectVersionManager.DisplayVersionsTab(li))
                    {
                        menuLayout.Visible           = true;
                        iLayout.Text                 = ResHelper.GetString("PlaceholderMenu.IconLayoutMore", culture);
                        lblSharedLayoutVersions.Text = ResHelper.GetString("PlaceholderMenu.SharedLayoutVersions", culture);
                        pnlSharedLayout.Attributes.Add("onclick", GetVersionsDialog(li.TypeInfo.ObjectType, li.LayoutId));
                    }
                }
            }
            else
            {
                iLayout.Visible = false;
            }

            if (documentExists)
            {
                // Template properties
                iTemplate.Text = ResHelper.GetString("PlaceholderMenu.IconTemplate", culture);

                int    templateID = (pti != null) ? pti.PageTemplateId : 0;
                String aliasPath  = (pi != null) ? pi.NodeAliasPath : "";

                String url = UIContextHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", templateID, String.Format("aliaspath={0}", aliasPath));
                iTemplate.Attributes.Add("onclick", String.Format("modalDialog('{0}', 'edittemplate', '95%', '95%');", url));

                if (pti != null)
                {
                    // Display template versions sub-menu
                    if (ObjectVersionManager.DisplayVersionsTab(pti))
                    {
                        menuTemplate.Visible     = true;
                        iTemplate.Text           = ResHelper.GetString("PlaceholderMenu.IconTemplateMore", culture);
                        lblTemplateVersions.Text = ResHelper.GetString("PlaceholderMenu.TemplateVersions", culture);
                        pnlTemplateVersions.Attributes.Add("onclick", GetVersionsDialog(pti.TypeInfo.ObjectType, pti.PageTemplateId));
                    }
                }
            }
        }

        if (pti != null)
        {
            if ((!isAspx) && documentExists && pti.IsReusable)
            {
                if (!SynchronizationHelper.UseCheckinCheckout || CurrentPageInfo.UsedPageTemplateInfo.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser))
                {
                    iClone.Text          = ResHelper.GetString("PlaceholderMenu.IconClone", culture);
                    iClone.OnClientClick = "CloneTemplate(GetContextMenuParameter('pagePlaceholderMenu'));";
                }
            }
            else
            {
                iSaveAsNew.Text = ResHelper.GetString("PageProperties.Save", culture);

                int templateId = pi.UsedPageTemplateInfo.PageTemplateId;
                iSaveAsNew.OnClientClick = String.Format(
                    "modalDialog('{0}?refresh=1&templateId={1}&siteid={2}', 'SaveNewTemplate', 720, 430); return false;",
                    ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/SaveNewPageTemplate.aspx"),
                    templateId,
                    SiteContext.CurrentSiteID);
            }
        }

        iRefresh.Text = ResHelper.GetString("PlaceholderMenu.IconRefresh", culture);
        iRefresh.Attributes.Add("onclick", "RefreshPage();");
    }
Exemple #27
0
    /// <summary>
    /// Reloads the controls on the page to the appropriate state
    /// </summary>
    protected void ReloadControls()
    {
        TreeNode node = DocumentManager.Node;

        if (node.NodeAliasPath == "/")
        {
            // For root, inherit option means no page template
            radInherit.ResourceString = "Template.NoTemplate";
        }

        // Get the template ID
        int    templateId = SelectedTemplateID;
        string suffix     = null;
        bool   inherit    = radInherit.Checked;

        plcUIClone.Visible = false;
        plcUIEdit.Visible  = false;
        plcUISave.Visible  = false;

        if (inherit)
        {
            // Inherited
            selectorEnabled = false;

            // Inherit
            templateId = GetInheritedPageTemplateId(node);

            if (templateId > 0)
            {
                suffix = " " + GetString("Template.Inherited");
            }
        }
        else
        {
            // Standard selection
            selectorEnabled = true;
        }

        // Set modal dialogs
        btnSave.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/SaveNewPageTemplate.aspx") + "?startingpath=/&templateId=" + templateId + "&siteid=" + SiteContext.CurrentSiteID + "', 'SaveNewTemplate', 720, 430); return false;";

        String url = UIContextHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", templateId, String.Format("aliaspath={0}", node.NodeAliasPath));

        btnEditTemplateProperties.OnClientClick = "modalDialog('" + url + "', 'Template edit', '95%', '95%');return false;";

        // Load the page template name
        pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
        if (pti != null)
        {
            txtTemplate.Text = ResHelper.LocalizeString(pti.DisplayName);

            plcUISave.Visible  = true;
            plcUIEdit.Visible  = (!pti.IsReusable || currentUser.IsAuthorizedPerUIElement("CMS.Content", "Template.ModifySharedTemplates"));
            plcUIClone.Visible = pti.IsReusable || inherit;
        }
        else
        {
            txtTemplate.Text = GetString("Template.SelectorNoTemplate");
        }

        txtTemplate.Text += suffix;
    }
    protected override void OnLoad(EventArgs e)
    {
        // Show message when reordering and not all reordered product were added to cart
        if (!URLHelper.IsPostback() && QueryHelper.GetBoolean("notallreordered", false))
        {
            lblError.Text = GetString("com.notallreordered");
        }

        if ((ShoppingCart != null) && IsLiveSite)
        {
            // Get order information
            OrderInfo oi = OrderInfoProvider.GetOrderInfo(ShoppingCart.OrderId);
            // If order is paid
            if ((oi != null) && (oi.OrderIsPaid))
            {
                // Clean shopping cart if paid order cart is still in customers current cart on LS
                ShoppingCartControl.CleanUpShoppingCart();
            }
        }

        if ((ShoppingCart != null) && (ShoppingCart.CountryID == 0) && (SiteContext.CurrentSite != null))
        {
            string      countryName = ECommerceSettings.DefaultCountryName(SiteContext.CurrentSiteName);
            CountryInfo ci          = CountryInfoProvider.GetCountryInfo(countryName);
            ShoppingCart.CountryID = (ci != null) ? ci.CountryID : 0;

            // Set currency selectors site ID
            selectCurrency.SiteID = ShoppingCart.ShoppingCartSiteID;
        }

        lnkNewItem.Text        = GetString("ecommerce.shoppingcartcontent.additem");
        btnUpdate.Text         = GetString("ecommerce.shoppingcartcontent.btnupdate");
        btnEmpty.Text          = GetString("ecommerce.shoppingcartcontent.btnempty");
        btnEmpty.OnClientClick = string.Format("return confirm({0});", ScriptHelper.GetString(GetString("ecommerce.shoppingcartcontent.emptyconfirm")));

        // Add new product dialog
        string addProductUrl = UIContextHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.addorderitems", 0, GetCMSDeskShoppingCartSessionNameQuery());

        lnkNewItem.OnClientClick = ScriptHelper.GetModalDialogScript(addProductUrl, "addproduct", 1000, 620);

        gridData.Columns[4].HeaderText  = GetString("general.remove");
        gridData.Columns[5].HeaderText  = GetString("ecommerce.shoppingcartcontent.actions");
        gridData.Columns[6].HeaderText  = GetString("ecommerce.shoppingcartcontent.skuname");
        gridData.Columns[7].HeaderText  = GetString("ecommerce.shoppingcartcontent.skuunits");
        gridData.Columns[8].HeaderText  = GetString("ecommerce.shoppingcartcontent.unitprice");
        gridData.Columns[9].HeaderText  = GetString("ecommerce.shoppingcartcontent.unitdiscount");
        gridData.Columns[10].HeaderText = GetString("ecommerce.shoppingcartcontent.tax");
        gridData.Columns[11].HeaderText = GetString("ecommerce.shoppingcartcontent.subtotal");
        gridData.RowDataBound          += gridData_RowDataBound;

        // Hide "add product" action for live site order
        if (!ShoppingCartControl.IsInternalOrder)
        {
            pnlNewItem.Visible = false;

            ShoppingCartControl.ButtonBack.Text        = GetString("ecommerce.cartcontent.buttonbacktext");
            ShoppingCartControl.ButtonBack.ButtonStyle = ButtonStyle.Default;
            ShoppingCartControl.ButtonNext.Text        = GetString("ecommerce.cartcontent.buttonnexttext");

            if (!ShoppingCartControl.IsCurrentStepPostBack)
            {
                // Get shopping cart item parameters from URL
                ShoppingCartItemParameters itemParams = ShoppingCartItemParameters.GetShoppingCartItemParameters();

                // Set item in the shopping cart
                AddProducts(itemParams);
            }
        }

        // Set sending order notification when editing existing order according to the site settings
        if (ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems)
        {
            if (!ShoppingCartControl.IsCurrentStepPostBack)
            {
                if (!string.IsNullOrEmpty(ShoppingCart.SiteName))
                {
                    chkSendEmail.Checked = ECommerceSettings.SendOrderNotification(ShoppingCart.SiteName);
                }
            }
            // Show send email checkbox
            chkSendEmail.Visible = true;
            chkSendEmail.Text    = GetString("shoppingcartcontent.sendemail");

            // Setup buttons
            ShoppingCartControl.ButtonBack.Visible = false;
            ShoppingCart.CheckAvailableItems       = false;
            ShoppingCartControl.ButtonNext.Text    = GetString("general.next");

            if ((!ExistAnotherStepsExceptPayment) && (ShoppingCartControl.PaymentGatewayProvider == null))
            {
                ShoppingCartControl.ButtonNext.Text = GetString("general.ok");
            }
        }

        // Fill dropdownlist
        if (!ShoppingCartControl.IsCurrentStepPostBack)
        {
            if (!ShoppingCart.IsEmpty || ShoppingCartControl.IsInternalOrder)
            {
                if (ShoppingCart.ShoppingCartCurrencyID == 0)
                {
                    // Select customer preferred currency
                    if (ShoppingCart.Customer != null)
                    {
                        CustomerInfo customer = ShoppingCart.Customer;
                        ShoppingCart.ShoppingCartCurrencyID = (customer.CustomerUser != null) ? customer.CustomerUser.GetUserPreferredCurrencyID(SiteContext.CurrentSiteName) : 0;
                    }
                }

                if (ShoppingCart.ShoppingCartCurrencyID == 0)
                {
                    if (SiteContext.CurrentSite != null)
                    {
                        var mainCurrency = CurrencyInfoProvider.GetMainCurrency(SiteContext.CurrentSiteID);
                        if (mainCurrency != null)
                        {
                            ShoppingCart.ShoppingCartCurrencyID = mainCurrency.CurrencyID;
                        }
                    }
                }

                selectCurrency.SelectedID = ShoppingCart.ShoppingCartCurrencyID;

                // Fill textbox with discount coupon code
                if (!String.IsNullOrEmpty(ShoppingCart.ShoppingCartCouponCode))
                {
                    txtCoupon.Text = ShoppingCart.ShoppingCartCouponCode;
                }
            }

            ReloadData();
        }

        // Check if customer is enabled
        if ((ShoppingCart.Customer != null) && (!ShoppingCart.Customer.CustomerEnabled))
        {
            HideCartContent(GetString("ecommerce.cartcontent.customerdisabled"));
        }

        // Ensure order currency in selector
        if ((ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems) && (ShoppingCart.Order != null))
        {
            selectCurrency.AdditionalItems += ShoppingCart.Order.OrderCurrencyID + ";";
        }

        // Turn on available items checking after content is loaded
        ShoppingCart.CheckAvailableItems = true;

        base.OnLoad(e);
    }