public void LoadSettings(NUnit.Util.ISettings settings)
		{
			this.settings = settings;

			TabInfoCollection info = new TabInfoCollection();
			string tabList = (string)settings.GetSetting( Prefix + "TabList" );

			if ( tabList != null ) 
			{
				string[] tabNames = tabList.Split( new char[] { ',' } );
				foreach( string name in tabNames )
				{
					string prefix = Prefix + name;
					string text = (string)settings.GetSetting(prefix + ".Title");
					if ( text == null )
						break;

					TabInfo tab = new TabInfo( name, text );
					tab.Content = (TextDisplayContent)settings.GetSetting(prefix + ".Content", TextDisplayContent.Empty );
					tab.Enabled = settings.GetSetting( prefix + ".Enabled", true );
					info.Add( tab );
				}
			}

			if ( info.Count > 0 )		
				tabInfo = info;
			else 
				LoadDefaults();
		}
        public void AddTab(TabHost.TabSpec tabSpec, Class clss, Bundle args)
        {
            tabSpec.SetContent(new DummyTabFactory(_context));
            var tag = tabSpec.Tag;

            var info = new TabInfo(tag, clss, args);

            _tabs.Add(info);
            _tabHost.AddTab(tabSpec);
            NotifyDataSetChanged();
        }
		ObservableCollection<TabInfo> CreateCollection() {
			var list = new List<TabInfo>();
			foreach (var tabState in MainWindow.Instance.GetTabStateInOrder()) {
				var info = new TabInfo();
				info.TabState = tabState;
				info.FirstModuleName = tabState.Name ?? string.Empty;
				info.FirstModuleFullName = tabState.FileName ?? string.Empty;
				list.Add(info);
			}
			list.Sort((a, b) => StringComparer.InvariantCultureIgnoreCase.Compare(a.TabState.ShortHeader, b.TabState.ShortHeader));
			return new ObservableCollection<TabInfo>(list);
		}
        /// <summary>
        /// Check if current user can see a specific page
        /// </summary>
        /// <param name="tab"> The TabInfo to be checked</param>
        /// <returns>True if current user can see the specific page. Otherwise, False</returns>
        internal static bool CanSeeVersionedPages(TabInfo tab)
        {
            if (!Thread.CurrentPrincipal.Identity.IsAuthenticated)
            {
                return false;
            }

            var currentPortal = PortalController.Instance.GetCurrentPortalSettings();
            var isAdminUser = currentPortal.UserInfo.IsSuperUser || PortalSecurity.IsInRole(currentPortal.AdministratorRoleName);
            if (isAdminUser)
            {
                return true;
            }

            return TabPermissionController.HasTabPermission(tab.TabPermissions, "EDIT,CONTENT,MANAGE");
        }
            public void AddTab(TabHost.TabSpec tabSpec, Class clss, Bundle args)
            {
                tabSpec.SetContent(new DummyTabFactory(_activity));
                var tag = tabSpec.Tag;

                var info = new TabInfo(tag, clss, args);

                // Check to see if we already have a fragment for this tab, probably
                // from a previously saved state.  If so, deactivate it, because our
                // initial state is that a tab isn't shown.
                info.fragment = _activity.SupportFragmentManager.FindFragmentByTag(tag);
                if (info.fragment != null && !info.fragment.IsDetached) {
                    var ft = _activity.SupportFragmentManager.BeginTransaction();
                    ft.Detach(info.fragment);
                    ft.Commit();
                }

                _tabs.Add(tag, info);
                _tabHost.AddTab(tabSpec);
            }
        public List<TabInfo> GetRibbonMenuTags()
        {
            //SmartThreadPool pool = new SmartThreadPool();
            List<TabInfo> tags = new List<TabInfo>();
            foreach (var downloader in Downloader.GetAllDownloaders())
            {
                var attributes = downloader.GetType().GetCustomAttributes(typeof(DownloaderAttribute), true);
                if (attributes != null)
                {
                    foreach (DownloaderAttribute att in attributes)
                    {
                        var tag = tags.Find(p => p.Name == att.MetroTab);
                        if (tag == null)
                        {
                            tag = new TabInfo();
                            tags.Add(tag);
                        }
                        tag.Name = att.MetroTab;

                        //global::System.Resources.ResourceManager resourceMan = new global::System.Resources.ResourceManager("ComicDownloader.Properties.Resources", typeof(ComicDownloader.Properties.Resources).Assembly);

                       Thread.Sleep(new Random().Next(1,10));
                        var m = new Random(DateTime.Now.Millisecond);
                        int next = m.Next(0, int.MaxValue);

                        var title = new MetroFramework.Controls.MetroTile();
                        title.ActiveControl = null;
                        title.Tag = downloader;
                        title.Location = new System.Drawing.Point(20, 150);
                        title.Cursor = System.Windows.Forms.Cursors.Hand;
                        title.Size = new System.Drawing.Size(150, 120);

                        title.CustomBackground = true;
                        var index = next%colorArray.Length;
                        title.BackColor = colorArray[index];

                        title.CustomForeColor = true;
                        title.ForeColor = ColorTranslator.FromHtml("#ffffff");
                        
                        title.TileTextFontSize = MetroTileTextSize.Medium;
                        title.TileTextFontWeight = MetroTileTextWeight.Bold;

                        //title.Style = (MetroFramework.MetroColorStyle)(next%13);
                        title.TabIndex = 2;
                        //if (title.Style == MetroColorStyle.White) title.Style = MetroColorStyle.Red;
                        title.Text = downloader.Name;
                        title.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                        title.Theme = MetroFramework.MetroThemeStyle.Dark;
                        title.Click += new System.EventHandler(delegate(object sender, System.EventArgs e)
                        {
                            var dl = ((MetroTile)sender).Tag as Downloader;
                            if (mainApp == null) mainApp = new AppMainForm();
                            
                                mainApp.Show();
                                mainApp.SetDownloader(dl);
                                mainApp.WindowState = FormWindowState.Maximized;
                            
                        });

                        
                        this.metroToolTip1.SetToolTip(title, downloader.Name);

                        //pool.QueueWorkItem(delegate(object obj) {

                        //    TitleLogoUpdate data = (TitleLogoUpdate)obj;
                        //    if(!string.IsNullOrEmpty(data.Downloader.Logo) ){

                        //        var img = data.Downloader.Logo.DownloadAsImage();
                        //        img = img.Clip(data.Title.Width, data.Title.Height);
                        //        data.Title.TileImage = img;
                        //        data.Title.UseTileImage = true;
                        //        data.Title.TileImageAlign = ContentAlignment.MiddleCenter;
                        //        data.Title.TextAlign = ContentAlignment.BottomCenter;
                            
                        //    }
                        
                        
                        //}, 
                        //new TitleLogoUpdate()
                        //{
                        //    Title = title,
                        //    Downloader = downloader
                        //});
                       

                        //tag.Titles.Add(metroTile2);
                        tag.Titles.Add(title);
                    }
                }

            }
           // pool.Start();
            return tags;
        }
Example #7
0
        private int AddNewModule(TabInfo tab, string title, int desktopModuleId, string paneName, int permissionType, string align)
        {
            TabPermissionCollection objTabPermissions = tab.TabPermissions;
            var objPermissionController = new PermissionController();
            var objModules = new ModuleController();
            int j;
            var mdc = new ModuleDefinitionController();

            foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
            {
                var objModule = new ModuleInfo();
                objModule.Initialize(tab.PortalID);

                objModule.PortalID = tab.PortalID;
                objModule.TabID    = tab.TabID;
                if (string.IsNullOrEmpty(title))
                {
                    objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                }
                else
                {
                    objModule.ModuleTitle = title;
                }
                objModule.PaneName               = paneName;
                objModule.ModuleDefID            = objModuleDefinition.ModuleDefID;
                objModule.CacheTime              = 0;
                objModule.InheritViewPermissions = true;
                objModule.DisplayTitle           = false;

                // get the default module view permissions
                ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");

                // get the permissions from the page
                foreach (TabPermissionInfo objTabPermission in objTabPermissions)
                {
                    if (objTabPermission.PermissionKey == "VIEW" && permissionType == 0)
                    {
                        //Don't need to explicitly add View permisisons if "Same As Page"
                        continue;
                    }

                    // get the system module permissions for the permissionkey
                    ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
                    // loop through the system module permissions
                    for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
                    {
                        // create the module permission
                        PermissionInfo objSystemModulePermission = default(PermissionInfo);
                        objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j];
                        if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == 1 && objTabPermission.PermissionKey != "EDIT")
                        {
                            //Only Page Editors get View permissions if "Page Editors Only"
                            continue;
                        }

                        ModulePermissionInfo objModulePermission = AddModulePermission(objModule,
                                                                                       objSystemModulePermission,
                                                                                       objTabPermission.RoleID,
                                                                                       objTabPermission.UserID,
                                                                                       objTabPermission.AllowAccess);

                        // ensure that every EDIT permission which allows access also provides VIEW permission
                        if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess)
                        {
                            ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule,
                                                                                         (PermissionInfo)arrSystemModuleViewPermissions[0],
                                                                                         objModulePermission.RoleID,
                                                                                         objModulePermission.UserID,
                                                                                         true);
                        }
                    }
                }

                objModule.AllTabs   = false;
                objModule.Alignment = align;

                return(objModules.AddModule(objModule));
            }
            return(-1);
        }
Example #8
0
        /// <inheritdoc/>
        public async Task <string> AddTabToConversationAsync(ConversationContext conversationContext, TabInfo tabInfo)
        {
            // Check if a tab is already added.
            var existingTabs = await this.graphServiceClient.Chats[conversationContext.ConversationId].Tabs
                               .Request().GetAsync();
            var resourceTab = existingTabs.Where(tab => tabInfo.EntityId.Equals(tab.Configuration.EntityId)).FirstOrDefault();

            if (resourceTab != null)
            {
                // Return an existing tab id.
                return(resourceTab.Id);
            }

            // Add a new tab.
            var teamsTab = new TeamsTab
            {
                DisplayName   = tabInfo.DisplayName,
                Configuration = new TeamsTabConfiguration
                {
                    EntityId   = tabInfo.EntityId,
                    ContentUrl = tabInfo.ContentUrl,
                    WebsiteUrl = tabInfo.WebsiteUrl,
                    RemoveUrl  = tabInfo.RemoveUrl,
                },
                AdditionalData = new Dictionary <string, object>()
                {
                    { "*****@*****.**", $"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{this.appSettings.CatalogAppId}" },
                },
            };

            var result = await this.graphServiceClient.Chats[conversationContext.ConversationId].Tabs
                         .Request()
                         .AddAsync(teamsTab);

            return(result?.Id);
        }
 private TabInfo CreateTabInfo(object item)
 {
     string id = Guid.NewGuid().ToString("n");
     var spec = TabHost.NewTabSpec(id);
     var tabInfo = new TabInfo(item, spec, GetContent(item));
     _tabToContent[id] = tabInfo;
     SetIndicator(spec, item);
     spec.SetContent(_tabFactory);
     spec.SetDataContext(item);
     return tabInfo;
 }
 public TabInfo AddNewTab( string title )
 {
     TabInfo tabInfo = new TabInfo( GetNextName(), title );
     InnerList.Add( tabInfo );
     return tabInfo;
 }
		string GetSaveButtonText(TabInfo[] tabs) {
			if (tabs.Length == 1 && !(tabs[0].TabState is DecompileTabState))
				return "_Save...";
			return "_Save Code...";
		}
