Commit d18fb7bf10a77c8d477fff4fc5968b7249a1a4af
1 parent
6f7fd7ac
收藏中英文分离修改
Showing
13 changed files
with
63 additions
and
53 deletions
CNLiveScioLive/AppDelegate.m
| ... | ... | @@ -39,8 +39,7 @@ |
| 39 | 39 | |
| 40 | 40 | [[BaiduMobStat defaultStat] startWithAppId:uBaiduMobStat]; |
| 41 | 41 | |
| 42 | - //收藏 | |
| 43 | - [[DBAction sharedDBAction] createTable]; | |
| 42 | + | |
| 44 | 43 | |
| 45 | 44 | //分享 |
| 46 | 45 | [MobClick startWithAppkey:uMengKey reportPolicy:BATCH channelId:nil]; |
| ... | ... | @@ -51,6 +50,9 @@ |
| 51 | 50 | //语言 |
| 52 | 51 | [self setApplicationLanguage]; |
| 53 | 52 | |
| 53 | + //收藏 | |
| 54 | + [[DBAction sharedDBAction] createTable:@"en"]; | |
| 55 | + [[DBAction sharedDBAction] createTable:@"zh"]; | |
| 54 | 56 | //版本更新 |
| 55 | 57 | [self checkAppUpdate]; |
| 56 | 58 | |
| ... | ... | @@ -101,9 +103,11 @@ |
| 101 | 103 | //获取系统语言 |
| 102 | 104 | if (IS_CHINESE) { |
| 103 | 105 | self.lan =@"zh-Hans"; |
| 106 | + [User_Defaults setObject:@"zh-Hans" forKey:Language_Local]; | |
| 104 | 107 | [IQKeyboardManager sharedManager].toolbarDoneBarButtonItemText = @"完成"; |
| 105 | 108 | }else{ |
| 106 | 109 | self.lan =@"en"; |
| 110 | + [User_Defaults setObject:@"en" forKey:Language_Local]; | |
| 107 | 111 | [IQKeyboardManager sharedManager].toolbarDoneBarButtonItemText = @"Done"; |
| 108 | 112 | } |
| 109 | 113 | } | ... | ... |
CNLiveScioLive/Pages/Home/新闻详情/Controller/ArticleDetailViewController.m
| ... | ... | @@ -216,9 +216,9 @@ |
| 216 | 216 | { |
| 217 | 217 | NSDictionary *dic = [weakSelf.model toDictionary]; |
| 218 | 218 | TableData *notice = [[TableData alloc] initWithJSONDictionary:dic]; |
| 219 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 219 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 220 | 220 | if (!isIn) { |
| 221 | - BOOL isInsert = [[DBAction sharedDBAction] insertTable:notice]; | |
| 221 | + BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 222 | 222 | if (isInsert) { |
| 223 | 223 | [AlertViewTool showHUDAddedToView:weakSelf.view text:CustomStr(@"CollectSuccess")]; |
| 224 | 224 | [weakSelf.detailsView.btn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| ... | ... | @@ -226,7 +226,7 @@ |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | } else { |
| 229 | - BOOL isDelete = [[DBAction sharedDBAction] deleteTable:notice]; | |
| 229 | + BOOL isDelete = [[DBAction sharedDBAction] deleteTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 230 | 230 | if (isDelete) { |
| 231 | 231 | [AlertViewTool showHUDAddedToView:weakSelf.view text:CustomStr(@"CancelCollect")]; |
| 232 | 232 | [weakSelf.detailsView.btn setImage:[UIImage imageNamed:@"cnlive_isfavorite"] forState:UIControlStateNormal]; | ... | ... |
CNLiveScioLive/Pages/Home/新闻详情/Controller/VideoDetailViewController.m
| ... | ... | @@ -227,9 +227,9 @@ static NSString *newsLeftPicTableViewCell = @"CNLiveNewsLeftPicTableViewCell"; |
| 227 | 227 | { |
| 228 | 228 | NSDictionary *dic = [weakSelf.model toDictionary]; |
| 229 | 229 | TableData *notice = [[TableData alloc] initWithJSONDictionary:dic]; |
| 230 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 230 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 231 | 231 | if (!isIn) { |
| 232 | - BOOL isInsert = [[DBAction sharedDBAction] insertTable:notice]; | |
| 232 | + BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 233 | 233 | if (isInsert) { |
| 234 | 234 | [AlertViewTool showHUDAddedToView:weakSelf.view text:CustomStr(@"CollectSuccess")]; |
| 235 | 235 | [weakSelf.detailsView.btn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| ... | ... | @@ -237,7 +237,7 @@ static NSString *newsLeftPicTableViewCell = @"CNLiveNewsLeftPicTableViewCell"; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | } else { |
| 240 | - BOOL isDelete = [[DBAction sharedDBAction] deleteTable:notice]; | |
| 240 | + BOOL isDelete = [[DBAction sharedDBAction] deleteTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 241 | 241 | if (isDelete) { |
| 242 | 242 | [AlertViewTool showHUDAddedToView:weakSelf.view text:CustomStr(@"CancelCollect")]; |
| 243 | 243 | [weakSelf.detailsView.btn setImage:[UIImage imageNamed:@"cnlive_isfavorite"] forState:UIControlStateNormal]; | ... | ... |
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldArticleDetailViewController.m
| ... | ... | @@ -203,7 +203,7 @@ |
| 203 | 203 | |
| 204 | 204 | UIButton *isFavoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 205 | 205 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 206 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 206 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 207 | 207 | if (isIn) { |
| 208 | 208 | [isFavoriteButton setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 209 | 209 | } else { |
| ... | ... | @@ -270,17 +270,17 @@ |
| 270 | 270 | } |
| 271 | 271 | } else if (20000 == btn.tag) { |
| 272 | 272 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 273 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 273 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 274 | 274 | |
| 275 | 275 | if (!isIn) { |
| 276 | - BOOL isInsert = [[DBAction sharedDBAction] insertTable:notice]; | |
| 276 | + BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 277 | 277 | if (isInsert) { |
| 278 | 278 | [AlertViewTool showHUDAddedToView:self.view text:CustomStr(@"CollectSuccess")]; |
| 279 | 279 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | } else { |
| 283 | - BOOL isDelete = [[DBAction sharedDBAction] deleteTable:notice]; | |
| 283 | + BOOL isDelete = [[DBAction sharedDBAction] deleteTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 284 | 284 | if (isDelete) { |
| 285 | 285 | [AlertViewTool showHUDAddedToView:self.view text:CustomStr(@"CancelCollect")]; |
| 286 | 286 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorite"] forState:UIControlStateNormal]; | ... | ... |
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldVideoDetailViewController.m
| ... | ... | @@ -104,7 +104,7 @@ |
| 104 | 104 | |
| 105 | 105 | UIButton *isFavoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 106 | 106 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 107 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 107 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 108 | 108 | if (isIn) { |
| 109 | 109 | [isFavoriteButton setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 110 | 110 | } else { |
| ... | ... | @@ -142,7 +142,7 @@ |
| 142 | 142 | [_webView loadHTMLString:[self setHTMLString] baseURL:nil]; |
| 143 | 143 | } else if (20000 == btn.tag) { |
| 144 | 144 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 145 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 145 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 146 | 146 | |
| 147 | 147 | NSMutableDictionary *author = [NSMutableDictionary dictionaryWithContentsOfFile:FavouriteAuthors_PATH]; |
| 148 | 148 | if (!author) { |
| ... | ... | @@ -150,7 +150,7 @@ |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | if (!isIn) { |
| 153 | - BOOL isInsert = [[DBAction sharedDBAction] insertTable:notice]; | |
| 153 | + BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 154 | 154 | [author setObject:self.authorName forKey:notice.pageUrl]; |
| 155 | 155 | [author writeToFile:FavouriteAuthors_PATH atomically:YES]; |
| 156 | 156 | if (isInsert) { |
| ... | ... | @@ -158,7 +158,7 @@ |
| 158 | 158 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 159 | 159 | } |
| 160 | 160 | } else { |
| 161 | - BOOL isDelete = [[DBAction sharedDBAction] deleteTable:notice]; | |
| 161 | + BOOL isDelete = [[DBAction sharedDBAction] deleteTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 162 | 162 | [author removeObjectForKey:notice.pageUrl]; |
| 163 | 163 | [author writeToFile:FavouriteAuthors_PATH atomically:YES]; |
| 164 | 164 | if (isDelete) { | ... | ... |
CNLiveScioLive/Pages/Home/新闻详情/OldController/SCIOSpecialViewController.m
| ... | ... | @@ -77,7 +77,7 @@ |
| 77 | 77 | |
| 78 | 78 | UIButton *isFavoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 79 | 79 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 80 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 80 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 81 | 81 | if (isIn) { |
| 82 | 82 | [isFavoriteButton setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 83 | 83 | } else { |
| ... | ... | @@ -107,15 +107,15 @@ |
| 107 | 107 | UIButton *btn = (UIButton *)sender; |
| 108 | 108 | if (20000 == btn.tag) { |
| 109 | 109 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 110 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 110 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 111 | 111 | if (!isIn) { |
| 112 | - BOOL isInsert = [[DBAction sharedDBAction] insertTable:notice]; | |
| 112 | + BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 113 | 113 | if (isInsert) { |
| 114 | 114 | [AlertViewTool showHUDAddedToView:self.view text:CustomStr(@"CollectSuccess")]; |
| 115 | 115 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | - BOOL isDelete = [[DBAction sharedDBAction] deleteTable:notice]; | |
| 118 | + BOOL isDelete = [[DBAction sharedDBAction] deleteTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 119 | 119 | if (isDelete) { |
| 120 | 120 | [AlertViewTool showHUDAddedToView:self.view text:CustomStr(@"CancelCollect")]; |
| 121 | 121 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorite"] forState:UIControlStateNormal]; | ... | ... |
CNLiveScioLive/Pages/Home/新闻详情/View/CNLiveNewsDetailsView.m
| ... | ... | @@ -49,7 +49,7 @@ |
| 49 | 49 | if(i == 1){ |
| 50 | 50 | self.btn = btn; |
| 51 | 51 | TableData *notice = [[TableData alloc] initWithJSONDictionary:self.dic]; |
| 52 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 52 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 53 | 53 | if (isIn) { |
| 54 | 54 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 55 | 55 | } else { | ... | ... |
CNLiveScioLive/Pages/Live/Controller/TopNoticeViewController.m
| ... | ... | @@ -156,7 +156,7 @@ |
| 156 | 156 | UIButton *isFavoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 157 | 157 | isFavoriteButton.tag = 20000; |
| 158 | 158 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary[@"programs"][0]]; |
| 159 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 159 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 160 | 160 | if (isIn) { |
| 161 | 161 | [isFavoriteButton setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 162 | 162 | } else { |
| ... | ... | @@ -200,15 +200,15 @@ |
| 200 | 200 | } |
| 201 | 201 | } else if (20000 == btn.tag) { |
| 202 | 202 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary[@"programs"][0]]; |
| 203 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 203 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 204 | 204 | if (!isIn) { |
| 205 | - BOOL isInsert = [[DBAction sharedDBAction] insertTable:notice]; | |
| 205 | + BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 206 | 206 | if (isInsert) { |
| 207 | 207 | [AlertViewTool showHUDViewText:CustomStr(@"CollectSuccess")]; |
| 208 | 208 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 209 | 209 | } |
| 210 | 210 | } else { |
| 211 | - BOOL isDelete = [[DBAction sharedDBAction] deleteTable:notice]; | |
| 211 | + BOOL isDelete = [[DBAction sharedDBAction] deleteTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 212 | 212 | if (isDelete) { |
| 213 | 213 | [AlertViewTool showHUDViewText:CustomStr(@"CancelCollect")]; |
| 214 | 214 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorite"] forState:UIControlStateNormal]; | ... | ... |
CNLiveScioLive/Pages/Live/Controller/VideoPlayBackViewController.m
| ... | ... | @@ -113,7 +113,7 @@ |
| 113 | 113 | |
| 114 | 114 | UIButton *isFavoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 115 | 115 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 116 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 116 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 117 | 117 | if (isIn) { |
| 118 | 118 | [isFavoriteButton setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 119 | 119 | } else { |
| ... | ... | @@ -151,15 +151,15 @@ |
| 151 | 151 | [_webView loadHTMLString:[self setHTMLString] baseURL:nil]; |
| 152 | 152 | } else if (20000 == btn.tag) { |
| 153 | 153 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 154 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 154 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 155 | 155 | if (!isIn) { |
| 156 | - BOOL isInsert = [[DBAction sharedDBAction] insertTable:notice]; | |
| 156 | + BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 157 | 157 | if (isInsert) { |
| 158 | 158 | [AlertViewTool showHUDViewText:CustomStr(@"CollectSuccess")]; |
| 159 | 159 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 160 | 160 | } |
| 161 | 161 | } else { |
| 162 | - BOOL isDelete = [[DBAction sharedDBAction] deleteTable:notice]; | |
| 162 | + BOOL isDelete = [[DBAction sharedDBAction] deleteTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 163 | 163 | if (isDelete) { |
| 164 | 164 | [AlertViewTool showHUDViewText:CustomStr(@"CancelCollect")]; |
| 165 | 165 | [btn setImage:[UIImage imageNamed:@"cnlive_isfavorite"] forState:UIControlStateNormal]; | ... | ... |
CNLiveScioLive/Pages/My/我的收藏/Controller/CNLiveMyCollectionViewController.m
| ... | ... | @@ -26,7 +26,7 @@ static NSString *myAnnouncementsTableViewCell = @"CNMyAnnouncementsTableViewCell |
| 26 | 26 | #pragma mark - Data |
| 27 | 27 | - (void)viewWillAppear:(BOOL)animated{ |
| 28 | 28 | [super viewWillAppear:animated]; |
| 29 | - self.data = [[DBAction sharedDBAction] queryTable]; | |
| 29 | + self.data = [[DBAction sharedDBAction] queryTable:[User_Defaults objectForKey:Language_Local]]; | |
| 30 | 30 | self.errorLabel.hidden = self.data.count != 0; |
| 31 | 31 | [self.tableView reloadData]; |
| 32 | 32 | ... | ... |
CNLiveScioLive/Pages/Newsound/OldController/VoiceViewController.m
| ... | ... | @@ -403,7 +403,7 @@ static const NSInteger margin = 34; |
| 403 | 403 | |
| 404 | 404 | // 判断收藏按钮状态 |
| 405 | 405 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 406 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 406 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 407 | 407 | if (isIn) { |
| 408 | 408 | [favoriteBtn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 409 | 409 | } else { |
| ... | ... | @@ -849,7 +849,7 @@ static const NSInteger margin = 34; |
| 849 | 849 | } |
| 850 | 850 | // 判断收藏按钮状态 |
| 851 | 851 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 852 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 852 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 853 | 853 | if (isIn) { |
| 854 | 854 | [favoriteBtn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 855 | 855 | } else { |
| ... | ... | @@ -1070,14 +1070,14 @@ static const NSInteger margin = 34; |
| 1070 | 1070 | |
| 1071 | 1071 | - (void)favoriteBtnClicked:(id)sender { |
| 1072 | 1072 | TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; |
| 1073 | - BOOL isIn = [[DBAction sharedDBAction] isInTable:notice]; | |
| 1073 | + BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 1074 | 1074 | NSMutableDictionary *author = [NSMutableDictionary dictionaryWithContentsOfFile:FavouriteAuthors_PATH]; |
| 1075 | 1075 | if (!author) { |
| 1076 | 1076 | author = [NSMutableDictionary dictionary]; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | if (!isIn) { |
| 1080 | - BOOL isInsert = [[DBAction sharedDBAction] insertTable:notice]; | |
| 1080 | + BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 1081 | 1081 | [author setObject:_dictionary[@"author"] forKey:notice.pageUrl]; |
| 1082 | 1082 | [author writeToFile:FavouriteAuthors_PATH atomically:YES]; |
| 1083 | 1083 | if (isInsert) { |
| ... | ... | @@ -1085,7 +1085,7 @@ static const NSInteger margin = 34; |
| 1085 | 1085 | [favoriteBtn setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal]; |
| 1086 | 1086 | } |
| 1087 | 1087 | } else { |
| 1088 | - BOOL isDelete = [[DBAction sharedDBAction] deleteTable:notice]; | |
| 1088 | + BOOL isDelete = [[DBAction sharedDBAction] deleteTable:[User_Defaults objectForKey:Language_Local] notice:notice]; | |
| 1089 | 1089 | [author removeObjectForKey:notice.pageUrl]; |
| 1090 | 1090 | [author writeToFile:FavouriteAuthors_PATH atomically:YES]; |
| 1091 | 1091 | if (isDelete) { | ... | ... |
CNLiveScioLive/Pages/Tools/DBAction/DBAction.h
| ... | ... | @@ -18,9 +18,9 @@ |
| 18 | 18 | - (NSMutableArray *)queryNoticeTable; |
| 19 | 19 | |
| 20 | 20 | |
| 21 | -- (void)createTable; | |
| 22 | -- (BOOL)isInTable:(TableData*)notice; | |
| 23 | -- (BOOL)insertTable: (TableData*)notice; | |
| 24 | -- (BOOL)deleteTable: (TableData*)notice; | |
| 25 | -- (NSMutableArray *)queryTable; | |
| 21 | +- (void)createTable:(NSString *)tableName; | |
| 22 | +- (BOOL)isInTable:(NSString *)tableName notice:(TableData*)notice; | |
| 23 | +- (BOOL)insertTable:(NSString *)tableName notice:(TableData*)notice; | |
| 24 | +- (BOOL)deleteTable:(NSString *)tableName notice:(TableData*)notice; | |
| 25 | +- (NSMutableArray *)queryTable:(NSString *)tableName; | |
| 26 | 26 | @end | ... | ... |
CNLiveScioLive/Pages/Tools/DBAction/DBAction.m
| ... | ... | @@ -124,16 +124,18 @@ static DBAction *instance = nil; |
| 124 | 124 | return list; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | -- (void)createTable{ | |
| 127 | +- (void)createTable:(NSString *)tableName{ | |
| 128 | 128 | if ([db open]) { |
| 129 | - NSString * sql = @"CREATE TABLE DATATABLE (cmsColumnName varchar, cmsColumnId varchar, cmsContentId int, createDate varchar, desc varchar, gxbArticleId int, gxbVideoId int, img varchar, pageUrl varchar, picType varchar, playType varchar, publishDate varchar, subTitle varchar, title varchar, type varchar, uploadVideoUrl varchar, videoUrl varchar, vipFlag int, uuid varchar)"; | |
| 129 | + tableName = [tableName substringToIndex:2]; | |
| 130 | + NSString * sql = [NSString stringWithFormat:@"CREATE TABLE %@DATATABLE (cmsColumnName varchar, cmsColumnId varchar, cmsContentId int, createDate varchar, desc varchar, gxbArticleId int, gxbVideoId int, img varchar, pageUrl varchar, picType varchar, playType varchar, publishDate varchar, subTitle varchar, title varchar, type varchar, uploadVideoUrl varchar, videoUrl varchar, vipFlag int, uuid varchar)",tableName.uppercaseString]; | |
| 130 | 131 | BOOL res = [db executeUpdate:sql]; |
| 131 | 132 | if (!res) { |
| 132 | 133 | NSLog(@"建表失败"); |
| 133 | - NSString *sql1 = [NSString stringWithFormat:@"ALTER TABLE %@ ADD %@ VARCHAR",@"DATATABLE",@"playType"]; | |
| 134 | + | |
| 135 | + NSString *sql1 = [NSString stringWithFormat:@"ALTER TABLE %@DATATABLE ADD %@ VARCHAR",tableName,@"playType"]; | |
| 134 | 136 | BOOL result1 = [db executeUpdate:sql1]; |
| 135 | 137 | |
| 136 | - NSString *sql2 = [NSString stringWithFormat:@"ALTER TABLE %@ ADD %@ VARCHAR",@"DATATABLE",@"uuid"]; | |
| 138 | + NSString *sql2 = [NSString stringWithFormat:@"ALTER TABLE %@DATATABLE ADD %@ VARCHAR",tableName,@"uuid"]; | |
| 137 | 139 | BOOL result2 = [db executeUpdate:sql2]; |
| 138 | 140 | |
| 139 | 141 | } else { |
| ... | ... | @@ -145,9 +147,10 @@ static DBAction *instance = nil; |
| 145 | 147 | } |
| 146 | 148 | } |
| 147 | 149 | |
| 148 | -- (BOOL)isInTable:(TableData*)notice{ | |
| 150 | +- (BOOL)isInTable:(NSString *)tableName notice:(TableData*)notice{ | |
| 149 | 151 | if ([db open]) { |
| 150 | - NSString * check = [NSString stringWithFormat:@"SELECT * FROM DATATABLE where cmsContentId = %d",notice.cmsContentId]; | |
| 152 | + tableName = [tableName substringToIndex:2]; | |
| 153 | + NSString * check = [NSString stringWithFormat:@"SELECT * FROM %@DATATABLE where cmsContentId = %d",tableName.uppercaseString,notice.cmsContentId]; | |
| 151 | 154 | FMResultSet * re = [db executeQuery:check]; |
| 152 | 155 | while ([re next]) { |
| 153 | 156 | return YES; |
| ... | ... | @@ -157,13 +160,14 @@ static DBAction *instance = nil; |
| 157 | 160 | return NO; |
| 158 | 161 | } |
| 159 | 162 | |
| 160 | -- (BOOL)insertTable:(TableData*)notice{ | |
| 163 | +- (BOOL)insertTable:(NSString *)tableName notice:(TableData*)notice{ | |
| 161 | 164 | if ([db open]) { |
| 162 | - NSString * check = [NSString stringWithFormat:@"SELECT * FROM DATATABLE where cmsContentId = %d",notice.cmsContentId]; | |
| 165 | + tableName = [tableName substringToIndex:2]; | |
| 166 | + NSString * check = [NSString stringWithFormat:@"SELECT * FROM %@DATATABLE where cmsContentId = %d",tableName.uppercaseString,notice.cmsContentId]; | |
| 163 | 167 | FMResultSet * re = [db executeQuery:check]; |
| 164 | 168 | if (![re next]) { |
| 165 | 169 | NSString *desc = [notice.desc stringByReplacingOccurrencesOfString:@"'" withString:@"''"]; |
| 166 | - NSString * sql = [NSString stringWithFormat:@"INSERT INTO DATATABLE (cmsColumnName, cmsColumnId, cmsContentId, createDate, desc, gxbArticleId, gxbVideoId, img, pageUrl, picType, playType, publishDate, subTitle, title, type, uploadVideoUrl, videoUrl, vipFlag, uuid) values('%@','%@','%d', '%@','%@','%d','%d', '%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%d', '%@')", notice.cmsColumnName, notice.cmsColumnId, notice.cmsContentId, notice.createDate, desc, notice.gxbArticleId, notice.gxbVideoId, notice.img, notice.pageUrl, notice.picType, notice.playType, notice.publishDate, notice.subTitle, notice.title, notice.type, notice.uploadVideoUrl, notice.videoUrl, notice.vipFlag, notice.uuid?notice.uuid:@""]; | |
| 170 | + NSString * sql = [NSString stringWithFormat:@"INSERT INTO %@DATATABLE (cmsColumnName, cmsColumnId, cmsContentId, createDate, desc, gxbArticleId, gxbVideoId, img, pageUrl, picType, playType, publishDate, subTitle, title, type, uploadVideoUrl, videoUrl, vipFlag, uuid) values('%@','%@','%d', '%@','%@','%d','%d', '%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%d', '%@')",tableName.uppercaseString, notice.cmsColumnName, notice.cmsColumnId, notice.cmsContentId, notice.createDate, desc, notice.gxbArticleId, notice.gxbVideoId, notice.img, notice.pageUrl, notice.picType, notice.playType, notice.publishDate, notice.subTitle, notice.title, notice.type, notice.uploadVideoUrl, notice.videoUrl, notice.vipFlag, notice.uuid?notice.uuid:@""]; | |
| 167 | 171 | BOOL res = [db executeUpdate:sql]; |
| 168 | 172 | if (!res) { |
| 169 | 173 | return NO; |
| ... | ... | @@ -176,9 +180,10 @@ static DBAction *instance = nil; |
| 176 | 180 | return NO; |
| 177 | 181 | } |
| 178 | 182 | |
| 179 | -- (BOOL)deleteTable:(TableData*)notice{ | |
| 183 | +- (BOOL)deleteTable:(NSString *)tableName notice:(TableData*)notice{ | |
| 180 | 184 | if ([db open]) { |
| 181 | - NSString * sql = [NSString stringWithFormat:@"DELETE FROM DATATABLE where cmsContentId = %d",notice.cmsContentId]; | |
| 185 | + tableName = [tableName substringToIndex:2]; | |
| 186 | + NSString * sql = [NSString stringWithFormat:@"DELETE FROM %@DATATABLE where cmsContentId = %d",tableName.uppercaseString,notice.cmsContentId]; | |
| 182 | 187 | BOOL res = [db executeUpdate:sql]; |
| 183 | 188 | if (!res) { |
| 184 | 189 | return NO; |
| ... | ... | @@ -190,10 +195,11 @@ static DBAction *instance = nil; |
| 190 | 195 | return NO; |
| 191 | 196 | } |
| 192 | 197 | |
| 193 | -- (NSMutableArray *)queryTable{ | |
| 198 | +- (NSMutableArray *)queryTable:(NSString *)tableName{ | |
| 194 | 199 | NSMutableArray *list = [[NSMutableArray alloc] init]; |
| 195 | 200 | if ([db open]) { |
| 196 | - NSString * sql = @"SELECT * FROM DATATABLE"; | |
| 201 | + tableName = [tableName substringToIndex:2]; | |
| 202 | + NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@DATATABLE",tableName.uppercaseString]; | |
| 197 | 203 | FMResultSet * rs = [db executeQuery:sql]; |
| 198 | 204 | while ([rs next]) { |
| 199 | 205 | TableData * notice = [[TableData alloc] init]; | ... | ... |