Ejemplo n.º 1
0
        public void InitView(String configurationPath, String moduleCode, EditorType selectedType, Boolean allowAnonymous)
        {
            if (!allowAnonymous && UserContext.isAnonymous)
            {
                View.CurrentType = EditorType.none;
            }
            else
            {
                EditorConfiguration config = ServiceEditor.GetConfiguration(configurationPath);
                if (config == null || (config.DefaultEditor == null && !config.Settings.Any()))
                {
                    View.CurrentType = EditorType.none;
                }
                else
                {
                    ModuleEditorSettings mSettings = (config.ModuleSettings == null) ? null : config.ModuleSettings.Where(m => m.ModuleCode == moduleCode).FirstOrDefault();

                    EditorType loadType = (mSettings != null) ?
                                          mSettings.EditorType
                                        :
                                          ((config.Settings.Any() && config.Settings.Where(s => s.EditorType == selectedType).Any())
                                        ? selectedType : ((config.DefaultEditor != null) ? config.DefaultEditor.EditorType:  EditorType.none));
                    View.CurrentType = loadType;
                    EditorSettings    rSettings    = (config.Settings.Any() ? config.Settings.Where(s => s.EditorType == loadType).FirstOrDefault(): null);
                    EditorInitializer eInitializer = GetInitializer(loadType, config, (rSettings != null) ? rSettings: config.DefaultEditor, mSettings);

                    View.LoadEditor(loadType, eInitializer);
                    View.isInitialized = true;
                }
            }
        }
        private void InitializeView(String configurationPath, NoticeboardMessage message)
        {
            lm.Comol.Core.BaseModules.Editor.EditorConfiguration config = ServiceEditor.GetConfiguration(configurationPath);
            if (!(config == null || (config.DefaultEditor == null && !config.Settings.Any())))
            {
                ModuleEditorSettings mSettings = (config.ModuleSettings == null) ? null : config.ModuleSettings.Where(m => m.ModuleCode == ModuleNoticeboard.UniqueID).FirstOrDefault();

                EditorType loadType = (mSettings != null) ?
                                      mSettings.EditorType
                                    :
                                      ((config.Settings.Any() && config.Settings.Where(s => s.EditorType == EditorType.telerik).Any())
                                    ? EditorType.telerik : ((config.DefaultEditor != null) ? config.DefaultEditor.EditorType : EditorType.none));
                EditorSettings rSettings = (config.Settings.Any() ? config.Settings.Where(s => s.EditorType == loadType).FirstOrDefault() : null);

                EditorSettings settings   = (rSettings != null) ? rSettings : config.DefaultEditor;
                String         fontfamily = (mSettings != null) ? mSettings.FontNames : (settings != null) ? settings.FontNames : config.FontNames;
                if (String.IsNullOrEmpty(fontfamily))
                {
                    fontfamily = config.FontNames;
                }

                String  fontSizes       = (mSettings != null) ? mSettings.FontSizes : (settings != null) ? settings.FontSizes : config.FontSizes;
                String  realFontSizes   = (mSettings != null) ? mSettings.RealFontSizes : (settings != null) ? settings.RealFontSizes : config.RealFontSizes;
                Boolean useRealFontSize = (!String.IsNullOrEmpty(realFontSizes)) ? View.UseRealFontSize : (mSettings != null) ? mSettings.UseRealFontSize : (settings != null) ? settings.UseRealFontSize : config.UseRealFontSize;


                FontConfiguration   defaultFont      = (mSettings != null && mSettings.DefaultFont != null) ? mSettings.DefaultFont : (settings != null && settings.DefaultFont != null) ? settings.DefaultFont : config.DefaultFont;
                FontConfiguration   defaultRealFont  = (mSettings != null && mSettings.DefaultRealFont != null) ? mSettings.DefaultRealFont : (settings != null && settings.DefaultRealFont != null) ? settings.DefaultRealFont : config.DefaultRealFont;
                List <FontSettings> fontSizeSettings = config.FontSizeSettings;
                List <String>       fitems           = fontfamily.Split(',').Where(s => !String.IsNullOrEmpty(s)).ToList();


                String dFont = "";
                if (!useRealFontSize && defaultFont != null && fitems.Select(s => s.ToLower()).Contains(defaultFont.Family.ToLower()))
                {
                    dFont = defaultFont.Family;
                }
                else if (useRealFontSize && defaultRealFont != null && fitems.Select(s => s.ToLower()).Contains(defaultRealFont.Family.ToLower()))
                {
                    dFont = defaultRealFont.Family;
                }
                if (message.StyleSettings != null && !String.IsNullOrEmpty(message.StyleSettings.FontFamily) && fitems.Select(s => s.ToLower()).Contains(message.StyleSettings.FontFamily.ToLower()))
                {
                    dFont = message.StyleSettings.FontFamily;
                }
                View.LoadFontFamily(fitems, dFont);


                List <String> sizeItems = fontSizeSettings.Select(s => s.Value).ToList();

                //fontfamily.Split(',').Where(s=> !String.IsNullOrEmpty(s)).ToList();

                //LoadFontSize
            }
            View.isInitialized = true;
        }