Example #12
0
        private void ExecuteTestForTab(string test, TabInfo tab, FriendlyUrlSettings settings, Dictionary <string, string> testFields)
        {
            var    httpAlias    = testFields["Alias"];
            var    defaultAlias = testFields.GetValue("DefaultAlias", String.Empty);
            var    tabName      = testFields["Page Name"];
            var    scheme       = testFields["Scheme"];
            var    parameters   = testFields["Params"];
            var    result       = testFields["Expected Url"];
            var    customPage   = testFields.GetValue("Custom Page Name", _defaultPage);
            string vanityUrl    = testFields.GetValue("VanityUrl", String.Empty);

            var httpAliasFull  = scheme + httpAlias + "/";
            var expectedResult = result.Replace("{alias}", httpAlias)
                                 .Replace("{usealias}", defaultAlias)
                                 .Replace("{tabName}", tabName)
                                 .Replace("{tabId}", tab.TabID.ToString())
                                 .Replace("{vanityUrl}", vanityUrl)
                                 .Replace("{defaultPage}", _defaultPage);


            if (!String.IsNullOrEmpty(parameters) && !parameters.StartsWith("&"))
            {
                parameters = "&" + parameters;
            }

            var userName = testFields.GetValue("UserName", String.Empty);

            if (!String.IsNullOrEmpty(userName))
            {
                var user = UserController.GetUserByName(PortalId, userName);
                if (user != null)
                {
                    expectedResult = expectedResult.Replace("{userId}", user.UserID.ToString());
                    parameters     = parameters.Replace("{userId}", user.UserID.ToString());
                }
            }


            var    baseUrl = httpAliasFull + "Default.aspx?TabId=" + tab.TabID + parameters;
            string testUrl;

            if (test == "Base")
            {
                testUrl = AdvancedFriendlyUrlProvider.BaseFriendlyUrl(tab,
                                                                      baseUrl,
                                                                      customPage,
                                                                      httpAlias,
                                                                      settings);
            }
            else
            {
                testUrl = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(tab,
                                                                          baseUrl,
                                                                          customPage,
                                                                          httpAlias,
                                                                          true,
                                                                          settings,
                                                                          Guid.Empty);
            }

            Assert.AreEqual(expectedResult, testUrl);
        }
Example #13
0
 public TabInfo LocaliseTab(TabInfo tab, int portalId)
 {
     return(apiMember.Invoke(null, new object[] { tab }) as TabInfo ?? tab);
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <remarks>
        /// - Obtain PortalSettings from Current Context
        /// - redirect to a specific tab based on name
        /// - if first time loading this page then reload to avoid caching
        /// - set page title and stylesheet
        /// - check to see if we should show the Assembly Version in Page Title
        /// - set the background image if there is one selected
        /// - set META tags, copyright, keywords and description
        /// </remarks>
        /// -----------------------------------------------------------------------------
        private void InitializePage()
        {
            //There could be a pending installation/upgrade process
            if (InstallBlocker.Instance.IsInstallInProgress())
            {
                Exceptions.ProcessHttpException(new HttpException(503, Localization.GetString("SiteAccessedWhileInstallationWasInProgress.Error", Localization.GlobalResourceFile)));
            }

            //Configure the ActiveTab with Skin/Container information
            PortalSettingsController.Instance().ConfigureActiveTab(PortalSettings);

            //redirect to a specific tab based on name
            if (!String.IsNullOrEmpty(Request.QueryString["tabname"]))
            {
                TabInfo tab = TabController.Instance.GetTabByName(Request.QueryString["TabName"], PortalSettings.PortalId);
                if (tab != null)
                {
                    var parameters = new List <string>(); //maximum number of elements
                    for (int intParam = 0; intParam <= Request.QueryString.Count - 1; intParam++)
                    {
                        switch (Request.QueryString.Keys[intParam].ToLowerInvariant())
                        {
                        case "tabid":
                        case "tabname":
                            break;

                        default:
                            parameters.Add(
                                Request.QueryString.Keys[intParam] + "=" + Request.QueryString[intParam]);
                            break;
                        }
                    }
                    Response.Redirect(NavigationManager.NavigateURL(tab.TabID, Null.NullString, parameters.ToArray()), true);
                }
                else
                {
                    //404 Error - Redirect to ErrorPage
                    Exceptions.ProcessHttpException(Request);
                }
            }
            string cacheability = Request.IsAuthenticated ? Host.AuthenticatedCacheability : Host.UnauthenticatedCacheability;

            switch (cacheability)
            {
            case "0":
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                break;

            case "1":
                Response.Cache.SetCacheability(HttpCacheability.Private);
                break;

            case "2":
                Response.Cache.SetCacheability(HttpCacheability.Public);
                break;

            case "3":
                Response.Cache.SetCacheability(HttpCacheability.Server);
                break;

            case "4":
                Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
                break;

            case "5":
                Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
                break;
            }

            //page comment
            if (Host.DisplayCopyright)
            {
                Comment += string.Concat(Environment.NewLine,
                                         "<!--*********************************************-->",
                                         Environment.NewLine,
                                         "<!-- DNN Platform - http://www.dnnsoftware.com   -->",
                                         Environment.NewLine,
                                         "<!-- Copyright (c) 2002-2018, by DNN Corporation -->",
                                         Environment.NewLine,
                                         "<!--*********************************************-->",
                                         Environment.NewLine);
            }

            //Only insert the header control if a comment is needed
            if (!String.IsNullOrWhiteSpace(Comment))
            {
                Page.Header.Controls.AddAt(0, new LiteralControl(Comment));
            }

            if (PortalSettings.ActiveTab.PageHeadText != Null.NullString && !Globals.IsAdminControl())
            {
                Page.Header.Controls.Add(new LiteralControl(PortalSettings.ActiveTab.PageHeadText));
            }

            if (!string.IsNullOrEmpty(PortalSettings.PageHeadText))
            {
                metaPanel.Controls.Add(new LiteralControl(PortalSettings.PageHeadText));
            }

            //set page title
            if (UrlUtils.InPopUp())
            {
                var strTitle    = new StringBuilder(PortalSettings.PortalName);
                var slaveModule = UIUtilities.GetSlaveModule(PortalSettings.ActiveTab.TabID);

                //Skip is popup is just a tab (no slave module)
                if (slaveModule.DesktopModuleID != Null.NullInteger)
                {
                    var    control   = ModuleControlFactory.CreateModuleControl(slaveModule) as IModuleControl;
                    string extension = Path.GetExtension(slaveModule.ModuleControl.ControlSrc.ToLowerInvariant());
                    switch (extension)
                    {
                    case ".mvc":
                        var segments = slaveModule.ModuleControl.ControlSrc.Replace(".mvc", "").Split('/');

                        control.LocalResourceFile = String.Format("~/DesktopModules/MVC/{0}/{1}/{2}.resx",
                                                                  slaveModule.DesktopModule.FolderName,
                                                                  Localization.LocalResourceDirectory,
                                                                  segments[0]);
                        break;

                    default:
                        control.LocalResourceFile = string.Concat(
                            slaveModule.ModuleControl.ControlSrc.Replace(
                                Path.GetFileName(slaveModule.ModuleControl.ControlSrc), string.Empty),
                            Localization.LocalResourceDirectory, "/",
                            Path.GetFileName(slaveModule.ModuleControl.ControlSrc));
                        break;
                    }
                    var title = Localization.LocalizeControlTitle(control);

                    strTitle.Append(string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName));
                    strTitle.Append(string.Concat(" > ", title));
                }
                else
                {
                    strTitle.Append(string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName));
                }

                //Set to page
                Title = strTitle.ToString();
            }
            else
            {
                //If tab is named, use that title, otherwise build it out via breadcrumbs
                if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Title))
                {
                    Title = PortalSettings.ActiveTab.Title;
                }
                else
                {
                    //Elected for SB over true concatenation here due to potential for long nesting depth
                    var strTitle = new StringBuilder(PortalSettings.PortalName);
                    foreach (TabInfo tab in PortalSettings.ActiveTab.BreadCrumbs)
                    {
                        strTitle.Append(string.Concat(" > ", tab.TabName));
                    }
                    Title = strTitle.ToString();
                }
            }

            //set the background image if there is one selected
            if (!UrlUtils.InPopUp() && FindControl("Body") != null)
            {
                if (!string.IsNullOrEmpty(PortalSettings.BackgroundFile))
                {
                    var fileInfo = GetBackgroundFileInfo();
                    var url      = FileManager.Instance.GetUrl(fileInfo);

                    ((HtmlGenericControl)FindControl("Body")).Attributes["style"] = string.Concat("background-image: url('", url, "')");
                }
            }

            //META Refresh
            // Only autorefresh the page if we are in VIEW-mode and if we aren't displaying some module's subcontrol.
            if (PortalSettings.ActiveTab.RefreshInterval > 0 && this.PortalSettings.UserMode == PortalSettings.Mode.View && Request.QueryString["ctl"] == null)
            {
                MetaRefresh.Content = PortalSettings.ActiveTab.RefreshInterval.ToString();
                MetaRefresh.Visible = true;
            }
            else
            {
                MetaRefresh.Visible = false;
            }

            //META description
            if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Description))
            {
                Description = PortalSettings.ActiveTab.Description;
            }
            else
            {
                Description = PortalSettings.Description;
            }

            //META keywords
            if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.KeyWords))
            {
                KeyWords = PortalSettings.ActiveTab.KeyWords;
            }
            else
            {
                KeyWords = PortalSettings.KeyWords;
            }
            if (Host.DisplayCopyright)
            {
                KeyWords += ",DotNetNuke,DNN";
            }

            //META copyright
            if (!string.IsNullOrEmpty(PortalSettings.FooterText))
            {
                Copyright = PortalSettings.FooterText.Replace("[year]", DateTime.Now.Year.ToString());
            }
            else
            {
                Copyright = string.Concat("Copyright (c) ", DateTime.Now.Year, " by ", PortalSettings.PortalName);
            }

            //META generator
            if (Host.DisplayCopyright)
            {
                Generator = "DotNetNuke ";
            }
            else
            {
                Generator = "";
            }

            //META Robots - hide it inside popups and if PageHeadText of current tab already contains a robots meta tag
            if (!UrlUtils.InPopUp() &&
                !(HeaderTextRegex.IsMatch(PortalSettings.ActiveTab.PageHeadText) ||
                  HeaderTextRegex.IsMatch(PortalSettings.PageHeadText)))
            {
                MetaRobots.Visible = true;
                var allowIndex = true;
                if ((PortalSettings.ActiveTab.TabSettings.ContainsKey("AllowIndex") &&
                     bool.TryParse(PortalSettings.ActiveTab.TabSettings["AllowIndex"].ToString(), out allowIndex) &&
                     !allowIndex)
                    ||
                    (Request.QueryString["ctl"] != null &&
                     (Request.QueryString["ctl"] == "Login" || Request.QueryString["ctl"] == "Register")))
                {
                    MetaRobots.Content = "NOINDEX, NOFOLLOW";
                }
                else
                {
                    MetaRobots.Content = "INDEX, FOLLOW";
                }
            }

            //NonProduction Label Injection
            if (NonProductionVersion() && Host.DisplayBetaNotice && !UrlUtils.InPopUp())
            {
                string versionString = string.Format(" ({0} Version: {1})", DotNetNukeContext.Current.Application.Status,
                                                     DotNetNukeContext.Current.Application.Version);
                Title += versionString;
            }

            //register the custom stylesheet of current page
            if (PortalSettings.ActiveTab.TabSettings.ContainsKey("CustomStylesheet") && !string.IsNullOrEmpty(PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString()))
            {
                var customStylesheet = Path.Combine(PortalSettings.HomeDirectory, PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString());
                ClientResourceManager.RegisterStyleSheet(this, customStylesheet);
            }

            // Cookie Consent
            if (PortalSettings.ShowCookieConsent)
            {
                ClientAPI.RegisterClientVariable(this, "cc_morelink", PortalSettings.CookieMoreLink, true);
                ClientAPI.RegisterClientVariable(this, "cc_message", Localization.GetString("cc_message", Localization.GlobalResourceFile), true);
                ClientAPI.RegisterClientVariable(this, "cc_dismiss", Localization.GetString("cc_dismiss", Localization.GlobalResourceFile), true);
                ClientAPI.RegisterClientVariable(this, "cc_link", Localization.GetString("cc_link", Localization.GlobalResourceFile), true);
                ClientResourceManager.RegisterScript(Page, "~/Resources/Shared/Components/CookieConsent/cookieconsent.min.js", FileOrder.Js.DnnControls);
                ClientResourceManager.RegisterStyleSheet(Page, "~/Resources/Shared/Components/CookieConsent/cookieconsent.min.css", FileOrder.Css.ResourceCss);
                ClientResourceManager.RegisterScript(Page, "~/js/dnn.cookieconsent.js", FileOrder.Js.DefaultPriority);
            }
        }
