diff --git a/fcl/db/Makefile b/fcl/db/Makefile index 496e6d5c41..5bc608c7a1 100644 --- a/fcl/db/Makefile +++ b/fcl/db/Makefile @@ -1,8 +1,8 @@ # -# Don't edit, this file is generated by FPCMake Version 1.1 [2003/04/01] +# Don't edit, this file is generated by FPCMake Version 1.1 [2003/06/26] # default: all -MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx palmos macos macosx emx +MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx palmos macos darwin emx override PATH:=$(subst \,/,$(PATH)) ifeq ($(findstring ;,$(PATH)),) inUnix=1 @@ -32,7 +32,7 @@ inOS2=1 endif endif else -ifneq ($(findstring cygwin,$(MACHTYPE)),) +ifneq ($(findstring cygdrive,$(PATH)),) inCygWin=1 endif endif @@ -220,7 +220,7 @@ endif ifeq ($(OS_TARGET),openbsd) override TARGET_DIRS+=mysql interbase endif -override TARGET_UNITS+=db ddg_ds ddg_rec +override TARGET_UNITS+=db ddg_ds ddg_rec dbwhtml override TARGET_EXAMPLEDIRS+=tests override INSTALL_FPCPACKAGE=y override COMPILER_OPTIONS+=-S2 @@ -534,6 +534,12 @@ ifeq ($(OS_TARGET),macos) EXEEXT= FPCMADE=fpcmade.mcc endif +ifeq ($(OS_TARGET),darwin) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.darwin +ZIPSUFFIX=darwin +endif else ifeq ($(OS_TARGET),go32v1) PPUEXT=.pp1 @@ -892,69 +898,159 @@ TAREXT=.tar.gz endif override REQUIRE_PACKAGES=rtl ifeq ($(OS_TARGET),linux) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_MYSQL=1 REQUIRE_PACKAGES_IBASE=1 endif +endif +ifeq ($(OS_TARGET),linux) +ifeq ($(CPU_TARGET),m68k) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_MYSQL=1 +REQUIRE_PACKAGES_IBASE=1 +endif +endif +ifeq ($(OS_TARGET),linux) +ifeq ($(CPU_TARGET),powerpc) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_MYSQL=1 +REQUIRE_PACKAGES_IBASE=1 +endif +endif +ifeq ($(OS_TARGET),linux) +ifeq ($(CPU_TARGET),sparc) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_MYSQL=1 +REQUIRE_PACKAGES_IBASE=1 +endif +endif +ifeq ($(OS_TARGET),linux) +ifeq ($(CPU_TARGET),x86_64) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_MYSQL=1 +REQUIRE_PACKAGES_IBASE=1 +endif +endif ifeq ($(OS_TARGET),go32v2) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),win32) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_MYSQL=1 REQUIRE_PACKAGES_IBASE=1 endif +endif ifeq ($(OS_TARGET),os2) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),freebsd) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_MYSQL=1 REQUIRE_PACKAGES_IBASE=1 endif +endif +ifeq ($(OS_TARGET),freebsd) +ifeq ($(CPU_TARGET),m68k) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_MYSQL=1 +REQUIRE_PACKAGES_IBASE=1 +endif +endif ifeq ($(OS_TARGET),beos) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),netbsd) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_MYSQL=1 REQUIRE_PACKAGES_IBASE=1 endif +endif +ifeq ($(OS_TARGET),netbsd) +ifeq ($(CPU_TARGET),m68k) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_MYSQL=1 +REQUIRE_PACKAGES_IBASE=1 +endif +endif ifeq ($(OS_TARGET),amiga) +ifeq ($(CPU_TARGET),m68k) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),atari) +ifeq ($(CPU_TARGET),m68k) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),sunos) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 endif +endif +ifeq ($(OS_TARGET),sunos) +ifeq ($(CPU_TARGET),sparc) +REQUIRE_PACKAGES_RTL=1 +endif +endif ifeq ($(OS_TARGET),qnx) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),netware) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),openbsd) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_MYSQL=1 REQUIRE_PACKAGES_IBASE=1 endif -ifeq ($(OS_TARGET),wdosx) +endif +ifeq ($(OS_TARGET),openbsd) +ifeq ($(CPU_TARGET),m68k) REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_MYSQL=1 +REQUIRE_PACKAGES_IBASE=1 +endif +endif +ifeq ($(OS_TARGET),wdosx) +ifeq ($(CPU_TARGET),i386) +REQUIRE_PACKAGES_RTL=1 +endif endif ifeq ($(OS_TARGET),palmos) +ifeq ($(CPU_TARGET),m68k) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),macos) +ifeq ($(CPU_TARGET),powerpc) REQUIRE_PACKAGES_RTL=1 endif -ifeq ($(OS_TARGET),macosx) +endif +ifeq ($(OS_TARGET),darwin) +ifeq ($(CPU_TARGET),powerpc) REQUIRE_PACKAGES_RTL=1 endif +endif ifeq ($(OS_TARGET),emx) +ifeq ($(CPU_TARGET),i386) REQUIRE_PACKAGES_RTL=1 endif +endif ifdef REQUIRE_PACKAGES_RTL PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR)))))) ifneq ($(PACKAGEDIR_RTL),) @@ -1152,7 +1248,7 @@ override COMPILER:=$(FPC) $(FPCOPT) ifeq (,$(findstring -s ,$(COMPILER))) EXECPPAS= else -ifeq ($(OS_SOURCE),$(OS_TARGET)) +ifeq ($(FULL_SOURCE),$(FULL_TARGET)) EXECPPAS:=@$(PPAS) endif endif diff --git a/fcl/db/Makefile.fpc b/fcl/db/Makefile.fpc index c2dca72630..c9e1963330 100644 --- a/fcl/db/Makefile.fpc +++ b/fcl/db/Makefile.fpc @@ -12,7 +12,7 @@ dirs_freebsd=mysql interbase dirs_netbsd=mysql interbase dirs_openbsd=mysql interbase dirs_win32=mysql interbase -units=db ddg_ds ddg_rec +units=db ddg_ds ddg_rec dbwhtml exampledirs=tests [compiler] diff --git a/fcl/db/dbwhtml.pp b/fcl/db/dbwhtml.pp new file mode 100644 index 0000000000..9d0ee1eb77 --- /dev/null +++ b/fcl/db/dbwhtml.pp @@ -0,0 +1,483 @@ +{$mode objfpc} +{$H+} +unit dbwhtml; + +Interface + +uses sysutils,classes,db,whtml; + +Type + THTMLAlign = (haDefault,haLeft,haRight,haCenter); // Compatible with Delphi. + + TTableColumn = Class(TCollectionItem) + private + FActionUrl: String; + FAlign: THTMLAlign; + FBGColor: String; + FCaptionURL: String; + FFieldName : String; + FCaption : String; + FGetColumn: String; + FImgUrl: String; + Protected + FField : TField; // Filled. + Published + Property FieldName : String Read FFieldName Write FFieldName; + Property Caption : String Read FCaption Write FCaption; + Property ImgUrl : String Read FImgUrl Write FImgUrl; + Property ActionUrl : String Read FActionUrl Write FActionUrl; + Property CaptionURL : String Read FCaptionURL Write FCaptionURL; + Property BGColor : String Read FBGColor Write FBGColor; + Property Align : THTMLAlign read FAlign Write Falign; + end; + + TTableColumns = Class(TCollection) + Constructor Create; + end; + + THTMLProducer = Class(TComponent) + Private + FDataset : TDataset; + FContents: TMemorySTream; + Function GetContent : String; + Protected + Procedure CheckContents; + Procedure WriteString(S : TStream; Const Value : String); + Procedure WriteString(S : TStream; Const Fmt : String; Args : Array Of Const); + Public + Destructor Destroy; override; + Procedure ClearContent; + Procedure CreateContent; virtual; Abstract; + Property Content : String Read GetContent; + Published + Property Dataset : TDataset Read FDataset Write FDataset; + end; + + + TTableProducer = Class(THTMLProducer) + Private + FTableColumns : TTableColumns; + FBorder : Boolean; + Protected + Procedure BindColumns; + Procedure CreateTableColumns; Virtual; + Procedure CreateTableHeader(Stream : TStream); + Procedure CreateHeaderCell(C : TTableColumn; Stream : TStream); virtual; + Procedure CreateTableRow(Stream : TStream);virtual; + Procedure StartTable(Stream : TStream); virtual; + Procedure EndTable(Stream : TStream); virtual; + Procedure EmitFieldCell(C : TTableColumn; Stream : TStream); virtual; + Public + Constructor Create(AOwner : TComponent); override; + Destructor Destroy; virtual; + Procedure Clear; + Procedure CreateColumns(FieldList : TStrings); + Procedure CreateColumns(FieldList : String); + Procedure CreateTable(Stream : TStream); + Procedure CreateTable; + Procedure CreateContent; override; + Published + Property Border : Boolean Read FBorder Write FBorder; + end; + + TComboBoxProducer = Class(THTMLProducer) + private + FDatafield: String; + FInputName: String; + FValue: String; + FValueField: String; + function GetInputName: String; + protected + procedure CreateItem(Stream : TStream; VF,DF : TField; Selected : Boolean); virtual; + Public + Constructor Create(AOwner : TComponent); override; + Destructor Destroy; virtual; + Procedure CreateComboBox(Stream : TStream); + Procedure CreateComboBox; + Procedure CreateContent; override; + Published + Property ValueField : String Read FValueField Write FValueField; + Property DataField : String Read FDatafield Write FDataField; + Property Value : String Read FValue Write FValue; + Property InputName : String Read GetInputName Write FInputName; + end; + + TDBHtmlWriter = Class(THTMLWriter) + Protected + Function CreateTableProducer: TTableProducer; virtual; + Public + Procedure CreateTable(Dataset : TDataset); + Procedure CreateTable(Dataset : TDataset; Producer : TTableProducer); + end; + + +Implementation + +{ TTableColumns } + +constructor TTableColumns.Create; +begin + inherited Create(TTableColumn); +end; + +{ TTableProducer } + + +procedure TTableProducer.BindColumns; + +Var + I : Integer; + +begin + With FTableColumns do + For I:=0 to Count-1 do + With TTableColumn(Items[I]) do + FField:=FDataset.FieldByName(FieldName); +end; + +procedure TTableProducer.CreateTableColumns; +begin + FTableColumns:=TTableColumns.Create; +end; + +procedure TTableProducer.CreateTableHeader(Stream : TStream); + +Var + I : Integer; + +begin + WriteString(Stream,'