コード例 #1
0
ファイル: Template.cs プロジェクト: jraghu24/Rraghu
        private static Template MakeNew(string name, BusinessLogic.User u, Template master, string design)
        {
            // CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
            CMSNode n = CMSNode.MakeNew(-1, _objectType, u.Id, 1, name, Guid.NewGuid());

            //ensure unique alias
            name = helpers.Casing.SafeAlias(name);
            if (GetByAlias(name) != null)
            {
                name = EnsureUniqueAlias(name, 1);
            }
            name = name.Replace("/", ".").Replace("\\", "");

            if (name.Length > 100)
            {
                name = name.Substring(0, 95) + "...";
            }


            SqlHelper.ExecuteNonQuery("INSERT INTO cmsTemplate (NodeId, Alias, design, master) VALUES (@nodeId, @alias, @design, @master)",
                                      SqlHelper.CreateParameter("@nodeId", n.Id),
                                      SqlHelper.CreateParameter("@alias", name),
                                      SqlHelper.CreateParameter("@design", ' '),
                                      SqlHelper.CreateParameter("@master", DBNull.Value));

            Template     t = new Template(n.Id);
            NewEventArgs e = new NewEventArgs();

            t.OnNew(e);

            if (master != null)
            {
                t.MasterTemplate = master.Id;
            }

            switch (DetermineRenderingEngine(t, design))
            {
            case RenderingEngine.Mvc:
                ViewHelper.CreateViewFile(t, true);
                break;

            case RenderingEngine.WebForms:
                MasterPageHelper.CreateMasterPage(t, true);
                break;
            }

            //if a design is supplied ensure it is updated.
            if (!design.IsNullOrWhiteSpace())
            {
                t.ImportDesign(design);
            }

            return(t);
        }
コード例 #2
0
        public static Template Import(XmlNode n, User u)
        {
            string alias = xmlHelper.GetNodeValue(n.SelectSingleNode("Alias"));

            Template t = Template.GetByAlias(alias);

            if (t == null)
            {
                t = MakeNew(xmlHelper.GetNodeValue(n.SelectSingleNode("Name")), u);
            }

            t.Alias = alias;

            t.ImportDesign(xmlHelper.GetNodeValue(n.SelectSingleNode("Design")));

            return(t);
        }
コード例 #3
0
ファイル: Template.cs プロジェクト: rickliveshere/Umbraco-CMS
        private static Template MakeNew(string name, BusinessLogic.User u, Template master, string design)
        {

            // CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
            CMSNode n = CMSNode.MakeNew(-1, _objectType, u.Id, 1, name, Guid.NewGuid());

            //ensure unique alias 
            name = helpers.Casing.SafeAlias(name);
            if (GetByAlias(name) != null)
                name = EnsureUniqueAlias(name, 1);
            name = name.Replace("/", ".").Replace("\\", "");

            if (name.Length > 100)
                name = name.Substring(0, 95) + "...";

          
            SqlHelper.ExecuteNonQuery("INSERT INTO cmsTemplate (NodeId, Alias, design, master) VALUES (@nodeId, @alias, @design, @master)",
                                      SqlHelper.CreateParameter("@nodeId", n.Id),
                                      SqlHelper.CreateParameter("@alias", name),
                                      SqlHelper.CreateParameter("@design", ' '),
                                      SqlHelper.CreateParameter("@master", DBNull.Value));

            Template t = new Template(n.Id);
            NewEventArgs e = new NewEventArgs();
            t.OnNew(e);

            if (master != null)
                t.MasterTemplate = master.Id;

			switch (DetermineRenderingEngine(t, design))
			{
				case RenderingEngine.Mvc:
					ViewHelper.CreateViewFile(t);
					break;
				case RenderingEngine.WebForms:
					MasterPageHelper.CreateMasterPage(t);
					break;
			}

			//if a design is supplied ensure it is updated.
			if (!design.IsNullOrWhiteSpace())
			{
				t.ImportDesign(design);
			}

            return t;
        }