예제 #1
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(UrlResolver.ResolveUrl(contentUrl));
        }

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

        if (NodeID <= 0 || !IsAllowedInProductsStartingPath(NodeID))
        {
            // 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
                string liveURL = DocumentUIHelper.GetAbsolutePageUrl(rootNode, rootNode.DocumentCulture);

                ScriptHelper.RegisterStartupScript(this, typeof(string), "SetDefaultLiveSiteURL", ScriptHelper.GetScript("SetLiveSiteURL('" + HttpUtility.JavaScriptStringEncode(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');
}
");
        // Set ddNotScroll global variable to ensure FloatingBehavior.startDrag() will count with scrolling offset
        AddScript("window.ddNotScroll = true;");
    }