Ignore:
Timestamp:
Dec 31, 2010, 9:59:19 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Třídy THtmlForm. THtmlInput a THtmlLineBreak.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Network/CoolWeb/Common/UHtmlClasses.pas

    r94 r104  
    66
    77uses
    8   UXmlClasses, Classes, SysUtils, SpecializedList, SpecializedObjectList;
     8  UXmlClasses, Classes, SysUtils, SpecializedList;
    99
    1010type
     
    9090  end;
    9191
     92  { THtmlLineBreak }
     93
     94  THtmlLineBreak = class(THtmlElement)
     95  private
     96    function GetAsXmlElement: TXmlElement; override;
     97  public
     98    constructor Create;
     99  end;
     100
    92101  THtmlBlock = class(THtmlElement)
    93102  private
     
    125134    Source: TURL;
    126135    AlternateText: string;
     136    constructor Create;
     137    destructor Destroy; override;
     138  end;
     139
     140  THtmlInputType = (itText, itComboBox, itRadioButton, itReset, itPassword,
     141    itSubmit, itHidden, itFileSelect, itButton, itCheckBox);
     142
     143  { THtmlInput }
     144
     145  THtmlInput = class(THtmlElement)
     146  private
     147    function GetAsXmlElement: TXmlElement; override;
     148  public
     149    InputType: THtmlInputType;
     150    Value: Variant;
     151    constructor Create;
     152    destructor Destroy; override;
     153  end;
     154
     155  { THtmlForm }
     156
     157  THtmlForm = class(THtmlBlock)
     158  private
     159  public
     160    Method: string;
     161    Action: TURL;
     162    function GetAsXmlElement: TXmlElement; override;
    127163    constructor Create;
    128164    destructor Destroy; override;
     
    211247    Result := False;
    212248  end;
     249end;
     250
     251{ THtmlLineBreak }
     252
     253function THtmlLineBreak.GetAsXmlElement: TXmlElement;
     254begin
     255  Result := inherited GetAsXmlElement;
     256  TXmlTag(Result).Name := 'br';
     257end;
     258
     259constructor THtmlLineBreak.Create;
     260begin
     261end;
     262
     263{ THtmlInput }
     264
     265function THtmlInput.GetAsXmlElement: TXmlElement;
     266var
     267  InputTypeString: string;
     268begin
     269  Result := TXmlTag.Create;
     270  with TXmlTag(Result) do begin
     271    Name := 'input';
     272    case InputType of
     273      itButton: InputTypeString := 'button';
     274      itRadioButton: InputTypeString := 'radio';
     275      itCheckBox: InputTypeString := 'checkbox';
     276      itText: InputTypeString := 'text';
     277      itFileSelect: InputTypeString := 'file';
     278      itSubmit: InputTypeString := 'submit';
     279      itHidden: InputTypeString := 'hidden';
     280      itPassword: InputTypeString := 'password';
     281    end;
     282    Attributes.Add('type', InputTypeString);
     283    Attributes.Add('value', Value);
     284    Attributes.Add('name', Name);
     285  end;
     286end;
     287
     288constructor THtmlInput.Create;
     289begin
     290
     291end;
     292
     293destructor THtmlInput.Destroy;
     294begin
     295  inherited Destroy;
     296end;
     297
     298{ THtmlForm }
     299
     300function THtmlForm.GetAsXmlElement: TXmlElement;
     301begin
     302  Result := TXmlTag.Create;
     303  with TXmlTag(Result) do begin
     304    Name := 'form';
     305    Attributes.Add('action', Action.AsString);
     306    Attributes.Add('method', Method);
     307  end;
     308end;
     309
     310constructor THtmlForm.Create;
     311begin
     312  inherited;
     313  Action := TURL.Create;
     314  BlockType := btBlockLevel;
     315  Method := 'get';
     316end;
     317
     318destructor THtmlForm.Destroy;
     319begin
     320  Action.Free;
     321  inherited Destroy;
    213322end;
    214323
     
    294403constructor THtmlBlock.Create;
    295404begin
     405  inherited;
    296406  SubItems := TListObject.Create;
    297407end;
     
    323433function THtmlElement.GetAsXmlElement: TXmlElement;
    324434begin
    325 
     435  Result := TXmlTag.Create;
     436  with TXmlTag(Result).Attributes do begin
     437    if Name <> '' then Add('name', Name);
     438    if Style <> '' then Add('style', Style);
     439    if ClassId <> '' then Add('class', ClassId);
     440    if Id <> '' then Add('id', Id);
     441  end;
    326442end;
    327443
     
    472588    StrArray.Explode(Value, '.', StrToStr);
    473589    SetLength(Levels, StrArray.Count);
    474     for I := 0 to StrArray.Count do
    475       Levels[StrArray.Count - I] := StrArray[I];
     590    for I := 0 to StrArray.Count - 1 do
     591      Levels[StrArray.Count - 1 - I] := StrArray[I];
    476592  finally
    477593    StrArray.Free;
Note: See TracChangeset for help on using the changeset viewer.