| 4 |
|
|
| 5 |
uses |
uses |
| 6 |
Messages, SysUtils, Classes, Contnrs, ComCtrls, {HttpApp,} YofUtils, |
Messages, SysUtils, Classes, Contnrs, ComCtrls, {HttpApp,} YofUtils, |
| 7 |
GikoSystem{, XMLIntf, XMLDoc}, GikoXMLDoc, BoardGroup, windows; |
GikoSystem{, XMLIntf, XMLDoc}, GikoXMLDoc, BoardGroup, windows, |
| 8 |
|
MojuUtils; |
| 9 |
{SAX, SAXHelpers, SAXComps, SAXKW;} |
{SAX, SAXHelpers, SAXComps, SAXKW;} |
| 10 |
|
|
| 11 |
type |
type |
| 62 |
procedure SetFavTreeView(TreeView: TTreeView); |
procedure SetFavTreeView(TreeView: TTreeView); |
| 63 |
procedure ReadFavorite; |
procedure ReadFavorite; |
| 64 |
procedure WriteFavorite; |
procedure WriteFavorite; |
| 65 |
|
procedure URLReplace(oldURLs: TStringList; newURLs: TStringList); |
| 66 |
property TreeView: TTreeView read FTreeView; |
property TreeView: TTreeView read FTreeView; |
| 67 |
end; |
end; |
| 68 |
|
|
| 539 |
end; |
end; |
| 540 |
end; |
end; |
| 541 |
|
|
| 542 |
|
procedure TFavoriteDM.URLReplace(oldURLs: TStringList; newURLs: TStringList); |
| 543 |
|
var |
| 544 |
|
FavoriteFilePath: string; |
| 545 |
|
tempStringList: TStringList; |
| 546 |
|
i: Integer; |
| 547 |
|
j: Integer; |
| 548 |
|
tmpURL: string; |
| 549 |
|
oldHost: string; |
| 550 |
|
oldBoardName: string; |
| 551 |
|
newHost: string; |
| 552 |
|
newBoardName: string; |
| 553 |
|
tempString: string; |
| 554 |
|
begin |
| 555 |
|
|
| 556 |
|
FavoriteFilePath := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |
| 557 |
|
|
| 558 |
|
if FileExists( FavoriteFilePath ) then begin |
| 559 |
|
tempStringList := TStringList.Create; |
| 560 |
|
try |
| 561 |
|
tempStringList.LoadFromFile( FavoriteFilePath ); |
| 562 |
|
if oldURLs.Count = newURLs.Count then begin |
| 563 |
|
//これで、Boardは全て切り替わる |
| 564 |
|
for i := 0 to oldURLs.Count - 1 do begin |
| 565 |
|
CustomStringReplace(tempStringList,oldURLs[i],newURLs[i],true); |
| 566 |
|
end; |
| 567 |
|
//面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。 |
| 568 |
|
for i := 0 to oldURLs.Count - 1 do begin |
| 569 |
|
tmpURL := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1); |
| 570 |
|
oldHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) ); |
| 571 |
|
oldBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/'; |
| 572 |
|
tmpURL := Copy(newURLs[i], 1, Length(newURLs[i]) -1); |
| 573 |
|
newHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) ); |
| 574 |
|
newBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/'; |
| 575 |
|
|
| 576 |
|
for j := 0 to tempStringList.Count - 1 do begin |
| 577 |
|
tempString := tempStringList[j]; |
| 578 |
|
if AnsiPos('favtype="thread"',tempString ) <> 0 then begin |
| 579 |
|
tempString := Copy(tempString, AnsiPos('url="',tempString ) + 5, AnsiPos('" title="',tempString ) -AnsiPos('url="',tempString ) - 5); |
| 580 |
|
if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin |
| 581 |
|
tempString := StringReplace(tempStringList[j], oldHost, newHost,[]); |
| 582 |
|
//tempString := StringReplace(tempString, oldBoardName, newBoardName,[]); |
| 583 |
|
tempStringList[j] := tempString; |
| 584 |
|
end; |
| 585 |
|
|
| 586 |
|
end; |
| 587 |
|
end; |
| 588 |
|
end; |
| 589 |
|
|
| 590 |
|
end; |
| 591 |
|
|
| 592 |
|
tempStringList.SaveToFile( FavoriteFilePath ); |
| 593 |
|
finally |
| 594 |
|
tempStringList.Free; |
| 595 |
|
end; |
| 596 |
|
end; |
| 597 |
|
end; |
| 598 |
|
|
| 599 |
function TFavoriteDM.GetFavoriteFilePath() : String; |
function TFavoriteDM.GetFavoriteFilePath() : String; |
| 600 |
begin |
begin |
| 601 |
Result := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |
Result := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |