Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
Mirror.php
Go to the documentation of this file.
1
<?php
15
19
require_once
'PEAR/Command/Common.php'
;
20
33
class
PEAR_Command_Mirror
extends
PEAR_Command_Common
34
{
35
var
$commands
= array(
36
'download-all'
=> array(
37
'summary'
=>
'Downloads each available package from the default channel'
,
38
'function'
=>
'doDownloadAll'
,
39
'shortcut'
=>
'da'
,
40
'options'
=> array(
41
'channel'
=>
42
array(
43
'shortopt'
=>
'c'
,
44
'doc'
=>
'specify a channel other than the default channel'
,
45
'arg'
=>
'CHAN'
,
46
),
47
),
48
'doc'
=>
'
49
Requests a list of available packages from the default channel ({config default_channel})
50
and downloads them to current working directory. Note: only
51
packages within preferred_state ({config preferred_state}) will be downloaded'
52
),
53
);
54
62
function
__construct
(&
$ui
, &
$config
)
63
{
64
parent::__construct(
$ui
,
$config
);
65
}
66
70
function
&
factory
($a)
71
{
72
$a = &
PEAR_Command::factory
($a, $this->config);
73
return
$a;
74
}
75
87
function
doDownloadAll
(
$command
,
$options
, $params)
88
{
89
$savechannel = $this->config->get(
'default_channel'
);
90
$reg = &$this->config->getRegistry();
91
$channel = isset(
$options
[
'channel'
]) ?
$options
[
'channel'
] :
92
$this->config->get(
'default_channel'
);
93
if
(!$reg->channelExists($channel)) {
94
$this->config->set(
'default_channel'
, $savechannel);
95
return
$this->raiseError(
'Channel "'
. $channel .
'" does not exist'
);
96
}
97
$this->config->set(
'default_channel'
, $channel);
98
99
$this->ui->outputData(
'Using Channel '
. $this->config->get(
'default_channel'
));
100
$chan = $reg->getChannel($channel);
101
if
(
PEAR::isError
($chan)) {
102
return
$this->raiseError($chan);
103
}
104
105
if
($chan->supportsREST($this->config->get(
'preferred_mirror'
)) &&
106
$base = $chan->getBaseURL(
'REST1.0'
, $this->config->get(
'preferred_mirror'
))) {
107
$rest = &$this->config->getREST(
'1.0'
, array());
108
$remoteInfo = array_flip($rest->listPackages($base, $channel));
109
}
110
111
if
(
PEAR::isError
($remoteInfo)) {
112
return
$remoteInfo;
113
}
114
115
$cmd = &$this->
factory
(
"download"
);
116
if
(
PEAR::isError
($cmd)) {
117
return
$cmd;
118
}
119
120
$this->ui->outputData(
'Using Preferred State of '
.
121
$this->config->get(
'preferred_state'
));
122
$this->ui->outputData(
'Gathering release information, please wait...'
);
123
128
PEAR::staticPushErrorHandling
(
PEAR_ERROR_RETURN
);
129
$err = $cmd->run(
'download'
, array(
'downloadonly'
=>
true
), array_keys($remoteInfo));
130
PEAR::staticPopErrorHandling
();
131
$this->config->set(
'default_channel'
, $savechannel);
132
if
(
PEAR::isError
($err)) {
133
$this->ui->outputData($err->getMessage());
134
}
135
136
return
true
;
137
}
138
}
PEAR_ERROR_RETURN
const PEAR_ERROR_RETURN
Definition
PEAR.php:24
PEAR_Command_Common
Definition
Common.php:36
PEAR_Command_Common\$config
$config
Definition
Common.php:43
PEAR_Command_Common\$ui
$ui
Definition
Common.php:54
PEAR_Command_Mirror
Definition
Mirror.php:34
PEAR_Command_Mirror\__construct
__construct(&$ui, &$config)
Definition
Mirror.php:62
PEAR_Command_Mirror\factory
& factory($a)
Definition
Mirror.php:70
PEAR_Command_Mirror\doDownloadAll
doDownloadAll($command, $options, $params)
Definition
Mirror.php:87
PEAR_Command_Mirror\$commands
$commands
Definition
Mirror.php:35
PEAR_Command\factory
static & factory($command, &$config)
Definition
Command.php:112
PEAR\staticPopErrorHandling
static staticPopErrorHandling()
Definition
PEAR.php:654
PEAR\staticPushErrorHandling
static staticPushErrorHandling($mode, $options=null)
Definition
PEAR.php:619
PEAR\isError
static isError($data, $code=null)
Definition
PEAR.php:306
$options
$options
Definition
pearcmd.php:145
$command
if( $raw) foreach($opts as $opt) if( $store_system_config) if($store_user_config) $command
Definition
pearcmd.php:322
sandbox
core
libs
php
pear
pear
PEAR
Command
Mirror.php
Generated by
1.17.0