require_once "PEAR/Command/Common.php";
require_once "PEAR/Installer.php";
-require_once "Console/Getopt.php";
/**
* PEAR commands for installation or deinstallation/upgrading of
*
* @access public
*/
- function log($level, $msg)
+ function log($level, $msg, $append_crlf = true)
{
if ($this->debug >= $level) {
if (is_object($this->ui)) {
- $this->ui->log($msg);
+ $this->ui->log($msg, $append_crlf);
} else {
print "$msg\n";
}
}
$bytes = 0;
if ($callback) {
- call_user_func($callback, 'start', $length);
+ call_user_func($callback, 'start', array(basename($dest_file), $length));
}
while ($data = @fread($fp, 1024)) {
$bytes += strlen($data);
// {{{ log(text)
- function log($text)
+ function log($text, $append_crlf = true)
{
- return $this->_displayLine($text);
+ if ($append_crlf) {
+ return $this->_displayLine($text);
+ }
+ return $this->_display($text);
}
case 'done':
$this->log(1, '...done: ' . number_format($params, 0, '', ',') . ' bytes');
break;
+ case 'bytesread':
+ static $bytes;
+ if (empty($bytes)) {
+ $bytes = 0;
+ }
+ if (!($bytes % 10240)) {
+ $this->log(1, '.', false);
+ }
+ $bytes += $params;
+ break;
+ case 'start':
+ $this->log(1, "Starting to download {$params[0]} (".number_format($params[1], 0, '', ',')." bytes)");
+ break;
}
if (method_exists($this->ui, '_downloadCallback'))
$this->ui->_downloadCallback($msg, $params);