Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
Role.php
Go to the documentation of this file.
1
<?php
15
19
require_once
'PEAR/Installer/Role/Common.php'
;
20
require_once
'PEAR/XMLParser.php'
;
31
class
PEAR_Installer_Role
32
{
39
public
static
function
initializeConfig
(&
$config
)
40
{
41
if
(!isset(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
])) {
42
PEAR_Installer_Role::registerRoles
();
43
}
44
45
foreach
(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
] as $class => $info) {
46
if
(!$info[
'config_vars'
]) {
47
continue
;
48
}
49
50
$config
->_addConfigVars($class, $info[
'config_vars'
]);
51
}
52
}
53
60
public
static
function
&
factory
($pkg, $role, &
$config
)
61
{
62
if
(!isset(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
])) {
63
PEAR_Installer_Role::registerRoles
();
64
}
65
66
if
(!in_array($role,
PEAR_Installer_Role::getValidRoles
($pkg->getPackageType()))) {
67
$a =
false
;
68
return
$a;
69
}
70
71
$a =
'PEAR_Installer_Role_'
. ucfirst($role);
72
if
(!class_exists($a)) {
73
require_once str_replace(
'_'
,
'/'
, $a) .
'.php'
;
74
}
75
76
$b =
new
$a(
$config
);
77
return
$b;
78
}
79
88
public
static
function
getValidRoles
($release, $clear =
false
)
89
{
90
if
(!isset(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
])) {
91
PEAR_Installer_Role::registerRoles
();
92
}
93
94
static
$ret = array();
95
if
($clear) {
96
$ret = array();
97
}
98
99
if
(isset($ret[$release])) {
100
return
$ret[$release];
101
}
102
103
$ret[$release] = array();
104
foreach
(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
] as $role => $okreleases) {
105
if
(in_array($release, $okreleases[
'releasetypes'
])) {
106
$ret[$release][] = strtolower(str_replace(
'PEAR_Installer_Role_'
,
''
, $role));
107
}
108
}
109
110
return
$ret[$release];
111
}
112
122
public
static
function
getInstallableRoles
($clear =
false
)
123
{
124
if
(!isset(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
])) {
125
PEAR_Installer_Role::registerRoles
();
126
}
127
128
static
$ret;
129
if
($clear) {
130
unset($ret);
131
}
132
133
if
(isset($ret)) {
134
return
$ret;
135
}
136
137
$ret = array();
138
foreach
(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
] as $role => $okreleases) {
139
if
($okreleases[
'installable'
]) {
140
$ret[] = strtolower(str_replace(
'PEAR_Installer_Role_'
,
''
, $role));
141
}
142
}
143
144
return
$ret;
145
}
146
156
public
static
function
getBaseinstallRoles
($clear =
false
)
157
{
158
if
(!isset(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
])) {
159
PEAR_Installer_Role::registerRoles
();
160
}
161
162
static
$ret;
163
if
($clear) {
164
unset($ret);
165
}
166
167
if
(isset($ret)) {
168
return
$ret;
169
}
170
171
$ret = array();
172
foreach
(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
] as $role => $okreleases) {
173
if
($okreleases[
'honorsbaseinstall'
]) {
174
$ret[] = strtolower(str_replace(
'PEAR_Installer_Role_'
,
''
, $role));
175
}
176
}
177
178
return
$ret;
179
}
180
187
public
static
function
getPhpRoles
($clear =
false
)
188
{
189
if
(!isset(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
])) {
190
PEAR_Installer_Role::registerRoles
();
191
}
192
193
static
$ret;
194
if
($clear) {
195
unset($ret);
196
}
197
198
if
(isset($ret)) {
199
return
$ret;
200
}
201
202
$ret = array();
203
foreach
(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
] as $role => $okreleases) {
204
if
($okreleases[
'phpfile'
]) {
205
$ret[] = strtolower(str_replace(
'PEAR_Installer_Role_'
,
''
, $role));
206
}
207
}
208
209
return
$ret;
210
}
211
222
public
static
function
registerRoles
($dir =
null
)
223
{
224
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
] = array();
225
$parser =
new
PEAR_XMLParser
;
226
if
($dir ===
null
) {
227
$dir = dirname(__FILE__) .
'/Role'
;
228
}
229
230
if
(!file_exists($dir) || !is_dir($dir)) {
231
return
PEAR::raiseError(
"registerRoles: opendir($dir) failed: does not exist/is not directory"
);
232
}
233
234
$dp = @opendir($dir);
235
if
(empty($dp)) {
236
return
PEAR::raiseError(
"registerRoles: opendir($dir) failed: $php_errmsg"
);
237
}
238
239
while
($entry = readdir($dp)) {
240
if
($entry[0] ==
'.'
|| substr($entry, -4) !=
'.xml'
) {
241
continue
;
242
}
243
244
$class =
"PEAR_Installer_Role_"
.substr($entry, 0, -4);
245
// List of roles
246
if
(!isset(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
][$class])) {
247
$file =
"$dir/$entry"
;
248
$parser->parse(file_get_contents($file));
249
$data = $parser->getData();
250
if
(!is_array($data[
'releasetypes'
])) {
251
$data[
'releasetypes'
] = array($data[
'releasetypes'
]);
252
}
253
254
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
][$class] = $data;
255
}
256
}
257
258
closedir($dp);
259
ksort(
$GLOBALS
[
'_PEAR_INSTALLER_ROLES'
]);
260
PEAR_Installer_Role::getBaseinstallRoles
(
true
);
261
PEAR_Installer_Role::getInstallableRoles
(
true
);
262
PEAR_Installer_Role::getPhpRoles
(
true
);
263
PEAR_Installer_Role::getValidRoles
(
'****'
,
true
);
264
return
true
;
265
}
266
}
$GLOBALS
$GLOBALS['_PEAR_default_error_mode']
Definition
PEAR.php:46
PEAR_Installer_Role
Definition
Role.php:32
PEAR_Installer_Role\getBaseinstallRoles
static getBaseinstallRoles($clear=false)
Definition
Role.php:156
PEAR_Installer_Role\registerRoles
static registerRoles($dir=null)
Definition
Role.php:222
PEAR_Installer_Role\factory
static & factory($pkg, $role, &$config)
Definition
Role.php:60
PEAR_Installer_Role\getValidRoles
static getValidRoles($release, $clear=false)
Definition
Role.php:88
PEAR_Installer_Role\initializeConfig
static initializeConfig(&$config)
Definition
Role.php:39
PEAR_Installer_Role\getPhpRoles
static getPhpRoles($clear=false)
Definition
Role.php:187
PEAR_Installer_Role\getInstallableRoles
static getInstallableRoles($clear=false)
Definition
Role.php:122
PEAR_XMLParser
Definition
XMLParser.php:30
$config
$config
Definition
pearcmd.php:182
sandbox
core
libs
php
pear
pear
PEAR
Installer
Role.php
Generated by
1.17.0