public ActionResult Create(int defaultRoleId, int[] templateIds) { Site site = new Site(); try { UpdateModel(site, new [] { "Name", "SiteUrl", "WebmasterEmail", "UserFriendlyUrls", "DefaultCulture" }); site.DefaultRole = this._userService.GetRoleById(defaultRoleId); if (ValidateModel(site)) { IList <Template> templates = new List <Template>(); if (templateIds.Length > 0) { templates = this._templateService.GetAllSystemTemplates().Where(t => templateIds.Contains(t.Id)).ToList(); } string systemTemplateDir = Server.MapPath(Config.GetConfiguration()["TemplateDir"]); this._siteService.CreateSite(site, Server.MapPath("~/SiteData"), templates, systemTemplateDir); return(RedirectToAction("CreateSuccess", new { siteId = site.Id })); } } 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"] = this._templateService.GetAllSystemTemplates(); return(View("NewSite", site)); }
public ActionResult New() { ViewData["Roles"] = new SelectList(this._userService.GetAllGlobalRoles(), "Id", "Name"); ViewData["Cultures"] = new SelectList(Globalization.GetOrderedCultures(), "Key", "Value"); ViewData["Templates"] = this._templateService.GetAllSystemTemplates(); return(View("NewSite", new Site())); }
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)); }
private void BindCultures() { ddlCultures.DataSource = Globalization.GetOrderedCultures(); ddlCultures.DataValueField = "Key"; ddlCultures.DataTextField = "Value"; ddlCultures.DataBind(); if (ActiveNode.Culture != null) { ddlCultures.Items.FindByValue(ActiveNode.Culture).Selected = true; } }
private SelectList GetAvailableCultures() { // Get all cultures, but remove the cultures that are already connected to a root node. SortedList availableCultures = Globalization.GetOrderedCultures(); foreach (Node rootNode in CuyahogaContext.CurrentSite.RootNodes) { availableCultures.Remove(rootNode.Culture); } return(new SelectList(availableCultures, "Key", "Value")); }
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 SelectPage(int nodeId) { Node node = this._nodeService.GetNodeById(nodeId); if (node.IsExternalLink) { ViewData["LinkTargets"] = new SelectList(EnumHelper.GetValuesWithDescription <LinkTarget>(), "Key", "Value", (int)node.LinkTarget); return(PartialView("SelectedLink", node)); } else { ViewData["Cultures"] = new SelectList(Globalization.GetOrderedCultures(), "Key", "Value", node.Culture); return(PartialView("SelectedPage", node)); } }
private void BindCultures() { this.ddlCultures.DataSource = Globalization.GetOrderedCultures(); this.ddlCultures.DataValueField = "Key"; this.ddlCultures.DataTextField = "Value"; this.ddlCultures.DataBind(); if (this._activeSite.DefaultCulture != null) { ListItem li = ddlCultures.Items.FindByValue(this._activeSite.DefaultCulture); if (li != null) { ddlCultures.Items.FindByValue(this._activeSite.DefaultCulture).Selected = true; } } }
protected void Page_Load(object sender, EventArgs e) { Title = Resources.titleAdminCurrencies; if (!IsPostBack) { repeaterCurrencies.DataSource = Module.CurrencyGetAll(); repeaterCurrencies.DataBind(); dropDownListCulture.DataSource = Globalization.GetOrderedCultures(); dropDownListCulture.DataValueField = "Key"; dropDownListCulture.DataTextField = "Value"; dropDownListCulture.DataBind(); labelFormTitle.Text = Resources.labelNewCurrency; btnDelete.Visible = false; btnDelete.Enabled = false; } }
public ActionResult Index(int?id) { // The given id is of the active node. if (id.HasValue) { // There is an active node. Add node to ViewData. Node activeNode = this._nodeService.GetNodeById(id.Value); if (activeNode.IsExternalLink) { ViewData["LinkTargets"] = new SelectList(EnumHelper.GetValuesWithDescription <LinkTarget>(), "Key", "Value", (int)activeNode.LinkTarget); } else { ViewData["Cultures"] = new SelectList(Globalization.GetOrderedCultures(), "Key", "Value", activeNode.Culture); } ViewData["ActiveNode"] = activeNode; ViewData["NewLinkTargets"] = new SelectList(EnumHelper.GetValuesWithDescription <LinkTarget>(), "Key", "Value"); } ViewData["AvailableCultures"] = GetAvailableCultures(); return(View("Index", CuyahogaContext.CurrentSite.RootNodes)); }