4,18 → 4,11 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Alexander Merz <alexmerz@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Mirror.php,v 1.18 2006/03/02 18:14:13 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.2.0 |
*/ |
31,16 → 24,14 |
* @category pear |
* @package PEAR |
* @author Alexander Merz <alexmerz@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.2.0 |
*/ |
class PEAR_Command_Mirror extends PEAR_Command_Common |
{ |
// {{{ properties |
|
var $commands = array( |
'download-all' => array( |
'summary' => 'Downloads each available package from the default channel', |
61,10 → 52,6 |
), |
); |
|
// }}} |
|
// {{{ constructor |
|
/** |
* PEAR_Command_Mirror constructor. |
* |
72,13 → 59,11 |
* @param object PEAR_Frontend a reference to an frontend |
* @param object PEAR_Config a reference to the configuration data |
*/ |
function PEAR_Command_Mirror(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
|
// }}} |
|
/** |
* For unit-testing |
*/ |
88,7 → 73,6 |
return $a; |
} |
|
// {{{ doDownloadAll() |
/** |
* retrieves a list of avaible Packages from master server |
* and downloads them |
97,8 → 81,8 |
* @param string $command the command |
* @param array $options the command options before the command |
* @param array $params the stuff after the command name |
* @return bool true if succesful |
* @throw PEAR_Error |
* @return bool true if successful |
* @throw PEAR_Error |
*/ |
function doDownloadAll($command, $options, $params) |
{ |
111,32 → 95,34 |
return $this->raiseError('Channel "' . $channel . '" does not exist'); |
} |
$this->config->set('default_channel', $channel); |
|
$this->ui->outputData('Using Channel ' . $this->config->get('default_channel')); |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $this->raiseError($chan); |
} |
|
if ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { |
$rest = &$this->config->getREST('1.0', array()); |
$remoteInfo = array_flip($rest->listPackages($base)); |
} else { |
$remote = &$this->config->getRemote(); |
$stable = ($this->config->get('preferred_state') == 'stable'); |
$remoteInfo = $remote->call("package.listAll", true, $stable, false); |
$remoteInfo = array_flip($rest->listPackages($base, $channel)); |
} |
|
if (PEAR::isError($remoteInfo)) { |
return $remoteInfo; |
} |
|
$cmd = &$this->factory("download"); |
if (PEAR::isError($cmd)) { |
return $cmd; |
} |
|
$this->ui->outputData('Using Preferred State of ' . |
$this->config->get('preferred_state')); |
$this->ui->outputData('Gathering release information, please wait...'); |
|
/** |
* Error handling not necessary, because already done by |
* Error handling not necessary, because already done by |
* the download command |
*/ |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
146,8 → 132,7 |
if (PEAR::isError($err)) { |
$this->ui->outputData($err->getMessage()); |
} |
|
return true; |
} |
|
// }}} |
} |