Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/RoundData.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.19.2.2 - (show annotations) (download) (as text)
Sun May 22 04:39:10 2005 UTC (18 years, 11 months ago) by h677
Branch: remodeling
CVS Tags: v1_50_0_577, v1_50_0_576
Changes since 1.19.2.1: +29 -16 lines
File MIME type: text/x-pascal
TBoard、TThreadItemのRoundNameプロパティをPCharに変更

1 unit RoundData;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes,
7 GikoSystem, BoardGroup;
8
9 type
10 TGikoRoundType = (grtBoard, grtItem);
11 TRoundItem = class;
12
13 TRoundList = class(TObject)
14 private
15 FOldFileRead: Boolean;
16 FBoardList: TList;
17 FItemList: TList;
18 function GetCount(RoundType: TGikoRoundType): Integer;
19 function GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
20 function ParseRoundBoardLine(Line: string): Boolean;
21 function ParseRoundThreadLine(Line: string): Boolean;
22 function ParseOldRoundBoardLine(Line: string): Boolean;
23 function ParseOldRoundThreadLine(Line: string): Boolean;
24 public
25 RoundNameList: TStringList;
26
27 constructor Create;
28 destructor Destroy; override;
29 function Add(Board: TBoard): Integer; overload;
30 function Add(ThreadItem: TThreadItem): Integer; overload;
31 procedure Delete(Board: TBoard); overload;
32 procedure Delete(ThreadItem: TThreadItem); overload;
33 procedure Delete(URL: string; RoundType: TGikoRoundType); overload;
34 procedure Clear;
35 function Find(Board: TBoard): Integer; overload;
36 function Find(ThreadItem: TThreadItem): Integer; overload;
37 function Find(URL: string; RoundType: TGikoRoundType): Integer; overload;
38 property Count[RoundType: TGikoRoundType]: Integer read GetCount;
39 property OldFileRead: Boolean read FOldFileRead;
40 property Items[Index: integer; RoundType: TGikoRoundType]: TRoundItem read GetRoundItem;
41 //procedure SetRoundName(Board: TBoard; RoundName: string); overload;
42 //procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload;
43
44 procedure LoadRoundBoardFile;
45 procedure LoadRoundThreadFile;
46 procedure SaveRoundFile;
47
48 procedure URLReplace(oldURLs: TStringList; newURLs :TStringList);
49 end;
50
51 TRoundItem = class(TObject)
52 private
53 //
54 FItem : TObject;
55 FBBSType: TGikoBBSType;
56 FRoundName: string;
57 FRoundType: TGikoRoundType;
58 //Item : TObject;
59 //FURL : string;
60 //FBoardTitle: string;
61 //FThreadTitle: string;
62 //FFileName: string;
63 FTmpURL : string;
64 FBoolData: Boolean; //鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申
65 function GetBoardTitle : string;
66 function GetThreadTitle : string;
67 function GetURL : string;
68 function GetFileName : string;
69 public
70
71 constructor Create;
72 property Item : TObject read FItem;
73 //property BBSType: TGikoBBSType read FBBSType write FBBSType;
74 property RoundName: string read FRoundName write FRoundName;
75 property RoundType: TGikoRoundType read FRoundType write FRoundType;
76 //property Item : TObject read FItem write FItem;
77 property URL : string read GetURL;
78 property TmpURL : string read FTmpURL write FTmpURL;
79 property BoardTitle: string read GetBoardTitle;
80 property ThreadTitle: string read GetThreadTitle;
81 property FileName: string read GEtFileName;
82 property BoolData: Boolean read FBoolData write FBoolData;
83 end;
84
85 var
86 RoundList: TRoundList;
87
88 implementation
89 const
90 ROUND_BOARD_FILENAME: string = 'RoundBoard.2ch'; //鐃緒申鐃緒申鐃緒申BoardGroup鐃緒申鐃緒申鐃緒申
91 ROUND_ITEM_FILENAME: string = 'RoundItem.2ch'; //鐃緒申鐃緒申
92 ROUND_INDEX_VERSION: string = '2.00';
93 ERROR_BOARD_FILENAME: string = 'ErrorBoard.2ch'; //Error鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
94 ERROR_ITEM_FILENAME: string = 'ErrorItem.2ch'; //Error鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
95 constructor TRoundItem.Create;
96 begin
97 inherited Create;
98 end;
99 function TRoundItem.GetBoardTitle : string;
100 begin
101 Result := '';
102 if( Self.FItem <> nil) then begin
103 if( Self.FItem is TBoard) then begin
104 Result := TBoard(Self.FItem).Title;
105 end else if( Self.FItem is TThreadItem) then begin
106 Result := TThreadItem(Self.FItem).ParentBoard.Title;
107 end;
108 end;
109 end;
110 function TRoundItem.GetThreadTitle : string;
111 begin
112 Result := '';
113 if( Self.FItem <> nil) then begin
114 if( Self.FItem is TThreadItem) then begin
115 Result := TThreadItem(Self.FItem).Title;
116 end;
117 end;
118 end;
119 function TRoundItem.GetURL : string;
120 begin
121 Result := '';
122 if( Self.FItem <> nil) then begin
123 if( Self.FItem is TBoard) then begin
124 Result := TBoard(Self.FItem).URL;
125 end else if( Self.FItem is TThreadItem) then begin
126 Result := TThreadItem(Self.FItem).URL;
127 end;
128 end;
129 end;
130 function TRoundItem.GetFileName : string;
131 begin
132 Result := '';
133 if( Self.FItem <> nil) then begin
134 if( Self.FItem is TThreadItem) then begin
135 Result := TThreadItem(Self.FItem).FileName;
136 end;
137 end;
138 end;
139 constructor TRoundList.Create;
140 begin
141 inherited;
142 FBoardList := TList.Create;
143 FItemList := TList.Create;
144 RoundNameList := TStringList.Create;
145 RoundNameList.Sorted := True;
146 RoundNameList.Duplicates := dupIgnore;
147 FOldFileRead := false;
148 end;
149
150 destructor TRoundList.Destroy;
151 begin
152 RoundNameList.Free;
153 Clear;
154 FBoardList.Free;
155 FItemList.Free;
156 //inherited;
157 end;
158
159 function TRoundList.Add(Board: TBoard): Integer;
160 var
161 idx: Integer;
162 Item: TRoundItem;
163 begin
164 Result := -1;
165 idx := Find(Board);
166 //RoundNameList.Add(Board.RoundName);
167 if idx = -1 then begin
168 Item := TRoundItem.Create;
169 Item.FItem := Board;
170 // Item.BBSType := gbt2ch; //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
171 Item.RoundType := grtBoard;
172 // Item.Item := Board;
173 //Item.URL := Board.URL;
174 //Item.BoardTitle := Board.Title;
175 //Item.ThreadTitle := '';
176 //Item.FileName := '';
177 Item.RoundName := Board.RoundName;
178 Result := FBoardList.Add(Item);
179 end;
180 end;
181
182 function TRoundList.Add(ThreadItem: TThreadItem): Integer;
183 var
184 idx: Integer;
185 Item: TRoundItem;
186 begin
187 Result := -1;
188 idx := Find(ThreadItem);
189 //RoundNameList.Add(ThreadItem.RoundName);
190 if idx = -1 then begin
191 Item := TRoundItem.Create;
192 Item.FItem := ThreadItem;
193 // Item.BBSType := gbt2ch; //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
194 Item.RoundType := grtItem;
195 // Item.Item := ThreadItem;
196 //Item.URL := Threaditem.URL;
197 //Item.BoardTitle := ThreadItem.ParentBoard.Title;
198 //Item.ThreadTitle := ThreadItem.Title;
199 //Item.FileName := ThreadItem.FileName;
200 Item.RoundName := ThreadItem.RoundName;
201 Result := FItemList.Add(Item);
202 end;
203 end;
204
205 procedure TRoundList.Delete(Board: TBoard);
206 var
207 idx: Integer;
208 // Item: TRoundItem;
209 begin
210 idx := Find(Board);
211 if idx <> -1 then begin
212 TBoard(TRoundItem(FBoardList[idx]).FItem).RoundName := '';
213 TRoundItem(FBoardList[idx]).Free;
214 FBoardList.Delete(idx);
215 end;
216 end;
217
218 procedure TRoundList.Delete(ThreadItem: TThreadItem);
219 var
220 idx: Integer;
221 // Item: TRoundItem;
222 begin
223 idx := Find(ThreadItem);
224 if idx <> -1 then begin
225 TThreadItem(TRoundItem(FItemList[idx]).FItem).RoundName := '';
226 TRoundItem(FItemList[idx]).Free;
227 FItemList.Delete(idx);
228 end;
229 end;
230
231 procedure TRoundList.Clear;
232 var
233 i: Integer;
234 begin
235 for i := FBoardList.Count - 1 downto 0 do begin
236 if FBoardList[i] <> nil then
237 TRoundItem(FBoardList[i]).Free;
238 FBoardList.Delete(i);
239 end;
240 FBoardList.Capacity := FBoardList.Count;
241 for i := FItemList.Count - 1 downto 0 do begin
242 if FItemList[i] <> nil then
243 TRoundItem(FItemList[i]).Free;
244 FItemList.Delete(i);
245 end;
246 FItemList.Capacity := FItemList.Count;
247 end;
248
249 function TRoundList.Find(Board: TBoard): Integer;
250 var
251 i: Integer;
252 Item: TRoundItem;
253 begin
254 Result := -1;
255 for i := 0 to FBoardList.Count - 1 do begin
256 Item := TRoundItem(FBoardList[i]);
257 if Item.FRoundType <> grtBoard then Continue;
258 if Item.FItem = Board then begin
259 Result := i;
260 Exit;
261 end;
262 end;
263 end;
264
265 function TRoundList.Find(ThreadItem: TThreadItem): Integer;
266 var
267 i: Integer;
268 Item: TRoundItem;
269 begin
270 Result := -1;
271 for i := 0 to FItemList.Count - 1 do begin
272 Item := TRoundItem(FItemList[i]);
273 if Item.FRoundType <> grtItem then Continue;
274 if Item.FItem = ThreadItem then begin
275 Result := i;
276 Exit;
277 end;
278 end;
279 end;
280 function TRoundList.Find(URL: string; RoundType: TGikoRoundType): Integer;
281 var
282 i: Integer;
283 Item: TRoundItem;
284 begin
285 Result := -1;
286 if RoundType = grtItem then begin
287 for i := 0 to FItemList.Count - 1 do begin
288 Item := TRoundItem(FItemList[i]);
289 if Item.FRoundType <> RoundType then Continue;
290 if Item.URL = URL then begin
291 Result := i;
292 Exit;
293 end;
294 end;
295 end else begin
296 for i := 0 to FBoardList.Count - 1 do begin
297 Item := TRoundItem(FBoardList[i]);
298 if Item.FRoundType <> RoundType then Continue;
299 if Item.URL = URL then begin
300 Result := i;
301 Exit;
302 end;
303 end;
304 end;
305 end;
306 procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType);
307 var
308 idx: Integer;
309 Item: TRoundItem;
310 board: TBoard;
311 threadItem: TThreadItem;
312 begin
313 idx := Find(URL, RoundType);
314 if idx <> -1 then begin
315
316 if RoundType = grtBoard then begin
317 Item := TRoundItem(FBoardList[idx]);
318 board := TBoard(Item);
319 Item.Free;
320 FBoardList.Delete(idx);
321 //board := BBSsFindBoardFromURL(URL);
322 if board <> nil then begin
323 board.Round := False;
324 board.RoundName := '';
325 end;
326 end else begin
327 Item := TRoundItem(FItemList[idx]);
328 threadItem := TThreadItem(Item.FItem);
329 Item.Free;
330 FItemList.Delete(idx);
331
332 //threadItem := BBSsFindThreadFromURL(URL);
333 if threadItem <> nil then begin
334 threadItem.Round := false;
335 threadItem.RoundName := '';
336 end;
337 end;
338 end;
339 end;
340 {
341 procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);
342 var
343 idx: Integer;
344 Item: TRoundItem;
345 begin
346 idx := Find(Board);
347 if idx <> -1 then begin
348 Item := TRoundItem(FBoardList[idx]);
349 Item.RoundName := RoundName;
350 end;
351 end;
352 }
353 {
354 procedure TRoundList.SetRoundName(ThreadItem: TThreadItem; RoundName: string);
355 var
356 idx: Integer;
357 Item: TRoundItem;
358 begin
359 idx := Find(ThreadItem);
360 if idx <> -1 then begin
361 Item := TRoundItem(FItemList[idx]);
362 Item.RoundName := RoundName;
363 end;
364 end;
365 }
366 function TRoundList.GetCount(RoundType: TGikoRoundType): Integer;
367 begin
368 Result := 0;
369 if RoundType = grtBoard then
370 Result := FBoardList.Count
371 else if RoundType = grtItem then
372 Result := FItemList.Count;
373 end;
374
375 function TRoundList.GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
376 begin
377 Result := nil;
378 if RoundType = grtBoard then begin
379 if (Index >= 0) and (Index < FBoardList.Count) then
380 Result := TRoundItem(FBoardList[Index]);
381 end else if RoundType = grtItem then begin
382 if (Index >= 0) and (Index < FItemList.Count) then
383 Result := TRoundItem(FItemList[Index]);
384 end;
385 end;
386 procedure TRoundList.LoadRoundBoardFile;
387 var
388 i: Integer;
389 sl: TStringList;
390 FileName, bFileName: string;
391 errorSl: TStringList;
392 errorFileName: string;
393 //Item: TRoundItem;
394 delCount: Integer;
395 begin
396 sl := TStringList.Create;
397 errorSl := TStringList.Create;
398 errorSl.Duplicates := dupIgnore;
399 try
400 //鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
401 FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
402 bFileName := GikoSys.GetConfigDir + '~' + ROUND_BOARD_FILENAME;
403 //鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
404 errorFileName := GikoSys.GetConfigDir + ERROR_BOARD_FILENAME;
405
406 if FileExists(FileName) then begin
407 sl.LoadFromFile(FileName);
408 if FileExists(bFileName) then
409 DeleteFile(bFileName);
410 //鐃?鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
411 sl.SaveToFile(bFileName);
412 if FileExists(errorFileName) then begin
413 try
414 errorSl.LoadFromFile(errorFileName);
415 except
416 end;
417 end;
418 //Item := TRoundItem.Create;
419 delCount := 0;
420 //鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申
421 if sl[0] = ROUND_INDEX_VERSION then begin
422 for i := 1 to sl.Count - 1 do begin
423 if not ParseRoundBoardLine(sl[i - delCount]) then begin
424 errorSl.Add( sl[i - delCount] );
425 sl.Delete(i- delCount);
426 Inc(delCount);
427 end;
428 end;
429 end else begin
430 if FOldFileRead then begin //鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
431 for i := 1 to sl.Count - 1 do begin
432 if not ParseOldRoundBoardLine(sl[i - delCount]) then begin
433 errorSl.Add( sl[i- delCount] );
434 sl.Delete(i- delCount);
435 Inc(delCount);
436 end;
437 end;
438 end else
439 FOldFileRead := true;
440 end;
441 end;
442 if errorSl.Count > 0 then
443 errorSl.SaveToFile(errorFileName);
444 finally
445 errorSl.Free;
446 sl.Free;
447 end;
448 end;
449 procedure TRoundList.LoadRoundThreadFile;
450 var
451 i: Integer;
452 // j: Integer;
453 sl: TStringList;
454 FileName, bFileName: string;
455 errorSl: TStringList;
456 errorFileName: string;
457 // Item: TRoundItem;
458 delCount: Integer;
459 // boardList : TStringList;
460 begin
461 // boardList := TStringList.Create;
462 // boardList.Duplicates := dupIgnore;
463 errorSl := TStringList.Create;
464 errorSl.Duplicates := dupIgnore;
465 sl := TStringList.Create;
466 try
467 //鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
468 FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
469 bFileName := GikoSys.GetConfigDir + '~' + ROUND_ITEM_FILENAME;
470 //鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
471 errorFileName := GikoSys.GetConfigDir + ERROR_ITEM_FILENAME;
472 if FileExists(FileName) then begin
473 sl.LoadFromFile(FileName);
474 if FileExists(bFileName) then
475 DeleteFile(bFileName);
476 sl.SaveToFile(bFileName);
477 if FileExists(errorFileName) then begin
478 try
479 errorSl.LoadFromFile(errorFileName);
480 except
481 end;
482 end;
483 //Item := TRoundItem.Create;
484 delCount := 0;
485 //鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申
486 if sl[0] = ROUND_INDEX_VERSION then begin
487 for i := 1 to sl.Count - 1 do begin
488 if not ParseRoundThreadLine(sl[i - delCount]) then begin
489 errorSl.Add(sl[i - delCount]);
490 sl.Delete(i - delCount);
491 Inc(delCount);
492 end;
493 end;
494 end else begin
495 LoadRoundBoardFile;
496 for i := 1 to sl.Count - 1 do begin
497 if not ParseOldRoundThreadLine(sl[i - delCount]) then begin
498 errorSl.Add(sl[i - delCount]);
499 sl.Delete(i - delCount);
500 Inc(delCount);
501 end;
502 end;
503 end;
504 // j := boardList.Count - 1;
505 // while j >= 0 do begin
506 // GikoSys.ReadSubjectFile( BBSsFindBoardFromURL( boardList[j] ) );
507 // boardList.Delete(j);
508 // Dec(j);
509 // end;
510 if errorSl.Count > 0 then
511 errorSl.SaveToFile(errorFileName);
512 end;
513 finally
514 errorSl.Free;
515 sl.Free;
516 // boardList.Free;
517 end;
518 end;
519 procedure TRoundList.SaveRoundFile;
520 var
521 i: integer;
522 FileName: string;
523 sl: TStringList;
524 s: string;
525 Item: TRoundItem;
526 begin
527 GikoSys.ForceDirectoriesEx(GikoSys.GetConfigDir);
528
529 sl := TStringList.Create;
530 try
531 FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
532 sl.Add(ROUND_INDEX_VERSION);
533 for i := 0 to FBoardList.Count - 1 do begin
534 Item := TRoundItem(FBoardList[i]);
535 if Item.TmpURL <> '' then begin
536 s := Item.TmpURL + #1
537 + Item.BoardTitle + #1
538 + Item.RoundName;
539 end else begin
540 s := Item.URL + #1
541 + Item.BoardTitle + #1
542 + Item.RoundName;
543 end;
544 sl.Add(s);
545 end;
546 sl.SaveToFile(FileName);
547 sl.Clear;
548 FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
549 sl.Add(ROUND_INDEX_VERSION);
550 for i := 0 to FItemList.Count - 1 do begin
551 Item := TRoundItem(FItemList[i]);
552 if Item.TmpURL <> '' then begin
553 s := Item.TmpURL + #1
554 + Item.BoardTitle + #1
555 + Item.FileName + #1
556 + Item.ThreadTitle + #1
557 + Item.RoundName;
558 end else begin
559 s := Item.URL + #1
560 + Item.BoardTitle + #1
561 + Item.FileName + #1
562 + Item.ThreadTitle + #1
563 + Item.RoundName;
564 end;
565 sl.Add(s);
566 end;
567 sl.SaveToFile(FileName);
568 finally
569 sl.Free;
570 end;
571 end;
572 function TRoundList.ParseRoundBoardLine(Line: string): Boolean;
573 var
574 s: string;
575 roundname: string;
576 board: TBoard;
577 i: Integer;
578 begin
579 //Result := TRoundItem.Create;
580 //Result.ThreadTitle := '';
581 //Result.FileName := '';
582 //Result.RoundType := grtBoard;
583 board := nil;
584 for i := 0 to 2 do begin
585 s := GikoSys.GetTokenIndex(Line, #1, i);
586 try
587 case i of
588 0:
589 begin
590 board := BBSsFindBoardFromURL(s);
591 //Result.URL := s;
592 end;
593 //1: Result.BoardTitle := s;
594 2: roundname := s;
595 end;
596 except
597 Result := false;
598 Exit;
599 end;
600 end;
601 if( board <> nil ) then begin
602 if not board.Round then begin
603 //board.RoundName := roundname;
604 RoundNameList.Add(roundname);
605 RoundNameList.Find(roundname, i);
606 board.RoundName := PChar(RoundNameList[i]);
607 board.Round := true;
608 end;
609 Result := true;
610 end else begin
611 Result := false;
612 end;
613 end;
614
615 function TRoundList.ParseRoundThreadLine(Line: string): Boolean;
616 var
617 s: string;
618 roundname: string;
619 threadItem: TThreadItem;
620 i: Integer;
621 // threadItem: TThreadItem;
622 begin
623 //Result := TRoundItem.Create;
624 //Result.RoundType := grtItem;
625 threadItem := nil;
626 for i := 0 to 4 do begin
627 s := GikoSys.GetTokenIndex(Line, #1, i);
628 try
629 case i of
630 0:
631 begin
632 //Result.URL := s;
633 threadItem := BBSsFindThreadFromURL( s );
634 //if threadItem <> nil then begin
635 // BoardList.Add( threadItem.ParentBoard.URL );
636 //end;
637 end;
638 //1: Result.BoardTitle := s;
639 //2: Result.FileName := s;
640 //3: Result.ThreadTitle := s;
641 4: roundname := s;
642 end;
643 except
644 Result := false;
645 Exit;
646 end;
647 end;
648 if( threadItem <> nil ) then begin
649 if not threadItem.Round then begin
650 //threadItem.RoundName := roundname;
651 RoundNameList.Add(roundname);
652 RoundNameList.Find(roundname, i);
653 threadItem.RoundName := PChar(RoundNameList[i]);
654 threadItem.Round := True;
655 end;
656 Result := true;
657 end else begin
658 Result := false;
659 end;
660 end;
661
662 function TRoundList.ParseOldRoundBoardLine(Line: string): Boolean;
663 var
664 i: Integer;
665 s: string;
666 roundname: string;
667 board: TBoard;
668 begin
669 //Result := TRoundItem.Create;
670 //Result.ThreadTitle := '';
671 //Result.FileName := '';
672 //Result.RoundType := grtBoard;
673 board := nil;
674 for i := 0 to 2 do begin
675 s := GikoSys.GetTokenIndex(Line, #1, i);
676 try
677 case i of
678 0:
679 begin
680 board := BBSs[ 0 ].FindBBSID( s );
681 if board = nil then begin
682 raise Exception.Create('鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?');
683 end;
684 end;
685 //1: Result.FBoardTitle := s;
686 2: roundname := s;
687 end;
688 except
689 Result := false;
690 Exit;
691 end;
692 end;
693 if( board <> nil ) then begin
694 if not board.Round then begin
695 //board.RoundName := roundname;
696 RoundNameList.Add(roundname);
697 RoundNameList.Find(roundname, i);
698 board.RoundName := PChar(RoundNameList[i]);
699 board.Round := true;
700 end;
701 Result := true;
702 end else begin
703 Result := false;
704 end;
705 end;
706
707 function TRoundList.ParseOldRoundThreadLine(Line: string): Boolean;
708 var
709 i: Integer;
710 s: string;
711 roundname : string;
712 buf: string;
713 board: TBoard;
714 threadItem: TThreadItem;
715 bbsID: string;
716 begin
717 // Result := TRoundItem.Create;
718 // Result.RoundType := grtItem;
719 threadItem := nil;
720 for i := 0 to 4 do begin
721 s := GikoSys.GetTokenIndex(Line, #1, i);
722 try
723 case i of
724 0: bbsID := s;
725 //1: Result.BoardTitle := s;
726 2:
727 begin
728 //Result.FileName := s;
729 board := BBSs[ 0 ].FindBBSID(bbsID);
730 if board <> nil then begin
731 buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);
732 buf := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';
733 threadItem := BBSsFindThreadFromURL(buf);
734 end else begin
735 raise Exception.Create('鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申');
736 end;
737 end;
738 //3: Result.ThreadTitle := s;
739 4: roundname := s;
740 end;
741 except
742 Result := false;
743 Exit;
744 end;
745 end;
746 if( threadItem <> nil ) then begin
747 if not threadItem.Round then begin
748 //threadItem.RoundName := roundname;
749 RoundNameList.Add(roundname);
750 RoundNameList.Find(roundname, i);
751 threadItem.RoundName := PChar(RoundNameList[i]);
752 threadItem.Round := true;
753 end;
754 Result := true;
755 end else begin
756 Result := false;
757 end;
758
759 end;
760 procedure TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);
761 var
762 i: Integer;
763 j: Integer;
764 tempString: string;
765 tmpURL: string;
766 oldHost: string;
767 oldBoardName: string;
768 newHost: string;
769 newBoardName: string;
770 begin
771 if oldURLs.Count <> newURLs.Count then
772 Exit;
773 //鐃緒申鐃緒申鐃緒申鐃緒申鐃?Board鐃緒申URL鐃緒申鐃緒申鐃?
774 for j :=0 to oldURLs.Count - 1 do begin
775 for i :=0 to FBoardList.Count - 1 do begin
776 if TRoundItem(FBoardList[i]).URL = oldURLs[j] then
777 TRoundItem(FBoardList[i]).TmpURL := newURLs[j];
778 end;
779 end;
780 //鐃緒申鐃緒申鐃緒申鐃緒申鐃?Board鐃緒申URL鐃緒申鐃緒申鐃?
781
782 //鐃緒申鐃緒申鐃緒申鐃緒申鐃?Thread鐃緒申URL鐃緒申鐃緒申鐃?
783 //鐃緒申鐃?鐃緒申鐃緒申鐃緒申thread鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申URL鐃緒申鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?
784 for i := 0 to oldURLs.Count - 1 do begin
785 tmpURL := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
786 oldHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
787 oldBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
788 tmpURL := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
789 newHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
790 newBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
791
792 for j := 0 to FItemList.Count - 1 do begin
793 tempString := TRoundItem(FItemList[j]).URL;
794 if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
795 tempString := StringReplace(tempString, oldHost, newHost,[]);
796 TRoundItem(FItemList[j]).TmpURL := tempString;
797 end;
798 end;
799 end;
800 //鐃緒申鐃緒申鐃緒申鐃緒申鐃?Thread鐃緒申URL鐃緒申鐃緒申鐃?
801
802 end;
803
804 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26