private void FillPanelWithComponents() { string value; // Try to retrieve data from the cache if (!CacheHelper.TryGetItem(CACHE_KEY, out value)) { var controls = FormUserControlInfoProvider.GetFormUserControls("UserControlDisplayName,UserControlCodeName,UserControlDescription,UserControlThumbnailGUID", "UserControlShowInBizForms = 1 AND UserControlPriority = 100", "UserControlDisplayName"); StringBuilder content = new StringBuilder(); foreach (var control in controls) { string iconUrl; if (control.UserControlThumbnailGUID == Guid.Empty) { iconUrl = GetImageUrl("CMSModules/CMS_FormEngine/custom.png"); } else { iconUrl = ResolveUrl(MetaFileURLProvider.GetMetaFileUrl(control.UserControlThumbnailGUID, "icon")); } content.AppendFormat("<div title=\"{0}\"><div class=\"form-component component_{1}\" ondblclick=\"FormBuilder.addNewField('{1}','',-1);FormBuilder.scrollPosition=9999;FormBuilder.showSavingInfo();\"><span class=\"component-label\">{2}</span><img src=\"{3}\" alt=\"{1}\" /></div></div>", ResHelper.LocalizeString(control.UserControlDescription), control.UserControlCodeName, control.UserControlDisplayName, iconUrl); } value = content.ToString(); var dependency = CacheHelper.GetCacheDependency(FormUserControlInfo.OBJECT_TYPE + "|all"); CacheHelper.Add(CACHE_KEY, value, dependency, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5)); } pnlFormComponents.Controls.Add(new LiteralControl(value)); }
/// <summary> /// Returns URL for the metafile specified by arguments. /// </summary> /// <param name="attachmentGuid">GUID of the metafile</param> /// <param name="attachmentName">Name of the metafile</param> /// <param name="height">Height parameter that should be added to the URL</param> /// <param name="width">Width parameter that should be added to the URL</param> /// <param name="maxSideSize">Maximum size of the item if metafile is image</param> public string GetMetaFileItemUrl(Guid attachmentGuid, string attachmentName, int height, int width, int maxSideSize) { string result = MetaFileURLProvider.GetMetaFileUrl(attachmentGuid, attachmentName); // If current site is different from attachment site make URL absolute (domain included) if (Config.UseFullURL || (SiteContext.CurrentSiteID != SiteObj.SiteID) || (SiteContext.CurrentSiteID != GetCurrentSiteId())) { result = URLHelper.GetAbsoluteUrl(result, SiteObj.DomainName, URLHelper.GetApplicationUrl(SiteObj.DomainName), null); } return(AddURLDimensionsAndResolve(result, height, width, maxSideSize)); }
/// <summary> /// Sets source and alternative text for image element. If image Guid is not set, uses default image according to given base info. /// </summary> /// <param name="baseInfo">Edited object, determines default image if image guid is not specified</param> private void SetImageAttributes(BaseInfo baseInfo) { Guid imageGuid = ValidationHelper.GetGuid(Value, Guid.Empty); if (imageGuid == Guid.Empty) { var manager = new DefaultClassThumbnail(baseInfo.TypeInfo.ObjectType); imageGuid = manager.GetDefaultClassThumbnailGuid() ?? Guid.Empty; } string imageUrl = MetaFileURLProvider.GetMetaFileUrl(imageGuid, string.Empty); imageUrl = URLHelper.UpdateParameterInUrl(imageUrl, "maxsidesize", "256"); imgPreview.Src = imageUrl; imgPreview.Alt = GetString("general.objectimage"); }
protected void Page_PreRender(object sender, EventArgs e) { // Data is used instead of EditedObject to display image even when creating a new object var baseInfo = Data as BaseInfo; if (baseInfo == null) { return; } var classInfo = DataClassInfoProvider.GetDataClassInfo(baseInfo.TypeInfo.ObjectType); if (classInfo == null) { return; } int classId = classInfo.ClassID; string modalUrl = ResolveUrl("~/CMSModules/AdminControls/Pages/ClassThumbnailSelector.aspx"); SetImageAttributes(baseInfo); if (!Enabled) { divContainer.Attributes["class"] += " disabled"; } else { ScriptHelper.RegisterDialogScript(Page); // - {0} - metafile GUID. // - {1} - extensionless metafile file name. string metafileUrlFormat = URLHelper.ResolveUrl(MetaFileURLProvider.GetMetaFileUrlFormat()); ScriptHelper.RegisterModule(this, "AdminControls/ClassThumbnailSelectorFormControl", new { ClassId = classId, ModalUrl = modalUrl, SelectButtonId = btnSelectImage.ClientID, HiddenInputId = hdnMetafileGuid.ClientID, PreviewImageId = imgPreview.ClientID, PreviewImageAnchorId = imgPreviewAnchor.ClientID, MetafileUrlFormat = metafileUrlFormat }); } }
private void FillPanelWithComponents() { var controls = FormUserControlInfoProvider.GetFormUserControls("UserControlShowInBizForms = 1 AND UserControlPriority = 100", null); StringBuilder content = new StringBuilder(); foreach (var control in controls) { string iconUrl; if (control.UserControlThumbnailGUID == Guid.Empty) { iconUrl = GetImageUrl("CMSModules/CMS_FormEngine/custom.png"); } else { iconUrl = ResolveUrl(MetaFileURLProvider.GetMetaFileUrl(control.UserControlThumbnailGUID, "icon")); } content.AppendFormat("<div title=\"{0}\"><div class=\"form-component component_{1}\" ondblclick=\"FormBuilder.addNewField('{1}','',-1);FormBuilder.scrollPosition=9999;\"><span class=\"component-label\">{2}</span><img src=\"{3}\" alt=\"{1}\" /></div></div>", ResHelper.LocalizeString(control.UserControlDescription), control.UserControlCodeName, control.UserControlDisplayName, iconUrl); } pnlFormComponents.Controls.Add(new LiteralControl(content.ToString())); }
/// <summary> /// Gets the meta file URL. /// </summary> protected override string GetUrl() { return(MetaFileURLProvider.GetWebDAVUrl(MetaFileGUID, FileName, SiteName)); }
/// <summary> /// Loads device profile menu. /// </summary> private void LoadDevicesMenu() { string defaultSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_list.png"); string defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default.png"); if ((Page is PortalPage) || (Page is TemplatePage)) { // Display grayscale icon in On-site editing defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_grayscale.png"); defaultSmallIconUrl = defaultBigIconUrl; } string deviceSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/list.png"); string deviceBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/module.png"); string defaultString = HTMLHelper.HTMLEncode(GetString("general.default")); MenuItem devMenuItem = new MenuItem { Text = defaultString, Tooltip = defaultString, ImagePath = defaultBigIconUrl, ImageAltText = defaultString }; SetStyles(devMenuItem); buttons.Buttons.Add(devMenuItem); // Load enabled profiles InfoDataSet <DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfileInfos("ProfileEnabled = 1", "ProfileOrder"); if (!DataHelper.DataSourceIsEmpty(ds)) { // Create default item SubMenuItem defaultMenuItem = new SubMenuItem { Text = defaultString, Tooltip = defaultString, ImagePath = defaultSmallIconUrl, ImageAltText = defaultString, OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice('');", ScriptHelper.GetString(defaultString), ScriptHelper.GetString(ResolveUrl(defaultBigIconUrl))) }; devMenuItem.SubItems.Add(defaultMenuItem); foreach (DeviceProfileInfo profileInfo in ds.Items) { string bigIconUrl = null; string smallIconUrl = null; if (profileInfo.ProfileIconGuid == Guid.Empty) { smallIconUrl = deviceSmallIconUrl; bigIconUrl = deviceBigIconUrl; } else { string iconUrl = MetaFileURLProvider.GetMetaFileUrl(profileInfo.ProfileIconGuid, profileInfo.ProfileName); smallIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "16"); bigIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "24"); } string profileName = GetString(profileInfo.ProfileDisplayName); SubMenuItem menuItem = new SubMenuItem { Text = HTMLHelper.HTMLEncode(profileName), Tooltip = HTMLHelper.HTMLEncode(profileName), ImagePath = smallIconUrl, ImageAltText = HTMLHelper.HTMLEncode(profileName), OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice({2});", ScriptHelper.GetString(profileName), ScriptHelper.GetString(ResolveUrl(bigIconUrl)), ScriptHelper.GetString(profileInfo.ProfileName)) }; devMenuItem.SubItems.Add(menuItem); // Update main button if current device profile is equal currently processed profile if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0)) { devMenuItem.Text = HTMLHelper.HTMLEncode(profileName); devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName); devMenuItem.ImagePath = bigIconUrl; devMenuItem.ImageAltText = HTMLHelper.HTMLEncode(profileName); } } } }