Joomla CMS
4.2.2
Documentation des API du CMS Joomla en version 4.2.2
|
Fonctions membres publiques | |
__construct ($writeprefix='', $readprefix='', $context=[]) | |
__destruct () | |
open ($filename, $mode='r', $useIncludePath=false, $context=null, $usePrefix=false, $relative=false, $detectprocessingmode=false) | |
close () | |
eof () | |
filesize () | |
gets ($length=0) | |
read ($length=0) | |
seek ($offset, $whence=\SEEK_SET) | |
tell () | |
write (&$string, $length=0, $chunk=0) | |
chmod ($filename='', $mode=0) | |
get_meta_data () | |
_buildContext () | |
setContextOptions ($context) | |
addContextEntry ($wrapper, $name, $value) | |
deleteContextEntry ($wrapper, $name) | |
applyContextToStream () | |
appendFilter ($filtername, $readWrite=\STREAM_FILTER_READ, $params=[]) | |
prependFilter ($filtername, $readWrite=\STREAM_FILTER_READ, $params=[]) | |
removeFilter (&$resource, $byindex=false) | |
copy ($src, $dest, $context=null, $usePrefix=true, $relative=false) | |
move ($src, $dest, $context=null, $usePrefix=true, $relative=false) | |
delete ($filename, $context=null, $usePrefix=true, $relative=false) | |
upload ($src, $dest, $context=null, $usePrefix=true, $relative=false) | |
writeFile ($filename, &$buffer, $appendToFile=false) | |
_getFilename ($filename, $mode, $usePrefix, $relative) | |
getFileHandle () | |
set ($property, $value=null) | |
get ($property, $default=null) | |
Fonctions membres publiques statiques | |
static | getStream ($usePrefix=true, $ua=null, $uamask=false) |
Attributs protégés | |
$filemode = 0644 | |
$dirmode = 0755 | |
$chunksize = 8192 | |
$filename | |
$writeprefix | |
$readprefix | |
$processingmethod = 'f' | |
$filters = [] | |
$fh | |
$filesize | |
$context | |
$contextOptions | |
$openmode | |
Joomla! Stream Interface
The Joomla! stream interface is designed to handle files as streams where as the legacy JFile static class treated files in a rather atomic manner.
This class adheres to the stream wrapper operations:
https://www.php.net/manual/en/intro.stream.php PHP Stream Manual https://www.php.net/manual/en/wrappers.php Stream Wrappers https://www.php.net/manual/en/filters.php Stream Filters https://www.php.net/manual/en/transports.php Socket Transports (used by some options, particularly HTTP proxy) 1.0
__construct | ( | $writeprefix = '' , |
|
$readprefix = '' , |
|||
$context = [] |
|||
) |
Constructor
string | $writeprefix | Prefix of the stream (optional). Unlike the JPATH_*, this has a final path separator! |
string | $readprefix | The read prefix (optional). |
array | $context | The context options (optional). |
Références Stream\$context, Stream\$readprefix, Stream\$writeprefix, et Stream\_buildContext().
__destruct | ( | ) |
_buildContext | ( | ) |
Stream contexts Builds the context from the array
Références null.
Référencé par Stream\__construct(), Stream\addContextEntry(), Stream\deleteContextEntry(), et Stream\setContextOptions().
_getFilename | ( | $filename, | |
$mode, | |||
$usePrefix, | |||
$relative | |||
) |
Determine the appropriate 'filename' of a file
string | $filename | Original filename of the file |
string | $mode | Mode string to retrieve the filename |
boolean | $usePrefix | Controls the use of a prefix |
boolean | $relative | Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped. |
Références Stream\$filename, $mode, Stream\$readprefix, Laminas\Diactoros\$stream, Stream\$writeprefix, Helper\getWriteModes(), et JPATH_ROOT.
Référencé par Stream\copy(), Stream\delete(), Stream\move(), et Stream\open().
addContextEntry | ( | $wrapper, | |
$name, | |||
$value | |||
) |
Adds a particular options to the context
string | $wrapper | The wrapper to use |
string | $name | The option to set |
string | $value | The value of the option |
Stream Context Creation https://www.php.net/manual/en/context.php Context Options for various streams 1.0
Références $name, $value, $wrapper, et Stream\_buildContext().
appendFilter | ( | $filtername, | |
$readWrite = \STREAM_FILTER_READ , |
|||
$params = [] |
|||
) |
Stream filters Append a filter to the chain
string | $filtername | The key name of the filter. |
integer | $readWrite | Optional. Defaults to STREAM_FILTER_READ. |
array | $params | An array of params for the stream_filter_append call. |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
applyContextToStream | ( | ) |
Applies the current context to the stream
Use this to change the values of the context after you've opened a stream
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références null.
chmod | ( | $filename = '' , |
|
$mode = 0 |
|||
) |
Chmod wrapper
string | $filename | File name. |
mixed | $mode | Mode to use. |
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\$filemode, Stream\$filename, $mode, Helper\ftpChmod(), et null.
Référencé par Stream\close(), Stream\copy(), Stream\move(), et Stream\writeFile().
close | ( | ) |
Attempt to close a file handle
Will return false if it failed and true on success If the file is not open the system will return true, this function destroys the file handle as well
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\chmod(), et null.
Référencé par Stream\__destruct(), et Stream\writeFile().
Copy a file from src to dest
string | $src | The file path to copy from. |
string | $dest | The file path to copy to. |
resource | $context | A valid context resource (optional) created with stream_context_create. |
boolean | $usePrefix | Controls the use of a prefix (optional). |
boolean | $relative | Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped. |
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\$context, Stream\_getFilename(), Stream\chmod(), elseif, et null.
Référencé par Stream\upload().
Delete a file
string | $filename | The file path to delete. |
resource | $context | A valid context resource (optional) created with stream_context_create. |
boolean | $usePrefix | Controls the use of a prefix (optional). |
boolean | $relative | Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped. |
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\$context, Stream\$filename, Stream\_getFilename(), elseif, et null.
deleteContextEntry | ( | $wrapper, | |
$name | |||
) |
Deletes a particular setting from a context
string | $wrapper | The wrapper to use |
string | $name | The option to unset |
Références $name, $wrapper, et Stream\_buildContext().
eof | ( | ) |
Work out if we're at the end of the file for a stream
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références null.
Référencé par Stream\read().
filesize | ( | ) |
Retrieve the file size of the path
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\$filesize, null, et Helper\remotefsize().
Référencé par Stream\read().
get | ( | $property, | |
$default = null |
|||
) |
Returns a property of the object or the default value if the property is not set.
string | $property | The name of the property. |
mixed | $default | The default value. |
Références $default.
get_meta_data | ( | ) |
getFileHandle | ( | ) |
gets | ( | $length = 0 | ) |
Get a line from the stream source.
integer | $length | The number of bytes (optional) to read. |
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références null.
Creates a new stream object with appropriate prefix
boolean | $usePrefix | Prefix the connections for writing |
string | $ua | UA User agent to use |
boolean | $uamask | User agent masking (prefix Mozilla) |
Références Stream\$context, et JPATH_ROOT.
Référencé par Folder\copy(), File\copy(), Bzip2\extract(), Gzip\extract(), File\move(), Folder\move(), File\upload(), et File\write().
Moves a file
string | $src | The file path to move from. |
string | $dest | The file path to move to. |
resource | $context | A valid context resource (optional) created with stream_context_create. |
boolean | $usePrefix | Controls the use of a prefix (optional). |
boolean | $relative | Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped. |
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\$context, Stream\_getFilename(), Stream\chmod(), elseif, et null.
open | ( | $filename, | |
$mode = 'r' , |
|||
$useIncludePath = false , |
|||
$context = null , |
|||
$usePrefix = false , |
|||
$relative = false , |
|||
$detectprocessingmode = false |
|||
) |
Generic File Operations
Open a stream with some lazy loading smarts
string | $filename | Filename |
string | $mode | Mode string to use |
boolean | $useIncludePath | Use the PHP include path |
resource | $context | Context to use when opening |
boolean | $usePrefix | Use a prefix to open the file |
boolean | $relative | Filename is a relative path (if false, strips JPATH_ROOT to make it relative) |
boolean | $detectprocessingmode | Detect the processing method for the file and use the appropriate function to handle output automatically |
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\$context, Stream\$filename, $mode, $url, __DIR__, Stream\_getFilename(), elseif, Helper\isJoomlaStream(), et null.
Référencé par Stream\writeFile().
prependFilter | ( | $filtername, | |
$readWrite = \STREAM_FILTER_READ , |
|||
$params = [] |
|||
) |
Prepend a filter to the chain
string | $filtername | The key name of the filter. |
integer | $readWrite | Optional. Defaults to STREAM_FILTER_READ. |
array | $params | An array of params for the stream_filter_prepend call. |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
read | ( | $length = 0 | ) |
Read a file
Handles user space streams appropriately otherwise any read will return 8192
integer | $length | Length of data to read |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\$filesize, Stream\eof(), Stream\filesize(), et null.
removeFilter | ( | & | $resource, |
$byindex = false |
|||
) |
Remove a filter, either by resource (handed out from the append or prepend function) or via getting the filter list)
resource | $resource | The resource. |
boolean | $byindex | The index of the filter. |
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références null.
seek | ( | $offset, | |
$whence = \SEEK_SET |
|||
) |
Seek the file
Note: the return value is different to that of fseek
integer | $offset | Offset to use when seeking. |
integer | $whence | Seek mode to use. |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Joomla\Database\Query\$offset, et null.
set | ( | $property, | |
$value = null |
|||
) |
setContextOptions | ( | $context | ) |
Updates the context to the array
Format is the same as the options for stream_context_create
array | $context | Options to create the context with |
Références Stream\$context, et Stream\_buildContext().
tell | ( | ) |
Returns the current position of the file read/write pointer.
FilesystemException |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références null.
Upload a file
string | $src | The file path to copy from (usually a temp folder). |
string | $dest | The file path to copy to. |
resource | $context | A valid context resource (optional) created with stream_context_create. |
boolean | $usePrefix | Controls the use of a prefix (optional). |
boolean | $relative | Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped. |
FilesystemException |
Références Stream\$context, et Stream\copy().
write | ( | & | $string, |
$length = 0 , |
|||
$chunk = 0 |
|||
) |
File write
Whilst this function accepts a reference, the underlying fwrite will do a copy! This will roughly double the memory allocation for any write you do. Specifying chunked will get around this by only writing in specific chunk sizes. This defaults to 8192 which is a sane number to use most of the time (change the default with Stream::set('chunksize', newsize);) Note: This doesn't support gzip/bzip2 writing like reading does
string | $string | Reference to the string to write. |
integer | $length | Length of the string to write. |
integer | $chunk | Size of chunks to write in. |
PhpElementIsNotAvailableInCurrentPhpVersionInspection
Références Stream\$chunksize, $start, et null.
Référencé par Stream\writeFile().
writeFile | ( | $filename, | |
& | $buffer, | ||
$appendToFile = false |
|||
) |
Writes a chunk of data to a file.
string | $filename | The file name. |
string | $buffer | The data to write to the file. |
boolean | $appendToFile | Append to the file and not overwrite it. |
Références $buffer, Stream\$filename, $result, Stream\chmod(), Stream\close(), Stream\open(), et Stream\write().
|
protected |
Référencé par Stream\write().
|
protected |
|
protected |
|
protected |
|
protected |
Référencé par Stream\getFileHandle().
|
protected |
Référencé par Stream\chmod().
|
protected |
Référencé par Stream\_getFilename(), Stream\chmod(), Stream\delete(), Stream\open(), et Stream\writeFile().
|
protected |
Référencé par Stream\filesize(), et Stream\read().
|
protected |
|
protected |
|
protected |
|
protected |
Référencé par Stream\__construct(), et Stream\_getFilename().
|
protected |
Référencé par Stream\__construct(), et Stream\_getFilename().