| 36 |
procedure CreateUseCSSHTML(html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string ); |
procedure CreateUseCSSHTML(html: TStringList; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string ); |
| 37 |
procedure CreateDefaultHTML (html: TStringList; 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; |
| 302 |
end else |
end else |
| 303 |
Result := AID; |
Result := AID; |
| 304 |
end; |
end; |
| 305 |
|
procedure THTMLCreate.separateNumber(var st: String; var et: String; const Text, Separator: String); |
| 306 |
|
var |
| 307 |
|
p : Integer; |
| 308 |
|
begin |
| 309 |
|
p := Pos(Separator,Text); |
| 310 |
|
if (p > 0 ) then begin |
| 311 |
|
st := Copy(Text, 1, p - 1); |
| 312 |
|
et := Copy(Text, p + Length(Separator), Length(Text)); |
| 313 |
|
end else begin |
| 314 |
|
st := Text; |
| 315 |
|
et := Text; |
| 316 |
|
end; |
| 317 |
|
end; |
| 318 |
|
|
| 319 |
(************************************************************************* |
(************************************************************************* |
| 320 |
* |
* |
| 321 |
* from HotZonu |
* from HotZonu |
| 323 |
function THTMLCreate.ConvRes(const Body, Bbs, Key, |
function THTMLCreate.ConvRes(const Body, Bbs, Key, |
| 324 |
ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; |
ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; |
| 325 |
DatToHTML: boolean = false): string; |
DatToHTML: boolean = false): string; |
| 326 |
|
const |
| 327 |
|
GT = '>'; |
| 328 |
|
SN = '0123456789'; |
| 329 |
|
ZN = '0123456789'; |
| 330 |
|
FORMAT_LINK = '<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">'; |
| 331 |
|
var |
| 332 |
|
i : integer; |
| 333 |
|
s : string; |
| 334 |
|
sw: boolean; |
| 335 |
|
No: string; |
| 336 |
|
oc : string; |
| 337 |
|
st, et: string; |
| 338 |
|
pos, pmin : integer; |
| 339 |
|
j : integer; |
| 340 |
|
token : array[0..5] of string; |
| 341 |
|
ch : string; |
| 342 |
|
db : boolean; |
| 343 |
|
|
| 344 |
|
begin |
| 345 |
|
//s に本文を全部入れる |
| 346 |
|
s := Body; |
| 347 |
|
//結果をクリア |
| 348 |
|
Result := ''; |
| 349 |
|
//検索対象の文字列郡 |
| 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) > 0 do begin |
| 359 |
|
pmin := Length(s) + 1; |
| 360 |
|
i := length(token); |
| 361 |
|
for j := 0 to length(token) - 1 do begin |
| 362 |
|
pos := AnsiPos(token[j], s); |
| 363 |
|
if pos <> 0 then begin |
| 364 |
|
if pos < pmin then begin |
| 365 |
|
//どれでヒットしたか保存 |
| 366 |
|
i := j; |
| 367 |
|
//最小値を更新 |
| 368 |
|
pmin := pos; |
| 369 |
|
end; |
| 370 |
|
end; |
| 371 |
|
end; |
| 372 |
|
|
| 373 |
|
//ヒットした文字列の一つ手前まで結果にコピー |
| 374 |
|
Result := Result + Copy(s, 1, pmin - 1); |
| 375 |
|
Delete(s, 1, pmin - 1); |
| 376 |
|
|
| 377 |
|
if i = length(token) then begin |
| 378 |
|
//ヒットなし |
| 379 |
|
end else if (i = 4) or (i = 5) then begin |
| 380 |
|
//'<a ' or '<A' でヒット '</a>' or '</A>' までコピー |
| 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 |
|
Result := Result + Copy(s, 1, pmin + 3); |
| 391 |
|
Delete(s, 1, pmin + 3); |
| 392 |
|
end else begin |
| 393 |
|
//何かしら見つかったパターン |
| 394 |
|
j := Length(token[i]) + 1; |
| 395 |
|
oc := ''; |
| 396 |
|
No := ''; |
| 397 |
|
sw := false; |
| 398 |
|
db := false; |
| 399 |
|
while j <= Length(s) do begin |
| 400 |
|
if (ByteType(s, j) = mbSingleByte) then begin |
| 401 |
|
//1byte文字 |
| 402 |
|
ch := s[j]; |
| 403 |
|
Inc(j); |
| 404 |
|
db := false; |
| 405 |
|
end else begin |
| 406 |
|
//2byte文字 |
| 407 |
|
ch := ZenToHan(Copy(s, j, 2)); |
| 408 |
|
Inc(j, 2); |
| 409 |
|
db := true; |
| 410 |
|
end; |
| 411 |
|
|
| 412 |
|
if AnsiPos(ch, SN) > 0 then begin |
| 413 |
|
No := No + ch; |
| 414 |
|
end else if (ch = '-') then begin |
| 415 |
|
if sw then break; |
| 416 |
|
if No = '' then break; |
| 417 |
|
sw := true; |
| 418 |
|
end else begin |
| 419 |
|
break; |
| 420 |
|
end; |
| 421 |
|
end; |
| 422 |
|
//終端まで行っての終了かチェック |
| 423 |
|
if j <= Length(s) then begin |
| 424 |
|
if db then j := j - 2 |
| 425 |
|
else j := j - 1; |
| 426 |
|
end; |
| 427 |
|
//何も数字が見つからないとき |
| 428 |
|
if No = '' then begin |
| 429 |
|
Result := Result + Copy(s, 1, j - 1); |
| 430 |
|
end else begin |
| 431 |
|
separateNumber(st, et, No, '-'); |
| 432 |
|
|
| 433 |
|
if not DatToHTML then begin |
| 434 |
|
Result := Format(FORMAT_LINK, |
| 435 |
|
[ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) |
| 436 |
|
+ Copy(s, 1, j - 1) + '</a>'; |
| 437 |
|
end else begin |
| 438 |
|
Result := Format('<a href="#%s">', [st]) |
| 439 |
|
+ Copy(s, 1, j - 1) + '</a>'; |
| 440 |
|
end; |
| 441 |
|
end; |
| 442 |
|
Delete(s, 1, j - 1); |
| 443 |
|
end; |
| 444 |
|
end; |
| 445 |
|
end; |
| 446 |
|
{ |
| 447 |
|
function THTMLCreate.ConvRes(const Body, Bbs, Key, |
| 448 |
|
ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; |
| 449 |
|
DatToHTML: boolean = false): string; |
| 450 |
type |
type |
| 451 |
PIndex = ^TIndex; |
PIndex = ^TIndex; |
| 452 |
TIndex = record |
TIndex = record |
| 461 |
FORMAT_LINK = '<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">'; |
FORMAT_LINK = '<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">'; |
| 462 |
var |
var |
| 463 |
i : integer; |
i : integer; |
| 464 |
s{,r} : string; |
s : string; |
| 465 |
b : TMbcsByteType; |
b : TMbcsByteType; |
| 466 |
sw: boolean; |
sw: boolean; |
| 467 |
sp: integer; |
sp: integer; |
| 496 |
end; |
end; |
| 497 |
end; |
end; |
| 498 |
begin |
begin |
|
{ v1.0 b2 - 03 } |
|
| 499 |
s := Body; |
s := Body; |
| 500 |
Result := Body; |
Result := Body; |
| 501 |
i := 1; |
i := 1; |
| 543 |
begin |
begin |
| 544 |
sw := True; |
sw := True; |
| 545 |
sp := i; |
sp := i; |
|
//i := i + 1; |
|
| 546 |
oc:=''; |
oc:=''; |
| 547 |
end; |
end; |
| 548 |
end else |
end else |
| 557 |
end; |
end; |
| 558 |
sw := False; |
sw := False; |
| 559 |
Dec(i); |
Dec(i); |
|
i := i - 1; |
|
| 560 |
No := ''; |
No := ''; |
| 561 |
oc:=''; |
oc:=''; |
| 562 |
end; |
end; |
| 580 |
if (not sw) and (Copy(s,i,2) = '>') then begin |
if (not sw) and (Copy(s,i,2) = '>') then begin |
| 581 |
sw := True; |
sw := True; |
| 582 |
sp := i; |
sp := i; |
| 583 |
i := i + 1; |
Inc(i); |
| 584 |
chk := True; |
chk := True; |
| 585 |
end else |
end else |
| 586 |
if (sw) then begin |
if (sw) then begin |
| 592 |
Add(sp, i, No); |
Add(sp, i, No); |
| 593 |
end; |
end; |
| 594 |
sw := False; |
sw := False; |
| 595 |
i := i - 1; |
Dec(i); |
| 596 |
No := ''; |
No := ''; |
| 597 |
end; |
end; |
| 598 |
end else begin |
end else begin |
| 613 |
for i := List.Count - 1 downto 0 do begin |
for i := List.Count - 1 downto 0 do begin |
| 614 |
separateNumber(st, et, PIndex(List[i]).FNo, '-'); |
separateNumber(st, et, PIndex(List[i]).FNo, '-'); |
| 615 |
if not DatToHTML then |
if not DatToHTML then |
| 616 |
Result := Copy(Result,1, PIndex(List[i]).FIndexFrom - 1) + |
Result := Copy(Result,1, PIndex(List[i]).FIndexFrom - 1) + |
| 617 |
Format(FORMAT_LINK, [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) + |
Format(FORMAT_LINK, [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) + |
| 618 |
Copy(Result,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' + |
Copy(Result,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' + |
| 619 |
Copy(Result,PIndex(List[i]).FIndexTo,Length(Result)) |
Copy(Result,PIndex(List[i]).FIndexTo,Length(Result)) |
| 620 |
else |
else |
| 621 |
Result := Copy(Result,1, PIndex(List[i]).FIndexFrom - 1) + |
Result := Copy(Result,1, PIndex(List[i]).FIndexFrom - 1) + |
| 622 |
Format('<a href="#%s">', [st]) + |
Format('<a href="#%s">', [st]) + |
| 623 |
Copy(Result,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' + |
Copy(Result,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' + |
| 624 |
Copy(Result,PIndex(List[i]).FIndexTo,Length(Result)); |
Copy(Result,PIndex(List[i]).FIndexTo,Length(Result)); |
| 627 |
end; |
end; |
| 628 |
List.Free; |
List.Free; |
| 629 |
end; |
end; |
| 630 |
|
} |
| 631 |
function THTMLCreate.ConvRes( |
function THTMLCreate.ConvRes( |
| 632 |
const Body, Bbs, Key, ParamBBS, ParamKey, |
const Body, Bbs, Key, ParamBBS, ParamKey, |
| 633 |
ParamStart, ParamTo, ParamNoFirst, |
ParamStart, ParamTo, ParamNoFirst, |