Changeset 104


Ignore:
Timestamp:
Dec 31, 2010, 9:59:19 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Třídy THtmlForm. THtmlInput a THtmlLineBreak.
Location:
Network/CoolWeb
Files:
7 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;
  • Network/CoolWeb/Common/UPool.pas

    r94 r104  
    66
    77uses
    8   Classes, SysUtils, syncobjs, SpecializedObjectList;
     8  Classes, SysUtils, syncobjs, SpecializedList;
    99
    1010type
  • Network/CoolWeb/Common/UXmlClasses.pas

    r94 r104  
    55interface
    66
    7 uses Classes, SysUtils, StrUtils, SpecializedList, SpecializedObjectList,
     7uses Classes, SysUtils, StrUtils, SpecializedList,
    88  SpecializedDictionary;
    99
  • Network/CoolWeb/CoolWeb.lpk

    r94 r104  
    88      <SearchPaths>
    99        <OtherUnitFiles Value="WebServer;Persistence;Network;Modules;Common"/>
    10         <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)/"/>
     10        <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
    1111      </SearchPaths>
    1212      <Other>
     
    8787      <Item1>
    8888        <PackageName Value="TemplateGenerics"/>
     89        <MaxVersion Minor="3" Valid="True"/>
     90        <MinVersion Minor="3" Valid="True"/>
    8991      </Item1>
    9092      <Item2>
  • Network/CoolWeb/Persistence/USqlDatabase.pas

    r94 r104  
    33{$mode Delphi}{$H+}
    44
    5 // Upraveno: 28.10.2010
     5// Modified: 2010-12-24
    66
    77interface
    88
    99uses
    10   SysUtils, Classes, Dialogs, mysql50, TypInfo, SpecializedObjectList,
     10  SysUtils, Classes, Dialogs, mysql50, TypInfo,
    1111  SpecializedDictionary, SpecializedList;
    1212
  • Network/CoolWeb/WebServer/UHTTPServer.pas

    r94 r104  
    77uses
    88  Classes, SysUtils, UTCPServer, UCommon, UMemoryStreamEx, UMIMEType,
    9   Synautil, SpecializedObjectList, SpecializedList;
     9  Synautil, SpecializedList;
    1010
    1111type
     
    113113  SEmptyHTTPHandler = 'No handler defined for HTTP server.';
    114114  SFileNotFound = 'File %s not found.';
     115  SPageNotFound = 'Page %s not found.';
    115116
    116117implementation
     
    163164begin
    164165  with HandlerData, Response.Stream do begin
    165     WriteString('<html><body>Page ' + Request.Path + ' not found.</body></html>');
     166    WriteString('<html><body>' + Format(SPageNotFound, [Request.Path]) + '</body></html>');
    166167  end;
    167168end;
     
    194195    with Response.Stream do begin
    195196      WriteLn(Format(SFileNotFound, [Request.Path]));
    196       WriteString('<html><body>File ' + Request.Path + ' not found.</body></html>');
     197      WriteString('<html><body>' + Format(SFileNotFound, [Request.Path]) + '</body></html>');
    197198    end;
    198199  end;
     
    386387  WriteLn(hstdout^, 'Content-type: text/html');
    387388  WriteLn(hstdout^);
    388   Writeln(hstdout^, 'An unhandled exception occurred at $', HexStr(PtrUInt(Addr), SizeOf(PtrUInt) * 2), ' :');
     389  Writeln(hstdout^, 'An unhandled exception occurred at $', HexStr(PtrUInt(Addr), SizeOf(PtrUInt) * 2), ' :<br/>');
    389390  if Obj is exception then
    390391   begin
    391392     Message := Exception(Obj).ClassName + ' : ' + Exception(Obj).Message;
    392      Writeln(hstdout^, Message);
     393     Writeln(hstdout^, Message + '<br/>');
    393394   end
    394395  else
    395     Writeln(hstdout^, 'Exception object ', Obj.ClassName, ' is not of class Exception.');
    396   Writeln(hstdout^, BackTraceStrFunc(Addr));
     396    Writeln(hstdout^, 'Exception object ', Obj.ClassName, ' is not of class Exception.<br/>');
     397  Writeln(hstdout^, BackTraceStrFunc(Addr) + '<br/>');
    397398  if (FrameCount > 0) then
    398399    begin
    399400      for i := 0 to FrameCount - 1 do
    400401        if I < Length(TArrayOfPointer(Frames)) then
    401           Writeln(hstdout^, BackTraceStrFunc(TArrayOfPointer(Frames)[i]));
    402     end;
    403   Writeln(hstdout^,'');
     402          Writeln(hstdout^, BackTraceStrFunc(TArrayOfPointer(Frames)[i]) + '<br/>');
     403    end;
     404  Writeln(hstdout^, '');
    404405end;
    405406
     
    433434          Writeln(hstderr^, BackTraceStrFunc(TArrayOfPointer(Frames)[i]));
    434435    end;
    435   Writeln(hstderr^,'');
     436  Writeln(hstderr^, '');
    436437end;
    437438
  • Network/CoolWeb/WebServer/UHTTPServerCGI.pas

    r94 r104  
    2222
    2323implementation
     24
     25resourcestring
     26  SEnvironmentVariables = 'Environment variables:';
    2427
    2528{ THTTPServerCGI }
     
    107110  inherited;
    108111  with HandlerData, Response.Stream do begin
    109     WriteString('<h5>Environment variables:</h5>');
     112    WriteString('<h5>' + SEnvironmentVariables + '</h5>');
    110113    WriteString('<table border="1">');
    111114    for I := 0 to EnvVars.Count - 1 do begin
Note: See TracChangeset for help on using the changeset viewer.