コード例 #1
0
    private void OnProductSaved(object sender, EventArgs args)
    {
        if (!IsProductsUI)
        {
            // If not EditLive view mode, switch to form mode to keep editing the form
            if (PortalContext.ViewMode != ViewModeEnum.EditLive)
            {
                PortalContext.ViewMode = ViewModeEnum.EditForm;
            }
        }

        bool refreshEcommerceTree = (ECommerceSettings.ProductsTree(SiteContext.CurrentSiteName) == ProductsTreeModeEnum.Sections) && (ECommerceSettings.DisplayProductsInSectionsTree(SiteContext.CurrentSiteName));

        if ((productEditElem.Product is TreeNode) && (!IsProductsUI || refreshEcommerceTree))
        {
            var node = (TreeNode)productEditElem.Product;
            if (productEditElem.ProductSavedCreateAnother)
            {
                ScriptHelper.RefreshTree(this, node.NodeParentID, node.NodeParentID);
                ScriptHelper.RegisterStartupScript(Page, typeof(string), "Refresh", ScriptHelper.GetScript("CreateAnother();"));
            }
            else
            {
                ScriptHelper.RefreshTree(this, node.NodeParentID, node.NodeID);
            }
        }
        else if (productEditElem.ProductSavedCreateAnother)
        {
            RedirectToNewProduct();
        }
        else
        {
            RedirectToSavedProduct(productEditElem.Product);
        }
    }
コード例 #2
0
    private void OnButtonCreating(object sender, UniMenuArgs eventArgs)
    {
        var    element     = eventArgs.UIElement;
        string elementName = element.ElementName;

        if (elementName.CompareToCSafe("products", true) == 0)
        {
            // Change URL if products management UI has product tree disabled by setting
            if (ECommerceSettings.ProductsTree(SiteContext.CurrentSiteName) == ProductsTreeModeEnum.None)
            {
                element.ElementTargetURL = "~/CMSModules/Ecommerce/Pages/Tools/Products/Product_List.aspx";
            }
        }
    }
コード例 #3
0
    /// <summary>
    /// Initializes the product edit control.
    /// </summary>
    private void InitProductEdit()
    {
        CurrentMaster.PanelContent.CssClass = null;

        plcProductEdit.Visible        = true;
        productEditElem.ProductSaved += (sender, args) =>
        {
            if (IsContent)
            {
                // If not EditLive view mode, switch to form mode to keep editing the form
                if (CMSContext.ViewMode != ViewModeEnum.EditLive)
                {
                    CMSContext.ViewMode = ViewModeEnum.EditForm;
                }
            }
            else
            {
                UIContext.ProductTab = ProductTabEnum.General;
            }

            bool refreshEcommerceTree = (ECommerceSettings.ProductsTree(CMSContext.CurrentSiteName) == ProductsTreeModeEnum.Sections) &&
                                        (ECommerceSettings.DisplayProductsInSectionsTree(CMSContext.CurrentSiteName));

            if (productEditElem.Product is TreeNode && (IsContent || refreshEcommerceTree))
            {
                var node = (TreeNode)productEditElem.Product;
                if (productEditElem.ProductSavedCreateAnother)
                {
                    ScriptHelper.RefreshTree(this, node.NodeParentID, node.NodeParentID);
                    ScriptHelper.RegisterStartupScript(Page, typeof(string), "Refresh", ScriptHelper.GetScript("CreateAnother();"));
                }
                else
                {
                    ScriptHelper.RefreshTree(this, node.NodeParentID, node.NodeID);
                }
            }
            else
            {
                if (productEditElem.ProductSavedCreateAnother)
                {
                    RedirectToNewProduct();
                }
                else
                {
                    RedirectToSavedProduct(productEditElem.Product);
                }
            }
        };
    }
コード例 #4
0
    private void uiToolbarElem_OnButtonCreating(object sender, UniMenuArgs eventArgs)
    {
        string elementName = eventArgs.UIElement.ElementName;

        if (elementName.CompareToCSafe("products", true) == 0)
        {
            if (ECommerceSettings.ProductsTree(CurrentSiteName) == ProductsTreeModeEnum.None)
            {
                eventArgs.UIElement.ElementTargetURL = "javascript: SelectItem('Products',  'Products/Product_List.aspx');";
            }
        }

        // Resolve hash in dashboard url
        if (elementName.CompareToCSafe("ecommercedashboard", true) == 0)
        {
            string url = eventArgs.UIElement.ElementTargetURL;
            url = URLHelper.EnsureHashToQueryParameters(url);
            eventArgs.UIElement.ElementTargetURL = url;
        }
    }
コード例 #5
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        string contentUrl = "Product_List.aspx" + RequestContext.CurrentQueryString;

        // Display product list if display tree of product sections is not allowed
        if (ECommerceSettings.ProductsTree(SiteContext.CurrentSiteID) == ProductsTreeModeEnum.None)
        {
            URLHelper.Redirect(URLHelper.ResolveUrl(contentUrl));
        }

        contenttree.Values.AddRange(new[] { new UILayoutValue("NodeID", ResultNodeID), new UILayoutValue("ExpandNodeID", ExpandNodeID), new UILayoutValue("Culture", SelectedCulture) });

        if (NodeID <= 0)
        {
            // Root
            string baseDoc = "/";
            if (!string.IsNullOrEmpty(ProductsStartingPath))
            {
                // Change to products root node
                baseDoc = ProductsStartingPath.TrimEnd('/');
            }

            // Get the root node
            TreeNode rootNode = Tree.SelectSingleNode(SiteContext.CurrentSiteName, baseDoc, TreeProvider.ALL_CULTURES, false, null, false);
            if (rootNode != null)
            {
                string nodeString = rootNode.NodeID.ToString();
                contentUrl = URLHelper.AddParameterToUrl(contentUrl, "nodeId", nodeString);

                // Set default live site URL in header link
                string liveURL = URLHelper.ResolveUrl(rootNode.RelativeURL) + "?viewmode=livesite";
                ScriptHelper.RegisterStartupScript(this, typeof(string), "SetDefaultLiveSiteURL", ScriptHelper.GetScript("SetLiveSiteURL('" + liveURL + "');"));
            }
        }

        contentview.Src = contentUrl;

        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Content/CMSDesk/Content.js");

        // Override content functions
        AddScript(
            @"
function SetMode(mode, passive) {
    if (!CheckChanges()) {
        return false;
    }
 
    SetSelectedMode(mode);
    if (!passive) {
        DisplayDocument();
    }
    return true;
}

function DragOperation(nodeId, targetNodeId, operation) {
    window.PerformContentRedirect(null, 'drag', nodeId, '&action=' + operation + '&targetnodeid=' + targetNodeId + '&mode=productssection');
}
");
    }
