PHP Class PEAR_Downloader

Author: Greg Beaver ([email protected])
Author: Stig Bakken ([email protected])
Author: Tomas V. V. Cox ([email protected])
Author: Martin Jansen ([email protected])
Inheritance: extends PEAR_Common
Datei anzeigen Open project: sourcefabric/newscoop Class Usage Examples

Public Properties

Property Type Description
$_downloadDir string Temporary directory, or configuration value where downloads will occur
$_downloadedPackages array Format of each entry: array('pkg' => 'package_name', 'file' => '/path/to/local/file', 'info' => array() // parsed package.xml );
$_errorStack array
$_installed array Format: array('package1' => 0, 'package2' => 1, );
$_internalDownload boolean
$_options array Recognized options:
- onlyreqdeps : install all required dependencies as well - alldeps : install all dependencies, including optional - installroot : base relative path to install files in - force : force a download even if warnings would prevent it - nocompress : download uncompressed tarballs
$_packageSortTree array Temporary variable used in sorting packages by dependency in {@link sortPkgDeps()}
$_preferredState string | null Preferred Installation State (snapshot, devel, alpha, beta, stable)
$_registry PEAR_Registry
$_toDownload array This is used to prevent downloading a package more than once should it be a dependency for two packages to be installed. Format of each entry:
array('package_name1' => parsed package.xml, 'package_name2' => parsed package.xml,
);

Public Methods

Method Description
PEAR_Downloader ( &$ui, $options, &$config )
_checkDepTree ( $channel, $package, $b, $checked = [] )
_dependsOn ( $a, $b )
_detectDepCycle ( &$deplinks ) Detect recursive links between dependencies and break the cycles
_downloadCallback ( $msg, $params = null )
_getDepPackageDownloadUrl ( $dep, $parr )
_getPackageDownloadUrl ( $parr )
_prependPath ( $path, $prepend )
_setupGraph ( array $t, PEAR_Registry $reg, array &$deplinks, array &$nodes, string $package ) Set up the dependency for installation parsing
_sortInstall ( $a, $b )
_testCycle ( $test, $deplinks, $dep )
analyzeDependencies ( &$params, $force = false )
configSet ( $key, $value, $layer = 'user', $channel = false )
discover ( $channel ) : boolean Attempt to discover a channel's remote capabilities from its server name
download ( $params )
downloadHttp ( string $url, object &$ui, string $save_dir = '.', mixed $callback = null, false | string | array $lastmodified = null, false | array $accept = false, false | string $channel = false ) : string | array Download a file through HTTP. Considers suggested file name in Content-disposition: header and can run a callback function for different events. The callback will be called with two parameters: the callback type, and parameters. The implemented callback types are:
getDependency2Object ( &$c, $i, $p, $s ) For simpler unit-testing
getDownloadDir ( ) : string Retrieve the directory that downloads will happen in
getDownloadedPackages ( ) : array Retrieve a list of downloaded packages after a call to {@link download()}.
getErrorMsgs ( )
getOptions ( )
getPackageDownloadUrl ( $package, $version = null, $channel = false )
newDownloaderPackage ( &$t ) : PEAR_Downloader_Package For simpler unit-testing
pushError ( $errmsg, $code )
setDownloadDir ( $dir )
setOptions ( $options )
sortPackagesForInstall ( &$packages ) : array Sort a list of arrays of array(downloaded packagefilename) by dependency.
sortPkgDeps ( &$packages, $uninstall = false ) for BC

Method Details

PEAR_Downloader() public method

public PEAR_Downloader ( &$ui, $options, &$config )

_checkDepTree() public method

public _checkDepTree ( $channel, $package, $b, $checked = [] )

_dependsOn() public method

public _dependsOn ( $a, $b )

_detectDepCycle() public method

Detect recursive links between dependencies and break the cycles
public _detectDepCycle ( &$deplinks )

_downloadCallback() public method

public _downloadCallback ( $msg, $params = null )

_getDepPackageDownloadUrl() public method

public _getDepPackageDownloadUrl ( $dep, $parr )

_getPackageDownloadUrl() public method

public _getPackageDownloadUrl ( $parr )

_prependPath() public method

public _prependPath ( $path, $prepend )

_setupGraph() public method

Set up the dependency for installation parsing
public _setupGraph ( array $t, PEAR_Registry $reg, array &$deplinks, array &$nodes, string $package )
$t array dependency information
$reg PEAR_Registry
$deplinks array list of dependency links already established
$nodes array all existing package nodes
$package string parent package name

_sortInstall() public method

public _sortInstall ( $a, $b )

_testCycle() public method

public _testCycle ( $test, $deplinks, $dep )

analyzeDependencies() public method

public analyzeDependencies ( &$params, $force = false )

configSet() public method

public configSet ( $key, $value, $layer = 'user', $channel = false )

discover() public method

Attempt to discover a channel's remote capabilities from its server name
public discover ( $channel ) : boolean
return boolean

download() public method

public download ( $params )

downloadHttp() public method

'setup' called at the very beginning, parameter is a UI object that should be used for all output 'message' the parameter is a string with an informational message 'saveas' may be used to save with a different file name, the parameter is the filename that is about to be used. If a 'saveas' callback returns a non-empty string, that file name will be used as the filename instead. Note that $save_dir will not be affected by this, only the basename of the file. 'start' download is starting, parameter is number of bytes that are expected, or -1 if unknown 'bytesread' parameter is the number of bytes read so far 'done' download is complete, parameter is the total number of bytes read 'connfailed' if the TCP/SSL connection fails, this callback is called with array(host,port,errno,errmsg) 'writefailed' if writing to disk fails, this callback is called with array(destfile,errmsg) If an HTTP proxy has been configured (http_proxy PEAR_Config setting), the proxy will be used.
public downloadHttp ( string $url, object &$ui, string $save_dir = '.', mixed $callback = null, false | string | array $lastmodified = null, false | array $accept = false, false | string $channel = false ) : string | array
$url string the URL to download
$ui object PEAR_Frontend_* instance
$save_dir string directory to save file in
$callback mixed function/method to call for status updates
$lastmodified false | string | array header values to check against for caching use false to return the header values from this download
$accept false | array Accept headers to send
$channel false | string Channel to use for retrieving authentication
return string | array Returns the full path of the downloaded file or a PEAR error on failure. If the error is caused by socket-related errors, the error object will have the fsockopen error code available through getCode(). If caching is requested, then return the header values.

getDependency2Object() public method

For simpler unit-testing
public getDependency2Object ( &$c, $i, $p, $s )

getDownloadDir() public method

Retrieve the directory that downloads will happen in
public getDownloadDir ( ) : string
return string

getDownloadedPackages() public method

Also resets the list of downloaded packages.
public getDownloadedPackages ( ) : array
return array

getErrorMsgs() public method

public getErrorMsgs ( )

getOptions() public method

public getOptions ( )

getPackageDownloadUrl() public method

Deprecation: in favor of _getPackageDownloadUrl
public getPackageDownloadUrl ( $package, $version = null, $channel = false )

newDownloaderPackage() public method

For simpler unit-testing
public newDownloaderPackage ( &$t ) : PEAR_Downloader_Package
return PEAR_Downloader_Package

pushError() public method

public pushError ( $errmsg, $code )

setDownloadDir() public method

public setDownloadDir ( $dir )

setOptions() public method

public setOptions ( $options )

sortPackagesForInstall() public method

This uses the topological sort method from graph theory, and the Structures_Graph package to properly sort dependencies for installation.
public sortPackagesForInstall ( &$packages ) : array
return array array of array(packagefilename, package.xml contents)

sortPkgDeps() public method

for BC
Deprecation:
public sortPkgDeps ( &$packages, $uninstall = false )

Property Details

$_downloadDir public_oe property

Temporary directory, or configuration value where downloads will occur
public string $_downloadDir
return string

$_downloadedPackages public_oe property

Format of each entry: array('pkg' => 'package_name', 'file' => '/path/to/local/file', 'info' => array() // parsed package.xml );
public array $_downloadedPackages
return array

$_errorStack public_oe property

public array $_errorStack
return array

$_installed public_oe property

Format: array('package1' => 0, 'package2' => 1, );
public array $_installed
return array

$_internalDownload public_oe property

public bool $_internalDownload
return boolean

$_options public_oe property

Recognized options:
- onlyreqdeps : install all required dependencies as well - alldeps : install all dependencies, including optional - installroot : base relative path to install files in - force : force a download even if warnings would prevent it - nocompress : download uncompressed tarballs
See also: PEAR_Command_Install
public array $_options
return array

$_packageSortTree public_oe property

Temporary variable used in sorting packages by dependency in {@link sortPkgDeps()}
public array $_packageSortTree
return array

$_preferredState public_oe property

Preferred Installation State (snapshot, devel, alpha, beta, stable)
public string|null $_preferredState
return string | null

$_registry public_oe property

public PEAR_Registry $_registry
return PEAR_Registry

$_toDownload public_oe property

This is used to prevent downloading a package more than once should it be a dependency for two packages to be installed. Format of each entry:
array('package_name1' => parsed package.xml, 'package_name2' => parsed package.xml,
);
public array $_toDownload
return array