• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# template.Template类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中umbraco.cms.businesslogic.template.Template的典型用法代码示例。如果您正苦于以下问题:C# Template类的具体用法?C# Template怎么用?C# Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Template类属于umbraco.cms.businesslogic.template命名空间,在下文中一共展示了Template类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UpdateViewFile

        internal static string UpdateViewFile(Template t, string currentAlias = null)
        {
            var path = IOHelper.MapPath(ViewPath(t.Alias));

			if (string.IsNullOrEmpty(currentAlias) == false && currentAlias != t.Alias)
			{
				//NOTE: I don't think this is needed for MVC, this was ported over from the
				// masterpages helper but I think only relates to when templates are stored in the db.
				////Ensure that child templates have the right master masterpage file name
				//if (t.HasChildren)
				//{
				//	var c = t.Children;
				//	foreach (CMSNode cmn in c)
				//		UpdateViewFile(new Template(cmn.Id), null);
				//}

				//then kill the old file.. 
				var oldFile = IOHelper.MapPath(ViewPath(currentAlias));
				if (File.Exists(oldFile))
					File.Delete(oldFile);
			}

            File.WriteAllText(path, t.Design, Encoding.UTF8);
            return t.Design;
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:25,代码来源:ViewHelper.cs


示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            templateID = int.Parse(Request["id"]);
            Template t = new Template(templateID);

            if (Skinning.StarterKitGuid(templateID).HasValue)
            {
                p_apply.Visible = true;

                string currentSkin = Skinning.GetCurrentSkinAlias(templateID);
                int templateRoot = FindTemplateRoot((CMSNode)t);

                dd_skins.Items.Add("Choose...");
                foreach (KeyValuePair<string,string> kvp in Skinning.AllowedSkins(templateRoot))
                {
                    ListItem li = new ListItem(kvp.Value, kvp.Key);
                    if (kvp.Key == currentSkin)
                        li.Selected = true;

                    dd_skins.Items.Add(li);
                }

                if (!string.IsNullOrEmpty(Skinning.GetCurrentSkinAlias(templateID)))
                {
                    ph_rollback.Visible = true;
                }
            }
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:28,代码来源:TemplateSkinning.aspx.cs


示例3: SaveTemplateToFile

 internal static string SaveTemplateToFile(Template template, string currentAlias)
 {
     var design = EnsureInheritedLayout(template);
     File.WriteAllText(IOHelper.MapPath(ViewPath(template.Alias)), design, Encoding.UTF8);
     
     return template.Design;
 }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:7,代码来源:ViewHelper.cs


示例4: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            _templateId = int.Parse(Request["id"]);
            var t = new Template(_templateId);

            if (Skinning.StarterKitGuid(_templateId).HasValue)
            {
                p_apply.Visible = true;

                var currentSkin = Skinning.GetCurrentSkinAlias(_templateId);
                var templateRoot = FindTemplateRoot(t);

                dd_skins.Items.Add("Choose...");
                foreach (var kvp in Skinning.AllowedSkins(templateRoot))
                {
                    var li = new ListItem(kvp.Value, kvp.Key);
                    if (kvp.Key == currentSkin)
                        li.Selected = true;

                    dd_skins.Items.Add(li);
                }

                if (!string.IsNullOrEmpty(Skinning.GetCurrentSkinAlias(_templateId)))
                {
                    ph_rollback.Visible = true;
                }
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:28,代码来源:TemplateSkinning.aspx.cs


示例5: UpdateMasterPageFile

        internal static string UpdateMasterPageFile(Template t, string currentAlias)
        {
            var template = UpdateMasterPageContent(t, currentAlias);
            UpdateChildTemplates(t, currentAlias);
            SaveDesignToFile(t, currentAlias, template);

            return template;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:8,代码来源:MasterpageHelper.cs


示例6: delete

        public void delete(int id, string username, string password)
        {
            Authenticate(username, password);

            if (id == 0) throw new Exception("ID must be specifed when updating");

            cms.businesslogic.template.Template template = new cms.businesslogic.template.Template(id);
            template.delete();
        }
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:9,代码来源:TemplateService.asmx.cs


示例7: RenderTemplate

        public string RenderTemplate(int id)
        {
            const string urlPattern = "http://{0}/?altTemplate={1}";

            var t = new Template(id);
            var host = HttpContext.Current.Request.Url.Host;
            if (HttpContext.Current.Request.Url.Port != 80) host += ":" + HttpContext.Current.Request.Url.Port;

            var url = string.Format(urlPattern, host, t.Alias);
            return ReadUrl(url);
        }
开发者ID:OlivierAlbertini,项目名称:workflow-for-dot-net,代码行数:11,代码来源:Helper.cs


示例8: GetFileContents

        internal static string GetFileContents(Template t)
        {
            string masterpageContent = "";
			if (File.Exists(GetFilePath(t)))
			{
				System.IO.TextReader tr = new StreamReader(GetFilePath(t));
                masterpageContent = tr.ReadToEnd();
                tr.Close();
            }

            return masterpageContent;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:12,代码来源:MasterpageHelper.cs


示例9: GetDocPath

        private static string GetDocPath(Template item)
        {
            string path = "";
            if (item != null)
            {
                if (item.MasterTemplate != 0)
                {
                    path = GetDocPath(new Template(item.MasterTemplate));
                }

                path = string.Format("{0}//{1}", path, helpers.XmlDoc.ScrubFile(item.Alias));
            }
            return path;
        }
开发者ID:howej,项目名称:jumps.umbraco.usync,代码行数:14,代码来源:SyncTemplate.cs


示例10: GetFileContents

        internal static string GetFileContents(Template t)
        {
            string viewContent = "";
			string path = IOHelper.MapPath(ViewPath(t.Alias));

            if (File.Exists(path))
            {
                TextReader tr = new StreamReader(path);
                viewContent = tr.ReadToEnd();
                tr.Close();
            }

            return viewContent;
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:14,代码来源:ViewHelper.cs


示例11: CreateMasterPage

	    internal static string CreateMasterPage(Template t, bool overWrite = false)
        {
            string masterpageContent = "";

			if (!File.Exists(GetFilePath(t)) || overWrite)
                masterpageContent = SaveTemplateToFile(t, t.Alias);
            else
            {
				System.IO.TextReader tr = new StreamReader(GetFilePath(t));
                masterpageContent = tr.ReadToEnd();
                tr.Close();
            }

            return masterpageContent;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:15,代码来源:MasterpageHelper.cs


示例12: Template

        /// <summary>
        /// Converts an umbraco template to a package xml node
        /// </summary>
        /// <param name="templateId">The template id.</param>
        /// <param name="doc">The xml doc.</param>
        /// <returns></returns>
        public static XmlNode Template(int templateId, XmlDocument doc) {

            Template tmpl = new Template(templateId);

            XmlNode template = doc.CreateElement("Template");
            template.AppendChild(_node("Name", tmpl.Text, doc));
            template.AppendChild(_node("Alias", tmpl.Alias, doc));

            if (tmpl.MasterTemplate != 0) {
                template.AppendChild(_node("Master", new Template(tmpl.MasterTemplate).Alias, doc));
            }
            template.AppendChild(_node("Design", "<![CDATA[" + tmpl.Design + "]]>", doc));

            return template;
        }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:21,代码来源:utill.cs


示例13: CreateViewFile

        internal static string CreateViewFile(Template t, bool overWrite = false)
        {
            string viewContent;
			string path = IOHelper.MapPath(ViewPath(t.Alias));

            if (File.Exists(path) == false || overWrite)
                viewContent = SaveTemplateToFile(t, t.Alias);
            else
            {
                TextReader tr = new StreamReader(path);
                viewContent = tr.ReadToEnd();
                tr.Close();
            }

            return viewContent;
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:16,代码来源:ViewHelper.cs


示例14: SaveToDisk

 public static void SaveToDisk(Template item)
 {
     if (item != null)
     {
         try
         {
             XmlDocument xmlDoc = helpers.XmlDoc.CreateDoc();
             xmlDoc.AppendChild(item.ToXml(xmlDoc));
             helpers.XmlDoc.SaveXmlDoc(
                 item.GetType().ToString(), GetDocPath(item) , "def", xmlDoc);
         }
         catch (Exception ex)
         {
             helpers.uSyncLog.ErrorLog(ex, "uSync: Error Saving Template {0} - {1}", item.Text, ex.ToString());
         }
     }
 }
开发者ID:howej,项目名称:jumps.umbraco.usync,代码行数:17,代码来源:SyncTemplate.cs


示例15: FindModule

        private HtmlNode FindModule(int template, string id, bool remove)
        {
            Template t = new Template(template);
            string TargetFile = t.MasterPageFile;
            string TargetID = id;

            HtmlDocument doc = new HtmlDocument();
            doc.Load(TargetFile);

            if (doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID)) != null)
            {
                if (!remove)
                    return doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID));
                else
                {
                    HtmlNode r = doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID)).Clone();

                    doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID)).RemoveAll();

                    doc.Save(TargetFile);

                    return r;
                }
            }
            else
            {
                if (t.HasMasterTemplate)
                    return FindModule(template,id,remove);
                else
                    return null;
            }
        }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:32,代码来源:SkinModule.cs


