public void ApplyTemplateAllNodesInSite(Template template, Site site)
 {
     ISession session = this._sessionManager.OpenSession();
     string sql = "UPDATE cuyahoga_node  SET templateid = :Template  WHERE (siteid = :Site)";
     ISQLQuery SQLQuery = session.CreateSQLQuery(sql);
     SQLQuery.SetInt32("Template", template.Id);
     SQLQuery.SetInt32("Site", site.Id);
     SQLQuery.ExecuteUpdate();
 }
 public void AttachSectionToTemplate(Section section, Template template, string placeholder)
 {
     // First test if the section is already attached. If so, remove.
     if (template.Sections.Any(s => s.Value == section))
     {
         RemoveSectionFromTemplate(section, template);
     }
     // Add the section to the template
     template.Sections.Add(placeholder, section);
     this._commonDao.UpdateObject(template);
     // Invalidate cache
     this._commonDao.RemoveCollectionFromCache("Cuyahoga.Core.Domain.Template.Sections", section.Id);
 }
Exemplo n.º 3
0
 public ActionResult Create()
 {
     Template template = new Template();
     try
     {
         template.Site = CuyahogaContext.CurrentSite;
         if (TryUpdateModel(template, new[] { "Name", "BasePath", "TemplateControl", "Css" }) && ValidateModel(template))
         {
             this._templateService.SaveTemplate(template);
             Messages.AddMessageWithParams("TemplateCreatedMessage", template.Name);
             return RedirectToAction("Index");
         }
     }
     catch (Exception ex)
     {
         Messages.AddException(ex);
     }
     return RenderNewTemplateView(template);
 }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            this.Title = "Attach Section to Template Placeholder";
            if (Context.Request.QueryString["TemplateId"] != null
                && Context.Request.QueryString["Placeholder"] != null)
            {
                this._activeTemplate = TemplateService.GetTemplateById(Int32.Parse(Context.Request.QueryString["TemplateId"]));
                this._activePlaceholder = Context.Request.QueryString["Placeholder"];

                if (!this.IsPostBack)
                {
                    BindTemplateControls();
                    BindSections();
                }
            }
            else
            {
                ShowError("Passed invalid template or placeholder");
            }
        }
