当前位置: 首页>>代码示例>>C#>>正文


C# ContentItem.FindPath方法代码示例

本文整理汇总了C#中ContentItem.FindPath方法的典型用法代码示例。如果您正苦于以下问题:C# ContentItem.FindPath方法的具体用法?C# ContentItem.FindPath怎么用?C# ContentItem.FindPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentItem的用法示例。


在下文中一共展示了ContentItem.FindPath方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildUrl

        /// <summary>Calculates an item url by walking it's parent path.</summary>
        /// <param name="item">The item whose url to compute.</param>
        /// <returns>A friendly url to the supplied item.</returns>
        public override string BuildUrl(ContentItem item)
        {
            if (item == null) throw new ArgumentNullException("item");

            ContentItem current = item;

            if (item.VersionOf.HasValue)
            {
                current = item.VersionOf;
            }

            // move up until first real page
            while(current != null && !current.IsPage)
            {
                current = current.Parent;
            }

            // no start page found, use rewritten url
            if (current == null) return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();

            Url url;
            if (host.IsStartPage(current))
            {
                // we move right up to the start page
                url = "/";
            }
            else
            {
                // at least one node before the start page
                url = new Url("/" + current.Name + current.Extension);
                current = current.Parent;
                // build path until a start page
                while (current != null && !host.IsStartPage(current))
                {
                    url = url.PrependSegment(current.Name);
                    current = current.Parent;
                }
            }

            // no start page found, use rewritten url
            if (current == null) return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();

            if (item.IsPage && item.VersionOf.HasValue)
                // the item was a version, add this information as a query string
                url = url.AppendQuery(PathData.PageQueryKey, item.ID);
            else if(!item.IsPage)
                // the item was not a page, add this information as a query string
                url = url.AppendQuery(PathData.ItemQueryKey, item.ID);

            if (current.ID == host.CurrentSite.StartPageID)
            {
                // the start page belongs to the current site, use relative url
                return Url.ToAbsolute("~" + url.PathAndQuery);
            }

            var site = host.GetSite(current.ID) ?? host.DefaultSite;

            return GetHostedUrl(item, url, site);
        }
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:62,代码来源:MultipleHostsUrlParser.cs

示例2: GetPreviewUrl

        protected override string GetPreviewUrl(ContentItem item)
        {
            if (item.VersionOf == null)
                return item.Url;

            return Url.Parse(item.FindPath(PathData.DefaultAction).RewrittenUrl)
                .AppendQuery("preview", item.ID)
                .AppendQuery("original", item.VersionOf.ID);
        }
开发者ID:joaohortencio,项目名称:n2cms,代码行数:9,代码来源:Default.aspx.cs