Example #15
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchResults gets the search results for a passed in criteria string
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="portalId">A Id of the Portal</param>
        /// <param name="criteria">The criteria string</param>
        /// -----------------------------------------------------------------------------
        public override SearchResultsInfoCollection GetSearchResults(int portalId, string criteria)
        {
            bool hasExcluded  = Null.NullBoolean;
            bool hasMandatory = Null.NullBoolean;

            var portal = PortalController.Instance.GetPortal(portalId);

            //Get the Settings for this Portal
            var portalSettings = new PortalSettings(portal);

            //We will assume that the content is in the locale of the Portal
            Hashtable commonWords = GetCommonWords(portalSettings.DefaultLanguage);

            //clean criteria
            criteria = criteria.ToLowerInvariant();

            //split search criteria into words
            var searchWords = new SearchCriteriaCollection(criteria);

            var searchResults = new Dictionary <string, SearchResultsInfoCollection>();

            //dicResults is a Dictionary(Of SearchItemID, Dictionary(Of TabID, SearchResultsInfo)
            var dicResults = new Dictionary <int, Dictionary <int, SearchResultsInfo> >();

            //iterate through search criteria words
            foreach (SearchCriteria criterion in searchWords)
            {
                if (commonWords.ContainsKey(criterion.Criteria) == false || portalSettings.SearchIncludeCommon)
                {
                    if (!searchResults.ContainsKey(criterion.Criteria))
                    {
                        searchResults.Add(criterion.Criteria, SearchDataStoreController.GetSearchResults(portalId, criterion.Criteria));
                    }
                    if (searchResults.ContainsKey(criterion.Criteria))
                    {
                        foreach (SearchResultsInfo result in searchResults[criterion.Criteria])
                        {
                            //Add results to dicResults
                            if (!criterion.MustExclude)
                            {
                                if (dicResults.ContainsKey(result.SearchItemID))
                                {
                                    //The Dictionary exists for this SearchItemID already so look in the TabId keyed Sub-Dictionary
                                    Dictionary <int, SearchResultsInfo> dic = dicResults[result.SearchItemID];
                                    if (dic.ContainsKey(result.TabId))
                                    {
                                        //The sub-Dictionary contains the item already so update the relevance
                                        SearchResultsInfo searchResult = dic[result.TabId];
                                        searchResult.Relevance += result.Relevance;
                                    }
                                    else
                                    {
                                        //Add Entry to Sub-Dictionary
                                        dic.Add(result.TabId, result);
                                    }
                                }
                                else
                                {
                                    //Create new TabId keyed Dictionary
                                    var dic = new Dictionary <int, SearchResultsInfo>();
                                    dic.Add(result.TabId, result);

                                    //Add new Dictionary to SearchResults
                                    dicResults.Add(result.SearchItemID, dic);
                                }
                            }
                        }
                    }
                }
            }
            foreach (SearchCriteria criterion in searchWords)
            {
                var mandatoryResults = new Dictionary <int, bool>();
                var excludedResults  = new Dictionary <int, bool>();
                if (searchResults.ContainsKey(criterion.Criteria))
                {
                    foreach (SearchResultsInfo result in searchResults[criterion.Criteria])
                    {
                        if (criterion.MustInclude)
                        {
                            //Add to mandatory results lookup
                            mandatoryResults[result.SearchItemID] = true;
                            hasMandatory = true;
                        }
                        else if (criterion.MustExclude)
                        {
                            //Add to exclude results lookup
                            excludedResults[result.SearchItemID] = true;
                            hasExcluded = true;
                        }
                    }
                }
                foreach (KeyValuePair <int, Dictionary <int, SearchResultsInfo> > kvpResults in dicResults)
                {
                    //The key of this collection is the SearchItemID,  Check if the value of this collection should be processed
                    if (hasMandatory && (!mandatoryResults.ContainsKey(kvpResults.Key)))
                    {
                        //1. If mandatoryResults exist then only process if in mandatoryResults Collection
                        foreach (SearchResultsInfo result in kvpResults.Value.Values)
                        {
                            result.Delete = true;
                        }
                    }
                    else if (hasExcluded && (excludedResults.ContainsKey(kvpResults.Key)))
                    {
                        //2. Do not process results in the excludedResults Collection
                        foreach (SearchResultsInfo result in kvpResults.Value.Values)
                        {
                            result.Delete = true;
                        }
                    }
                }
            }

            //Process results against permissions and mandatory and excluded results
            var results = new SearchResultsInfoCollection();

            foreach (KeyValuePair <int, Dictionary <int, SearchResultsInfo> > kvpResults in dicResults)
            {
                foreach (SearchResultsInfo result in kvpResults.Value.Values)
                {
                    if (!result.Delete)
                    {
                        //Check If authorised to View Tab
                        TabInfo objTab = TabController.Instance.GetTab(result.TabId, portalId, false);
                        if (TabPermissionController.CanViewPage(objTab))
                        {
                            //Check If authorised to View Module
                            ModuleInfo objModule = ModuleController.Instance.GetModule(result.ModuleId, result.TabId, false);
                            if (ModulePermissionController.CanViewModule(objModule))
                            {
                                results.Add(result);
                            }
                        }
                    }
                }
            }

            //Return Search Results Collection
            return(results);
        }
 private bool ModuleIsAvailable(TabInfo tab, ModuleInfo module)
 {
     return(GetModules(tab).Any(m => m.ModuleID == module.ModuleID && !m.IsDeleted));
 }
Example #17
0
        public static bool CanShowTab(TabInfo objTab, bool isAdminMode, bool showDisabled)
        {
            bool showHidden = false;

            return(CanShowTab(objTab, isAdminMode, showDisabled, showHidden));
        }
        public Int32 AddNewModule(string title, int desktopModuleId, TabInfo ActiveTab, string paneName, int position, ViewPermissionType permissionType, string align)
        {
            int ModuleId = 0;
            TabPermissionCollection objTabPermissions       = ActiveTab.TabPermissions;
            PermissionController    objPermissionController = new PermissionController();
            ModuleController        objModules = new ModuleController();

            DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();
            int j;

            try
            {
                DesktopModuleInfo desktopModule = null;
                if (!DesktopModuleController.GetDesktopModules(BSkin.PortalSettings.PortalId).TryGetValue(desktopModuleId, out desktopModule))
                {
                    throw new ArgumentException("desktopModuleId");
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
            int UserId = -1;

            if (BSkin.Request.IsAuthenticated)
            {
                UserInfo objUserInfo = UserController.GetCurrentUserInfo();
                UserId = objUserInfo.UserID;
            }
            foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
            {
                ModuleInfo objModule = new ModuleInfo();
                objModule.Initialize(BSkin.PortalSettings.PortalId);
                objModule.PortalID    = BSkin.PortalSettings.PortalId;
                objModule.TabID       = ActiveTab.TabID;
                objModule.ModuleOrder = position;
                if (String.IsNullOrEmpty(title))
                {
                    objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                }
                else
                {
                    objModule.ModuleTitle = title;
                }
                objModule.PaneName    = paneName;
                objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                if (objModuleDefinition.DefaultCacheTime > 0)
                {
                    objModule.CacheTime = objModuleDefinition.DefaultCacheTime;
                    if (BSkin.PortalSettings.DefaultModuleId > Null.NullInteger && BSkin.PortalSettings.DefaultTabId > Null.NullInteger)
                    {
                        ModuleInfo defaultModule = objModules.GetModule(BSkin.PortalSettings.DefaultModuleId, BSkin.PortalSettings.DefaultTabId, true);
                        if (defaultModule != null)
                        {
                            objModule.CacheTime = defaultModule.CacheTime;
                        }
                    }
                }
                switch (permissionType)
                {
                case ViewPermissionType.View:
                    objModule.InheritViewPermissions = true;
                    break;

                case ViewPermissionType.Edit:
                    objModule.InheritViewPermissions = false;
                    break;
                }
                ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");
                foreach (TabPermissionInfo objTabPermission in objTabPermissions)
                {
                    if (objTabPermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.View)
                    {
                        continue;
                    }
                    ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
                    for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
                    {
                        PermissionInfo objSystemModulePermission;
                        objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j];
                        if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.Edit && objTabPermission.PermissionKey != "EDIT")
                        {
                            continue;
                        }
                        ModulePermissionInfo objModulePermission = AddModulePermission(objModule, objSystemModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess);
                        if (objModulePermission.PermissionKey == "EDIT" && objModulePermission.AllowAccess)
                        {
                            ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule, (PermissionInfo)arrSystemModuleViewPermissions[0], objModulePermission.RoleID, objModulePermission.UserID, true);
                        }
                    }
                    if (objTabPermission.PermissionKey == "EDIT")
                    {
                        ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID);
                        for (j = 0; j <= arrCustomModulePermissions.Count - 1; j++)
                        {
                            PermissionInfo objCustomModulePermission;
                            objCustomModulePermission = (PermissionInfo)arrCustomModulePermissions[j];
                            AddModulePermission(objModule, objCustomModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess);
                        }
                    }
                }


                objModule.AllTabs   = false;
                objModule.Alignment = align;
                ModuleId            = objModules.AddModule(objModule);
            }
            return(ModuleId);
        }
 private static void RemoveTab(TabHostItemsSourceGenerator generator, TabInfo tab)
 {
 }
        /// <summary>
        /// 初始化的方法
        /// </summary>
        public void Init()
        {
            if (!ThemePlugin_Init)
            {
                Int32 x_ModuleID = 0;

                TabInfo parentTab = BSkin.objTabs.GetTabByName("Admin", BSkin.PortalSettings.PortalId);

                if (parentTab != null && parentTab.TabID > 0)
                {
                    TabInfo dnnTab = BSkin.objTabs.GetTabByName("ThemePlugin", BSkin.PortalSettings.PortalId, parentTab.TabID);
                    if (!(dnnTab != null && dnnTab.TabID > 0))
                    {
                        dnnTab             = new TabInfo();
                        dnnTab.PortalID    = BSkin.PortalSettings.PortalId;
                        dnnTab.TabName     = "ThemePlugin";
                        dnnTab.Title       = "ThemePlugin";
                        dnnTab.IsVisible   = true;
                        dnnTab.DisableLink = false;
                        dnnTab.IsDeleted   = false;

                        if (parentTab != null && parentTab.TabID > 0)
                        {
                            dnnTab.PortalID = parentTab.PortalID;
                            dnnTab.ParentId = parentTab.TabID;
                            dnnTab.Level    = parentTab.Level + 1;
                            dnnTab.TabPermissions.Clear();
                            dnnTab.TabPermissions.AddRange(parentTab.TabPermissions);//增加权限
                        }
                        else
                        {
                            dnnTab.ParentId = Null.NullInteger;
                            dnnTab.Level    = 0;
                        }
                        dnnTab.TabPath = DotNetNuke.Common.Globals.GenerateTabPath(dnnTab.ParentId, dnnTab.TabName);
                        dnnTab.TabID   = BSkin.objTabs.AddTab(dnnTab);

                        if (dnnTab.TabID > 0)
                        {
                            x_ModuleID = AddNewModule(dnnTab);
                        }
                    }

                    if (!(ThemePlugin_Init_ModuleID > 0 && ThemePlugin_Init_TabID > 0))
                    {
                        if (!(x_ModuleID > 0))
                        {
                            x_ModuleID = AddNewModule(dnnTab);
                        }


                        BSkin.UpdateSetting("Init_ThemePlugin_TabID", dnnTab.TabID.ToString());
                        BSkin.UpdateSetting("Init_ThemePlugin_ModuleID", x_ModuleID.ToString());
                    }



                    BSkin.UpdateSetting("Init_ThemePlugin", "true");
                }
            }
        }
