-
Notifications
You must be signed in to change notification settings - Fork 16
/
php4DelphiReg.pas
194 lines (172 loc) · 5.05 KB
/
php4DelphiReg.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{*******************************************************}
{ PHP4Delphi }
{ PHP4Delphi components registration }
{ }
{ Author: }
{ Serhiy Perevoznyk }
{ serge_perevoznyk@hotmail.com }
{ http://users.chello.be/ws36637 }
{*******************************************************}
{$I PHP.INC}
{ $Id: php4DelphiReg.pas,v 6.2 02/2006 delphi32 Exp $ }
unit php4DelphiReg;
interface
uses
Windows, SysUtils, Classes, Dialogs, Forms,
PHPCommon,
{$IFDEF VERSION6}
DesignIntf,
DesignEditors,
{$ELSE}
dsgnintf,
{$ENDIF}
ShlObj,
ZendAPI, PHPAPI,
PHP4Delphi, phpAbout, phpModules, phpLibrary, ShellAPI,
phpClass,
phpCustomLibrary;
type
TScriptFileProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
TINIFolderProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
TpsvPHPEditor = class(TDefaultEditor)
public
{$IFDEF VERSION6}
procedure EditProperty(const Prop: IProperty; var Continue: Boolean); override;
{$ELSE}
procedure EditProperty(PropertyEditor: TPropertyEditor;
var Continue, FreeEditor: boolean); override;
{$ENDIF}
procedure ExecuteVerb(Index: integer); override;
function GetVerb(Index: integer): string; override;
function GetVerbCount: integer; override;
procedure Edit; override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('PHP', [TpsvPHP]);
RegisterComponents('PHP', [TPHPLibrary]);
RegisterComponents('PHP', [TPHPClass]);
RegisterComponents('PHP', [TPHPSystemLibrary]);
RegisterPropertyEditor(TypeInfo(String), TpsvPHP, 'FileName', TScriptFileProperty);
RegisterPropertyEditor(TypeInfo(TPHPAboutInfo), TPHPComponent, 'About', TPHPVersionEditor);
RegisterPropertyEditor(TypeInfo(TPHPAboutInfo), TCustomPHPExtension, 'About', TphpVersionEditor);
RegisterComponentEditor(TPHPExtension, TpsvPHPEditor);
RegisterComponentEditor(TPHPLibrary, TpsvPHPEditor);
end;
procedure TScriptFileProperty.Edit;
var
MPFileOpen: TOpenDialog;
begin
MPFileOpen := TOpenDialog.Create(Application);
MPFileOpen.Filename := GetValue;
MPFileOpen.Filter := 'PHP Script (*.php)|*.php';
MPFileOpen.Options := MPFileOpen.Options + [ofPathMustExist,
ofFileMustExist];
try
if MPFileOpen.Execute then SetValue(MPFileOpen.Filename);
finally
MPFileOpen.Free;
end;
end;
function TScriptFileProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
{$IFDEF VERSION6}
procedure TpsvPHPEditor.EditProperty(const Prop: IProperty; var Continue: Boolean);
var
PropName: string;
begin
PropName := Prop.GetName;
if (CompareText(PropName, 'FUNCTIONS') = 0) then
begin
Prop.Edit;
Continue := False;
end;
end;
{$ELSE}
procedure TpsvPHPEditor.EditProperty(PropertyEditor: TPropertyEditor;
var Continue,
FreeEditor: boolean);
var
PropName: string;
begin
PropName := PropertyEditor.GetName;
if (CompareText(PropName, 'FUNCTIONS') = 0) then
begin
PropertyEditor.Edit;
Continue := False;
end;
end;
{$ENDIF}
procedure TpsvPHPEditor.Edit;
begin
inherited;
end;
procedure TpsvPHPEditor.ExecuteVerb(Index: integer);
begin
case Index of
0:
begin
Edit;
Designer.Modified;
end;
1: ShellExecute(0, 'open', 'http://www.php.net', nil, nil, SW_SHOW);
2: ShellExecute(0, 'open', 'http://users.chello.be/ws36637', nil, nil, SW_SHOW);
end;
end;
function TpsvPHPEditor.GetVerb(Index: integer): string;
begin
case Index of
0: Result := 'Edit PHP Functions...';
1: Result := 'PHP Home Page';
2: Result := 'PHP4Delphi Home Page';
end;
end;
function TpsvPHPEditor.GetVerbCount: integer;
begin
Result := 3;
end;
{ TINIFolderProperty }
procedure TINIFolderProperty.Edit;
var
BrowseInfo: TBrowseInfo;
ItemIDList: PItemIDList;
ItemSelected : PItemIDList;
NameBuffer: array[0..MAX_PATH] of Char;
WindowList: Pointer;
begin
itemIDList := nil;
FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
BrowseInfo.hwndOwner := Forms.Application.Handle;
BrowseInfo.pidlRoot := ItemIDList;
BrowseInfo.pszDisplayName := NameBuffer;
BrowseInfo.lpszTitle := 'Select folder';
BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
WindowList := DisableTaskWindows(0);
try
ItemSelected := SHBrowseForFolder(BrowseInfo);
finally
EnableTaskWindows(WindowList);
end;
if (ItemSelected <> nil) then
begin
SHGetPathFromIDList(ItemSelected,NameBuffer);
SetValue(NameBuffer);
end;
end;
function TINIFolderProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
end.