예제 #1
0
    /// <summary>
    /// Creates breadcrumbs array leading to specified node using given tree provider and starting at given starting path.
    /// </summary>
    /// <param name="node">Tree node to generate breadcrumbs for.</param>
    /// <param name="startingPath">Path where to start to generate.</param>
    protected virtual string[,] CreateBreadcrumbs(TreeNode node, string startingPath)
    {
        string[,] breadcrumbs = null;

        if (node != null)
        {
            const string columns = "NodeID, NodeAliasPath, NodeSiteID, NodeOwner, DocumentName, DocumentLastVersionName, DocumentMenuCaption, DocumentCulture, SiteName, ClassName, NodeACLID";

            // Prepare the where condition
            string where = SqlHelperClass.AddWhereCondition(null, TreeProvider.GetNodesOnPathWhereCondition(node.NodeAliasPath, true, true));
            DataSet ds = DocumentHelper.GetDocuments(CurrentSiteName, startingPath, TreeProvider.ALL_CULTURES, true, null, where, "NodeAliasPath ASC", -1, false, 0, columns, node.TreeProvider);

            ds = TreeSecurityProvider.FilterDataSetByPermissions(ds, NodePermissionsEnum.Read, CMSContext.CurrentUser);

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                // Initialize resolver
                ContextResolver currentResolver = CMSContext.CurrentResolver.CreateContextChild();
                currentResolver.EncodeResolvedValues = true;

                DataRow[] resolverData = new DataRow[1];
                DataTable table        = ds.Tables[0];

                // Prepare breadcrumbs
                breadcrumbs = new string[table.Rows.Count + 1, 4];

                int i = 0;

                foreach (DataRow dr in table.Rows)
                {
                    // Add current datarow to the resolver
                    resolverData[0]            = dr;
                    currentResolver.SourceData = resolverData;

                    // Prepare the item name. Disable encoding.
                    currentResolver.EncodeResolvedValues = false;
                    string linkName = currentResolver.ResolveMacros(TreePathUtils.GetMenuCaption(ValidationHelper.GetString(dr["DocumentMenuCaption"], String.Empty), ValidationHelper.GetString(dr["DocumentName"], String.Empty)));
                    currentResolver.EncodeResolvedValues = true;

                    // Use site name for root node
                    linkName = string.IsNullOrEmpty(linkName) ? CMSContext.CurrentSite.DisplayName : linkName;

                    // Create breadcrumb
                    breadcrumbs[i, 0] = HTMLHelper.HTMLEncode(linkName);
                    breadcrumbs[i, 1] = "~/CMSModules/Ecommerce/Pages/Tools/Products/Product_List.aspx?nodeid=" + dr["NodeID"];
                    breadcrumbs[i, 3] = string.Format("EditDocument({0}); RefreshTree({0},{0});", dr["NodeID"]);

                    // Increment index
                    i++;
                }

                // Add 'properties' breadcrumb
                breadcrumbs[i, 0] = HTMLHelper.HTMLEncode(GetString((Action == "new") ? "com.productsection.new" : "com.productsection.properties"));
                breadcrumbs[i, 1] = "";
                breadcrumbs[i, 2] = "";
            }
        }

        return(breadcrumbs);
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Current Node ID
        int nodeId = 0;

        if (Request.QueryString["nodeid"] != null)
        {
            nodeId = ValidationHelper.GetInteger(Request.QueryString["nodeid"], 0);
        }

        switch (QueryHelper.GetString("action", "edit").ToLower())
        {
        case "delete":
            // Do not include title upon delete
            this.titleElem.SetWindowTitle = false;
            break;
        }

        // Get the node
        string aliasPath = TreePathUtils.GetAliasPathByNodeId(nodeId);

        if (aliasPath == "/")
        {
            // Set path as site name if empty
            SiteInfo si = CMSContext.CurrentSite;
            if (si != null)
            {
                this.titleElem.CreateStaticBreadCrumbs(HttpUtility.HtmlEncode(si.DisplayName));
            }
        }
        else
        {
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

            // Get the DataSet of nodes
            string where = TreeProvider.GetNodesOnPathWhereCondition(aliasPath, true, true);
            DataSet ds = DocumentHelper.GetDocuments(CMSContext.CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "NodeLevel ASC", -1, false, tree);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                string[,] bc = new string[ds.Tables[0].Rows.Count, 3];
                int index = 0;

                // Build the path
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string documentName = ValidationHelper.GetString(dr["DocumentName"], "");

                    bc[index, 0] = documentName;
                    bc[index, 1] = string.Empty;
                    bc[index, 2] = string.Empty;

                    index++;
                }

                this.titleElem.Breadcrumbs = bc;
            }
        }
    }