Exemplo n.º 5
0
 public ActionResult New()
 {
     Template template = new Template();
     return RenderNewTemplateView(template);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Retrieve a list of Nodes that are connected to a given template.
 /// </summary>
 /// <param name="template"></param>
 /// <returns></returns>
 public virtual IList GetNodesByTemplate(Template template)
 {
     string hql = "from Node n where n.Template.Id = :templateId ";
     IQuery q = this._activeSession.CreateQuery(hql);
     q.SetInt32("templateId", template.Id);
     return q.List();
 }
Exemplo n.º 7
0
 private TemplateViewData BuildTemplateViewData(Template template)
 {
     string siteDataDir = CuyahogaContext.CurrentSite.SiteDataDirectory;
     string absoluteBasePath = VirtualPathUtility.Combine(siteDataDir, template.BasePath) + "/";
     string htmlContent = ViewUtil.RenderTemplateHtml(VirtualPathUtility.Combine(absoluteBasePath, template.TemplateControl));
     string cssContent = GetCssContent(absoluteBasePath + "Css/" + template.Css);
     TemplateViewData templateViewData = new TemplateViewData(template, htmlContent, cssContent);
     templateViewData.PrepareTemplateDataForEmbedding(Url.Content(CuyahogaContext.CurrentSite.SiteDataDirectory));
     return templateViewData;
 }
Exemplo n.º 8
0
        private void Page_Load(object sender, EventArgs e)
        {
            this.Title = "Edit template";

            if (Context.Request.QueryString["TemplateId"] != null)
            {
                if (Int32.Parse(Context.Request.QueryString["TemplateId"]) == -1)
                {
                    this._activeTemplate = new Template();
                }
                else
                {
                    this._activeTemplate = (Template)base.CoreRepository.GetObjectById(typeof(Template)
                        , Int32.Parse(Context.Request.QueryString["TemplateId"]));
                    this.pnlPlaceholders.Visible = true;
                }

                if (! this.IsPostBack)
                {
                    BindTemplateControls();
                    BindTemplateUserControls();
                    BindCss();
                    if (this._activeTemplate.Id != -1)
                    {
                        BindPlaceholders();
                    }
                }
            }
        }
 public void RemoveSectionFromTemplate(Section section, Template template)
 {
     string placeholder = template.Sections.Where(s => s.Value == section).Select(s => s.Key).SingleOrDefault();
     if (placeholder != null)
     {
         template.Sections.Remove(placeholder);
         this._commonDao.UpdateObject(template);
         // Invalidate cache
         this._commonDao.RemoveCollectionFromCache("Cuyahoga.Core.Domain.Template.Sections", section.Id);
     }
 }
Exemplo n.º 10
0
        private void BindTemplates()
        {
            IList templates = this._templateService.GetAllTemplates();
            // Insert option for no template
            Template emptyTemplate = new Template();
            emptyTemplate.Id = -1;
            emptyTemplate.Name = "No template";
            templates.Insert(0, emptyTemplate);

            // Bind
            this.ddlTemplates.DataSource = templates;
            this.ddlTemplates.DataValueField = "Id";
            this.ddlTemplates.DataTextField = "Name";
            this.ddlTemplates.DataBind();
            if (this._activeSite.DefaultTemplate != null)
            {
                ddlTemplates.Items.FindByValue(this._activeSite.DefaultTemplate.Id.ToString()).Selected = true;
                BindPlaceholders();
            }
            this.ddlTemplates.Visible = true;
            ddlOfflinePageTemplate.DataSource = templates;
            ddlOfflinePageTemplate.DataValueField = "Id";
            ddlOfflinePageTemplate.DataTextField = "Name";
            ddlOfflinePageTemplate.DataBind();
            if (_activeSite.OfflineTemplate != null)
            {
                ddlOfflinePageTemplate.Items.FindByValue(_activeSite.OfflineTemplate.Id.ToString()).Selected = true;
            }
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "Edit template";

            if (Context.Request.QueryString["TemplateId"] != null)
            {
                int templateid = Int32.Parse(Context.Request.QueryString["TemplateId"]);
                if (templateid == -1)
                {
                    this._activeTemplate = new Template();
                    this.pnlNoPlaceholders.Visible = true;
                }
                else
                {
                    this._activeTemplate = this.TemplateService.GetTemplateById(templateid);
                    this.pnlPlaceholders.Visible = true;
                    this.pnlNoPlaceholders.Visible = false;
                }

                if (!Page.IsPostBack)
                {
                    BindTemplateControls();
                    BindTemplateUserControls();
                    BindCss();

                    if (this._activeTemplate.Id != -1)
                    {
                        BindPlaceholders();
                    }

                    //Custom Added
                    BindSites();
                }

                //Custom Added
                //TO DO: Add messages to localised resources
                btnCopyToSite.Visible = (this.ActiveSite != null && this._activeTemplate.Id > 0);
                ddlSites.Enabled = (this._activeTemplate.Id > 0);
                if (this.ActiveSite != null)
                {
                    litMessages.Text = "Uploads to: " + this.ActiveSite.Name + "'s tempates folder.";
                }
                else
                {
                    litMessages.Text = "Uploads to shared templates folder. Select a specific site to upload to its folder.";
                }
            }
        }
Exemplo n.º 12
0
 public TemplateViewData(Template template, string templateHtml, string _templateCss)
 {
     _template = template;
     this._templateCss = _templateCss;
     _templateHtml = templateHtml;
 }
 public void DeleteTemplate(Template template)
 {
     this._commonDao.DeleteObject(template);
 }
 public void SaveTemplate(Template template)
 {
     this._commonDao.SaveOrUpdateObject(template);
 }
Exemplo n.º 15
0
        private ActionResult RenderNewTemplateView(Template template)
        {
            string siteDataDir = CuyahogaContext.CurrentSite.SiteDataDirectory;
            var basePaths = (	from directory in this._fileService.GetSubDirectories(Server.MapPath(VirtualPathUtility.Combine(siteDataDir, "Templates")))
                             	select "Templates/" + directory
                            ).ToArray();
            if (basePaths.Length == 0)
            {
                throw new Exception("Can't register a new template when there are no template directories on the server.");
            }
            string relativeBasePath = template.BasePath ?? basePaths[0];
            ViewData["BasePaths"] = new SelectList(basePaths, relativeBasePath);

            SetupTemplateControlAndCssLists(template, relativeBasePath);

            return View("NewTemplate", template);
        }
Exemplo n.º 16
0
 private void SetupTemplateControlAndCssLists(Template template, string relativeBasePath)
 {
     string siteDataDir = CuyahogaContext.CurrentSite.SiteDataDirectory;
     string absoluteBasePath = VirtualPathUtility.Combine(siteDataDir, relativeBasePath);
     string[] templateControls = this._fileService.GetFiles(Server.MapPath(absoluteBasePath));
     ViewData["TemplateControls"] = new SelectList(templateControls, template.TemplateControl);
     string absoluteCssPath = absoluteBasePath + "/Css";
     string[] cssFiles = this._fileService.GetFiles(Server.MapPath(absoluteCssPath));
     ViewData["CssFiles"] = new SelectList(cssFiles, template.Css);
 }
 public override IList GetNodesByTemplate(Template template)
 {
     return this._siteStructureDao.GetNodesByTemplate(template);
 }
Exemplo n.º 18
0
 private void InitNode()
 {
     this._shortDescription = null;
     this._parentNode = null;
     this._template = null;
     this._childNodes = null;
     this._sections = null;
     this._position = -1;
     this._trail = null;
     this._showInNavigation = true;
     this._sections = new ArrayList();
     this._nodePermissions = new ArrayList();
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            this.Title = "Attach Section to Template Placeholder";
            if (Context.Request.QueryString["TemplateId"] != null
                && Context.Request.QueryString["Placeholder"] != null)
            {
                this._activeTemplate = (Template)base.CoreRepository.GetObjectById(typeof(Template)
                    , Int32.Parse(Context.Request.QueryString["TemplateId"]));
                this._activePlaceholder = Context.Request.QueryString["Placeholder"];

                if (! this.IsPostBack)
                {
                    BindTemplateControls();
                    BindSections();
                }
            }
            else
            {
                ShowError("Passed invalid template or placeholder");
            }
        }
Exemplo n.º 20
0
        public IList GetNodesByTemplate(Template template)
        {
            ISession session = this._sessionManager.OpenSession();

            string hql = "from Node n where n.Template.Id = :templateId ";
            IQuery q = session.CreateQuery(hql);
            q.SetInt32("templateId", template.Id);
            return q.List();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Get a clean copy of this template.
        /// </summary>
        /// <returns></returns>
        public virtual Template GetCopy()
        {
            Template newTemplate = new Template();
            newTemplate.Name = this.Name;
            newTemplate.BasePath = this.BasePath;
            newTemplate.TemplateControl = this.TemplateControl;
            newTemplate.Css = this.Css;

            return newTemplate;
        }