Changeset 132


Ignore:
Timestamp:
Mar 18, 2022, 3:47:27 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UWebObjects.pas

    r130 r132  
    66
    77uses
    8   Classes, SysUtils, UHtmlClasses, UXmlClasses, SpecializedList, SpecializedDictionary;
     8  Classes, SysUtils, UHtmlClasses, UXmlClasses, SpecializedDictionary, fgl;
    99
    1010type
    11   TListView = class
    12 
    13   end;
    14 
    1511  TQueryFormItemType = (fitText, fitComboBox, fitRadioButton, fitSelect, fitPassword,
    1612    fitSubmit, fitReset, fitHidden, fitFileSelect, fitButton, fitCheckBox, fitTextArea);
     
    3834  { TQueryFormItemList }
    3935
    40   TQueryFormItemList = class(TListObject)
     36  TQueryFormItemList = class(TFPGObjectList<TQueryFormItem>)
    4137    function FindByName(AValue: string): TQueryFormItem;
    4238  end;
     
    5349  end;
    5450
     51  TQueryFormGroups = class(TFPGObjectList<TQueryFormGroup>)
     52  end;
     53
    5554  TQueryAction = class
    5655    Caption: string;
    5756    Action: string;
     57  end;
     58
     59  TQueryActions = class(TFPGObjectList<TQueryAction>)
    5860  end;
    5961
     
    6365  public
    6466    Title: string;
    65     Groups: TListObject; // TListObject<TQueryFormGroup>
    66     Actions: TListObject; // TListObject<TQueryAction>
     67    Groups: TQueryFormGroups;
     68    Actions: TQueryActions;
    6769    ClassId: string;
    6870    function AddNewGroup: TQueryFormGroup;
     
    7274    destructor Destroy; override;
    7375  end;
     76
    7477
    7578implementation
     
    122125destructor TQueryFormItem.Destroy;
    123126begin
    124   Value.Free;
    125   inherited Destroy;
     127  FreeAndNil(Value);
     128  inherited;
    126129end;
    127130
     
    189192function TQueryForm.AddNewGroup: TQueryFormGroup;
    190193begin
    191   Result := TQueryFormGroup(Groups.AddNew(TQueryFormGroup.Create));
     194  Result := TQueryFormGroup.Create;
     195  Groups.Add(Result);
    192196end;
    193197
    194198function TQueryForm.AddNewAction(Caption, Action: string): TQueryAction;
    195199begin
    196   Result := TQueryAction(Actions.AddNew(TQueryAction.Create));
     200  Result := TQueryAction.Create;
    197201  Result.Caption := Caption;
    198202  Result.Action := Action;
     203  Actions.Add(Result);
    199204end;
    200205
     
    210215begin
    211216  inherited;
    212   Actions := TListObject.Create;
    213   Groups := TListObject.Create;
     217  Actions := TQueryActions.Create;
     218  Groups := TQueryFormGroups.Create;
    214219  Method := 'post';
    215220  Action.AsString := '';
     
    218223destructor TQueryForm.Destroy;
    219224begin
    220   Actions.Free;
    221   Groups.Free;
    222   inherited Destroy;
     225  FreeAndNil(Actions);
     226  FreeAndNil(Groups);
     227  inherited;
    223228end;
    224229
     
    238243function TQueryFormGroup.AddNewItem: TQueryFormItem;
    239244begin
    240   Result := TQueryFormItem(Rows.AddNew(TQueryFormItem.Create));
     245  Result := TQueryFormItem.Create;
     246  Rows.Add(Result);
    241247end;
    242248
     
    248254destructor TQueryFormGroup.Destroy;
    249255begin
    250   Rows.Free;
    251   inherited Destroy;
     256  FreeAndNil(Rows);
     257  inherited;
    252258end;
    253259
  • trunk/Modules/Finance/UModuleFinance.pas

    r105 r132  
    66
    77uses
    8   Classes, SysUtils, UModularSystem, SpecializedDictionary, UModuleBase,
     8  Classes, SysUtils, UModularSystem, UModuleBase,
    99  UWebPage;
    1010
     
    7373var
    7474  DbRows: TDbRows;
    75   Data: TDictionaryStringString;
    7675begin
    7776  try
    7877    DbRows := TDbRows.Create;
    79     Data := TDictionaryStringString.Create;
    8078
    8179    Core.CommonDatabase.Query(DbRows,
     
    144142
    145143  finally
    146     Data.Free;
    147144    DbRows.Free;
    148145  end;
  • trunk/Modules/Network/UModuleNetwork.pas

    r105 r132  
    66
    77uses
    8   Classes, SysUtils, UModularSystem, SpecializedDictionary, UModuleBase,
     8  Classes, SysUtils, UModularSystem, UModuleBase,
    99  UWebPage;
    1010
     
    7373var
    7474  DbRows: TDbRows;
    75   Data: TDictionaryStringString;
    7675begin
    7776  try
    7877    DbRows := TDbRows.Create;
    79     Data := TDictionaryStringString.Create;
    8078
    8179    Core.CommonDatabase.Query(DbRows,
     
    151149
    152150  finally
    153     Data.Free;
    154151    DbRows.Free;
    155152  end;
    156   inherited Install;
     153  inherited;
    157154end;
    158155
  • trunk/Modules/News/UNews.pas

    r107 r132  
    66
    77uses
    8   Classes, SysUtils, SpecializedList, USqlDatabase, UModuleUser, UUtils,
    9   UWebSession, UHTTPServer, UModuleBase;
     8  Classes, SysUtils, USqlDatabase, UModuleUser, UUtils, fgl, UWebSession,
     9  UHTTPServer, UModuleBase, SpecializedList;
    1010
    1111type
     
    1919  end;
    2020
     21  TNewsSettingItems = class(TFPGObjectList<TNewsSettingItem>)
     22  end;
     23
    2124  { TNews }
    2225
     
    2629    UploadedFilesFolder: string; // = 'aktuality/uploads/';
    2730  public
    28     Settings: TListObject; // TListObject<TNewsSettingItem>
     31    Settings: TNewsSettingItems;
    2932    Database: TSqlDatabase;
    3033    ModuleUser: TModuleUser;
     
    152155constructor TNews.Create;
    153156begin
    154   inherited Create;
    155   Settings := TListObject.Create;
     157  inherited;
     158  Settings := TNewsSettingItems.Create;
    156159end;
    157160
     
    159162begin
    160163  FreeAndNil(Settings);
    161   inherited Destroy;
     164  inherited;
    162165end;
    163166
  • trunk/Modules/Portal/UModulePortal.pas

    r130 r132  
    66
    77uses
    8   Classes, SysUtils, UModularSystem, SpecializedDictionary, USqlDatabase,
     8  Classes, SysUtils, UModularSystem, USqlDatabase,
    99  UUtils, UWebSession, SpecializedList, UUser, UWebPage, UHtmlClasses,
    1010  UModuleBase, UModuleUser, UModuleNews;
     
    8585var
    8686  DbRows: TDbRows;
    87   Data: TDictionaryStringString;
    8887begin
    8988  try
    9089    DbRows := TDbRows.Create;
    91     Data := TDictionaryStringString.Create;
    9290
    9391    Core.CommonDatabase.Query(DbRows,
     
    140138
    141139  finally
    142     Data.Free;
    143140    DbRows.Free;
    144141  end;
    145   inherited Install;
     142  inherited;
    146143end;
    147144
  • trunk/Modules/Portal/UPagePortal.pas

    r114 r132  
    77uses
    88  Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, USqlDatabase, UUtils,
    9   SpecializedDictionary, UWebSession, SpecializedList, UHtmlClasses,
    10   UModularSystem, UModuleUser, UModuleNews;
     9  SpecializedDictionary, UWebSession, UHtmlClasses, UModularSystem, UModuleUser,
     10  UModuleNews;
    1111
    1212type
     
    1818  private
    1919    Session: TWebSession;
    20     function ShowPanel(Title, Content: string; Menu: TListString = nil): string;
     20    function ShowPanel(Title, Content: string; Menu: TStrings = nil): string;
    2121    function SystemMessage(Title, Text: string): string;
    2222    function ShowLinks(GroupId: Integer): string;
     
    283283end;
    284284
    285 function TWebPagePortal.ShowPanel(Title, Content: string; Menu: TListString): string;
     285function TWebPagePortal.ShowPanel(Title, Content: string; Menu: TStrings): string;
    286286var
    287287  I: Integer;
  • trunk/Modules/TV/UModuleTV.pas

    r105 r132  
    66
    77uses
    8   Classes, SysUtils, UModularSystem, SpecializedDictionary, UModuleBase,
    9   UWebPage;
     8  Classes, SysUtils, UModularSystem, UModuleBase, UWebPage;
    109
    1110type
     
    7271var
    7372  DbRows: TDbRows;
    74   Data: TDictionaryStringString;
    7573begin
    7674  try
    7775    DbRows := TDbRows.Create;
    78     Data := TDictionaryStringString.Create;
    7976
    8077    Core.CommonDatabase.Query(DbRows,
     
    9592
    9693  finally
    97     Data.Free;
    9894    DbRows.Free;
    9995  end;
  • trunk/Modules/User/UModuleUser.pas

    r108 r132  
    66
    77uses
    8   Classes, SysUtils, UModularSystem, SpecializedDictionary, UUser,
    9   UModuleBase, UWebPage;
     8  Classes, SysUtils, UModularSystem, UUser, UModuleBase, UWebPage;
    109
    1110type
     
    8382var
    8483  DbRows: TDbRows;
    85   Data: TDictionaryStringString;
    8684begin
    8785  try
    8886    DbRows := TDbRows.Create;
    89     Data := TDictionaryStringString.Create;
    9087
    9188    Core.CommonDatabase.Query(DbRows,
     
    171168    '  ADD CONSTRAINT `PermissionUserAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `permissiongroup` (`Id`),' +
    172169    '  ADD CONSTRAINT `PermissionUserAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `permissionoperation` (`Id`);');
    173 
    174 
    175170  finally
    176     Data.Free;
    177171    DbRows.Free;
    178172  end;
    179   inherited Install;
     173  inherited;
    180174end;
    181175
     
    184178  DbRows: TDbRows;
    185179begin
    186   inherited Uninstall;
     180  inherited;
    187181  try
    188182    DbRows := TDbRows.Create;
  • trunk/Modules/ZdechovNET/UModuleZdechovNET.pas

    r119 r132  
    66
    77uses
    8   Classes, SysUtils, UModularSystem, SpecializedDictionary, UWebPage,
     8  Classes, SysUtils, UModularSystem, UWebPage,
    99  UWebSession, DateUtils, UModuleBase, UModuleUser, UIPTVPage,
    1010  UInternetPage, UHostingPage, UHistoryPage, UDocumentsPage, UVoIPPage,
     
    6969destructor TModuleZdechovNET.Destroy;
    7070begin
    71   inherited Destroy;
     71  inherited;
    7272end;
    7373
     
    167167var
    168168  DbRows: TDbRows;
    169   Data: TDictionaryStringString;
    170169begin
    171170  try
    172171    DbRows := TDbRows.Create;
    173     Data := TDictionaryStringString.Create;
    174172
    175173    Core.CommonDatabase.Query(DbRows,
     
    235233
    236234  finally
    237     Data.Free;
    238235    DbRows.Free;
    239236  end;
    240237
    241   inherited Install;
     238  inherited;
    242239end;
    243240
     
    246243  DbRows: TDbRows;
    247244begin
    248   inherited Uninstall;
     245  inherited;
    249246  ModuleBase.GeneratePage := nil;
    250247  try
     
    377374end;
    378375
    379 
    380376end.
    381377
  • trunk/Packages/CoolWeb/CoolWeb.lpk

    r114 r132  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<CONFIG>
    3   <Package Version="4">
     3  <Package Version="5">
    44    <Name Value="CoolWeb"/>
    55    <Type Value="RunAndDesignTime"/>
     
    1111        <IncludeFiles Value="WebServer"/>
    1212        <OtherUnitFiles Value="WebServer;Persistence;Network;Modules;Common;/usr/lib/mysql/;/usr/lib64/mysql/"/>
    13         <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
     13        <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    1414      </SearchPaths>
    1515      <Parsing>
    1616        <SyntaxOptions>
    1717          <SyntaxMode Value="Delphi"/>
     18          <CStyleOperator Value="False"/>
     19          <AllowLabel Value="False"/>
     20          <CPPInline Value="False"/>
    1821        </SyntaxOptions>
    1922      </Parsing>
     23      <CodeGeneration>
     24        <Optimizations>
     25          <OptimizationLevel Value="0"/>
     26        </Optimizations>
     27      </CodeGeneration>
     28      <Linking>
     29        <Debugging>
     30          <GenerateDebugInfo Value="False"/>
     31        </Debugging>
     32      </Linking>
     33      <Other>
     34        <CompilerMessages>
     35          <IgnoredMessages idx6058="True" idx3124="True" idx3123="True"/>
     36        </CompilerMessages>
     37      </Other>
    2038    </CompilerOptions>
    2139    <Description Value="Unit set for generating CGI or server web application."/>
     
    104122      </Item18>
    105123    </Files>
     124    <CompatibilityMode Value="True"/>
    106125    <RequiredPkgs Count="8">
    107126      <Item1>
  • trunk/Packages/CoolWeb/LazIDEReg.pas

    r84 r132  
    3939  CGIAppDescriptor: TCGIApplicationDescriptor;
    4040
     41procedure Register;
    4142
    42 procedure Register;
    4343
    4444implementation
     
    100100function TCGIApplicationDescriptor.InitProject(AProject: TLazProject): TModalResult;
    101101var
    102   le: string;
    103102  NewSource: TStringList;
    104103  MainFile: TLazProjectFile;
  • trunk/Packages/CoolWeb/Modules/UWebUser.pas

    r114 r132  
    267267  Result := False;
    268268  try
    269       DbRows2 := TDbRows.Create;
    270 
    271       // Check group-operation relation
    272       Database.Select(DbRows2, 'PermissionGroupAssignment', 'Id',
    273         '`User` = ' + IntToStr(Id) + ' AND `AssignedOperation` = ' + IntToStr(Operation));
    274       if DbRows2.Count > 0 then begin
     269    DbRows2 := TDbRows.Create;
     270
     271    // Check group-operation relation
     272    Database.Select(DbRows2, 'PermissionGroupAssignment', 'Id',
     273      '`User` = ' + IntToStr(Id) + ' AND `AssignedOperation` = ' + IntToStr(Operation));
     274    if DbRows2.Count > 0 then begin
     275      Result := True;
     276      Exit;
     277    end;
     278
     279    // Check group-group relation
     280    Database.Select(DbRows2, 'PermissionGroupAssignment', 'AssignedGroup',
     281      '`User` = ' + IntToStr(Id) + ' AND `AssignedGroup` IS NOT NULL');
     282    if DbRows2.Count > 0 then begin
     283      if CheckGroupPermission(StrToInt(DbRows2[0].Values['AssignedGroup']), Operation) then begin
    275284        Result := True;
    276285        Exit;
    277286      end;
    278 
    279       // Check group-group relation
    280       Database.Select(DbRows2, 'PermissionGroupAssignment', 'AssignedGroup',
    281         '`User` = ' + IntToStr(Id) + ' AND `AssignedGroup` IS NOT NULL');
    282       if DbRows2.Count > 0 then begin
    283         if CheckGroupPermission(StrToInt(DbRows2[0].Values['AssignedGroup']), Operation) then begin
    284           Result := True;
    285           Exit;
    286         end;
    287       end;
    288     finally
    289       DbRows2.Free;
    290     end;
     287    end;
     288  finally
     289    DbRows2.Free;
     290  end;
    291291end;
    292292
  • trunk/Packages/CoolWeb/WebServer/UWebApp.pas

    r108 r132  
    66
    77uses
    8   Classes, SysUtils, CustApp, SpecializedList, UWebPage, UHTTPSessionFile,
    9   UHTTPServer, Forms, FileUtil;
     8  Classes, SysUtils, UWebPage, UHTTPSessionFile,
     9  UHTTPServer, Forms, FileUtil, fgl;
    1010
    1111type
     
    2222  { TPageList }
    2323
    24   TPageList = class(TListObject)
     24  TPageList = class(TFPGObjectList<TRegistredPage>)
    2525    RootDir: string;
    2626    function FindByPage(Page: TWebPage): TRegistredPage;
     
    2929    procedure UnregisterPage(Page: TWebPage);
    3030    function ProducePage(HandlerData: THTTPHandlerData): Boolean;
    31     constructor Create; override;
     31    constructor Create(FreeObjects: Boolean = True);
    3232  end;
    3333
     
    6464  UHTTPServerCGI, UHTTPServerTCP, UHTTPServerTurboPower;
    6565
    66 
    6766procedure Register;
    6867begin
     
    7776end;
    7877
    79 
    8078{ TPageList }
    8179
     
    8583begin
    8684  I := 0;
    87   while (I < Count) and (TRegistredPage(Items[I]).Page <> Page) do Inc(I);
    88   if I < Count then Result := TRegistredPage(Items[I])
     85  while (I < Count) and (Items[I].Page <> Page) do Inc(I);
     86  if I < Count then Result := Items[I]
    8987    else Result := nil;
    9088end;
     
    9593begin
    9694  I := 0;
    97   while (I < Count) and (TRegistredPage(Items[I]).Name <> Name) do Inc(I);
    98   if I < Count then Result := TRegistredPage(Items[I])
     95  while (I < Count) and (Items[I].Name <> Name) do Inc(I);
     96  if I < Count then Result := Items[I]
    9997    else Result := nil;
    10098end;
     
    132130var
    133131  NewPage: TRegistredPage;
    134   Instance: TWebPage;
    135 begin
    136   NewPage := TRegistredPage(AddNew(TRegistredPage.Create));
     132begin
     133  NewPage := TRegistredPage.Create;
    137134//  NewPage.Page := PageClass.Create(Self);
    138135  NewPage.Page := Page;
    139136  NewPage.Name := Path;
     137  Add(NewPage);
    140138end;
    141139
     
    166164constructor TPageList.Create;
    167165begin
    168   inherited Create;
    169   OwnsObjects := False;
     166  inherited;
     167  FreeObjects := False;
    170168end;
    171169
     
    212210constructor TWebApp.Create(AOwner: TComponent);
    213211begin
    214   inherited Create(AOwner);
     212  inherited;
    215213  HTTPServer := THTTPServerCGI.Create(nil);
    216214  HTTPServer.OnRequest := HTTPServerRequest;
     
    219217destructor TWebApp.Destroy;
    220218begin
    221   HTTPServer.Free;
    222   inherited Destroy;
     219  FreeAndNil(HTTPServer);
     220  inherited;
    223221end;
    224222
  • trunk/Packages/ModularSystem/ModularSystem.lpk

    r105 r132  
    1 <?xml version="1.0"?>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<CONFIG>
    3   <Package Version="4">
     3  <Package Version="5">
    44    <PathDelim Value="\"/>
    55    <Name Value="ModularSystem"/>
     6    <Type Value="RunAndDesignTime"/>
    67    <Author Value="Chronos (robie@centrum.cz)"/>
    78    <CompilerOptions>
     
    910      <PathDelim Value="\"/>
    1011      <SearchPaths>
    11         <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
     12        <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    1213      </SearchPaths>
     14      <Parsing>
     15        <SyntaxOptions>
     16          <CStyleOperator Value="False"/>
     17          <AllowLabel Value="False"/>
     18          <CPPInline Value="False"/>
     19        </SyntaxOptions>
     20      </Parsing>
     21      <CodeGeneration>
     22        <Optimizations>
     23          <OptimizationLevel Value="0"/>
     24        </Optimizations>
     25      </CodeGeneration>
     26      <Linking>
     27        <Debugging>
     28          <GenerateDebugInfo Value="False"/>
     29        </Debugging>
     30      </Linking>
    1331      <Other>
    1432        <CompilerMessages>
    15           <MsgFileName Value=""/>
     33          <IgnoredMessages idx6058="True" idx3124="True" idx3123="True"/>
    1634        </CompilerMessages>
    17         <CompilerPath Value="$(CompPath)"/>
    1835      </Other>
    1936    </CompilerOptions>
     
    2845      </Item1>
    2946    </Files>
     47    <CompatibilityMode Value="True"/>
    3048    <i18n>
    3149      <EnableI18N Value="True"/>
     
    3351      <EnableI18NForLFM Value="True"/>
    3452    </i18n>
    35     <Type Value="RunAndDesignTime"/>
    3653    <RequiredPkgs Count="2">
    3754      <Item1>
  • trunk/Packages/ModularSystem/UModularSystem.pas

    r105 r132  
    66
    77uses
    8   Classes, SysUtils, Contnrs, URegistry;
     8  Classes, SysUtils, fgl, URegistry;
    99
    1010type
     
    1212
    1313  TAPI = class(TComponent)
    14 
    1514  end;
    1615
     
    6665  end;
    6766
     67  TModules = class(TFPGObjectList<TModule>)
     68  end;
     69
    6870  TModuleEvent = procedure (Sender: TObject; Module: TModule) of object;
    6971
     
    7678    procedure SetAPI(AValue: TAPI);
    7779  public
    78     Modules: TObjectList; // TObjectList<TModule>
     80    Modules: TModules;
    7981    function FindModuleByName(Name: string): TModule;
    8082    function ModuleRunning(Name: string): Boolean;
     
    310312begin
    311313  inherited;
    312   Modules := TObjectList.Create;
     314  Modules := TModules.Create;
    313315  //Modules.OwnsObjects := False;
    314316end;
  • trunk/UCore.pas

    r123 r132  
    99  UHTTPServer, USqlDatabase, INIFiles, DateUtils, UWebPage, UWebApp,
    1010  UXmlClasses, UHtmlClasses, UUtils, UApplicationInfo, UHTTPServerTCP,
    11   UHTTPSessionFile, UUser, SpecializedList, Registry,
    12   UModularSystem, UWebSession, LazUTF8;
     11  UHTTPSessionFile, UUser, Registry, UModularSystem, UWebSession, LazUTF8;
    1312
    1413const
  • trunk/ZdechovNET.lpi

    r130 r132  
    7373      <SharedMatrixOptions Count="3">
    7474        <Item1 ID="999041476570" Modes="Release,Debug" Type="IDEMacro" MacroName="LCLWidgetType" Value="nogui"/>
    75         <Item2 ID="896442313085" Targets="Common" Modes="Debug" Value="-g -gl -gh -CirotR -O1"/>
    76         <Item3 ID="926538202016" Targets="Common" Modes="Release" Value="-CX -XX -O3"/>
     75        <Item2 ID="896442313085" Targets="Common,CoolWeb,ModularSystem" Modes="Debug" Value="-g -gl -gh -CirotR -O1"/>
     76        <Item3 ID="926538202016" Targets="Common,CoolWeb,ModularSystem" Modes="Release" Value="-CX -XX -O3"/>
    7777      </SharedMatrixOptions>
    7878    </BuildModes>
  • trunk/ZdechovNET.lpr

    r123 r132  
    77  cthreads, clocale,
    88  {$ENDIF}
    9   UUtils, USqlDatabase, SysUtils, Contnrs, Forms,
     9  UUtils, USqlDatabase, SysUtils, Forms,
    1010  UUser, UHTTPSessionMySQL, UHTTPSessionFile, Printers,
    1111  UCommon, UHTTPServer, UHTTPServerTCP, UHTTPServerCGI, UTCPServer, UPool,
Note: See TracChangeset for help on using the changeset viewer.