Actions

API16

Difference between revisions of "JFactory/getStream"

From Joomla! Documentation

< API16:JFactory
(New page: ===Description=== Creates a new stream object with appropriate prefix <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JFactory/getStream|Edit Descri...)
 
m (removing red link to edit, no existant pages)
 
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JFactory/getStream|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JFactory/getStream}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 73: Line 73:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JFactory/getStream|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JFactory/getStream}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 88: Line 88:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 00:06, 13 May 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Creates a new stream object with appropriate prefix

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

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

libraries/joomla/factory.php

Importing

jimport( 'joomla.factory' );

Source Body

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 edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />