Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
 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);
 }