Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/Favorite.pas

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

revision 1.33 by h677, Tue Apr 13 13:29:30 2004 UTC revision 1.34 by yoffy, Thu Apr 15 08:32:23 2004 UTC
# Line 612  end; Line 612  end;
612    
613  procedure TFavoriteDM.URLReplace(oldURLs: TStringList; newURLs: TStringList);  procedure TFavoriteDM.URLReplace(oldURLs: TStringList; newURLs: TStringList);
614  var  var
615          FavoriteFilePath: string;          i, j                    : Integer;
616      tempStringList: TStringList;                  tmpURL: string;
     i: Integer;  
     j: Integer;  
     tmpURL: string;  
617      oldHost: string;      oldHost: string;
618      oldBoardName: string;      oldBoardName: string;
619      newHost: string;      newHost: string;
620      newBoardName: string;      newBoardName: string;
621      tempString: string;                  tempString: string;
622            favBoard        : TFavoriteBoardItem;
623            favThread       : TFavoriteThreadItem;
624            favorites       : TTreeNodes;
625  begin  begin
626    
627          FavoriteFilePath := GikoSys.GetConfigDir + FAVORITE_FILE_NAME;          // 面倒だけどthreadはそれぞれURLをチェックしながらやってかなきゃいけない。
628            favorites := FavoriteDM.FTreeView.Items;
629          if FileExists( FavoriteFilePath ) then begin          for i := 0 to oldURLs.Count - 1 do begin
                 tempStringList := TStringList.Create;  
630                  try                  try
631                          tempStringList.LoadFromFile( FavoriteFilePath );                          tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
632              if oldURLs.Count = newURLs.Count then begin                          oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
633                  //これで、Boardは全て切り替わる                          oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
634                          for i := 0 to oldURLs.Count - 1 do begin                          tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
635                                          try                          newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
636                                                  CustomStringReplace(tempStringList,oldURLs[i],newURLs[i],true);                          newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
637                                          except  
638                                          end;                          for j := favorites.Count - 1 downto 0 do begin
639                                  end;                                  try
640                                  //面倒だけどthreadはそれぞれURLをチャックしながらやってかなきゃいけない。                                          if TObject( favorites.Item[ j ].Data ) is TFavoriteBoardItem then begin
641                                  for i := 0 to oldURLs.Count - 1 do begin                                                  favBoard := TFavoriteBoardItem( favorites.Item[ j ].Data );
642                                          try                                                  if favBoard = nil then continue;
643                                                  tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);                                                  tempString := favBoard.URL;
644                                                  oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );                                                  if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
645                                                  oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';                                                          tempString              := StringReplace(tempString, oldHost, newHost,[]);
646                                                  tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);                                                          favBoard.URL    := tempString;
647                                                  newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );                                                  end;
648                                                  newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';                                          end else if TObject( favorites.Item[ j ].Data ) is TFavoriteThreadItem then begin
649                                                    if favThread = nil then continue;
650                                                  for j := 0 to tempStringList.Count - 1 do begin                                                  tempString := favThread.URL;
651                                                          try                                                  if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
652                                                                  tempString := tempStringList[j];                                                          tempString              := StringReplace(tempString, oldHost, newHost,[]);
653                                                                  if AnsiPos('favtype="thread"',tempString ) <> 0 then begin                                                          favThread.URL   := tempString;
                                                                         tempString := Copy(tempString, AnsiPos('url="',tempString ) + 5, AnsiPos('" title="',tempString ) -AnsiPos('url="',tempString ) - 5);  
                                                                         if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin  
                                                                                 tempString := StringReplace(tempStringList[j], oldHost, newHost,[]);  
                                                                                 //tempString := StringReplace(tempString, oldBoardName, newBoardName,[]);  
                                                                                 tempStringList[j] := tempString;  
                                                                         end;  
                                                                 end;  
                                                         except  
                                                         end;  
654                                                  end;                                                  end;
                                         except  
655                                          end;                                          end;
656                  end;                                  except
657                                    end;
658              end;                          end;
659                    except
                         tempStringList.SaveToFile( FavoriteFilePath );  
                 finally  
                         tempStringList.Free;  
660                  end;                  end;
661          end;          end;
662    
663  end;  end;
664    
665  function TFavoriteDM.GetFavoriteFilePath() : String;  function TFavoriteDM.GetFavoriteFilePath() : String;

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

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