/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that threw event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void UniGridUICultures_OnAction(string actionName, object actionArgument) { if (actionName.EqualsCSafe("edit", true)) { URLHelper.Redirect("UICulture_StringsDefault_Edit.aspx?stringCodeName=" + actionArgument + "&cultureID=" + CultureID); } else if (actionName.EqualsCSafe("delete", true) && (resourceEditor != null)) { // Delete string from global resource helper FileResourceManager frm = LocalizationHelper.GetFileManager(cultureCode); if (frm != null) { frm.DeleteString(actionArgument.ToString()); } try { // Delete string from resource file resourceEditor.DeleteResourceString(actionArgument.ToString(), cultureCode); } catch (Exception ex) { ShowError(GetString("general.saveerror"), ex.Message, null); } } }
public static string GetFlagIconFile(IResource flag) { string iconName = flag.GetStringProp("IconName"); if (iconName == null) { return(null); } string tempDir = FileResourceManager.GetTrashDirectory(); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } string path = Path.Combine(tempDir, iconName); if (!File.Exists(path)) { Icon icon = DoGetResourceIcon(flag); if (icon == null) { return(null); } using (FileStream fs = new FileStream(path, FileMode.Create)) { icon.Save(fs); } } return(path); }
public void DisplayResource(IResource resource) { _resource = resource; _errorLabel.Visible = false; _picturePanel.Visible = true; using (new LayoutSuspender(this)) { FileStream stream = IOTools.OpenRead(Core.FileResourceManager.GetSourceFile(resource)); if (stream != null) { _imageStream = new JetMemoryStream(0x10000); using ( stream ) { FileResourceManager.CopyStream(stream, _imageStream); try { _picturebox.Image = Image.FromStream(_imageStream); } catch (Exception) { _errorLabel.Visible = true; _picturePanel.Visible = false; return; } } } } PerformLayout(); }
internal static Process CreateConverterProcess(string fileName, bool background) { if (!File.Exists(fileName)) { throw new Exception("Could not find the file to convert: " + fileName); } string tmpPath = "-tmp" + Utils.QuotedString(FileResourceManager.GetTrashDirectory()); Process process = new Process(); process.StartInfo.FileName = _converterName; process.StartInfo.Arguments = tmpPath + " -nd -te "; if (background) { process.StartInfo.Arguments += "-l "; } process.StartInfo.Arguments += Utils.QuotedString(fileName); process.StartInfo.WorkingDirectory = Application.StartupPath; process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; return(process); }
protected override ExplorerContent InitializeExplorerContent() { #if VS16 var content = FileResourceManager.GetElement("Resources/ExplorerContent_15.0.xaml") as ExplorerContent; // TODO still using 15.0 version for now #elif VS15 var content = FileResourceManager.GetElement("Resources/ExplorerContent_15.0.xaml") as ExplorerContent; #elif VS14 var content = FileResourceManager.GetElement("Resources/ExplorerContent_14.0.xaml") as ExplorerContent; #elif VS12 var content = FileResourceManager.GetElement("Resources/ExplorerContent_12.0.xaml") as ExplorerContent; #else var content = FileResourceManager.GetElement("Resources/ExplorerContent_11.0.xaml") as ExplorerContent; #endif // // DO NOT use a static resourceDictionary below. For some reason, calling MergedDictionaries.Add() // will associate a pointer from the static resourceDictionary to _frameContent. I wasn't able to make this reference // go away, even by calling MergedDictionaries.Remove(). The end result was the _frameContent would always stay in memory, // and this would in turn keep the entire artifact and model in memory. // var resourceDictionary = FileResourceManager.GetResourceDictionary("Resources/Styles.xaml"); content.Resources.MergedDictionaries.Add(resourceDictionary); return(content); }
public FileResourceInternalApiV1Controller( FileResourceManager fileResourceModelManager, IFileResourceManager fileResourceManager, IdentityUserManager identityUserManager ) : base(identityUserManager) { m_fileResourceModelManager = fileResourceModelManager; m_fileResourceManager = fileResourceManager; }
protected void btnOK_Click(object sender, EventArgs e) { // History back count BackCount++; string newKey = txtKey.Text.Trim().ToLowerCSafe(); string result = new Validator().NotEmpty(newKey, rfvKey.ErrorMessage).IsCodeName(newKey, GetString("culture.InvalidCodeName")).Result; if (String.IsNullOrEmpty(result)) { CultureInfo uic = CultureInfoProvider.GetCultureInfo(cultureId); if (uic != null) { string cultureCode = uic.CultureCode; stringCodeName = stringCodeName.ToLowerCSafe(); FileResourceManager frm = LocalizationHelper.GetFileManager(cultureCode); FileResourceEditor resourceEditor = new FileResourceEditor(Server.MapPath(FileResourceManager.GetResFilename(cultureCode)), cultureCode); try { if ((frm != null) && (resourceEditor != null)) { if (!stringCodeName.EqualsCSafe(newKey, StringComparison.InvariantCultureIgnoreCase)) { frm.DeleteString(stringCodeName); resourceEditor.DeleteResourceString(stringCodeName, cultureCode, true); } frm.SetString(newKey, txtText.Text); resourceEditor.SetResourceString(newKey, txtText.Text, cultureCode); } } catch (Exception ex) { ShowError(GetString("general.saveerror"), ex.Message, null); return; } ShowChangesSaved(); codeNameBreadcrumbItem.Text = newKey; } else { ShowError(GetString("general.invalidcultureid")); } } else { ShowError(result); } }
private static void DisplayHTML(IResource resource, AbstractWebBrowser browser, WordPtr[] wordsToHighlight) { try { StreamReader reader = Core.FileResourceManager.GetStreamReader(resource); if (reader != null) { string sourceUrl = ""; string htmlText = Utils.StreamReaderReadToEnd(reader); reader.BaseStream.Close(); IResource source = FileResourceManager.GetSource(resource); if (source != null) { string url = string.Empty; if (Core.ResourceStore.PropTypes.Exist("URL")) { url = source.GetPropText("URL"); } if (url.Length > 0) { sourceUrl = url; htmlText = HtmlTools.FixRelativeLinks(htmlText, url); } else { string directory = source.GetPropText("Directory"); if (directory.Length > 0) { if ((!directory.EndsWith("/")) && (!directory.EndsWith("\\"))) { directory += "/"; } htmlText = HtmlTools.FixRelativeLinks(htmlText, directory); } } } try { WebSecurityContext context = WebSecurityContext.Restricted; context.WorkOffline = false; browser.ShowHtml(htmlText, context, DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection)); browser.CurrentUrl = sourceUrl; } catch (Exception e) { Trace.WriteLine(e.ToString(), "Html.Plugin"); } } } catch (ObjectDisposedException) {} }
/** * tracking adding links to file resources * if link added to a transient file resource, it becomes permanent * ParentFolder links are obviously ignored */ private static void ResourceStore_LinkAdded(object sender, LinkEventArgs e) { IResource res = e.Source; if (e.PropType != _propParentFolder && res.IsTransient) { IResource source = FileResourceManager.GetSource(res); if (source != null && source.Type == _folderResourceType) { res.EndUpdate(); Core.TextIndexManager.QueryIndexing(res.Id); } } }
/// <summary> /// Returns a path to the file that contains the given icon. /// If the file does not exist yet, it is created in the Omea trash folder. If there is one already, it will be reused. /// </summary> /// <param name="icon">Icon that should be saved as a file.</param> /// <param name="origin">Resource that is somehow related to the icon. It is used to generate an unique file name for the icon. May be <c>Null</c>.</param> /// <param name="relation">Describes how the resource specified by <paramref name="origin"/> relates to the icon being saved. This helps to get an unique file name in case there is more than one icon related to the resource. May be <c>Null</c> if only one icon is expected for the resource.</param> /// <param name="bRenderToBitmap">If set to <c>False</c>, saves the icon into an icon file (.ico). If <c>True</c>, renders the icon to an in-memory bitmap, and saves the produced bitmap as a PNG file.</param> /// <returns>Full path to the icon file.</returns> public static string GetIconFile(Icon icon, object origin, object relation, bool bRenderToBitmap) { if (icon == null) { throw new ArgumentNullException("icon"); } // Generate the file name string extension = bRenderToBitmap ? ".png" : ".ico"; string name = String.Format("Icon-{0:X8}-{1:X8}-{2:X8}{3}", icon.Handle.ToInt32(), (origin != null ? origin.GetHashCode() : 0), (relation != null ? relation.GetHashCode() : 0), extension); // Get access to the Omea trash folder string folderTemp = FileResourceManager.GetTrashDirectory(); if (!Directory.Exists(folderTemp)) { Directory.CreateDirectory(folderTemp); } string folder = Path.Combine(folderTemp, "RenderIcons"); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } // Get the combined file path string path = Path.Combine(folder, name); // Save the icon (if it does not exist) if (!File.Exists(path)) { try { Bitmap bmpWrap = GraphicalUtils.ConvertIco2Bmp(icon); using (FileStream fs = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read)) bmpWrap.Save(fs, ImageFormat.Png); } catch (Exception e) { Core.ReportBackgroundException(e); } } return(path); }
protected void Page_Load(object sender, EventArgs e) { // Get available cultures if (!RequestHelper.IsPostBack()) { GetAvailableCultures(); // Pre-select the appropriate UI culture if (PassedCultureID > 0) { ddlAvailableCultures.Items.FindByValue(PassedCultureID.ToString()).Selected = true; } } // Initialize the property keeping information on selected culture CultureID = ValidationHelper.GetInteger(ddlAvailableCultures.SelectedItem.Value, 0); // Init new header action HeaderAction action = new HeaderAction() { Text = GetString("culture.newstring"), RedirectUrl = "~/CMSModules/SystemDevelopment/Development/Resources/UICulture_StringsDefault_New.aspx?cultureid=" + CultureID, }; CurrentMaster.HeaderActions.ActionsList.Add(action); // Get requested culture CultureInfo ui = CultureInfoProvider.GetCultureInfo(CultureID); if (ui != null) { cultureCode = ui.CultureCode; resourceEditor = new FileResourceEditor(Server.MapPath(FileResourceManager.GetResFilename(cultureCode)), cultureCode); UniGridStrings.OnDataReload += UniGridStrings_OnDataReload; UniGridStrings.OnAction += UniGridUICultures_OnAction; } else { lblInfo.Visible = true; } }
protected void btnOK_Click(object sender, EventArgs e) { string key = txtKey.Text.Trim().ToLowerCSafe(); string result = new Validator().NotEmpty(key, rfvKey.ErrorMessage).IsCodeName(key, GetString("culture.InvalidCodeName")).Result; if (String.IsNullOrEmpty(result)) { CultureInfo uic = CultureInfoProvider.GetCultureInfo(cultureId); if (uic != null) { string cultureCode = uic.CultureCode; FileResourceManager frm = LocalizationHelper.GetFileManager(cultureCode); FileResourceEditor resourceEditor = new FileResourceEditor(Server.MapPath(FileResourceManager.GetResFilename(cultureCode)), cultureCode); try { frm.SetString(key, txtText.Text); resourceEditor.SetResourceString(key, txtText.Text, cultureCode); } catch (Exception ex) { ShowError(GetString("general.saveerror"), ex.Message, null); return; } URLHelper.Redirect("UICulture_StringsDefault_Edit.aspx?cultureID=" + cultureId + "&stringCodeName=" + key + "&saved=1"); } else { ShowError(GetString("general.invalidcultureid")); } } else { ShowError(result); } }
public Icon GetResourceIcon(IResource resource) { IResource source = FileResourceManager.GetSource(resource); Icon icon; if (source == null || source.Type != "Weblink") { icon = FileIcons.GetFileSmallIcon(resource.GetPropText(Core.Props.Name)); } else { string path = string.Empty; try { Uri uri = new Uri(source.GetPropText("URL")); string query = uri.Query; if (query.Length > 1) { query = query.Substring(1); // skip leading '?' int i = query.IndexOf('='); if (i >= 0 && i < query.Length) { query = query.Substring(i + 1); } if (query.Length > 0) { return(FileIcons.GetFileSmallIcon(query)); } } path = uri.LocalPath; } catch {} icon = FileIcons.GetFileSmallIcon(path); } return(icon); }
private static IResource CreateFragmentResource(string subject, TextFormat textFormat, string text, string sourceUrl, IResource baseResource) { IResource clipping = Core.ResourceStore.NewResourceTransient("Fragment"); string baseFileName = null; if (baseResource != null && Core.ResourceStore.ResourceTypes [baseResource.Type].HasFlag(ResourceTypeFlags.FileFormat)) { string directory = baseResource.GetStringProp("Directory"); if (directory == null) { IResource source = FileResourceManager.GetSource(baseResource); if (source != null) { directory = baseResource.GetStringProp("Directory"); } } if (directory != null && baseResource.HasProp("Name")) { baseFileName = Path.Combine(directory, baseResource.GetStringProp("Name")); } } if (textFormat == TextFormat.Html) { StringBuilder htmlBuilder = new StringBuilder("<html><body style=\"font-family: Verdana; font-size: 10pt; \">"); if (baseFileName != null) { htmlBuilder.Append(text); htmlBuilder.Append("<p class=\"Clipping-Url\"><a href=\""); htmlBuilder.Append(HttpUtility.HtmlEncode(baseFileName)); htmlBuilder.Append("\">"); htmlBuilder.Append(HttpUtility.HtmlEncode(baseFileName)); htmlBuilder.Append("</a>"); } else if (sourceUrl != null) { htmlBuilder.Append(HtmlTools.FixRelativeLinks(text, sourceUrl)); htmlBuilder.Append("<p class=\"Clipping-Url\"><a href=\""); htmlBuilder.Append(sourceUrl); htmlBuilder.Append("\">"); htmlBuilder.Append(sourceUrl); htmlBuilder.Append("</a>"); } else { htmlBuilder.Append(text); } htmlBuilder.Append("</body></html>"); clipping.SetProp(Core.Props.LongBody, htmlBuilder.ToString()); clipping.SetProp(Core.Props.LongBodyIsHTML, true); } else if (textFormat == TextFormat.Rtf) { clipping.SetProp(Core.Props.LongBody, text); clipping.SetProp(Core.Props.LongBodyIsRTF, true); } clipping.SetProp(Core.Props.Subject, subject); clipping.SetProp("IsClippingFakeProp", true); clipping.SetProp(Core.Props.Date, DateTime.Now); if (baseResource != null) { clipping.SetProp("ContentType", baseResource.Type); int[] linkTypeIds = baseResource.GetLinkTypeIds(); foreach (int propId in linkTypeIds) { if (Core.ResourceStore.PropTypes [propId].HasFlag(PropTypeFlags.SourceLink)) { clipping.SetProp("ContentLinks", Core.ResourceStore.PropTypes [propId].Name); break; } } clipping.AddLink("Fragment", baseResource); } else if (sourceUrl != null) { clipping.SetProp("ContentType", "Weblink"); clipping.SetProp("Url", sourceUrl); } return(clipping); }
/// <summary> /// Button OK clicked. /// </summary> protected void btnOk_Click(object sender, EventArgs e) { // Check if current user's culture exists string cultureCode = CultureHelper.PreferredUICultureCode; if (string.IsNullOrEmpty(cultureCode)) { cultureCode = CultureHelper.DefaultUICultureCode; } ResourceStringInfo ri; string key; // Creating new resource string if (lstExistingOrNew.SelectedValue == "new") { key = SystemContext.DevelopmentMode ? txtNewResource.Text.Trim() : resourceKeyPrefix + txtNewResource.Text.Trim(); ri = ResourceStringInfo.Provider.Get(key); // Resource string doesn't exists yet if (ri == null) { if (!ValidationHelper.IsCodeName(key)) { ShowError(GetString("culture.invalidresstringkey")); } else { // Save ResourceString ri = new ResourceStringInfo(); ri.StringKey = key; ri.CultureCode = cultureCode; ri.TranslationText = plainText; ri.StringIsCustom = !SystemContext.DevelopmentMode; ResourceStringInfo.Provider.Set(ri); } } string script = ScriptHelper.GetScript("CloseDialog(); wopener.SetResourceAndOpen('" + hdnValue + "', '" + ScriptHelper.GetString(key, false) + "', '" + textbox + "', " + ScriptHelper.GetString(plainText) + ", '" + btnLocalizeField + "', '" + btnLocalizeString + "', '" + btnRemoveLocalization + "', '" + localizedInputContainer + "');"); ScriptHelper.RegisterStartupScript(this, typeof(string), "localizeField", script); } // Using existing resource string else { key = ValidationHelper.GetString(resourceSelector.Value, String.Empty); ri = ResourceStringInfo.Provider.Get(key); // Key not found in DB if (ri == null) { // Try to find it in .resx file FileResourceManager resourceManager = LocalizationHelper.GetFileManager(cultureCode); if (resourceManager != null) { string translation = resourceManager.GetString(key); if (!string.IsNullOrEmpty(translation)) { if (!SystemContext.DevelopmentMode) { // Save the key in DB ri = new ResourceStringInfo { StringKey = key, StringIsCustom = true, CultureCode = cultureCode, TranslationText = translation }; ResourceStringInfo.Provider.Set(ri); } string script = ScriptHelper.GetScript("CloseDialog(); wopener.SetResource('" + hdnValue + "', '" + key + "', '" + textbox + "', " + ScriptHelper.GetString(translation) + ", '" + btnLocalizeField + "', '" + btnLocalizeString + "', '" + btnRemoveLocalization + "', '" + localizedInputContainer + "');"); ScriptHelper.RegisterStartupScript(this, typeof(string), "localizeField", script); } else { ShowError(GetString("localize.doesntexist")); } } else { ShowError(GetString("localize.doesntexist")); } } // Send to parent window selected resource key else { using (LocalizationActionContext context = new LocalizationActionContext()) { context.ResolveSubstitutionMacros = false; var localizedText = ScriptHelper.GetString(GetString(key), true, true); string script = ScriptHelper.GetScript($"wopener.SetResource('{hdnValue}', '{key}', '{textbox}', {localizedText}, '{btnLocalizeField}', '{btnLocalizeString}', '{btnRemoveLocalization}', '{localizedInputContainer}'); CloseDialog();"); ScriptHelper.RegisterStartupScript(this, typeof(string), "localizeField", script); } } } }
/// <summary> /// Button OK clicked. /// </summary> void btnOk_Click(object sender, EventArgs e) { // Check permissions if (CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Localization", "LocalizeStrings")) { string key = null; ResourceStringInfo ri = null; // Check if current user's culture exists UICultureInfo uiCulture = null; string cultureCode = CultureHelper.PreferredUICulture; try { uiCulture = UICultureInfoProvider.GetUICultureInfo(CultureHelper.PreferredUICulture); } // Use default UI culture catch { cultureCode = CultureHelper.DefaultUICulture; } // Use default UI culture if (uiCulture == null) { cultureCode = CultureHelper.DefaultUICulture; } // Creating new resource string if (lstExistingOrNew.SelectedIndex == 0) { if (SettingsKeyProvider.DevelopmentMode && String.IsNullOrEmpty(resourceKeyPrefix)) { key = txtNewResource.Text.Trim(); } else { key = resourceKeyPrefix + txtNewResource.Text.Trim(); } ri = SqlResourceManager.GetResourceStringInfo(key); // Resource string doesn't exists yet if (ri == null) { lblError.Text = new Validator().NotEmpty(key, GetString("Administration-UICulture_String_New.EmptyKey")).IsCodeName(key, GetString("Administration-UICulture_String_New.InvalidCodeName")).Result; if (!String.IsNullOrEmpty(lblError.Text)) { lblError.Visible = true; } else { // Save ResourceString ri = new ResourceStringInfo(); ri.StringKey = key; ri.UICultureCode = cultureCode; ri.TranslationText = plainText; ri.StringIsCustom = !SettingsKeyProvider.DevelopmentMode; SqlResourceManager.SetResourceStringInfo(ri); ScriptHelper.RegisterStartupScript(this, typeof(string), "localizeField", ScriptHelper.GetScript("wopener.SetResourceAndOpen('" + hdnValue + "', '" + key + "', '" + textbox + "', " + ScriptHelper.GetString(plainText) + ", '" + hdnIsMacro + "', '" + btnLocalizeField + "', '" + btnLocalizeString + "', '" + btnRemoveLocalization + "', window);")); } } // If resource string already exists with different translation else { lblError.Visible = true; lblError.ResourceString = "localize.alreadyexists"; } } // Using existing resource string else { key = ValidationHelper.GetString(resourceSelector.Value, String.Empty).Trim(); ri = SqlResourceManager.GetResourceStringInfo(key); // Key not found in DB if (ri == null) { // Try to find it in .resx file and save it in DB FileResourceManager resourceManager = ResHelper.GetFileManager(cultureCode); if (resourceManager != null) { string translation = resourceManager.GetString(key); if (!String.IsNullOrEmpty(translation)) { ri = new ResourceStringInfo(); ri.StringKey = key; ri.StringIsCustom = !SettingsKeyProvider.DevelopmentMode; ri.UICultureCode = cultureCode; ri.TranslationText = translation; SqlResourceManager.SetResourceStringInfo(ri); ScriptHelper.RegisterStartupScript(this, typeof(string), "localizeField", ScriptHelper.GetScript("wopener.SetResource('" + hdnValue + "', '" + key + "', '" + textbox + "', " + ScriptHelper.GetString(translation) + ", '" + hdnIsMacro + "', '" + btnLocalizeField + "', '" + btnLocalizeString + "', '" + btnRemoveLocalization + "', window);")); } else { lblError.Visible = true; lblError.ResourceString = "localize.doesntexist"; } } else { lblError.Visible = true; lblError.ResourceString = "localize.doesntexist"; } } // Send to parent window selected resource key else { string existingTranslation = GetString(key); ScriptHelper.RegisterStartupScript(this, typeof(string), "localizeField", ScriptHelper.GetScript("wopener.SetResource('" + hdnValue + "', '" + key + "', '" + textbox + "', " + ScriptHelper.GetString(existingTranslation) + ", '" + hdnIsMacro + "', '" + btnLocalizeField + "', '" + btnLocalizeString + "', '" + btnRemoveLocalization + "', window);")); } } } else { lblError.ResourceString = "general.actiondenied"; lblError.Visible = true; pnlControls.Visible = false; } }
/** * User should manually close returned stream */ public static Stream Serialize(IResource resource) { JetMemoryStream result = new JetMemoryStream(); BinaryWriter writer = new BinaryWriter(result); writer.Write(resource.Type); writer.Write(resource.Properties.Count); foreach (IResourceProperty prop in resource.Properties) { writer.Write((int)prop.DataType); int propId = prop.PropId; writer.Write(propId); switch (prop.DataType) { case PropDataType.Link: { IResourceList links; if (Core.ResourceStore.PropTypes[propId].HasFlag(PropTypeFlags.DirectedLink)) { links = (propId < 0) ? resource.GetLinksTo(null, -propId) : resource.GetLinksFrom(null, propId); } else { links = resource.GetLinksOfType(null, propId); } writer.Write(links.Count); foreach (IResource linked in links) { writer.Write(linked.Id); } break; } case PropDataType.String: case PropDataType.LongString: { writer.Write(resource.GetPropText(propId)); break; } case PropDataType.StringList: { IStringList strList = resource.GetStringListProp(propId); int count = strList.Count; writer.Write(count); for (int i = 0; i < count; ++i) { writer.Write(strList[i]); } break; } case PropDataType.Int: { writer.Write(resource.GetIntProp(propId)); break; } case PropDataType.Date: { writer.Write(resource.GetDateProp(propId).Ticks); break; } case PropDataType.Bool: { /** * if a resource has bool prop, then it's equal to 'true' * there is no need always to write 'true' to stream :-) */ break; } case PropDataType.Double: { writer.Write(resource.GetDoubleProp(propId)); break; } case PropDataType.Blob: { Stream stream = resource.GetBlobProp(propId); writer.Write((int)stream.Length); FileResourceManager.CopyStream(stream, result); break; } default: { throw new Exception("Serialized resource has properties of unknown type"); } } } return(result); }
protected void Page_Load(object sender, EventArgs e) { stringCodeName = QueryHelper.GetString("stringCodeName", String.Empty); cultureId = QueryHelper.GetInteger("cultureId", 0); // Validate culture ID if (cultureId <= 0) { ShowError(GetString("general.invalidcultureid")); return; } if (QueryHelper.GetBoolean("saved", false)) { ShowChangesSaved(); } // Init new header action HeaderAction action = new HeaderAction { Text = GetString("culture.newstring"), RedirectUrl = "~/CMSModules/SystemDevelopment/Development/Resources/UICulture_StringsDefault_New.aspx?cultureId=" + cultureId, }; CurrentMaster.HeaderActions.ActionsList.Add(action); codeNameBreadcrumbItem = new BreadcrumbItem { Text = stringCodeName.ToLowerCSafe(), }; PageBreadcrumbs.AddBreadcrumb(codeNameBreadcrumbItem); // Ensure breadcrumbs suffix UIHelper.SetBreadcrumbsSuffix(GetString("objecttype.cms_resourcestring")); // Initialize controls rfvKey.ErrorMessage = GetString("culture.enterakey"); if (!RequestHelper.IsPostBack()) { CultureInfo uic = CultureInfoProvider.GetCultureInfo(cultureId); if (uic != null) { string cultureCode = uic.CultureCode; FileResourceEditor fre = new FileResourceEditor(Server.MapPath(FileResourceManager.GetResFilename(cultureCode)), cultureCode); if (fre != null) { txtKey.Text = stringCodeName; txtText.Text = fre.GetResourceString(stringCodeName, cultureCode); } } else { ShowError(GetString("general.invalidcultureid")); } } }
private static void UpdateResources() { string[] lastTypes = ObjectStore.ReadString("UnknownFiles", "LastConf").Split(';'); string[] types = (Core.FileResourceManager as FileResourceManager).GetResourceTypes(); if (types.Length == lastTypes.Length) { bool needUpdate = false; Array.Sort(types); Array.Sort(lastTypes); for (int i = 0; i < types.Length; ++i) { if (types[i] != lastTypes[i]) { needUpdate = true; break; } } // plugin configuration not changed if (!needUpdate) { return; } } IResourceList unknownRcs = Core.ResourceStore.GetAllResources(_unknowFileResourceType); IProgressWindow progressWindow = Core.ProgressWindow; for (int i = 0, percents = 0; i < unknownRcs.Count && Core.State != CoreState.ShuttingDown; ++i) { if (progressWindow != null) { progressWindow.UpdateProgress(percents / unknownRcs.Count, "Updating unknown resources", null); percents += 100; } IResource unknown = unknownRcs[i]; IResource source = FileResourceManager.GetSource(unknown); if (source != null) { string resourceType = Core.FileResourceManager.GetResourceTypeByExtension( IOTools.GetExtension(unknown.GetPropText(Core.Props.Name))); if (resourceType != null) { unknown.ChangeType(resourceType); } } } foreach (IResourceType resType in Core.ResourceStore.ResourceTypes) { if (resType.HasFlag(ResourceTypeFlags.FileFormat) && !resType.OwnerPluginLoaded) { IResourceList formatFiles = Core.ResourceStore.GetAllResources(resType.Name); foreach (IResource formatFile in formatFiles) { formatFile.ChangeType(_unknowFileResourceType); } } } StringBuilder confString = new StringBuilder(); foreach (string restype in types) { confString.Append(restype); confString.Append(";"); } ObjectStore.WriteString("UnknownFiles", "LastConf", confString.ToString().TrimEnd(';')); }
static FileTable() { Microsoft.Expression.Project.FileTable.resourceManager = new FileResourceManager(typeof(Microsoft.Expression.Project.FileTable).Assembly); }