Example #21
0
        private static void ProcessTab(DNNNode objRootNode, TabInfo objTab, Hashtable objTabLookup, Hashtable objBreadCrumbs, int intLastBreadCrumbId, ToolTipSource eToolTips, int intStartTabId,
                                       int intDepth, int intNavNodeOptions)
        {
            PortalSettings objPortalSettings = PortalController.GetCurrentPortalSettings();

            DNNNodeCollection objRootNodes = objRootNode.DNNNodes;

            bool showHidden = (intNavNodeOptions & (int)NavNodeOptions.IncludeHiddenNodes) == (int)NavNodeOptions.IncludeHiddenNodes;

            if (CanShowTab(objTab, TabPermissionController.CanAdminPage(), true, showHidden)) //based off of tab properties, is it shown
            {
                DNNNodeCollection objParentNodes;
                DNNNode           objParentNode = objRootNodes.FindNode(objTab.ParentId.ToString());
                bool blnParentFound             = objParentNode != null;
                if (objParentNode == null)
                {
                    objParentNode = objRootNode;
                }
                objParentNodes = objParentNode.DNNNodes;
                if (objTab.TabID == intStartTabId)
                {
                    //is this the starting tab
                    if ((intNavNodeOptions & (int)NavNodeOptions.IncludeParent) != 0)
                    {
                        //if we are including parent, make sure there is one, then add
                        if (objTabLookup[objTab.ParentId] != null)
                        {
                            AddNode((TabInfo)objTabLookup[objTab.ParentId], objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                            objParentNode  = objRootNodes.FindNode(objTab.ParentId.ToString());
                            objParentNodes = objParentNode.DNNNodes;
                        }
                    }
                    if ((intNavNodeOptions & (int)NavNodeOptions.IncludeSelf) != 0)
                    {
                        //if we are including our self (starting tab) then add
                        AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                    }
                }
                else if (((intNavNodeOptions & (int)NavNodeOptions.IncludeSiblings) != 0) && IsTabSibling(objTab, intStartTabId, objTabLookup))
                {
                    //is this a sibling of the starting node, and we are including siblings, then add it
                    AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                }
                else
                {
                    if (blnParentFound) //if tabs parent already in hierarchy (as is the case when we are sending down more than 1 level)
                    {
                        //parent will be found for siblings.  Check to see if we want them, if we don't make sure tab is not a sibling
                        if (((intNavNodeOptions & (int)NavNodeOptions.IncludeSiblings) != 0) || IsTabSibling(objTab, intStartTabId, objTabLookup) == false)
                        {
                            //determine if tab should be included or marked as pending
                            bool blnPOD = (intNavNodeOptions & (int)NavNodeOptions.MarkPendingNodes) != 0;
                            if (IsTabPending(objTab, objParentNode, objRootNode, intDepth, objBreadCrumbs, intLastBreadCrumbId, blnPOD))
                            {
                                if (blnPOD)
                                {
                                    objParentNode.HasNodes = true; //mark it as a pending node
                                }
                            }
                            else
                            {
                                AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                            }
                        }
                    }
                    else if ((intNavNodeOptions & (int)NavNodeOptions.IncludeSelf) == 0 && objTab.ParentId == intStartTabId)
                    {
                        //if not including self and parent is the start id then add
                        AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                    }
                }
            }
        }
        public ConsoleResultModel Run()
        {
            StringBuilder sbMessage = new StringBuilder();

            try
            {
                TabInfo tab = new TabInfo();
                tab.TabName  = Name;
                tab.PortalID = PortalId;
                if (!string.IsNullOrEmpty(Title))
                {
                    tab.Title = Title;
                }
                if (!string.IsNullOrEmpty(Url))
                {
                    tab.Url = Url;
                }
                if (!string.IsNullOrEmpty(Description))
                {
                    tab.Description = Description;
                }
                if (!string.IsNullOrEmpty(Keywords))
                {
                    tab.KeyWords = Keywords;
                }
                if (ParentId.HasValue)
                {
                    tab.ParentId = (int)ParentId;
                }
                else
                {
                    tab.ParentId = CurrentTab.ParentId;
                }
                ParentTab = (new TabController()).GetTab(tab.ParentId, PortalId);
                if (ParentTab != null)
                {
                    tab.TabPermissions.AddRange(ParentTab.TabPermissions);
                }

                tab.IsVisible = (bool)Visible;

                // create the tab
                var lstResults = new List <PageModel>();
                var newTabId   = TabController.Instance.AddTab(tab);
                if (newTabId > 0)
                {
                    // success
                    var addedTab = TabController.Instance.GetTab(newTabId, PortalId);
                    if (addedTab == null)
                    {
                        return(new ConsoleErrorResultModel(string.Format("Unable to retrieve newly created page with ID of '{0}'", newTabId)));
                    }
                    lstResults.Add(new PageModel(addedTab));
                }
                else
                {
                    return(new ConsoleErrorResultModel(string.Format("Unable to create the new page")));
                }

                return(new ConsoleResultModel("The page has been created")
                {
                    data = lstResults
                });
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }

            return(new ConsoleErrorResultModel("An unexpected error has occurred, please see the Event Viewer for more details"));
        }
Example #23
0
 private void ����Ի�ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (lstVisitors.SelectedItems.Count>0)
     {
         if (IsIP == lstVisitors.SelectedItems[0].SubItems[2].Text)
         {
             DialogResult choice = MessageBox.Show("��������û���������", "�Ƿ��ط�?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
             if (choice == DialogResult.OK)
             {
                 RequestInfo info = this.lstVisitors.SelectedItems[0].Tag as RequestInfo;
                 ChatRequestInfo requestinfo = new ChatRequestInfo();
                 requestinfo.ChatId = Guid.NewGuid().ToString();//chatid
                 requestinfo.AccountId = info.AccoutId.ToString();
                 requestinfo.VisitorIP = lstVisitors.SelectedItems[0].SubItems[2].Text;//IP
                 requestinfo.AcceptByOpereratorId = Program.CurrentOperator.Id; //������Ա
                 requestinfo.RequestDate = DateTime.Now;
                 requestinfo.VisitorName = "";
                 requestinfo.VisitorEmail = "";
                 requestinfo.VisitorUserAgent = lstVisitors.SelectedItems[0].SubItems[4].Text;//�����
                 requestinfo.WasAccept = false;
                 //��Ϣ��ʾ
                 TabPage tab = new TabPage(requestinfo.VisitorIP);
                 LiveChat lc = new LiveChat();
                 lc.Tag = tabChats;
                 lc.ChatRequest = requestinfo;
                 lc.Dock = DockStyle.Fill;
                 tab.Controls.Add(lc);
                 tabChats.TabPages.Add(tab);
                 tab.Focus();
                 TabInfo tabInfo = new TabInfo();
                 tabInfo.ChatId = requestinfo.ChatId;
                 tabInfo.Dock = DockStyle.Fill;
                 if (currentVisitors.ContainsKey(requestinfo.VisitorIP))
                 {
                     tabInfo.RequestEntity = currentVisitors[requestinfo.VisitorIP] as RequestInfo;
                 }
                 //�޸�������Ϣ
                 chatInfo.Add(tabInfo);
                 RefreshTabInfo();
                 IsIP = lstVisitors.SelectedItems[0].SubItems[2].Text;
                 ws.TransferChat(requestinfo);
                 //�޸Ŀͷ����
                 ws.AcceptChatRequest(requestinfo.ChatId, Program.CurrentOperator.Id);//������Ա
             }
         }
         else
         {
             DialogResult choice = MessageBox.Show("�Ƿ�ȷ�Ϸ�������", "YesNo?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (choice == DialogResult.Yes)
             {
                 RequestInfo info = this.lstVisitors.SelectedItems[0].Tag as RequestInfo;
                 ChatRequestInfo requestinfo = new ChatRequestInfo();
                 requestinfo.ChatId = Guid.NewGuid().ToString();//chatid
                 requestinfo.AccountId = info.AccoutId.ToString();
                 requestinfo.VisitorIP = lstVisitors.SelectedItems[0].SubItems[2].Text;//IP
                 requestinfo.AcceptByOpereratorId = Program.CurrentOperator.Id; //������Ա
                 requestinfo.RequestDate = DateTime.Now;
                 requestinfo.VisitorName = "";
                 requestinfo.VisitorEmail = "";
                 requestinfo.VisitorUserAgent = lstVisitors.SelectedItems[0].SubItems[4].Text;//�����
                 requestinfo.WasAccept = false;
                 ws.TransferChat(requestinfo);
                 IsIP = lstVisitors.SelectedItems[0].SubItems[2].Text;
                 //��Ϣ��ʾ
                 TabPage tab = new TabPage(requestinfo.VisitorIP);
                 LiveChat lc = new LiveChat();
                 lc.Tag = tabChats;
                 lc.ChatRequest = requestinfo;
                 lc.Dock = DockStyle.Fill;
                 tab.Controls.Add(lc);
                 tabChats.TabPages.Add(tab);
                 tab.Focus();
                 TabInfo tabInfo = new TabInfo();
                 tabInfo.ChatId = requestinfo.ChatId;
                 tabInfo.Dock = DockStyle.Fill;
                 if (currentVisitors.ContainsKey(requestinfo.VisitorIP))
                 {
                     tabInfo.RequestEntity = currentVisitors[requestinfo.VisitorIP] as RequestInfo;
                 }
                 //�޸�������Ϣ
                 chatInfo.Add(tabInfo);
                 RefreshTabInfo();
             }
         }
     }
     else
     {
         MessageBox.Show("�㻹û��ѡ���˭���жԻ�","��ѡ��",MessageBoxButtons.OK,MessageBoxIcon.Stop);
     }
 }
Example #24
0
 private static bool?CacheIncludeExclude(TabInfo tab)
 {
     return(tab.TabSettings["CacheIncludeExclude"] != null ? (string)tab.TabSettings["CacheIncludeExclude"] == "1" : (bool?)null);
 }
Example #25
0
        void richEditControl_InitializeDocument(object sender, EventArgs e) {
            var document = Control.Document;
            document.BeginUpdate();
            try {
                document.DefaultCharacterProperties.FontName = "Courier New";
                document.DefaultCharacterProperties.FontSize = 10;
                document.Sections[0].Page.Width = Units.InchesToDocumentsF(100);

                SizeF tabSize = Control.MeasureSingleLineString("    ", document.DefaultCharacterProperties);
                TabInfoCollection tabs = document.Paragraphs[0].BeginUpdateTabs(true);
                try {
                    for (int i = 1; i <= 30; i++) {
                        var tab = new TabInfo { Position = i * tabSize.Width };
                        tabs.Add(tab);
                    }
                }
                finally {
                    document.Paragraphs[0].EndUpdateTabs(tabs);
                }
            }
            finally {
                document.EndUpdate();
            }
        }
Example #26
0
 private static bool LinkNewWindow(TabInfo tab)
 {
     return(tab.TabSettings["LinkNewWindow"] != null && (string)tab.TabSettings["LinkNewWindow"] == "True");
 }
        /// <summary>
        /// For the supplied options, return a tab path for the specified tab.
        /// </summary>
        /// <param name="tab">TabInfo object of selected tab.</param>
        /// <param name="settings">FriendlyUrlSettings.</param>
        /// <param name="options"></param>
        /// <param name="ignoreCustomRedirects">Whether to add in the customised Tab redirects or not.</param>
        /// <param name="homePageSiteRoot"></param>
        /// <param name="isHomeTab"></param>
        /// <param name="cultureCode"></param>
        /// <param name="isDefaultCultureCode"></param>
        /// <param name="hasPath"></param>
        /// <param name="dropLangParms"></param>
        /// <param name="customHttpAlias"></param>
        /// <param name="isCustomPath"></param>
        /// <param name="parentTraceId"></param>
        /// <remarks>751 : include isDefaultCultureCode flag to determine when using the portal default language
        /// 770 : include custom http alias output for when the Url uses a specific alias due to custom Url rules
        ///  : include new out parameter 'isCustomPath' to return whether the Url was generated from Url-Master custom url.
        /// </remarks>
        /// <returns>The tab path as specified.</returns>
        internal static string GetTabPath(
            TabInfo tab,
            FriendlyUrlSettings settings,
            FriendlyUrlOptions options,
            bool ignoreCustomRedirects,
            bool homePageSiteRoot,
            bool isHomeTab,
            string cultureCode,
            bool isDefaultCultureCode,
            bool hasPath,
            out bool dropLangParms,
            out string customHttpAlias,
            out bool isCustomPath,
            Guid parentTraceId)
        {
            string newTabPath;

            dropLangParms   = false;
            customHttpAlias = null;
            isCustomPath    = false;
            if (homePageSiteRoot && isHomeTab && !hasPath)

            // && !isDefaultCultureCode - not working for non-language specifc custom root urls
            {
                newTabPath = "/"; // site root for home page
            }
            else
            {
                // build the tab path and check for space replacement
                string baseTabPath = TabIndexController.GetTabPath(tab, options, parentTraceId);

                // this is the new tab path
                newTabPath = baseTabPath;

                // 871 : case insensitive compare for culture code, all lookups done on lower case
                string cultureCodeKey = string.Empty;
                if (cultureCode != null)
                {
                    cultureCodeKey = cultureCode.ToLowerInvariant();
                }

                bool checkForCustomHttpAlias = false;

                // get a custom tab name if redirects are being used
                SharedDictionary <string, string> customAliasForTabs = null;
                SharedDictionary <int, SharedDictionary <string, string> > urlDict;

                // 886 : don't fetch custom urls for host tabs (host tabs can't have redirects or custom Urls)
                if (tab.PortalID > -1)
                {
                    urlDict = CustomUrlDictController.FetchCustomUrlDictionary(tab.PortalID, false, false, settings, out customAliasForTabs, parentTraceId);
                }
                else
                {
                    urlDict = new SharedDictionary <int, SharedDictionary <string, string> >();

                    // create dummy dictionary for this tab
                }

                if (ignoreCustomRedirects == false)
                {
                    // if not ignoring the custom redirects, look for the Url of the page in this list
                    // this will be used as the page path if there is one.
                    using (urlDict.GetReadLock())
                    {
                        if (urlDict.ContainsKey(tab.TabID))
                        {
                            // we want the custom value
                            string customTabPath = null;
                            SharedDictionary <string, string> tabpaths = urlDict[tab.TabID];

                            using (tabpaths.GetReadLock())
                            {
                                if (tabpaths.ContainsKey(cultureCodeKey))
                                {
                                    customTabPath = tabpaths[cultureCodeKey];
                                    dropLangParms = true;

                                    // the url is based on a custom value which has embedded language parms, therefore don't need them in the url
                                }
                                else
                                {
                                    if (isDefaultCultureCode && tabpaths.ContainsKey(string.Empty))
                                    {
                                        customTabPath = tabpaths[string.Empty];

                                        // dropLangParms = true;//drop the language parms if they exist, because this is the default language
                                    }
                                }
                            }

                            if (customTabPath != null)
                            {
                                // 770 : pull out custom http alias if in string
                                int aliasSeparator = customTabPath.IndexOf("::", StringComparison.Ordinal);
                                if (aliasSeparator > 0)
                                {
                                    customHttpAlias = customTabPath.Substring(0, aliasSeparator);
                                    newTabPath      = customTabPath.Substring(aliasSeparator + 2);
                                }
                                else
                                {
                                    newTabPath = customTabPath;
                                }
                            }

                            if (newTabPath == string.Empty && hasPath)
                            {
                                // can't pass back a custom path which is blank if there are path segments to the requested final Url
                                newTabPath = baseTabPath; // revert back to the standard DNN page path
                            }
                            else
                            {
                                isCustomPath = true; // we are providing a custom Url
                            }
                        }
                        else
                        {
                            checkForCustomHttpAlias = true;
                        }
                    }
                }
                else
                {
                    checkForCustomHttpAlias = true;

                    // always want to check for custom alias, even when we don't want to see any custom redirects
                }

                // 770 : check for custom alias in these tabs
                if (checkForCustomHttpAlias && customAliasForTabs != null)
                {
                    string key = tab.TabID.ToString() + ":" + cultureCodeKey;
                    using (customAliasForTabs.GetReadLock())
                    {
                        if (customAliasForTabs.ContainsKey(key))
                        {
                            // this tab uses a custom alias
                            customHttpAlias = customAliasForTabs[key];
                            isCustomPath    = true; // using custom alias
                        }
                    }
                }

                if (!dropLangParms)
                {
                    string tabCultureCode = tab.CultureCode;
                    if (!string.IsNullOrEmpty(tabCultureCode))
                    {
                        dropLangParms = true;

                        // if the tab has a specified culture code, then drop the language parameters from the friendly Url
                    }
                }

                // make lower case if necessary
                newTabPath = AdvancedFriendlyUrlProvider.ForceLowerCaseIfAllowed(tab, newTabPath, settings);
            }

            return(newTabPath);
        }
Example #28
0
        private static bool AllowIndex(TabInfo tab)
        {
            bool allowIndex;

            return(!tab.TabSettings.ContainsKey("AllowIndex") || !bool.TryParse(tab.TabSettings["AllowIndex"].ToString(), out allowIndex) || allowIndex);
        }
Example #29
0
        public static string GetRichValue(ProfilePropertyDefinition property, string formatString, CultureInfo formatProvider)
        {
            string result = "";

            if (!String.IsNullOrEmpty(property.PropertyValue) || DisplayDataType(property).Equals("image", StringComparison.InvariantCultureIgnoreCase))
            {
                switch (DisplayDataType(property).ToLowerInvariant())
                {
                case "truefalse":
                    result = PropertyAccess.Boolean2LocalizedYesNo(Convert.ToBoolean(property.PropertyValue), formatProvider);
                    break;

                case "date":
                case "datetime":
                    if (formatString == string.Empty)
                    {
                        formatString = "g";
                    }
                    result = DateTime.Parse(property.PropertyValue, CultureInfo.InvariantCulture).ToString(formatString, formatProvider);
                    break;

                case "integer":
                    if (formatString == string.Empty)
                    {
                        formatString = "g";
                    }
                    result = int.Parse(property.PropertyValue).ToString(formatString, formatProvider);
                    break;

                case "page":
                    int tabid;
                    if (int.TryParse(property.PropertyValue, out tabid))
                    {
                        TabInfo tab = TabController.Instance.GetTab(tabid, Null.NullInteger, false);
                        if (tab != null)
                        {
                            result = string.Format("<a href='{0}'>{1}</a>", TestableGlobals.Instance.NavigateURL(tabid), tab.LocalizedTabName);
                        }
                    }
                    break;

                case "image":
                    //File is stored as a FileID
                    int fileID;
                    if (Int32.TryParse(property.PropertyValue, out fileID) && fileID > 0)
                    {
                        result = Globals.LinkClick(String.Format("fileid={0}", fileID), Null.NullInteger, Null.NullInteger);
                    }
                    else
                    {
                        result = IconController.IconURL("Spacer", "1X1");
                    }
                    break;

                case "richtext":
                    var objSecurity = PortalSecurity.Instance;
                    result = PropertyAccess.FormatString(objSecurity.InputFilter(HttpUtility.HtmlDecode(property.PropertyValue), PortalSecurity.FilterFlag.NoScripting), formatString);
                    break;

                default:
                    result = HttpUtility.HtmlEncode(PropertyAccess.FormatString(property.PropertyValue, formatString));
                    break;
                }
            }
            return(result);
        }
Example #30
0
        public static T ConvertToPageSettings <T>(TabInfo tab) where T : PageSettings, new()
        {
            if (tab == null)
            {
                return(null);
            }

            var pageManagementController = PageManagementController.Instance;

            var description = !string.IsNullOrEmpty(tab.Description) ? tab.Description : PortalSettings.Current.Description;
            var keywords    = !string.IsNullOrEmpty(tab.KeyWords) ? tab.KeyWords : PortalSettings.Current.KeyWords;
            var pageType    = GetPageType(tab.Url);

            var file     = GetFileRedirection(tab.Url);
            var fileId   = file?.FileId;
            var fileUrl  = file?.Folder;
            var fileName = file?.FileName;

            return(new T
            {
                TabId = tab.TabID,
                Name = tab.TabName,
                AbsoluteUrl = tab.FullUrl,
                LocalizedName = tab.LocalizedTabName,
                Title = tab.Title,
                Description = description,
                Keywords = keywords,
                Tags = string.Join(",", from t in tab.Terms select t.Name),
                Alias = PortalSettings.Current.PortalAlias.HTTPAlias,
                Url = pageManagementController.GetTabUrl(tab),
                ExternalRedirection = pageType == "url" ? tab.Url : null,
                FileIdRedirection = pageType == "file" ? fileId : null,
                FileFolderPathRedirection = pageType == "file" ? fileUrl : null,
                FileNameRedirection = pageType == "file" ? fileName : null,
                ExistingTabRedirection = pageType == "tab" ? tab.Url : null,
                Created = pageManagementController.GetCreatedInfo(tab),
                Hierarchy = pageManagementController.GetTabHierarchy(tab),
                Status = GetTabStatus(tab),
                PageType = pageType,
                CreatedOnDate = tab.CreatedOnDate,
                IncludeInMenu = tab.IsVisible,
                CustomUrlEnabled = !tab.IsSuperTab && (Config.GetFriendlyUrlProvider() == "advanced"),
                StartDate = tab.StartDate != Null.NullDate ? tab.StartDate : (DateTime?)null,
                EndDate = tab.EndDate != Null.NullDate ? tab.EndDate : (DateTime?)null,
                IsSecure = tab.IsSecure,
                AllowIndex = AllowIndex(tab),
                CacheProvider = (string)tab.TabSettings["CacheProvider"],
                CacheDuration = CacheDuration(tab),
                CacheIncludeExclude = CacheIncludeExclude(tab),
                CacheIncludeVaryBy = (string)tab.TabSettings["IncludeVaryBy"],
                CacheExcludeVaryBy = (string)tab.TabSettings["ExcludeVaryBy"],
                CacheMaxVaryByCount = MaxVaryByCount(tab),
                PageHeadText = tab.PageHeadText,
                SiteMapPriority = tab.SiteMapPriority,
                PermanentRedirect = tab.PermanentRedirect,
                LinkNewWindow = LinkNewWindow(tab),
                PageStyleSheet = (string)tab.TabSettings["CustomStylesheet"],
                ThemeName = GetThemeNameFromSkinSrc(tab.SkinSrc),
                SkinSrc = tab.SkinSrc,
                ContainerSrc = tab.ContainerSrc,
                HasChild = pageManagementController.TabHasChildren(tab)
            });
        }
            public void OnTabChanged(string tabId)
            {
                var newTab = _tabs[tabId];
                if (_lastTab != newTab) {
                    var ft = _activity.SupportFragmentManager.BeginTransaction();
                    if (_lastTab != null) {
                        if (_lastTab.fragment != null) {
                            ft.Detach(_lastTab.fragment);
                        }
                    }
                    if (newTab != null) {
                        if (newTab.fragment == null) {
                            newTab.fragment = Fragment.Instantiate(_activity, newTab.clss.Name, newTab.args);
                            ft.Add(_containerId, newTab.fragment, newTab.tag);
                        } else {
                            ft.Attach(newTab.fragment);
                        }
                    }

                    _lastTab = newTab;
                    ft.Commit();
                    _activity.SupportFragmentManager.ExecutePendingTransactions();
                }
            }
Example #32
0
        /// <summary>
        /// Adds a chat message to the specified tab.
        /// </summary>
        /// <param name="tabId">The tab id.</param>
        /// <param name="text">The message.</param>
        public void ReceiveChatMessage(int tabId, string text)
        {
            TabInfo tabInfo = this.GetTabInfo(tabId);

            // Make sure we have tab info
            if (tabInfo == null || tabInfo.content == null)
            {
                return;
            }

            // Create the text line
            GameObject obj = new GameObject("Text " + tabInfo.content.childCount.ToString(), typeof(RectTransform));

            // Prepare the game object
            obj.layer = this.gameObject.layer;

            // Get the rect transform
            RectTransform rectTransform = (obj.transform as RectTransform);

            // Prepare the rect transform
            rectTransform.localScale = new Vector3(1f, 1f, 1f);
            rectTransform.pivot      = new Vector2(0f, 1f);
            rectTransform.anchorMin  = new Vector2(0f, 1f);
            rectTransform.anchorMax  = new Vector2(0f, 1f);

            // Set the parent
            rectTransform.SetParent(tabInfo.content, false);

            // Add the text component
            Text textComp = obj.AddComponent <Text>();

            // Prepare the text component
            textComp.font        = this.m_TextFont;
            textComp.fontSize    = this.m_TextFontSize;
            textComp.lineSpacing = this.m_TextLineSpacing;
            textComp.color       = this.m_TextColor;
            textComp.text        = text;

            // Prepare the text effect
            if (this.m_TextEffect != TextEffect.None)
            {
                switch (this.m_TextEffect)
                {
                case TextEffect.Shadow:
                    Shadow shadow = obj.AddComponent <Shadow>();
                    shadow.effectColor    = this.m_TextEffectColor;
                    shadow.effectDistance = this.m_TextEffectDistance;
                    break;

                case TextEffect.Outline:
                    NicerOutline outline = obj.AddComponent <NicerOutline>();
                    outline.effectColor    = this.m_TextEffectColor;
                    outline.effectDistance = this.m_TextEffectDistance;
                    break;
                }
            }

            // Rebuild the content layout
            LayoutRebuilder.ForceRebuildLayoutImmediate(tabInfo.content as RectTransform);

            // Scroll to bottom
            this.OnScrollToBottomClick();
        }
            public void AddTab(TabHost.TabSpec tabSpec, System.Type clss, Bundle args) {
                tabSpec.SetContent(new DummyTabFactory(mContext));
                string tag = tabSpec.GetTag();

                TabInfo info = new TabInfo(tag, clss, args);
                mTabs.Add(info);
                mTabHost.AddTab(tabSpec);
                NotifyDataSetChanged();
            }
Example #34
0
        /// <summary>Called when a module is upgraded.</summary>
        /// <param name="version">The version.</param>
        /// <returns>Success if all goes well, otherwise, Failed</returns>
        public string UpgradeModule(string version)
        {
            try
            {
                switch (version)
                {
                case "07.04.00":
                    const string ResourceFile    = ModuleFolder + "/App_LocalResources/ProviderConfiguration.ascx.resx";
                    string       pageName        = Localization.GetString("HTMLEditorPageName", ResourceFile);
                    string       pageDescription = Localization.GetString("HTMLEditorPageDescription", ResourceFile);

                    // Create HTML Editor Config Page (or get existing one)
                    TabInfo editorPage = Upgrade.AddHostPage(pageName, pageDescription, ModuleFolder + "/images/HtmlEditorManager_Standard_16x16.png", ModuleFolder + "/images/HtmlEditorManager_Standard_32x32.png", false);

                    // Find the RadEditor control and remove it
                    Upgrade.RemoveModule("RadEditor Manager", editorPage.TabName, editorPage.ParentId, false);

                    // Add Module To Page
                    int moduleDefId = this.GetModuleDefinitionID("DotNetNuke.HtmlEditorManager", "Html Editor Management");
                    Upgrade.AddModuleToPage(editorPage, moduleDefId, pageName, ModuleFolder + "/images/HtmlEditorManager_Standard_32x32.png", true);

                    foreach (var item in DesktopModuleController.GetDesktopModules(Null.NullInteger))
                    {
                        DesktopModuleInfo moduleInfo = item.Value;

                        if (moduleInfo.ModuleName == "DotNetNuke.HtmlEditorManager")
                        {
                            moduleInfo.Category = "Host";
                            DesktopModuleController.SaveDesktopModule(moduleInfo, false, false);
                        }
                    }

                    break;

                case "09.01.01":
                    if (RadEditorProviderInstalled())
                    {
                        UpdateRadCfgFiles();
                    }
                    if (TelerikAssemblyExists())
                    {
                        UpdateWebConfigFile();
                    }
                    break;

                case "09.02.00":
                    if (TelerikAssemblyExists())
                    {
                        UpdateTelerikEncryptionKey("Telerik.Web.UI.DialogParametersEncryptionKey");
                    }
                    break;

                case "09.02.01":
                    if (TelerikAssemblyExists())
                    {
                        UpdateTelerikEncryptionKey("Telerik.Upload.ConfigurationHashKey");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                var xlc = new ExceptionLogController();
                xlc.AddLog(ex);

                return("Failed");
            }

            return("Success");
        }
Example #35
0
        private int ValidateTabId(int tabId, int portalId)
        {
            TabInfo tab = TabController.Instance.GetTab(tabId, portalId);

            return(tab != null && !tab.IsDeleted ? tab.TabID : Null.NullInteger);
        }
 ObservableCollection<TabInfo> CreateCollection()
 {
     var list = new List<TabInfo>();
     foreach (var tabState in MainWindow.Instance.GetTabStateInOrder()) {
         var info = new TabInfo();
         info.TabState = tabState;
         var module = ILSpyTreeNode.GetModule(tabState.DecompiledNodes);
         if (module != null) {
             info.FirstModuleName = module.Name;
             info.FirstModuleFullName = module.Location;
         }
         else {
             info.FirstModuleName = string.Empty;
             info.FirstModuleFullName = string.Empty;
         }
         list.Add(info);
     }
     list.Sort((a, b) => StringComparer.InvariantCultureIgnoreCase.Compare(a.TabState.ShortHeader, b.TabState.ShortHeader));
     return new ObservableCollection<TabInfo>(list);
 }
		bool CanSave(TabInfo[] tabs) {
			if (tabs.Length != 1)
				return false;
			var dec = tabs[0].TabState as DecompileTabState;
			if (dec != null)
				return dec.DecompiledNodes.Length > 0;
			return true;
		}
 void ActivateWindow(TabInfo info)
 {
     LastActivatedTabState = info.TabState;
     MainWindow.Instance.SetActiveTab(info.TabState);
 }
Example #39
0
        protected override void ShowPage()
        {
            pagetitle = string.Format("激活{0}", config.Spacename);

            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }

            UserInfo user = Users.GetUserInfo(userid);

            if (config.Enablespace != 1)
            {
                AddErrLine(string.Format("{0}功能已被关闭", config.Spacename));
                return;
            }

            bool isactivespace = false;
            bool isallowapply  = true;

            if (user.Spaceid > 0)
            {
                isactivespace = true;
            }
            else
            {
                if (user.Spaceid < 0)
                {
                    isallowapply = false;
                }
                else
                {
                    if (spaceactiveconfig.AllowPostcount == "1" || spaceactiveconfig.AllowDigestcount == "1" ||
                        spaceactiveconfig.AllowScore == "1" || spaceactiveconfig.AllowUsergroups == "1")
                    {
                        if (spaceactiveconfig.AllowPostcount == "1")
                        {
                            isallowapply = isallowapply && (Convert.ToInt32(spaceactiveconfig.Postcount) <= user.Posts);
                        }
                        if (spaceactiveconfig.AllowDigestcount == "1")
                        {
                            isallowapply = isallowapply &&
                                           (Convert.ToInt32(spaceactiveconfig.Digestcount) <= user.Digestposts);
                        }
                        if (spaceactiveconfig.AllowScore == "1")
                        {
                            isallowapply = isallowapply && (Convert.ToInt32(spaceactiveconfig.Score) <= user.Credits);
                        }
                        if (spaceactiveconfig.AllowUsergroups == "1")
                        {
                            isallowapply = isallowapply &&
                                           (("," + spaceactiveconfig.Usergroups + ",").IndexOf("," + user.Groupid + ",") !=
                                            -1);
                        }
                    }
                    else
                    {
                        isallowapply = false;
                    }
                }
            }

            if (isactivespace)
            {
                AddErrLine("您已经申请过个人空间!");
                return;
            }
            if (!isallowapply)
            {
                AddErrLine("您未被允许申请个人空间!");
                return;
            }

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }
                if (DNTRequest.GetString("spacetitle").Length > 100)
                {
                    AddErrLine("个人空间标题不得超过100个字符");
                    return;
                }
                if (DNTRequest.GetString("description").Length > 200)
                {
                    AddErrLine("个人空间描述不得超过200个字符");
                    return;
                }
                if (DNTRequest.GetInt("bpp", 0) == 0)
                {
                    AddErrLine("显示日志篇数必需是一个大于0的数字");
                    return;
                }

                if (page_err == 0)
                {
                    DataRow dr = DbProvider.GetInstance().GetThemes();
                    spaceconfiginfo                = new SpaceConfigInfo();
                    spaceconfiginfo.UserID         = userid;
                    spaceconfiginfo.Spacetitle     = Utils.HtmlEncode(DNTRequest.GetString("spacetitle"));
                    spaceconfiginfo.Description    = Utils.HtmlEncode(DNTRequest.GetString("description"));
                    spaceconfiginfo.BlogDispMode   = DNTRequest.GetInt("blogdispmode", 0);
                    spaceconfiginfo.Bpp            = DNTRequest.GetInt("bpp", 0);
                    spaceconfiginfo.Commentpref    = DNTRequest.GetInt("commentpref", 0);
                    spaceconfiginfo.MessagePref    = DNTRequest.GetInt("messagepref", 0);
                    spaceconfiginfo.UpdateDateTime = spaceconfiginfo.CreateDateTime = DateTime.Now;
                    string rewritename = DNTRequest.GetFormString("rewritename").Trim();
                    if (rewritename != string.Empty)
                    {
                        if (Globals.CheckSpaceRewriteNameAvailable(rewritename) == 0)
                        {
                            spaceconfiginfo.Rewritename = rewritename;
                        }
                        else
                        {
                            AddErrLine("您输入的 个性域名 不可用或含有非法字符");
                            return;
                        }
                    }
                    else
                    {
                        spaceconfiginfo.Rewritename = "";
                    }

                    spaceconfiginfo.ThemeID      = int.Parse(dr["themeid"].ToString());
                    spaceconfiginfo.ThemePath    = dr["directory"].ToString();
                    spaceconfiginfo.PostCount    = 0;
                    spaceconfiginfo.CommentCount = 0;
                    spaceconfiginfo.VisitedTimes = 0;
                    spaceconfiginfo.DefaultTab   = 0;

                    string errorinfo = "";
                    int    blogid    = DbProvider.GetInstance().AddSpaceConfigData(spaceconfiginfo);
                    Users.UpdateUserSpaceId(-blogid, userid);

                    SpaceActiveConfigInfo _spaceconfiginfo = SpaceActiveConfigs.GetConfig();
                    if (_spaceconfiginfo.ActiveType == "0")
                    {
                        if (errorinfo == "")
                        {
                            SetUrl("index.aspx");
                            SetMetaRefresh();
                            SetShowBackLink(true);
                            AddMsgLine("您的申请已经提交,请等待管理员开通您的个人空间");
                        }
                        else
                        {
                            AddErrLine(errorinfo);
                            return;
                        }
                    }
                    else
                    {
                        Discuz.Data.DatabaseProvider.GetInstance().UpdateUserSpaceId(userid);
                        int     tabid = Spaces.GetNewTabId(userid);
                        TabInfo tab   = new TabInfo();
                        tab.TabID        = tabid;
                        tab.UserID       = userid;
                        tab.DisplayOrder = 0;
                        tab.TabName      = "首页";
                        tab.IconFile     = "";
                        tab.Template     = "template_25_75.htm";
                        Spaces.AddTab(tab);
                        Spaces.AddLocalModule("builtin_calendarmodule.xml", userid, tabid, 1);
                        Spaces.AddLocalModule("builtin_statisticmodule.xml", userid, tabid, 1);
                        Spaces.AddLocalModule("builtin_postlistmodule.xml", userid, tabid, 2);
                        if (SpaceActiveConfigs.GetConfig().Spacegreeting != string.Empty)
                        {
                            SpacePostInfo spacepostsinfo = new SpacePostInfo();
                            spacepostsinfo.Title          = string.Format("欢迎使用 {0} 个人空间", config.Forumtitle);
                            spacepostsinfo.Content        = SpaceActiveConfigs.GetConfig().Spacegreeting;
                            spacepostsinfo.Category       = string.Empty;
                            spacepostsinfo.PostStatus     = 1;
                            spacepostsinfo.CommentStatus  = 0;
                            spacepostsinfo.Postdatetime   = DateTime.Now;
                            spacepostsinfo.Author         = username;
                            spacepostsinfo.Uid            = userid;
                            spacepostsinfo.PostUpDateTime = DateTime.Now;
                            spacepostsinfo.Commentcount   = 0;
                            DbProvider.GetInstance().AddSpacePost(spacepostsinfo);
                        }

                        ///添加最新主题到日志
                        List <TopicInfo> list = Topics.GetTopicsByUserId(userid, 1, config.Topictoblog, 0, 0);
                        foreach (TopicInfo mytopic in list)
                        {
                            int      pid  = Posts.GetFirstPostId(mytopic.Tid);
                            PostInfo post = Posts.GetPostInfo(mytopic.Tid, pid);
                            if (post != null && post.Message.Trim() != string.Empty)
                            {
                                SpacePostInfo spacepost = new SpacePostInfo();
                                spacepost.Author = username;
                                string content = Posts.GetPostMessageHTML(post, new AttachmentInfo[0]);
                                spacepost.Category       = "";
                                spacepost.Content        = content;
                                spacepost.Postdatetime   = DateTime.Now;
                                spacepost.PostStatus     = 1;
                                spacepost.PostUpDateTime = DateTime.Now;
                                spacepost.Title          = post.Title;
                                spacepost.Uid            = userid;
                                DbProvider.GetInstance().AddSpacePost(spacepost);
                            }
                        }
                        SetUrl("space/");
                        SetMetaRefresh();
                        SetShowBackLink(true);
                        AddMsgLine("恭喜您,您的个人空间已经被开通");
                    }
                }
            }
            else
            {
                spaceconfiginfo = BlogProvider.GetSpaceConfigInfo(userid);
            }
        }
Example #40
0
        private static bool IsTabPending(TabInfo objTab, DNNNode objParentNode, DNNNode objRootNode, int intDepth, Hashtable objBreadCrumbs, int intLastBreadCrumbId, bool blnPOD)
        {
            //
            //A
            //|
            //--B
            //| |
            //| --B-1
            //| | |
            //| | --B-1-1
            //| | |
            //| | --B-1-2
            //| |
            //| --B-2
            //|   |
            //|   --B-2-1
            //|   |
            //|   --B-2-2
            //|
            //--C
            //  |
            //  --C-1
            //  | |
            //  | --C-1-1
            //  | |
            //  | --C-1-2
            //  |
            //  --C-2
            //    |
            //    --C-2-1
            //    |
            //    --C-2-2

            //if we aren't restricting depth then its never pending
            if (intDepth == -1)
            {
                return(false);
            }

            //parents level + 1 = current node level
            //if current node level - (roots node level) <= the desired depth then not pending
            if (objParentNode.Level + 1 - objRootNode.Level <= intDepth)
            {
                return(false);
            }


            //--- These checks below are here so tree becomes expands to selected node ---
            if (blnPOD)
            {
                //really only applies to controls with POD enabled, since the root passed in may be some node buried down in the chain
                //and the depth something like 1.  We need to include the appropriate parent's and parent siblings
                //Why is the check for POD required?  Well to allow for functionality like RootOnly requests.  We do not want any children
                //regardless if they are a breadcrumb

                //if tab is in the breadcrumbs then obviously not pending
                if (objBreadCrumbs.Contains(objTab.TabID))
                {
                    return(false);
                }

                //if parent is in the breadcrumb and it is not the last breadcrumb then not pending
                //in tree above say we our breadcrumb is (A, B, B-2) we want our tree containing A, B, B-2 AND B-1 AND C since A and B are expanded
                //we do NOT want B-2-1 and B-2-2, thus the check for Last Bread Crumb
                if (objBreadCrumbs.Contains(objTab.ParentId) && intLastBreadCrumbId != objTab.ParentId)
                {
                    return(false);
                }
            }
            return(true);
        }
 TabInfo[] GetSelectedItems()
 {
     var list = new TabInfo[listView.SelectedItems.Count];
     for (int i = 0; i < list.Length; i++)
         list[i] = (TabInfo)listView.SelectedItems[i];
     return list;
 }
Example #42
0
 public string FriendlyUrl(TabInfo tab, string path, string pageName)
 {
     return(Globals.FriendlyUrl(tab, path, pageName));
 }
 public void Add( TabInfo tabInfo )
 {
     InnerList.Add( tabInfo );
 }
Example #44
0
 public string FriendlyUrl(TabInfo tab, string path, string pageName, PortalSettings settings)
 {
     return(Globals.FriendlyUrl(tab, path, pageName, settings));
 }
 public void Insert( int index, TabInfo tabInfo )
 {
     InnerList.Insert(index, tabInfo);
 }
Example #46
0
 public string FriendlyUrl(TabInfo tab, string path, string pageName, string portalAlias)
 {
     return(Globals.FriendlyUrl(tab, path, pageName, portalAlias));
 }
Example #47
0
        //��������
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (drpChatRequest.SelectedItem != null)
            {
                //����
                player.Stop();
                //������Ϣ
                ChatRequestInfo req = (ChatRequestInfo)drpChatRequest.SelectedItem;
                drpChatRequest.Items.Remove(req);
                drpChatRequest.Text = string.Empty;

                TabPage tab = new TabPage(req.VisitorIP);
                LiveChat lc = new LiveChat();
                lc.Tag = tabChats;
                lc.ChatRequest = req;
                lc.Dock = DockStyle.Fill;
                tab.Controls.Add(lc);
                tabChats.TabPages.Add(tab);
                tab.Focus();

                TabInfo tabInfo = new TabInfo();
                tabInfo.ChatId = req.ChatId;
                tabInfo.Dock = DockStyle.Fill;
                if (currentVisitors.ContainsKey(req.VisitorIP))
                {
                    tabInfo.RequestEntity = currentVisitors[req.VisitorIP] as RequestInfo;
                }
                //���������Ϣ
                chatInfo.Add(tabInfo);
                RefreshTabInfo();
                //�޸Ŀͷ����
                ws.AcceptChatRequest(req.ChatId,Program.CurrentOperator.Id);//������Ա
            }
        }
 public override string FriendlyUrl(TabInfo tab, string path)
 {
     return(_providerInstance.FriendlyUrl(tab, path));
 }
 private static void RemoveTab(TabHostItemsSourceGenerator generator, TabInfo tab)
 {
     var view = tab.Content as View;
     if (view != null)
         view.ClearBindingsRecursively(true, true);
 }
 public override string FriendlyUrl(TabInfo tab, string path, string pageName, PortalSettings settings)
 {
     return(_providerInstance.FriendlyUrl(tab, path, pageName, settings));
 }
 public override string FriendlyUrl(TabInfo tab, string path, string pageName, string portalAlias)
 {
     return(_providerInstance.FriendlyUrl(tab, path, pageName, portalAlias));
 }