示例16: MoveModule

        private bool MoveModule(int template, HtmlNode module, string targetId, int index)
        {
            Template t = new Template(template);

            string TargetFile = t.MasterPageFile;
            string TargetID = targetId;

            HtmlDocument doc = new HtmlDocument();
            doc.Load(TargetFile);

            if (doc.DocumentNode.SelectNodes(string.Format("//*[@id = '{0}']", TargetID)) != null)
            {
                HtmlNode parent = doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID));

                if (index > 0 && parent.ChildNodes.Count > 0)
                {
                    parent.InsertAfter(module, parent.ChildNodes[index - 1]);
                }
                else if (index == 0 && parent.ChildNodes.Count > 0)
                {
                    parent.InsertBefore(module, parent.ChildNodes[0]);
                }
                else
                {
                    parent.AppendChild(module);
                    //parent.ChildNodes.Add(module);
                }

                doc.Save(TargetFile);

                return true;

            }
            else
            {
                //might be on master template
                if (t.HasMasterTemplate)
                    return MoveModule(template, module, targetId,index);
                else
                    return false;
            }
        }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:42,代码来源:SkinModule.cs


示例17: CanInsertModules

        private bool CanInsertModules(int template)
        {
            Template t = new Template(template);

            HtmlDocument doc = new HtmlDocument();
            doc.Load(t.MasterPageFile);

            if (doc.DocumentNode.SelectNodes(string.Format("//*[@class = '{0}']", "umbModuleContainer")) != null)
                return true;
            else
            {
                if (t.HasMasterTemplate)
                    return CanInsertModules(t.MasterTemplate);
                else
                    return false;
            }

        }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:18,代码来源:SkinModule.cs


