public static List <logicalView> getAll(bool includeDisabled) { List <logicalView> views = new List <logicalView>(); foreach (DBView view in DBView.getAll(includeDisabled)) { views.Add(new logicalView(view)); } return(views); }
/// <summary> /// Get a list of views in users database that skin can present for menu /// Returns a list of keyvaluepairs, where /// Key: is the view name used in the buttons hyperlinkparameter property /// Val: can be used as a default display name for the menu item /// </summary> public static List <KeyValuePair <string, string> > GetSkinViews() { List <KeyValuePair <string, string> > viewList = new List <KeyValuePair <string, string> >(); foreach (DBView view in DBView.getAll(false)) { string viewName = view[DBView.cTransToken]; string viewDisplayName = string.IsNullOrEmpty(Translation.GetByName(viewName)) ? viewName : Translation.GetByName(viewName); KeyValuePair <string, string> skinview = new KeyValuePair <string, string>(viewName, viewDisplayName); viewList.Add(skinview); } return(viewList); }
public static void fillDefaults() { DBView dummy = new DBView(); DBView[] views = DBView.getAll(true); if (views == null || views.Length == 0) { // no views in the db => put the default ones DBView view = new DBView(); view[cIndex] = "0"; view[cEnabled] = "1"; view[cSort] = "1"; view[cTransToken] = cTranslateTokenAll; view[cPrettyName] = ""; view[cViewConfig] = @"series<;><;><;>" + "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" + "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; view[cTaggedView] = "0"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "1"; view[cEnabled] = "1"; view[cSort] = "2"; view[cTransToken] = cTranslateTokenFavourite; view[cPrettyName] = ""; view[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenFavourite); view[cTaggedView] = "1"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "2"; view[cEnabled] = "1"; view[cSort] = "3"; view[cTransToken] = cTranslateTokenOnlineFavourite; view[cPrettyName] = ""; view[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenOnlineFavourite); view[cTaggedView] = "1"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "3"; view[cEnabled] = "1"; view[cSort] = "4"; view[cTransToken] = cTranslateTokenUnwatched; view[cPrettyName] = ""; view[cViewConfig] = @"series<;><Episode.Watched>;=;0<;><;>" + "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" + "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; view[cTaggedView] = "0"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "4"; view[cEnabled] = "1"; view[cSort] = "5"; view[cTransToken] = cTranslateTokenChannels; view[cPrettyName] = ""; view[cViewConfig] = @"group:<Series.Network><;><;><;>" + "<nextStep>series<;><;><;>" + "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" + "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; view[cTaggedView] = "0"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "5"; view[cEnabled] = "1"; view[cSort] = "6"; view[cTransToken] = cTranslateTokenGenres; view[cPrettyName] = ""; view[cViewConfig] = @"group:<Series.Genre><;><;><;>" + "<nextStep>series<;><;><;>" + "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" + "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; view[cTaggedView] = "0"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "6"; view[cEnabled] = "1"; view[cSort] = "7"; view[cTransToken] = cTranslateTokenContentRating; view[cPrettyName] = ""; view[cViewConfig] = @"group:<Series.ContentRating><;><;><;>" + "<nextStep>series<;><;><;>" + "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" + "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; view[cTaggedView] = "0"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "7"; view[cEnabled] = "1"; view[cSort] = "8"; view[cTransToken] = cTranslateTokenViewTags; view[cPrettyName] = ""; view[cViewConfig] = @"group:<Series.ViewTags><;><;><;>" + "<nextStep>series<;><;><;>" + "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" + "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; view[cTaggedView] = "0"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "8"; view[cEnabled] = "1"; view[cSort] = "9"; view[cTransToken] = cTranslateTokenLatest; view[cPrettyName] = ""; view[cViewConfig] = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>"; view[cTaggedView] = "0"; view[cParentalControl] = "0"; view.Commit(); view = new DBView(); view[cIndex] = "9"; view[cEnabled] = "1"; view[cSort] = "10"; view[cTransToken] = cTranslateTokenRecentlyAdded; view[cPrettyName] = ""; view[cViewConfig] = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>"; view[cTaggedView] = "0"; view[cParentalControl] = "0"; view.Commit(); } int nCurrentDBVersion = cDBVersion; int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBViewsVersion); while (nUpgradeDBVersion != nCurrentDBVersion) { // WARNING: as of version 4, we can now remove and add views. // Be particularly carefull if adding/Removing/Updating // take care of the upgrade in the table switch (nUpgradeDBVersion) { case 1: //Upgrade to version 2; 'Latest' view doesn't show anything from the future, and shows only from the last 30 days DBView view = new DBView(5); view[cViewConfig] = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>"; view.Commit(); nUpgradeDBVersion++; break; case 2: // Upgrade to version 3, new view 'Recently Added' view = new DBView(); view[cIndex] = "6"; view[cEnabled] = "1"; view[cSort] = "7"; view[cTransToken] = cTranslateTokenRecentlyAdded; view[cPrettyName] = ""; view[cViewConfig] = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>"; view.Commit(); nUpgradeDBVersion++; break; case 3: // Upgrade to version 4, new view 'Content Rating' view = new DBView(); view[cIndex] = "7"; view[cEnabled] = "1"; view[cSort] = "8"; view[cTransToken] = cTranslateTokenContentRating; view[cPrettyName] = ""; view[cViewConfig] = @"group:<Series.ContentRating><;><;><;>" + "<nextStep>series<;><;><;>" + "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" + "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; view[cParentalControl] = "0"; view.Commit(); // New view 'View Tags' view = new DBView(); view[cIndex] = "8"; view[cEnabled] = "1"; view[cSort] = "9"; view[cTransToken] = cTranslateTokenViewTags; view[cPrettyName] = ""; view[cViewConfig] = @"group:<Series.ViewTags><;><;><;>" + "<nextStep>series<;><;><;>" + "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" + "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; view[cParentalControl] = "0"; view.Commit(); nUpgradeDBVersion++; break; case 4: // Get All current Views DBView[] viewList = DBView.getAll(true); // Update old Favourite View to Tagged View foreach (DBView v in viewList) { if (v[DBView.cTransToken] == cTranslateTokenFavourite) { v[cTaggedView] = "1"; v[cTransToken] = cTranslateTokenFavourite; v[cPrettyName] = ""; v[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenFavourite); v.Commit(); } } // Add Online Favourites as Taqged View view = new DBView(); view[cIndex] = viewList.Length; view[cEnabled] = "1"; view[cSort] = viewList.Length + 1; view[cTransToken] = cTranslateTokenOnlineFavourite; view[cPrettyName] = ""; view[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenOnlineFavourite); view[cParentalControl] = "0"; view[cTaggedView] = "1"; view.Commit(); nUpgradeDBVersion++; break; default: nUpgradeDBVersion = nCurrentDBVersion; break; } } DBOption.SetOptions(DBOption.cDBViewsVersion, nCurrentDBVersion); }