示例3: GetPreviewUrl

		/// <summary>Gets the url for the preview frame.</summary>
		/// <param name="selectedItem">The currently selected item.</param>
		/// <returns>An url.</returns>
		public virtual string GetPreviewUrl(ContentItem selectedItem)
		{
			try
			{
				// If hostname == localhost, then don't use custom hostnames in the management navigation tree
				if (HttpContext.Current != null && HttpContext.Current.Request.Url.Host == "localhost")
					return selectedItem.FindPath(PathData.DefaultAction).GetRewrittenUrl();

				Url url = ResolveResourceUrl(parser.BuildUrl(selectedItem));
				return url;
			}
			catch (N2Exception)
			{
				return Url.ResolveTokens("{ManagementUrl}/Empty.aspx?item=" + selectedItem.ID);
			}
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:19,代码来源:EditUrlManager.cs

示例4: BuildUrl

		/// <summary>Calculates an item url by walking it's parent path.</summary>
		/// <param name="item">The item whose url to compute.</param>
		/// <returns>A friendly url to the supplied item.</returns>
		public override Url BuildUrl(ContentItem item)
		{
			if (item == null) throw new ArgumentNullException("item");

			if (item.VersionOf.HasValue && item.VersionOf.Value != null)
			{
				return BuildUrl(item.VersionOf.Value)
					.SetQueryParameter(PathData.VersionIndexQueryKey, item.VersionIndex);
			}
			else if (item.ID == 0)
			{
				var page = Find.ClosestPage(item);
				if (page != null && page != item)
				{
					return BuildUrl(page)
						.SetQueryParameter(PathData.VersionIndexQueryKey, page.VersionIndex)
						.SetQueryParameter("versionKey", item.GetVersionKey());
				}
			}

			// move up until first real page
			var current = Find.ClosestPage(item);

			// no page found, throw
			if (current == null) throw new N2Exception("Cannot build url to data item '{0}' with no containing page item.", item);

			Url url = BuildPageUrl(current, ref current);

			var startPage = FindStartPage(current);
			// no start page found, use rewritten url
			if (startPage == null)
				return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();

			if (!item.IsPage)
				// the item was not a page, add this information as a query string
				url = url.AppendQuery(PathData.ItemQueryKey, item.ID);

			if (startPage.ID == host.CurrentSite.StartPageID)
            {
                // the start page belongs to the current site, use relative url
            	return Url.ToAbsolute("~" + url.PathAndQuery);
            }

			var site = host.GetSite(startPage.ID) ?? host.DefaultSite;

            return GetHostedUrl(item, url, site);
        }
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:50,代码来源:MultipleHostsUrlParser.cs

示例5: ResolvePath

		public override PathData ResolvePath(ContentItem startingPoint, string path)
		{
			return startingPoint.FindPath(path);
		}
开发者ID:davethieben,项目名称:n2cms,代码行数:4,代码来源:DatabaseSource.cs

示例6: GetTemplateUrl

		/// <summary>Gets the path to the given item's template. This is a way to override the default template provided by the content item.</summary>
		/// <param name="item">The item whose path is requested.</param>
		/// <returns>The virtual path of the template or null if the item is not supposed to be added.</returns>
		protected virtual string GetTemplateUrl(ContentItem item)
		{
			return item.FindPath(PathData.DefaultAction).TemplateUrl;
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:7,代码来源:PartsAdapter.cs

示例7: GetHostedUrl

        private static string GetHostedUrl(ContentItem item, string url, Site site)
        {
            string hostName = site.GetHostName(item.Language);
            if (string.IsNullOrEmpty(hostName))
                return item.FindPath(PathData.DefaultAction).RewrittenUrl;

            return Url.Parse(url).SetAuthority(hostName);
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:8,代码来源:MultipleSitesUrlParser.cs

示例8: BuildUrl

        /// <summary>Calculates an item url by walking it's parent path.</summary>
        /// <param name="item">The item whose url to compute.</param>
        /// <returns>A friendly url to the supplied item.</returns>
        public virtual string BuildUrl(ContentItem item)
        {
            if (item == null) throw new ArgumentNullException("item");

            ContentItem current = item;

            if (item.VersionOf != null)
            {
                current = item.VersionOf;
            }

            // move up until first real page
            while (current != null && !current.IsPage)
            {
                current = current.Parent;
            }

            // no page found, use rewritten url
            if (current == null) throw new N2Exception("Cannot build url to data item '{0}' with no containing page item.", item);

            Url url;
            if (host.IsStartPage(current))
            {
                // we move right up to the start page
                url = "/";
            }
            else
            {
                // at least one node before the start page
                url = new Url("/" + current.Name + current.Extension);
                current = current.Parent;
                // build path until a start page
                while (current != null && !host.IsStartPage(current))
                {
                    url = url.PrependSegment(current.Name);
                    current = current.Parent;
                }
            }

            // no start page found, use rewritten url
            if (current == null) return item.FindPath(PathData.DefaultAction).RewrittenUrl;

            if (item.IsPage && item.VersionOf != null)
                // the item was a version, add this information as a query string
                url = url.AppendQuery(PathData.PageQueryKey, item.ID);
            else if (!item.IsPage)
                // the item was not a page, add this information as a query string
                url = url.AppendQuery(PathData.ItemQueryKey, item.ID);

            return Url.ToAbsolute("~" + url);
        }
开发者ID:joaohortencio,项目名称:n2cms,代码行数:54,代码来源:UrlParser.cs

示例9: GetHostedUrl

        private string GetHostedUrl(ContentItem item, string url, Site site)
        {
            if (string.IsNullOrEmpty(site.Authority))
                return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();

            return Url.Parse(url).SetAuthority(site.Authority);
        }
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:7,代码来源:MultipleHostsUrlParser.cs

示例10: GetEditExistingItemUrl

        /// <summary>Gets the url to the edit page where to edit an existing item.</summary>
        /// <param name="item">The item to edit.</param>
        /// <returns>The url to the edit page</returns>
        public virtual string GetEditExistingItemUrl(ContentItem item)
        {
            if (item == null)
                return null;

            string editUrl = Url.ResolveTokens(EditItemUrl);
            if (item.VersionOf != null)
                return string.Format("{0}?selectedUrl={1}", editUrl,
                                     HttpUtility.UrlEncode(item.FindPath(PathData.DefaultAction).RewrittenUrl));

            return Url.Parse(editUrl).AppendQuery("selected", item.Path);
        }
开发者ID:spmason,项目名称:n2cms,代码行数:15,代码来源:EditUrlManager.cs

示例11: RegisterRefreshNavigationScript

        protected virtual void RegisterRefreshNavigationScript(ContentItem item)
        {
            string script = string.Format(refreshScriptFormat,
                VirtualPathUtility.ToAbsolute(Engine.ManagementPaths.ResolveResourceUrl("{ManagementUrl}/Content/Default.aspx")), // 0
                GetNavigationUrl(item), // 1
                item.ID, // 2
                item.FindPath(PathData.DefaultAction).RewrittenUrl, // 3
                item.Path // 4
                );

            ClientScript.RegisterClientScriptBlock(
                typeof(Default),
                "AddRefreshEditScript",
                script, true);
        }
开发者ID:spmason,项目名称:n2cms,代码行数:15,代码来源:Default.aspx.cs

示例12: BuildUrl

		/// <summary>Calculates an item url by walking it's parent path.</summary>
		/// <param name="item">The item whose url to compute.</param>
		/// <returns>A friendly url to the supplied item.</returns>
		public virtual Url BuildUrl(ContentItem item)
		{
			if (item == null) throw new ArgumentNullException("item");

			if (item.VersionOf.HasValue)
			{
				ContentItem version = item.VersionOf;
				if (version != null)
					return BuildUrl(version).SetQueryParameter(PathData.VersionIndexQueryKey, item.VersionIndex);
			}
			else if (item.ID == 0)
			{
				var page = Find.ClosestPage(item);
				if (page != null && page != item)
				{
					return BuildUrl(page)
						.SetQueryParameter(PathData.VersionIndexQueryKey, page.VersionIndex)
						.SetQueryParameter("versionKey", item.GetVersionKey());
				}
			}

			var current = Find.ClosestPage(item);

			// no page found, throw
			if (current == null) throw new N2Exception("Cannot build url to data item '{0}' with no containing page item.", item);

			Url url = BuildPageUrl(current, ref current);

			if (current == null)
				// no start page found, use rewritten url
				return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();

			if (!item.IsPage)
				// the item was not a page, add this information as a query string
				url = url.AppendQuery(PathData.ItemQueryKey, item.ID);

			var absoluteUrl = Url.ToAbsolute("~" + url);
			if (BuiltUrl != null)
			{
				var args = new UrlEventArgs(item) { Url = absoluteUrl };
				BuiltUrl(this, args);
				return args.Url;
			}
			else
				return absoluteUrl;
		}
开发者ID:nagarjunachallapalli,项目名称:n2cms,代码行数:49,代码来源:UrlParser.cs

示例13: GetPreviewUrl

 public override string GetPreviewUrl(ContentItem item)
 {
     return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();
 }
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:4,代码来源:RssFeed.cs

示例14: GetEditExistingItemUrl

        /// <summary>Gets the url to the edit page where to edit an existing item.</summary>
        /// <param name="item">The item to edit.</param>
        /// <param name="language">The language to edit (or create if it doesn't exist).</param>
        /// <returns>The url to the edit page</returns>
        public string GetEditExistingItemUrl(ContentItem item, string languageCode)
        {
            if (item == null)
                return null;

            if (string.IsNullOrEmpty(languageCode))
                languageCode = item.Language;

            if (item.VersionOf != null)
                return string.Format("{0}?selectedUrl={1}&language={2}", EditItemUrl, HttpUtility.UrlEncode(item.FindPath(PathData.DefaultAction).RewrittenUrl), languageCode);

            return string.Format("{0}?selected={1}&language={2}", EditItemUrl, item.Path, languageCode);
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:17,代码来源:AdminManager.cs


注:本文中的ContentItem.FindPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。