Наследование: SenseNet.ContentRepository.File
Пример #1
0
        public void PageTemplate_Constructor()
        {
            Node parent = Repository.Root;

            PageTemplate target = new PageTemplate(parent);

            Assert.IsNotNull(target, "PageTemplate is null.");

        }
Пример #2
0
		public void PageTemplateManager_GetFileNameWithoutExt_Test()
		{
			object target = SenseNet.ContentRepository.Tests.SenseNet_Portal_PageTemplateManagerAccessor.CreatePrivate();
			SenseNet.ContentRepository.Tests.SenseNet_Portal_PageTemplateManagerAccessor accessor = new SenseNet.ContentRepository.Tests.SenseNet_Portal_PageTemplateManagerAccessor(target);

			string expected = "word";

			PageTemplate pageTemplate = new PageTemplate(this.TestRoot);
			pageTemplate.Name = "word.doc";
			accessor.PageTemplateNode = pageTemplate;
			string actual = accessor.GetFileNameWithoutExt();

			Assert.AreEqual(expected, actual, "PageTemplateManager.GetFileNameWithoutExt did not return the expected value.");
		}
Пример #3
0
		public void PageTemplateManager_CheckPageTemplateBinaryStream_NullBinaryTest()
		{
			PageTemplate pageTemplate = new PageTemplate(this.TestRoot);

			bool expected = false;
			bool actual = SenseNet.ContentRepository.Tests.SenseNet_Portal_PageTemplateManagerAccessor.CheckPageTemplateBinaryStream(pageTemplate);

			Assert.AreEqual(expected, actual, "PageTemplateManager.CheckPageTemplateBinaryStream did not return the expected value.");
		}
Пример #4
0
		public void PageTemplateManager_CheckPageTemplateBinaryStream_Test()
		{
			PageTemplate pageTemplate = new PageTemplate(this.TestRoot);
			BinaryData binaryData = new BinaryData();
			string streamData = "TestString";
			binaryData.SetStream(Tools.GetStreamFromString(streamData));
			pageTemplate.Binary = binaryData;

			bool expected = true;
			bool actual = SenseNet.ContentRepository.Tests.SenseNet_Portal_PageTemplateManagerAccessor.CheckPageTemplateBinaryStream(pageTemplate);

			Assert.AreEqual(expected, actual, "PageTemplateManager.CheckPageTemplateBinaryStream did not return the expected value.");
		}
Пример #5
0
		private PageTemplate CreatePageTemplate(string zoneName, string parentPath)
		{
            var folderpath = parentPath ?? this.TestRoot.Path;

			PageTemplate pageTemplate = null;
            pageTemplate = Node.LoadNode(string.Concat(folderpath, "/TestPageTemplate.html")) as PageTemplate;
			if (pageTemplate == null)
			{
                var parent = Node.LoadNode(folderpath);
                pageTemplate = new PageTemplate(parent);
				pageTemplate.Name = "TestPageTemplate.html";
			}
			
			BinaryData binaryData = new BinaryData();
			binaryData.FileName = new BinaryFileName("TestPageTemplate.html");
			string streamString = string.Concat(
										"<html>",
										"	<body>",
										"		<snpe-zone name=\"ZoneName_", zoneName, "\"></snpe-zone>",
										"		<snpe-edit name=\"Editor\"></snpe-edit>",
										"		<snpe-catalog name=\"Catalog\"></snpe-catalog>",
										"		<snpe:PortalRemoteControl2 ID=\"RemoteControl1\" runat=\"server\" />",
										"	</body>",
										"</html>"
									);
			Stream stream = Tools.GetStreamFromString(streamString);
			binaryData.SetStream(stream);

			pageTemplate.Binary = binaryData;
			pageTemplate.Save();

			return pageTemplate;
		}
Пример #6
0
        public static BinaryData GetPageBinaryData(Page page, PageTemplate pageTemplate)
        {
            PageTemplateManager pageTemplateManager = new PageTemplateManager();

            return(pageTemplateManager.GetASPXBinaryByPageTemplate(page, pageTemplate));
        }
Пример #7
0
 private static bool CheckPageTemplateBinaryStream(PageTemplate pageTemplate)
 {
     return(pageTemplate != null && pageTemplate.Binary != null && pageTemplate.Binary.GetStream() != null);
 }
