Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/HTMLCreate.pas

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


Revision 1.4.2.10 - (show annotations) (download) (as text)
Thu Nov 3 08:12:15 2005 UTC (18 years, 5 months ago) by h677
Branch: Bdraw
CVS Tags: v1_51_0_611
Changes since 1.4.2.9: +3 -1 lines
File MIME type: text/x-pascal
アンカーで終わっているときに例外がでるのを修正

1 unit HTMLCreate;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, {Graphics,} Controls, {Forms,}
7 ComCtrls, IniFiles, ShellAPI, Math, GikoSystem, ActiveX,
8 {$IF Defined(DELPRO) }
9 SHDocVw,
10 MSHTML,
11 {$ELSE}
12 SHDocVw_TLB,
13 MSHTML_TLB,
14 {$IFEND}
15 {HttpApp,} YofUtils, {URLMon,} BoardGroup, {gzip,} {Dolib,}
16 {bmRegExp,} AbonUnit, MojuUtils, Setting,
17 ExternalBoardManager, ExternalBoardPlugInMain{,}
18 {Sort,} ,GikoBayesian;
19
20 type
21 THTMLCreate = class(TObject)
22 private
23 { Private ?辿?転 }
24 anchorLen : Integer;
25 pURLCHARs,pURLCHARe : PChar;
26 pANCHORs, pANCHORe : PChar;
27 pCTAGLs, pCTAGLe : PChar;
28 pCTAGUs, pCTAGUe : PChar;
29 pREF_MARKSs : array[0..9] of PChar;
30 pREF_MARKSe : array[0..9] of PChar;
31 constructor Create;
32
33 function AddBeProfileLink(AID : string; ANum: Integer):string ;
34 procedure CreateUsePluginHTML(html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
35 procedure CreateUseSKINHTML(html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList);
36 procedure CreateUseCSSHTML(html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
37 procedure CreateDefaultHTML (html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
38 function ConvertResAnchor(res: string): string;
39 procedure separateNumber(var st: String; var et: String; const Text, Separator: String);
40 public
41 { Public ?辿?転 }
42 function AddAnchorTag(s: string): string;
43 function LoadFromSkin(fileName: string; ThreadItem: TThreadItem; SizeByte: Integer): string;
44 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;
46 procedure CreateHTML2(doc: IDispatch; ThreadItem: TThreadItem; var sTitle: string);
47 procedure CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
48 end;
49
50 var
51 HTMLCreater: THTMLCreate;
52
53 implementation
54
55 const
56 URL_CHAR: string = '0123456789'
57 + 'abcdefghijklmnopqrstuvwxyz'
58 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
59 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
60 ANCHOR_REF = 'href=';
61 CLOSE_TAGAL = '</a>';
62 CLOSE_TAGAU = '</A>';
63 RES_REF = '&gt;&gt;';
64 REF_MARK: array[0..9] of string = ('http://', 'ttp://', 'tp://',
65 'ms-help://','p://', 'https://',
66 'www.', 'ftp://','news://','rtsp://');
67
68 constructor THTMLCreate.Create;
69 var
70 j : Integer;
71 begin
72 // + 3 ?? 'href="' ('"'???鼎)???????o???G?[?V???????]?T???????邸?辿????
73 anchorLen := Length( ANCHOR_REF ) + 3;
74 pANCHORs := PChar(ANCHOR_REF);
75 pANCHORe := pANCHORs + Length(ANCHOR_REF);
76 pURLCHARs := PChar(URL_CHAR);
77 pURLCHARe := pURLCHARs + Length(URL_CHAR);
78 pCTAGLs := PChar(CLOSE_TAGAL);
79 pCTAGLe := pCTAGLs + 4;
80 pCTAGUs := PChar(CLOSE_TAGAU);
81 pCTAGUe := pCTAGUs + 4;
82 for j := 0 to 9 do begin
83 pREF_MARKSs[j] := PChar(REF_MARK[j]);
84 pREF_MARKSe[j] := pREF_MARKSs[j] + Length(REF_MARK[j]);
85 end;
86 end;
87 // ?X?L?????????????A?l???u?????辿
88 function THTMLCreate.LoadFromSkin(
89 fileName: string;
90 ThreadItem: TThreadItem;
91 SizeByte: Integer
92 ): string;
93 var
94 Skin: TStringList;
95 begin
96
97 Skin := TStringList.Create;
98 try
99 if FileExists( fileName ) then begin
100 Skin.LoadFromFile( fileName );
101
102 // ?但???????????直???纏???A?I?v?V?????_?C?A???O???v???r???[?p try
103 try
104 if ThreadItem.ParentBoard <> nil then
105 if ThreadItem.ParentBoard.ParentCategory <> nil then
106 CustomStringReplace( Skin, '<BBSNAME/>', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
107 CustomStringReplace( Skin, '<THREADURL/>', ThreadItem.URL);
108 except end;
109 CustomStringReplace( Skin, '<BOARDNAME/>', ThreadItem.ParentBoard.Title);
110 CustomStringReplace( Skin, '<BOARDURL/>', ThreadItem.ParentBoard.URL);
111 CustomStringReplace( Skin, '<THREADNAME/>', ThreadItem.Title);
112 CustomStringReplace( Skin, '<SKINPATH/>', GikoSys.Setting.CSSFileName);
113 CustomStringReplace( Skin, '<GETRESCOUNT/>', IntToStr( ThreadItem.Count - ThreadItem.NewResCount ));
114 CustomStringReplace( Skin, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ));
115 CustomStringReplace( Skin, '<ALLRESCOUNT/>', IntToStr( ThreadItem.Count ));
116
117 CustomStringReplace( Skin, '<NEWDATE/>',FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
118 CustomStringReplace( Skin, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ));
119 CustomStringReplace( Skin, '<SIZE/>', IntToStr( SizeByte ));
120
121
122 //----- ?????????存???甜???`?直?叩?????p?B?R?????g?A?E?g?直???????直
123 if GikoSys.Setting.UseKatjushaType then begin
124 // ?但???????????直???纏???A?I?v?V?????_?C?A???O???v???r???[?p try
125 try
126 if ThreadItem.ParentBoard <> nil then
127 if ThreadItem.ParentBoard.ParentCategory <> nil then
128 CustomStringReplace( Skin, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
129 CustomStringReplace( Skin, '&THREADURL', ThreadItem.URL);
130 except end;
131 CustomStringReplace( Skin, '&BOARDNAME', ThreadItem.ParentBoard.Title);
132 CustomStringReplace( Skin, '&BOARDURL', ThreadItem.ParentBoard.URL);
133 CustomStringReplace( Skin, '&THREADNAME', ThreadItem.Title);
134 CustomStringReplace( Skin, '&SKINPATH', GikoSys.Setting.CSSFileName);
135 CustomStringReplace( Skin, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ));
136 CustomStringReplace( Skin, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ));
137 CustomStringReplace( Skin, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ));
138
139 CustomStringReplace( Skin, '&NEWDATE', FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
140 CustomStringReplace( Skin, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ));
141 CustomStringReplace( Skin, '&SIZE', IntToStr( SizeByte ));
142 //----- ???????長
143 end;
144 end;
145 Result := Skin.Text;
146 finally
147 Skin.Free;
148 end;
149 end;
150
151 // ???X???l???u?????辿
152 function THTMLCreate.SkinedRes(
153 skin: string;
154 Res: TResRec;
155 No: string
156 ): string;
157 var
158 spamminess : Extended;
159 wordCount : TWordCount;
160 begin
161
162 wordCount := TWordCount.Create;
163 try
164 spamminess := Floor( GikoSys.SpamParse(
165 Res.FName + '<>' + Res.FMailTo + '<>' + Res.FBody, wordCount ) * 100 );
166
167 Skin := CustomStringReplace( Skin, '<NUMBER/>',
168 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
169 Skin := CustomStringReplace( Skin, '<PLAINNUMBER/>', No);
170 Skin := CustomStringReplace( Skin, '<NAME/>', '<b>' + Res.FName + '</b>');
171 Skin := CustomStringReplace( Skin, '<MAILNAME/>',
172 '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
173 Skin := CustomStringReplace( Skin, '<MAIL/>', Res.FMailTo);
174 Skin := CustomStringReplace( Skin, '<DATE/>', Res.FDateTime);
175 Skin := CustomStringReplace( Skin, '<MESSAGE/>', Res.FBody);
176 Skin := CustomStringReplace( Skin, '<SPAMMINESS/>', FloatToStr( spamminess ) );
177 Skin := CustomStringReplace( Skin, '<NONSPAMMINESS/>', FloatToStr( 100 - spamminess ) );
178
179 //----- ???甜???`?直?叩?????p?B?R?????g?A?E?g?直???????直
180 if GikoSys.Setting.UseKatjushaType then begin
181 Skin := CustomStringReplace( Skin, '&NUMBER',
182 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
183 Skin := CustomStringReplace( Skin, '&PLAINNUMBER', No);
184 Skin := CustomStringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>');
185 Skin := CustomStringReplace( Skin, '&MAILNAME',
186 '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
187 Skin := CustomStringReplace( Skin, '&MAIL', Res.FMailTo);
188 Skin := CustomStringReplace( Skin, '&DATE', Res.FDateTime);
189 Skin := CustomStringReplace( Skin, '&MESSAGE', Res.FBody);
190 Skin := CustomStringReplace( Skin, '&SPAMMINESS', FloatToStr( spamminess ) );
191 Skin := CustomStringReplace( Skin, '&NONSPAMMINESS', FloatToStr( 100 - spamminess ) );
192 end;
193 //----- ???????長
194
195 Result := Skin;
196 finally
197 wordCount.Free;
198 end;
199
200 end;
201 (*************************************************************************
202 *http://??????????anchor?^?O?t?鼎?????辿?B
203 *************************************************************************)
204 function THTMLCreate.AddAnchorTag(s: string): string;
205 var
206 url: string;
207 href: string;
208 i, j, b: Integer;
209 tmp: Integer;
210 idx, idx2: Integer;
211 pos : PChar;
212 pp, pe : PChar;
213 begin
214 Result := '';
215
216 while True do begin
217 idx := MaxInt;
218 idx2 := MaxInt;
219 pp := PChar(s);
220 pe := pp + Length(s);
221
222 for j := 0 to 9 do begin
223 pos := AnsiStrPosEx(pp, pe, pREF_MARKSs[j], pREF_MARKSe[j]);
224 if pos <> nil then begin
225 tmp := pos - pp + 1;
226 idx := Min(tmp, idx);
227 if idx = tmp then idx2 := j; //?????}?[?N?長?????????????????徹??
228 end;
229 end;
230
231 if idx = MaxInt then begin
232 //?????N?????????B
233 Result := Result + s;
234 Break;
235 end;
236
237 if (idx > 1) and (idx > anchorLen) and
238 (AnsiStrPosEx(pp + idx - 1 - anchorLen, pp + idx, pANCHORs, pANCHORe) <> nil) then begin
239 //?哲???????N?^?O???????????辿???徹?????鼎?????V
240 //</a></A>???T???A?店?????長???????巽???纏?????頂?????長????
241 pos := AnsiStrPosEx(pp + idx, pe, pCTAGLs, pCTAGLe);
242 if pos = nil then
243 pos := AnsiStrPosEx(pp + idx, pe, pCTAGUs, pCTAGUe);
244 if pos = nil then
245 b := Length(REF_MARK[idx2])
246 else
247 b := pos - pp + 1;
248
249 Result := Result + Copy(s, 1, idx + b);
250 Delete(s, 1, idx + b);
251 Continue;
252 end;
253
254 Result := Result + Copy(s, 1, idx - 1);
255 Delete(s, 1, idx - 1);
256 b := Length( s ) + 1;
257 pp := PChar(s);
258 for i := 1 to b do begin
259 pe := AnsiStrPosEx(pURLCHARs, pURLCHARe, pp, pp + 1);
260
261 if pe = nil then begin
262 //URL???叩?????????足???I?????A?????????足???????B
263 url := Copy(s, 1, i - 1);
264 case idx2 of
265 1 : href := 'h' + url;
266 2 : href := 'ht' + url;
267 4 : href := 'htt' + url;
268 6 : href := 'http://' + url;
269 else
270 href := url;
271 end;
272
273 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
274 Delete(s, 1, i - 1);
275 Break;
276 end;
277 //???????i???辿?B
278 Inc(pp);
279 end;
280 end;
281 end;
282
283 //?????AAID?F???徹?????辿?炭?tID???????AANum:???X?? AURL?F?泥???X???b?h??URL
284 function THTMLCreate.AddBeProfileLink(AID : string; ANum: Integer):string ;
285 var
286 p : integer;
287 BNum, BMark : string;
288 begin
289 p := AnsiPos('BE:', AnsiUpperCase(AID));
290 if p > 0 then begin
291 BNum := Copy(AID, p, Length(AID));
292 AID := Copy(AID, 1, p - 1);
293 p := AnsiPos('-', BNum);
294 if p > 0 then begin
295 BMark := '?' + Trim(Copy(BNum, p + 1, Length(BNum)));
296 BNum := Copy(BNum, 1, p - 1);
297 end;
298 BNum := Trim(BNum);
299 Result := AID + ' <a href="' + BNum + '/' + IntToStr(ANum)
300 + '" target=_blank>' + BMark + '</a>';
301 end else
302 Result := AID;
303 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
321 *************************************************************************)
322 function THTMLCreate.ConvRes(const Body, Bbs, Key,
323 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string;
324 DatToHTML: boolean = false): string;
325 const
326 GT = '&gt;';
327 SN = '0123456789';
328 FORMAT_LINK = '<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">';
329 var
330 i : integer;
331 s : string;
332 sw: boolean;
333 cm: boolean;
334 No: string;
335 oc : string;
336 st, et: string;
337 pos, pmin : integer;
338 j : integer;
339 token : array[0..5] of string;
340 ch : string;
341 db : boolean;
342 len : integer;
343 rink : string;
344 begin
345 //s ???{?????S???端???辿
346 s := Body;
347 //???????N???A
348 Result := '';
349 //???????徹?????????S
350 token[0] := GT + GT;
351 token[1] := GT;
352 token[2] := '????';
353 token[3] := '??';
354 token[4] := '<a ';
355 token[5] := '<A ';
356
357 //
358 while Length(s) > 2 do begin
359 pmin := Length(s) + 1;
360 i := Length(token);
361 for j := 0 to 5 do begin
362 pos := AnsiPos(token[j], s);
363 if pos <> 0 then begin
364 if pos < pmin then begin
365 //?????長?q?b?g?直?????徹??
366 i := j;
367 //?長?店?l???X?V
368 pmin := pos;
369 end;
370 end;
371 end;
372
373 //?q?b?g?直?????????????????O???長???????R?s?[
374 Result := Result + Copy(s, 1, pmin - 1);
375 Delete(s, 1, pmin - 1);
376
377 if i = 6 then begin
378 //?q?b?g???直
379 end else if (i = 4) or (i = 5) then begin
380 //'<a ' or '<A' ?長?q?b?g '</a>' or '</A>' ???長?R?s?[
381 pmin := AnsiPos('</a>' , s);
382 pos := AnsiPos('</A>' , s);
383 if (pmin <> 0) and (pos <> 0) then begin
384 if (pmin > pos) then begin
385 pmin := pos;
386 end;
387 end else if (pos <> 0) then begin
388 pmin := pos;
389 end;
390 rink := Copy(s, 1, pmin + 3);
391 Result := Result + rink;
392 Delete(s, 1, pmin + 3);
393
394 pmin := Length(rink);
395 i := Length(token);
396 for j := 0 to 3 do begin
397 pos := AnsiPos(token[j], rink);
398 if pos <> 0 then begin
399 if pos < pmin then begin
400 //?????長?q?b?g?直?????徹??
401 i := j;
402 //?長?店?l???X?V
403 pmin := pos;
404 end;
405 end;
406 end;
407 // ???X?A???J?[???????????????巽,?????足?????A???J?[???直???直?造
408 if i <= 3 then begin
409 cm := false;
410 j := 1 ;
411 len := Length(s);
412 if ((len > 0) and (s[j] = ',')) or
413 ((len > 1) and (ZenToHan(Copy(s, j ,2)) = ',')) then begin
414 cm := true;
415 db := false;
416 sw := false;
417 if (ByteType(s, j) = mbSingleByte) then
418 Inc(j)
419 else
420 Inc(j, 2);
421 No := '';
422 len := Length(s);
423 while cm do begin
424 while (j <= len) do begin
425 if (ByteType(s, j) = mbSingleByte) then begin
426 //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 //?I?[???長?s???????I?邸???`?F?b?N
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;
479 end;
480 end;
481 end;
482 end else begin
483 //?????直?巽???????????p?^?[??
484 j := Length(token[i]) + 1;
485 oc := '';
486 No := '';
487 sw := false;
488 db := false;
489 len := Length(s);
490 while j <= len do begin
491 if (ByteType(s, j) = mbSingleByte) then begin
492 //1byte????
493 ch := s[j];
494 Inc(j);
495 db := false;
496 end else begin
497 //2byte????
498 ch := ZenToHan(Copy(s, j, 2));
499 Inc(j, 2);
500 db := true;
501 end;
502
503 if System.Pos(ch, SN) > 0 then begin
504 No := No + ch;
505 end else if (ch = '-') then begin
506 if sw then break;
507 if No = '' then break;
508 No := No + ch;
509 sw := true;
510 end else begin
511 break;
512 end;
513 end;
514 //?I?[???長?s???????I?邸???`?F?b?N
515 if j <= len then begin
516 if db then j := j - 2
517 else j := j - 1;
518 end;
519 //?????????????????巽???????鼎
520 if No = '' then begin
521 Result := Result + Copy(s, 1, j - 1);
522 end else begin
523 separateNumber(st, et, No, '-');
524
525 if not DatToHTML then begin
526 Result := Result + Format(FORMAT_LINK,
527 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]);
528 end else begin
529 Result := Result + Format('<a href="#%s">', [st]);
530 end;
531 Result := Result + Copy(s, 1, j - 1) + '</a>';
532 end;
533 Delete(s, 1, j - 1);
534 end;
535 end;
536 Result := Result + s;
537 end;
538
539 function THTMLCreate.ConvertResAnchor(res: string): string;
540 const
541 _HEAD : string = '<a href="../';
542 _TAIL : string = ' target="_blank">';
543 _ST: string = '&st=';
544 _TO: string = '&to=';
545 _STA: string = '&START=';
546 _END: string = '&END=';
547 var
548 i, j, k: Integer;
549 tmp: string;
550 begin
551 Result := '';
552 i := AnsiPos(_HEAD, res);
553 while i <> 0 do begin
554 Result := Result + Copy(res, 1, i -1);
555 Delete(res, 1, i - 1);
556 j := AnsiPos(_TAIL, res);
557 if j = 0 then begin
558 Result := Result + res;
559 Exit;
560 end;
561 tmp := Copy(res, 1, j - 1);
562 Delete(res, 1, j + 16);
563 if (AnsiPos(_ST, tmp) <> 0) and (AnsiPos(_TO, tmp) <> 0) then begin
564 Delete(tmp, 1, AnsiPos(_ST, tmp) + 3);
565 Delete(tmp, AnsiPos(_TO, tmp), Length(tmp));
566 Result := Result + '<a href="#' + tmp + '">';
567 end else if (AnsiPos(_STA, tmp) <> 0) and (AnsiPos(_END, tmp) <> 0) then begin
568 Delete(tmp, 1, AnsiPos(_STA, tmp) + 6);
569 Delete(tmp, AnsiPos(_END, tmp), Length(tmp));
570 Result := Result + '<a href="#' + tmp + '">';
571 end else begin
572 k := LastDelimiter('/', tmp);
573 Delete(tmp, 1, k);
574 if AnsiPos('-', tmp) < AnsiPos('"', tmp) then
575 Delete(tmp, AnsiPos('-', tmp), Length(tmp))
576 else
577 Delete(tmp, AnsiPos('"', tmp), Length(tmp));
578
579 Result := Result + '<a href="#' + tmp + '">';
580 end;
581 i := AnsiPos(_HEAD, res);
582 end;
583 Result := Result + res;
584
585 end;
586
587 //Plugin?????p???辿Board???X???b?h??HTML?????店?直??doc?????鼎???鄭
588 procedure THTMLCreate.CreateUsePluginHTML(html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
589 var
590 i: integer;
591 NewReceiveNo: Integer;
592 boardPlugIn : TBoardPlugIn;
593 UserOptionalStyle: string;
594 begin
595 if ThreadItem <> nil then begin
596 if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
597 //===== ?v???O?C???????辿?\??
598 boardPlugIn := ThreadItem.ParentBoard.BoardPlugIn;
599 NewReceiveNo := ThreadItem.NewReceive;
600 // ?t?H???g?但?T?C?Y??????
601 UserOptionalStyle := GikoSys.SetUserOptionalStyle;
602 html.BeginUpdate;
603 try
604 // ?w?b?_
605 html.Append( boardPlugIn.GetHeader( DWORD( threadItem ),
606 '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ));
607 html.Add('<p id="idSearch"></p>');
608 for i := 0 to threadItem.Count - 1 do begin
609 // 1 ???K?存?\??
610 if i <> 0 then begin
611 // ?\????????????
612 case GikoSys.ResRange of
613 Ord( grrKoko ):
614 if ThreadItem.Kokomade > (i + 1) then
615 Continue;
616 Ord( grrNew ):
617 if NewReceiveNo > (i + 1) then
618 Continue;
619 10..65535:
620 if (threadItem.Count - i) > GikoSys.ResRange then
621 Continue;
622 end;
623 end;
624
625 // ?V???}?[?N
626 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
627 try
628 if GikoSys.Setting.UseSkin then begin
629 if FileExists( GikoSys.GetSkinNewmarkFileName ) then
630 html.Append( LoadFromSkin( GikoSys.GetSkinNewmarkFileName, ThreadItem, ThreadItem.Size ))
631 else
632 //doc.Write( '<a name="new"></a>' + #13#10 );
633 html.Append( '<a name="new"></a>' );
634 end else if GikoSys.Setting.UseCSS then begin
635 html.Append('<a name="new"></a><div class="new">?V?????X <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
636 end else begin
637 html.Append('</dl>');
638 html.Append('<a name="new"></a>');
639 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>?V?????X ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
640 html.Append('<dl>');
641 end;
642 except
643 html.Append( '<a name="new"></a>');
644 end;
645 end;
646
647 // ???X
648 html.Append( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) );
649
650 if ThreadItem.Kokomade = (i + 1) then begin
651 // ???????長?????転
652 try
653 if GikoSys.Setting.UseSkin then begin
654 if FileExists( GikoSys.GetSkinBookmarkFileName ) then
655 html.Append( LoadFromSkin( GikoSys.GetSkinBookmarkFileName, ThreadItem, ThreadItem.Size ) )
656 else
657 html.Append( '<a name="koko"></a>' );
658 end else if GikoSys.Setting.UseCSS then begin
659 html.Append('<a name="koko"></a><div class="koko">?R?R???長?????転</div>' );
660 end else begin
661 html.Append('</dl>');
662 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>?R?R???長?????転</b></font></td></tr></table>');
663 html.Append('<dl>' );
664 end;
665 except
666 html.Append( '<a name="koko"></a>' );
667 end;
668 end;
669 end;
670
671
672 // ?X?L??(?t?b?^)
673 html.Append( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
674 finally
675 html.EndUpdate;
676 end;
677
678 end;
679 end;
680 end;
681
682
683 procedure THTMLCreate.CreateUseSKINHTML(html : TStringList; ThreadItem: TThreadItem; ReadList: TStringList);
684 var
685 i: integer;
686 No: string;
687 CSSFileName: string;
688 NewReceiveNo: Integer;
689 Res: TResRec;
690 UserOptionalStyle: string;
691 SkinHeader: string;
692 SkinNewRes: string;
693 SkinRes: string;
694 strTmp : string;
695 threadKey : string;
696 begin
697 if ThreadItem <> nil then begin
698 // ?X?L???g?p
699 if GikoSys.Setting.UseSkin then begin
700 NewReceiveNo := ThreadItem.NewReceive;
701 // ?t?H???g?但?T?C?Y??????
702 UserOptionalStyle := GikoSys.SetUserOptionalStyle;
703 CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;
704
705 threadKey := ChangeFileExt(ThreadItem.FileName, '');
706 html.BeginUpdate;
707 try
708 //doc.charset := 'Shift_JIS';
709
710 // ?X?L????????
711 try
712 SkinHeader := LoadFromSkin( GikoSys.GetSkinHeaderFileName, ThreadItem, ThreadItem.Size);
713 if Length( UserOptionalStyle ) > 0 then
714 SkinHeader := CustomStringReplace( SkinHeader, '</head>',
715 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>');
716 html.Append( SkinHeader);
717 except
718 end;
719
720 try
721 SkinNewRes := LoadFromSkin( GikoSys.GetSkinNewResFileName, ThreadItem, ThreadItem.Size);
722 except
723 end;
724
725 try
726 SkinRes := LoadFromSkin( GikoSys.GetSkinResFileName, ThreadItem, ThreadItem.Size );
727 except
728 end;
729
730 html.Append('<p id="idSearch"></p>');
731 html.Append('<a name="top"></a>');
732
733 for i := 0 to ReadList.Count - 1 do begin
734 // 1 ???K?存?\??
735 if i <> 0 then begin
736 // ?\????????????
737 case GikoSys.ResRange of
738 Ord( grrKoko ):
739 if ThreadItem.Kokomade > (i + 1) then
740 Continue;
741 Ord( grrNew ):
742 if NewReceiveNo > (i + 1) then
743 Continue;
744 10..65535:
745 if (threadItem.Count - i) > GikoSys.ResRange then
746 Continue;
747 end;
748 end;
749 // ?V???}?[?N
750 if (NewReceiveNo = i + 1) or ((NewReceiveNo = 0) and (i = 0)) then begin
751 try
752 if FileExists( GikoSys.GetSkinNewmarkFileName ) then
753 html.Append( LoadFromSkin( GikoSys.GetSkinNewmarkFileName, ThreadItem, ThreadItem.Size ) )
754 else
755 html.Append( '<a name="new"></a>' );
756 except
757 html.Append( '<a name="new"></a>' );
758 end;
759 end;
760
761 if (Trim(ReadList[i]) <> '') then begin
762 No := IntToStr(i + 1);
763
764 Res := DivideStrLine(ReadList[i]);
765 Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, threadKey, 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
766 Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
767
768 try
769 if NewReceiveNo <= (i + 1) then
770 // ?V?????X
771 strTmp := SkinedRes( SkinNewRes, Res, No )
772 else
773 // ???鱈?????X
774 strTmp := SkinedRes( SkinRes, Res, No );
775
776 html.Append( strTmp );
777 except
778 end;
779 end;
780
781 if ThreadItem.Kokomade = (i + 1) then begin
782 // ???????長?????転
783 try
784 if FileExists( GikoSys.GetSkinBookmarkFileName ) then
785 html.Append( LoadFromSkin( GikoSys.GetSkinBookmarkFileName, ThreadItem, ThreadItem.Size ) )
786 else
787 html.Append( '<a name="koko"></a>' );
788 except
789 html.Append( '<a name="koko"></a>' );
790 end;
791 end;
792 end;
793
794 html.Append('<a name="bottom"></a>' );
795 // ?X?L??(?t?b?^)
796 try
797 html.Append( LoadFromSkin( GikoSys.GetSkinFooterFileName, ThreadItem, ThreadItem.Size ) );
798 except
799 end;
800 finally
801 html.EndUpdate;
802 end;
803 end;
804 end;
805 end;
806
807 procedure THTMLCreate.CreateUseCSSHTML(html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
808 var
809 i: integer;
810 No: string;
811 CSSFileName: string;
812 NewReceiveNo: Integer;
813 Res: TResRec;
814 UserOptionalStyle: string;
815 begin
816 if ThreadItem <> nil then begin
817 //doc.open;
818 html.BeginUpdate;
819 try
820 //doc.charset := 'Shift_JIS';
821 NewReceiveNo := ThreadItem.NewReceive;
822 // ?t?H???g?但?T?C?Y??????
823 UserOptionalStyle := GikoSys.SetUserOptionalStyle;
824 CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;
825 if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
826 //CSS?g?p
827 html.Append('<html><head>');
828 html.Append('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
829 html.Append('<title>' + sTitle + '</title>');
830 html.Append('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
831 if Length( UserOptionalStyle ) > 0 then
832 html.Append('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
833 html.Append('</head>');
834 html.Append('<body>');
835 html.Append('<a name="top"></a>');
836 html.Append('<p id="idSearch"></p>');
837 html.Append('<div class="title">' + sTitle + '</div>');
838 for i := 0 to ReadList.Count - 1 do begin
839 // 1 ???K?存?\??
840 if i <> 0 then begin
841 // ?\????????????
842 case GikoSys.ResRange of
843 Ord( grrKoko ):
844 if ThreadItem.Kokomade > (i + 1) then
845 Continue;
846 Ord( grrNew ):
847 if NewReceiveNo > (i + 1) then
848 Continue;
849 10..65535:
850 if (threadItem.Count - i) > GikoSys.ResRange then
851 Continue;
852 end;
853 end;
854
855 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
856 html.Append('<a name="new"></a><div class="new">?V?????X <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
857 end;
858
859 if (Trim(ReadList[i]) <> '') then begin
860 No := IntToStr(i + 1);
861 Res := DivideStrLine(ReadList[i]);
862 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);
864 if Res.FMailTo = '' then
865 html.Append('<a name="' + No + '"></a>'
866 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
867 + '<span class="name_label">?添?O?F</span> '
868 + '<span class="name"><b>' + Res.FName + '</b></span> '
869 + '<span class="date_label">???e?炭?F</span> '
870 + '<span class="date">' + Res.FDateTime+ '</span></div>'
871 + '<div class="mes">' + Res.FBody + ' </div>')
872 else if GikoSys.Setting.ShowMail then
873 html.Append('<a name="' + No + '"></a>'
874 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
875 + '<span class="name_label"> ?添?O?F </span>'
876 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
877 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
878 + '<span class="date_label"> ???e?炭?F</span>'
879 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
880 + '<div class="mes">' + Res.FBody + ' </div>')
881 else
882 html.Append('<a name="' + No + '"></a>'
883 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
884 + '<span class="name_label"> ?添?O?F </span>'
885 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
886 + '<b>' + Res.FName + '</b></a>'
887 + '<span class="date_label"> ???e?炭?F</span>'
888 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
889 + '<div class="mes">' + Res.FBody + ' </div>');
890 end;
891
892 if ThreadItem.Kokomade = (i + 1) then begin
893 html.Append('<a name="koko"></a><div class="koko">?R?R???長?????転</div>');
894 end;
895
896 end;
897
898 html.Append('<a name="bottom"></a>');
899 html.Append('<a name="last"></a>');
900 html.Append('</body></html>');
901 end;
902 finally
903 html.EndUpdate;
904 //doc.Close;
905 end;
906 end;
907 end;
908
909 procedure THTMLCreate.CreateDefaultHTML (html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
910 var
911 i: integer;
912 No: string;
913 NewReceiveNo: Integer;
914 Res: TResRec;
915 begin
916 if ThreadItem <> nil then begin
917 //doc.open;
918 html.BeginUpdate;
919 try
920 //doc.charset := 'Shift_JIS';
921 NewReceiveNo := ThreadItem.NewReceive;
922 html.Append('<html><head>');
923 html.Append('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
924 html.Append('<title>' + sTitle + '</title></head>');
925 html.Append('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
926 html.Append('<a name="top"></a>');
927 html.Append('<font size=+1 color="#FF0000">' + sTitle + '</font>');
928 html.Append('<dl>');
929 html.Append('<p id="idSearch"></p>');
930 for i := 0 to ReadList.Count - 1 do begin
931 // 1 ???K?存?\??
932 if i <> 0 then begin
933 // ?\????????????
934 case GikoSys.ResRange of
935 Ord( grrKoko ):
936 if ThreadItem.Kokomade > (i + 1) then
937 Continue;
938 Ord( grrNew ):
939 if NewReceiveNo > (i + 1) then
940 Continue;
941 10..65535:
942 if (threadItem.Count - i) > GikoSys.ResRange then
943 Continue;
944 end;
945 end;
946
947 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
948 html.Append('</dl>');
949 html.Append('<a name="new"></a>');
950 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>?V?????X ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
951 html.Append('<dl>');
952 end;
953
954 if (Trim(ReadList[i]) <> '') then begin
955 No := IntToStr(i + 1);
956 Res := DivideStrLine(ReadList[i]);
957 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);
959 if Res.FMailTo = '' then
960 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ?添?O?F<font color="forestgreen"><b> ' + Res.FName + ' </b></font> ???e?炭?F <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>')
961 else if GikoSys.Setting.ShowMail then
962 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ?添?O?F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] ???e?炭?F <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>')
963 else
964 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ?添?O?F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> ???e?炭?F <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>');
965 end;
966 if ThreadItem.Kokomade = (i + 1) then begin
967 html.Append('</dl>');
968 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>?R?R???長?????転</b></font></td></tr></table>');
969 html.Append('<dl>');
970 end;
971 end;
972 html.Append('</dl>');
973 html.Append('<a name="bottom"></a>');
974 html.Append('</body></html>');
975 finally
976 //doc.Close;
977 html.EndUpdate;
978 end;
979 end;
980 end;
981
982 procedure THTMLCreate.CreateHTML2(doc: IDispatch; ThreadItem: TThreadItem; var sTitle: string);
983 var
984 ReadList: TStringList;
985 CSSFileName: string;
986 FileName: string;
987 Res: TResRec;
988 html: TStringList;
989 mStream : TMemoryStream;
990 {$IFDEF DEBUG}
991 st, rt: Cardinal;
992 {$ENDIF}
993 begin
994 {$IFDEF DEBUG}
995 Writeln('Create HTML');
996 st := GetTickCount;
997 {$ENDIF}
998 if ThreadItem <> nil then begin
999 html := TStringList.Create;
1000 try
1001 if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
1002 CreateUsePluginHTML(html, ThreadItem, sTitle);
1003 end else begin
1004 ShortDayNames[1] := '?炭'; ShortDayNames[2] := '??';
1005 ShortDayNames[3] := '??'; ShortDayNames[4] := '??';
1006 ShortDayNames[5] := '??'; ShortDayNames[6] := '??';
1007 ShortDayNames[7] := '?y';
1008
1009 ReadList := TStringList.Create;
1010 try
1011 ReadList.BeginUpdate;
1012 if ThreadItem.IsLogFile then begin
1013 FileName := ThreadItem.GetThreadFileName;
1014 ReadList.LoadFromFile(FileName);
1015 GikoSys.FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1016 GikoSys.FAbon.Execute(ReadList); // ?????`???直??
1017 GikoSys.FSelectResFilter.Execute(ReadList); //???X???t?B???^?????O?????辿
1018 if ThreadItem.Title = '' then begin
1019 Res := DivideStrLine(ReadList[0]);
1020 sTitle := Res.FTitle;
1021 end else
1022 sTitle := ThreadItem.Title
1023 end else begin
1024 sTitle := CustomStringReplace(ThreadItem.Title, '???M', ',');
1025 end;
1026
1027 // ?t?H???g?但?T?C?Y??????
1028 CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;
1029 if GikoSys.Setting.UseSkin then begin
1030 CreateUseSKINHTML(html, ThreadItem, ReadList);
1031 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1032 CreateUseCSSHTML(html, ThreadItem, ReadList, sTitle);
1033 end else begin
1034 CreateDefaultHTML(html, ThreadItem, ReadList, sTitle);
1035 end;
1036 finally
1037 ReadList.EndUpdate;
1038 ReadList.Free;
1039 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
1048 mStream.Free;
1049 end;
1050 finally
1051 html.Free;
1052 end;
1053 end;
1054 {$IFDEF DEBUG}
1055 rt := GetTickCount - st;
1056 Writeln('Done.');
1057 Writeln(IntToStr(rt) + ' ms');
1058 {$ENDIF}
1059 end;
1060
1061 procedure THTMLCreate.CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
1062 var
1063 i: integer;
1064 No: string;
1065 //bufList : TStringList;
1066 ReadList: TStringList;
1067 // SaveList: TStringList;
1068 CSSFileName: string;
1069 BBSID: string;
1070 FileName: string;
1071 Res: TResRec;
1072 boardPlugIn : TBoardPlugIn;
1073
1074 UserOptionalStyle: string;
1075 SkinHeader: string;
1076 SkinRes: string;
1077 tmp, tmp1: string;
1078 function LoadSkin( fileName: string ): string;
1079 begin
1080 Result := LoadFromSkin( fileName, ThreadItem, ThreadItem.Size );
1081 end;
1082 function ReplaceRes( skin: string ): string;
1083 begin
1084 Result := SkinedRes( skin, Res, No );
1085 end;
1086
1087 begin
1088 if ThreadItem <> nil then begin
1089 CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;
1090 html.Clear;
1091 html.BeginUpdate;
1092 //if ThreadItem.IsBoardPlugInAvailable then begin
1093 if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
1094 //===== ?v???O?C???????辿?\??
1095 //boardPlugIn := ThreadItem.BoardPlugIn;
1096 boardPlugIn := ThreadItem.ParentBoard.BoardPlugIn;
1097 // ?t?H???g?但?T?C?Y??????
1098 UserOptionalStyle := GikoSys.SetUserOptionalStyle;
1099 try
1100 // ?????R?[?h???v???O?C?????C?邸?辿
1101 // ?w?b?_
1102 tmp := boardPlugIn.GetHeader( DWORD( threadItem ),
1103 '<style type="text/css">body {' + UserOptionalStyle + '}</style>' );
1104 //?但???Q?????巽?????Q????
1105 if GikoSys.Setting.UseSkin then begin
1106 tmp1 := './' + GikoSys.Setting.CSSFileName;
1107 tmp1 := CustomStringReplace(tmp1, GikoSys.GetConfigDir, '');
1108 tmp1 := CustomStringReplace(tmp1, '\', '/');
1109 tmp := CustomStringReplace(tmp, ExtractFilePath(GikoSys.Setting.CSSFileName), tmp1);
1110 end else if GikoSys.Setting.UseCSS then begin
1111 tmp1 := './' + CSSFileName;
1112 tmp1 := CustomStringReplace(tmp1, GikoSys.GetConfigDir, '');
1113 tmp1 := CustomStringReplace(tmp1, '\', '/');
1114 tmp := CustomStringReplace(tmp, CSSFileName, tmp1);
1115 end;
1116 html.Append( tmp );
1117
1118 for i := 0 to threadItem.Count - 1 do begin
1119
1120 // ???X
1121 html.Append( ConvertResAnchor(boardPlugIn.GetRes( DWORD( threadItem ), i + 1 )) );
1122
1123 end;
1124 // ?X?L??(?t?b?^)
1125 html.Append( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
1126 finally
1127 end;
1128 html.EndUpdate;
1129 //Exit;
1130 end else begin
1131 ShortDayNames[1] := '?炭'; ShortDayNames[2] := '??';
1132 ShortDayNames[3] := '??'; ShortDayNames[4] := '??';
1133 ShortDayNames[5] := '??'; ShortDayNames[6] := '??';
1134 ShortDayNames[7] := '?y';
1135 BBSID := ThreadItem.ParentBoard.BBSID;
1136 ReadList := TStringList.Create;
1137 try
1138 if ThreadItem.IsLogFile then begin
1139 FileName := ThreadItem.GetThreadFileName;
1140 ReadList.LoadFromFile(FileName);
1141 GikoSys.FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1142 GikoSys.FAbon.Execute(ReadList); // ?????`???直??
1143 GikoSys.FSelectResFilter.Execute(ReadList); //???X???t?B???^?????O?????辿
1144 Res := DivideStrLine(ReadList[0]);
1145 //Res.FTitle := CustomStringReplace(Res.FTitle, '???M', ',');
1146 sTitle := Res.FTitle;
1147 end else begin
1148 sTitle := CustomStringReplace(ThreadItem.Title, '???M', ',');
1149 end;
1150 try
1151 // ?t?H???g?但?T?C?Y??????
1152 UserOptionalStyle := GikoSys.SetUserOptionalStyle;
1153
1154 if GikoSys.Setting.UseSkin then begin
1155 // ?X?L???g?p
1156 // ?X?L????????
1157 try
1158 SkinHeader := LoadSkin( GikoSys.GetSkinHeaderFileName );
1159 if Length( UserOptionalStyle ) > 0 then
1160 SkinHeader := CustomStringReplace( SkinHeader, '</head>',
1161 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>');
1162 //?但???Q?????巽?????Q????
1163 tmp1 := './' + GikoSys.Setting.CSSFileName;
1164 tmp1 := CustomStringReplace(tmp1, GikoSys.GetConfigDir, '');
1165 tmp1 := CustomStringReplace(tmp1, '\', '/');
1166 SkinHeader := CustomStringReplace(SkinHeader, ExtractFilePath(GikoSys.Setting.CSSFileName), tmp1);
1167 html.Append( SkinHeader );
1168 except
1169 end;
1170 try
1171 SkinRes := LoadSkin( GikoSys.GetSkinResFileName );
1172 except
1173 end;
1174 html.Append('<a name="top"></a>');
1175 for i := 0 to ReadList.Count - 1 do begin
1176 if (Trim(ReadList[i]) <> '') then begin
1177 No := IntToStr(i + 1);
1178
1179 Res := DivideStrLine(ReadList[i]);
1180 Res.FBody := AddAnchorTag(Res.FBody);
1181 Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true));
1182
1183 try
1184 html.Append( ReplaceRes( SkinRes ) );
1185 except
1186 end;
1187 end;
1188
1189 end;
1190 html.Append('<a name="bottom"></a>');
1191 // ?X?L??(?t?b?^)
1192 try
1193 html.Append( LoadSkin( GikoSys.GetSkinFooterFileName ) );
1194 except
1195 end;
1196 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1197 //CSS?g?p
1198 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1199 html.Append('<html><head>');
1200 html.Append('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1201 html.Append('<title>' + sTitle + '</title>');
1202 //?但???Q?????巽?????Q????
1203 tmp1 := './' + CSSFileName;
1204 tmp1 := CustomStringReplace(tmp1, GikoSys.GetConfigDir, '');
1205 tmp1 := CustomStringReplace(tmp1, '\', '/');
1206
1207 html.Append('<link rel="stylesheet" href="'+tmp1+'" type="text/css">');
1208 if Length( UserOptionalStyle ) > 0 then
1209 html.Append('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
1210 html.Append('</head>');
1211 html.Append('<body>');
1212 html.Append('<a name="top"></a>');
1213 html.Append('<div class="title">' + sTitle + '</div>');
1214 for i := 0 to ReadList.Count - 1 do begin
1215 if (Trim(ReadList[i]) <> '') then begin
1216 No := IntToStr(i + 1);
1217 Res := DivideStrLine(ReadList[i]);
1218 Res.FBody := AddAnchorTag(Res.FBody);
1219 Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true));
1220 if Res.FMailTo = '' then
1221 html.Append('<a name="' + No + '"></a>'
1222 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1223 + '<span class="name_label">?添?O?F</span> '
1224 + '<span class="name"><b>' + Res.FName + '</b></span> '
1225 + '<span class="date_label">???e?炭?F</span> '
1226 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1227 + '<div class="mes">' + Res.FBody + ' </div>')
1228 else if GikoSys.Setting.ShowMail then
1229 html.Append('<a name="' + No + '"></a>'
1230 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1231 + '<span class="name_label"> ?添?O?F </span>'
1232 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1233 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1234 + '<span class="date_label"> ???e?炭?F</span>'
1235 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1236 + '<div class="mes">' + Res.FBody + ' </div>')
1237 else
1238 html.Append('<a name="' + No + '"></a>'
1239 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1240 + '<span class="name_label"> ?添?O?F </span>'
1241 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1242 + '<b>' + Res.FName + '</b></a>'
1243 + '<span class="date_label"> ???e?炭?F</span>'
1244 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1245 + '<div class="mes">' + Res.FBody + ' </div>');
1246 end;
1247 end;
1248 html.Append('<a name="bottom"></a>');
1249 html.Append('<a name="last"></a>');
1250 html.Append('</body></html>');
1251 end else begin
1252 //CSS???g?p
1253 html.Append('<html><head>');
1254 html.Append('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1255 html.Append('<title>' + sTitle + '</title></head>');
1256 html.Append('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1257 html.Append('<a name="top"></a>');
1258 html.Append('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1259 html.Append('<dl>');
1260 for i := 0 to ReadList.Count - 1 do begin
1261 if (Trim(ReadList[i]) <> '') then begin
1262 No := IntToStr(i + 1);
1263 Res := DivideStrLine(ReadList[i]);
1264 Res.FBody := AddAnchorTag(Res.FBody);
1265 Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true));
1266 if Res.FMailTo = '' then
1267 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ?添?O?F<font color="forestgreen"><b> ' + Res.FName + ' </b></font> ???e?炭?F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1268 else if GikoSys.Setting.ShowMail then
1269 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ?添?O?F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] ???e?炭?F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1270 else
1271 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ?添?O?F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> ???e?炭?F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>');
1272 end;
1273 end;
1274 html.Append('</dl>');
1275 html.Append('<a name="bottom"></a>');
1276 html.Append('</body></html>');
1277 end;
1278 finally
1279 html.EndUpdate;
1280 end;
1281 finally
1282 ReadList.Free;
1283 end;
1284 end;
1285 end;
1286 end;
1287
1288 initialization
1289 HTMLCreater := THTMLCreate.Create;
1290
1291 finalization
1292 if HTMLCreater <> nil then begin
1293 HTMLCreater.Free;
1294 HTMLCreater := nil;
1295 end;
1296
1297 end.

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