public void TestPhysicalPath() { string templateName = "template1"; var site = new Site("Site1"); var template = new Layout(site, templateName); string expected1 = Path.Combine(site.PhysicalPath, "templates", "layouts", templateName); Assert.AreEqual(expected1, template.PhysicalPath, true); string expected2 = Path.Combine(expected1, "template.aspx"); Assert.AreEqual(expected2, template.PhysicalTemplateFileName, true); }
public void TestVirtualPath() { string templateName = "template1"; var site = new Site("Site1"); var template = new Layout(site, templateName); string expected1 = Kooboo.Web.Url.UrlUtility.Combine(site.VirtualPath, "templates", "layouts", templateName); Assert.AreEqual(expected1, template.VirtualPath, true); string expected2 = Kooboo.Web.Url.UrlUtility.Combine(expected1, "template.aspx"); Assert.AreEqual(expected2, template.TemplateFileVirutalPath, true); }
public void TestParseFromPhysicalPath() { string siteName = "site1"; string templateName = "template1"; string physicalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sites", siteName, "templates", "layouts", templateName); var template = new Layout(physicalPath); Assert.AreEqual(templateName, template.Name); Assert.IsTrue(template.IsDummy); Assert.IsTrue(template.Site.IsDummy); Assert.AreEqual(siteName, template.Site.Name); }
public virtual ActionResult ExecutePlugins() { // Execute plugins on page var page = PageRequestContext.Page.AsActual(); var httpMethod = this.ControllerContext.HttpContext.Request.HttpMethod.ToUpper(); if (page.Plugins != null) { foreach (var plugin in page.Plugins) { var result = ExecutePlugin(plugin, null, httpMethod); if (result != null) { return result; } } } if (!string.IsNullOrEmpty(this.PageLayout)) { // Execute plugins on Layout var layout = new Layout(this.PageRequestContext.Site, this.PageLayout).LastVersion().AsActual(); if (layout != null && layout.Plugins != null) { foreach (var plugin in layout.Plugins) { var result = ExecutePlugin(plugin, null, httpMethod); if (result != null) { return result; } } } } // Execute plugins on views var viewPositions = page.PagePositions.Where(it => it is ViewPosition).OrderBy(it => it.Order); foreach (ViewPosition viewPosition in viewPositions) { var view = new Models.View(PageRequestContext.Site, viewPosition.ViewName).LastVersion().AsActual(); if (view != null) { if (view.Plugins != null) { var positionContext = new PagePositionContext(view, viewPosition.ToParameterDictionary(), GetPositionViewData(viewPosition.PagePositionId)); foreach (var plugin in view.Plugins) { var result = ExecutePlugin(plugin, positionContext, httpMethod); if (result != null) { return result; } } } } } return null; }
private static IEnumerable<TabInfo> LayoutTabs(Site site, string layoutName) { var layout = new Layout(site, layoutName); string tabPath = Path.Combine(layout.PhysicalPath, PageTabsDir); return GetTabs(tabPath); }