Ejemplo n.º 3
0
        public void InitView(String editorConfigurationPath, System.Guid currentWorkingApplicationId)
        {
            NoticeboardMessage message = null;

            EditorConfiguration config = ServiceEditor.GetConfiguration(editorConfigurationPath);

            if (config != null)
            {
                ModuleEditorSettings mSettings = (config.ModuleSettings == null) ? null : config.ModuleSettings.Where(m => m.ModuleCode == ModuleNoticeboard.UniqueID).FirstOrDefault();
                if (mSettings == null && config.CssFiles.Any())
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, config.CssFiles);
                }
                else if (mSettings != null && mSettings.CssFiles != null && mSettings.CssFiles.Any() && mSettings.OvverideCssFileSettings)
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, mSettings.CssFiles);
                }
                else if (mSettings != null && mSettings.CssFiles != null && !mSettings.OvverideCssFileSettings)
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, config.CssFiles);
                }
            }

            long idMessage   = View.PreloadedIdMessage;
            int  IdCommunity = View.PreloadedIdCommunity;

            if (idMessage != 0)
            {
                message = Service.GetMessage(idMessage);
            }
            else
            {
                message = Service.GetLastMessage(IdCommunity);
                if (message != null)
                {
                    idMessage = message.Id;
                }
            }
            if (message != null && message.Community != null)
            {
                IdCommunity = message.Community.Id;
            }
            else if (message != null && message.isForPortal)
            {
                IdCommunity = 0;
            }
            else
            {
                IdCommunity = UserContext.WorkingCommunityID;
            }

            Community community = null;

            if (IdCommunity > 0)
            {
                community = CurrentManager.GetCommunity(IdCommunity);
            }
            if (community == null && IdCommunity > 0)
            {
                View.ContainerName = "";
            }
            else if (community != null)
            {
                View.ContainerName = community.Name;
            }
            else
            {
                View.ContainerName = View.PortalName;
            }

            Boolean anonymousViewAllowed = (View.PreloadWorkingApplicationId != Guid.Empty && View.PreloadWorkingApplicationId == currentWorkingApplicationId);

            if (message == null && idMessage > 0)
            {
                View.DisplayUnknownMessage();
                View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewUnknownMessage);
            }
            else if (message == null && idMessage == 0)
            {
                View.DisplayEmptyMessage();
                View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewEmptyMessage);
            }
            else if (UserContext.isAnonymous && !anonymousViewAllowed)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                View.IdCurrentMessage = idMessage;

                ModuleNoticeboard module = null;
                if (IdCommunity == 0 && message.isForPortal)
                {
                    module = ModuleNoticeboard.CreatePortalmodule((UserContext.isAnonymous) ? (int)UserTypeStandard.Guest : UserContext.UserTypeID);
                }
                else if (IdCommunity > 0)
                {
                    module = new ModuleNoticeboard(CurrentManager.GetModulePermission(UserContext.CurrentUserID, IdCommunity, ModuleID));
                }
                else
                {
                    module = new ModuleNoticeboard();
                }
                if (module.Administration || module.ViewCurrentMessage || module.ViewOldMessage || anonymousViewAllowed)
                {
                    View.DisplayMessage(message);
                    View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewMessage);
                }
                else
                {
                    View.DisplayNoPermission();
                    View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.NoPermission);
                }
            }
        }