コード例 #6
0
    protected void OnTabCreated(object sender, TabCreatedEventArgs e)
    {
        if (e.Tab == null)
        {
            return;
        }

        var tab     = e.Tab;
        var element = e.UIElement;

        bool splitViewSupported = false;

        string lowerElementName = element.ElementName.ToLowerCSafe();

        switch (lowerElementName)
        {
        case "products.attachments":
        case "products.metadata":
        case "products.categories":
        case "products.workflow":
        case "products.versions":
            splitViewSupported = true;
            break;

        case "products.general":
            splitViewSupported = true;
            break;
        }

        switch (lowerElementName)
        {
        case "products.attachments":
        case "products.metadata":
        case "products.categories":
        case "products.workflow":
        case "products.versions":
        case "products.relatedproducts":
            // Check if editing product with its document
            if (NodeID <= 0)
            {
                e.Tab = null;
                return;
            }
            break;

        case "products.documents":
            if ((NodeID <= 0) && (ECommerceSettings.ProductsTree(SiteContext.CurrentSiteName) == ProductsTreeModeEnum.Sections))
            {
                if (!MembershipContext.AuthenticatedUser.IsGlobalAdministrator || (sku == null) || !sku.IsGlobal)
                {
                    e.Tab = null;
                    return;
                }
            }
            break;

        case "products.preview":
        {
            // Check if editing product with its document
            if (NodeID <= 0)
            {
                e.Tab = null;
                return;
            }

            var settings = new UIPageURLSettings
            {
                Mode              = "preview",
                NodeID            = Node.NodeID,
                Culture           = Node.DocumentCulture,
                Node              = Node,
                AllowViewValidate = false
            };

            tab.RedirectUrl = ProductUIHelper.GetProductPageUrl(settings);

            tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "nodeid", NodeID.ToString());
            tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "showdevicesselection", "0");
        }
        break;

        case "products.advanced":
        {
            tab.Expand = (NodeID <= 0);

            // Append product/node params to url
            var url = tab.RedirectUrl;
            url = URLHelper.AddParameterToUrl(url, "productid", ProductID.ToString());
            if (Node != null)
            {
                url = URLHelper.AddParameterToUrl(url, "nodeid", Node.NodeID.ToString());
                url = URLHelper.AddParameterToUrl(url, "culture", Node.DocumentCulture);
            }

            tab.RedirectUrl = url;
        }
        break;

        case "products.options":
            tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "productId", ProductID.ToString());
            break;
        }

        // Add SiteId parameter to each tab
        if (!string.IsNullOrEmpty(tab.RedirectUrl))
        {
            tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "siteId", siteId.ToString());
        }

        // Ensure split view mode
        if ((NodeID > 0) && splitViewSupported && UIContext.DisplaySplitMode)
        {
            tab.RedirectUrl = DocumentUIHelper.GetSplitViewUrl(tab.RedirectUrl);
        }

        // Make URL absolute
        tab.RedirectUrl = URLHelper.GetAbsoluteUrl(tab.RedirectUrl);
    }
コード例 #7
0
    protected void OnTabCreated(object sender, TabCreatedEventArgs e)
    {
        if (e.Tab == null)
        {
            return;
        }

        var tab     = e.Tab;
        var element = e.UIElement;
        var node    = documentManager.Node;

        bool   splitViewSupported = false;
        string lowerElementName   = element.ElementName.ToLowerCSafe();

        // Skip some elements if editing just SKU without document binding
        switch (lowerElementName)
        {
        case "products.relatedproducts":
            if (node == null)
            {
                e.Tab = null;
                return;
            }

            break;

        case "products.documents":
            var displayTree = ECommerceSettings.ProductsTree(siteId) == ProductsTreeModeEnum.Sections;
            if ((node == null) && displayTree)
            {
                if (!MembershipContext.AuthenticatedUser.IsGlobalAdministrator || (sku == null) || !sku.IsGlobal)
                {
                    e.Tab = null;
                    return;
                }
            }
            break;

        case "products.workflow":
        case "products.versions":
            splitViewSupported = true;
            if ((node == null) || (documentManager.Workflow == null))
            {
                e.Tab = null;
                return;
            }
            break;
        }

        // Add SiteId parameter to each tab
        if (!string.IsNullOrEmpty(tab.RedirectUrl) && (siteId != SiteContext.CurrentSiteID))
        {
            tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "siteId", siteId.ToString());
        }

        // Ensure split view mode
        if (splitViewSupported && UIContext.DisplaySplitMode)
        {
            tab.RedirectUrl = DocumentUIHelper.GetSplitViewUrl(tab.RedirectUrl);
        }
    }