JFactory/getStream
From Joomla! Documentation
< API16:JFactory
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Creates a new stream object with appropriate prefix
<! removed transcluded page call, red link never existed >
Syntax[edit]
getStream($use_prefix=true, $use_network=true, $ua=null, $uamask=false)
Parameter Name | Default Value | Description |
---|---|---|
$use_prefix | true | Prefix the connections for writing |
$use_network | true | Use network if available for writing; use false to disable (e.g. FTP, SCP) |
$ua | null | UA User agent to use |
$uamask | false | User agent masking (prefix Mozilla) |
Defined in[edit]
libraries/joomla/factory.php
Importing[edit]
jimport( 'joomla.factory' );
Source Body[edit]
function getStream($use_prefix=true, $use_network=true,$ua=null, $uamask=false) {
jimport('joomla.filesystem.stream');
// Setup the context; Joomla! UA and overwrite
$context = Array();
$version = new JVersion();
// set the UA for HTTP and overwrite for FTP
$context['http']['user_agent'] = $version->getUserAgent($ua, $uamask);
$context['ftp']['overwrite'] = true;
if($use_prefix) {
jimport('joomla.client.helper');
$FTPOptions = JClientHelper::getCredentials('ftp');
$SCPOptions = JClientHelper::getCredentials('scp');
if ($FTPOptions['enabled'] == 1 && $use_network) {
$prefix = 'ftp://'. $FTPOptions['user'] .':'. $FTPOptions['pass'] .'@'. $FTPOptions['host'];
$prefix .= $FTPOptions['port'] ? ':'. $FTPOptions['port'] : '';
$prefix .= $FTPOptions['root'];
} else if($SCPOptions['enabled'] == 1 && $use_network) {
$prefix = 'ssh2.sftp://'. $SCPOptions['user'] .':'. $SCPOptions['pass'] .'@'. $SCPOptions['host'];
$prefix .= $SCPOptions['port'] ? ':'. $SCPOptions['port'] : '';
$prefix .= $SCPOptions['root'];
} else {
$prefix = JPATH_ROOT.DS;
}
$retval = new JStream($prefix, JPATH_ROOT, $context);
} else {
$retval = new JStream('','',$context);
}
return $retval;
}
<! removed transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]