Пример #8
0
		private static void CreateTestPageTemplate()
		{
			PageTemplate pt = null;

			pt = new PageTemplate(Node.LoadNode(_rootNodePath));
			pt.Name = _testPageTemplateName;
			BinaryData binaryData = new BinaryData();
			binaryData.FileName = new BinaryFileName(_testPageTemplateName);
			string streamString = _pageTemplateHtml;

			Stream stream = Tools.GetStreamFromString(streamString);
			binaryData.SetStream(stream);

			pt.Binary = binaryData;
			pt.Save();

			_pageTemplatePath = pt.Path;
		}
Пример #9
0
        public void GenericContent_KeepReferenceAfterUndocheckout()
        {
            //create page template
            PageTemplate samplePageTemplate = new PageTemplate(TestRoot);
            samplePageTemplate.Name = "Sample Page Template";
            samplePageTemplate.Binary = CreateBinaryDataFromString("<html><head></head><body></body></html>");
            samplePageTemplate.Save();

            Page samplePage = new Page(TestRoot);

            samplePage.Name = "SamplePage";

            //set reference
            samplePage.PageTemplateNode = samplePageTemplate;

            samplePage.Save();
            samplePage.CheckOut();
            samplePage.UndoCheckOut();

            //asserts
            CheckPageTemplateInPage(samplePage, samplePageTemplate.Id);

        }
Пример #10
0
		public static BinaryData GetPageBinaryData(Page page, PageTemplate pageTemplate)
		{
			PageTemplateManager pageTemplateManager = new PageTemplateManager();
			return pageTemplateManager.GetASPXBinaryByPageTemplate(page, pageTemplate);	
		}
Пример #11
0
		public BinaryData GetASPXBinaryByPageTemplate(Page page, PageTemplate pageTemplate)
		{
			if (page == null)
			{
				throw new ArgumentNullException("page");
			}

			if (pageTemplate == null)
			{
				throw new ArgumentNullException("pageTemplate");
			}

			BinaryData binaryData = new BinaryData();
            if (page.Binary != null)
            {
				binaryData = page.Binary;
			}

			string pageTmp = Tools.GetStreamString(pageTemplate.Binary.GetStream());
			IList<object> fragments = SplitPageTemplate(pageTmp);
			StringBuilder aspx = new StringBuilder();

            //MasterPage is inside the PageTemplates folder.
            aspx.AppendFormat(ASPXHEADER, string.Concat("/", GetFileNameWithoutExt(pageTemplate.Name), MASTER), Repository.PageTemplatesFolderPath);
			for (int i = 0; i < fragments.Count; i++)
			{
				if (fragments[i] is PageZone)
				{
					PageZone zone = fragments[i] as PageZone;
					aspx.AppendFormat(WEBPARTZONE, zone.Name, zone.InnerText, zone.AttrListText);
				}
			}

			binaryData.SetStream(Tools.GetStreamFromString(aspx.ToString()));
			binaryData.FileName = new BinaryFileName (ASPX);
			binaryData.ContentType = ASPXCONTENTTYPE;

			return binaryData;
		}
Пример #12
0
		private static bool CheckPageTemplateBinaryStream(PageTemplate pageTemplate)
		{
			return pageTemplate != null && pageTemplate.Binary != null && pageTemplate.Binary.GetStream() != null;
		}
Пример #13
0
		private PageTemplate CreatePageTemplate(string name)
		{
			PageTemplate pageTemplate = Node.LoadNode(string.Concat(this.TestRoot.Path, "/", name)) as PageTemplate;
			if (pageTemplate == null)
			{
				pageTemplate = new PageTemplate(this.TestRoot);
				pageTemplate.Name = name;
				pageTemplate.Binary = CreateBinaryFromString("TestPageTemplateVersion.bnr", "<html><body></body></html>");
				pageTemplate.Save();
			}
			return pageTemplate;
		}
Пример #14
0
        public void PageTemplate_SetMasterPageNode()
        {
            Node parent = Repository.Root;

            MasterPage target = new MasterPage(parent);
			target.Save();

            PageTemplate val = new PageTemplate(parent);

            val.MasterPageNode = target;

            Assert.IsNotNull(val.MasterPageNode, "#1");
            Assert.AreNotEqual(target, val.MasterPageNode, "#2"); // reference not equal because property getter returns a new instance.
            Assert.AreEqual(target.VersionId, val.MasterPageNode.VersionId, "#3");
        }