protected void languageTranslatedCheckbox_CheckChanged(object sender, EventArgs e) { try { if ((sender) is DnnCheckBox) { var translatedCheckbox = (DnnCheckBox)sender; int tabId = int.Parse(translatedCheckbox.CommandArgument); var tabCtrl = new TabController(); TabInfo localizedTab = tabCtrl.GetTab(tabId, PortalId, false); tabCtrl.UpdateTranslationStatus(localizedTab, translatedCheckbox.Checked); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
protected void translatedCheckbox_CheckedChanged(object sender, EventArgs e) { var tabCtrl = new TabController(); TabInfo localizedTab = tabCtrl.GetTab(TabId, PortalId, false); tabCtrl.UpdateTranslationStatus(localizedTab, translatedCheckbox.Checked); //Rebind Tab _tab = null; BindLocalization(true); }
/// <summary> /// SaveTabData saves the Tab to the Database /// </summary> /// <remarks> /// </remarks> /// <param name = "strAction">The action to perform "edit" or "add"</param> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// [jlucarino] 2/26/2009 Added CreatedByUserID and LastModifiedByUserID /// </history> private int SaveTabData(string strAction) { string strIcon; string strIconLarge; strIcon = ctlIcon.Url; strIconLarge = ctlIconLarge.Url; var objTabs = new TabController(); Tab.TabName = txtTabName.Text; Tab.Title = txtTitle.Text; Tab.Description = txtDescription.Text; Tab.KeyWords = txtKeyWords.Text; Tab.IsVisible = chkMenu.Checked; Tab.DisableLink = chkDisableLink.Checked; TabInfo parentTab = null; if (cboParentTab.SelectedItem != null) { var parentTabID = Int32.Parse(cboParentTab.SelectedItem.Value); var controller = new TabController(); parentTab = controller.GetTab(parentTabID, -1, false); } if (parentTab != null) { Tab.PortalID = parentTab.PortalID; Tab.ParentId = parentTab.TabID; } else { Tab.ParentId = Null.NullInteger; } Tab.IconFile = strIcon; Tab.IconFileLarge = strIconLarge; Tab.IsDeleted = false; Tab.Url = ctlURL.Url; Tab.TabPermissions.Clear(); if (Tab.PortalID != Null.NullInteger) { Tab.TabPermissions.AddRange(dgPermissions.Permissions); } Tab.Terms.Clear(); Tab.Terms.AddRange(termsSelector.Terms); Tab.SkinSrc = pageSkinCombo.SelectedValue; Tab.ContainerSrc = pageContainerCombo.SelectedValue; Tab.TabPath = Globals.GenerateTabPath(Tab.ParentId, Tab.TabName); //Check for invalid if (!IsValidTabName(Tab.TabName)) { return Null.NullInteger; } //Validate Tab Path if (!IsValidTabPath(Tab, Tab.TabPath)) { return Null.NullInteger; } //Set Culture Code var positionTabID = Null.NullInteger; if (cboPositionTab.SelectedItem != null) { positionTabID = Int32.Parse(cboPositionTab.SelectedItem.Value); } if (strAction != "edit") { if (PortalSettings.ContentLocalizationEnabled) { switch (cultureTypeList.SelectedValue) { case "Localized": var defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId); Tab.CultureCode = defaultLocale.Code; break; case "Culture": Tab.CultureCode = PortalSettings.CultureCode; break; default: Tab.CultureCode = Null.NullString; break; } var tabLocale = LocaleController.Instance.GetLocale(Tab.CultureCode) ?? LocaleController.Instance.GetDefaultLocale(PortalId); //Fix parent if (Tab.ParentId > Null.NullInteger) { parentTab = objTabs.GetTab(Tab.ParentId, PortalId, false); if (parentTab.CultureCode != Tab.CultureCode) { parentTab = objTabs.GetTabByCulture(Tab.ParentId, PortalId, tabLocale); } Tab.ParentId = parentTab.TabID; } //Fix position TabId if (positionTabID > Null.NullInteger) { var positionTab = objTabs.GetTab(positionTabID, PortalId, false); if (positionTab.CultureCode != Tab.CultureCode) { positionTab = objTabs.GetTabByCulture(positionTabID, PortalId, tabLocale); } positionTabID = positionTab.TabID; } } else { Tab.CultureCode = Null.NullString; } } //Validate Tab Path if (string.IsNullOrEmpty(strAction)) { var tabID = TabController.GetTabByTabPath(Tab.PortalID, Tab.TabPath, Tab.CultureCode); if (tabID != Null.NullInteger) { var existingTab = objTabs.GetTab(tabID, PortalId, false); if (existingTab != null && existingTab.IsDeleted) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabRecycled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); } else { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } return Null.NullInteger; } } Tab.StartDate = datepickerStartDate.SelectedDate != null ? datepickerStartDate.SelectedDate.Value : Null.NullDate; Tab.EndDate = datepickerEndDate.SelectedDate != null ? datepickerEndDate.SelectedDate.Value : Null.NullDate; if (Tab.StartDate > Null.NullDate && Tab.EndDate > Null.NullDate && Tab.StartDate.AddDays(1) >= Tab.EndDate) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("InvalidTabDates", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } if (txtRefreshInterval.Text.Length > 0 && Regex.IsMatch(txtRefreshInterval.Text, "^\\d+$")) { Tab.RefreshInterval = Convert.ToInt32(txtRefreshInterval.Text); } Tab.SiteMapPriority = float.Parse(txtPriority.Text); Tab.PageHeadText = txtPageHeadText.Text; Tab.IsSecure = chkSecure.Checked; Tab.PermanentRedirect = chkPermanentRedirect.Checked; if (strAction == "edit") { // trap circular tab reference if (cboParentTab.SelectedItem != null && Tab.TabID != Int32.Parse(cboParentTab.SelectedItem.Value) && !IsCircularReference(Int32.Parse(cboParentTab.SelectedItem.Value), Tab.PortalID)) { objTabs.UpdateTab(Tab); if (IsHostMenu && Tab.PortalID != Null.NullInteger) { //Host Tab moved to Portal so clear Host cache objTabs.ClearCache(Null.NullInteger); } if (!IsHostMenu && Tab.PortalID == Null.NullInteger) { //Portal Tab moved to Host so clear portal cache objTabs.ClearCache(PortalId); } UpdateTabSettings(Tab.TabID); } // add or copy } else { if (positionTabID == Null.NullInteger) { Tab.TabID = objTabs.AddTab(Tab); } else { if (rbInsertPosition.SelectedValue == "After" && positionTabID > Null.NullInteger) { Tab.TabID = objTabs.AddTabAfter(Tab, positionTabID); } else if (rbInsertPosition.SelectedValue == "Before" && positionTabID > Null.NullInteger) { Tab.TabID = objTabs.AddTabBefore(Tab, positionTabID); } else { Tab.TabID = objTabs.AddTab(Tab); } } UpdateTabSettings(Tab.TabID); //Create Localized versions if (PortalSettings.ContentLocalizationEnabled && cultureTypeList.SelectedValue == "Localized") { objTabs.CreateLocalizedCopies(Tab); //Refresh tab _tab = objTabs.GetTab(Tab.TabID, Tab.PortalID, true); } var copyTabId = Int32.Parse(cboCopyPage.SelectedItem.Value); if (copyTabId != -1) { var objModules = new ModuleController(); ModuleInfo objModule; CheckBox chkModule; RadioButton optCopy; RadioButton optReference; TextBox txtCopyTitle; foreach (DataGridItem objDataGridItem in grdModules.Items) { chkModule = (CheckBox)objDataGridItem.FindControl("chkModule"); if (chkModule.Checked) { var intModuleID = Convert.ToInt32(grdModules.DataKeys[objDataGridItem.ItemIndex]); optCopy = (RadioButton)objDataGridItem.FindControl("optCopy"); optReference = (RadioButton)objDataGridItem.FindControl("optReference"); txtCopyTitle = (TextBox)objDataGridItem.FindControl("txtCopyTitle"); objModule = objModules.GetModule(intModuleID, copyTabId, false); ModuleInfo newModule = null; if ((objModule != null)) { //Clone module as it exists in the cache and changes we make will update the cached object newModule = objModule.Clone(); if (!optReference.Checked) { newModule.ModuleID = Null.NullInteger; } newModule.TabID = Tab.TabID; newModule.DefaultLanguageGuid = Null.NullGuid; newModule.CultureCode = Tab.CultureCode; newModule.ModuleTitle = txtCopyTitle.Text; newModule.ModuleID = objModules.AddModule(newModule); if (optCopy.Checked) { if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass)) { var objObject = Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass); if (objObject is IPortable) { var content = Convert.ToString(((IPortable)objObject).ExportModule(intModuleID)); if (!string.IsNullOrEmpty(content)) { ((IPortable)objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, UserInfo.UserID); } } } } } if (optReference.Checked) { //Make reference copies on secondary language foreach (var m in objModule.LocalizedModules.Values) { var newLocalizedModule = m.Clone(); var localizedTab = Tab.LocalizedTabs[m.CultureCode]; newLocalizedModule.TabID = localizedTab.TabID; newLocalizedModule.CultureCode = localizedTab.CultureCode; newLocalizedModule.ModuleTitle = txtCopyTitle.Text; newLocalizedModule.DefaultLanguageGuid = newModule.UniqueId; newLocalizedModule.ModuleID = objModules.AddModule(newLocalizedModule); } } } } } else { // create the page from a template if (cboTemplate.SelectedItem != null && cboTemplate.SelectedItem.Value != Null.NullInteger.ToString()) { var xmlDoc = new XmlDocument(); try { // open the XML file xmlDoc.Load(PortalSettings.HomeDirectoryMapPath + cboFolders.SelectedValue + cboTemplate.SelectedValue); } catch (Exception ex) { Exceptions.LogException(ex); UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("BadTemplate", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } TabController.DeserializePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), Tab.PortalID, Tab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable()); //save tab permissions RibbonBarManager.DeserializeTabPermissions(xmlDoc.SelectNodes("//portal/tabs/tab/tabpermissions/permission"), Tab); var tabIndex = 0; var exceptions = string.Empty; foreach (XmlNode tabNode in xmlDoc.SelectSingleNode("//portal/tabs").ChildNodes) { //Create second tab onward tabs. Note first tab is already created above. if(tabIndex > 0) { try { TabController.DeserializeTab(tabNode, null, PortalId, PortalTemplateModuleAction.Replace); } catch (Exception ex) { Exceptions.LogException(ex); exceptions += string.Format("Template Tab # {0}. Error {1}<br/>", tabIndex + 1, ex.Message); } } tabIndex++; } if (!string.IsNullOrEmpty(exceptions)) { UI.Skins.Skin.AddModuleMessage(this, exceptions, ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } } } } // url tracking var objUrls = new UrlController(); objUrls.UpdateUrl(PortalId, ctlURL.Url, ctlURL.UrlType, 0, Null.NullDate, Null.NullDate, ctlURL.Log, ctlURL.Track, Null.NullInteger, ctlURL.NewWindow); //Clear the Tab's Cached modules DataCache.ClearModuleCache(TabId); //Update Cached Tabs as TabPath may be needed before cache is cleared TabInfo tempTab; if (new TabController().GetTabsByPortal(PortalId).TryGetValue(Tab.TabID, out tempTab)) { tempTab.TabPath = Tab.TabPath; } //Update Translation Status objTabs.UpdateTranslationStatus(Tab, translatedCheckbox.Checked); return Tab.TabID; }
protected void publishPageButton_Click(object sender, EventArgs e) { var tabCtrl = new TabController(); var modCtrl = new ModuleController(); //First mark all modules as translated foreach (ModuleInfo m in modCtrl.GetTabModules(Tab.TabID).Values) { modCtrl.UpdateTranslationStatus(m, true); } //First mark tab as translated tabCtrl.UpdateTranslationStatus(Tab, true); //Next publish Tab (update Permissions) tabCtrl.PublishTab(Tab); //Redirect to refresh page (and skinobjects) Response.Redirect(Request.RawUrl, true); }
public void MarkTranslatedSelectedItems(bool translated) { foreach (GridDataItem row in localizedTabsGrid.SelectedItems) { var language = (string) row.OwnerTableView.DataKeyValues[row.ItemIndex]["CultureCode"]; var tabCtrl = new TabController(); TabInfo localizedTab = null; if (Tab.LocalizedTabs.TryGetValue(language, out localizedTab)) { tabCtrl.UpdateTranslationStatus(localizedTab, translated); } } //Raise Changed event OnTabLocalizationChanged(EventArgs.Empty); //Rebind localized Tabs DataBind(); }