OSDN Git Service

板更新で、自動で巡回のURLを更新するようにした
[gikonavigoeson/gikonavi.git] / RoundData.pas
index 4f65064..90ebfd6 100644 (file)
@@ -44,6 +44,8 @@ type
                procedure LoadRoundBoardFile;
         procedure LoadRoundThreadFile;
                procedure SaveRoundFile;
+
+        procedure URLReplace(oldURLs: TStringList; newURLs :TStringList);
        end;
 
        TRoundItem = class(TObject)
@@ -630,5 +632,48 @@ begin
         end;
     end;
 end;
+procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);
+var
+       i: Integer;
+    j: Integer;
+    tempString: string;
+    tmpURL: string;
+    oldHost: string;
+    oldBoardName: string;
+    newHost: string;
+    newBoardName: string;
+begin
+    if oldURLs.Count <> newURLs.Count then
+       Exit;
+    //\82±\82±\82©\82ç\81ABoard\82ÌURL\82Ì\95Ï\8dX
+    for j :=0 to oldURLs.Count - 1 do begin
+               for i :=0 to FBoardList.Count - 1 do begin
+               if TRoundItem(FBoardList[i]).FURL = oldURLs[i] then
+               TRoundItem(FBoardList[i]).FURL := newURLs[i];
+       end;
+    end;
+    //\82±\82±\82Ü\82Å\81ABoard\82ÌURL\82Ì\95Ï\8dX
+
+    //\82±\82±\82©\82ç\81AThread\82ÌURL\82Ì\95Ï\8dX
+    //\96Ê\93|\82¾\82¯\82Çthread\82Í\82»\82ê\82¼\82êURL\82ð\83`\83\83\83b\83N\82µ\82È\82ª\82ç\82â\82Á\82Ä\82©\82È\82«\82á\82¢\82¯\82È\82¢\81B
+    for i := 0 to oldURLs.Count - 1 do begin
+        tmpURL                         := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
+        oldHost                        := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
+        oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
+        tmpURL                         := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
+        newHost                        := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
+        newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
+
+        for j := 0 to FItemList.Count - 1 do begin
+            tempString := TRoundItem(FItemList[j]).FURL;
+            if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
+               tempString := StringReplace(tempString, oldHost, newHost,[]);
+                TRoundItem(FItemList[j]).FURL := tempString;
+            end;
+        end;
+    end;
+    //\82±\82±\82Ü\82Å\81AThread\82ÌURL\82Ì\95Ï\8dX
+
+end;
 
 end.