Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/HTMLCreate.pas

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

revision 1.4 by h677, Thu Aug 25 16:11:02 2005 UTC revision 1.4.2.10 by h677, Thu Nov 3 08:12:15 2005 UTC
# Line 4  interface Line 4  interface
4    
5  uses  uses
6          Windows, Messages, SysUtils, Classes, {Graphics,} Controls, {Forms,}          Windows, Messages, SysUtils, Classes, {Graphics,} Controls, {Forms,}
7          ComCtrls, IniFiles, ShellAPI, Math, GikoSystem,          ComCtrls, IniFiles, ShellAPI, Math, GikoSystem, ActiveX,
8  {$IF Defined(DELPRO) }  {$IF Defined(DELPRO) }
9          SHDocVw,          SHDocVw,
10          MSHTML,          MSHTML,
# Line 31  type Line 31  type
31                  constructor Create;                  constructor Create;
32    
33                  function AddBeProfileLink(AID : string; ANum: Integer):string ;                  function AddBeProfileLink(AID : string; ANum: Integer):string ;
34                  procedure CreateUsePluginHTML(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);                  procedure CreateUsePluginHTML(html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
35                  procedure CreateUseSKINHTML(doc: Variant; ThreadItem: TThreadItem; ReadList: TStringList);                  procedure CreateUseSKINHTML(html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList);
36                  procedure CreateUseCSSHTML(doc: Variant; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );                  procedure CreateUseCSSHTML(html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
37                  procedure CreateDefaultHTML (doc: Variant; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );                  procedure CreateDefaultHTML (html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
38                  function ConvertResAnchor(res: string): string;                  function ConvertResAnchor(res: string): string;
39                    procedure separateNumber(var st: String; var et: String; const Text, Separator: String);
40          public          public
41                  { Public 宣言 }                  { Public 宣言 }
42                  function AddAnchorTag(s: string): string;                  function AddAnchorTag(s: string): string;
43                  function LoadFromSkin(fileName: string; ThreadItem: TThreadItem; SizeByte: Integer): string;                  function LoadFromSkin(fileName: string; ThreadItem: TThreadItem; SizeByte: Integer): string;
44                  function SkinedRes(skin: string; Res: TResRec; No: string): string;                  function SkinedRes(skin: string; Res: TResRec; No: string): string;
45                  function ConvRes(const Body, Bbs, Key,  ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; DatToHTML: boolean = false): string; overload;                  function ConvRes(const Body, Bbs, Key,  ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; DatToHTML: boolean = false): string; overload;
46                  function ConvRes(const Body, Bbs, Key,  ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue, FullURL : string): string; overload;                  procedure CreateHTML2(doc: IDispatch; ThreadItem: TThreadItem; var sTitle: string);
                 procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);  
47                  procedure CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string);                  procedure CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
48          end;          end;
49    
# Line 118  begin Line 118  begin
118                          CustomStringReplace( Skin, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ));                          CustomStringReplace( Skin, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ));
119                          CustomStringReplace( Skin, '<SIZE/>', IntToStr( SizeByte ));                          CustomStringReplace( Skin, '<SIZE/>', IntToStr( SizeByte ));
120    
121    
122                          //----- とりあえずかちゅ〜しゃ互換用。コメントアウトしてもよし                          //----- とりあえずかちゅ〜しゃ互換用。コメントアウトしてもよし
123                          // やりかたが苦しいけど、オプションダイアログのプレビュー用 try                          if GikoSys.Setting.UseKatjushaType then begin
124                          try                                  // やりかたが苦しいけど、オプションダイアログのプレビュー用 try
125                                  if ThreadItem.ParentBoard <> nil then                                  try
126                                          if ThreadItem.ParentBoard.ParentCategory <> nil then                                          if ThreadItem.ParentBoard <> nil then
127                                                  CustomStringReplace( Skin, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);                                                  if ThreadItem.ParentBoard.ParentCategory <> nil then
128                                          CustomStringReplace( Skin, '&THREADURL', ThreadItem.URL);                                                          CustomStringReplace( Skin, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
129                          except end;                                                  CustomStringReplace( Skin, '&THREADURL', ThreadItem.URL);
130                          CustomStringReplace( Skin, '&BOARDNAME', ThreadItem.ParentBoard.Title);                                  except end;
131                          CustomStringReplace( Skin, '&BOARDURL', ThreadItem.ParentBoard.URL);                                  CustomStringReplace( Skin, '&BOARDNAME', ThreadItem.ParentBoard.Title);
132                          CustomStringReplace( Skin, '&THREADNAME', ThreadItem.Title);                                  CustomStringReplace( Skin, '&BOARDURL', ThreadItem.ParentBoard.URL);
133                          CustomStringReplace( Skin, '&SKINPATH', GikoSys.Setting.CSSFileName);                                  CustomStringReplace( Skin, '&THREADNAME', ThreadItem.Title);
134                          CustomStringReplace( Skin, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ));                                  CustomStringReplace( Skin, '&SKINPATH', GikoSys.Setting.CSSFileName);
135                          CustomStringReplace( Skin, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ));                                  CustomStringReplace( Skin, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ));
136                          CustomStringReplace( Skin, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ));                                  CustomStringReplace( Skin, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ));
137                                    CustomStringReplace( Skin, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ));
138                          CustomStringReplace( Skin, '&NEWDATE', FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));  
139                          CustomStringReplace( Skin, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ));                                  CustomStringReplace( Skin, '&NEWDATE', FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
140                          CustomStringReplace( Skin, '&SIZE', IntToStr( SizeByte ));                                  CustomStringReplace( Skin, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ));
141                          //----- ここまで                                  CustomStringReplace( Skin, '&SIZE', IntToStr( SizeByte ));
142                                    //----- ここまで
143                            end;
144                  end;                  end;
145                  Result := Skin.Text;                  Result := Skin.Text;
146          finally          finally
# Line 174  begin Line 177  begin
177                  Skin := CustomStringReplace( Skin, '<NONSPAMMINESS/>', FloatToStr( 100 - spamminess ) );                  Skin := CustomStringReplace( Skin, '<NONSPAMMINESS/>', FloatToStr( 100 - spamminess ) );
178    
179                  //----- かちゅ〜しゃ互換用。コメントアウトしてもよし                  //----- かちゅ〜しゃ互換用。コメントアウトしてもよし
180                  Skin := CustomStringReplace( Skin, '&NUMBER',                  if GikoSys.Setting.UseKatjushaType then begin
181                          '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');                          Skin := CustomStringReplace( Skin, '&NUMBER',
182                  Skin := CustomStringReplace( Skin, '&PLAINNUMBER', No);                                  '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
183                  Skin := CustomStringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>');                          Skin := CustomStringReplace( Skin, '&PLAINNUMBER', No);
184                  Skin := CustomStringReplace( Skin, '&MAILNAME',                          Skin := CustomStringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>');
185                          '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');                          Skin := CustomStringReplace( Skin, '&MAILNAME',
186                  Skin := CustomStringReplace( Skin, '&MAIL', Res.FMailTo);                                  '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
187                  Skin := CustomStringReplace( Skin, '&DATE', Res.FDateTime);                          Skin := CustomStringReplace( Skin, '&MAIL', Res.FMailTo);
188                  Skin := CustomStringReplace( Skin, '&MESSAGE', Res.FBody);                          Skin := CustomStringReplace( Skin, '&DATE', Res.FDateTime);
189                  Skin := CustomStringReplace( Skin, '&SPAMMINESS', FloatToStr( spamminess ) );                          Skin := CustomStringReplace( Skin, '&MESSAGE', Res.FBody);
190                  Skin := CustomStringReplace( Skin, '&NONSPAMMINESS', FloatToStr( 100 - spamminess ) );                          Skin := CustomStringReplace( Skin, '&SPAMMINESS', FloatToStr( spamminess ) );
191                            Skin := CustomStringReplace( Skin, '&NONSPAMMINESS', FloatToStr( 100 - spamminess ) );
192            end;
193                  //----- ここまで                  //----- ここまで
194    
195                  Result := Skin;                  Result := Skin;
# Line 296  begin Line 301  begin
301          end else          end else
302                  Result := AID;                  Result := AID;
303  end;  end;
304    procedure THTMLCreate.separateNumber(var st: String; var et: String; const Text, Separator: String);
305    var
306            p : Integer;
307    begin
308            p := Pos(Separator,Text);
309            if (p > 0 ) then begin
310                    st := Copy(Text, 1, p - 1);
311                    et := Copy(Text, p + Length(Separator), Length(Text));
312            end else begin
313                    st := Text;
314                    et := Text;
315            end;
316    end;
317    
318  (*************************************************************************  (*************************************************************************
319   *   *
320   * from HotZonu   * from HotZonu
# Line 303  end; Line 322  end;
322  function THTMLCreate.ConvRes(const Body, Bbs, Key,  function THTMLCreate.ConvRes(const Body, Bbs, Key,
323          ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string;          ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string;
324          DatToHTML: boolean = false): string;          DatToHTML: boolean = false): string;
 type  
         PIndex = ^TIndex;  
         TIndex = record  
                 FIndexFrom      : integer;  
                 FIndexTo                : integer;  
                 FNo                              : string;  
         end;  
325  const  const
326          GT      = '&gt;';          GT      = '&gt;';
327          SN      = '0123456789-';          SN      = '0123456789';
328          ZN      = '0123456789−';          FORMAT_LINK = '<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">';
329  var  var
330          i : integer;          i : integer;
331          s,r : string;          s : string;
         b : TMbcsByteType;  
332          sw: boolean;          sw: boolean;
333          sp: integer;          cm: boolean;
334          No: string;          No: string;
         sx: string;  
         List: TList;  
335          oc      : string;          oc      : string;
336          st, et: string;          st, et: string;
337          chk : boolean;          pos, pmin : integer;
338          al : boolean;          j : integer;
339          procedure Add(IndexFrom, IndexTo: integer; const No: string);          token : array[0..5] of string;
340          var          ch : string;
341                  FIndex : PIndex;          db : boolean;
342          begin          len : integer;
343                  New(FIndex);          rink : string;
                 FIndex.FIndexFrom       := IndexFrom;  
                 FIndex.FIndexTo         := IndexTo;  
                 FIndex.FNo                               := No;  
                 List.Add(FIndex);  
         end;  
         function ChooseString(const Text, Separator: string; Index: integer): string;  
         var  
                 S : string;  
                 i, p : integer;  
         begin  
                 S :=    Text;  
                 for i :=        0 to    Index - 1 do    begin  
                         if      (AnsiPos(Separator, S) = 0) then        S :=    ''  
                         else    S :=    Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));  
                 end;  
                 p :=    AnsiPos(Separator, S);  
                 if      (p > 0) then    Result  :=      Copy(S, 1, p - 1) else Result :=        S;  
         end;  
344  begin  begin
345          { v1.0 b2 - 03 }          //s に本文を全部入れる
346          s        :=     Body;          s        :=     Body;
347          r        :=     Body;          //結果をクリア
348          i        :=     1;          Result   :=     '';
349          sw      :=      False;          //検索対象の文字列郡
350          No      :=      '';          token[0] := GT + GT;
351          List:=  TList.Create;          token[1] := GT;
352          oc      :=      '';          token[2] := '>>';
353          sp      :=      0;          token[3] := '>';
354          chk :=  False;          token[4] := '<a ';
355          al      :=      False;          token[5] := '<A ';
356          while true      do      begin  
357                  b :=    ByteType(s, i);          //
358                  case    b of          while Length(s) > 2 do begin
359                          mbSingleByte    : begin                  pmin := Length(s) + 1;
360                                  if      (not sw) and (Copy(s,i,8) = GT + GT) then       begin                  i       := Length(token);
361                                          if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then        begin                  for j := 0 to 5 do begin
362                                                  sw      :=      True;                          pos := AnsiPos(token[j], s);
363                                                  sp      :=      i;                          if pos <> 0 then begin
364                                                  i :=    i + 7;                                  if pos < pmin then begin
365                                                  oc:='';                                          //どれでヒットしたか保存
366                                                  chk :=  True;                                          i := j;
367                                          end;                                          //最小値を更新
368                                  end else                                          pmin := pos;
369                                  if      (not sw) and (Copy(s,i,8) = GT + GT) then       begin                                  end;
370                                          if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then        begin                          end;
371                                                  i :=    i + 7;                  end;
372                                                  oc:='';  
373                                                  chk :=  True;                  //ヒットした文字列の一つ手前まで結果にコピー
374                                          end;                  Result := Result + Copy(s, 1, pmin - 1);
375                                  end else                  Delete(s, 1, pmin - 1);
376                                  if      (not sw) and (Copy(s,i,4) = GT) then    begin  
377                                          if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then        begin                  if i = 6 then begin
378                                                  sw      :=      True;                          //ヒットなし
379                                                  sp      :=      i;                  end else if (i = 4) or (i = 5) then begin
380                                                  i :=    i + 3;                          //'<a ' or '<A' でヒット '</a>' or '</A>' までコピー
381                                                  oc:='';                          pmin := AnsiPos('</a>' , s);
382                                                  chk :=  True;                          pos := AnsiPos('</A>' , s);
383                                          end;                          if (pmin <> 0) and (pos <> 0) then begin
384                                  end else                                  if (pmin > pos) then begin
385                                  if      ((not sw) and (Copy(s,i,1) = ',')) or                                          pmin := pos;
386                                                  ((not sw) and (Copy(s,i,1) = '=')) then begin                                  end;
387                                          if      ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or                          end else if (pos <> 0) then begin
388                                                          ((Chk) and      (oc = '')) or                                  pmin := pos;
389                                                          ((not Chk) and (al)) then                          end;
390                                          begin                          rink := Copy(s, 1, pmin + 3);
391                                                  sw      :=      True;                          Result := Result + rink;
392                                                  sp      :=      i;                          Delete(s, 1, pmin + 3);
393                                                  //i :=  i + 1;  
394                                                  oc:='';                          pmin := Length(rink);
395                                          end;                          i       := Length(token);
396                                  end else                          for j := 0 to 3 do begin
397                                  if      (sw) then begin                                  pos := AnsiPos(token[j], rink);
398                                          sx      :=      Copy(s,i,1);                                  if pos <> 0 then begin
399                                          if      (AnsiPos(sx, SN) > 0)   then    begin                                          if pos < pmin then begin
400                                                  No      :=      No      + sx;                                                  //どれでヒットしたか保存
401                                          end else begin                                                  i := j;
402                                                  if      (No <> '') and (No <> '-')       then   begin                                                  //最小値を更新
403                                                          Add(sp, i, No);                                                  pmin := pos;
                                                         al := True;  
                                                 end;  
                                                 sw      :=      False;  
                                                 //  
                                                 i := i - 1;  
                                                 //  
                                                 No      := '';  
                                                 oc:='';  
                                                 //chk :=        False;  
404                                          end;                                          end;
                                 end else begin  
                                         if      Copy(s,i,1) = '<' then  oc      :=      '';  
                                         oc      :=      oc + Copy(s,i,1);  
                                         chk :=  False;  
                                         al      :=      False;  
405                                  end;                                  end;
406                          end;                          end;
407                          mbLeadByte      : begin                          // レスアンカーが含まれていたら,が続く限りアンカーとして扱う
408                                  if      (not sw) and (Copy(s,i,4) = '>>') then        begin                          if i <= 3 then begin
409                                          sw      :=      True;                                  cm := false;
410                                          sp      :=      i;                                  j := 1 ;
411                                          i :=    i + 3;                                  len := Length(s);
412                                          chk :=  True;                                  if ((len > 0) and (s[j] = ',')) or
413                                  end else                                          ((len > 1) and (ZenToHan(Copy(s, j ,2)) = ',')) then begin
414                                  if      (not sw) and (Copy(s,i,2) = '>') then  begin                                          cm := true;
415                                          sw      :=      True;                                          db := false;
416                                          sp      :=      i;                                          sw := false;
417                                          i :=    i + 1;                                          if (ByteType(s, j) = mbSingleByte) then
418                                          chk :=  True;                                                  Inc(j)
419                                  end else                                          else
420                                  if      (sw) then begin                                                  Inc(j, 2);
421                                          sx      :=      Copy(s,i,2);                                          No := '';
422                                          if      (AnsiPos(sx, ZN) > 0)   then    begin                                          len := Length(s);
423                                                  No      :=      No      + ZenToHan(sx);                                          while cm do begin
424                                          end else begin                                                  while (j <= len) do begin
425                                                  if      (No <> '') and (No <> '-')      and (No <> '−') then   begin                                                          if (ByteType(s, j) = mbSingleByte) then begin
426                                                          Add(sp, i, No);                                                                  //1byte文字
427                                                                    ch := s[j];
428                                                                    Inc(j);
429                                                                    db := false;
430                                                            end else begin
431                                                                    //2byte文字
432                                                                    ch := ZenToHan(Copy(s, j, 2));
433                                                                    Inc(j, 2);
434                                                                    db := true;
435                                                            end;
436                                                            if System.Pos(ch, SN) > 0 then begin
437                                                                    No := No + ch;
438                                                            end else if (ch = '-') then begin
439                                                                    if sw then break;
440                                                                    if No = '' then cm := false;
441                                                                    No := No + ch;
442                                                                    sw := true;
443                                                            end else begin
444                                                                    break;
445                                                            end;
446                                                    end;
447                                                    //終端まで行っての終了かチェック
448                                                    if j <= len then begin
449                                                            if db then j := j - 2
450                                                            else j := j - 1;
451                                                    end;
452                                                    //何も数字が見つからないとき
453                                                    if No = '' then begin
454                                                            Result := Result + Copy(s, 1, j - 1);
455                                                    end else begin
456                                                            separateNumber(st, et, No, '-');
457    
458                                                            if not DatToHTML then begin
459                                                                    Result := Result + Format(FORMAT_LINK,
460                                                                            [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]);
461                                                            end else begin
462                                                                    Result := Result + Format('<a href="#%s">', [st]);
463                                                            end;
464                                                            Result := Result + Copy(s, 1, j - 1) + '</a>';
465                                                    end;
466                                                    Delete(s, 1, j - 1);
467                                                    j := 1;
468                                                    if (s[j] = ',') or (ZenToHan(Copy(s, j ,2)) = ',')  then begin
469                                                            cm := true;
470                                                            if (ByteType(s, j) = mbSingleByte) then
471                                                                    Inc(j)
472                                                            else
473                                                                    Inc(j, 2);
474                                                            No := '';
475                                                            len := Length(s);
476                                                    end else begin
477                                                            cm := false;
478                                                  end;                                                  end;
                                                 sw      :=      False;  
                                                 i := i - 1;  
                                                 No      :=      '';  
479                                          end;                                          end;
                                 end else begin  
                                         oc      :=      '';  
                                         chk :=  False;  
480                                  end;                                  end;
                                 al      :=      False;  
481                          end;                          end;
                 end;  
                 inc(i);  
                 if      (i > Length(Body))      then    begin  
                         if      (sw)    then    begin  
                                 if      (No <> '')      then    Add(sp, i, No);  
                         end;  
                         Break;  
                 end;  
         end;  
         for i :=        List.Count - 1  downto  0 do    begin  
                 if      (AnsiPos('-', PIndex(List[i]).FNo) > 0) then    begin  
                         st      :=      ChooseString(PIndex(List[i]).FNo, '-', 0);  
                         et      :=      ChooseString(PIndex(List[i]).FNo, '-', 1);  
482                  end else begin                  end else begin
483                          st      :=      PIndex(List[i]).FNo;                          //何かしら見つかったパターン
484                          et      :=      PIndex(List[i]).FNo;                          j := Length(token[i]) + 1;
485                  end;                          oc := '';
486                  if not DatToHTML then                          No := '';
487                  r :=    Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +                          sw := false;
488                                          Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',                          db := false;
489                                                                  [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +                          len := Length(s);
490                                          Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +                          while j <= len do begin
491                                          Copy(r,PIndex(List[i]).FIndexTo,Length(r))                                  if (ByteType(s, j) = mbSingleByte) then begin
492                  else                                          //1byte文字
493                  r :=    Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +                                          ch := s[j];
494                                          Format('<a href="#%s">', [st]) +                                          Inc(j);
495                                          Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +                                          db := false;
496                                          Copy(r,PIndex(List[i]).FIndexTo,Length(r));                                  end else begin
497                                            //2byte文字
498                  Dispose(PIndex(List[i]));                                          ch := ZenToHan(Copy(s, j, 2));
499          end;                                          Inc(j, 2);
500          List.Free;                                          db := true;
501          Result  :=      r;                                  end;
 end;  
502    
503  function THTMLCreate.ConvRes(                                  if System.Pos(ch, SN) > 0 then begin
504          const Body, Bbs, Key, ParamBBS, ParamKey,                                          No := No + ch;
505          ParamStart, ParamTo, ParamNoFirst,                                  end else if (ch = '-') then begin
506          ParamTrue, FullURL : string                                          if sw then break;
507  ): string;                                          if No = '' then break;
508  type                                          No := No + ch;
509          PIndex = ^TIndex;                                          sw := true;
         TIndex = record  
                 FIndexFrom      : integer;  
                 FIndexTo                : integer;  
                 FNo                              : string;  
         end;  
 const  
         GT      = '&gt;';  
         SN      = '0123456789-';  
         ZN      = '0123456789−';  
 var  
         i : integer;  
         s,r : string;  
         b : TMbcsByteType;  
         sw: boolean;  
         sp: integer;  
         No: string;  
         sx: string;  
         List: TList;  
         oc      : string;  
         st, et: string;  
         chk : boolean;  
         al : boolean;  
         procedure Add(IndexFrom, IndexTo: integer; const No: string);  
         var  
                 FIndex : PIndex;  
         begin  
                 New(FIndex);  
                 FIndex.FIndexFrom       := IndexFrom;  
                 FIndex.FIndexTo         := IndexTo;  
                 FIndex.FNo                               := No;  
                 List.Add(FIndex);  
         end;  
         function ChooseString(const Text, Separator: string; Index: integer): string;  
         var  
                 S : string;  
                 i, p : integer;  
         begin  
                 S :=    Text;  
                 for i :=        0 to    Index - 1 do    begin  
                         if      (AnsiPos(Separator, S) = 0) then        S :=    ''  
                         else    S :=    Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));  
                 end;  
                 p :=    AnsiPos(Separator, S);  
                 if      (p > 0) then    Result  :=      Copy(S, 1, p - 1) else Result :=        S;  
         end;  
 begin  
         { v1.0 b2 - 03 }  
         s        :=     Body;  
         r        :=     Body;  
         i        :=     1;  
         sw      :=      False;  
         No      :=      '';  
         List:=  TList.Create;  
         oc      :=      '';  
         sp      :=      0;  
         chk :=  False;  
         al      :=      False;  
         while true      do      begin  
                 b :=    ByteType(s, i);  
                 case    b of  
                         mbSingleByte    : begin  
                                 if      (not sw) and (Copy(s,i,8) = GT + GT) then       begin  
                                         if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then        begin  
                                                 sw      :=      True;  
                                                 sp      :=      i;  
                                                 i :=    i + 7;  
                                                 oc:='';  
                                                 chk :=  True;  
                                         end;  
                                 end else  
                                 if      (not sw) and (Copy(s,i,8) = GT + GT) then       begin  
                                         if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then        begin  
                                                 i :=    i + 7;  
                                                 oc:='';  
                                                 chk :=  True;  
                                         end;  
                                 end else  
                                 if      (not sw) and (Copy(s,i,4) = GT) then    begin  
                                         if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then        begin  
                                                 sw      :=      True;  
                                                 sp      :=      i;  
                                                 i :=    i + 3;  
                                                 oc:='';  
                                                 chk :=  True;  
                                         end;  
                                 end else  
                                 if      ((not sw) and (Copy(s,i,1) = ',')) or  
                                                 ((not sw) and (Copy(s,i,1) = '=')) then begin  
                                         if      ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or  
                                                         ((Chk) and      (oc = '')) or  
                                                         ((not Chk) and (al)) then  
                                         begin  
                                                 sw      :=      True;  
                                                 sp      :=      i;  
                                                 //i :=  i + 1;  
                                                 oc:='';  
                                         end;  
                                 end else  
                                 if      (sw) then begin  
                                         sx      :=      Copy(s,i,1);  
                                         if      (AnsiPos(sx, SN) > 0)   then    begin  
                                                 No      :=      No      + sx;  
                                         end else begin  
                                                 if      (No <> '') and (No <> '-')       then   begin  
                                                         Add(sp, i, No);  
                                                         al := True;  
                                                 end;  
                                                 sw      :=      False;  
                                                 //  
                                                 i := i - 1;  
                                                 //  
                                                 No      := '';  
                                                 oc:='';  
                                                 //chk :=        False;  
                                         end;  
510                                  end else begin                                  end else begin
511                                          if      Copy(s,i,1) = '<' then  oc      :=      '';                                          break;
                                         oc      :=      oc + Copy(s,i,1);  
                                         chk :=  False;  
                                         al      :=      False;  
512                                  end;                                  end;
513                          end;                          end;
514                          mbLeadByte      : begin                          //終端まで行っての終了かチェック
515                                  if      (not sw) and (Copy(s,i,4) = '>>') then        begin                          if j <= len then begin
516                                          sw      :=      True;                                  if db then j := j - 2
517                                          sp      :=      i;                                  else j := j - 1;
518                                          i :=    i + 3;                          end;
519                                          chk :=  True;                          //何も数字が見つからないとき
520                                  end else                          if No = '' then begin
521                                  if      (not sw) and (Copy(s,i,2) = '>') then  begin                                  Result := Result + Copy(s, 1, j - 1);
522                                          sw      :=      True;                          end else begin
523                                          sp      :=      i;                                  separateNumber(st, et, No, '-');
524                                          i :=    i + 1;  
525                                          chk :=  True;                                  if not DatToHTML then begin
526                                  end else                                          Result := Result + Format(FORMAT_LINK,
527                                  if      (sw) then begin                                                                  [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]);
                                         sx      :=      Copy(s,i,2);  
                                         if      (AnsiPos(sx, ZN) > 0)   then    begin  
                                                 No      :=      No      + ZenToHan(sx);  
                                         end else begin  
                                                 if      (No <> '') and (No <> '-')      and (No <> '−') then   begin  
                                                         Add(sp, i, No);  
                                                 end;  
                                                 sw      :=      False;  
                                                 i := i - 1;  
                                                 No      :=      '';  
                                         end;  
528                                  end else begin                                  end else begin
529                                          oc      :=      '';                                          Result := Result + Format('<a href="#%s">', [st]);
                                         chk :=  False;  
530                                  end;                                  end;
531                                  al      :=      False;                                  Result := Result + Copy(s, 1, j - 1) + '</a>';
                         end;  
                 end;  
                 inc(i);  
                 if      (i > Length(Body))      then    begin  
                         if      (sw)    then    begin  
                                 if      (No <> '')      then    Add(sp, i, No);  
532                          end;                          end;
533                          Break;                          Delete(s, 1, j - 1);
                 end;  
         end;  
         for i :=        List.Count - 1  downto  0 do    begin  
                 //plName := Copy(PluginName, LastDelimiter('\',PluginName) + 1, Length(PluginName) - LastDelimiter('/',PluginName) -1 );  
                 if      (AnsiPos('-', PIndex(List[i]).FNo) > 0) then    begin  
                         st      :=      ChooseString(PIndex(List[i]).FNo, '-', 0);  
                         et      :=      ChooseString(PIndex(List[i]).FNo, '-', 1);  
                 end else begin  
                         st      :=      PIndex(List[i]).FNo;  
                         et      :=      PIndex(List[i]).FNo;  
534                  end;                  end;
                 r :=    Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +  
                                         Format('<a href="%s&%s=%s&%s=%s&%s=%s" target="_blank">',  
                                                                 [FullURL, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +  
                                         Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +  
                                         Copy(r,PIndex(List[i]).FIndexTo,Length(r));  
                 Dispose(PIndex(List[i]));  
535          end;          end;
536          List.Free;          Result := Result + s;
         Result  :=      r;  
537  end;  end;
538    
539  function THTMLCreate.ConvertResAnchor(res: string): string;  function THTMLCreate.ConvertResAnchor(res: string): string;
# Line 731  begin Line 585  begin
585  end;  end;
586    
587  //Pluginを利用するBoardのスレッドのHTMLを作成してdocに書き込む  //Pluginを利用するBoardのスレッドのHTMLを作成してdocに書き込む
588  procedure THTMLCreate.CreateUsePluginHTML(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);  procedure THTMLCreate.CreateUsePluginHTML(html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
589  var  var
590          i: integer;          i: integer;
591          NewReceiveNo: Integer;          NewReceiveNo: Integer;
# Line 745  begin Line 599  begin
599                          NewReceiveNo    := ThreadItem.NewReceive;                          NewReceiveNo    := ThreadItem.NewReceive;
600                          // フォントやサイズの設定                          // フォントやサイズの設定
601                          UserOptionalStyle := GikoSys.SetUserOptionalStyle;                          UserOptionalStyle := GikoSys.SetUserOptionalStyle;
602                            html.BeginUpdate;
603                          try                          try
                                 doc.open;  
604                                  // ヘッダ                                  // ヘッダ
605                                  doc.Write( boardPlugIn.GetHeader( DWORD( threadItem ),                                  html.Append( boardPlugIn.GetHeader( DWORD( threadItem ),
606                                          '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ) + #13#10 );                                          '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ));
607                                  doc.Write('<p id="idSearch"></p>' + #13#10 );                                  html.Add('<p id="idSearch"></p>');
   
608                                  for i := 0 to threadItem.Count - 1 do begin                                  for i := 0 to threadItem.Count - 1 do begin
609                                          // 1 は必ず表示                                          // 1 は必ず表示
610                                          if i <> 0 then begin                                          if i <> 0 then begin
# Line 774  begin Line 627  begin
627                                                  try                                                  try
628                                                          if GikoSys.Setting.UseSkin then begin                                                          if GikoSys.Setting.UseSkin then begin
629                                                                  if FileExists( GikoSys.GetSkinNewmarkFileName ) then                                                                  if FileExists( GikoSys.GetSkinNewmarkFileName ) then
630                                                                          doc.Write( LoadFromSkin( GikoSys.GetSkinNewmarkFileName, ThreadItem, ThreadItem.Size ) + #13#10 )                                                                          html.Append( LoadFromSkin( GikoSys.GetSkinNewmarkFileName, ThreadItem, ThreadItem.Size ))
631                                                                  else                                                                  else
632                                                                          doc.Write( '<a name="new"></a>' + #13#10 );                                                                          //doc.Write( '<a name="new"></a>' + #13#10 );
633                                                                            html.Append( '<a name="new"></a>' );
634                                                          end else if GikoSys.Setting.UseCSS then begin                                                          end else if GikoSys.Setting.UseCSS then begin
635                                                                  doc.Write('<a name="new"></a><div class="new">新着レス <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>' + #13#10);                                                                  html.Append('<a name="new"></a><div class="new">新着レス <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
636                                                          end else begin                                                          end else begin
637                                                                  doc.Write('</dl>');                                                                  html.Append('</dl>');
638                                                                  doc.Write('<a name="new"></a>');                                                                  html.Append('<a name="new"></a>');
639                                                                  doc.Write('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>新着レス ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');                                                                  html.Append('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>新着レス ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
640                                                                  doc.Write('<dl> + #13#10');                                                                  html.Append('<dl>');
641                                                          end;                                                          end;
642                                                  except                                                  except
643                                                          doc.Write( '<a name="new"></a>' + #13#10);                                                          html.Append( '<a name="new"></a>');
644                                                  end;                                                  end;
645                                          end;                                          end;
646    
647                                          // レス                                          // レス
648                                          doc.Write( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) + #13#10 );                                          html.Append( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) );
649    
650                                          if ThreadItem.Kokomade = (i + 1) then begin                                          if ThreadItem.Kokomade = (i + 1) then begin
651                                                  // ここまで読んだ                                                  // ここまで読んだ
652                                                  try                                                  try
653                                                          if GikoSys.Setting.UseSkin then begin                                                          if GikoSys.Setting.UseSkin then begin
654                                                                  if FileExists( GikoSys.GetSkinBookmarkFileName ) then                                                                  if FileExists( GikoSys.GetSkinBookmarkFileName ) then
655                                                                          doc.Write( LoadFromSkin( GikoSys.GetSkinBookmarkFileName, ThreadItem, ThreadItem.Size ) + #13#10 )                                                                          html.Append( LoadFromSkin( GikoSys.GetSkinBookmarkFileName, ThreadItem, ThreadItem.Size ) )
656                                                                  else                                                                  else
657                                                                          doc.Write( '<a name="koko"></a>' + #13#10 );                                                                          html.Append( '<a name="koko"></a>' );
658                                                          end else if GikoSys.Setting.UseCSS then begin                                                          end else if GikoSys.Setting.UseCSS then begin
659                                                                  doc.Write('<a name="koko"></a><div class="koko">ココまで読んだ</div>' + #13#10 );                                                                  html.Append('<a name="koko"></a><div class="koko">ココまで読んだ</div>' );
660                                                          end else begin                                                          end else begin
661                                                                  doc.Write('</dl>');                                                                  html.Append('</dl>');
662                                                                  doc.Write('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>ココまで読んだ</b></font></td></tr></table>');                                                                  html.Append('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>ココまで読んだ</b></font></td></tr></table>');
663                                                                  doc.Write('<dl>' + #13#10 );                                                                  html.Append('<dl>' );
664                                                          end;                                                          end;
665                                                  except                                                  except
666                                                          doc.Write( '<a name="koko"></a>' + #13#10 );                                                          html.Append( '<a name="koko"></a>' );
667                                                  end;                                                  end;
668                                          end;                                          end;
669                                  end;                                  end;
670    
671    
672                                  // スキン(フッタ)                                  // スキン(フッタ)
673                                  doc.Write( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) + #13#10 );                                  html.Append( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
674                          finally                          finally
675                                  doc.Close;                                  html.EndUpdate;
676                          end;                          end;
677    
678                  end;                  end;
# Line 826  begin Line 680  begin
680  end;  end;
681    
682    
683  procedure THTMLCreate.CreateUseSKINHTML(doc: Variant; ThreadItem: TThreadItem; ReadList: TStringList);  procedure THTMLCreate.CreateUseSKINHTML(html : TStringList; ThreadItem: TThreadItem; ReadList: TStringList);
684  var  var
685          i: integer;          i: integer;
686          No: string;          No: string;
# Line 838  var Line 692  var
692          SkinNewRes: string;          SkinNewRes: string;
693          SkinRes: string;          SkinRes: string;
694          strTmp : string;          strTmp : string;
695          function ReplaceRes( skin: string ): string;          threadKey : string;
         begin  
                 Result := SkinedRes( skin, Res, No );  
         end;  
696  begin  begin
697          if ThreadItem <> nil then begin          if ThreadItem <> nil then begin
698                  // スキン使用                  // スキン使用
# Line 850  begin Line 701  begin
701                          // フォントやサイズの設定                          // フォントやサイズの設定
702                          UserOptionalStyle := GikoSys.SetUserOptionalStyle;                          UserOptionalStyle := GikoSys.SetUserOptionalStyle;
703                          CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;                          CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;
704                          doc.open;  
705                            threadKey := ChangeFileExt(ThreadItem.FileName, '');
706                            html.BeginUpdate;
707                          try                          try
708                                  doc.charset := 'Shift_JIS';                                  //doc.charset := 'Shift_JIS';
709    
710                                  // スキンの設定                                  // スキンの設定
711                                  try                                  try
# Line 860  begin Line 713  begin
713                                          if Length( UserOptionalStyle ) > 0 then                                          if Length( UserOptionalStyle ) > 0 then
714                                                  SkinHeader := CustomStringReplace( SkinHeader, '</head>',                                                  SkinHeader := CustomStringReplace( SkinHeader, '</head>',
715                                                          '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>');                                                          '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>');
716                                          doc.Write( SkinHeader + #13#10);                                          html.Append( SkinHeader);
717                                  except                                  except
718                                  end;                                  end;
719    
# Line 874  begin Line 727  begin
727                                  except                                  except
728                                  end;                                  end;
729    
730                                  doc.Write('<p id="idSearch"></p>' + #13#10);                                  html.Append('<p id="idSearch"></p>');
731                                  doc.Write('<a name="top"></a>' + #13#10);                                  html.Append('<a name="top"></a>');
732    
733                                  for i := 0 to ReadList.Count - 1 do begin                                  for i := 0 to ReadList.Count - 1 do begin
734                                          // 1 は必ず表示                                          // 1 は必ず表示
# Line 893  begin Line 746  begin
746                                                                  Continue;                                                                  Continue;
747                                                  end;                                                  end;
748                                          end;                                          end;
   
749                                          // 新着マーク                                          // 新着マーク
750                                          if (NewReceiveNo = i + 1) or ((NewReceiveNo = 0) and (i = 0)) then begin                                          if (NewReceiveNo = i + 1) or ((NewReceiveNo = 0) and (i = 0)) then begin
751                                                  try                                                  try
752                                                          if FileExists( GikoSys.GetSkinNewmarkFileName ) then                                                          if FileExists( GikoSys.GetSkinNewmarkFileName ) then
753                                                                  doc.Write( LoadFromSkin( GikoSys.GetSkinNewmarkFileName, ThreadItem, ThreadItem.Size )  + #13#10)                                                                  html.Append( LoadFromSkin( GikoSys.GetSkinNewmarkFileName, ThreadItem, ThreadItem.Size ) )
754                                                          else                                                          else
755                                                                  doc.Write( '<a name="new"></a>' + #13#10 );                                                                  html.Append( '<a name="new"></a>' );
756                                                  except                                                  except
757                                                          doc.Write( '<a name="new"></a>' + #13#10 );                                                          html.Append( '<a name="new"></a>' );
758                                                  end;                                                  end;
759                                          end;                                          end;
760    
# Line 910  begin Line 762  begin
762                                                  No := IntToStr(i + 1);                                                  No := IntToStr(i + 1);
763    
764                                                  Res := DivideStrLine(ReadList[i]);                                                  Res := DivideStrLine(ReadList[i]);
765                                                  Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');                                                  Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, threadKey, 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
766                                                  Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);                                                  Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
767    
768                                                  try                                                  try
769                                                          if NewReceiveNo <= (i + 1) then                                                          if NewReceiveNo <= (i + 1) then
770                                                                  // 新着レス                                                                  // 新着レス
771                                                                  strTmp := ReplaceRes( SkinNewRes )                                                                  strTmp := SkinedRes( SkinNewRes, Res, No )
772                                                          else                                                          else
773                                                                  // 通常のレス                                                                  // 通常のレス
774                                                                  strTmp := ReplaceRes( SkinRes );                                                                  strTmp := SkinedRes( SkinRes, Res, No  );
775    
776                                                          doc.Write( strTmp + #13#10 );                                                          html.Append( strTmp );
777                                                  except                                                  except
778                                                  end;                                                  end;
779                                          end;                                          end;
# Line 930  begin Line 782  begin
782                                                  // ここまで読んだ                                                  // ここまで読んだ
783                                                  try                                                  try
784                                                          if FileExists( GikoSys.GetSkinBookmarkFileName ) then                                                          if FileExists( GikoSys.GetSkinBookmarkFileName ) then
785                                                                  doc.Write( LoadFromSkin( GikoSys.GetSkinBookmarkFileName, ThreadItem, ThreadItem.Size ) + #13#10 )                                                                  html.Append( LoadFromSkin( GikoSys.GetSkinBookmarkFileName, ThreadItem, ThreadItem.Size ) )
786                                                          else                                                          else
787                                                                  doc.Write( '<a name="koko"></a>' + #13#10 );                                                                  html.Append( '<a name="koko"></a>' );
788                                                  except                                                  except
789                                                          doc.Write( '<a name="koko"></a>' + #13#10 );                                                          html.Append( '<a name="koko"></a>' );
790                                                  end;                                                  end;
791                                          end;                                          end;
792                                  end;                                  end;
793    
794                                  doc.Write('<a name="bottom"></a>' + #13#10);                                  html.Append('<a name="bottom"></a>' );
795                                  // スキン(フッタ)                                  // スキン(フッタ)
796                                  try                                  try
797                                          doc.Write( LoadFromSkin( GikoSys.GetSkinFooterFileName, ThreadItem, ThreadItem.Size ) + #13#10 );                                          html.Append( LoadFromSkin( GikoSys.GetSkinFooterFileName, ThreadItem, ThreadItem.Size ) );
798                                  except                                  except
799                                  end;                                  end;
800                          finally                          finally
801                                  doc.close;                                  html.EndUpdate;
802                          end;                          end;
803                  end;                  end;
804          end;          end;
805  end;  end;
806    
807  procedure THTMLCreate.CreateUseCSSHTML(doc: Variant; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );  procedure THTMLCreate.CreateUseCSSHTML(html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
808  var  var
809          i: integer;          i: integer;
810          No: string;          No: string;
# Line 962  var Line 814  var
814          UserOptionalStyle: string;          UserOptionalStyle: string;
815  begin  begin
816          if ThreadItem <> nil then begin          if ThreadItem <> nil then begin
817                  doc.open;                  //doc.open;
818                    html.BeginUpdate;
819                  try                  try
820                          doc.charset := 'Shift_JIS';                          //doc.charset := 'Shift_JIS';
821                          NewReceiveNo := ThreadItem.NewReceive;                          NewReceiveNo := ThreadItem.NewReceive;
822                          // フォントやサイズの設定                          // フォントやサイズの設定
823                          UserOptionalStyle := GikoSys.SetUserOptionalStyle;                          UserOptionalStyle := GikoSys.SetUserOptionalStyle;
824                          CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;                          CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;
825                          if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin                          if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
826                                  //CSS使用                                  //CSS使用
827                                  doc.Write('<html><head>' + #13#10);                                  html.Append('<html><head>');
828                                  doc.Write('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">' + #13#10);                                  html.Append('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
829                                  doc.Write('<title>' + sTitle + '</title>' + #13#10);                                  html.Append('<title>' + sTitle + '</title>');
830                                  doc.Write('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">' + #13#10);                                  html.Append('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
831                                  if Length( UserOptionalStyle ) > 0 then                                  if Length( UserOptionalStyle ) > 0 then
832                                          doc.Write('<style type="text/css">body {' + UserOptionalStyle + '}</style>' + #13#10);                                          html.Append('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
833                                  doc.Write('</head>' + #13#10);                                  html.Append('</head>');
834                                  doc.Write('<body>' + #13#10);                                  html.Append('<body>');
835                                  doc.Write('<a name="top"></a>' + #13#10);                                  html.Append('<a name="top"></a>');
836                                  doc.Write('<p id="idSearch"></p>' + #13#10);                                  html.Append('<p id="idSearch"></p>');
837                                  doc.Write('<div class="title">' + sTitle + '</div>' + #13#10);                                  html.Append('<div class="title">' + sTitle + '</div>');
838                                  for i := 0 to ReadList.Count - 1 do begin                                  for i := 0 to ReadList.Count - 1 do begin
839                                          // 1 は必ず表示                                          // 1 は必ず表示
840                                          if i <> 0 then begin                                          if i <> 0 then begin
# Line 1000  begin Line 853  begin
853                                          end;                                          end;
854    
855                                          if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin                                          if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
856                                                  doc.Write('<a name="new"></a><div class="new">新着レス <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>' + #13#10);                                                  html.Append('<a name="new"></a><div class="new">新着レス <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
857                                          end;                                          end;
858    
859                                          if (Trim(ReadList[i]) <> '') then begin                                          if (Trim(ReadList[i]) <> '') then begin
# Line 1009  begin Line 862  begin
862                                                  Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');                                                  Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
863                                                  Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);                                                  Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
864                                                  if Res.FMailTo = '' then                                                  if Res.FMailTo = '' then
865                                                          doc.Write('<a name="' + No + '"></a>'                                                          html.Append('<a name="' + No + '"></a>'
866                                                                                  + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '                                                                                  + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
867                                                                                  + '<span class="name_label">名前:</span> '                                                                                  + '<span class="name_label">名前:</span> '
868                                                                                  + '<span class="name"><b>' + Res.FName + '</b></span> '                                                                                  + '<span class="name"><b>' + Res.FName + '</b></span> '
869                                                                                  + '<span class="date_label">投稿日:</span> '                                                                                  + '<span class="date_label">投稿日:</span> '
870                                                                                  + '<span class="date">' + Res.FDateTime+ '</span></div>'                                                                                  + '<span class="date">' + Res.FDateTime+ '</span></div>'
871                                                                                  + '<div class="mes">' + Res.FBody + ' </div>' + #13#10)                                                                                  + '<div class="mes">' + Res.FBody + ' </div>')
872                                                  else if GikoSys.Setting.ShowMail then                                                  else if GikoSys.Setting.ShowMail then
873                                                          doc.Write('<a name="' + No + '"></a>'                                                          html.Append('<a name="' + No + '"></a>'
874                                                                                  + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'                                                                                  + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
875                                                                                  + '<span class="name_label"> 名前: </span>'                                                                                  + '<span class="name_label"> 名前: </span>'
876                                                                                  + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'                                                                                  + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
877                                                                                  + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'                                                                                  + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
878                                                                                  + '<span class="date_label"> 投稿日:</span>'                                                                                  + '<span class="date_label"> 投稿日:</span>'
879                                                                                  + '<span class="date"> ' + Res.FDateTime+ '</span></div>'                                                                                  + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
880                                                                                  + '<div class="mes">' + Res.FBody + ' </div>' + #13#10)                                                                                  + '<div class="mes">' + Res.FBody + ' </div>')
881                                                  else                                                  else
882                                                          doc.Write('<a name="' + No + '"></a>'                                                          html.Append('<a name="' + No + '"></a>'
883                                                                                  + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'                                                                                  + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
884                                                                                  + '<span class="name_label"> 名前: </span>'                                                                                  + '<span class="name_label"> 名前: </span>'
885                                                                                  + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'                                                                                  + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
886                                                                                  + '<b>' + Res.FName + '</b></a>'                                                                                  + '<b>' + Res.FName + '</b></a>'
887                                                                                  + '<span class="date_label"> 投稿日:</span>'                                                                                  + '<span class="date_label"> 投稿日:</span>'
888                                                                                  + '<span class="date"> ' + Res.FDateTime+ '</span></div>'                                                                                  + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
889                                                                                  + '<div class="mes">' + Res.FBody + ' </div>' + #13#10);                                                                                  + '<div class="mes">' + Res.FBody + ' </div>');
890                                          end;                                          end;
891    
892                                          if ThreadItem.Kokomade = (i + 1) then begin                                          if ThreadItem.Kokomade = (i + 1) then begin
893                                                  doc.Write('<a name="koko"></a><div class="koko">ココまで読んだ</div>' + #13#10);                                                  html.Append('<a name="koko"></a><div class="koko">ココまで読んだ</div>');
894                                          end;                                          end;
895    
896                                  end;                                  end;
897    
898                                  doc.Write('<a name="bottom"></a>' + #13#10);                                  html.Append('<a name="bottom"></a>');
899                                  doc.Write('<a name="last"></a>' + #13#10);                                  html.Append('<a name="last"></a>');
900                                  doc.Write('</body></html>' + #13#10);                                  html.Append('</body></html>');
901                          end;                          end;
902                  finally                  finally
903                          doc.Close;                          html.EndUpdate;
904                            //doc.Close;
905                  end;                  end;
906          end;          end;
907  end;  end;
908    
909  procedure THTMLCreate.CreateDefaultHTML (doc: Variant; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );  procedure THTMLCreate.CreateDefaultHTML (html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
910  var  var
911          i: integer;          i: integer;
912          No: string;          No: string;
# Line 1060  var Line 914  var
914          Res: TResRec;          Res: TResRec;
915  begin  begin
916          if ThreadItem <> nil then begin          if ThreadItem <> nil then begin
917                  doc.open;                  //doc.open;
918                    html.BeginUpdate;
919                  try                  try
920                          doc.charset := 'Shift_JIS';                          //doc.charset := 'Shift_JIS';
921                          NewReceiveNo := ThreadItem.NewReceive;                          NewReceiveNo := ThreadItem.NewReceive;
922                          doc.Write('<html><head>' + #13#10);                          html.Append('<html><head>');
923                          doc.Write('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">' + #13#10);                          html.Append('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
924                          doc.Write('<title>' + sTitle + '</title></head>' + #13#10);                          html.Append('<title>' + sTitle + '</title></head>');
925                          doc.Write('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">' + #13#10);                          html.Append('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
926                          doc.Write('<a name="top"></a>' + #13#10);                          html.Append('<a name="top"></a>');
927                          doc.Write('<font size=+1 color="#FF0000">' + sTitle + '</font>' + #13#10);                          html.Append('<font size=+1 color="#FF0000">' + sTitle + '</font>');
928                          doc.Write('<dl>' + #13#10);                          html.Append('<dl>');
929                          doc.Write('<p id="idSearch"></p>' + #13#10);                          html.Append('<p id="idSearch"></p>');
930                          for i := 0 to ReadList.Count - 1 do begin                          for i := 0 to ReadList.Count - 1 do begin
931                                  // 1 は必ず表示                                  // 1 は必ず表示
932                                  if i <> 0 then begin                                  if i <> 0 then begin
# Line 1090  begin Line 945  begin
945                                  end;                                  end;
946    
947                                  if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin                                  if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
948                                          doc.Write('</dl>' + #13#10);                                          html.Append('</dl>');
949                                          doc.Write('<a name="new"></a>' + #13#10);                                          html.Append('<a name="new"></a>');
950                                          doc.Write('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>新着レス ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>' + #13#10);                                          html.Append('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>新着レス ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
951                                          doc.Write('<dl>' + #13#10);                                          html.Append('<dl>');
952                                  end;                                  end;
953    
954                                  if (Trim(ReadList[i]) <> '') then begin                                  if (Trim(ReadList[i]) <> '') then begin
# Line 1102  begin Line 957  begin
957                                          Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');                                          Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
958                                          Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);                                          Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
959                                          if Res.FMailTo = '' then                                          if Res.FMailTo = '' then
960                                                  doc.Write('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> 名前:<font color="forestgreen"><b> ' + Res.FName + ' </b></font> 投稿日: <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>' + #13#10)                                                  html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> 名前:<font color="forestgreen"><b> ' + Res.FName + ' </b></font> 投稿日: <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>')
961                                          else if GikoSys.Setting.ShowMail then                                          else if GikoSys.Setting.ShowMail then
962                                                  doc.Write('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> 名前:<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] 投稿日: <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>' + #13#10)                                                  html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> 名前:<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] 投稿日: <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>')
963                                          else                                          else
964                                                  doc.Write('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> 名前:<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> 投稿日: <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>' + #13#10);                                                  html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> 名前:<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> 投稿日: <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>');
965                                  end;                                  end;
966                                  if ThreadItem.Kokomade = (i + 1) then begin                                  if ThreadItem.Kokomade = (i + 1) then begin
967                                          doc.Write('</dl>' + #13#10);                                          html.Append('</dl>');
968                                          doc.Write('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>ココまで読んだ</b></font></td></tr></table>' + #13#10);                                          html.Append('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>ココまで読んだ</b></font></td></tr></table>');
969                                          doc.Write('<dl>' + #13#10);                                          html.Append('<dl>');
970                                  end;                                  end;
971                          end;                          end;
972                          doc.Write('</dl>' + #13#10);                          html.Append('</dl>');
973                          doc.Write('<a name="bottom"></a>' + #13#10);                          html.Append('<a name="bottom"></a>');
974                          doc.Write('</body></html>' + #13#10);                          html.Append('</body></html>');
975                  finally                  finally
976                          doc.Close;                          //doc.Close;
977                            html.EndUpdate;
978                  end;                  end;
979          end;          end;
980  end;  end;
981    
982  procedure THTMLCreate.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);  procedure THTMLCreate.CreateHTML2(doc: IDispatch; ThreadItem: TThreadItem; var sTitle: string);
983  var  var
984          ReadList: TStringList;          ReadList: TStringList;
985          CSSFileName: string;          CSSFileName: string;
986          FileName: string;          FileName: string;
987          Res: TResRec;          Res: TResRec;
988            html: TStringList;
989            mStream : TMemoryStream;
990  {$IFDEF DEBUG}  {$IFDEF DEBUG}
991          st, rt: Cardinal;          st, rt: Cardinal;
992  {$ENDIF}  {$ENDIF}
# Line 1138  begin Line 996  begin
996          st := GetTickCount;          st := GetTickCount;
997  {$ENDIF}  {$ENDIF}
998          if ThreadItem <> nil then begin          if ThreadItem <> nil then begin
999                  if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin                  html := TStringList.Create;
1000                          CreateUsePluginHTML(doc, ThreadItem, sTitle);                  try
1001                  end else begin                          if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
1002                          ShortDayNames[1] := '日';               ShortDayNames[2] := '月';                                  CreateUsePluginHTML(html, ThreadItem, sTitle);
1003                          ShortDayNames[3] := '火';               ShortDayNames[4] := '水';                          end else begin
1004                          ShortDayNames[5] := '木';               ShortDayNames[6] := '金';                                  ShortDayNames[1] := '日';               ShortDayNames[2] := '月';
1005                          ShortDayNames[7] := '土';                                  ShortDayNames[3] := '火';               ShortDayNames[4] := '水';
1006                                    ShortDayNames[5] := '木';               ShortDayNames[6] := '金';
1007                                    ShortDayNames[7] := '土';
1008    
1009                          ReadList := TStringList.Create;                                  ReadList := TStringList.Create;
1010                          try                                  try
1011                                  if ThreadItem.IsLogFile then begin                                          ReadList.BeginUpdate;
1012                                          FileName := ThreadItem.GetThreadFileName;                                          if ThreadItem.IsLogFile then begin
1013                                          ReadList.LoadFromFile(FileName);                                                  FileName := ThreadItem.GetThreadFileName;
1014                                          GikoSys.FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));                                                  ReadList.LoadFromFile(FileName);
1015                                          GikoSys.FAbon.Execute(ReadList);                //       あぼ〜んして                                                  GikoSys.FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1016                                          GikoSys.FSelectResFilter.Execute(ReadList); //レスのフィルタリングをする                                                  GikoSys.FAbon.Execute(ReadList);                //       あぼ〜んして
1017                                          if ThreadItem.Title = '' then begin                                                  GikoSys.FSelectResFilter.Execute(ReadList); //レスのフィルタリングをする
1018                                                  Res := DivideStrLine(ReadList[0]);                                                  if ThreadItem.Title = '' then begin
1019                                                  sTitle := Res.FTitle;                                                          Res := DivideStrLine(ReadList[0]);
1020                                          end else                                                          sTitle := Res.FTitle;
1021                                                  sTitle := ThreadItem.Title                                                  end else
1022                                  end else begin                                                          sTitle := ThreadItem.Title
1023                                          sTitle := CustomStringReplace(ThreadItem.Title, '@`', ',');                                          end else begin
1024                                  end;                                                  sTitle := CustomStringReplace(ThreadItem.Title, '@`', ',');
1025                                            end;
1026    
1027                                  // フォントやサイズの設定                                          // フォントやサイズの設定
1028                                  CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;                                          CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;
1029                                  if GikoSys.Setting.UseSkin then begin                                          if GikoSys.Setting.UseSkin then begin
1030                                          CreateUseSKINHTML(doc, ThreadItem, ReadList);                                                  CreateUseSKINHTML(html, ThreadItem, ReadList);
1031                                  end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin                                          end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1032                                          CreateUseCSSHTML(doc, ThreadItem, ReadList, sTitle);                                                  CreateUseCSSHTML(html, ThreadItem, ReadList, sTitle);
1033                                  end else begin                                          end else begin
1034                                          CreateDefaultHTML(doc, ThreadItem, ReadList, sTitle);                                                  CreateDefaultHTML(html, ThreadItem, ReadList, sTitle);
1035                                            end;
1036                                    finally
1037                        ReadList.EndUpdate;
1038                                            ReadList.Free;
1039                                  end;                                  end;
1040                            end;
1041                            //WebBrowserに書き込み
1042                            mStream := TMemoryStream.Create;
1043                            try
1044                                    html.SaveToStream(mStream);
1045                                    mStream.Seek(soFromBeginning, 0);
1046                                    (doc as IPersistStreamInit).Load(TStreamAdapter.Create(mStream));
1047                          finally                          finally
1048                                  ReadList.Free;                                  mStream.Free;
1049                          end;                          end;
1050                    finally
1051                            html.Free;
1052                  end;                  end;
1053          end;          end;
1054  {$IFDEF DEBUG}  {$IFDEF DEBUG}

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.4.2.10

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