本文整理汇总了C#中Kooboo.CMS.Sites.Models.Page.AsActual方法的典型用法代码示例。如果您正苦于以下问题:C# Page.AsActual方法的具体用法?C# Page.AsActual怎么用?C# Page.AsActual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kooboo.CMS.Sites.Models.Page
的用法示例。
在下文中一共展示了Page.AsActual方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GeneratePageUrl
public static IHtmlString GeneratePageUrl(UrlHelper urlHelper, Site site, Page page, object values, FrontRequestChannel channel)
{
RouteValueDictionary routeValues = RouteValuesHelpers.GetRouteValues(values);
page = page.AsActual();
if (page == null)
{
return new HtmlString("");
}
if (page.Route != null && !string.IsNullOrEmpty(page.Route.ExternalUrl))
{
return new HtmlString(page.Route.ExternalUrl);
}
var pageRoute = page.Route.ToMvcRoute();
routeValues = RouteValuesHelpers.MergeRouteValues(pageRoute.Defaults, routeValues);
var routeVirtualPath = pageRoute.GetVirtualPath(urlHelper.RequestContext, routeValues);
if (routeVirtualPath == null)
{
throw new InvalidPageRouteException(page);
}
//string contentUrl = routeVirtualPath.VirtualPath;//don't decode the url. why??
//if do not decode the url, the route values contains Chinese character will cause bad request.
string contentUrl = HttpUtility.UrlDecode(routeVirtualPath.VirtualPath);
string pageUrl = contentUrl;
if (!string.IsNullOrEmpty(contentUrl) || (string.IsNullOrEmpty(pageUrl) && !page.IsDefault))
{
pageUrl = Kooboo.Web.Url.UrlUtility.Combine(page.VirtualPath, contentUrl);
}
if (string.IsNullOrEmpty(pageUrl))
{
pageUrl = urlHelper.Content("~/");
}
else
{
pageUrl = HttpUtility.UrlDecode(
urlHelper.RouteUrl("Page", new { PageUrl = new HtmlString(pageUrl) }));
}
var url = FrontUrlHelper.WrapperUrl(pageUrl, site, channel, page.RequireHttps);
return url;
}
示例2: PageRequestContext
/// <summary>
/// Initializes a new instance of the <see cref="FrontRequestContext"/> class.
/// </summary>
/// <param name="site">The site.</param>
/// <param name="page">The page.</param>
/// <param name="requestChannel">The request channel.</param>
/// <param name="httpContext">The HTTP context.</param>
/// <param name="pageRequestUrl">The page request url with out page virtual path.</param>
public PageRequestContext(ControllerContext controllerContext, Site site, Page page, FrontRequestChannel requestChannel, string pageRequestUrl)
{
RouteValues = new RouteValueDictionary();
this.ControllerContext = controllerContext;
var httpContext = HttpContext.Current;
this.Site = site.AsActual();
this.Page = page.AsActual();
this.RequestChannel = requestChannel;
this.AllQueryString = new NameValueCollection(httpContext.Request.QueryString);
HttpContextBase pageContext = new PageHttpContenxt(httpContext, new PageHttpRequest(httpContext.Request, "~/" + pageRequestUrl, ""));
var routeData = page.Route.ToMvcRoute().GetRouteData(pageContext);
if (routeData != null)
{
RouteValues = routeData.Values;
//Combine page parameters to [QueryString].
foreach (var item in RouteValues)
{
if (item.Value != null)
{
AllQueryString[item.Key] = item.Value.ToString();
}
}
}
var moduleUrl = AllQueryString[ModuleUrlSegment];
ModuleUrlContext = new ModuleUrlContext(this, moduleUrl);
}
示例3: Preview
public static IHtmlString Preview(UrlHelper urlHelper, Site site, Page page, object values)
{
if (page != null)
{
page = page.AsActual();
}
var pageUrl = urlHelper.Content("~/");
if (page != null && !page.IsDefault)
{
pageUrl = urlHelper.Content("~/" + page.VirtualPath);
}
var previewUrl = FrontUrlHelper.WrapperUrl(pageUrl, site, FrontRequestChannel.Unknown).ToString();
if (values != null)
{
RouteValueDictionary routeValues = new RouteValueDictionary(values);
foreach (var item in routeValues)
{
if (item.Value != null)
{
previewUrl = Kooboo.Web.Url.UrlUtility.AddQueryParam(previewUrl, item.Key, item.Value.ToString());
}
}
}
return new HtmlString(previewUrl);
}
示例4: PageRequestContext
/// <summary>
/// Initializes a new instance of the <see cref="PageRequestContext" /> class.
/// </summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="rawSite">The raw.</param>
/// <param name="site">The site.</param>
/// <param name="page">The page.</param>
/// <param name="requestChannel">The request channel.</param>
/// <param name="pageRequestUrl">The page request url with out page virtual path.</param>
public PageRequestContext(ControllerContext controllerContext, Site rawSite, Site site, Page rawPage, Page page, FrontRequestChannel requestChannel, string pageRequestUrl)
{
RouteValues = new RouteValueDictionary();
this.ControllerContext = controllerContext;
var httpContext = HttpContext.Current;
this.RawSite = rawSite;
this.RawPage = rawPage;
this.Site = site.AsActual();
this.Page = page.AsActual();
this.RequestChannel = requestChannel;
this.AllQueryString = new NameValueCollection();
var queryString = httpContext.Request.QueryString;
foreach (var key in queryString.AllKeys)
{
var value = queryString[key];
if (!string.IsNullOrEmpty(value))
{
AllQueryString[HttpUtility.HtmlEncode(key)] = HttpUtility.HtmlEncode(value);
}
else
{
AllQueryString[HttpUtility.HtmlEncode(key)] = value;
}
}
HttpContextBase pageContext = new PageHttpContenxt(httpContext, new PageHttpRequest(httpContext.Request, "~/" + pageRequestUrl, ""));
var routeData = page.Route.ToMvcRoute().GetRouteData(pageContext);
if (routeData != null)
{
RouteValues = routeData.Values;
//Combine page parameters to [QueryString].
foreach (var item in RouteValues)
{
if (item.Value != null)
{
AllQueryString[item.Key] = item.Value.ToString();
}
}
}
var moduleUrl = AllQueryString[ModuleUrlContext.ModuleUrlSegment];
ModuleUrlContext = new ModuleUrlContext(this, moduleUrl);
}
示例5: PublishPage
public virtual void PublishPage(string[] docs, bool localPublish, bool remotePublish, bool publishSchedule, bool publishDraft, string[] remoteEndpoints, DateTime? publishDate, DateTime? unpublishDate, string userName)
{
foreach (string uuid in docs)
{
if (localPublish)
{
if (publishSchedule)
{
var queue = new LocalPublishingQueue()
{
ObjectUUID = uuid,
ObjectTitle=uuid,
UserId = userName,
SiteName = Site.Current.Name,
UtcCreationDate = DateTime.UtcNow,
PublishingObject = PublishingObject.Page,
PublishDraft = publishDraft,
Status = QueueStatus.Pending
};
if (publishDate.HasValue)
{
queue.UtcTimeToPublish = publishDate.Value.ToUniversalTime();
}
if (unpublishDate.HasValue)
{
queue.UtcTimeToUnpublish = unpublishDate.Value.ToUniversalTime();
}
this._localPublishingQueueManager.Add(queue);
}
else
{
var page = new Page(Site.Current, uuid);
page = page.AsActual();
_pageManager.Publish(page, publishDraft, userName);
_publishingLogProvider.Add(new PublishingLog()
{
QueueType = QueueType.Local,
SiteName = Site.Current.Name,
PublishingObject = PublishingObject.Page,
ObjectUUID = uuid,
ObjectTitle = uuid,
PublishingAction = PublishingAction.Publish,
UserId = userName,
PublishDraft = publishDraft,
Status = QueueStatus.OK,
UtcProcessedTime = DateTime.UtcNow
});
}
}
if (remotePublish)
{
foreach (var endpoint in remoteEndpoints)
{
var queue = new RemotePublishingQueue()
{
ObjectUUID = uuid,
ObjectTitle = uuid,
PublishingObject = PublishingObject.Page,
SiteName = Site.Current.Name,
UserId = userName,
RemoteEndpoint = endpoint,
UtcCreationDate = DateTime.UtcNow,
PublishDraft = publishDraft,
Status = QueueStatus.Pending
};
if (publishSchedule)
{
if (publishDate.HasValue)
{
queue.UtcTimeToPublish = publishDate.Value.ToUniversalTime();
}
if (unpublishDate.HasValue)
{
queue.UtcTimeToUnpublish = unpublishDate.Value.ToUniversalTime();
}
}
else
{
queue.UtcTimeToPublish = DateTime.UtcNow;
}
this._remotePublishingQueueManager.Add(queue);
}
}
}
}
示例6: GetViewsInPage
private IEnumerable<Models.View> GetViewsInPage(Site site, Page page)
{
var viewPositions = page.AsActual().PagePositions.Where(it => it is ViewPosition).OrderBy(it => it.Order);
foreach (ViewPosition viewPosition in viewPositions)
{
var view = new Models.View(site, viewPosition.ViewName).LastVersion();
if (!view.Exists())
{
throw new KoobooException(string.Format("The view '{0}' does not exists.Name.", view.Name));
}
yield return view;
}
}
示例7: FindPage
private static Page FindPage(Page page, string viewName)
{
var actualPage = page.AsActual();
if (actualPage != null && actualPage.PagePositions.Where(it => it is ViewPosition && ((ViewPosition)it).ViewName.EqualsOrNullEmpty(viewName, StringComparison.CurrentCultureIgnoreCase)).Count() > 0)
{
return actualPage;
}
var childPages = Persistence.Providers.PageProvider.ChildPages(page);
foreach (var child in childPages)
{
var result = FindPage(child, viewName);
if (result != null)
{
return result;
}
}
return null;
}