Manages navigation paths.
Exemple #1
0
        /// <summary>
        /// Sets the navigation paths label.
        /// </summary>
        private void SetupNavigationPaths()
        {
            string[] paths = NavigationPaths.PathsPerPage(currentPage);

            string currentPath = Request["NavPath"];

            if (!string.IsNullOrEmpty(currentPath))
            {
                currentPath = currentPath.ToLowerInvariant();
            }

            if (!discussMode && !viewCodeMode && paths.Length > 0)
            {
                StringBuilder sb = new StringBuilder(500);
                sb.Append(Properties.Messages.Paths);
                sb.Append(": ");
                for (int i = 0; i < paths.Length; i++)
                {
                    NavigationPath path = NavigationPaths.Find(paths[i]);
                    if (path != null)
                    {
                        if (currentPath != null && paths[i].ToLowerInvariant().Equals(currentPath))
                        {
                            sb.Append("<b>");
                        }

                        sb.Append(@"<a href=""");
                        sb.Append(UrlTools.BuildUrl("Default.aspx?Page=", Tools.UrlEncode(currentPage.FullName), "&amp;NavPath=", Tools.UrlEncode(paths[i])));
                        sb.Append(@""" title=""");
                        sb.Append(NameTools.GetLocalName(path.FullName));
                        sb.Append(@""">");
                        sb.Append(NameTools.GetLocalName(path.FullName));
                        sb.Append("</a>");

                        if (currentPath != null && paths[i].ToLowerInvariant().Equals(currentPath))
                        {
                            sb.Append("</b>");
                        }

                        if (i != paths.Length - 1)
                        {
                            sb.Append(", ");
                        }
                    }
                }

                lblNavigationPaths.Text = sb.ToString();
            }
            else
            {
                lblNavigationPaths.Visible = false;
            }
        }
        protected void rptNavPaths_DataBinding(object sender, EventArgs e)
        {
            bool canManagePages         = CanManagePagesInCurrentNamespace();
            List <NavigationPath> paths = NavigationPaths.GetNavigationPaths(Pages.FindNamespace(lstNamespace.SelectedValue));

            List <NavigationPathRow> result = new List <NavigationPathRow>(paths.Count);

            foreach (NavigationPath path in paths)
            {
                result.Add(new NavigationPathRow(path, canManagePages, path.FullName == txtCurrentNavPath.Value));
            }

            rptNavPaths.DataSource = result;
        }
Exemple #3
0
		public void PrintNavPaths() {
			StringBuilder sb = new StringBuilder();
			sb.Append("<ul>");
			List<NavigationPath> paths = NavigationPaths.GetNavigationPaths(DetectNamespaceInfo());
			for(int i = 0; i < paths.Count; i++) {
				sb.Append(@"<li><a href=""");
				UrlTools.BuildUrl(sb, "Default.aspx?Page=", Tools.UrlEncode(paths[i].Pages[0]),
					"&amp;NavPath=", Tools.UrlEncode(paths[i].FullName));

				sb.Append(@""">");
				sb.Append(paths[i].FullName);
				sb.Append("</a></li>");
			}
			sb.Append("</ul>");

			lblNavPathList.Text = sb.ToString();
		}
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!CanManagePagesInCurrentNamespace())
            {
                return;
            }

            bool done = NavigationPaths.ModifyNavigationPath(txtCurrentNavPath.Value, GetSelectedPages());

            if (done)
            {
                RefreshList();
                lblResult.CssClass = "resultok";
                lblResult.Text     = Properties.Messages.NavPathSaved;
                ReturnToList();
            }
            else
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.CouldNotSaveNavPath;
            }
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (!CanManagePagesInCurrentNamespace())
            {
                return;
            }

            bool done = NavigationPaths.RemoveNavigationPath(DetectWiki(), txtCurrentNavPath.Value);

            if (done)
            {
                RefreshList();
                lblResult.CssClass = "resultok";
                lblResult.Text     = Properties.Messages.NavPathDeleted;
                ReturnToList();
            }
            else
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.CouldNotDeleteNavPath;
            }
        }
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            if (!CanManagePagesInCurrentNamespace())
            {
                return;
            }

            txtName.Text = txtName.Text.Trim();

            if (!Page.IsValid)
            {
                return;
            }

            if (lstPages.Items.Count == 0)
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.TheNavPathMustContain;
                return;
            }

            bool done = NavigationPaths.AddNavigationPath(Pages.FindNamespace(lstNamespace.SelectedValue),
                                                          txtName.Text, GetSelectedPages(), null);

            if (done)
            {
                RefreshList();
                lblResult.CssClass = "resultok";
                lblResult.Text     = Properties.Messages.NavPathCreated;
                ReturnToList();
            }
            else
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.CouldNotCreateNavPath;
            }
        }
        protected void rptNavPaths_ItemCommand(object sender, CommandEventArgs e)
        {
            txtCurrentNavPath.Value = e.CommandArgument as string;

            if (e.CommandName == "Select")
            {
                if (!CanManagePagesInCurrentNamespace())
                {
                    return;
                }

                string currentWiki = DetectWiki();

                txtName.Text    = txtCurrentNavPath.Value;
                txtName.Enabled = false;

                NavigationPath path = NavigationPaths.Find(currentWiki, txtCurrentNavPath.Value);
                foreach (string page in path.Pages)
                {
                    PageContent pageContent = Pages.FindPage(currentWiki, page);
                    if (pageContent != null)
                    {
                        lstPages.Items.Add(new ListItem(FormattingPipeline.PrepareTitle(currentWiki, pageContent.Title, false, FormattingContext.Other, pageContent.FullName), pageContent.FullName));
                    }
                }

                cvName2.Enabled   = false;
                btnCreate.Visible = false;
                btnSave.Visible   = true;
                btnDelete.Visible = true;

                pnlList.Visible        = false;
                pnlEditNavPath.Visible = true;

                lblResult.Text = "";
            }
        }
 protected void cvName2_ServerValidate(object sender, ServerValidateEventArgs e)
 {
     e.IsValid = NavigationPaths.Find(NameTools.GetFullName(lstNamespace.SelectedValue, txtName.Text)) == null;
 }
Exemple #9
0
        /// <summary>
        /// Prepares the previous and next pages link for navigation paths.
        /// </summary>
        /// <param name="previousPageLink">The previous page link.</param>
        /// <param name="nextPageLink">The next page link.</param>
        private void SetupAdjacentPages()
        {
            StringBuilder prev = new StringBuilder(50), next = new StringBuilder(50);

            if (Request["NavPath"] != null)
            {
                NavigationPath path = NavigationPaths.Find(Request["NavPath"]);

                if (path != null)
                {
                    int idx = Array.IndexOf(path.Pages, currentPage.FullName);
                    if (idx != -1)
                    {
                        if (idx > 0)
                        {
                            PageInfo prevPage = Pages.FindPage(path.Pages[idx - 1]);
                            prev.Append(@"<a href=""");
                            UrlTools.BuildUrl(prev, "Default.aspx?Page=", Tools.UrlEncode(prevPage.FullName),
                                              "&amp;NavPath=", Tools.UrlEncode(path.FullName));

                            prev.Append(@""" title=""");
                            prev.Append(Properties.Messages.PrevPage);
                            prev.Append(": ");
                            prev.Append(FormattingPipeline.PrepareTitle(Content.GetPageContent(prevPage, true).Title, false, FormattingContext.PageContent, currentPage));
                            prev.Append(@"""><b>&laquo;</b></a> ");
                        }
                        if (idx < path.Pages.Length - 1)
                        {
                            PageInfo nextPage = Pages.FindPage(path.Pages[idx + 1]);
                            next.Append(@" <a href=""");
                            UrlTools.BuildUrl(next, "Default.aspx?Page=", Tools.UrlEncode(nextPage.FullName),
                                              "&amp;NavPath=", Tools.UrlEncode(path.FullName));

                            next.Append(@""" title=""");
                            next.Append(Properties.Messages.NextPage);
                            next.Append(": ");
                            next.Append(FormattingPipeline.PrepareTitle(Content.GetPageContent(nextPage, true).Title, false, FormattingContext.PageContent, currentPage));
                            next.Append(@"""><b>&raquo;</b></a>");
                        }
                    }
                }
            }

            if (prev.Length > 0)
            {
                lblPreviousPage.Text = prev.ToString();
            }
            else
            {
                lblPreviousPage.Visible = false;
            }

            if (next.Length > 0)
            {
                lblNextPage.Text = next.ToString();
            }
            else
            {
                lblNextPage.Visible = false;
            }
        }