Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions WordPress/Classes/Models/Blog+CoreDataProperties.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import Foundation
import CoreData

extension Blog {
/// Unusued, to be removed.
@available(*, unavailable)
@NSManaged var apiKey: String?

/// Deprecated, it used to store the blog ID, but it's useless on self hosted, so we're moving to dotComID instead for clarity.
@available(*, unavailable, message="Use dotComID instead")
@NSManaged var blogID: NSNumber

/// The ID for the blog's current theme. Only present for WordPress.com blogs if themes have been Cached.
@NSManaged var currentThemeId: String?

/// Unused, to be removed.
@available(*, unavailable)
@NSManaged var hasOlderPages: Bool

/// Unused, to be removed.
@available(*, unavailable)
@NSManaged var hasOlderPosts: Bool

/// URL for the site icon.
@NSManaged var icon: String?

/// Unused, to ne removed.
@available(*, unavailable)
@NSManaged var isActivated: Bool

/// Stores if the current user is an administrator of the blog.
/// - warning: This is not 100% reliable: if the API is unable to tell us if the user is an admin, we check if the user can edit the blog title and use that as an indicator.
@NSManaged var isAdmin: Bool

/// Stores if the blog is hosted on WordPress.com.
@NSManaged var isHostedAtWPcom: Bool

/// Stores if the blog has more than one author.
@NSManaged var isMultiAuthor: Bool

/// Date of the last time comments were synced.
@NSManaged var lastCommentsSync: NSDate

/// Date of the last time pages were synced.
@NSManaged var lastPagesSync: NSDate

/// Date of the last time posts were synced.
@NSManaged var lastPostsSync: NSDate

/// Unusued, to be removed.
@available(*, unavailable)
@NSManaged var lastStatsSync: NSDate

/// WordPress version for which we last alerted the user about a required update.
/// When the Blog's version is lower than the required MinimumVersion, we show an alert to the user. The MinimumVersion value at that time is stored here so we only show the alert once.
@NSManaged var lastUpdateWarning: String?

/// Stores the blog options as they come from the API.
///
/// For legacy reasons, this currently tries to mimic the structure of the dictionary returned by XML-RPC's wp.getOptions.
///
/// Each value in the dictionary should be a dictionary with keys: "value", "desc", and "readonly".
///
/// For convenience, use getOptionValue(_) to get the value for a specific option.
///
/// - seealso: getOptionValue(_)
@NSManaged var options: [String: AnyObject]?

/// Stores the product ID of the blog's plan.
@NSManaged var planID: NSNumber?

/// Post formats supported by the blog.
/// The key is the post format "slug", and the value is the "label".
@NSManaged var postFormats: [String: String]?

/// Full URL to the site.
@NSManaged var url: String

/// Stores the username for self hosted blogs.
/// - warning: for WordPress.com or Jetpack managed sites this will be `nil`. Use `usernameForSite` instead
/// - seealso: usernameForSite
@NSManaged var username: String?

/// Stores if the blog should be visible.
/// WordPress.com supports hiding blogs from the blog list by going to the [My Blogs](https://dashboard.wordpress.com/wp-admin/index.php?page=my-blogs) section. This property defaults to `true` so self hosted blogs are always visible.
@NSManaged var visible: Bool

/// URL for the XML-RPC endpoing
@NSManaged var xmlrpc: String


// MARK: - Relationships

/// The associated WordPress.com account, if it's the default account
/// If this is a self hosted site with Jetpack connected to a WordPress.com account different than the default account, this will be `nil` and the connected WordPress.com account will be set in `jetpackAccount`.
@NSManaged var account: WPAccount?

/// Inverse relationship to `WPAccount.defaultBlog`. Not very useful, but Core Data requires it, so added it here for completeness.
@NSManaged var accountForDefaultBlog: WPAccount?

/// Cached categories for this blog.
@NSManaged var categories: Set<PostCategory>

/// Cached comments for this blog.
@NSManaged var comments: Set<Comment>

/// Cached Publicize connections for this blog.
@NSManaged var connections: Set<PublicizeConnection>

/// The connected WordPress.com account for a Jetpack site, if different from the default WordPress.com account.
@NSManaged var jetpackAccount: WPAccount?

/// Cached media items for this blog.
@NSManaged var media: Set<Media>

/// Cached menu locations for this blog.
/// - seealso: MenuLocation
@NSManaged var menuLocations: NSOrderedSet//<MenuLocation>

/// Cached menus for this blog.
/// - seealso: Menu
@NSManaged var menus: NSOrderedSet//<Menu>

/// Cached posts for this blog. Includes both posts and pages.
@NSManaged var posts: Set<AbstractPost>

/// Settings for this blog, encapsulated in a BlogSettings instance
/// - seealso: BlogSettings
@NSManaged var settings: BlogSettings?

/// Cached tags for this blog.
@NSManaged var tags: Set<PostTag>

/// Cached available themes for this blog.
@NSManaged var themes: Set<Theme>

/// Cached buttons to share to a third-party service.
@NSManaged var sharingButtons: Set<SharingButton>
}
50 changes: 0 additions & 50 deletions WordPress/Classes/Models/Blog.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,61 +52,13 @@ typedef NS_ENUM(NSInteger, SiteVisibility) {

@interface Blog : NSManagedObject

@property (nonatomic, strong, readwrite) NSNumber *blogID __deprecated_msg("Use dotComID instead");
@property (nonatomic, strong, readwrite) NSNumber *dotComID;
@property (nonatomic, strong, readwrite) NSString *xmlrpc;
@property (nonatomic, strong, readwrite) NSString *apiKey;
@property (nonatomic, strong, readwrite) NSNumber *hasOlderPosts;
@property (nonatomic, strong, readwrite) NSNumber *hasOlderPages;
@property (nonatomic, strong, readwrite) NSSet *posts;
@property (nonatomic, strong, readwrite) NSSet *categories;
@property (nonatomic, strong, readwrite) NSSet *tags;
@property (nonatomic, strong, readwrite) NSSet *comments;
@property (nonatomic, strong, readwrite) NSSet *connections;
@property (nonatomic, strong, readwrite) NSSet *themes;
@property (nonatomic, strong, readwrite) NSSet *media;
@property (nonatomic, strong, readwrite) NSOrderedSet *menus;
@property (nonatomic, strong, readwrite) NSOrderedSet *menuLocations;
@property (nonatomic, strong, readwrite) NSString *currentThemeId;
@property (nonatomic, assign, readwrite) BOOL isSyncingPosts;
@property (nonatomic, assign, readwrite) BOOL isSyncingPages;
@property (nonatomic, assign, readwrite) BOOL isSyncingMedia;
@property (nonatomic, strong, readwrite) NSDate *lastPostsSync;
@property (nonatomic, strong, readwrite) NSDate *lastPagesSync;
@property (nonatomic, strong, readwrite) NSDate *lastCommentsSync;
@property (nonatomic, strong, readwrite) NSDate *lastStatsSync;
@property (nonatomic, strong, readwrite) NSString *lastUpdateWarning;
@property (nonatomic, assign, readwrite) BOOL visible;
@property (nonatomic, weak, readwrite) NSNumber *isActivated;
@property (nonatomic, strong, readwrite) NSDictionary *options;
@property (nonatomic, strong, readwrite) NSDictionary *postFormats;
@property (nonatomic, strong, readwrite) WPAccount *account;
@property (nonatomic, strong, readwrite) WPAccount *jetpackAccount;
@property (nonatomic, assign, readwrite) BOOL videoPressEnabled;
@property (nonatomic, assign, readwrite) BOOL isMultiAuthor;
@property (nonatomic, assign, readwrite) BOOL isHostedAtWPcom;
@property (nonatomic, strong, readwrite) NSString *icon;
@property (nonatomic, assign, readwrite) SiteVisibility siteVisibility;
@property (nonatomic, strong, readwrite) NSNumber *planID;
@property (nonatomic, strong, readwrite) NSSet *sharingButtons;

/**
* @details Maps to a BlogSettings instance, which contains a collection of the available preferences,
* and their values.
*/
@property (nonatomic, strong, readwrite) BlogSettings *settings;

/**
* @details Flags whether the current user is an admin on the blog.
*/
@property (nonatomic, assign, readwrite) BOOL isAdmin;

/**
* @details Stores the username for self hosted sites
*
* @warn For WordPress.com or Jetpack Managed sites this will be nil. Use usernameForSite instead
*/
@property (nonatomic, strong, readwrite) NSString *username;
@property (nonatomic, strong, readwrite) NSString *password;


Expand Down Expand Up @@ -136,8 +88,6 @@ typedef NS_ENUM(NSInteger, SiteVisibility) {
// kept for compatibilty, used as a key to store passwords
@property (weak, readonly) NSString *hostURL;
@property (weak, readonly) NSString *homeURL;
// http://wp.koke.me/sub
@property (nonatomic, strong) NSString *url;
// Used for reachability checks (IDN encoded)
// wp.koke.me
@property (weak, readonly) NSString *hostname;
Expand Down
36 changes: 0 additions & 36 deletions WordPress/Classes/Models/Blog.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,6 @@ @interface Blog ()

@implementation Blog

@dynamic blogID;
@dynamic url;
@dynamic xmlrpc;
@dynamic apiKey;
@dynamic hasOlderPosts;
@dynamic hasOlderPages;
@dynamic posts;
@dynamic categories;
@dynamic tags;
@dynamic comments;
@dynamic connections;
@dynamic themes;
@dynamic media;
@dynamic menus;
@dynamic menuLocations;
@dynamic currentThemeId;
@dynamic lastPostsSync;
@dynamic lastStatsSync;
@dynamic lastPagesSync;
@dynamic lastCommentsSync;
@dynamic lastUpdateWarning;
@dynamic options;
@dynamic postFormats;
@dynamic isActivated;
@dynamic visible;
@dynamic account;
@dynamic jetpackAccount;
@dynamic isAdmin;
@dynamic isMultiAuthor;
@dynamic isHostedAtWPcom;
@dynamic icon;
@dynamic username;
@dynamic settings;
@dynamic planID;
@dynamic sharingButtons;

@synthesize api = _api;
@synthesize isSyncingPosts;
@synthesize isSyncingPages;
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Models/Post.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "NSMutableDictionary+Helpers.h"
#import "NSString+Helpers.h"
#import "ContextManager.h"
#import "WordPress-Swift.h"
#import <WordPressShared/NSString+XMLExtensions.h>

@interface Post()
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Models/Theme.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#import "WPAccount.h"
#import "AccountService.h"
#import "NSString+Helpers.h"
#import "WordPress-Swift.h"

static NSString* const ThemeAdminUrlCustomize = @"customize.php?theme=%@&hide_close=true";
static NSString* const ThemeUrlDemoParameters = @"?demo=true&iframe=true&theme_preview=true";
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Services/CommentService.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "PostService.h"
#import "AbstractPost.h"
#import "NSDate+WordPressJSON.h"
#import "WordPress-Swift.h"

NSUInteger const WPTopLevelHierarchicalCommentsPerPage = 20;
NSInteger const WPNumberOfCommentsToSync = 100;
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Services/PostCategoryService.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "TaxonomyServiceRemote.h"
#import "TaxonomyServiceRemoteREST.h"
#import "TaxonomyServiceRemoteXMLRPC.h"
#import "WordPress-Swift.h"

@implementation PostCategoryService

Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Services/PostTagService.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import "TaxonomyServiceRemoteREST.h"
#import "TaxonomyServiceRemoteXMLRPC.h"
#import "RemoteTaxonomyPaging.h"
#import "WordPress-Swift.h"

@interface PostTagService ()

Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Services/ThemeService.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "ThemeServiceRemote.h"
#import "WPAccount.h"
#import "ContextManager.h"
#import "WordPress-Swift.h"

/**
* @brief Place unordered themes after loaded pages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class WP3DTouchShortcutCreator: NSObject
public func loggedInShortcutArray() -> [UIApplicationShortcutItem] {
var defaultBlogName: String?
if blogService.blogCountForAllAccounts() > 1 {
defaultBlogName = blogService.lastUsedOrFirstBlog().settings.name
defaultBlogName = blogService.lastUsedOrFirstBlog().settings?.name
}

let notificationsShortcut = UIMutableApplicationShortcutItem(type: WP3DTouchShortcutHandler.ShortcutIdentifier.Notifications.type,
Expand Down
7 changes: 6 additions & 1 deletion WordPress/Classes/System/WordPress-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
#import <UIDeviceIdentifier/UIDeviceHardware.h>
#import <NSObject_SafeExpectations/NSDictionary+SafeExpectations.h>

#import "AbstractPost.h"
#import "AccountService.h"
#import "AppRatingUtility.h"

#import "Blog.h"
#import "BlogService.h"
#import "CommentService.h"

#import "Comment.h"
#import "CommentService.h"
#import "Constants.h"
#import "ContextManager.h"
#import "CustomHighlightButton.h"
Expand All @@ -21,6 +23,7 @@

#import "LoginViewController.h"

#import "Media.h"
#import "MediaService.h"
#import "MeHeaderView.h"

Expand All @@ -34,8 +37,10 @@
#import "UIApplication+Helpers.h"

#import "PhotonImageURLHelper.h"
#import "PostCategory.h"
#import "PostListFooterView.h"
#import "PostMetaButton.h"
#import "PostTag.h"
#import "WPPostViewController.h"

#import "ReachabilityUtils.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,9 @@ public class DiscussionSettingsViewController : UITableViewController

// MARK: - Computed Properties
private var settings : BlogSettings {
return blog.settings
// FIXME: Settings is not guaranteed to be non-nil. This might crash
// @koke 2016-02-03
return blog.settings!
}

// MARK: - Typealiases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ public class StartOverViewController: UITableViewController
tableView.deselectSelectedRowWithAnimation(true)

if HelpshiftUtils.isHelpshiftEnabled() {
setupHelpshift(blog.account)

if let account = blog.account {
setupHelpshift(account)
}

let metadata = helpshiftMetadata(blog)
Helpshift.sharedInstance().showConversation(self, withOptions: metadata)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public protocol ThemePresenter: class
return nil
}

for theme in blog.themes as! Set<Theme> {
for theme in blog.themes {
if theme.themeId == themeId {
return theme
}
Expand Down
Loading