示例18: SaveTemplate

		public JsonResult SaveTemplate(string templateName, string templateAlias, string templateContents, int templateId, int masterTemplateId)
		{
			Template t;
			try
			{
				t = new Template(templateId)
						{
							Text = templateName,
							Alias = templateAlias,
							MasterTemplate = masterTemplateId,
							Design = templateContents
						};
			}
			catch (ArgumentException ex)
			{
				//the template does not exist
				return Failed("Template does not exist", ui.Text("speechBubbles", "templateErrorHeader"), ex);
			}

			try
			{
				t.Save();

				// Clear cache in rutime
				if (UmbracoSettings.UseDistributedCalls)
					dispatcher.Refresh(new Guid("dd12b6a0-14b9-46e8-8800-c154f74047c8"), t.Id);
				else
					template.ClearCachedTemplate(t.Id);

				return Success(ui.Text("speechBubbles", "templateSavedText"), ui.Text("speechBubbles", "templateSavedHeader"));
			}
			catch (Exception ex)
			{
				return Failed(ui.Text("speechBubbles", "templateErrorText"), ui.Text("speechBubbles", "templateErrorHeader"), ex);
			}
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:36,代码来源:SaveFileController.cs


示例19: GetRoutingContext

		/// <summary>
		/// Return a new RoutingContext
		/// </summary>
		/// <param name="url"></param>
		/// <param name="template"></param>
		/// <param name="routeData"></param>
		/// <returns></returns>
		protected RoutingContext GetRoutingContext(string url, Template template, RouteData routeData = null)
		{
			return GetRoutingContext(url, template.Id, routeData);
		}
开发者ID:elrute,项目名称:Triphulcas,代码行数:11,代码来源:BaseRoutingTest.cs


示例20: SaveMasterPageFile

        public void SaveMasterPageFile(string masterPageContent)
        {
            // Add header to master page if it doesn't exist
            if (!masterPageContent.StartsWith("<%@"))
            {
                masterPageContent = getMasterPageHeader() + "\n" + masterPageContent;
            }
            else
            {
                // verify that the masterpage attribute is the same as the masterpage
                string masterHeader = masterPageContent.Substring(0, masterPageContent.IndexOf("%>") + 2).Trim(Environment.NewLine.ToCharArray());
                // find the masterpagefile attribute
                MatchCollection m = Regex.Matches(masterHeader, "(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"",
                                  RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                foreach (Match attributeSet in m)
                {
                    if (attributeSet.Groups["attributeName"].Value.ToLower() == "masterpagefile")
                    {
                        // validate the masterpagefile
                        string currentMasterPageFile = attributeSet.Groups["attributeValue"].Value;
                        string currentMasterTemplateFile = currentMasterTemplateFileName();
                        if (currentMasterPageFile != currentMasterTemplateFile)
                        {
                            masterPageContent =
                                masterPageContent.Replace(
                                attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterPageFile + "\"",
                                attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterTemplateFile + "\"");

                        }
                    }
                }

            }

            //we have a Old Alias if the alias and therefor the masterpage file name has changed...
            //so before we save the new masterfile, we'll clear the old one, so we don't up with
            //Unused masterpage files
            if (!string.IsNullOrEmpty(_oldAlias) && _oldAlias != _alias)
            {

                //Ensure that child templates have the right master masterpage file name
                if (HasChildren)
                {
                    //store children array here because iterating over an Array property object is very inneficient.
                    var c = Children;
                    foreach (CMSNode cmn in c)
                    {
                        Template t = new Template(cmn.Id);
                        t.SaveAsMasterPage();
                        t.Save();
                    }
                }

                //then kill the old file..
                string _oldFile = IOHelper.MapPath(SystemDirectories.Masterpages + "/" + _oldAlias.Replace(" ", "") + ".master");

                if (System.IO.File.Exists(_oldFile))
                    System.IO.File.Delete(_oldFile);
            }

            // save the file in UTF-8

            File.WriteAllText(MasterPageFile, masterPageContent, System.Text.Encoding.UTF8);
        }
开发者ID:jracabado,项目名称:justEdit-,代码行数:64,代码来源:Template.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# web.Document类代码示例发布时间:2022-05-26
下一篇:
C# member.Member类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap