/// <summary>
    /// Returns Correct URL of the link dialog.
    /// </summary>
    /// <param name="nodeId">ID Of the node to be copied or moved</param>
    private string GetLinkDialogUrl(int nodeId)
    {
        DialogConfiguration config = ProductUIHelper.GetProductDialogConfig("linkdoc", null);
        string url = CMSDialogHelper.GetDialogUrl(config, false, false, null, false);

        // Prepare url for link dialog
        url = URLHelper.RemoveParameterFromUrl(url, "hash");
        url = URLHelper.AddParameterToUrl(url, "sourcenodeids", nodeId.ToString());
        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));

        return(url);
    }
Exemplo n.º 2
0
    private void gridData_OnAction(string actionName, object actionArgument)
    {
        if (string.IsNullOrEmpty(actionName))
        {
            return;
        }

        var argument = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerInvariant())
        {
        case "edit":
        {
            string url   = ProductUIHelper.GetProductEditUrl();
            string query = DocumentListingDisplayed ? "?sectionId=" + NodeID + "&nodeId=" + argument + "&culture=" + CultureCode : "?productid=" + argument;

            url = URLHelper.AppendQuery(url, query);

            URLHelper.Redirect(UrlResolver.ResolveUrl(url));
        }
        break;

        case "delete":
            if (DocumentListingDisplayed)
            {
                var url = "Product_Section.aspx?action=delete&nodeId=" + argument;
                URLHelper.Redirect(UrlResolver.ResolveUrl(URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url))));
            }
            else
            {
                SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(argument);

                // Check module permissions
                CheckModifyPermission(skuObj);

                // Check dependencies
                if (SKUInfoProvider.CheckDependencies(argument))
                {
                    // Show error message
                    ShowError(EcommerceUIHelper.GetDependencyMessage(skuObj));

                    return;
                }

                SKUInfoProvider.DeleteSKUInfo(skuObj);
            }

            break;
        }
    }
Exemplo n.º 3
0
    private void gridData_OnAction(string actionName, object actionArgument)
    {
        int argument = ValidationHelper.GetInteger(actionArgument, 0);

        actionName = actionName.ToLowerCSafe();

        switch (actionName)
        {
        case "edit":
        {
            string url   = ProductUIHelper.GetProductEditUrl();
            string query = DocumentListingDisplayed ? "?sectionId=" + NodeID + "&nodeId=" + argument + "&culture=" + CultureCode : "?productid=" + argument;

            url = URLHelper.AppendQuery(url, query);

            URLHelper.Redirect(url);
        }
        break;

        case "delete":
            if (DocumentListingDisplayed)
            {
                URLHelper.Redirect("Product_Section.aspx?action=delete&nodeId=" + argument);
            }
            else
            {
                SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(argument);

                // Check module permissions
                CheckModifyPermission(skuObj);

                // Check dependencies
                if (SKUInfoProvider.CheckDependencies(argument))
                {
                    // Show error message
                    ShowError(ECommerceHelper.GetDependencyMessage(skuObj));

                    return;
                }

                SKUInfoProvider.DeleteSKUInfo(skuObj);
            }

            break;
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Redirects to the edit page of the saved product.
    /// </summary>
    private void RedirectToSavedProduct(BaseInfo product)
    {
        string url = ProductUIHelper.GetProductEditUrl();

        // Creating product options of type other than products is redirected directly to form
        if (OptionCategoryID > 0)
        {
            var categoryInfo = OptionCategoryInfoProvider.GetOptionCategoryInfo(OptionCategoryID);
            if (categoryInfo != null)
            {
                url = "Product_Edit_General.aspx";

                if (categoryInfo.CategoryType == OptionCategoryTypeEnum.Products)
                {
                    url = UIContextHelper.GetElementUrl("cms.ecommerce", "ProductOptions.Options.Edit", false);
                }
            }
        }

        url = URLHelper.AddParameterToUrl(url, "siteId", SiteID.ToString());
        url = URLHelper.AddParameterToUrl(url, "categoryId", OptionCategoryID.ToString());
        url = URLHelper.AddParameterToUrl(url, "objectid", OptionCategoryID.ToString());

        if (product is TreeNode)
        {
            int nodeId = product.GetIntegerValue("NodeID", 0);
            url = URLHelper.AddParameterToUrl(url, "nodeId", nodeId.ToString());
        }
        else if (product is SKUInfo)
        {
            int skuId = product.GetIntegerValue("SKUID", 0);
            url = URLHelper.AddParameterToUrl(url, "productId", skuId.ToString());

            // Select general tab if stan-alone SKU is saved
            if (OptionCategoryID == 0)
            {
                url = URLHelper.AddParameterToUrl(url, "tabName", "Products.General");
            }
        }

        url = URLHelper.AddParameterToUrl(url, "saved", "1");

        URLHelper.Redirect(url);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Redirects to the edit page of the saved product.
    /// </summary>
    private void RedirectToSavedProduct(BaseInfo product)
    {
        string url = ProductUIHelper.GetProductEditUrl();

        if (OptionCategoryID > 0)
        {
            var categoryInfo = OptionCategoryInfoProvider.GetOptionCategoryInfo(OptionCategoryID);
            if (categoryInfo != null)
            {
                url = UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "ProductOptions.Options.General", false);
            }
        }

        var categoryID = OptionCategoryID.ToString();

        url = URLHelper.AddParameterToUrl(url, "siteId", SiteID.ToString());
        url = URLHelper.AddParameterToUrl(url, "categoryId", categoryID);
        url = URLHelper.AddParameterToUrl(url, "parentobjectid", categoryID);

        if (product is TreeNode)
        {
            int nodeId = product.GetIntegerValue("NodeID", 0);
            url = URLHelper.AddParameterToUrl(url, "nodeId", nodeId.ToString());
        }
        else if (product is SKUInfo)
        {
            var skuId = product.GetIntegerValue("SKUID", 0).ToString();
            url = URLHelper.AddParameterToUrl(url, "productId", skuId);
            url = URLHelper.AddParameterToUrl(url, "objectid", skuId);

            // Select general tab if stan-alone SKU is saved
            if (OptionCategoryID == 0)
            {
                url = URLHelper.AddParameterToUrl(url, "tabName", "Products.General");
            }
        }

        url = URLHelper.AddParameterToUrl(url, "saved", "1");

        URLHelper.Redirect(UrlResolver.ResolveUrl(url));
    }
Exemplo n.º 6
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        showProductsInTree = ECommerceSettings.DisplayProductsInSectionsTree(CurrentSiteName);

        if (DocumentListingDisplayed)
        {
            // Init document list
            docList.NodeID                         = NodeID;
            docList.Grid.GridName                  = "~/CMSModules/Ecommerce/Pages/Tools/Products/Product_List_Documents.xml";
            docList.AdditionalColumns              = "SKUID, DocumentSKUName, NodeParentID, NodeID, NodeSKUID, SKUName, SKUNumber, SKUPrice, SKUAvailableItems, SKUEnabled, SKUSiteID, SKUPublicStatusID, SKUInternalStatusID, SKUReorderAt, SKUTrackInventory";
            docList.WhereCondition                 = GetDocumentWhereCondition();
            docList.OrderBy                        = ShowSections ? "CASE WHEN NodeSKUID IS NULL THEN 0 ELSE 1 END, DocumentName" : "DocumentName";
            docList.OnExternalAdditionalDataBound += gridData_OnExternalDataBound;
            docList.OnDocumentFlagsCreating       += docList_OnDocumentFlagsCreating;
            docList.Grid.OnAction                 += gridData_OnAction;
            docList.Grid.RememberStateByParam      = "";
            docList.SelectLanguageJSFunction       = "EditProductInCulture";

            docList.DeleteReturnUrl  = CONTENT_CMSDESK_FOLDER + "Delete.aspx?multiple=true";
            docList.PublishReturnUrl = CONTENT_CMSDESK_FOLDER + "PublishArchive.aspx?multiple=true";
            docList.ArchiveReturnUrl = CONTENT_CMSDESK_FOLDER + "PublishArchive.aspx?multiple=true";

            docList.TranslateReturnUrl = "~/CMSModules/Translations/Pages/TranslateDocuments.aspx";

            if (!string.IsNullOrEmpty(ProductsStartingPath))
            {
                docList.CopyMoveLinkStartingPath = ProductsStartingPath;
            }

            string languageSelectionScript = $@"
function EditProductInCulture(nodeId, culture, translated, url) {{
    parent.RefreshTree(nodeId, nodeId); 
    window.location.href = '{ProductUIHelper.GetProductEditUrl()}&nodeid=' + nodeId + '&culture=' + culture;
    parent.ChangeLanguage(culture);
}}
";

            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "EditProductInCulture", ScriptHelper.GetScript(languageSelectionScript));

            plcSKUListing.Visible = false;

            // Stop processing SKU table
            gridData.StopProcessing = true;

            EditedObject = docList.Node;

            // Set title
            string title = docList.Node.IsRoot() ? GetString("com.sku.productslist") : docList.Node.GetDocumentName();
            SetTitle(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(title)));
        }
        else
        {
            // Init Unigrid
            gridData.OnAction            += gridData_OnAction;
            gridData.OnExternalDataBound += gridData_OnExternalDataBound;

            // Stop processing product document listing
            docList.StopProcessing     = true;
            plcDocumentListing.Visible = false;

            // Set title according display tree setting
            SetTitle(GetString(DisplayTreeInProducts ? "com.sku.unassignedlist" : "com.sku.productslist"));
        }

        // Show warning when exchange rate from global main currency is missing
        if (AllowGlobalObjects && ECommerceContext.IsExchangeRateFromGlobalMainCurrencyMissing)
        {
            ShowWarning(GetString("com.NeedExchangeRateFromGlobal"));
        }
    }
Exemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        const string CONTENT_CMSDESK_FOLDER = "~/CMSModules/Content/CMSDesk/";

        // Register script files
        ScriptHelper.RegisterScriptFile(this, CONTENT_CMSDESK_FOLDER + "EditTabs.js");

        bool   checkCulture       = false;
        bool   splitViewSupported = false;
        string action             = QueryHelper.GetString("action", "edit").ToLowerCSafe();

        switch (action)
        {
        // New dialog / new page form
        case "new":
            int classId = QueryHelper.GetInteger("classid", 0);
            if (classId <= 0)
            {
                // Get by class name if specified
                string className = QueryHelper.GetString("classname", string.Empty);
                if (className != string.Empty)
                {
                    classInfo = DataClassInfoProvider.GetDataClassInfo(className);
                    if (classInfo != null)
                    {
                        classId = classInfo.ClassID;
                    }
                }
            }

            const string EC_PRODUCTS_FOLDER = "~/CMSModules/Ecommerce/Pages/Tools/Products/";

            if (classId > 0)
            {
                viewpage = ResolveUrl(CONTENT_CMSDESK_FOLDER + "Edit/Edit.aspx");

                // Check if document type is allowed under parent node
                if (parentNodeID > 0)
                {
                    // Get the node
                    TreeNode = Tree.SelectSingleNode(parentNodeID, TreeProvider.ALL_CULTURES);
                    if (TreeNode != null)
                    {
                        if (!DocumentHelper.IsDocumentTypeAllowed(TreeNode, classId))
                        {
                            viewpage = CONTENT_CMSDESK_FOLDER + "NotAllowed.aspx?action=child";
                        }
                    }
                }

                // Use product page when product type is selected
                classInfo = classInfo ?? DataClassInfoProvider.GetDataClassInfo(classId);
                if ((classInfo != null) && (classInfo.ClassIsProduct))
                {
                    viewpage = ResolveUrl(EC_PRODUCTS_FOLDER + "Product_New.aspx");
                }
            }
            else
            {
                if (parentNodeID > 0)
                {
                    viewpage = EC_PRODUCTS_FOLDER + "New_ProductOrSection.aspx";
                }
                else
                {
                    viewpage = EC_PRODUCTS_FOLDER + "Product_New.aspx?parentNodeId=0";
                }
            }
            break;

        case "delete":
            // Delete dialog
            viewpage = CONTENT_CMSDESK_FOLDER + "Delete.aspx";
            break;

        default:
            // Edit mode
            viewpage           = CONTENT_CMSDESK_FOLDER + "Edit/edit.aspx?mode=editform";
            splitViewSupported = true;

            // Ensure class info
            if ((classInfo == null) && (Node != null))
            {
                classInfo = DataClassInfoProvider.GetDataClassInfo(Node.NodeClassName);
            }

            // Check explicit editing page url
            if ((classInfo != null) && !string.IsNullOrEmpty(classInfo.ClassEditingPageURL))
            {
                viewpage = URLHelper.AppendQuery(ResolveUrl(classInfo.ClassEditingPageURL), RequestContext.CurrentQueryString);
            }

            checkCulture = true;
            break;
        }

        // If culture version should be checked, check
        if (checkCulture)
        {
            // Check (and ensure) the proper content culture
            if (!CheckPreferredCulture())
            {
                RefreshParentWindow();
            }

            // Check split mode
            bool isSplitMode = PortalUIHelper.DisplaySplitMode;
            bool combineWithDefaultCulture = !isSplitMode && SiteInfoProvider.CombineWithDefaultCulture(SiteContext.CurrentSiteName);

            var nodeId = QueryHelper.GetInteger("nodeid", 0);
            TreeNode = Tree.SelectSingleNode(nodeId, CultureCode, combineWithDefaultCulture);
            if (TreeNode == null)
            {
                // Document does not exist -> redirect to new culture version creation dialog
                viewpage = ProductUIHelper.GetNewCultureVersionPageUrl();
            }
        }

        // Apply the additional transformations to the view page URL
        viewpage = URLHelper.AppendQuery(viewpage, RequestContext.CurrentQueryString);
        viewpage = URLHelper.RemoveParameterFromUrl(viewpage, "mode");
        viewpage = URLHelper.AddParameterToUrl(viewpage, "mode", "productssection");
        viewpage = ResolveUrl(viewpage);
        viewpage = URLHelper.AddParameterToUrl(viewpage, "hash", QueryHelper.GetHash(viewpage));

        // Split mode enabled
        if (splitViewSupported && PortalUIHelper.DisplaySplitMode && (TreeNode != null) && (action == "edit" || action == "preview" || (TreeNode.IsPublished && action == "livesite")))
        {
            viewpage = DocumentUIHelper.GetSplitViewUrl(viewpage);
        }

        URLHelper.Redirect(UrlResolver.ResolveUrl(viewpage));
    }
Exemplo n.º 8
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);
    }
Exemplo n.º 9
0
    /// <summary>
    /// Initializes the extender
    /// </summary>
    public override void OnInit()
    {
        base.OnInit();
        var  breadcrumbName      = "";
        bool generateBreadcrumbs = true;


        // Ensure selection of general tab in case EditForm is requested
        var tabName = QueryHelper.GetString("tabName", "");

        if (tabName.EqualsCSafe("EditForm", true))
        {
            Control.SelectedTabName = "Products.General";
        }

        var page = (CMSPage)Control.Page;

        if (ProductID <= 0)
        {
            // Setup the document manager
            var manager = page.DocumentManager;
            manager.RedirectForNonExistingDocument = false;
            manager.Tree.CombineWithDefaultCulture = false;

            var node = manager.Node;
            if (node == null)
            {
                // Redirect to create new culture version
                URLHelper.ResponseRedirect(ProductUIHelper.GetNewCultureVersionPageUrl(), false);
                CMSHttpContext.Current.ApplicationInstance.CompleteRequest();
                return;
            }

            Node           = node;
            breadcrumbName = Node.Site.Generalized.ObjectDisplayName;
        }

        // Get product name and option category ID
        if (ProductID > 0)
        {
            sku = SKUInfoProvider.GetSKUInfo(ProductID);
            if (sku != null)
            {
                breadcrumbName   = ResHelper.LocalizeString(sku.SKUName);
                optionCategoryId = sku.SKUOptionCategoryID;
                siteId           = sku.SKUSiteID;

                // Check if edited object belongs to configured site
                if ((siteId != SiteContext.CurrentSiteID) && ((siteId != 0) || !AllowGlobalObjects))
                {
                    page.EditedObject = null;
                }

                var dialogMode = QueryHelper.GetBoolean("dialog", false);

                int hideBreadcrumbs = QueryHelper.GetInteger("hidebreadcrumbs", 0);

                // Show breadcrumbs if not dialog mode or dialog mode is in product option UI
                if ((hideBreadcrumbs != 0) || dialogMode)
                {
                    generateBreadcrumbs = false;
                }
            }
        }

        if (generateBreadcrumbs)
        {
            ProductUIHelper.EnsureProductBreadcrumbs(page.PageBreadcrumbs, breadcrumbName, (ProductID <= 0), ProductListInTree);
        }

        Control.Page.Load += Page_Load;

        Control.ElementName = (optionCategoryId > 0) ? "ProductOptions.Options" : "Products.Properties";
    }