Example #52
0
        internal static bool CheckForParameterRedirect(Uri requestUri,
                                                       ref UrlAction result,
                                                       NameValueCollection queryStringCol,
                                                       FriendlyUrlSettings settings)
        {
            //check for parameter replaced works by inspecting the parameters on a rewritten request, comparing
            //them agains the list of regex expressions on the friendlyurls.config file, and redirecting to the same page
            //but with new parameters, if there was a match
            bool redirect = false;
            //get the redirect actions for this portal
            var messages = new List <string>();
            Dictionary <int, List <ParameterRedirectAction> > redirectActions = CacheController.GetParameterRedirects(settings, result.PortalId, ref messages);

            if (redirectActions != null && redirectActions.Count > 0)
            {
                try
                {
                    #region trycatch block

                    string rewrittenUrl = result.RewritePath ?? result.RawUrl;

                    List <ParameterRedirectAction> parmRedirects = null;
                    //find the matching redirects for the tabid
                    int tabId = result.TabId;
                    if (tabId > -1)
                    {
                        if (redirectActions.ContainsKey(tabId))
                        {
                            //find the right set of replaced actions for this tab
                            parmRedirects = redirectActions[tabId];
                        }
                    }
                    //check for 'all tabs' redirections
                    if (redirectActions.ContainsKey(-1)) //-1 means 'all tabs' - rewriting across all tabs
                    {
                        //initialise to empty collection if there are no specific tab redirects
                        if (parmRedirects == null)
                        {
                            parmRedirects = new List <ParameterRedirectAction>();
                        }
                        //add in the all redirects
                        List <ParameterRedirectAction> allRedirects = redirectActions[-1];
                        parmRedirects.AddRange(allRedirects); //add the 'all' range to the tab range
                        tabId = result.TabId;
                    }
                    if (redirectActions.ContainsKey(-2) && result.OriginalPath.ToLower().Contains("default.aspx"))
                    {
                        //for the default.aspx page
                        if (parmRedirects == null)
                        {
                            parmRedirects = new List <ParameterRedirectAction>();
                        }
                        List <ParameterRedirectAction> defaultRedirects = redirectActions[-2];
                        parmRedirects.AddRange(defaultRedirects); //add the default.aspx redirects to the list
                        tabId = result.TabId;
                    }
                    //726 : allow for site-root redirects, ie redirects where no page match
                    if (redirectActions.ContainsKey(-3))
                    {
                        //request is for site root
                        if (parmRedirects == null)
                        {
                            parmRedirects = new List <ParameterRedirectAction>();
                        }
                        List <ParameterRedirectAction> siteRootRedirects = redirectActions[-3];
                        parmRedirects.AddRange(siteRootRedirects); //add the site root redirects to the collection
                    }
                    //OK what we have now is a list of redirects for the currently requested tab (either because it was specified by tab id,
                    // or because there is a replaced for 'all tabs'

                    if (parmRedirects != null && parmRedirects.Count > 0 && rewrittenUrl != null)
                    {
                        foreach (ParameterRedirectAction parmRedirect in parmRedirects)
                        {
                            //regex test each replaced to see if there is a match between the parameter string
                            //and the parmRedirect
                            string compareWith   = rewrittenUrl;
                            var    redirectRegex = new Regex(parmRedirect.LookFor,
                                                             RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                            Match regexMatch    = redirectRegex.Match(compareWith);
                            bool  success       = regexMatch.Success;
                            bool  siteRootTried = false;
                            //if no match, but there is a site root redirect to try
                            if (!success && parmRedirect.TabId == -3)
                            {
                                siteRootTried = true;
                                compareWith   = result.OriginalPathNoAlias;
                                regexMatch    = redirectRegex.Match(compareWith);
                                success       = regexMatch.Success;
                            }
                            if (!success)
                            {
                                result.DebugMessages.Add(parmRedirect.Name + " redirect not matched (" + rewrittenUrl +
                                                         ")");
                                if (siteRootTried)
                                {
                                    result.DebugMessages.Add(parmRedirect.Name + " redirect not matched [site root] (" +
                                                             result.OriginalPathNoAlias + ")");
                                }
                            }
                            else
                            {
                                //success! there was a match in the parameters
                                string parms = redirectRegex.Replace(compareWith, parmRedirect.RedirectTo);
                                if (siteRootTried)
                                {
                                    result.DebugMessages.Add(parmRedirect.Name + " redirect matched [site root] with (" +
                                                             result.OriginalPathNoAlias + "), replaced with " + parms);
                                }
                                else
                                {
                                    result.DebugMessages.Add(parmRedirect.Name + " redirect matched with (" +
                                                             compareWith + "), replaced with " + parms);
                                }
                                string finalUrl = "";
                                //now we need to generate the friendly Url

                                //first check to see if the parameter replacement string has a destination tabid specified
                                if (parms.ToLower().Contains("tabid/"))
                                {
                                    //if so, using a feature whereby the dest tabid can be changed within the parameters, which will
                                    //redirect the page as well as redirecting the parameter values
                                    string[] parmParts = parms.Split('/');
                                    bool     tabIdNext = false;
                                    foreach (string parmPart in parmParts)
                                    {
                                        if (tabIdNext)
                                        {
                                            //changes the tabid of page, effects a page redirect along with a parameter redirect
                                            Int32.TryParse(parmPart, out tabId);
                                            parms = parms.Replace("tabid/" + tabId.ToString(), "");
                                            //remove the tabid/xx from the path
                                            break; //that's it, we're finished
                                        }
                                        if (parmPart.ToLower() == "tabid")
                                        {
                                            tabIdNext = true;
                                        }
                                    }
                                }
                                else if (tabId == -1)
                                {
                                    //find the home tabid for this portal
                                    //735 : switch to custom method for getting portal
                                    PortalInfo portal = CacheController.GetPortal(result.PortalId, true);
                                    tabId = portal.HomeTabId;
                                }
                                if (parmRedirect.ChangeToSiteRoot)
                                {
                                    //when change to siteroot requested, new path goes directly off the portal alias
                                    //so set the finalUrl as the poratl alias
                                    finalUrl = result.Scheme + result.HttpAlias + "/";
                                }
                                else
                                {
                                    //if the tabid has been supplied, do a friendly url provider lookup to get the correct format for the tab url
                                    if (tabId > -1)
                                    {
                                        TabInfo tab = TabController.Instance.GetTab(tabId, result.PortalId, false);
                                        if (tab != null)
                                        {
                                            string path = Globals.glbDefaultPage + TabIndexController.CreateRewritePath(tab.TabID, "");
                                            string friendlyUrlNoParms = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(tab,
                                                                                                                        path,
                                                                                                                        Globals.glbDefaultPage,
                                                                                                                        result.HttpAlias,
                                                                                                                        false,
                                                                                                                        settings,
                                                                                                                        Guid.Empty);
                                            if (friendlyUrlNoParms.EndsWith("/") == false)
                                            {
                                                friendlyUrlNoParms += "/";
                                            }
                                            finalUrl = friendlyUrlNoParms;
                                        }
                                        if (tab == null)
                                        {
                                            result.DebugMessages.Add(parmRedirect.Name +
                                                                     " tabId in redirect rule (tabId:" +
                                                                     tabId.ToString() + ", portalId:" +
                                                                     result.PortalId.ToString() +
                                                                     " ), tab was not found");
                                        }
                                        else
                                        {
                                            result.DebugMessages.Add(parmRedirect.Name +
                                                                     " tabId in redirect rule (tabId:" +
                                                                     tabId.ToString() + ", portalId:" +
                                                                     result.PortalId.ToString() + " ), tab found : " +
                                                                     tab.TabName);
                                        }
                                    }
                                }
                                if (parms.StartsWith("//"))
                                {
                                    parms = parms.Substring(2);
                                }
                                if (parms.StartsWith("/"))
                                {
                                    parms = parms.Substring(1);
                                }

                                if (settings.PageExtensionUsageType != PageExtensionUsageType.Never)
                                {
                                    if (parms.EndsWith("/"))
                                    {
                                        parms = parms.TrimEnd('/');
                                    }
                                    if (parms.Length > 0)
                                    {
                                        //we are adding more parms onto the end, so remove the page extension
                                        //from the parameter list
                                        //946 : exception when settings.PageExtension value is empty
                                        parms += settings.PageExtension;
                                        //816: if page extension is /, then don't do this
                                        if (settings.PageExtension != "/" &&
                                            string.IsNullOrEmpty(settings.PageExtension) == false)
                                        {
                                            finalUrl = finalUrl.Replace(settings.PageExtension, "");
                                        }
                                    }
                                    else
                                    {
                                        //we are removing all the parms altogether, so
                                        //the url needs to end in the page extension only
                                        //816: if page extension is /, then don't do this
                                        if (settings.PageExtension != "/" &&
                                            string.IsNullOrEmpty(settings.PageExtension) == false)
                                        {
                                            finalUrl = finalUrl.Replace(settings.PageExtension + "/",
                                                                        settings.PageExtension);
                                        }
                                    }
                                }
                                //put the replaced parms back on the end
                                finalUrl += parms;

                                //set the final url
                                result.FinalUrl = finalUrl;
                                result.Reason   = RedirectReason.Custom_Redirect;
                                switch (parmRedirect.Action)
                                {
                                case "301":
                                    result.Action = ActionType.Redirect301;
                                    break;

                                case "302":
                                    result.Action = ActionType.Redirect302;
                                    break;

                                case "404":
                                    result.Action = ActionType.Output404;
                                    break;
                                }
                                redirect = true;
                                break;
                            }
                        }
                    }

                    #endregion
                }
                catch (Exception ex)
                {
                    Services.Exceptions.Exceptions.LogException(ex);
                    messages.Add("Exception: " + ex.Message + "\n" + ex.StackTrace);
                }
                finally
                {
                    if (messages.Count > 0)
                    {
                        result.DebugMessages.AddRange(messages);
                    }
                }
            }
            return(redirect);
        }