public ActionResult Update(int id, int defaultRoleId, int defaultTemplateId) { Site site = this._siteService.GetSiteById(id); try { UpdateModel(site, new [] { "Name", "SiteUrl", "WebmasterEmail", "UserFriendlyUrls", "DefaultCulture", "DefaultPlaceholder", "MetaDescription", "MetaKeywords" }); site.DefaultRole = this._userService.GetRoleById(defaultRoleId); site.DefaultTemplate = this._templateService.GetTemplateById(defaultTemplateId); if (ValidateModel(site)) { this._siteService.SaveSite(site); Messages.AddMessage("SiteUpdatedMessage"); RedirectToAction("Index"); } } catch (Exception ex) { Messages.AddException(ex); } ViewData["Roles"] = new SelectList(this._userService.GetAllGlobalRoles(), "Id", "Name", site.DefaultRole.Id); ViewData["Cultures"] = new SelectList(Globalization.GetOrderedCultures(), "Key", "Value", site.DefaultCulture); ViewData["Templates"] = new SelectList(site.Templates, "Id", "Name", site.DefaultTemplate != null ? site.DefaultTemplate.Id : 0); if (site.DefaultTemplate != null) { string virtualTemplatePath = VirtualPathUtility.Combine(site.SiteDataDirectory, site.DefaultTemplate.Path); ViewData["PlaceHolders"] = new SelectList(ViewUtil.GetPlaceholdersFromVirtualPath(virtualTemplatePath).Keys, site.DefaultPlaceholder); } return(View("EditSite", site)); }
public ActionResult GetPlaceholdersByTemplateId(int templateId) { Template template = this._templateService.GetTemplateById(templateId); string virtualTemplatePath = VirtualPathUtility.Combine(CuyahogaContext.CurrentSite.SiteDataDirectory, template.Path); var placeholders = ViewUtil.GetPlaceholdersFromVirtualPath(virtualTemplatePath); var jsonValues = from key in placeholders.Keys select new { Placeholder = key }; return(Json(jsonValues)); }
public ActionResult Index() { Site currentSite = CuyahogaContext.CurrentSite; ViewData["Roles"] = new SelectList(this._userService.GetAllGlobalRoles(), "Id", "Name", currentSite.DefaultRole.Id); ViewData["Cultures"] = new SelectList(Globalization.GetOrderedCultures(), "Key", "Value", currentSite.DefaultCulture); ViewData["Templates"] = new SelectList(currentSite.Templates, "Id", "Name", currentSite.DefaultTemplate != null ? currentSite.DefaultTemplate.Id : 0); if (currentSite.DefaultTemplate != null) { string virtualTemplatePath = VirtualPathUtility.Combine(currentSite.SiteDataDirectory, currentSite.DefaultTemplate.Path); ViewData["PlaceHolders"] = new SelectList(ViewUtil.GetPlaceholdersFromVirtualPath(virtualTemplatePath).Keys, currentSite.DefaultPlaceholder); } return(View("EditSite", currentSite)); }
public ActionResult AttachSectionToTemplate(int id) { var model = new AttachSectionTemplateViewData(); model.Section = this._sectionService.GetSectionById(id); model.Templates = this._templateService.GetAllTemplatesBySite(CuyahogaContext.CurrentSite); foreach (var template in model.Templates) { // read placeholders string virtualTemplatePath = VirtualPathUtility.Combine(CuyahogaContext.CurrentSite.SiteDataDirectory, template.Path); model.PlaceHoldersByTemplate[template] = ViewUtil.GetPlaceholdersFromVirtualPath(virtualTemplatePath).Select(p => p.Key).ToArray(); // add sectiontemplate viewdata var sectionTemplate = new SectionTemplateViewData(); sectionTemplate.TemplateId = template.Id; if (template.Sections.Any(s => s.Value == model.Section)) { KeyValuePair <string, Section> templateSection = template.Sections.Where(s => s.Value == model.Section).Single(); sectionTemplate.Placeholder = templateSection.Key; sectionTemplate.IsAttached = true; } model.SectionTemplates.Add(template.Id, sectionTemplate); } return(View(model)); }